HEX
Server: nginx/1.24.0
System: Linux webserver-one 6.8.0-101-generic #101-Ubuntu SMP PREEMPT_DYNAMIC Mon Feb 9 10:15:05 UTC 2026 x86_64
User: www-data (33)
PHP: 8.4.18
Disabled: NONE
Upload Files
File: /srv/www/rectt-csmcri.res.in/admin_html/admin_dashboard.php
<?php
session_start();
// ini_set("display_errors", 1);
// ini_set("display_startup_errors", 1);
// error_reporting(E_ALL);

require_once dirname(__DIR__) . '/public_html/sites/config/config.php';

if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header("Location: admin_login.php");
    exit;
}

// 1) basic session checks
if (
    empty($_SESSION['admin_id']) || empty($_SESSION['session_token'])
) {
    header("Location: admin_login.php");
    exit;
}

// 2) pull the token (and role) from the database
$stmt = $conn->prepare("SELECT session_token FROM admin_users WHERE id = ?");
$stmt->bind_param("i", $_SESSION['admin_id']);
$stmt->execute();
$result = $stmt->get_result()->fetch_assoc();
$stmt->close();

// 3) if the DB token is gone or doesn’t match the session’s, force logout
if (
    ! $result || $result['session_token'] !== $_SESSION['session_token']
) {
    session_unset();
    session_destroy();
    header("Location: admin_login.php?error=" . urlencode("Your session has expired."));
    exit;
}


$role = $_SESSION['admin_role'] ?? '';

if ($role === 'reviewer') {
    header('Location: view.php');
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Admin Dashboard</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        body {
            background: #f0f4f8;
            font-family: 'Segoe UI', sans-serif;
        }

        .dashboard-card {
            max-width: 500px;
            margin: auto;
            border-radius: 16px;
            background-color: #fff;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
        }

        .dashboard-header {
            font-weight: 600;
            text-align: center;
            margin-bottom: 30px;
            color: #222;
        }

        .dashboard-btn {
            width: 100%;
            padding: 12px 20px;
            font-size: 16px;
            margin-bottom: 14px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            transition: all 0.2s ease-in-out;
        }

        .dashboard-btn:hover {
            transform: translateY(-2px);
        }

        .logout-btn {
            margin-top: 20px;
            border-radius: 10px;
        }

        .bi {
            font-size: 1.1rem;
        }
    </style>
</head>

<body>
    <div class="container py-5">
        <div class="dashboard-card p-4">
            <h2 class="dashboard-header">Admin Dashboard</h2>
            <div>
                <?php if ($role === 'superadmin'): ?>
                    <a href="admin_register.php" class="btn btn-primary dashboard-btn">
                        <i class="bi bi-person-plus"></i> Create User
                    </a>
                    <a href="manage_admin_users.php" class="btn btn-danger dashboard-btn">
                        <i class="bi bi-key"></i> Reset User Password
                    </a>
                <?php endif; ?>

                <a href="view.php" class="btn btn-info text-white dashboard-btn">
                    <i class="bi bi-eye"></i> View Applications
                </a>

                <a href="manage_advertisement.php" class="btn btn-success dashboard-btn">
                    <i class="bi bi-bullhorn"></i> Manage Advertisements
                </a>

                <a href="manage_posts.php" class="btn btn-warning dashboard-btn">
                    <i class="bi bi-file-text"></i> Manage Posts
                </a>

                <a href="generate_excel.php" class="btn btn-dark dashboard-btn">
                    <i class="bi bi-file-earmark-excel"></i> Generate Excel Sheet
                </a>

                <a href="admin_logout.php" class="btn btn-outline-secondary dashboard-btn logout-btn">
                    <i class="bi bi-box-arrow-right"></i> Logout
                </a>
            </div>
        </div>
    </div>
</body>

</html>