Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 29
  1. #11
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: Need some help diagnosing functions_general,php errors

    I had one last idea before shutting down

    PHP Code:
    // bof dynamic filter 1 of 3
            
    if ( (!in_array($key$exclude_array)) && (strlen((int)$value) > || is_array($value) && array_filter($value) ) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
    // eof dynamic filter 1 of 3 
    I added (int) to the strlen and it seems to do the job, but I am no expert.

    p.s. I wasn't getting any errors at first because I made some other stupid mistake. after fixing that the errors started coming in until I added the int
    Last edited by Design75; 12 Feb 2013 at 12:28 AM.

  2. #12
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Need some help diagnosing functions_general,php errors

    PHP Code:
    if ( (!in_array($key$exclude_array)) && (strlen($value) > || is_array($value) && array_filter($value) ) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) { 
    The statement is testing conditions for some situation, based on $key which stands for the name of the current array-item key in the array being evaluated, and $value which holds the value of the current key.
    Breaking down the statement,
    if ( (!in_array($key, $exclude_array))
    ---> the key is not in a list of keys to exclude,

    && (strlen($value) > 0 || is_array($value) && array_filter($value) )
    ---> and the value is a string that is longer than '' (empty or blank) or the value is an array and this filter applied to it gives "true' or a positive result

    && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
    ---> and the key is not one of these names.


    Apparently $value should not be an array if the key passes the "exclude" test. Casting it to int seems to make it safe, but destroys the test's value (unless it is a string starting with a number, it will be viewed as 0 (zero)); casting it to string will keep the information if it is a string, and hopefully make it safe if it is an array.

    Best would be to find out why it is being an array when it apparently should not, and fixing that, or testing for it being an array and handling it appropriately if it is.
    Last edited by gjh42; 12 Feb 2013 at 03:23 AM.

  3. #13
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Need some help diagnosing functions_general,php errors

    PHP Code:
    && (strlen($value) > || is_array($value) && array_filter($value) ) 
    could be rewritten as

    PHP Code:
    && (is_string($value) && strlen($value) > || is_array($value) && array_filter($value) ) 

  4. #14
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    277

    Default Re: Need some help diagnosing functions_general,php errors

    Perhaps the version of functions_general you're using is based on old code?
    http://www.zen-cart.com/showthread.p...09#post1136209
    .

    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.

  5. #15
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Need some help diagnosing functions_general,php errors

    Thanks very much. Speak soon :-)
    Phil Rogers
    A problem shared is a problem solved.

  6. #16
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Need some help diagnosing functions_general,php errors

    Wow loads of ideas, just replied to what I thought was te last post then boom all of a sudden I had all these great suggestions.
    Now @Design75 did your fix work? Does it work when applying a filter and then going to the second page of te filter results

    @gjh42 I will try your suggestion also thanks for your input, and thank you for explaining the code :-)

    @DrByte how can I incorporate that fix with the dynamic filter code?

    Thanks all
    Phil Rogers
    A problem shared is a problem solved.

  7. #17
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: Need some help diagnosing functions_general,php errors

    Quote Originally Posted by philip937 View Post
    Wow loads of ideas, just replied to what I thought was te last post then boom all of a sudden I had all these great suggestions.
    Now @Design75 did your fix work? Does it work when applying a filter and then going to the second page of te filter results

    @gjh42 I will try your suggestion also thanks for your input, and thank you for explaining the code :-)

    @DrByte how can I incorporate that fix with the dynamic filter code?

    Thanks all
    Wow indeed ;)

    @philip937: My fix worked, but gjh42 is better. Like he said, my fix always assumes an integer, which may not be the case.

    @gjh42 thank you for the lesson, like said before. I am learning PHP bit by bit. Everyday I am understanding a little more.

    @DrByte, I am using the functions_general.php that came with ZC 1.5.1, and merged the dynamic filter code in to it.

    This is how the merged result looks like, including Glenn's fix.
    PHP Code:
      function zen_get_all_get_params($exclude_array ''$search_engine_safe true) {

        if (!
    is_array($exclude_array)) $exclude_array = array();
        
    $exclude_array array_merge($exclude_array, array(zen_session_name(), 'main_page''error''x''y'));
        
    $get_url '';
        if (
    is_array($_GET) && (sizeof($_GET) > 0)) {
          
    reset($_GET);
          while (list(
    $key$value) = each($_GET)) {
    // bof dynamic filter 1 of 3
            
    if ( (!in_array($key$exclude_array)) && (is_string($value) && strlen($value) > || is_array($value) && array_filter($value) ) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
    // eof dynamic filter 1 of 3
    // bof dynamic filter 2 of 3
                
    if (is_array($value)) {
                  foreach(
    $value as $arr){
                    
    $get_url .= zen_sanitize_string($key) . '[]=' rawurlencode(stripslashes($arr)) . '&';
                  }
                } else {
    // eof dynamic filter 2 of 3
                  
    $get_url .= zen_sanitize_string($key) . '=' rawurlencode(stripslashes($value)) . '&';
    // bof dynamic filter 3 of 3
          
    }
    // eof dynamic filter 3 of 3
              
            
    }
          }
        }
        while (
    strstr($get_url'&&')) $get_url str_replace('&&''&'$get_url);
        while (
    strstr($get_url'&&')) $get_url str_replace('&&''&'$get_url);

        return 
    $get_url;
      } 

  8. #18
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Need some help diagnosing functions_general,php errors

    Thanks guys, just got to work so will have to test later this evening on my set up.

    Many many many thanks :)
    Phil Rogers
    A problem shared is a problem solved.

  9. #19
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Need some help diagnosing functions_general,php errors

    Quote Originally Posted by Design75 View Post
    Wow indeed ;)

    @philip937: My fix worked, but gjh42 is better. Like he said, my fix always assumes an integer, which may not be the case.

    @gjh42 thank you for the lesson, like said before. I am learning PHP bit by bit. Everyday I am understanding a little more.

    @DrByte, I am using the functions_general.php that came with ZC 1.5.1, and merged the dynamic filter code in to it.

    This is how the merged result looks like, including Glenn's fix.
    PHP Code:
      function zen_get_all_get_params($exclude_array ''$search_engine_safe true) {

        if (!
    is_array($exclude_array)) $exclude_array = array();
        
    $exclude_array array_merge($exclude_array, array(zen_session_name(), 'main_page''error''x''y'));
        
    $get_url '';
        if (
    is_array($_GET) && (sizeof($_GET) > 0)) {
          
    reset($_GET);
          while (list(
    $key$value) = each($_GET)) {
    // bof dynamic filter 1 of 3
            
    if ( (!in_array($key$exclude_array)) && (is_string($value) && strlen($value) > || is_array($value) && array_filter($value) ) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
    // eof dynamic filter 1 of 3
    // bof dynamic filter 2 of 3
                
    if (is_array($value)) {
                  foreach(
    $value as $arr){
                    
    $get_url .= zen_sanitize_string($key) . '[]=' rawurlencode(stripslashes($arr)) . '&';
                  }
                } else {
    // eof dynamic filter 2 of 3
                  
    $get_url .= zen_sanitize_string($key) . '=' rawurlencode(stripslashes($value)) . '&';
    // bof dynamic filter 3 of 3
          
    }
    // eof dynamic filter 3 of 3
              
            
    }
          }
        }
        while (
    strstr($get_url'&&')) $get_url str_replace('&&''&'$get_url);
        while (
    strstr($get_url'&&')) $get_url str_replace('&&''&'$get_url);

        return 
    $get_url;
      } 
    LOVE YOU ALL!!!! SORTED.
    Phil Rogers
    A problem shared is a problem solved.

  10. #20
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    277

    Default Re: Need some help diagnosing functions_general,php errors

    Quote Originally Posted by gjh42 View Post
    && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
    ---> and the key is not one of these names.
    ... and that part is fully redundant because the test for $exclude_array already handles those names.
    .

    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 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Need to display Product ID in functions_general.php to edit Category List Showcase
    By vandiermen in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 9 Mar 2009, 03:25 AM
  2. Need to override functions_general.php
    By lbowenc in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 28 Mar 2008, 12:18 PM
  3. Replies: 2
    Last Post: 1 Jul 2007, 05:10 AM

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