473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Disabling Zend optimizer, ionCube loader, etc

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
9 5434
pbmods
5,821 Expert 4TB
Heya, adamalton.

What is the code that causes the crash?
Jul 21 '07 #2
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
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
5,821 Expert 4TB
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
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
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
5,821 Expert 4TB
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
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
5,821 Expert 4TB
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

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

Similar topics

4
by: Munja | last post by:
I have PHP script running complex query and then calculating data for different conditions from received result set. Actually, it's doing the same as if I would make several queries with different...
0
by: Michal Zajaczkowski | last post by:
Hello I have installed php 4.3.3 and Zend Optimizer2.1.0b on debian woody. I added to my php.ini lines: zend_optimizer.optimization_level=7 zend_extension="/usr/local/Zend/lib/ZendOptimizer.so"...
1
by: Nick Mudge | last post by:
Hi, Does anybody know the performance difference between having your PHP code cached and just running your code with the zend optimizer? Is there much difference? Nick
1
by: Toni | last post by:
I've tried to reinstall the zend environment and debugger on my new computer. I almost succeeded but when I try to debug or profile a webpage by clicking on the buttons on the toolbars I get the...
3
by: nntp | last post by:
What is ZEND. Why it has anything to do with programming PHP?
1
by: Xristos Nikolopoulos | last post by:
Hello, I have made an application that needs to upload files, the application is deployed in several folders, and each folder has its php files. The problem is, I have in the folder I want to...
7
by: archimonde2 | last post by:
What are pros any cons to use eaccelerator and zend optimizer on php5-mod with apache2.2 ?? Does accelerators work immediately after install on all php files? When both are in use which...
1
by: maheswaran | last post by:
Hi I have tring to run a simple test script using ioncube loader (like echo "welocme"l). I could not . In my server ioncube is installed and run successfully (some thrid party script).Any one...
4
by: Blueparty | last post by:
I am going to use Ioncube or Zend compiler/encoder to deploy PHP5 applications on servers at customers premisses. The factors that affect choice are: - reliability - easy of deployment at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.