From 75714505a0f04b014c9e37dbfaf9939e11037e5f Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sun, 30 Jun 2024 16:48:22 +0200 Subject: [PATCH] config.php: add auto_maintenance configuration option --- inc/config.php | 5 +++++ inc/functions.php | 2 +- inc/mod/pages.php | 4 ++-- post.php | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/inc/config.php b/inc/config.php index c2c25da2..880de88b 100644 --- a/inc/config.php +++ b/inc/config.php @@ -92,6 +92,11 @@ // to the environment path (seperated by :). $config['shell_path'] = '/usr/local/bin'; + // Automatically execute some maintenance tasks when some pages are opened, which may result in higher + // latencies. + // If set to false, ensure to periodically invoke the tools/maintenance.php script. + $config['auto_maintenance'] = true; + /* * ==================== * Database settings diff --git a/inc/functions.php b/inc/functions.php index 908aff59..31e5dfac 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -876,7 +876,7 @@ function checkBan($board = false) { } foreach ($ips as $ip) { - $bans = Bans::find($ip, $board, $config['show_modname'], null, true); + $bans = Bans::find($ip, $board, $config['show_modname'], null, $config['auto_maintenance']); foreach ($bans as &$ban) { if ($ban['expires'] && $ban['expires'] < time()) { diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 7483a27d..826e7c6f 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -897,7 +897,7 @@ function mod_page_ip($cip) { $args['token'] = make_secure_link_token('ban'); if (hasPermission($config['mod']['view_ban'])) { - $args['bans'] = Bans::find($ip, false, true, null, true); + $args['bans'] = Bans::find($ip, false, true, null, $config['auto_maintenance']); } if (hasPermission($config['mod']['view_notes'])) { @@ -927,7 +927,7 @@ function mod_edit_ban($ban_id) { if (!hasPermission($config['mod']['edit_ban'])) error($config['error']['noaccess']); - $args['bans'] = Bans::find(null, false, true, $ban_id, true); + $args['bans'] = Bans::find(null, false, true, $ban_id, $config['auto_maintenance']); $args['ban_id'] = $ban_id; $args['boards'] = listBoards(); $args['current_board'] = isset($args['bans'][0]['board']) ? $args['bans'][0]['board'] : false; diff --git a/post.php b/post.php index 9d1c1783..8eab4da2 100644 --- a/post.php +++ b/post.php @@ -1439,7 +1439,7 @@ if (isset($_POST['delete'])) { $ban_id = (int)$_POST['ban_id']; - $ban = Bans::findSingle($_SERVER['REMOTE_ADDR'], $ban_id, $config['require_ban_view'], true); + $ban = Bans::findSingle($_SERVER['REMOTE_ADDR'], $ban_id, $config['require_ban_view'], $config['auto_maintenance']); if (empty($ban)) { error($config['error']['noban']);