Blame Identity/Models/Html/phpBB/3.0.4/common.php

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

The config.$phpEx file could not be found.

Click here to install phpBB

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