-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·156 lines (155 loc) · 5.48 KB
/
index.php
File metadata and controls
executable file
·156 lines (155 loc) · 5.48 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
<?php
//TODO: Lots of commenting
//Load config and modules
ob_start();
require("config.php");
require("modules/class.Core.php");
require("modules/class.MySQL.php");
require("modules/class.Page.php");
require("modules/class.Utils.php");
require("modules/page/class.ErrorPage.php");
error_reporting(E_ALL ^ E_NOTICE); //Get rid of annoying notices
//Initialize the core with MySQL information
$core = new Core(new MySQL(MYSQL_HOST, MYSQL_PORT, MYSQL_DB, MYSQL_USER, MYSQL_PASSWORD));
//Check if ?p= was not entered
if (!array_key_exists("p", $_GET)) {
require("modules/page/class.HomePage.php");
$home = new HomePage("home", $core);
$home->writePage();
return;
}
//Switch ?p= and do stuff for each page
switch ($_GET['p']) {
case "home":
require("modules/page/class.HomePage.php");
$page = new HomePage("home", $core);
$page->writePage();
break;
case "forgot":
require("modules/page/class.ForgotPage.php");
$page = new ForgotPage("forgot", $core);
$page->writePage();
break;
case "login":
if ($_SESSION['loggedIn']) {
$_SESSION['loggedIn'] = false;
unset($_SESSION['email']);
header("Location: ?p=home");
}
else {
require("modules/page/class.LoginPage.php");
$page = new LoginPage("login", $core);
$page->writePage();
}
break;
case "json":
require("modules/page/class.Json.php");
$page = new Json("json", $core);
$page->writePage();
break;
case "me":
//Make sure user is signed in before showing me
if (!$_SESSION['loggedIn']) {
$page = new ErrorPage("autherror", $core, "Authentication", "You need to be signed in to access this page!");
$page->writePage();
break;
}
require("modules/page/class.UserPage.php");
$page = new UserPage("me", $core);
$page->writePage();
break;
case "directory":
//Make sure user is signed in before showing directory
if (!$_SESSION['loggedIn'] || $core->getUser($_SESSION['email'])['rank'] < 8) {
$page = new ErrorPage("autherror", $core, "Authentication", "You don't have enough permissions to access this page!");
$page->writePage();
break;
}
require("modules/page/class.DirectoryPage.php");
$page = new DirectoryPage("directory", $core);
$page->writePage();
break;
case "admindir":
//Make sure user is signed in before showing directory
if (!$_SESSION['loggedIn'] || $core->getUser($_SESSION['email'])['rank'] < 8) {
$page = new ErrorPage("autherror", $core, "Authentication", "You don't have enough permissions to access this page!");
$page->writePage();
break;
}
require("modules/page/class.AdminDirectoryPage.php");
$page = new AdminDirectoryPage("admindir", $core);
$page->writePage();
break;
case "konami":
//Make sure user is signed in before showing directory
if (!$_SESSION['loggedIn'] || $core->getUser($_SESSION['email'])['rank'] < 8) {
$page = new ErrorPage("autherror", $core, "Authentication", "You don't have enough permissions to access this page!");
$page->writePage();
break;
}
header("Location: ?p=json&r=konami");
case "parentdir":
//Make sure user is signed in before showing directory
if (!$_SESSION['loggedIn'] || $core->getUser($_SESSION['email'])['rank'] < 8) {
$page = new ErrorPage("autherror", $core, "Authentication", "You don't have enough permissions to access this page!");
$page->writePage();
break;
}
require("modules/page/class.ParentDirectoryPage.php");
$page = new ParentDirectoryPage("parentdir", $core);
$page->writePage();
break;
case "del":
if (!$_SESSION['loggedIn'] || $core->getUser($_SESSION['email'])['rank'] < 10) {
$page = new ErrorPage("autherror", $core, "Authentication", "You don't have enough permissions to access this page!");
$page->writePage();
break;
}
if ($core->getUser($_SESSION['email'])['id'] == $_GET['id']) {
$page = new ErrorPage("autherror", $core, "Action", "You can't delete your own account!");
$page->writePage();
break;
}
require("modules/page/class.DeletePage.php");
$page = new DeletePage("del", $core);
$page->writePage();
break;
case "checkin":
if (!$_SESSION['loggedIn'] || $core->getUser($_SESSION['email'])['rank'] < 9) {
$page = new ErrorPage("autherror", $core, "Authentication", "You don't have enough permissions to access this page!");
$page->writePage();
break;
}
require("modules/page/class.CheckinPage.php");
require("modules/page/class.Ritterisms.php");
$page = new CheckinPage("checkin", $core);
$page->writePage();
break;
case "broadcast":
if (!$_SESSION['loggedIn'] || $core->getUser($_SESSION['email'])['rank'] < 9) {
$page = new ErrorPage("autherror", $core, "Authentication", "You don't have enough permissions to access this page!");
$page->writePage();
break;
}
require("modules/page/class.BroadcastPage.php");
$page = new BroadcastPage("broadcast", $core);
$page->writePage();
break;
case "confirm":
if (!$_SESSION['loggedIn'] || $core->getUser($_SESSION['email'])['rank'] < 9) {
$page = new ErrorPage("autherror", $core, "Authentication", "You don't have enough permissions to access this page!");
$page->writePage();
break;
}
require("modules/page/class.ConfirmPage.php");
$page = new ConfirmPage("confirm", $core);
$page->writePage();
break;
default:
$page = new ErrorPage("404", $core, "404", "Page not found.");
header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); //Set 404 HTTP header
$page->writePage();
break;
}
ob_end_flush();
?>