2010-12-01 05:53:11 -05:00
|
|
|
<?php
|
2012-04-11 12:49:22 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2010-2012 Tinyboard Development Group
|
|
|
|
*/
|
|
|
|
|
|
|
|
require 'inc/functions.php';
|
2012-04-12 12:11:41 -04:00
|
|
|
require 'inc/mod/auth.php';
|
|
|
|
require 'inc/mod/pages.php';
|
2012-04-11 12:49:22 -04:00
|
|
|
|
2012-04-12 12:11:41 -04:00
|
|
|
// Fix for magic quotes
|
2012-04-11 12:49:22 -04:00
|
|
|
if (get_magic_quotes_gpc()) {
|
|
|
|
function strip_array($var) {
|
2012-04-12 07:56:01 -04:00
|
|
|
return is_array($var) ? array_map('strip_array', $var) : stripslashes($var);
|
2012-04-11 12:49:22 -04:00
|
|
|
}
|
2010-12-01 05:53:11 -05:00
|
|
|
|
2012-04-11 12:49:22 -04:00
|
|
|
$_GET = strip_array($_GET);
|
|
|
|
$_POST = strip_array($_POST);
|
|
|
|
}
|
|
|
|
|
|
|
|
$query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
|
|
|
|
|
2012-04-12 12:11:41 -04:00
|
|
|
$pages = array(
|
|
|
|
'/^$/' => ':?/', // redirect to dashboard
|
|
|
|
'/^\/$/' => 'dashboard', // dashboard
|
2011-02-16 03:59:13 -05:00
|
|
|
|
2012-04-12 12:11:41 -04:00
|
|
|
'/^\/IP\/(.+)$/' => 'ip', // view ip address
|
2012-04-11 12:49:22 -04:00
|
|
|
|
2012-04-12 12:11:41 -04:00
|
|
|
// This should always be at the end:
|
|
|
|
'/^\/(\w+)\/' . preg_quote($config['file_index'], '/') . '?$/' => 'view_board',
|
|
|
|
'/^\/(\w+)\/' . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '/')) . '$/' => 'view_board',
|
|
|
|
'/^\/(\w+)\/' . preg_quote($config['dir']['res'], '/') .
|
|
|
|
str_replace('%d', '(\d+)', preg_quote($config['file_page'], '/')) . '$/' => 'view_thread',
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!$mod)
|
|
|
|
$pages = array('//' => 'login');
|
|
|
|
|
|
|
|
foreach ($pages as $uri => $handler) {
|
|
|
|
if (preg_match($uri, $query, $matches)) {
|
|
|
|
$matches = array_slice($matches, 1);
|
|
|
|
|
|
|
|
if ($config['debug']) {
|
|
|
|
$debug['mod_page'] = array(
|
|
|
|
'req' => $query,
|
|
|
|
'match' => $uri,
|
|
|
|
'handler' => $handler
|
2012-04-11 12:49:22 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-04-12 12:11:41 -04:00
|
|
|
if ($handler[0] == ':') {
|
|
|
|
header('Location: ' . substr($handler, 1), true, $config['redirect_http']);
|
|
|
|
} elseif (is_callable("mod_page_$handler")) {
|
|
|
|
call_user_func_array("mod_page_$handler", $matches);
|
|
|
|
} elseif (is_callable("mod_$handler")) {
|
|
|
|
call_user_func_array("mod_$handler", $matches);
|
2012-04-11 12:49:22 -04:00
|
|
|
} else {
|
2012-04-12 12:11:41 -04:00
|
|
|
error("Mod page '$handler' not found!");
|
2012-04-11 12:49:22 -04:00
|
|
|
}
|
|
|
|
|
2012-04-12 12:11:41 -04:00
|
|
|
exit;
|
2010-12-01 05:53:11 -05:00
|
|
|
}
|
2012-04-11 12:49:22 -04:00
|
|
|
}
|
2011-11-16 02:53:37 -05:00
|
|
|
|
2012-04-12 12:11:41 -04:00
|
|
|
error($config['error']['404']);
|
|
|
|
|