Пример #1
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();
 }
Пример #2
0
 /**
  * Set up application data, etc.
  *
  * @return	@e void
  * @author	MattMecham
  */
 protected static function _finalizeAppData()
 {
     //-----------------------------------------
     // Run the app class post output func
     //-----------------------------------------
     $app_class = self::getAppClass(IPS_APP_COMPONENT);
     if ($app_class and method_exists($app_class, 'afterOutputInit')) {
         $app_class->afterOutputInit(self::instance());
     }
     //-----------------------------------------
     // Version numbers
     //-----------------------------------------
     if (strpos(self::$acpversion, '.') !== false) {
         list($n, $b, $r) = explode(".", self::$acpversion);
     } else {
         $n = $b = $r = '';
     }
     self::$vn_full = self::$acpversion;
     self::$acpversion = $n;
     self::$vn_build_date = $b;
     self::$vn_build_reason = $r;
     # Figure out default modules, etc
     $_module = IPSText::alphanumericalClean(ipsRegistry::$request['module']);
     $_first = '';
     //-----------------------------------------
     // Set up some defaults
     //-----------------------------------------
     ipsRegistry::$current_application = IPS_APP_COMPONENT;
     if (IPS_AREA == 'admin') {
         //-----------------------------------------
         // Application: Do we have permission?
         //-----------------------------------------
         if (ipsRegistry::$request['module'] != 'login') {
             ipsRegistry::getClass('class_permissions')->return = 0;
             ipsRegistry::getClass('class_permissions')->checkForAppAccess(IPS_APP_COMPONENT);
             ipsRegistry::getClass('class_permissions')->return = 1;
         }
         //-----------------------------------------
         // Got a module
         //-----------------------------------------
         if (ipsRegistry::$request['module'] == 'ajax') {
             $_module = 'ajax';
         } else {
             $fakeApps = ipsRegistry::getClass('output')->fetchFakeApps();
             foreach (ipsRegistry::$modules as $app => $items) {
                 if (is_array($items)) {
                     foreach ($items as $data) {
                         if ($data['sys_module_admin'] and $data['sys_module_application'] == ipsRegistry::$current_application) {
                             if (!$_first) {
                                 # Got permission for this one?
                                 ipsRegistry::getClass('class_permissions')->return = 1;
                                 if (ipsRegistry::getClass('class_permissions')->checkForModuleAccess($data['sys_module_application'], $data['sys_module_key']) === TRUE) {
                                     if (is_dir(IPSLib::getAppDir($data['sys_module_application']) . "/modules_admin/{$data['sys_module_key']}") === TRUE) {
                                         $isFakeApp = false;
                                         foreach ($fakeApps as $tab => $apps) {
                                             foreach ($apps as $thisApp) {
                                                 if ($thisApp['app'] == $app and $thisApp['module'] == $data['sys_module_key']) {
                                                     $isFakeApp = true;
                                                 }
                                             }
                                         }
                                         if (!$isFakeApp) {
                                             $_first = $data['sys_module_key'];
                                         }
                                     }
                                 }
                                 ipsRegistry::getClass('class_permissions')->return = 0;
                             }
                             if (ipsRegistry::$request['module'] == $data['sys_module_key']) {
                                 $_module = $data['sys_module_key'];
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     } else {
         //-----------------------------------------
         // Got a module?
         //-----------------------------------------
         if ($_module == 'ajax') {
             $_module = 'ajax';
         } else {
             foreach (ipsRegistry::$modules as $app => $items) {
                 if (is_array($items)) {
                     foreach ($items as $data) {
                         if (!$data['sys_module_admin'] and $data['sys_module_application'] == ipsRegistry::$current_application) {
                             if (!$_first) {
                                 $_first = $data['sys_module_key'];
                             }
                             if ($_module == $data['sys_module_key']) {
                                 $_module = $data['sys_module_key'];
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Finish off...
     //-----------------------------------------
     ipsRegistry::$current_module = $_module ? $_module : $_first;
     ipsRegistry::$current_section = ipsRegistry::$request['section'] ? ipsRegistry::$request['section'] : '';
     /* Clean */
     ipsRegistry::$current_module = IPSText::alphanumericalClean(ipsRegistry::$current_module);
     ipsRegistry::$current_section = IPSText::alphanumericalClean(ipsRegistry::$current_section);
     IPSDebug::addMessage("Setting current module to: " . ipsRegistry::$current_module . " and current section to: " . ipsRegistry::$current_section);
     if (IPS_AREA == 'admin') {
         //-----------------------------------------
         // Module: Do we have permission?
         //-----------------------------------------
         ipsRegistry::getClass('class_permissions')->return = 0;
         ipsRegistry::getClass('class_permissions')->checkForModuleAccess(ipsRegistry::$current_application, ipsRegistry::$current_module);
         ipsRegistry::getClass('class_permissions')->return = 1;
     }
 }
Пример #3
0
 /**
  * Retreive the command
  *
  * @access	public
  * @param	object		ipsRegistry reference
  * @return	object
  */
 public function getCommand(ipsRegistry $registry)
 {
     $_NOW = IPSDebug::getMemoryDebugFlag();
     $module = ipsRegistry::$current_module;
     $section = ipsRegistry::$current_section;
     $filepath = IPSLib::getAppDir(IPS_APP_COMPONENT) . '/' . self::$modules_dir . '/' . $module . '/';
     /* Bug Fix #21009 */
     if (!ipsRegistry::$applications[IPS_APP_COMPONENT]['app_enabled']) {
         throw new Exception("The specified application has been disabled");
     }
     if (!IN_ACP and !IPSLib::moduleIsEnabled($module, IPS_APP_COMPONENT) and $module != 'ajax') {
         throw new Exception("The specified module has been disabled");
     }
     /* Got a section? */
     if (!$section) {
         if (is_file($filepath . 'defaultSection.php')) {
             $DEFAULT_SECTION = '';
             include $filepath . 'defaultSection.php';
             /*noLibHook*/
             if ($DEFAULT_SECTION) {
                 $section = $DEFAULT_SECTION;
                 ipsRegistry::$current_section = $section;
             }
         }
     }
     $_classname = self::$class_dir . '_' . IPS_APP_COMPONENT . '_' . $module . '_';
     /* Rarely used, let's leave file_exists which is faster for non-existent files */
     if (file_exists($filepath . 'manualResolver.php')) {
         $classname = IPSLib::loadActionOverloader($filepath . 'manualResolver.php', $_classname . 'manualResolver');
     } else {
         if (is_file($filepath . $section . '.php')) {
             $classname = IPSLib::loadActionOverloader($filepath . $section . '.php', $_classname . $section);
         }
     }
     IPSDebug::setMemoryDebugFlag("Controller getCommand executed");
     if (class_exists($classname)) {
         $cmd_class = new ReflectionClass($classname);
         if ($cmd_class->isSubClassOf(self::$base_cmd)) {
             return $cmd_class->newInstance();
         } else {
             throw new Exception("{$section} in {$module} does not exist!");
         }
     } else {
         throw new Exception("{$classname} does not exist!");
     }
     # Fudge it to return just the default object
     return clone self::$default_cmd;
 }
 /**
  * Set up request redirect stuff
  *
  * @return	@e void
  * @author	MattMecham
  * @access	protected
  */
 protected static function _setUpAppData()
 {
     $_default = IPS_IS_UPGRADER ? 'upgrade' : 'install';
     # Finalize the app component constants
     $_appcomponent = preg_replace("/[^a-zA-Z0-9\\-\\_]/", "", isset($_REQUEST['app']) && trim($_REQUEST['app']) ? $_REQUEST['app'] : $_default);
     define('IPS_APP_COMPONENT', $_appcomponent ? $_appcomponent : $_default);
     self::$current_section = IPSText::alphanumericalClean($_REQUEST['section']);
 }