common.php
author indvdum (gotoindvdum[at]gmail[dot]com)
Wed, 07 Mar 2012 23:05:50 +0400
changeset 5 8b13f18d7412
parent 0 ceef6d64c21d
permissions -rw-r--r--
MD5 password fix
indvdum@0
     1
<?php
indvdum@0
     2
/**
indvdum@0
     3
*
indvdum@0
     4
* @package phpBB3
indvdum@0
     5
* @version $Id$
indvdum@0
     6
* @copyright (c) 2005 phpBB Group
indvdum@0
     7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
indvdum@0
     8
*
indvdum@0
     9
* Minimum Requirement: PHP 4.3.3
indvdum@0
    10
*/
indvdum@0
    11
indvdum@0
    12
/**
indvdum@0
    13
*/
indvdum@0
    14
if (!defined('IN_PHPBB'))
indvdum@0
    15
{
indvdum@0
    16
	exit;
indvdum@0
    17
}
indvdum@0
    18
indvdum@0
    19
require($phpbb_root_path . 'includes/startup.' . $phpEx);
indvdum@0
    20
indvdum@0
    21
if (file_exists($phpbb_root_path . 'config.' . $phpEx))
indvdum@0
    22
{
indvdum@0
    23
	require($phpbb_root_path . 'config.' . $phpEx);
indvdum@0
    24
}
indvdum@0
    25
indvdum@0
    26
if (!defined('PHPBB_INSTALLED'))
indvdum@0
    27
{
indvdum@0
    28
	// Redirect the user to the installer
indvdum@0
    29
	// We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
indvdum@0
    30
	// available as used by the redirect function
indvdum@0
    31
	$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
indvdum@0
    32
	$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
indvdum@0
    33
	$secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
indvdum@0
    34
indvdum@0
    35
	$script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
indvdum@0
    36
	if (!$script_name)
indvdum@0
    37
	{
indvdum@0
    38
		$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
indvdum@0
    39
	}
indvdum@0
    40
indvdum@0
    41
	// Replace any number of consecutive backslashes and/or slashes with a single slash
indvdum@0
    42
	// (could happen on some proxy setups and/or Windows servers)
indvdum@0
    43
	$script_path = trim(dirname($script_name)) . '/install/index.' . $phpEx;
indvdum@0
    44
	$script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
indvdum@0
    45
indvdum@0
    46
	$url = (($secure) ? 'https://' : 'http://') . $server_name;
indvdum@0
    47
indvdum@0
    48
	if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
indvdum@0
    49
	{
indvdum@0
    50
		// HTTP HOST can carry a port number...
indvdum@0
    51
		if (strpos($server_name, ':') === false)
indvdum@0
    52
		{
indvdum@0
    53
			$url .= ':' . $server_port;
indvdum@0
    54
		}
indvdum@0
    55
	}
indvdum@0
    56
indvdum@0
    57
	$url .= $script_path;
indvdum@0
    58
	header('Location: ' . $url);
indvdum@0
    59
	exit;
indvdum@0
    60
}
indvdum@0
    61
indvdum@0
    62
if (defined('DEBUG_EXTRA'))
indvdum@0
    63
{
indvdum@0
    64
	$base_memory_usage = 0;
indvdum@0
    65
	if (function_exists('memory_get_usage'))
indvdum@0
    66
	{
indvdum@0
    67
		$base_memory_usage = memory_get_usage();
indvdum@0
    68
	}
indvdum@0
    69
}
indvdum@0
    70
indvdum@0
    71
// Load Extensions
indvdum@0
    72
// dl() is deprecated and disabled by default as of PHP 5.3.
indvdum@0
    73
if (!empty($load_extensions) && function_exists('dl'))
indvdum@0
    74
{
indvdum@0
    75
	$load_extensions = explode(',', $load_extensions);
indvdum@0
    76
indvdum@0
    77
	foreach ($load_extensions as $extension)
indvdum@0
    78
	{
indvdum@0
    79
		@dl(trim($extension));
indvdum@0
    80
	}
indvdum@0
    81
}
indvdum@0
    82
indvdum@0
    83
// Include files
indvdum@0
    84
require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
indvdum@0
    85
require($phpbb_root_path . 'includes/cache.' . $phpEx);
indvdum@0
    86
require($phpbb_root_path . 'includes/template.' . $phpEx);
indvdum@0
    87
require($phpbb_root_path . 'includes/session.' . $phpEx);
indvdum@0
    88
require($phpbb_root_path . 'includes/auth.' . $phpEx);
indvdum@0
    89
indvdum@0
    90
require($phpbb_root_path . 'includes/functions.' . $phpEx);
indvdum@0
    91
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
indvdum@0
    92
indvdum@0
    93
require($phpbb_root_path . 'includes/constants.' . $phpEx);
indvdum@0
    94
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
indvdum@0
    95
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
indvdum@0
    96
indvdum@0
    97
// Set PHP error handler to ours
indvdum@0
    98
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
indvdum@0
    99
indvdum@0
   100
// Instantiate some basic classes
indvdum@0
   101
$user		= new user();
indvdum@0
   102
$auth		= new auth();
indvdum@0
   103
$template	= new template();
indvdum@0
   104
$cache		= new cache();
indvdum@0
   105
$db			= new $sql_db();
indvdum@0
   106
indvdum@0
   107
// Connect to DB
indvdum@0
   108
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
indvdum@0
   109
indvdum@0
   110
// We do not need this any longer, unset for safety purposes
indvdum@0
   111
unset($dbpasswd);
indvdum@0
   112
indvdum@0
   113
// Grab global variables, re-cache if necessary
indvdum@0
   114
$config = $cache->obtain_config();
indvdum@0
   115
indvdum@0
   116
// Add own hook handler
indvdum@0
   117
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
indvdum@0
   118
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
indvdum@0
   119
indvdum@0
   120
foreach ($cache->obtain_hooks() as $hook)
indvdum@0
   121
{
indvdum@0
   122
	@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
indvdum@0
   123
}
indvdum@0
   124
indvdum@0
   125
?>