- Audit log: every admin_log entry is also stored permanently in the database (admin/audit.php, audit.view) - Rate limits per account, login throttling per IP (not per account), emergency lock after mass deletions, force logout / lock in user management - Comments under gallery pictures (picture page, report button, owner can disable them) - Moderation: new members, links, reported content and a "moderate everything" switch go to the approval list (moderation.php) - Every uploaded image is re-encoded (strips appended code and EXIF data) - Custom 404 page, also shown for pages without permission Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
190 lines
10 KiB
PHP
190 lines
10 KiB
PHP
<?php
|
|
/**
|
|
* Moderation: Freigabe-Liste (wartende Bilder und Kommentare) und gemeldete Inhalte.
|
|
*/
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
require_once __DIR__ . '/includes/member_profile.php';
|
|
require_permission('comments.moderate');
|
|
|
|
$pdo = db();
|
|
$name = "COALESCE(NULLIF(u.display_name, ''), u.username)";
|
|
|
|
$pendingPictures = $pdo->query(
|
|
"SELECT g.id, g.filename, g.caption, g.moderation_note, g.created_at, g.user_id, $name AS author
|
|
FROM member_gallery g JOIN users u ON u.id = g.user_id WHERE g.status = 'pending' ORDER BY g.created_at"
|
|
)->fetchAll();
|
|
$pendingComments = $pdo->query(
|
|
"SELECT c.id, c.body, c.moderation_note, c.created_at, c.author_id, c.gallery_id, g.filename, $name AS author
|
|
FROM gallery_comments c JOIN users u ON u.id = c.author_id JOIN member_gallery g ON g.id = c.gallery_id
|
|
WHERE c.status = 'pending' ORDER BY c.created_at"
|
|
)->fetchAll();
|
|
|
|
// Gemeldet, aber (noch) sichtbar - unter der Schwelle fuers automatische Ausblenden
|
|
$reportedPictures = $pdo->query(
|
|
"SELECT g.id, g.filename, g.caption, g.created_at, g.user_id, $name AS author
|
|
FROM member_gallery g JOIN users u ON u.id = g.user_id
|
|
WHERE g.status = 'visible' AND EXISTS (SELECT 1 FROM content_reports r WHERE r.content_type = 'picture' AND r.content_id = g.id)"
|
|
)->fetchAll();
|
|
$reportedComments = $pdo->query(
|
|
"SELECT c.id, c.body, c.created_at, c.author_id, c.gallery_id, g.filename, $name AS author
|
|
FROM gallery_comments c JOIN users u ON u.id = c.author_id JOIN member_gallery g ON g.id = c.gallery_id
|
|
WHERE c.status = 'visible' AND EXISTS (SELECT 1 FROM content_reports r WHERE r.content_type = 'comment' AND r.content_id = c.id)"
|
|
)->fetchAll();
|
|
|
|
// Alle Meldungen mit Grund und Melder, gruppiert nach Inhalt
|
|
$reports = [];
|
|
foreach ($pdo->query(
|
|
"SELECT r.content_type, r.content_id, r.reason, r.created_at, $name AS reporter
|
|
FROM content_reports r JOIN users u ON u.id = r.reporter_id ORDER BY r.created_at"
|
|
)->fetchAll() as $row) {
|
|
$reports[$row['content_type'] . ':' . $row['content_id']][] = $row;
|
|
}
|
|
|
|
$pendingTotal = count($pendingPictures) + count($pendingComments);
|
|
$reportedTotal = count($reportedPictures) + count($reportedComments);
|
|
|
|
/** Knoepfe fuer einen Inhalt. */
|
|
$actions = static function (string $type, int $id, array $which): string {
|
|
$labels = [
|
|
'approve' => ['Freigeben', 'button-success'],
|
|
'hide' => ['Ausblenden', 'button-secondary'],
|
|
'dismiss' => ['Meldungen verwerfen', 'button-secondary'],
|
|
'delete' => ['Löschen', 'button-danger'],
|
|
];
|
|
$html = '<div class="moderation-actions">';
|
|
foreach ($which as $action) {
|
|
[$label, $class] = $labels[$action];
|
|
$confirm = $action === 'delete' ? ' onsubmit="return confirm("Endgültig löschen?");"' : '';
|
|
$html .= '<form class="inline-form" method="post" action="/moderation_action.php"' . $confirm . '>' . csrf_field()
|
|
. '<input type="hidden" name="action" value="' . $action . '"><input type="hidden" name="type" value="' . $type . '">'
|
|
. '<input type="hidden" name="id" value="' . $id . '">'
|
|
. '<button type="submit" class="button-small ' . $class . '">' . $label . '</button></form>';
|
|
}
|
|
return $html . '</div>';
|
|
};
|
|
|
|
/** Meldungen zu einem Inhalt als kleine Liste. */
|
|
$reportList = static function (string $type, int $id) use ($reports): string {
|
|
$list = $reports[$type . ':' . $id] ?? [];
|
|
if (!$list) {
|
|
return '';
|
|
}
|
|
$html = '<ul class="moderation-reports">';
|
|
foreach ($list as $report) {
|
|
$html .= '<li>' . icon('flag') . ' <strong>' . e((string) $report['reporter']) . '</strong>'
|
|
. ($report['reason'] ? ': ' . e((string) $report['reason']) : ' <span class="text-muted">(ohne Grund)</span>')
|
|
. ' <span class="text-muted">· ' . e(date('d.m.Y H:i', strtotime((string) $report['created_at']))) . '</span></li>';
|
|
}
|
|
return $html . '</ul>';
|
|
};
|
|
|
|
$pageTitle = 'Moderation';
|
|
$containerWide = true;
|
|
include __DIR__ . '/includes/header.php';
|
|
?>
|
|
<div class="panel">
|
|
<h1>Moderation</h1>
|
|
<p class="text-muted">
|
|
Bilder und Kommentare neuer Mitglieder (erste <?= MODERATION_TRUST_DAYS ?> Tage), Beiträge mit Links und alles,
|
|
was <?= MODERATION_REPORT_THRESHOLD ?>-mal gemeldet wurde, warten hier auf eine Entscheidung. Bis dahin sieht sie
|
|
nur der Verfasser. Alle Entscheidungen landen im Audit-Log.
|
|
</p>
|
|
<form class="settings-toggle" method="post" action="/admin/settings_action.php">
|
|
<?= csrf_field() ?>
|
|
<input type="hidden" name="setting" value="moderation_all">
|
|
<label>
|
|
<input type="checkbox" name="value" value="1" <?= moderation_all_manual() ? 'checked' : '' ?> onchange="this.form.submit()">
|
|
<span><strong>Alles manuell freigeben</strong> - jedes neue Bild und jeder Kommentar wartet auf Freigabe (z.B. bei einer Spam-Welle)</span>
|
|
</label>
|
|
<noscript><button type="submit" class="button-secondary button-small">Speichern</button></noscript>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="panel">
|
|
<h2>Wartet auf Freigabe <span class="chip-count"><?= $pendingTotal ?></span></h2>
|
|
<?php if ($pendingTotal === 0): ?>
|
|
<p class="text-muted">Alles erledigt - nichts wartet auf Freigabe. 🎉</p>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($pendingPictures): ?>
|
|
<div class="moderation-grid">
|
|
<?php foreach ($pendingPictures as $picture): ?>
|
|
<div class="moderation-card">
|
|
<a href="/member_picture.php?id=<?= (int) $picture['id'] ?>" class="moderation-thumb">
|
|
<img src="<?= e(profile_image_url($picture['filename'])) ?>" alt="" loading="lazy">
|
|
</a>
|
|
<div class="moderation-body">
|
|
<div class="moderation-meta">
|
|
<span class="badge">Bild</span>
|
|
<a href="/member.php?id=<?= (int) $picture['user_id'] ?>"><strong><?= e((string) $picture['author']) ?></strong></a>
|
|
<span class="text-muted"><?= e(date('d.m.Y H:i', strtotime((string) $picture['created_at']))) ?></span>
|
|
</div>
|
|
<?php if (!empty($picture['caption'])): ?><p><?= e((string) $picture['caption']) ?></p><?php endif; ?>
|
|
<?php if (!empty($picture['moderation_note'])): ?><p class="moderation-reason">Grund: <?= e((string) $picture['moderation_note']) ?></p><?php endif; ?>
|
|
<?= $reportList('picture', (int) $picture['id']) ?>
|
|
<?= $actions('picture', (int) $picture['id'], ['approve', 'delete']) ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php foreach ($pendingComments as $comment): ?>
|
|
<div class="moderation-card moderation-comment">
|
|
<a href="/member_picture.php?id=<?= (int) $comment['gallery_id'] ?>#kommentar-<?= (int) $comment['id'] ?>" class="moderation-thumb moderation-thumb-small" title="Zum Bild">
|
|
<img src="<?= e(profile_image_url($comment['filename'])) ?>" alt="" loading="lazy">
|
|
</a>
|
|
<div class="moderation-body">
|
|
<div class="moderation-meta">
|
|
<span class="badge">Kommentar</span>
|
|
<a href="/member.php?id=<?= (int) $comment['author_id'] ?>"><strong><?= e((string) $comment['author']) ?></strong></a>
|
|
<span class="text-muted"><?= e(date('d.m.Y H:i', strtotime((string) $comment['created_at']))) ?></span>
|
|
</div>
|
|
<p class="moderation-text"><?= nl2br(e((string) $comment['body']), false) ?></p>
|
|
<?php if (!empty($comment['moderation_note'])): ?><p class="moderation-reason">Grund: <?= e((string) $comment['moderation_note']) ?></p><?php endif; ?>
|
|
<?= $reportList('comment', (int) $comment['id']) ?>
|
|
<?= $actions('comment', (int) $comment['id'], ['approve', 'delete']) ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<?php if ($reportedTotal > 0): ?>
|
|
<div class="panel">
|
|
<h2>Gemeldet, aber noch sichtbar <span class="chip-count"><?= $reportedTotal ?></span></h2>
|
|
<p class="text-muted">Weniger als <?= MODERATION_REPORT_THRESHOLD ?> Meldungen - noch nicht automatisch ausgeblendet.</p>
|
|
<?php foreach ($reportedPictures as $picture): ?>
|
|
<div class="moderation-card moderation-comment">
|
|
<a href="/member_picture.php?id=<?= (int) $picture['id'] ?>" class="moderation-thumb moderation-thumb-small">
|
|
<img src="<?= e(profile_image_url($picture['filename'])) ?>" alt="" loading="lazy">
|
|
</a>
|
|
<div class="moderation-body">
|
|
<div class="moderation-meta">
|
|
<span class="badge">Bild</span>
|
|
<a href="/member.php?id=<?= (int) $picture['user_id'] ?>"><strong><?= e((string) $picture['author']) ?></strong></a>
|
|
<?php if (!empty($picture['caption'])): ?><span><?= e((string) $picture['caption']) ?></span><?php endif; ?>
|
|
</div>
|
|
<?= $reportList('picture', (int) $picture['id']) ?>
|
|
<?= $actions('picture', (int) $picture['id'], ['hide', 'dismiss', 'delete']) ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php foreach ($reportedComments as $comment): ?>
|
|
<div class="moderation-card moderation-comment">
|
|
<a href="/member_picture.php?id=<?= (int) $comment['gallery_id'] ?>#kommentar-<?= (int) $comment['id'] ?>" class="moderation-thumb moderation-thumb-small" title="Zum Bild">
|
|
<img src="<?= e(profile_image_url($comment['filename'])) ?>" alt="" loading="lazy">
|
|
</a>
|
|
<div class="moderation-body">
|
|
<div class="moderation-meta">
|
|
<span class="badge">Kommentar</span>
|
|
<a href="/member.php?id=<?= (int) $comment['author_id'] ?>"><strong><?= e((string) $comment['author']) ?></strong></a>
|
|
</div>
|
|
<p class="moderation-text"><?= nl2br(e((string) $comment['body']), false) ?></p>
|
|
<?= $reportList('comment', (int) $comment['id']) ?>
|
|
<?= $actions('comment', (int) $comment['id'], ['hide', 'dismiss', 'delete']) ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php include __DIR__ . '/includes/footer.php'; ?>
|