1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-23 23:20:57 +01:00
vichan/mod.php

85 lines
2.5 KiB
PHP
Raw Normal View History

2010-12-01 11:53:11 +01:00
<?php
2012-04-11 18:49:22 +02:00
/*
* Copyright (c) 2010-2012 Tinyboard Development Group
*/
require 'inc/functions.php';
2012-04-12 18:11:41 +02:00
require 'inc/mod/auth.php';
require 'inc/mod/pages.php';
2012-04-11 18:49:22 +02:00
2012-04-12 18:11:41 +02:00
// Fix for magic quotes
2012-04-11 18:49:22 +02:00
if (get_magic_quotes_gpc()) {
function strip_array($var) {
return is_array($var) ? array_map('strip_array', $var) : stripslashes($var);
2012-04-11 18:49:22 +02:00
}
2010-12-01 11:53:11 +01:00
2012-04-11 18:49:22 +02:00
$_GET = strip_array($_GET);
$_POST = strip_array($_POST);
}
$query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
2012-04-12 18:11:41 +02:00
$pages = array(
2012-04-13 02:41:30 +02:00
'!^$!' => ':?/', // redirect to dashboard
'!^/$!' => 'dashboard', // dashboard
2012-04-13 13:43:01 +02:00
'!^/confirm/(.+)$!' => 'confirm', // confirm action (if javascript didn't work)
2012-04-13 02:41:30 +02:00
'!^/log$!' => 'log', // modlog
2012-04-13 12:57:59 +02:00
'!^/log/(\d+)$!' => 'log', // modlog
2012-04-16 08:40:24 +02:00
2012-04-13 13:43:01 +02:00
'!^/users$!' => 'users', // manage users
'!^/users/(\d+)/(promote|demote)$!' => 'user_promote', // prmote/demote user
2012-04-13 14:00:40 +02:00
'!^/new_PM/([^/]+)$!' => 'new_pm', // create a new pm
2012-04-16 08:40:24 +02:00
'!^/PM/(\d+)(/reply)?$!' => 'pm', // read a pm
2012-04-13 02:41:30 +02:00
'!^/rebuild$!' => 'rebuild', // rebuild static files
2012-04-16 09:28:57 +02:00
'!^/reports$!' => 'reports', // report queue
'!^/reports/(\d+)/dismiss(all)?$!' => 'report_dismiss', // dismiss a report
2012-04-13 02:41:30 +02:00
'!^/ban$!' => 'ban', // new ban
'!^/IP/([\w.:]+)$!' => 'ip', // view ip address
'!^/IP/([\w.:]+)/remove_note/(\d+)$!' => 'ip_remove_note', // remove note from ip address
2012-04-16 08:40:24 +02:00
'!^/bans$!' => 'bans', // ban list
2012-04-16 11:13:30 +02:00
'!^/bans/(\d+)$!' => 'bans', // ban list
2012-04-13 02:41:30 +02:00
'!^/(\w+)/delete/(\d+)$!' => 'delete', // delete post
2012-04-11 18:49:22 +02:00
2012-04-12 18:11:41 +02:00
// This should always be at the end:
'!^/(\w+)/' . preg_quote($config['file_index'], '!') . '?$!' => 'view_board',
2012-04-13 01:29:08 +02:00
'!^/(\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',
2012-04-12 18:11:41 +02:00
);
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 18:49:22 +02:00
);
}
2012-04-12 18:11:41 +02: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 18:49:22 +02:00
} else {
2012-04-12 18:11:41 +02:00
error("Mod page '$handler' not found!");
2012-04-11 18:49:22 +02:00
}
2012-04-12 18:11:41 +02:00
exit;
2010-12-01 11:53:11 +01:00
}
2012-04-11 18:49:22 +02:00
}
2012-04-12 18:11:41 +02:00
error($config['error']['404']);