-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.php
399 lines (348 loc) · 8.65 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
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
<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board
| =============================================
| by Matthew Mecham
| (c) 2001 - 2006 Invision Power Services, Inc.
|
| =============================================
|
|
+---------------------------------------------------------------------------
| > $Date: 2007-12-28 17:06:28 -0500 (Fri, 28 Dec 2007) $
| > $Revision: 1152 $
| > $Author: bfarber $
+---------------------------------------------------------------------------
|
| > INIT (Yes, it is)
| > Basic class to initialize defines and other stuff
| > Date started: Wednesday 19th July 2005 (14:57)
|
+--------------------------------------------------------------------------
*/
if ( @function_exists( 'memory_get_usage' ) )
{
define( 'IPB_MEMORY_START', memory_get_usage() );
}
/**
* INIT File
*
* Sets up globals
*
* @package InvisionPowerBoard
* @author Matt Mecham
* @copyright Invision Power Services, Inc.
* @version 2.1
*/
//-----------------------------------------------
// USER CONFIGURABLE ELEMENTS
//-----------------------------------------------
/**
* ROOT PATH
*
* If __FILE__ is not supported, try ./ and
* turn off "USE_SHUTDOWN" or manually add in
* the full path
* @since 2.0.0.2005-01-01
*/
define( 'ROOT_PATH', dirname( __FILE__ ) ."/" );
//-----------------------------------------------
// Security features
//-----------------------------------------------
/**
* Directory name for the admin folder
* @since 2.2.0.2006-11-06
*/
define( 'IPB_ACP_DIRECTORY', 'admin' );
/**
* DEV MODE
*
* Turns IPB into 'developers' mode which enables
* some debugging and other tools. This is NOT recommended
* as it opens your board up to potential security risks
* @since 2.0.0.2005-01-01
*/
define ( 'IN_DEV', 0 );
/**
* SQL DEBUG MODE
*
* Turns on SQL debugging mode. This is NOT recommended
* as it opens your board up to potential security risks
* @since 2.2.0.2006-11-06
*/
define ( 'IPS_SQL_DEBUG_MODE', 0 );
/**
* MEMORY DEBUG MODE
*
* Turns on MEMORY debugging mode. This is NOT recommended
* as it opens your board up to potential security risks
* @since 2.2.0.2006-11-06
*/
define ( 'IPS_MEMORY_DEBUG_MODE', 0 );
/**
* Write to debug file?
* Enter relative / full path into the constant below
* Remove contents to turn off debugging.
* WARNING: If you are passing passwords and such via XML_RPC
* AND wish to debug, ensure that the debug file ends with .php
* to prevent it loading as plain text via HTTP which would show
* the entire contents of the file.
* @since 2.2.0.2006-11-06
*/
define( 'IPS_XML_RPC_DEBUG_ON' , 0 );
define( 'IPS_XML_RPC_DEBUG_FILE', ROOT_PATH . 'cache/xmlrpc_debug.cgi' );
/**
* Allow IP address matching when dealing with ACP sessions
* @since 2.2.0.2006-06-30
*/
define( 'IPB_ACP_IP_MATCH', 1 );
/**
* Allow exec.url="" tags
* Turning this on is a potential security risk as a malicious user
* could, with access to your ACP, add in an executable
* shell script which would allow root access to your
* server!
*/
define( 'IPB_ACP_ALLOW_EXEC_URL', 0 );
/**
* Allow PHP tags in template HTML?
* Turning this on is a potential security risk as a malicious user
* could, with access to your ACP, add in an executable
* shell script which would allow root access to your
* server!
*/
define( 'IPB_ACP_ALLOW_TEMPLATE_PHP', 0 );
/**
* Make the IPB portal your default forum page?
*/
define( 'IPB_MAKE_PORTAL_HOMEPAGE', 0 );
/**
* Use GZIP page compression in the ACP
* @since 2.2.0.2006-06-30
*/
define( 'IPB_ACP_USE_GZIP', 1 );
//-----------------------------------------------
// Other
//-----------------------------------------------
/**
* USE SHUT DOWN
*
* Enable shut down features?
* Uses PHPs register_shutdown_function to save
* low priority tasks until end of exec
* @since 2.0.0.2005-01-01
*/
define ( 'USE_SHUTDOWN', IPB_THIS_SCRIPT == 'public' ? 1 : 0 );
/**
* IPS KERNEL PATH
*
* @since 2.0.0.2005-01-01
*/
define( 'KERNEL_PATH' , ROOT_PATH.'ips_kernel/' );
/**
* LEGACY MODE
*
* Legacy mode? Will enable hacks for 2.0 to work
* with a little modification
* @since 2.1.0.2005-07-12
*/
define( 'LEGACY_MODE', 0 );
/**
* USE MODULES
*
* Enable module usage?
* (Vital for some mods and IPB enhancements)
* @since 2.0.0.2005-01-01
*/
define ( 'USE_MODULES', 1 );
/**
* CUSTOM ERROR
*
* Enable custom error handling?
* Useful to trap skin errors, etc
* @since 2.0.0.2005-01-01
*/
define( 'CUSTOM_ERROR', 0 );
/**
* TRIAL VERSION
*
* Seriously, like, leave this alone
* @since 2.0.0.2005-01-01
*/
define( 'TRIAL_VERSION', 0 );
/**
* Version numbers
*
* @since 2.0.0.2005-01-01
*/
define ( 'IPBVERSION', '2.3.4' );
define ( 'IPB_LONG_VERSION', '23007' );
//-----------------------------------------------
// NO USER EDITABLE SECTIONS BELOW
//-----------------------------------------------
@set_magic_quotes_runtime(0);
error_reporting (E_ERROR | E_WARNING | E_PARSE);
// This is for developing to catch notices - leave OFF!
//error_reporting( E_ALL | E_NOTICE);
/**
* IN IPB
*
* @since 2.0.0.2005-01-01
*/
define ( 'IN_IPB', 1 );
/**
* IN ACP
*
* @since 2.0.0.2005-01-01
*/
define ( 'IN_ACP', 1 );
/**
* SAFE MODE
*
* Seriously, like, leave this alone too
* @since 2.0.0.2005-01-01
*/
if ( IPB_THIS_SCRIPT != 'public' )
{
if ( function_exists('ini_get') )
{
define ( 'SAFE_MODE_ON', @ini_get("safe_mode") ? 1 : 0 );
}
else
{
define ( 'SAFE_MODE_ON', 1 );
}
}
else
{
define ( 'SAFE_MODE_ON', 0 );
}
/**
* INITIATED
*
* Seriously, like, leave this alone too
* @since 2.1.0.2005-07-19
*/
define ( 'IPB_INIT_DONE', 1 );
/**
* Fix for PHP 5.1.x warning
*
* Sets default time zone to server time zone
* @since 2.2.0.2006-05-19
*/
if ( function_exists( 'date_default_timezone_set' ) )
{
date_default_timezone_set( date_default_timezone_get() );
}
//===========================================================================
// DEBUG CLASS
//===========================================================================
/**
* Debug class
*
* @package InvisionPowerBoard
* @author Matt Mecham
* @version 2.1
*/
class Debug
{
function startTimer()
{
global $starttime;
$mtime = microtime ();
$mtime = explode (' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
}
function endTimer()
{
global $starttime;
$mtime = microtime ();
$mtime = explode (' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = round (($endtime - $starttime), 5);
return $totaltime;
}
}
/*-------------------------------------------------------------------------*/
// GLOBAL ROUTINES
/*-------------------------------------------------------------------------*/
/**
* Fatal error
*
* @param string Message
* @param string Help
* @return void
*/
function fatal_error($message="", $help="")
{
echo("$message<br /><br />$help");
exit;
}
/*-------------------------------------------------------------------------*/
// Custom error handler
/*-------------------------------------------------------------------------*/
/**
* Custom error handler
*
* @param integer Error number
* @param string Error string
* @param string Error file
* @param string Error line number
* @return void
*/
function my_error_handler( $errno, $errstr, $errfile, $errline )
{
global $ipsclass;
// Did we turn off errors with @?
if ( ! error_reporting() )
{
return;
}
$errfile = str_replace( @getcwd(), "", $errfile );
switch ($errno)
{
case E_ERROR:
echo "<b>IPB ERROR</b> [$errno] $errstr (Line: $errline of $errfile)<br />\n";
if( is_object($ipsclass) )
{
$ipsclass->DB->close_db();
}
exit(1);
break;
case E_WARNING:
if ( strstr( $errstr, 'load_template(./skin_cache/cacheid_' ) )
{
if ( IPB_THIS_SCRIPT != 'admin' )
{
echo "<div style='font-family:sans-serif'><b>IPB TEMPLATE ERROR:</b> Could not load the required template.
<br /><br />First, try and remove any custom skin settings by clicking <a href='index.php?setskin&id=0'>here</a>
<br /><br />Then, please visit your <a href='" . IPB_ACP_DIRECTORY . "/index.php'>Admin Control Panel</a> to repair this template.
<br /><br /><span style='font-size:90%;color:gray'>Error: $errstr</span></div>";
}
else
{
skin_emergency();
}
}
else
{
echo "<b>IPB WARNING</b> [$errno] $errstr (Line: $errline of $errfile)<br />\n";
}
break;
default:
//Do nothing
break;
}
}
//-----------------------------------------------
// Use custom handler?
// Moved due to possible php bug? Bug id# 1245
//-----------------------------------------------
if ( CUSTOM_ERROR )
{
set_error_handler("my_error_handler");
}
?>