/**
  * Check we can upgrade
  *
  * @return	mixed	Boolean true or error message
  */
 public function checkForProblems()
 {
     //-----------------------------------------
     // Compatibility check
     //-----------------------------------------
     $minAppVersions = array();
     $args = func_get_args();
     if (!empty($args)) {
         $errors = array();
         foreach ($minAppVersions as $k => $v) {
             if (!isset(ipsRegistry::$applications[$k]) or !ipsRegistry::$applications[$k]['app_enabled']) {
                 continue;
             }
             $numbers = IPSSetUp::fetchAppVersionNumbers($k);
             /* Are we upgrading this app now? */
             if (isset($args[0][$k])) {
                 $ourVersion = $numbers['latest'][0];
             } else {
                 $ourVersion = $numbers['current'][0];
             }
             if ($v > $ourVersion) {
                 $appName = ipsRegistry::$applications[$k]['app_title'];
                 $allVersions = IPSSetUp::fetchXmlAppVersions($k);
                 return "The version of {$appName} you have installed will not work with this version of IP.Board. You must upgrade {$appName} to {$allVersions[$v]} or higher, or disable it in the Admin CP in order continue.";
             }
         }
     }
     return TRUE;
 }
예제 #2
0
 /**
  * Check we can upgrade
  *
  * @return	mixed	Boolean true or error message
  */
 public function checkForProblems()
 {
     //-----------------------------------------
     // Compatibility check
     //-----------------------------------------
     $minAppVersions = array();
     $args = func_get_args();
     if (!empty($args)) {
         $errors = array();
         foreach ($minAppVersions as $k => $v) {
             if (!isset(ipsRegistry::$applications[$k]) or !ipsRegistry::$applications[$k]['app_enabled']) {
                 continue;
             }
             $numbers = IPSSetUp::fetchAppVersionNumbers($k);
             /* Are we upgrading this app now? */
             if (isset($args[0][$k])) {
                 $ourVersion = $numbers['latest'][0];
             } else {
                 $ourVersion = $numbers['current'][0];
             }
             if ($v > $ourVersion) {
                 $appName = ipsRegistry::$applications[$k]['app_title'];
                 $allVersions = IPSSetUp::fetchXmlAppVersions($k);
                 return "Установленная версия {$appName} не будет работать с этой версией IP.Board. Вы должны обновить {$appName} версии {$allVersions[$v]} или выше, или отключить приложение в админцентре для продолжения.";
             }
         }
     }
     return TRUE;
 }
예제 #3
0
 /**
  * Execute selected method
  *
  * @access	public
  * @param	object		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* Remove the FURL cache */
     @unlink(FURL_CACHE_PATH);
     /* Got anything to show? */
     $apps = explode(',', IPSSetUp::getSavedData('install_apps'));
     $vNums = IPSSetUp::getSavedData('version_numbers');
     $output = array();
     if (is_array($apps) and count($apps)) {
         foreach ($apps as $app) {
             /* Grab version numbers */
             $numbers = IPSSetUp::fetchAppVersionNumbers($app);
             /* Grab all numbers */
             $nums[$app] = IPSSetUp::fetchXmlAppVersions($app);
             /* Grab app data */
             $appData[$app] = IPSSetUp::fetchXmlAppInformation($app, $this->settings['gb_char_set']);
             $appClasses[$app] = IPSSetUp::fetchVersionClasses($app, $vNums[$app], $numbers['latest'][0]);
         }
         /* Got anything? */
         if (count($appClasses)) {
             foreach ($appClasses as $app => $data) {
                 foreach ($data as $num) {
                     if (is_file(IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php')) {
                         $_class = 'version_class_' . $app . '_' . $num;
                         require_once IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php';
                         /*noLibHook*/
                         $_tmp = new $_class($this->registry);
                         if (method_exists($_tmp, 'postInstallNotices')) {
                             $_t = $_tmp->postInstallNotices();
                             if (is_array($_t) and count($_t)) {
                                 $output[$app][$num] = array('long' => $nums[$app][$num], 'app' => $appData[$app], 'out' => implode("<br />", $_t));
                             }
                         }
                     }
                 }
             }
         }
     }
     /* Remove any SQL source files */
     IPSSetUp::removeSqlSourceFiles();
     /* Simply return the Done page */
     $this->registry->output->setTitle("Complete!");
     $this->registry->output->setHideButton(TRUE);
     $this->registry->output->addContent($this->registry->output->template()->upgrade_complete($output));
     $this->registry->output->sendOutput();
 }
예제 #4
0
 /**
  * Check we can upgrade
  *
  * @return	mixed	Boolean true or error message
  */
 public function checkForProblems()
 {
     //-----------------------------------------
     // Compatibility check
     //-----------------------------------------
     $requiredIpbVersion = 32006;
     // 3.2.3
     $args = func_get_args();
     if (!empty($args)) {
         $numbers = IPSSetUp::fetchAppVersionNumbers('core');
         /* Are we upgrading core now? */
         if (isset($args[0]['core'])) {
             $ourVersion = $numbers['latest'][0];
         } else {
             $ourVersion = $numbers['current'][0];
         }
         if ($requiredIpbVersion > $ourVersion) {
             $allVersions = IPSSetUp::fetchXmlAppVersions('core');
             return "This version of IP.Chat requires IP.Board {$allVersions[$requiredIpbVersion]} or higher.";
         }
     }
     return TRUE;
 }
예제 #5
0
파일: apps.php 프로젝트: mover5/imobackup
 /**
  * Execute selected method
  *
  * @access	public
  * @param	object		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* Delete sessions and continue */
     if ($this->request['do'] == 'rsessions') {
         IPSSetUp::removePreviousSession();
     }
     /* Rebuild from last session and continue */
     if ($this->request['do'] == 'rcontinue') {
         $oldSession = IPSSetUp::checkForPreviousSessions();
         if (count($oldSession) and $oldSession['_session_get']['section'] and $oldSession['_sd']['install_apps']) {
             IPSSetUp::restorePreviousSession($oldSession);
             exit;
         }
     }
     /* Check for failed upgrade */
     if (!$this->request['do'] or $this->request['do'] != 'rsessions') {
         $oldSession = IPSSetUp::checkForPreviousSessions();
         if (count($oldSession) and $oldSession['_session_get']['section'] and $oldSession['_sd']['install_apps']) {
             /* Page Output */
             $this->registry->output->setTitle("Applications");
             $this->registry->output->setNextAction('apps&do=rsessions');
             //$this->registry->output->setHideButton( TRUE );
             $this->registry->output->addContent($this->registry->output->template()->upgrade_previousSession($oldSession));
             $this->registry->output->sendOutput();
         }
     }
     /* Save data */
     if ($this->request['do'] == 'save') {
         $apps = explode(',', IPSSetUp::getSavedData('install_apps'));
         $toSave = array();
         $vNums = array();
         if (is_array($apps) and count($apps)) {
             foreach ($apps as $app) {
                 /* Grab version numbers */
                 $numbers = IPSSetUp::fetchAppVersionNumbers($app);
                 /* Grab all numbers */
                 $nums[$app] = IPSSetUp::fetchXmlAppVersions($app);
                 /* Grab app data */
                 $appData[$app] = IPSSetUp::fetchXmlAppInformation($app, $this->settings['gb_char_set']);
                 $appClasses[$app] = IPSSetUp::fetchVersionClasses($app, $numbers['current'][0], $numbers['latest'][0]);
                 /* Store starting vnums */
                 $vNums[$app] = $numbers['current'][0];
             }
             /* Got anything? */
             if (count($appClasses)) {
                 foreach ($appClasses as $app => $data) {
                     foreach ($data as $num) {
                         if (is_file(IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php')) {
                             $_class = 'version_class_' . $app . '_' . $num;
                             require_once IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php';
                             /*noLibHook*/
                             $_tmp = new $_class($this->registry);
                             if (method_exists($_tmp, 'preInstallOptionsSave')) {
                                 $_t = $_tmp->preInstallOptionsSave();
                                 if (is_array($_t) and count($_t)) {
                                     $toSave[$app][$num] = $_t;
                                 }
                             }
                         }
                     }
                 }
                 /* Save it */
                 if (count($toSave)) {
                     IPSSetUp::setSavedData('custom_options', $toSave);
                 }
                 if (count($vNums)) {
                     IPSSetUp::setSavedData('version_numbers', $vNums);
                 }
             }
         }
         /* Next Action */
         $this->registry->autoLoadNextAction('license');
     } else {
         if ($this->request['do'] == 'check') {
             /* Check Directory */
             if (!is_array($_POST['apps']) or !count($_POST['apps'])) {
                 /* We use 'warning' because it has same effect but does not block the 'next' button (which they'll want to use after selecting an app when page reloads) */
                 $this->registry->output->addWarning('You must select to upgrade at least one application');
             } else {
                 /* If it's lower than 3.0.0, then add in the removed apps */
                 if (IPSSetUp::is300plus() !== TRUE) {
                     $_POST['apps']['forums'] = 1;
                     $_POST['apps']['members'] = 1;
                     $_POST['apps']['calendar'] = 1;
                     $_POST['apps']['chat'] = 1;
                 } else {
                     if ($_POST['apps']['core']) {
                         $_POST['apps']['forums'] = 1;
                         $_POST['apps']['members'] = 1;
                     }
                 }
                 /* Save Form Data */
                 IPSSetUp::setSavedData('install_apps', implode(',', array_keys($_POST['apps'])));
                 /* Got any app-version classes? */
                 $appClasses = array();
                 $output = array();
                 $nums = array();
                 $appData = array();
                 foreach ($_POST['apps'] as $app => $val) {
                     /* Grab version numbers */
                     $numbers = IPSSetUp::fetchAppVersionNumbers($app);
                     /* Grab all numbers */
                     $nums[$app] = IPSSetUp::fetchXmlAppVersions($app);
                     /* Grab app data */
                     $appData[$app] = IPSSetUp::fetchXmlAppInformation($app, $this->settings['gb_char_set']);
                     $appClasses[$app] = IPSSetUp::fetchVersionClasses($app, $numbers['current'][0], $numbers['latest'][0]);
                 }
                 /* Got anything? */
                 $error = FALSE;
                 if (count($appClasses)) {
                     foreach ($appClasses as $app => $data) {
                         if (is_file(IPSLib::getAppDir($app) . '/setup/upgradeCheck.php')) {
                             $_class = $app . '_upgradeCheck';
                             require_once IPSLib::getAppDir($app) . '/setup/upgradeCheck.php';
                             /*noLibHook*/
                             $requirements_class = new $_class();
                             if (method_exists($requirements_class, 'checkForProblems')) {
                                 $check = $requirements_class->checkForProblems($appClasses);
                                 if ($check !== TRUE) {
                                     $error = TRUE;
                                     $this->registry->output->addError($check);
                                 }
                             }
                         }
                         foreach ($data as $num) {
                             if (is_file(IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php')) {
                                 $_class = 'version_class_' . $app . '_' . $num;
                                 require_once IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php';
                                 /*noLibHook*/
                                 $_tmp = new $_class($this->registry);
                                 if (method_exists($_tmp, 'preInstallOptionsForm')) {
                                     $_t = $_tmp->preInstallOptionsForm();
                                     if ($_t) {
                                         $output[$app][$num] = array('long' => $nums[$app][$num], 'app' => $appData[$app], 'out' => $_t);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 /* Finally... */
                 if (count($output) or $error === TRUE) {
                     $this->registry->output->setTitle("Applications");
                     $this->registry->output->setNextAction('apps&do=save');
                     //$this->registry->output->setHideButton( TRUE );
                     if (!$error) {
                         $this->registry->output->addContent($this->registry->output->template()->upgrade_appsOptions($output));
                     }
                     $this->registry->output->sendOutput();
                 } else {
                     /* Next Action */
                     $this->registry->autoLoadNextAction('license');
                 }
             }
         }
     }
     /* Generate apps... */
     $apps = array('core' => array(), 'ips' => array(), 'other' => array());
     foreach (array('applications', 'applications_addon/ips', 'applications_addon/other') as $_pBit) {
         $path = IPS_ROOT_PATH . $_pBit;
         $handle = opendir($path);
         while (($file = readdir($handle)) !== FALSE) {
             if (!preg_match("#^\\.#", $file)) {
                 if (is_dir($path . '/' . $file)) {
                     //-----------------------------------------
                     // Get it!
                     //-----------------------------------------
                     if (!is_file(IPS_ROOT_PATH . $_pBit . '/' . $file . '/xml/information.xml')) {
                         continue;
                     }
                     $data = IPSSetUp::fetchXmlAppInformation($file, $this->settings['gb_char_set']);
                     switch ($_pBit) {
                         case 'applications':
                             $apps['core'][$file] = $data;
                             break;
                         case 'applications_addon/ips':
                             $apps['ips'][$file] = $data;
                             break;
                         case 'applications_addon/other':
                             $apps['other'][$file] = $data;
                             break;
                     }
                 }
             }
         }
         closedir($handle);
     }
     /* Reorder the array so that core is first */
     $new_array = array();
     $new_array['core'] = $apps['core']['core'];
     foreach ($apps['core'] as $app => $data) {
         if ($app == 'core') {
             continue;
         }
         $new_array[$app] = $data;
     }
     $apps['core'] = $new_array;
     /* Now get version numbers */
     foreach ($apps as $type => $app) {
         foreach ($apps[$type] as $app => $data) {
             if ($type == 'core' and ($app == 'forums' or $app == 'members')) {
                 /* Skip forums and members and just count core for now */
                 continue;
             }
             /* Grab version numbers */
             $numbers = IPSSetUp::fetchAppVersionNumbers($app);
             $appClasses[$app] = IPSSetUp::fetchVersionClasses($app, $numbers['current'][0], $numbers['latest'][0]);
             $apps[$type][$app]['_vnumbers'] = $numbers;
         }
     }
     /* Any notices? */
     $notices = array();
     if (count($appClasses)) {
         foreach ($appClasses as $app => $data) {
             $notices[$app] = array();
             foreach ($data as $num) {
                 if (is_file(IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php')) {
                     $_class = 'version_class_' . $app . '_' . $num;
                     require_once IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php';
                     /*noLibHook*/
                     $_tmp = new $_class($this->registry);
                     if (method_exists($_tmp, 'preInstallNotices')) {
                         $_t = $_tmp->preInstallNotices();
                         if ($_t) {
                             $notices[$app] = array_merge($_t, $notices[$app]);
                         }
                     }
                 }
             }
         }
     }
     /* If it's lower than 3.0.0, then remove some apps and make them part of 'core' */
     if (IPSSetUp::is300plus() !== TRUE) {
         unset($apps['ips']['calendar']);
         unset($apps['ips']['chat']);
     }
     /* Page Output */
     $this->registry->output->setTitle("Applications");
     $this->registry->output->setNextAction('apps&do=check');
     //$this->registry->output->setHideButton( TRUE );
     $this->registry->output->addContent($this->registry->output->template()->upgrade_apps($apps, $notices));
     $this->registry->output->sendOutput();
 }
예제 #6
0
 /**
  * Check for previous sessions.
  * Checks to see if there's an unfinished upgrade.
  *
  * @param	array
  * @access	public
  */
 public static function restorePreviousSession($session)
 {
     /* Delete all previous sessions */
     ipsRegistry::DB()->delete('upgrade_sessions', 'session_id != \'' . ipsRegistry::$request['s'] . '\'');
     /* Update the session */
     ipsRegistry::DB()->update('upgrade_sessions', array('session_current_time' => time(), 'session_section' => $session['session_section'], 'session_post' => serialize($session['_session_post']), 'session_get' => serialize($session['_session_get'])), 'session_id=\'' . ipsRegistry::$request['s'] . '\'');
     /* Set correct app */
     $_GET['app'] = 'upgrade';
     $_POST['app'] = 'upgrade';
     ipsRegistry::$request['app'] = 'upgrade';
     ipsRegistry::$current_section = 'upgrade';
     /* Set correct section */
     $_GET['section'] = $session['_session_get']['section'];
     $_POST['section'] = $session['_session_get']['section'];
     ipsRegistry::$request['section'] = $session['_session_get']['section'];
     ipsRegistry::$current_section = $session['_session_get']['section'];
     /* Set up the correct do */
     $_GET['do'] = $session['_session_get']['do'];
     $_POST['do'] = $session['_session_get']['do'];
     ipsRegistry::$request['do'] = $session['_session_get']['do'];
     /* Set up the correct previous */
     $_GET['previous'] = $session['_session_get']['previous'];
     $_POST['previous'] = $session['_session_get']['previous'];
     ipsRegistry::$request['previous'] = $session['_session_get']['previous'];
     /* Set up SD */
     $_POST['_sd'] = $session['_sd'];
     ipsRegistry::$request['_sd'] = $session['_sd'];
     /* App dir, etc */
     ipsRegistry::$request['appdir'] = $session['_sd']['appdir'];
     ipsRegistry::$request['man'] = $session['_sd']['man'];
     ipsRegistry::$request['helpfile'] = $session['_sd']['helpfile'];
     $apps = explode(',', $session['_sd']['install_apps']);
     $toSave = array();
     $vNums = array();
     /* set saved data */
     if (count($session['_sd'])) {
         foreach ($session['_sd'] as $k => $v) {
             if ($k) {
                 IPSSetUp::setSavedData($k, $v);
             }
         }
     }
     if (is_array($apps) and count($apps)) {
         /* Grab data */
         foreach ($apps as $app) {
             /* Grab version numbers */
             $numbers = IPSSetUp::fetchAppVersionNumbers($app);
             /* Grab all numbers */
             $nums[$app] = IPSSetUp::fetchXmlAppVersions($app);
             /* Grab app data */
             $appData[$app] = IPSSetUp::fetchXmlAppInformation($app);
             $appClasses[$app] = IPSSetUp::fetchVersionClasses($app, $numbers['current'][0], $numbers['latest'][0]);
             /* Store starting vnums */
             $vNums[$app] = $numbers['current'][0];
         }
         /* Got anything? */
         if (count($appClasses)) {
             foreach ($appClasses as $app => $data) {
                 foreach ($data as $num) {
                     if (is_file(IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php')) {
                         $_class = 'version_class_' . $app . '_' . $num;
                         require_once IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php';
                         /*noLibHook*/
                         $_tmp = new $_class(ipsRegistry::instance());
                         if (method_exists($_tmp, 'preInstallOptionsSave')) {
                             $_t = $_tmp->preInstallOptionsSave();
                             if (is_array($_t) and count($_t)) {
                                 $toSave[$app][$num] = $_t;
                             }
                         }
                     }
                 }
             }
             /* Save it */
             if (count($toSave)) {
                 IPSSetUp::setSavedData('custom_options', $toSave);
             }
             if (count($vNums)) {
                 IPSSetUp::setSavedData('version_numbers', $vNums);
             }
         }
         /* Freeze data */
         IPSSetUp::freezeSavedData();
         /* Thaw it */
         IPSSetUp::thawSavedData();
     }
     /* Re run our controller */
     ipsController::run();
 }
예제 #7
0
 /**
  * Get application versions
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _getAppVersions()
 {
     /* Init vars */
     $i = intval($this->request['i']);
     $app = trim($this->request['chosenApp']);
     $versions = array();
     /* Load setup library & get versions */
     require_once IPS_ROOT_PATH . 'setup/sources/base/setup.php';
     /*noLibHook*/
     $_versions = IPSSetUp::fetchXmlAppVersions($app);
     krsort($_versions);
     /* Setup our default 'no version' value */
     $versions[] = array(0, $this->lang->words['h_any_version']);
     foreach ($_versions as $long => $human) {
         if ($long < 30000 && in_array($app, array('core', 'forums', 'members'))) {
             continue;
         }
         $versions[] = array($long, $human);
     }
     /* Return data ;o */
     $minVersions = $this->registry->output->formDropdown("minVersion[{$i}]", $versions);
     $maxVersions = $this->registry->output->formDropdown("maxVersion[{$i}]", $versions);
     $this->returnHtml("{$this->lang->words['a_min']}: {$minVersions}<br /><br />{$this->lang->words['a_max']}: {$maxVersions}");
 }
 /**
  * Little function to return the version number data
  *
  * Handy to use when dealing with IN_DEV, etc
  * Uses the constant where available
  *
  * @access	public
  * @param	string  App ( Default 'core')
  * @return	array  array( 'long' => x, 'human' => x )
  */
 public static function fetchVersionNumber($app = 'core')
 {
     if (!defined(IPB_VERSION) or !defined(IPB_LONG_VERSION)) {
         require_once IPS_ROOT_PATH . 'setup/sources/base/setup.php';
         $XMLVersions = IPSSetUp::fetchXmlAppVersions($app);
         $tmp = $XMLVersions;
         krsort($tmp);
         foreach ($tmp as $long => $human) {
             $return = array('long' => $long, 'human' => $human);
             break;
         }
     } else {
         $return = array('long' => IPB_LONG_VERSION, 'human' => IPB_VERSION);
     }
     return $return;
 }
예제 #9
0
 /**
  * Check if the hook meets all the requirements
  * 
  * @param	mixed	$hook	Can be an hook ID or an array of the hook data
  * @return	@e array Errors found
  */
 public function checkHookRequirements($hook)
 {
     /* Init vars */
     $hookData = array();
     $reqsData = array();
     $errors = array();
     /* We already have some data? */
     if (is_array($hook) && count($hook)) {
         $hookData = $hook;
     } elseif (is_int($hook)) {
         $hookData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook));
     }
     /* Requirements are still serialized? */
     if (IPSLib::isSerialized($hookData['hook_requirements'])) {
         $hookData['hook_requirements'] = unserialize($hookData['hook_requirements']);
     }
     /* Make our var shorter... */
     $reqsData =& $hookData['hook_requirements'];
     /* Old data? - @todo: remove this check around 3.3(4?) */
     if (!isset($reqsData['required_applications']['core']) && isset($reqsData['hook_ipb_version_min']) && ($reqsData['hook_ipb_version_min'] > 0 || $reqsData['hook_ipb_version_max'] > 0)) {
         $reqsData['hook_ipb_version_min'] = $reqsData['hook_ipb_version_min'] < 30000 ? 30000 : $reqsData['hook_ipb_version_min'];
         $reqsData['required_applications']['core'] = array('min_version' => intval($reqsData['hook_ipb_version_min']), 'max_version' => intval($reqsData['hook_ipb_version_max']));
     }
     //-----------------------------------------
     // Let's start checking requirements
     //-----------------------------------------
     /* PHP */
     if ($reqsData['hook_php_version_min'] or $reqsData['hook_php_version_max']) {
         if ($reqsData['hook_php_version_min'] and version_compare(PHP_VERSION, $reqsData['hook_php_version_min'], '<') == true) {
             $errors['php_min'] = sprintf($this->lang->words['h_phpold'], $reqsData['hook_php_version_min']);
         }
         if ($reqsData['hook_php_version_max'] and version_compare(PHP_VERSION, $reqsData['hook_php_version_max'], '>') == true) {
             $errors['php_max'] = sprintf($this->lang->words['h_phpnew'], $reqsData['hook_php_version_max']);
         }
     }
     /* Additional applications */
     if (is_array($reqsData['required_applications']) && count($reqsData['required_applications'])) {
         /* Get the setup class */
         require_once IPS_ROOT_PATH . 'setup/sources/base/setup.php';
         /*noLibHook*/
         /* Loop through all apps */
         foreach ($reqsData['required_applications'] as $appKey => $appData) {
             /* Versions file doesn't exist? */
             if (!is_file(IPSLib::getAppDir($appKey) . '/xml/versions.xml')) {
                 $errors[$appKey . '_app'] = sprintf($this->lang->words['hook_require_appnotfound'], $appData['app_name']);
             } elseif (!IPSLib::appIsInstalled($appKey)) {
                 $errors[$appKey . '_app'] = sprintf($this->lang->words['hook_require_appdisabled'], ipsRegistry::$applications[$appKey]['app_title']);
             } elseif ($appData['min_version'] or $appData['max_version']) {
                 /* Fetch and check versions */
                 if (!isset($this->cachedVersions[$appKey])) {
                     $this->cachedVersions[$appKey] = IPSSetUp::fetchXmlAppVersions($appKey);
                 }
                 $versions = $this->cachedVersions[$appKey];
                 if (is_array($versions) && count($versions)) {
                     if (!isset($this->cachedUpgradeInfo[$appKey])) {
                         $_key = in_array($appKey, array('forums', 'members')) ? 'core' : $appKey;
                         $this->cachedUpgradeInfo[$_key] = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'upgrade_history', 'where' => "upgrade_app='{$_key}'", 'order' => 'upgrade_version_id DESC', 'limit' => array(1)));
                         /* Extra caching for the three core apps */
                         if (in_array($appKey, array('core', 'forums', 'members'))) {
                             $this->cachedUpgradeInfo['core'] = $this->cachedUpgradeInfo[$_key];
                             $this->cachedUpgradeInfo['forums'] = $this->cachedUpgradeInfo[$_key];
                             $this->cachedUpgradeInfo['members'] = $this->cachedUpgradeInfo[$_key];
                         }
                     }
                     /* Do we meet tha requirements? */
                     if ($appData['min_version'] and $this->cachedUpgradeInfo[$appKey]['upgrade_version_id'] < $appData['min_version']) {
                         $errors[$appKey . '_min'] = sprintf($this->lang->words['hook_require_tooold'], isset($versions[$appData['min_version']]) ? $versions[$appData['min_version']] : $appData['min_version']);
                     }
                     if ($appData['max_version'] and $this->cachedUpgradeInfo[$appKey]['upgrade_version_id'] > $appData['max_version']) {
                         $errors[$appKey . '_max'] = sprintf($this->lang->words['hook_require_toonew'], isset($versions[$appData['max_version']]) ? $versions[$appData['max_version']] : $appData['max_version']);
                     }
                 }
             }
         }
     }
     return $errors;
 }
 /**
  * Check if you meet hook requirements
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _checkRequirements()
 {
     $id = intval($this->request['id']);
     if (!$id) {
         $this->registry->output->showError($this->lang->words['h_norequirements'], 11112);
     }
     $hookData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id));
     if (!$hookData['hook_id']) {
         $this->registry->output->showError($this->lang->words['h_norequirements'], 11113);
     }
     $hookData['hook_requirements'] = unserialize($hookData['hook_requirements']);
     $hookIpbBad = false;
     $hookPhpBad = false;
     /* Ensure we match at least 3.0.0 */
     $hookData['hook_requirements']['hook_ipb_version_min'] = $hookData['hook_requirements']['hook_ipb_version_min'] < 30000 ? 30000 : $hookData['hook_requirements']['hook_ipb_version_min'];
     if ($hookData['hook_requirements']['hook_ipb_version_min'] or $hookData['hook_requirements']['hook_ipb_version_max']) {
         /* Get the setup class */
         require IPS_ROOT_PATH . "setup/sources/base/setup.php";
         /* Fetch numbers */
         $versions = IPSSetUp::fetchXmlAppVersions('core');
         $currentIPB = (int) IPB_LONG_VERSION;
         if ($hookData['hook_requirements']['hook_ipb_version_min'] and $currentIPB < $hookData['hook_requirements']['hook_ipb_version_min']) {
             $hookIpbBad = $this->lang->words['h_tooold'];
         }
         if ($hookData['hook_requirements']['hook_ipb_version_max'] and $currentIPB > $hookData['hook_requirements']['hook_ipb_version_max']) {
             $hookIpbBad = $this->lang->words['h_toonew'];
         }
         foreach ($versions as $long => $human) {
             if ($hookData['hook_requirements']['hook_ipb_version_min'] <= $long) {
                 $hookData['hook_requirements']['hook_ipb_version_min'] = $human;
                 break;
             }
         }
         krsort($versions);
         foreach ($versions as $long => $human) {
             if ($hookData['hook_requirements']['hook_ipb_version_max'] >= $long) {
                 $hookData['hook_requirements']['hook_ipb_version_max'] = $human;
                 break;
             }
         }
     }
     if ($hookData['hook_requirements']['hook_php_version_min'] or $hookData['hook_requirements']['hook_php_version_max']) {
         if ($hookData['hook_requirements']['hook_php_version_min'] and version_compare(PHP_VERSION, $hookData['hook_requirements']['hook_php_version_min'], '<') == true) {
             $hookPhpBad = $this->lang->words['h_phpold'];
         }
         if ($hookData['hook_requirements']['hook_php_version_max'] and version_compare(PHP_VERSION, $hookData['hook_requirements']['hook_php_version_max'], '>') == true) {
             $hookPhpBad = $this->lang->words['h_phpnew'];
         }
     }
     /* Output */
     $this->registry->output->html .= $this->html->hookRequirements($hookData, $hookIpbBad, $hookPhpBad);
 }
예제 #11
0
 /**
  * Fetch a session
  *
  * @access	public
  * @param	int			Session ID
  * @param	bool		Parse data
  * @return	mixed 		Array of data, or false
  */
 public function fetchSession($diffSessionID, $parse = false)
 {
     $session = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_merge_session', 'where' => 'merge_id=' . $diffSessionID));
     if ($session['merge_id'] and $parse === true) {
         /* Fetch set up class */
         require_once IPS_ROOT_PATH . "setup/sources/base/setup.php";
         /*noLibHook*/
         /* Fetch version numbers */
         $versions = IPSSetUp::fetchXmlAppVersions('core');
         /* Prep dates */
         $session['_date'] = ipsRegistry::getClass('class_localization')->getDate($session['merge_date'], 'TINY');
         /* Prep version numbers */
         $session['_oldHumanVersion'] = $versions[$session['merge_old_version']];
         $session['_newHumanVersion'] = $versions[$session['merge_new_version']];
         /* Skin data */
         $session['_skinData'] = $this->fetchSkinData($session['merge_set_id']);
         /* Title */
         $session['_title'] = $this->fetchReportTitle($session);
     }
     return $session['merge_id'] ? $session : FALSE;
 }
 /**
  * Execute selected method
  *
  * @access	public
  * @param	object		Registry object
  * @return	void
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* Save data */
     if ($this->request['do'] == 'save') {
         $apps = explode(',', IPSSetUp::getSavedData('install_apps'));
         $toSave = array();
         $vNums = array();
         if (is_array($apps) and count($apps)) {
             foreach ($apps as $app) {
                 /* Grab version numbers */
                 $numbers = IPSSetUp::fetchAppVersionNumbers($app);
                 /* Grab all numbers */
                 $nums[$app] = IPSSetUp::fetchXmlAppVersions($app);
                 /* Grab app data */
                 $appData[$app] = IPSSetUp::fetchXmlAppInformation($app);
                 $appClasses[$app] = IPSSetUp::fetchVersionClasses($app, $numbers['current'][0], $numbers['latest'][0]);
                 /* Store starting vnums */
                 $vNums[$app] = $numbers['current'][0];
             }
             /* Got anything? */
             if (count($appClasses)) {
                 foreach ($appClasses as $app => $data) {
                     foreach ($data as $num) {
                         if (file_exists(IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php')) {
                             $_class = 'version_class_' . $num;
                             require_once IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php';
                             $_tmp = new $_class($this->registry);
                             if (method_exists($_tmp, 'preInstallOptionsSave')) {
                                 $_t = $_tmp->preInstallOptionsSave();
                                 if (is_array($_t) and count($_t)) {
                                     $toSave[$app][$num] = $_t;
                                 }
                             }
                         }
                     }
                 }
                 /* Save it */
                 if (count($toSave)) {
                     IPSSetUp::setSavedData('custom_options', $toSave);
                 }
                 if (count($vNums)) {
                     IPSSetUp::setSavedData('version_numbers', $vNums);
                 }
             }
         }
         /* Next Action */
         $this->registry->autoLoadNextAction('upgrade');
     } else {
         if ($this->request['do'] == 'check') {
             /* Check Directory */
             if (!is_array($_POST['apps']) or !count($_POST['apps'])) {
                 $this->registry->output->addError('You must select to upgrade at least one application');
             } else {
                 /* If it's lower than 3.0.0, then add in the removed apps */
                 if (IPSSetUp::is300plus() !== TRUE) {
                     $_POST['apps']['forums'] = 1;
                     $_POST['apps']['members'] = 1;
                     $_POST['apps']['calendar'] = 1;
                     $_POST['apps']['chat'] = 1;
                     $_POST['apps']['portal'] = 1;
                     //$_POST['apps']['subscriptions'] = 1;
                 } else {
                     if ($_POST['apps']['core']) {
                         $_POST['apps']['forums'] = 1;
                         $_POST['apps']['members'] = 1;
                     }
                 }
                 /* Save Form Data */
                 IPSSetUp::setSavedData('install_apps', implode(',', array_keys($_POST['apps'])));
                 /* Got any app-version classes? */
                 $appClasses = array();
                 $output = array();
                 $nums = array();
                 $appData = array();
                 foreach ($_POST['apps'] as $app => $val) {
                     /* Grab version numbers */
                     $numbers = IPSSetUp::fetchAppVersionNumbers($app);
                     /* Grab all numbers */
                     $nums[$app] = IPSSetUp::fetchXmlAppVersions($app);
                     /* Grab app data */
                     $appData[$app] = IPSSetUp::fetchXmlAppInformation($app);
                     $appClasses[$app] = IPSSetUp::fetchVersionClasses($app, $numbers['current'][0], $numbers['latest'][0]);
                 }
                 /* Got anything? */
                 if (count($appClasses)) {
                     foreach ($appClasses as $app => $data) {
                         foreach ($data as $num) {
                             if (file_exists(IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php')) {
                                 $_class = 'version_class_' . $num;
                                 require_once IPSLib::getAppDir($app) . '/setup/versions/upg_' . $num . '/version_class.php';
                                 $_tmp = new $_class($this->registry);
                                 if (method_exists($_tmp, 'preInstallOptionsForm')) {
                                     $_t = $_tmp->preInstallOptionsForm();
                                     if ($_t) {
                                         $output[$app][$num] = array('long' => $nums[$app][$num], 'app' => $appData[$app], 'out' => $_t);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 /* Finally... */
                 if (count($output)) {
                     $this->registry->output->setTitle("Applications");
                     $this->registry->output->setNextAction('apps&do=save');
                     //$this->registry->output->setHideButton( TRUE );
                     $this->registry->output->addContent($this->registry->output->template()->upgrade_appsOptions($output));
                     $this->registry->output->sendOutput();
                 } else {
                     /* Next Action */
                     $this->registry->autoLoadNextAction('upgrade');
                 }
             }
         }
     }
     /* Generate apps... */
     $apps = array('core' => array(), 'ips' => array(), 'other' => array());
     foreach (array('applications', 'applications_addon/ips', 'applications_addon/other') as $_pBit) {
         $path = IPS_ROOT_PATH . $_pBit;
         $handle = opendir($path);
         while (($file = readdir($handle)) !== FALSE) {
             if (!preg_match("#^\\.#", $file)) {
                 if (is_dir($path . '/' . $file)) {
                     //-----------------------------------------
                     // Get it!
                     //-----------------------------------------
                     if (!file_exists(IPS_ROOT_PATH . $_pBit . '/' . $file . '/xml/information.xml')) {
                         continue;
                     }
                     $data = IPSSetUp::fetchXmlAppInformation($file);
                     switch ($_pBit) {
                         case 'applications':
                             $apps['core'][$file] = $data;
                             break;
                         case 'applications_addon/ips':
                             $apps['ips'][$file] = $data;
                             break;
                         case 'applications_addon/other':
                             $apps['other'][$file] = $data;
                             break;
                     }
                 }
             }
         }
         closedir($handle);
     }
     /* Reorder the array so that core is first */
     $new_array = array();
     $new_array['core'] = $apps['core']['core'];
     foreach ($apps['core'] as $app => $data) {
         if ($app == 'core') {
             continue;
         }
         $new_array[$app] = $data;
     }
     $apps['core'] = $new_array;
     /* Now get version numbers */
     foreach ($apps as $type => $app) {
         foreach ($apps[$type] as $app => $data) {
             if ($type == 'core' and ($app == 'forums' or $app == 'members')) {
                 /* Skip forums and members and just count core for now */
                 continue;
             }
             /* Grab version numbers */
             $numbers = IPSSetUp::fetchAppVersionNumbers($app);
             $apps[$type][$app]['_vnumbers'] = $numbers;
         }
     }
     /* If it's lower than 3.0.0, then remove some apps and make them part of 'core' */
     if (IPSSetUp::is300plus() !== TRUE) {
         unset($apps['ips']['calendar']);
         unset($apps['ips']['chat']);
         unset($apps['ips']['portal']);
         unset($apps['other']['subscriptions']);
     }
     /* Page Output */
     $this->registry->output->setTitle("Applications");
     $this->registry->output->setNextAction('apps&do=check');
     //$this->registry->output->setHideButton( TRUE );
     $this->registry->output->addContent($this->registry->output->template()->upgrade_apps($apps));
     $this->registry->output->sendOutput();
 }