-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcommon.php
465 lines (421 loc) · 16.8 KB
/
common.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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
<?php
/***************************************************************************
* common.php
* -------------------
* begin : Saturday, Jan 16, 2005
* copyright : (C) 2007-2008 Douglas Wagner
* email : [email protected]
*
* $Id: common.php,v 2.00 2007/11/23 14:45:33 psotfx Exp $
*
***************************************************************************/
/***************************************************************************
*
* WoW Raid Manager - Raid Management Software for World of Warcraft
* Copyright (C) 2007-2008 Douglas Wagner
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*
****************************************************************************/
/******************************************
* Hacking Protection Section
******************************************/
if ( !defined('IN_PHPRAID'))
print_error("Hacking Attempt", "Invalid access detected", 1);
if(isset($_GET['phpraid_dir']) || isset($_POST['phpraid_dir']))
die("Hacking attempt detected!");
// force reporting - Turn on the First Error_Reporting for Development, The Second for Production.
//error_reporting(E_ALL ^ E_NOTICE);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// feel free to set this to absolute if necessary
$phpraid_dir = './';
/*************************************************
* Installation Redirect if Needed (Deprecated)
*************************************************/
// redirect to setup if it exists
if(file_exists($phpraid_dir.'install/')) {
header("Location: install/install.php");
}
// Sanity Check the Config File
require_once($phpraid_dir."sanity.php");
//FIX FOR OPEN BASEDIR ISSUES.
// No Win here, some people aren't allowed to include files not listed in the include list,
// others aren't able to modify their ini variables with INI set. End result? Someone
// blows up on this code.
// Get list of Includes and Add them to ini_set for include path.
// - COMMNET THIS OUT IF YOU HAVE ISSUES WITH INI_SET ON YOUR HOST.
$include_list .= $phpraid_dir . "auth/";
$include_list .= ":" . $phpraid_dir . "db/";
$include_list .= ":" . $phpraid_dir . "includes/";
$include_list .= ":" . ini_get('include_path');
ini_set('include_path', $include_list);
// Class require_onces
require_once($phpraid_dir.'includes/functions_mbwrapper.php');
require_once($phpraid_dir.'version.php');
require_once($phpraid_dir.'config.php');
require_once($phpraid_dir.'includes/functions.php');
require_once($phpraid_dir.'includes/functions_mysql.php');
require_once($phpraid_dir.'includes/functions_date.php');
require_once($phpraid_dir.'includes/functions_logging.php');
require_once($phpraid_dir.'includes/functions_tables.php');
require_once($phpraid_dir.'includes/functions_users.php');
require_once($phpraid_dir.'includes/class_template.php');
require_once($phpraid_dir.'includes/ubb.php');
require_once($phpraid_dir.'includes/scheduler.php');
require_once($phpraid_dir.'includes/wowarmory/simple_html_dom.php');
require_once($phpraid_dir.'includes/wowarmory/scrapper.class.php');
/****************************************************
* Report Output Setup (Deprecated)
* The information in this section is deprecated from 4.x on
* users should NOT uncomment these values unless otherwise told.
* This section will be removed as of 4.0.
****************************************************/
//require_once($phpraid_dir.'includes/report.php');
// reports for all data listing
//global $report;
//$report = &new ReportList;
/************************************************
* Database Connection and phpraid_config Load
************************************************/
// database connection
global $db_raid, $errorTitle, $errorMsg, $errorDie;
if ($phpraid_config['persistent_db'])
$db_raid = create_db_connection($phpraid_config['db_host'],$phpraid_config['db_user'],$phpraid_config['db_pass'],$phpraid_config['db_name'],TRUE,TRUE);
else
$db_raid = create_db_connection($phpraid_config['db_host'],$phpraid_config['db_user'],$phpraid_config['db_pass'],$phpraid_config['db_name'],TRUE,FALSE);
if(!$db_raid->db_connect_id)
{
die('<div align="center"><strong>There appears to be a problem with the database server.<br>We should be back up shortly.</strong></div>');
}
// unset database password for security reasons
// we won't use it after this point
unset($phpraid_config['db_user']);
unset($phpraid_config['db_pass']);
// Set Application to UTF8 Return
set_WRM_DB_utf8();
//
// Populate the $phpraid_config array
//
$sql = "SELECT * FROM " . $phpraid_config['db_prefix'] . "config";
$result = $db_raid->sql_query($sql) or print_error($sql, $db_raid->sql_error(), 1);
while($data = $db_raid->sql_fetchrow($result, true))
{
//$phpraid_config["{$data['0']}"] = $data['1'];
$phpraid_config[$data['config_name']] = $data['config_value'];
}
/****************************************************
* Setup DEBUG Log File
****************************************************/
// Open an error log to write to for information.
if (isset($phpraid_config['debug']) && $phpraid_config['debug'])
{
define('DEBUG', TRUE);
if (defined('DEBUG') && DEBUG)
{
$stdoutfptr = fopen($phpraid_dir."/cache/wrm_debug.log", "w");
}
}
if (defined('DEBUG') && DEBUG)
{
fwrite($stdoutfptr, "==================================================\n");
fwrite($stdoutfptr, "Loading common.php [common.php]\n");
fwrite($stdoutfptr, __FILE__ . ":" . __LINE__ . "\n");
fwrite($stdoutfptr, "==================================================\n");
}
/**********************************************************
* Load Template System Here (Smarty)
**********************************************************/
//Load Smarty Library
$wrm_dir = $curr_dir = dirname(__FILE__);
define('SMARTY_DIR', $wrm_dir .'/includes/smarty/libs/');
require(SMARTY_DIR . 'Smarty.class.php');
$wrmsmarty = new Smarty();
$wrmsmarty->template_dir = $wrm_dir . '/templates/' . $phpraid_config['template'] . '/';
$wrmsmarty->compile_dir = $wrm_dir . '/cache/templates_c/';
$wrmsmarty->config_dir = $wrm_dir . '/includes/smarty/configs/';
$wrmsmarty->cache_dir = $wrm_dir . '/cache/smarty_cache/';
// Turning on Caching will cause many pages not to display dynamic changes properly.
$wrmsmarty->caching = false;
$wrmsmarty->compile_check = true;
/* Turn on/off Smarty Template Debugging by commenting/uncommenting the lines below. */
$wrmsmarty->debugging = false;
//$wrmsmarty->debugging = true;
/***************************************************
* Load Language Files
***************************************************/
//FIX FOR OPEN BASEDIR ISSUES.
// No Win here, some people aren't allowed to include files not listed in the include list,
// others aren't able to modify their ini variables with INI set. End result? Someone
// blows up on this code.
// Setup the Include for the Language Files.
// - COMMNET THIS OUT IF YOU HAVE ISSUES WITH INI_SET ON YOUR HOST.
$include_list = $phpraid_dir . "language/lang_" . $phpraid_config['language'] . "/";
$include_list .= ":" . ini_get('include_path');
ini_set('include_path', $include_list);
ini_set('safe_mode', 'off');
//Load English, then load system setting
if(!is_file($phpraid_dir."language/lang_english/lang_main.php"))
{
die("The language file <i>" . $phpraid_config['language'] . "</i> could not be found!");
$db_raid->sql_close();
}
else
{
require_once($phpraid_dir."language/lang_english/lang_main.php");
if ($phpraid_config['language'] != 'enlgish')
{
if(!is_file($phpraid_dir."language/lang_{$phpraid_config['language']}/lang_main.php"))
{
die("The language file <i>" . $phpraid_config['language'] . "</i> could not be found!");
$db_raid->sql_close();
}
else
{
require_once($phpraid_dir."language/lang_{$phpraid_config['language']}/lang_main.php");
}
}
}
//Load English first
if(!is_file($phpraid_dir."gamepack/" . $phpraid_config['gamepack_name'] . "/language/lang_english.php"))
{
die("The language file <i>" . $phpraid_config['language'] . "</i> could not be found!");
$db_raid->sql_close();
}
else
{
require_once($phpraid_dir."gamepack/" . $phpraid_config['gamepack_name'] . "/language/lang_english.php");
if ($phpraid_config['language'] != 'enlgish')
{
if(!is_file($phpraid_dir."gamepack/" . $phpraid_config['gamepack_name'] . "/language/lang_".$phpraid_config['language'].".php"))
{
die("The language file <i>" . $phpraid_config['language'] . "</i> could not be found!");
$db_raid->sql_close();
}
else
{
require_once($phpraid_dir."gamepack/" . $phpraid_config['gamepack_name'] . "/language/lang_".$phpraid_config['language'].".php");
}
}
}
/***************************************************
* Set WRM Template
***************************************************/
$wrmtemplate = new wrm_template($db_raid,$phpraid_config,$phprlang, $phpraid_dir);
$wrmtemplate->set_smarty($wrmsmarty);
//$wrmthemplate->set_loginbox_show_status($ShowLoginForm);
$wrmtemplate->set_BridgeSupportPWDChange_status($BridgeSupportPWDChange);
/***************************************************
* Set Authentication Method and Load Auth Files
***************************************************/
// get auth type
// Illydth: We've updated this to parse the "auth" file from the auth directory prior to the definition
// of wrm_login() within the functions_auth.php file. This allows users to custom define a wrm_login()
// function that will work with specialtiy bridges. The "function_exists" check calls a function that
// dymanically defines the "wrm_login()" function at runtime.
require_once($phpraid_dir.'auth/auth_' . $phpraid_config['auth_type'] . '.php');
require_once($phpraid_dir.'includes/functions_auth.php');
if (defined('DEBUG') && DEBUG)
{
fwrite($stdoutfptr, "DETERMINING AUTH TYPE\n");
fwrite($stdoutfptr, " Auth Type: " . $phpraid_config['auth_type'] . "\n");
}
if (!function_exists('wrm_login'))
{
if (defined('DEBUG') && DEBUG)
{
fwrite($stdoutfptr, " Calling DEFINE_wrm_login()\n");
}
DEFINE_wrm_login();
}
// good ole authentication
$lifetime = get_cfg_var("session.gc_maxlifetime");
$temp = session_name("WRM-" . $phpraid_config['auth_type']);
$temp = session_set_cookie_params($lifetime, getCookiePath());
session_start();
$_SESSION['name'] = "WRM-" . $phpraid_config['auth_type'];
if (defined('DEBUG') && DEBUG)
{
fwrite($stdoutfptr, " Setting Session Information:\n");
fwrite($stdoutfptr, " -> Session Lifetime: " . $lifetime . "\n");
fwrite($stdoutfptr, " -> Session Name: " . $_SESSION['name'] . "\n");
fwrite($stdoutfptr, " -> Session Already Initiated? " . $_SESSION['initiated'] . "\n");
fwrite($stdoutfptr, var_dump_string($temp));
}
// set session defaults
if (!isset($_SESSION['initiated']))
{
if (defined('DEBUG') && DEBUG)
{
fwrite($stdoutfptr, " Session Not Initiated, Starting new Session.\n");
}
if(isset($_COOKIE['profile_id']) && isset($_COOKIE['password']))
{
if (defined('DEBUG') && DEBUG)
{
fwrite($stdoutfptr, " COOKIE Variables Set, Call WRM_LOGIN() for Cookie Auth.\n");
}
$testval = wrm_login();
if (!$testval)
{
if (defined('DEBUG') && DEBUG)
{
fwrite($stdoutfptr, " Login Returned Failure, logging out.\n");
}
wrm_logout();
session_regenerate_id();
set_WRM_SESSION(-1, 0, 'Anonymous', true);
}
}
else
{
session_regenerate_id();
set_WRM_SESSION(-1, 0, 'Anonymous', true);
if (defined('DEBUG') && DEBUG)
{
fwrite($stdoutfptr, " Cookie Info not Set.\n");
fwrite($stdoutfptr, " Dumping Session Data:\n");
fwrite($stdoutfptr, var_dump_string($_SESSION));
}
}
}
get_permissions($_SESSION['profile_id']);
/***************************************************
* Set Up Column Modification Array
***************************************************/
$col_mod = array();
/***************************************************
* Set Up Column Modification Array
***************************************************/
$expboxid = exp1243304747;
/***************************************************
* Load Game Specific Data to Global Variables
***************************************************/
$wrm_global_classes = array();
$wrm_global_races = array();
$wrm_global_roles = array();
$wrm_global_gender = array();
$wrm_global_specs = array();
$wrm_global_resistance = array();
// Load the Specs Array
$sql = "SELECT * ".
" FROM " . $phpraid_config['db_prefix'] . "class_role".
" WHERE `gamepack_id` = ".$phpraid_config['gamepack_id'].";";
$result = $db_raid->sql_query($sql) or print_error($sql, $db_raid->sql_error(), 1);
$x = 0;
while($data = $db_raid->sql_fetchrow($result, true))
{
$wrm_global_specs[$x]['spec'] = $data['subclass'];
$wrm_global_specs[$x]['lang_index'] = $data['lang_index'];
$x++;
}
// Load the Classes Array
$sql = "SELECT * ".
" FROM " . $phpraid_config['db_prefix'] . "classes".
" WHERE `gamepack_id` = ".$phpraid_config['gamepack_id'].";";
$result = $db_raid->sql_query($sql) or print_error($sql, $db_raid->sql_error(), 1);
$x = 0;
while($data = $db_raid->sql_fetchrow($result, true))
{
$wrm_global_classes[$x]['class_index'] = $data['class_index'];
$wrm_global_classes[$x]['class_id'] = $data['class_id'];
$wrm_global_classes[$x]['class_code'] = $data['class_code'];
$wrm_global_classes[$x]['lang_index'] = $data['lang_index'];
$wrm_global_classes[$x]['image'] = $data['image'];
$x++;
}
// Load the Races Array
$sql = "SELECT * ".
" FROM " . $phpraid_config['db_prefix'] . "races".
" WHERE `gamepack_id` = ".$phpraid_config['gamepack_id'].";";
$result = $db_raid->sql_query($sql) or print_error($sql, $db_raid->sql_error(), 1);
$x = 0;
while($data = $db_raid->sql_fetchrow($result, true))
{
$wrm_global_races[$x]['race_id'] = $data['race_id'];
$wrm_global_races[$x]['faction'] = $data['faction'];
$wrm_global_races[$x]['lang_index'] = $data['lang_index'];
$x++;
}
// Load the Roles Array
$sql = "SELECT * ".
" FROM " . $phpraid_config['db_prefix'] . "roles".
" WHERE `gamepack_id` = ".$phpraid_config['gamepack_id'].";";
$result = $db_raid->sql_query($sql) or print_error($sql, $db_raid->sql_error(), 1);
$x = 0;
while($data = $db_raid->sql_fetchrow($result, true))
{
$wrm_global_roles[$x]['role_id'] = $data['role_id'];
$wrm_global_roles[$x]['role_name'] = $data['role_name'];
$wrm_global_roles[$x]['lang_index'] = $data['lang_index'];
$wrm_global_roles[$x]['image'] = $data['image'];
$x++;
}
// Load the Gender Array
$sql = "SELECT * ".
" FROM " . $phpraid_config['db_prefix'] . "gender".
" WHERE `gamepack_id` = ".$phpraid_config['gamepack_id'].";";
$result = $db_raid->sql_query($sql) or print_error($sql, $db_raid->sql_error(), 1);
$x = 0;
while($data = $db_raid->sql_fetchrow($result, true))
{
$wrm_global_gender[$x]['gender_id'] = $data['gender_id'];
$wrm_global_gender[$x]['lang_index'] = $data['lang_index'];
$x++;
}
/*
// Load the Resistance Array
$sql = "SELECT * FROM " . $phpraid_config['db_prefix'] . "resistance";
$result = $db_raid->sql_query($sql) or print_error($sql, $db_raid->sql_error(), 1);
$x = 0;
while($data = $db_raid->sql_fetchrow($result, true))
{
$wrm_global_resistance[$x]['resistance_name'] = $data['resistance_name'];
$wrm_global_resistance[$x]['lang_index'] = $data['lang_index'];
$wrm_global_resistance[$x]['font_color'] = $data['font_color'];
$wrm_global_resistance[$x]['image'] = $data['image'];
$x++;
}*/
/****************************************************
* Maintenance Flag Disable Site
****************************************************/
if($phpraid_config['disable'] == 1 && $_SESSION['priv_configuration'] == 0)
{
$errorTitle = $phprlang['maintenance_header'];
$errorMsg = $phprlang['maintenance_message'];
$errorDie = 1;
}
/****************************************************
* Execute the Scheduler to Perform Automated Tasks
****************************************************/
// Do not execute Scheduler if the site is disabled.
$return_code = array();
$return_code = scheduler();
switch ($return_code['errval'])
{
case 0:
//all good, move on.
break;
case 1 - 4: //Error Returned from Recurring Raids Scheduler
$errorTitle = $return_code['errorTitle'];
$errorMsg = $return_code['errorMsg'];
$errorMsg .= "<br><br>Error Code: " . $return_code['errval'];
$errorDie = $return_code['errorDie'];
break;
default:
$errorTitle = $phprlang['scheduler_error_header'];
$errorMsg = $phprlang['scheduler_unknown'];
$errorMsg .= "<br><br>Error Code: " . $return_code;
$errorDie = 1;
break;
}
?>