forked from WoWRoster/wowroster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.php
369 lines (324 loc) · 8.31 KB
/
settings.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<?php
/**
* WoWRoster.net WoWRoster
*
* Here is where all the magic happens
* All of the includes, defines, locales, this file loads everything
*
*
* @copyright 2002-2011 WoWRoster.net
* @license http://www.gnu.org/licenses/gpl.html Licensed under the GNU General Public License v3.
* @version SVN: $Id$
* @link http://www.wowroster.net
* @since File available since Release 1.7.0
* @package WoWRoster
*/
if( !defined('IN_ROSTER') )
{
exit('Detected invalid access to this file!');
}
/**
* Set PHP error reporting
*/
error_reporting(E_ALL);
/**
* Attempt to detect a current session and not set it
* Sometimes it doesn't work...
*/
if( session_id() == '' )
{
session_start();
}
// Be paranoid with passed vars
// Destroy GET/POST/Cookie variables from the global scope
if( intval(ini_get('register_globals')) != 0 )
{
foreach( $_REQUEST as $key => $val )
{
if( isset($$key) )
{
unset($$key);
}
}
}
// Unset old style global vars, we use only php 4.3+ style globals
unset($HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS);
/**
* Set magic quotes runtime off
* Checking for function existance for php6
*/
if( function_exists('set_magic_quotes_runtime') )
{
ini_set('magic_quotes_runtime', 0);
}
/**
* Begin Roster Timing
*/
$sec = explode(' ', microtime());
define('ROSTER_STARTTIME', $sec[0] + $sec[1]);
define('REQUEST_TIME', (int)$_SERVER['REQUEST_TIME']);
unset($sec);
/**
* Can we use ini_set
*/
define('CAN_INI_SET', !preg_match('/ini_set/', ini_get('disable_functions')));
define('WIN', strtoupper(substr(PHP_OS, 0, 3)) == 'WIN');
if( !function_exists('posix_getpwuid') || WIN )
{
define('ROSTER_PROCESS_UID', '0');
define('ROSTER_PROCESS_OWNER', 'nobody');
}
else
{
define('ROSTER_PROCESS_UID', posix_geteuid());
$processUser = posix_getpwuid(ROSTER_PROCESS_UID);
define('ROSTER_PROCESS_OWNER', $processUser['name']);
}
/**
* OS specific Directory Seperator
*/
define('DIR_SEP', DIRECTORY_SEPARATOR);
/**
* Base, absolute roster directory
*/
define('ROSTER_BASE', dirname(__FILE__) . DIR_SEP);
/**
* Check PHP version
*/
if( version_compare(phpversion(), '5.1.0', '<') )
{
die('You must have PHP version 5.1 or later to run WoWRoster');
}
/**
* Base, absolute roster library directory
*/
define('ROSTER_LIB', ROSTER_BASE . 'lib' . DIR_SEP);
/**
* Include constants file
*/
require_once (ROSTER_LIB . 'constants.php');
/**
* Include common functions
**/
require_once (ROSTER_LIB . 'functions.lib.php');
/**
* Include aprint library
**/
require_once (ROSTER_LIB . 'aprint.php');
/**
* Slash global data if magic_quotes_gpc is off.
* Checking for function existance for php6
*/
if( function_exists('get_magic_quotes_gpc') )
{
if( !get_magic_quotes_gpc() )
{
$_GET = escape_array($_GET);
$_POST = escape_array($_POST);
$_COOKIE = escape_array($_COOKIE);
$_REQUEST = escape_array($_REQUEST);
}
}
else
{
$_GET = escape_array($_GET);
$_POST = escape_array($_POST);
$_COOKIE = escape_array($_COOKIE);
$_REQUEST = escape_array($_REQUEST);
}
/**
* Check to see if we need to install
*/
if( !file_exists(ROSTER_CONF_FILE) )
{
require (ROSTER_BASE . 'install.php');
die();
}
else
{
require_once (ROSTER_CONF_FILE);
}
/**
* Re-direct to the install page if we are not installed
*/
if( !defined('ROSTER_INSTALLED') )
{
require (ROSTER_BASE . 'install.php');
die();
}
/**
* Roster base class
*/
include (ROSTER_LIB . 'roster.php');
$roster = new roster();
/**
* Roster Error Handler
*/
include (ROSTER_LIB . 'roster_error.php');
$roster->error = new roster_error();
/**
* Load the dbal
*/
$roster->load_dbal();
unset($db_config);
/**
* Include cache class
*/
require_once (ROSTER_LIB . 'cache.php');
$roster->cache = new RosterCache();
/**
* Load the config
*/
$roster->load_config();
/**
* Inject some different locale setting if the locale url switch is set
*/
$locale = (isset($_GET['locale']) ? $_GET['locale'] : (isset($_POST['locale']) ? $_POST['locale'] : ''));
if( $locale != '' )
{
$_SESSION['locale'] = $locale;
$roster->config['locale'] = $locale;
}
unset($locale);
/**
* Include API class
* MUST to be after the local define for url parsing
* since we use it for the API url
*/
if (function_exists('curl_init'))
{
require_once (ROSTER_API . 'api.php');
$roster->api = new WowAPI($roster->config['api_url_region']);
}
/**
* Include cms linking file
*/
require_once (ROSTER_LIB . 'cmslink.lib.php');
/**
* Include the CSS/JS Aggregator
*/
include (ROSTER_LIB . 'css_js.php');
/**
* Load the Template Parser
*/
include (ROSTER_LIB . 'template.php');
$roster->tpl = new RosterTemplate();
if( file_exists($roster->tpl->root . DIR_SEP . 'theme.php') )
{
include_once ($roster->tpl->root . DIR_SEP . 'theme.php');
}
/**
* Cache addon data
*/
$roster->get_addon_data();
/**
* Load the locale class
*/
include (ROSTER_LIB . 'locale.php');
$roster->locale = new roster_locale();
/**
* Include the Roster Menu class
*/
require_once (ROSTER_LIB . 'menu.php');
if( version_compare($roster->config['version'], '2.1.9.2530', '>='))
{
$roster->get_global_plugins();
}
/**
* Figure out the page
*/
$roster->get_page_name();
/**
* Load scope data classes
*/
include(ROSTER_LIB . 'scope' . DIR_SEP . 'util.php');
include(ROSTER_LIB . 'scope' . DIR_SEP . 'realm.php');
include(ROSTER_LIB . 'scope' . DIR_SEP . 'guild.php');
include(ROSTER_LIB . 'scope' . DIR_SEP . 'char.php');
include(ROSTER_LIB . 'scope' . DIR_SEP . 'user.php');
/**
* Run the scope algorithm to load the data and figure out the data to load
*/
$roster->get_scope_data();
/**
* Include Login class, external or Roster's
*/
if( file_exists(ROSTER_ADDONS . $roster->config['external_auth'] . DIR_SEP . 'inc' . DIR_SEP . 'login.php') )
{
require_once (ROSTER_ADDONS . $roster->config['external_auth'] . DIR_SEP . 'inc' . DIR_SEP . 'login.php');
}
else
{
if( version_compare($roster->config['version'], '2.1.9.0000', '>='))
{
$roster->config['external_auth'] = 'roster';
require_once (ROSTER_LIB . 'login.php');
require_once (ROSTER_LIB . 'sessions.lib.php');
$roster->auth = new RosterLogin();
/**
* run sessions after update happens
*/
$roster->session = new Session();
}
}
/**
* Assign initial template vars
*/
$roster->tpl->assign_vars(array(
'S_SEO_URL' => $roster->config['seo_url'],
'S_HEADER_LOGO' => (!empty($roster->config['logo']) ? true : false),
'U_MAKELINK' => makelink(),
'U_LINKFORM' => linkform(),
'ROSTER_URL' => ROSTER_URL,
'ROSTER_PATH' => ROSTER_PATH,
'WEBSITE_ADDRESS' => $roster->config['website_address'],
'HEADER_LOGO' => $roster->config['logo'],
'IMG_URL' => $roster->config['img_url'],
'INTERFACE_URL' => $roster->config['interface_url'],
'IMG_SUFFIX' => $roster->config['img_suffix'],
'ROSTER_VERSION' => $roster->config['version'],
'ROSTER_CREDITS' => sprintf($roster->locale->act['roster_credits'], makelink('credits')),
'XML_LANG' => substr($roster->config['locale'], 0, 2),
'T_BORDER_WHITE' => border('swhite', 'start'),
'T_BORDER_GRAY' => border('sgray', 'start'),
'T_BORDER_GOLD' => border('sgold', 'start'),
'T_BORDER_RED' => border('sred', 'start'),
'T_BORDER_ORANGE' => border('sorange', 'start'),
'T_BORDER_YELLOW' => border('syellow', 'start'),
'T_BORDER_GREEN' => border('sgreen', 'start'),
'T_BORDER_PURPLE' => border('spurple', 'start'),
'T_BORDER_BLUE' => border('sblue', 'start'),
'T_BORDER_END' => border('sgray', 'end'),
'ROSTER_SCOPE' => 'util',
'PAGE_TITLE' => 'WoWRoster',
'ROSTER_HEAD' => '',
'ROSTER_HEAD_JS' => '',
'ROSTER_HEAD_CSS' => '',
'ROSTER_BODY' => '',
'ROSTER_ONLOAD' => '',
'ROSTER_TOP' => '',
));
/**
* Set db->error_die off, our framework is good to go... hopefully
*/
$roster->db->error_die(false);
/**
* If the db version doesn't match our constant, redirect to upgrader
*/
if( (empty($roster->config['version']) || version_compare($roster->config['version'], ROSTER_VERSION, '<')) && ROSTER_PAGE_NAME != 'realmstatus' )
{
require (ROSTER_PAGES . 'upgrade.php');
die();
}
/**
* Cache plugin data
* putting this here untill release.....
*/
$roster->get_plugin_data();
/**
* If the install directory or files exist, die()
*/
if( file_exists(ROSTER_BASE . 'install.php') && !file_exists(ROSTER_BASE . 'version_match.php') )
{
roster_die($roster->locale->act['remove_install_files_text'], $roster->locale->act['remove_install_files'], 'sred');
}