- impressum.php (§ 18 MStV) and datenschutz.php, which describes what the website and the Discord bot actually process: Discord login scopes, member area, bot data (raids, premades, player reports with the automatic 48 h timeout, activity checks), cookies and browser storage keys, retention periods and rights. Both stay reachable in maintenance mode and are noindex. Operator data defaults to the c/o address of the Impressum service Online-Impressum.de (LEGAL_OPERATOR_DEFAULT), the hoster to Living-Bots; both can be changed under Admin -> Impressum & Datenschutz (new permission site.legal, schema v43). The audit/Discord log only records which fields changed, not the name or address. - Links in the footer of all public pages, the start page footer, the sidebar and the maintenance page, plus a short data notice on the login page. - Wiki and profile texts: YouTube, Twitch and Vimeo players and images or video files from other servers render as placeholders and load only after a click (embed_consent_html(), assets/js/embed-consent.js). "immer direkt laden" is remembered per provider in localStorage and can be reset in the privacy policy. Image URLs are now protected from inline formatting (e.g. _underscores_ in the address). - map_frame.php only serves logged-in, active members. - Deleting a user also removes the avatar file; audit_log entries older than 12 months are deleted automatically (AUDIT_LOG_KEEP_MONTHS). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
3.3 KiB
PHP
84 lines
3.3 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../includes/bootstrap.php';
|
|
require_permission('users.delete');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
redirect('/admin/users.php');
|
|
}
|
|
|
|
verify_csrf();
|
|
|
|
$id = (int) ($_POST['id'] ?? 0);
|
|
$currentUser = current_user();
|
|
|
|
if ($id === (int) $currentUser['id']) {
|
|
set_flash('error', 'Du kannst deinen eigenen Account nicht löschen.');
|
|
redirect('/admin/users.php');
|
|
}
|
|
|
|
// Administratoren darf nur loeschen, wer selbst Administratoren verwalten darf.
|
|
$adminStmt = db()->prepare('SELECT is_admin, discord_id, avatar_filename FROM users WHERE id = ?');
|
|
$adminStmt->execute([$id]);
|
|
$target = $adminStmt->fetch() ?: ['is_admin' => 0, 'discord_id' => null, 'avatar_filename' => null];
|
|
if (is_developer($target) && !is_developer($currentUser)) {
|
|
set_flash('error', 'Das Konto des Entwicklers kann nicht gelöscht werden.');
|
|
redirect('/admin/users.php');
|
|
}
|
|
if ((int) $target['is_admin'] === 1 && !user_has_permission('users.admin')) {
|
|
set_flash('error', 'Administratoren kann nur löschen, wer die Berechtigung users.admin hat.');
|
|
redirect('/admin/users.php');
|
|
}
|
|
|
|
$deletedName = admin_log_user($id);
|
|
// Was mit dem Konto verloren geht - fuers Audit-Log
|
|
try {
|
|
$infoStmt = db()->prepare(
|
|
"SELECT u.username, u.status,
|
|
(SELECT GROUP_CONCAT(COALESCE(NULLIF(r.display_name, ''), r.name) ORDER BY r.name SEPARATOR ', ')
|
|
FROM user_roles ur JOIN roles r ON r.id = ur.role_id WHERE ur.user_id = u.id) AS roles
|
|
FROM users u WHERE u.id = ?"
|
|
);
|
|
$infoStmt->execute([$id]);
|
|
$deletedInfo = $infoStmt->fetch() ?: [];
|
|
} catch (PDOException $e) {
|
|
$deletedInfo = [];
|
|
}
|
|
|
|
// Bilder der Profilseite (Charaktere, Galerie) mit entfernen - die Datenbankzeilen fallen
|
|
// per ON DELETE CASCADE weg, die Dateien nicht.
|
|
require_once __DIR__ . '/../includes/member_profile.php';
|
|
try {
|
|
$files = db()->prepare(
|
|
'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 = ?'
|
|
);
|
|
$files->execute([$id, $id, $id]);
|
|
$profileFiles = $files->fetchAll(PDO::FETCH_COLUMN);
|
|
} catch (PDOException $e) {
|
|
$profileFiles = [];
|
|
}
|
|
$stmt = db()->prepare('DELETE FROM users WHERE id = ?');
|
|
$stmt->execute([$id]);
|
|
if ($stmt->rowCount() > 0) {
|
|
foreach ($profileFiles as $file) {
|
|
profile_delete_file($file);
|
|
}
|
|
// Auch das Profilbild (hochgeladen oder von Discord kopiert) - sonst bliebe es auf dem Server liegen
|
|
$avatarFile = (string) ($target['avatar_filename'] ?? '');
|
|
$avatarPath = __DIR__ . '/../assets/uploads/avatars/' . $avatarFile;
|
|
if ($avatarFile !== '' && strpos($avatarFile, '/') === false && strpos($avatarFile, '\\') === false && is_file($avatarPath)) {
|
|
@unlink($avatarPath);
|
|
}
|
|
admin_log('🗑️ Benutzer gelöscht', [
|
|
'Benutzer' => $deletedName,
|
|
'Benutzername' => (string) ($deletedInfo['username'] ?? ''),
|
|
'Status' => (string) ($deletedInfo['status'] ?? ''),
|
|
'Gruppen' => (string) ($deletedInfo['roles'] ?? ''),
|
|
'Administrator' => !empty($target['is_admin']) ? 'ja' : '',
|
|
'Profilbilder gelöscht' => $profileFiles ? (string) count($profileFiles) : '',
|
|
], 'danger');
|
|
}
|
|
|
|
set_flash('success', 'Benutzer wurde gelöscht.');
|
|
redirect('/admin/users.php');
|