This commit is contained in:
torsten 2026-10-27 12:59:45 +01:00
parent c707c09460
commit 9e6b96fb0d
17 changed files with 290 additions and 53 deletions

View file

@ -60,6 +60,16 @@ docker compose exec app php import.php
Sobald das Skript durchgelaufen ist, sind die sauberen Daten im System und du kannst die Anwendung auf Port 8080 testen.
#### Bestehende Datenbank auf PayPal umstellen
Falls bereits eine `tippspiel2027`-Datenbank existiert und kein Neuimport gewünscht ist, entfernt das Migrationsskript die Spalten `bankname`, `blz` und `kontonr` und ergänzt `paypal` (im `tools`-Verzeichnis ausführen):
```bash
docker compose exec app php migrate_users_paypal.php
```
Das Skript ist idempotent. Vor dem Entfernen der beiden Spalten sollte `export_accounts.php` gelaufen sein, falls die Daten noch benötigt werden.
## Mannschaften & Vereinslogos
In der Rangliste, der Tippübersicht und bei der Tippeingabe werden neben den Mannschaftsnamen Vereinslogos bzw. Länderflaggen angezeigt. Da die Mannschaftsnamen in `games` Freitext sind, werden sie über eine kuratierte Zuordnung eindeutig auf eine kanonische Mannschaft abgebildet.
@ -159,9 +169,8 @@ openssl rand -base64 32
`encrypt_ibans.php` gelaufen ist.
- Ein Verlust des Schlüssels macht die IBANs unlesbar — den Schlüssel sicher und
getrennt von den Datenbank-Backups aufbewahren.
- `bankname`, `blz` und `kontonr` bleiben vorerst im Klartext; sie sind durch die
IBAN weitgehend ersetzbar und können später entfernt oder ebenfalls
verschlüsselt werden.
- `paypal` bleibt vorerst im Klartext. Die IBAN ist verschlüsselt; für eine
spätere Ausbaustufe kann auch PayPal verschlüsselt werden.
## Mailversand

View file

@ -51,8 +51,8 @@ gespeichert.
gesichert und die Felder anschließend gelöscht.
- Die Ciphertexte sind damit zusammen mit dem Schlüssel die **einzige** Kopie
der IBANs.
- `bankname`, `blz`, `kontonr` und `mobile` bleiben weiterhin im Klartext
(`README.md:162–164`).
- `paypal` und `mobile` bleiben weiterhin im Klartext
(`README.md:172–173`). `bankname`, `blz` und `kontonr` wurden inzwischen entfernt.
- Die Legacy-Dumps unter `tools/pfosten_*.sql` (60 Dateien, in Git
eingecheckt) enthalten in den Ständen bis einschließlich 2026-10-23 je
ca. 65 Klartext-IBANs. Der Dump vom 2026-10-27 enthält noch eine IBAN im
@ -100,7 +100,7 @@ expliziten Ausnahme nur für Entwicklungsumgebungen.
### 2.4 Nur die IBAN ist verschlüsselt
`bankname`, `blz`, `kontonr`, `mobile` und Freitextfelder (z. B.
`paypal`, `mobile` und Freitextfelder (z. B.
Rundenberichte, Mails) sind ungeschützt. Freitext ist besonders relevant,
weil dort IBANs versehentlich hineinkopiert werden können (siehe der Fund im
Dump vom 2026-10-27).
@ -212,8 +212,7 @@ Anforderungen:
### P2 — Datenminimierung und Altlasten
- [ ] Entscheiden, ob `bankname`, `blz`, `kontonr`, `mobile` verschlüsselt
oder entfernt werden.
- [ ] Entscheiden, ob `paypal`, `mobile` verschlüsselt oder entfernt werden.
- [ ] Freitextfelder (Rundenberichte, Mails, Logs) nach IBAN-Mustern scannen
und bereinigen.
- [ ] Legacy-Dumps (`tools/pfosten_*.sql`) aus dem Repo entfernen; Git-Historie

View file

@ -136,6 +136,30 @@ body.home-page .page {
margin: 0.25em 0;
text-align: center;
}
/* Direkter Weg zur Tippabgabe der gefährdeten Runde */
.lock-warning .lock-warning-link {
display: inline-block;
margin-top: 0.35em;
padding: 0.45em 1.2em;
font-family: var(--font-display);
font-size: 0.7em;
font-weight: 700;
line-height: 1.2;
letter-spacing: 0.05em;
text-transform: uppercase;
text-decoration: none;
color: #fff;
background: var(--col-joker-exact);
border-radius: 999px;
box-shadow: 0 2px 0 rgba(150, 25, 25, 0.9);
}
.lock-warning .lock-warning-link:hover {
background: #b51f1f;
}
.lock-warning .lock-warning-link:focus-visible {
outline: 3px solid var(--pitch);
outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
.lock-warning {
animation: none;
@ -336,7 +360,7 @@ tfoot th, tfoot td { background: #f0f4f1; color: var(--ink); border-top: 2px sol
/* Formulare --------------------------------------------------------------- */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="datetime-local"], select, textarea {
input[type="tel"], input[type="datetime-local"], select, textarea {
font: inherit;
padding: 0.35em 0.55em;
border: 1px solid #b9c4bd;
@ -411,6 +435,28 @@ td.tipp-cell.col_joker_exact { background-color: var(--col-joker-exact) !importa
font-weight: 800;
text-align: center;
}
/* Top 10: dezente grüne Hervorhebung; Gold/Silber/Bronze bleibt für 1–3 */
tr.rank-top10 td:not(.tipp-cell) { background-color: #e7f2ea; }
tbody tr.rank-top10:hover td:not(.tipp-cell) { background-color: var(--pitch-light); }
/* Sichtbarer Einschnitt zwischen Platz 10 und dem Rest der Rangliste:
Abschlusslinie unter Platz 10, Abstand, Rahmenlinie über Platz 11. */
.ranking-table tr.rank-gap td {
height: 0.9em;
padding: 0;
border: none;
line-height: 0;
background: transparent !important;
}
.ranking-table tr.rank-top10-last td {
border-bottom: 2px solid var(--pitch-dark);
}
.ranking-table tr.rank-rest-first td {
border-top: 2px solid var(--pitch-dark);
}
tr.rank-top10:not(.rank-1):not(.rank-2):not(.rank-3) .rank-badge {
background: #dbeadf;
color: var(--pitch-dark);
}
tr.rank-1 .rank-badge { background: var(--gold); color: #3d2d00; }
tr.rank-2 .rank-badge { background: var(--silver); color: #23292e; }
tr.rank-3 .rank-badge { background: var(--bronze); color: #fff; }

View file

@ -115,16 +115,28 @@ if ($page === 'reminder') {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = [
'firstname' => $_POST['firstname'] ?? '',
'lastname' => $_POST['lastname'] ?? '',
'email' => $_POST['email'] ?? '',
'firstname' => trim($_POST['firstname'] ?? ''),
'lastname' => trim($_POST['lastname'] ?? ''),
'email' => trim($_POST['email'] ?? ''),
'password' => $_POST['password'] ?? '',
'iban' => trim($_POST['iban'] ?? ''),
'paypal' => trim($_POST['paypal'] ?? ''),
'mobile' => trim($_POST['mobile'] ?? ''),
];
$data['iban'] = strtoupper(str_replace(' ', '', $data['iban']));
$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.';
if (
$data['firstname'] === ''
|| $data['lastname'] === ''
|| $data['email'] === ''
|| $data['mobile'] === ''
|| $data['password'] === ''
) {
$error = 'Bitte fülle alle Pflichtfelder aus.';
} elseif ($data['iban'] === '' && $data['paypal'] === '') {
$error = 'Bitte gib eine Zahlungsmöglichkeit an (IBAN oder PayPal).';
} elseif ($data['password'] !== $password_confirm) {
$error = 'Die Passwörter stimmen nicht überein.';
} elseif (User::findByEmail($data['email'])) {
@ -749,6 +761,9 @@ if ($page === 'reminder') {
'lastname' => $_POST['lastname'],
'email' => $_POST['email'],
'password' => $_POST['password'],
'iban' => strtoupper(str_replace(' ', '', trim($_POST['iban'] ?? ''))),
'paypal' => trim($_POST['paypal'] ?? ''),
'mobile' => trim($_POST['mobile'] ?? ''),
'admin' => isset($_POST['admin']) ? 1 : 0,
];
@ -789,6 +804,15 @@ if ($page === 'reminder') {
$editUser = null;
if (isset($_GET['edit_id'])) {
$editUser = User::findById((int)$_GET['edit_id']);
if ($editUser) {
// IBAN liegt verschlüsselt in der DB und wird nur für das Formular entschlüsselt.
try {
$editUser['iban'] = \App\Core\Crypto::decrypt($editUser['iban']);
} catch (\Throwable $e) {
$editUser['iban'] = '';
$error = 'Die hinterlegte IBAN konnte nicht entschlüsselt werden.';
}
}
}
require __DIR__ . '/../src/Views/admin/users.php';

View file

@ -423,7 +423,7 @@ class Ranking {
* @param array $result Ergebnis von compute()
* @param bool $withBankData Bankdaten (IBAN etc.) nur für Admins mitliefern/entschlüsseln
* @return array Liste von ['user_id', 'name', 'amount'] und optional
* ['iban', 'iban_masked', 'bankname', 'blz', 'kontonr']
* ['iban', 'iban_masked', 'paypal']
*/
public static function moneyRanking(array $result, $withBankData = false) {
$list = [];
@ -439,9 +439,7 @@ class Ranking {
$iban = self::readableIban($user['iban']);
$row['iban'] = $iban;
$row['iban_masked'] = Crypto::maskIban($iban);
$row['bankname'] = $user['bankname'];
$row['blz'] = $user['blz'];
$row['kontonr'] = $user['kontonr'];
$row['paypal'] = $user['paypal'];
}
$list[] = $row;

View file

@ -152,13 +152,20 @@ class Round {
}
$missing = Tipp::getMissing((int)$round['id'], [(int)$userId]);
$user = User::findById((int)$userId);
return [
'round_id' => (int)$round['id'],
'name' => (string)$round['name'],
'lock_time' => $lockTime,
'remaining' => self::formatRemainingTime($secondsLeft),
'missing_tipps' => in_array((int)$userId, $missing['tipps'], true),
'missing_joker' => in_array((int)$userId, $missing['joker'], true),
'missing_payment' => $user
? trim((string)$user['iban']) === '' && trim((string)$user['paypal']) === ''
: false,
'missing_email' => $user ? trim((string)$user['email']) === '' : false,
'missing_mobile' => $user ? trim((string)$user['mobile']) === '' : false,
];
}

View file

@ -10,7 +10,7 @@ class User {
/**
* Felder, die ein Admin bzw. der Benutzer selbst optional ändern darf.
*/
const BANK_FIELDS = ['iban', 'bankname', 'blz', 'kontonr', 'mobile'];
const BANK_FIELDS = ['iban', 'paypal', 'mobile'];
/**
* Findet einen Benutzer anhand seiner E-Mail-Adresse.
@ -172,7 +172,7 @@ class User {
/**
* Erstellt einen neuen Benutzer.
*
* @param array $data ['firstname', 'lastname', 'email', 'password', optional 'admin']
* @param array $data ['firstname', 'lastname', 'email', 'password', 'iban', 'paypal', 'mobile', optional 'admin']
* @return int|false Die ID des neuen Benutzers oder false bei einem Fehler.
*/
public static function create($data) {
@ -181,8 +181,10 @@ class User {
$lastname = trim($data['lastname'] ?? '');
$stmt = $db->prepare(
"INSERT INTO users (firstname, lastname, name, email, password, admin, created_at, updated_at)
VALUES (:firstname, :lastname, :name, :email, :password, :admin, NOW(), NOW())"
"INSERT INTO users
(firstname, lastname, name, email, password, iban, paypal, mobile, admin, created_at, updated_at)
VALUES
(:firstname, :lastname, :name, :email, :password, :iban, :paypal, :mobile, :admin, NOW(), NOW())"
);
$ok = $stmt->execute([
@ -191,6 +193,9 @@ class User {
':name' => $firstname . ' ' . $lastname,
':email' => trim($data['email']),
':password' => password_hash($data['password'], PASSWORD_DEFAULT),
':iban' => self::prepareBankValue('iban', $data['iban'] ?? ''),
':paypal' => trim((string)($data['paypal'] ?? '')),
':mobile' => trim((string)($data['mobile'] ?? '')),
':admin' => !empty($data['admin']) ? 1 : 0,
]);
@ -243,7 +248,7 @@ class User {
* (Legacy: UsersController::storeUserEdit). Name ist dort nicht änderbar.
*
* @param int $id
* @param array $data ['email', 'iban', 'bankname', 'blz', 'kontonr', 'mobile', 'gets_reminders']
* @param array $data ['email', 'iban', 'paypal', 'mobile', 'gets_reminders']
* @return bool
*/
public static function updateProfile($id, $data) {

View file

@ -33,22 +33,22 @@ $euro = fn($amount) => number_format($amount, 2, ',', '.') . ' €';
<thead>
<tr>
<th>Name</th>
<th>Ausschüttung</th>
<th>Bankname</th>
<th class="amount">Ausschüttung</th>
<th>PayPal</th>
<th>IBAN</th>
<th>BLZ</th>
<th>Kontonummer</th>
</tr>
</thead>
<tbody>
<?php foreach ($moneyRanking as $entry):
$hasPayout = $entry['amount'] > 0;
$missingAccount = $hasPayout && empty($entry['iban']) && empty($entry['kontonr']);
$missingAccount = $hasPayout
&& empty($entry['iban'])
&& empty($entry['paypal']);
?>
<tr <?php if (!$hasPayout) echo 'class="no-payout"'; ?>>
<td><a href="/index.php?page=money_ranking&amp;user_id=<?php echo (int)$entry['user_id']; ?>"><?php echo htmlspecialchars($entry['name']); ?></a></td>
<td class="amount"><?php echo $euro($entry['amount']); ?></td>
<td><?php echo htmlspecialchars((string)$entry['bankname']); ?></td>
<td><?php echo htmlspecialchars((string)$entry['paypal']); ?></td>
<td class="iban <?php if ($missingAccount) echo 'missing'; ?>">
<?php if ($missingAccount): ?>
fehlt
@ -59,8 +59,6 @@ $euro = fn($amount) => number_format($amount, 2, ',', '.') . ' €';
<?php endif; ?>
<?php endif; ?>
</td>
<td><?php echo htmlspecialchars((string)$entry['blz']); ?></td>
<td><?php echo htmlspecialchars((string)$entry['kontonr']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
@ -68,7 +66,7 @@ $euro = fn($amount) => number_format($amount, 2, ',', '.') . ' €';
<tr>
<th>Summe</th>
<th class="amount"><?php echo $euro(array_sum(array_column($moneyRanking, 'amount'))); ?></th>
<th colspan="4"></th>
<th colspan="2"></th>
</tr>
</tfoot>
</table>
@ -76,7 +74,14 @@ $euro = fn($amount) => number_format($amount, 2, ',', '.') . ' €';
<?php endif; ?>
<style>
.accounts-table td.amount, .accounts-table th.amount { text-align: right; white-space: nowrap; }
.accounts-table td.amount, .accounts-table th.amount {
/* Spalte fest auf Platz für max. vier Vorkommastellen begrenzen (z. B. 9.999,99 €) */
width: 1%;
min-width: 8em;
text-align: right;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.accounts-table td.iban { font-family: monospace; white-space: nowrap; }
.accounts-table td.missing { color: #c00; font-family: inherit; font-weight: bold; }
.accounts-table tr.no-payout td { color: #999; }

View file

@ -31,6 +31,18 @@ require __DIR__ . '/../partials/header.php';
<label for="email">E-Mail:</label>
<input type="email" id="email" name="email" value="<?php echo htmlspecialchars($editUser['email']); ?>" required>
</div>
<div class="form-group">
<label for="mobile">Handynummer:</label>
<input type="tel" id="mobile" name="mobile" value="<?php echo htmlspecialchars((string)$editUser['mobile']); ?>">
</div>
<div class="form-group">
<label for="iban">IBAN:</label>
<input type="text" id="iban" name="iban" maxlength="34" value="<?php echo htmlspecialchars((string)$editUser['iban']); ?>">
</div>
<div class="form-group">
<label for="paypal">PayPal:</label>
<input type="text" id="paypal" name="paypal" maxlength="255" placeholder="E-Mail oder PayPal.Me-Link" value="<?php echo htmlspecialchars((string)$editUser['paypal']); ?>">
</div>
<div class="form-group">
<label for="password">Passwort:</label>
<input type="password" id="password" name="password" placeholder="Leer lassen, um nicht zu ändern">

View file

@ -14,11 +14,23 @@ require __DIR__ . '/partials/header.php';
<?php if ($lockWarning['missing_joker']): ?>
<p>Fehlender Joker für <?php echo htmlspecialchars($lockWarning['name']); ?></p>
<?php endif; ?>
<?php if ($lockWarning['missing_payment']): ?>
<p>Fehlende Zahlungsmöglichkeit (IBAN oder PayPal)</p>
<?php endif; ?>
<?php if ($lockWarning['missing_email']): ?>
<p>Fehlende E-Mail-Adresse</p>
<?php endif; ?>
<?php if ($lockWarning['missing_mobile']): ?>
<p>Fehlende Handynummer</p>
<?php endif; ?>
<p>
<?php echo htmlspecialchars($lockWarning['name']); ?> sperrt sich:
<?php echo $lockWarning['lock_time']->format('Y-m-d H:i:s'); ?>
( noch <?php echo htmlspecialchars($lockWarning['remaining']); ?> )
</p>
<p>
<a class="lock-warning-link" href="/index.php?page=tipp_round&amp;id=<?php echo (int)$lockWarning['round_id']; ?>">Jetzt tippen</a>
</p>
</div>
<?php endif; ?>

View file

@ -203,6 +203,13 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
<?php if ($selectedRound): ?>
<?php if (!empty($ranking)): ?>
<?php
// Spaltenzahl für die Abstandszeile zwischen Top 10 und Rest
$rankingColumnCount = 5 + count($games) * 3
+ ($roundCompleted ? 1 : 0)
+ ($roundHasJackpot ? 1 : 0)
+ ($isFinalRound ? 1 : 0);
?>
<table class="ranking-table">
<thead>
<tr>
@ -243,9 +250,21 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
</tr>
</thead>
<tbody>
<?php foreach ($ranking as $entry):
<?php foreach ($ranking as $entryIndex => $entry):
$nextEntry = $ranking[$entryIndex + 1] ?? null;
$prevEntry = $entryIndex > 0 ? ($ranking[$entryIndex - 1] ?? null) : null;
$isLastTop10 = $entry['rank'] <= 10
&& $nextEntry !== null
&& (int)$nextEntry['rank'] > 10;
$isFirstRest = $prevEntry !== null
&& (int)$prevEntry['rank'] <= 10
&& (int)$entry['rank'] > 10;
$rowClasses = [];
if ($entry['rank'] <= 3) $rowClasses[] = 'rank-' . $entry['rank'];
if ($entry['rank'] <= 10) $rowClasses[] = 'rank-top10';
if ($isLastTop10) $rowClasses[] = 'rank-top10-last';
if ($isFirstRest) $rowClasses[] = 'rank-rest-first';
if ((int)$entry['user_id'] === (int)App\Core\Auth::id()) $rowClasses[] = 'me';
// Aufschlüsselung der Rundenpunkte für den Popup
@ -307,6 +326,11 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
<td class="text-center"><?php echo $entry['ranking_payout'] > 0 ? number_format($entry['ranking_payout'], 2, ',', '.') . ' €' : ''; ?></td>
<?php endif; ?>
</tr>
<?php if ($isLastTop10): ?>
<tr class="rank-gap" aria-hidden="true">
<td colspan="<?php echo (int)$rankingColumnCount; ?>"></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
<tfoot>

View file

@ -28,6 +28,11 @@ require __DIR__ . '/partials/header.php';
.form-group button {
margin-left: calc(200px + 10px);
}
.form-hint {
margin: 0 0 1rem calc(200px + 10px);
color: var(--muted);
font-size: 0.9em;
}
</style>
<form action="/index.php?page=register" method="post">
<div class="form-group">
@ -42,6 +47,19 @@ require __DIR__ . '/partials/header.php';
<label for="email">E-Mail:</label>
<input type="email" id="email" name="email" value="<?php echo htmlspecialchars($_POST['email'] ?? ''); ?>" required>
</div>
<div class="form-group">
<label for="mobile">Handynummer:</label>
<input type="tel" id="mobile" name="mobile" value="<?php echo htmlspecialchars($_POST['mobile'] ?? ''); ?>" required>
</div>
<div class="form-group">
<label for="iban">IBAN (oder PayPal):</label>
<input type="text" id="iban" name="iban" maxlength="34" value="<?php echo htmlspecialchars($_POST['iban'] ?? ''); ?>">
</div>
<div class="form-group">
<label for="paypal">PayPal (oder IBAN):</label>
<input type="text" id="paypal" name="paypal" maxlength="255" placeholder="E-Mail oder PayPal.Me-Link" value="<?php echo htmlspecialchars($_POST['paypal'] ?? ''); ?>">
</div>
<p class="form-hint">Bitte mindestens eine Zahlungsmöglichkeit angeben: IBAN oder PayPal.</p>
<div class="form-group">
<label for="password">Passwort:</label>
<input type="password" id="password" name="password" required>

View file

@ -31,16 +31,8 @@ require __DIR__ . '/partials/header.php';
<input type="text" id="iban" name="iban" maxlength="34" value="<?php echo htmlspecialchars((string)$user['iban']); ?>">
</div>
<div class="form-group">
<label for="bankname">Bankname:</label>
<input type="text" id="bankname" name="bankname" value="<?php echo htmlspecialchars((string)$user['bankname']); ?>">
</div>
<div class="form-group">
<label for="blz">BLZ:</label>
<input type="text" id="blz" name="blz" value="<?php echo htmlspecialchars((string)$user['blz']); ?>">
</div>
<div class="form-group">
<label for="kontonr">Kontonummer:</label>
<input type="text" id="kontonr" name="kontonr" value="<?php echo htmlspecialchars((string)$user['kontonr']); ?>">
<label for="paypal">PayPal:</label>
<input type="text" id="paypal" name="paypal" maxlength="255" placeholder="E-Mail oder PayPal.Me-Link" value="<?php echo htmlspecialchars((string)$user['paypal']); ?>">
</div>
<div class="form-group">
<label for="mobile">Handynummer:</label>

View file

@ -1,6 +1,7 @@
<?php
// Leert die Kontofelder (iban, bankname, blz, kontonr) aller Benutzer.
// Leert die Kontofelder (iban, paypal; auf der Legacy-DB zusätzlich bankname,
// blz und kontonr) aller Benutzer.
// Vorher sollte export_accounts.php gelaufen sein, um die Daten zu sichern.
//
// Aufruf (im App-Container):
@ -32,13 +33,23 @@ try {
die("Fehler: Datenbank '$targetDb' nicht gefunden.\n");
}
$stmt = $pdo->prepare(
"UPDATE `$targetDb`.`users`
SET iban = NULL, bankname = NULL, blz = NULL, kontonr = NULL"
);
// Nur Felder leeren, die in der Ziel-DB tatsächlich existieren. So läuft
// das Skript sowohl auf der Legacy-DB (mit bankname/blz) als auch auf der
// neuen DB (mit paypal).
$columns = $pdo->query("SHOW COLUMNS FROM `$targetDb`.`users`")->fetchAll(PDO::FETCH_COLUMN);
$fields = array_values(array_intersect(
['iban', 'paypal', 'kontonr', 'bankname', 'blz'],
$columns
));
if (empty($fields)) {
die("Fehler: Keine bekannten Kontofelder in '$targetDb'.users gefunden.\n");
}
$assignments = implode(', ', array_map(fn($field) => "`$field` = NULL", $fields));
$stmt = $pdo->prepare("UPDATE `$targetDb`.`users` SET $assignments");
$stmt->execute();
echo "Kontofelder (iban, bankname, blz, kontonr) in '$targetDb' geleert.\n";
echo "Kontofelder (" . implode(', ', $fields) . ") in '$targetDb' geleert.\n";
echo "Betroffene Zeilen: " . $stmt->rowCount() . "\n";
} catch (PDOException $e) {

View file

@ -6,6 +6,8 @@
// Tote Features wie "Spieler Ligen" und "grünes Trikot" werden ignoriert.
// IBANs werden beim Import direkt verschlüsselt (sofern IBAN_KEY gesetzt ist),
// damit Klartext-IBANs gar nicht erst in der neuen DB landen.
// Die Legacy-Felder bankname/blz/kontonr werden nicht mehr übernommen; das neue
// Feld paypal wird nur kopiert, wenn es in der Quelldatenbank bereits existiert.
// Crypto-Klasse laden (funktioniert im Container und direkt auf dem Host).
$cryptoCandidates = [

View file

@ -0,0 +1,75 @@
<?php
// Einmalige Schema-Migration für bestehende Datenbanken:
// - users.bankname, users.blz und users.kontonr entfernen
// - users.paypal ergänzen
//
// Ab sofort gelten für Auszahlungen nur noch IBAN und PayPal.
//
// Aufruf (im App-Container):
// docker compose exec app php migrate_users_paypal.php [datenbank]
//
// Standard-Ziel: DB_NEW_NAME, Standard "tippspiel2027".
// Das Skript ist idempotent und kann gefahrlos mehrfach ausgeführt werden.
$host = getenv('DB_HOST') ?: '127.0.0.1';
$user = getenv('DB_USER') ?: 'root';
$pass = getenv('DB_PASS') ?: '';
$targetDb = $argv[1] ?? (getenv('DB_NEW_NAME') ?: 'tippspiel2027');
if (!preg_match('/^[A-Za-z0-9_]+$/', $targetDb)) {
die("Fehler: Ungültiger Datenbankname '$targetDb'.\n");
}
try {
$pdo = new PDO("mysql:host=$host;charset=utf8mb4", $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$existsStmt = $pdo->prepare(
"SELECT SCHEMA_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = ?"
);
$existsStmt->execute([$targetDb]);
if (!$existsStmt->fetchColumn()) {
die("Fehler: Datenbank '$targetDb' nicht gefunden.\n");
}
$columns = $pdo->query("SHOW COLUMNS FROM `$targetDb`.`users`")->fetchAll(PDO::FETCH_COLUMN);
$changes = [];
if (!in_array('paypal', $columns, true)) {
$changes[] = "ADD COLUMN `paypal` varchar(255) DEFAULT NULL AFTER `iban`";
}
if (in_array('bankname', $columns, true)) {
$changes[] = "DROP COLUMN `bankname`";
}
if (in_array('blz', $columns, true)) {
$changes[] = "DROP COLUMN `blz`";
}
if (in_array('kontonr', $columns, true)) {
$changes[] = "DROP COLUMN `kontonr`";
}
if (empty($changes)) {
echo "Schema von '$targetDb'.users ist bereits aktuell. Keine Änderungen nötig.\n";
exit(0);
}
$droppedBankFields = array_intersect(['bankname', 'blz', 'kontonr'], $columns);
$sql = "ALTER TABLE `$targetDb`.`users` " . implode(', ', $changes);
$pdo->exec($sql);
echo "Migration in '$targetDb'.users abgeschlossen:\n";
foreach ($changes as $change) {
echo " - $change\n";
}
if (!empty($droppedBankFields)) {
echo "Hinweis: " . implode(', ', $droppedBankFields) . " wurden unwiderruflich entfernt. "
. "Falls die Daten noch benötigt werden, vorher export_accounts.php ausführen.\n";
}
} catch (PDOException $e) {
die("Datenbankfehler: " . $e->getMessage() . "\n");
} catch (\Throwable $e) {
die("Fehler: " . $e->getMessage() . "\n");
}

View file

@ -7,9 +7,7 @@ CREATE TABLE `users` (
`email` varchar(150) NOT NULL,
`password` varchar(100) NOT NULL,
`iban` varchar(255) DEFAULT NULL,
`bankname` varchar(64) DEFAULT NULL,
`blz` varchar(20) DEFAULT NULL,
`kontonr` varchar(64) DEFAULT NULL,
`paypal` varchar(255) DEFAULT NULL,
`mobile` varchar(255) DEFAULT NULL,
`deleted` timestamp NULL DEFAULT NULL,
`admin` tinyint(1) NOT NULL DEFAULT '0',