ycxyxc
All checks were successful
Deploy / deploy (push) Successful in 1m3s

This commit is contained in:
2026-08-04 00:42:40 +02:00
parent fc34e87622
commit fa6e975df4
17 changed files with 701 additions and 3 deletions

View File

@@ -37,5 +37,47 @@ $app = \App\App::get();
$app->session()->start();
$clientId = $app->session()->ensureClientId();
try {
$pdo = $app->pdo();
if ($pdo) {
$settings = new \App\SystemSettings($pdo);
$settings->ensureSchema();
if ($settings->getBool('site_maintenance_mode')) {
$isAdminUser = false;
if (isset($_SESSION['user_id'])) {
$communityCfg = __DIR__ . '/community.php';
$communityConfig = file_exists($communityCfg) ? require $communityCfg : [];
$communityAccess = new \App\CommunityAccess($pdo, $communityConfig);
$isAdminUser = $communityAccess->canManageApplications((int)$_SESSION['user_id']);
}
$uriPath = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/';
$uriPath = preg_replace('~/{2,}~', '/', $uriPath);
$uriPath = trim($uriPath, '/');
$maintenanceWhitelist = [
'login',
'logout',
'verify',
'reset',
'impressum',
'datenschutz',
];
if (!$isAdminUser && !in_array($uriPath, $maintenanceWhitelist, true)) {
http_response_code(503);
header('Retry-After: 600');
$message = htmlspecialchars(
$settings->get('site_maintenance_message', 'Papa-Kind-Treff ist gerade kurz in Wartung. Bitte versuche es in Kürze erneut.') ?? '',
ENT_QUOTES
);
echo '<!doctype html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Wartung</title><style>body{margin:0;font-family:sans-serif;background:#f6efe5;color:#243b53;display:grid;place-items:center;min-height:100vh;padding:24px}.card{max-width:680px;background:#fff;border:1px solid #e5d7c3;border-radius:20px;padding:28px;box-shadow:0 20px 60px rgba(36,59,83,.08)}h1{margin:0 0 12px;font-size:2rem}p{margin:0;line-height:1.6;color:#486581}</style></head><body><main class="card"><h1>Papa-Kind-Treff ist kurz in Wartung</h1><p>' . $message . '</p></main></body></html>';
exit;
}
}
}
} catch (\Throwable) {
// Fail open to avoid locking the whole site on transient settings/schema issues.
}
// Optionally expose a single global for templates if desired
$GLOBALS['client_id'] = $clientId;