Blame Identity/Webenv/App/phpBB/3.0.4/common.php

f2e824
f2e824
/**
f2e824
*
f2e824
* @package phpBB3
f2e824
* @version $Id: common.php 8760 2008-08-15 19:46:51Z aptx $
f2e824
* @copyright (c) 2005 phpBB Group
f2e824
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
f2e824
*
f2e824
* Minimum Requirement: PHP 4.3.3
f2e824
*/
f2e824
f2e824
/**
f2e824
*/
f2e824
if (!defined('IN_PHPBB'))
f2e824
{
f2e824
	exit;
f2e824
}
f2e824
f2e824
$starttime = explode(' ', microtime());
f2e824
$starttime = $starttime[1] + $starttime[0];
f2e824
f2e824
// Report all errors, except notices
f2e824
error_reporting(E_ALL ^ E_NOTICE);
f2e824
f2e824
/*
f2e824
* Remove variables created by register_globals from the global scope
f2e824
* Thanks to Matt Kavanagh
f2e824
*/
f2e824
function deregister_globals()
f2e824
{
f2e824
	$not_unset = array(
f2e824
		'GLOBALS'	=> true,
f2e824
		'_GET'		=> true,
f2e824
		'_POST'		=> true,
f2e824
		'_COOKIE'	=> true,
f2e824
		'_REQUEST'	=> true,
f2e824
		'_SERVER'	=> true,
f2e824
		'_SESSION'	=> true,
f2e824
		'_ENV'		=> true,
f2e824
		'_FILES'	=> true,
f2e824
		'phpEx'		=> true,
f2e824
		'phpbb_root_path'	=> true
f2e824
	);
f2e824
f2e824
	// Not only will array_merge and array_keys give a warning if
f2e824
	// a parameter is not an array, array_merge will actually fail.
f2e824
	// So we check if _SESSION has been initialised.
f2e824
	if (!isset($_SESSION) || !is_array($_SESSION))
f2e824
	{
f2e824
		$_SESSION = array();
f2e824
	}
f2e824
f2e824
	// Merge all into one extremely huge array; unset this later
f2e824
	$input = array_merge(
f2e824
		array_keys($_GET),
f2e824
		array_keys($_POST),
f2e824
		array_keys($_COOKIE),
f2e824
		array_keys($_SERVER),
f2e824
		array_keys($_SESSION),
f2e824
		array_keys($_ENV),
f2e824
		array_keys($_FILES)
f2e824
	);
f2e824
f2e824
	foreach ($input as $varname)
f2e824
	{
f2e824
		if (isset($not_unset[$varname]))
f2e824
		{
f2e824
			// Hacking attempt. No point in continuing unless it's a COOKIE
f2e824
			if ($varname !== 'GLOBALS' || isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_SERVER['GLOBALS']) || isset($_SESSION['GLOBALS']) || isset($_ENV['GLOBALS']) || isset($_FILES['GLOBALS']))
f2e824
			{
f2e824
				exit;
f2e824
			}
f2e824
			else
f2e824
			{
f2e824
				$cookie = &$_COOKIE;
f2e824
				while (isset($cookie['GLOBALS']))
f2e824
				{
f2e824
					foreach ($cookie['GLOBALS'] as $registered_var => $value)
f2e824
					{
f2e824
						if (!isset($not_unset[$registered_var]))
f2e824
						{
f2e824
							unset($GLOBALS[$registered_var]);
f2e824
						}
f2e824
					}
f2e824
					$cookie = &$cookie['GLOBALS'];
f2e824
				}
f2e824
			}
f2e824
		}
f2e824
f2e824
		unset($GLOBALS[$varname]);
f2e824
	}
f2e824
f2e824
	unset($input);
f2e824
}
f2e824
f2e824
// If we are on PHP >= 6.0.0 we do not need some code
f2e824
if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
f2e824
{
f2e824
	/**
f2e824
	* @ignore
f2e824
	*/
f2e824
	define('STRIP', false);
f2e824
}
f2e824
else
f2e824
{
f2e824
	@set_magic_quotes_runtime(0);
f2e824
f2e824
	// Be paranoid with passed vars
f2e824
	if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on' || !function_exists('ini_get'))
f2e824
	{
f2e824
		deregister_globals();
f2e824
	}
f2e824
f2e824
	define('STRIP', (get_magic_quotes_gpc()) ? true : false);
f2e824
}
f2e824
f2e824
if (defined('IN_CRON'))
f2e824
{
f2e824
	$phpbb_root_path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
f2e824
}
f2e824
f2e824
if (!file_exists($phpbb_root_path . 'config.' . $phpEx))
f2e824
{
f2e824
	die("

The config.$phpEx file could not be found.

Click here to install phpBB

");
f2e824
}
f2e824
f2e824
require($phpbb_root_path . 'config.' . $phpEx);
f2e824
f2e824
if (!defined('PHPBB_INSTALLED'))
f2e824
{
f2e824
	// Redirect the user to the installer
f2e824
	// We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
f2e824
	// available as used by the redirect function
f2e824
	$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
f2e824
	$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
f2e824
	$secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
f2e824
f2e824
	$script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
f2e824
	if (!$script_name)
f2e824
	{
f2e824
		$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
f2e824
	}
f2e824
f2e824
	// Replace any number of consecutive backslashes and/or slashes with a single slash
f2e824
	// (could happen on some proxy setups and/or Windows servers)
f2e824
	$script_path = trim(dirname($script_name)) . '/install/index.' . $phpEx;
f2e824
	$script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
f2e824
f2e824
	$url = (($secure) ? 'https://' : 'http://') . $server_name;
f2e824
f2e824
	if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
f2e824
	{
f2e824
		// HTTP HOST can carry a port number...
f2e824
		if (strpos($server_name, ':') === false)
f2e824
		{
f2e824
			$url .= ':' . $server_port;
f2e824
		}
f2e824
	}
f2e824
f2e824
	$url .= $script_path;
f2e824
	header('Location: ' . $url);
f2e824
	exit;
f2e824
}
f2e824
f2e824
if (defined('DEBUG_EXTRA'))
f2e824
{
f2e824
	$base_memory_usage = 0;
f2e824
	if (function_exists('memory_get_usage'))
f2e824
	{
f2e824
		$base_memory_usage = memory_get_usage();
f2e824
	}
f2e824
}
f2e824
f2e824
// Load Extensions
f2e824
if (!empty($load_extensions))
f2e824
{
f2e824
	$load_extensions = explode(',', $load_extensions);
f2e824
f2e824
	foreach ($load_extensions as $extension)
f2e824
	{
f2e824
		@dl(trim($extension));
f2e824
	}
f2e824
}
f2e824
f2e824
// Include files
f2e824
require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
f2e824
require($phpbb_root_path . 'includes/cache.' . $phpEx);
f2e824
require($phpbb_root_path . 'includes/template.' . $phpEx);
f2e824
require($phpbb_root_path . 'includes/session.' . $phpEx);
f2e824
require($phpbb_root_path . 'includes/auth.' . $phpEx);
f2e824
f2e824
require($phpbb_root_path . 'includes/functions.' . $phpEx);
f2e824
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
f2e824
f2e824
require($phpbb_root_path . 'includes/constants.' . $phpEx);
f2e824
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
f2e824
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
f2e824
f2e824
// Set PHP error handler to ours
f2e824
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
f2e824
f2e824
// Instantiate some basic classes
f2e824
$user		= new user();
f2e824
$auth		= new auth();
f2e824
$template	= new template();
f2e824
$cache		= new cache();
f2e824
$db			= new $sql_db();
f2e824
f2e824
// Connect to DB
f2e824
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
f2e824
f2e824
// We do not need this any longer, unset for safety purposes
f2e824
unset($dbpasswd);
f2e824
f2e824
// Grab global variables, re-cache if necessary
f2e824
$config = $cache->obtain_config();
f2e824
f2e824
// Add own hook handler
f2e824
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
f2e824
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
f2e824
f2e824
foreach ($cache->obtain_hooks() as $hook)
f2e824
{
f2e824
	@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
f2e824
}
f2e824
f2e824
?>