- Sidebar: number of upcoming raids next to "Raids" (all not archived, same as the dashboard
tile). Gold while a raid was posted since the last visit of the raid page (users.raids_seen_at,
schema v46; the posting time comes from the raid id = Discord message id). New raids are
marked "Neu" on the raid page, also in live updates; your own new raid is not. The raid ids
are cached in settings.raids_nav_cache: every raid fetch refreshes it, otherwise the sidebar
asks the bot after 5 minutes with a 3 s timeout and keeps the last state if it is down.
- Start page: the group photo alternates every 6 s with gallery pictures that members released
themselves ("Auf der Startseite zeigen", member_gallery.show_on_home, schema v47) - without
name or caption, only visible pictures of active members, with a pause button, only while
the photo is in view. Only the member can release a picture; leadership can only take it off
(logged).
- Dashboard: the tiles "Mitglieder" and "Berechtigungsgruppen" link to the user management and
the roles, like "Anstehende Raids".
- Tour: new steps for gallery, calendar, gear planner and patch notes; menu customization,
profile page, daily reward and the raid count mentioned.
- Privacy policy (activity, start page, withdrawal), account anonymization (resets
raids_seen_at), README and patch notes updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
318 lines
17 KiB
PHP
318 lines
17 KiB
PHP
<?php
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
require_once __DIR__ . '/includes/member_profile.php';
|
|
require_permission('members.view');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
redirect('/members.php');
|
|
}
|
|
// Zu grosse Uploads leeren $_POST komplett - dann fehlt auch das CSRF-Token.
|
|
if (empty($_POST) && (int) ($_SERVER['CONTENT_LENGTH'] ?? 0) > 0) {
|
|
set_flash('error', 'Die Dateien waren zu groß für den Server. Bitte weniger oder kleinere Bilder auf einmal hochladen.');
|
|
redirect('/member_edit.php');
|
|
}
|
|
verify_csrf();
|
|
|
|
$action = (string) ($_POST['action'] ?? '');
|
|
$userId = (int) ($_POST['user_id'] ?? 0);
|
|
$me = current_user();
|
|
if (!profile_can_edit($userId)) {
|
|
set_flash('error', 'Du darfst nur deine eigene Profilseite bearbeiten.');
|
|
redirect('/member.php?id=' . $userId);
|
|
}
|
|
$pdo = db();
|
|
$back = '/member_edit.php?id=' . $userId;
|
|
// Aenderungen der Leitung an fremden Profilen gehoeren ins Discord-Log (Moderation).
|
|
$moderating = (int) $me['id'] !== $userId;
|
|
$modLog = static function (string $what) use ($moderating, $userId): void {
|
|
if ($moderating) {
|
|
admin_log('🧑 Profilseite eines Mitglieds bearbeitet (Leitung)', ['Mitglied' => admin_log_user($userId), 'Änderung' => $what], 'warning');
|
|
}
|
|
};
|
|
|
|
switch ($action) {
|
|
case 'bio_save':
|
|
$bio = trim(str_replace("\r\n", "\n", (string) ($_POST['profile_bio'] ?? '')));
|
|
if (mb_strlen($bio) > PROFILE_MAX_BIO) {
|
|
set_flash('error', 'Der Text ist zu lang (höchstens ' . number_format(PROFILE_MAX_BIO, 0, ',', '.') . ' Zeichen).');
|
|
redirect($back);
|
|
}
|
|
$pdo->prepare('UPDATE users SET profile_bio = ? WHERE id = ?')->execute([$bio !== '' ? $bio : null, $userId]);
|
|
$modLog('Text „Über mich“ geändert');
|
|
set_flash('success', 'Gespeichert.');
|
|
redirect($back);
|
|
|
|
case 'character_save':
|
|
$characterId = (int) ($_POST['character_id'] ?? 0);
|
|
$existing = null;
|
|
if ($characterId > 0) {
|
|
$stmt = $pdo->prepare('SELECT * FROM member_characters WHERE id = ? AND user_id = ?');
|
|
$stmt->execute([$characterId, $userId]);
|
|
$existing = $stmt->fetch();
|
|
if (!$existing) {
|
|
set_flash('error', 'Diesen Charakter gibt es nicht mehr.');
|
|
redirect($back);
|
|
}
|
|
} else {
|
|
$count = $pdo->prepare('SELECT COUNT(*) FROM member_characters WHERE user_id = ?');
|
|
$count->execute([$userId]);
|
|
if ((int) $count->fetchColumn() >= PROFILE_MAX_CHARACTERS) {
|
|
set_flash('error', 'Mehr als ' . PROFILE_MAX_CHARACTERS . ' Charaktere gehen nicht.');
|
|
redirect($back);
|
|
}
|
|
}
|
|
|
|
$name = trim((string) ($_POST['name'] ?? ''));
|
|
if ($name === '' || mb_strlen($name) > 60) {
|
|
set_flash('error', 'Bitte einen Namen mit höchstens 60 Zeichen angeben.');
|
|
redirect($back);
|
|
}
|
|
$class = in_array($_POST['class_name'] ?? '', AION_CLASSES, true) ? $_POST['class_name'] : null;
|
|
$levelInput = trim((string) ($_POST['level'] ?? ''));
|
|
$level = filter_var($levelInput, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'max_range' => PROFILE_MAX_LEVEL]]) ?: null;
|
|
if ($levelInput !== '' && $level === null) {
|
|
set_flash('error', 'Die Stufe muss zwischen 1 und ' . PROFILE_MAX_LEVEL . ' liegen.');
|
|
redirect($back);
|
|
}
|
|
$note = mb_substr(trim((string) ($_POST['note'] ?? '')), 0, 255);
|
|
$isMain = !empty($_POST['is_main']) ? 1 : 0;
|
|
|
|
$portrait = $existing['portrait_filename'] ?? null;
|
|
$image = $existing['image_filename'] ?? null;
|
|
// Erst beide neuen Bilder speichern; scheitert eines, das andere wieder wegraeumen,
|
|
// damit weder halbe Aenderungen noch verwaiste Dateien entstehen.
|
|
$newPortrait = null;
|
|
$newImage = null;
|
|
try {
|
|
if (($_FILES['portrait']['error'] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_NO_FILE) {
|
|
$newPortrait = profile_store_upload($_FILES['portrait'], 'char' . $userId . 'p', 600);
|
|
}
|
|
if (($_FILES['image']['error'] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_NO_FILE) {
|
|
$newImage = profile_store_upload($_FILES['image'], 'char' . $userId . 'i', 1600);
|
|
}
|
|
} catch (RuntimeException $e) {
|
|
profile_delete_file($newPortrait);
|
|
profile_delete_file($newImage);
|
|
set_flash('error', $e->getMessage());
|
|
redirect($back);
|
|
}
|
|
if ($newPortrait !== null || !empty($_POST['remove_portrait'])) {
|
|
profile_delete_file($portrait);
|
|
$portrait = $newPortrait;
|
|
}
|
|
if ($newImage !== null || !empty($_POST['remove_image'])) {
|
|
profile_delete_file($image);
|
|
$image = $newImage;
|
|
}
|
|
|
|
// Nur ein Hauptcharakter pro Mitglied
|
|
if ($isMain) {
|
|
$pdo->prepare('UPDATE member_characters SET is_main = 0 WHERE user_id = ?')->execute([$userId]);
|
|
}
|
|
if ($existing) {
|
|
$pdo->prepare(
|
|
'UPDATE member_characters SET name = ?, class_name = ?, level = ?, note = ?, portrait_filename = ?, image_filename = ?, is_main = ? WHERE id = ?'
|
|
)->execute([$name, $class, $level, $note !== '' ? $note : null, $portrait, $image, $isMain, $characterId]);
|
|
$modLog('Charakter „' . $name . '“ bearbeitet');
|
|
set_flash('success', '„' . $name . '“ gespeichert.');
|
|
} else {
|
|
$order = $pdo->prepare('SELECT COALESCE(MAX(sort_order), 0) + 10 FROM member_characters WHERE user_id = ?');
|
|
$order->execute([$userId]);
|
|
$pdo->prepare(
|
|
'INSERT INTO member_characters (user_id, name, class_name, level, note, portrait_filename, image_filename, is_main, sort_order)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
|
)->execute([$userId, $name, $class, $level, $note !== '' ? $note : null, $portrait, $image, $isMain, (int) $order->fetchColumn()]);
|
|
$modLog('Charakter „' . $name . '“ angelegt');
|
|
set_flash('success', '„' . $name . '“ angelegt.');
|
|
}
|
|
redirect($back);
|
|
|
|
case 'character_delete':
|
|
$stmt = $pdo->prepare('SELECT * FROM member_characters WHERE id = ? AND user_id = ?');
|
|
$stmt->execute([(int) ($_POST['character_id'] ?? 0), $userId]);
|
|
$character = $stmt->fetch();
|
|
if ($character) {
|
|
$pdo->prepare('DELETE FROM member_characters WHERE id = ?')->execute([(int) $character['id']]);
|
|
profile_delete_file($character['portrait_filename']);
|
|
profile_delete_file($character['image_filename']);
|
|
$modLog('Charakter „' . $character['name'] . '“ gelöscht');
|
|
set_flash('success', '„' . $character['name'] . '“ gelöscht.');
|
|
}
|
|
redirect($back);
|
|
|
|
case 'gallery_upload':
|
|
$count = $pdo->prepare('SELECT COUNT(*), COALESCE(MAX(sort_order), 0) FROM member_gallery WHERE user_id = ? AND is_background = 0');
|
|
$count->execute([$userId]);
|
|
[$existingCount, $order] = array_map('intval', $count->fetch(PDO::FETCH_NUM));
|
|
$caption = mb_substr(trim((string) ($_POST['caption'] ?? '')), 0, 150);
|
|
|
|
// $_FILES['images'] kommt spaltenweise (name[], tmp_name[] ...) - in Einzeldateien umbauen.
|
|
$files = [];
|
|
foreach ((array) ($_FILES['images']['error'] ?? []) as $i => $error) {
|
|
$files[] = [
|
|
'error' => $error,
|
|
'size' => $_FILES['images']['size'][$i] ?? 0,
|
|
'tmp_name' => $_FILES['images']['tmp_name'][$i] ?? '',
|
|
];
|
|
}
|
|
if (moderation_blocks($caption, 'Bildunterschrift (Galerie)')) {
|
|
set_flash('error', 'Die Bildunterschrift enthält ein Wort, das hier nicht erlaubt ist.');
|
|
redirect($back);
|
|
}
|
|
$uploadCount = count(array_filter($files, static fn (array $f): bool => $f['error'] !== UPLOAD_ERR_NO_FILE));
|
|
if ($uploadCount > 0 && !security_throttle('upload', $uploadCount)) {
|
|
set_flash('error', 'Du hast in den letzten Minuten schon sehr viele Bilder hochgeladen. Bitte warte ein paar Minuten.');
|
|
redirect($back);
|
|
}
|
|
$added = 0;
|
|
$errors = [];
|
|
// Neue Mitglieder, Links in der Bildunterschrift oder "Alles manuell": erst nach Freigabe sichtbar
|
|
[$status, $moderationNote] = moderation_initial_status('picture', $caption);
|
|
// Fuer die oeffentliche Startseite gibt nur das Mitglied selbst frei (Einwilligung), nie die Leitung
|
|
$showOnHome = !$moderating && !empty($_POST['show_on_home']) ? 1 : 0;
|
|
$insert = $pdo->prepare('INSERT INTO member_gallery (user_id, filename, caption, status, moderation_note, sort_order, show_on_home) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
|
foreach ($files as $file) {
|
|
if ($file['error'] === UPLOAD_ERR_NO_FILE) {
|
|
continue;
|
|
}
|
|
if ($existingCount + $added >= PROFILE_MAX_GALLERY) {
|
|
$errors[] = 'Die Galerie ist voll (' . PROFILE_MAX_GALLERY . ' Bilder).';
|
|
break;
|
|
}
|
|
try {
|
|
$filename = profile_store_upload($file, 'gal' . $userId, 1920);
|
|
$order += 10;
|
|
$insert->execute([$userId, $filename, $caption !== '' ? $caption : null, $status, $moderationNote, $order, $showOnHome]);
|
|
$added++;
|
|
} catch (RuntimeException $e) {
|
|
$errors[] = $e->getMessage();
|
|
}
|
|
}
|
|
if ($added > 0) {
|
|
set_flash('success', ($added === 1 ? 'Bild hochgeladen.' : $added . ' Bilder hochgeladen.')
|
|
. ($status === 'pending' ? ' Sichtbar für alle nach einer kurzen Freigabe durch die Moderation.' : ''));
|
|
}
|
|
foreach (array_unique($errors) as $error) {
|
|
set_flash('error', $error);
|
|
}
|
|
$modLog($added . ' Bild(er) in die Galerie hochgeladen');
|
|
redirect($back);
|
|
|
|
case 'background_save':
|
|
$choice = (string) ($_POST['background'] ?? '');
|
|
$value = null;
|
|
if (preg_match('/^preset:(landscape\d+)$/', $choice, $m) && in_array($m[1], PROFILE_BACKGROUND_PRESETS, true)) {
|
|
$value = $choice;
|
|
} elseif (preg_match('/^gallery:(\d+)$/', $choice, $m)) {
|
|
$own = $pdo->prepare("SELECT COUNT(*) FROM member_gallery WHERE id = ? AND user_id = ? AND (status = 'visible' OR is_background = 1)");
|
|
$own->execute([(int) $m[1], $userId]);
|
|
if ((int) $own->fetchColumn() === 0) {
|
|
set_flash('error', 'Dieses Bild kann nicht als Hintergrund dienen (nicht in deiner Galerie oder noch nicht freigegeben).');
|
|
redirect($back . '#hintergrund');
|
|
}
|
|
$value = $choice;
|
|
}
|
|
$pdo->prepare('UPDATE users SET profile_background = ? WHERE id = ?')->execute([$value, $userId]);
|
|
$modLog('Hintergrund der Profilseite geändert');
|
|
set_flash('success', $value === null ? 'Hintergrund zurückgesetzt.' : 'Hintergrund gespeichert.');
|
|
redirect($back . '#hintergrund');
|
|
|
|
case 'background_upload':
|
|
// Eigenes Bild nur fuer den Hintergrund: kommt nicht in die Galerie, geht aber durch dieselbe
|
|
// Moderation (neue Mitglieder / "alles manuell" -> erst nach Freigabe sichtbar).
|
|
$file = $_FILES['background_image'] ?? null;
|
|
if (!security_throttle('upload')) {
|
|
set_flash('error', 'Du hast in den letzten Minuten schon sehr viele Bilder hochgeladen. Bitte warte ein paar Minuten.');
|
|
redirect($back . '#hintergrund');
|
|
}
|
|
try {
|
|
$filename = profile_store_upload(is_array($file) ? $file : null, 'bg' . $userId, 2560);
|
|
} catch (RuntimeException $e) {
|
|
set_flash('error', $e->getMessage());
|
|
redirect($back . '#hintergrund');
|
|
}
|
|
[$status, $moderationNote] = moderation_initial_status('picture');
|
|
// Es gibt hoechstens ein eigenes Hintergrundbild - das alte faellt weg
|
|
profile_background_image_delete($userId);
|
|
$pdo->prepare('INSERT INTO member_gallery (user_id, filename, status, moderation_note, is_background) VALUES (?, ?, ?, ?, 1)')
|
|
->execute([$userId, $filename, $status, $moderationNote]);
|
|
$pdo->prepare('UPDATE users SET profile_background = ? WHERE id = ?')
|
|
->execute(['gallery:' . (int) $pdo->lastInsertId(), $userId]);
|
|
$modLog('Eigenes Hintergrundbild hochgeladen');
|
|
set_flash('success', $status === 'pending'
|
|
? 'Hintergrundbild hochgeladen. Es erscheint nach einer kurzen Freigabe durch die Moderation - bis dahin bleibt der Standard-Hintergrund.'
|
|
: 'Hintergrundbild hochgeladen und als Hintergrund gesetzt.');
|
|
redirect($back . '#hintergrund');
|
|
|
|
case 'background_delete':
|
|
profile_background_image_delete($userId);
|
|
$modLog('Eigenes Hintergrundbild entfernt');
|
|
set_flash('success', 'Eigenes Hintergrundbild entfernt.');
|
|
redirect($back . '#hintergrund');
|
|
|
|
case 'gallery_comments_toggle':
|
|
$enabled = !empty($_POST['enabled']) ? 1 : 0;
|
|
$pdo->prepare('UPDATE users SET gallery_comments_enabled = ? WHERE id = ?')->execute([$enabled, $userId]);
|
|
$modLog($enabled ? 'Kommentare unter den Bildern eingeschaltet' : 'Kommentare unter den Bildern abgeschaltet');
|
|
set_flash('success', $enabled ? 'Kommentare unter deinen Bildern sind eingeschaltet.' : 'Kommentare unter deinen Bildern sind abgeschaltet - vorhandene werden ausgeblendet.');
|
|
redirect($back);
|
|
|
|
case 'gallery_update':
|
|
$caption = mb_substr(trim((string) ($_POST['caption'] ?? '')), 0, 150);
|
|
if (moderation_blocks($caption, 'Bildunterschrift (Galerie)')) {
|
|
set_flash('error', 'Die Bildunterschrift enthält ein Wort, das hier nicht erlaubt ist.');
|
|
redirect($back);
|
|
}
|
|
$current = $pdo->prepare('SELECT show_on_home, status FROM member_gallery WHERE id = ? AND user_id = ?');
|
|
$current->execute([(int) ($_POST['picture_id'] ?? 0), $userId]);
|
|
$picture = $current->fetch() ?: ['show_on_home' => 0, 'status' => 'visible'];
|
|
// Fuer die Startseite freigeben kann nur das Mitglied selbst - die Leitung nur zuruecknehmen
|
|
$wasOnHome = (int) $picture['show_on_home'];
|
|
$onHome = !empty($_POST['show_on_home']) ? 1 : 0;
|
|
if ($moderating) {
|
|
$onHome = min($onHome, $wasOnHome);
|
|
}
|
|
$pdo->prepare('UPDATE member_gallery SET caption = ?, show_on_home = ? WHERE id = ? AND user_id = ?')
|
|
->execute([$caption !== '' ? $caption : null, $onHome, (int) ($_POST['picture_id'] ?? 0), $userId]);
|
|
$homeMessage = null;
|
|
if ($onHome !== $wasOnHome) {
|
|
$modLog('Bild von der Startseite genommen');
|
|
$homeMessage = $onHome === 0
|
|
? 'Gespeichert - das Bild erscheint nicht mehr auf der Startseite.'
|
|
: ($picture['status'] === 'pending'
|
|
? 'Gespeichert - das Bild erscheint nach der Freigabe durch die Moderation auf der Startseite.'
|
|
: 'Gespeichert - das Bild erscheint jetzt im Wechsel auf der Startseite.');
|
|
}
|
|
// Nachtraeglich ein Link oder zurueckgehaltenes Wort in der Unterschrift? Dann erst wieder nach Freigabe sichtbar.
|
|
[$captionStatus, $captionNote] = $caption !== '' ? moderation_initial_status('caption', $caption) : ['visible', null];
|
|
$captionReason = $captionNote !== null && (moderation_has_link($caption) || str_starts_with($captionNote, 'Schimpfwortfilter'));
|
|
if ($captionStatus === 'pending' && $captionReason) {
|
|
$pdo->prepare("UPDATE member_gallery SET status = 'pending', moderation_note = ? WHERE id = ? AND user_id = ?")
|
|
->execute([$captionNote, (int) ($_POST['picture_id'] ?? 0), $userId]);
|
|
set_flash('success', 'Bildunterschrift gespeichert. Das Bild ist bis zur Freigabe durch die Moderation nur für dich sichtbar.');
|
|
redirect($back);
|
|
}
|
|
set_flash('success', $homeMessage ?? 'Bildunterschrift gespeichert.');
|
|
redirect($back);
|
|
|
|
case 'gallery_delete':
|
|
$stmt = $pdo->prepare('SELECT filename FROM member_gallery WHERE id = ? AND user_id = ?');
|
|
$stmt->execute([(int) ($_POST['picture_id'] ?? 0), $userId]);
|
|
$filename = $stmt->fetchColumn();
|
|
if ($filename !== false) {
|
|
require_once __DIR__ . '/includes/reactions.php';
|
|
$commentIds = $pdo->prepare('SELECT id FROM gallery_comments WHERE gallery_id = ?');
|
|
$commentIds->execute([(int) ($_POST['picture_id'] ?? 0)]);
|
|
reactions_delete('comment', $commentIds->fetchAll(PDO::FETCH_COLUMN));
|
|
reactions_delete('picture', [(int) ($_POST['picture_id'] ?? 0)]);
|
|
$pdo->prepare('DELETE FROM member_gallery WHERE id = ?')->execute([(int) ($_POST['picture_id'] ?? 0)]);
|
|
profile_delete_file((string) $filename);
|
|
moderation_clear_reports('picture', (int) ($_POST['picture_id'] ?? 0));
|
|
$modLog('Bild aus der Galerie gelöscht');
|
|
set_flash('success', 'Bild gelöscht.');
|
|
}
|
|
redirect($back);
|
|
|
|
default:
|
|
redirect($back);
|
|
}
|