|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package phpBB3
|
|
|
ef5584 |
* @version $Id: common.php 8760 2008-08-15 19:46:51Z aptx $
|
|
|
ef5584 |
* @copyright (c) 2005 phpBB Group
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* Minimum Requirement: PHP 4.3.3
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if (!defined('IN_PHPBB'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$starttime = explode(' ', microtime());
|
|
|
ef5584 |
$starttime = $starttime[1] + $starttime[0];
|
|
|
ef5584 |
|
|
|
ef5584 |
// Report all errors, except notices
|
|
|
ef5584 |
error_reporting(E_ALL ^ E_NOTICE);
|
|
|
ef5584 |
|
|
|
ef5584 |
/*
|
|
|
ef5584 |
* Remove variables created by register_globals from the global scope
|
|
|
ef5584 |
* Thanks to Matt Kavanagh
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function deregister_globals()
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$not_unset = array(
|
|
|
ef5584 |
'GLOBALS' => true,
|
|
|
ef5584 |
'_GET' => true,
|
|
|
ef5584 |
'_POST' => true,
|
|
|
ef5584 |
'_COOKIE' => true,
|
|
|
ef5584 |
'_REQUEST' => true,
|
|
|
ef5584 |
'_SERVER' => true,
|
|
|
ef5584 |
'_SESSION' => true,
|
|
|
ef5584 |
'_ENV' => true,
|
|
|
ef5584 |
'_FILES' => true,
|
|
|
ef5584 |
'phpEx' => true,
|
|
|
ef5584 |
'phpbb_root_path' => true
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Not only will array_merge and array_keys give a warning if
|
|
|
ef5584 |
// a parameter is not an array, array_merge will actually fail.
|
|
|
ef5584 |
// So we check if _SESSION has been initialised.
|
|
|
ef5584 |
if (!isset($_SESSION) || !is_array($_SESSION))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$_SESSION = array();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Merge all into one extremely huge array; unset this later
|
|
|
ef5584 |
$input = array_merge(
|
|
|
ef5584 |
array_keys($_GET),
|
|
|
ef5584 |
array_keys($_POST),
|
|
|
ef5584 |
array_keys($_COOKIE),
|
|
|
ef5584 |
array_keys($_SERVER),
|
|
|
ef5584 |
array_keys($_SESSION),
|
|
|
ef5584 |
array_keys($_ENV),
|
|
|
ef5584 |
array_keys($_FILES)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($input as $varname)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (isset($not_unset[$varname]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Hacking attempt. No point in continuing unless it's a COOKIE
|
|
|
ef5584 |
if ($varname !== 'GLOBALS' || isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_SERVER['GLOBALS']) || isset($_SESSION['GLOBALS']) || isset($_ENV['GLOBALS']) || isset($_FILES['GLOBALS']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$cookie = &$_COOKIE;
|
|
|
ef5584 |
while (isset($cookie['GLOBALS']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
foreach ($cookie['GLOBALS'] as $registered_var => $value)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!isset($not_unset[$registered_var]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
unset($GLOBALS[$registered_var]);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$cookie = &$cookie['GLOBALS'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
unset($GLOBALS[$varname]);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
unset($input);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// If we are on PHP >= 6.0.0 we do not need some code
|
|
|
ef5584 |
if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @ignore
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
define('STRIP', false);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
@set_magic_quotes_runtime(0);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Be paranoid with passed vars
|
|
|
ef5584 |
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on' || !function_exists('ini_get'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
deregister_globals();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (defined('IN_CRON'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$phpbb_root_path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!file_exists($phpbb_root_path . 'config.' . $phpEx))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
die("The config.$phpEx file could not be found. Click here to install phpBB ");
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
require($phpbb_root_path . 'config.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!defined('PHPBB_INSTALLED'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Redirect the user to the installer
|
|
|
ef5584 |
// We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
|
|
|
ef5584 |
// available as used by the redirect function
|
|
|
ef5584 |
$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
|
|
|
ef5584 |
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
|
|
|
ef5584 |
$secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
|
|
|
ef5584 |
|
|
|
ef5584 |
$script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
|
|
|
ef5584 |
if (!$script_name)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Replace any number of consecutive backslashes and/or slashes with a single slash
|
|
|
ef5584 |
// (could happen on some proxy setups and/or Windows servers)
|
|
|
ef5584 |
$script_path = trim(dirname($script_name)) . '/install/index.' . $phpEx;
|
|
|
ef5584 |
$script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
|
|
|
ef5584 |
|
|
|
ef5584 |
$url = (($secure) ? 'https://' : 'http://') . $server_name;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// HTTP HOST can carry a port number...
|
|
|
ef5584 |
if (strpos($server_name, ':') === false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$url .= ':' . $server_port;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$url .= $script_path;
|
|
|
ef5584 |
header('Location: ' . $url);
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (defined('DEBUG_EXTRA'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$base_memory_usage = 0;
|
|
|
ef5584 |
if (function_exists('memory_get_usage'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$base_memory_usage = memory_get_usage();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Load Extensions
|
|
|
ef5584 |
if (!empty($load_extensions))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$load_extensions = explode(',', $load_extensions);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($load_extensions as $extension)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
@dl(trim($extension));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Include files
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/cache.' . $phpEx);
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/template.' . $phpEx);
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/session.' . $phpEx);
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/auth.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/functions.' . $phpEx);
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Set PHP error handler to ours
|
|
|
ef5584 |
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
|
|
|
ef5584 |
|
|
|
ef5584 |
// Instantiate some basic classes
|
|
|
ef5584 |
$user = new user();
|
|
|
ef5584 |
$auth = new auth();
|
|
|
ef5584 |
$template = new template();
|
|
|
ef5584 |
$cache = new cache();
|
|
|
ef5584 |
$db = new $sql_db();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Connect to DB
|
|
|
ef5584 |
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
|
|
|
ef5584 |
|
|
|
ef5584 |
// We do not need this any longer, unset for safety purposes
|
|
|
ef5584 |
unset($dbpasswd);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Grab global variables, re-cache if necessary
|
|
|
ef5584 |
$config = $cache->obtain_config();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Add own hook handler
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
|
|
ef5584 |
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($cache->obtain_hooks() as $hook)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|