32 lines
1 KiB
PHP
32 lines
1 KiB
PHP
|
<?php
|
||
|
require(dirname(__FILE__) . '/includes/init.inc.php');
|
||
|
require(dirname(__FILE__) . '/includes/init.web.inc.php');
|
||
|
|
||
|
// Prepare the request URI
|
||
|
$uri = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
|
||
|
$uri = '/' . trim(str_replace($uri, '', $_SERVER['REQUEST_URI']), '/');
|
||
|
$uri = urldecode($uri);
|
||
|
|
||
|
// Which route is it?
|
||
|
foreach ($routes as $action => $rule) {
|
||
|
if (preg_match('~^'.$rule.'$~i', $uri, $params)) {
|
||
|
include('includes/views.inc.php');
|
||
|
$r = eval('return views::' . $action . '($params);');
|
||
|
switch ($r[0]) {
|
||
|
case 0:
|
||
|
exit;
|
||
|
case 404:
|
||
|
break;
|
||
|
default:
|
||
|
if ($r > 9000) die('<h1>It\'s over 9000!</h1>');
|
||
|
header("HTTP/1.1 500 Internal Server Error", true, 500);
|
||
|
exit('<h1>500 Internal Server Error</h1>');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// No match? Send 404!
|
||
|
header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
|
||
|
if (isset($r[1])) $tpl->assign('type', $r[1]);
|
||
|
$tpl->display('error404.html');
|