Disabling Zend optimizer, ionCube loader, etc

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adamalton
    New Member
    • Feb 2007
    • 93

    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.en able 0
    php_flag eaccelerator.op timizer 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.hostult ra.com/

    Here's the phpinfo for my own server:
    http://uk.geocities.co m/adz999/phpinfo.php.htm l

    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.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, adamalton.

    What is the code that causes the crash?

    Comment

    • adamalton
      New Member
      • Feb 2007
      • 93

      #3
      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_s elect($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=4202 0

      Thanks

      Comment

      • adamalton
        New Member
        • Feb 2007
        • 93

        #4
        Here's the code if you want a gander (it's not very easy to read on the php site):
        [PHP]//$arr_request_da ta is a multi-dimentional array in the format $arr_request_da ta[]=array(post data for form , PHPSESSID cookie , Tracker cookie);
        foreach ($arr_request_d ata as $i =>$request_data )
        {
        $arr_requests[$i] = curl_init("http ://www.example.com ");
        curl_setopt($ar r_requests[$i], CURLOPT_RETURNT RANSFER, 1);
        curl_setopt($ar r_requests[$i], CURLOPT_HEADER, 1);
        curl_setopt($ar r_requests[$i], CURLOPT_NOBODY, 1); //i only need the header
        curl_setopt($ar r_requests[$i], CURLOPT_POST, 1);
        curl_setopt($ar r_requests[$i], CURLOPT_POSTFIE LDS, $request_data[0]);
        curl_setopt($ar r_requests[$i], CURLOPT_COOKIE, "PHPSESSID= ". $request_data[1] ."; Tracker=". $request_data[2]);
        curl_setopt($ar r_requests[$i], CURLOPT_REFERER , "http://www.example.com ");
        curl_setopt($ar r_requests[$i], CURLOPT_USERAGE NT, $agent); //that's already set using $_SERVER['HTTP_USER_AGEN T']
        curl_setopt($ar r_requests[$i], CURLOPT_TIMEOUT ,10);
        curl_setopt($ar r_requests[$i], CURLOPT_CONNECT TIMEOUT,2);
        curl_setopt($ar r_requests[$i], CURLOPT_FORBID_ REUSE,1);
        curl_setopt($ar r_requests[$i], CURLOPT_LOW_SPE ED_LIMIT,100);
        curl_setopt($ar r_requests[$i], CURLOPT_LOW_SPE ED_TIME,2);
        }

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

        $mh = curl_multi_init ();
        foreach(array_k eys($arr_reques ts) as $i)
        curl_multi_add_ handle ($mh,$arr_reque sts[$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_MULT I_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_sel ect($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_MULT I_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_k eys($arr_reques t_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_requ est_data,$arr_r equests);
        return;
        }


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


        // retrieve data
        foreach (array_keys($ar r_requests) as $i){
        if(curl_error($ arr_requests[$i]) == '') //if all went well
        {
        $arr_results[$i]=curl_multi_get content($arr_re quests[$i]);
        curl_multi_remo ve_handle($mh,$ arr_requests[$i]);
        curl_close($arr _requests[$i]);
        unset($arr_requ ests[$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_co unt[$i]++; //start/increment the tally of how many times it has been retried
        else
        {
        //just delete it:
        unset($arr_requ est_data[$i]);
        $arr_results[$i]="curl_error ";
        curl_multi_remo ve_handle($mh,$ arr_requests[$i]);
        curl_close($arr _requests[$i]);
        unset($arr_requ ests[$i]);
        }
        }

        }//end foreach

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

        curl_multi_clos e($mh);
        }//end of while($arr_requ ests)[/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_sele ct($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.

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          If you remove the curl_multi_sele ct() call, does the rest of the script output (i.e., is that statement what's causing it to die)?

          Comment

          • adamalton
            New Member
            • Feb 2007
            • 93

            #6
            Yes, if I change
            curl_multi_sele ct($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_sele ct 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_sele ct then that would be great, do you know if that's possible?

            Thanks

            Comment

            • adamalton
              New Member
              • Feb 2007
              • 93

              #7
              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_s elect($mh) != -1)
              line?

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

              Any ideas?
              Thanks

              Comment

              • pbmods
                Recognized Expert Expert
                • Apr 2007
                • 5821

                #8
                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.

                Comment

                • adamalton
                  New Member
                  • Feb 2007
                  • 93

                  #9
                  Ok,
                  I want my code to take a multi dimensional array in the format:
                  $arr_request_da ta[0] = array(post_data _to_be_sent , cookie1 , cookie2);
                  $arr_request_da ta[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_RETURN TRANSFER).

                  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_da ta[0] request";
                  $arr_results[1] = "the reply that was given for the $arr_request_da ta[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_s elect($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_s elect($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.

                  Comment

                  • pbmods
                    Recognized Expert Expert
                    • Apr 2007
                    • 5821

                    #10
                    Is it possible to simplify the code at all? I'm not familiar with curl_multi_anyt hing(), but have a look at this example.

                    Comment

                    Working...