[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 plugin_support.php

Zen Cart 源代码 plugin_support.php




下载文件

文件名: plugin_support.php
文件类型: PHP文件
文件大小: 2.32 KiB
MD5: f6b46bfee2bf3d0ac8d4b317f9542ecb

plugin_support.php - 关闭高亮
  1. <?php
  2. /**
  3.  * plugin_support.php
  4.  *
  5.  * @package functions
  6.  * @copyright Copyright 2003-2014 Zen Cart Development Team
  7.  * @copyright Portions Copyright 2003 osCommerce
  8.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  9.  * @version GIT: $Id: Author: DrByte  Tue Apr 1 15:45:22 2014 -0400 New in v1.5.3 $
  10.  */
  11. /**
  12.  * Functions to support plugin usage
  13.  */
  14.  
  15.   /**
  16.    * Check for updated version of a plugin
  17.    * Arguments:
  18.    *   $plugin_file_id = the fileid number for the plugin as hosted on the zen-cart.com plugins library
  19.    *   $version_string_to_compare = the version that I have now on my own server (will be checked against the one on the ZC server)
  20.    * If the "version string" passed to this function evaluates (see strcmp) to a value less-then-or-equal-to the one on the ZC server, FALSE will be returned.
  21.    * If the "version string" on the ZC server is greater than the version string passed to this function, this function will return an array with up-to-date information. The [link] value is the plugin page at zen-cart.com
  22.    * If no plugin_file_id is passed, or if no result is found, then FALSE will be returned.
  23.    *
  24.    * USAGE:
  25.    *   if (IS_ADMIN_FLAG) {
  26.    *     $new_version_details = plugin_version_check_for_updates(999999999, 'some_string');
  27.    *     if ($new_version_details !== FALSE) {
  28.    *       $message = '<span class="alert">' . ' - NOTE: A NEW VERSION OF THIS PLUGIN IS AVAILABLE. <a href="' . $new_version_details['link'] . '" target="_blank">[Details]</a>' . '</span>';
  29.    *     }
  30.    *   }
  31.    */
  32.   function plugin_version_check_for_updates($plugin_file_id = 0, $version_string_to_compare = '')
  33.   {
  34.     if ($plugin_file_id == 0) return FALSE;
  35.     $new_version_available = FALSE;
  36.     $lookup_index = 0;
  37.     $url = 'http://www.zen-cart.com/downloads.php?do=versioncheck' . '&id='.(int)$plugin_file_id;
  38.     $data = json_decode(file_get_contents($url), true);
  39.     // compare versions
  40.     if (strcmp($data[$lookup_index]['latest_plugin_version'], $version_string_to_compare) > 0) $new_version_available = TRUE;
  41.     // check whether present ZC version is compatible with the latest available plugin version
  42.     if (!in_array('v'. PROJECT_VERSION_MAJOR . '.' . PROJECT_VERSION_MINOR, $data[$lookup_index]['zcversions'])) $new_version_available = FALSE;
  43.     return ($new_version_available) ? $data[$lookup_index] : FALSE;
  44.   }
  45.  
  46.