= heute; NULL = Alt-Code ohne Ablauf). */ function ggs_student_has_valid_license(PDO $pdo, int $studentId): bool { if ($studentId <= 0) return false; $st = $pdo->prepare( "SELECT 1 FROM licenses WHERE student_id = ? AND canceled_at IS NULL AND (valid_until IS NULL OR valid_until >= CURDATE()) LIMIT 1" ); $st->execute([$studentId]); return (bool)$st->fetchColumn(); } /** Ist die Route eine spielbare Sim (play_url ODER module_id, aktiv/beta)? */ function ggs_is_sim_route(PDO $pdo, string $route): bool { if ($route === '') return false; $st = $pdo->prepare( "SELECT 1 FROM module_info WHERE (play_url = ? OR module_id = ?) AND status IN ('aktiv','beta') LIMIT 1" ); $st->execute([$route, $route]); return (bool)$st->fetchColumn(); } /** * Front-Controller-Hook: blockt Sim-Zugriff eingeloggter Klassen-Schüler ohne * gültige Lizenz. Schnell-Ausstieg fuer alle anderen (kein Cookie / keine Sim). */ function ggs_license_gate(string $route): void { $sessionId = $_COOKIE['ggs_session'] ?? null; if (!$sessionId) return; // nur eingeloggte Schüler:innen $pdo = getDB(); $st = $pdo->prepare('SELECT student_id, class_id FROM student_sessions WHERE id = ?'); $st->execute([$sessionId]); $sess = $st->fetch(PDO::FETCH_ASSOC); if (!$sess || empty($sess['class_id'])) return; // Autodidakt ohne Klasse: nicht im Lizenzmodell if (!ggs_is_sim_route($pdo, $route)) return; // keine Sim-Route $studentId = (int)($sess['student_id'] ?? 0); if (ggs_student_has_valid_license($pdo, $studentId)) return; ggs_render_license_wall(); // beendet die Anfrage } function ggs_render_license_wall(): void { http_response_code(403); header('Content-Type: text/html; charset=utf-8'); $css = BASE_PATH . '/assets/css/design-system.css'; $cockpit = BASE_PATH . '/schueler'; echo << Lizenz benötigt · GeoGraSim
🔑

Noch keine Lizenz

Deine Lehrperson muss dir noch eine gültige Lizenz zuweisen.

Sobald das erledigt ist, kannst du alle freigegebenen Simulationen nutzen.

← Zurück zum Cockpit

HTML; exit; }