Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default "/ajax.php" adds itself to the navigation history

    Steps to Replicate:
    1. Add an item to the shopping cart.
    2. Visit shopping cart page.
    3. At this point "Back to Shopping" returns the URL to the last page.
    4. Refresh the shopping cart page (or update the quantity of a product).
    5. At this point "Back to Shopping" no longer returns the URL to the last page.


    It appears when "/ajax.php" is loaded via JavaScript, the contents of the navigation history are being updated to add "/index.php?main_page=index&act=ajaxPayment&method=setNoscriptCookie". While not a high priority, this may negatively affect the user experience.


    Perhaps not the correct fix, but adding the following line to "/ajax.php" may be a workaround:
    Code:
    require ('includes/application_top.php');
    $_SESSION['navigation']->remove_current_page();  // Remove page from navigation history
    $language_page_directory = DIR_WS_LANGUAGES.$_SESSION['language'].'/';
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: "/ajax.php" adds itself to the navigation history

    See if this works better:
    Code:
    $_SESSION['navigation']->set_snapshot();
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: "/ajax.php" adds itself to the navigation history

    NOTE: this appears to work when coming from product_info page but more work is needed for when coming from the Product Listing ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  4. #4
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: "/ajax.php" adds itself to the navigation history

    When changing from "$_SESSION['navigation']->remove_current_page();" to "$_SESSION['navigation']->set_snapshot();" the issue is once again present.

    Currently testing under PHP 5.4 and PHP 5.5.
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: "/ajax.php" adds itself to the navigation history

    Interesting ... it does fail ...

    What worked was testing your method then changing the code with what I posted ... but what I posted does not work on a clean session ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: "/ajax.php" adds itself to the navigation history

    Can someone test whether this works reliably?

    /includes/classes/navigation_history.php
    Around line 32 add the highlighted lines:
    Code:
      function add_current_page() {
    
    
        // don't put the ajax handler calls into nav history
        if (preg_match('|ajax\.php$|', $_SERVER['SCRIPT_NAME']) && isset($_GET['act']) && $_GET['act'] != '') return;
    
    
        global $request_type, $cPath;
    And also test on a Windows server too?
    Last edited by DrByte; 14 Jan 2015 at 05:00 AM. Reason: updated regex, and changed the code to do early-return (and changed line number)
    .

    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
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,872
    Plugin Contributions
    96

    Default Re: "/ajax.php" adds itself to the navigation history

    Quote Originally Posted by DrByte View Post
    Can someone test whether this works reliably?

    /includes/classes/navigation.php
    At line 80 add the highlighted lines:
    Code:
        // don't put the ajax handler calls into nav history
        if (preg_match('|/ajax.php$|', $_SERVER['SCRIPT_NAME']) && isset($_GET['act']) && $_GET['act'] != '') $set = 'false';
    
    
        if ($set == 'true') {
          if ($_GET['main_page']) {
    And also test on a Windows server too?
    Apologies, but what was wrong with lhungil's initial proposal? That implementation allows the ajax.php module to "take care of" itself, rather than muddying-up the navigation class.

  8. #8
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: "/ajax.php" adds itself to the navigation history

    I kind of like the page / script itself handling itself... But I suspect there is a possibility for a race condition when someone has multiple tabs open (actually loading)... Potentially causing the wrong page to be removed (with the code I posted).

    Perhaps a long term solution would be to change the code where a page is added to the navigation? Perhaps only adding the page to the history inside application_bottom (instead of application_top). Then we could set a "flag" in the page / script indicating it should not be added to the navigation history?

    I've not dug into the core code far enough to see if this is already the way things work, but if not already implemented as above... I would recommend something along those lines...

    Quote Originally Posted by DrByte View Post
    Can someone test whether this works reliably?

    /includes/classes/navigation.php
    At line 80 add the highlighted lines:
    Code:
        // don't put the ajax handler calls into nav history
        if (preg_match('|/ajax.php$|', $_SERVER['SCRIPT_NAME']) && isset($_GET['act']) && $_GET['act'] != '') $set = 'false';
    
    
        if ($set == 'true') {
          if ($_GET['main_page']) {
    ...
    Appears to work for me under Windows x64 (PHP 5.4, 5.5, and 5.6) and Linux (Debian 7 - PHP 5.4.36).
    Last edited by lhungil; 13 Jan 2015 at 09:46 PM.
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  9. #9
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: "/ajax.php" adds itself to the navigation history

    Quote Originally Posted by lat9 View Post
    Apologies, but what was wrong with lhungil's initial proposal? That implementation allows the ajax.php module to "take care of" itself, rather than muddying-up the navigation class.
    Simple: it didn't work properly.
    .

    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.

  10. #10
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: "/ajax.php" adds itself to the navigation history

    Quote Originally Posted by lhungil View Post
    Perhaps a long term solution would be to change the code where a page is added to the navigation?
    That's basically what my proposed change does.

    I agree that a better solution is desirable, but the goal of any fix to share for v1.5.4 needs to be as brief and simple-to-implement as possible. Any broader architectural changes would go into a new version. I know you understand this. I'm just writing it for the sake of others who read this discussion.

    At present the class is instantiated via the auto-loader system, and there's no interception option there to say "do or don't do based on XYZ conditions".


    I personally never use those "go back to the previous page" navigation buttons, because I always just use the browser's "back" button ... it's a lot faster than having to find something to click on. If I had my way I'd remove all such buttons from all templates, as I feel they just clutter the page. But, I know some people swear by them and don't even realize that the browser has a "back" button. Sigh.
    .

    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.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 2 Jan 2011, 01:14 PM
  2. Editing the "tpl_product_info_display.php" to change the "call for Price" message
    By camospi13 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 1 Sep 2010, 05:50 AM
  3. Please help, no "my account" or "order history"
    By jaypg1 in forum General Questions
    Replies: 15
    Last Post: 18 Oct 2009, 07:05 PM

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