com web/php: Cache & attempt to gzip the search indexes: cached.php js/search.js

From: Date: Fri, 22 Nov 2013 08:07:04 +0000
Subject: com web/php: Cache & attempt to gzip the search indexes: cached.php js/search.js
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-17190@lists.php.net to get a copy of this message
Commit: e3ce6e7728618ff13fb390a392418d7e37be13f5 Author: Hannes Magnusson <bjori@mongodb.com> Fri, 22 Nov 2013 00:06:45 -0800 Parents: edb410a8af22bd35e0326dc93005f492cc110b5d Branches: master Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=e3ce6e7728618ff13fb390a392418d7e37be13f5 Log: Cache & attempt to gzip the search indexes Changed paths: M cached.php M js/search.js Diff: diff --git a/cached.php b/cached.php index 196fd77..0de9e2d 100644 --- a/cached.php +++ b/cached.php @@ -2,12 +2,26 @@ $_SERVER['BASE_PAGE'] = 'cached.php'; include_once 'include/prepend.inc'; -if (!isset($_GET["t"], $_GET["f"])) { +if (!isset($_GET["f"])) { header("Location: http://php.net/"); exit; } +$abs = $_SERVER["DOCUMENT_ROOT"]. "/" .(string)$_GET["f"]; +$abs = realpath($abs); + +if (strncmp($abs, $_SERVER["DOCUMENT_ROOT"], strlen($_SERVER["DOCUMENT_ROOT"])) != 0) { + header("Location: http://php.net"); + exit; +} + +if (isset($_GET["t"])) { + $time = (int)$_GET["t"]; +} else { + $time = filemtime($abs); +} + -$tsstring = gmdate("D, d M Y H:i:s ", $_GET["t"]) . "GMT"; +$tsstring = gmdate("D, d M Y H:i:s ", $time) . "GMT"; if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && ($_SERVER["HTTP_IF_MODIFIED_SINCE"] == $tsstring)) { header("HTTP/1.1 304 Not Modified"); @@ -16,13 +30,6 @@ if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && header("Last-Modified: " . $tsstring); -$abs = $_SERVER["DOCUMENT_ROOT"]. "/" .(string)$_GET["f"]; -$abs = realpath($abs); - -if (strncmp($abs, $_SERVER["DOCUMENT_ROOT"], strlen($_SERVER["DOCUMENT_ROOT"])) != 0) { - header("Location: http://php.net"); - exit; -} if (substr($abs, -3) == ".js" || substr($abs, -5) == ".json") { header("Content-Type: application/javascript"); } elseif (substr($abs, -4) == ".css") { diff --git a/js/search.js b/js/search.js index b5d6765..4957fcd 100644 --- a/js/search.js +++ b/js/search.js @@ -272,10 +272,10 @@ success(backends); }, - url: "/manual/" + language + "/search-description.json" + url: "/cached.php?f=/manual/" + language + "/search-description.json" }); }, - url: "/manual/" + language + "/search-index.json" + url: "/cached.php?f=/manual/" + language + "/search-index.json" }); };

« previous php.webmaster (#17190) next »