/** * Export the config params to the client, thus the client can adjust it's logic according the config. * * @access public * @return void */ public function exportConfig() { $view = new stdclass(); $view->version = $this->config->version; $view->requestType = $this->config->requestType; $view->pathType = $this->config->pathType; $view->requestFix = $this->config->requestFix; $view->moduleVar = $this->config->moduleVar; $view->methodVar = $this->config->methodVar; $view->viewVar = $this->config->viewVar; $view->sessionVar = $this->config->sessionVar; $this->session->set('rand', mt_rand(0, 10000)); $view->sessionName = session_name(); $view->sessionID = session_id(); $view->rand = $this->session->rand; $view->expiredTime = ini_get('session.gc_maxlifetime'); echo json_encode($view); }
/** * Sets http headers for proper caching with 304-code according to the file's change data. * * @param ojbect $fileObject the fileObject who's change date should be compared against the * browser's cache-timestsamp * * @return bool indicating if file is cached in browser */ private function _setHttpCacheHeaders($fileObject) { # Do not force 304 caching if disabled by config if (static::$_aggressiveCaching !== true) { return false; } # Collect some information about file requested and file in browser's cache $fileModifiedTimestamp = $fileObject->getMTime(); $fileName = $fileObject->getFileName(); $browserModifiedTimestamp = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : null; # Makes the browser respond with HTTP_IF_MODIFIED_SINCE and If-None-Match for E-Tag validation header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $fileModifiedTimestamp) . " GMT"); header('ETag: "' . md5($fileModifiedTimestamp . $fileName) . '"'); header('Cache-Control: public'); # Now check if file content needs to be send if ($browserModifiedTimestamp !== null && $fileModifiedTimestamp <= $browserModifiedTimestamp) { http_response_code(304); return true; } return false; }