Removed application folder (Ci3) added maintenance mode

This commit is contained in:
2026-01-12 17:07:11 +01:00
parent f0b9c6ad40
commit 5b73926ffe
227 changed files with 327 additions and 17706 deletions
+34
View File
@@ -22,6 +22,40 @@ if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
exit(1);
}
/*
*---------------------------------------------------------------
* MAINTENANCE MODE CHECK
*---------------------------------------------------------------
*/
$maintenanceFile = __DIR__ . '/../writable/down';
if (file_exists($maintenanceFile)) {
$maintenanceData = json_decode(file_get_contents($maintenanceFile), true) ?: [];
$allowedIps = $maintenanceData['allowed'] ?? [];
// Get the visitor's IP address
$visitorIp = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['HTTP_CLIENT_IP'] ?? $_SERVER['REMOTE_ADDR'] ?? '';
// Handle comma-separated IPs in X-Forwarded-For
if (str_contains($visitorIp, ',')) {
$visitorIp = trim(explode(',', $visitorIp)[0]);
}
// Check if visitor IP is whitelisted
if (! in_array($visitorIp, $allowedIps, true)) {
http_response_code(503);
header('Retry-After: 3600');
header('Content-Type: text/html; charset=UTF-8');
$maintenancePage = __DIR__ . '/../app/Views/errors/html/maintenance.php';
if (file_exists($maintenancePage)) {
include $maintenancePage;
} else {
echo '<h1>Service Unavailable</h1><p>The site is currently under maintenance.</p>';
}
exit(1);
}
}
/*
*---------------------------------------------------------------
* SET THE CURRENT DIRECTORY