Results 1 to 10 of 29

Hybrid View

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

    Default Need some help diagnosing functions_general,php errors

    I am getting nowhere fast posting in the contributions and addons section with regard to this mod so apologies for posting in general questions, however, I am hoping that I may get more views from the gurus out there that may be able to spot the problem.

    I am using the dynamic filter sidebox addon. everything is working great apart from getting some PHP warnings in the log directory building up.

    I have seen similar posts and have tried some of the suggestions, however none seem to be fixing hte pronlem that I have.

    the only file that appeared to be out of date is the function_general.php when installing so I did a merge on the file which maybe thats why I am having issues..

    the warning I get is:
    PHP Warning: strlen() expects parameter 1 to be string, array given in /home/site/public_html/newsite/includes/functions/functions_general.php on line 158

    now the code that is causing the warnings and that I merged was like this:
    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)) {
     
    //removed below for merging dynamic filter
     //      if (is_array($value) || in_array($key, $exclude_array)) continue;
     //      if (strlen($value) > 0) {
     //         $get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';

    // bof dynamic filter 1 of 3

    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') ) {

    // eof dynamic filter 1 of 3
              
    if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
    //    die ('here');
                
    $get_url .= $key '/' rawurlencode(stripslashes($value)) . '/';
              } else {
    // 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;
      } 
    I found that the errors stopped if I removed one of the lines I commented out like this:
    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)) {
     
    //removed below for merging dynamic filter
           
    if (is_array($value) || in_array($key$exclude_array)) continue;
     
    //      if (strlen($value) > 0) {
     //         $get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';

    // bof dynamic filter 1 of 3

    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') ) {

    // eof dynamic filter 1 of 3
              
    if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
    //    die ('here');
                
    $get_url .= $key '/' rawurlencode(stripslashes($value)) . '/';
              } else {
    // 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;
      } 
    however, when the errors stopped, I noticed that the filter is lost when navigating to page 2 of the results (so basically breaks it)

    So I guess I have two options, dig dig dig and see if there is a proper solution, or, somehow find a way to stop the error log building up by ignoring the warning some how as it doesn't seem to actually affect the functionality of the site at all. After all its only a warning right??

    Can anyone please help? I spoke to a friend that also has this mod on a fresh install of zen-cart and also has the same warning log files.

    Thanks in Advance,
    Phil Rogers
    A problem shared is a problem solved.

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

    Default Re: Need some help diagnosing functions_general,php errors

    This is from my functions_general.php file, and I don't get any errors, maybe it is helping.
    it's from ZC 1.5.1

    PHP Code:
    /**
     * Return all HTTP GET variables, except those passed as a parameter
     *
     * The return is a urlencoded string
     *
     * @param mixed either a single or array of parameter names to be excluded from output
    */
      
    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)) && (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;
      } 

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

    Default Re: Need some help diagnosing functions_general,php errors

    I just tried you code and I still get the PHP warning.. :'(

    I am running CEON URI Mapping but I get the same even with the mapping switched off so pretty sure its not that.. I dont get it
    Phil Rogers
    A problem shared is a problem solved.

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

    Default Re: Need some help diagnosing functions_general,php errors

    the line the warning is triggering on is this one specifically:

    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') ) { 
    Phil Rogers
    A problem shared is a problem solved.

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

    Default Re: Need some help diagnosing functions_general,php errors

    @Design75 so you don't get any php warning files in your /log directory at all??
    Phil Rogers
    A problem shared is a problem solved.

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

    Default Re: Need some help diagnosing functions_general,php errors

    no, not a single one

  7. #7
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    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.

 

 

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

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