Bei ~150 Empfängern lief der synchrone SMTP-Versand in die Zeitlimits des Shared Hosts; bei Abbruch gingen bereits verschickte Mails ins Leere und der Protokolleintrag fehlte. Jetzt verschickt jeder Aufruf 10 Mails, der Fortschritt liegt in der Session und wird pro Empfänger gesichert. Die Fortschrittsseite stößt die Blöcke per fetch an, ein offener Rest lässt sich auf der Übersicht fortsetzen. Ein Cron-Job ist dafür nicht nötig.
165 lines
24 KiB
Markdown
165 lines
24 KiB
Markdown
# Code-Map
|
|
|
|
> Automatisch erzeugt von `tools/gen_codemap.py` aus dem Arbeitsstand.
|
|
> Nicht von Hand ändern: Zweck-Texte im `PURPOSE`-Dict pflegen, danach neu
|
|
> erzeugen. `--check` vergleicht Baum und Map exakt. Welcher Code-Stand
|
|
> enthalten ist, sagt `git log -1 -- docs/code-map.md`.
|
|
|
|
Diese Datei ersetzt die Erkundung. Erst hier nachschlagen, dann gezielt mit
|
|
`grep -n` und `read` (offset/limit) öffnen — es reicht, den passenden
|
|
Abschnitt zu lesen. `docs/legacy/` ist absichtlich ausgeblendet (siehe
|
|
`.ignore`); dort liegt der alte Laravel-Stand.
|
|
|
|
Umfang: 11504 Zeilen in 66 Dateien.
|
|
|
|
## Einstiegspunkte
|
|
|
|
| Datei | Zeilen | Zweck |
|
|
|---|---|---|
|
|
| `tippspiel/public/index.php` | 1289 | Front-Controller; Routing ist eine if/elseif-Kette auf `?page=` |
|
|
| `tippspiel/src/autoload.php` | 26 | PSR-4-artiger Autoloader für `App\` |
|
|
| `tools/schema.sql` | 204 | Schema der neuen DB (Tabellen, Indizes) |
|
|
| `tippspiel/public/sw.js` | 114 | Service Worker für Web-Push |
|
|
|
|
## Routen (`?page=…`)
|
|
|
|
| page | Zugriff | View | ab Zeile |
|
|
|--------------------------|---------|------------------------------------------------------------------------------------------|----------|
|
|
| `reminder` | — | (Textausgabe) | 54 |
|
|
| `fetch_results` | — | (Textausgabe) | 71 |
|
|
| `login` | — | `login` | 86 |
|
|
| `register` | — | `register`, `login` | 107 |
|
|
| `logout` | — | — | 181 |
|
|
| `tipp_game` | Login | `tipps/game` (Fallback) | 185 |
|
|
| `tipps` | Login | `tipps/index` | 209 |
|
|
| `tipp_round` | Login | `tipps/round` | 232 |
|
|
| `datenschutz` | — | `info/privacy` | 303 |
|
|
| `guide` | Login | `info/guide` | 306 |
|
|
| `guide_admin` | Admin | `info/guide_admin` | 317 |
|
|
| `info_quotas` | Login | `info/quotas` | 322 |
|
|
| `money_ranking` | Login | `tipps/no_payment`, `info/no_ranking`, `info/money_ranking_detail`, `info/money_ranking` | 334 |
|
|
| `admin_accounts` | Admin | `admin/accounts` | 366 |
|
|
| `admin_message` | Admin | `admin/message` | 379 |
|
|
| `admin_fetcher_activity` | Admin | `admin/fetcher_activity` | 397 |
|
|
| `push_subscribe` | Login | (JSON) | 412 |
|
|
| `push_unsubscribe` | Login | — | 439 |
|
|
| `push_test` | Login | — | 445 |
|
|
| `settings` | Login | `settings` | 514 |
|
|
| `admin` | Admin | — | 562 |
|
|
| `admin_seasons` | Admin | `admin/seasons` | 586 |
|
|
| `admin_rounds` | Admin | `admin/rounds` | 696 |
|
|
| `admin_roundmails` | Admin | `admin/roundmails` | 804 |
|
|
| `admin_users` | Admin | `admin/users` | 954 |
|
|
| `round` | Login | `round` | 1058 |
|
|
| `ranking` | Login | `ranking` | 1117 |
|
|
| `questions` | Login | `questions` | 1182 |
|
|
| `home` | Login | `home` | 1245 |
|
|
|
|
Alle übrigen Pfade laufen auf `home` bzw. 404. Reihenfolge und Bedingungen
|
|
stehen in `tippspiel/public/index.php`. `(Fallback)` markiert Seiten eines
|
|
`in_array`-Zweigs ohne eigene `$page ===`-Prüfung; `(JSON)` sind Endpunkte
|
|
ohne View.
|
|
|
|
## Core (`App\Core`)
|
|
|
|
| Datei | Zeilen | Zweck | öffentliche Methoden |
|
|
|----------------------------------------|--------|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
| `tippspiel/src/Core/Auth.php` | 112 | Session, Login/Logout, Rollenprüfung (requireLogin/requireAdmin) | `start()`, `login($firstname, $lastname, $password)`, `logout()`, `check()`, `id()`, `user()`, `isAdmin()`, `requireLogin()`, … |
|
|
| `tippspiel/src/Core/Crypto.php` | 127 | Symmetrische Verschlüsselung sensibler Felder (IBAN), Schlüssel aus IBAN_KEY | `key()`, `isEncrypted($value)`, `encrypt($plaintext)`, `decrypt($value)`, `maskIban($iban)` |
|
|
| `tippspiel/src/Core/Database.php` | 38 | PDO-Singleton, Verbindung aus DB_*-Umgebungsvariablen | `getInstance()`, `getConnection()` |
|
|
| `tippspiel/src/Core/ErrorHandler.php` | 75 | Globale Fehlerbehandlung: Log + lesbare Fehlerseite statt leerem 500 | `register()`, `handleException($e)`, `handleFatal()`, `render()` |
|
|
| `tippspiel/src/Core/ErrorLog.php` | 52 | PHP-Fehlerdatei außerhalb des Web-Roots, Rotation bei 5 MB | `path()`, `rotateIfNeeded($maxBytes)` |
|
|
| `tippspiel/src/Core/Iban.php` | 51 | IBAN normalisieren und prüfen | `normalize($value)`, `isValid($value)` |
|
|
| `tippspiel/src/Core/Mailer.php` | 167 | Minimaler SMTP-Client ohne externe Abhängigkeiten | `send($recipients, $subject, $html, $replyTo, …)` |
|
|
| `tippspiel/src/Core/ResultFetcher.php` | 535 | Ergebnisse von openligadb und API-Football holen und eintragen | `openligadb($apply, $check)`, `apifootball($apply, $check)` |
|
|
| `tippspiel/src/Core/WebPush.php` | 446 | Web-Push (VAPID, RFC 8291) ohne externe Abhängigkeiten | `isConfigured()`, `publicKey()`, `subject()`, `isValidEndpoint($endpoint)`, `isValidKeyMaterial($p256dh, $auth)`, `send($subscription, $payload)`, `encrypt($payload, $p256dh, $auth, $salt, …)` |
|
|
|
|
## Models (`App\Models`)
|
|
|
|
| Datei | Zeilen | Zweck | öffentliche Methoden |
|
|
|---------------------------------------------|--------|--------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
| `tippspiel/src/Models/FetcherLog.php` | 65 | Protokoll des Ergebnis-Fetchers | `create($action, $message)`, `getRange($fromDate, $toDate)`, `deleteOld()` |
|
|
| `tippspiel/src/Models/Game.php` | 93 | Spiele lesen, Sperre 1 Minute vor Anpfiff, Ergebnisse | `isLocked($kickoffTime)`, `getResultString($score1, $score2, $kickoffTime)`, `getGamesByRound($roundId)`, `getById($id)`, `update($id, $data)` |
|
|
| `tippspiel/src/Models/Payment.php` | 44 | Zahlungen je Saison (user_id -> paid_date) | `getPaymentsBySeason($seasonId)`, `setPaidStatus($userId, $seasonId, $hasPaid)` |
|
|
| `tippspiel/src/Models/PushSubscription.php` | 195 | Push-Abos der Spieler | `isAvailable()`, `hasSubscription($userId)`, `save($userId, $endpoint, $p256dh, $auth)`, `findForUserAndEndpoint($userId, $endpoint)`, `deleteForUser($userId)`, `deleteByEndpoint($endpoint)`, `getForUsers($userIds)`, `sendReminder($userIds, $payload)` |
|
|
| `tippspiel/src/Models/Question.php` | 164 | Spielerfragen an die Admins inklusive Antworten | `create($userId, $question)`, `findByUser($userId)`, `findAllForAdmin()`, `findById($id)`, `answer($id, $answer, $adminId)`, `hasNewAnswer($userId)`, `hasOpenQuestion()`, `markAnswersSeen($userId)`, … |
|
|
| `tippspiel/src/Models/Quota.php` | 171 | Ausschüttungsbeträge einer Saison (aus Legacy portiert) | `computePayouts($seasonId)`, `get6Divisor($number)`, `getBySeason($seasonId)`, `getMapBySeason($seasonId)`, `editableNames()`, `defaults()`, `validate($quotas)`, `saveForSeason($seasonId, $quotas)` |
|
|
| `tippspiel/src/Models/Ranking.php` | 623 | Rangliste, Tagessieg, Ausschüttungen einer Saison | `compute($seasonId, $maxRoundId)`, `roundTable($result)`, `payoutItems($result)`, `roundSummary($result)`, `getJackpotStatus($seasonId)`, `computeForMoneyRanking($seasonId)`, `moneyRanking($result, $withBankData)` |
|
|
| `tippspiel/src/Models/Round.php` | 185 | Runden lesen, Reihenfolge, erste tippbare Runde | `getById($id)`, `getBySeason($seasonId)`, `updateName($id, $name)`, `updateReport($id, $report)`, `reportToText($report)`, `getLockTime($games)`, `isCompleted($games)`, `isLocked($games)`, … |
|
|
| `tippspiel/src/Models/Roundmail.php` | 310 | Rundmail-Protokoll und Erinnerungsversand | `count($excludeReminders)`, `getPage($limit, $offset, $excludeReminders)`, `findById($id)`, `create($userId, $recipients, $topic, $messageHtml, …)`, `textToHtml($text)`, `parseRecipients($list)`, `recipientGroups($seasonId, $tippableRound)`, `sendReminder($appUrl)`, … |
|
|
| `tippspiel/src/Models/Season.php` | 280 | Saisons; global aktive Saison aus settings.current_season_id | `getCurrent()`, `getViewSeason()`, `viewSeasonId()`, `setViewSeason($id)`, `getAll()`, `findById($id)`, `create($data)`, `update($id, $data)`, … |
|
|
| `tippspiel/src/Models/Setting.php` | 80 | Systemeinstellungen aus der settings-Tabelle | `isRegistrationOpen()`, `setRegistrationOpen($open)`, `getMessage()`, `setMessage($message)` |
|
|
| `tippspiel/src/Models/Team.php` | 227 | Mannschaften mit Aliasen und Logo | `normalize($name)`, `findByAlias($name)`, `resolve($name)`, `suggest($name, $limit)`, `findById($id)`, `logoUrl($team)`, `logoExists($team)`, `logoMap($ids)`, … |
|
|
| `tippspiel/src/Models/Tipp.php` | 497 | Tipps speichern und Punkte werten (aus Legacy portiert) | `getScoreLocal($goals1, $goals2, $tipp1, $tipp2, …)`, `isExact($goals1, $goals2, $tipp1, $tipp2)`, `getCol($goals1, $goals2, $tipp1, $tipp2, …)`, `evaluateRound($games, $tippsByGameId)`, `compareDayScore($a, $b)`, `findByUserAndRound($userId, $roundId)`, `findByRound($roundId)`, `getJokerUsage($userId, $seasonId, $excludeRoundId, $upToRoundId)`, … |
|
|
| `tippspiel/src/Models/User.php` | 407 | Benutzer, Kontodaten (IBAN verschlüsselt), Löschfristen | `findByEmail($email)`, `findByFirstAndLastName($firstname, $lastname)`, `findById($id)`, `getProfileWarnings($userId)`, `nameExists($firstname, $lastname, $excludeId)`, `emailExists($email, $excludeId)`, `countAll()`, `getAll()`, … |
|
|
|
|
## Views (`tippspiel/src/Views`)
|
|
|
|
| Datei | Zeilen | Zweck |
|
|
|-----------------------------------------------------|--------|--------------------------------------------------------------|
|
|
| `tippspiel/src/Views/admin/accounts.php` | 108 | Konto- und Ausschüttungsübersicht |
|
|
| `tippspiel/src/Views/admin/fetcher_activity.php` | 64 | Protokoll des Ergebnis-Fetchers |
|
|
| `tippspiel/src/Views/admin/message.php` | 34 | Mitteilung an alle Spieler setzen |
|
|
| `tippspiel/src/Views/admin/roundmails.php` | 272 | Rundmails verfassen und versenden |
|
|
| `tippspiel/src/Views/admin/rounds.php` | 206 | Spiele und Ergebnisse eintragen |
|
|
| `tippspiel/src/Views/admin/seasons.php` | 217 | Saisons verwalten |
|
|
| `tippspiel/src/Views/admin/users.php` | 190 | Benutzer verwalten (inkl. Tipp-/Joker-Lücken) |
|
|
| `tippspiel/src/Views/error.php` | 34 | Fehlerseite (vom ErrorHandler genutzt) |
|
|
| `tippspiel/src/Views/home.php` | 138 | Startseite: Begrüßung und abgeschlossene Runden |
|
|
| `tippspiel/src/Views/info/guide.php` | 207 | Anleitung für Spieler |
|
|
| `tippspiel/src/Views/info/guide_admin.php` | 144 | Anleitung für Admins |
|
|
| `tippspiel/src/Views/info/money_ranking.php` | 49 | Geldrangliste |
|
|
| `tippspiel/src/Views/info/money_ranking_detail.php` | 44 | Ausschüttungsdetails je Spieler |
|
|
| `tippspiel/src/Views/info/no_ranking.php` | 14 | Hinweis, solange keine Rangliste vorliegt |
|
|
| `tippspiel/src/Views/info/privacy.php` | 84 | Datenschutzerklärung |
|
|
| `tippspiel/src/Views/info/quotas.php` | 61 | Quoten und Ausschüttung der Saison |
|
|
| `tippspiel/src/Views/login.php` | 55 | Login-Formular |
|
|
| `tippspiel/src/Views/partials/footer.php` | 32 | Seitenabschluss und Skripte |
|
|
| `tippspiel/src/Views/partials/header.php` | 104 | HTML-Kopf, Navigation inkl. Admin-Menü und Saison-Umschalter |
|
|
| `tippspiel/src/Views/questions.php` | 138 | Fragen der Spieler und Admin-Antworten |
|
|
| `tippspiel/src/Views/ranking.php` | 433 | Rangliste (Runde/Saison) inkl. Joker-Wertung |
|
|
| `tippspiel/src/Views/register.php` | 81 | Registrierung inkl. Zahlungshinweis |
|
|
| `tippspiel/src/Views/round.php` | 101 | Tippübersicht aller Spieler bis zu einer Runde |
|
|
| `tippspiel/src/Views/settings.php` | 293 | Eigene Daten: IBAN/PayPal/Mobilnummer, E-Mail, Erinnerungen |
|
|
| `tippspiel/src/Views/tipps/game.php` | 82 | Tipp-Formular für ein einzelnes Spiel |
|
|
| `tippspiel/src/Views/tipps/index.php` | 221 | Tipp-Startseite: Runden mit Spielen, eigenen Tipps und Joker |
|
|
| `tippspiel/src/Views/tipps/no_payment.php` | 9 | Hinweis auf offene Zahlung vor der Tippabgabe |
|
|
| `tippspiel/src/Views/tipps/round.php` | 107 | Rundenliste mit Spielen, Tipps und Joker |
|
|
|
|
## Werkzeuge (`tools/`)
|
|
|
|
| Datei | Zeilen | Zweck | öffentliche Methoden |
|
|
|---------------------------------------|--------|--------------------------------------------------------------------|----------------------|
|
|
| `tools/clear_account_fields.php` | 59 | Kontofelder aller Benutzer leeren (nach Export) | — |
|
|
| `tools/encrypt_ibans.php` | 65 | IBAN-Klartexte verschlüsseln (idempotent) | — |
|
|
| `tools/export_accounts.php` | 114 | Kontodaten der aktiven Spieler als CSV exportieren | — |
|
|
| `tools/fetch_results_apifootball.php` | 19 | CLI-Wrapper: Ergebnisse Länderspiele/Europapokal | — |
|
|
| `tools/fetch_results_openligadb.php` | 19 | CLI-Wrapper: Ergebnisse Bundesliga/DFB-Pokal | — |
|
|
| `tools/import.php` | 135 | Legacy-Dump in die neue DB importieren (tote Features ausgelassen) | — |
|
|
| `tools/import_accounts.php` | 291 | Kontodaten-CSV in users importieren | — |
|
|
| `tools/migrate_users_paypal.php` | 75 | Schema-Migration: bankname/blz/kontonr -> paypal | — |
|
|
| `tools/seed_teams.php` | 363 | Mannschaften/Aliase anlegen und Spiele zuordnen | — |
|
|
| `tools/test_webpush_rfc8291.php` | 62 | Testnachricht für Web-Push | — |
|
|
| `tools/deploy_live.py` | 745 | Deploy per FTP; --db-sync/--db-only nur nach Bestätigung | — |
|
|
| `tools/dump_tippspiel.py` | 220 | Live-DB nach tools/dumps sichern (14 Dumps werden behalten) | — |
|
|
| `tools/fetch_logos.py` | 299 | Vereinslogos (Wikipedia) und Flaggen (flagcdn) laden | — |
|
|
| `tools/gen_codemap.py` | 447 | Erzeugt docs/code-map.md: eine kompakte Landkarte der Codebase. | — |
|
|
| `tools/generate_vapid_keys.py` | 125 | VAPID-Schlüssel für Web-Push erzeugen | — |
|
|
|
|
## Wo finde ich was?
|
|
|
|
- **Neue Seite / Route** → `tippspiel/public/index.php` (if/elseif auf `?page=`), View unter `tippspiel/src/Views/`
|
|
- **Login, Session, Rechte** → `Core/Auth.php`
|
|
- **Tippabgabe und Sperre** → `Models/Game.php` (`isLocked`), `Models/Tipp.php`, `Views/tipps/*`
|
|
- **Punkte und Rangliste** → `Models/Ranking.php`, `Models/Tipp.php`, `Views/ranking.php`
|
|
- **Ausschüttung und Quoten** → `Models/Quota.php`, `Views/info/quotas.php`
|
|
- **Zahlungen** → `Models/Payment.php`, `Views/admin/accounts.php`
|
|
- **Ergebnisse holen (Cron)** → `Core/ResultFetcher.php`, `?page=fetch_results`, `tools/fetch_results_*.php`
|
|
- **Erinnerungsmails (Cron)** → `Models/Roundmail.php`, `?page=reminder`, `Core/Mailer.php`
|
|
- **App-Erinnerungen / Push** → `Core/WebPush.php`, `Models/PushSubscription.php`, `public/sw.js`
|
|
- **IBAN und Verschlüsselung** → `Core/Crypto.php`, `Core/Iban.php`, `tools/encrypt_ibans.php`
|
|
- **Import aus dem Legacy-Dump** → `tools/import.php`, danach `tools/seed_teams.php`
|
|
- **Live-Deploy** → `tools/deploy_live.py`
|
|
- **DB-Dumps** → `tools/dump_tippspiel.py` (Ziel `tools/dumps/`, gitignored)
|
|
- **Fehlerlog und Betrieb** → `Core/ErrorLog.php`, `Core/ErrorHandler.php`, `docs/betriebsdiagnose.md`
|
|
- **Alter Laravel-Stand (nur Referenz)** → `docs/legacy/`
|