diff --git a/404.php b/404.php index 364ae33a..5ac7f2ad 100644 --- a/404.php +++ b/404.php @@ -1,33 +1,34 @@ init(); +if (!is_dir($dir)) + mkdir($dir); -if($cache->get("404glob") == false){ -$files = glob("404/*.*"); -$cache->set("404glob", $files); -}else -$files = $cache->get("404glob"); +if ($config['cache']['enabled']) { + $files = cache::get('notfound_files'); +} -if(count($files) == 0) - $errorimage = ""; -else +if (!isset($files) or !$files) { + $files = array_diff(scandir($dir), array('..', '.')); + + if ($config['cache']['enabled']) { + cache::set('notfound_files', $files); + } +} + +if (count($files) == 0) { + $errorimage = false; +} else { $errorimage = $files[array_rand($files)]; +} $page = <<
-

404 Not Found

- - +

- EOT; -echo Element("page.html", array("config" => $config, "body" => $page, "title" => "")); +echo Element("page.html", array("config" => $config, "body" => $errorimage ? $page : "", "title" => "404 Not Found"));