-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
47 lines (43 loc) · 1.57 KB
/
dashboard.php
File metadata and controls
47 lines (43 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
include 'config.php'; // Include configuration and authentication logic
if (!isset($_SESSION['username'])) {
header("Location: login.php"); // Redirect to login if not authenticated
exit();
}
// Check user role for access control
if ($_SESSION['role'] !== 'admin') {
// For non-admin users, restrict access to certain pages
$restrictedPages = ['teams', 'tnc', 'urls']; // Pages restricted for non-admin users
// Get the requested page from the URL
$currentPage = basename($_SERVER['PHP_SELF'], '.php');
if (in_array($currentPage, $restrictedPages)) {
header("Location: unauthorized.php");
exit();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dashboard</title>
<!-- Add your CSS styles -->
</head>
<body>
<h1>Welcome to Dashboard, <?php echo $_SESSION['username']; ?></h1>
<!-- Dashboard content -->
<ul>
<li><a href="customerdocs.html" class="menu-btn">Customer Docs</a></li>
<li><a href="about.html" class="menu-btn">About</a></li>
<li><a href="services.html" class="menu-btn">Services</a></li>
<li><a href="coming_soon.html" class="menu-btn">Staff Docs</a></li>
<?php if ($_SESSION['role'] === 'admin') { ?>
<li><a href="#teams" class="menu-btn">#Teams</a></li>
<li><a href="tnc.html" class="menu-btn">T&C</a></li>
<li><a href="urls.html" class="menu-btn">Links</a></li>
<?php } ?>
<!-- Add logout link -->
<li><a href="logout.php" class="menu-btn">Logout</a></li>
</ul>
</body>
</html>