/** * Perform installation. */ function execute() { define('RUNNING_UPGRADE', 1); $templateMgr = TemplateManager::getManager($this->_request); $installer = new Upgrade($this->_data); // FIXME Use logger? // FIXME Mostly common with InstallForm if ($installer->execute()) { if (!$installer->wroteConfig()) { // Display config file contents for manual replacement $templateMgr->assign(array('writeConfigFailed' => true, 'configFileContents' => $installer->getConfigContents())); } $templateMgr->assign('notes', $installer->getNotes()); $templateMgr->assign('newVersion', $installer->getNewVersion()); $templateMgr->display('install/upgradeComplete.tpl'); } else { switch ($installer->getErrorType()) { case INSTALLER_ERROR_DB: $this->dbInstallError($installer->getErrorMsg()); break; default: $this->installError($installer->getErrorMsg()); break; } } $installer->destroy(); }
public function __construct() { parent::__construct(); // Load cache $this->cache = new Cache(); // Load session $this->session = new Session(); // Load database $this->db = new Database(); $upgrade = new Upgrade(); $this->auth = new Auth(); $this->session = Session::instance(); $this->auth->auto_login(); if (!$this->auth->logged_in('login')) { url::redirect('login'); } // Set Table Prefix $this->table_prefix = Kohana::config('database.default.table_prefix'); //fetch latest release of ushahidi $this->release = $upgrade->_fetch_core_release(); if (!empty($this->release)) { $this->template->version = $this->_get_release_version(); $this->template->critical = $this->release->critical; } // Get Session Information $this->user = new User_Model($_SESSION['auth_user']->id); // Check if user has the right to see the admin panel if (admin::admin_access($this->user) == FALSE) { // This user isn't allowed in the admin panel url::redirect('/'); } $this->template->admin_name = $this->user->name; // Retrieve Default Settings $this->template->site_name = Kohana::config('settings.site_name'); $this->template->mapstraction = Kohana::config('settings.mapstraction'); $this->template->api_url = Kohana::config('settings.api_url'); // Javascript Header $this->template->map_enabled = FALSE; $this->template->flot_enabled = FALSE; $this->template->treeview_enabled = FALSE; $this->template->protochart_enabled = FALSE; $this->template->colorpicker_enabled = FALSE; $this->template->editor_enabled = FALSE; $this->template->js = ''; $this->template->form_error = FALSE; // Initialize some variables for raphael impact charts $this->template->raphael_enabled = FALSE; $this->template->impact_json = ''; // Generate main tab navigation list. $this->template->main_tabs = admin::main_tabs(); // Generate sub navigation list (in default layout, sits on right side). $this->template->main_right_tabs = admin::main_right_tabs($this->user); $this->template->this_page = ""; // Load profiler // $profiler = new Profiler; }
public function __construct() { parent::__construct(); // Load cache $this->cache = new Cache(); // Load session $this->session = new Session(); // Load database $this->db = new Database(); $upgrade = new Upgrade(); $this->auth = new Auth(); $this->session = Session::instance(); $this->auth->auto_login(); if (!$this->auth->logged_in('admin') && !$this->auth->logged_in('login')) { url::redirect('login'); } //fetch latest version of ushahidi $version_number = $upgrade->_fetch_core_version(); $this->template->version = $version_number; // Get version coded numbers to display $this->template->code_version = Kohana::config('version.ushahidi_version'); $this->template->db_version = Kohana::config('version.ushahidi_db_version'); // Get version from the db $this->template->actual_code_version = Kohana::config('settings.ushahidi_version'); $this->template->actual_db_version = Kohana::config('settings.db_version'); // Get Session Information $user = new User_Model($_SESSION['auth_user']->id); $this->template->admin_name = $user->name; // Retrieve Default Settings $this->template->site_name = Kohana::config('settings.site_name'); $this->template->mapstraction = Kohana::config('settings.mapstraction'); $this->template->api_url = Kohana::config('settings.api_url'); // Javascript Header $this->template->map_enabled = FALSE; $this->template->flot_enabled = FALSE; $this->template->treeview_enabled = FALSE; $this->template->protochart_enabled = FALSE; $this->template->colorpicker_enabled = FALSE; $this->template->editor_enabled = FALSE; $this->template->js = ''; // Initialize some variables for raphael impact charts $this->template->raphael_enabled = FALSE; $this->template->impact_json = ''; // Generate main tab navigation list. Key = Page (/admin/???), Val = Tab Name $tabs = array('dashboard' => Kohana::lang('ui_admin.dashboard'), 'reports' => Kohana::lang('ui_admin.reports'), 'comments' => Kohana::lang('ui_admin.comments'), 'messages' => Kohana::lang('ui_admin.messages'), 'feedback' => Kohana::lang('ui_admin.feedback'), 'stats' => Kohana::lang('ui_admin.stats'), 'apilogs' => Kohana::lang('ui_admin.api_logs')); if (Kohana::config('config.enable_mhi') == TRUE && Kohana::config('settings.subdomain') == '') { $tabs['mhi'] = Kohana::lang('ui_admin.mhi'); } $this->template->tabs = $tabs; // Load profiler // $profiler = new Profiler; }
public function __construct() { parent::__construct(); // Load cache $this->cache = new Cache(); // Load session $this->session = new Session(); // Load database $this->db = new Database(); $upgrade = new Upgrade(); $this->auth = new Auth(); $this->session = Session::instance(); $this->auth->auto_login(); if (!$this->auth->logged_in('login')) { url::redirect('login'); } //fetch latest version of ushahidi $version_number = $upgrade->_fetch_core_version(); $this->template->version = $version_number; // Get Session Information $this->user = new User_Model($_SESSION['auth_user']->id); $this->template->admin_name = $this->user->name; // Retrieve Default Settings $this->template->site_name = Kohana::config('settings.site_name'); $this->template->mapstraction = Kohana::config('settings.mapstraction'); $this->template->api_url = Kohana::config('settings.api_url'); // Javascript Header $this->template->map_enabled = FALSE; $this->template->flot_enabled = FALSE; $this->template->treeview_enabled = FALSE; $this->template->protochart_enabled = FALSE; $this->template->colorpicker_enabled = FALSE; $this->template->editor_enabled = FALSE; $this->template->js = ''; $this->template->form_error = FALSE; // Initialize some variables for raphael impact charts $this->template->raphael_enabled = FALSE; $this->template->impact_json = ''; // Generate main tab navigation list. $this->template->main_tabs = admin::main_tabs(); // Generate sub navigation list (in default layout, sits on right side). $this->template->main_right_tabs = admin::main_right_tabs($this->auth); // Load profiler // $profiler = new Profiler; }
/** * * Downloads the latest ushahidi file. * Extracts the compressed folder. * Delete the folders that needs to be preserved. * Delete the downloaded ushahidi file. * Delete the extracted ushahidi file. * */ private function _do_upgrade() { $upgrade = new Upgrade(); $url = "http://download.ushahidi.com/ushahidi.zip"; $working_dir = "media/uploads/"; $zip_file = "media/uploads/ushahidi.zip"; //download the latest ushahidi $latest_ushahidi = $upgrade->download_ushahidi($url); //download went successful if ($upgrade->success) { $upgrade->write_to_file($latest_ushahidi, $zip_file); } //extract compressed file if ($upgrade->success) { $upgrade->unzip_ushahidi($zip_file, $working_dir); } if ($upgrade->success) { //remove delete database.php and config.php files. we don't want to overwrite them. unlink($working_dir . "ushahidi/application/config/database.php"); unlink($working_dir . "ushahidi/application/config/config.php"); $upgrade->remove_recursively($working_dir . "ushahidi/application/cache"); $upgrade->remove_recursively($working_dir . "ushahidi/application/logs"); $upgrade->remove_recursively($working_dir . "ushahidi/media/uploads"); } if ($upgrade->success) { $upgrade->log[] = sprintf("Copying files..."); $upgrade->copy_recursively($working_dir . "ushahidi", "."); $upgrade->log[] = sprintf("Successfully copied files"); } if ($upgrade->success) { $upgrade->log[] = sprintf("Upgrading tables..."); if ($this->_upgrade_tables()) { $upgrade->log[] = sprintf("Tables upgrade went successful"); } else { $upgrade->errors[] = sprintf("Tables upgrade failed"); } } if ($upgrade->success) { $upgrade->remove_recursively($working_dir . "ushahidi"); unlink($zip_file); $upgrade->log[] = sprintf("Upgrade went successful."); } return $upgrade; }
/** * Run upgrade script. */ function upgrade() { $pretend = false; // isset($this->argv[1]) && $this->argv[1] == 'pretend'; $installer = new Upgrade(array('manualInstall' => $pretend)); $installer->setLogger($this); if ($installer->execute()) { if (count($installer->getNotes()) > 0) { printf("\nRelease Notes\n"); printf("----------------------------------------\n"); foreach ($installer->getNotes() as $note) { printf("%s\n\n", $note); } } if ($pretend) { if (count($installer->getSQL()) > 0) { printf("\nSQL\n"); printf("----------------------------------------\n"); foreach ($installer->getSQL() as $sql) { printf("%s\n\n", $sql); } } } else { $newVersion =& $installer->getNewVersion(); printf("Successfully upgraded to version %s\n", $newVersion->getVersionString()); } } else { printf("ERROR: Upgrade failed: %s\n", $installer->getErrorString()); } }
/** * Run upgrade script. */ function upgrade() { $installer = new Upgrade(array()); $installer->setLogger($this); if ($installer->execute()) { if (count($installer->getNotes()) > 0) { printf("\nRelease Notes\n"); printf("----------------------------------------\n"); foreach ($installer->getNotes() as $note) { printf("%s\n\n", $note); } } $newVersion =& $installer->getNewVersion(); printf("Successfully upgraded to version %s\n", $newVersion->getVersionString()); } else { printf("ERROR: Upgrade failed: %s\n", $installer->getErrorString()); } }
return 1; } } function execute_php($php_file, $upgrade, $path_file_log) { preg_match("/\\/(\\d+\\.\\d+\\.\\d+)/", $php_file, $version); $upgrade->create_php_upgrade_object($php_file, $version[1]); $ret = $upgrade->php->end_upgrade($path_file_log); $upgrade->destroy_php_upgrade_object(); return $ret; } $path_class = '/usr/share/ossim/include/'; $path_log = '/var/log/ossim/'; ini_set('include_path', $path_class); require_once 'av_init.php'; $upgrade = new Upgrade(); echo "\n\nDate: " . date("j/m/Y") . "\n\n"; echo "-------------------------------------------------------------------\n"; echo "Detected Ossim Version: " . $upgrade->ossim_current_version . "\n"; echo "-------------------------------------------------------------------\n"; echo "Detected Schema Version: " . $upgrade->ossim_schema_version . "\n"; echo "-------------------------------------------------------------------\n"; echo "Detected Database Type: " . $upgrade->ossim_dbtype . "\n"; echo "-------------------------------------------------------------------\n"; $ok = $upgrade->needs_upgrade(); if (!$ok) { echo "\nNo upgrades needed\n\n"; exit; } echo "\nSearching upgrades...\n\n"; $cont = 1;
public function testIsCurrentYes() { $config = $this->config; $config->defaults->currentCodeVersion = '3.3.3'; $upgrade = new Upgrade(array('config' => $config)); $res = $upgrade->isCurrent(); $this->assertTrue($res); }
/** * Class and Function List: * Function list: * Classes list: */ require_once 'ossim_conf.inc'; require_once 'classes/Upgrade.inc'; require_once 'classes/Session.inc'; require_once 'classes/Util.inc'; require_once 'classes/Sensor.inc'; $conf = $GLOBALS["CONF"]; $version = $conf->get_conf("ossim_server_version", FALSE); $cloud_instance = $conf->get_conf("cloud_instance", FALSE) == 1 ? true : false; $opensource = !preg_match("/pro|demo/i", $version) ? true : false; $prodemo = preg_match("/pro|demo/i", $version) ? true : false; $upgrade = new Upgrade(); if (Session::am_i_admin() && $upgrade->needs_upgrade()) { $menu["Upgrade"][] = array("name" => gettext("System Upgrade Needed"), "id" => "Upgrade", "url" => "upgrade/index.php"); $hmenu["Upgrade"][] = array("name" => gettext("Software Upgrade"), "id" => "Upgrade", "url" => "upgrade/"); $hmenu["Upgrade"][] = array("name" => gettext("Update Notification"), "id" => "Updates", "url" => "updates/index.php"); $GLOBALS['ossim_last_error'] = false; } /* Dashboards */ $dashboards = 0; if (Session::menu_perms("MenuControlPanel", "ControlPanelExecutive")) { $dashboards = 1; $menu["Dashboards"][] = array("name" => gettext("Dashboards"), "id" => "Executive Panel", "url" => "panel/"); } if (Session::menu_perms("MenuControlPanel", "BusinessProcesses") || Session::menu_perms("MenuControlPanel", "ControlPanelMetrics")) { $dashboards = 1; if (Session::menu_perms("MenuControlPanel", "BusinessProcesses")) {
/** * Run Upgrade Process: * - do WP-Property settings backup. * * @author peshkov@UD */ public function run_upgrade_process() { Upgrade::run($this->old_version, $this->args['version']); }
public function __construct() { parent::__construct(); // Load cache $this->cache = new Cache(); // Load session $this->session = new Session(); // Load database $this->db = new Database(); $upgrade = new Upgrade(); $this->auth = new Auth(); $this->session = Session::instance(); $this->auth->auto_login(); if (!$this->auth->logged_in('login')) { url::redirect('login'); } // Set Table Prefix $this->table_prefix = Kohana::config('database.default.table_prefix'); //fetch latest release of ushahidi $this->release = $upgrade->_fetch_core_release(); if (!empty($this->release)) { $this->template->version = $this->_get_release_version(); $this->template->critical = $this->release->critical; } // Get Session Information $this->user = new User_Model($_SESSION['auth_user']->id); $this->template->admin_name = $this->user->name; //make sure the user is supposed to be here: $group_id = groups::get_user_group($this->user); if (!$group_id) { url::redirect(url::site() . 'admin/simplegroups/nogroup'); } //Get Group Info $groups = ORM::factory("simplegroups_groups")->join("simplegroups_groups_users", "simplegroups_groups.id", "simplegroups_groups_users.simplegroups_groups_id")->where("simplegroups_groups_users.users_id", $this->user->id)->find_all(); foreach ($groups as $group) { $this->group = $group; $this->template->group_name = $group->name; $this->template->group_logo = $group->logo; } // Retrieve Default Settings $this->template->site_name = Kohana::config('settings.site_name'); $this->template->mapstraction = Kohana::config('settings.mapstraction'); $this->template->api_url = Kohana::config('settings.api_url'); // Javascript Header $this->template->map_enabled = FALSE; $this->template->flot_enabled = FALSE; $this->template->treeview_enabled = FALSE; $this->template->protochart_enabled = FALSE; $this->template->colorpicker_enabled = FALSE; $this->template->editor_enabled = FALSE; $this->template->js = ''; $this->template->form_error = FALSE; // Initialize some variables for raphael impact charts $this->template->raphael_enabled = FALSE; $this->template->impact_json = ''; // Generate main tab navigation list. $this->template->main_tabs = admin::main_tabs(); // Generate sub navigation list (in default layout, sits on right side). $this->template->main_right_tabs = admin::main_right_tabs($this->user); $this->template->this_page = ""; // Load profiler // $profiler = new Profiler; }
function ReleaseUpgrade($p_release) { Upgrade::Upgrade('release_' . $p_release, 'Mark release for database version ' . $p_release); $this->release_name = $p_release; }
<html> <head> <title><?php echo gettext("OSSIM Framework"); ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <meta http-equiv="Pragma" content="no-cache"/> <link rel="stylesheet" type="text/css" href="/ossim/style/av_common.css?t=<?php echo Util::get_css_id(); ?> "/> </head> <body> <?php $upgrade = new Upgrade(); if (GET('submit')) { $ok = $upgrade->needs_upgrade(); if (!$ok) { echo ossim_error(_("No upgrades needed"), AV_INFO); exit; } if (ossim_error()) { echo ossim_error(_("Not clean installation detected. Refusing to apply upgrades, please do it manually")); exit; } $upgrade->apply_needed(); echo "<br><br>\n <form>\n <table width='100%' class='noborder' style='background:transparent;'>\n <tr>\n <td class='nobborder' style='text-align:center;'>\n <input type='button' onclick=\"top.frames['main'].window.location.reload();\" value='" . _("Continue") . "'/>\n </td>\n </tr>\n </table>\n </form>"; exit; } // Force a certain upgrade
public function check_current_version() { //This is an AJAX call, so none of this fancy templating, just render the data $this->template = ""; $this->auto_render = FALSE; // Disable profiler if (isset($this->profiler)) { $this->profiler->disable(); } $view = View::factory('admin/current_version'); $upgrade = new Upgrade(); //fetch latest release of ushahidi $this->release = $upgrade->_fetch_core_release(); if (!empty($this->release)) { $view->version = $this->_get_release_version(); $view->critical = $this->release->critical; } $view->render(TRUE); }
/** * 执行模块升级脚本 * @param type $module 模块名称 * @return boolean */ public function upgrade($module) { //检查模块是否安装 if ($this->isInstall($module) == false) { $this->error = '模块没进行安装,无法进行模块升级!'; return -10022; } //取得模块信息 $info = $this->where(array('module' => $module))->find(); if (empty($info)) { $this->error = '获取模块信息错误!'; return -10023; } //模块路径 $base = $this->appPath . $module . '/'; //SQL脚本文件 $exec = $base . 'Upgrade/upgrade.sql'; //phpScript $phpScript = $base . 'Upgrade/Upgrade.class.php'; //判断是否有数据库升级脚本 if (file_exists($exec)) { //获取全部参数 preg_match_all("/#\\[version=(.*?)\\](.+?)#\\[\\/version\\]/ism", file_get_contents($exec), $match); //遍历 foreach ($match[1] as $index => $version) { //比较模块版本,仅处理小于或等于当前版本 if ($version && version_compare($version, $info['version'], '>=')) { //记录最后一个更新的版本号 $upgradeVersion = $version; $sql = $this->sqlSplit($sql, C("DB_PREFIX")); if (!empty($sql) && is_array($sql)) { foreach ($sql as $sql_split) { $this->execute($sql_split); } } } } } //判断是否有升级程序脚本 if (file_exists($phpScript)) { require_cache($phpScript); if (class_exists('Upgrade')) { $Upgrade = new Upgrade(); if ($Upgrade->run() == false) { $this->error = $Upgrade->getError() ? $Upgrade->getError() : "执行模块升级脚本错误,升级未完成!"; return -10024; } } } //加载配置 $config = $this->getModuleInstallConfig($module); if (!empty($config)) { //更新版本号 $this->where(array('module' => $module))->save(array('version' => $config['version'], 'updatedate' => date('Y-m-d'))); } return true; }
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt ****************************************************************************/ /***************************************************************************** * This script apply SQL schema upgrade files automatically ****************************************************************************/ function execute_sql($path_file_log, $sql_file) { $cmd = "ossim-db < {$sql_file} > {$path_file_log} 2>&1"; system($cmd, $ret); return $ret; } $path_class = '/usr/share/ossim/include/'; $path_log = '/var/log/ossim/'; ini_set('include_path', $path_class); require_once 'classes/Upgrade.inc'; $upgrade = new Upgrade(); echo "\n\nDate: " . date("j/m/Y") . "\n\n"; echo "-------------------------------------------------------------------\n"; echo "Detected Ossim Version: " . $upgrade->ossim_current_version . "\n"; echo "-------------------------------------------------------------------\n"; echo "Detected Schema Version: " . $upgrade->ossim_schema_version . "\n"; echo "-------------------------------------------------------------------\n"; echo "Detected Database Type: " . $upgrade->ossim_dbtype . "\n"; echo "-------------------------------------------------------------------\n"; $ok = $upgrade->needs_upgrade(); if (!$ok) { echo "\nNo upgrades needed\n\n"; exit; } echo "\nSearching upgrades...\n\n"; $cont = 1;
/** * ajax返回提示应付金额或是否允许操作 */ public function action_ajax() { $info = explode(',', base64_decode(trim($this->getQuery('t')))); $upgrade = new Upgrade($this->auth, $info[0], $info[1]); $payPrice = $upgrade->calculate()->getMoney(); // 订单金额 $getGroupPrice = $upgrade->getGroupPrice(); // 订单金额 if ($payPrice < 1) { echo '<span style="color:#FF7E00;">无法升级'; } else { echo "应付:<span style=\"color:#FF7E00;\">" . $payPrice . "</span>元"; } $this->auto_render = false; }
/** * Execute upgrade task */ function execute() { import('classes.install.Upgrade'); Upgrade::fixFilenames($this->dryrun); }
/** * displayUpgradeDatabase * * @return void */ function displayUpgradeDatabase() { $fcmsError = FCMS_Error::getInstance(); $fcmsDatabase = Database::getInstance($fcmsError); $fcmsUpgrade = new Upgrade($fcmsError, $fcmsDatabase); $latestVersion = $_SESSION['latestVersion']; if (!$fcmsUpgrade->upgrade()) { // Jacked html, but should work displayHeader(); $fcmsError->displayError(); displayFooter(); return; } if (!$fcmsUpgrade->updateCurrentVersion($latestVersion)) { // Jacked html, but should work displayHeader(); $fcmsError->displayError(); displayFooter(); return; } header('Location: upgrade.php?manual=1'); }
break; } } private static function selectUpgrade(Smarty $smarty) { $upgrades = array(); foreach (Utils::getFilelist(SYSTEM_ROOT . '/upgrade/scripts/') as $file) { if (preg_match('~upgrade-(.*?)-(.*?).php~', $file, $matches)) { $upgrades[$file] = "Version " . $matches[1] . " -> " . $matches[2]; } } if (Utils::getPOST('submit', false) !== false) { $upgrade = Utils::getPOST('upgrade', ''); if (array_key_exists($upgrade, $upgrades) && file_exists(SYSTEM_ROOT . '/upgrade/scripts/' . $upgrade)) { include_once SYSTEM_ROOT . '/upgrade/scripts/' . $upgrade; } } $smarty->assign('upgrades', $upgrades); $smarty->assign('heading', 'Select upgrade'); $smarty->assign('curStep', 1); $smarty->display('upgrade.tpl'); } private static function success(Smarty $smarty) { $smarty->assign('heading', 'Upgrade finished'); $smarty->assign('curStep', 2); $smarty->display('success.tpl'); } } Upgrade::run(Utils::getGET('action', ''));
/** * Upgrade a plugin to a newer version from the user's filesystem * @param $path string path to plugin Directory * @param $templateMgr reference to template manager * @param $category string * @param $plugin string * @return boolean */ function upgradePlugin($path, &$templateMgr, $category, $plugin) { $this->validate(); $versionFile = $path . VERSION_FILE; $templateMgr->assign('error', true); $templateMgr->assign('pageHierarchy', $this->setBreadcrumbs(true, $category)); $pluginVersion =& VersionCheck::getValidPluginVersionInfo($versionFile, $templateMgr); if (is_null($pluginVersion)) { return false; } assert(is_a($pluginVersion, 'Version')); // Check whether the uploaded plug-in fits the original plug-in. if ('plugins.' . $category != $pluginVersion->getProductType()) { $templateMgr->assign('message', 'manager.plugins.wrongCategory'); return false; } if ($plugin != $pluginVersion->getProduct()) { $templateMgr->assign('message', 'manager.plugins.wrongName'); return false; } $versionDao =& DAORegistry::getDAO('VersionDAO'); $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true); if (!$installedPlugin) { $templateMgr->assign('message', 'manager.plugins.pleaseInstall'); return false; } if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) { $templateMgr->assign('message', 'manager.plugins.installedVersionNewer'); return false; } else { $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $plugin; $pluginLibDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $plugin; // Delete existing files. if (is_dir($pluginDest)) { FileManager::rmtree($pluginDest); } if (is_dir($pluginLibDest)) { FileManager::rmtree($pluginLibDest); } // Check whether deleting has worked. if (is_dir($pluginDest) || is_dir($pluginLibDest)) { $templateMgr->assign('message', 'manager.plugins.deleteError'); return false; } // Copy the plug-in from the temporary folder to the // target folder. // Start with the library part (if any). $libPath = $path . DIRECTORY_SEPARATOR . 'lib'; if (is_dir($libPath)) { if (!FileManager::copyDir($libPath, $pluginLibDest)) { $templateMgr->assign('message', 'manager.plugins.copyError'); return false; } // Remove the library part of the temporary folder. FileManager::rmtree($libPath); } // Continue with the application-specific part (mandatory). if (!FileManager::copyDir($path, $pluginDest)) { $templateMgr->assign('message', 'manager.plugins.copyError'); return false; } // Remove the temporary folder. FileManager::rmtree(dirname($path)); $upgradeFile = $pluginDest . UPGRADE_FILE; if (FileManager::fileExists($upgradeFile)) { $params = $this->_setConnectionParams(); $installer = new Upgrade($params, $upgradeFile, true); if (!$installer->execute()) { $templateMgr->assign('message', array('manager.plugins.upgradeFailed', $installer->getErrorString())); return false; } } $installedPlugin->setCurrent(0); $pluginVersion->setCurrent(1); $versionDao->insertVersion($pluginVersion, true); $templateMgr->assign('category', $category); $templateMgr->assign('plugin', $plugin); $templateMgr->assign('message', array('manager.plugins.upgradeSuccessful', $pluginVersion->getVersionString())); $templateMgr->assign('uploaded', true); $templateMgr->assign('error', false); return true; } }
/** * Upgrade a plugin to a newer version from the user's filesystem * @param $category string * @param $plugin string * @param $path string path to plugin Directory * @param $category string * @param $plugin string * @return Version|null The upgraded version, on success; null on fail */ function upgradePlugin($category, $plugin, $path, &$errorMsg) { $versionFile = $path . '/' . PLUGIN_VERSION_FILE; $pluginVersion = VersionCheck::getValidPluginVersionInfo($versionFile, $errorMsg); if (!$pluginVersion) { return null; } // Check whether the uploaded plug-in fits the original plug-in. if ('plugins.' . $category != $pluginVersion->getProductType()) { $errorMsg = __('manager.plugins.wrongCategory'); return null; } if ($plugin != $pluginVersion->getProduct()) { $errorMsg = __('manager.plugins.wrongName'); return null; } $versionDao = DAORegistry::getDAO('VersionDAO'); $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true); if (!$installedPlugin) { $errorMsg = __('manager.plugins.pleaseInstall'); return null; } if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) { $errorMsg = __('manager.plugins.installedVersionNewer'); return null; } else { $pluginDest = Core::getBaseDir() . '/plugins/' . $category . '/' . $plugin; $pluginLibDest = Core::getBaseDir() . '/' . PKP_LIB_PATH . '/plugins/' . $category . '/' . $plugin; // Delete existing files. $fileManager = new FileManager(); if (is_dir($pluginDest)) { $fileManager->rmtree($pluginDest); } if (is_dir($pluginLibDest)) { $fileManager->rmtree($pluginLibDest); } // Check whether deleting has worked. if (is_dir($pluginDest) || is_dir($pluginLibDest)) { $errorMsg = __('message', 'manager.plugins.deleteError'); return null; } // Copy the plug-in from the temporary folder to the // target folder. // Start with the library part (if any). $libPath = $path . '/lib'; if (is_dir($libPath)) { if (!$fileManager->copyDir($libPath, $pluginLibDest)) { $errorMsg = __('manager.plugins.copyError'); return null; } // Remove the library part of the temporary folder. $fileManager->rmtree($libPath); } // Continue with the application-specific part (mandatory). if (!$fileManager->copyDir($path, $pluginDest)) { $errorMsg = __('manager.plugins.copyError'); return null; } // Remove the temporary folder. $fileManager->rmtree(dirname($path)); $upgradeFile = $pluginDest . '/' . PLUGIN_UPGRADE_FILE; if ($fileManager->fileExists($upgradeFile)) { $params = $this->_getConnectionParams(); $installer = new Upgrade($params, $upgradeFile, true); if (!$installer->execute()) { $errorMsg = __('manager.plugins.upgradeFailed', array('errorString' => $installer->getErrorString())); return null; } } $installedPlugin->setCurrent(0); $pluginVersion->setCurrent(1); $versionDao->insertVersion($pluginVersion, true); return $pluginVersion; } }
$GroundArmorLevel3 = new Upgrade("Ground Armor Level 3", Protoss, array($TwilightCouncil), array($Forge), 250, 250, 220); $AirArmorLevel1 = new Upgrade("Air Armor Level 1", Protoss, array(), array($CyberneticsCore), 150, 150, 160); $AirArmorLevel2 = new Upgrade("Air Armor Level 2", Protoss, array($FleetBeacon), array($CyberneticsCore), 225, 225, 190); $AirArmorLevel3 = new Upgrade("Air Armor Level 3", Protoss, array($FleetBeacon), array($CyberneticsCore), 300, 300, 220); $ShieldsLevel1 = new Upgrade("Shields Level 1", Protoss, array(), array($Forge), 200, 200, 160); $ShieldsLevel2 = new Upgrade("Shields Level 2", Protoss, array($TwilightCouncil), array($Forge), 300, 300, 190); $ShieldsLevel3 = new Upgrade("Shields Level 3", Protoss, array($TwilightCouncil), array($Forge), 400, 400, 220); $Charge = new Upgrade("Charge", Protoss, array(), array($TwilightCouncil), 200, 200, 140); $GraviticBoosters = new Upgrade("Gravitic Boosters", Protoss, array(), array($RoboticsBay), 100, 100, 80); $GraviticDrive = new Upgrade("Gravitic Drive", Protoss, array(), array($RoboticsBay), 100, 100, 80); $FluxVanes = new Upgrade("Flux Vanes", Protoss, array(), array($FleetBeacon), 150, 150, 80); $ExtendedThermalLance = new Upgrade("Extended Thermal Lance", Protoss, array(), array($RoboticsBay), 200, 200, 140); $PsionicStorm = new Upgrade("Psionic Storm", Protoss, array(), array($TemplarArchives), 200, 200, 110); $Hallucination = new Upgrade("Hallucination", Protoss, array(), array($CyberneticsCore), 100, 100, 110); $Blink = new Upgrade("Blink", Protoss, array(), array($TwilightCouncil), 150, 150, 110); $KhaydarinAmulet = new Upgrade("Khaydarin Amulet", Protoss, array(), array($TemplarArchives), 150, 150, 110); $GravitonCatapult = new Upgrade("Graviton Catapult", Protoss, array(), array($FleetBeacon), 150, 150, 80); /// Protoss morphs $TransformToWarpgate = new Morph("Transform to Warpgate", Protoss, array($WarpgateUpgrade), array($Gateway), array($Warpgate), null, 0, 0, 10); $TransformToGateway = new Morph("Transform to Gateway", Protoss, array($WarpgateUpgrade), array($Warpgate), array($Gateway), null, 0, 0, 10); /// Protoss units $Probe = new Unit("Probe", Protoss, array(), array($Nexus), 1, 50, 0, 17); $Mothership = new Unit("Mothership", Protoss, array($FleetBeacon), array($Nexus), 8, 400, 400, 160); $Zealot = new Unit("Zealot", Protoss, array(), array($Gateway, $Warpgate), 2, 100, 0, 38); $Stalker = new Unit("Stalker", Protoss, array($CyberneticsCore), array($Gateway, $Warpgate), 2, 125, 50, 42); $Sentry = new Unit("Sentry", Protoss, array($CyberneticsCore), array($Gateway, $Warpgate), 2, 50, 100, 42); $HighTemplar = new Unit("High Templar", Protoss, array($TemplarArchives), array($Gateway, $Warpgate), 2, 50, 150, 55); $DarkTemplar = new Unit("Dark Templar", Protoss, array($DarkShrine), array($Gateway, $Warpgate), 2, 125, 125, 55); $Observer = new Unit("Observer", Protoss, array(), array($RoboticsFacility), 1, 50, 100, 40); $Immortal = new Unit("Immortal", Protoss, array(), array($RoboticsFacility), 4, 250, 100, 50); $WarpPrism = new Unit("Warp Prism", Protoss, array(), array($RoboticsFacility), 2, 200, 0, 50);
/** * Upgrade a plugin to a newer version from the user's filesystem * @param $path string path to plugin Directory * @param $templateMgr reference to template manager * @return boolean */ function upgradePlugin($path, &$templateMgr) { $versionFile = $path . VERSION_FILE; $templateMgr->assign('error', true); $templateMgr->assign('path', 'upgrade'); if (FileManager::fileExists($versionFile)) { $versionInfo =& VersionCheck::parseVersionXML($versionFile); } else { $templateMgr->assign('message', 'manager.plugins.versionFileNotFound'); return false; } $pluginVersion = $versionInfo['version']; $pluginName = $versionInfo['application']; $category = explode(".", $pluginVersion->getProductType()); $versionDao =& DAORegistry::getDAO('VersionDAO'); $installedPlugin = $versionDao->getCurrentVersion($pluginName); if (!$installedPlugin) { $templateMgr->assign('message', 'manager.plugins.pleaseInstall'); return false; } if (PluginManagementHandler::checkIfNewer($pluginName, $pluginVersion)) { $templateMgr->assign('message', 'manager.plugins.installedVersionNewer'); return false; } else { $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $pluginName; FileManager::rmtree($pluginDest); if (FileManager::fileExists($pluginDest, 'dir')) { $templateMgr->assign('message', 'manager.plugins.deleteError'); return false; } if (!FileManager::copyDir($path, $pluginDest)) { $templateMgr->assign('message', 'manager.plugins.copyError'); return false; } $upgradeFile = $pluginDest . DIRECTORY_SEPARATOR . UPGRADE_FILE; if (FileManager::fileExists($upgradeFile)) { $params = PluginManagementHandler::setConnectionParams(); $installer = new Upgrade($params, $upgradeFile, true); if (!$installer->execute()) { $templateMgr->assign('message', array('manager.plugins.upgradeFailed', $installer->getErrorString())); return false; } } $installedPlugin->setCurrent(0); $pluginVersion->setCurrent(1); $versionDao->insertVersion($pluginVersion); $templateMgr->assign('message', array('manager.plugins.upgradeSuccessful', $pluginVersion->getVersionString())); $templateMgr->assign('uploaded', true); $templateMgr->assign('error', false); return true; } }
public function onActivate() { $upgrade = new Upgrade(); $upgrade->upgradeFromJWPlayer(); }
/** * Upgrade a plugin to a newer version from the user's filesystem * @param $path string path to plugin Directory * @param $templateMgr reference to template manager * @return boolean */ function upgradePlugin($path, &$templateMgr) { $this->validate(); $versionFile = $path . VERSION_FILE; $templateMgr->assign('error', true); $templateMgr->assign('path', 'upgrade'); $pluginVersion =& VersionCheck::getValidPluginVersionInfo($versionFile, $templateMgr); if (is_null($pluginVersion)) { return false; } assert(is_a($pluginVersion, 'Version')); $versionDao =& DAORegistry::getDAO('VersionDAO'); $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProduct(), true); if (!$installedPlugin) { $templateMgr->assign('message', 'manager.plugins.pleaseInstall'); return false; } if ($this->checkIfNewer($pluginVersion->getProduct(), $pluginVersion)) { $templateMgr->assign('message', 'manager.plugins.installedVersionNewer'); return false; } else { $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . strtr($pluginVersion->getProductType(), '.', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $pluginVersion->getProduct(); FileManager::rmtree($pluginDest); if (FileManager::fileExists($pluginDest, 'dir')) { $templateMgr->assign('message', 'manager.plugins.deleteError'); return false; } if (!FileManager::copyDir($path, $pluginDest)) { $templateMgr->assign('message', 'manager.plugins.copyError'); return false; } $upgradeFile = $pluginDest . UPGRADE_FILE; if (FileManager::fileExists($upgradeFile)) { $params = $this->setConnectionParams(); $installer = new Upgrade($params, $upgradeFile, true); if (!$installer->execute()) { $templateMgr->assign('message', array('manager.plugins.upgradeFailed', $installer->getErrorString())); return false; } } $installedPlugin->setCurrent(0); $pluginVersion->setCurrent(1); $versionDao->insertVersion($pluginVersion, true); $templateMgr->assign('message', array('manager.plugins.upgradeSuccessful', $pluginVersion->getVersionString())); $templateMgr->assign('uploaded', true); $templateMgr->assign('error', false); return true; } }
@set_time_limit(0); // Get the new version and the current version, and compare them. If we don't need to upgrade, home we go! require "../config.default.php"; require "../config/versions.php"; if ($versions["esoTalk"] == ESOTALK_VERSION) { header("Location: ../index.php"); exit; } // Require essential files. require "../lib/functions.php"; require "../lib/database.php"; require "../config/config.php"; require "upgrade.controller.php"; // Start a session if one does not already exist if (!session_id()) { session_start(); } // Undo register globals undoRegisterGlobals(); // If magic quotes is on, strip the slashes that it added if (get_magic_quotes_gpc()) { $_GET = array_map("undoMagicQuotes", $_GET); $_POST = array_map("undoMagicQuotes", $_POST); $_COOKIE = array_map("undoMagicQuotes", $_COOKIE); } // Clean and sterilize the request data $_POST = sanitize($_POST); $_GET = sanitize($_GET); $_COOKIE = sanitize($_COOKIE); $upgrade = new Upgrade(); $upgrade->init();
/** * Plugin upgrades. * * @internal * * @since 0.8.2 */ private function upgrade() { $upgrade = new Upgrade(); // Run plugin upgrades $upgrade->upgrades(); }
/** * 计算升级用户所需费用 */ public function action_fee() { $uid = (int) $this->getQuery('uid'); $groupId = (int) $this->getQuery('group'); $time = (int) $this->getQuery('time'); $status = (int) $this->getQuery('status'); if ($status) { $time = $time * 12; } $userInfo = DB::select()->from('users')->where('uid', '=', $uid)->execute()->current(); $upgrade = new Upgrade($userInfo, $groupId, $time); $payPrice = $upgrade->calculate()->getMoney(); // 订单金额 echo json_encode(array('price' => ceil($payPrice))); $this->auto_render = false; }