forked from leftypol/leftypol
pages.php: use Context provided config
This commit is contained in:
parent
4cf6fd3838
commit
63228d04be
1 changed files with 91 additions and 50 deletions
|
|
@ -46,7 +46,7 @@ function clone_wrapped_with_exist_check($clonefn, $src, $dest) {
|
|||
}
|
||||
|
||||
function mod_login(Context $ctx, $redirect = false) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
$args = [];
|
||||
|
||||
|
|
@ -89,15 +89,16 @@ function mod_confirm(Context $ctx, $request) {
|
|||
}
|
||||
|
||||
function mod_logout(Context $ctx) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
destroyCookies();
|
||||
|
||||
header('Location: ?/', true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
function mod_dashboard(Context $ctx) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
$report_queries = $ctx->get(ReportQueries::class);
|
||||
|
||||
$args = [];
|
||||
|
|
@ -191,7 +192,7 @@ function mod_dashboard(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_search_redirect(Context $ctx) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['search']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -471,7 +472,9 @@ function mod_edit_board(Context $ctx, $boardName) {
|
|||
}
|
||||
|
||||
function mod_new_board(Context $ctx) {
|
||||
global $config, $board;
|
||||
global $board;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['newboard']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -537,7 +540,9 @@ function mod_new_board(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_noticeboard(Context $ctx, $page_no = 1) {
|
||||
global $config, $pdo, $mod;
|
||||
global $pdo, $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if ($page_no < 1)
|
||||
error($config['error']['404']);
|
||||
|
|
@ -592,7 +597,7 @@ function mod_noticeboard(Context $ctx, $page_no = 1) {
|
|||
}
|
||||
|
||||
function mod_noticeboard_delete(Context $ctx, $id) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['noticeboard_delete']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -610,7 +615,9 @@ function mod_noticeboard_delete(Context $ctx, $id) {
|
|||
}
|
||||
|
||||
function mod_news(Context $ctx, $page_no = 1) {
|
||||
global $config, $pdo, $mod;
|
||||
global $pdo, $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if ($page_no < 1)
|
||||
error($config['error']['404']);
|
||||
|
|
@ -657,7 +664,7 @@ function mod_news(Context $ctx, $page_no = 1) {
|
|||
}
|
||||
|
||||
function mod_news_delete(Context $ctx, $id) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['news_delete']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -672,7 +679,7 @@ function mod_news_delete(Context $ctx, $id) {
|
|||
}
|
||||
|
||||
function mod_log(Context $ctx, $page_no = 1) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if ($page_no < 1)
|
||||
error($config['error']['404']);
|
||||
|
|
@ -697,7 +704,7 @@ function mod_log(Context $ctx, $page_no = 1) {
|
|||
}
|
||||
|
||||
function mod_user_log(Context $ctx, $username, $page_no = 1) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if ($page_no < 1)
|
||||
error($config['error']['404']);
|
||||
|
|
@ -734,7 +741,7 @@ function protect_ip($entry) {
|
|||
}
|
||||
|
||||
function mod_board_log(Context $ctx, $board, $page_no = 1, $hide_names = false, $public = false) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if ($page_no < 1)
|
||||
error($config['error']['404']);
|
||||
|
|
@ -802,7 +809,9 @@ function mod_view_catalog(Context $ctx, $boardName) {
|
|||
}
|
||||
|
||||
function mod_view_board(Context $ctx, $boardName, $page_no = 1) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($boardName)){
|
||||
require "templates/themes/overboards/overboards.php";
|
||||
|
|
@ -833,20 +842,24 @@ function mod_view_board(Context $ctx, $boardName, $page_no = 1) {
|
|||
}
|
||||
|
||||
function mod_view_thread(Context $ctx, $boardName, $thread) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
if (!openBoard($boardName))
|
||||
if (!openBoard($boardName)) {
|
||||
$config = $ctx->get('config');
|
||||
error($config['error']['noboard']);
|
||||
}
|
||||
|
||||
$page = buildThread($thread, true, $mod);
|
||||
echo $page;
|
||||
}
|
||||
|
||||
function mod_view_thread50(Context $ctx, $boardName, $thread) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
if (!openBoard($boardName))
|
||||
if (!openBoard($boardName)) {
|
||||
$config = $ctx->get('config');
|
||||
error($config['error']['noboard']);
|
||||
}
|
||||
|
||||
$page = buildThread50($thread, true, $mod);
|
||||
echo $page;
|
||||
|
|
@ -1095,7 +1108,7 @@ function mod_user_posts_by_passwd(Context $ctx, string $passwd, string $encoded_
|
|||
}
|
||||
|
||||
function mod_ban(Context $ctx) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['ban']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -1116,7 +1129,7 @@ function mod_ban(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_warning(Context $ctx) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['warning']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -1133,9 +1146,10 @@ function mod_warning(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_bans(Context $ctx) {
|
||||
global $config;
|
||||
global $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['view_banlist']))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
|
|
@ -1168,7 +1182,9 @@ function mod_bans(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_bans_json(Context $ctx) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['ban']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -1180,7 +1196,9 @@ function mod_bans_json(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_ban_appeals(Context $ctx) {
|
||||
global $config, $board;
|
||||
global $board;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['view_ban_appeals']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -1262,7 +1280,7 @@ function mod_ban_appeals(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_lock(Context $ctx, $board, $unlock, $post) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -1298,7 +1316,7 @@ function mod_lock(Context $ctx, $board, $unlock, $post) {
|
|||
}
|
||||
|
||||
function mod_sticky(Context $ctx, $board, $unsticky, $post) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -1322,7 +1340,7 @@ function mod_sticky(Context $ctx, $board, $unsticky, $post) {
|
|||
}
|
||||
|
||||
function mod_cycle(Context $ctx, $board, $uncycle, $post) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -1344,7 +1362,7 @@ function mod_cycle(Context $ctx, $board, $uncycle, $post) {
|
|||
}
|
||||
|
||||
function mod_bumplock(Context $ctx, $board, $unbumplock, $post) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -1927,7 +1945,9 @@ function mod_merge(Context $ctx, $originBoard, $postID) {
|
|||
}
|
||||
|
||||
function mod_ban_post(Context $ctx, $board, $delete, $post, $token = false) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -2046,7 +2066,9 @@ function mod_ban_post(Context $ctx, $board, $delete, $post, $token = false) {
|
|||
}
|
||||
|
||||
function mod_warning_post(Context $ctx, $board, $post, $token = false) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -2143,7 +2165,7 @@ function mod_warning_post(Context $ctx, $board, $post, $token = false) {
|
|||
}
|
||||
|
||||
function mod_edit_post(Context $ctx, $board, $edit_raw_html, $postID) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -2220,7 +2242,9 @@ function mod_edit_post(Context $ctx, $board, $edit_raw_html, $postID) {
|
|||
}
|
||||
|
||||
function mod_delete(Context $ctx, $board, $post) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -2283,7 +2307,7 @@ function mod_delete(Context $ctx, $board, $post) {
|
|||
}
|
||||
|
||||
function mod_deletefile(Context $ctx, $board, $post, $file) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -2306,7 +2330,7 @@ function mod_deletefile(Context $ctx, $board, $post, $file) {
|
|||
}
|
||||
|
||||
function mod_spoiler_image(Context $ctx, $board, $post, $file) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -2351,8 +2375,9 @@ function mod_spoiler_image(Context $ctx, $board, $post, $file) {
|
|||
}
|
||||
|
||||
function mod_deletebyip(Context $ctx, $boardName, $post, $global = false) {
|
||||
global $config, $board, $mod;
|
||||
global $board, $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
$global = (bool)$global;
|
||||
|
||||
if (!openBoard($boardName))
|
||||
|
|
@ -2470,7 +2495,9 @@ function mod_deletebyip(Context $ctx, $boardName, $post, $global = false) {
|
|||
}
|
||||
|
||||
function mod_user(Context $ctx, $uid) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['editusers']) && !(hasPermission($config['mod']['change_password']) && $uid == $mod['id']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -2648,7 +2675,7 @@ function mod_user_new(Context $ctx) {
|
|||
|
||||
|
||||
function mod_users(Context $ctx) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['manageusers']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -2669,7 +2696,7 @@ function mod_users(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_user_promote(Context $ctx, $uid, $action) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['promoteusers']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -2767,7 +2794,7 @@ function mod_pm(Context $ctx, $id, $reply = false) {
|
|||
}
|
||||
|
||||
function mod_inbox(Context $ctx) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
$query = prepare('SELECT `unread`,``pms``.`id`, `time`, `sender`, `to`, `message`, `username` FROM ``pms`` LEFT JOIN ``mods`` ON ``mods``.`id` = `sender` WHERE `to` = :mod ORDER BY `unread` DESC, `time` DESC');
|
||||
$query->bindValue(':mod', $mod['id']);
|
||||
|
|
@ -2791,7 +2818,9 @@ function mod_inbox(Context $ctx) {
|
|||
|
||||
|
||||
function mod_new_pm(Context $ctx, $username) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['create_pm']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -2839,7 +2868,9 @@ function mod_new_pm(Context $ctx, $username) {
|
|||
}
|
||||
|
||||
function mod_rebuild(Context $ctx) {
|
||||
global $config, $twig;
|
||||
global $twig;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['rebuild']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -2911,7 +2942,9 @@ function mod_rebuild(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_reports(Context $ctx) {
|
||||
global $config, $mod;
|
||||
global $mod;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['reports']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -2978,7 +3011,7 @@ function mod_reports(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_report_dismiss(Context $ctx, $id, $all = false) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
$report_queries = $ctx->get(ReportQueries::class);
|
||||
$report = $report_queries->getReportById($id);
|
||||
|
|
@ -3010,7 +3043,9 @@ function mod_report_dismiss(Context $ctx, $id, $all = false) {
|
|||
}
|
||||
|
||||
function mod_recent_posts(Context $ctx, $lim, $board_list = false, $json = false) {
|
||||
global $config, $mod, $pdo;
|
||||
global $mod, $pdo;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['recent']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -3120,7 +3155,9 @@ function mod_recent_posts(Context $ctx, $lim, $board_list = false, $json = false
|
|||
}
|
||||
|
||||
function mod_config(Context $ctx, $board_config = false) {
|
||||
global $config, $mod, $board;
|
||||
global $mod, $board;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if ($board_config && !openBoard($board_config))
|
||||
error($config['error']['noboard']);
|
||||
|
|
@ -3260,7 +3297,7 @@ function mod_config(Context $ctx, $board_config = false) {
|
|||
}
|
||||
|
||||
function mod_themes_list(Context $ctx) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['themes']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -3294,7 +3331,7 @@ function mod_themes_list(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_theme_configure(Context $ctx, $theme_name) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['themes']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -3376,7 +3413,7 @@ function mod_theme_configure(Context $ctx, $theme_name) {
|
|||
}
|
||||
|
||||
function mod_theme_uninstall(Context $ctx, $theme_name) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['themes']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -3393,7 +3430,7 @@ function mod_theme_uninstall(Context $ctx, $theme_name) {
|
|||
}
|
||||
|
||||
function mod_theme_rebuild(Context $ctx, $theme_name) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['themes']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
@ -3442,7 +3479,7 @@ function mod_delete_page_board(Context $ctx, $page = '', $board = false) {
|
|||
}
|
||||
|
||||
function mod_edit_page(Context $ctx, $id) {
|
||||
global $config, $mod, $board;
|
||||
global $mod, $board;
|
||||
|
||||
$query = prepare('SELECT * FROM ``pages`` WHERE `id` = :id');
|
||||
$query->bindValue(':id', $id);
|
||||
|
|
@ -3452,6 +3489,8 @@ function mod_edit_page(Context $ctx, $id) {
|
|||
if (!$page)
|
||||
error(_('Could not find the page you are trying to edit.'));
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!$page['board'] && $mod['boards'][0] !== '*')
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
|
|
@ -3513,11 +3552,13 @@ function mod_edit_page(Context $ctx, $id) {
|
|||
}
|
||||
|
||||
function mod_pages(Context $ctx, $board = false) {
|
||||
global $config, $mod, $pdo;
|
||||
global $mod, $pdo;
|
||||
|
||||
if (empty($board))
|
||||
$board = false;
|
||||
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!$board && $mod['boards'][0] !== '*')
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
|
|
@ -3638,7 +3679,7 @@ function mod_debug_recent_posts(Context $ctx) {
|
|||
}
|
||||
|
||||
function mod_debug_sql(Context $ctx) {
|
||||
global $config;
|
||||
$config = $ctx->get('config');
|
||||
|
||||
if (!hasPermission($config['mod']['debug_sql']))
|
||||
error($config['error']['noaccess']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue