diff --git a/public/index.php b/public/index.php index 7b661bd..1af61d3 100644 --- a/public/index.php +++ b/public/index.php @@ -11,7 +11,27 @@ use App\Models\Season; $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); -if ($uri === '/' || $uri === '/index.php') { +// Routing basierend auf Query-Parametern, um Probleme mit URL-Rewriting zu umgehen +if (($_GET['page'] ?? null) === 'round' && isset($_GET['id'])) { + try { + $roundId = (int)$_GET['id']; + $round = Round::getById($roundId); + + if (!$round) { + http_response_code(404); + echo "404 Not Found: Runde nicht gefunden."; + exit; + } + + $games = Game::getGamesByRound($roundId); + + // Lade das View-Template für die Rundenansicht + require __DIR__ . '/../src/Views/round.php'; + } catch (Throwable $e) { + http_response_code(500); + echo "

Fehler: " . htmlspecialchars($e->getMessage()) . "

"; + } +} elseif ($uri === '/' || $uri === '/index.php') { echo "

Willkommen bei Tippspiel 2027

"; echo "

Dies ist die Nachfolgeversion des alten Tippspiels (Pure PHP Variante).

"; @@ -32,7 +52,8 @@ if ($uri === '/' || $uri === '/index.php') { if ($rounds) { echo ""; } else { @@ -75,25 +96,6 @@ if ($uri === '/' || $uri === '/index.php') { } elseif ($uri === '/api/status') { header('Content-Type: application/json'); echo json_encode(['status' => 'ok', 'version' => '2027.1']); -} elseif (preg_match('/^\/round\/(\d+)$/', $uri, $matches)) { - try { - $roundId = $matches[1]; - $round = Round::getById($roundId); - - if (!$round) { - http_response_code(404); - echo "404 Not Found: Runde nicht gefunden."; - exit; - } - - $games = Game::getGamesByRound($roundId); - - // Lade das View-Template für die Rundenansicht - require __DIR__ . '/../src/Views/round.php'; - } catch (Throwable $e) { - http_response_code(500); - echo "

Fehler: " . htmlspecialchars($e->getMessage()) . "

"; - } } else { http_response_code(404); echo "404 Not Found";