private static function loadCurrentSession() { AnwDebug::startbench("Current session load"); try { self::$oSession = AnwSessions::getCurrentSession(); //keepalive $nElapsedTimeSinceKeepalive = time() - self::getLastKeepAlive(); $nKeepAliveInterval = AnwComponent::globalCfgKeepaliveDelay(); AnwDebug::log('(AnwSessions) Time elapsed since last keepalive: ' . $nElapsedTimeSinceKeepalive . '/' . $nKeepAliveInterval . 's'); if ($nElapsedTimeSinceKeepalive > $nKeepAliveInterval) { AnwDebug::log('(AnwSessions) Running keepalive...'); $nTime = time(); self::resetLastKeepAlive(); //keepalive session AnwSessions::keepAlive(); //run hooks $oSessionUser = self::$oSession->getUser(); AnwPlugins::hook("session_keepalive_any", $oSessionUser); if (self::$oSession->isLoggedIn()) { AnwPlugins::hook("session_keepalive_loggedin", $oSessionUser); } else { AnwPlugins::hook("session_keepalive_loggedout", $oSessionUser); } } } catch (AnwUserNotFoundException $e) { //current user doesn't exist anymore self::$oSession = new AnwSession(); self::logout(); } AnwDebug::stopbench("Current session load"); }
/** * @throws AnwUnexpectedException */ static function loadDriver() { AnwDebug::startbench("Storage driver init"); self::$oDriver = AnwStorageDriver::loadComponent(AnwComponent::globalCfgDriverStorage()); AnwDebug::stopbench("Storage driver init"); }
function output($bEmergencyError = false) { AnwDebug::startbench("output", true); //render head $this->renderHeadForOutput(); //global actions /*$asAllGlobalActions = array("lastchanges", "sitemap", "untranslated", "management"); $asAvailableGlobalActions = array(); foreach ($asAllGlobalActions as $sAction) { if (AnwCurrentSession::isActionGlobalAllowed($sAction)) { $asAvailableGlobalActions[] = array( 'action' => $sAction, 'link' => AnwUtils::alink($sAction), 'translation' => self::g_("action_".$sAction) ); } }*/ if (!$bEmergencyError) { //session nav if (AnwCurrentSession::isLoggedIn()) { $sLinkProfile = AnwUsers::isDriverInternal() ? AnwUtils::alink("profile") : AnwUsers::getLinkProfile(AnwCurrentSession::getUser()); $sLinkSettings = AnwUtils::aLink("settings"); $sLinkLogout = AnwSessions::isDriverInternal() ? AnwUtils::alink("logout") : AnwSessions::getLogoutLink(); $sessionnav = $this->tpl()->sessionNavLoggedin(AnwCurrentSession::getUser()->getDisplayName(), $sLinkProfile, $sLinkSettings, $sLinkLogout); } else { $sLinkSettings = AnwUtils::aLink("settings"); $sLinkLogin = AnwSessions::isDriverInternal() ? AnwUtils::alink("login") : AnwSessions::getLoginLink(); if (self::globalCfgUsersRegisterEnabled()) { $sLinkRegister = AnwUsers::isDriverInternal() ? AnwUtils::alink("register") : AnwUsers::getRegisterLink(); } else { $sLinkRegister = false; } $sessionnav = $this->tpl()->sessionNavGuest($sLinkSettings, $sLinkLogin, $sLinkRegister); } $aoAllowedGlobalNavEntries = $this->getGlobalNavEntriesAllowed(); if (count($aoAllowedGlobalNavEntries) > 0) { $globalnav = $this->tpl()->globalNav($aoAllowedGlobalNavEntries); } else { $globalnav = ""; } } else { $sessionnav = ""; $globalnav = ""; } $this->out = $this->tpl()->globalBody($sessionnav, $globalnav, $this->out); $this->out = $this->tpl()->globalHtml(self::g_("local_html_lang", array(), self::getActionLang()), self::g_("local_html_dir", array(), self::getActionLang()), $this->title, $this->head, $this->out); AnwDebug::stopbench("output"); $this->printOutput(); }
/** * @throws AnwUnexpectedException */ static function loadDriver() { AnwDebug::startbench("Acls driver init"); self::$oDriver = AnwAclsDriver::loadComponent(AnwComponent::globalCfgDriverAcls()); AnwDebug::stopbench("Acls driver init"); }
define('ANWIKI_MODE_MINIMAL', true); } require_once "engine.inc.php"; //install redirect if (!file_exists(ANWIKI_INSTALL_LOCK) && AnwEnv::_GET('a') != 'install') { $sUrlInstall = AnwEnv::_SERVER('SCRIPT_URI') . '?a=install'; header("Location: " . $sUrlInstall); print '<a href="' . AnwUtils::xQuote($sUrlInstall) . '">' . AnwUtils::xQuote($sUrlInstall) . '</a>'; exit; } AnwDebug::startbench("preparing action", true); //load action code try { $sAction = strtolower(AnwEnv::_GET(AnwAction::GET_ACTIONNAME, "view")); $oAction = AnwAction::loadComponent($sAction); } catch (AnwException $e) { $sAction = "view"; $oAction = AnwAction::loadComponent($sAction); } //security check if (ANWIKI_MODE_MINIMAL && !$oAction instanceof AnwActionMinimal) { AnwDieCriticalError("Unauthorized mode / bad URL"); } $oAction->setAsCurrentAction(); AnwDebug::log("Action : " . $sAction); AnwDebug::stopbench("preparing action"); //run $oAction->runAndOutput(); } catch (AnwException $e) { errorApp($e); }
/** * Run output (which has been cleaned and maybe cached) on each hit. * Result will be immediately displayed and not reused, so we don't need to keep track of special tags for next execution. */ protected function run($sReturn, $bRunDynamicParsing, $bRunDynamicPhp) { $sReturn = AnwPlugins::vhook('output_run_before', $sReturn, $this->oPage); self::debug("run : dynamicParsing=" . $bRunDynamicParsing . ", dynamicPhp=" . $bRunDynamicPhp); //execute user's php code (if any) //it seems safer to execute PHP code before that any dynamic transformation to the content is applied (cache, loops...) //so that we are *sure* that the PHP code being executed comes directly from the edited content, //and not generated from a compromised dynamic transformation. if ($bRunDynamicPhp) { AnwDebug::startbench("runPhp", true); $sReturn = AnwUtils::evalMixedPhpCode($sReturn); AnwDebug::stopbench("runPhp"); } //PHP code has been executed, we should never go back in this function! if ($bRunDynamicParsing) { $sReturn = $this->getParser()->parse($sReturn); } $sReturn = AnwPlugins::vhook('output_run', $sReturn, $this->oPage); return $sReturn; }
/** * @throws AnwUnexpectedException */ static function loadDriver() { AnwDebug::startbench("Sessions driver init"); self::$oDriver = AnwSessionsDriver::loadComponent(AnwComponent::globalCfgDriverSessions()); self::$oDriver->init(); if (self::isDriverInternal()) { self::debug("Sessions Driver loaded : internal"); } else { if (self::isDriverExternal()) { self::debug("Sessions Driver loaded : external"); } else { throw new AnwUnexpectedException("Unknown sessionsdriver type"); } } AnwDebug::stopbench("Sessions driver init"); }