forked from phpbb/quickinstall
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
269 lines (225 loc) · 7.31 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?php
/**
*
* @package quickinstall
* @copyright (c) 2007 phpBB Limited
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
define('IN_PHPBB', true);
define('IN_QUICKINSTALL', true);
define('IN_INSTALL', true);
$quickinstall_path = './';
$phpbb_root_path = $quickinstall_path . 'sources/phpBB3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
// Report all errors, except notices
$level = E_ALL ^ E_NOTICE;
// Include scripts for quickinstall
require("{$quickinstall_path}includes/qi_constants.$phpEx");
require("{$quickinstall_path}includes/class_phpbb_functions.$phpEx");
require("{$quickinstall_path}includes/class_qi.$phpEx");
require("{$quickinstall_path}includes/class_qi_settings.$phpEx");
require("{$quickinstall_path}includes/qi_functions.$phpEx");
require("{$quickinstall_path}includes/functions_files.$phpEx");
require("{$quickinstall_path}includes/functions_module.$phpEx");
require("{$quickinstall_path}includes/template.$phpEx");
if (version_compare(PHP_VERSION, '5.4.0-dev', '>='))
{
// PHP 5.4 adds E_STRICT to E_ALL.
// Our utf8 normalizer triggers E_STRICT output on PHP 5.4.
// Unfortunately it cannot be made E_STRICT-clean while
// continuing to work on PHP 4.
// Therefore, in phpBB 3.0.x we disable E_STRICT on PHP 5.4+,
// while phpBB 3.1 will fix utf8 normalizer.
// E_STRICT is defined starting with PHP 5
if (!defined('E_STRICT'))
{
define('E_STRICT', 2048);
}
$level &= ~E_STRICT;
}
if (version_compare(PHP_VERSION, '5.5.0', '>='))
{
// The /e modifier is deprecated as of PHP 5.5.0 according to php.net.
// it is used in phpBB 3.0.x file: includes\functions_content.php
// That is needed to work on PHP 4.x
// It will be fixed in phpBB 3.1
if (!defined('E_DEPRECATED'))
{
define('E_DEPRECATED', 8192);
}
$level &= ~E_DEPRECATED;
}
error_reporting($level);
if (version_compare(PHP_VERSION, '5.2.0', '<'))
{
gen_error_msg('You are running an unsupported PHP version. phpBB QuickInstall only supports PHP version 5.2.0 and newer.');
}
// 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
{
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
}
// Try to override some limits - maybe it helps some...
@set_time_limit(0);
@ini_set('memory_limit', '128M');
// Set PHP error handler to ours
set_error_handler(array('qi', 'msg_handler'), E_ALL);
// Make sure we have phpBB.
if (!file_exists($quickinstall_path . 'sources/phpBB3/common.' . $phpEx))
{
gen_error_msg('phpBB not found. You need to download the latest phpBB 3.0.x or phpBB 3.1.x from <a href="https://www.phpbb.com/downloads/">https://www.phpbb.com/downloads/</a>,<br />extract it and copy the phpBB3 folder to sources/. Choose the version you do most work with, for your own convenience.');
}
// Let's get the config.
$page = legacy_request_var('page', 'main');
$mode = legacy_request_var('mode', '');
$profile = legacy_request_var('qi_profile', '');
$page = ($page == 'docs') ? 'about' : $page;
$settings = new settings($profile, $mode);
// This is only usefull when working on QI.
if (file_exists($quickinstall_path . 'purge_cache'))
{
$cache_dir = $settings->get_config('cache_dir', '');
if (!empty($cache_dir))
{
$cache_dir = $quickinstall_path . $cache_dir;
$dh = opendir($cache_dir);
while (($file = readdir($dh)) !== false)
{
if ($file[0] != '.')
{
unlink($cache_dir . $file);
}
}
closedir($dh);
}
}
// We need some phpBB functions too.
$alt_env = $settings->get_config('alt_env', '');
if ($alt_env !== '')
{
$phpbb_root_path = "{$quickinstall_path}sources/phpBB3_alt/$alt_env/";
if (!file_exists($phpbb_root_path) || is_file($phpbb_root_path))
{
gen_error_msg("The specified alternative environment, <strong>$alt_env</strong>, doesn’t exist.");
}
}
if (file_exists($phpbb_root_path . 'phpbb/class_loader.' . $phpEx))
{
define('PHPBB_31', true);
require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx);
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', $phpbb_root_path . 'phpbb/', $phpEx);
$phpbb_class_loader->register();
}
require($phpbb_root_path . 'includes/functions.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
$delete_profile = (isset($_POST['delete-profile'])) ? true : false;
// Need to set prefix here before constants.php are included.
$table_prefix = $settings->get_config('table_prefix');
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
if (defined('PHPBB_31'))
{
$user = new \phpbb\user('\phpbb\datetime');
$auth = new \phpbb\auth\auth();
$cache = new \phpbb\cache\driver\file();
require($phpbb_root_path . 'vendor/autoload.' . $phpEx);
}
else
{
require($phpbb_root_path . 'includes/acm/acm_file.' . $phpEx);
require($phpbb_root_path . 'includes/auth.' . $phpEx);
require($phpbb_root_path . 'includes/cache.' . $phpEx);
require($phpbb_root_path . 'includes/session.' . $phpEx);
// Create the user.
$user = new user();
$auth = new auth();
$cache = new cache();
}
// We need to set the template here.
$template = new template();
$template->set_custom_template('style', 'qi');
$profiles = $settings->get_profiles();
if (empty($profiles['count']))
{
$template->assign_var('S_NO_PROFILE', true);
$page = ($page == 'main' || $page == '') ? 'settings' : $page;
}
$template->assign_var('CONFIG_TEXT', false);
// If there is a language selected in the dropdown menu in settings it's sent as GET, then igonre the hidden POST field.
if (isset($_GET['lang']))
{
$language = request_var('lang', '');
}
else if (!empty($_POST['sel_lang']))
{
$language = request_var('sel_lang', '');
}
else
{
$language = '';
}
$settings->apply_language($language);
// Updated settings?
if (legacy_request_var('update_all', false))
{
$settings->update_profiles();
}
else if (!empty($settings->update_text)) // PROFILE_UPDATED
{
$update_title = sprintf($user->lang['PROFILE_UPDATED'], $settings->profile);
$update_explain = sprintf($user->lang['UPDATED_EXPLAIN'], QI_VERSION);
$update_msg = '<ul>';
foreach ($settings->update_text as $update)
{
$update_msg .= '<li>' . $user->lang[$update] . '</li>';
}
$update_msg .= '</ul>';
gen_error_msg($update_msg, $update_title, $update_explain, true);
}
// Probably best place to validate the settings
$settings->validate();
$error = $settings->get_error();
$page = (empty($error)) ? $page : 'settings';
if ($page == 'main' || $page == 'settings')
{
if ($settings->install || $settings->is_converted || $mode == 'update_settings' || $page == 'settings')
{
$page = 'settings';
require($quickinstall_path . 'includes/qi_settings.' . $phpEx);
}
}
// Hide manage boards if there is no saved config.
$template->assign_var('S_IN_INSTALL', $settings->install);
// now create a module_handler object
$module = new module_handler($quickinstall_path . 'modules/', 'qi_');
// Set some standard variables we want to force
if (defined('PHPBB_31'))
{
$config = new \phpbb\config\config(array(
'load_tplcompile' => '1',
));
set_config(false, false, false, $config);
set_config_count(null, null, null, $config);
}
else
{
$config = array(
'load_tplcompile' => '1',
);
}
// overwrite
$cache->cache_dir = $settings->get_cache_dir();
$template->cachepath = $cache->cache_dir . 'tpl_qi_';
// Load the main module
$module->load($page, 'qi_main');