Mercurial > dirlist-php
comparison index.php @ 25:69b2c15cadfb
Better(?) way to check DL_DIR variable.
| author | edogawaconan <me@myconan.net> |
|---|---|
| date | Thu, 30 Oct 2014 11:39:11 +0900 |
| parents | 949398173ecb |
| children | eee7ca924a5e |
comparison
equal
deleted
inserted
replaced
| 24:f9588ccb7a42 | 25:69b2c15cadfb |
|---|---|
| 10 $uri = substr($uri, 0, $query_string_start); | 10 $uri = substr($uri, 0, $query_string_start); |
| 11 } | 11 } |
| 12 $uri = urldecode($uri); | 12 $uri = urldecode($uri); |
| 13 | 13 |
| 14 // $dir: filesystem path | 14 // $dir: filesystem path |
| 15 $dir = $_SERVER["DL_DIR"]; | 15 $dir = isset($_SERVER["DL_DIR"]) ? $_SERVER["DL_DIR"] : $_SERVER["DOCUMENT_ROOT"] . $uri; |
| 16 if ($dir === null || $dir === "") { $dir = $_SERVER["DOCUMENT_ROOT"] . $uri; } | |
| 17 | 16 |
| 18 if (realpath($dir) === false) { | 17 if (realpath($dir) === false) { |
| 19 header("HTTP/1.0 404 Not Found"); | 18 header("HTTP/1.0 404 Not Found"); |
| 20 } elseif (substr($uri, -1) !== "/") { | 19 } elseif (substr($uri, -1) !== "/") { |
| 21 header("Location: " . $uri . "/"); | 20 header("Location: " . $uri . "/"); |
