LuminaWebsite/datenauskunft.php
Maaxxs cd8716e791 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>
2026-09-24 17:02:42 +02:00

82 lines
3.8 KiB
PHP

<?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'; ?>