PNG IHDR x sBIT|d pHYs + tEXtSoftware www.inkscape.org< ,tEXtComment
<?php
session_start();
require '../db.php';
// 1. Security Check
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
header('Location: login.php');
exit;
}
// 2. Handle Delete Request
if (isset($_GET['delete'])) {
$id = (int)$_GET['delete'];
$stmt = $pdo->prepare("DELETE FROM posts WHERE post_id = ?");
$stmt->execute([$id]);
header("Location: posts.php?msg=deleted");
exit;
}
// 3. Fetch All Posts
$stmt = $pdo->query("SELECT * FROM posts ORDER BY created_at DESC");
$posts = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Manage Posts - Global Relief Bridge</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* --- COPYING ADMIN DASHBOARD STYLES --- */
:root {
--primary-green: #8ac926;
--dark-green: #070767;
--primary-purple: #9b5de5;
--bg-light: #f4f7f6;
--text-dark: #333;
}
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', sans-serif; }
body { background-color: var(--bg-light); display: flex; min-height: 100vh; }
/* Sidebar & Main */
.sidebar { width: 260px; background: var(--dark-green); color: white; display: flex; flex-direction: column; padding: 30px 20px; position: fixed; height: 100%; }
.brand { font-size: 1.5rem; font-weight: 800; margin-bottom: 50px; color: white; text-decoration: none; }
.nav-link { color: rgba(255,255,255,0.7); text-decoration: none; padding: 15px; border-radius: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 15px; transition: 0.3s; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,0.1); color: white; }
.main-content { margin-left: 260px; padding: 40px; width: 100%; }
/* Page Specific */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.btn-add { background: var(--primary-green); color: white; padding: 12px 25px; border-radius: 30px; text-decoration: none; font-weight: bold; }
.btn-add:hover { background: #76b020; }
.table-card { background: white; border-radius: 20px; padding: 25px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 15px; color: #888; border-bottom: 1px solid #eee; }
td { padding: 15px; border-bottom: 1px solid #f9f9f9; color: var(--text-dark); vertical-align: middle; }
.thumb { width: 60px; height: 40px; object-fit: cover; border-radius: 5px; }
.action-btn { padding: 5px 10px; border-radius: 10px; text-decoration: none; font-size: 0.85rem; margin-right: 5px; }
.edit { background: #e3f2fd; color: #2196f3; }
.delete { background: #ffebee; color: #f44336; }
</style>
</head>
<body>
<?php include 'side.php'; ?>
<div class="main-content">
<div class="header">
<h2>Blog Posts</h2>
<a href="post_editor.php" class="btn-add"><i class="fas fa-plus"></i> Create New Post</a>
</div>
<div class="table-card">
<table>
<thead>
<tr>
<th>Image</th>
<th>Title</th>
<th>Date</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $post): ?>
<tr>
<td>
<?php if($post['featured_image']): ?>
<img src="../<?php echo $post['featured_image']; ?>" class="thumb">
<?php else: ?>
<div style="width:60px; height:40px; background:#eee; border-radius:5px;"></div>
<?php endif; ?>
</td>
<td>
<strong><?php echo htmlspecialchars($post['title']); ?></strong><br>
<small style="color:#999"><?php echo substr($post['excerpt'], 0, 50); ?>...</small>
</td>
<td><?php echo date('M d, Y', strtotime($post['created_at'])); ?></td>
<td><span style="color: green; font-weight:bold;">Published</span></td>
<td>
<a href="post_editor.php?id=<?php echo $post['post_id']; ?>" class="action-btn edit"><i class="fas fa-edit"></i></a>
<a href="posts.php?delete=<?php echo $post['post_id']; ?>" class="action-btn delete" onclick="return confirm('Delete this post?')"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
b IDATxytVսϓ22 A@IR:hCiZ[v*E:WũZA ^dQeQ @ !jZ'>gsV仿$|?g)&x-E