LuminaWebsite/account_delete.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

34 lines
1.4 KiB
PHP

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