summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-21 21:00:48 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-21 21:00:48 -0400
commit6ced32a51269303343a6d3e803dc299eff39781d (patch)
treefc1d2edd2dd5642f90003bbf9a8c614f8004d9f3
parent1037a46baca97a364540b02a5d8f7886506df095 (diff)
revert the last commit
-rw-r--r--index.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/index.php b/index.php
index 82d3213..694931a 100644
--- a/index.php
+++ b/index.php
@@ -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">