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/messages.php
<?php require_once __DIR__ . '/../config/db.php'; // Check authentication if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } // Mark as read if (isset($_GET['read'])) { $id = (int)$_GET['read']; $pdo->prepare("UPDATE messages SET is_read = 1 WHERE id = ?")->execute([$id]); header('Location: messages.php'); exit; } // Delete message if (isset($_GET['delete'])) { $id = (int)$_GET['delete']; $pdo->prepare("DELETE FROM messages WHERE id = ?")->execute([$id]); header('Location: messages.php?msg=deleted'); exit; } // Mark all as read if (isset($_GET['read_all'])) { $pdo->query("UPDATE messages SET is_read = 1 WHERE is_read = 0"); header('Location: messages.php'); exit; } $admin_page_title = 'Messages'; require_once 'includes/header.php'; // Filter $filter = $_GET['filter'] ?? 'all'; $sql = "SELECT m.*, o.title as offer_title FROM messages m LEFT JOIN offers o ON m.offer_id = o.id"; if ($filter === 'unread') $sql .= " WHERE m.is_read = 0"; elseif ($filter === 'contact') $sql .= " WHERE m.type = 'contact'"; elseif ($filter === 'inquiry') $sql .= " WHERE m.type = 'offer_inquiry'"; $sql .= " ORDER BY m.created_at DESC"; $messages = $pdo->query($sql)->fetchAll(); ?> <?php if (isset($_GET['msg'])): ?> <div class="alert-dismiss mb-4 px-4 py-3 rounded-xl text-sm font-medium bg-red-100 text-red-700">🗑️ Message deleted!</div> <?php endif; ?> <div class="flex flex-wrap items-center justify-between mb-6 gap-3"> <div class="flex space-x-2"> <a href="messages.php" class="px-3 py-1.5 rounded-lg text-sm font-medium <?= $filter === 'all' ? 'bg-primary-700 text-white' : 'bg-gray-200 text-gray-600 hover:bg-gray-300' ?>">All</a> <a href="messages.php?filter=unread" class="px-3 py-1.5 rounded-lg text-sm font-medium <?= $filter === 'unread' ? 'bg-primary-700 text-white' : 'bg-gray-200 text-gray-600 hover:bg-gray-300' ?>">Unread</a> <a href="messages.php?filter=contact" class="px-3 py-1.5 rounded-lg text-sm font-medium <?= $filter === 'contact' ? 'bg-primary-700 text-white' : 'bg-gray-200 text-gray-600 hover:bg-gray-300' ?>">Contact</a> <a href="messages.php?filter=inquiry" class="px-3 py-1.5 rounded-lg text-sm font-medium <?= $filter === 'inquiry' ? 'bg-primary-700 text-white' : 'bg-gray-200 text-gray-600 hover:bg-gray-300' ?>">Offer Inquiry</a> </div> <a href="messages.php?read_all=1" class="text-sm text-primary-600 hover:text-primary-800 font-medium"><i class="fas fa-check-double mr-1"></i>Mark all as read</a> </div> <div class="space-y-3"> <?php if (empty($messages)): ?> <div class="text-center py-12 text-gray-400 bg-white rounded-xl"><i class="fas fa-inbox text-3xl mb-2 block"></i>No messages found</div> <?php else: ?> <?php foreach ($messages as $msg): ?> <div class="bg-white rounded-xl shadow-sm p-5 <?= !$msg['is_read'] ? 'border-l-4 border-primary-500' : '' ?>"> <div class="flex items-start justify-between"> <div class="flex-1"> <div class="flex items-center space-x-3 mb-2"> <h4 class="font-semibold text-gray-800"><?= htmlspecialchars($msg['name']) ?></h4> <span class="px-2 py-0.5 rounded-full text-xs font-medium <?= $msg['type'] === 'offer_inquiry' ? 'bg-gold-100 text-gold-500' : 'bg-blue-100 text-blue-600' ?>"> <?= $msg['type'] === 'offer_inquiry' ? 'Offer Inquiry' : 'Contact' ?> </span> <?php if (!$msg['is_read']): ?> <span class="px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-700">New</span> <?php endif; ?> </div> <?php if ($msg['offer_title']): ?> <p class="text-sm text-primary-600 mb-1"><i class="fas fa-tag mr-1"></i>Offer: <?= htmlspecialchars($msg['offer_title']) ?></p> <?php endif; ?> <p class="text-sm text-gray-600 mb-2"><?= nl2br(htmlspecialchars($msg['message'])) ?></p> <div class="flex flex-wrap gap-3 text-xs text-gray-400"> <?php if ($msg['phone']): ?><span><i class="fas fa-phone mr-1"></i><?= htmlspecialchars($msg['phone']) ?></span><?php endif; ?> <?php if ($msg['email']): ?><span><i class="fas fa-envelope mr-1"></i><?= htmlspecialchars($msg['email']) ?></span><?php endif; ?> <?php if ($msg['address']): ?><span><i class="fas fa-map-marker-alt mr-1"></i><?= htmlspecialchars($msg['address']) ?></span><?php endif; ?> <span><i class="fas fa-clock mr-1"></i><?= date('M j, Y g:i A', strtotime($msg['created_at'])) ?></span> </div> </div> <div class="flex space-x-2 ml-4"> <?php if (!$msg['is_read']): ?> <a href="messages.php?read=<?= $msg['id'] ?>" class="text-primary-600 hover:text-primary-800 text-sm" title="Mark as read"><i class="fas fa-check"></i></a> <?php endif; ?> <a href="messages.php?delete=<?= $msg['id'] ?>" onclick="return confirm('Delete this message?')" class="text-red-600 hover:text-red-800 text-sm" title="Delete"><i class="fas fa-trash"></i></a> </div> </div> </div> <?php endforeach; ?> <?php endif; ?> </div> <?php require_once 'includes/footer.php'; ?>