| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /laragon4/www/bpkd.test_/admin/ |
Upload File : |
<?php
$page_title = 'Manajemen Komentar';
require_once 'config/database.php';
require_once 'includes/header.php';
// Handle delete
if (isset($_GET['delete'])) {
$id = (int)$_GET['delete'];
$conn->query("DELETE FROM comments WHERE id = $id");
redirect('comments.php?msg=deleted');
}
// Get comments - tanpa filter status dulu
$comments_query = "
SELECT c.*,
a.title as article_title,
p.title as page_title
FROM comments c
LEFT JOIN articles a ON c.article_id = a.id
LEFT JOIN pages p ON c.page_id = p.id
ORDER BY c.created_at DESC
";
$comments = $conn->query($comments_query);
// Check if query was successful
if (!$comments) {
die("Error in comments query: " . $conn->error . "<br>Query: " . $comments_query);
}
$msg = '';
if (isset($_GET['msg'])) {
if ($_GET['msg'] == 'deleted') $msg = '<div class="alert alert-success">Komentar dihapus!</div>';
}
?>
<div class="container-fluid">
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Manajemen Komentar</h1>
</div>
<?php echo $msg; ?>
<!-- Comments List -->
<div class="card shadow mb-4">
<div class="card-body">
<?php if ($comments && $comments->num_rows > 0): ?>
<?php while($comment = $comments->fetch_assoc()): ?>
<div class="comment-item mb-4 p-3 border rounded">
<div class="d-flex justify-content-between align-items-start">
<div class="flex-grow-1">
<div class="d-flex align-items-center mb-2">
<div class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center me-2" style="width: 40px; height: 40px;">
<i class="fas fa-user"></i>
</div>
<div>
<h5 class="mb-0">
<strong><?php echo htmlspecialchars($comment['name']); ?></strong>
</h5>
<p class="text-muted small mb-0">
<i class="fas fa-envelope me-1"></i><?php echo htmlspecialchars($comment['email']); ?>
<i class="fas fa-clock ms-2 me-1"></i><?php echo date('d M Y H:i', strtotime($comment['created_at'])); ?>
</p>
</div>
</div>
<div class="message-box p-3 bg-light rounded mb-2">
<?php echo nl2br(htmlspecialchars($comment['comment'])); ?>
</div>
<p class="small text-muted mb-0">
<i class="fas fa-link me-1"></i>
<strong>Pada:</strong>
<?php if(!empty($comment['article_title'])): ?>
<a href="../article.php?id=<?php echo $comment['article_id']; ?>" target="_blank">
<i class="fas fa-newspaper me-1"></i><?php echo htmlspecialchars($comment['article_title']); ?>
</a>
<?php elseif(!empty($comment['page_title'])): ?>
<a href="../page.php?id=<?php echo $comment['page_id']; ?>" target="_blank">
<i class="fas fa-file me-1"></i><?php echo htmlspecialchars($comment['page_title']); ?>
</a>
<?php else: ?>
<em class="text-muted">Konten telah dihapus</em>
<?php endif; ?>
</p>
<?php if(!empty($comment['ip_address'])): ?>
<small class="text-muted">
<i class="fas fa-network-wired me-1"></i>IP: <?php echo $comment['ip_address']; ?>
</small>
<?php endif; ?>
</div>
<div class="ms-3">
<a href="?delete=<?php echo $comment['id']; ?>"
class="btn btn-sm btn-danger"
onclick="return confirm('Yakin ingin menghapus komentar ini?')"
title="Hapus">
<i class="fas fa-trash me-1"></i>Hapus
</a>
</div>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<div class="text-center py-5">
<i class="fas fa-comments fa-4x text-muted mb-3"></i>
<h5>Tidak ada komentar</h5>
<p class="text-muted">Belum ada komentar dari pengunjung</p>
</div>
<?php endif; ?>
</div>
</div>
</div>
<style>
.comment-item {
transition: all 0.3s ease;
}
.comment-item:hover {
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.message-box {
font-size: 0.95rem;
line-height: 1.6;
}
</style>
<?php require_once 'includes/footer.php'; ?>