post.php, mod.php: pass the context to check_login

This commit is contained in:
Zankaria 2024-10-01 22:15:03 +02:00
parent 4197b5a376
commit 8cf497eb93
3 changed files with 23 additions and 18 deletions

View file

@ -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']);