/** * @see \Ableron\Install\Step\InstallationStepInterface::prepareDisplay() */ public function prepareDisplay() { // perform installation before displaying final page $this->executeAutomatically(); // register template variables $this->getInstaller()->getTemplateHandler()->registerVariables(array('backend.basePath' => Application::getConfig()->get('backend.basePath'), 'frontend.basePath' => Application::getConfig()->get('frontend.basePath'))); }
/** * Checks whether the maximum inactivity time has been exceeded. * * Returns TRUE in case the maximum inactivity time has not been exceeded. * Otherwise returns FALSE. * * @see \Ableron\Core\Session\Validators\ValidatorInterface::isValid() */ public function isValid(SessionEntity $session) { // get setting key for the timeout to use $settingKeySessionInactivityTimeout = Application::getRequestHandler()->isFrontendRequest() ? 'session.frontend.inactivityTimeoutValidator.timeout' : 'session.backend.inactivityTimeoutValidator.timeout'; // return whether session has timed out return $session->getLastActivityTime() > DateUtil::getCurrentUtcDateTime()->sub(Application::getConfig()->get($settingKeySessionInactivityTimeout)); }
/** * Initializes the request handler. */ public function __construct() { // set request object $this->setRequest(new HttpRequest($this->getRequestUri(), EnvironmentUtil::getEnvironmentVariable('REQUEST_METHOD'), $this->getRequestHttpVersion(), $this->getRequestHeaders(), $_GET, $_POST, $this->getRequestCookies())); // get the URLs we need $frontendBaseUrl = new Uri(rtrim(rtrim(EnvironmentUtil::getSiteUrl()->toString(), '/') . Application::getConfig()->get('frontend.basePath'), '/')); $backendBaseUrl = new Uri(rtrim(rtrim(EnvironmentUtil::getSiteUrl()->toString(), '/') . Application::getConfig()->get('backend.basePath'), '/')); $requestPath = $this->getRequest()->getUri()->getPath(); // set whether we have a frontend request $this->isFrontendRequest = $this->checkIsFrontendRequest($frontendBaseUrl, $backendBaseUrl, $this->getRequest()->getUri()->getHost(), $requestPath); // determine module base path $this->moduleBasePath = '/' . explode('/', trim(StringUtil::getSubstring($requestPath, StringUtil::getLength($this->isFrontendRequest ? $frontendBaseUrl->getPath() : $backendBaseUrl->getPath())), '/'), 2)[0]; // get requested module $this->requestedModule = Application::getModuleManager()->findModuleByBasePath($this->moduleBasePath, $this->isFrontendRequest); // make sure module base path points to an existing module if ($this->requestedModule === null || !$this->requestedModule->isActive()) { $this->moduleBasePath = '/'; $this->requestedModule = Application::getModuleManager()->findModuleByBasePath($this->moduleBasePath, $this->isFrontendRequest); } // set module request URI $this->setModuleRequestUri(new Uri('/' . ltrim(StringUtil::getSubstring($requestPath, StringUtil::getLength($this->isFrontendRequest ? $frontendBaseUrl->getPath() : $backendBaseUrl->getPath()) + StringUtil::getLength($this->moduleBasePath)), '/'))); $this->getModuleRequestUri()->setQuery($this->getRequest()->getUri()->getQuery()); }
/** * Returns all enabled session validators. * * @return \Ableron\Lib\Collections\Implementations\ObjectSet */ protected function getValidators() { if ($this->validators === null) { // init object set of validators $this->validators = new ObjectSet(ValidatorInterface::class); // get setting keys $settingKeySessionInactivityTimeoutValidatorEnabled = Application::getRequestHandler()->isFrontendRequest() ? 'session.frontend.inactivityTimeoutValidator.isEnabled' : 'session.backend.inactivityTimeoutValidator.isEnabled'; $settingKeySessionUserAgentValidatorEnabled = Application::getRequestHandler()->isFrontendRequest() ? 'session.frontend.userAgentValidator.isEnabled' : 'session.backend.userAgentValidator.isEnabled'; $settingKeySessionIpAddressValidatorEnabled = Application::getRequestHandler()->isFrontendRequest() ? 'session.frontend.ipAddressValidator.isEnabled' : 'session.backend.ipAddressValidator.isEnabled'; // handle inactivity timeout validator if (Application::getConfig()->get($settingKeySessionInactivityTimeoutValidatorEnabled)) { $this->validators->add(new InactivityTimeoutValidator()); } // handle user agent validator if (Application::getConfig()->get($settingKeySessionUserAgentValidatorEnabled)) { $this->validators->add(new UserAgentValidator()); } // handle IP address validator if (Application::getConfig()->get($settingKeySessionIpAddressValidatorEnabled)) { $this->validators->add(new IpAddressValidator()); } } return $this->validators; }
/** * Returns the base URL of the current area, i.e. either the base URL of the * frontend or the base URL of the backend. * * @return \Ableron\Lib\Net\Uri */ public static function getBaseUrl() { return clone CacheUtil::getFromCache(self::getCache(), __FUNCTION__, function () { // get setting key of the base path to use $settingKeyBasePath = Application::getRequestHandler()->isFrontendRequest() ? 'frontend.basePath' : 'backend.basePath'; // calculate and return base path return (new Uri(rtrim(rtrim(self::getSiteUrl()->toString(), '/') . '/' . trim(Application::getConfig()->get($settingKeyBasePath), '/'), '/')))->normalize(); }); }
/** * Sends the response content. * * Compresses the output automatically if possible. * * Discards all output sent using echo/print. * * There has been a problem with ob_gzhandler + empty response body + HTTP * status code 304 in at least PHP 5.2. This problem does not seem to exist * anymore in PHP 5.4. * * @link https://bugs.php.net/bug.php?id=51579 * @link http://www.php.net/manual/en/function.ob-gzhandler.php#97385 * @return void */ private function sendResponseContent() { // let ob_gzhandler manage the compression if (Application::getConfig()->get('performance.outputCompression.isEnabled') && ABLERON_EXT_ZLIB_AVAILABLE && !$this->transparentOutputCompressionEnabled() && !$this->getResponse()->getContentType()->hasBinaryContent() && !$this->getResponse()->isRedirect()) { ob_end_clean(); ob_start('ob_gzhandler'); } // send current content echo $this->getResponse()->getContent(); // clear response content cache $this->getResponse()->setContent(''); }
/** * Initializes the security handler. */ public function __construct() { $this->csrfProtector = new CsrfProtector(Application::getConfig()->get('security.csrfProtection.tokenLength')); }