diff --git a/admin/easypopulate_4.php b/admin/easypopulate_4.php index 52fd635..b3347d1 100644 --- a/admin/easypopulate_4.php +++ b/admin/easypopulate_4.php @@ -78,8 +78,17 @@ //$sql_fail_test == true; // used to cause an sql error on new product upload - tests error handling & logs /* Test area end */ +$curver = '4.0.33'; +$message = ''; +if (IS_ADMIN_FLAG) { + $new_version_details = plugin_version_check_for_updates(2068, $curver); + if ($new_version_details !== FALSE) { + $message = '' . ' - NOTE: A NEW VERSION OF THIS PLUGIN IS AVAILABLE. [Details]' . ''; + } +} + // Current EP Version - Modded by mc12345678 after Chadd had done so much -$curver = '4.0.33 - Beta 02-29-2016'; +$curver = $curver . ' - Beta 02-29-2016' . $message; $display_output = ''; // results of import displayed after script run $ep_dltype = NULL; $ep_stack_sql_error = false; // function returns true on any 1 error, and notifies user of an error diff --git a/admin/includes/functions/extra_functions/easypopulate_4_functions.php b/admin/includes/functions/extra_functions/easypopulate_4_functions.php index 52fb6f9..e051744 100644 --- a/admin/includes/functions/extra_functions/easypopulate_4_functions.php +++ b/admin/includes/functions/extra_functions/easypopulate_4_functions.php @@ -213,6 +213,74 @@ function zen_get_sub_categories(&$categories, $categories_id) { } } +if (!function_exists('plugin_version_check_for_updates')) { +/** + * plugin_support.php + * + * @package functions + * @copyright Copyright 2003-2015 Zen Cart Development Team + * @copyright Portions Copyright 2003 osCommerce + * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 + * @version $Id: Modified in v1.5.5 $ + */ +/** + * Functions to support plugin usage + */ + /** + * Check for updated version of a plugin + * Arguments: + * $plugin_file_id = the fileid number for the plugin as hosted on the zen-cart.com plugins library + * $version_string_to_compare = the version that I have now on my own server (will be checked against the one on the ZC server) + * 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. + * 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 + * If no plugin_file_id is passed, or if no result is found, then FALSE will be returned. + * + * USAGE: + * if (IS_ADMIN_FLAG) { + * $new_version_details = plugin_version_check_for_updates(999999999, 'some_string'); + * if ($new_version_details !== FALSE) { + * $message = '' . ' - NOTE: A NEW VERSION OF THIS PLUGIN IS AVAILABLE. [Details]' . ''; + * } + * } + */ + 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; + } + +} + function ep_4_get_uploaded_file($filename) { if (isset($_FILES[$filename])) { //global $_FILES; diff --git a/changelog.txt b/changelog.txt index 6a97e5f..16016bb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -277,4 +277,5 @@ Added a .htaccess file that only includes permission for .csv and .txt files based off of the admin/.htaccess file available from ZC 1.5.4. Updated instructions to add some additional considerations. - + EP4 had been submitted for download, download from ZC is available from: + https://www.zen-cart.com/downloads.php?do=file&id=2068