diff --git a/TODO b/TODO index 4c57a72..b89c6b5 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ * manage url encoding: The filename fetched on disk may differ from that was asked by URL. * check /etc/passwd not accessible: Perform sanity checks against unauthorized access. -* manage 404: Display better errors. * a way to get the source of a page, using urlrewriting * options to activate the text decoration * HTML caching: Nginx tries the html, if not found use this script to build it diff --git a/index.php b/index.php index 778d98f..50661b2 100644 --- a/index.php +++ b/index.php @@ -13,6 +13,9 @@ define("DASHES" ); $url = @$_REQUEST["url"]; + + +######################################## Installation page if (empty($url)) { ?> @@ -31,17 +34,41 @@ if (empty($url)) { echo "\n\n"; die(); } +######################################## /Installation page +# Removes the trailling slash, to be sure there's not any. +$GMI_DIR = rtrim($_SERVER['DOCUMENT_ROOT'], "/"); +$filePath = $GMI_DIR."/".$url; -$GMI_DIR = $_SERVER['DOCUMENT_ROOT']; - - -$filePath = $GMI_DIR.$url; $fileContents = @file_get_contents($filePath); -if (!$fileContents) { - http_response_code(404); - die("404: $url"); + + +######################################## 404 page +if (empty($fileContents)) { + http_response_code(404); ?> + + + + + + + + $url rééssayer ? +=> / index +EOF; +echo translateGemToHtml($text404); +echo "\n"; +die(); } +######################################## /404 page # Removes the Byte Order Mark $fileContents = preg_replace("/\xEF\xBB\xBF/", "", $fileContents);