~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/php/phpBB3/install/index.php

  • Committer: dcoles
  • Date: 2008-02-29 02:11:58 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:624
forum: Removed the subsilver2 style and phpBB installer
Modified prosilver theme to be more IVLE integrated
Added db dumps for setup

setup.py: Added config.php generator code

doc/setup/install_proc.txt: New setup/install details

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
*
4
 
* @package install
5
 
* @version $Id: index.php,v 1.71 2007/10/06 11:45:04 acydburn Exp $
6
 
* @copyright (c) 2005 phpBB Group
7
 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
8
 
*
9
 
*/
10
 
 
11
 
/**#@+
12
 
* @ignore
13
 
*/
14
 
define('IN_PHPBB', true);
15
 
define('IN_INSTALL', true);
16
 
/**#@-*/
17
 
 
18
 
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
19
 
$phpEx = substr(strrchr(__FILE__, '.'), 1);
20
 
 
21
 
// Report all errors, except notices
22
 
error_reporting(E_ALL ^ E_NOTICE);
23
 
 
24
 
// @todo Review this test and see if we can find out what it is which prevents PHP 4.2.x from even displaying the page with requirements on it
25
 
if (version_compare(PHP_VERSION, '4.3.3') < 0)
26
 
{
27
 
        die('You are running an unsupported PHP version. Please upgrade to PHP 4.3.3 or higher before trying to install phpBB 3.0');
28
 
}
29
 
 
30
 
/*
31
 
* Remove variables created by register_globals from the global scope
32
 
* Thanks to Matt Kavanagh
33
 
*/
34
 
function deregister_globals()
35
 
{
36
 
        $not_unset = array(
37
 
                'GLOBALS'       => true,
38
 
                '_GET'          => true,
39
 
                '_POST'         => true,
40
 
                '_COOKIE'       => true,
41
 
                '_REQUEST'      => true,
42
 
                '_SERVER'       => true,
43
 
                '_SESSION'      => true,
44
 
                '_ENV'          => true,
45
 
                '_FILES'        => true,
46
 
                'phpEx'         => true,
47
 
                'phpbb_root_path'       => true
48
 
        );
49
 
 
50
 
        // Not only will array_merge and array_keys give a warning if
51
 
        // a parameter is not an array, array_merge will actually fail.
52
 
        // So we check if _SESSION has been initialised.
53
 
        if (!isset($_SESSION) || !is_array($_SESSION))
54
 
        {
55
 
                $_SESSION = array();
56
 
        }
57
 
 
58
 
        // Merge all into one extremely huge array; unset this later
59
 
        $input = array_merge(
60
 
                array_keys($_GET),
61
 
                array_keys($_POST),
62
 
                array_keys($_COOKIE),
63
 
                array_keys($_SERVER),
64
 
                array_keys($_SESSION),
65
 
                array_keys($_ENV),
66
 
                array_keys($_FILES)
67
 
        );
68
 
 
69
 
        foreach ($input as $varname)
70
 
        {
71
 
                if (isset($not_unset[$varname]))
72
 
                {
73
 
                        // Hacking attempt. No point in continuing unless it's a COOKIE
74
 
                        if ($varname !== 'GLOBALS' || isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_SERVER['GLOBALS']) || isset($_SESSION['GLOBALS']) || isset($_ENV['GLOBALS']) || isset($_FILES['GLOBALS']))
75
 
                        {
76
 
                                exit;
77
 
                        }
78
 
                        else
79
 
                        {
80
 
                                $cookie = &$_COOKIE;
81
 
                                while (isset($cookie['GLOBALS']))
82
 
                                {
83
 
                                        foreach ($cookie['GLOBALS'] as $registered_var => $value)
84
 
                                        {
85
 
                                                if (!isset($not_unset[$registered_var]))
86
 
                                                {
87
 
                                                        unset($GLOBALS[$registered_var]);
88
 
                                                }
89
 
                                        }
90
 
                                        $cookie = &$cookie['GLOBALS'];
91
 
                                }
92
 
                        }
93
 
                }
94
 
 
95
 
                unset($GLOBALS[$varname]);
96
 
        }
97
 
 
98
 
        unset($input);
99
 
}
100
 
 
101
 
// If we are on PHP >= 6.0.0 we do not need some code
102
 
if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
103
 
{
104
 
        /**
105
 
        * @ignore
106
 
        */
107
 
        define('STRIP', false);
108
 
}
109
 
else
110
 
{
111
 
        set_magic_quotes_runtime(0);
112
 
 
113
 
        // Be paranoid with passed vars
114
 
        if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
115
 
        {
116
 
                deregister_globals();
117
 
        }
118
 
 
119
 
        define('STRIP', (get_magic_quotes_gpc()) ? true : false);
120
 
}
121
 
 
122
 
// Try to override some limits - maybe it helps some...
123
 
@set_time_limit(0);
124
 
$mem_limit = @ini_get('memory_limit');
125
 
if (!empty($mem_limit))
126
 
{
127
 
        $unit = strtolower(substr($mem_limit, -1, 1));
128
 
        $mem_limit = (int) $mem_limit;
129
 
 
130
 
        if ($unit == 'k')
131
 
        {
132
 
                $mem_limit = floor($mem_limit / 1024);
133
 
        }
134
 
        else if ($unit == 'g')
135
 
        {
136
 
                $mem_limit *= 1024;
137
 
        }
138
 
        else if (is_numeric($unit))
139
 
        {
140
 
                $mem_limit = floor((int) ($mem_limit . $unit) / 1048576);
141
 
        }
142
 
        $mem_limit = max(128, $mem_limit) . 'M';
143
 
}
144
 
else
145
 
{
146
 
        $mem_limit = '128M';
147
 
}
148
 
@ini_set('memory_limit', $mem_limit);
149
 
 
150
 
// Include essential scripts
151
 
require($phpbb_root_path . 'includes/functions.' . $phpEx);
152
 
 
153
 
if (file_exists($phpbb_root_path . 'includes/functions_content.' . $phpEx))
154
 
{
155
 
        require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
156
 
}
157
 
 
158
 
include($phpbb_root_path . 'includes/auth.' . $phpEx);
159
 
include($phpbb_root_path . 'includes/session.' . $phpEx);
160
 
include($phpbb_root_path . 'includes/template.' . $phpEx);
161
 
include($phpbb_root_path . 'includes/acm/acm_file.' . $phpEx);
162
 
include($phpbb_root_path . 'includes/cache.' . $phpEx);
163
 
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
164
 
include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
165
 
require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
166
 
 
167
 
// Try and load an appropriate language if required
168
 
$language = basename(request_var('language', ''));
169
 
 
170
 
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !$language)
171
 
{
172
 
        $accept_lang_ary = explode(',', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
173
 
        foreach ($accept_lang_ary as $accept_lang)
174
 
        {
175
 
                // Set correct format ... guess full xx_yy form
176
 
                $accept_lang = substr($accept_lang, 0, 2) . '_' . substr($accept_lang, 3, 2);
177
 
 
178
 
                if (file_exists($phpbb_root_path . 'language/' . $accept_lang))
179
 
                {
180
 
                        $language = $accept_lang;
181
 
                        break;
182
 
                }
183
 
                else
184
 
                {
185
 
                        // No match on xx_yy so try xx
186
 
                        $accept_lang = substr($accept_lang, 0, 2);
187
 
                        if (file_exists($phpbb_root_path . 'language/' . $accept_lang))
188
 
                        {
189
 
                                $language = $accept_lang;
190
 
                                break;
191
 
                        }
192
 
                }
193
 
        }
194
 
}
195
 
 
196
 
// No appropriate language found ... so let's use the first one in the language
197
 
// dir, this may or may not be English
198
 
if (!$language)
199
 
{
200
 
        $dir = @opendir($phpbb_root_path . 'language');
201
 
 
202
 
        if (!$dir)
203
 
        {
204
 
                die('Unable to access the language directory');
205
 
                exit;
206
 
        }
207
 
 
208
 
        while (($file = readdir($dir)) !== false)
209
 
        {
210
 
                $path = $phpbb_root_path . 'language/' . $file;
211
 
 
212
 
                if (!is_file($path) && !is_link($path) && file_exists($path . '/iso.txt'))
213
 
                {
214
 
                        $language = $file;
215
 
                        break;
216
 
                }
217
 
        }
218
 
        closedir($dir);
219
 
}
220
 
 
221
 
if (!file_exists($phpbb_root_path . 'language/' . $language))
222
 
{
223
 
        die('No language found!');
224
 
}
225
 
 
226
 
// And finally, load the relevant language files
227
 
include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx);
228
 
include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx);
229
 
include($phpbb_root_path . 'language/' . $language . '/acp/board.' . $phpEx);
230
 
include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx);
231
 
include($phpbb_root_path . 'language/' . $language . '/posting.' . $phpEx);
232
 
 
233
 
$mode = request_var('mode', 'overview');
234
 
$sub = request_var('sub', '');
235
 
 
236
 
// Set PHP error handler to ours
237
 
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
238
 
 
239
 
$user = new user();
240
 
$auth = new auth();
241
 
$cache = new cache();
242
 
$template = new template();
243
 
 
244
 
// Add own hook handler, if present. :o
245
 
if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
246
 
{
247
 
        require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
248
 
        $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
249
 
 
250
 
        foreach ($cache->obtain_hooks() as $hook)
251
 
        {
252
 
                @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
253
 
        }
254
 
}
255
 
else
256
 
{
257
 
        $phpbb_hook = false;
258
 
}
259
 
 
260
 
// Set some standard variables we want to force
261
 
$config = array(
262
 
        'load_tplcompile'       => '1'
263
 
);
264
 
 
265
 
$template->set_custom_template('../adm/style', 'admin');
266
 
$template->assign_var('T_TEMPLATE_PATH', '../adm/style');
267
 
 
268
 
// the acp template is never stored in the database
269
 
$user->theme['template_storedb'] = false;
270
 
 
271
 
$install = new module();
272
 
 
273
 
$install->create('install', "index.$phpEx", $mode, $sub);
274
 
$install->load();
275
 
 
276
 
// Generate the page
277
 
$install->page_header();
278
 
$install->generate_navigation();
279
 
 
280
 
$template->set_filenames(array(
281
 
        'body' => $install->get_tpl_name())
282
 
);
283
 
 
284
 
$install->page_footer();
285
 
 
286
 
/**
287
 
* @package install
288
 
*/
289
 
class module
290
 
{
291
 
        var $id = 0;
292
 
        var $type = 'install';
293
 
        var $module_ary = array();
294
 
        var $filename;
295
 
        var $module_url = '';
296
 
        var $tpl_name = '';
297
 
        var $mode;
298
 
        var $sub;
299
 
 
300
 
        /**
301
 
        * Private methods, should not be overwritten
302
 
        */
303
 
        function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
304
 
        {
305
 
                global $db, $config, $phpEx, $phpbb_root_path;
306
 
 
307
 
                $module = array();
308
 
 
309
 
                // Grab module information using Bart's "neat-o-module" system (tm)
310
 
                $dir = @opendir('.');
311
 
 
312
 
                if (!$dir)
313
 
                {
314
 
                        $this->error('Unable to access the installation directory', __LINE__, __FILE__);
315
 
                }
316
 
 
317
 
                $setmodules = 1;
318
 
                while (($file = readdir($dir)) !== false)
319
 
                {
320
 
                        if (preg_match('#^install_(.*?)\.' . $phpEx . '$#', $file))
321
 
                        {
322
 
                                include($file);
323
 
                        }
324
 
                }
325
 
                closedir($dir);
326
 
 
327
 
                unset($setmodules);
328
 
 
329
 
                if (!sizeof($module))
330
 
                {
331
 
                        $this->error('No installation modules found', __LINE__, __FILE__);
332
 
                }
333
 
 
334
 
                // Order to use and count further if modules get assigned to the same position or not having an order
335
 
                $max_module_order = 1000;
336
 
 
337
 
                foreach ($module as $row)
338
 
                {
339
 
                        // Check any module pre-reqs
340
 
                        if ($row['module_reqs'] != '')
341
 
                        {
342
 
                        }
343
 
 
344
 
                        // Module order not specified or module already assigned at this position?
345
 
                        if (!isset($row['module_order']) || isset($this->module_ary[$row['module_order']]))
346
 
                        {
347
 
                                $row['module_order'] = $max_module_order;
348
 
                                $max_module_order++;
349
 
                        }
350
 
 
351
 
                        $this->module_ary[$row['module_order']]['name'] = $row['module_title'];
352
 
                        $this->module_ary[$row['module_order']]['filename'] = $row['module_filename'];
353
 
                        $this->module_ary[$row['module_order']]['subs'] = $row['module_subs'];
354
 
                        $this->module_ary[$row['module_order']]['stages'] = $row['module_stages'];
355
 
 
356
 
                        if (strtolower($selected_mod) == strtolower($row['module_title']))
357
 
                        {
358
 
                                $this->id = (int) $row['module_order'];
359
 
                                $this->filename = (string) $row['module_filename'];
360
 
                                $this->module_url = (string) $module_url;
361
 
                                $this->mode = (string) $selected_mod;
362
 
                                // Check that the sub-mode specified is valid or set a default if not
363
 
                                if (is_array($row['module_subs']))
364
 
                                {
365
 
                                        $this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_subs'])) ? $selected_submod : $row['module_subs'][0]);
366
 
                                }
367
 
                                else if (is_array($row['module_stages']))
368
 
                                {
369
 
                                        $this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_stages'])) ? $selected_submod : $row['module_stages'][0]);
370
 
                                }
371
 
                                else
372
 
                                {
373
 
                                        $this->sub = '';
374
 
                                }
375
 
                        }
376
 
                } // END foreach
377
 
        } // END create
378
 
 
379
 
        /**
380
 
        * Load and run the relevant module if applicable
381
 
        */
382
 
        function load($mode = false, $run = true)
383
 
        {
384
 
                global $phpbb_root_path, $phpEx;
385
 
 
386
 
                if ($run)
387
 
                {
388
 
                        if (!empty($mode))
389
 
                        {
390
 
                                $this->mode = $mode;
391
 
                        }
392
 
 
393
 
                        $module = $this->filename;
394
 
                        if (!class_exists($module))
395
 
                        {
396
 
                                $this->error('Module "' . htmlspecialchars($module) . '" not accessible.', __LINE__, __FILE__);
397
 
                        }
398
 
                        $this->module = new $module($this);
399
 
 
400
 
                        if (method_exists($this->module, 'main'))
401
 
                        {
402
 
                                $this->module->main($this->mode, $this->sub);
403
 
                        }
404
 
                }
405
 
        }
406
 
 
407
 
        /**
408
 
        * Output the standard page header
409
 
        */
410
 
        function page_header()
411
 
        {
412
 
                if (defined('HEADER_INC'))
413
 
                {
414
 
                        return;
415
 
                }
416
 
 
417
 
                define('HEADER_INC', true);
418
 
                global $template, $lang, $stage, $phpbb_root_path;
419
 
 
420
 
                $template->assign_vars(array(
421
 
                        'L_CHANGE'                              => $lang['CHANGE'],
422
 
                        'L_INSTALL_PANEL'               => $lang['INSTALL_PANEL'],
423
 
                        'L_SELECT_LANG'                 => $lang['SELECT_LANG'],
424
 
                        'L_SKIP'                                => $lang['SKIP'],
425
 
                        'PAGE_TITLE'                    => $this->get_page_title(),
426
 
                        'T_IMAGE_PATH'                  => $phpbb_root_path . 'adm/images/',
427
 
 
428
 
                        'S_CONTENT_DIRECTION'   => $lang['DIRECTION'],
429
 
                        'S_CONTENT_FLOW_BEGIN'  => ($lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
430
 
                        'S_CONTENT_FLOW_END'    => ($lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
431
 
                        'S_CONTENT_ENCODING'    => 'UTF-8',
432
 
 
433
 
                        'S_USER_LANG'                   => $lang['USER_LANG'],
434
 
                        )
435
 
                );
436
 
 
437
 
                header('Content-type: text/html; charset=UTF-8');
438
 
                header('Cache-Control: private, no-cache="set-cookie"');
439
 
                header('Expires: 0');
440
 
                header('Pragma: no-cache');
441
 
 
442
 
                return;
443
 
        }
444
 
 
445
 
        /**
446
 
        * Output the standard page footer
447
 
        */
448
 
        function page_footer()
449
 
        {
450
 
                global $db, $template;
451
 
 
452
 
                $template->display('body');
453
 
        
454
 
                // Close our DB connection.
455
 
                if (!empty($db) && is_object($db))
456
 
                {
457
 
                        $db->sql_close();
458
 
                }
459
 
 
460
 
                if (function_exists('exit_handler'))
461
 
                {
462
 
                        exit_handler();
463
 
                }
464
 
        }
465
 
 
466
 
        /**
467
 
        * Returns desired template name
468
 
        */
469
 
        function get_tpl_name()
470
 
        {
471
 
                return $this->module->tpl_name . '.html';
472
 
        }
473
 
 
474
 
        /**
475
 
        * Returns the desired page title
476
 
        */
477
 
        function get_page_title()
478
 
        {
479
 
                global $lang;
480
 
 
481
 
                if (!isset($this->module->page_title))
482
 
                {
483
 
                        return '';
484
 
                }
485
 
 
486
 
                return (isset($lang[$this->module->page_title])) ? $lang[$this->module->page_title] : $this->module->page_title;
487
 
        }
488
 
 
489
 
        /**
490
 
        * Generate an HTTP/1.1 header to redirect the user to another page
491
 
        * This is used during the installation when we do not have a database available to call the normal redirect function
492
 
        * @param string $page The page to redirect to relative to the installer root path
493
 
        */
494
 
        function redirect($page)
495
 
        {
496
 
                $server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME');
497
 
                $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
498
 
                $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
499
 
 
500
 
                $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
501
 
                if (!$script_name)
502
 
                {
503
 
                        $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
504
 
                }
505
 
 
506
 
                // Replace backslashes and doubled slashes (could happen on some proxy setups)
507
 
                $script_name = str_replace(array('\\', '//'), '/', $script_name);
508
 
                $script_path = trim(dirname($script_name));
509
 
 
510
 
                $url = (($secure) ? 'https://' : 'http://') . $server_name;
511
 
 
512
 
                if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
513
 
                {
514
 
                        $url .= ':' . $server_port;
515
 
                }
516
 
 
517
 
                $url .= $script_path . '/' . $page;
518
 
                header('Location: ' . $url);
519
 
                exit;
520
 
        }
521
 
 
522
 
        /**
523
 
        * Generate the navigation tabs
524
 
        */
525
 
        function generate_navigation()
526
 
        {
527
 
                global $lang, $template, $phpEx, $language;
528
 
 
529
 
                if (is_array($this->module_ary))
530
 
                {
531
 
                        @ksort($this->module_ary);
532
 
                        foreach ($this->module_ary as $cat_ary)
533
 
                        {
534
 
                                $cat = $cat_ary['name'];
535
 
                                $l_cat = (!empty($lang['CAT_' . $cat])) ? $lang['CAT_' . $cat] : preg_replace('#_#', ' ', $cat);
536
 
                                $cat = strtolower($cat);
537
 
                                $url = $this->module_url . "?mode=$cat&amp;language=$language";
538
 
                                
539
 
                                if ($this->mode == $cat)
540
 
                                {
541
 
                                        $template->assign_block_vars('t_block1', array(
542
 
                                                'L_TITLE'               => $l_cat,
543
 
                                                'S_SELECTED'    => true,
544
 
                                                'U_TITLE'               => $url,
545
 
                                        ));
546
 
 
547
 
                                        if (is_array($this->module_ary[$this->id]['subs']))
548
 
                                        {
549
 
                                                $subs = $this->module_ary[$this->id]['subs'];
550
 
                                                foreach ($subs as $option)
551
 
                                                {
552
 
                                                        $l_option = (!empty($lang['SUB_' . $option])) ? $lang['SUB_' . $option] : preg_replace('#_#', ' ', $option);
553
 
                                                        $option = strtolower($option);
554
 
                                                        $url = $this->module_url . '?mode=' . $this->mode . "&amp;sub=$option&amp;language=$language";
555
 
 
556
 
                                                        $template->assign_block_vars('l_block1', array(
557
 
                                                                'L_TITLE'               => $l_option,
558
 
                                                                'S_SELECTED'    => ($this->sub == $option),
559
 
                                                                'U_TITLE'               => $url,
560
 
                                                        ));
561
 
                                                }
562
 
                                        }
563
 
 
564
 
                                        if (is_array($this->module_ary[$this->id]['stages']))
565
 
                                        {
566
 
                                                $subs = $this->module_ary[$this->id]['stages'];
567
 
                                                $matched = false;
568
 
                                                foreach ($subs as $option)
569
 
                                                {
570
 
                                                        $l_option = (!empty($lang['STAGE_' . $option])) ? $lang['STAGE_' . $option] : preg_replace('#_#', ' ', $option);
571
 
                                                        $option = strtolower($option);
572
 
                                                        $matched = ($this->sub == $option) ? true : $matched;
573
 
 
574
 
                                                        $template->assign_block_vars('l_block2', array(
575
 
                                                                'L_TITLE'               => $l_option,
576
 
                                                                'S_SELECTED'    => ($this->sub == $option),
577
 
                                                                'S_COMPLETE'    => !$matched,
578
 
                                                        ));
579
 
                                                }
580
 
                                        }
581
 
                                }
582
 
                                else
583
 
                                {
584
 
                                        $template->assign_block_vars('t_block1', array(
585
 
                                                'L_TITLE'               => $l_cat,
586
 
                                                'S_SELECTED'    => false,
587
 
                                                'U_TITLE'               => $url,
588
 
                                        ));
589
 
                                }
590
 
                        }
591
 
                }
592
 
        }
593
 
 
594
 
        /**
595
 
        * Output an error message
596
 
        * If skip is true, return and continue execution, else exit
597
 
        */
598
 
        function error($error, $line, $file, $skip = false)
599
 
        {
600
 
                global $lang, $db, $template;
601
 
 
602
 
                if ($skip)
603
 
                {
604
 
                        $template->assign_block_vars('checks', array(
605
 
                                'S_LEGEND'      => true,
606
 
                                'LEGEND'        => $lang['INST_ERR'],
607
 
                        ));
608
 
 
609
 
                        $template->assign_block_vars('checks', array(
610
 
                                'TITLE'         => basename($file) . ' [ ' . $line . ' ]',
611
 
                                'RESULT'        => '<b style="color:red">' . $error . '</b>',
612
 
                        ));
613
 
 
614
 
                        return;
615
 
                }
616
 
 
617
 
                echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
618
 
                echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
619
 
                echo '<head>';
620
 
                echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
621
 
                echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
622
 
                echo '<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
623
 
                echo '</head>';
624
 
                echo '<body id="errorpage">';
625
 
                echo '<div id="wrap">';
626
 
                echo '  <div id="page-header">';
627
 
                echo '  </div>';
628
 
                echo '  <div id="page-body">';
629
 
                echo '          <div id="acp">';
630
 
                echo '          <div class="panel">';
631
 
                echo '                  <span class="corners-top"><span></span></span>';
632
 
                echo '                  <div id="content">';
633
 
                echo '                          <h1>' . $lang['INST_ERR_FATAL'] . '</h1>';
634
 
                echo '          <p>' . $lang['INST_ERR_FATAL'] . "</p>\n";
635
 
                echo '          <p>' . basename($file) . ' [ ' . $line . " ]</p>\n";
636
 
                echo '          <p><b>' . $error . "</b></p>\n";
637
 
                echo '                  </div>';
638
 
                echo '                  <span class="corners-bottom"><span></span></span>';
639
 
                echo '          </div>';
640
 
                echo '          </div>';
641
 
                echo '  </div>';
642
 
                echo '  <div id="page-footer">';
643
 
                echo '          Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>';
644
 
                echo '  </div>';
645
 
                echo '</div>';
646
 
                echo '</body>';
647
 
                echo '</html>';
648
 
 
649
 
                if (!empty($db) && is_object($db))
650
 
                {
651
 
                        $db->sql_close();
652
 
                }
653
 
 
654
 
                exit_handler();
655
 
        }
656
 
 
657
 
        /**
658
 
        * Output an error message for a database related problem
659
 
        * If skip is true, return and continue execution, else exit
660
 
        */
661
 
        function db_error($error, $sql, $line, $file, $skip = false)
662
 
        {
663
 
                global $lang, $db, $template;
664
 
 
665
 
                if ($skip)
666
 
                {
667
 
                        $template->assign_block_vars('checks', array(
668
 
                                'S_LEGEND'      => true,
669
 
                                'LEGEND'        => $lang['INST_ERR_FATAL'],
670
 
                        ));
671
 
 
672
 
                        $template->assign_block_vars('checks', array(
673
 
                                'TITLE'         => basename($file) . ' [ ' . $line . ' ]',
674
 
                                'RESULT'        => '<b style="color:red">' . $error . '</b><br />&#187; SQL:' . $sql,
675
 
                        ));
676
 
 
677
 
                        return;
678
 
                }
679
 
 
680
 
                $template->set_filenames(array(
681
 
                        'body' => 'install_error.html')
682
 
                );
683
 
                $this->page_header();
684
 
                $this->generate_navigation();
685
 
 
686
 
                $template->assign_vars(array(
687
 
                        'MESSAGE_TITLE'         => $lang['INST_ERR_FATAL_DB'],
688
 
                        'MESSAGE_TEXT'          => '<p>' . basename($file) . ' [ ' . $line . ' ]</p><p>SQL : ' . $sql . '</p><p><b>' . $error . '</b></p>',
689
 
                ));
690
 
 
691
 
                // Rollback if in transaction
692
 
                if ($db->transaction)
693
 
                {
694
 
                        $db->sql_transaction('rollback');
695
 
                }
696
 
 
697
 
                $this->page_footer();
698
 
        }
699
 
 
700
 
        /**
701
 
        * Generate the relevant HTML for an input field and the associated label and explanatory text
702
 
        */
703
 
        function input_field($name, $type, $value='', $options='')
704
 
        {
705
 
                global $lang;
706
 
                $tpl_type = explode(':', $type);
707
 
                $tpl = '';
708
 
 
709
 
                switch ($tpl_type[0])
710
 
                {
711
 
                        case 'text':
712
 
                        case 'password':
713
 
                                $size = (int) $tpl_type[1];
714
 
                                $maxlength = (int) $tpl_type[2];
715
 
 
716
 
                                $tpl = '<input id="' . $name . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $value . '" />';
717
 
                        break;
718
 
 
719
 
                        case 'textarea':
720
 
                                $rows = (int) $tpl_type[1];
721
 
                                $cols = (int) $tpl_type[2];
722
 
 
723
 
                                $tpl = '<textarea id="' . $name . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $value . '</textarea>';
724
 
                        break;
725
 
 
726
 
                        case 'radio':
727
 
                                $key_yes        = ($value) ? ' checked="checked" id="' . $name . '"' : '';
728
 
                                $key_no         = (!$value) ? ' checked="checked" id="' . $name . '"' : '';
729
 
 
730
 
                                $tpl_type_cond = explode('_', $tpl_type[1]);
731
 
                                $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
732
 
 
733
 
                                $tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $lang['NO'] : $lang['DISABLED']) . '</label>';
734
 
                                $tpl_yes = '<label><input type="radio" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $lang['YES'] : $lang['ENABLED']) . '</label>';
735
 
 
736
 
                                $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . '&nbsp;&nbsp;' . $tpl_no : $tpl_no . '&nbsp;&nbsp;' . $tpl_yes;
737
 
                        break;
738
 
 
739
 
                        case 'select':
740
 
                                eval('$s_options = ' . str_replace('{VALUE}', $value, $options) . ';');
741
 
                                $tpl = '<select id="' . $name . '" name="' . $name . '">' . $s_options . '</select>';
742
 
                        break;
743
 
 
744
 
                        case 'custom':
745
 
                                eval('$tpl = ' . str_replace('{VALUE}', $value, $options) . ';');
746
 
                        break;
747
 
 
748
 
                        default:
749
 
                        break;
750
 
                }
751
 
 
752
 
                return $tpl;
753
 
        }
754
 
 
755
 
        /**
756
 
        * Generate the drop down of available language packs
757
 
        */
758
 
        function inst_language_select($default = '')
759
 
        {
760
 
                global $phpbb_root_path, $phpEx;
761
 
 
762
 
                $dir = @opendir($phpbb_root_path . 'language');
763
 
 
764
 
                if (!$dir)
765
 
                {
766
 
                        $this->error('Unable to access the language directory', __LINE__, __FILE__);
767
 
                }
768
 
 
769
 
                while ($file = readdir($dir))
770
 
                {
771
 
                        $path = $phpbb_root_path . 'language/' . $file;
772
 
 
773
 
                        if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS')
774
 
                        {
775
 
                                continue;
776
 
                        }
777
 
 
778
 
                        if (file_exists($path . '/iso.txt'))
779
 
                        {
780
 
                                list($displayname, $localname) = @file($path . '/iso.txt');
781
 
                                $lang[$localname] = $file;
782
 
                        }
783
 
                }
784
 
                closedir($dir);
785
 
 
786
 
                @asort($lang);
787
 
                @reset($lang);
788
 
 
789
 
                $user_select = '';
790
 
                foreach ($lang as $displayname => $filename)
791
 
                {
792
 
                        $selected = (strtolower($default) == strtolower($filename)) ? ' selected="selected"' : '';
793
 
                        $user_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>';
794
 
                }
795
 
 
796
 
                return $user_select;
797
 
        }
798
 
}
799
 
 
800
 
?>
 
 
b'\\ No newline at end of file'