47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
|
|
<?php
|
|
session_start();
|
|
|
|
// Protect admin pages
|
|
if (basename($_SERVER['PHP_SELF']) != 'login.php') {
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
}
|
|
|
|
$current_page = basename($_SERVER['PHP_SELF']);
|
|
|
|
// Fetch site title from settings
|
|
require_once __DIR__ . '/../../db/config.php';
|
|
$pdo = db();
|
|
$stmt = $pdo->query("SELECT setting_value FROM `settings` WHERE setting_key = 'site_title'");
|
|
$site_title = $stmt->fetchColumn();
|
|
if (!$site_title) {
|
|
$site_title = 'Admin Panel';
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo htmlspecialchars($site_title); ?></title>
|
|
<link rel="stylesheet" href="style.css?v=<?php echo time(); ?>">
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<?php if (isset($_SESSION['user_id'])): ?>
|
|
<div class="sidebar">
|
|
<a href="index.php" class="<?php echo ($current_page == 'index.php') ? 'active' : ''; ?>">Dashboard</a>
|
|
<a href="users.php" class="<?php echo ($current_page == 'users.php') ? 'active' : ''; ?>">User Management</a>
|
|
<a href="analytics.php" class="<?php echo ($current_page == 'analytics.php') ? 'active' : ''; ?>">Analytics</a>
|
|
<a href="pages.php" class="<?php echo ($current_page == 'pages.php' || $current_page == 'edit_page.php') ? 'active' : ''; ?>">Pages</a>
|
|
<a href="settings.php" class="<?php echo ($current_page == 'settings.php') ? 'active' : ''; ?>">Settings</a>
|
|
<a href="logout.php">Logout</a>
|
|
</div>
|
|
<div class="main-content">
|
|
<?php endif; ?>
|