示例#1
0
 /**
  * Execute selected method
  *
  * @access	public
  * @param	object		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* INIT */
     $error = false;
     /* Check input? */
     if ($this->request['do'] == 'check') {
         /* Check Directory */
         if (!is_dir($this->request['install_dir'])) {
             $error = true;
             $this->registry->output->addWarning('The specified directory does not exist');
         }
         /* Check URL */
         if (!$this->request['install_dir']) {
             $error = true;
             $this->registry->output->addWarning('You did not specify a URL');
         }
         if (!$error) {
             /* Save Form Data */
             IPSSetUp::setSavedData('install_dir', preg_replace("#(//)\$#", "", str_replace('\\', '/', $this->request['install_dir']) . '/'));
             IPSSetUp::setSavedData('install_url', preg_replace("#(//)\$#", "", str_replace('\\', '/', $this->request['install_url']) . '/'));
             /* Next Action */
             $this->registry->autoLoadNextAction('db');
         }
     }
     /* Guess at directory */
     if (!defined('CP_DIRECTORY')) {
         define('CP_DIRECTORY', 'admin');
     }
     $dir = str_replace(CP_DIRECTORY . '/install', '', getcwd());
     $dir = str_replace(CP_DIRECTORY . '\\install', '', $dir);
     // Windows
     $dir = str_replace('\\', '/', $dir);
     /* Guess at URL */
     $url = str_replace("/" . CP_DIRECTORY . "/installer/index.php", "", $_SERVER['HTTP_REFERER']);
     $url = str_replace("/" . CP_DIRECTORY . "/installer/", "", $url);
     $url = str_replace("/" . CP_DIRECTORY . "/installer", "", $url);
     $url = str_replace("/" . CP_DIRECTORY . "/install/index.php", "", $_SERVER['HTTP_REFERER']);
     $url = str_replace("/" . CP_DIRECTORY . "/install/", "", $url);
     $url = str_replace("/" . CP_DIRECTORY . "/install", "", $url);
     $url = str_replace("/" . CP_DIRECTORY, "", $url);
     $url = str_replace("index.php", "", $url);
     $url = preg_replace("!\\?(.+?)*!", "", $url);
     $url = "{$url}/";
     /* Page Output */
     $this->registry->output->setTitle("Paths and URLs");
     $this->registry->output->setNextAction("address&do=check");
     $this->registry->output->addContent($this->registry->output->template()->page_address($dir, $url));
     $this->registry->output->sendOutput();
 }
示例#2
0
 /**
  * Execute selected method
  *
  * @access	public
  * @param	object		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     $_e = 0;
     /* Check input? */
     if ($this->request['do'] == 'check') {
         if (!$this->request['username']) {
             $_e = 1;
             $this->registry->output->addWarning('You must specify a display name for the admin account');
         }
         if (!$this->request['password']) {
             $_e = 1;
             $this->registry->output->addWarning('You must specify a password for the admin account');
         } else {
             if ($this->request['password'] != $this->request['confirm_password']) {
                 $_e = 1;
                 $this->registry->output->addWarning('The admin passwords did not match');
             }
         }
         if (!$this->request['email'] or IPSText::checkEmailAddress($this->request['email']) !== TRUE) {
             $_e = 1;
             $this->registry->output->addWarning('You must specify an email address for the admin account');
         }
         if ($_e) {
             $this->registry->output->setTitle("Admin: Errors");
             $this->registry->output->setNextAction('admin&do=check');
             $this->registry->output->addContent($this->registry->output->template()->page_admin());
             $this->registry->output->sendOutput();
         } else {
             /* Save Form Data */
             IPSSetUp::setSavedData('admin_user', $this->request['username']);
             IPSSetUp::setSavedData('admin_pass', $this->request['password']);
             IPSSetUp::setSavedData('admin_email', $this->request['email']);
             /* Next Action */
             $this->registry->autoLoadNextAction('install');
             return;
         }
     }
     /* Output */
     $this->registry->output->setTitle("Admin Account Creation");
     $this->registry->output->setNextAction('admin&do=check');
     $this->registry->output->addContent($this->registry->output->template()->page_admin());
     $this->registry->output->sendOutput();
 }
示例#3
0
 /**
  * Execute selected method
  *
  * @access	public
  * @param	object		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     $_e = 0;
     /* Check input? */
     if ($this->request['do'] == 'check') {
         if (!$this->request['username']) {
             $_e = 1;
             $this->registry->output->addWarning('Необходимо указать отображаемое имя пользователя');
         }
         if (!$this->request['password']) {
             $_e = 1;
             $this->registry->output->addWarning('Необходимо ввести пароль');
         } else {
             if ($this->request['password'] != $this->request['confirm_password']) {
                 $_e = 1;
                 $this->registry->output->addWarning('Введенные пароли не совпадают');
             }
         }
         if (!$this->request['email'] or IPSText::checkEmailAddress($this->request['email']) !== TRUE) {
             $_e = 1;
             $this->registry->output->addWarning('Необходимо указать Email');
         }
         if ($_e) {
             $this->registry->output->setTitle("Администратор: Ошибка");
             $this->registry->output->setNextAction('admin&do=check');
             $this->registry->output->addContent($this->registry->output->template()->page_admin());
             $this->registry->output->sendOutput();
         } else {
             /* Save Form Data */
             IPSSetUp::setSavedData('admin_user', $this->request['username']);
             IPSSetUp::setSavedData('admin_pass', $this->request['password']);
             IPSSetUp::setSavedData('admin_email', $this->request['email']);
             /* Next Action */
             $this->registry->autoLoadNextAction('install');
             return;
         }
     }
     /* Output */
     $this->registry->output->setTitle("Создание учетной записи администратора");
     $this->registry->output->setNextAction('admin&do=check');
     $this->registry->output->addContent($this->registry->output->template()->page_admin());
     $this->registry->output->sendOutput();
 }
示例#4
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();
 }
示例#5
0
 /**
  * Import Settings
  *
  * @return	@e void
  */
 public function settings()
 {
     /* INIT */
     $vars = $this->getVars();
     $output = array();
     $errors = array();
     $knownSettings = array();
     $this->registry->class_localization->loadLanguageFile(array('admin_tools'), 'core');
     if (is_file($this->app_full_path . 'xml/' . $vars['app_directory'] . '_settings.xml')) {
         /* Get the settings class */
         $classToLoad = IPSLib::loadActionOverloader(IPS_ROOT_PATH . 'applications/core/modules_admin/settings/settings.php', 'admin_core_settings_settings');
         $settings = new $classToLoad();
         $settings->makeRegistryShortcuts($this->registry);
         $this->request['app_dir'] = $vars['app_directory'];
         //-----------------------------------------
         // Known settings
         //-----------------------------------------
         if (substr($this->settings['_original_base_url'], -1) == '/') {
             IPSSetUp::setSavedData('install_url', substr($this->settings['_original_base_url'], 0, -1));
         }
         if (substr($this->settings['base_dir'], -1) == '/') {
             IPSSetUp::setSavedData('install_dir', substr($this->settings['base_dir'], 0, -1));
         }
         /* Fetch known settings  */
         if (is_file(IPSLib::getAppDir($vars['app_directory']) . '/setup/versions/install/knownSettings.php')) {
             require IPSLib::getAppDir($vars['app_directory']) . '/setup/versions/install/knownSettings.php';
             /*noLibHook*/
         }
         $settings->importAllSettings(1, 1, $knownSettings);
         $settings->settingsRebuildCache();
     } else {
         $this->registry->output->global_message = $this->lang->words['settings_nofile'];
     }
     $output[] = $this->registry->output->global_message;
     /* Clear main messaage */
     $this->registry->output->global_message = '';
     /* Show redirect... */
     $this->showRedirectScreen($vars['app_directory'], $output, $errors, $this->getNextURL('hooks', $vars));
 }
示例#6
0
 /**
  * Execute selected method
  *
  * @access	public
  * @param	object		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* Dealing with the result of the form asking for DB input */
     if ($this->request['do'] == 'check') {
         /* Make sure the fields were filled out */
         if (!$this->request['overwrite'] and !$this->request['db_host'] || !$this->request['db_name'] || !$this->request['db_user']) {
             $this->registry->output->addWarning('You must fill out the form completely');
         } else {
             if (preg_match("/[^a-zA-Z0-9_]/", $this->request['db_pre'])) {
                 $this->registry->output->addWarning('You cannot use special characters in the database prefix');
             } else {
                 //-----------------------------------------
                 // Quick basic check for extensions
                 //-----------------------------------------
                 if (strtolower(IPSSetUp::getSavedData('sql_driver')) == 'mysql') {
                     if (!function_exists('mysqli_connect') and !function_exists('mysql_connect')) {
                         $this->registry->output->setTitle("Databases: Error");
                         $this->registry->output->setNextAction('db&do=check');
                         $this->registry->output->addWarning("You do not have the mysql or mysqli PHP extension installed.  You must install one of these PHP extensions before you can continue.");
                         $this->registry->output->addContent($this->fetchContent());
                         $this->registry->output->sendOutput();
                         return;
                     }
                 }
                 //-----------------------------------------
                 // Load DB driver..
                 //-----------------------------------------
                 require_once IPS_KERNEL_PATH . 'classDb' . ucwords(IPSSetUp::getSavedData('sql_driver')) . '.php';
                 /*noLibHook*/
                 $classname = "db_driver_" . IPSSetUp::getSavedData('sql_driver');
                 $DB = new $classname();
                 $DB->obj['sql_database'] = $this->request['db_name'];
                 $DB->obj['sql_user'] = $this->request['db_user'];
                 $DB->obj['sql_pass'] = $_REQUEST['db_pass'];
                 $DB->obj['sql_host'] = $this->request['db_host'];
                 $DB->obj['sql_tbl_prefix'] = $this->request['db_pre'];
                 //--------------------------------------------------
                 // Any "extra" configs required for this driver?
                 //--------------------------------------------------
                 if (is_file(IPS_ROOT_PATH . 'setup/sql/' . IPSSetUp::getSavedData('sql_driver') . '_install.php')) {
                     require_once IPS_ROOT_PATH . 'setup/sql/' . IPSSetUp::getSavedData('sql_driver') . '_install.php';
                     /*noLibHook*/
                     $extra_install = new install_extra($this->registry);
                     $extra_install->install_form_process();
                     if (count($extra_install->errors)) {
                         $this->registry->output->addWarning(implode("<br />", $extra_install->errors));
                     }
                     if (is_array($extra_install->info_extra) and count($extra_install->info_extra)) {
                         foreach ($extra_install->info_extra as $k => $v) {
                             IPSSetUp::setSavedData('__sql__' . $k, $v);
                         }
                     }
                     if (is_array($DB->connect_vars) and count($DB->connect_vars)) {
                         foreach ($DB->connect_vars as $k => $v) {
                             $DB->connect_vars[$k] = $extra_install->info_extra[$k];
                         }
                     }
                 }
                 //-----------------------------------------
                 // Error check
                 //-----------------------------------------
                 if (count($extra_install->errors)) {
                     $this->registry->output->setTitle("Databases: Error");
                     $this->registry->output->setNextAction('db&do=check');
                     $this->registry->output->addContent($this->fetchContent());
                     $this->registry->output->sendOutput();
                     return;
                 }
                 //------------------------------------------
                 // Make CONSTANT
                 //------------------------------------------
                 define('SQL_DRIVER', IPSSetUp::getSavedData('sql_driver'));
                 define('IPS_MAIN_DB_CLASS_LOADED', TRUE);
                 //------------------------------------------
                 // Try a DB connection
                 //------------------------------------------
                 $DB->return_die = true;
                 if (!$DB->connect()) {
                     $errors[] = $DB->error;
                 }
                 //-----------------------------------------
                 // Error check
                 //-----------------------------------------
                 if (is_array($errors) and count($errors)) {
                     $this->registry->output->setTitle("Databases: Error");
                     $this->registry->output->setNextAction('db&do=check');
                     $this->registry->output->addWarning(implode("<br />", $errors));
                     $this->registry->output->addContent($this->fetchContent());
                     $this->registry->output->sendOutput();
                     return;
                 }
                 /* Save Form Data */
                 IPSSetUp::setSavedData('db_host', $_REQUEST['db_host']);
                 IPSSetUp::setSavedData('db_name', $this->request['db_name']);
                 IPSSetUp::setSavedData('db_user', $this->request['db_user']);
                 IPSSetUp::setSavedData('db_pass', $_REQUEST['db_pass']);
                 IPSSetUp::setSavedData('db_pre', $this->request['db_pre']);
                 /* Are we overwriting an IP.Board 2.x or 3.x installation? */
                 if (!$this->request['overwrite']) {
                     if ($DB->checkForTable('upgrade_history')) {
                         /* Get latest version */
                         $latest = $DB->buildAndFetch(array('select' => '*', 'from' => 'upgrade_history', 'where' => "upgrade_app='core'", 'order' => 'upgrade_version_id DESC', 'limit' => array(0, 1)));
                         if (is_array($latest)) {
                             $this->registry->output->setTitle("Databases: Error");
                             $this->registry->output->setNextAction('db&do=check');
                             $this->registry->output->addWarning("Existing IP.Board " . $latest['upgrade_version_human'] . " Detected");
                             $this->registry->output->addContent($this->fetchContent(TRUE));
                             $this->registry->output->sendOutput();
                             return;
                         }
                     }
                 }
                 /* Next Action */
                 $this->registry->autoLoadNextAction('admin');
                 return;
             }
         }
     }
     //--------------------------------------------------
     // DO WE HAVE A DB DRIVER SET?
     //--------------------------------------------------
     IPSSetUp::setSavedData('sql_driver', strtolower(IPSSetUp::getSavedData('sql_driver') == "" ? $_REQUEST['sql_driver'] : IPSSetUp::getSavedData('sql_driver')));
     if (!IPSSetUp::getSavedData('sql_driver')) {
         //----------------------------------------------
         // Test to see how many DB driver's we've got..
         //----------------------------------------------
         $dh = opendir(IPS_KERNEL_PATH);
         while ($file = @readdir($dh)) {
             if (preg_match("/^classDb([a-zA-Z0-9]*)\\.php/i", $file, $driver)) {
                 if (stristr($driver[1], 'client') or !$driver[1]) {
                     continue;
                 }
                 $drivers[] = $driver[1];
             }
         }
         @closedir($dh);
         //----------------------------------------------
         // Got more than one?
         //----------------------------------------------
         if (count($drivers) > 1) {
             //------------------------------------------
             // Show choice screen first...
             //------------------------------------------
             /* Page Output */
             $this->registry->output->setTitle("Databases");
             $this->registry->output->setNextAction('db');
             $this->registry->output->addContent($this->registry->output->template()->page_check_db($drivers));
             $this->registry->output->sendOutput();
         } else {
             //------------------------------------------
             // Use only driver installed
             //------------------------------------------
             IPSSetUp::setSavedData('sql_driver', strtolower($drivers[0]));
         }
     }
     $this->request['db_host'] = $this->request['db_host'] ? $this->request['db_host'] : 'localhost';
     $this->registry->output->setTitle("Databases");
     $this->registry->output->setNextAction('db&do=check');
     $this->registry->output->addContent($this->fetchContent());
     $this->registry->output->sendOutput();
 }
 /**
  * Rebuilds language from XML files
  *
  * @return @e void
  */
 public function rebuildFromXml()
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $apps = array();
     $previous = trim($this->request['previous']);
     $type = trim($this->request['type']);
     $id = intval($this->request['id']);
     $_word = $type == 'admin' ? 'admin' : 'public';
     //-----------------------------------------
     // Verify writable
     //-----------------------------------------
     if (!is_writeable(IPS_CACHE_PATH . 'cache/lang_cache/' . $id)) {
         $this->registry->output->global_error = $this->lang->words['cannot_write_to_cache'] ? sprintf($this->lang->words['cannot_write_to_cache'], $id) : "Cannot write to cache/lang_cache/" . $id;
         $this->languagesList();
         return;
     }
     //-----------------------------------------
     // Get setup class
     //-----------------------------------------
     require_once IPS_ROOT_PATH . "setup/sources/base/setup.php";
     /*noLibHook*/
     //-----------------------------------------
     // Get apps
     //-----------------------------------------
     foreach (ipsRegistry::$applications as $appDir => $appData) {
         $apps[] = $appDir;
     }
     //-----------------------------------------
     // Klude for setup class
     //-----------------------------------------
     IPSSetUp::setSavedData('install_apps', implode(',', $apps));
     //-----------------------------------------
     // Get next app
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous, '', $this->settings['gb_char_set']);
     if ($next['key']) {
         $msg = $next['title'] . sprintf($this->lang->words['importing_x_langs'], $_word);
         $_PATH = IPSLib::getAppDir($next['key']) . '/xml/';
         //-----------------------------------------
         // Try to import all the lang packs
         //-----------------------------------------
         try {
             foreach (new DirectoryIterator($_PATH) as $f) {
                 if (preg_match("#" . $_word . "_(.+?)_language_pack.xml#", $f->getFileName())) {
                     $this->request['file_location'] = $_PATH . $f->getFileName();
                     $this->imprtFromXML(1, true, true, $next['key']);
                 }
             }
         } catch (Exception $e) {
         }
         //-----------------------------------------
         // Off to next setp
         //-----------------------------------------
         $this->registry->output->html .= $this->registry->output->global_template->temporaryRedirect($this->settings['base_url'] . $this->form_code . "do=rebuildFromXml&amp;id={$id}&amp;type={$type}&amp;previous=" . $next['key'], $msg . '<br>' . $this->registry->output->global_message);
         $this->registry->output->global_message = '';
         return;
     } else {
         if ($type == 'public') {
             //-----------------------------------------
             // Onto admin languages
             //-----------------------------------------
             $this->registry->output->html .= $this->registry->output->global_template->temporaryRedirect($this->settings['base_url'] . $this->form_code . "do=rebuildFromXml&amp;id={$id}&amp;type=admin", $this->lang->words['starting_admin_import']);
             return;
         } else {
             //-----------------------------------------
             // And we're done
             //-----------------------------------------
             $this->registry->output->redirect($this->settings['base_url'] . $this->form_code, $this->lang->words['lang_reimport_done']);
         }
     }
 }
示例#8
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();
 }
示例#9
0
 /**
  * Execute selected method
  *
  * @access	public
  * @param	object		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* Check input? */
     if ($this->request['do'] == 'check') {
         /* Check Directory */
         if (!is_array($_POST['apps']) or !count($_POST['apps'])) {
             $this->registry->output->addError('You must select to install at least one application');
         } else {
             /* Save Form Data */
             IPSSetUp::setSavedData('install_apps', implode(',', array_keys($_POST['apps'])));
             /* Check writeable files */
             foreach (array_keys($_POST['apps']) as $appDir) {
                 $info = IPSSetUp::fetchXmlAppWriteableFiles($appDir);
                 if (count($info['notexist'])) {
                     foreach ($info['notexist'] as $path) {
                         $this->registry->output->addWarning('File or directory does not exist: "' . $path . '", please create it via FTP');
                     }
                 }
                 if (count($info['notwrite'])) {
                     foreach ($info['notwrite'] as $path) {
                         $this->registry->output->addWarning('File or directory is not writeable: "' . $path . '", please CHMOD via FTP');
                     }
                 }
                 /**
                  * Custom errors
                  */
                 if (count($info['other'])) {
                     foreach ($info['other'] as $error) {
                         $this->registry->output->addWarning($error);
                     }
                 }
             }
             /* Do we have errors? */
             if (!count($this->registry->output->fetchWarnings())) {
                 /* Next Action */
                 $this->registry->autoLoadNextAction('address');
             }
         }
     }
     /* 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);
     }
     /* We don't want IP.SEO to be installed on future versions. Bad things happen. */
     unset($apps['ips']['ipseo']);
     unset($apps['other']['ipseo']);
     /* 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;
     /* Page Output */
     $this->registry->output->setTitle("Applications");
     $this->registry->output->setNextAction('apps&do=check');
     $this->registry->output->addContent($this->registry->output->template()->page_apps($apps));
     $this->registry->output->sendOutput();
 }
示例#10
0
//-----------------------------------------
// Set Configuration
//-----------------------------------------
IPSSetUp::setSavedData('install_apps', $_SERVER['argv'][1]);
IPSSetUp::setSavedData('install_dir', $_SERVER['argv'][2]);
IPSSetUp::setSavedData('install_url', $_SERVER['argv'][3]);
IPSSetUp::setSavedData('lkey', $_SERVER['argv'][4]);
IPSSetUp::setSavedData('sql_driver', 'mysql');
IPSSetUp::setSavedData('db_host', $_SERVER['argv'][5]);
IPSSetUp::setSavedData('db_name', $_SERVER['argv'][6]);
IPSSetUp::setSavedData('db_user', $_SERVER['argv'][7]);
IPSSetUp::setSavedData('db_pass', $_SERVER['argv'][8]);
IPSSetUp::setSavedData('db_pre', '');
IPSSetUp::setSavedData('admin_user', $_SERVER['argv'][9]);
IPSSetUp::setSavedData('admin_pass', $_SERVER['argv'][10]);
IPSSetUp::setSavedData('admin_email', $_SERVER['argv'][11]);
/* Write it */
IPSInstall::writeConfiguration();
//-----------------------------------------
// Install
//-----------------------------------------
file_get_contents("http://license.invisionpower.com/?a=activate&key={$_SERVER['argv'][4]}&url={$_SERVER['argv'][3]}");
file_put_contents("../../../cache/installer_lock.php", "AUTOINSTALLED");
require_once IPS_ROOT_PATH . 'setup/applications/install/sections/install.php';
/*noLibHook*/
$controller = new install_install();
$output = new CLIOutput($steps, $controller);
$registry->setClass('output', $output);
$controller->makeRegistryShortcuts($registry);
$output->setNextAction('do=sql');
$output->sendOutput();
 function convert_polls()
 {
     $start = intval($this->request['st']) > 0 ? intval($this->request['st']) : 0;
     $lend = 50;
     $end = $start + $lend;
     $max = intval(IPSSetUp::getSavedData('max'));
     $converted = intval(IPSSetUp::getSavedData('conv'));
     //-----------------------------------------
     // First off.. grab number of polls to convert
     //-----------------------------------------
     if (!$max) {
         $total = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as max', 'from' => 'topics', 'where' => "poll_state IN ('open', 'close', 'closed')"));
         $max = $total['max'];
     }
     //-----------------------------------------
     // In steps...
     //-----------------------------------------
     $this->DB->build(array('select' => '*', 'from' => 'topics', 'where' => "poll_state IN ('open', 'close', 'closed' )", 'limit' => array(0, $lend)));
     $o = $this->DB->execute();
     //-----------------------------------------
     // Do it...
     //-----------------------------------------
     if ($this->DB->getTotalRows($o)) {
         //-----------------------------------------
         // Got some to convert!
         //-----------------------------------------
         while ($r = $this->DB->fetch($o)) {
             $converted++;
             //-----------------------------------------
             // All done?
             //-----------------------------------------
             if ($converted >= $max) {
                 $done = 1;
             }
             $new_poll = array(1 => array());
             $poll_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => "tid=" . $r['tid']));
             if (!$poll_data['pid']) {
                 continue;
             }
             if (!$poll_data['poll_question']) {
                 $poll_data['poll_question'] = $r['title'];
             }
             //-----------------------------------------
             // Kick start new poll
             //-----------------------------------------
             $new_poll[1]['question'] = $poll_data['poll_question'];
             //-----------------------------------------
             // Get OLD polls
             //-----------------------------------------
             $poll_answers = unserialize(stripslashes($poll_data['choices']));
             reset($poll_answers);
             foreach ($poll_answers as $entry) {
                 $id = $entry[0];
                 $choice = $entry[1];
                 $votes = $entry[2];
                 $total_votes += $votes;
                 if (strlen($choice) < 1) {
                     continue;
                 }
                 $new_poll[1]['choice'][$id] = $choice;
                 $new_poll[1]['votes'][$id] = $votes;
             }
             //-----------------------------------------
             // Got something?
             //-----------------------------------------
             if (count($new_poll[1]['choice'])) {
                 $this->DB->update('polls', array('choices' => serialize($new_poll)), 'tid=' . $r['tid']);
                 $this->DB->update('topics', array('poll_state' => 1), 'tid=' . $r['tid']);
             }
         }
     } else {
         $done = 1;
     }
     if (!$done) {
         $this->registry->output->addMessage("Polls: {$start} to {$end} completed....");
         $this->request['workact'] = 'polls';
         $this->request['st'] = $end;
         IPSSetUp::setSavedData('max', $max);
         IPSSetUp::setSavedData('conv', $converted);
         return FALSE;
     } else {
         $this->registry->output->addMessage("Polls converted, proceeding to calendar events...");
         $this->request['workact'] = 'calevents';
         $this->request['st'] = '0';
         return FALSE;
     }
 }
 function step_11()
 {
     $this->DB->return_die = 1;
     $start = intval($this->request['st']) ? intval($this->request['st']) : 0;
     $lend = 300;
     $end = $start + $lend;
     $max = 0;
     $this->DB->build(array('select' => 'id', 'from' => 'members', 'where' => "id > {$end}"));
     $this->DB->execute();
     $max = $this->DB->fetch();
     $o = $this->DB->query($this->sql_members_converge($start, $end));
     $found = 0;
     //-----------------------------------------
     // Do it...
     //-----------------------------------------
     while ($r = $this->DB->fetch($o)) {
         if (!$r['cid'] or !$r['id']) {
             $r['password'] = $r['password'] ? $r['password'] : $r['legacy_password'];
             $salt = IPSMember::generatePasswordSalt(5);
             $salt = str_replace('\\', "\\\\", $salt);
             $this->DB->insert('members_converge', array('converge_id' => $r['id'], 'converge_email' => strtolower($r['email']), 'converge_joined' => $r['joined'], 'members_pass_hash' => md5(md5($salt) . $r['password']), 'members_pass_salt' => $salt));
             $member_login_key = IPSMember::generateAutoLoginKey();
             $this->DB->update('members', array('member_login_key' => $member_login_key, 'email' => strtolower($r['email'])), 'id=' . $r['id']);
             if ($r['id'] == IPSSetUp::getSavedData('mid')) {
                 // Reset loginkey
                 IPSSetUp::setSavedData('loginkey', $member_login_key);
                 $this->member->setProperty('member_login_key', $member_login_key);
                 IPSSetUp::setSavedData('securekey', $this->member->form_hash);
             }
         }
         $found++;
     }
     if (!$found and !$max['id']) {
         $this->registry->output->addMessage("Converge completed, converting personal messages...");
         $this->request['workact'] = 'step_12';
         $this->request['st'] = 0;
     } else {
         $this->request['st'] = $end;
         $this->registry->output->addMessage("Converge added: {$start} to {$end} completed....");
         $this->request['workact'] = 'step_11';
     }
 }
示例#13
0
 /**
  * Installs Settings schematic
  *
  * @return void
  */
 public function install_settings()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous, '{app}_settings.xml', $this->settings['gb_char_set']);
     //-----------------------------------------
     // Install settings
     //-----------------------------------------
     if ($next['key']) {
         $output[] = $next['title'] . ": Обновление настроек";
         $_PATH = IPSLib::getAppDir($next['key']) . '/xml/';
         if (is_file($_PATH . $next['key'] . '_settings.xml')) {
             //-----------------------------------------
             // Continue
             //-----------------------------------------
             require_once IPS_ROOT_PATH . 'applications/core/modules_admin/settings/settings.php';
             /*noLibHook*/
             $settings = new admin_core_settings_settings();
             $settings->makeRegistryShortcuts($this->registry);
             $this->request['app_dir'] = $next['key'];
             //-----------------------------------------
             // Known settings
             //-----------------------------------------
             if (substr(IPSSetUp::getSavedData('install_url'), -1) == '/') {
                 IPSSetUp::setSavedData('install_url', substr(IPSSetUp::getSavedData('install_url'), 0, -1));
             }
             if (substr(IPSSetUp::getSavedData('install_dir'), -1) == '/') {
                 IPSSetUp::setSavedData('install_dir', substr(IPSSetUp::getSavedData('install_dir'), 0, -1));
             }
             /* Fetch known settings  */
             $knownSettings = array();
             if (is_file(IPSLib::getAppDir($next['key']) . '/setup/versions/install/knownSettings.php')) {
                 require IPSLib::getAppDir($next['key']) . '/setup/versions/install/knownSettings.php';
                 /*noLibHook*/
             }
             $settings->importAllSettings(1, 1, $knownSettings);
         }
         //-----------------------------------------
         // Done.. so get some more!
         //-----------------------------------------
         $this->_finishStep($output, "Обновление: Настройки для " . $next['title'], 'upgrade&do=settings&previous=' . $next['key']);
     } else {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output[] = "Все настройки обновлены";
         $this->_finishStep($output, "Обновление: Настройки", 'upgrade&do=templates');
     }
 }
示例#14
0
 /**
  * Installs Settings schematic
  *
  * @return void
  */
 public function install_settings()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous, '{app}_settings.xml', $this->settings['gb_char_set']);
     /* Set up DB driver */
     $extra_install = $this->_setUpDBDriver(FALSE);
     //-----------------------------------------
     // Install settings
     //-----------------------------------------
     if ($next['key']) {
         $output[] = $next['title'] . ": Добавление настроек";
         $_PATH = IPSLib::getAppDir($next['key']) . '/xml/';
         $knownSettings = array();
         if (is_file($_PATH . $next['key'] . '_settings.xml')) {
             //-----------------------------------------
             // Adjust the table?
             //-----------------------------------------
             if ($extra_install and method_exists($extra_install, 'before_inserts_run')) {
                 $q = $extra_install->before_inserts_run('settings');
             }
             //-----------------------------------------
             // Continue
             //-----------------------------------------
             require_once IPS_ROOT_PATH . 'applications/core/modules_admin/settings/settings.php';
             /*noLibHook*/
             $settings = new admin_core_settings_settings();
             $settings->makeRegistryShortcuts($this->registry);
             $this->request['app_dir'] = $next['key'];
             //-----------------------------------------
             // Known settings
             //-----------------------------------------
             if (substr(IPSSetUp::getSavedData('install_url'), -1) == '/') {
                 IPSSetUp::setSavedData('install_url', substr(IPSSetUp::getSavedData('install_url'), 0, -1));
             }
             if (substr(IPSSetUp::getSavedData('install_dir'), -1) == '/') {
                 IPSSetUp::setSavedData('install_dir', substr(IPSSetUp::getSavedData('install_dir'), 0, -1));
             }
             /* Fetch known settings  */
             if (is_file(IPSLib::getAppDir($next['key']) . '/setup/versions/install/knownSettings.php')) {
                 require IPSLib::getAppDir($next['key']) . '/setup/versions/install/knownSettings.php';
                 /*noLibHook*/
             }
             $this->request['app_dir'] = $next['key'];
             $settings->importAllSettings(1, 1, $knownSettings);
             //-----------------------------------------
             // Adjust the table?
             //-----------------------------------------
             if ($extra_install and method_exists($extra_install, 'after_inserts_run')) {
                 $q = $extra_install->after_inserts_run('settings');
             }
         }
         //-----------------------------------------
         // Done.. so get some more!
         //-----------------------------------------
         $this->_finishStep($output, "Установка: Настройки", 'install&do=settings&previous=' . $next['key']);
     } else {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output[] = "Настройки добавлены";
         $this->_finishStep($output, "Установка: Настройки", 'install&do=templates');
     }
 }
 /**
  * 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();
 }
 /**
  * Installs Settings schematic
  *
  * @return void
  */
 public function install_settings()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous, '{app}_settings.xml');
     //-----------------------------------------
     // Install settings
     //-----------------------------------------
     if ($next['key']) {
         $output[] = $next['title'] . ": Upgrading settings...";
         $_PATH = IPSLib::getAppDir($next['key']) . '/xml/';
         if (file_exists($_PATH . $next['key'] . '_settings.xml')) {
             //-----------------------------------------
             // Continue
             //-----------------------------------------
             require_once IPS_ROOT_PATH . 'applications/core/modules_admin/tools/settings.php';
             $settings = new admin_core_tools_settings();
             $settings->makeRegistryShortcuts($this->registry);
             $this->request['app_dir'] = $next['key'];
             //-----------------------------------------
             // Known settings
             //-----------------------------------------
             if (substr(IPSSetUp::getSavedData('install_url'), -1) == '/') {
                 IPSSetUp::setSavedData('install_url', substr(IPSSetUp::getSavedData('install_url'), 0, -1));
             }
             if (substr(IPSSetUp::getSavedData('install_dir'), -1) == '/') {
                 IPSSetUp::setSavedData('install_dir', substr(IPSSetUp::getSavedData('install_dir'), 0, -1));
             }
             /* Fetch known settings  */
             if (file_exists(IPSLib::getAppDir($next['key']) . '/setup/versions/install/knownSettings.php')) {
                 require IPSLib::getAppDir($next['key']) . '/setup/versions/install/knownSettings.php';
             }
             $settings->importAllSettings(1, 1, $knownSettings);
         }
         //-----------------------------------------
         // Done.. so get some more!
         //-----------------------------------------
         $this->_finishStep($output, "Upgrade: " . $next['title'] . " Settings", 'upgrade&do=settings&previous=' . $next['key']);
     } else {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output[] = "All settings upgraded";
         $this->_finishStep($output, "Upgrade: Settings", 'upgrade&do=templates');
     }
 }