Repository navigation
Expand file tree
/
Copy pathinit.php
More file actions
110 lines (83 loc) · 2.93 KB
/
Copy pathinit.php
File metadata and controls
110 lines (83 loc) · 2.93 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
<?php
spl_autoload_register(function ($class) {
$file = 'class/' . lcfirst($class) . '.php';
if(file_exists($file)) {
include $file;
}
$moduleClass = 'modules/installed/'.$class.'/' . lcfirst($class) . '.class.php';
if(file_exists($moduleClass)) {
include $moduleClass;
}
});
new ErrorHandler();
$start = microtime();
session_start();
if (file_exists("install/index.php") && !file_exists("install/install.lock")) {
header("Location: install/");
exit;
}
include 'dbconn.php';
if (!isset($_SESSION['userID']) && isset($_COOKIE["authToken"])) {
$token = $_COOKIE["authToken"];
$checkToken = $db->select("SELECT * FROM loginCookies WHERE LC_token = :token", array(
"token" => $token
));
if ($checkToken) {
if ($checkToken["LC_userAgent"] == $_SERVER['HTTP_USER_AGENT']) {
if ($checkToken["LC_expiry"] > time()) {
$_SESSION['userID'] = $checkToken["LC_user"];
} else {
$db->query("DELETE FROM loginCookies WHERE LC_id = :id", array(
"id" => $checkToken["LC_id"]
));
}
}
}
}
$settings = new settings();
$page = new Page();
$page->loadModuleMetaData();
if (!isset($_GET['page'])) {
$_GET['page'] = $page->landingPage;
}
$pageToLoad = $_GET['page'];
$user = false;
if (!empty($_SESSION['userID'])) {
$user = new user($_SESSION['userID']);
if (isset($user->info->U_id)) {
$user->updateTimer('laston', time());
$user->checkRank();
} else {
$user = false;
unset($_SESSION["userID"]);
}
}
if (!isset($page->modules[$pageToLoad])) {
$page->loadPage("pageNotFound");
} else {
$moduleInfo = $page->modules[$pageToLoad];
/* If the user is logged in load the page */
if ($user) {
/* Always let the user logout no matter what */
if ($_GET["page"] == "logout") {
$page->loadPage('logout');
} else {
/* Let a hook override what page to load */
$hook = new Hook("moduleLoad");
$pageToLoad = $hook->run($pageToLoad, true);
$page->loadPage($pageToLoad);
}
/* If they are not logged in check if they can access the page when not logged in */
} else if (!$moduleInfo["requireLogin"]) {
$page->loadPage($_GET['page']);
/* show the login page */
} else {
$loginPage = "login";
$hook = new Hook("loginPage");
$loginPage = $hook->run($loginPage, true);
$page->loadPage($loginPage);
}
}
$page->printPage();
$page->success = true;
?>