-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
151 lines (105 loc) · 3 KB
/
bootstrap.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
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
<?php
/**
* bootstrap
*
* @package Delus
* @author Dmitry
*/
// set ABSPATH
define('ABSPATH', __DIR__ . '/');
// get system version & exceptions
require(ABSPATH . 'includes/sys_ver.php');
require(ABSPATH . 'includes/exceptions.php');
// require dependencies
require(ABSPATH . 'vendor/autoload.php');
// check config file
if (!file_exists(ABSPATH . 'includes/config.php')) {
/* the config file doesn't exist -> start the installer */
header('Location: ./install');
}
// get config file
require(ABSPATH . 'includes/config.php');
// set debugging settings
if (DEBUGGING) {
ini_set("display_errors", true);
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT);
} else {
ini_set("display_errors", false);
error_reporting(0);
}
// get functions
require(ABSPATH . 'includes/functions.php');
// check system URL
check_system_url();
// init system session
init_system_session();
// init system datetime
$date = init_system_datetime();
// configure localization
$gettextTranslator = new Gettext\Translator();
$gettextTranslator->register();
// init database connection
try {
$db = init_db_connection();
} catch (Exception $e) {
_error('DB_ERROR');
}
// init system
global $system;
try {
init_system($system);
} catch (Exception $e) {
_error(__("Error"), $e->getMessage());
}
// get system session hash
$session_hash = get_system_session_hash($system['session_hash']);
if (!$session_hash) {
_error(__("Error"), __("Your session hash has been broken, Please contact Delus's support!"));
}
// init smarty
global $smarty;
$smarty = init_smarty();
// get user
global $user;
require_once(ABSPATH . 'includes/class-user.php');
try {
$user = new User();
} catch (Exception $e) {
_error(__("Error"), $e->getMessage());
}
// init essential checks
/* check if system is live */
if (!$system['system_live'] && ((!$user->_logged_in && !isset($override_shutdown)) || ($user->_logged_in && $user->_data['user_group'] != 1))) {
_error(__('System Message'), $system['system_message']);
}
/* check if the viewer IP is banned */
if ($system['viewer_ip_banned']) {
_error(__("System Message"), __("Your IP has been blocked"));
}
/* check if the viewer is banned */
if ($user->_is_banned) {
_error(__("System Message"), $user->_data['user_banned_message']);
}
// 🚀 Starting the web app ...
// log session
$user->log_session();
// get emojis
global $emojis;
$emojis = $user->get_emojis();
// set control panel varibles
if ($user->_is_admin) {
$control_panel['title'] = __("Admin");
$control_panel['url'] = "admincp";
} elseif ($user->_is_moderator) {
$control_panel['title'] = __("Moderator");
$control_panel['url'] = "modcp";
}
// assign global varibles
$smarty->assign('secret', $_SESSION['secret']);
$smarty->assign('session_hash', $session_hash);
$smarty->assign('date', $date);
$smarty->assign('system', $system);
$smarty->assign('user', $user);
$smarty->assign('emojis', $emojis);
$smarty->assign('reactions', $user->get_reactions());
$smarty->assign('reactions_enabled', $user->get_reactions(true));