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/offers.php
<?php require_once __DIR__ . '/../config/db.php'; // Check authentication if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } // Handle delete if (isset($_GET['delete'])) { $id = (int)$_GET['delete']; $stmt = $pdo->prepare("SELECT image FROM offers WHERE id = ?"); $stmt->execute([$id]); $offer = $stmt->fetch(); if ($offer && $offer['image'] && file_exists('../uploads/offers/' . $offer['image'])) { unlink('../uploads/offers/' . $offer['image']); } $pdo->prepare("DELETE FROM offers WHERE id = ?")->execute([$id]); header('Location: offers.php?msg=deleted'); exit; } $admin_page_title = 'Manage Offers'; require_once 'includes/header.php'; $offers = $pdo->query("SELECT * FROM offers 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' ?>"> <?php if ($_GET['msg'] === 'added'): ?>✅ Offer added successfully! <?php elseif ($_GET['msg'] === 'updated'): ?>✅ Offer updated successfully! <?php elseif ($_GET['msg'] === 'deleted'): ?>🗑️ Offer deleted successfully! <?php endif; ?> </div> <?php endif; ?> <div class="flex items-center justify-between mb-6"> <p class="text-gray-500 text-sm"><?= count($offers) ?> total offers</p> <a href="offer_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 flex items-center"> <i class="fas fa-plus mr-2"></i> Add Offer </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">Price</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-left text-xs font-semibold text-gray-500 uppercase">Date</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($offers)): ?> <tr><td colspan="7" class="px-6 py-8 text-center text-gray-400"><i class="fas fa-tags text-3xl mb-2 block"></i>No offers found</td></tr> <?php else: ?> <?php foreach ($offers as $i => $offer): ?> <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 ($offer['image']): ?> <img src="../uploads/offers/<?= htmlspecialchars($offer['image']) ?>" class="w-16 h-12 object-cover rounded-lg" alt=""> <?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"><?= htmlspecialchars($offer['title']) ?></td> <td class="px-6 py-4 text-sm text-gray-600"><?= htmlspecialchars($offer['price'] ?? 'N/A') ?></td> <td class="px-6 py-4"> <span class="px-2.5 py-1 rounded-full text-xs font-medium <?= $offer['status'] === 'active' ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-600' ?>"> <?= ucfirst($offer['status']) ?> </span> </td> <td class="px-6 py-4 text-sm text-gray-500"><?= date('M j, Y', strtotime($offer['created_at'])) ?></td> <td class="px-6 py-4 text-center"> <a href="offer_edit.php?id=<?= $offer['id'] ?>" class="text-blue-600 hover:text-blue-800 mr-3" title="Edit"><i class="fas fa-edit"></i></a> <a href="offers.php?delete=<?= $offer['id'] ?>" onclick="return confirm('Are you sure you want to delete this offer?')" 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'; ?>