-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
109 lines (99 loc) · 3.88 KB
/
Copy pathindex.php
File metadata and controls
109 lines (99 loc) · 3.88 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
<?php
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
session_start();
function display($path){
$file = fopen($path,"r");
while (!feof($file)) {
$line = fgets($file);
echo $line;
}
fclose($file);
}
display("matter/top.htm");
if (sizeof($_GET) == 0) {
display("matter/main.htm");
}
else {
switch ($_GET["Page"]) {
case "Home":
display("matter/main.htm");
break;
case "Dashboard":
if ($_SESSION['user_type'] == 'student'){
echo "<script>window.addEventListener('load', loadLevels); window.addEventListener('load', filterCourses);</script>";
display("matter/dashboard.htm");
}
elseif ($_SESSION['user_type'] == 'staff'){
display("matter/staffdash.htm");
echo "<script>const userID ='" . $_SESSION['user_id'] . "';</script>";
echo "<script>window.addEventListener('load', fetchApt);</script>";
echo "<script>window.addEventListener('load', onLoad);</script>";
}
else {
echo "Invalid user type";
}
break;
case "StaffList":
$courseID = isset($_GET["course_id"]) ? $_GET["course_id"] : null; //check course_id provided
if ($courseID) {
// Pass the course_id as a JavaScript variable for use in the staff list
echo "<script>const courseID = '$courseID'; window.addEventListener('load', loadStaff);</script>";
display("matter/list_staff.htm");
} else {
echo "<p>No course selected!</p>";
}
break;
case "StaffCourses":
if ($_SESSION['user_type'] == 'staff'){
display("matter/staffcourses.htm");
echo "<script>window.addEventListener('load', fetchCourses);</script>";
}
else {
echo "Invalid user type";
}
break;
case "AddCourse":
if ($_SESSION['user_type'] == 'staff') {
display("matter/addcourse.htm");
} else {
echo "Invalid user type";
}
break;
case "Calendar":
$userID = isset($_GET['user_id']) ? $_GET["user_id"] : null;
$use_session = isset($_GET['session']) ? $_GET['session'] : null;
if ($use_session){
$userID = $_SESSION['user_id'];
}
if ($userID){
echo "<script>const userID ='" . $userID . "';</script>";
}
echo "<script>window.addEventListener('load', onLoad); window.addEventListener('load', function(){ getUserNames('$userID'); });</script>";
display('matter/calendar.htm');
break;
case "Event":
$eventID = isset($_GET['event_id']) ? $_GET["event_id"] : null;
if ($eventID){
echo "<script>const eventID ='" . $eventID . "'; window.addEventListener('load', popoutEvent);</script>";
echo "<script>window.addEventListener('load', onLoad); window.addEventListener('load', forceMobile);</script>";
}
display('matter/event.htm');
break;
case "PendingRequests":
if ($_SESSION['user_type'] == 'staff') {
// Add the Pending Requests page and load the corresponding JS function
echo "<script>window.addEventListener('load', loadPendingRequests);</script>";
display("matter/pending.htm");
} else {
echo "<p>Unauthorized access!</p>";
}
break;
default:
echo "<p>Page not found!</p>";
break;
}
}
display("matter/bot.htm");
?>