From a90653e7e235ed6a9485f289cd17098551cac2ae Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Wed, 3 Jul 2024 16:20:50 +0700 Subject: [PATCH] Fixed broken "Disable Board" function (#1529) * Fixed broken "Disable Board" function * Update CHANGELOG.md --- CHANGELOG.md | 1 + library/includes/init_bb.php | 8 ++------ src/Ajax.php | 16 +++++++--------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10512eb47..8a027213d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ **Merged pull requests:** - Release 2.4.4 🦩 ([belomaxorka](https://github.com/belomaxorka)) +- Fixed broken "Disable Board" function [\#1529](https://github.com/torrentpier/torrentpier/pull/1529) ([belomaxorka](https://github.com/belomaxorka)) - Create tech stack docs (techstack.yml and techstack.md) [\#1521](https://github.com/torrentpier/torrentpier/pull/1521), [\#1522](https://github.com/torrentpier/torrentpier/pull/1522) ([belomaxorka](https://github.com/belomaxorka)) - Fixed seed bonus accrual [\#1518](https://github.com/torrentpier/torrentpier/pull/1518) ([belomaxorka](https://github.com/belomaxorka)) - [BETA] Added emojis support 😄😁 [\#1514](https://github.com/torrentpier/torrentpier/pull/1514) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index d55fabdf6..7e74b48fa 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -459,15 +459,11 @@ if (($bb_cfg['board_disable'] || is_file(BB_DISABLED)) && !defined('IN_ADMIN') & if ($bb_cfg['board_disable']) { // admin lock send_no_cache_headers(); - if (\TorrentPier\Helpers\CronHelper::isEnabled()) { - bb_die('BOARD_DISABLE', 503); - } + bb_die('BOARD_DISABLE', 503); } elseif (is_file(BB_DISABLED)) { // trigger lock TorrentPier\Helpers\CronHelper::releaseDeadlock(); send_no_cache_headers(); - if (\TorrentPier\Helpers\CronHelper::isEnabled()) { - bb_die('BOARD_DISABLE_CRON', 503); - } + bb_die('BOARD_DISABLE_CRON', (\TorrentPier\Helpers\CronHelper::isEnabled() ? 503 : null)); } } diff --git a/src/Ajax.php b/src/Ajax.php index 6b73aee1a..6a6109850 100644 --- a/src/Ajax.php +++ b/src/Ajax.php @@ -21,13 +21,13 @@ class Ajax public array $response = []; public array $valid_actions = [ - // ACTION NAME => [AJAX_AUTH, IN_ADMIN_CP (optional)] + // ACTION NAME => [AJAX_AUTH] 'edit_user_profile' => ['admin'], 'change_user_rank' => ['admin'], 'change_user_opt' => ['admin'], 'manage_user' => ['admin'], - 'manage_admin' => ['admin', true], - 'sitemap' => ['admin', true], + 'manage_admin' => ['admin'], + 'sitemap' => ['admin'], 'mod_action' => ['mod'], 'topic_tpl' => ['mod'], @@ -89,12 +89,10 @@ class Ajax // Exit if board is disabled via ON/OFF trigger or by admin if ($bb_cfg['board_disable'] || is_file(BB_DISABLED)) { - if (!isset($action_params[1]) || $action_params[1] !== true) { - if ($bb_cfg['board_disable']) { - $this->ajax_die($lang['BOARD_DISABLE']); - } elseif (is_file(BB_DISABLED)) { - $this->ajax_die($lang['BOARD_DISABLE_CRON']); - } + if ($bb_cfg['board_disable']) { + $this->ajax_die($lang['BOARD_DISABLE']); + } elseif (is_file(BB_DISABLED) && $this->action !== 'manage_admin') { + $this->ajax_die($lang['BOARD_DISABLE_CRON']); } }