mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-12 02:25:18 +02:00
Add core bootstrap. Also change common.php to use it.
git-svn-id: file:///svn/phpbb/trunk@9231 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
5b9a3c9a7d
commit
705d706a7f
197
phpBB/common.php
197
phpBB/common.php
@ -7,6 +7,8 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
* Minimum Requirement: PHP 5.2.0+
|
||||
*
|
||||
* Within this file the framework with all components as well as all phpBB-specific things will be loaded
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -16,118 +18,11 @@ if (!defined('IN_PHPBB'))
|
||||
exit;
|
||||
}
|
||||
|
||||
$starttime = explode(' ', microtime());
|
||||
$starttime = $starttime[1] + $starttime[0];
|
||||
// Init Framework
|
||||
require PHPBB_ROOT_PATH . 'includes/core/bootstrap.' . PHP_EXT;
|
||||
|
||||
// Report all errors, except notices
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
/*
|
||||
* Remove variables created by register_globals from the global scope
|
||||
* Thanks to Matt Kavanagh
|
||||
*/
|
||||
function deregister_globals()
|
||||
{
|
||||
$not_unset = array(
|
||||
'GLOBALS' => true,
|
||||
'_GET' => true,
|
||||
'_POST' => true,
|
||||
'_COOKIE' => true,
|
||||
'_REQUEST' => true,
|
||||
'_SERVER' => true,
|
||||
'_SESSION' => true,
|
||||
'_ENV' => true,
|
||||
'_FILES' => true,
|
||||
'phpEx' => true,
|
||||
'phpbb_root_path' => true
|
||||
);
|
||||
|
||||
// Not only will array_merge and array_keys give a warning if
|
||||
// a parameter is not an array, array_merge will actually fail.
|
||||
// So we check if _SESSION has been initialised.
|
||||
if (!isset($_SESSION) || !is_array($_SESSION))
|
||||
{
|
||||
$_SESSION = array();
|
||||
}
|
||||
|
||||
// Merge all into one extremely huge array; unset this later
|
||||
$input = array_merge(
|
||||
array_keys($_GET),
|
||||
array_keys($_POST),
|
||||
array_keys($_COOKIE),
|
||||
array_keys($_SERVER),
|
||||
array_keys($_SESSION),
|
||||
array_keys($_ENV),
|
||||
array_keys($_FILES)
|
||||
);
|
||||
|
||||
foreach ($input as $varname)
|
||||
{
|
||||
if (isset($not_unset[$varname]))
|
||||
{
|
||||
// Hacking attempt. No point in continuing unless it's a COOKIE
|
||||
if ($varname !== 'GLOBALS' || isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_SERVER['GLOBALS']) || isset($_SESSION['GLOBALS']) || isset($_ENV['GLOBALS']) || isset($_FILES['GLOBALS']))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cookie = &$_COOKIE;
|
||||
while (isset($cookie['GLOBALS']))
|
||||
{
|
||||
foreach ($cookie['GLOBALS'] as $registered_var => $value)
|
||||
{
|
||||
if (!isset($not_unset[$registered_var]))
|
||||
{
|
||||
unset($GLOBALS[$registered_var]);
|
||||
}
|
||||
}
|
||||
$cookie = &$cookie['GLOBALS'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($GLOBALS[$varname]);
|
||||
}
|
||||
|
||||
unset($input);
|
||||
}
|
||||
|
||||
// If we are on PHP >= 6.0.0 we do not need some code
|
||||
if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
|
||||
{
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('STRIP', false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@set_magic_quotes_runtime(0);
|
||||
|
||||
// Be paranoid with passed vars
|
||||
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on' || !function_exists('ini_get'))
|
||||
{
|
||||
deregister_globals();
|
||||
}
|
||||
|
||||
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
|
||||
}
|
||||
|
||||
if (defined('IN_CRON'))
|
||||
{
|
||||
@define('PHPBB_ROOT_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
if (!file_exists(PHPBB_ROOT_PATH . 'config.' . PHP_EXT))
|
||||
{
|
||||
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>');
|
||||
}
|
||||
|
||||
require(PHPBB_ROOT_PATH . 'config.' . PHP_EXT);
|
||||
|
||||
if (!defined('PHPBB_INSTALLED'))
|
||||
// Run through remaining Framework states
|
||||
if (defined('PHPBB_CONFIG_MISSING') || !defined('PHPBB_INSTALLED'))
|
||||
{
|
||||
// Redirect the user to the installer
|
||||
// We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
|
||||
@ -163,60 +58,48 @@ if (!defined('PHPBB_INSTALLED'))
|
||||
exit;
|
||||
}
|
||||
|
||||
if (defined('DEBUG_EXTRA'))
|
||||
{
|
||||
$base_memory_usage = 0;
|
||||
if (function_exists('memory_get_usage'))
|
||||
{
|
||||
$base_memory_usage = memory_get_usage();
|
||||
}
|
||||
}
|
||||
|
||||
// Load Extensions
|
||||
if (!empty($load_extensions))
|
||||
{
|
||||
$load_extensions = explode(',', $load_extensions);
|
||||
|
||||
foreach ($load_extensions as $extension)
|
||||
{
|
||||
@dl(trim($extension));
|
||||
}
|
||||
}
|
||||
|
||||
// Include files
|
||||
require(PHPBB_ROOT_PATH . 'includes/acm/acm_' . $acm_type . '.' . PHP_EXT);
|
||||
require(PHPBB_ROOT_PATH . 'includes/cache.' . PHP_EXT);
|
||||
require(PHPBB_ROOT_PATH . 'includes/template.' . PHP_EXT);
|
||||
require(PHPBB_ROOT_PATH . 'includes/session.' . PHP_EXT);
|
||||
require(PHPBB_ROOT_PATH . 'includes/auth.' . PHP_EXT);
|
||||
|
||||
require(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT);
|
||||
require(PHPBB_ROOT_PATH . 'includes/functions_content.' . PHP_EXT);
|
||||
|
||||
require(PHPBB_ROOT_PATH . 'includes/constants.' . PHP_EXT);
|
||||
require(PHPBB_ROOT_PATH . 'includes/db/' . $dbms . '.' . PHP_EXT);
|
||||
require(PHPBB_ROOT_PATH . 'includes/utf/utf_tools.' . PHP_EXT);
|
||||
|
||||
// Set PHP error handler to ours
|
||||
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
|
||||
|
||||
// enforce the use of the request class
|
||||
phpbb_request::disable_super_globals();
|
||||
|
||||
// Instantiate some basic classes
|
||||
$user = new user();
|
||||
$auth = new auth();
|
||||
$template = new template();
|
||||
$cache = new acm();
|
||||
$db = new $sql_db();
|
||||
// @todo Syndicate config variables somehow and check them here. It would be also nice to not have so many global vars from the config file (means: re-think layout of config file, maybe require phpbb:: to be set)
|
||||
|
||||
// Connect to DB
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
|
||||
if (!empty($dbms))
|
||||
{
|
||||
// Register DB object.
|
||||
phpbb::assign('db', phpbb_db_dbal::connect($dbms, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false));
|
||||
}
|
||||
|
||||
// We do not need this any longer, unset for safety purposes
|
||||
unset($dbpasswd);
|
||||
// We do not need the db password any longer, unset for safety purposes
|
||||
if (!empty($dbpasswd))
|
||||
{
|
||||
unset($dbpasswd);
|
||||
}
|
||||
|
||||
// Grab global variables, re-cache if necessary
|
||||
$config = phpbb_cache::obtain_config();
|
||||
// Register Cache Manager
|
||||
phpbb::register('acm');
|
||||
|
||||
// Grab global variables
|
||||
phpbb_cache::obtain_config();
|
||||
|
||||
// Register Template
|
||||
phpbb::register('template');
|
||||
|
||||
// Register permission class
|
||||
phpbb::register('acl');
|
||||
|
||||
// Register user object
|
||||
phpbb::register('user', false, false, phpbb::$config['auth_method']);
|
||||
|
||||
// Register API
|
||||
phpbb::register('api');
|
||||
|
||||
// Register Plugins
|
||||
phpbb::$plugins->init(PHPBB_ROOT_PATH . 'plugins/');
|
||||
|
||||
// Setup Plugins
|
||||
phpbb::$plugins->setup();
|
||||
|
||||
?>
|
130
phpBB/includes/core/bootstrap.php
Normal file
130
phpBB/includes/core/bootstrap.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package core
|
||||
* @version $Id: bootstrap.php 9216 2008-12-23 18:40:33Z acydburn $
|
||||
* @copyright (c) 2008 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
* Within this file only the framework with all components but no phpBB-specific things will be loaded
|
||||
*/
|
||||
|
||||
/**
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
$starttime = explode(' ', microtime());
|
||||
$starttime = $starttime[1] + $starttime[0];
|
||||
|
||||
// Report all errors, except notices
|
||||
error_reporting(E_ALL | E_STRICT); // ^ E_NOTICE
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Initialize some standard variables, constants and classes we need
|
||||
require_once PHPBB_ROOT_PATH . 'includes/core/core.' . PHP_EXT;
|
||||
require_once PHPBB_ROOT_PATH . 'plugins/bootstrap.' . PHP_EXT;
|
||||
|
||||
// Define STRIP if it is not already defined
|
||||
if (!defined('STRIP'))
|
||||
{
|
||||
// If we are on PHP >= 6.0.0 we do not need some code
|
||||
if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
|
||||
{
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('STRIP', false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@set_magic_quotes_runtime(0);
|
||||
|
||||
// We do not allow register globals set
|
||||
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on' || !function_exists('ini_get'))
|
||||
{
|
||||
die('phpBB will not work with register globals turned on. Please turn register globals off.');
|
||||
}
|
||||
|
||||
define('STRIP', (@get_magic_quotes_gpc()) ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
// we check for the cron script and change the root path
|
||||
if (defined('IN_CRON'))
|
||||
{
|
||||
@define('PHPBB_ROOT_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
// Set some default configuration parameter if the config file does not exist
|
||||
if (!file_exists(PHPBB_ROOT_PATH . 'config.' . PHP_EXT))
|
||||
{
|
||||
define('CONFIG_ADM_FOLDER', 'adm');
|
||||
define('CONFIG_ACM_TYPE', 'file');
|
||||
|
||||
// This allows common.php or an installation script to do specific actions if the configuration is missing
|
||||
define('PHPBB_CONFIG_MISSING', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
require PHPBB_ROOT_PATH . 'config.' . PHP_EXT;
|
||||
}
|
||||
|
||||
// Set default configuration variables if phpBB is not installed
|
||||
if (!defined('PHPBB_INSTALLED'))
|
||||
{
|
||||
$dbms = $dbhost = $dbport = $dbname = $dbuser = $dbpasswd = '';
|
||||
$table_prefix = 'phpbb_';
|
||||
}
|
||||
|
||||
if (defined('DEBUG_EXTRA'))
|
||||
{
|
||||
$base_memory_usage = 0;
|
||||
if (function_exists('memory_get_usage'))
|
||||
{
|
||||
$base_memory_usage = memory_get_usage();
|
||||
}
|
||||
}
|
||||
|
||||
// Load Extensions
|
||||
if (!empty($load_extensions))
|
||||
{
|
||||
$load_extensions = explode(',', $load_extensions);
|
||||
|
||||
foreach ($load_extensions as $extension)
|
||||
{
|
||||
@dl(trim($extension));
|
||||
}
|
||||
}
|
||||
|
||||
// Register autoload function
|
||||
spl_autoload_register('__phpbb_autoload');
|
||||
|
||||
// Set error handler before a real one is there
|
||||
set_error_handler(array('phpbb', 'error_handler'));
|
||||
|
||||
// Add constants
|
||||
include_once PHPBB_ROOT_PATH . 'includes/constants.' . PHP_EXT;
|
||||
|
||||
// Add global functions
|
||||
// @todo remove functions_content, trim down functions.php
|
||||
require_once PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT;
|
||||
require_once PHPBB_ROOT_PATH . 'includes/functions_content.' . PHP_EXT;
|
||||
|
||||
// Add UTF8 tools
|
||||
require_once PHPBB_ROOT_PATH . 'includes/utf/utf_tools.' . PHP_EXT;
|
||||
|
||||
// Add pre-defined system core files
|
||||
require_once PHPBB_ROOT_PATH . 'includes/core/request.' . PHP_EXT;
|
||||
|
||||
phpbb::register('security', false, 'core/security');
|
||||
phpbb::register('url', false, 'core/url');
|
||||
phpbb::register('system', false, 'core/system');
|
||||
phpbb::register('server-vars', 'phpbb_system_info', 'core/system_info');
|
||||
|
||||
// Make plugins structure available
|
||||
phpbb::register('plugins');
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user