- 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>
88 lines
3.6 KiB
PHP
88 lines
3.6 KiB
PHP
<?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);
|
|
}
|