-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
165 lines (133 loc) · 4.85 KB
/
Copy pathindex.php
File metadata and controls
165 lines (133 loc) · 4.85 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
// Start the PHP session so the website can remember logged-in users.
session_start();
// DM Studio AI - Front Controller.
// This file controls which page is shown based on the route in the URL.
// Navigation token used in prototype URLs.
// This is not a security feature.
$navToken = "dmstudioai";
// Project root folder.
$rootPath = __DIR__;
// Allowed routes only.
$routes = [
// Public pages.
"home" => "pages/home.php",
"courses" => "pages/courses.php",
"tools" => "pages/tools.php",
"about" => "pages/about.php",
"intro-lesson" => "pages/intro-lesson.php",
// Privacy and security page.
"privacy-security" => "security/privacy-security.php",
// Dashboard pages.
"student" => "pages/student-dashboard.php",
"teacher" => "pages/teacher-dashboard.php",
"manager" => "pages/manager-dashboard.php",
"owner" => "pages/owner-dashboard.php",
// Teacher task pages.
"create-task" => "pages/create-task.php",
"view-tasks" => "pages/view-tasks.php",
"assign-task" => "pages/assign-task.php",
// Student task pages.
"my-tasks" => "pages/my-tasks.php",
"student-task" => "pages/student-task.php",
// User management pages.
"users" => "pages/user-management.php",
"student-profile" => "pages/student-profile.php",
"review-submission" => "pages/review-submission.php",
// Student quick action pages.
"lessons" => "pages/lessons.php",
"submit-work" => "pages/submit-work.php",
"feedback" => "pages/feedback.php",
// Authentication pages.
"login" => "pages/login.php",
"register" => "pages/register.php"
];
// Page titles.
$pageTitles = [
// Public page titles.
"home" => "DM Studio AI",
"courses" => "Courses | DM Studio AI",
"tools" => "Tools | DM Studio AI",
"about" => "About | DM Studio AI",
"intro-lesson" => "pages/intro-lesson.php",
// Privacy and security page title.
"privacy-security" => "Privacy & Security | DM Studio AI",
// Dashboard page titles.
"student" => "Student Dashboard | DM Studio AI",
"teacher" => "Teacher Dashboard | DM Studio AI",
"manager" => "Manager Dashboard | DM Studio AI",
"owner" => "Owner Dashboard | DM Studio AI",
// Teacher task page titles.
"create-task" => "Create Task | DM Studio AI",
"view-tasks" => "View Tasks | DM Studio AI",
"assign-task" => "Assign Task | DM Studio AI",
// Student task page titles.
"my-tasks" => "My Tasks | DM Studio AI",
"student-task" => "Student Task | DM Studio AI",
// User management page titles.
"users" => "User Management | DM Studio AI",
"student-profile" => "Student Profile | DM Studio AI",
"review-submission" => "Review Submission | DM Studio AI",
// Student quick action page titles.
"lessons" => "Lessons | DM Studio AI",
"submit-work" => "Submit Work | DM Studio AI",
"feedback" => "Feedback | DM Studio AI",
// Authentication page titles.
"login" => "Login | DM Studio AI",
"register" => "Register | DM Studio AI"
];
// Get route from URL, or use home as default.
$route = $_GET["route"] ?? "home";
// Clean route value.
$route = strtolower(trim($route));
// Track errors.
$isInvalidRoute = false;
$isMissingFile = false;
// If route does not exist, show page not found message.
if (!array_key_exists($route, $routes)) {
$isInvalidRoute = true;
$pageTitle = "Page Not Found | DM Studio AI";
$pageFile = null;
} else {
// Set page title and page file.
$pageTitle = $pageTitles[$route] ?? "DM Studio AI";
$pageFile = $rootPath . "/" . $routes[$route];
// Safety check for missing page files.
if (!file_exists($pageFile)) {
$isMissingFile = true;
$pageTitle = "Page File Missing | DM Studio AI";
$pageFile = null;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo htmlspecialchars($pageTitle); ?></title>
<?php include $rootPath . "/includes/head.php"; ?>
</head>
<body>
<?php include $rootPath . "/includes/header.php"; ?>
<main>
<?php if ($isInvalidRoute): ?>
<section class="page-hero">
<h1>Page Not Found</h1>
<p>The page you requested does not exist. Please check the link or return to the homepage.</p>
<a href="index.php?route=home&nav=<?php echo htmlspecialchars($navToken); ?>" class="hero-btn">
Back to Home
</a>
</section>
<?php elseif ($isMissingFile): ?>
<section class="page-hero">
<h1>Page File Missing</h1>
<p>The route exists, but the page file could not be found.</p>
<p>Please check that this file exists:</p>
<p><strong>security/privacy-security.php</strong></p>
</section>
<?php elseif ($pageFile !== null): ?>
<?php include $pageFile; ?>
<?php endif; ?>
</main>
<?php include $rootPath . "/includes/footer.php"; ?>
</body>
</html>