Added proper 404 errors on file or directory not found

This commit is contained in:
Marc MAURICE 2010-11-06 14:40:46 +01:00
parent 3287102a85
commit 4c7e1533e4
2 changed files with 10 additions and 0 deletions

View file

@ -103,6 +103,11 @@ $otherFiles = array();
$realDir = IMAGES_DIR.$shortPath;
if (! is_dir($realDir)) {
header("HTTP/1.1 404 Not Found");
die("Directory Not Found");
}
foreach (scandir($realDir) as $file) if ($file != '.' and $file != '..')
{
if (is_dir("$realDir/$file"))

View file

@ -24,6 +24,11 @@ if ($shortPath == '/') $shortPath = '';
// extra security check to avoid /photos/index/../.. like urls, maybe useless but..
if (strpos($shortPath, '..') !== false) die(".. found in url");
if (! is_file(IMAGES_DIR.$shortPath)) {
header("HTTP/1.1 404 Not Found");
die("File Not Found");
}
$scriptPath = $_SERVER["SCRIPT_NAME"];
// get all images in an array