small change

This commit is contained in:
Michael Save 2012-05-06 12:44:37 +10:00
parent c2f790ee86
commit 8ea20109fe

98
mod.php
View File

@ -21,69 +21,79 @@ if (get_magic_quotes_gpc()) {
$query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; $query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
$pages = array( $pages = array(
'!^$!' => ':?/', // redirect to dashboard '' => ':?/', // redirect to dashboard
'!^/$!' => 'dashboard', // dashboard '/' => 'dashboard', // dashboard
'!^/confirm/(.+)$!' => 'confirm', // confirm action (if javascript didn't work) '/confirm/(.+)' => 'confirm', // confirm action (if javascript didn't work)
'!^/logout$!' => 'logout', // logout '/logout' => 'logout', // logout
'!^/users$!' => 'users', // manage users '/users' => 'users', // manage users
'!^/users/(\d+)$!' => 'user', // edit user '/users/(\d+)' => 'user', // edit user
'!^/users/(\d+)/(promote|demote)$!' => 'user_promote', // prmote/demote user '/users/(\d+)/(promote|demote)' => 'user_promote', // prmote/demote user
'!^/users/new$!' => 'user_new', // create a new user '/users/new' => 'user_new', // create a new user
'!^/new_PM/([^/]+)$!' => 'new_pm', // create a new pm '/new_PM/([^/]+)' => 'new_pm', // create a new pm
'!^/PM/(\d+)(/reply)?$!' => 'pm', // read a pm '/PM/(\d+)(/reply)?' => 'pm', // read a pm
'!^/inbox$!' => 'inbox', // pm inbox '/inbox' => 'inbox', // pm inbox
'!^/noticeboard$!' => 'noticeboard', // view noticeboard '/noticeboard' => 'noticeboard', // view noticeboard
'!^/noticeboard/(\d+)$!' => 'noticeboard', // view noticeboard '/noticeboard/(\d+)' => 'noticeboard', // view noticeboard
'!^/noticeboard/delete/(\d+)$!' => 'noticeboard_delete',// delete from noticeboard '/noticeboard/delete/(\d+)' => 'noticeboard_delete',// delete from noticeboard
'!^/log$!' => 'log', // modlog '/log' => 'log', // modlog
'!^/log/(\d+)$!' => 'log', // modlog '/log/(\d+)' => 'log', // modlog
'!^/news$!' => 'news', // view news '/news' => 'news', // view news
'!^/news/(\d+)$!' => 'news', // view news '/news/(\d+)' => 'news', // view news
'!^/news/delete/(\d+)$!' => 'news_delete', // delete from news '/news/delete/(\d+)' => 'news_delete', // delete from news
'!^/edit/(\w+)$!' => 'edit_board', // edit board details '/edit/(\w+)' => 'edit_board', // edit board details
'!^/new-board$!' => 'new_board', // create a new board '/new-board' => 'new_board', // create a new board
'!^/rebuild$!' => 'rebuild', // rebuild static files '/rebuild' => 'rebuild', // rebuild static files
'!^/reports$!' => 'reports', // report queue '/reports' => 'reports', // report queue
'!^/reports/(\d+)/dismiss(all)?$!' => 'report_dismiss', // dismiss a report '/reports/(\d+)/dismiss(all)?' => 'report_dismiss', // dismiss a report
'!^/ban$!' => 'ban', // new ban '/ban' => 'ban', // new ban
'!^/IP/([\w.:]+)$!' => 'ip', // view ip address '/IP/([\w.:]+)' => 'ip', // view ip address
'!^/IP/([\w.:]+)/remove_note/(\d+)$!' => 'ip_remove_note', // remove note from ip address '/IP/([\w.:]+)/remove_note/(\d+)' => 'ip_remove_note', // remove note from ip address
'!^/bans$!' => 'bans', // ban list '/bans' => 'bans', // ban list
'!^/bans/(\d+)$!' => 'bans', // ban list '/bans/(\d+)' => 'bans', // ban list
'!^/(\w+)/delete/(\d+)$!' => 'delete', // delete post '/(\w+)/delete/(\d+)' => 'delete', // delete post
'!^/(\w+)/ban(&delete)?/(\d+)$!' => 'ban_post', // ban poster '/(\w+)/ban(&delete)?/(\d+)' => 'ban_post', // ban poster
'!^/(\w+)/deletefile/(\d+)$!' => 'deletefile', // delete file from post '/(\w+)/deletefile/(\d+)' => 'deletefile', // delete file from post
'!^/(\w+)/deletebyip/(\d+)(/global)?$!' => 'deletebyip', // delete all posts by IP address '/(\w+)/deletebyip/(\d+)(/global)?' => 'deletebyip', // delete all posts by IP address
'!^/(\w+)/(un)?lock/(\d+)$!' => 'lock', // lock thread '/(\w+)/(un)?lock/(\d+)' => 'lock', // lock thread
'!^/(\w+)/(un)?sticky/(\d+)$!' => 'sticky', // sticky thread '/(\w+)/(un)?sticky/(\d+)' => 'sticky', // sticky thread
'!^/(\w+)/bump(un)?lock/(\d+)$!' => 'bumplock', // "bumplock" thread '/(\w+)/bump(un)?lock/(\d+)' => 'bumplock', // "bumplock" thread
// these pages aren't listed in the dashboard without $config['debug'] // these pages aren't listed in the dashboard without $config['debug']
'!^/debug/antispam$!' => 'debug_antispam', '/debug/antispam' => 'debug_antispam',
// This should always be at the end: // This should always be at the end:
'!^/(\w+)/$!' => 'view_board', '/(\w+)/' => 'view_board',
'!^/(\w+)/' . preg_quote($config['file_index'], '!') . '$!' => 'view_board', '/(\w+)/' . preg_quote($config['file_index'], '!') => 'view_board',
'!^/(\w+)/' . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) . '$!' => 'view_board', '/(\w+)/' . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) => 'view_board',
'!^/(\w+)/' . preg_quote($config['dir']['res'], '!') . '/(\w+)/' . preg_quote($config['dir']['res'], '!') .
str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) . '$!' => 'view_thread', str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) => 'view_thread',
); );
if (!$mod) { if (!$mod) {
$pages = array('//' => 'login'); $pages = array('!!' => 'login');
} elseif (isset($_GET['status'], $_GET['r'])) { } elseif (isset($_GET['status'], $_GET['r'])) {
header('Location: ' . $_GET['r'], true, (int)$_GET['status']); header('Location: ' . $_GET['r'], true, (int)$_GET['status']);
} elseif (isset($config['mod']['custom_pages'])) { exit;
}
if (isset($config['mod']['custom_pages'])) {
$pages = array_merge($pages, $config['mod']['custom_pages']); $pages = array_merge($pages, $config['mod']['custom_pages']);
} }
$new_pages = array();
foreach ($pages as $key => $callback) {
$new_pages[@$key[0] == '!' ? $key : "!^$key$!"] = $callback;
}
$pages = $new_pages;
foreach ($pages as $uri => $handler) { foreach ($pages as $uri => $handler) {
if (preg_match($uri, $query, $matches)) { if (preg_match($uri, $query, $matches)) {
$matches = array_slice($matches, 1); $matches = array_slice($matches, 1);