public function __construct() { $this->enabled = (bool) Primitive::getConfigValue('site.cache') && !(bool) Primitive::getConfigValue('site.debug') && is_dir(self::CACHE_DIR) && is_writable(self::CACHE_DIR); }
/** * Real PHP session start procedure */ private function launch() { session_set_save_handler($this); session_name(self::DEFAULT_SESSION_NAME); // устанавливаем время жизни cookie if (Primitive::getConfigValue('site.domain')) { $path = '/'; $domain = '.' . Primitive::getConfigValue('site.domain'); } else { $path = E()->getSiteManager()->getCurrentSite()->root; $domain = ''; } session_set_cookie_params($this->lifespan, $path, $domain); session_id($this->phpSessId); session_start(); $this->isStarted = true; }
/** * Create URI. * * @param string $uriString URI string. * @return URI */ public static function create($uriString = '') { self::$trick = true; if (!$uriString) { $host = Primitive::getConfigValue('site.domain'); $protocol = 'http'; $requestURI = '/'; if (!E()->Utils->is_PHP_CLI()) { $host = explode(':', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']); $protocol = isset($_SERVER['HTTPS']) ? 'https' : 'http'; $requestURI = $_SERVER['REQUEST_URI']; } if (sizeof($host) == 1) { $port = $protocol == 'http' ? 80 : 443; list($host) = $host; } else { list($host, $port) = $host; } $uriString = $protocol . '://' . $host . ':' . $port . $requestURI; } return new URI($uriString); }
/** * Send response to the client. * @note This the last step. */ public function commit() { if (!headers_sent()) { $this->sendHeaders(); $this->sendCookies(); } else { //throw new SystemException('ERR_HEADERS_SENT', SystemException::ERR_CRITICAL); } $contents = $this->body; if ((bool) Primitive::getConfigValue('site.compress') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && !(bool) Primitive::getConfigValue('site.debug')) { header("Vary: Accept-Encoding"); header("Content-Encoding: gzip"); $contents = gzencode($contents, 6); } echo $contents; session_write_close(); exit; }