/** * Reloads extensions and changes siteaccess globally * If you only want changes on a instance of ini, use {@link eZSiteAccess::getIni()} * * - clears all in-memory caches used by the INI system * - re-builds the list of paths where INI files are searched for * - runs {@link eZSiteAccess::change()} * - re-searches module paths {@link eZModule::setGlobalPathList()} * * @since 4.4 * @param array $access An associative array with 'name' (string), 'type' (int) and 'uri_part' (array). * See {@link eZSiteAccess::match()} for array structure definition * @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini * If set, then global siteacceess will not be changed as well. * @return array The $access parameter */ static function load( array $access, eZINI $siteINI = null ) { $currentSiteAccess = $GLOBALS['eZCurrentAccess']; unset( $GLOBALS['eZCurrentAccess'] ); // Clear all ini override dirs if ( $siteINI instanceof eZINI ) { $siteINI->resetOverrideDirs(); } else { eZINI::resetAllInstances(); eZExtension::clearActiveExtensionsMemoryCache(); eZTemplateDesignResource::clearInMemoryCache(); } // Reload extensions, siteaccess and access extensions eZExtension::activateExtensions( 'default', $siteINI ); $access = self::change( $access, $siteINI ); eZExtension::activateExtensions( 'access', $siteINI ); // Restore current (old) siteacces if changes where only to be applied to locale instance of site.ini if ( $siteINI instanceof eZINI ) { $GLOBALS['eZCurrentAccess'] = $currentSiteAccess; } else { $moduleRepositories = eZModule::activeModuleRepositories(); eZModule::setGlobalPathList( $moduleRepositories ); } return $access; }
function initialize() { if (ob_get_length() != 0) { ob_end_clean(); } $debugINI = eZINI::instance('debug.ini'); eZDebugSetting::setDebugINI($debugINI); // Initialize text codec settings $this->updateTextCodecSettings(); // Initialize debug settings $this->updateDebugSettings($this->UseDebugOutput); // Set the different permissions/settings. $ini = eZINI::instance(); $iniFilePermission = $ini->variable('FileSettings', 'StorageFilePermissions'); $iniDirPermission = $ini->variable('FileSettings', 'StorageDirPermissions'); $iniVarDirectory = eZSys::cacheDirectory(); eZCodePage::setPermissionSetting(array('file_permission' => octdec($iniFilePermission), 'dir_permission' => octdec($iniDirPermission), 'var_directory' => $iniVarDirectory)); eZExecution::addCleanupHandler('eZDBCleanup'); eZExecution::addFatalErrorHandler('eZFatalError'); eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP); if ($this->UseExtensions) { // Check for extension eZExtension::activateExtensions('default'); // Extension check end } else { if (!$this->isQuiet()) { $cli = eZCLI::instance(); $cli->output("Notice: This script uses 'use-extensions' => false, meaning extension settings are not loaded!"); } } $siteaccess = $this->SiteAccess; if ($siteaccess) { $access = array('name' => $siteaccess, 'type' => eZSiteAccess::TYPE_STATIC); } else { $ini = eZINI::instance(); $siteaccess = $ini->variable('SiteSettings', 'DefaultAccess'); $access = array('name' => $siteaccess, 'type' => eZSiteAccess::TYPE_DEFAULT); } $access = eZSiteAccess::change($access); if ($this->UseExtensions) { // Check for siteaccess extension eZExtension::activateExtensions('access'); // Extension check end } // Now that all extensions are activated and siteaccess has been changed, reset // all eZINI instances as they may not take into account siteaccess specific settings. eZINI::resetAllInstances(false); // Set the global setting which is read by the session lib $GLOBALS['eZSiteBasics']['session-required'] = $this->UseSession; if ($this->UseSession) { $db = eZDB::instance(); if ($db->isConnected()) { eZSession::start(); } else { $this->setIsInitialized(false); $this->InitializationErrorMessage = 'database error: ' . $db->errorMessage(); return; } } if ($this->User) { $userLogin = $this->User['login']; $userPassword = $this->User['password']; if ($userLogin and $userPassword) { $userID = eZUser::loginUser($userLogin, $userPassword); if (!$userID) { $cli = eZCLI::instance(); if ($this->isLoud()) { $cli->warning('Failed to login with user ' . $userLogin); } eZExecution::cleanup(); eZExecution::setCleanExit(); } } } // Initialize module handling if ($this->UseModules) { $moduleRepositories = eZModule::activeModuleRepositories($this->UseExtensions); eZModule::setGlobalPathList($moduleRepositories); } $this->setIsInitialized(true); }
protected function requestInit() { if ($this->isInitialized) { return; } eZExecution::setCleanExit(false); $scriptStartTime = microtime(true); $GLOBALS['eZRedirection'] = false; $this->access = eZSiteAccess::current(); eZDebug::setScriptStart($scriptStartTime); eZDebug::addTimingPoint("Script start"); $this->uri = eZURI::instance(eZSys::requestURI()); $GLOBALS['eZRequestedURI'] = $this->uri; // Be able to do general events early in process ezpEvent::getInstance()->notify('request/preinput', array($this->uri)); // Initialize module loading $this->siteBasics['module-repositories'] = eZModule::activeModuleRepositories(); eZModule::setGlobalPathList($this->siteBasics['module-repositories']); // make sure we get a new $ini instance now that it has been reset $ini = eZINI::instance(); // start: eZCheckValidity // pre check, setup wizard related so needs to be before session/db init // TODO: Move validity check in the constructor? Setup is not meant to be launched at each (sub)request is it? if ($ini->variable('SiteAccessSettings', 'CheckValidity') === 'true') { $this->check = array('module' => 'setup', 'function' => 'init'); // Turn off some features that won't bee needed yet $this->siteBasics['policy-check-omit-list'][] = 'setup'; $this->siteBasics['show-page-layout'] = $ini->variable('SetupSettings', 'PageLayout'); $this->siteBasics['validity-check-required'] = true; $this->siteBasics['session-required'] = $this->siteBasics['user-object-required'] = false; $this->siteBasics['db-required'] = $this->siteBasics['no-cache-adviced'] = $this->siteBasics['url-translator-allowed'] = false; $this->siteBasics['site-design-override'] = $ini->variable('SetupSettings', 'OverrideSiteDesign'); $this->access = eZSiteAccess::change(array('name' => 'setup', 'type' => eZSiteAccess::TYPE_URI)); eZTranslatorManager::enableDynamicTranslations(); } // stop: eZCheckValidity if ($this->siteBasics['session-required']) { // Check if this should be run in a cronjob if ($ini->variable('Session', 'BasketCleanup') !== 'cronjob') { eZSession::addCallback('destroy_pre', function (eZDBInterface $db, $key, $escapedKey) { $basket = eZBasket::fetch($key); if ($basket instanceof eZBasket) { $basket->remove(); } }); eZSession::addCallback('gc_pre', function (eZDBInterface $db, $time) { eZBasket::cleanupExpired($time); }); eZSession::addCallback('cleanup_pre', function (eZDBInterface $db) { eZBasket::cleanup(); }); } // addCallBack to update session id for shop basket on session regenerate eZSession::addCallback('regenerate_post', function (eZDBInterface $db, $escNewKey, $escOldKey) { $db->query("UPDATE ezbasket SET session_id='{$escNewKey}' WHERE session_id='{$escOldKey}'"); }); // TODO: Session starting should be made only once in the constructor $this->sessionInit(); } // if $this->siteBasics['db-required'], open a db connection and check that db is connected if ($this->siteBasics['db-required'] && !eZDB::instance()->isConnected()) { $this->warningList[] = array('error' => array('type' => 'kernel', 'number' => eZError::KERNEL_NO_DB_CONNECTION), 'text' => 'No database connection could be made, the system might not behave properly.'); } // eZCheckUser: pre check, RequireUserLogin & FORCE_LOGIN related so needs to be after session init if (!isset($this->check)) { $this->check = eZUserLoginHandler::preCheck($this->siteBasics, $this->uri); } ezpEvent::getInstance()->notify('request/input', array($this->uri)); // Initialize with locale settings // TODO: Move to constructor? Is it relevant to init the locale/charset for each (sub)requests? $this->languageCode = eZLocale::instance()->httpLocaleCode(); $phpLocale = trim($ini->variable('RegionalSettings', 'SystemLocale')); if ($phpLocale != '') { setlocale(LC_ALL, explode(',', $phpLocale)); } $this->httpCharset = eZTextCodec::httpCharset(); // TODO: are these parameters supposed to vary across potential sub-requests? $this->site = array('title' => $ini->variable('SiteSettings', 'SiteName'), 'design' => $ini->variable('DesignSettings', 'SiteDesign'), 'http_equiv' => array('Content-Type' => 'text/html; charset=' . $this->httpCharset, 'Content-language' => $this->languageCode)); // Read role settings $this->siteBasics['policy-check-omit-list'] = array_merge($this->siteBasics['policy-check-omit-list'], $ini->variable('RoleSettings', 'PolicyOmitList')); $this->isInitialized = true; }
public function __construct($action, $request) { $moduleRepositories = eZModule::activeModuleRepositories(); eZModule::setGlobalPathList($moduleRepositories); parent::__construct($action, $request); }
// Siteaccess extension check end // reload soap.ini cache now that override paths have changed $soapINI->loadCache(); /*! Reads settings from i18n.ini and passes them to eZTextCodec. */ function eZUpdateTextCodecSettings() { $ini = eZINI::instance('i18n.ini'); list($i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension']) = $ini->variableMulti('CharacterSettings', array('Charset', 'HTTPCharset', 'MBStringExtension'), array(false, false, 'enabled')); eZTextCodec::updateSettings($i18nSettings); } // Initialize text codec settings eZUpdateTextCodecSettings(); // Initialize module loading $moduleRepositories = eZModule::activeModuleRepositories(); eZModule::setGlobalPathList($moduleRepositories); // Load soap extensions $enableSOAP = $soapINI->variable('GeneralSettings', 'EnableSOAP'); if ($enableSOAP == 'true') { eZSys::init('soap.php'); // Login if we have username and password. if (eZHTTPTool::username() and eZHTTPTool::password()) { eZUser::loginUser(eZHTTPTool::username(), eZHTTPTool::password()); } $server = new eZSOAPServer(); foreach ($soapINI->variable('ExtensionSettings', 'SOAPExtensions') as $extension) { include_once eZExtension::baseDirectory() . '/' . $extension . '/soap/initialize.php'; } $server->processRequest(); }
/** * Reloads extensions and changes siteaccess globally * If you only want changes on a instance of ini, use {@link eZSiteAccess::getIni()} * * - clears all in-memory caches used by the INI system * - re-builds the list of paths where INI files are searched for * - runs {@link eZSiteAccess::change()} * - re-searches module paths {@link eZModule::setGlobalPathList()} * * @since 4.4 * @param array $access An associative array with 'name' (string), 'type' (int) and 'uri_part' (array). * See {@link eZSiteAccess::match()} for array structure definition * @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini * If set, then global siteacceess will not be changed as well. * @return array The $access parameter */ static function load( array $access, eZINI $siteINI = null ) { $currentSiteAccess = $GLOBALS['eZCurrentAccess']; unset( $GLOBALS['eZCurrentAccess'] ); // Clear all ini override dirs if ( $siteINI instanceof eZINI ) { $siteINI->resetOverrideDirs(); } else { eZINI::resetAllInstances(); eZExtension::clearActiveExtensionsMemoryCache(); eZTemplateDesignResource::clearInMemoryCache(); } // Reload extensions, siteaccess and access extensions eZExtension::activateExtensions( 'default', $siteINI ); $access = self::change( $access, $siteINI ); eZExtension::activateExtensions( 'access', $siteINI ); // Reload Extenion ordering to reorder eZINI Global Override Dirs. // @TODO : Améliorer la gestion globale (éviter des appels multiples !!!) if ( $siteINI instanceof eZINI && $siteINI->variable( 'ExtensionSettings', 'ExtensionOrdering' ) === 'enabled' ) { eZINI::removeGlobalOverrideDirsByScope( 'sa-extension' ); eZINI::removeGlobalOverrideDirsByScope( 'extension' ); eZExtension::activateExtensions( false ); } // Restore current (old) siteacces if changes where only to be applied to locale instance of site.ini if ( $siteINI instanceof eZINI ) { $GLOBALS['eZCurrentAccess'] = $currentSiteAccess; } else { $moduleRepositories = eZModule::activeModuleRepositories(); eZModule::setGlobalPathList( $moduleRepositories ); } return $access; }