-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
107 lines (99 loc) · 2.58 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
// var_dump($_SERVER["DOCUMENT_ROOT"]); // "/www/kinsta/public/simple-cms"
// start session; required on any page SESSION global variable is used
session_start();
require "actions/functions.php";
// echo "<br>".$test; // sanity check
// current session credentials
// if (isLoggedIn()) {
// print_r($_SESSION["user"]);
// }
// Uniform Resource Identifier requested by prior page i.e. header("Location: X");
$path = $_SERVER["REQUEST_URI"];
// var_dump($_SERVER["REQUEST_URI"]); // current route
// // remove query from URL in GET scenario
$path = parse_url($path, PHP_URL_PATH);
// remove starting slash
$path = trim($path, "/");
switch ($path) {
// actions
case "signup_action":
require "actions/auth/signup.php";
break;
case "login_action":
require "actions/auth/login.php";
break;
case "logout_action":
require "actions/auth/logout.php";
break;
case "addpost_action":
require "actions/post/add.php";
break;
case "updatepost_action":
require "actions/post/update.php";
break;
case "deletepost_action":
require "actions/post/delete.php";
break;
case "adduser_action":
require "actions/user/add.php";
break;
case "updateuser_action":
require "actions/user/update.php";
break;
case "changepassword_action":
require "actions/user/changepassword.php";
break;
case "deleteuser_action":
require "actions/user/delete.php";
break;
// pages
case "signup":
$subpage_title = "Sign Up";
require "pages/signup.php";
break;
case "login":
$subpage_title = "Login";
require "pages/login.php";
break;
case "dashboard":
$subpage_title = "Dashboard";
require "pages/dashboard.php";
break;
case "post":
// $subpage_title = "Post";
require "pages/post.php";
break;
case "managepost":
$subpage_title = "Manage Posts";
require "pages/post/manage.php";
break;
case "addpost":
$subpage_title = "Add New Post";
require "pages/post/add.php";
break;
case "editpost":
$subpage_title = "Edit Post";
require "pages/post/edit.php";
break;
case "manageuser":
$subpage_title = "Manage Users";
require "pages/user/manage.php";
break;
case "adduser":
$subpage_title = "Add New User";
require "pages/user/add.php";
break;
case "edituser":
$subpage_title = "Edit User";
require "pages/user/edit.php";
break;
case "changepassword":
$subpage_title = "Change Password";
require "pages/user/changepassword.php";
break;
default:
$subpage_title = "Home";
require "pages/home.php";
break;
}