Hi, i currently have a page that performs functions determined by other parameters set on the site. The page runs an API script for de-captcher.com that submits & retrieves completed captchas. So if i have 5 accounts on the site set to submit & retrieve captchers it submits 1 at a time.

Now my problem is, it at random times just stops working which forces me to page refresh or click the link that activates the function again. It logs into the site perfectly fine & sends & retrieves completed captcha's fine, it just at random points stops. I thought it was a time-out problem & i put in anti time-out code but that didnt work. I contacted my host to ask if they limit the script run times & they said no my scripts can run as long as desired. I contacted de-captcher.com support & they looked on my account & no time-outs was recorded so it must be a script problem.

When the script is running, the page in status bar continue's to say waiting for mydomain.com & as long as i see that, i know its working, however it stops working when it changes to Done & its not completed its task.

Some times it almost complete's its task, sometimes it fails to even complete the first task.

Here is the page that does the job, i hope someone can help because im an amature coder & i had help with this & i've always had great help from this forum in the past so here i am.

Thanks

PHP Code:
<?php
require ("./includes/header.php");
require (
"./api/ccproto_client.php");
//*PageProtect(1);*//
//*set_time_limit(440);*//
$raidbarId = isset($_GET['sctRaidbar']) ? $_GET['sctRaidbar'] : 0;

if (
$siteConfig['site_msg'] != '0')
{
    
header('Location: ./index.php');
    exit();
}

$server = array(=> "sigil"=> "torax"=> "fabar"=> "zimbob"=> "rancid"=> "quiver");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $siteConfig['title']; ?> : Capcha Viewer</title>
<meta name="keywords" content="" />
<link href="./template/default.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body style="padding-left: 5px; padding-right:5px;">
<script>
//*window.onload= function() { window.location = window.location; };*//
</script>
<h3>Raiding System</h3>
<pre>
<?php    
    $raidid 
mysql_query("SELECT * FROM `raidbar_raidid` WHERE `rdId` = '".$raidbarId."'");
    
$raidid mysql_fetch_array($raidid);
    
    if (
$raidid['raidid'] != 0)
    {        
        
$result mysql_query("SELECT * FROM `raidbar_users` WHERE `groupid` = '" . (int)$_REQUEST['group'] ."' AND `rdId` = '".$raidbarId."'") or die(mysql_error());
        
$accts false;
        
$i 0;
        
        
$ccp = new ccproto();
        
$ccp->init();

        print( 
"Logging in..." );

        if( 
$ccp->login("api.decaptcher-reloaded.com"$siteConfig['DeCaptcherPort'], $siteConfig['DeCaptcherUserName'], $siteConfig['DeCaptcherUserPass']) < ) {
            print( 
" FAILED\n" );
            return;
        } else {
            print( 
" OK\n" );
        }

        while(
$row mysql_fetch_array($result))
        {
            
$page curl("http://" $server[$siteConfig['userServer']] . ".outwar.com/joinraid.php?raidid=".$raidid['raidid']."&suid=" $row['owid'] . "&serverid=" $siteConfig['userServer']);
            
preg_match('/It will take <b>([\d|,]+)<\/b> of your <b>([\d|,]+)<\/b> rage/'$page$rage);
            
            if (
preg_match('/Recaptcha\.create\("(.+?)".+_params: "(.+?)"/'$page$matches) && preg_match('/codeid" value="(.+?)"/'$page$codeid) && str_replace(',','',$rage[2]) > str_replace(',','',$rage[1]))
            {
                
$page curl("http://api.recaptcha.net/challenge?k=" $matches[1]. "&" $matches[2]);
                
                if (
preg_match("/challenge\s?:\s?'(.+?)'/",$page,$matches))
                {
                    
$image curl("http://www.google.com/recaptcha/api/image?c=$matches[1]");
                    
                    
$major_id    0;
                    
$minor_id    0;
                    
$max_trys   3;
                    for( 
$i 0$i $max_trys$i++ ) {
                        
$pict $image;
                        
$text '';
                        print( 
"sending a picture for ".$row['owid']."...\n" );

                        
$pict_to    ptoDEFAULT;
                        
$pict_type    ptUNSPECIFIED;
        
                        
$res $ccp->picture2$pict$pict_to$pict_type$text$major_id$minor_id );
                        switch( 
$res )
                        {
                            case 
ccERR_OK:
                                
$page curl("http://" $server[$siteConfig['userServer']] . ".outwar.com/joinraid.php?raidid=".$raidid['raidid']."&suid=" $row['owid'] . "&serverid=" $siteConfig['userServer'], "recaptcha_challenge_field=" $matches[1] . "&recaptcha_response_field=" $text "&codeid=" .$codeid[1] . "&submit=Launch!");
                                
                                if (
preg_match('/It will take <b>([\d|,]+)<\/b> of your <b>([\d|,]+)<\/b> rage/'$page$rage))
                                {
                                    print( 
"Incorrect return - Naming picture ".$major_id."/".$minor_id." as bad\n" );
                                    
$ccp->picture_bad2$major_id$minor_id );
                                } 
                                else
                                {
                                    
$page curl("http://" .  $server[$siteConfig['userServer']] . ".outwar.com/raidmembers.php?raidid=".$raidid['raidid']);
                                    
preg_match("/(\d*) people have joined this raid/"$page$matches);
                                    
mysql_query("UPDATE `raidbar_raidid` SET `JOINED` = '" $matches[1] . "' WHERE `rdId` = '".$raidbarId."'");
                                    print( 
" got return for ".$row['owid'].": text = '".$text."', submitted to Outwar" );
                                    
$i $max_trys;
                                }
                            break;
                            case 
ccERR_BALANCE:
                                print( 
"not enough funds to process a picture, balance is depleted" );
                            break;
                            case 
ccERR_TIMEOUT:
                                print( 
"picture has been timed out on server (payment not taken)" );
                            break;
                            case 
ccERR_OVERLOAD:
                                print( 
"temporarily server-side error server's overloaded, wait a little before sending a new picture" );
                            break;
                            case 
ccERR_STATUS:
                                print( 
"local error." );
                            break;
                            case 
ccERR_NET_ERROR:
                                print( 
"network troubles, better to call ccproto_login() again" );
                            break;
                            case 
ccERR_TEXT_SIZE:
                                print( 
"size of the text returned is too big" );
                            break;
                            case 
ccERR_GENERAL:
                                print( 
"server-side error, better to call ccproto_login() again" );
                            break;
                            case 
ccERR_UNKNOWN:
                                print( 
"unknown error, better to call ccproto_login() again" );
                            break;
        
                            default:
                                break;
                        }
                        print ( 
"\n" );
                    }
                }
                
flush();
                
$i++;
            }
        }
        
$ccp->close();
        
        
$former mysql_query("SELECT `owid` FROM `raidbar_users` WHERE `username` = '" $raidid['former'] . "' AND `rdId` = '".$raidbarId."'");
        
$former mysql_fetch_array($former);
                
        
curl("http://".$server[$siteConfig['userServer']].".outwar.com/joinraid.php?raidid=" $raidid['raidid'] . "&suid=" $former['owid'] . "&launchraid=no");
        print (
"\nLaunched!\n");

        
$result mysql_query("SELECT `JOINED` FROM `raidbar_raidid` WHERE rdId = '".$raidbarId."'");
        
$row mysql_fetch_array($result);
        echo 
$row['JOINED'] . " people have joined this raid";
    }
?>
</pre>
</body>
</html>