Fehler: " . htmlspecialchars($e->getMessage()) . "
"; } } elseif (($_GET['page'] ?? null) === 'ranking') { try { $currentSeason = Season::getCurrent(); if (!$currentSeason) { throw new \Exception("Keine aktuelle Saison gefunden."); } $rankingData = Ranking::getRanking($currentSeason['id']); $ranking = $rankingData['ranking']; $games = $rankingData['games']; require __DIR__ . '/../src/Views/ranking.php'; } catch (Throwable $e) { http_response_code(500); echo "Fehler: " . htmlspecialchars($e->getMessage()) . "
"; } } elseif ($uri === '/' || $uri === '/index.php') { try { $db = Database::getConnection(); $userCount = $db->query("SELECT COUNT(*) FROM users")->fetchColumn(); $currentSeason = Season::getCurrent(); if ($currentSeason) { $rounds = Round::getBySeason($currentSeason['id']); } else { $rounds = []; } // Testdaten für die Startseite $scoreTest = Tipp::getScoreLocal(2, 1, 2, 1, true); $lastRoundId = $db->query("SELECT round_id FROM games WHERE score1 > -1 ORDER BY id DESC LIMIT 1")->fetchColumn(); if ($lastRoundId) { $games = Game::getGamesByRound($lastRoundId); } else { $games = []; } require __DIR__ . '/../src/Views/home.php'; } catch (Throwable $e) { echo "Fehler: " . $e->getMessage() . "
"; } } elseif ($uri === '/api/status') { header('Content-Type: application/json'); echo json_encode(['status' => 'ok', 'version' => '2027.1']); } else { http_response_code(404); echo "404 Not Found"; }