summaryrefslogtreecommitdiff
path: root/mod.php
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2013-08-03 19:05:25 -0400
committerczaks <marcin@6irc.net>2013-08-03 19:05:25 -0400
commita0855cdcf5634d64fbb1ba294b05c8365ce37338 (patch)
treefa1217beedf487c321405432ea746343ec6afcec /mod.php
parent7d5fef9ace3bba46de40604b04ea2dee1dac7cb3 (diff)
parenta3fbff225927469e68efc7ab31977736f34c7480 (diff)
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Conflicts: inc/config.php inc/functions.php templates/generic_page.html templates/index.html
Diffstat (limited to 'mod.php')
-rw-r--r--mod.php84
1 files changed, 47 insertions, 37 deletions
diff --git a/mod.php b/mod.php
index cd4d17d4..742eeefb 100644
--- a/mod.php
+++ b/mod.php
@@ -21,64 +21,65 @@ if (get_magic_quotes_gpc()) {
$query = isset($_SERVER['QUERY_STRING']) ? urldecode($_SERVER['QUERY_STRING']) : '';
$pages = array(
- '' => ':?/', // redirect to dashboard
- '/' => 'dashboard', // dashboard
+ '' => ':?/', // redirect to dashboard
+ '/' => 'dashboard', // dashboard
'/confirm/(.+)' => 'confirm', // confirm action (if javascript didn't work)
- '/logout' => 'logout', // logout
+ '/logout' => 'logout', // logout
- '/users' => 'users', // manage users
- '/users/(\d+)' => 'user', // edit user
- '/users/(\d+)/(promote|demote)' => 'user_promote', // prmote/demote user
+ '/users' => 'users', // manage users
+ '/users/(\d+)' => 'user', // edit user
+ '/users/(\d+)/(promote|demote)' => 'user_promote', // prmote/demote user
'/users/new' => 'user_new', // create a new user
'/new_PM/([^/]+)' => 'new_pm', // create a new pm
- '/PM/(\d+)(/reply)?' => 'pm', // read a pm
- '/inbox' => 'inbox', // pm inbox
+ '/PM/(\d+)(/reply)?' => 'pm', // read a pm
+ '/inbox' => 'inbox', // pm inbox
'/noticeboard' => 'noticeboard', // view noticeboard
- '/noticeboard/(\d+)' => 'noticeboard', // view noticeboard
- '/noticeboard/delete/(\d+)' => 'noticeboard_delete',// delete from noticeboard
- '/log' => 'log', // modlog
- '/log/(\d+)' => 'log', // modlog
+ '/noticeboard/(\d+)' => 'noticeboard', // view noticeboard
+ '/noticeboard/delete/(\d+)' => 'noticeboard_delete', // delete from noticeboard
+ '/log' => 'log', // modlog
+ '/log/(\d+)' => 'log', // modlog
'/log:([^/]+)' => 'user_log', // modlog
- '/log:([^/]+)/(\d+)' => 'user_log', // modlog
- '/news' => 'news', // view news
- '/news/(\d+)' => 'news', // view news
- '/news/delete/(\d+)' => 'news_delete', // delete from news
+ '/log:([^/]+)/(\d+)' => 'user_log', // modlog
+ '/news' => 'news', // view news
+ '/news/(\d+)' => 'news', // view news
+ '/news/delete/(\d+)' => 'news_delete', // delete from news
'/edit/(\%b)' => 'edit_board', // edit board details
'/new-board' => 'new_board', // create a new board
- '/rebuild' => 'rebuild', // rebuild static files
- '/reports' => 'reports', // report queue
- '/reports/(\d+)/dismiss(all)?' => 'report_dismiss', // dismiss a report
+ '/rebuild' => 'rebuild', // rebuild static files
+ '/reports' => 'reports', // report queue
+ '/reports/(\d+)/dismiss(all)?' => 'report_dismiss', // dismiss a report
- '/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
- '/bans' => 'bans', // ban list
- '/bans/(\d+)' => 'bans', // ban list
+ '/bans' => 'bans', // ban list
+ '/bans/(\d+)' => 'bans', // ban list
- '/search' => 'search_redirect', // search
+ '/search' => 'search_redirect', // search
'/search/(posts|IP_notes|bans|log)/(.+)/(\d+)' => 'search', // search
- '/search/(posts|IP_notes|bans|log)/(.+)' => 'search', // search
+ '/search/(posts|IP_notes|bans|log)/(.+)' => 'search', // search
// CSRF-protected moderator actions
- '/ban' => 'secure_POST ban', // new ban
- '/(\%b)/ban(&delete)?/(\d+)' => 'secure_POST ban_post', // ban poster
- '/(\%b)/move/(\d+)' => 'secure_POST move', // move thread
+ '/ban' => 'secure_POST ban', // new ban
+ '/(\%b)/ban(&delete)?/(\d+)' => 'secure_POST ban_post', // ban poster
+ '/(\%b)/move/(\d+)' => 'secure_POST move', // move thread
'/(\%b)/edit(_raw)?/(\d+)' => 'secure_POST edit_post', // edit post
- '/(\%b)/delete/(\d+)' => 'secure delete', // delete post
- '/(\%b)/deletefile/(\d+)' => 'secure deletefile', // delete file from post
+ '/(\%b)/delete/(\d+)' => 'secure delete', // delete post
+ '/(\%b)/deletefile/(\d+)' => 'secure deletefile', // delete file from post
'/(\%b)/deletebyip/(\d+)(/global)?' => 'secure deletebyip', // delete all posts by IP address
- '/(\%b)/(un)?lock/(\d+)' => 'secure lock', // lock thread
- '/(\%b)/(un)?sticky/(\d+)' => 'secure sticky', // sticky thread
- '/(\%b)/bump(un)?lock/(\d+)' => 'secure bumplock', // "bumplock" thread
+ '/(\%b)/(un)?lock/(\d+)' => 'secure lock', // lock thread
+ '/(\%b)/(un)?sticky/(\d+)' => 'secure sticky', // sticky thread
+ '/(\%b)/bump(un)?lock/(\d+)' => 'secure bumplock', // "bumplock" thread
- '/themes' => 'themes_list', // manage themes
+ '/themes' => 'themes_list', // manage themes
'/themes/(\w+)' => 'theme_configure', // configure/reconfigure theme
- '/themes/(\w+)/rebuild' => 'theme_rebuild', // rebuild theme
- '/themes/(\w+)/uninstall' => 'theme_uninstall', // uninstall theme
+ '/themes/(\w+)/rebuild' => 'theme_rebuild', // rebuild theme
+ '/themes/(\w+)/uninstall' => 'theme_uninstall', // uninstall theme
- '/config' => 'config', // config editor
+ '/config' => 'config', // config editor
+ '/config/(\%b)' => 'config', // config editor
// these pages aren't listed in the dashboard without $config['debug']
'/debug/antispam' => 'debug_antispam',
@@ -109,7 +110,7 @@ $new_pages = array();
foreach ($pages as $key => $callback) {
if (is_string($callback) && preg_match('/^secure /', $callback))
$key .= '(/(?P<token>[a-f0-9]{8}))?';
- $key = str_replace('\%b', $config['board_regex'], $key);
+ $key = str_replace('\%b', '?P<board>' . sprintf(substr($config['board_path'], 0, -1), $config['board_regex']), $key);
$new_pages[@$key[0] == '!' ? $key : '!^' . $key . '(?:&[^&=]+=[^&]*)*$!u'] = $callback;
}
$pages = $new_pages;
@@ -118,6 +119,15 @@ foreach ($pages as $uri => $handler) {
if (preg_match($uri, $query, $matches)) {
$matches = array_slice($matches, 1);
+ if (isset($matches['board'])) {
+ $board_match = $matches['board'];
+ unset($matches['board']);
+ $key = array_search($board_match, $matches);
+ if (preg_match('/^' . sprintf(substr($config['board_path'], 0, -1), '(' . $config['board_regex'] . ')') . '$/u', $matches[$key], $board_match)) {
+ $matches[$key] = $board_match[1];
+ }
+ }
+
if (is_string($handler) && preg_match('/^secure(_POST)? /', $handler, $m)) {
$secure_post_only = isset($m[1]);
if (!$secure_post_only || $_SERVER['REQUEST_METHOD'] == 'POST') {