🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:index.php
<?php /** * ARCHI-TECH Admin Dashboard Index */ require_once __DIR__ . '/../includes/db.php'; require_once __DIR__ . '/../includes/functions.php'; // Check user role credentials check_admin_auth(); // Safe counter fallback assignments $counts = [ 'services' => 0, 'projects' => 0, 'gallery' => 0, 'testimonials' => 0, 'team' => 0, 'messages_unread' => 0, 'messages_total' => 0, 'pdf_uploads' => 0 ]; $recent_messages = []; try { $counts['services'] = $pdo->query("SELECT COUNT(*) FROM services")->fetchColumn(); $counts['projects'] = $pdo->query("SELECT COUNT(*) FROM projects")->fetchColumn(); $counts['gallery'] = $pdo->query("SELECT COUNT(*) FROM gallery")->fetchColumn(); $counts['testimonials'] = $pdo->query("SELECT COUNT(*) FROM testimonials")->fetchColumn(); $counts['team'] = $pdo->query("SELECT COUNT(*) FROM team_members")->fetchColumn(); $counts['messages_unread'] = $pdo->query("SELECT COUNT(*) FROM contact_messages WHERE is_read = 0")->fetchColumn(); $counts['messages_total'] = $pdo->query("SELECT COUNT(*) FROM contact_messages")->fetchColumn(); $counts['pdf_uploads'] = $pdo->query("SELECT COUNT(*) FROM pdf_uploads")->fetchColumn(); // Fetch 5 most recent customer inquiries $msg_stmt = $pdo->query("SELECT * FROM contact_messages ORDER BY id DESC LIMIT 5"); $recent_messages = $msg_stmt->fetchAll(); } catch (PDOException $e) { // Setup fallback variables for developer local previews $counts = [ 'services' => 11, 'projects' => 2, 'gallery' => 4, 'testimonials' => 3, 'team' => 3, 'messages_unread' => 1, 'messages_total' => 1, 'pdf_uploads' => 0 ]; $recent_messages = [ [ 'id' => 1, 'name' => 'Dilan Perera', 'email' => 'dilan@zenith.com', 'phone' => '0717771871', 'subject' => 'Corporate Headquarter Concept Proposal', 'message' => 'We are interested in mapping design options for our upcoming 10-story eco office complex in Colombo.', 'is_read' => 0, 'created_at' => date('Y-m-d H:i:s') ] ]; } require_once __DIR__ . '/header.php'; require_once __DIR__ . '/navbar.php'; ?> <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-4 border-bottom border-secondary"> <h1 class="h2 text-white text-uppercase" style="letter-spacing: -0.01em; font-family: 'Syne', sans-serif;">Dashboard</h1> <div class="btn-toolbar mb-2 mb-md-0"> <a href="<?= BASE_URL ?>admin/pdf_extract.php" class="btn btn-gold btn-sm py-2 px-3"><i class="bi bi-file-earmark-pdf me-2"></i>Upload PDF Portfolio</a> </div> </div> <!-- Alert Banner about active database --> <?php if (empty($pdo)): ?> <div class="alert alert-danger border-0 bg-danger text-white mb-4"> <i class="bi bi-exclamation-octagon-fill me-2"></i> <strong>Warning:</strong> Database connections are currently offline. Displaying simulated administrative figures. Please start MySQL. </div> <?php endif; ?> <!-- Stat Counter Cards --> <div class="row g-4 mb-5"> <div class="col-lg-3 col-md-6 col-sm-6"> <div class="glass-card p-4"> <div class="d-flex align-items-center justify-content-between"> <div> <span class="d-block small text-muted text-uppercase fw-bold" style="font-size: 0.75rem;">Total Projects</span> <h3 class="display-6 fw-bold text-accent-color mt-1 mb-0"><?= $counts['projects'] ?></h3> </div> <div class="fs-1 text-muted opacity-50"><i class="bi bi-kanban"></i></div> </div> </div> </div> <div class="col-lg-3 col-md-6 col-sm-6"> <div class="glass-card p-4"> <div class="d-flex align-items-center justify-content-between"> <div> <span class="d-block small text-muted text-uppercase fw-bold" style="font-size: 0.75rem;">Company Services</span> <h3 class="display-6 fw-bold text-accent-color mt-1 mb-0"><?= $counts['services'] ?></h3> </div> <div class="fs-1 text-muted opacity-50"><i class="bi bi-briefcase"></i></div> </div> </div> </div> <div class="col-lg-3 col-md-6 col-sm-6"> <div class="glass-card p-4"> <div class="d-flex align-items-center justify-content-between"> <div> <span class="d-block small text-muted text-uppercase fw-bold" style="font-size: 0.75rem;">Inbound Messages</span> <h3 class="display-6 fw-bold text-accent-color mt-1 mb-0"><?= $counts['messages_unread'] ?> <span class="fs-6 text-muted">/ <?= $counts['messages_total'] ?></span></h3> </div> <div class="fs-1 text-muted opacity-50"><i class="bi bi-envelope"></i></div> </div> </div> </div> <div class="col-lg-3 col-md-6 col-sm-6"> <div class="glass-card p-4"> <div class="d-flex align-items-center justify-content-between"> <div> <span class="d-block small text-muted text-uppercase fw-bold" style="font-size: 0.75rem;">PDF Uploads</span> <h3 class="display-6 fw-bold text-accent-color mt-1 mb-0"><?= $counts['pdf_uploads'] ?></h3> </div> <div class="fs-1 text-muted opacity-50"><i class="bi bi-file-earmark-pdf"></i></div> </div> </div> </div> </div> <!-- Section Layout --> <div class="row g-5"> <!-- Recent Messages Table --> <div class="col-lg-8"> <div class="glass-card p-4 mb-4"> <h3 class="h5 text-white text-uppercase mb-4" style="letter-spacing: 0.05em;"><i class="bi bi-chat-left-dots text-accent-color me-2"></i>Recent Messages</h3> <div class="table-responsive"> <table class="table table-dark table-striped table-hover align-middle border-secondary table-dark-custom"> <thead> <tr> <th scope="col" style="font-size: 0.8rem; text-transform: uppercase;">From</th> <th scope="col" style="font-size: 0.8rem; text-transform: uppercase;">Subject</th> <th scope="col" style="font-size: 0.8rem; text-transform: uppercase;">Received</th> <th scope="col" style="font-size: 0.8rem; text-transform: uppercase;">Status</th> <th scope="col" style="font-size: 0.8rem; text-transform: uppercase; text-align: center;">Action</th> </tr> </thead> <tbody> <?php if (!empty($recent_messages)): ?> <?php foreach ($recent_messages as $msg): ?> <tr> <td> <strong><?= sanitize_input($msg['name']) ?></strong> <small class="d-block text-muted"><?= sanitize_input($msg['email']) ?></small> </td> <td><?= sanitize_input(substr($msg['subject'], 0, 40)) ?><?= strlen($msg['subject']) > 40 ? '...' : '' ?></td> <td class="small text-muted"><?= date('M d, Y', strtotime($msg['created_at'])) ?></td> <td> <?php if (intval($msg['is_read']) === 1): ?> <span class="badge bg-secondary">Read</span> <?php else: ?> <span class="badge bg-warning text-dark fw-bold">Unread</span> <?php endif; ?> </td> <td align="center"> <a href="<?= BASE_URL ?>admin/messages.php?id=<?= $msg['id'] ?>" class="btn btn-outline-light btn-sm"><i class="bi bi-eye"></i></a> </td> </tr> <?php endforeach; ?> <?php else: ?> <tr> <td colspan="5" class="text-center text-muted py-4">No inbox messages available.</td> </tr> <?php endif; ?> </tbody> </table> </div> <div class="text-end mt-3"> <a href="<?= BASE_URL ?>admin/messages.php" class="small text-accent-color text-uppercase fw-bold text-decoration-none">Open Full Message Inbox <i class="bi bi-arrow-right ms-1"></i></a> </div> </div> </div> <!-- Quick Shortcuts Panel --> <div class="col-lg-4"> <div class="glass-card p-4"> <h3 class="h5 text-white text-uppercase mb-4" style="letter-spacing: 0.05em;"><i class="bi bi-gear-fill text-accent-color me-2"></i>Quick Tasks</h3> <div class="d-grid gap-3"> <a href="<?= BASE_URL ?>admin/projects.php?action=add" class="btn btn-outline-light text-start p-3"><i class="bi bi-plus-circle-fill text-accent-color me-3"></i>Create Project Entry</a> <a href="<?= BASE_URL ?>admin/services.php?action=add" class="btn btn-outline-light text-start p-3"><i class="bi bi-plus-circle-fill text-accent-color me-3"></i>Create Service Category</a> <a href="<?= BASE_URL ?>admin/gallery.php" class="btn btn-outline-light text-start p-3"><i class="bi bi-cloud-upload-fill text-accent-color me-3"></i>Manage Photo Gallery</a> <a href="<?= BASE_URL ?>admin/settings.php" class="btn btn-outline-light text-start p-3"><i class="bi bi-sliders me-3 text-accent-color"></i>Update Site Settings</a> </div> </div> </div> </div> <?php require_once __DIR__ . '/footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder