diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b0ac3ed --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.aider* diff --git a/ai_info.txt b/ai_info.txt new file mode 100644 index 0000000..cc074bd --- /dev/null +++ b/ai_info.txt @@ -0,0 +1 @@ +Wir befinden uns im Ordner /hom/torsten/repos/tippspiel2027. Es soll ein Nachfolgeprojekt von /home/torsten/repos/tippspiel sein. Während tippspiel auf einer alten Laravel7 Version basiert, soll tippspiel2027 entweder auf reinem PHP basieren, oder maximal ein Microframework wie Slim benötigen - das Kriterium ist die leichte adaptierbarkeit für zukünftige Versionen, sowie die Lesbarkeit des entstandenen Code ( nur so viele Abstraktionsstufen wie nötig ). tippspiel2027 enthält auch viele tote Features, die nicht mehr verwendet werden ( wie z.B. Spieler Ligen und grünes Trikot ). Weiterhin ist wichtig, dass tippspiel2027 im Tabellen Back-end kompatibel zu tippspiel ist, weil das testing über das Laden eines live dumps des in Betrieb befindlichen tippspiel erfolgt. Es müssen keine Legacy Felder übernommen werden, solange es ein Import Script für tippspiel2027 gibt, das mit einem Dump aus tippspiel klarkommt. Wir habeb bereits ein MySQL Backend migriert und geben uns jetzt an die Implementierung der FUnktionen. diff --git a/composer.json b/composer.json deleted file mode 100644 index af97f43..0000000 --- a/composer.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "torsten/tippspiel2027", - "description": "Nachfolgeprojekt von tippspiel in Pure PHP", - "type": "project", - "autoload": { - "psr-4": { - "App\\": "src/" - } - } -} diff --git a/public/css/style.css b/public/css/style.css deleted file mode 100644 index e0f5cf5..0000000 --- a/public/css/style.css +++ /dev/null @@ -1,68 +0,0 @@ -/* Globale Stile */ -body { font-family: sans-serif; margin: 2em; } -nav { background: #f4f4f4; padding: 1em; margin-bottom: 2em; } -nav a { margin-right: 1em; text-decoration: none; color: #333; font-weight: bold; } - -/* Standard-Tabellen */ -table { - border-collapse: collapse; - width: 100%; - max-width: 800px; - margin-top: 1em; -} -th, td { border: 1px solid #ccc; padding: 8px; text-align: left; } -th { background-color: #f4f4f4; } -/* tr:nth-child(even) { background-color: #f9f9f9; } */ /* Deaktiviert, da es mit Zell-Farben interferiert */ - -/* Utility-Klassen */ -.text-center { text-align: center !important; } - -/* Container für breite, scrollbare Tabellen (Rangliste, Rundenansicht) */ -.table-container { - width: 100%; - overflow-x: auto; - margin-top: 20px; -} -/* Spezifische Stile für Tabellen in diesem Container */ -.table-container table { - width: auto; - min-width: 100%; -} - -/* Stile für Zellen in Rangliste/Rundenansicht */ -td.tipp-cell { text-align: center !important; position: relative; } -td.tipp-cell.col_exact { background-color: orange !important; color: white; } /* Exaktes Ergebnis */ -td.tipp-cell.col_diff { background-color: gold !important; } /* Richtige Tordifferenz */ -td.tipp-cell.col_tendenz { background-color: grey !important; color: white; } /* Richtige Tendenz */ -td.tipp-cell.col_joker_exact { background-color: red !important; color: white; } /* Exaktes Ergebnis mit Joker */ - -.round-filter { margin-bottom: 20px; } -.joker-icon { - width: 1.1em; - height: 1.1em; - vertical-align: text-bottom; - margin-left: 4px; -} -th.game-header { white-space: normal; } - -/* Legende */ -.legend { - margin: 20px 0; - padding: 10px; - border: 1px solid #ccc; - background-color: #f9f9f9; - display: flex; - flex-wrap: wrap; - gap: 15px; - align-items: center; -} -.legend-item { - display: flex; - align-items: center; - gap: 5px; -} -.legend-color { - width: 20px; - height: 20px; - border: 1px solid #666; -} diff --git a/public/icons/harlequin-hat.svg b/public/icons/harlequin-hat.svg deleted file mode 100644 index d9623f3..0000000 --- a/public/icons/harlequin-hat.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/public/icons/joker.png b/public/icons/joker.png new file mode 100644 index 0000000..0f20d50 Binary files /dev/null and b/public/icons/joker.png differ diff --git a/public/image.php b/public/image.php deleted file mode 100644 index 20a5c2a..0000000 --- a/public/image.php +++ /dev/null @@ -1,46 +0,0 @@ - 'image/png', - 'jpg' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'gif' => 'image/gif', - 'svg' => 'image/svg+xml', -]; - -$mimeType = $mimeTypes[$extension] ?? 'application/octet-stream'; - -header('Content-Type: ' . $mimeType); -readfile($filePath); diff --git a/public/index.php b/public/index.php deleted file mode 100644 index 147dce4..0000000 --- a/public/index.php +++ /dev/null @@ -1,382 +0,0 @@ - $_POST['firstname'] ?? '', - 'lastname' => $_POST['lastname'] ?? '', - 'email' => $_POST['email'] ?? '', - 'password' => $_POST['password'] ?? '', - ]; - $password_confirm = $_POST['password_confirm'] ?? ''; - $error = null; - - if (empty($data['firstname']) || empty($data['lastname']) || empty($data['email']) || empty($data['password'])) { - $error = 'Alle Felder sind erforderlich.'; - } elseif ($data['password'] !== $password_confirm) { - $error = 'Die Passwörter stimmen nicht überein.'; - } elseif (User::findByEmail($data['email'])) { - $error = 'Diese E-Mail-Adresse ist bereits registriert.'; - } else { - try { - if (User::create($data)) { - // Automatically log in the new user - if (Auth::login($data['firstname'], $data['lastname'], $data['password'])) { - header('Location: /index.php?page=ranking'); - exit; - } else { - // This should not happen if creation was successful - $error = 'Anmeldung nach Registrierung fehlgeschlagen. Bitte versuchen Sie, sich manuell anzumelden.'; - require __DIR__ . '/../src/Views/login.php'; - exit; - } - } else { - $error = 'Ein Fehler ist bei der Registrierung aufgetreten.'; - } - } catch (\Throwable $e) { - // Could be a unique constraint violation from DB - $error = 'Ein Datenbankfehler ist aufgetreten. Die E-Mail könnte bereits vergeben sein.'; - } - } - - // Show form again with error - require __DIR__ . '/../src/Views/register.php'; - - } else { - // Show registration form - require __DIR__ . '/../src/Views/register.php'; - } -} elseif ($page === 'logout') { - Auth::logout(); - header('Location: /index.php?page=login'); - exit; -} elseif ($page === 'admin') { - Auth::requireLogin(); - Auth::requireAdmin(); - require __DIR__ . '/../src/Views/admin.php'; -} elseif ($page === 'admin_seasons') { - Auth::requireLogin(); - Auth::requireAdmin(); - - $message = null; - $error = null; - - if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $action = $_POST['action'] ?? ''; - $seasonId = $_POST['id'] ?? null; - $redirect = '/index.php?page=admin_seasons'; - - try { - if ($action === 'create' || $action === 'update') { - $data = [ - 'name' => $_POST['name'], - 'rounds' => $_POST['rounds'], - ]; - $stake = $_POST['stake'] ?? '0'; - if (empty($data['name']) || !is_numeric($data['rounds']) || !is_numeric($stake)) { - throw new \Exception('Name, Runden und Einsatz sind erforderlich.'); - } - - $quotasToSave = [['name' => 'Einsatz', 'prc' => $stake]]; - if (isset($_POST['quotas']) && is_array($_POST['quotas'])) { - $quotasToSave = array_merge($quotasToSave, $_POST['quotas']); - } - - if ($action === 'create') { - $newSeasonId = Season::create($data); - if ($newSeasonId) { - Quota::updateForSeason($newSeasonId, $quotasToSave); - Season::setCurrent($newSeasonId); - $_SESSION['admin_message'] = "Saison erfolgreich erstellt und als aktiv gesetzt."; - } else { - throw new \Exception("Saison konnte nicht erstellt werden."); - } - } elseif ($seasonId) { - Season::update($seasonId, $data); - Quota::updateForSeason($seasonId, $quotasToSave); - $_SESSION['admin_message'] = "Saison erfolgreich aktualisiert."; - } - } elseif ($action === 'set_current' && $seasonId) { - Season::setCurrent($seasonId); - $_SESSION['admin_message'] = "Aktive Saison wurde geändert."; - } - } catch (\Throwable $e) { - $_SESSION['admin_error'] = "Fehler: " . $e->getMessage(); - if ($action === 'update' && $seasonId) { - $redirect = '/index.php?page=admin_seasons&edit_id=' . $seasonId; - } - } - - header('Location: ' . $redirect); - exit; - } - - if (isset($_SESSION['admin_message'])) { - $message = $_SESSION['admin_message']; - unset($_SESSION['admin_message']); - } - if (isset($_SESSION['admin_error'])) { - $error = $_SESSION['admin_error']; - unset($_SESSION['admin_error']); - } - - $seasons = Season::getAll(); - $currentSeason = Season::getCurrent(); - $editSeason = null; - $quotasForForm = []; - $stakeValue = '25.00'; // Default - if (isset($_GET['edit_id'])) { - $editSeason = Season::findById((int)$_GET['edit_id']); - if ($editSeason) { - $allQuotas = Quota::getBySeason($editSeason['id']); - foreach ($allQuotas as $quota) { - if ($quota['name'] === 'Einsatz') { - $stakeValue = $quota['prc']; - } else { - $quotasForForm[] = $quota; - } - } - } - } - - require __DIR__ . '/../src/Views/admin/seasons.php'; -} elseif ($page === 'admin_users') { - Auth::requireLogin(); - Auth::requireAdmin(); - - $currentSeason = Season::getCurrent(); - $message = null; - $error = null; - - if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $action = $_POST['action'] ?? ''; - $userId = $_POST['id'] ?? null; - $redirect = '/index.php?page=admin_users'; - - try { - if ($action === 'create' || $action === 'update') { - $data = [ - 'firstname' => $_POST['firstname'], - 'lastname' => $_POST['lastname'], - 'email' => $_POST['email'], - 'password' => $_POST['password'], - 'admin' => isset($_POST['admin']) ? 1 : 0, - ]; - - if ($action === 'create') { - if (empty($data['password'])) { - throw new \Exception('Passwort ist erforderlich.'); - } - User::create($data); - $_SESSION['admin_message'] = "Benutzer erfolgreich erstellt."; - } elseif ($userId) { - User::update($userId, $data); - if ($currentSeason) { - Payment::setPaidStatus($userId, $currentSeason['id'], isset($_POST['has_paid'])); - } - $_SESSION['admin_message'] = "Benutzer erfolgreich aktualisiert."; - } - } elseif ($action === 'delete' && $userId) { - User::delete($userId); - $_SESSION['admin_message'] = "Benutzer erfolgreich gelöscht."; - } - } catch (\Throwable $e) { - $_SESSION['admin_error'] = "Fehler: " . $e->getMessage(); - if ($action === 'update' && $userId) { - $redirect = '/index.php?page=admin_users&edit_id=' . $userId; - } - } - - header('Location: ' . $redirect); - exit; - } - - if (isset($_SESSION['admin_message'])) { - $message = $_SESSION['admin_message']; - unset($_SESSION['admin_message']); - } - if (isset($_SESSION['admin_error'])) { - $error = $_SESSION['admin_error']; - unset($_SESSION['admin_error']); - } - - $users = User::getAll(); - $payments = []; - if ($currentSeason) { - $payments = Payment::getPaymentsBySeason($currentSeason['id']); - } - $editUser = null; - if (isset($_GET['edit_id'])) { - $editUser = User::findById((int)$_GET['edit_id']); - } - - require __DIR__ . '/../src/Views/admin/users.php'; -} elseif ($page === 'round' && isset($_GET['id'])) { - Auth::requireLogin(); - try { - $roundId = (int)$_GET['id']; - $selectedRound = Round::getById($roundId); - - if (!$selectedRound) { - http_response_code(404); - echo "404 Not Found: Runde nicht gefunden."; - exit; - } - - // Alle Runden der Saison holen - $allRoundsInSeason = Round::getBySeason($selectedRound['season_id']); - - $roundsToShow = []; - $all_game_ids = []; - foreach ($allRoundsInSeason as $round) { - if ($round['id'] <= $selectedRound['id']) { - $gamesOfRound = Game::getGamesByRound($round['id']); - $round['games'] = $gamesOfRound; - $roundsToShow[] = $round; - if (!empty($gamesOfRound)) { - $all_game_ids = array_merge($all_game_ids, array_column($gamesOfRound, 'id')); - } - } - } - - // Hole alle zahlenden User der Saison - $db = Database::getConnection(); - $stmt_users = $db->prepare("SELECT u.id, u.name FROM users u JOIN payments p ON u.id = p.user_id WHERE p.season_id = ? AND u.deleted IS NULL AND p.paid_date IS NOT NULL ORDER BY u.name ASC"); - $stmt_users->execute([$selectedRound['season_id']]); - $users = $stmt_users->fetchAll(\PDO::FETCH_ASSOC); - - // Hole alle relevanten Tipps - $tipps_map = []; - if (!empty($all_game_ids) && !empty($users)) { - $user_ids = array_column($users, 'id'); - $game_placeholders = implode(',', array_fill(0, count($all_game_ids), '?')); - $user_placeholders = implode(',', array_fill(0, count($user_ids), '?')); - - $stmt_tipps = $db->prepare(" - SELECT user_id, game_id, score1 AS tipp1, score2 AS tipp2, joker - FROM tipps - WHERE game_id IN ($game_placeholders) AND user_id IN ($user_placeholders) - "); - $stmt_tipps->execute(array_merge($all_game_ids, $user_ids)); - - foreach ($stmt_tipps->fetchAll(\PDO::FETCH_ASSOC) as $tipp) { - $tipps_map[$tipp['user_id']][$tipp['game_id']] = $tipp; - } - } - - // 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 ($page === 'ranking') { - Auth::requireLogin(); - try { - $currentSeason = Season::getCurrent(); - if (!$currentSeason) { - throw new \Exception("Keine aktuelle Saison gefunden."); - } - - $selectedRoundId = isset($_GET['round_id']) ? (int)$_GET['round_id'] : null; - - $data = Ranking::getRanking($currentSeason['id'], $selectedRoundId); - $ranking = $data['ranking']; - $games = $data['games']; - $allRounds = $data['allRounds']; - $selectedRound = $data['selectedRound']; - $dailyWinners = $data['dailyWinners']; - - require __DIR__ . '/../src/Views/ranking.php'; - } catch (Throwable $e) { - http_response_code(500); - echo "

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

"; - } -} elseif ($page === 'home') { - Auth::requireLogin(); - 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"; -} diff --git a/start_aider.sh b/start_aider.sh new file mode 100644 index 0000000..c7be6aa --- /dev/null +++ b/start_aider.sh @@ -0,0 +1 @@ +aider --model claude-opus-5-5