BLACKSITE
:
216.73.216.140
:
199.188.200.160 / jeddahhousingltd.com
:
Linux server383.web-hosting.com 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
:
/
home
/
jeddveug
/
www
/
admin
/
Upload File:
files >> /home/jeddveug/www/admin/blogs.php
<?php require_once __DIR__ . '/../config/db.php'; // Check authentication if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } if (isset($_GET['delete'])) { $id = (int)$_GET['delete']; $stmt = $pdo->prepare("SELECT image FROM blogs WHERE id = ?"); $stmt->execute([$id]); $b = $stmt->fetch(); if ($b && $b['image'] && file_exists('../uploads/blogs/' . $b['image'])) unlink('../uploads/blogs/' . $b['image']); $pdo->prepare("DELETE FROM blogs WHERE id = ?")->execute([$id]); header('Location: blogs.php?msg=deleted'); exit; } $admin_page_title = 'Manage Blog Posts'; require_once 'includes/header.php'; $blogs = $pdo->query("SELECT * FROM blogs ORDER BY created_at DESC")->fetchAll(); ?> <?php if (isset($_GET['msg'])): ?> <div class="alert-dismiss mb-4 px-4 py-3 rounded-xl text-sm font-medium <?= $_GET['msg'] === 'deleted' ? 'bg-red-100 text-red-700' : 'bg-green-100 text-green-700' ?>"> <?= $_GET['msg'] === 'added' ? '✅ Blog post created!' : ($_GET['msg'] === 'updated' ? '✅ Blog post updated!' : '🗑️ Blog post deleted!') ?> </div> <?php endif; ?> <div class="flex items-center justify-between mb-6"> <p class="text-gray-500 text-sm"><?= count($blogs) ?> total posts</p> <a href="blog_add.php" class="bg-primary-700 hover:bg-primary-800 text-white px-5 py-2.5 rounded-xl text-sm font-medium transition-colors"><i class="fas fa-plus mr-2"></i>Add Blog Post</a> </div> <div class="bg-white rounded-xl shadow-sm overflow-hidden"> <div class="overflow-x-auto"> <table class="w-full"> <thead class="bg-gray-50"> <tr> <th class="px-6 py-3 text-left text-xs font-semibold text-gray-500 uppercase">#</th> <th class="px-6 py-3 text-left text-xs font-semibold text-gray-500 uppercase">Image</th> <th class="px-6 py-3 text-left text-xs font-semibold text-gray-500 uppercase">Title</th> <th class="px-6 py-3 text-left text-xs font-semibold text-gray-500 uppercase">Author</th> <th class="px-6 py-3 text-left text-xs font-semibold text-gray-500 uppercase">Date</th> <th class="px-6 py-3 text-left text-xs font-semibold text-gray-500 uppercase">Status</th> <th class="px-6 py-3 text-center text-xs font-semibold text-gray-500 uppercase">Actions</th> </tr> </thead> <tbody class="divide-y"> <?php if (empty($blogs)): ?> <tr><td colspan="7" class="px-6 py-8 text-center text-gray-400"><i class="fas fa-blog text-3xl mb-2 block"></i>No blog posts found</td></tr> <?php else: ?> <?php foreach ($blogs as $i => $blog): ?> <tr class="hover:bg-gray-50"> <td class="px-6 py-4 text-sm text-gray-500"><?= $i + 1 ?></td> <td class="px-6 py-4"> <?php if ($blog['image']): ?> <img src="../uploads/blogs/<?= htmlspecialchars($blog['image']) ?>" class="w-16 h-12 object-cover rounded-lg"> <?php else: ?> <div class="w-16 h-12 bg-gray-200 rounded-lg flex items-center justify-center"><i class="fas fa-image text-gray-400"></i></div> <?php endif; ?> </td> <td class="px-6 py-4 text-sm font-medium text-gray-800 max-w-xs truncate"><?= htmlspecialchars($blog['title']) ?></td> <td class="px-6 py-4 text-sm text-gray-600"><?= htmlspecialchars($blog['author']) ?></td> <td class="px-6 py-4 text-sm text-gray-500"><?= $blog['publish_date'] ? date('M j, Y', strtotime($blog['publish_date'])) : '-' ?></td> <td class="px-6 py-4"> <span class="px-2.5 py-1 rounded-full text-xs font-medium <?= $blog['status'] === 'publish' ? 'bg-green-100 text-green-700' : 'bg-yellow-100 text-yellow-700' ?>"> <?= ucfirst($blog['status']) ?> </span> </td> <td class="px-6 py-4 text-center"> <a href="../blog_details.php?slug=<?= $blog['slug'] ?>" target="_blank" class="text-gray-600 hover:text-gray-800 mr-2" title="View"><i class="fas fa-eye"></i></a> <a href="blog_edit.php?id=<?= $blog['id'] ?>" class="text-blue-600 hover:text-blue-800 mr-2" title="Edit"><i class="fas fa-edit"></i></a> <a href="blogs.php?delete=<?= $blog['id'] ?>" onclick="return confirm('Delete this blog post?')" class="text-red-600 hover:text-red-800" title="Delete"><i class="fas fa-trash"></i></a> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> <?php require_once 'includes/footer.php'; ?>