- 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>
163 lines
9.3 KiB
PHP
163 lines
9.3 KiB
PHP
<?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'; ?>
|