Commit: 13e0c38c367c1f878b1b7609fbfb9f26a7207798 Author: Hannes Magnusson <[email protected]> Fri, 22 Nov 2013 00:06:45 -0800 Parents: 1238eb0c05eb0fcf907a5e635afa280eb7db367f Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=13e0c38c367c1f878b1b7609fbfb9f26a7207798 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" }); }; -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
