diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-21 21:00:48 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-21 21:00:48 -0400 |
commit | 6ced32a51269303343a6d3e803dc299eff39781d (patch) | |
tree | fc1d2edd2dd5642f90003bbf9a8c614f8004d9f3 | |
parent | 1037a46baca97a364540b02a5d8f7886506df095 (diff) |
revert the last commit
-rw-r--r-- | index.php | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -19,6 +19,20 @@ $dirname = explode("?", $_SERVER["REQUEST_URI"], 2)[0]; //////////////////////////////////////////////////////////////////////////////// +function show_404() { + // This is the template used by Nginx internally; + // if you want something else, have Nginx intercept it. + // Separation of concerns. + ?><html> +<head><title>404 Not Found</title></head> +<body bgcolor="white"> +<center><h1>404 Not Found</h1></center> +<hr><center><?php echo $_SERVER["SERVER_SOFTWARE"]; ?></center> +</body> +</html> +<?php +} + function normalizeN($filename) { $parts = preg_split("|/+|", $filename, -1, PREG_SPLIT_NO_EMPTY); $abs = substr($filename, 0, 1) === '/'; @@ -76,6 +90,19 @@ function classify($root, $dirname, $filename) { } //////////////////////////////////////////////////////////////////////////////// + +if (!is_dir($root.'/'.$dirname)) { + if (is_file($root.'/'.$dirname)) { + header('Content-Type: text/plain'); // gross, but if Nginx is "properly" configured, this only happens when serving itself, which is text + readfile($root.'/'.$dirname); + } else { + header("HTTP/1.0 404 Not Found"); + show_404(); + } + exit(0); +} + +//////////////////////////////////////////////////////////////////////////////// ?> <!DOCTYPE html> <html lang="en"> |