Compare commits
3 Commits
5f9a0fe75b
...
d90320f5f9
| Author | SHA1 | Date |
|---|---|---|
|
|
d90320f5f9 | |
|
|
3695761b9e | |
|
|
692fec9bfe |
|
|
@ -143,6 +143,10 @@ class Feedback {
|
||||||
'type' => self::TYPE_WARNING,
|
'type' => self::TYPE_WARNING,
|
||||||
'dismissible' => true
|
'dismissible' => true
|
||||||
],
|
],
|
||||||
|
'MAINTENANCE_ON' => [
|
||||||
|
'type' => self::TYPE_WARNING,
|
||||||
|
'dismissible' => false
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
private static $strings = null;
|
private static $strings = null;
|
||||||
|
|
|
||||||
|
|
@ -45,5 +45,6 @@ return [
|
||||||
'DB_CONNECT_ERROR' => 'Error connecting to DB: %s',
|
'DB_CONNECT_ERROR' => 'Error connecting to DB: %s',
|
||||||
'DB_UNKNOWN_TYPE' => 'Error: unknown database type "%s"',
|
'DB_UNKNOWN_TYPE' => 'Error: unknown database type "%s"',
|
||||||
'MIGRATIONS_PENDING' => '%s',
|
'MIGRATIONS_PENDING' => '%s',
|
||||||
|
'MAINTENANCE_ON' => 'Maintenance mode is enabled. Regular users see a maintenance page.',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ if (!$canAdmin) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get any old feedback messages
|
||||||
|
include __DIR__ . '/../helpers/feedback.php';
|
||||||
|
|
||||||
// Handle actions
|
// Handle actions
|
||||||
$action = $_POST['action'] ?? '';
|
$action = $_POST['action'] ?? '';
|
||||||
|
|
||||||
|
|
@ -141,8 +144,5 @@ try {
|
||||||
// CSRF token
|
// CSRF token
|
||||||
$csrf_token = $security->generateCsrfToken();
|
$csrf_token = $security->generateCsrfToken();
|
||||||
|
|
||||||
// Get any new feedback messages
|
|
||||||
include __DIR__ . '/../helpers/feedback.php';
|
|
||||||
|
|
||||||
// Load the template
|
// Load the template
|
||||||
include __DIR__ . '/../templates/admin-tools.php';
|
include __DIR__ . '/../templates/admin-tools.php';
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ if (!Session::isValidSession()) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get any old feedback messages
|
||||||
|
include '../app/helpers/feedback.php';
|
||||||
|
|
||||||
// Handle theme switching
|
// Handle theme switching
|
||||||
if (isset($_GET['switch_to'])) {
|
if (isset($_GET['switch_to'])) {
|
||||||
$themeName = $_GET['switch_to'];
|
$themeName = $_GET['switch_to'];
|
||||||
|
|
@ -64,8 +67,5 @@ $themes = $themeData;
|
||||||
// Generate CSRF token for the form
|
// Generate CSRF token for the form
|
||||||
$csrf_token = $security->generateCsrfToken();
|
$csrf_token = $security->generateCsrfToken();
|
||||||
|
|
||||||
// Get any new feedback messages
|
|
||||||
include '../app/helpers/feedback.php';
|
|
||||||
|
|
||||||
// Load the template
|
// Load the template
|
||||||
include '../app/templates/theme.php';
|
include '../app/templates/theme.php';
|
||||||
|
|
|
||||||
|
|
@ -241,6 +241,8 @@ try {
|
||||||
}
|
}
|
||||||
if (!$isSuperuser) {
|
if (!$isSuperuser) {
|
||||||
http_response_code(503);
|
http_response_code(503);
|
||||||
|
// Advise clients to retry after 10 minutes (600 seconds; configure here)
|
||||||
|
header('Retry-After: 600');
|
||||||
// Show themed maintenance page
|
// Show themed maintenance page
|
||||||
\App\Helpers\Theme::include('page-header');
|
\App\Helpers\Theme::include('page-header');
|
||||||
\App\Helpers\Theme::include('page-menu');
|
\App\Helpers\Theme::include('page-menu');
|
||||||
|
|
@ -248,6 +250,16 @@ try {
|
||||||
\App\Helpers\Theme::include('page-footer');
|
\App\Helpers\Theme::include('page-footer');
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
exit;
|
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) {
|
} catch (\Throwable $e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue