Adds a notice for maintenance mode for superusers

main
Yasen Pramatarov 2025-09-25 18:18:40 +03:00
parent 692fec9bfe
commit 3695761b9e
4 changed files with 18 additions and 3 deletions

View File

@ -143,6 +143,10 @@ class Feedback {
'type' => self::TYPE_WARNING,
'dismissible' => true
],
'MAINTENANCE_ON' => [
'type' => self::TYPE_WARNING,
'dismissible' => false
],
];
private static $strings = null;

View File

@ -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.',
],
];

View File

@ -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';

View File

@ -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 .= ' <em>' . htmlspecialchars($maintMsg) . '</em>';
}
$custom .= ' Control it in <a href="' . htmlspecialchars($app_root) . '?page=admin-tools">Admin tools</a>';
// Non-dismissible and small, do not sanitize to allow link and <em>
Feedback::flash('SYSTEM', 'MAINTENANCE_ON', $custom, false, true, false);
}
}
} catch (\Throwable $e) {