function getCachedOutputKeyDynamic() { $sCacheKey = ""; //we need this in order to get the dynamic link "?feed=rss2" working... if (AnwEnv::_GET(self::GET_FEED) == AnwFeed::TYPE_RSS2) { $sCacheKey .= AnwFeed::TYPE_RSS2; //rss links are absolute and may be in HTTP or HTTPS, depending on protocol currently in use $sCacheKey .= "|" . (AnwEnv::isHttps() ? "HTTPS" : "HTTP"); } return $sCacheKey; }
function runAndOutput() { try { AnwDebug::startbench("action runAndOutput", true); //captcha request? if (AnwEnv::_GET(self::GET_CAPTCHA)) { $this->doCaptcha(); exit; } //make sure this action is enabled in configuration if (!in_array($this->getName(), AnwComponent::getEnabledComponents(AnwComponent::TYPE_ACTION))) { throw new AnwAclException("Trying to execute an action which is not enabled"); } //is it an admin action? if ($this instanceof AnwAdminAction) { if (!AnwCurrentSession::getUser()->isAdminAllowed()) { throw new AnwAclException("Admin is not allowed"); } } //does action require https if available? if (self::isHttpsAction($this->getName())) { //do we need to redirect to https? if (self::globalCfgHttpsEnabled() && !AnwEnv::isHttps()) { //redirect to https self::debug("Redirecting to https..."); AnwUtils::httpPostToSession(); $asParams = $_GET; $sLink = AnwUtils::alink($this->getName(), $asParams); AnwUtils::redirect($sLink); //should automatically use https } } if (AnwCurrentSession::needsReauth()) { //reauth processing if (AnwEnv::_POST("reauth")) { self::debug("Processing reauth request..."); try { //check password and reset reauth $this->doReauth(AnwEnv::_POST("reauth")); self::debug("Reauth request success!"); } catch (AnwException $e) { //reauth failed, show reauth form again self::debug("Reauth success failed."); $this->doReauthForm(); //post data is already in session exit; } } //must the user reauth for this action? - do this after reauth processing if ($this instanceof AnwHarmlessAction) { //ok, user is authorized to run action without reauthenticating } else { //user needs to reauthenticate $this->checkReauth(); } } //restore POST if any in session AnwUtils::restoreHttpPostFromSession(); $this->initializeAction(); //run the action $this->init(); $this->run(); AnwDebug::stopbench("action runAndOutput"); $this->output(); } catch (AnwLockException $e) { $aoLocks = $e->getLocks(); $asLockInfos = array(); foreach ($aoLocks as $oLock) { $nLockType = $oLock->getLockType(); switch ($nLockType) { case AnwLock::TYPE_PAGEONLY: $sTranslation = "err_ex_lock_details_pageonly"; break; case AnwLock::TYPE_PAGEGROUP: $sTranslation = "err_ex_lock_details_pagegroup"; break; default: throw new AnwUnexpectedException("lock type unknown"); break; } $asLockInfos[] = self::g_($sTranslation, array("user" => '<b>' . AnwUtils::xText($oLock->getLockUser()->getDisplayName()) . '</b>', "pagename" => '<i>' . AnwUtils::xText($oLock->getLockPage()->getName()) . '</i>', "timestart" => Anwi18n::dateTime($oLock->getLockTime()), "timeseen" => Anwi18n::dateTime($oLock->getLockTimeLast()), "timeexpire" => Anwi18n::dateTime($oLock->getLockTimeLast() + self::globalCfgLocksExpiry()))); } $this->headJs($this->tpl()->errorLock_js()); $this->out = $this->tpl()->errorLock($asLockInfos); $this->output(); } catch (AnwException $e) { $nErrorNumber = false; if ($e instanceof AnwAclPhpEditionException) { $sTitle = self::g_("err_ex_acl_t"); $sExplain = self::g_("err_ex_acl_php_p"); $sImageSrc = AnwUtils::pathImg("warning.gif"); } else { if ($e instanceof AnwAclJsEditionException) { $sTitle = self::g_("err_ex_acl_t"); $sExplain = self::g_("err_ex_acl_js_p"); $sImageSrc = AnwUtils::pathImg("warning.gif"); } else { if ($e instanceof AnwAclMinTranslatedPercentException) { $sTitle = self::g_("err_ex_acl_t"); $sExplain = self::g_("err_ex_acl_mintranslatedpercent_p", array('percent' => $e->getTranslatedPercent())); $sImageSrc = AnwUtils::pathImg("warning.gif"); } else { if ($e instanceof AnwAclException) { $sTitle = self::g_("err_ex_acl_t"); if (AnwCurrentSession::isLoggedIn()) { $sExplain = self::g_("err_ex_acl_loggedin_p"); } else { $sExplain = self::g_("err_ex_acl_loggedout_p"); } $sImageSrc = AnwUtils::pathImg("warning.gif"); } else { if ($e instanceof AnwBadCallException) { $sTitle = self::g_("err_ex_badcall_t"); $sExplain = self::g_("err_ex_badcall_p"); $sImageSrc = AnwUtils::pathImg("warning.gif"); } else { if ($e instanceof AnwDbConnectException) { $sTitle = self::g_("err_ex_dbconnect_t"); $sExplain = self::g_("err_ex_dbconnect_p"); $sImageSrc = AnwUtils::pathImg("error.gif"); $nErrorNumber = AnwDebug::reportError($e); } else { $sTitle = self::g_("err_ex_unexpected_t"); $sExplain = self::g_("err_ex_unexpected_p"); $sImageSrc = AnwUtils::pathImg("error.gif"); $nErrorNumber = AnwDebug::reportError($e); } } } } } } $this->out = $this->tpl()->errorException($sTitle, $sExplain, $sImageSrc, $nErrorNumber); //self::output(); //not use $this to avoid potential errors if it's an ActionPage $this->output(); } }
/** * Appropriated link base (absolute or relative, HTTP or HTTPS). */ private static function doLinkBase($bUseSecureUrl, $bUseAbsoluteUrl) { // when we are in HTTPS, we want to stay in this mode... if (AnwComponent::globalCfgHttpsEnabled() && ($bUseSecureUrl || AnwAction::isActionSecure($sAction) || AnwEnv::isHttps())) { if (!AnwEnv::isHttps() || $bUseAbsoluteUrl) { // we switch to HTTPS (or force absolute url) $sLink = AnwComponent::globalCfgHttpsUrl(); } else { // we are already in HTTPS (and we want to stay in this mode - even if action doesn't require it) $sLink = self::linkRelative(); } } else { if ($bUseAbsoluteUrl) { // we force absolute url $sLink = AnwComponent::globalCfgUrlRoot(); } else { // we are already in HTTP $sLink = self::linkRelative(); } } return $sLink; }