phpBB
Statistics
| Revision:

root / trunk / phpBB / common.php

History | View | Annotate | Download (4.8 kB)

1 38 psotfx
<?php
2 8130 acydburn
/**
3 5114 acydburn
*
4 5114 acydburn
* @package phpBB3
5 8130 acydburn
* @copyright (c) 2005 phpBB Group
6 11653 git-gate
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7 5114 acydburn
*
8 11290 git-gate
* Minimum Requirement: PHP 5.2.0
9 5114 acydburn
*/
10 38 psotfx
11 5193 acydburn
/**
12 5193 acydburn
*/
13 3341 psotfx
if (!defined('IN_PHPBB'))
14 2327 psotfx
{
15 4970 psotfx
        exit;
16 2327 psotfx
}
17 2327 psotfx
18 11238 git-gate
require($phpbb_root_path . 'includes/startup.' . $phpEx);
19 4441 psotfx
20 10808 git-gate
if (file_exists($phpbb_root_path . 'config.' . $phpEx))
21 6045 naderman
{
22 10808 git-gate
        require($phpbb_root_path . 'config.' . $phpEx);
23 6045 naderman
}
24 6045 naderman
25 5859 acydburn
if (!defined('PHPBB_INSTALLED'))
26 2532 psotfx
{
27 6154 grahamje
        // Redirect the user to the installer
28 6154 grahamje
        // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
29 6154 grahamje
        // available as used by the redirect function
30 8348 acydburn
        $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
31 6154 grahamje
        $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
32 6154 grahamje
        $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
33 6154 grahamje
34 6154 grahamje
        $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
35 6154 grahamje
        if (!$script_name)
36 6154 grahamje
        {
37 6154 grahamje
                $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
38 6154 grahamje
        }
39 6154 grahamje
40 6204 ludovic_arnaud
        // Replace any number of consecutive backslashes and/or slashes with a single slash
41 6204 ludovic_arnaud
        // (could happen on some proxy setups and/or Windows servers)
42 6155 grahamje
        $script_path = trim(dirname($script_name)) . '/install/index.' . $phpEx;
43 6204 ludovic_arnaud
        $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
44 6154 grahamje
45 6154 grahamje
        $url = (($secure) ? 'https://' : 'http://') . $server_name;
46 6154 grahamje
47 6154 grahamje
        if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
48 6154 grahamje
        {
49 8348 acydburn
                // HTTP HOST can carry a port number...
50 8348 acydburn
                if (strpos($server_name, ':') === false)
51 8348 acydburn
                {
52 8348 acydburn
                        $url .= ':' . $server_port;
53 8348 acydburn
                }
54 6154 grahamje
        }
55 6154 grahamje
56 6155 grahamje
        $url .= $script_path;
57 6154 grahamje
        header('Location: ' . $url);
58 5859 acydburn
        exit;
59 5859 acydburn
}
60 824 psotfx
61 5859 acydburn
// Load Extensions
62 10342 acydburn
// dl() is deprecated and disabled by default as of PHP 5.3.
63 10342 acydburn
if (!empty($load_extensions) && function_exists('dl'))
64 5859 acydburn
{
65 5859 acydburn
        $load_extensions = explode(',', $load_extensions);
66 3528 acydburn
67 5859 acydburn
        foreach ($load_extensions as $extension)
68 3528 acydburn
        {
69 5859 acydburn
                @dl(trim($extension));
70 3528 acydburn
        }
71 3528 acydburn
}
72 3528 acydburn
73 5246 acydburn
// Include files
74 10650 git-gate
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
75 5246 acydburn
require($phpbb_root_path . 'includes/session.' . $phpEx);
76 5423 acydburn
require($phpbb_root_path . 'includes/auth.' . $phpEx);
77 8139 acydburn
78 5246 acydburn
require($phpbb_root_path . 'includes/functions.' . $phpEx);
79 8139 acydburn
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
80 8139 acydburn
81 5246 acydburn
require($phpbb_root_path . 'includes/constants.' . $phpEx);
82 5859 acydburn
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
83 6380 naderman
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
84 5246 acydburn
85 2970 psotfx
// Set PHP error handler to ours
86 8073 acydburn
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
87 1452 bartvb
88 10801 git-gate
// Setup class loader first
89 11557 git-gate
$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
90 11557 git-gate
$phpbb_class_loader_ext->register();
91 11557 git-gate
$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
92 11557 git-gate
$phpbb_class_loader->register();
93 10801 git-gate
94 10917 git-gate
// set up caching
95 10917 git-gate
$cache_factory = new phpbb_cache_factory($acm_type);
96 10917 git-gate
$cache = $cache_factory->get_service();
97 11557 git-gate
$phpbb_class_loader_ext->set_cache($cache->get_driver());
98 11557 git-gate
$phpbb_class_loader->set_cache($cache->get_driver());
99 10917 git-gate
100 3341 psotfx
// Instantiate some basic classes
101 10801 git-gate
$request        = new phpbb_request();
102 4164 psotfx
$user                = new user();
103 4164 psotfx
$auth                = new auth();
104 5859 acydburn
$db                        = new $sql_db();
105 4164 psotfx
106 10801 git-gate
// make sure request_var uses this request instance
107 10801 git-gate
request_var('', 0, false, false, $request); // "dependency injection" for a function
108 10801 git-gate
109 5859 acydburn
// Connect to DB
110 8246 naderman
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
111 2673 psotfx
112 5859 acydburn
// We do not need this any longer, unset for safety purposes
113 5859 acydburn
unset($dbpasswd);
114 5108 acydburn
115 5859 acydburn
// Grab global variables, re-cache if necessary
116 10925 git-gate
$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE);
117 10925 git-gate
set_config(null, null, null, $config);
118 10925 git-gate
set_config_count(null, null, null, $config);
119 3360 ludovic_arnaud
120 11557 git-gate
// load extensions
121 11557 git-gate
$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver());
122 11358 git-gate
123 11557 git-gate
$phpbb_template_locator = new phpbb_template_locator();
124 11557 git-gate
$phpbb_template_path_provider = new phpbb_template_extension_path_provider($phpbb_extension_manager, new phpbb_template_path_provider());
125 11557 git-gate
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_template_locator, $phpbb_template_path_provider);
126 11557 git-gate
127 8100 acydburn
// Add own hook handler
128 8100 acydburn
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
129 8100 acydburn
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
130 8100 acydburn
131 8100 acydburn
foreach ($cache->obtain_hooks() as $hook)
132 8100 acydburn
{
133 8102 acydburn
        @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
134 8100 acydburn
}
135 10965 git-gate
136 10965 git-gate
if (!$config['use_system_cron'])
137 10965 git-gate
{
138 11557 git-gate
        $cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver());
139 10965 git-gate
}