diff --git a/inc/config.php b/inc/config.php index 3e183dc1..15fe3f64 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". @@ -1563,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. @@ -1657,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 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; } 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']);