By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,533 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

Disabling Zend optimizer, ionCube loader, etc

P: 93
Hi, I'm having a problem with what appears to be a bug in php, where one of my scripts runs fine on my own server, and it runs fine *sometimes* on my webhost's server, but I call it from within a certain script on my webhsot then php just dies, no error message, nothing. It's all a bit complex, but basically I want to know how to disable ANYTHING that might be causing php to behave strangely on the webshost.

Baring in mind that it's shared hosting so I can't change the php.ini file or uninstall things etc.
I've already added these 2 lines to the .htaccess file:
php_flag eaccelerator.enable 0
php_flag eaccelerator.optimizer 0

I know that my webhost has got the ionCube Loader on it, but would that make any difference if I'm not using any encoded php files? If it might make a difference, how do I disable it?

Here's the phpinfo for my webserver:
http://phpinfo.hostultra.com/

Here's the phpinfo for my own server:
http://uk.geocities.com/adz999/phpinfo.php.html

Can anyone see any other differences that might be making php behave differently? (I know my webhost is php 5.2.3 and mine is 5.2.1, but my webhost was 5.2.1 a until a couple of days ago, and when they upgraded it made no difference.)

Any help greatly appreciated.
Jul 20 '07 #1
Share this Question
Share on Google+
9 Replies


pbmods
Expert 5K+
P: 5,821
Heya, adamalton.

What is the code that causes the crash?
Jul 21 '07 #2

P: 93
Well...I've got a script which processes some search queries to another website using cURL (let's call it 'processor.php'). I've then got a 'master script' which includes various scripts, each one of which generates some search queries to be processed, and then includes processor.php to perform the searches.

When processor.php is called from some of the scripts it works fine, and when it's called from other scripts it just stops dead, the connection to the web browser dies, no error message is displayed, it just stops. I've tried printing out a message in between each line of code and then flush()ing the buffer so that I can monitor its progress as it goes. It dies at this line: [PHP]if(curl_multi_select($mh) != -1){[/PHP]
With so many scripts involved it's a bit hard to determine what the factor is that's causing to fail. The code is fine syntax wise because it works (when called from some of the scripts), and if it wasn't then I would get an error message. Oh and it works on my own computer, so it's DEFINITELY fine in terms of coding. So there must be a difference between my php and my web host's php, which is why I'm trying to figure out how to disable any add-ons and stuff.

I've submitted a bug report to php, which is here (and show's some example code):
http://bugs.php.net/bug.php?id=42020

Thanks
Jul 21 '07 #3

P: 93
Here's the code if you want a gander (it's not very easy to read on the php site):
[PHP]//$arr_request_data is a multi-dimentional array in the format $arr_request_data[]=array(post data for form , PHPSESSID cookie , Tracker cookie);
foreach ($arr_request_data as $i =>$request_data)
{
$arr_requests[$i] = curl_init("http://www.example.com");
curl_setopt($arr_requests[$i], CURLOPT_RETURNTRANSFER, 1);
curl_setopt($arr_requests[$i], CURLOPT_HEADER,1);
curl_setopt($arr_requests[$i], CURLOPT_NOBODY,1); //i only need the header
curl_setopt($arr_requests[$i], CURLOPT_POST, 1);
curl_setopt($arr_requests[$i], CURLOPT_POSTFIELDS, $request_data[0]);
curl_setopt($arr_requests[$i], CURLOPT_COOKIE, "PHPSESSID=". $request_data[1] ."; Tracker=". $request_data[2]);
curl_setopt($arr_requests[$i], CURLOPT_REFERER, "http://www.example.com");
curl_setopt($arr_requests[$i], CURLOPT_USERAGENT, $agent); //that's already set using $_SERVER['HTTP_USER_AGENT']
curl_setopt($arr_requests[$i], CURLOPT_TIMEOUT,10);
curl_setopt($arr_requests[$i], CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($arr_requests[$i], CURLOPT_FORBID_REUSE,1);
curl_setopt($arr_requests[$i], CURLOPT_LOW_SPEED_LIMIT,100);
curl_setopt($arr_requests[$i], CURLOPT_LOW_SPEED_TIME,2);
}

//now perform the requests:
while($arr_requests) //while they have NOT all SUCCESSFULLY completed
{

$mh = curl_multi_init();
foreach(array_keys($arr_requests) as $i)
curl_multi_add_handle ($mh,$arr_requests[$i]);


print "got as far as executing the curl stuff<br>"; while (ob_end_flush()); while (flush());


do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM && $active>0);


print "1<br>"; while (ob_end_flush()); while (flush());

while ($active>0 and $mrc == CURLM_OK){

print "2<br>"; while (ob_end_flush()); while (flush());

// wait for network
if (curl_multi_select($mh) != -1){
// pull in any new data, or at least handle timeouts
do {
print "3<br>"; while (ob_end_flush()); while (flush());

$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM && $active>0);
}
}

print "4<br>"; while (ob_end_flush()); while (flush());

if($mrc != CURLM_OK) //if it all went wrong
{
//then make all results into "curl_error" and exit the script
foreach(array_keys($arr_request_data) as $i)//some elements may have already been deleted, but only if they were curl_errors enyway
$arr_results[$i]="curl_error";
unset($arr_request_data,$arr_requests);
return;
}


print "5<br>"; while (ob_end_flush()); while (flush());


// retrieve data
foreach (array_keys($arr_requests) as $i){
if(curl_error($arr_requests[$i]) == '') //if all went well
{
$arr_results[$i]=curl_multi_getcontent($arr_requests[$i]);
curl_multi_remove_handle($mh,$arr_requests[$i]);
curl_close($arr_requests[$i]);
unset($arr_requests[$i]); //it has to be unset as well, otherwise it still exists
}
else //if we got a curl error
{
print "<br>Send request loop: ". curl_error($arr_requests[$i]);

if($arr_retries_count[$i]<3) //if it has NOT been retried 3 times already (4 times including the 1st one)
$arr_retries_count[$i]++; //start/increment the tally of how many times it has been retried
else
{
//just delete it:
unset($arr_request_data[$i]);
$arr_results[$i]="curl_error";
curl_multi_remove_handle($mh,$arr_requests[$i]);
curl_close($arr_requests[$i]);
unset($arr_requests[$i]);
}
}

}//end foreach

print "6<br>"; while (ob_end_flush()); while (flush());

curl_multi_close($mh);
}//end of while($arr_requests)[/PHP]
It's not very easy to read there either!!

It gets as far as printing out "2<br>" and then it dies. Dead. Nothing. If curl_multi_select($mh) is not equal to -1 then it should print out "3<br>" and if it IS equal to -1 then the while ($active>0 and $mrc == CURLM_OK) should go round again and it should print out "2<br>" again, but it doesn't, it just dies.
Jul 21 '07 #4

pbmods
Expert 5K+
P: 5,821
If you remove the curl_multi_select() call, does the rest of the script output (i.e., is that statement what's causing it to die)?
Jul 21 '07 #5

P: 93
Yes, if I change
curl_multi_select($mh) != -1
to
TRUE
then the
while ($active>0 and $mrc == CURLM_OK)
loop just goes round and round lots of times printing out "2<br>" and "3<br>" each time. I'm not sure that the curl stuff works when I do that, but it stops the script from dying a silent death.

Do you know any more about exactly what curl_multi_select does, other than what's in the php manual? I took the user-added example code from the curl_multi_exec page of the php manual and adapted it for my needs, so I must admit I'm no expert on the curl multi functions. I tried looking on the curl.haxx site, but the multi functions that it lists don't quite match the functions that php uses and I didn't gain any great wisdom by reading what was there.

If I could adapt the code so that I don't need to use curl_multi_select then that would be great, do you know if that's possible?

Thanks
Jul 21 '07 #6

P: 93
Actually the loop goes round several hundred times, but it DOES eventually finish, and the curl operations DO appear to work. So maybe i should just dump the if(curl_multi_select($mh) != -1)
line?

If I leave the curl_multi_select line in, and if the script works, then the loop would only go round 2 or 3 times, which suggests that the curl_multi_select does have some purpose, but maybe it's not essential?

Any ideas?
Thanks
Jul 21 '07 #7

pbmods
Expert 5K+
P: 5,821
Heya, adamalton.

Let's go back to basics for a second.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Jul 21 '07 #8

P: 93
Ok,
I want my code to take a multi dimensional array in the format:
$arr_request_data[0] = array(post_data_to_be_sent , cookie1 , cookie2);
$arr_request_data[1] = array(post_data_to_be_sent , cookie1 , cookie2);
etc,
and for each array row I want it to create a curl handle that will send the post data and the 2 cookies to a given url, and return the response from the server (CURLOPT_RETURNTRANSFER).

I then want it to execute all of these curl handles simultaneously, and put the 'replies' into an array:
$arr_results[0] = "the reply that was given for the $arr_request_data[0] request";
$arr_results[1] = "the reply that was given for the $arr_request_data[1] request";
etc

What is your code doing that you don't want it to do? Give an example.
My original code that contained the line:
if(curl_multi_select($mh) != -1)
would cause php to fail, silently at that line, which apart from not allowing the transfers to complete also stops me from 'handling' the errors, because php execution stops.

What is your code *not* doing that it is supposed to? Give an example.
It is not completing the curl transfers.


***********************************************
After experimenting a bit more I now realize that the transfers DO complete if I take out the line:
if(curl_multi_select($mh) != -1)
*but* if I do that then as I mentioned earlier php goes round and round the
while ($active>0 and $mrc == CURLM_OK)
loop several hundred times, which (after running some more tests) often causes php to fail because of it exceeds its maximum execution time, so is not really a viable solution.
Jul 21 '07 #9

pbmods
Expert 5K+
P: 5,821
Is it possible to simplify the code at all? I'm not familiar with curl_multi_anything(), but have a look at this example.
Jul 21 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.