Undefined offset: error "help needed

Discussion in 'PHP' started by mr_bill, Apr 18, 2007.

  1. #1
    Just received a notice from my host stating that "we have suspended this site due to the fact that it is spawning multiple apache children on our servers and taking up a lot of resources."


    error code


    Here is line 579 - 586

    This code is from the index.php of the latest version of PHProxy


    Thank you
    William
     
    mr_bill, Apr 18, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Usually these errors are not show, because PHP's error reporting is set to E_ALL ^ E_NOTICE by default. There are two ways to fix it, one by modifying the script, and another by modifying your PHP settings.

    I assume that PHProxy has a config.php file, or similar which is included in all files. You can set this line at the top of it:
    
    error_reporting(E_ALL ^ E_NOTICE);
    
    PHP:
    If you have access to your php.ini file, you can change the value there, so you don't have to modify every bad written script you want to run.

    The other (quickest) way would be putting @ signs infront of the variables that cause these errors.

    
    if ($cookie_id[0] === 'COOKIE')
    {
    @$cookie_id[3] = str_replace('_', '.', @$cookie_id[3]); //stupid PHP can't have dots in var names
    
    if (count($cookie_id) < 4 || (@$cookie_content[1] == 'secure' && $_url_parts['scheme'] != 'https'))
    {
    continue;
    }
    
    PHP:
     
    nico_swd, Apr 18, 2007 IP
  3. mr_bill

    mr_bill Banned

    Messages:
    1,292
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    135
    #3
    Thank you will try the "@" see if it fixes the issue
     
    mr_bill, Apr 18, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I would guess it's eating up resources because it's a proxy and thats what they do. The error messages are just a minor issue in the code (or your php config, depending how you look at it), hence the term 'notice'.
     
    rodney88, Apr 18, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    Professionally written scripts should not leave any notices, warnings or errors, not even if error reporting is set to E_ALL. Each time one of those occurs, the log file has to be opened, the error has to be written to it, and the files closed again. This all takes unnecessary time and slows the performance of your script down. No matter what kind of script it is, this should not happen...
     
    nico_swd, Apr 18, 2007 IP
  6. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #6
    True, but as you said the default suppresses notices (and if suppressed, it's not logged). Considering a massive number of commercially available scripts would generate notices, if a host were to set error reporting to E_ALL, you could safely say its an issue with the php config.

    Of course in development it should be set as high as E_STRICT to avoid any bad practices but that's beside the point.
     
    rodney88, Apr 18, 2007 IP
  7. mr_bill

    mr_bill Banned

    Messages:
    1,292
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    135
    #7
    nico if this something you could do would you be willing to look at the script and tell hard it would be to so what you mention in your first sentence.. Also a price.. Seems this would be a good fix for proxy users if it reduces resources.

    Could you pm if interested
     
    mr_bill, Apr 18, 2007 IP