- Moderation page with tabs: approval, all comments (critical/suspicious flags, search, filters), swear word filter (mark / hold / block, maintained by mods, detects leetspeak) - Discord-style emoji reactions on gallery pictures and comments (without reloading) - Member list and profile: "last active" / online dot, sortable - Map: all marker categories hidden at start Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
150 lines
6.2 KiB
PHP
150 lines
6.2 KiB
PHP
<?php
|
|
/**
|
|
* Moderation von Galeriebildern und Kommentaren:
|
|
* - report: jedes Mitglied meldet einen Inhalt (ab 2 Meldungen automatisch ausgeblendet)
|
|
* - approve: freigeben (sichtbar fuer alle, Meldungen verworfen)
|
|
* - hide: ausblenden (zurueck in die Freigabe-Liste)
|
|
* - dismiss: Meldungen verwerfen, Inhalt bleibt sichtbar
|
|
* - delete: endgueltig loeschen
|
|
* - word_add / word_delete: Schimpfwortfilter pflegen (Hinzufuegen aendert auch die Aktion)
|
|
*/
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
require_once __DIR__ . '/includes/member_profile.php';
|
|
require_once __DIR__ . '/includes/reactions.php';
|
|
require_permission('members.view');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
redirect('/members.php');
|
|
}
|
|
verify_csrf();
|
|
|
|
$action = (string) ($_POST['action'] ?? '');
|
|
|
|
// Schimpfwortfilter (nur Moderation)
|
|
if ($action === 'word_add' || $action === 'word_delete') {
|
|
if (!moderation_can()) {
|
|
show_not_found();
|
|
}
|
|
$word = mb_strtolower(trim((string) preg_replace('/\s+/u', ' ', (string) ($_POST['word'] ?? ''))));
|
|
$word = mb_substr($word, 0, 60);
|
|
if (trim($word, '* ') === '') {
|
|
set_flash('error', 'Bitte ein Wort eingeben.');
|
|
redirect('/moderation.php?tab=filter');
|
|
}
|
|
if ($action === 'word_delete') {
|
|
db()->prepare('DELETE FROM moderation_words WHERE word = ?')->execute([$word]);
|
|
admin_log('🧹 Wort aus dem Schimpfwortfilter entfernt', ['Wort' => $word], 'info', 'members');
|
|
set_flash('success', '„' . $word . '“ entfernt.');
|
|
} else {
|
|
$wordAction = isset(MODERATION_WORD_ACTIONS[$_POST['word_action'] ?? '']) ? (string) $_POST['word_action'] : 'flag';
|
|
$exists = db()->prepare('SELECT action FROM moderation_words WHERE word = ?');
|
|
$exists->execute([$word]);
|
|
$before = $exists->fetchColumn();
|
|
if ($before === false) {
|
|
db()->prepare('INSERT INTO moderation_words (word, action, created_by) VALUES (?, ?, ?)')
|
|
->execute([$word, $wordAction, (int) current_user()['id']]);
|
|
} else {
|
|
db()->prepare('UPDATE moderation_words SET action = ? WHERE word = ?')->execute([$wordAction, $word]);
|
|
}
|
|
admin_log($before === false ? '🧹 Wort zum Schimpfwortfilter hinzugefügt' : '🧹 Schimpfwortfilter geändert', [
|
|
'Wort' => $word,
|
|
'Aktion' => MODERATION_WORD_ACTIONS[$wordAction],
|
|
], 'info', 'members');
|
|
set_flash('success', '„' . $word . '“: ' . MODERATION_WORD_ACTIONS[$wordAction] . '.');
|
|
}
|
|
redirect('/moderation.php?tab=filter');
|
|
}
|
|
|
|
$type = (string) ($_POST['type'] ?? '');
|
|
$id = (int) ($_POST['id'] ?? 0);
|
|
if (!isset(MODERATION_TYPES[$type]) || $id <= 0) {
|
|
set_flash('error', 'Unbekannter Inhalt.');
|
|
redirect('/members.php');
|
|
}
|
|
[$table, $label] = MODERATION_TYPES[$type];
|
|
$pdo = db();
|
|
|
|
// Wohin danach: zur Bildseite (von dort aus gemeldet/freigegeben) oder zur Freigabe-Liste
|
|
$pictureId = $id;
|
|
if ($type === 'comment') {
|
|
$stmt = $pdo->prepare('SELECT gallery_id FROM gallery_comments WHERE id = ?');
|
|
$stmt->execute([$id]);
|
|
$pictureId = (int) $stmt->fetchColumn();
|
|
}
|
|
$back = ($action === 'report' || ($_POST['back'] ?? '') === 'picture')
|
|
? '/member_picture.php?id=' . $pictureId . ($type === 'comment' ? '#kommentare' : '')
|
|
: (($_POST['back'] ?? '') === 'comments' ? '/moderation.php?tab=comments' : '/moderation.php');
|
|
|
|
if ($action === 'report') {
|
|
if (!security_throttle('report')) {
|
|
set_flash('error', 'Du hast in den letzten Minuten schon viel gemeldet. Bitte warte kurz.');
|
|
redirect($back);
|
|
}
|
|
$reason = mb_substr(trim((string) ($_POST['reason'] ?? '')), 0, 255);
|
|
set_flash('success', moderation_report($type, $id, $reason));
|
|
redirect($back);
|
|
}
|
|
|
|
// Ab hier nur die Moderation
|
|
if (!moderation_can()) {
|
|
show_not_found();
|
|
}
|
|
|
|
$owner = $type === 'picture' ? 'user_id' : 'author_id';
|
|
$stmt = $pdo->prepare("SELECT * , $owner AS owner_id FROM $table WHERE id = ?");
|
|
$stmt->execute([$id]);
|
|
$content = $stmt->fetch();
|
|
if (!$content) {
|
|
set_flash('error', 'Diesen Inhalt gibt es nicht (mehr).');
|
|
redirect('/moderation.php');
|
|
}
|
|
$logFields = [
|
|
'Von' => admin_log_user((int) $content['owner_id']),
|
|
$type === 'picture' ? 'Bildunterschrift' : 'Text' => mb_strimwidth((string) ($type === 'picture' ? ($content['caption'] ?? '') : $content['body']), 0, 300, '…'),
|
|
'Grund der Prüfung' => (string) ($content['moderation_note'] ?? ''),
|
|
];
|
|
|
|
switch ($action) {
|
|
case 'approve':
|
|
$pdo->prepare("UPDATE $table SET status = 'visible', moderation_note = NULL WHERE id = ?")->execute([$id]);
|
|
moderation_clear_reports($type, $id);
|
|
admin_log('✅ ' . $label . ' freigegeben', $logFields, 'success', 'members');
|
|
set_flash('success', $label . ' freigegeben - jetzt für alle sichtbar.');
|
|
break;
|
|
|
|
case 'hide':
|
|
$pdo->prepare("UPDATE $table SET status = 'pending', moderation_note = ? WHERE id = ?")
|
|
->execute(['Von der Moderation ausgeblendet', $id]);
|
|
admin_log('🙈 ' . $label . ' ausgeblendet', $logFields, 'warning', 'members');
|
|
set_flash('success', $label . ' ausgeblendet.');
|
|
break;
|
|
|
|
case 'dismiss':
|
|
moderation_clear_reports($type, $id);
|
|
admin_log('👌 Meldungen verworfen (' . $label . ' bleibt)', $logFields, 'info', 'members');
|
|
set_flash('success', 'Meldungen verworfen.');
|
|
break;
|
|
|
|
case 'delete':
|
|
if ($type === 'picture') {
|
|
$commentIds = $pdo->prepare('SELECT id FROM gallery_comments WHERE gallery_id = ?');
|
|
$commentIds->execute([$id]);
|
|
reactions_delete('comment', $commentIds->fetchAll(PDO::FETCH_COLUMN));
|
|
}
|
|
reactions_delete($type, [$id]);
|
|
$pdo->prepare("DELETE FROM $table WHERE id = ?")->execute([$id]);
|
|
moderation_clear_reports($type, $id);
|
|
if ($type === 'picture') {
|
|
profile_delete_file((string) $content['filename']); // Kommentare fallen per ON DELETE CASCADE weg
|
|
}
|
|
admin_log('🗑️ ' . $label . ' gelöscht (Moderation)', $logFields, 'warning', 'members');
|
|
set_flash('success', $label . ' gelöscht.');
|
|
if (str_starts_with($back, '/member_picture.php')) {
|
|
$back = '/moderation.php';
|
|
}
|
|
break;
|
|
|
|
default:
|
|
set_flash('error', 'Unbekannte Aktion.');
|
|
}
|
|
redirect($back);
|