phpBB
Statistics
| Revision:

root / trunk / phpBB / common.php

History | View | Annotate | Download (4.8 kB)

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