-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.php
More file actions
145 lines (100 loc) · 2.84 KB
/
bootstrap.php
File metadata and controls
145 lines (100 loc) · 2.84 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
<?php
/**
* bootstrap
*
* @package Delus
* @author Sorokin Dmitry Olegovich
*/
// set ABSPATH
define('ABSPATH', __DIR__ . DIRECTORY_SEPARATOR);
// get system version & exceptions
require(ABSPATH . 'includes/sys_ver.php');
require(ABSPATH . 'includes/exceptions.php');
// require dependencies
require(ABSPATH . 'vendor/autoload.php');
// get functions
require(ABSPATH . 'includes/functions.php');
// check config file
if (!file_exists(ABSPATH . 'includes/config.php')) {
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);
} else {
ini_set("display_errors", false);
error_reporting(0);
}
// configure localization
$gettextLoader = new Gettext\Loader\PoLoader();
$gettextTranslator = Gettext\Translations::create('default');
// check system URL
if (URL_CHECK) {
check_system_url();
}
// init system session
init_system_session();
// init system datetime
$date = init_system_datetime();
// init database connection
try {
$db = init_db_connection();
} catch (Exception $e) {
_error('DB_ERROR');
}
// init system
try {
$system = init_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
$smarty = init_smarty();
// get 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
$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 variables
$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);