2014-09-25 01:41:23 +02:00
|
|
|
<?php
|
|
|
|
|
2014-11-21 13:05:20 +01:00
|
|
|
require_once "inc/functions.php";
|
|
|
|
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
2014-09-25 01:41:23 +02:00
|
|
|
|
2015-04-07 01:48:03 +02:00
|
|
|
global $config;
|
|
|
|
|
2014-09-28 04:21:34 +02:00
|
|
|
$dir = "static/404/";
|
2014-09-25 01:41:23 +02:00
|
|
|
|
2014-09-28 04:21:34 +02:00
|
|
|
if (!is_dir($dir))
|
|
|
|
mkdir($dir);
|
2014-09-26 00:40:43 +02:00
|
|
|
|
2014-09-28 04:21:34 +02:00
|
|
|
if ($config['cache']['enabled']) {
|
|
|
|
$files = cache::get('notfound_files');
|
|
|
|
}
|
2014-09-25 02:02:40 +02:00
|
|
|
|
2014-09-28 04:21:34 +02: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-25 02:02:40 +02:00
|
|
|
$errorimage = $files[array_rand($files)];
|
2014-09-28 04:21:34 +02:00
|
|
|
}
|
2014-09-25 01:41:23 +02:00
|
|
|
|
2015-01-01 07:28:00 +01:00
|
|
|
if (preg_match('!'.$config['board_regex'].'/'.$config['dir']['res'].'\d+\.html!u', $_SERVER['REQUEST_URI'])) {
|
|
|
|
$return_link = '<a href="../index.html">[ Return ]</a>';
|
|
|
|
} else {
|
|
|
|
$return_link = '';
|
|
|
|
}
|
|
|
|
|
2015-02-17 01:33:13 +01:00
|
|
|
$ad = Element("ad_top.html", array());
|
|
|
|
|
2014-09-25 01:41:23 +02:00
|
|
|
$page = <<<EOT
|
2015-02-17 01:33:13 +01:00
|
|
|
<div style="text-align:center">$ad</div>
|
2014-09-25 02:02:40 +02:00
|
|
|
<div class="ban">
|
2014-09-28 04:21:34 +02:00
|
|
|
<p style="text-align:center"><img src="/static/404/{$errorimage}" style="width:100%"></p>
|
2015-01-01 07:28:00 +01:00
|
|
|
<p style="text-align:center"><a href="/index.html">[ Home ]</a>{$return_link}</p>
|
2014-09-25 02:02:40 +02:00
|
|
|
</div>
|
2014-09-28 04:39:41 +02:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
if (localStorage.favorites) {
|
|
|
|
var faves = JSON.parse(localStorage.favorites);
|
|
|
|
|
|
|
|
$.each(faves, function(k, v) {
|
2014-11-12 10:16:42 +01:00
|
|
|
if ((window.location.pathname === '/' + v + '/') || (window.location.pathname === '/' + v)) {
|
2014-12-20 16:00:26 +01:00
|
|
|
faves.splice(k, 1);
|
2014-09-28 04:39:41 +02:00
|
|
|
localStorage.favorites = JSON.stringify(faves);
|
2014-09-28 04:47:36 +02:00
|
|
|
|
|
|
|
alert('As /' + v + '/ no longer exists, it has been removed from your favorites.');
|
2014-09-28 04:39:41 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</script>
|
2014-09-25 01:41:23 +02:00
|
|
|
EOT;
|
|
|
|
|
2014-09-28 04:21:34 +02:00
|
|
|
echo Element("page.html", array("config" => $config, "body" => $errorimage ? $page : "", "title" => "404 Not Found"));
|