BLACKSITE
:
216.73.217.148
:
172.93.223.125 / www.geeteetravels.com
:
Linux ubuntu 5.15.0-179-generic #189-Ubuntu SMP Tue May 5 18:20:56 UTC 2026 x86_64
:
/
home
/
geeteetravels
/
public_html
/
admin
/
Upload File:
files >> /home/geeteetravels/public_html/admin/messages.php
<?php $pageTitle = 'Contact Messages'; $currentPage = 'messages'; require_once 'includes/header.php'; // Self-Healing: Create table if missing try { $pdo->exec("CREATE TABLE IF NOT EXISTS contact_messages ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, subject VARCHAR(255) NOT NULL, message TEXT NOT NULL, status VARCHAR(20) DEFAULT 'Unread', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP )"); } catch (PDOException $e) { die("Database Error: " . $e->getMessage()); } // Handle status updates if (isset($_GET['action']) && $_GET['action'] == 'update' && isset($_GET['id'])) { $id = $_GET['id']; $status = $_GET['status']; $stmt = $pdo->prepare("UPDATE contact_messages SET status = ? WHERE id = ?"); $stmt->execute([$status, $id]); header("Location: messages.php?msg=Message status updated"); exit(); } // Handle Delete if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id'])) { $id = $_GET['id']; $stmt = $pdo->prepare("DELETE FROM contact_messages WHERE id = ?"); $stmt->execute([$id]); header("Location: messages.php?msg=Message deleted successfully"); exit(); } // Fetch all messages $stmt = $pdo->query("SELECT * FROM contact_messages ORDER BY created_at DESC"); $messages = $stmt->fetchAll(); ?> <div class="section-card"> <div class="section-header"> <h3>User Messages (from Contact Us)</h3> <?php if(isset($_GET['msg'])): ?> <div class="alert alert-success" style="margin: 0; padding: 5px 15px; display: inline-block; animation: fadeOut 3s forwards 2s;"><?php echo $_GET['msg']; ?></div> <?php endif; ?> </div> <div class="table-responsive"> <table class="admin-table"> <thead> <tr> <th style="width: 60px;">S.No</th> <th>Name</th> <th>Email</th> <th>Subject</th> <th>Date</th> <th>Status</th> <th>Action</th> </tr> </thead> <tbody> <?php if (empty($messages)): ?> <tr> <td colspan="7" style="text-align: center;">No messages found.</td> </tr> <?php else: ?> <?php $sno = 1; foreach ($messages as $msg): ?> <tr class="<?php echo ($msg['status'] == 'Unread') ? 'unread-row' : ''; ?>"> <td><?php echo $sno++; ?></td> <td><strong><?php echo htmlspecialchars($msg['name']); ?></strong></td> <td><?php echo htmlspecialchars($msg['email']); ?></td> <td><?php echo htmlspecialchars($msg['subject']); ?></td> <td><?php echo date('d M, Y', strtotime($msg['created_at'])); ?></td> <td> <span class="badge badge-<?php echo strtolower($msg['status']); ?>"> <?php echo $msg['status']; ?> </span> </td> <td> <div class="action-btns"> <button class="btn-icon view-msg" data-name="<?php echo htmlspecialchars($msg['name']); ?>" data-msg="<?php echo htmlspecialchars($msg['message']); ?>" title="Read Message"> <i class="fa fa-eye"></i> </button> <a href="messages.php?action=update&id=<?php echo $msg['id']; ?>&status=Read" class="btn-icon" title="Mark as Read"> <i class="fa fa-check"></i> </a> <a href="messages.php?action=delete&id=<?php echo $msg['id']; ?>" class="btn-icon text-danger" onclick="return confirm('Delete this message?')" title="Delete"> <i class="fa fa-trash"></i> </a> </div> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> <!-- Simple Message Modal --> <div id="messageModal" class="modal-wrapper" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); z-index:10000; align-items:center; justify-content:center;"> <div class="modal-content-card" style="background:#fff; padding:30px; border-radius:15px; max-width:600px; width:90%; position:relative;"> <h2 id="modalName" style="color:var(--primary-color); margin-bottom:15px;"></h2> <div id="modalText" style="line-height:1.6; color:var(--text-dark); max-height:400px; overflow-y:auto; padding:15px; background:#f8fafc; border-radius:10px;"></div> <button onclick="closeMsgModal()" class="btn-primary" style="margin-top:20px; width:100%;">Close</button> </div> </div> <style> .unread-row { background-color: rgba(212, 164, 40, 0.03); } .badge-unread { background: #fee2e2; color: #ef4444; } .badge-read { background: #dcfce7; color: #10b981; } </style> <script> document.querySelectorAll('.view-msg').forEach(btn => { btn.addEventListener('click', function() { document.getElementById('modalName').innerText = "Message from: " + this.getAttribute('data-name'); document.getElementById('modalText').innerText = this.getAttribute('data-msg'); document.getElementById('messageModal').style.display = 'flex'; }); }); function closeMsgModal() { document.getElementById('messageModal').style.display = 'none'; } </script> <?php require_once 'includes/footer.php'; ?>