forked from leftypol/leftypol
post.php, mod.php: pass the context to check_login
This commit is contained in:
parent
4197b5a376
commit
8cf497eb93
3 changed files with 23 additions and 18 deletions
|
@ -850,7 +850,7 @@ function mod_view_thread50(Context $ctx, $boardName, $thread) {
|
|||
}
|
||||
|
||||
function mod_ip_remove_note(Context $ctx, $ip, $id) {
|
||||
global $config, $mod;
|
||||
global $config;
|
||||
|
||||
if (!hasPermission($config['mod']['remove_notes']))
|
||||
error($config['error']['noaccess']);
|
||||
|
@ -1057,7 +1057,7 @@ function mod_ip(Context $ctx, $ip, string $encoded_cursor = '') {
|
|||
mod_page(sprintf('%s: %s', _('IP'), htmlspecialchars($ip)), 'mod/view_ip.html', $args, $args['hostname']);
|
||||
}
|
||||
|
||||
function mod_ban() {
|
||||
function mod_ban(Context $ctx) {
|
||||
global $config;
|
||||
|
||||
if (!hasPermission($config['mod']['ban']))
|
||||
|
@ -1433,7 +1433,7 @@ function mod_move_reply(Context $ctx, $originBoard, $postID) {
|
|||
}
|
||||
|
||||
function mod_move(Context $ctx, $originBoard, $postID) {
|
||||
global $board, $config, $pdo;
|
||||
global $board, $config, $pdo;
|
||||
|
||||
if (!openBoard($originBoard))
|
||||
error($config['error']['noboard']);
|
||||
|
@ -1645,8 +1645,8 @@ function mod_move(Context $ctx, $originBoard, $postID) {
|
|||
mod_page(_('Move thread'), 'mod/move.html', array('post' => $postID, 'board' => $originBoard, 'boards' => $boards, 'token' => $security_token));
|
||||
}
|
||||
|
||||
function mod_merge($originBoard, $postID) {
|
||||
global $board, $config, $mod, $pdo;
|
||||
function mod_merge(Context $ctx, $originBoard, $postID) {
|
||||
global $board, $config, $pdo;
|
||||
|
||||
if (!openBoard($originBoard))
|
||||
error($config['error']['noboard']);
|
||||
|
|
7
mod.php
7
mod.php
|
@ -12,7 +12,10 @@ if ($config['debug']) {
|
|||
require_once 'inc/bans.php';
|
||||
require_once 'inc/mod/pages.php';
|
||||
|
||||
check_login(true);
|
||||
|
||||
$ctx = Vichan\build_context($config);
|
||||
|
||||
check_login($ctx, true);
|
||||
|
||||
$query = isset($_SERVER['QUERY_STRING']) ? rawurldecode($_SERVER['QUERY_STRING']) : '';
|
||||
|
||||
|
@ -148,8 +151,6 @@ foreach ($pages as $key => $callback) {
|
|||
}
|
||||
$pages = $new_pages;
|
||||
|
||||
$ctx = Vichan\build_context($config);
|
||||
|
||||
foreach ($pages as $uri => $handler) {
|
||||
if (preg_match($uri, $query, $matches)) {
|
||||
$matches[0] = $ctx; // Replace the text captured by the full pattern with a reference to the context.
|
||||
|
|
24
post.php
24
post.php
|
@ -3,6 +3,8 @@
|
|||
* Copyright (c) 2010-2014 Tinyboard Development Group
|
||||
*/
|
||||
|
||||
use Vichan\Context;
|
||||
|
||||
require_once 'inc/bootstrap.php';
|
||||
|
||||
/**
|
||||
|
@ -529,7 +531,7 @@ function handle_nntpchan()
|
|||
);
|
||||
}
|
||||
|
||||
function handle_delete()
|
||||
function handle_delete(Context $ctx)
|
||||
{
|
||||
// Delete
|
||||
global $config, $board, $mod;
|
||||
|
@ -537,7 +539,7 @@ function handle_delete()
|
|||
error($config['error']['bot']);
|
||||
}
|
||||
|
||||
check_login(false);
|
||||
check_login($ctx, false);
|
||||
$is_mod = !!$mod;
|
||||
|
||||
if (isset($_POST['mod']) && $_POST['mod'] && !$mod) {
|
||||
|
@ -653,7 +655,7 @@ function handle_delete()
|
|||
rebuildThemes('post-delete', $board['uri']);
|
||||
}
|
||||
|
||||
function handle_report()
|
||||
function handle_report(Context $ctx)
|
||||
{
|
||||
global $config, $board;
|
||||
if (!isset($_POST['board'], $_POST['reason']))
|
||||
|
@ -802,7 +804,7 @@ function handle_report()
|
|||
}
|
||||
}
|
||||
|
||||
function handle_post()
|
||||
function handle_post(Context $ctx)
|
||||
{
|
||||
global $config, $dropped_post, $board, $mod, $pdo;
|
||||
|
||||
|
@ -911,7 +913,7 @@ function handle_post()
|
|||
}
|
||||
|
||||
if ($post['mod'] = isset($_POST['mod']) && $_POST['mod']) {
|
||||
check_login(false);
|
||||
check_login($ctx, false);
|
||||
if (!$mod) {
|
||||
// Liar. You're not a mod >:-[
|
||||
error($config['error']['notamod']);
|
||||
|
@ -1846,7 +1848,7 @@ function handle_post()
|
|||
}
|
||||
}
|
||||
|
||||
function handle_appeal()
|
||||
function handle_appeal(Context $ctx)
|
||||
{
|
||||
global $config;
|
||||
if (!isset($_POST['ban_id'])) {
|
||||
|
@ -1899,14 +1901,16 @@ if (isset($_GET['Newsgroups'])) {
|
|||
}
|
||||
}
|
||||
|
||||
$ctx = Vichan\build_context($config);
|
||||
|
||||
if (isset($_POST['delete'])) {
|
||||
handle_delete();
|
||||
handle_delete($ctx);
|
||||
} elseif (isset($_POST['report'])) {
|
||||
handle_report();
|
||||
handle_report($ctx);
|
||||
} elseif (isset($_POST['post']) || $dropped_post) {
|
||||
handle_post();
|
||||
handle_post($ctx);
|
||||
} elseif (isset($_POST['appeal'])) {
|
||||
handle_appeal();
|
||||
handle_appeal($ctx);
|
||||
} else {
|
||||
if (!file_exists($config['has_installed'])) {
|
||||
header('Location: install.php', true, $config['redirect_http']);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue