Data export and account deletion (anonymization) with a grace period
- Data export (Art. 15/20 GDPR, includes/data_export.php): ZIP with daten.json, LIESMICH.txt and the
member's own images (avatar, characters, gallery, bug reports). It covers every table related to the
account plus, via the bot API, raid sign-ups, premades, created events and activity checks. Password hash,
tokens and player reports (they name the reporters) are left out. The ZIP is written by data_export_zip(),
so the PHP zip extension is not needed.
- Members find export and deletion under "Mein Profil" at the very bottom in a collapsed "Konto & Daten"
section (data_export.php, account_delete.php).
- Leadership: new icon "Daten & Löschung" in the user admin (admin/user_export.php, permission users.export).
It downloads the export or creates a download link for someone without access (datenauskunft.php?t=...,
7 days, 5 downloads, only the SHA-256 hash stored in data_export_links). The link page shows a button first,
so link previews don't use up downloads. It also works in maintenance mode.
- Account deletion (includes/account_deletion.php): the account is anonymized instead of removed.
- Deleted: profile, avatar, characters, gallery, gear sets, private tactics, groups, tokens, calendar
participations and bug report images.
- Contributions remain as "Ehemaliges Mitglied" without name or Discord ID.
- Requested by the member (type LÖSCHEN) or by the leadership (users.delete, also immediately).
- Executed after 7 days by account_deletion_run_due(); logging in before that cancels it and tells the member.
- The user admin shows "Löschung am ..." and "Gelöscht (unkenntlich)". Privacy policy, README and a
leadership patch note are updated. Schema v44 (users.deletion_scheduled_at, users.deleted_at, data_export_links).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
62d6634829
commit
cd8716e791
22 changed files with 1347 additions and 16 deletions
29
README.md
29
README.md
|
|
@ -979,6 +979,35 @@ Zentral in `includes/security.php` (Grenzen in `SECURITY_LIMITS`):
|
|||
- Außerhalb der Website: Vertrag zur Auftragsverarbeitung (AVV) mit dem Hoster abschließen und
|
||||
die Aufbewahrung der Zugriffsprotokolle im Hosting-Panel kurz halten.
|
||||
|
||||
### Datenauskunft und Kontolöschung
|
||||
|
||||
- **Datenauskunft** (Art. 15/20 DSGVO, `includes/data_export.php`): ein ZIP mit `daten.json`,
|
||||
`LIESMICH.txt` und den eigenen Bildern (Profilbild, Charaktere, Galerie, Fehlermeldungen). Es enthält
|
||||
alle Tabellen mit Bezug zum Konto und über die Bot-API Raid-Anmeldungen, Premades, selbst angelegte
|
||||
Events und Aktivitätschecks. Nicht enthalten sind Passwort-Hash und Tokens sowie Reports über die Person
|
||||
(nennen die Meldenden). Das ZIP baut `data_export_zip()` selbst, die PHP-Erweiterung `zip` ist nicht nötig.
|
||||
- Mitglieder laden ihre Auskunft unter **Mein Profil → Konto & Daten** herunter; der Bereich ist ganz unten
|
||||
und zugeklappt, damit niemand damit herumspielt (`data_export.php`, Tempolimit `export`).
|
||||
- Die Leitung öffnet in der Benutzerverwaltung das Symbol **Daten & Löschung** (`admin/user_export.php`,
|
||||
Berechtigung `users.export`). Dort lädt sie die Auskunft herunter oder erzeugt einen **Download-Link**
|
||||
(`datenauskunft.php?t=…`) für jemanden ohne Zugang. Der Link gilt 7 Tage und für 5 Downloads, gespeichert
|
||||
ist nur sein Hash (`data_export_links`). Sein Aufruf zeigt erst eine Seite mit Knopf, damit Link-Vorschauen
|
||||
von Discord keinen Download verbrauchen. Er funktioniert auch im Wartungsmodus.
|
||||
- **Kontolöschung** (`includes/account_deletion.php`): Das Konto wird nicht entfernt, sondern unkenntlich
|
||||
gemacht.
|
||||
- Gelöscht werden Profil, Profilbild, Charaktere, Galerie, Gear-Sets, private Taktiken, Gruppen,
|
||||
Terminteilnahmen, Bilder an Fehlermeldungen und Tokens.
|
||||
- Beiträge (Kommentare, Wiki, Lumipunkte, Shop, Lagerhaus, Raid-Anwesenheit) bleiben als „Ehemaliges
|
||||
Mitglied“ ohne Namen und Discord-ID.
|
||||
- Mitglieder beantragen sie unter Mein Profil (`account_delete.php`, LÖSCHEN eintippen; nicht für
|
||||
Admins/Entwickler), die Leitung auf der Seite Daten & Löschung (Recht `users.delete`, auch sofort).
|
||||
- Ausgeführt wird sie nach 7 Tagen durch `account_deletion_run_due()` (nebenbei in der bootstrap,
|
||||
höchstens alle 15 Minuten).
|
||||
- Anmelden vor Ablauf bricht sie ab und zeigt das an (`account_deletion_on_login()` in
|
||||
`auth_login_session()`).
|
||||
- Nicht erfasst werden Daten beim Discord-Bot und alte Nachrichten im Log-Kanal auf Discord. Die löscht
|
||||
die Leitung auf Anfrage von Hand.
|
||||
|
||||
## Kalender
|
||||
|
||||
**Kalender** im Menü (`calendar.php`) zeigt Raids (gold) und Events (blau) als Monatsübersicht mit
|
||||
|
|
|
|||
34
account_delete.php
Normal file
34
account_delete.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* "Konto löschen" (Mein Profil -> Konto & Daten): beantragt die Loeschung des eigenen Kontos.
|
||||
* Ausgefuehrt wird sie nach ACCOUNT_DELETION_DAYS Tagen - wer sich vorher anmeldet, bricht sie ab
|
||||
* (includes/account_deletion.php).
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_login();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
redirect('/profile.php?konto#konto-loeschen');
|
||||
}
|
||||
verify_csrf();
|
||||
|
||||
$me = current_user();
|
||||
if (!empty($me['is_admin']) || is_developer($me)) {
|
||||
set_flash('error', 'Administratoren können ihr Konto nicht selbst löschen - lass dir zuerst die Administrator-Rechte entziehen.');
|
||||
redirect('/profile.php?konto#konto-loeschen');
|
||||
}
|
||||
// Gegen versehentliches Loeschen muss man das Wort eintippen
|
||||
if (mb_strtoupper(trim((string) ($_POST['confirm_word'] ?? ''))) !== 'LÖSCHEN') {
|
||||
set_flash('error', 'Zum Bestätigen bitte LÖSCHEN eintippen - dein Konto wurde nicht gelöscht.');
|
||||
redirect('/profile.php?konto#konto-loeschen');
|
||||
}
|
||||
|
||||
$due = account_deletion_request((int) $me['id'], $me);
|
||||
|
||||
// Abmelden - erst eine neue Anmeldung bricht die Loeschung ab
|
||||
auth_remember_forget();
|
||||
$_SESSION = [];
|
||||
session_regenerate_id(true);
|
||||
set_flash('info', 'Dein Konto wird am ' . date('d.m.Y \u\m H:i', (int) strtotime($due)) . ' Uhr gelöscht und du bist abgemeldet. '
|
||||
. 'Meldest du dich vorher wieder an, brechen wir die Löschung ab.');
|
||||
redirect('/login.php');
|
||||
163
admin/user_export.php
Normal file
163
admin/user_export.php
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
/**
|
||||
* Daten & Löschung eines Mitglieds (Recht users.export, Löschen zusätzlich users.delete):
|
||||
* Datenauskunft herunterladen, Download-Link für jemanden ohne Zugang erzeugen
|
||||
* (includes/data_export.php) und die Kontolöschung planen, abbrechen oder sofort ausführen
|
||||
* (includes/account_deletion.php).
|
||||
*/
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/data_export.php';
|
||||
require_permission('users.export');
|
||||
|
||||
$id = (int) ($_GET['id'] ?? 0);
|
||||
$target = data_export_target($id);
|
||||
if ($target === null) {
|
||||
show_not_found();
|
||||
}
|
||||
$account = data_export_rows('SELECT deletion_scheduled_at, deleted_at FROM users WHERE id = ?', [$id])[0] ?? [];
|
||||
$isDeleted = !empty($account['deleted_at']);
|
||||
$scheduled = $account['deletion_scheduled_at'] ?? null;
|
||||
$canDelete = user_has_permission('users.delete') && $id !== (int) current_user()['id'];
|
||||
$name = $target['display_name'] !== '' ? $target['display_name'] : $target['username'];
|
||||
|
||||
// Frisch erzeugter Link - nur einmal sichtbar, gespeichert ist nur sein Hash
|
||||
$newLink = $_SESSION['data_export_new_link'] ?? null;
|
||||
unset($_SESSION['data_export_new_link']);
|
||||
if (!is_array($newLink) || (int) ($newLink['user_id'] ?? 0) !== $id) {
|
||||
$newLink = null;
|
||||
}
|
||||
|
||||
data_export_links_cleanup();
|
||||
$links = data_export_rows(
|
||||
"SELECT l.*, COALESCE(NULLIF(u.display_name, ''), u.username) AS created_by_name
|
||||
FROM data_export_links l LEFT JOIN users u ON u.id = l.created_by WHERE l.user_id = ? ORDER BY l.created_at DESC",
|
||||
[$id]
|
||||
);
|
||||
$statusBadges = ['aktiv' => 'badge-active', 'widerrufen' => 'badge-disabled', 'aufgebraucht' => '', 'abgelaufen' => ''];
|
||||
$fmt = static fn (?string $dt): string => $dt ? date('d.m.Y, H:i', (int) strtotime($dt)) . ' Uhr' : '-';
|
||||
|
||||
$pageTitle = 'Daten & Löschung';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
<div class="panel">
|
||||
<p class="text-muted data-admin-back"><a href="/admin/users.php">← Benutzerverwaltung</a></p>
|
||||
<h1>Daten & Löschung: <?= e($name) ?></h1>
|
||||
<p class="text-muted">
|
||||
Für Anfragen nach der DSGVO: Auskunft über alle gespeicherten Daten (Art. 15 und 20) und Löschung (Art. 17).
|
||||
Beantworten musst du sie innerhalb eines Monats. Mitglieder mit Zugang finden beides selbst unter
|
||||
„Mein Profil“ → „Konto & Daten“.
|
||||
</p>
|
||||
<?php if ($isDeleted): ?>
|
||||
<div class="legal-missing">Dieses Konto wurde am <?= e($fmt($account['deleted_at'])) ?> gelöscht (unkenntlich gemacht) - es sind keine persönlichen Daten mehr übrig.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!$isDeleted): ?>
|
||||
<div class="panel site-admin-section">
|
||||
<h2>📦 Datenauskunft herunterladen</h2>
|
||||
<p class="text-muted">
|
||||
Alles, was Website und Discord-Bot zu diesem Konto gespeichert haben - als ZIP mit daten.json, LIESMICH.txt
|
||||
und den hochgeladenen Bildern. Zum Weiterleiten per E-Mail o. Ä.; der Download steht im Audit-Log.
|
||||
</p>
|
||||
<form method="post" action="/admin/user_export_action.php">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $id ?>">
|
||||
<input type="hidden" name="action" value="download">
|
||||
<button type="submit" class="button-secondary"><?= icon('archive') ?> Daten herunterladen (ZIP)</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="panel site-admin-section">
|
||||
<h2>🔗 Download-Link für das Mitglied</h2>
|
||||
<p class="text-muted">
|
||||
Für jemanden, der sich nicht mehr anmelden kann (z. B. gesperrt). Der Link gilt <?= DATA_EXPORT_LINK_DAYS ?> Tage
|
||||
und für höchstens <?= DATA_EXPORT_LINK_MAX_DOWNLOADS ?> Downloads und liefert immer den aktuellen Stand. Er funktioniert
|
||||
nur, solange das Konto nicht gelöscht ist - soll es gelöscht werden, warte, bis der Link benutzt wurde.
|
||||
</p>
|
||||
<?php if ($newLink !== null): ?>
|
||||
<div class="data-link-new">
|
||||
<label for="data-link-url">Neuer Link - nur jetzt sichtbar, kopier ihn und schick ihn per Discord-PN oder E-Mail:</label>
|
||||
<div class="data-link-copy">
|
||||
<input type="text" id="data-link-url" value="<?= e((string) $newLink['url']) ?>" readonly>
|
||||
<button type="button" class="button-secondary" data-copy-target="data-link-url">Kopieren</button>
|
||||
</div>
|
||||
<p class="text-muted">Gültig bis <?= e($fmt((string) $newLink['expires_at'])) ?>.</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form method="post" action="/admin/user_export_action.php">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $id ?>">
|
||||
<input type="hidden" name="action" value="create_link">
|
||||
<button type="submit"><?= icon('link') ?> Neuen Link erzeugen</button>
|
||||
</form>
|
||||
<?php if ($links): ?>
|
||||
<div class="legal-table-wrap data-links-table">
|
||||
<table>
|
||||
<thead><tr><th>Erzeugt</th><th>Gültig bis</th><th>Downloads</th><th>Status</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($links as $link): ?>
|
||||
<?php $status = data_export_link_status($link); ?>
|
||||
<tr>
|
||||
<td><?= e($fmt($link['created_at'])) ?><br><span class="text-muted"><?= e((string) ($link['created_by_name'] ?? '-')) ?></span></td>
|
||||
<td><?= e($fmt($link['expires_at'])) ?></td>
|
||||
<td><?= (int) $link['downloads'] ?> / <?= DATA_EXPORT_LINK_MAX_DOWNLOADS ?><?= $link['last_download_at'] ? '<br><span class="text-muted">zuletzt ' . e($fmt($link['last_download_at'])) . '</span>' : '' ?></td>
|
||||
<td><span class="badge <?= e($statusBadges[$status]) ?>"><?= e(ucfirst($status)) ?></span></td>
|
||||
<td>
|
||||
<?php if ($status === 'aktiv'): ?>
|
||||
<form method="post" action="/admin/user_export_action.php" class="inline-form" data-confirm="Der Link funktioniert danach nicht mehr." data-confirm-title="Link widerrufen?" data-confirm-danger data-confirm-ok="Widerrufen">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $id ?>">
|
||||
<input type="hidden" name="link_id" value="<?= (int) $link['id'] ?>">
|
||||
<input type="hidden" name="action" value="revoke_link">
|
||||
<button type="submit" class="button-secondary button-small">Widerrufen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($canDelete): ?>
|
||||
<div class="panel site-admin-section<?= $scheduled ? ' is-active' : '' ?>">
|
||||
<h2>🗑️ Konto löschen (unkenntlich machen)</h2>
|
||||
<p class="text-muted">
|
||||
Persönliches wird gelöscht (Profil, Profilbild, Charaktere, Galerie, Gear-Sets, Gruppen, Zugänge), Beiträge zur Legion
|
||||
bleiben als „<?= e(ACCOUNT_DELETED_NAME) ?>“ ohne Namen und Discord-ID erhalten. Daten beim Discord-Bot und Nachrichten im
|
||||
Log-Kanal auf Discord erfasst das nicht - die bei Bedarf dort entfernen.
|
||||
</p>
|
||||
<?php if ($scheduled): ?>
|
||||
<p><strong>Löschung beantragt:</strong> wird am <?= e($fmt($scheduled)) ?> ausgeführt. Meldet sich das Mitglied vorher an, ist sie abgebrochen.</p>
|
||||
<?php endif; ?>
|
||||
<div class="site-admin-actions">
|
||||
<?php if ($scheduled): ?>
|
||||
<form method="post" action="/admin/user_export_action.php" class="inline-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $id ?>">
|
||||
<input type="hidden" name="action" value="delete_cancel">
|
||||
<button type="submit" class="button-secondary">Löschung abbrechen</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<form method="post" action="/admin/user_export_action.php" class="inline-form" data-confirm="Das Konto wird in <?= ACCOUNT_DELETION_DAYS ?> Tagen gelöscht und sofort überall abgemeldet. Meldet es sich vorher wieder an, ist die Löschung abgebrochen." data-confirm-title="Löschung planen?" data-confirm-ok="Planen">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $id ?>">
|
||||
<input type="hidden" name="action" value="delete_schedule">
|
||||
<button type="submit" class="button-secondary">In <?= ACCOUNT_DELETION_DAYS ?> Tagen löschen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<form method="post" action="/admin/user_export_action.php" class="inline-form" data-confirm="Das lässt sich nicht rückgängig machen. Zum Bestätigen LÖSCHEN eintippen." data-confirm-title="Konto jetzt löschen?" data-confirm-danger data-confirm-ok="Jetzt löschen" data-confirm-input="confirm_word" data-confirm-placeholder="LÖSCHEN">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $id ?>">
|
||||
<input type="hidden" name="action" value="delete_now">
|
||||
<input type="hidden" name="confirm_word" value="">
|
||||
<button type="submit" class="button-danger">Jetzt löschen</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<script src="<?= e(asset_url('/assets/js/copy-button.js')) ?>"></script>
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
88
admin/user_export_action.php
Normal file
88
admin/user_export_action.php
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/** Aktionen der Seite "Daten & Löschung" (admin/user_export.php). */
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/data_export.php';
|
||||
require_permission('users.export');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
redirect('/admin/users.php');
|
||||
}
|
||||
verify_csrf();
|
||||
|
||||
$id = (int) ($_POST['id'] ?? 0);
|
||||
$target = data_export_target($id);
|
||||
if ($target === null) {
|
||||
show_not_found();
|
||||
}
|
||||
$me = current_user();
|
||||
$back = '/admin/user_export.php?id=' . $id;
|
||||
$action = (string) ($_POST['action'] ?? '');
|
||||
$deleted = (bool) (data_export_rows('SELECT deleted_at FROM users WHERE id = ?', [$id])[0]['deleted_at'] ?? null);
|
||||
if ($deleted) {
|
||||
set_flash('error', 'Dieses Konto ist schon gelöscht.');
|
||||
redirect($back);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'download':
|
||||
if (!security_throttle('export')) {
|
||||
set_flash('error', 'Gerade wurden schon mehrere Auskünfte heruntergeladen - versuch es in einer Stunde noch einmal.');
|
||||
redirect($back);
|
||||
}
|
||||
admin_log('📦 Datenauskunft heruntergeladen', ['Benutzer' => admin_log_user($id)], 'info', 'users');
|
||||
try {
|
||||
data_export_send($id);
|
||||
} catch (Throwable $e) {
|
||||
set_flash('error', 'Die Daten konnten nicht zusammengestellt werden: ' . $e->getMessage());
|
||||
redirect($back);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'create_link':
|
||||
$link = data_export_link_create($id, (int) $me['id']);
|
||||
$_SESSION['data_export_new_link'] = ['user_id' => $id] + $link;
|
||||
admin_log('🔗 Download-Link für Datenauskunft erzeugt', [
|
||||
'Benutzer' => admin_log_user($id),
|
||||
'Gültig bis' => date('d.m.Y, H:i', (int) strtotime($link['expires_at'])) . ' Uhr',
|
||||
'Downloads' => 'höchstens ' . DATA_EXPORT_LINK_MAX_DOWNLOADS,
|
||||
], 'info', 'users');
|
||||
set_flash('success', 'Link erzeugt - kopier ihn jetzt, er wird nur dieses eine Mal angezeigt.');
|
||||
redirect($back);
|
||||
|
||||
case 'revoke_link':
|
||||
$stmt = db()->prepare('UPDATE data_export_links SET revoked_at = NOW() WHERE id = ? AND user_id = ? AND revoked_at IS NULL');
|
||||
$stmt->execute([(int) ($_POST['link_id'] ?? 0), $id]);
|
||||
if ($stmt->rowCount() > 0) {
|
||||
admin_log('🔗 Download-Link für Datenauskunft widerrufen', ['Benutzer' => admin_log_user($id)], 'info', 'users');
|
||||
}
|
||||
set_flash('success', 'Link widerrufen.');
|
||||
redirect($back);
|
||||
|
||||
case 'delete_schedule':
|
||||
case 'delete_cancel':
|
||||
case 'delete_now':
|
||||
require_permission('users.delete');
|
||||
if ($id === (int) $me['id']) {
|
||||
set_flash('error', 'Dein eigenes Konto löschst du unter „Mein Profil“.');
|
||||
redirect($back);
|
||||
}
|
||||
if ($action === 'delete_schedule') {
|
||||
$due = account_deletion_request($id, $me);
|
||||
set_flash('success', 'Löschung geplant für den ' . date('d.m.Y, H:i', (int) strtotime($due)) . ' Uhr - das Konto ist überall abgemeldet.');
|
||||
} elseif ($action === 'delete_cancel') {
|
||||
account_deletion_cancel($id, 'von der Leitung abgebrochen', $me);
|
||||
set_flash('success', 'Löschung abgebrochen.');
|
||||
} else {
|
||||
if (mb_strtoupper(trim((string) ($_POST['confirm_word'] ?? ''))) !== 'LÖSCHEN') {
|
||||
set_flash('error', 'Zum Bestätigen bitte LÖSCHEN eintippen - das Konto wurde nicht gelöscht.');
|
||||
redirect($back);
|
||||
}
|
||||
account_anonymize($id, $me);
|
||||
set_flash('success', 'Konto gelöscht - es ist jetzt unkenntlich gemacht.');
|
||||
}
|
||||
redirect($back);
|
||||
|
||||
default:
|
||||
set_flash('error', 'Unbekannte Aktion.');
|
||||
redirect($back);
|
||||
}
|
||||
|
|
@ -6,11 +6,12 @@ $canCreate = user_has_permission('users.create');
|
|||
$canEdit = user_has_permission('users.edit');
|
||||
$canDelete = user_has_permission('users.delete');
|
||||
$canManageAdmins = user_has_permission('users.admin');
|
||||
$canExport = user_has_permission('users.export');
|
||||
$currentUser = current_user();
|
||||
|
||||
$users = db()->query(
|
||||
"SELECT u.id, u.username, u.display_name, u.status, u.last_login, u.created_at, u.must_change_password,
|
||||
u.password_login, u.is_admin, u.discord_id, u.discord_username,
|
||||
u.password_login, u.is_admin, u.discord_id, u.discord_username, u.deletion_scheduled_at, u.deleted_at,
|
||||
MIN(r.roster_order) AS best_rank,
|
||||
GROUP_CONCAT(COALESCE(NULLIF(r.display_name, ''), r.name) ORDER BY COALESCE(r.roster_order, 999), r.name SEPARATOR ', ') AS role_names
|
||||
FROM users u
|
||||
|
|
@ -161,7 +162,14 @@ include __DIR__ . '/../includes/header.php';
|
|||
<td><?= e($u['role_names'] ?: '-') ?></td>
|
||||
<td>
|
||||
<div class="badge-group">
|
||||
<?php if (!empty($u['deleted_at'])): ?>
|
||||
<span class="badge badge-disabled" title="Am <?= e(date('d.m.Y', (int) strtotime((string) $u['deleted_at']))) ?> gelöscht - ohne Namen und Discord-ID">Gelöscht (unkenntlich)</span>
|
||||
<?php else: ?>
|
||||
<span class="badge <?= e($statusClass) ?>"><?= e($statusLabel) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($u['deletion_scheduled_at']) && empty($u['deleted_at'])): ?>
|
||||
<span class="badge badge-disabled" title="Vom Mitglied beantragt - Anmelden bricht die Löschung ab">Löschung am <?= e(date('d.m.', (int) strtotime((string) $u['deletion_scheduled_at']))) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if ($isDevRow): ?>
|
||||
<span class="badge badge-developer" title="Entwickler der Website - hat immer alle Berechtigungen"><?= icon('code') ?> Entwickler</span>
|
||||
<?php endif; ?>
|
||||
|
|
@ -189,6 +197,9 @@ include __DIR__ . '/../includes/header.php';
|
|||
<?php if ($canEdit && !$protectedAdmin): ?>
|
||||
<a class="icon-button" href="/admin/user_form.php?id=<?= (int) $u['id'] ?>" title="Bearbeiten" aria-label="Bearbeiten"><?= icon('edit') ?></a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canExport && !$protectedAdmin): ?>
|
||||
<a class="icon-button" href="/admin/user_export.php?id=<?= (int) $u['id'] ?>" title="Daten & Löschung (Auskunft, Download-Link, Konto löschen)" aria-label="Daten und Löschung"><?= icon('archive') ?></a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canEdit && !$protectedAdmin && $u['status'] === 'active' && (int) $u['id'] !== (int) $currentUser['id']): ?>
|
||||
<?php foreach (['logout' => ['log-out', 'Abmelden erzwingen (alle Sitzungen beenden)', 'Alle Sitzungen dieses Kontos beenden?'], 'lock' => ['lock', 'Sperren und überall abmelden', 'Dieses Konto sperren und überall abmelden?']] as $secAction => [$secIcon, $secTitle, $secQuestion]): ?>
|
||||
<form class="inline-form" method="post" action="/admin/user_security.php"
|
||||
|
|
|
|||
|
|
@ -7378,3 +7378,34 @@ html.has-scroll-progress::-webkit-scrollbar { display: none; }
|
|||
.embed-consent-remember input { width: auto; margin: 0; }
|
||||
.embed-consent-image { display: inline-flex; max-width: 100%; margin: 0.25rem 0; vertical-align: middle; background: rgba(0, 0, 0, 0.25); border: 1px dashed var(--border); border-radius: 10px; }
|
||||
.embed-consent-image .embed-consent-inner { padding: 0.9rem 1rem; }
|
||||
|
||||
/* ---- Mein Profil: Konto & Daten (bewusst unauffaellig, zugeklappt) ---- */
|
||||
.account-data { margin: 2.5rem 0 1rem; }
|
||||
.account-data > summary {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
padding: 0.2rem 0.1rem;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.82rem;
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.account-data > summary::-webkit-details-marker { display: none; }
|
||||
.account-data > summary::before { content: "▸"; transition: transform 0.15s ease; }
|
||||
.account-data[open] > summary::before { transform: rotate(90deg); }
|
||||
.account-data > summary:hover { color: var(--text); opacity: 1; }
|
||||
.account-data-body { margin-top: 0.6rem; }
|
||||
.account-data-body section + section { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
|
||||
.account-data-body h2 { font-size: 1.05rem; margin: 0 0 0.35rem; }
|
||||
|
||||
/* ---- Verwaltung: Daten & Loeschung (admin/user_export.php) ---- */
|
||||
.data-admin-back { margin: 0 0 0.25rem; font-size: 0.85rem; }
|
||||
.data-link-new { margin: 0.75rem 0 1rem; padding: 0.75rem 1rem; background: rgba(76, 175, 80, 0.08); border: 1px solid rgba(76, 175, 80, 0.45); border-radius: 8px; }
|
||||
.data-link-new label { display: block; margin-bottom: 0.4rem; font-size: 0.9rem; }
|
||||
.data-link-new p { margin: 0.4rem 0 0; font-size: 0.85rem; }
|
||||
.data-link-copy { display: flex; gap: 0.5rem; }
|
||||
.data-link-copy input { flex: 1 1 auto; min-width: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.85rem; }
|
||||
.data-links-table { margin-top: 1rem; }
|
||||
.data-links-table td { vertical-align: top; font-size: 0.9rem; }
|
||||
|
|
|
|||
27
assets/js/copy-button.js
Normal file
27
assets/js/copy-button.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* Knopf "Kopieren": <button data-copy-target="id-eines-feldes"> kopiert den Inhalt des Feldes in die
|
||||
* Zwischenablage (z.B. den Download-Link der Datenauskunft in admin/user_export.php).
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
document.addEventListener('click', function (event) {
|
||||
var button = event.target.closest('[data-copy-target]');
|
||||
if (!button) return;
|
||||
var field = document.getElementById(button.getAttribute('data-copy-target'));
|
||||
if (!field) return;
|
||||
var label = button.textContent;
|
||||
var done = function () {
|
||||
button.textContent = 'Kopiert ✓';
|
||||
setTimeout(function () { button.textContent = label; }, 2000);
|
||||
};
|
||||
field.select();
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
navigator.clipboard.writeText(field.value).then(done, function () {
|
||||
if (document.execCommand('copy')) done();
|
||||
});
|
||||
} else if (document.execCommand('copy')) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
})();
|
||||
30
data_export.php
Normal file
30
data_export.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* "Meine Daten herunterladen" (Mein Profil): Datenauskunft zum eigenen Konto als ZIP -
|
||||
* siehe includes/data_export.php.
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/data_export.php';
|
||||
|
||||
$me = current_user();
|
||||
if (!$me) {
|
||||
redirect('/login.php');
|
||||
}
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
redirect('/profile.php?konto#meine-daten');
|
||||
}
|
||||
verify_csrf();
|
||||
|
||||
if (!security_throttle('export')) {
|
||||
set_flash('error', 'Du hast deine Daten gerade schon mehrmals heruntergeladen - versuch es in einer Stunde noch einmal.');
|
||||
redirect('/profile.php?konto#meine-daten');
|
||||
}
|
||||
|
||||
// Nur ins Audit-Log, nicht in den Discord-Log der Leitung - das ist die eigene Sache des Mitglieds
|
||||
audit_store('📦 Eigene Daten heruntergeladen', [], 'info', 'users');
|
||||
try {
|
||||
data_export_send((int) $me['id']);
|
||||
} catch (Throwable $e) {
|
||||
set_flash('error', 'Deine Daten konnten nicht zusammengestellt werden: ' . $e->getMessage());
|
||||
redirect('/profile.php?konto#meine-daten');
|
||||
}
|
||||
82
datenauskunft.php
Normal file
82
datenauskunft.php
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/**
|
||||
* Datenauskunft ueber einen Download-Link, den die Leitung erzeugt hat (admin/user_export.php) -
|
||||
* fuer Mitglieder, die sich nicht mehr anmelden koennen. Auch im Wartungsmodus erreichbar.
|
||||
*
|
||||
* Der Aufruf des Links zeigt nur eine Seite mit Knopf: Link-Vorschauen (Discord & Co.) rufen die
|
||||
* Adresse selbst auf und wuerden sonst einen Download verbrauchen. Erst das Absenden laedt das ZIP.
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/data_export.php';
|
||||
|
||||
// Der Schluessel steht in der Adresse - nicht als Referrer an andere Seiten weitergeben
|
||||
header('Referrer-Policy: no-referrer');
|
||||
|
||||
$token = (string) ($_POST['t'] ?? $_GET['t'] ?? '');
|
||||
$ipKey = client_ip_key();
|
||||
// Gegen Durchprobieren: hoechstens 20 ungueltige Aufrufe je IP in 15 Minuten
|
||||
$blocked = rate_limit_count('export_link_fail', $ipKey, 900) >= 20;
|
||||
$link = $blocked ? null : data_export_link_find($token);
|
||||
if ($link === null && !$blocked) {
|
||||
rate_limit_add('export_link_fail', $ipKey);
|
||||
}
|
||||
|
||||
$error = null;
|
||||
if ($link !== null && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
verify_csrf();
|
||||
db()->prepare('UPDATE data_export_links SET downloads = downloads + 1, last_download_at = NOW() WHERE id = ?')
|
||||
->execute([(int) $link['id']]);
|
||||
admin_log('📦 Datenauskunft über Download-Link heruntergeladen', [
|
||||
'Benutzer' => admin_log_user((int) $link['user_id']),
|
||||
'Download' => ((int) $link['downloads'] + 1) . ' von höchstens ' . DATA_EXPORT_LINK_MAX_DOWNLOADS,
|
||||
], 'info', 'users');
|
||||
try {
|
||||
data_export_send((int) $link['user_id']);
|
||||
} catch (Throwable $e) {
|
||||
$error = 'Die Daten konnten nicht zusammengestellt werden: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if ($link === null) {
|
||||
http_response_code(404);
|
||||
}
|
||||
$pageTitle = 'Datenauskunft';
|
||||
$publicLayout = true;
|
||||
$metaRobots = 'noindex';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<article class="panel legal-page">
|
||||
<h1>Datenauskunft</h1>
|
||||
<?php if ($link === null): ?>
|
||||
<div class="legal-missing">
|
||||
<?php if ($blocked): ?>
|
||||
Zu viele ungültige Aufrufe - bitte versuch es in 15 Minuten noch einmal.
|
||||
<?php else: ?>
|
||||
Dieser Link ist ungültig oder nicht mehr gültig. Download-Links gelten <?= DATA_EXPORT_LINK_DAYS ?> Tage
|
||||
und für höchstens <?= DATA_EXPORT_LINK_MAX_DOWNLOADS ?> Downloads. Bitte wende dich an die Legionsleitung,
|
||||
wenn du einen neuen brauchst - Kontakt im <a href="/impressum.php">Impressum</a>.
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php if ($error !== null): ?>
|
||||
<div class="flash flash-error"><?= e($error) ?></div>
|
||||
<?php endif; ?>
|
||||
<p>
|
||||
Über diesen Link lädst du alles herunter, was die Website und der Discord-Bot der Legion
|
||||
Lumina Ascendens zu deinem Konto gespeichert haben (Art. 15 und 20 DSGVO): eine ZIP-Datei mit
|
||||
einer JSON-Datei, einer Erklärung und deinen hochgeladenen Bildern.
|
||||
</p>
|
||||
<p class="text-muted">
|
||||
Der Link gilt bis <?= e(date('d.m.Y, H:i', (int) strtotime((string) $link['expires_at']))) ?> Uhr und lässt sich noch
|
||||
<?= DATA_EXPORT_LINK_MAX_DOWNLOADS - (int) $link['downloads'] ?>-mal verwenden. Gib ihn nicht weiter - wer ihn hat,
|
||||
kann die Daten herunterladen.
|
||||
</p>
|
||||
<form method="post" action="/datenauskunft.php">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="t" value="<?= e($token) ?>">
|
||||
<button type="submit"><?= icon('archive') ?> Daten herunterladen (ZIP)</button>
|
||||
</form>
|
||||
<p class="text-muted">Was mit deinen Daten passiert, steht in der <a href="/datenschutz.php">Datenschutzerklärung</a>.</p>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
* Website oder Bot verarbeiten, hier nachziehen und LEGAL_PRIVACY_UPDATED anpassen.
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/data_export.php'; // Fristen der Download-Links
|
||||
|
||||
$operator = legal_operator();
|
||||
$complete = legal_complete();
|
||||
|
|
@ -43,7 +44,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<li>Auf den öffentlichen Seiten verarbeitet nur der Webserver die technisch nötigen Zugriffsdaten.</li>
|
||||
<li>Den Mitgliederbereich nutzen Mitglieder unseres Discord-Servers - angemeldet wird über Discord.</li>
|
||||
<li>Videos von YouTube, Twitch und Vimeo sowie Bilder von fremden Servern laden erst, wenn du sie anklickst.</li>
|
||||
<li>Du kannst jederzeit Auskunft über deine Daten verlangen oder dein Konto löschen lassen - eine kurze Nachricht genügt.</li>
|
||||
<li>Deine Daten kannst du jederzeit herunterladen und dein Konto löschen - unter „Mein Profil“ → „Konto & Daten“ oder mit einer kurzen Nachricht an uns.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
@ -286,12 +287,22 @@ include __DIR__ . '/includes/header.php';
|
|||
Legion, sperrt oder löscht die Legionsleitung dein Konto; auf Wunsch löschen wir es jederzeit.
|
||||
</p>
|
||||
<p>
|
||||
Beim Löschen deines Kontos entfernen wir dein Profil samt Profilbild, Charakteren, Galerie, Kommentaren
|
||||
und Reaktionen, deine Gear-Sets, Termine, Lumipunkte und Shop-Anträge sowie deine Login- und
|
||||
Discord-Zugangsschlüssel. Erhalten bleiben Einträge, die zur gemeinsamen Geschichte der Legion gehören,
|
||||
ohne Verknüpfung zu deinem Konto: Wiki-Bearbeitungen und Taktiken, Lagerhaus-Buchungen,
|
||||
Fehlermeldungen, Raid-Anwesenheiten (mit Discord-ID und Name) sowie Einträge im Audit-Log (mit Name).
|
||||
Auf Wunsch löschen oder anonymisieren wir auch diese.
|
||||
<strong>Konto löschen:</strong> Das kannst du selbst unter „Mein Profil“ → „Konto & Daten“ (ganz unten)
|
||||
oder per Nachricht an uns. Die Löschung wird <?= ACCOUNT_DELETION_DAYS ?> Tage nach dem Antrag ausgeführt; du
|
||||
wirst sofort überall abgemeldet. Meldest du dich in dieser Zeit wieder an, ist die Löschung abgebrochen - das
|
||||
zeigen wir dir beim Anmelden an.
|
||||
</p>
|
||||
<p>
|
||||
Dabei löschen wir dein Profil samt Profilbild und Profiltext, deine Charaktere, Galeriebilder (mit den
|
||||
Kommentaren darunter), Gear-Sets, privaten Taktiken, Gruppen, Terminteilnahmen, Bilder an deinen
|
||||
Fehlermeldungen sowie deine Login- und Discord-Zugangsschlüssel. Was du zur Legion beigetragen hast -
|
||||
Kommentare, Reaktionen, Wiki-Bearbeitungen, öffentliche Taktiken, Termine, Lumipunkte, Shop-Anträge,
|
||||
Lagerhaus-Buchungen, Raid-Anwesenheiten und Fehlermeldungen - bleibt erhalten, aber ohne deinen Namen,
|
||||
deine Discord-ID und Bemerkungen wie Charakternamen; es erscheint als „<?= e(ACCOUNT_DELETED_NAME) ?>“.
|
||||
Deine eigenen Einträge im Audit-Log tragen danach keinen Namen mehr; andere Einträge, in denen du vorkommst,
|
||||
verfallen mit der regulären Löschung nach <?= AUDIT_LOG_KEEP_MONTHS ?> Monaten. Nicht automatisch erfasst werden
|
||||
deine Daten beim Discord-Bot (Raid-Anmeldungen, Premades, Aktivitätschecks) und frühere Nachrichten im
|
||||
internen Log-Kanal auf Discord - die löschen wir auf deine Anfrage.
|
||||
</p>
|
||||
<div class="legal-table-wrap">
|
||||
<table class="legal-table">
|
||||
|
|
@ -305,7 +316,8 @@ include __DIR__ . '/includes/header.php';
|
|||
<tr><td>Meldungen über Spieler im Discord-Bot</td><td>nach 10 Tagen</td></tr>
|
||||
<tr><td>Audit-Log</td><td>nach <?= AUDIT_LOG_KEEP_MONTHS ?> Monaten</td></tr>
|
||||
<tr><td>Raid-Anmeldungen, Premades und Aktivitätschecks im Discord-Bot</td><td>solange sie für die Organisation der Legion gebraucht werden, auf Wunsch sofort</td></tr>
|
||||
<tr><td>Konto und Inhalte im Mitgliederbereich</td><td>beim Löschen des Kontos (siehe oben)</td></tr>
|
||||
<tr><td>Konto und Inhalte im Mitgliederbereich</td><td><?= ACCOUNT_DELETION_DAYS ?> Tage nach dem Löschantrag (siehe oben)</td></tr>
|
||||
<tr><td>Download-Links für eine Datenauskunft</td><td>gültig <?= DATA_EXPORT_LINK_DAYS ?> Tage, Eintrag gelöscht <?= DATA_EXPORT_LINK_KEEP_DAYS ?> Tage nach Ablauf</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -322,7 +334,12 @@ include __DIR__ . '/includes/header.php';
|
|||
<li>Beschwerde bei einer Datenschutz-Aufsichtsbehörde (Art. 77 DSGVO), zum Beispiel in dem Bundesland, in dem du wohnst.</li>
|
||||
</ul>
|
||||
<p>
|
||||
Schreib uns dafür einfach <?= $operator['email'] !== '' ? 'an ' . legal_email_html($operator['email']) : 'an die Adresse aus dem Impressum' ?>
|
||||
Eine Kopie aller Daten zu deinem Konto lädst du selbst unter „Mein Profil“ → „Konto & Daten“ herunter - als
|
||||
ZIP mit einer JSON-Datei und deinen Bildern. Dort kannst du dein Konto auch löschen. Kannst du dich nicht mehr
|
||||
anmelden, schicken wir dir auf Anfrage einen persönlichen Download-Link, der <?= DATA_EXPORT_LINK_DAYS ?> Tage gilt.
|
||||
</p>
|
||||
<p>
|
||||
Für alles andere schreib uns einfach <?= $operator['email'] !== '' ? 'an ' . legal_email_html($operator['email']) : 'an die Adresse aus dem Impressum' ?>
|
||||
oder wende dich an die Legionsleitung auf Discord. Wir antworten innerhalb eines Monats.
|
||||
</p>
|
||||
<p>
|
||||
|
|
|
|||
216
includes/account_deletion.php
Normal file
216
includes/account_deletion.php
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Konto loeschen: Das Konto wird nicht entfernt, sondern unkenntlich gemacht - Persoenliches
|
||||
* (Profil, Bilder, Charaktere, Galerie, Gear-Sets, Zugaenge) wird geloescht, Beitraege zur Legion
|
||||
* (Kommentare, Wiki, Lumipunkte, Raid-Anwesenheit, Lagerhaus ...) bleiben als ACCOUNT_DELETED_NAME
|
||||
* erhalten, ohne Namen und Discord-ID.
|
||||
*
|
||||
* Ablauf: Das Mitglied beantragt die Loeschung (Mein Profil -> Konto & Daten, account_delete.php),
|
||||
* wird ueberall abgemeldet, und nach ACCOUNT_DELETION_DAYS Tagen fuehrt account_deletion_run_due()
|
||||
* sie aus (laeuft nebenbei in der bootstrap). Meldet es sich vorher wieder an, bricht
|
||||
* account_deletion_on_login() die Loeschung ab und sagt ihm das. Die Leitung kann die Loeschung
|
||||
* auch planen, abbrechen oder sofort ausfuehren (admin/user_export.php, Recht users.delete).
|
||||
*/
|
||||
|
||||
const ACCOUNT_DELETION_DAYS = 7;
|
||||
const ACCOUNT_DELETED_NAME = 'Ehemaliges Mitglied';
|
||||
// Wie oft nebenbei nach faelligen Loeschungen gesehen wird (Sekunden)
|
||||
const ACCOUNT_DELETION_CHECK_INTERVAL = 900;
|
||||
// "Wer" im Log, wenn die Frist abgelaufen ist (kein Konto - sonst stuende der zufaellige Besucher dort)
|
||||
const ACCOUNT_DELETION_SYSTEM_ACTOR = ['id' => null, 'username' => 'system', 'display_name' => 'Automatisch (Löschfrist abgelaufen)'];
|
||||
|
||||
/** Konto, das beim Anmelden bzw. im Log als "wer" steht. */
|
||||
function account_deletion_actor(int $userId): ?array
|
||||
{
|
||||
$stmt = db()->prepare('SELECT id, username, display_name, discord_id FROM users WHERE id = ?');
|
||||
$stmt->execute([$userId]);
|
||||
return $stmt->fetch() ?: null;
|
||||
}
|
||||
|
||||
/** Loeschung planen: in ACCOUNT_DELETION_DAYS Tagen, alle Sitzungen und "Angemeldet bleiben" enden. */
|
||||
function account_deletion_request(int $userId, ?array $actor = null): string
|
||||
{
|
||||
$due = date('Y-m-d H:i:s', time() + ACCOUNT_DELETION_DAYS * 86400);
|
||||
db()->prepare('UPDATE users SET deletion_scheduled_at = ?, session_epoch = session_epoch + 1 WHERE id = ? AND deleted_at IS NULL')
|
||||
->execute([$due, $userId]);
|
||||
db()->prepare('DELETE FROM auth_tokens WHERE user_id = ?')->execute([$userId]);
|
||||
$self = $actor !== null && (int) $actor['id'] === $userId;
|
||||
admin_log($self ? '🗑️ Kontolöschung beantragt' : '🗑️ Kontolöschung geplant', [
|
||||
'Konto' => admin_log_user($userId),
|
||||
'Wird ausgeführt' => date('d.m.Y, H:i', (int) strtotime($due)) . ' Uhr - Anmelden bricht sie ab',
|
||||
], 'warning', 'users', $actor);
|
||||
return $due;
|
||||
}
|
||||
|
||||
/** Geplante Loeschung abbrechen (Leitung oder Anmeldung). */
|
||||
function account_deletion_cancel(int $userId, string $reason, ?array $actor = null): void
|
||||
{
|
||||
$stmt = db()->prepare('UPDATE users SET deletion_scheduled_at = NULL WHERE id = ? AND deletion_scheduled_at IS NOT NULL AND deleted_at IS NULL');
|
||||
$stmt->execute([$userId]);
|
||||
if ($stmt->rowCount() > 0) {
|
||||
admin_log('↩️ Kontolöschung abgebrochen', ['Konto' => admin_log_user($userId), 'Grund' => $reason], 'info', 'users', $actor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Beim Anmelden (auth_login_session): Wer seine Loeschung beantragt hat und sich vor Ablauf der
|
||||
* Frist wieder anmeldet, bricht sie damit ab und bekommt das angezeigt. Ist die Frist schon
|
||||
* abgelaufen, wird das Konto jetzt geloescht und die Anmeldung beendet.
|
||||
*/
|
||||
function account_deletion_on_login(int $userId): void
|
||||
{
|
||||
try {
|
||||
$stmt = db()->prepare('SELECT deletion_scheduled_at FROM users WHERE id = ? AND deleted_at IS NULL');
|
||||
$stmt->execute([$userId]);
|
||||
$due = $stmt->fetchColumn();
|
||||
} catch (PDOException $e) {
|
||||
return; // Spalte kommt erst mit dem naechsten Schema-Abgleich
|
||||
}
|
||||
if (!is_string($due) || $due === '') {
|
||||
return;
|
||||
}
|
||||
if (strtotime($due) <= time()) {
|
||||
account_anonymize($userId, ACCOUNT_DELETION_SYSTEM_ACTOR);
|
||||
auth_force_logout('Dein Konto wurde wie beantragt gelöscht.');
|
||||
redirect('/login.php');
|
||||
}
|
||||
account_deletion_cancel($userId, 'Anmeldung vor Ablauf der Frist', account_deletion_actor($userId));
|
||||
set_flash('info', 'Du hattest die Löschung deines Kontos für den ' . date('d.m.Y', (int) strtotime($due))
|
||||
. ' beantragt. Weil du dich angemeldet hast, ist sie abgebrochen - dein Konto bleibt bestehen. Möchtest du es doch löschen, '
|
||||
. 'beantrage es unter „Mein Profil“ → „Konto & Daten“ erneut.');
|
||||
}
|
||||
|
||||
/** Faellige Loeschungen ausfuehren - laeuft nebenbei in der bootstrap, hoechstens alle 15 Minuten. */
|
||||
function account_deletion_run_due(): void
|
||||
{
|
||||
if (time() - (int) setting_get('account_deletion_checked') < ACCOUNT_DELETION_CHECK_INTERVAL) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
setting_set('account_deletion_checked', (string) time());
|
||||
$due = db()->query(
|
||||
'SELECT id FROM users WHERE deletion_scheduled_at IS NOT NULL AND deletion_scheduled_at <= NOW() AND deleted_at IS NULL'
|
||||
)->fetchAll(PDO::FETCH_COLUMN);
|
||||
} catch (PDOException $e) {
|
||||
return;
|
||||
}
|
||||
foreach ($due as $userId) {
|
||||
try {
|
||||
account_anonymize((int) $userId, ACCOUNT_DELETION_SYSTEM_ACTOR);
|
||||
} catch (Throwable $e) {
|
||||
security_log('⚠️ Kontolöschung fehlgeschlagen', ['Konto' => '#' . (int) $userId, 'Fehler' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Macht ein Konto unkenntlich. Loescht Persoenliches samt Dateien, entfernt Namen und Discord-ID
|
||||
* aus allem, was fuer die Legion bestehen bleibt. Nicht erfasst: Daten beim Discord-Bot, Nachrichten
|
||||
* im Log-Kanal auf Discord und Details anderer Audit-Log-Eintraege (die verfallen nach 12 Monaten).
|
||||
*/
|
||||
function account_anonymize(int $userId, ?array $actor = null): void
|
||||
{
|
||||
require_once __DIR__ . '/member_profile.php'; // PROFILE_UPLOAD_DIR
|
||||
require_once __DIR__ . '/bugs.php'; // BUG_UPLOAD_DIR
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('SELECT * FROM users WHERE id = ? AND deleted_at IS NULL');
|
||||
$stmt->execute([$userId]);
|
||||
$user = $stmt->fetch();
|
||||
if (!$user) {
|
||||
return;
|
||||
}
|
||||
$discordId = (string) ($user['discord_id'] ?? '');
|
||||
$ids = static function (string $sql, array $params) use ($pdo): array {
|
||||
$s = $pdo->prepare($sql);
|
||||
$s->execute($params);
|
||||
return array_map('intval', $s->fetchAll(PDO::FETCH_COLUMN));
|
||||
};
|
||||
$in = static fn (array $list): string => implode(',', array_map('intval', $list)) ?: '0';
|
||||
|
||||
// Dateien merken, geloescht werden sie erst nach dem erfolgreichen Speichern
|
||||
$files = [];
|
||||
if (!empty($user['avatar_filename'])) {
|
||||
$files[] = __DIR__ . '/../assets/uploads/avatars/' . $user['avatar_filename'];
|
||||
}
|
||||
foreach (data_rows_column($pdo, 'SELECT portrait_filename FROM member_characters WHERE user_id = ? UNION SELECT image_filename FROM member_characters WHERE user_id = ? UNION SELECT filename FROM member_gallery WHERE user_id = ?', [$userId, $userId, $userId]) as $file) {
|
||||
$files[] = PROFILE_UPLOAD_DIR . $file;
|
||||
}
|
||||
$bugIds = $ids('SELECT id FROM bug_reports WHERE user_id = ?', [$userId]);
|
||||
foreach (data_rows_column($pdo, 'SELECT filename FROM bug_report_images WHERE bug_id IN (' . $in($bugIds) . ')', []) as $file) {
|
||||
$files[] = BUG_UPLOAD_DIR . $file;
|
||||
}
|
||||
|
||||
$pdo->beginTransaction();
|
||||
try {
|
||||
// --- Persoenliches loeschen ---
|
||||
$pictureIds = $ids('SELECT id FROM member_gallery WHERE user_id = ?', [$userId]);
|
||||
$commentIds = $ids('SELECT id FROM gallery_comments WHERE gallery_id IN (' . $in($pictureIds) . ')', []);
|
||||
$pdo->exec("DELETE FROM reactions WHERE (content_type = 'picture' AND content_id IN (" . $in($pictureIds) . "))
|
||||
OR (content_type = 'comment' AND content_id IN (" . $in($commentIds) . '))');
|
||||
$pdo->exec("DELETE FROM content_reports WHERE (content_type = 'picture' AND content_id IN (" . $in($pictureIds) . "))
|
||||
OR (content_type = 'comment' AND content_id IN (" . $in($commentIds) . '))');
|
||||
foreach ([
|
||||
'DELETE FROM member_gallery WHERE user_id = ?', // Kommentare darunter per CASCADE
|
||||
'DELETE FROM member_characters WHERE user_id = ?',
|
||||
'DELETE FROM gear_sets WHERE user_id = ?', // Ausruestung, Skills, Planung per CASCADE
|
||||
'DELETE FROM user_roles WHERE user_id = ?',
|
||||
'DELETE FROM auth_tokens WHERE user_id = ?',
|
||||
'DELETE FROM wiki_contributors WHERE user_id = ?',
|
||||
'DELETE FROM calendar_participants WHERE user_id = ?',
|
||||
'DELETE FROM data_export_links WHERE user_id = ?',
|
||||
"DELETE FROM tactic_revisions WHERE owner_id = ? AND visibility = 'private'",
|
||||
"DELETE FROM tactics WHERE created_by = ? AND visibility = 'private'", // Schritte und Zeichnungen per CASCADE
|
||||
] as $sql) {
|
||||
$pdo->prepare($sql)->execute([$userId]);
|
||||
}
|
||||
// Bilder an Fehlermeldungen zeigen oft den Namen (Screenshot der Website) - Text bleibt
|
||||
$pdo->exec('DELETE FROM bug_report_images WHERE bug_id IN (' . $in($bugIds) . ')');
|
||||
|
||||
// --- Was bleibt: ohne Namen und ohne Hinweise auf die Person ---
|
||||
$pdo->prepare('UPDATE bug_reports SET user_agent = NULL, screenshot_url = NULL WHERE user_id = ?')->execute([$userId]);
|
||||
$pdo->prepare('UPDATE shop_orders SET note = NULL WHERE user_id = ?')->execute([$userId]); // oft der Charaktername
|
||||
$pdo->prepare('UPDATE warehouse_movements SET counterpart_name = NULL WHERE counterpart_user_id = ?')->execute([$userId]);
|
||||
$pdo->prepare('UPDATE audit_log SET actor_name = ? WHERE user_id = ?')->execute([ACCOUNT_DELETED_NAME, $userId]);
|
||||
if ($discordId !== '') {
|
||||
// Anwesenheit bleibt fuer Lumipunkte und Statistik - statt der Discord-ID die Konto-Nummer
|
||||
// (echte Discord-IDs sind 17-19 Stellen lang, das kann nie kollidieren)
|
||||
$pdo->prepare('UPDATE raid_attendance SET discord_id = ?, name = ? WHERE discord_id = ?')
|
||||
->execute([$userId, ACCOUNT_DELETED_NAME, $discordId]);
|
||||
}
|
||||
|
||||
$pdo->prepare(
|
||||
"UPDATE users SET username = CONCAT('geloescht-', id), display_name = ?, password_hash = ?, password_login = 0,
|
||||
must_change_password = 0, is_admin = 0, status = 'disabled', session_epoch = session_epoch + 1,
|
||||
discord_id = NULL, discord_username = NULL, discord_access_token = NULL, discord_refresh_token = NULL,
|
||||
discord_token_expires = NULL, discord_synced_at = NULL, discord_joined_at = NULL,
|
||||
class_name = NULL, classes = NULL, main_class = NULL, profile_bio = NULL, profile_background = NULL,
|
||||
gallery_comments_enabled = 0, avatar_filename = NULL, avatar_sync = 0, discord_avatar = NULL,
|
||||
tour_completed_at = NULL, sidebar_order = NULL, patchnotes_seen = NULL, announcement_dismissed = NULL,
|
||||
last_login = NULL, last_seen_at = NULL, deletion_scheduled_at = NULL, deleted_at = NOW()
|
||||
WHERE id = ?"
|
||||
)->execute([ACCOUNT_DELETED_NAME, password_hash(bin2hex(random_bytes(24)), PASSWORD_DEFAULT), $userId]);
|
||||
$pdo->commit();
|
||||
} catch (Throwable $e) {
|
||||
$pdo->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
foreach ($files as $path) {
|
||||
$name = basename($path);
|
||||
if ($name !== '' && strpbrk($name, '/\\') === false && is_file($path)) {
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
// Ohne Namen - sonst stuende er wieder im Log
|
||||
admin_log('🗑️ Konto gelöscht (unkenntlich gemacht)', ['Konto' => '#' . $userId, 'Bilder gelöscht' => (string) count($files)], 'warning', 'users', $actor);
|
||||
}
|
||||
|
||||
/** Erste Spalte einer Abfrage als Liste von Texten (leere Werte weg). */
|
||||
function data_rows_column(PDO $pdo, string $sql, array $params): array
|
||||
{
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
return array_values(array_filter(array_map('strval', $stmt->fetchAll(PDO::FETCH_COLUMN)), static fn (string $v): bool => $v !== ''));
|
||||
}
|
||||
|
|
@ -86,6 +86,8 @@ function auth_login_session(int $userId, string $method): void
|
|||
|
||||
db()->prepare('UPDATE users SET last_login = NOW() WHERE id = ?')->execute([$userId]);
|
||||
auth_remember_issue($userId, $method, (int) $_SESSION['session_epoch']);
|
||||
// Beantragte Kontoloeschung: Anmelden vor Ablauf der Frist bricht sie ab (includes/account_deletion.php)
|
||||
account_deletion_on_login($userId);
|
||||
}
|
||||
|
||||
function require_login(): void
|
||||
|
|
|
|||
|
|
@ -38,10 +38,14 @@ require_once __DIR__ . '/security.php';
|
|||
require_once __DIR__ . '/moderation.php';
|
||||
require_once __DIR__ . '/patchnotes.php';
|
||||
require_once __DIR__ . '/legal.php';
|
||||
require_once __DIR__ . '/account_deletion.php';
|
||||
require_once __DIR__ . '/site_notice.php';
|
||||
|
||||
ensure_schema();
|
||||
|
||||
// Beantragte Kontoloeschungen, deren Frist abgelaufen ist, ausfuehren (hoechstens alle 15 Minuten)
|
||||
account_deletion_run_due();
|
||||
|
||||
// Sitzung abgelaufen, aber "angemeldet bleiben"-Cookie da: wieder anmelden (includes/auth.php)
|
||||
auth_remember_restore();
|
||||
|
||||
|
|
|
|||
502
includes/data_export.php
Normal file
502
includes/data_export.php
Normal file
|
|
@ -0,0 +1,502 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Datenauskunft (Art. 15 und 20 DSGVO): alles, was Website und Discord-Bot zu einem Konto
|
||||
* gespeichert haben, als ZIP mit daten.json, LIESMICH.txt und den eigenen hochgeladenen Bildern.
|
||||
*
|
||||
* - Mitglieder laden ihre Daten selbst herunter: Mein Profil -> data_export.php.
|
||||
* - Die Leitung (Recht users.export) laedt die Daten eines Mitglieds herunter oder erzeugt einen
|
||||
* Download-Link fuer jemanden, der sich nicht mehr anmelden kann: admin/user_export.php, der Link
|
||||
* fuehrt auf datenauskunft.php. Gespeichert wird nur der Hash des Links (wie bei auth_tokens).
|
||||
*
|
||||
* Bewusst nicht enthalten: Passwort-Hash sowie Discord- und Login-Schluessel (Sicherheit) und
|
||||
* Meldungen ueber die Person im Discord-Bot - darin steht, wer gemeldet hat; die gibt die Leitung
|
||||
* nur auf Anfrage und ohne die Meldenden heraus.
|
||||
*
|
||||
* Das ZIP baut data_export_zip() selbst (ohne die PHP-Erweiterung zip, die nicht ueberall da ist).
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/member_profile.php'; // PROFILE_UPLOAD_DIR (Charaktere, Galerie)
|
||||
require_once __DIR__ . '/bugs.php'; // BUG_UPLOAD_DIR
|
||||
require_once __DIR__ . '/raids_api.php';
|
||||
require_once __DIR__ . '/events_api.php';
|
||||
require_once __DIR__ . '/activity_api.php';
|
||||
|
||||
const DATA_EXPORT_LINK_DAYS = 7;
|
||||
const DATA_EXPORT_LINK_MAX_DOWNLOADS = 5;
|
||||
// Eintraege abgelaufener Links bleiben so lange zur Nachvollziehbarkeit, dann werden sie geloescht
|
||||
const DATA_EXPORT_LINK_KEEP_DAYS = 30;
|
||||
// So viele der neuesten Aktivitaetschecks werden nach Antworten durchsucht (je Check eine Anfrage beim Bot)
|
||||
const DATA_EXPORT_ACTIVITY_CHECKS = 60;
|
||||
|
||||
/** Abfrage fuer die Auskunft - schlaegt sie fehl (z.B. Tabelle fehlt), bleibt der Abschnitt leer. */
|
||||
function data_export_rows(string $sql, array $params = []): array
|
||||
{
|
||||
try {
|
||||
$stmt = db()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
return $stmt->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/** Spalten entfernen, die nur intern sind (Fremdschluessel aufs eigene Konto, Sortierung). */
|
||||
function data_export_strip(array $rows, array $columns): array
|
||||
{
|
||||
return array_map(static function (array $row) use ($columns): array {
|
||||
foreach ($columns as $column) {
|
||||
unset($row[$column]);
|
||||
}
|
||||
return $row;
|
||||
}, $rows);
|
||||
}
|
||||
|
||||
/** Datei aus einem Upload-Ordner (nur ein Dateiname, kein Pfad) oder null. */
|
||||
function data_export_file(string $dir, ?string $filename): ?string
|
||||
{
|
||||
$filename = (string) $filename;
|
||||
if ($filename === '' || strpbrk($filename, '/\\') !== false || !is_file($dir . $filename)) {
|
||||
return null;
|
||||
}
|
||||
return $dir . $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Konto fuer die Auskunft durch die Leitung - null, wenn es fehlt oder geschuetzt ist
|
||||
* (Administratoren nur mit users.admin, Entwickler nur fuer Entwickler - wie in der Benutzerverwaltung).
|
||||
*/
|
||||
function data_export_target(int $userId): ?array
|
||||
{
|
||||
$rows = data_export_rows('SELECT id, username, display_name, status, is_admin, discord_id, avatar_filename FROM users WHERE id = ?', [$userId]);
|
||||
$target = $rows[0] ?? null;
|
||||
if ($target === null) {
|
||||
return null;
|
||||
}
|
||||
if (!empty($target['is_admin']) && !user_has_permission('users.admin')) {
|
||||
return null;
|
||||
}
|
||||
if (is_developer($target) && !is_developer(current_user())) {
|
||||
return null;
|
||||
}
|
||||
return $target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle Daten eines Kontos.
|
||||
*
|
||||
* @return array{data: array<string, mixed>, files: array<string, string>, name: string} files: Pfad im ZIP => Datei
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
function data_export_collect(int $userId): array
|
||||
{
|
||||
$account = data_export_rows('SELECT * FROM users WHERE id = ?', [$userId])[0] ?? null;
|
||||
if ($account === null) {
|
||||
throw new RuntimeException('Das Konto gibt es nicht (mehr).');
|
||||
}
|
||||
// Zugangsdaten gehoeren nicht in eine Datei, die man herumschickt
|
||||
foreach (['password_hash', 'discord_access_token', 'discord_refresh_token', 'discord_token_expires', 'session_epoch', 'discord_avatar'] as $secret) {
|
||||
unset($account[$secret]);
|
||||
}
|
||||
$discordId = (string) ($account['discord_id'] ?? '');
|
||||
$account['discord_id'] = $discordId !== '' ? $discordId : null; // als Text - 19 Stellen sind fuer JSON-Zahlen zu lang
|
||||
$files = [];
|
||||
|
||||
$avatar = data_export_file(__DIR__ . '/../assets/uploads/avatars/', $account['avatar_filename'] ?? null);
|
||||
if ($avatar !== null) {
|
||||
$account['datei_im_export'] = 'bilder/profilbild.' . strtolower(pathinfo($avatar, PATHINFO_EXTENSION));
|
||||
$files[$account['datei_im_export']] = $avatar;
|
||||
}
|
||||
|
||||
$characters = data_export_strip(data_export_rows('SELECT * FROM member_characters WHERE user_id = ? ORDER BY sort_order, id', [$userId]), ['user_id']);
|
||||
foreach ($characters as &$character) {
|
||||
foreach (['portrait_filename' => 'portrait', 'image_filename' => 'bild'] as $column => $suffix) {
|
||||
$path = data_export_file(PROFILE_UPLOAD_DIR, $character[$column] ?? null);
|
||||
if ($path !== null) {
|
||||
$character['datei_' . $suffix] = 'bilder/charaktere/' . $character['id'] . '-' . $suffix . '.' . strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
$files[$character['datei_' . $suffix]] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($character);
|
||||
|
||||
$gallery = data_export_strip(data_export_rows('SELECT * FROM member_gallery WHERE user_id = ? ORDER BY sort_order, id', [$userId]), ['user_id']);
|
||||
foreach ($gallery as &$picture) {
|
||||
$path = data_export_file(PROFILE_UPLOAD_DIR, $picture['filename'] ?? null);
|
||||
if ($path !== null) {
|
||||
$picture['datei_im_export'] = 'bilder/galerie/' . $picture['id'] . '.' . strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
$files[$picture['datei_im_export']] = $path;
|
||||
}
|
||||
}
|
||||
unset($picture);
|
||||
|
||||
$gearSets = data_export_strip(data_export_rows('SELECT * FROM gear_sets WHERE user_id = ? ORDER BY sort_order, id', [$userId]), ['user_id']);
|
||||
foreach ($gearSets as &$set) {
|
||||
$set['ausruestung'] = data_export_rows(
|
||||
'SELECT s.slot, i.name AS gegenstand, s.item_id, s.enchant, s.exceed, s.soul_imprint, s.manastones, s.godstone
|
||||
FROM gear_set_slots s LEFT JOIN gear_items i ON i.id = s.item_id WHERE s.set_id = ? ORDER BY s.slot',
|
||||
[$set['id']]
|
||||
);
|
||||
$set['skills'] = data_export_rows(
|
||||
"SELECT k.id AS skill_id, COALESCE(NULLIF(k.name_de, ''), k.name) AS skill, k.kind, s.level, s.specs
|
||||
FROM gear_set_skills s JOIN gear_skills k ON k.id = s.skill_id WHERE s.set_id = ? ORDER BY k.kind, k.sort_order",
|
||||
[$set['id']]
|
||||
);
|
||||
$set['planung'] = [];
|
||||
foreach (data_export_rows('SELECT section, data, updated_at FROM gear_set_plans WHERE set_id = ?', [$set['id']]) as $plan) {
|
||||
$set['planung'][$plan['section']] = json_decode((string) $plan['data'], true) ?? $plan['data'];
|
||||
}
|
||||
}
|
||||
unset($set);
|
||||
|
||||
$bugs = data_export_strip(data_export_rows('SELECT * FROM bug_reports WHERE user_id = ? ORDER BY id', [$userId]), ['user_id', 'handled_by']);
|
||||
foreach ($bugs as &$bug) {
|
||||
$bug['bilder'] = [];
|
||||
foreach (data_export_rows('SELECT filename FROM bug_report_images WHERE bug_id = ? ORDER BY id', [$bug['id']]) as $i => $image) {
|
||||
$path = data_export_file(BUG_UPLOAD_DIR, $image['filename']);
|
||||
if ($path !== null) {
|
||||
$name = 'bilder/fehlermeldungen/' . $bug['id'] . '-' . ($i + 1) . '.' . strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
$bug['bilder'][] = $name;
|
||||
$files[$name] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($bug);
|
||||
|
||||
$points = data_export_rows(
|
||||
'SELECT a.awarded_at, a.category, a.title, a.note, e.points
|
||||
FROM contribution_entries e JOIN contribution_awards a ON a.id = e.award_id WHERE e.user_id = ? ORDER BY a.awarded_at, a.id',
|
||||
[$userId]
|
||||
);
|
||||
|
||||
$data = [
|
||||
'auskunft' => [
|
||||
'erstellt_am' => date('Y-m-d H:i:s'),
|
||||
'zeitzone' => date_default_timezone_get(),
|
||||
'website' => site_url('/'),
|
||||
'verantwortlich' => legal_operator()['name'],
|
||||
'hinweis' => 'Datenauskunft nach Art. 15 und Art. 20 DSGVO. Was in den einzelnen Abschnitten steht, erklärt LIESMICH.txt.',
|
||||
],
|
||||
'konto' => $account,
|
||||
'gruppen' => array_column(data_export_rows(
|
||||
"SELECT COALESCE(NULLIF(r.display_name, ''), r.name) AS gruppe FROM user_roles ur JOIN roles r ON r.id = ur.role_id WHERE ur.user_id = ? ORDER BY r.name",
|
||||
[$userId]
|
||||
), 'gruppe'),
|
||||
'charaktere' => $characters,
|
||||
'galerie' => $gallery,
|
||||
'kommentare' => data_export_strip(data_export_rows('SELECT * FROM gallery_comments WHERE author_id = ? ORDER BY id', [$userId]), ['author_id']),
|
||||
'reaktionen' => data_export_strip(data_export_rows('SELECT * FROM reactions WHERE user_id = ? ORDER BY id', [$userId]), ['user_id', 'id']),
|
||||
'gemeldete_inhalte' => data_export_strip(data_export_rows('SELECT * FROM content_reports WHERE reporter_id = ? ORDER BY id', [$userId]), ['reporter_id']),
|
||||
'gear_sets' => $gearSets,
|
||||
'kalender_termine' => data_export_strip(data_export_rows('SELECT * FROM calendar_entries WHERE user_id = ? ORDER BY starts_at', [$userId]), ['user_id']),
|
||||
'kalender_teilnahmen' => data_export_rows(
|
||||
'SELECT e.id AS termin_id, e.title, e.starts_at, p.created_at AS angemeldet_am
|
||||
FROM calendar_participants p JOIN calendar_entries e ON e.id = p.entry_id WHERE p.user_id = ? ORDER BY e.starts_at',
|
||||
[$userId]
|
||||
),
|
||||
'lumipunkte' => ['summe' => array_sum(array_map('intval', array_column($points, 'points'))), 'verlauf' => $points],
|
||||
'shop_antraege' => data_export_strip(data_export_rows('SELECT * FROM shop_orders WHERE user_id = ? ORDER BY id', [$userId]), ['user_id', 'decided_by', 'delivered_by', 'award_id', 'warehouse_movement_id']),
|
||||
'lagerhaus' => data_export_rows(
|
||||
"SELECT m.occurred_at, IF(m.direction = 'in', 'von dir an die Legion', 'von der Legion an dich') AS richtung,
|
||||
i.name AS gegenstand, m.quantity, m.note
|
||||
FROM warehouse_movements m JOIN warehouse_items i ON i.id = m.item_id WHERE m.counterpart_user_id = ? ORDER BY m.occurred_at",
|
||||
[$userId]
|
||||
),
|
||||
'raid_anwesenheit' => $discordId === '' ? [] : array_map(static function (array $row): array {
|
||||
$row['raid_id'] = (string) $row['raid_id'];
|
||||
return $row;
|
||||
}, data_export_rows('SELECT raid_id, name, status, updated_at FROM raid_attendance WHERE discord_id = ? ORDER BY updated_at', [$discordId])),
|
||||
'wiki' => [
|
||||
'mitwirkend_seit' => data_export_rows('SELECT added_at FROM wiki_contributors WHERE user_id = ?', [$userId])[0]['added_at'] ?? null,
|
||||
'angelegte_seiten' => data_export_rows('SELECT title, slug, created_at FROM wiki_pages WHERE created_by = ? ORDER BY created_at', [$userId]),
|
||||
'bearbeitungen' => data_export_rows(
|
||||
'SELECT r.title AS titel_damals, p.title AS seite_heute, r.summary, r.created_at
|
||||
FROM wiki_revisions r LEFT JOIN wiki_pages p ON p.id = r.page_id WHERE r.edited_by = ? ORDER BY r.created_at',
|
||||
[$userId]
|
||||
),
|
||||
],
|
||||
'taktiken' => data_export_rows('SELECT id, map_slug, name, description, visibility, highlight, created_at, updated_at FROM tactics WHERE created_by = ? ORDER BY id', [$userId]),
|
||||
'fehlermeldungen' => $bugs,
|
||||
'angemeldete_geraete' => data_export_rows('SELECT login_method, user_agent, created_at, last_used_at, expires_at FROM auth_tokens WHERE user_id = ? ORDER BY created_at', [$userId]),
|
||||
// Verwaltungsaktionen, die das Konto selbst ausgefuehrt hat - ohne Details, darin stehen oft andere Mitglieder
|
||||
'protokoll_eigene_aktionen' => data_export_rows('SELECT created_at, area, title, ip FROM audit_log WHERE user_id = ? ORDER BY id', [$userId]),
|
||||
'discord_bot' => data_export_bot($discordId),
|
||||
];
|
||||
|
||||
return ['data' => $data, 'files' => $files, 'name' => (string) $account['username']];
|
||||
}
|
||||
|
||||
/**
|
||||
* Was der Discord-Bot zur Discord-ID gespeichert hat - ueber dieselbe Bot-API wie die Seiten
|
||||
* Raids, Premades, Events und Aktivitaetscheck. Ist der Bot nicht erreichbar, steht das im Abschnitt.
|
||||
*/
|
||||
function data_export_bot(string $discordId): array
|
||||
{
|
||||
if ($discordId === '') {
|
||||
return ['hinweis' => 'Kein Discord-Konto verknüpft - beim Discord-Bot ist zu diesem Konto nichts gespeichert.'];
|
||||
}
|
||||
$out = [
|
||||
'hinweis' => 'Meldungen über dich (Reports) sind nicht enthalten, weil darin steht, wer gemeldet hat. Auf Anfrage bekommst du sie von der Legionsleitung ohne die Namen der Meldenden; der Bot löscht sie nach 10 Tagen.',
|
||||
'raid_anmeldungen' => [],
|
||||
'premades' => [],
|
||||
'events_angelegt' => [],
|
||||
'aktivitaetschecks' => [],
|
||||
];
|
||||
$errors = [];
|
||||
|
||||
try {
|
||||
foreach (fetch_raids('all') as $raid) {
|
||||
foreach ((array) ($raid['signups'] ?? []) as $signup) {
|
||||
if ((string) ($signup['user_id'] ?? '') === $discordId) {
|
||||
$out['raid_anmeldungen'][] = [
|
||||
'raid_id' => (string) ($raid['raid_id'] ?? ''),
|
||||
'titel' => $raid['title'] ?? '',
|
||||
'termin' => $raid['date'] ?? (isset($raid['timestamp']) ? date('Y-m-d H:i', (int) $raid['timestamp']) : null),
|
||||
'name' => $signup['name'] ?? '',
|
||||
'klasse' => $signup['class'] ?? '',
|
||||
'gruppe' => $signup['group'] ?? null,
|
||||
'abgemeldet' => (int) ($signup['group'] ?? 0) === -1,
|
||||
'raid_archiviert' => !empty($raid['archived']),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
$errors[] = 'Raids: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
foreach (fetch_premades() as $premade) {
|
||||
$isOwner = (string) ($premade['owner_id'] ?? '') === $discordId;
|
||||
$mine = null; // nur der eigene Eintrag, nicht die anderen Mitglieder
|
||||
foreach ((array) ($premade['members'] ?? []) as $member) {
|
||||
if ((string) ($member['user_id'] ?? '') === $discordId) {
|
||||
$mine = $member;
|
||||
}
|
||||
}
|
||||
if ($isOwner || $mine !== null) {
|
||||
$out['premades'][] = [
|
||||
'id' => $premade['id'] ?? null,
|
||||
'name' => $premade['name'] ?? '',
|
||||
'rolle' => $isOwner ? 'Gründer' : 'Mitglied',
|
||||
'status' => $mine['status'] ?? null,
|
||||
'klasse' => $mine['class'] ?? ($isOwner ? ($premade['owner_class'] ?? null) : null),
|
||||
];
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
$errors[] = 'Premades: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
foreach (fetch_events() as $event) {
|
||||
if ((string) ($event['created_by'] ?? '') === $discordId) {
|
||||
$out['events_angelegt'][] = ['name' => $event['name'] ?? '', 'nachricht' => $event['message'] ?? '', 'kanal' => $event['channel_name'] ?? null,
|
||||
'naechster_termin' => $event['next_run'] ?? null, 'wiederholung_sekunden' => $event['interval_seconds'] ?? null];
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
$errors[] = 'Events: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
$checks = activity_api_request('GET', '', ['guild_id' => events_guild_id()])['checks'] ?? [];
|
||||
usort($checks, static fn (array $a, array $b): int => (int) ($b['check_id'] ?? 0) <=> (int) ($a['check_id'] ?? 0));
|
||||
foreach (array_slice($checks, 0, DATA_EXPORT_ACTIVITY_CHECKS) as $check) {
|
||||
$detail = isset($check['responses']) ? $check : (activity_api_request('GET', '/' . (int) ($check['check_id'] ?? 0))['check'] ?? []);
|
||||
$answer = null;
|
||||
foreach ((array) ($detail['responses'] ?? []) as $response) {
|
||||
if ((string) ($response['user_id'] ?? '') === $discordId) {
|
||||
unset($response['user_id']);
|
||||
$answer = $response;
|
||||
}
|
||||
}
|
||||
if ($answer === null) {
|
||||
$waiting = array_merge((array) ($detail['pending'] ?? []), (array) ($detail['result']['missing'] ?? []));
|
||||
foreach ($waiting as $row) {
|
||||
if ((string) ($row['user_id'] ?? '') === $discordId) {
|
||||
$answer = ['status' => ($detail['status'] ?? '') === 'open' ? 'noch keine Antwort' : 'keine Antwort'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($answer !== null) {
|
||||
$out['aktivitaetschecks'][] = ['check_id' => $detail['check_id'] ?? null, 'titel' => $detail['title'] ?? '', 'frist' => $detail['deadline'] ?? null,
|
||||
'status_check' => $detail['status'] ?? null, 'deine_antwort' => $answer];
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
$errors[] = 'Aktivitätschecks: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
if ($errors) {
|
||||
$out['fehler'] = array_merge(['Der Discord-Bot war nicht vollständig erreichbar - diese Teile fehlen. Lade die Auskunft später noch einmal herunter.'], $errors);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/** Erklaerung, die als LIESMICH.txt im ZIP liegt. */
|
||||
function data_export_readme(array $export): string
|
||||
{
|
||||
$lines = [
|
||||
'Datenauskunft - Lumina Ascendens',
|
||||
'Erstellt am ' . date('d.m.Y \u\m H:i \U\h\r'),
|
||||
'',
|
||||
'Diese Datei gehört zu deiner Datenauskunft nach Art. 15 und Art. 20 DSGVO. Sie enthält alles, was die Website',
|
||||
'der Legion und unser Discord-Bot zu deinem Konto gespeichert haben.',
|
||||
'',
|
||||
'daten.json - alle Angaben in einem gängigen, maschinenlesbaren Format (JSON, UTF-8). Die Abschnitte:',
|
||||
' konto dein Konto: Name, Discord-Verknüpfung, Klassen, Profiltext, Anmeldungen, Einstellungen',
|
||||
' gruppen deine Berechtigungsgruppen',
|
||||
' charaktere, galerie deine Charaktere und Galeriebilder (Bilder im Ordner bilder/)',
|
||||
' kommentare, reaktionen was du unter Galeriebildern geschrieben bzw. mit welchem Emoji du reagiert hast',
|
||||
' gemeldete_inhalte Inhalte, die du gemeldet hast',
|
||||
' gear_sets deine Ausrüstungssets samt Skills und Planung',
|
||||
' kalender_* Termine, die du eingetragen hast, und deine Teilnahmen',
|
||||
' lumipunkte Punktestand und jede Vergabe bzw. jeder Abzug',
|
||||
' shop_antraege deine Anträge im Lumishop',
|
||||
' lagerhaus Übergaben zwischen dir und der Legion',
|
||||
' raid_anwesenheit deine eingetragene Anwesenheit bei Raids',
|
||||
' wiki, taktiken Wiki-Seiten und -Bearbeitungen sowie Taktiken von dir',
|
||||
' fehlermeldungen deine Fehlermeldungen samt Bildern und Browser-Kennung',
|
||||
' angemeldete_geraete wo du über „Angemeldet bleiben“ angemeldet bist (Browser-Kennung)',
|
||||
' protokoll_eigene_aktionen Verwaltungsaktionen, die du ausgeführt hast (Audit-Log, IP gekürzt)',
|
||||
' discord_bot beim Discord-Bot: Raid-Anmeldungen, Premades, von dir angelegte Events, Aktivitätschecks',
|
||||
'',
|
||||
'Nicht enthalten sind Passwort-Hash und Zugangsschlüssel (aus Sicherheitsgründen) sowie Meldungen über dich im',
|
||||
'Discord-Bot, weil darin steht, wer gemeldet hat. Die bekommst du auf Anfrage ohne die Namen der Meldenden.',
|
||||
'',
|
||||
'Zeitangaben sind deutsche Zeit (' . date_default_timezone_get() . ').',
|
||||
'Fragen, Berichtigung oder Löschung: siehe ' . site_url('/datenschutz.php') . ' und ' . site_url('/impressum.php'),
|
||||
];
|
||||
if ($export['files']) {
|
||||
$lines[] = '';
|
||||
$lines[] = 'Enthaltene Bilder: ' . count($export['files']);
|
||||
}
|
||||
return implode("\r\n", $lines) . "\r\n";
|
||||
}
|
||||
|
||||
/** DOS-Zeit und -Datum fuer ZIP-Eintraege. */
|
||||
function data_export_dos_time(int $timestamp): array
|
||||
{
|
||||
$d = getdate($timestamp);
|
||||
return [
|
||||
($d['hours'] << 11) | ($d['minutes'] << 5) | intdiv($d['seconds'], 2),
|
||||
((max(1980, $d['year']) - 1980) << 9) | ($d['mon'] << 5) | $d['mday'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut ein ZIP in einen temporaeren Stream (grosse Archive landen auf der Platte statt im Speicher).
|
||||
* Texte werden komprimiert, Bilder unveraendert gespeichert (sind schon komprimiert).
|
||||
*
|
||||
* @param array<string, string> $texts Name im ZIP => Inhalt
|
||||
* @param array<string, string> $files Name im ZIP => Datei auf dem Server
|
||||
* @return resource
|
||||
*/
|
||||
function data_export_zip(array $texts, array $files)
|
||||
{
|
||||
$out = fopen('php://temp/maxmemory:' . (8 * 1024 * 1024), 'w+b');
|
||||
[$time, $date] = data_export_dos_time(time());
|
||||
$central = '';
|
||||
$count = 0;
|
||||
$add = static function (string $name, string $content, bool $deflate) use ($out, $time, $date, &$central, &$count): void {
|
||||
$crc = crc32($content);
|
||||
$packed = $deflate ? (string) gzdeflate($content, 6) : $content;
|
||||
$method = $deflate ? 8 : 0;
|
||||
$flags = 0x0800; // Dateinamen in UTF-8
|
||||
$offset = (int) ftell($out);
|
||||
fwrite($out, pack('VvvvvvVVVvv', 0x04034b50, 20, $flags, $method, $time, $date, $crc, strlen($packed), strlen($content), strlen($name), 0) . $name);
|
||||
fwrite($out, $packed);
|
||||
$central .= pack('VvvvvvvVVVvvvvvVV', 0x02014b50, 20, 20, $flags, $method, $time, $date, $crc, strlen($packed), strlen($content),
|
||||
strlen($name), 0, 0, 0, 0, 0, $offset) . $name;
|
||||
$count++;
|
||||
};
|
||||
foreach ($texts as $name => $content) {
|
||||
$add($name, $content, true);
|
||||
}
|
||||
foreach ($files as $name => $path) {
|
||||
$content = @file_get_contents($path);
|
||||
if ($content !== false) {
|
||||
$add($name, $content, false);
|
||||
}
|
||||
}
|
||||
$centralOffset = (int) ftell($out);
|
||||
fwrite($out, $central);
|
||||
fwrite($out, pack('VvvvvVVv', 0x06054b50, 0, 0, $count, $count, strlen($central), $centralOffset, 0));
|
||||
rewind($out);
|
||||
return $out;
|
||||
}
|
||||
|
||||
/** Stellt die Auskunft zusammen und schickt sie als ZIP-Download. Beendet den Aufruf. */
|
||||
function data_export_send(int $userId): void
|
||||
{
|
||||
$export = data_export_collect($userId);
|
||||
$json = (string) json_encode($export['data'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
$zip = data_export_zip(['daten.json' => $json, 'LIESMICH.txt' => data_export_readme($export)], $export['files']);
|
||||
$slug = trim((string) preg_replace('/[^a-z0-9_-]+/i', '-', $export['name']), '-') ?: 'konto';
|
||||
|
||||
session_write_close();
|
||||
while (ob_get_level() > 0) {
|
||||
ob_end_clean();
|
||||
}
|
||||
header('Content-Type: application/zip');
|
||||
header('Content-Disposition: attachment; filename="lumina-ascendens-daten-' . $slug . '-' . date('Y-m-d') . '.zip"');
|
||||
header('Content-Length: ' . (int) (fstat($zip)['size'] ?? 0));
|
||||
header('Cache-Control: no-store');
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
fpassthru($zip);
|
||||
fclose($zip);
|
||||
exit;
|
||||
}
|
||||
|
||||
// ---- Download-Links fuer Mitglieder ohne Zugang ----
|
||||
|
||||
/**
|
||||
* Neuer Link fuer ein Konto. Die Adresse steht nirgends gespeichert (nur ihr Hash) - wer den Link
|
||||
* verschicken will, muss ihn gleich kopieren.
|
||||
*
|
||||
* @return array{url: string, expires_at: string}
|
||||
*/
|
||||
function data_export_link_create(int $userId, int $createdBy): array
|
||||
{
|
||||
data_export_links_cleanup();
|
||||
$token = bin2hex(random_bytes(24));
|
||||
$expires = date('Y-m-d H:i:s', time() + DATA_EXPORT_LINK_DAYS * 86400);
|
||||
db()->prepare('INSERT INTO data_export_links (user_id, token_hash, created_by, expires_at) VALUES (?, ?, ?, ?)')
|
||||
->execute([$userId, hash('sha256', $token), $createdBy, $expires]);
|
||||
return ['url' => site_url('/datenauskunft.php?t=' . $token), 'expires_at' => $expires];
|
||||
}
|
||||
|
||||
/** Gueltiger Link zu einem Token (nicht abgelaufen, nicht widerrufen, Downloads uebrig) oder null. */
|
||||
function data_export_link_find(string $token): ?array
|
||||
{
|
||||
if (!preg_match('/^[0-9a-f]{48}$/', $token)) {
|
||||
return null;
|
||||
}
|
||||
$link = data_export_rows('SELECT * FROM data_export_links WHERE token_hash = ?', [hash('sha256', $token)])[0] ?? null;
|
||||
return $link !== null && data_export_link_status($link) === 'aktiv' ? $link : null;
|
||||
}
|
||||
|
||||
/** aktiv, widerrufen, aufgebraucht oder abgelaufen. */
|
||||
function data_export_link_status(array $link): string
|
||||
{
|
||||
if ($link['revoked_at'] !== null) {
|
||||
return 'widerrufen';
|
||||
}
|
||||
if ((int) $link['downloads'] >= DATA_EXPORT_LINK_MAX_DOWNLOADS) {
|
||||
return 'aufgebraucht';
|
||||
}
|
||||
return strtotime((string) $link['expires_at']) > time() ? 'aktiv' : 'abgelaufen';
|
||||
}
|
||||
|
||||
/** Eintraege von Links loeschen, die seit DATA_EXPORT_LINK_KEEP_DAYS abgelaufen sind. */
|
||||
function data_export_links_cleanup(): void
|
||||
{
|
||||
try {
|
||||
db()->prepare('DELETE FROM data_export_links WHERE expires_at < ?')
|
||||
->execute([date('Y-m-d H:i:s', time() - DATA_EXPORT_LINK_KEEP_DAYS * 86400)]);
|
||||
} catch (PDOException $e) {
|
||||
// Tabelle kommt erst mit dem naechsten Schema-Abgleich
|
||||
}
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ $isResetActive = $currentScript === 'reset.php';
|
|||
$isModerationActive = $currentScript === 'moderation.php';
|
||||
$isSiteActive = $currentScript === 'site.php';
|
||||
$isLegalActive = $currentScript === 'legal.php';
|
||||
$isUsersActive = in_array($currentScript, ['users.php', 'user_form.php', 'user_delete.php', 'user_approve.php'], true);
|
||||
$isUsersActive = in_array($currentScript, ['users.php', 'user_form.php', 'user_delete.php', 'user_approve.php', 'user_export.php'], true);
|
||||
$isRolesActive = in_array($currentScript, ['roles.php', 'role_form.php', 'role_delete.php'], true);
|
||||
|
||||
// Jeder Bereich bekommt ein eigenes, dezentes Hintergrundbild.
|
||||
|
|
@ -125,6 +125,7 @@ $pageBackgrounds = [
|
|||
'users.php' => 'bg-admin',
|
||||
'user_form.php' => 'bg-admin',
|
||||
'user_delete.php' => 'bg-admin',
|
||||
'user_export.php' => 'bg-admin',
|
||||
'roles.php' => 'bg-roles',
|
||||
'role_form.php' => 'bg-roles',
|
||||
'role_delete.php' => 'bg-roles',
|
||||
|
|
|
|||
|
|
@ -19,6 +19,16 @@ const PATCHNOTE_TYPES = [
|
|||
];
|
||||
|
||||
const PATCHNOTES = [
|
||||
[
|
||||
'id' => '2026-09-24-e',
|
||||
'date' => '2026-09-24',
|
||||
'title' => 'Datenauskunft und Kontolöschung',
|
||||
'summary' => 'Anfragen nach der DSGVO lassen sich jetzt direkt auf der Website erledigen.',
|
||||
'changes' => [
|
||||
['type' => 'neu', 'area' => 'Verwaltung', 'text' => 'Benutzerverwaltung → Symbol „Daten & Löschung“ (Recht users.export): alle Daten eines Mitglieds als ZIP herunterladen oder einen Download-Link erzeugen, der 7 Tage bzw. 5 Downloads gilt - für alle, die sich nicht mehr anmelden können. Mit users.delete lässt sich das Konto dort auch löschen (sofort oder in 7 Tagen).', 'audience' => 'leitung'],
|
||||
['type' => 'neu', 'area' => 'Verwaltung', 'text' => 'Mitglieder finden beides selbst unter „Mein Profil“ ganz unten (zugeklappt: „Konto & Daten“). Eine beantragte Löschung läuft nach 7 Tagen; meldet sich das Mitglied vorher an, ist sie abgebrochen. Gelöscht wird Persönliches, Beiträge bleiben als „Ehemaliges Mitglied“ ohne Namen und Discord-ID. Die Benutzerverwaltung zeigt „Löschung am …“ bzw. „Gelöscht“.', 'audience' => 'leitung'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => '2026-09-24-d',
|
||||
'date' => '2026-09-24',
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ const CORE_PERMISSIONS = [
|
|||
['key' => 'users.edit', 'description' => 'Benutzer bearbeiten'],
|
||||
['key' => 'users.delete', 'description' => 'Benutzer löschen'],
|
||||
['key' => 'users.admin', 'description' => 'Einzelnen Benutzern Administrator-Rechte (alle Berechtigungen) geben oder entziehen und Administratoren bearbeiten'],
|
||||
['key' => 'users.export', 'description' => 'Datenauskunft: alle gespeicherten Daten eines Mitglieds herunterladen und Download-Links für Mitglieder ohne Zugang erzeugen'],
|
||||
['key' => 'roles.manage', 'description' => 'Berechtigungsgruppen verwalten'],
|
||||
['key' => 'roles.assign', 'description' => 'Alle Berechtigungsgruppen an Benutzer vergeben und entziehen (einzelne Gruppen: roles.assign.<ID>)'],
|
||||
['key' => 'raids.view', 'description' => 'Raids einsehen'],
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
||||
const SCHEMA_VERSION = 43;
|
||||
const SCHEMA_VERSION = 44;
|
||||
|
||||
/**
|
||||
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
||||
|
|
@ -616,6 +616,24 @@ CREATE TABLE IF NOT EXISTS calendar_participants (
|
|||
FOREIGN KEY (entry_id) REFERENCES calendar_entries(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
// Download-Links fuer die Datenauskunft (includes/data_export.php, datenauskunft.php)
|
||||
'data_export_links' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS data_export_links (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
-- Nur der SHA-256-Hash - den Link selbst sieht nur, wer ihn erzeugt
|
||||
token_hash CHAR(64) NOT NULL UNIQUE,
|
||||
created_by INT UNSIGNED NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
expires_at DATETIME NOT NULL,
|
||||
downloads INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
last_download_at DATETIME NULL,
|
||||
revoked_at DATETIME NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_data_export_links_user (user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
'content_reports' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS content_reports (
|
||||
|
|
@ -653,6 +671,9 @@ function schema_column_upgrades(): array
|
|||
'highlighted_at' => "ALTER TABLE tactics ADD COLUMN highlighted_at DATETIME NULL AFTER highlighted_by",
|
||||
],
|
||||
'users' => [
|
||||
// Kontoloeschung (includes/account_deletion.php): beantragt bis / ausgefuehrt (unkenntlich gemacht) am
|
||||
'deletion_scheduled_at' => "ALTER TABLE users ADD COLUMN deletion_scheduled_at DATETIME NULL AFTER last_seen_at",
|
||||
'deleted_at' => "ALTER TABLE users ADD COLUMN deleted_at DATETIME NULL AFTER deletion_scheduled_at",
|
||||
// Zuletzt gelesene Patchnote (includes/patchnotes.php) - leer: "Neu" in der Seitenleiste
|
||||
'patchnotes_seen' => "ALTER TABLE users ADD COLUMN patchnotes_seen VARCHAR(20) NULL AFTER sidebar_order",
|
||||
// Weggeklickte Ankuendigung (includes/site_notice.php)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ const SECURITY_LIMITS = [
|
|||
'calendar' => [8, 3600], // eigene Kalender-Termine pro Konto
|
||||
'bug' => [5, 3600], // Fehlermeldungen pro Konto
|
||||
'discord_sync' => [10, 3600], // "Jetzt mit Discord abgleichen" im Profil pro Konto (dazu hoechstens alle 30 s)
|
||||
'export' => [6, 3600], // Datenauskunft herunterladen (eigene oder fuer andere) pro Konto
|
||||
'login_ip' => [15, 900], // fehlgeschlagene Logins pro IP (egal welches Konto)
|
||||
'login_pair' => [5, 900], // fehlgeschlagene Logins pro IP + Benutzername
|
||||
'destructive' => [20, 600], // Loeschungen pro Konto, danach automatische Sperre
|
||||
|
|
@ -137,7 +138,7 @@ function audit_store(string $title, array $fields, string $tone, ?string $area =
|
|||
db()->prepare(
|
||||
'INSERT INTO audit_log (user_id, actor_name, area, title, details, tone, ip) VALUES (?, ?, ?, ?, ?, ?, ?)'
|
||||
)->execute([
|
||||
$actor ? (int) $actor['id'] : null,
|
||||
!empty($actor['id']) ? (int) $actor['id'] : null, // ohne id: System (z.B. abgelaufene Loeschfrist)
|
||||
mb_substr($actorName, 0, 100),
|
||||
$area ?? audit_area_for_script((string) ($_SERVER['SCRIPT_NAME'] ?? '')),
|
||||
mb_substr($title, 0, 256),
|
||||
|
|
@ -233,6 +234,7 @@ function security_bucket_label(string $bucket): string
|
|||
'calendar' => 'Kalender-Termine',
|
||||
'bug' => 'Fehlermeldungen',
|
||||
'discord_sync' => 'Discord-Abgleich im Profil',
|
||||
'export' => 'Datenauskunft herunterladen',
|
||||
'destructive' => 'Löschungen',
|
||||
][$bucket] ?? $bucket;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const ANNOUNCEMENT_LEVELS = [
|
|||
// Datenschutzerklaerung muessen staendig verfuegbar sein.
|
||||
const MAINTENANCE_ALLOWED_SCRIPTS = [
|
||||
'login.php', 'logout.php', 'discord_login.php', 'discord_callback.php', 'bot_api.php', 'install.php',
|
||||
'impressum.php', 'datenschutz.php',
|
||||
'impressum.php', 'datenschutz.php', 'datenauskunft.php',
|
||||
];
|
||||
|
||||
function maintenance_active(): bool
|
||||
|
|
|
|||
40
profile.php
40
profile.php
|
|
@ -340,4 +340,44 @@ document.getElementById('avatar-upload-input').addEventListener('change', functi
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<?php // Datenauskunft und Kontoloeschung - bewusst unauffaellig zugeklappt ganz unten (data_export.php, account_delete.php) ?>
|
||||
<details class="account-data" id="konto-und-daten"<?= isset($_GET['konto']) ? ' open' : '' ?>>
|
||||
<summary>Konto & Daten</summary>
|
||||
<div class="panel account-data-body">
|
||||
<section id="meine-daten">
|
||||
<h2>Meine Daten herunterladen</h2>
|
||||
<p class="text-muted">
|
||||
Alles, was die Website und der Discord-Bot zu deinem Konto gespeichert haben - als ZIP mit einer JSON-Datei,
|
||||
einer Erklärung und deinen hochgeladenen Bildern (Art. 15 und 20 DSGVO).
|
||||
</p>
|
||||
<form method="post" action="/data_export.php" class="inline-form">
|
||||
<?= csrf_field() ?>
|
||||
<button type="submit" class="button-secondary"><?= icon('archive') ?> Meine Daten herunterladen</button>
|
||||
</form>
|
||||
</section>
|
||||
<section id="konto-loeschen">
|
||||
<h2>Konto löschen</h2>
|
||||
<?php if (!empty($user['is_admin']) || is_developer($user)): ?>
|
||||
<p class="text-muted">Als Administrator kannst du dein Konto nicht selbst löschen - lass dir zuerst die Administrator-Rechte entziehen.</p>
|
||||
<?php else: ?>
|
||||
<p class="text-muted">
|
||||
Die Löschung wird <?= ACCOUNT_DELETION_DAYS ?> Tage nach dem Antrag ausgeführt; du wirst sofort abgemeldet. Meldest du
|
||||
dich in dieser Zeit wieder an, ist sie abgebrochen. Gelöscht werden dein Profil, Profilbild, Charaktere, Galerie,
|
||||
Gear-Sets und deine Zugänge. Was du zur Legion beigetragen hast - Kommentare, Wiki-Bearbeitungen, Lumipunkte,
|
||||
Raid-Anwesenheiten und Ähnliches - bleibt ohne deinen Namen als „<?= e(ACCOUNT_DELETED_NAME) ?>“ erhalten.
|
||||
Lade vorher deine Daten herunter, wenn du sie behalten möchtest.
|
||||
</p>
|
||||
<form method="post" action="/account_delete.php" class="inline-form"
|
||||
data-confirm="Dein Konto wird in <?= ACCOUNT_DELETION_DAYS ?> Tagen gelöscht und du wirst jetzt abgemeldet. Zum Bestätigen LÖSCHEN eintippen."
|
||||
data-confirm-title="Konto löschen?" data-confirm-danger data-confirm-ok="Löschung beantragen"
|
||||
data-confirm-input="confirm_word" data-confirm-placeholder="LÖSCHEN">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="confirm_word" value="">
|
||||
<button type="submit" class="button-danger">Konto löschen …</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
|
|||
|
|
@ -56,7 +56,10 @@ CREATE TABLE IF NOT EXISTS users (
|
|||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_login DATETIME NULL,
|
||||
-- Zuletzt aktiv auf der Website (hoechstens alle paar Minuten aktualisiert)
|
||||
last_seen_at DATETIME NULL
|
||||
last_seen_at DATETIME NULL,
|
||||
-- Kontoloeschung (includes/account_deletion.php): beantragt bis / ausgefuehrt (unkenntlich gemacht) am
|
||||
deletion_scheduled_at DATETIME NULL,
|
||||
deleted_at DATETIME NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS roles (
|
||||
|
|
@ -761,3 +764,20 @@ CREATE TABLE IF NOT EXISTS activity_settings (
|
|||
result VARCHAR(255) NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Download-Links fuer die Datenauskunft (includes/data_export.php, datenauskunft.php)
|
||||
CREATE TABLE IF NOT EXISTS data_export_links (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
-- Nur der SHA-256-Hash - den Link selbst sieht nur, wer ihn erzeugt
|
||||
token_hash CHAR(64) NOT NULL UNIQUE,
|
||||
created_by INT UNSIGNED NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
expires_at DATETIME NOT NULL,
|
||||
downloads INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
last_download_at DATETIME NULL,
|
||||
revoked_at DATETIME NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_data_export_links_user (user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
|
|
|||
Loading…
Reference in a new issue