Ejemplo n.º 1
0
 /**
  * Gets the core system going.  
  * @param string $dsn dsn string to connect to the database
  * @param string $user_access_init the init string for the user access mechanism
  * @param string $site_module_file  the configttion file for the site module
  * @returns boolean.  True on sucess
  */
 public static function initializeDSN($dsn, $user_access_init, $site_module_file, $bring_up_system = true)
 {
     if (empty($dsn)) {
         self::raiseError("Please set the dsn string", E_USER_ERROR);
         if (!array_key_exists('HTTP_HOST', $_SERVER)) {
             //command line
             exit(11);
         } else {
             return false;
         }
     }
     $mdb2 = new MDB2();
     $dsn_info = $mdb2->parseDSN($dsn);
     if (I2CE_Dumper::dumpStaticURL($dsn_info['database'], 'file')) {
         exit;
     }
     if (!self::dbConnect($dsn_info)) {
         self::raiseError("Could not connect to the database");
         if (!array_key_exists('HTTP_HOST', $_SERVER)) {
             //command line
             exit(13);
         } else {
             return false;
         }
     }
     self::setupSession();
     $clear = false;
     if (!array_key_exists('HTTP_HOST', $_SERVER)) {
         //command line
         $clear = self::getRuntimeVariable('clear_cache', '0');
     } else {
         $URL = self::getAccessedBaseURL(false) . 'clear_cache.php';
         $clear = substr($_SERVER['REQUEST_URI'], 0, strlen($URL)) == $URL;
     }
     if ($clear) {
         $config = self::setupMagicData();
         $config->setIfIsSet(self::$email, "/I2CE/feedback/to");
         session_destroy();
         if (function_exists('apc_clear_cache')) {
             apc_clear_cache('user');
             I2CE::raiseError("Cleared APC User Cache");
         }
         I2CE::raiseError("Session destroyed");
         I2CE::getConfig()->clearCache();
         I2CE::raiseError("Magic data cleared -- Execution stopping");
         die(0);
     }
     $update = false;
     if (!array_key_exists('HTTP_HOST', $_SERVER)) {
         //command line
         $update = self::getRuntimeVariable('update', '0');
     } else {
         $URL = self::getAccessedBaseURL(false) . 'update.php';
         $update = substr($_SERVER['REQUEST_URI'], 0, strlen($URL)) == $URL;
     }
     if (self::siteInitialized()) {
         self::raiseError("Already initialized!", E_USER_WARNING);
         return true;
     }
     $db = MDB2::singleton();
     //get the instance we just created.
     if (!$update && $bring_up_system) {
         // just assume it is until we know otherwise.  This error
         // message to don't dumped to the screen.
         self::siteInitialized(true);
     }
     /*
     if (I2CE_Dumper::dumpStaticURL($db->database_name, 'file')) {
         exit();
     }
     */
     I2CE_Error::resetStoredMessages();
     if (empty($site_module_file)) {
         self::raiseError("Please set the site module's config file", E_USER_ERROR);
         if (!array_key_exists('HTTP_HOST', $_SERVER)) {
             //command line
             exit(14);
         } else {
             return false;
         }
     }
     $config = self::setupMagicData();
     $config->setIfIsSet(self::$email, "/I2CE/feedback/to");
     $site_module_file = I2CE_FileSearch::absolut($site_module_file, 1);
     self::setupFileSearch(array('MODULES' => array(dirname(dirname(__FILE__)), dirname($site_module_file)), 'CLASSES' => dirname(__FILE__)));
     self::setUserAccessInit($user_access_init, null, true);
     if ($update) {
         require_once 'I2CE_Updater.php';
         if (!I2CE_Updater::updateSite($site_module_file)) {
             if (array_key_exists('HTTP_HOST', $_SERVER)) {
                 die("<br/>Could not update site");
             } else {
                 I2CE::raiseError("\nCould not update site\n");
                 exit(15);
             }
         } else {
             if (!array_key_exists('HTTP_HOST', $_SERVER)) {
                 //command line
                 exit(0);
             }
         }
         return true;
     } else {
         if ($bring_up_system && !self::bringUpSystem($site_module_file)) {
             self::raiseError("Could not bring up system", E_USER_ERROR);
             exit(15);
         }
         I2CE::$ob_level = ob_get_level();
         return true;
     }
 }
 protected function destroyMyself()
 {
     $_SESSION['checked_module_prompt'] = 'prompted';
     $promptConfig = I2CE::getConfig()->traverse('/modules/modulePrompter/', true);
     $promptConfig->prompt_status = 'prompted';
     I2CE_Updater::updateModules(array(), array('modulePrompter'));
 }
Ejemplo n.º 3
0
 protected function actionEnableDisable()
 {
     I2CE_ModuleFactory::callHooks('pre_admin_enable_modules', array('page' => $this));
     if ($this->post_exists('redirect') && $this->post('redirect')) {
         $redirect = $this->post('redirect');
     } else {
         if ($this->shortname == 'I2CE') {
             $redirect = "admin/modules";
         } else {
             $redirect = "admin/modules/{$this->shortname}";
         }
     }
     if (!$this->post_exists('possibles') || !$this->post('possibles')) {
         $this->redirect($redirect);
         return;
     }
     $possibles = explode(':', $this->post('possibles'));
     $enable = array();
     if ($this->post_exists('modules')) {
         $enable = $this->post('modules');
     }
     $disable = array_diff($possibles, $enable);
     $msg = '';
     $optional_excludes = $disable;
     foreach ($enable as $i => $e) {
         if ($this->mod_factory->isEnabled($e)) {
             unset($enable[$i]);
         }
     }
     foreach ($disable as $i => $d) {
         if (!$this->mod_factory->isEnabled($d)) {
             unset($disable[$i]);
         }
     }
     if (count($enable) > 0) {
         $msg .= '<p>modules enabled: ' . implode(' ', $enable) . "</p>";
     }
     if (count($disable) > 0) {
         $msg .= '<p>modules disabled: ' . implode(' ', $disable) . "</p>";
     }
     if (I2CE_Updater::updateModules($enable, array(), $optional_excludes, $disable)) {
         $this->userMessage("Success" . $msg . "<br/>");
     } else {
         $this->userMessage("Failure on:" . $msg . "<br/>");
     }
     I2CE_ModuleFactory::callHooks('post_admin_enable_modules', array('page' => $this, 'possibles' => $possibles, 'enable' => $enable, 'disable' => $disable));
     $this->redirect($redirect);
 }