From 3695761b9ec31d5888bbb0a25d73a667c813aed0 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Thu, 25 Sep 2025 18:18:40 +0300 Subject: [PATCH] Adds a notice for maintenance mode for superusers --- app/classes/feedback.php | 4 ++++ app/includes/strings.php | 1 + app/pages/admin-tools.php | 6 +++--- public_html/index.php | 10 ++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/classes/feedback.php b/app/classes/feedback.php index 0a12ba4..b7bfa2b 100644 --- a/app/classes/feedback.php +++ b/app/classes/feedback.php @@ -143,6 +143,10 @@ class Feedback { 'type' => self::TYPE_WARNING, 'dismissible' => true ], + 'MAINTENANCE_ON' => [ + 'type' => self::TYPE_WARNING, + 'dismissible' => false + ], ]; private static $strings = null; diff --git a/app/includes/strings.php b/app/includes/strings.php index 863323c..7c76e2a 100644 --- a/app/includes/strings.php +++ b/app/includes/strings.php @@ -45,5 +45,6 @@ return [ 'DB_CONNECT_ERROR' => 'Error connecting to DB: %s', 'DB_UNKNOWN_TYPE' => 'Error: unknown database type "%s"', 'MIGRATIONS_PENDING' => '%s', + 'MAINTENANCE_ON' => 'Maintenance mode is enabled. Regular users see a maintenance page.', ], ]; diff --git a/app/pages/admin-tools.php b/app/pages/admin-tools.php index 1012c97..eb5127a 100644 --- a/app/pages/admin-tools.php +++ b/app/pages/admin-tools.php @@ -28,6 +28,9 @@ if (!$canAdmin) { exit; } +// Get any old feedback messages +include __DIR__ . '/../helpers/feedback.php'; + // Handle actions $action = $_POST['action'] ?? ''; @@ -141,8 +144,5 @@ try { // CSRF token $csrf_token = $security->generateCsrfToken(); -// Get any new feedback messages -include __DIR__ . '/../helpers/feedback.php'; - // Load the template include __DIR__ . '/../templates/admin-tools.php'; diff --git a/public_html/index.php b/public_html/index.php index 60da667..500021f 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -250,6 +250,16 @@ try { \App\Helpers\Theme::include('page-footer'); ob_end_flush(); exit; + } else { + // Superusers bypass maintenance; show a small banner + $maintMsg = \App\Core\Maintenance::getMessage(); + $custom = 'Maintenance mode is enabled.'; + if (!empty($maintMsg)) { + $custom .= ' ' . htmlspecialchars($maintMsg) . ''; + } + $custom .= ' Control it in Admin tools'; + // Non-dismissible and small, do not sanitize to allow link and + Feedback::flash('SYSTEM', 'MAINTENANCE_ON', $custom, false, true, false); } } } catch (\Throwable $e) {