84 lines
4.0 KiB
PHP
84 lines
4.0 KiB
PHP
<?php
|
|
require_once '../includes/db.php';
|
|
require_once '../includes/auth.php';
|
|
requireModerator();
|
|
|
|
// Handle moderation actions
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$comment_id = (int)$_POST['comment_id'];
|
|
if (isset($_POST['delete'])) {
|
|
$pdo->prepare("DELETE FROM comments WHERE id = ?")->execute([$comment_id]);
|
|
$msg = "Comment deleted.";
|
|
} elseif (isset($_POST['ignore'])) {
|
|
$pdo->prepare("UPDATE comments SET is_reported = FALSE WHERE id = ?")->execute([$comment_id]);
|
|
$msg = "Report dismissed.";
|
|
}
|
|
}
|
|
|
|
$reports = $pdo->query("
|
|
SELECT c.*, u.username, v.title as video_title
|
|
FROM comments c
|
|
JOIN users u ON c.user_id = u.id
|
|
JOIN videos v ON c.video_id = v.id
|
|
WHERE c.is_reported = TRUE
|
|
ORDER BY c.created_at DESC
|
|
")->fetchAll();
|
|
|
|
ob_start();
|
|
require_once '../includes/header.php';
|
|
$header = ob_get_clean();
|
|
echo str_replace(['assets/', 'index.php', 'login.php', 'logout.php', 'admin/'], ['../assets/', '../index.php', '../login.php', '../logout.php', './'], $header);
|
|
?>
|
|
|
|
<div style="max-width: 1000px; margin: 40px auto; padding: 0 24px;">
|
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px;">
|
|
<h1>Reported Comments</h1>
|
|
<a href="index.php" class="btn" style="background: var(--glass);">Back to Dashboard</a>
|
|
</div>
|
|
|
|
<?php if (isset($msg)): ?>
|
|
<div style="background: rgba(76,175,80,0.1); color: #4caf50; padding: 16px; border-radius: 8px; margin-bottom: 24px; border: 1px solid rgba(76,175,80,0.2);">
|
|
<?= $msg ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div style="background: var(--bg-card); border-radius: 16px; border: 1px solid var(--glass-border); overflow: hidden;">
|
|
<table style="width: 100%; border-collapse: collapse; text-align: left;">
|
|
<thead>
|
|
<tr style="background: var(--glass); color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase;">
|
|
<th style="padding: 16px;">Comment</th>
|
|
<th style="padding: 16px;">User</th>
|
|
<th style="padding: 16px;">Video</th>
|
|
<th style="padding: 16px;">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($reports as $r): ?>
|
|
<tr style="border-bottom: 1px solid var(--glass-border);">
|
|
<td style="padding: 16px; max-width: 300px;">
|
|
<div style="font-style: italic; color: var(--text-main);">"<?= htmlspecialchars($r['comment_text']) ?>"</div>
|
|
<div style="font-size: 0.75rem; color: var(--text-muted); margin-top: 4px;"><?= date('M d, Y', strtotime($r['created_at'])) ?></div>
|
|
</td>
|
|
<td style="padding: 16px;"><?= htmlspecialchars($r['username']) ?></td>
|
|
<td style="padding: 16px; font-size: 0.9rem; color: var(--text-muted);"><?= htmlspecialchars($r['video_title']) ?></td>
|
|
<td style="padding: 16px;">
|
|
<form method="POST" style="display: flex; gap: 10px;">
|
|
<input type="hidden" name="comment_id" value="<?= $r['id'] ?>">
|
|
<button type="submit" name="delete" class="btn" style="background: #ff4081; padding: 6px 12px; font-size: 0.8rem;">Delete</button>
|
|
<button type="submit" name="ignore" class="btn" style="background: var(--glass); padding: 6px 12px; font-size: 0.8rem;">Ignore</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php if (empty($reports)): ?>
|
|
<tr>
|
|
<td colspan="4" style="padding: 40px; text-align: center; color: var(--text-muted);">No reported comments. Everything is clean!</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once '../includes/footer.php'; ?>
|