-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
89 lines (79 loc) · 3.31 KB
/
index.php
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
<?php session_start(); ?>
<?php
include_once 'utils/protect_route.php';
// include_once 'utils/display_message.php';
// displayMessage();
// Determine which page to load based on the URL
$path = $_SERVER['REQUEST_URI'];
if ($path === '/signup') {
include_once 'frontend/html/forms/signup-page.php';
// include 'utils/display_message.php';
exit;
} else if ($path === "/login") {
include_once 'frontend/html/forms/login-page.php';
// include_once 'utils/display_message.php';
exit;
} else if ($path === "/logout") {
// Protect route by checking if there is an active session
// include_once 'utils/display_message.php';
protectRoute('backend/user/logout.php');
} else if ($path === "/profile") {
// include 'utils/display_message.php';
protectRoute('frontend/html/profile-page.php');
} else if ($path === "/edit-profile") {
// include 'utils/display_message.php';
protectRoute('frontend/html/forms/edit-profile-page.php');
} else if ($path === "/change-password") {
// include 'utils/display_message.php';
protectRoute('frontend/html/forms/change-password-page.php');
} else if ($path === "/change-profile-picture") {
// include 'utils/display_message.php';
protectRoute('frontend/html/forms/change-profile-picture-page.php');
}
// HOME PAGE
else if ($path === "/" || $path === "") {
include_once 'frontend/html/home-page.php';
// include 'utils/display_message.php';
exit;
}
// LIBRARY
else if ($path === "/library") {
// include 'utils/display_message.php';
protectRoute('frontend/html/library/library-page.php');
} elseif (preg_match('/\/library\/book\?id=\d+/', $path)) {
// The URL matches the expected pattern
// include 'utils/display_message.php';
protectRoute("frontend/html/library/book-detail-page.php");
} else if ($path === "/borrowed-books") {
// include 'utils/display_message.php';
protectRoute('frontend/html/library/borrowed-books-page.php');
} else if ($path === "/filtered-books") {
// include 'utils/display_message.php';
protectRoute('frontend/html/library/filtered-books-page.php');
}
// Filtering in Library
elseif (preg_match('/\/library\/filter\?genre=\d+/', $path)) {
// The URL matches the expected pattern
// include 'utils/display_message.php';
protectRoute("frontend/html/library/filtered-books-page.php");
} elseif (preg_match('/\/library\/filter\?author=\d+/', $path)) {
// The URL matches the expected pattern
// include 'utils/display_message.php';
protectRoute("frontend/html/library/filtered-books-page.php");
} elseif (preg_match('/\/library\/filter\?genre=\d+&author=\d+$/', $path)) {
// The URL matches the expected pattern
// include 'utils/display_message.php';
protectRoute("frontend/html/library/filtered-books-page.php");
}
// ADMIN PAGE
else if ($path === "/admin") {
include_once 'admin/index.php';
// include 'utils/display_message.php';
exit;
}
// PAGE NOT FOUND
else {
include_once 'frontend/html/page-not-found-page.php';
exit;
}
?>