Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,475
    Plugin Contributions
    88

    Default [Done v155] Plugin Version Check: Debug-log "flood" if allow_url_fopen=0

    The function plugin_version_check_for_updates, present in /includes/functions/plugin_support.php, throws debug-logs each time the admin is accessed in a client's installation:
    Code:
    [14-Oct-2015 17:03:46 UTC] Request URI: /theadmin/login.php?camefrom=server_info.php, IP address: 
    #1  file_get_contents() called at [/var/www/html/example.com/includes/functions/plugin_support.php:38]
    #2  plugin_version_check_for_updates() called at [/var/www/html/example.com/theadmin/includes/init_includes/init_zen_lightbox.php:85]
    #3  require(/var/www/html/example.com/theadmin/includes/init_includes/init_zen_lightbox.php) called at [/var/www/html/example.com/includes/autoload_func.php:48]
    #4  require(/var/www/html/example.com/includes/autoload_func.php) called at [/var/www/html/example.com/theadmin/includes/application_top.php:156]
    #5  require(/var/www/html/example.com/theadmin/includes/application_top.php) called at [/var/www/html/example.com/theadmin/login.php:16]
    
    [14-Oct-2015 17:03:46 UTC] PHP Warning:  file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /var/www/html/example.com/includes/functions/plugin_support.php on line 38
    [14-Oct-2015 17:03:46 UTC] Request URI: /theadmin/login.php?camefrom=server_info.php, IP address: 
    #1  file_get_contents() called at [/var/www/html/example.com/includes/functions/plugin_support.php:38]
    #2  plugin_version_check_for_updates() called at [/var/www/html/example.com/theadmin/includes/init_includes/init_zen_lightbox.php:85]
    #3  require(/var/www/html/example.com/theadmin/includes/init_includes/init_zen_lightbox.php) called at [/var/www/html/example.com/includes/autoload_func.php:48]
    #4  require(/var/www/html/example.com/includes/autoload_func.php) called at [/var/www/html/example.com/theadmin/includes/application_top.php:156]
    #5  require(/var/www/html/example.com/theadmin/includes/application_top.php) called at [/var/www/html/example.com/theadmin/login.php:16]
    
    [14-Oct-2015 17:03:46 UTC] PHP Warning:  file_get_contents(http://www.zen-cart.com/downloads.php?do=versioncheck&id=170): failed to open stream: no suitable wrapper could be found in /var/www/html/example.com/includes/functions/plugin_support.php on line 38
    [14-Oct-2015 17:03:46 UTC] Request URI: /theadmin/login.php?camefrom=server_info.php, IP address: 
    #1  in_array() called at [/var/www/html/example.com/includes/functions/plugin_support.php:42]
    #2  plugin_version_check_for_updates() called at [/var/www/html/example.com/theadmin/includes/init_includes/init_zen_lightbox.php:85]
    #3  require(/var/www/html/example.com/theadmin/includes/init_includes/init_zen_lightbox.php) called at [/var/www/html/example.com/includes/autoload_func.php:48]
    #4  require(/var/www/html/example.com/includes/autoload_func.php) called at [/var/www/html/example.com/theadmin/includes/application_top.php:156]
    #5  require(/var/www/html/example.com/theadmin/includes/application_top.php) called at [/var/www/html/example.com/theadmin/login.php:16]
    
    [14-Oct-2015 17:03:46 UTC] PHP Warning:  in_array() expects parameter 2 to be array, null given in /var/www/html/example.com/includes/functions/plugin_support.php on line 42
    As you can see from the logs, the Zen Lightbox plugin is trying to determine if there's an update available. The issue is that the site on which Zen Cart is installed has allow_url_fopen set to 0, which prohibits remote use of the PHP file_get_contents function.

    Perhaps the function can be re-coded to use a CURL interface?

    P.S. I was receiving the same error for the internal Zen Cart version check until I set Configuration->My Store->Show if version update is available to false.

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

    Default Re: Plugin Version Check: Debug-log "flood" if allow_url_fopen=0

    Mind testing this replacement?

    Code:
      function plugin_version_check_for_updates($plugin_file_id = 0, $version_string_to_compare = '')
      {
        if ($plugin_file_id == 0) return FALSE;
        $new_version_available = FALSE;
        $lookup_index = 0;
        $url = 'https://www.zen-cart.com/downloads.php?do=versioncheck' . '&id='.(int)$plugin_file_id;
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_VERBOSE, 0);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Plugin Version Check [' . (int)$plugin_file_id . '] ' . HTTP_SERVER);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        $error = curl_error($ch);
        
        if ($error > 0) {
          curl_setopt($ch, CURLOPT_URL, str_replace('tps:', 'tp:', $url));
          $response = curl_exec($ch);
          $error = curl_error($ch);
        }
        curl_close($ch);
        if ($error > 0 || $response == '') {
          $response = file_get_contents($url);
        }
        if ($response === false) {
          $response = file_get_contents(str_replace('tps:', 'tp:', $url));
        }
        if ($response === false) return false;
        
        $data = json_decode($response, true);
        if (!$data || !is_array($data)) return false;
        // compare versions
        if (strcmp($data[$lookup_index]['latest_plugin_version'], $version_string_to_compare) > 0) $new_version_available = TRUE;
        // check whether present ZC version is compatible with the latest available plugin version
        if (!in_array('v'. PROJECT_VERSION_MAJOR . '.' . PROJECT_VERSION_MINOR, $data[$lookup_index]['zcversions'])) $new_version_available = FALSE;
        return ($new_version_available) ? $data[$lookup_index] : FALSE;
      }
    .

    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.

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,475
    Plugin Contributions
    88

    Default Re: Plugin Version Check: Debug-log "flood" if allow_url_fopen=0

    Thanks for the quick update, DrByte. That seems to have corrected the issue.

  4. #4
    Join Date
    Feb 2008
    Posts
    34
    Plugin Contributions
    0

    Default Re: Plugin Version Check: Debug-log "flood" if allow_url_fopen=0

    DrByte,

    Would the replacement code you posted for lat9, contained below, also work for me? I am experiencing the same problems. I have Zen Cart 1.5.4 installed. Error log file is as follows:

    [07-Jan-2016 10:43:56 EST5EDT] PHP Warning: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /public_html/store/includes/functions/plugin_support.php on line 38
    [07-Jan-2016 10:43:56 EST5EDT] PHP Warning: file_get_contents(http://www.zen-cart.com/downloads.ph...heck&id=1292): failed to open stream: no suitable wrapper could be found in /public_html/store/includes/functions/plugin_support.php on line 38
    [07-Jan-2016 10:43:56 EST5EDT] PHP Warning: in_array() expects parameter 2 to be array, null given in /public_html/store/includes/functions/plugin_support.php on line 42

    Thank you very much for your time.

    Quote Originally Posted by DrByte View Post
    Mind testing this replacement?

    Code:
      function plugin_version_check_for_updates($plugin_file_id = 0, $version_string_to_compare = '')
      {
        if ($plugin_file_id == 0) return FALSE;
        $new_version_available = FALSE;
        $lookup_index = 0;
        $url = 'https://www.zen-cart.com/downloads.php?do=versioncheck' . '&id='.(int)$plugin_file_id;
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_VERBOSE, 0);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Plugin Version Check [' . (int)$plugin_file_id . '] ' . HTTP_SERVER);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        $error = curl_error($ch);
        
        if ($error > 0) {
          curl_setopt($ch, CURLOPT_URL, str_replace('tps:', 'tp:', $url));
          $response = curl_exec($ch);
          $error = curl_error($ch);
        }
        curl_close($ch);
        if ($error > 0 || $response == '') {
          $response = file_get_contents($url);
        }
        if ($response === false) {
          $response = file_get_contents(str_replace('tps:', 'tp:', $url));
        }
        if ($response === false) return false;
        
        $data = json_decode($response, true);
        if (!$data || !is_array($data)) return false;
        // compare versions
        if (strcmp($data[$lookup_index]['latest_plugin_version'], $version_string_to_compare) > 0) $new_version_available = TRUE;
        // check whether present ZC version is compatible with the latest available plugin version
        if (!in_array('v'. PROJECT_VERSION_MAJOR . '.' . PROJECT_VERSION_MINOR, $data[$lookup_index]['zcversions'])) $new_version_available = FALSE;
        return ($new_version_available) ? $data[$lookup_index] : FALSE;
      }

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

    Default Re: Plugin Version Check: Debug-log "flood" if allow_url_fopen=0

    The version for the upcoming v155 release can be found here ... and is compatible with v154: https://raw.githubusercontent.com/ze...in_support.php
    .

    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. v151 "500" on Cleanup Debug Log Files, PHP 5.4
    By rayw1679 in forum General Questions
    Replies: 5
    Last Post: 5 Mar 2013, 07:06 AM
  2. "Log In" "Log off" or main buttons wont enable. Css is disabled..
    By debishandbag in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 9 Jan 2011, 01:01 PM
  3. Comment out "Check for Updates" Button, "Support Site" Link, & "Version" Link?
    By g00glethis1 in forum Customization from the Admin
    Replies: 4
    Last Post: 15 Mar 2010, 06:32 AM
  4. Where is the log file when you set Debug Mode to "Log File"?
    By alicia1234 in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 1 Feb 2009, 12:05 AM
  5. "Flood" of Duplicate IP Addresses Showing On Site Simultaneously
    By chrislg1970 in forum General Questions
    Replies: 6
    Last Post: 5 Feb 2008, 06:30 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