/** * Controls the site update * @param string $site_module_file * @param boolean $verbose_errors. Defaults to true */ public static function updateSite($site_module_file, $verbose_errors = true) { if (!self::isAuthorizedToUpdate()) { return false; } I2CE::longExecution(); $site_module_file = I2CE_FileSearch::absolut($site_module_file, 1); I2CE::siteInitialized(false); if (self::_updateSite($site_module_file, $verbose_errors)) { $config = I2CE::getConfig(); $config->__set("/config/site/installation", 'done'); if (array_key_exists('HTTP_HOST', $_SERVER)) { if (array_key_exists('request', $_GET)) { $url = $_GET['request']; } else { $url = I2CE::getAccessedBaseURL(); } echo "<br/><span style='color:#993300'>Site was succesully updated. Continue on to your <a href='{$url}'>site</a>?</span>"; $msg = "Site was succesully updated. Continue on to your site?"; echo "<script type='text/javascript'>if (confirm('{$msg}')) {setTimeout(function() {window.location= '{$url}';},500)}</script>"; //reload the requested page after 5 seconds flush(); exit; } else { echo "Site was succesully updated\n"; $enable = preg_split('/,/', I2CE::getRuntimeVariable('enable', ''), -1, PREG_SPLIT_NO_EMPTY); $disable = preg_split('/,/', I2CE::getRuntimeVariable('disable', ''), -1, PREG_SPLIT_NO_EMPTY); if (count($enable) + count($disable) > 0) { $succ = self::updateModules($enable, $disable); I2CE::siteInitialized(false); return $succ; } else { return true; } } } else { return false; } }
<?php $path_to_i2ce_root = '..'; $path_to_i2ce_root = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . $path_to_i2ce_root) . DIRECTORY_SEPARATOR; require_once $path_to_i2ce_root . 'lib' . DIRECTORY_SEPARATOR . 'I2CE.php'; require_once $path_to_i2ce_root . 'lib' . DIRECTORY_SEPARATOR . 'I2CE_Configurator.php'; require_once $path_to_i2ce_root . 'lib' . DIRECTORY_SEPARATOR . 'I2CE_MagicData.php'; require_once $path_to_i2ce_root . 'lib' . DIRECTORY_SEPARATOR . 'I2CE_FileSearch.php'; require_once "Console/Getopt.php"; $cg = new Console_Getopt(); $args = $cg->readPHPArgv(); $dir = getcwd(); array_shift($args); $config = I2CE_MagicData::instance("check_validity"); I2CE::setConfig($config); foreach ($args as $file) { $file = realpath($file); echo "Checking the validity of {$file}\n"; chdir($path_to_i2ce_root . 'lib'); $config = I2CE_MagicData::instance("config"); $configurator = new I2CE_Configurator($config); if ($configurator->processConfigFile(I2CE_FileSearch::absolut($file), true, true)) { echo "\tThe file {$file} is valid\n"; } chdir($dir); } # Local Variables: # mode: php # c-default-style: "bsd" # indent-tabs-mode: nil # c-basic-offset: 4 # End:
/** * 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; } }