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

