function testVersionCompare() { $this->assertTrue(versionCompare('1.1.0', '1.1', '>=')); $this->assertTrue(versionCompare('1.1.5', '1.1', '>=')); $this->assertTrue(versionCompare('1.2', '1.1', '>=')); $this->assertTrue(versionCompare('1.0.0', '1.1', '<=')); $this->assertTrue(versionCompare('1.0', '1.1.0', '<=')); $this->assertTrue(versionCompare('1.0', '1.0.0', '==')); $this->assertTrue(versionCompare('1.0.*', '1.0.0', '==')); $this->assertTrue(versionCompare('1.1', '1', '==')); $this->assertTrue(versionCompare('1.3.*', '1.0.0', '>')); $this->assertTrue(versionCompare('0.9.*', '1.0.0', '<')); $this->assertFalse(versionCompare('1.1', '1', '>')); $this->assertFalse(versionCompare('1.1', '1', '<')); $a = versionCompare('1.1', '1', 'l'); $this->assertTrue($a->is('VERSION_COMPARE_OPERATOR_DOESNT_EXISTS')); }
if (!isset($module_directory)) { if (file_exists($temp_file)) { unlink($temp_file); } // Remove temp file $admin->print_error($MESSAGE['GENERIC_INVALID']); } // Check if this module is already installed // and compare versions if so $new_module_version = $module_version; $action = "install"; if (is_dir(WB_PATH . '/modules/' . $module_directory)) { if (file_exists(WB_PATH . '/modules/' . $module_directory . '/info.php')) { require WB_PATH . '/modules/' . $module_directory . '/info.php'; // Version to be installed is older than currently installed version if (versionCompare($module_version, $new_module_version, '>=')) { if (file_exists($temp_file)) { unlink($temp_file); } // Remove temp file $admin->print_error($MESSAGE['GENERIC_ALREADY_INSTALLED']); } $action = "upgrade"; } } // Set module directory $module_dir = WB_PATH . '/modules/' . $module_directory; // Make sure the module dir exists, and chmod if needed make_dir($module_dir); // Unzip module to the module dir if (isset($_POST['overwrite'])) {
if (!isset($language_code)) { if (file_exists($temp_file)) { unlink($temp_file); } // Remove temp file // Restore to correct language require WB_PATH . '/languages/' . LANGUAGE . '.php'; $admin->print_error($MESSAGE['GENERIC_INVALID_LANGUAGE_FILE']); } // Set destination for language file $language_file = WB_PATH . '/languages/' . $language_code . '.php'; $action = "install"; // Move to new location if (file_exists($language_file)) { require $language_file; if (versionCompare($language_version, $new_language_version, '>=')) { // Restore to correct language require WB_PATH . '/languages/' . LANGUAGE . '.php'; $admin->print_error($MESSAGE['GENERIC_ALREADY_INSTALLED']); } $action = "upgrade"; unlink($language_file); } rename($temp_file, $language_file); // Chmod the file change_mode($language_file, 'file'); // Load language info into DB load_language($language_file); // Restore to correct language require WB_PATH . '/languages/' . LANGUAGE . '.php'; // Print success message
<?php require 'version.php'; if (isset($argv)) { $jqm = isset($argv[1]) ? $argv[1] : ''; $jq = isset($argv[2]) ? $argv[2] : ''; $jqm_zip = "http://jquerymobile.com/resources/download/jquery.mobile-" . $jqm . ".zip"; $jqm_dir = "jquery.mobile-" . $jqm; $jq_path = "http://code.jquery.com/jquery-" . $jq . ".min.js"; chdir('jqm'); rrmdir($jqm); //get most recent version of jqm $versions = preg_grep('/^([^.])/', scandir(".")); $most_recent = ''; foreach ($versions as $version) { if (versionCompare($version, $most_recent)) { $most_recent = $version; } } mkdir($jqm); chdir($jqm); //Get the jqm zip file echo "Downloading the jQuery Mobile ZIP file...\n"; getFile($jqm_zip, $jqm_dir . ".zip"); //Extract the files to a temporary directory $zip = new ZipArchive(); if ($zip->open($jqm_dir . ".zip") === true) { $zip->extractTo($jqm_dir); $zip->close(); } else { echo "Could not extract ZIP file :(";
/** * Returns that the maximal version is exceeded. * To have a working plugin this should be false * @public * @return (bool) */ function isMaxVersionExceeded() { return versionCompare(MORGOS_VERSION, $this->_maxMorgOSVersion, '>'); }
public function doCloneTemplate() { if (!$this->request->is_POST()) { $this->redirect($this->html->getSecureURL('setting/setting', '&active=appearance')); } $this->loadLanguage('developer_tools/developer_tools'); $this->loadModel('tool/developer_tools'); $data = $this->request->post; $data['extension_category'] = 'template'; $data['extension_type'] = 'template'; $data['version'] = '1.0.0'; $data['cartversions'][0] = MASTER_VERSION . '.' . MINOR_VERSION; $data['install_php'] = 1; $data['install_sql'] = 1; $data['route'] = $data['extension_txt_id']; $data['hook_file'] = $data['extension_txt_id'] . '_hook.php'; $data['extension_admin_language_files'] = array('english'); if ($data['clone_to'] == 'extension') { //if need clone as extension we need to create tpls-list, that will be placed into main.php file of extension $data['views'] = $this->model_tool_developer_tools->getTemplateViewList($data['proto_template']); $result = $this->model_tool_developer_tools->generateExtension($data); $success_text = $this->language->get('developer_tools_text_success_generated_extension'); } else { if ($data['clone_to'] == 'core_template') { $result = $this->model_tool_developer_tools->cloneCoreTemplate($data); $success_text = $this->language->get('developer_tools_text_success_cloned_template'); } } if (!$result) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => implode('<br>', $this->model_tool_developer_tools->error), 'reset_value' => false)); } $this->session->data['success'] = $success_text; if (file_exists(DIR_BACKUP . 'developer_tools_autosave_' . $data['extension_txt_id'])) { unlink(DIR_BACKUP . 'developer_tools_autosave_' . $data['extension_txt_id']); } if (versionCompare(VERSION, '1.2.4', '>=')) { $url = $this->html->getSecureURL('design/template'); } else { $url = $this->html->getSecureURL('setting/setting', '&active=appearance&tmpl_id=' . $data['extension_txt_id']); } $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode(array('result_text' => $success_text, 'redirect_url' => $url))); }
static function updateAuto() { dbEntry_module::sync(); foreach (qg::$modules as $name => $egal) { // qg::$modules depency order is better then self::all() $E = D()->module->Entry(D()->row("SELECT * FROM module WHERE name = " . D()->quote($name))); $limit = G()->SET['qg']['module']['beta']->v ? 3 : 2; if ($E->local_version && versionCompare($E->local_version, $E->server_version, $limit)) { $E->update(); } } }
/** * @return bool */ private function _upgradeCore() { $package_info =& $this->session->data['package_info']; if (versionCompare(VERSION, $package_info['package_version'], ">=")) { $this->session->data['error'] = str_replace('%VERSION%', VERSION, $this->language->get('error_core_version')) . $package_info['package_version'] . '!'; unset($this->session->data['package_info']); $this->redirect($this->_get_begin_href()); } $corefiles = $package_info['package_content']['core']; $pmanager = new APackageManager(); /* * Commented by decision do not use it in community version. * Pasted alerts before upgrade process start. * Do not remove code yet. * //backup files $backup = new ABackup('abantecart_' . str_replace('.','',VERSION)); //interrupt if backup directory is inaccessable if ($backup->error) { $this->session->data['error'] = implode("\n", $backup->error); return false; } foreach ($corefiles as $core_file) { if (file_exists(DIR_ROOT . '/' . $core_file)) { if (!$backup->backupFile(DIR_ROOT . '/' . $core_file, false)) { return false; } } } // backup database if ($backup->dumpDatabase()) { $backup_dirname = $backup->getBackupName(); if ($backup_dirname) { if (!$backup->dumpDatabase()) { $this->session->data['error'] = implode("\n", $backup->error); return false; } if (!$backup->archive(DIR_BACKUP . $backup_dirname . '.tar.gz', DIR_BACKUP, $backup_dirname)) { $this->session->data['error'] = implode("\n", $backup->error); return false; } } else { $this->session->data['error'] = 'Error: Unknown directory name for backup.'; return false; } $install_upgrade_history = new ADataset('install_upgrade_history', 'admin'); $install_upgrade_history->addRows( array( 'date_added' => date("Y-m-d H:i:s", time()), 'name' => 'Backup before core upgrade. Core version: ' . VERSION, 'version' => VERSION, 'backup_file' => $backup_dirname . '.tar.gz', 'backup_date' => date("Y-m-d H:i:s", time()), 'type' => 'backup', 'user' => $this->user->getUsername() )); } else { $this->session->data['error'] = implode("\n", $backup->error); return false; }*/ //replace files $pmanager->replaceCoreFiles(); //run sql and php upgrade procedure files $package_dirname = $package_info['tmp_dir'] . $package_info['package_dir']; if ($pmanager->error) { $this->session->data['error'] = $pmanager->error; } /** * @var DOMNode $config */ $config = simplexml_load_string(file_get_contents($package_dirname . '/package.xml')); if (!$config) { $this->session->data['error'] = 'Error: package.xml from package content is not valid xml-file!'; unset($this->session->data['package_info']); $this->redirect($this->_get_begin_href()); } $pmanager->upgradeCore($config); $pmanager->updateCoreVersion((string) $config->version); if ($pmanager->error) { $this->session->data['error'] .= "\n" . $pmanager->error; } return true; }
/** * is extension support current core version * @param string $extension_txt_id * @param SimpleXmlElement $config * @return bool */ public function validateCoreVersion($extension_txt_id, $config) { if (!isset($config->cartversions->item)) { $this->errors[] = 'Error: config file of extension does not contain any information about versions of AbanteCart where it can be run.'; return false; } $cart_versions = array(); foreach ($config->cartversions->item as $item) { $version = (string) $item; $cart_versions[] = $version; } // check is cart version presents on extension cart version list foreach ($cart_versions as $version) { $result = versionCompare(VERSION, $version, '>='); if ($result) { return true; } } // if not - seek cart earlier version then current cart version in the list foreach ($cart_versions as $version) { $result = versionCompare($version, VERSION, '<'); if ($result) { $error_text = 'Extension <b>%s</b> written for earlier version of Abantecart (v.%s) lower that you have. '; $error_text .= 'Probably all will be OK.'; $error_text = sprintf($error_text, $extension_txt_id, implode(', ', $cart_versions)); $this->session->data['error'] = $error_text; $this->messages->saveWarning($extension_txt_id . ' extension warning', $error_text); return true; } } $error_text = '<b>%s</b> extension cannot be installed. AbanteCart version incompability. '; $error_text .= sizeof($cart_versions) > 1 ? 'Versions <b>%s</b> are required.' : 'Version <b>%s</b> is required.'; $this->errors[] = sprintf($error_text, $extension_txt_id, implode(', ', $cart_versions)); return false; }
$checkinterval = sprintf('%d', getConfig("check_new_version")); if (!isset($checkinterval)) { $checkinterval = 7; } if ($checkinterval) { $needscheck = Sql_Fetch_Row_Query(sprintf('select date_add(value,interval %d day) < now() as needscheck from %s where item = "updatelastcheck"', $checkinterval, $tables["config"])); if ($needscheck[0]) { ini_set("user_agent", NAME . " (PHPlist version " . VERSION . ")"); ini_set("default_socket_timeout", 5); if ($fp = @fopen("http://www.phplist.com/files/LATESTVERSION", "r")) { $latestversion = @fgets($fp); $latestversion = preg_replace("/[^\\.\\d]/", "", $latestversion); @fclose($fp); $thisversion = VERSION; $thisversion = preg_replace("/[^\\.\\d]/", "", $thisversion); if (!empty($latestversion) && versionCompare($latestversion, $thisversion)) { print '<div align=center><font color=green size=2>'; print $GLOBALS['I18N']->get('A new version of PHPlist is available!'); print '</font><br/>'; print '<br/>' . $GLOBALS['I18N']->get('The new version may have fixed security issues,<br/>so it is recommended to upgrade as soon as possible'); print '<br/>' . $GLOBALS['I18N']->get('Your version') . ': <b>' . $thisversion . '</b>'; print '<br/>' . $GLOBALS['I18N']->get('Latest version') . ': <b>' . $latestversion . '</b><br/> '; print '<a href="http://www.phplist.com/files/changelog">' . $GLOBALS['I18N']->get('View what has changed') . '</a> '; print '<a href="http://www.phplist.com/files/phplist-' . $latestversion . '.tgz">' . $GLOBALS['I18N']->get('Download') . '</a></div>'; } } Sql_Query(sprintf('replace into %s (item,value,editable) values("updatelastcheck",now(),0)', $tables["config"])); } } if (!stristr($_SERVER['HTTP_USER_AGENT'], 'firefox')) { print '<div align="right"><a href="http://www.spreadfirefox.com/?q=affiliates&id=131358&t=81"><img border="0" alt="Get Firefox!" title="Get Firefox!" src="images/getff.gif"/></a></div>';
function preCheckAddon($temp_addon_file) { /** * This funtion performs pretest upfront of the Add-On installation process. * The requirements can be specified via the array $PRECHECK which needs to * be defined in the optional Add-on file precheck.php. */ global $database, $admin, $TEXT, $HEADING, $MESSAGE; // path to the temporary Add-on folder $temp_path = WB_PATH . '/temp/unzip'; // check if file precheck.php exists for the Add-On uploaded via WB installation routine if (!file_exists($temp_path . '/precheck.php')) { return; } // unset any previous declared PRECHECK array unset($PRECHECK); // include Add-On precheck.php file include $temp_path . '/precheck.php'; // check if there are any Add-On requirements to check for if (!(isset($PRECHECK) && count($PRECHECK) > 0)) { return; } // sort precheck array $PRECHECK = sortPreCheckArray($PRECHECK); $failed_checks = 0; $msg = array(); // check if specified addon requirements are fullfilled foreach ($PRECHECK as $key => $value) { switch ($key) { case 'WB_VERSION': if (isset($value['VERSION'])) { // obtain operator for string comparison if exist $operator = isset($value['OPERATOR']) && trim($value['OPERATOR']) != '' ? $value['OPERATOR'] : '>='; // compare versions and extract actual status $status = versionCompare(WB_VERSION, $value['VERSION'], $operator); $msg[] = array('check' => 'WB-' . $TEXT['VERSION'] . ': ', 'required' => htmlentities($operator) . $value['VERSION'], 'actual' => WB_VERSION, 'status' => $status); // increase counter if required if (!$status) { $failed_checks++; } } break; case 'WB_ADDONS': if (is_array($PRECHECK['WB_ADDONS'])) { foreach ($PRECHECK['WB_ADDONS'] as $addon => $values) { if (is_array($values)) { // extract module version and operator $version = isset($values['VERSION']) && trim($values['VERSION']) != '' ? $values['VERSION'] : ''; $operator = isset($values['OPERATOR']) && trim($values['OPERATOR']) != '' ? $values['OPERATOR'] : '>='; } else { // no version and operator specified (only check if addon exists) $addon = strip_tags($values); $version = ''; $operator = ''; } // check if addon is listed in WB database $table = TABLE_PREFIX . 'addons'; $sql = "SELECT * FROM `{$table}` WHERE `directory` = '" . addslashes($addon) . "'"; $results = $database->query($sql); $status = false; $addon_status = $TEXT['NOT_INSTALLED']; if ($results && ($row = $results->fetchRow())) { $status = true; $addon_status = $TEXT['INSTALLED']; // compare version if required if ($version != '') { $status = versionCompare($row['version'], $version, $operator); $addon_status = $row['version']; } } // provide addon status $msg[] = array('check' => ' ' . $TEXT['ADDON'] . ': ' . htmlentities($addon), 'required' => $version != '' ? $operator . ' ' . $version : $TEXT['INSTALLED'], 'actual' => $addon_status, 'status' => $status); // increase counter if required if (!$status) { $failed_checks++; } } } break; case 'PHP_VERSION': if (isset($value['VERSION'])) { // obtain operator for string comparison if exist $operator = isset($value['OPERATOR']) && trim($value['OPERATOR']) != '' ? $value['OPERATOR'] : '>='; // compare versions and extract actual status $status = versionCompare(PHP_VERSION, $value['VERSION'], $operator); $msg[] = array('check' => 'PHP-' . $TEXT['VERSION'] . ': ', 'required' => htmlentities($operator) . ' ' . $value['VERSION'], 'actual' => PHP_VERSION, 'status' => $status); // increase counter if required if (!$status) { $failed_checks++; } } break; case 'PHP_EXTENSIONS': if (is_array($PRECHECK['PHP_EXTENSIONS'])) { foreach ($PRECHECK['PHP_EXTENSIONS'] as $extension) { $status = extension_loaded(strtolower($extension)); $msg[] = array('check' => ' ' . $TEXT['EXTENSION'] . ': ' . htmlentities($extension), 'required' => $TEXT['INSTALLED'], 'actual' => $status ? $TEXT['INSTALLED'] : $TEXT['NOT_INSTALLED'], 'status' => $status); // increase counter if required if (!$status) { $failed_checks++; } } } break; case 'PHP_SETTINGS': if (is_array($PRECHECK['PHP_SETTINGS'])) { foreach ($PRECHECK['PHP_SETTINGS'] as $setting => $value) { $actual_setting = ($temp = ini_get($setting)) ? $temp : 0; $status = $actual_setting == $value; $msg[] = array('check' => ' ' . $setting, 'required' => $value, 'actual' => $actual_setting, 'status' => $status); // increase counter if required if (!$status) { $failed_checks++; } } } break; case 'CUSTOM_CHECKS': if (is_array($PRECHECK['CUSTOM_CHECKS'])) { foreach ($PRECHECK['CUSTOM_CHECKS'] as $key => $values) { $status = true === array_key_exists('STATUS', $values) ? $values['STATUS'] : false; $msg[] = array('check' => $key, 'required' => $values['REQUIRED'], 'actual' => $values['ACTUAL'], 'status' => $status); } // increase counter if required if (!$status) { $failed_checks++; } } break; } } // leave if all requirements are fullfilled if ($failed_checks == 0) { return; } // output summary table with requirements not fullfilled echo <<<EOT <h2>{$HEADING['ADDON_PRECHECK_FAILED']}</h2> <p>{$MESSAGE['ADDON']['PRECHECK_FAILED']}</p> <table width="700px" cellpadding="4" border="0" style="margin: 0.5em; border-collapse: collapse; border: 1px solid silver;"> <tr> <th>{$TEXT['REQUIREMENT']}:</th> <th>{$TEXT['REQUIRED']}:</th> <th>{$TEXT['CURRENT']}:</th> </tr> EOT; foreach ($msg as $check) { echo '<tr>'; $style = $check['status'] ? 'color: #46882B;' : 'color: #C00;'; foreach ($check as $key => $value) { if ($key == 'status') { continue; } echo '<td style="' . $style . '">' . $value . '</td>'; } echo '</tr>'; } echo '</table>'; // delete the temp unzip directory rm_full_dir($temp_path); // delete the temporary zip file of the Add-on if (file_exists($temp_addon_file)) { unlink($temp_addon_file); } // output status message and die $admin->print_error(''); }
function initAllExtensions() { $this->extensions = array(); $files = scandir('extensions'); foreach ($files as $file) { $extension = array(); $extensionDir = 'extensions/' . $file; if ($file[0] != '.') { if (is_dir($extensionDir)) { if (file_exists($extensionDir . '/extension.php')) { if (is_file($extensionDir . '/extension.php')) { include $extensionDir . '/extension.php'; $minVersion = $extension['general']['minversion']; $maxVersion = $extension['general']['maxversion']; $extensionID = $extension['general']['ID']; $isCompatibleFunction = $extension['iscompatible_function']; if ($isCompatibleFunction != false) { if (!$isCompatibleFunction($this->genDB)) { $compatible = false; } else { $compatible = true; } } else { $compatible = true; } if ($compatible) { if ($extension['need_install'] == true) { $isInstalledFunction = $extension['is_installed_function']; $installable = $isInstalledFunction($this->genDB) ? false : true; $extension['is_installed'] = $isInstalledFunction($this->genDB); } else { $installable = false; //$extension['is_isntalled'] } $extension['installable'] = $installable; if (versionCompare(MORGOS_VERSION, $minVersion, '<') || versionCompare(MORGOS_VERSION, $maxVersion, '>')) { $status = 'incompatible'; } elseif ($this->extensionIsLoaded($extensionID)) { $status = 'loaded'; } elseif ($installable == true) { $status = 'not_installed'; } else { $status = 'ok'; if (array_key_exists('required_file', $extension)) { foreach ($extension['required_file'] as $reqFile) { if (!file_exists($extensionDir . '/' . $reqFile)) { $status = 'missing_file'; } } } } } else { $status = 'incompatible'; } $extension['status'] = $status; $extension['extension_dir'] = $extensionDir; $ID = $extension['general']['ID']; if (!array_key_exists($ID, $this->extensions)) { $this->extensions[$ID] = $extension; } else { trigger_error('ERROR: ' . $this->i10nMan->translate('Extension hasn\'t an unique ID')); } } } } } } }
/** * @return bool */ private function _upgradeCore() { $package_info =& $this->session->data['package_info']; if (versionCompare(VERSION, $package_info['package_version'], ">=")) { $this->session->data['error'] = str_replace('%VERSION%', VERSION, $this->language->get('error_core_version')) . $package_info['package_version'] . '!'; unset($this->session->data['package_info']); $this->redirect($this->_get_begin_href()); } $corefiles = $package_info['package_content']['core']; $pmanager = new APackageManager(); //#1 backup files $backup = new ABackup('abantecart_' . VERSION); foreach ($corefiles as $core_file) { if (file_exists(DIR_ROOT . '/' . $core_file)) { if (!$backup->backupFile(DIR_ROOT . '/' . $core_file, false)) { return false; } } } //#2 backup database if ($backup->dumpDatabase()) { $backup_dirname = $backup->getBackupName(); if ($backup_dirname) { if (!$backup->dumpDatabase()) { $this->session->data['error'] = $backup->error; return false; } if (!$backup->archive(DIR_BACKUP . $backup_dirname . '.tar.gz', DIR_BACKUP, $backup_dirname)) { return false; } } else { return false; } $install_upgrade_history = new ADataset('install_upgrade_history', 'admin'); $install_upgrade_history->addRows(array('date_added' => date("Y-m-d H:i:s", time()), 'name' => 'Backup before core upgrade. Core version: ' . VERSION, 'version' => VERSION, 'backup_file' => $backup_dirname . '.tar.gz', 'backup_date' => date("Y-m-d H:i:s", time()), 'type' => 'backup', 'user' => $this->user->getUsername())); } else { $this->session->data['error'] = $backup->error; return false; } //#3 replace files $pmanager->replaceCoreFiles(); //#4 run sql and php upgare procedure files $package_dirname = $package_info['tmp_dir'] . $package_info['package_dir']; /** * @var SimpleXmlElement $config */ $config = simplexml_load_string(file_get_contents($package_dirname . '/package.xml')); if (!$config) { $this->session->data['error'] = 'Error: package.xml from package content is not valid xml-file!'; unset($this->session->data['package_info']); $this->redirect($this->_get_begin_href()); } $pmanager->upgradeCore($config); $pmanager->updateCoreVersion((string) $config->version); return true; }
<h2><?php echo $i10nMan->translate('Required'); ?> </h2> <p><?php echo $i10nMan->translate('PHP Version 4.0.0 or higher'); ?> : <?php if (versionCompare(PHP_VERSION, '4.0.0', '>=')) { echo '<span class="ok">' . $i10nMan->translate('Yes') . '</span>'; } else { echo '<span class="notok">' . $i10nMan->translate('No') . '</span>'; $canrun = false; } if (versionCompare(PHP_VERSION, '4.1.0', '<') and versionCompare(PHP_VERSION, '4.0.0', '>=')) { echo ' <span class="warning"> ' . $i10nMan->translate('MorgOS is untested on PHP lower than PHP 4.1.0, if you encouter problems please report this. ') . '</span>'; } ?> </p> <p><?php echo $i10nMan->translate('Databases available'); ?> </p> <?php $DBMan = new genericDatabase($i10nMan); $supported = $DBMan->getAllSupportedDatabases(); $db = false; echo '<ul>'; foreach ($supported as $key => $support) { $db = true;
/** * Check if this template is already installed * and in this case compare versions * */ $new_template_version = $template_version; if (is_dir(LEPTON_PATH . '/templates/' . $template_directory)) { if (file_exists(LEPTON_PATH . '/templates/' . $template_directory . '/info.php')) { require_once LEPTON_PATH . '/templates/' . $template_directory . '/info.php'; $temp_error = false; $temp_msg = ""; /** * Version to be installed is older than currently installed version * */ if (versionCompare($template_version, $new_template_version, '>=')) { $temp_error = true; $temp_msg = $MESSAGE['GENERIC_ALREADY_INSTALLED']; } /** * Additional tests for required vars. * */ if (!isset($template_license) || !isset($template_author) || !isset($template_directory) || !isset($template_author) || !isset($template_version) || !isset($template_function)) { $temp_error = true; $temp_msg = $MESSAGE["TEMPLATES_MISSING_PARTS_NOTICE"]; } if (true === $temp_error) { if (file_exists($temp_file)) { unlink($temp_file); }
<?php if (preg_match('/^cms\\.(backend|cont|layout)\\./', $M->name)) { echo D()->one("SELECT count(*) FROM page WHERE module = " . D()->quote($M->name)); } ?> <td style="text-align:center"> <input onclick="moduleSetAccess(this,'<?php echo $M; ?> ');" <?php echo $M->access ? 'checked' : ''; ?> type=checkbox> <td> <?php if ($M->server_time && versionCompare($M->local_version, $M->server_version, 3)) { ?> <?php if ($M->checkRemoteFolder()) { ?> <a class=updateBtn onclick="return moduleUpdate(this,'<?php echo $M; ?> ');" href=""> <?php echo $M->local_time ? 'update' : 'installieren'; ?> </a> <?php } else { echo 'not found!';
function testVersionCompare() { $result = versionCompare('0.0.1', '0.0.2', ">"); $shouldReturn = false; testResult("A comparing error 1", $result !== $shouldReturn); $result = versionCompare('0.0.1', '0.0.2', "<"); $shouldReturn = true; testResult("A comparing error 2", $result !== $shouldReturn); $result = versionCompare('0.0.1', '0.0.2', "=="); $shouldReturn = false; testResult("A comparing error 3", $result !== $shouldReturn); $result = versionCompare('0.0.1', '0.0.2', ">="); $shouldReturn = false; testResult("A comparing error 4", $result !== $shouldReturn); $result = versionCompare('0.0.1', '0.0.2', "<="); $shouldReturn = true; testResult("A comparing error 5", $result !== $shouldReturn); $result = versionCompare('1.0.1', '1.1', "<"); $shouldReturn = true; testResult("A comparing error 6", $result !== $shouldReturn); $result = versionCompare('0.0.1', '0.0.*', "=="); $shouldReturn = true; testResult("A comparing error 7, probably in * comparision", $result !== $shouldReturn); $result = versionCompare('0.0.1', '0.0.1', "<="); $shouldReturn = true; testResult("A comparing error 8", $result !== $shouldReturn); $result = versionCompare('1.0.1', '0.1.2', ">"); $shouldReturn = true; testResult("A comparing error 9", $result !== $shouldReturn); $result = versionCompare('1.2.*', '1', "=="); $shouldReturn = true; testResult("A comparing error 10", $result !== $shouldReturn); $result = versionCompare('1.2.*', '1', ">"); $shouldReturn = false; testResult("A comparing error 11", $result !== $shouldReturn); $result = versionCompare('1.1', '1.0', "!="); $shouldReturn = true; testResult("A comparing error 12", $result !== $shouldReturn); }
private function _getBlockInfo4Xml($block_id) { $block_id = (int) $block_id; $sql = "SELECT b.block_id as block_id,\n\t\t\t\t b.block_txt_id as block_txt_id,\n\t\t\t\t b.controller as controller,\n\t\t\t\t bt.parent_block_id as parent_block_id,\n\t\t\t\t bt.template as template,\n\t\t\t\t pb.block_txt_id as parent_block_txt_id\n\t\t\t FROM " . DB_PREFIX . "blocks as b\n\t\t\t LEFT JOIN " . DB_PREFIX . "block_templates as bt ON (b.block_id = bt.block_id)\n\t\t\t LEFT JOIN " . DB_PREFIX . "blocks as pb ON (pb.block_id = bt.parent_block_id)\n\t\t\t WHERE b.block_id = " . $block_id; $result = $this->db->query($sql); $output = array(); foreach ($result->rows as $row) { $output['block_txt_id'] = $row['block_txt_id']; if ($this->template_id_src != 'default' || versionCompare(VERSION, '1.2.4', '<')) { $output['controller'] = $row['controller']; } if (($this->template_id_src != 'default' || versionCompare(VERSION, '1.2.4', '<')) && $this->placeholder_block_id == $row['parent_block_id']) { $output['templates']['template'][] = array('parent_block' => $row['parent_block_txt_id'], 'template_name' => $row['template']); // if we found needed template - interrupting loop break; } } return $output; }
return true; } else { if ($ver1[3] < $ver2[3]) { return false; } else { //tie if ($ver1[4] >= $ver2[4]) { return true; } else { if ($ver1[4] < $ver2[4]) { return false; } } } } } } } } } } } $ALL_JQUERY_VERSIONS = array("1.0.1" => "1.6.4", "1.1.2" => "1.7.2", "1.2.1" => "1.8.3", "1.3.2" => "1.9.1", "1.4.5" => "1.11.1"); $VERSION_LIST = array_keys($ALL_JQUERY_VERSIONS); $VERSION_LIST = array_reverse($VERSION_LIST); $JQM_VERSION = ""; foreach ($VERSION_LIST as $VERSION) { if (versionCompare($VERSION, $JQM_VERSION)) { $JQM_VERSION = $VERSION; } }
<h1>Comunidad PHPlist</h1> <p><b>Última versión</b><br/> Cuando vaya a presentar una notificación de errores asegúrese de que tiene la última versión.<br/> <?php ini_set("user_agent", NAME . " (PHPlist version " . VERSION . ")"); ini_set("default_socket_timeout", 5); if ($fp = @fopen("http://www.phplist.com/files/LATESTVERSION", "r")) { $latestversion = fgets($fp); $thisversion = VERSION; $thisversion = str_replace("-dev", "", $thisversion); if (versionCompare($thisversion, $latestversion)) { print "<font color=green size=2>Enhorabuena, está\n utilizando la última versión</font>"; } else { print "<font color=green size=2>No está utilizando la última versi&oacut;n</font>"; print "<br/>Su versi&oacut;n: <b>" . $thisversion . "</b>"; print "<br/>Última versión: <b>" . $latestversion . "</b> "; print '<a href="http://www.phplist.com/files/changelog">Ver los cambios</a> '; print '<a href="http://www.phplist.com/files/phplist-' . $latestversion . '.tgz">Descargar</a>'; } } else { print "<br/>Ver cuál es la última versión: <a href=http://www.phplist.com/files>aquí</a>"; } ?> <p>PHPlist nació a principios del año 2000 como un pequeño programa para el <a href="http://www.nationaltheatre.org.uk" target="_blank">National Theatre</a>, la compañía de teatro nacional de Gran Bretaña. Desde entonces ha crecido hasta convertirse en un completo sistema de gestión de relaciones con los clientes, y
/** * this method checks for updates on remote server * common/ant controller calls it every page load * @param bool $mode * @internal param array $extension_list * @return array|boolean */ public function check4Updates($mode = false) { $need_to_download = true; $extension_list = $this->loadExtensionsList(); $this->updates_path = is_writable(DIR_APP_SECTION . "system/") ? DIR_APP_SECTION . "system/" : sys_get_temp_dir() . "/"; $coreversion = MASTER_VERSION . '.' . MINOR_VERSION; // checks for downloaded xml-file and download it when it needs (one per day) if (file_exists($this->updates_path . 'updates.xml')) { $mtime = date("m/d/Y", filemtime($this->updates_path . "updates.xml")); $need_to_download = date("m/d/Y", time()) != $mtime ? true : false; $need_to_download = !filesize($this->updates_path . "updates.xml") ? true : $need_to_download; } if ($need_to_download) { $success = $this->getUpdateInfo(); if ($success === false) { file_put_contents($this->updates_path . "updates.xml", '<updates></updates>'); return false; } } else { // if file exists locally and session not expired - do nothing if (isset($this->session->data['extension_updates'])) { //return true; } } $this->session->data['extension_updates'] = array(); $updates_info = ''; if (file_exists($this->updates_path . "updates.xml") && filesize($this->updates_path . "updates.xml") > 20) { $updates_info = @simplexml_load_file($this->updates_path . "updates.xml"); } if ($updates_info) { $updates_info = $updates_info->extensions->extension; foreach ($updates_info as $ext) { $extension_id = strtolower((string) $ext->id); if (!$extension_list[$extension_id]) { continue; // check next extension in xml tree } $versions = array(); foreach ($ext->coreversions->item as $version) { $version = (string) $version; $version = explode('.', $version); $version = (int) $version[0] . '.' . (int) $version[1]; $versions[] = $version; } asort($versions, SORT_DESC); $versions = array_unique($versions); $result = true; if (!in_array($coreversion, $versions)) { foreach ($versions as $version) { $result = versionCompare($version, $coreversion, '<'); if ($result) { break; } } } if (!$result) { continue; // check next extension in xml tree } if (versionCompare($extension_list[$extension_id]['version'], (string) $ext->version, '<')) { $action = array('text' => $this->html->buildButton(array('name' => 'btn_upgrade', 'text' => $this->language->get('button_upgrade'), 'style' => 'button1')), 'link' => AEncryption::addEncoded_stid((string) $ext->url)); $this->session->data['extension_updates'][$extension_id] = array('id' => $extension_id, 'url' => (string) $ext->url, 'new_version' => (string) $ext->version, 'action' => $action); $this->session->data['extension_updates'][$extension_id] = array_merge($this->session->data['extension_updates'][$extension_id], $extension_list[$extension_id]); } } } // save notice in messages if we got new update data if (sizeof($this->session->data['extension_updates']) && $need_to_download) { $this->load->language('tool/updater'); foreach ($this->session->data['extension_updates'] as $extension_info) { $message_text = str_replace('%EXTENSION%', $extension_info['name'], $this->language->get('text_notice_text')); $url = AEncryption::addEncoded_stid($extension_info['url']); $message_text = str_replace('%LINK%', '<a onclick="window.open(\'' . $url . '\',\'marketplace\',\'width=700,height=700,resizable=yes,scrollbars=yes\');">' . $extension_info['url'] . '</a>', $message_text); $this->messages->saveNotice(str_replace('%EXTENSION%', $extension_info['name'], $this->language->get('text_notice_title')), $message_text); } } return true; }