|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package phpBB3
|
|
indvdum@0
|
5 |
* @copyright (c) 2011 phpBB Group
|
|
indvdum@0
|
6 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
7 |
*
|
|
indvdum@0
|
8 |
*/
|
|
indvdum@0
|
9 |
|
|
indvdum@0
|
10 |
/**
|
|
indvdum@0
|
11 |
*/
|
|
indvdum@0
|
12 |
if (!defined('IN_PHPBB'))
|
|
indvdum@0
|
13 |
{
|
|
indvdum@0
|
14 |
exit;
|
|
indvdum@0
|
15 |
}
|
|
indvdum@0
|
16 |
|
|
indvdum@0
|
17 |
// Report all errors, except notices and deprecation messages
|
|
indvdum@0
|
18 |
if (!defined('E_DEPRECATED'))
|
|
indvdum@0
|
19 |
{
|
|
indvdum@0
|
20 |
define('E_DEPRECATED', 8192);
|
|
indvdum@0
|
21 |
}
|
|
indvdum@0
|
22 |
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
|
|
indvdum@0
|
23 |
|
|
indvdum@0
|
24 |
/*
|
|
indvdum@0
|
25 |
* Remove variables created by register_globals from the global scope
|
|
indvdum@0
|
26 |
* Thanks to Matt Kavanagh
|
|
indvdum@0
|
27 |
*/
|
|
indvdum@0
|
28 |
function deregister_globals()
|
|
indvdum@0
|
29 |
{
|
|
indvdum@0
|
30 |
$not_unset = array(
|
|
indvdum@0
|
31 |
'GLOBALS' => true,
|
|
indvdum@0
|
32 |
'_GET' => true,
|
|
indvdum@0
|
33 |
'_POST' => true,
|
|
indvdum@0
|
34 |
'_COOKIE' => true,
|
|
indvdum@0
|
35 |
'_REQUEST' => true,
|
|
indvdum@0
|
36 |
'_SERVER' => true,
|
|
indvdum@0
|
37 |
'_SESSION' => true,
|
|
indvdum@0
|
38 |
'_ENV' => true,
|
|
indvdum@0
|
39 |
'_FILES' => true,
|
|
indvdum@0
|
40 |
'phpEx' => true,
|
|
indvdum@0
|
41 |
'phpbb_root_path' => true
|
|
indvdum@0
|
42 |
);
|
|
indvdum@0
|
43 |
|
|
indvdum@0
|
44 |
// Not only will array_merge and array_keys give a warning if
|
|
indvdum@0
|
45 |
// a parameter is not an array, array_merge will actually fail.
|
|
indvdum@0
|
46 |
// So we check if _SESSION has been initialised.
|
|
indvdum@0
|
47 |
if (!isset($_SESSION) || !is_array($_SESSION))
|
|
indvdum@0
|
48 |
{
|
|
indvdum@0
|
49 |
$_SESSION = array();
|
|
indvdum@0
|
50 |
}
|
|
indvdum@0
|
51 |
|
|
indvdum@0
|
52 |
// Merge all into one extremely huge array; unset this later
|
|
indvdum@0
|
53 |
$input = array_merge(
|
|
indvdum@0
|
54 |
array_keys($_GET),
|
|
indvdum@0
|
55 |
array_keys($_POST),
|
|
indvdum@0
|
56 |
array_keys($_COOKIE),
|
|
indvdum@0
|
57 |
array_keys($_SERVER),
|
|
indvdum@0
|
58 |
array_keys($_SESSION),
|
|
indvdum@0
|
59 |
array_keys($_ENV),
|
|
indvdum@0
|
60 |
array_keys($_FILES)
|
|
indvdum@0
|
61 |
);
|
|
indvdum@0
|
62 |
|
|
indvdum@0
|
63 |
foreach ($input as $varname)
|
|
indvdum@0
|
64 |
{
|
|
indvdum@0
|
65 |
if (isset($not_unset[$varname]))
|
|
indvdum@0
|
66 |
{
|
|
indvdum@0
|
67 |
// Hacking attempt. No point in continuing unless it's a COOKIE (so a cookie called GLOBALS doesn't lock users out completely)
|
|
indvdum@0
|
68 |
if ($varname !== 'GLOBALS' || isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_SERVER['GLOBALS']) || isset($_SESSION['GLOBALS']) || isset($_ENV['GLOBALS']) || isset($_FILES['GLOBALS']))
|
|
indvdum@0
|
69 |
{
|
|
indvdum@0
|
70 |
exit;
|
|
indvdum@0
|
71 |
}
|
|
indvdum@0
|
72 |
else
|
|
indvdum@0
|
73 |
{
|
|
indvdum@0
|
74 |
$cookie = &$_COOKIE;
|
|
indvdum@0
|
75 |
while (isset($cookie['GLOBALS']))
|
|
indvdum@0
|
76 |
{
|
|
indvdum@0
|
77 |
if (!is_array($cookie['GLOBALS']))
|
|
indvdum@0
|
78 |
{
|
|
indvdum@0
|
79 |
break;
|
|
indvdum@0
|
80 |
}
|
|
indvdum@0
|
81 |
|
|
indvdum@0
|
82 |
foreach ($cookie['GLOBALS'] as $registered_var => $value)
|
|
indvdum@0
|
83 |
{
|
|
indvdum@0
|
84 |
if (!isset($not_unset[$registered_var]))
|
|
indvdum@0
|
85 |
{
|
|
indvdum@0
|
86 |
unset($GLOBALS[$registered_var]);
|
|
indvdum@0
|
87 |
}
|
|
indvdum@0
|
88 |
}
|
|
indvdum@0
|
89 |
$cookie = &$cookie['GLOBALS'];
|
|
indvdum@0
|
90 |
}
|
|
indvdum@0
|
91 |
}
|
|
indvdum@0
|
92 |
}
|
|
indvdum@0
|
93 |
|
|
indvdum@0
|
94 |
unset($GLOBALS[$varname]);
|
|
indvdum@0
|
95 |
}
|
|
indvdum@0
|
96 |
|
|
indvdum@0
|
97 |
unset($input);
|
|
indvdum@0
|
98 |
}
|
|
indvdum@0
|
99 |
|
|
indvdum@0
|
100 |
// Register globals and magic quotes have been dropped in PHP 5.4
|
|
indvdum@0
|
101 |
if (version_compare(PHP_VERSION, '5.4.0-dev', '>='))
|
|
indvdum@0
|
102 |
{
|
|
indvdum@0
|
103 |
/**
|
|
indvdum@0
|
104 |
* @ignore
|
|
indvdum@0
|
105 |
*/
|
|
indvdum@0
|
106 |
define('STRIP', false);
|
|
indvdum@0
|
107 |
}
|
|
indvdum@0
|
108 |
else
|
|
indvdum@0
|
109 |
{
|
|
indvdum@0
|
110 |
@set_magic_quotes_runtime(0);
|
|
indvdum@0
|
111 |
|
|
indvdum@0
|
112 |
// Be paranoid with passed vars
|
|
indvdum@0
|
113 |
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on' || !function_exists('ini_get'))
|
|
indvdum@0
|
114 |
{
|
|
indvdum@0
|
115 |
deregister_globals();
|
|
indvdum@0
|
116 |
}
|
|
indvdum@0
|
117 |
|
|
indvdum@0
|
118 |
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
|
|
indvdum@0
|
119 |
}
|
|
indvdum@0
|
120 |
|
|
indvdum@0
|
121 |
// Prevent date/time functions from throwing E_WARNING on PHP 5.3 by setting a default timezone
|
|
indvdum@0
|
122 |
if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get'))
|
|
indvdum@0
|
123 |
{
|
|
indvdum@0
|
124 |
// For PHP 5.1.0 the date/time functions have been rewritten
|
|
indvdum@0
|
125 |
// and setting a timezone is required prior to calling any date/time function.
|
|
indvdum@0
|
126 |
|
|
indvdum@0
|
127 |
// Since PHP 5.2.0 calls to date/time functions without having a timezone set
|
|
indvdum@0
|
128 |
// result in E_STRICT errors being thrown.
|
|
indvdum@0
|
129 |
// Note: We already exclude E_STRICT errors
|
|
indvdum@0
|
130 |
// (to be exact: they are not included in E_ALL in PHP 5.2)
|
|
indvdum@0
|
131 |
|
|
indvdum@0
|
132 |
// In PHP 5.3.0 the error level has been raised to E_WARNING which causes problems
|
|
indvdum@0
|
133 |
// because we show E_WARNING errors and do not set a default timezone.
|
|
indvdum@0
|
134 |
// This is because we have our own timezone handling and work in UTC only anyway.
|
|
indvdum@0
|
135 |
|
|
indvdum@0
|
136 |
// So what we basically want to do is set our timezone to UTC,
|
|
indvdum@0
|
137 |
// but we don't know what other scripts (such as bridges) are involved,
|
|
indvdum@0
|
138 |
// so we check whether a timezone is already set by calling date_default_timezone_get().
|
|
indvdum@0
|
139 |
|
|
indvdum@0
|
140 |
// Unfortunately, date_default_timezone_get() itself might throw E_WARNING
|
|
indvdum@0
|
141 |
// if no timezone has been set, so we have to keep it quiet with @.
|
|
indvdum@0
|
142 |
|
|
indvdum@0
|
143 |
// date_default_timezone_get() tries to guess the correct timezone first
|
|
indvdum@0
|
144 |
// and then falls back to UTC when everything fails.
|
|
indvdum@0
|
145 |
// We just set the timezone to whatever date_default_timezone_get() returns.
|
|
indvdum@0
|
146 |
date_default_timezone_set(@date_default_timezone_get());
|
|
indvdum@0
|
147 |
}
|
|
indvdum@0
|
148 |
|
|
indvdum@0
|
149 |
$starttime = explode(' ', microtime());
|
|
indvdum@0
|
150 |
$starttime = $starttime[1] + $starttime[0];
|