6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 * Minimum Requirement: PHP 5.2.0+
14 if (!defined('IN_PHPBB'))
19 $starttime = explode(' ', microtime());
20 $starttime = $starttime[1] +
$starttime[0];
22 // Report all errors, except notices
23 error_reporting(E_ALL ^ E_NOTICE
);
24 date_default_timezone_set('UTC');
27 * Remove variables created by register_globals from the global scope
28 * Thanks to Matt Kavanagh
30 function deregister_globals()
43 'phpbb_root_path' => true
46 // Not only will array_merge and array_keys give a warning if
47 // a parameter is not an array, array_merge will actually fail.
48 // So we check if _SESSION has been initialised.
49 if (!isset($_SESSION) ||
!is_array($_SESSION))
54 // Merge all into one extremely huge array; unset this later
60 array_keys($_SESSION),
65 foreach ($input as $varname)
67 if (isset($not_unset[$varname]))
69 // Hacking attempt. No point in continuing unless it's a COOKIE
70 if ($varname !== 'GLOBALS' ||
isset($_GET['GLOBALS']) ||
isset($_POST['GLOBALS']) ||
isset($_SERVER['GLOBALS']) ||
isset($_SESSION['GLOBALS']) ||
isset($_ENV['GLOBALS']) ||
isset($_FILES['GLOBALS']))
77 while (isset($cookie['GLOBALS']))
79 foreach ($cookie['GLOBALS'] as $registered_var => $value)
81 if (!isset($not_unset[$registered_var]))
83 unset($GLOBALS[$registered_var]);
86 $cookie = &$cookie['GLOBALS'];
91 unset($GLOBALS[$varname]);
97 // If we are on PHP >= 6.0.0 we do not need some code
98 if (version_compare(PHP_VERSION
, '6.0.0-dev', '>='))
103 define('STRIP', false);
107 set_magic_quotes_runtime(0);
109 // Be paranoid with passed vars
110 if (@ini_get
('register_globals') == '1' ||
strtolower(@ini_get
('register_globals')) == 'on' ||
!function_exists('ini_get'))
112 deregister_globals();
115 define('STRIP', (get_magic_quotes_gpc()) ?
true : false);
118 if (defined('IN_CRON'))
120 @define
('PHPBB_ROOT_PATH', dirname(__FILE__
) . DIRECTORY_SEPARATOR
);
123 if (!file_exists(PHPBB_ROOT_PATH
. 'config.' . PHP_EXT
))
125 die('<p>The config.' . PHP_EXT
. ' file could not be found.</p><p><a href="' . PHPBB_ROOT_PATH
. 'install/index.' . PHP_EXT
. '">Click here to install phpBB</a></p>');
128 require(PHPBB_ROOT_PATH
. 'config.' . PHP_EXT
);
130 if (!defined('PHPBB_INSTALLED'))
132 // Redirect the user to the installer
133 // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
134 // available as used by the redirect function
135 $server_name = (!empty($_SERVER['HTTP_HOST'])) ?
strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ?
$_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
136 $server_port = (!empty($_SERVER['SERVER_PORT'])) ?
(int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
137 $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ?
1 : 0;
139 $script_name = (!empty($_SERVER['PHP_SELF'])) ?
$_SERVER['PHP_SELF'] : getenv('PHP_SELF');
142 $script_name = (!empty($_SERVER['REQUEST_URI'])) ?
$_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
145 // Replace any number of consecutive backslashes and/or slashes with a single slash
146 // (could happen on some proxy setups and/or Windows servers)
147 $script_path = trim(dirname($script_name)) . '/install/index.' . PHP_EXT
;
148 $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
150 $url = (($secure) ?
'https://' : 'http://') . $server_name;
152 if ($server_port && (($secure && $server_port <> 443) ||
(!$secure && $server_port <> 80)))
154 // HTTP HOST can carry a port number...
155 if (strpos($server_name, ':') === false)
157 $url .= ':' . $server_port;
161 $url .= $script_path;
162 header('Location: ' . $url);
166 if (defined('DEBUG_EXTRA'))
168 $base_memory_usage = 0;
169 if (function_exists('memory_get_usage'))
171 $base_memory_usage = memory_get_usage();
176 if (!empty($load_extensions))
178 $load_extensions = explode(',', $load_extensions);
180 foreach ($load_extensions as $extension)
182 @dl
(trim($extension));
187 require(PHPBB_ROOT_PATH
. 'includes/acm/acm_' . $acm_type . '.' . PHP_EXT
);
188 require(PHPBB_ROOT_PATH
. 'includes/cache.' . PHP_EXT
);
189 require(PHPBB_ROOT_PATH
. 'includes/template.' . PHP_EXT
);
190 require(PHPBB_ROOT_PATH
. 'includes/session.' . PHP_EXT
);
191 require(PHPBB_ROOT_PATH
. 'includes/auth.' . PHP_EXT
);
193 require(PHPBB_ROOT_PATH
. 'includes/functions.' . PHP_EXT
);
194 require(PHPBB_ROOT_PATH
. 'includes/functions_content.' . PHP_EXT
);
196 require(PHPBB_ROOT_PATH
. 'includes/constants.' . PHP_EXT
);
197 require(PHPBB_ROOT_PATH
. 'includes/db/' . $dbms . '.' . PHP_EXT
);
198 require(PHPBB_ROOT_PATH
. 'includes/utf/utf_tools.' . PHP_EXT
);
200 // Set PHP error handler to ours
201 set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER
: 'msg_handler');
203 // Instantiate some basic classes
206 $template = new template();
211 $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK
: false);
213 // We do not need this any longer, unset for safety purposes
216 // Grab global variables, re-cache if necessary
217 $config = cache
::obtain_config();
219 // Add own hook handler
220 require(PHPBB_ROOT_PATH
. 'includes/hooks/index.' . PHP_EXT
);
221 $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
223 foreach (cache
::obtain_hooks() as $hook)
225 @include
(PHPBB_ROOT_PATH
. 'includes/hooks/' . $hook . '.' . PHP_EXT
);