-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.php
160 lines (136 loc) · 3.92 KB
/
init.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
152
153
154
155
156
157
158
159
160
<?php
//################ Page Start Variables ################
define("START_MEMORY", memory_get_usage());
define("START_TIME", microtime(true));
//############### ERRORS/PHP INI #################
error_reporting(E_ALL ^ E_NOTICE);
ini_set("log_errors", 1);
ini_set("display_errors", 0);
if(!$AJAX_PAGE)
{
ini_set("error_log", dirname(__FILE__)."/administration/logs/php_errors.log");
}
else
{
ini_set("error_log", dirname(__FILE__)."/administration/logs/ajax_errors.log");
}
//################ Redirect if not included ################
if(!defined("INCLUDED"))
{
header('Location: index.php');
exit();
}
//################ Constants ################
define("DOC_ROOT", dirname(__FILE__));
//################ Variables ################
$page_name = array();
$USER = array();
//################ Required Resources ################
$REQUIRED_RESOURCES = array_merge(
array(
//Optional
'iso2country' => false,
'WoW' => false,
'Realm' => false,
'ReCAPTCHA' => false,
//The rest are required and may give an error if they are excluded
'Cookies' => true,
'MySQLi' => true,
'Core' => true,
'Users' => true,
'Templates' => true,
), $REQUIRED_RESOURCES);
//################ Include required classes and pages for each page ################
//Common constant and variables
require_once(DOC_ROOT."/includes/common.php");
//Iso to Country array
if($REQUIRED_RESOURCES['iso2country'])
{
require_once(DOC_ROOT."/includes/iso2country.include.php");
}
//Local configurations
require_once(DOC_ROOT."/includes/config.php");
//Display errors in HTML if debug mode is on
if($DEBUG && !$AJAX_PAGE)
{
ini_set("display_errors", 1);
}
//If admin did not add the REALMs yet
if(!count($REALM))
{
exit("No Realms Exists");
}
//Basic non OOP functions
require_once(DOC_ROOT."/includes/functions.php");
//Cookies class
if($REQUIRED_RESOURCES['Cookies'])
{
require_once(DOC_ROOT."/includes/class/Cookies.class.php");
$cookies = new Cookies();
}
//Initialize MySQL Connection
if($REQUIRED_RESOURCES['MySQLi'])
{
require_once(DOC_ROOT."/includes/class/MySQLi.class.php");
$DB = new MMySQLi($DATABASE_CONNECTION['host'], $DATABASE_CONNECTION['user'], $DATABASE_CONNECTION['pass'], DBNAME, $DATABASE_CONNECTION['port']);
}
//Core related class
if($REQUIRED_RESOURCES['Core'])
{
require_once(DOC_ROOT."/includes/class/Core.class.php");
$cms = new Core();
}
//Users related resources
if($REQUIRED_RESOURCES['Users'])
{
//User class of visitor
require_once(DOC_ROOT."/includes/class/User.class.php");
require_once(DOC_ROOT."/includes/class/Ban.class.php");
$UserSelf = new User(1);
$UserSelf->LoadUserDataFromDB(true, true, true);
//Account Related
require_once(DOC_ROOT."/includes/class/Users.class.php");
$uclass = new Users($UserSelf->UserGlobals(), $USER);
//Display php errors in HTML to administrators
if((int)$USER['access'] >= 4 && !$AJAX_PAGE) //If user is an administrator
{
ini_set("display_errors", 1);
}
//TODO User System
date_default_timezone_set('America/New_York');
}
//Templates class
if($REQUIRED_RESOURCES['Templates'])
{
require_once(DOC_ROOT."/includes/class/Templates.class.php");
$templates = new Templates($usetemplate);
}
//WoW resources class
if($REQUIRED_RESOURCES['WoW'])
{
require_once(DOC_ROOT."/includes/class/WoW.class.php");
}
//Realm related class
if($REQUIRED_RESOURCES['Realm'])
{
require_once(DOC_ROOT."/includes/class/Realm.class.php");
}
//Recaptcha library
if($REQUIRED_RESOURCES['ReCAPTCHA'])
{
require_once("includes/recaptcha/recaptchalib.php");
}
//################ Maintenance ################
if($OFFLINE_MAINTENANCE && $USER['access'] < 4 && !$AJAX_PAGE)
{
//Login page and payment handler page should not be affected by maintenance
if(strpos($_SERVER['PHP_SELF'], 'login.php') === false && strpos($_SERVER['PHP_SELF'], 'payments.php') === false)
{
$cms->BannedAccess(true);
eval($cms->SetPageAccess(ACCESS_ALL));
$page_name[] = array("Under Maintenance");
eval($templates->Output("maintenance"));
exit();
}
}
?>