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

