2014-09-24 16:41:23 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include "inc/functions.php";
|
|
|
|
|
2014-09-28 02:21:34 +00:00
|
|
|
$dir = "static/404/";
|
2014-09-24 16:41:23 -07:00
|
|
|
|
2014-09-28 02:21:34 +00:00
|
|
|
if (!is_dir($dir))
|
|
|
|
mkdir($dir);
|
2014-09-25 15:40:43 -07:00
|
|
|
|
2014-09-28 02:21:34 +00:00
|
|
|
if ($config['cache']['enabled']) {
|
|
|
|
$files = cache::get('notfound_files');
|
|
|
|
}
|
2014-09-24 17:02:40 -07:00
|
|
|
|
2014-09-28 02:21:34 +00:00
|
|
|
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 {
|
2014-09-24 17:02:40 -07:00
|
|
|
$errorimage = $files[array_rand($files)];
|
2014-09-28 02:21:34 +00:00
|
|
|
}
|
2014-09-24 16:41:23 -07:00
|
|
|
|
|
|
|
$page = <<<EOT
|
2014-09-24 17:02:40 -07:00
|
|
|
<div class="ban">
|
2014-09-28 02:21:34 +00:00
|
|
|
<p style="text-align:center"><img src="/static/404/{$errorimage}" style="width:100%"></p>
|
2014-09-24 17:02:40 -07:00
|
|
|
</div>
|
2014-09-24 16:41:23 -07:00
|
|
|
EOT;
|
|
|
|
|
2014-09-28 02:21:34 +00:00
|
|
|
echo Element("page.html", array("config" => $config, "body" => $errorimage ? $page : "", "title" => "404 Not Found"));
|