5 * @copyright (c) 2011 phpBB Group
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 if (!defined('IN_PHPBB'))
17 // Report all errors, except notices and deprecation messages
18 if (!defined('E_DEPRECATED'))
20 define('E_DEPRECATED', 8192);
22 error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
25 * Remove variables created by register_globals from the global scope
26 * Thanks to Matt Kavanagh
28 function deregister_globals()
41 'phpbb_root_path' => true
44 // Not only will array_merge and array_keys give a warning if
45 // a parameter is not an array, array_merge will actually fail.
46 // So we check if _SESSION has been initialised.
47 if (!isset($_SESSION) || !is_array($_SESSION))
52 // Merge all into one extremely huge array; unset this later
58 array_keys($_SESSION),
63 foreach ($input as $varname)
65 if (isset($not_unset[$varname]))
67 // Hacking attempt. No point in continuing unless it's a COOKIE (so a cookie called GLOBALS doesn't lock users out completely)
68 if ($varname !== 'GLOBALS' || isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_SERVER['GLOBALS']) || isset($_SESSION['GLOBALS']) || isset($_ENV['GLOBALS']) || isset($_FILES['GLOBALS']))
75 while (isset($cookie['GLOBALS']))
77 if (!is_array($cookie['GLOBALS']))
82 foreach ($cookie['GLOBALS'] as $registered_var => $value)
84 if (!isset($not_unset[$registered_var]))
86 unset($GLOBALS[$registered_var]);
89 $cookie = &$cookie['GLOBALS'];
94 unset($GLOBALS[$varname]);
100 // Register globals and magic quotes have been dropped in PHP 5.4
101 if (version_compare(PHP_VERSION, '5.4.0-dev', '>='))
106 define('STRIP', false);
110 @set_magic_quotes_runtime(0);
112 // Be paranoid with passed vars
113 if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on' || !function_exists('ini_get'))
115 deregister_globals();
118 define('STRIP', (get_magic_quotes_gpc()) ? true : false);
121 // Prevent date/time functions from throwing E_WARNING on PHP 5.3 by setting a default timezone
122 if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get'))
124 // For PHP 5.1.0 the date/time functions have been rewritten
125 // and setting a timezone is required prior to calling any date/time function.
127 // Since PHP 5.2.0 calls to date/time functions without having a timezone set
128 // result in E_STRICT errors being thrown.
129 // Note: We already exclude E_STRICT errors
130 // (to be exact: they are not included in E_ALL in PHP 5.2)
132 // In PHP 5.3.0 the error level has been raised to E_WARNING which causes problems
133 // because we show E_WARNING errors and do not set a default timezone.
134 // This is because we have our own timezone handling and work in UTC only anyway.
136 // So what we basically want to do is set our timezone to UTC,
137 // but we don't know what other scripts (such as bridges) are involved,
138 // so we check whether a timezone is already set by calling date_default_timezone_get().
140 // Unfortunately, date_default_timezone_get() itself might throw E_WARNING
141 // if no timezone has been set, so we have to keep it quiet with @.
143 // date_default_timezone_get() tries to guess the correct timezone first
144 // and then falls back to UTC when everything fails.
145 // We just set the timezone to whatever date_default_timezone_get() returns.
146 date_default_timezone_set(@date_default_timezone_get());
149 $starttime = explode(' ', microtime());
150 $starttime = $starttime[1] + $starttime[0];