Exemplo n.º 1
0
    /**
     * Add pre-upgrade options: Form
     * 
     * @return	string	 HTML block
     */
    public function preInstallOptionsForm()
    {
        $_wrapper = "<ul>%s</ul>";
        $_html = '';
        $posts = $this->DB->buildAndFetch(array('select' => 'count(*) as total', 'from' => 'posts'));
        // Is 3.1?
        if (IPSSetUp::is300plus() && !IPSSetUp::is320plus()) {
            // Got more than 100K posts?
            if ($posts['total'] > 100000 && !$this->DB->checkForField('post_field_int', 'posts')) {
                $_html .= <<<EOF
\t\t<li>
\t\t\t<input type='checkbox' name='manualPostsTableQuery' value='1' checked='checked' />
\t\t\tManually apply changes to the posts table?  Your site has more than 100,000 posts.  We <b>strongly recommend</b> that you enable this option and manually run the provided 
\t\t\tSQL query to alter your posts table in order to prevent timeouts in the web-based upgrader.  If you uncheck this option, it is very possible the upgrader will timeout attempting to
\t\t\tupdate your posts table.
\t\t</li>
EOF;
            }
        }
        $_html .= <<<EOF
\t\t<li>
\t\t\t<input type='checkbox' name='flagBanned' value='1' checked='checked' />
\t\t\t<strong>Flag all members in the Banned member group as banned</strong><br />
\t\t\t3.3.0 removes the need for a specific Banned Group and uses the built in 'flag' on a per-member basis. However, unless you choose to update all
\t\t\tmembers in the current Banned Group as 'banned' they may not appear when searching for banned members in the ACP.
\t\t\t<br />We recommend you keep this box ticked
\t\t</li>
EOF;
        if ($_html) {
            return sprintf($_wrapper, $_html);
        } else {
            return '';
        }
    }
Exemplo n.º 2
0
    /**
     * Add pre-upgrade options: Form
     * 
     * @return	string	 HTML block
     */
    public function preInstallOptionsForm()
    {
        $_wrapper = "<ul>%s</ul>";
        $_html = '';
        $posts = $this->DB->buildAndFetch(array('select' => 'count(*) as total', 'from' => 'posts'));
        // Is 3.1?
        if (IPSSetUp::is300plus() && !IPSSetUp::is320plus()) {
            // Got more than 100K posts?
            if ($posts['total'] > 100000 && !$this->DB->checkForField('post_field_int', 'posts')) {
                $_html .= <<<EOF
\t\t<li>
\t\t\t<input type='checkbox' name='manualPostsTableQuery' value='1' checked='checked' />
\t\t\tВнести изменения в структуру таблицы Posts вручную?  На вашем форуме более 100,000 сообщений.  Мы <b>настоятельно рекомендуем</b> вам включить данную опцию и самостоятельно выполнить 
\t\t\tSQL запросы для обновления таблицы сообщений. Если вы отключите данную опцию существует большая вероятность того, что мастер обновления не сможет обновить форум.
\t\t</li>
EOF;
            }
        }
        $_html .= <<<EOF
\t\t<li>
\t\t\t<input type='checkbox' name='flagBanned' value='1' checked='checked' />
\t\t\t<strong>Отметить всех пользователей из группы "Забаненные", как забаненных</strong><br />
\t\t\tВ 3.3.0 удалена отдельная группа для заблокированных, теперь проверка осуществляется на основе метки для каждого пользователя. Возможно, что часть пользователей, отмеченных как
\t\t\tзабаненные, в результате такого переноса, не будут находится поиском в админ-центре при применении фильтра поиска по заблокированным.
\t\t\t<br />Мы рекомендуем воспользоваться этой опцией.
\t\t</li>
EOF;
        if ($_html) {
            return sprintf($_wrapper, $_html);
        } else {
            return '';
        }
    }
Exemplo n.º 3
0
 /**
  * Execute selected method
  *
  * @access	public
  * @param	object		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* If less than 3, just bounce out as settings tables won't be here, etc */
     if (IPSSetUp::is300plus() !== TRUE) {
         $this->registry->autoLoadNextAction('upgrade');
         return;
     }
     if ($this->request['do'] == 'check') {
         $lcheck = $this->check();
         if ($lcheck === TRUE) {
             $this->registry->autoLoadNextAction('upgrade');
             return;
         }
     } else {
         $lcheck = $this->check(TRUE);
         if ($lcheck === TRUE) {
             $this->registry->autoLoadNextAction('upgrade');
             return;
         }
     }
     $this->registry->output->setTitle("License Key");
     $this->registry->output->setNextAction("license&do=check");
     $this->registry->output->addContent($this->registry->output->template()->page_license($lcheck));
     $this->registry->output->sendOutput();
 }
Exemplo n.º 4
0
 /**
  * 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();
 }
Exemplo n.º 5
0
 /**
  * Runs the upgrade specific file
  *
  * @return void
  */
 public function install_appclass()
 {
     /* INIT */
     $continue = 0;
     $customHTML = '';
     $file = '';
     /* Reset Errors */
     $this->_resetErrors();
     /* IPB 2.0.0+ Upgrade file */
     $fileNewer = IPSLib::getAppDir($this->_currentApp) . '/setup/versions/upg_' . $this->_uipLong . '/version_upgrade.php';
     /* Older files */
     $fileLegacy = IPSLib::getAppDir($this->_currentApp) . '/setup/versions/upg_' . $this->_uipLong . '/version_upgrade_' . $this->_dbDriver . '.php';
     /* Got any file? */
     if (is_file($fileNewer)) {
         $file = $fileNewer;
     } else {
         if (is_file($fileLegacy)) {
             $file = $fileLegacy;
         }
     }
     /* Do we have a file? */
     if ($file) {
         require_once $file;
         /*noLibHook*/
         $upgrade = new version_upgrade();
         $result = $upgrade->doExecute($this->registry);
         if (count($this->registry->output->fetchWarnings()) > 0) {
             if (!$result) {
                 $this->registry->output->setNextAction('upgrade&do=appclass');
             } elseif ($this->_uipLong >= $this->_latestLong || $this->_uipLong == 0) {
                 /* Got another app to do? */
                 $this->runCustomScript($this->_currentApp);
                 $next = IPSSetUp::fetchNextApplication($this->_currentApp, '', $this->settings['gb_char_set']);
                 if ($next['key']) {
                     $this->registry->output->setNextAction('upgrade&do=sql&appdir=' . $next['key']);
                 } else {
                     $this->registry->output->setNextAction('upgrade&do=checkdb');
                 }
             } else {
                 $this->registry->output->setNextAction('upgrade&do=sql');
             }
             $this->registry->output->setTitle("Обновление: Обновление версии");
             $this->registry->output->sendOutput();
         }
         /* App specific version upgrade is done */
         if ($result) {
             /* The individual upgrade files all shoot you to 2.0... */
             if ($this->_currentApp == 'core' and $this->_uipLong < 20000) {
                 //$this->_uipLong = '10004';
             }
             /* Update version history */
             if (IPSSetUp::is300plus() === TRUE) {
                 $this->DB->insert('upgrade_history', array('upgrade_version_id' => $this->_uipLong, 'upgrade_version_human' => $this->_uipHuman, 'upgrade_date' => time(), 'upgrade_app' => $this->_currentApp, 'upgrade_notes' => '', 'upgrade_mid' => 0));
                 /* Update app */
                 $_in = $this->_currentApp == 'core' ? "'core', 'forums', 'members'" : "'" . $this->_currentApp . "'";
                 $this->DB->update('core_applications', array('app_long_version' => $this->_uipLong, 'app_version' => $this->_uipHuman, 'app_website' => $this->_appData['website'], 'app_update_check' => $this->_appData['update_check']), 'app_directory IN (' . $_in . ')');
             } else {
                 $this->DB->insert('upgrade_history', array('upgrade_version_id' => $this->_uipLong, 'upgrade_version_human' => $this->_uipHuman, 'upgrade_date' => time(), 'upgrade_notes' => '', 'upgrade_mid' => 0));
             }
             if ($upgrade->fetchOutput()) {
                 $customHTML = $upgrade->fetchOutput();
             } else {
                 $output[] = "Успешно обновлено до версии {$this->_uipHuman}";
             }
         } else {
             if ($upgrade->fetchOutput()) {
                 $customHTML = $upgrade->fetchOutput();
             } else {
                 $output[] = "Продолжение обновления";
             }
             $continue = 1;
         }
     } else {
         /* Nothing to run */
         if ($this->_uipLong) {
             /* Update version history */
             if (IPSSetUp::is300plus() === TRUE) {
                 $this->DB->insert('upgrade_history', array('upgrade_version_id' => $this->_uipLong, 'upgrade_version_human' => $this->_uipHuman, 'upgrade_date' => time(), 'upgrade_app' => $this->_currentApp, 'upgrade_notes' => '', 'upgrade_mid' => 0));
                 /* Update app */
                 $_in = $this->_currentApp == 'core' ? "'core', 'forums', 'members'" : "'" . $this->_currentApp . "'";
                 $updateApp = array('app_long_version' => $this->_uipLong, 'app_version' => $this->_uipHuman);
                 /* Check only 1 field since we add both at the same time anyway */
                 if ($this->DB->checkForField('app_website', 'core_applications')) {
                     $updateApp['app_website'] = $this->_appData['website'];
                     $updateApp['app_update_check'] = $this->_appData['update_check'];
                 }
                 $this->DB->update('core_applications', $updateApp, 'app_directory IN (' . $_in . ')');
             } else {
                 $this->DB->insert('upgrade_history', array('upgrade_version_id' => $this->_uipLong, 'upgrade_version_human' => $this->_uipHuman, 'upgrade_date' => time(), 'upgrade_notes' => '', 'upgrade_mid' => 0));
             }
             $output[] = "Успешно обновлено до версии {$this->_uipHuman}";
         }
     }
     //-----------------------------------------
     // Next...
     //-----------------------------------------
     if ($continue) {
         $this->registry->output->setNextAction('upgrade&do=appclass');
     } elseif ($this->_uipLong >= $this->_latestLong || $this->_uipLong == 0) {
         /* Got another app to do? */
         $this->runCustomScript($this->_currentApp);
         $next = IPSSetUp::fetchNextApplication($this->_currentApp, '', $this->settings['gb_char_set']);
         if ($next['key']) {
             $this->registry->output->setNextAction('upgrade&do=sql&appdir=' . $next['key']);
         } else {
             $this->registry->output->setNextAction('upgrade&do=checkdb');
         }
     } else {
         $this->registry->output->setNextAction('upgrade&do=sql');
     }
     $this->registry->output->setTitle("Обновление: Обновление версии");
     if ($customHTML) {
         $this->registry->output->addContent($customHTML);
     } else {
         $this->registry->output->addContent($this->registry->output->template()->page_refresh($output));
     }
     $this->registry->output->setInstallStep($this->_stepCount, $this->_totalSteps);
     $this->registry->output->sendOutput();
 }
 /**
  * Initiate the registry
  *
  * @access	public
  * @return	@e void
  */
 public static function init()
 {
     if (self::$initiated === TRUE) {
         return FALSE;
     }
     self::$initiated = TRUE;
     /* Log current upgrade step */
     self::logUpgradeStep();
     /* Load static classes */
     require IPS_ROOT_PATH . "sources/base/core.php";
     /*noLibHook*/
     require IPS_ROOT_PATH . "sources/base/ipsMember.php";
     /*noLibHook*/
     require_once IPS_ROOT_PATH . "setup/sources/base/setup.php";
     /*noLibHook*/
     /* Load conf global and set up DB */
     if (IPS_IS_UPGRADER) {
         if (!is_file(DOC_IPS_ROOT_PATH . "conf_global.php")) {
             print "Cannot locate: " . DOC_IPS_ROOT_PATH . "conf_global.php";
             exit;
         }
         self::loadConfGlobal();
         /* Got settings? */
         if (!ipsRegistry::$settings['sql_driver']) {
             print "Settings not loaded from: " . DOC_IPS_ROOT_PATH . "conf_global.php - did you mean to install?";
             exit;
         }
         self::setDBHandle();
     } else {
         /* Ensure char set is defined */
         if (!defined('IPS_DOC_CHAR_SET')) {
             define('IPS_DOC_CHAR_SET', strtoupper(IPSSetUp::charSet));
         }
         if (!defined('IPS_CACHE_PATH')) {
             define('IPS_CACHE_PATH', DOC_IPS_ROOT_PATH);
         }
         require IPS_ROOT_PATH . "setup/sources/base/install.php";
         /*noLibHook*/
     }
     /* Input set up... */
     if (is_array($_POST) and count($_POST)) {
         foreach ($_POST as $key => $value) {
             # Skip post arrays
             if (!is_array($value)) {
                 $_POST[$key] = IPSText::stripslashes($value);
             }
         }
     }
     //-----------------------------------------
     // Clean globals, first.
     //-----------------------------------------
     IPSLib::cleanGlobals($_GET);
     IPSLib::cleanGlobals($_POST);
     IPSLib::cleanGlobals($_COOKIE);
     IPSLib::cleanGlobals($_REQUEST);
     # GET first
     $input = IPSLib::parseIncomingRecursively($_GET, array());
     # Then overwrite with POST
     self::$request = IPSLib::parseIncomingRecursively($_POST, $input);
     # Assign request method
     self::$request['request_method'] = strtolower(my_getenv('REQUEST_METHOD'));
     self::_setUpAppData();
     /* Make sure it's a string */
     if (is_array(self::$request['section'])) {
         self::$request['section'] = '';
     }
     /* Get caches */
     self::$handles['caches'] = ips_CacheRegistry::instance();
     if (IPS_IS_UPGRADER) {
         /* Make sure all is well before we proceed */
         self::instance()->setUpSettings();
         /* Build module and application caches */
         self::instance()->checkCaches();
         /* Load 'legacy' systems */
         $file = '';
         if (IPSSetUp::is300plus() === TRUE) {
             $file = '3xx.php';
         } else {
             if (IPSSetUp::is200plus() === TRUE) {
                 $file = '2xx.php';
             } else {
                 $file = '1xx.php';
             }
         }
         require_once IPS_ROOT_PATH . 'setup/sources/legacy/' . $file;
         /*noLibHook*/
         self::instance()->setClass('legacy', new upgradeLegacy(self::instance()));
     }
     /* Set up member */
     self::$handles['member'] = ips_MemberRegistry::instance();
     # Thaw saved data
     IPSSetUp::thawSavedData();
     /* Gather other classes */
     require_once IPS_ROOT_PATH . 'setup/sources/classes/output/output.php';
     /*noLibHook*/
     self::instance()->setClass('output', new output(self::instance(), TRUE));
     # Fetch global config
     if (self::readGlobalConfig() === FALSE) {
         self::getClass('output')->addError("Could not load config.xml");
     }
     if (IPS_IS_UPGRADER) {
         /* Check session status */
         $validationStatus = self::member()->sessionClass()->getStatus();
         $validationMessage = self::member()->sessionClass()->getMessage();
         if (self::$request['section'] and self::$request['section'] != 'index' and !$validationStatus) {
             /* Force log in */
             self::getClass('output')->setTitle("Upgrader: Error");
             self::getClass('output')->setNextAction('');
             self::getClass('output')->addContent(self::getClass('output')->template()->page_error($validationMessage));
             self::getClass('output')->sendOutput();
             exit;
         }
     } else {
         # Installer locked?
         if (is_file(DOC_IPS_ROOT_PATH . 'cache/installer_lock.php')) {
             self::getClass('output')->setTitle("Installer: Error");
             self::getClass('output')->setNextAction('');
             self::getClass('output')->addContent(self::getClass('output')->template()->page_locked());
             self::getClass('output')->sendOutput();
             exit;
         }
     }
 }
 /**
  * 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();
 }
 /**
  * Runs the upgrade specific file
  *
  * @return void
  */
 public function install_appclass()
 {
     /* INIT */
     $continue = 0;
     $customHTML = '';
     $file = '';
     /* Reset Errors */
     $this->_resetErrors();
     /* IPB 2.0.0+ Upgrade file */
     $fileNewer = IPSLib::getAppDir($this->_currentApp) . '/setup/versions/upg_' . $this->_uipLong . '/version_upgrade.php';
     /* Older files */
     $fileLegacy = IPSLib::getAppDir($this->_currentApp) . '/setup/versions/upg_' . $this->_uipLong . '/version_upgrade_' . $this->_dbDriver . '.php';
     /* Got any file? */
     if (file_exists($fileNewer)) {
         $file = $fileNewer;
     } else {
         if (file_exists($fileLegacy)) {
             $file = $fileLegacy;
         }
     }
     /* Do we have a file? */
     if ($file) {
         require_once $file;
         $upgrade = new version_upgrade();
         $result = $upgrade->doExecute($this->registry);
         if (count($this->registry->output->fetchWarnings()) > 0) {
             if (!$result) {
                 $this->registry->output->setNextAction('upgrade&do=appclass');
             } elseif ($this->_uipLong >= $this->_latestLong || $this->_uipLong == 0) {
                 /* Got another app to do? */
                 $next = IPSSetUp::fetchNextApplication($this->_currentApp);
                 if ($next['key']) {
                     $this->registry->output->setNextAction('upgrade&do=sql&appdir=' . $next['key']);
                 } else {
                     $this->registry->output->setNextAction('upgrade&do=checkdb');
                 }
             } else {
                 $this->registry->output->setNextAction('upgrade&do=sql');
             }
             $this->registry->output->setTitle("Upgrade: Version Upgrade");
             $this->registry->output->sendOutput();
         }
         /* App specific version upgrade is done */
         if ($result) {
             /* The individual upgrade files all shoot you to 2.0... */
             if ($this->_currentApp == 'core' and $this->_uipLong < 20000) {
                 //$this->_uipLong = '10004';
             }
             /* Update version history */
             if (IPSSetUp::is300plus() === TRUE) {
                 $this->DB->insert('upgrade_history', array('upgrade_version_id' => $this->_uipLong, 'upgrade_version_human' => $this->_uipHuman, 'upgrade_date' => time(), 'upgrade_app' => $this->_currentApp, 'upgrade_mid' => 0));
                 /* Update app */
                 $_in = $this->_currentApp == 'core' ? "'core', 'forums', 'members'" : "'" . $this->_currentApp . "'";
                 $this->DB->update('core_applications', array('app_long_version' => $this->_uipLong, 'app_version' => $this->_uipHuman), 'app_directory IN (' . $_in . ')');
             } else {
                 $this->DB->insert('upgrade_history', array('upgrade_version_id' => $this->_uipLong, 'upgrade_version_human' => $this->_uipHuman, 'upgrade_date' => time(), 'upgrade_mid' => 0));
             }
             if ($upgrade->fetchOutput()) {
                 $customHTML = $upgrade->fetchOutput();
             } else {
                 $output[] = "Successfully upgraded to version {$this->_uipHuman}";
             }
         } else {
             if ($upgrade->fetchOutput()) {
                 $customHTML = $upgrade->fetchOutput();
             } else {
                 $output[] = "Proceeding with update...";
             }
             $continue = 1;
         }
     } else {
         /* Nothing to run */
         if ($this->_uipLong) {
             /* Update version history */
             if (IPSSetUp::is300plus() === TRUE) {
                 $this->DB->insert('upgrade_history', array('upgrade_version_id' => $this->_uipLong, 'upgrade_version_human' => $this->_uipHuman, 'upgrade_date' => time(), 'upgrade_app' => $this->_currentApp, 'upgrade_mid' => 0));
                 /* Update app */
                 $_in = $this->_currentApp == 'core' ? "'core', 'forums', 'members'" : "'" . $this->_currentApp . "'";
                 $this->DB->update('core_applications', array('app_long_version' => $this->_uipLong, 'app_version' => $this->_uipHuman), 'app_directory IN (' . $_in . ')');
             } else {
                 $this->DB->insert('upgrade_history', array('upgrade_version_id' => $this->_uipLong, 'upgrade_version_human' => $this->_uipHuman, 'upgrade_date' => time(), 'upgrade_mid' => 0));
             }
             $output[] = "Successfully upgraded to version {$this->_uipHuman}";
         }
     }
     //-----------------------------------------
     // Next...
     //-----------------------------------------
     if ($continue) {
         $this->registry->output->setNextAction('upgrade&do=appclass');
     } elseif ($this->_uipLong >= $this->_latestLong || $this->_uipLong == 0) {
         /* Got another app to do? */
         $next = IPSSetUp::fetchNextApplication($this->_currentApp);
         if ($next['key']) {
             $this->registry->output->setNextAction('upgrade&do=sql&appdir=' . $next['key']);
         } else {
             $this->registry->output->setNextAction('upgrade&do=checkdb');
         }
     } else {
         $this->registry->output->setNextAction('upgrade&do=sql');
     }
     $this->registry->output->setTitle("Upgrade: Version Upgrade");
     if ($customHTML) {
         $this->registry->output->addContent($customHTML);
     } else {
         $this->registry->output->addContent($this->registry->output->template()->page_refresh($output));
     }
     $this->registry->output->setInstallStep($this->_stepCount, $this->_totalSteps);
     $this->registry->output->sendOutput();
 }