1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00
Files
archived-web-php/js/search-index.php
AllenJB 658fafec3e Update search to use new pre-combined indexes + local docs support (#1586)
* Update search.js to use new pre-combined indexes; Support for running search on local docs

* Update search.js to use new pre-combined indexes; Support for running search on local docs
2025-11-04 17:17:06 +00:00

26 lines
734 B
PHP

<?php
use phpweb\I18n\Languages;
$lang = $_GET["lang"] ?? "en";
if (empty($_SERVER["DOCUMENT_ROOT"])) {
$_SERVER["DOCUMENT_ROOT"] = __DIR__ . "/../";
}
include __DIR__ . '/../include/prepend.inc';
if (!isset(Languages::ACTIVE_ONLINE_LANGUAGES[$lang])) {
header("Location: http://php.net");
}
$combinedIndex = $_SERVER["DOCUMENT_ROOT"] . "/manual/$lang/search-combined.json";
$tsstring = gmdate("D, d M Y H:i:s ", filemtime($combinedIndex)) . "GMT";
if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) &&
($_SERVER["HTTP_IF_MODIFIED_SINCE"] == $tsstring)) {
header("HTTP/1.1 304 Not Modified");
exit;
}
header("Last-Modified: " . $tsstring);
header("Content-Type: application/javascript");
readfile($combinedIndex);