Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2006
    Posts
    20
    Plugin Contributions
    0

    Default [Done v1.3.9a/e] whos_online.php $start_cart endless loop for php 5.2.5

    FOR
    www.---.com/catalog/admin/whos_online.php

    frequently, but not always will get something like

    Fatal error: Maximum execution time of 60 seconds exceeded in /--path--/admin/whos_online.php on line 416

    sometimes the line number is different, sometime if load is lite it will
    make it..
    fyi, the box for /catalog showing whos online does not seem affected.



    I saw two separate threads in general on this.

    I think it may be a php5 issue perhaps... looking at vmstat and top,
    the web server spirals away trying to do php on some platforms


    see also in general:
    http://www.zen-cart.com/forum/showthread.php?t=85765
    http://www.zen-cart.com/forum/showthread.php?p=503832



    In my case I was using an openbsd AMD64
    running
    php5-core-5.2.5p1
    mysql-server-5.0.51

    tried to use the default secure php.ini settings... for the most part.


    and I saw it with both a 1.3.7 and a 1.3.8a version of zencart.


    got some things you want me to try?

  2. #2
    Join Date
    Sep 2006
    Posts
    20
    Plugin Contributions
    0

    Default whos_online.php $start_cart endless loop for php 5.2.5

    per discussion:

    http://www.zen-cart.com/forum/showth...t=85765&page=2



    It appears that for some, they get a timeout because perhaps the
    loop, for ($i=$start_cart; $i<$length; $i++) may not be using an
    integer for $start_cash

    When I put
    settype($start_cart,"integer");

    before line 409
    I stop getting the fatal error message "Maximum execution time"

    this appear to be so for 1.3.7 and 1.3.8a



    Notice this upon migration to a server with new version of php, 5.2.5

  3. #3
    Join Date
    Sep 2006
    Posts
    20
    Plugin Contributions
    0

    Default Re: whos_online.php $start_cart endless loop for php 5.2.5

    We are pretty sure that this issue is arising when the session data is encrypted.

    The whos_online.php is trying to grab information directly from the session information without adequate testing what it may or may not have snooped.

    Before the 'for' statement there is no check to ensure that $start_cart is a valid number. strpos() will return something equal to false if the string isn't found. If the session information is fubar then it may be causing an infinite loop.

    As more and more providers use 'hardened' php, issues like this will arise. Even more so if Zen Cart is a bit naughty and tries to read customers' session data directly to show you their cart contents. With secure session handling it breaks.

    So if we put the settype integer,
    we can work around this, but the cart information is not used....?


    Recommend reading the thread:
    http://www.zen-cart.com/forum/showth...t=85765&page=2

  4. #4
    Join Date
    Feb 2005
    Location
    Italy
    Posts
    199
    Plugin Contributions
    0

    Default Re: whos_online.php $start_cart endless loop for php 5.2.5

    I confirm.

    Zen cart 1.3.8
    PHP 5.2.6
    Session ecrypted (Suhosin v0.9.29)
    Dedicated server

    No time out but a very very long time to load the page.

    Setting the type to integer solved the performance issue.
    Last edited by s_p_ike; 12 Jan 2010 at 11:22 AM. Reason: Forgot one detail
    Paolo De Dionigi
    Co-maintainer of Zen Cart Italia

  5. #5
    Join Date
    Feb 2005
    Location
    Italy
    Posts
    199
    Plugin Contributions
    0

    Default Re: [Done v1.3.9] whos_online.php $start_cart endless loop for php 5.2.5

    ... but the cart details were no longer available.

    Now we moved on a new server, with similar configuration (of course it must be not the same, but I don't know where to look for differencies about this problem) and now the page is super fast and the cart details are available.
    Paolo De Dionigi
    Co-maintainer of Zen Cart Italia

  6. #6
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: whos_online.php $start_cart endless loop for php 5.2.5

    Quote Originally Posted by ppruett View Post
    We are pretty sure that this issue is arising when the session data is encrypted.

    Before the 'for' statement there is no check to ensure that $start_cart is a valid number. strpos() will return something equal to false if the string isn't found. If the session information is fubar then it may be causing an infinite loop.
    True, and there are some other factors involved too.

    Try changing this:
    Code:
        if ($length = strlen($session_data)) {
          if (PHP_VERSION < 4) {
            $start_id = strpos($session_data, 'customer_id[==]s');
            $start_cart = strpos($session_data, 'cart[==]o');
            $start_currency = strpos($session_data, 'currency[==]s');
            $start_country = strpos($session_data, 'customer_country_id[==]s');
            $start_zone = strpos($session_data, 'customer_zone_id[==]s');
          } else {
            $start_id = strpos($session_data, 'customer_id|s');
            $start_cart = strpos($session_data, 'cart|O');
            $start_currency = strpos($session_data, 'currency|s');
            $start_country = strpos($session_data, 'customer_country_id|s');
            $start_zone = strpos($session_data, 'customer_zone_id|s');
          }
    
          for ($i=$start_cart; $i<$length; $i++) {
            if ($session_data[$i] == '{') {
              if (isset($tag)) {
                $tag++;
              } else {
                $tag = 1;
              }
            } elseif ($session_data[$i] == '}') {
              $tag--;
            } elseif ( (isset($tag)) && ($tag < 1) ) {
              break;
            }
          }
    
          $session_data_id = substr($session_data, $start_id, (strpos($session_data, ';', $start_id) - $start_id + 1));
    // fix nnobo bug
          $session_data_cart = substr($session_data, $start_cart, $i - $start_cart);
          $session_data_currency = substr($session_data, $start_currency, (strpos($session_data, ';', $start_currency) - $start_currency + 1));
          $session_data_country = substr($session_data, $start_country, (strpos($session_data, ';', $start_country) - $start_country + 1));
          $session_data_zone = substr($session_data, $start_zone, (strpos($session_data, ';', $start_zone) - $start_zone + 1));
    
          session_decode($session_data_id);
          session_decode($session_data_currency);
          session_decode($session_data_country);
          session_decode($session_data_zone);
          session_decode($session_data_cart);
    
          if (PHP_VERSION < 4) {
            $broken_cart = $cart;
            $cart = new shoppingCart;
            $cart->unserialize($broken_cart);
          }
    to this:
    Code:
        if (strpos($session_data, 'cart|O') == 0) $session_data = base64_decode($session_data);
        if (strpos($session_data, 'cart|O') == 0) $session_data = '';
    
        $suhosinExtension = extension_loaded('suhosin');
        $suhosinSetting = strtoupper(@ini_get('suhosin.session.encrypt'));
        $hardenedStatus = ($suhosinExtension == TRUE || $suhosinSetting == 'On' || $suhosinSetting == 1) ? TRUE : FALSE;
        if ($session_data != '' && $hardenedStatus == TRUE) $session_data = '';
    
        if ($length = strlen($session_data)) {
          $start_id = (int)strpos($session_data, 'customer_id|s');
          $start_currency = (int)strpos($session_data, 'currency|s');
          $start_country = (int)strpos($session_data, 'customer_country_id|s');
          $start_zone = (int)strpos($session_data, 'customer_zone_id|s');
          $start_cart = (int)strpos($session_data, 'cart|O');
          $end_cart = (int)strpos($session_data, '|', $start_cart+6);
          $end_cart = (int)strrpos(substr($session_data, 0, $end_cart), ';}');
    
          $session_data_id = substr($session_data, $start_id, (strpos($session_data, ';', $start_id) - $start_id + 1));
          $session_data_cart = substr($session_data, $start_cart, ($end_cart - $start_cart+2));
          $session_data_currency = substr($session_data, $start_currency, (strpos($session_data, ';', $start_currency) - $start_currency + 1));
          $session_data_country = substr($session_data, $start_country, (strpos($session_data, ';', $start_country) - $start_country + 1));
          $session_data_zone = substr($session_data, $start_zone, (strpos($session_data, ';', $start_zone) - $start_zone + 1));
    
          session_decode($session_data_id);
          session_decode($session_data_currency);
          session_decode($session_data_country);
          session_decode($session_data_zone);
          session_decode($session_data_cart);
    This will at least attempt to work without errors in the case of encoding or encryption, plus fixes the 'for' loop problem, and more.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Dec 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: whos_online.php $start_cart endless loop for php 5.2.5

    Dear all,

    I encountered similar problem Error 500, therefore added "
    settype($start_cart,"integer");" as suggested and it works as in loading the who's online page without error.

    However, I encountered another problem as it shows all users having the same ip address and host which is my own ip & host. I no longer able to view where the users are from :-(

    Another problem is the info in each cart is no longer showing.

    I've tried Dr. Bytes suggestion and still similar problem.

    Anyone facing the same problem? Please help!

    TIA

  8. #8
    Join Date
    Jun 2010
    Posts
    2
    Plugin Contributions
    0

    Default Re: [Done v1.3.9a] whos_online.php $start_cart endless loop for php 5.2.5

    Yeh snapworks, I have similar problem like you. Could you resolve it? If yes, can you please tell me?
    Chris Bradly

  9. #9
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: [Done v1.3.9a] whos_online.php $start_cart endless loop for php 5.2.5

    Chris, upgrade to v1.3.9 and the $start_cart endless loop will disappear.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. v154 whos_online.php
    By SonarScope in forum General Questions
    Replies: 12
    Last Post: 26 Aug 2015, 12:25 AM
  2. Replies: 1
    Last Post: 5 Jan 2015, 11:56 PM
  3. admin redirect loop after upgrading to php 5.2 from php 4
    By TheGrub in forum Installing on a Linux/Unix Server
    Replies: 1
    Last Post: 4 Aug 2010, 08:45 PM
  4. Shopping Cart - Log-in Endless Loop
    By TnA! in forum Basic Configuration
    Replies: 1
    Last Post: 20 Jan 2010, 04:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR