From 13ca053e06cc759faf07f113b6a0992d89e0d47a Mon Sep 17 00:00:00 2001 From: Zankaria Date: Tue, 1 Oct 2024 21:52:50 +0200 Subject: [PATCH 1/4] config.php: fix default 'dir' configuration --- inc/config.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/inc/config.php b/inc/config.php index 3e183dc1..43222d31 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1429,14 +1429,10 @@ $config['dir'] = [ 'img' => 'src/', 'thumb' => 'thumb/', - 'res' => 'res/' - ]; - - // For load balancing, having a seperate server (and domain/subdomain) for serving static content is - // possible. This can either be a directory or a URL. Defaults to $config['root'] . 'static/'. - // $config['dir']['static'] = 'http://static.example.org/'; - - $config['dir'] = [ + 'res' => 'res/', + // For load balancing, having a seperate server (and domain/subdomain) for serving static content is + // possible. This can either be a directory or a URL. Defaults to $config['root'] . 'static/'. + // $config['dir']['static'] = 'http://static.example.org/'; // Where to store the .html templates. This folder and the template files must exist. 'template' => getcwd() . '/templates', // Location of vichan "themes". From e6133ef00f32060aa58ba0865f21fb9202a9cf70 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Tue, 1 Oct 2024 22:14:26 +0200 Subject: [PATCH 2/4] auth.php: passthrough the context --- inc/mod/auth.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/inc/mod/auth.php b/inc/mod/auth.php index ec9d6057..70cf23ff 100644 --- a/inc/mod/auth.php +++ b/inc/mod/auth.php @@ -4,6 +4,7 @@ * Copyright (c) 2010-2013 Tinyboard Development Group */ +use Vichan\Context; use Vichan\Functions\Net; defined('TINYBOARD') or exit; @@ -232,7 +233,7 @@ function make_secure_link_token(string $uri): string { return substr(sha1($config['cookies']['salt'] . '-' . $uri . '-' . $mod['id']), 0, 8); } -function check_login(bool $prompt = false): void { +function check_login(Context $ctx, bool $prompt = false): void { global $config, $mod; $is_https = Net\is_connection_secure($config['cookies']['secure_login_only'] === 1); @@ -246,7 +247,9 @@ function check_login(bool $prompt = false): void { if (count($cookie) != 3) { // Malformed cookies destroyCookies(); - if ($prompt) mod_login(); + if ($prompt) { + mod_login($ctx); + } exit; } @@ -259,7 +262,9 @@ function check_login(bool $prompt = false): void { if ($cookie[1] !== mkhash($cookie[0], $user['password'], $cookie[2])) { // Malformed cookies destroyCookies(); - if ($prompt) mod_login(); + if ($prompt) { + mod_login($ctx); + } exit; } From f4ff39c876d6e57d1a457a7afc34a6572c63b1f0 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Tue, 1 Oct 2024 22:15:03 +0200 Subject: [PATCH 3/4] post.php, mod.php: pass the context to check_login --- mod.php | 7 ++++--- post.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mod.php b/mod.php index 474210cd..c9e891ee 100644 --- a/mod.php +++ b/mod.php @@ -11,7 +11,10 @@ if ($config['debug']) { 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']) : ''; @@ -136,8 +139,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. diff --git a/post.php b/post.php index 6f29f50c..b20fdfc9 100644 --- a/post.php +++ b/post.php @@ -694,7 +694,7 @@ if (isset($_POST['delete'])) { if ($post['mod'] = isset($_POST['mod']) && $_POST['mod']) { - check_login(false); + check_login($context, false); if (!$mod) { // Liar. You're not a mod. error($config['error']['notamod']); From 3e9ad58e97d6701c156c949ae5c71a8eac957cca Mon Sep 17 00:00:00 2001 From: Zankaria Date: Tue, 1 Oct 2024 23:54:16 +0200 Subject: [PATCH 4/4] config.php: fix mod config array --- inc/config.php | 87 ++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/inc/config.php b/inc/config.php index 43222d31..15fe3f64 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1559,50 +1559,6 @@ 'lock_ip' => true, // The page that is first shown when a moderator logs in. Defaults to the dashboard (?/). 'default' => '/', - - 'link_delete' => '[D]', - 'link_ban' => '[B]', - 'link_bandelete' => '[&D]', - 'link_deletefile' => '[F]', - 'link_spoilerimage' => '[S]', - 'link_deletebyip' => '[D+]', - 'link_deletebyip_global' => '[D++]', - 'link_sticky' => '[Sticky]', - 'link_desticky' => '[-Sticky]', - 'link_lock' => '[Lock]', - 'link_unlock' => '[-Lock]', - 'link_bumplock' => '[Sage]', - 'link_bumpunlock' => '[-Sage]', - 'link_editpost' => '[Edit]', - 'link_move' => '[Move]', - 'link_cycle' => '[Cycle]', - 'link_uncycle' => '[-Cycle]' - ]; - - // Moderator capcodes. - $config['capcode'] = ' ## %s'; - - // "## Custom" becomes lightgreen, italic and bold: - //$config['custom_capcode']['Custom'] =' ## %s'; - - // "## Mod" makes everything purple, including the name and tripcode: - //$config['custom_capcode']['Mod'] = array( - // ' ## %s', - // 'color:purple', // Change name style; optional - // 'color:purple' // Change tripcode style; optional - //); - - // "## Admin" makes everything red and bold, including the name and tripcode: - //$config['custom_capcode']['Admin'] = array( - // ' ## %s', - // 'color:red;font-weight:bold', // Change name style; optional - // 'color:red;font-weight:bold' // Change tripcode style; optional - //); - - // Enable the moving of single replies - $config['move_replies'] = false; - - $config['mod'] = [ // Do DNS lookups on IP addresses to get their hostname for the moderator IP pages (?/IP/x.x.x.x). 'dns_lookup' => true, // How many recent posts, per board, to show in ?/IP/x.x.x.x. @@ -1653,9 +1609,50 @@ 'dismiss_reports_on_lock' => true, // Replace ?/config with a simple text editor for editing inc/instance-config.php. - 'config_editor_php' => false + 'config_editor_php' => false, + + 'link_delete' => '[D]', + 'link_ban' => '[B]', + 'link_bandelete' => '[&D]', + 'link_deletefile' => '[F]', + 'link_spoilerimage' => '[S]', + 'link_deletebyip' => '[D+]', + 'link_deletebyip_global' => '[D++]', + 'link_sticky' => '[Sticky]', + 'link_desticky' => '[-Sticky]', + 'link_lock' => '[Lock]', + 'link_unlock' => '[-Lock]', + 'link_bumplock' => '[Sage]', + 'link_bumpunlock' => '[-Sage]', + 'link_editpost' => '[Edit]', + 'link_move' => '[Move]', + 'link_cycle' => '[Cycle]', + 'link_uncycle' => '[-Cycle]' ]; + // Moderator capcodes. + $config['capcode'] = ' ## %s'; + + // "## Custom" becomes lightgreen, italic and bold: + //$config['custom_capcode']['Custom'] =' ## %s'; + + // "## Mod" makes everything purple, including the name and tripcode: + //$config['custom_capcode']['Mod'] = array( + // ' ## %s', + // 'color:purple', // Change name style; optional + // 'color:purple' // Change tripcode style; optional + //); + + // "## Admin" makes everything red and bold, including the name and tripcode: + //$config['custom_capcode']['Admin'] = array( + // ' ## %s', + // 'color:red;font-weight:bold', // Change name style; optional + // 'color:red;font-weight:bold' // Change tripcode style; optional + //); + + // Enable the moving of single replies + $config['move_replies'] = false; + /* * ==================== * Mod permissions