1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/install/index.php Wed Mar 07 16:41:10 2012 +0400
1.3 @@ -0,0 +1,729 @@
1.4 +<?php
1.5 +/**
1.6 +*
1.7 +* @package install
1.8 +* @version $Id$
1.9 +* @copyright (c) 2005 phpBB Group
1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
1.11 +*
1.12 +*/
1.13 +
1.14 +/**#@+
1.15 +* @ignore
1.16 +*/
1.17 +define('IN_PHPBB', true);
1.18 +define('IN_INSTALL', true);
1.19 +/**#@-*/
1.20 +
1.21 +$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
1.22 +$phpEx = substr(strrchr(__FILE__, '.'), 1);
1.23 +
1.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
1.25 +if (version_compare(PHP_VERSION, '4.3.3') < 0)
1.26 +{
1.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');
1.28 +}
1.29 +
1.30 +function phpbb_require_updated($path, $optional = false)
1.31 +{
1.32 + global $phpbb_root_path;
1.33 +
1.34 + $new_path = $phpbb_root_path . 'install/update/new/' . $path;
1.35 + $old_path = $phpbb_root_path . $path;
1.36 +
1.37 + if (file_exists($new_path))
1.38 + {
1.39 + require($new_path);
1.40 + }
1.41 + else if (!$optional || file_exists($old_path))
1.42 + {
1.43 + require($old_path);
1.44 + }
1.45 +}
1.46 +
1.47 +phpbb_require_updated('includes/startup.' . $phpEx);
1.48 +
1.49 +// Try to override some limits - maybe it helps some...
1.50 +@set_time_limit(0);
1.51 +$mem_limit = @ini_get('memory_limit');
1.52 +if (!empty($mem_limit))
1.53 +{
1.54 + $unit = strtolower(substr($mem_limit, -1, 1));
1.55 + $mem_limit = (int) $mem_limit;
1.56 +
1.57 + if ($unit == 'k')
1.58 + {
1.59 + $mem_limit = floor($mem_limit / 1024);
1.60 + }
1.61 + else if ($unit == 'g')
1.62 + {
1.63 + $mem_limit *= 1024;
1.64 + }
1.65 + else if (is_numeric($unit))
1.66 + {
1.67 + $mem_limit = floor((int) ($mem_limit . $unit) / 1048576);
1.68 + }
1.69 + $mem_limit = max(128, $mem_limit) . 'M';
1.70 +}
1.71 +else
1.72 +{
1.73 + $mem_limit = '128M';
1.74 +}
1.75 +@ini_set('memory_limit', $mem_limit);
1.76 +
1.77 +// Include essential scripts
1.78 +require($phpbb_root_path . 'includes/functions.' . $phpEx);
1.79 +
1.80 +phpbb_require_updated('includes/functions_content.' . $phpEx, true);
1.81 +
1.82 +include($phpbb_root_path . 'includes/auth.' . $phpEx);
1.83 +include($phpbb_root_path . 'includes/session.' . $phpEx);
1.84 +include($phpbb_root_path . 'includes/template.' . $phpEx);
1.85 +include($phpbb_root_path . 'includes/acm/acm_file.' . $phpEx);
1.86 +include($phpbb_root_path . 'includes/cache.' . $phpEx);
1.87 +include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
1.88 +include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
1.89 +require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
1.90 +
1.91 +// Try and load an appropriate language if required
1.92 +$language = basename(request_var('language', ''));
1.93 +
1.94 +if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !$language)
1.95 +{
1.96 + $accept_lang_ary = explode(',', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
1.97 + foreach ($accept_lang_ary as $accept_lang)
1.98 + {
1.99 + // Set correct format ... guess full xx_yy form
1.100 + $accept_lang = substr($accept_lang, 0, 2) . '_' . substr($accept_lang, 3, 2);
1.101 +
1.102 + if (file_exists($phpbb_root_path . 'language/' . $accept_lang) && is_dir($phpbb_root_path . 'language/' . $accept_lang))
1.103 + {
1.104 + $language = $accept_lang;
1.105 + break;
1.106 + }
1.107 + else
1.108 + {
1.109 + // No match on xx_yy so try xx
1.110 + $accept_lang = substr($accept_lang, 0, 2);
1.111 + if (file_exists($phpbb_root_path . 'language/' . $accept_lang) && is_dir($phpbb_root_path . 'language/' . $accept_lang))
1.112 + {
1.113 + $language = $accept_lang;
1.114 + break;
1.115 + }
1.116 + }
1.117 + }
1.118 +}
1.119 +
1.120 +// No appropriate language found ... so let's use the first one in the language
1.121 +// dir, this may or may not be English
1.122 +if (!$language)
1.123 +{
1.124 + $dir = @opendir($phpbb_root_path . 'language');
1.125 +
1.126 + if (!$dir)
1.127 + {
1.128 + die('Unable to access the language directory');
1.129 + exit;
1.130 + }
1.131 +
1.132 + while (($file = readdir($dir)) !== false)
1.133 + {
1.134 + $path = $phpbb_root_path . 'language/' . $file;
1.135 +
1.136 + if (!is_file($path) && !is_link($path) && file_exists($path . '/iso.txt'))
1.137 + {
1.138 + $language = $file;
1.139 + break;
1.140 + }
1.141 + }
1.142 + closedir($dir);
1.143 +}
1.144 +
1.145 +if (!file_exists($phpbb_root_path . 'language/' . $language) || !is_dir($phpbb_root_path . 'language/' . $language))
1.146 +{
1.147 + die('No language found!');
1.148 +}
1.149 +
1.150 +// And finally, load the relevant language files
1.151 +include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx);
1.152 +include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx);
1.153 +include($phpbb_root_path . 'language/' . $language . '/acp/board.' . $phpEx);
1.154 +include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx);
1.155 +include($phpbb_root_path . 'language/' . $language . '/posting.' . $phpEx);
1.156 +
1.157 +// usually we would need every single constant here - and it would be consistent. For 3.0.x, use a dirty hack... :(
1.158 +
1.159 +// Define needed constants
1.160 +define('CHMOD_ALL', 7);
1.161 +define('CHMOD_READ', 4);
1.162 +define('CHMOD_WRITE', 2);
1.163 +define('CHMOD_EXECUTE', 1);
1.164 +
1.165 +$mode = request_var('mode', 'overview');
1.166 +$sub = request_var('sub', '');
1.167 +
1.168 +// Set PHP error handler to ours
1.169 +set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
1.170 +
1.171 +$user = new user();
1.172 +$auth = new auth();
1.173 +$cache = new cache();
1.174 +$template = new template();
1.175 +
1.176 +// Add own hook handler, if present. :o
1.177 +if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
1.178 +{
1.179 + require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
1.180 + $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
1.181 +
1.182 + foreach ($cache->obtain_hooks() as $hook)
1.183 + {
1.184 + @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
1.185 + }
1.186 +}
1.187 +else
1.188 +{
1.189 + $phpbb_hook = false;
1.190 +}
1.191 +
1.192 +// Set some standard variables we want to force
1.193 +$config = array(
1.194 + 'load_tplcompile' => '1'
1.195 +);
1.196 +
1.197 +$template->set_custom_template('../adm/style', 'admin');
1.198 +$template->assign_var('T_TEMPLATE_PATH', '../adm/style');
1.199 +
1.200 +// the acp template is never stored in the database
1.201 +$user->theme['template_storedb'] = false;
1.202 +
1.203 +$install = new module();
1.204 +
1.205 +$install->create('install', "index.$phpEx", $mode, $sub);
1.206 +$install->load();
1.207 +
1.208 +// Generate the page
1.209 +$install->page_header();
1.210 +$install->generate_navigation();
1.211 +
1.212 +$template->set_filenames(array(
1.213 + 'body' => $install->get_tpl_name())
1.214 +);
1.215 +
1.216 +$install->page_footer();
1.217 +
1.218 +/**
1.219 +* @package install
1.220 +*/
1.221 +class module
1.222 +{
1.223 + var $id = 0;
1.224 + var $type = 'install';
1.225 + var $module_ary = array();
1.226 + var $filename;
1.227 + var $module_url = '';
1.228 + var $tpl_name = '';
1.229 + var $mode;
1.230 + var $sub;
1.231 +
1.232 + /**
1.233 + * Private methods, should not be overwritten
1.234 + */
1.235 + function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
1.236 + {
1.237 + global $db, $config, $phpEx, $phpbb_root_path;
1.238 +
1.239 + $module = array();
1.240 +
1.241 + // Grab module information using Bart's "neat-o-module" system (tm)
1.242 + $dir = @opendir('.');
1.243 +
1.244 + if (!$dir)
1.245 + {
1.246 + $this->error('Unable to access the installation directory', __LINE__, __FILE__);
1.247 + }
1.248 +
1.249 + $setmodules = 1;
1.250 + while (($file = readdir($dir)) !== false)
1.251 + {
1.252 + if (preg_match('#^install_(.*?)\.' . $phpEx . '$#', $file))
1.253 + {
1.254 + include($file);
1.255 + }
1.256 + }
1.257 + closedir($dir);
1.258 +
1.259 + unset($setmodules);
1.260 +
1.261 + if (!sizeof($module))
1.262 + {
1.263 + $this->error('No installation modules found', __LINE__, __FILE__);
1.264 + }
1.265 +
1.266 + // Order to use and count further if modules get assigned to the same position or not having an order
1.267 + $max_module_order = 1000;
1.268 +
1.269 + foreach ($module as $row)
1.270 + {
1.271 + // Module order not specified or module already assigned at this position?
1.272 + if (!isset($row['module_order']) || isset($this->module_ary[$row['module_order']]))
1.273 + {
1.274 + $row['module_order'] = $max_module_order;
1.275 + $max_module_order++;
1.276 + }
1.277 +
1.278 + $this->module_ary[$row['module_order']]['name'] = $row['module_title'];
1.279 + $this->module_ary[$row['module_order']]['filename'] = $row['module_filename'];
1.280 + $this->module_ary[$row['module_order']]['subs'] = $row['module_subs'];
1.281 + $this->module_ary[$row['module_order']]['stages'] = $row['module_stages'];
1.282 +
1.283 + if (strtolower($selected_mod) == strtolower($row['module_title']))
1.284 + {
1.285 + $this->id = (int) $row['module_order'];
1.286 + $this->filename = (string) $row['module_filename'];
1.287 + $this->module_url = (string) $module_url;
1.288 + $this->mode = (string) $selected_mod;
1.289 + // Check that the sub-mode specified is valid or set a default if not
1.290 + if (is_array($row['module_subs']))
1.291 + {
1.292 + $this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_subs'])) ? $selected_submod : $row['module_subs'][0]);
1.293 + }
1.294 + else if (is_array($row['module_stages']))
1.295 + {
1.296 + $this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_stages'])) ? $selected_submod : $row['module_stages'][0]);
1.297 + }
1.298 + else
1.299 + {
1.300 + $this->sub = '';
1.301 + }
1.302 + }
1.303 + } // END foreach
1.304 + } // END create
1.305 +
1.306 + /**
1.307 + * Load and run the relevant module if applicable
1.308 + */
1.309 + function load($mode = false, $run = true)
1.310 + {
1.311 + global $phpbb_root_path, $phpEx;
1.312 +
1.313 + if ($run)
1.314 + {
1.315 + if (!empty($mode))
1.316 + {
1.317 + $this->mode = $mode;
1.318 + }
1.319 +
1.320 + $module = $this->filename;
1.321 + if (!class_exists($module))
1.322 + {
1.323 + $this->error('Module "' . htmlspecialchars($module) . '" not accessible.', __LINE__, __FILE__);
1.324 + }
1.325 + $this->module = new $module($this);
1.326 +
1.327 + if (method_exists($this->module, 'main'))
1.328 + {
1.329 + $this->module->main($this->mode, $this->sub);
1.330 + }
1.331 + }
1.332 + }
1.333 +
1.334 + /**
1.335 + * Output the standard page header
1.336 + */
1.337 + function page_header()
1.338 + {
1.339 + if (defined('HEADER_INC'))
1.340 + {
1.341 + return;
1.342 + }
1.343 +
1.344 + define('HEADER_INC', true);
1.345 + global $template, $lang, $stage, $phpbb_root_path;
1.346 +
1.347 + $template->assign_vars(array(
1.348 + 'L_CHANGE' => $lang['CHANGE'],
1.349 + 'L_INSTALL_PANEL' => $lang['INSTALL_PANEL'],
1.350 + 'L_SELECT_LANG' => $lang['SELECT_LANG'],
1.351 + 'L_SKIP' => $lang['SKIP'],
1.352 + 'PAGE_TITLE' => $this->get_page_title(),
1.353 + 'T_IMAGE_PATH' => $phpbb_root_path . 'adm/images/',
1.354 +
1.355 + 'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
1.356 + 'S_CONTENT_FLOW_BEGIN' => ($lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
1.357 + 'S_CONTENT_FLOW_END' => ($lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
1.358 + 'S_CONTENT_ENCODING' => 'UTF-8',
1.359 +
1.360 + 'S_USER_LANG' => $lang['USER_LANG'],
1.361 + )
1.362 + );
1.363 +
1.364 + header('Content-type: text/html; charset=UTF-8');
1.365 + header('Cache-Control: private, no-cache="set-cookie"');
1.366 + header('Expires: 0');
1.367 + header('Pragma: no-cache');
1.368 +
1.369 + return;
1.370 + }
1.371 +
1.372 + /**
1.373 + * Output the standard page footer
1.374 + */
1.375 + function page_footer()
1.376 + {
1.377 + global $db, $template;
1.378 +
1.379 + $template->display('body');
1.380 +
1.381 + // Close our DB connection.
1.382 + if (!empty($db) && is_object($db))
1.383 + {
1.384 + $db->sql_close();
1.385 + }
1.386 +
1.387 + if (function_exists('exit_handler'))
1.388 + {
1.389 + exit_handler();
1.390 + }
1.391 + }
1.392 +
1.393 + /**
1.394 + * Returns desired template name
1.395 + */
1.396 + function get_tpl_name()
1.397 + {
1.398 + return $this->module->tpl_name . '.html';
1.399 + }
1.400 +
1.401 + /**
1.402 + * Returns the desired page title
1.403 + */
1.404 + function get_page_title()
1.405 + {
1.406 + global $lang;
1.407 +
1.408 + if (!isset($this->module->page_title))
1.409 + {
1.410 + return '';
1.411 + }
1.412 +
1.413 + return (isset($lang[$this->module->page_title])) ? $lang[$this->module->page_title] : $this->module->page_title;
1.414 + }
1.415 +
1.416 + /**
1.417 + * Generate an HTTP/1.1 header to redirect the user to another page
1.418 + * This is used during the installation when we do not have a database available to call the normal redirect function
1.419 + * @param string $page The page to redirect to relative to the installer root path
1.420 + */
1.421 + function redirect($page)
1.422 + {
1.423 + // HTTP_HOST is having the correct browser url in most cases...
1.424 + $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
1.425 + $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
1.426 + $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
1.427 +
1.428 + $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
1.429 + if (!$script_name)
1.430 + {
1.431 + $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
1.432 + }
1.433 +
1.434 + // Replace backslashes and doubled slashes (could happen on some proxy setups)
1.435 + $script_name = str_replace(array('\\', '//'), '/', $script_name);
1.436 + $script_path = trim(dirname($script_name));
1.437 +
1.438 + $url = (($secure) ? 'https://' : 'http://') . $server_name;
1.439 +
1.440 + if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
1.441 + {
1.442 + // HTTP HOST can carry a port number...
1.443 + if (strpos($server_name, ':') === false)
1.444 + {
1.445 + $url .= ':' . $server_port;
1.446 + }
1.447 + }
1.448 +
1.449 + $url .= $script_path . '/' . $page;
1.450 + header('Location: ' . $url);
1.451 + exit;
1.452 + }
1.453 +
1.454 + /**
1.455 + * Generate the navigation tabs
1.456 + */
1.457 + function generate_navigation()
1.458 + {
1.459 + global $lang, $template, $phpEx, $language;
1.460 +
1.461 + if (is_array($this->module_ary))
1.462 + {
1.463 + @ksort($this->module_ary);
1.464 + foreach ($this->module_ary as $cat_ary)
1.465 + {
1.466 + $cat = $cat_ary['name'];
1.467 + $l_cat = (!empty($lang['CAT_' . $cat])) ? $lang['CAT_' . $cat] : preg_replace('#_#', ' ', $cat);
1.468 + $cat = strtolower($cat);
1.469 + $url = $this->module_url . "?mode=$cat&language=$language";
1.470 +
1.471 + if ($this->mode == $cat)
1.472 + {
1.473 + $template->assign_block_vars('t_block1', array(
1.474 + 'L_TITLE' => $l_cat,
1.475 + 'S_SELECTED' => true,
1.476 + 'U_TITLE' => $url,
1.477 + ));
1.478 +
1.479 + if (is_array($this->module_ary[$this->id]['subs']))
1.480 + {
1.481 + $subs = $this->module_ary[$this->id]['subs'];
1.482 + foreach ($subs as $option)
1.483 + {
1.484 + $l_option = (!empty($lang['SUB_' . $option])) ? $lang['SUB_' . $option] : preg_replace('#_#', ' ', $option);
1.485 + $option = strtolower($option);
1.486 + $url = $this->module_url . '?mode=' . $this->mode . "&sub=$option&language=$language";
1.487 +
1.488 + $template->assign_block_vars('l_block1', array(
1.489 + 'L_TITLE' => $l_option,
1.490 + 'S_SELECTED' => ($this->sub == $option),
1.491 + 'U_TITLE' => $url,
1.492 + ));
1.493 + }
1.494 + }
1.495 +
1.496 + if (is_array($this->module_ary[$this->id]['stages']))
1.497 + {
1.498 + $subs = $this->module_ary[$this->id]['stages'];
1.499 + $matched = false;
1.500 + foreach ($subs as $option)
1.501 + {
1.502 + $l_option = (!empty($lang['STAGE_' . $option])) ? $lang['STAGE_' . $option] : preg_replace('#_#', ' ', $option);
1.503 + $option = strtolower($option);
1.504 + $matched = ($this->sub == $option) ? true : $matched;
1.505 +
1.506 + $template->assign_block_vars('l_block2', array(
1.507 + 'L_TITLE' => $l_option,
1.508 + 'S_SELECTED' => ($this->sub == $option),
1.509 + 'S_COMPLETE' => !$matched,
1.510 + ));
1.511 + }
1.512 + }
1.513 + }
1.514 + else
1.515 + {
1.516 + $template->assign_block_vars('t_block1', array(
1.517 + 'L_TITLE' => $l_cat,
1.518 + 'S_SELECTED' => false,
1.519 + 'U_TITLE' => $url,
1.520 + ));
1.521 + }
1.522 + }
1.523 + }
1.524 + }
1.525 +
1.526 + /**
1.527 + * Output an error message
1.528 + * If skip is true, return and continue execution, else exit
1.529 + */
1.530 + function error($error, $line, $file, $skip = false)
1.531 + {
1.532 + global $lang, $db, $template;
1.533 +
1.534 + if ($skip)
1.535 + {
1.536 + $template->assign_block_vars('checks', array(
1.537 + 'S_LEGEND' => true,
1.538 + 'LEGEND' => $lang['INST_ERR'],
1.539 + ));
1.540 +
1.541 + $template->assign_block_vars('checks', array(
1.542 + 'TITLE' => basename($file) . ' [ ' . $line . ' ]',
1.543 + 'RESULT' => '<b style="color:red">' . $error . '</b>',
1.544 + ));
1.545 +
1.546 + return;
1.547 + }
1.548 +
1.549 + echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
1.550 + echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
1.551 + echo '<head>';
1.552 + echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
1.553 + echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
1.554 + echo '<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
1.555 + echo '</head>';
1.556 + echo '<body id="errorpage">';
1.557 + echo '<div id="wrap">';
1.558 + echo ' <div id="page-header">';
1.559 + echo ' </div>';
1.560 + echo ' <div id="page-body">';
1.561 + echo ' <div id="acp">';
1.562 + echo ' <div class="panel">';
1.563 + echo ' <span class="corners-top"><span></span></span>';
1.564 + echo ' <div id="content">';
1.565 + echo ' <h1>' . $lang['INST_ERR_FATAL'] . '</h1>';
1.566 + echo ' <p>' . $lang['INST_ERR_FATAL'] . "</p>\n";
1.567 + echo ' <p>' . basename($file) . ' [ ' . $line . " ]</p>\n";
1.568 + echo ' <p><b>' . $error . "</b></p>\n";
1.569 + echo ' </div>';
1.570 + echo ' <span class="corners-bottom"><span></span></span>';
1.571 + echo ' </div>';
1.572 + echo ' </div>';
1.573 + echo ' </div>';
1.574 + echo ' <div id="page-footer">';
1.575 + echo ' Powered by <a href="http://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Group';
1.576 + echo ' </div>';
1.577 + echo '</div>';
1.578 + echo '</body>';
1.579 + echo '</html>';
1.580 +
1.581 + if (!empty($db) && is_object($db))
1.582 + {
1.583 + $db->sql_close();
1.584 + }
1.585 +
1.586 + exit_handler();
1.587 + }
1.588 +
1.589 + /**
1.590 + * Output an error message for a database related problem
1.591 + * If skip is true, return and continue execution, else exit
1.592 + */
1.593 + function db_error($error, $sql, $line, $file, $skip = false)
1.594 + {
1.595 + global $lang, $db, $template;
1.596 +
1.597 + if ($skip)
1.598 + {
1.599 + $template->assign_block_vars('checks', array(
1.600 + 'S_LEGEND' => true,
1.601 + 'LEGEND' => $lang['INST_ERR_FATAL'],
1.602 + ));
1.603 +
1.604 + $template->assign_block_vars('checks', array(
1.605 + 'TITLE' => basename($file) . ' [ ' . $line . ' ]',
1.606 + 'RESULT' => '<b style="color:red">' . $error . '</b><br />» SQL:' . $sql,
1.607 + ));
1.608 +
1.609 + return;
1.610 + }
1.611 +
1.612 + $template->set_filenames(array(
1.613 + 'body' => 'install_error.html')
1.614 + );
1.615 + $this->page_header();
1.616 + $this->generate_navigation();
1.617 +
1.618 + $template->assign_vars(array(
1.619 + 'MESSAGE_TITLE' => $lang['INST_ERR_FATAL_DB'],
1.620 + 'MESSAGE_TEXT' => '<p>' . basename($file) . ' [ ' . $line . ' ]</p><p>SQL : ' . $sql . '</p><p><b>' . $error . '</b></p>',
1.621 + ));
1.622 +
1.623 + // Rollback if in transaction
1.624 + if ($db->transaction)
1.625 + {
1.626 + $db->sql_transaction('rollback');
1.627 + }
1.628 +
1.629 + $this->page_footer();
1.630 + }
1.631 +
1.632 + /**
1.633 + * Generate the relevant HTML for an input field and the associated label and explanatory text
1.634 + */
1.635 + function input_field($name, $type, $value='', $options='')
1.636 + {
1.637 + global $lang;
1.638 + $tpl_type = explode(':', $type);
1.639 + $tpl = '';
1.640 +
1.641 + switch ($tpl_type[0])
1.642 + {
1.643 + case 'text':
1.644 + case 'password':
1.645 + $size = (int) $tpl_type[1];
1.646 + $maxlength = (int) $tpl_type[2];
1.647 +
1.648 + $tpl = '<input id="' . $name . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $value . '" />';
1.649 + break;
1.650 +
1.651 + case 'textarea':
1.652 + $rows = (int) $tpl_type[1];
1.653 + $cols = (int) $tpl_type[2];
1.654 +
1.655 + $tpl = '<textarea id="' . $name . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $value . '</textarea>';
1.656 + break;
1.657 +
1.658 + case 'radio':
1.659 + $key_yes = ($value) ? ' checked="checked" id="' . $name . '"' : '';
1.660 + $key_no = (!$value) ? ' checked="checked" id="' . $name . '"' : '';
1.661 +
1.662 + $tpl_type_cond = explode('_', $tpl_type[1]);
1.663 + $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
1.664 +
1.665 + $tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $lang['NO'] : $lang['DISABLED']) . '</label>';
1.666 + $tpl_yes = '<label><input type="radio" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $lang['YES'] : $lang['ENABLED']) . '</label>';
1.667 +
1.668 + $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . ' ' . $tpl_no : $tpl_no . ' ' . $tpl_yes;
1.669 + break;
1.670 +
1.671 + case 'select':
1.672 + eval('$s_options = ' . str_replace('{VALUE}', $value, $options) . ';');
1.673 + $tpl = '<select id="' . $name . '" name="' . $name . '">' . $s_options . '</select>';
1.674 + break;
1.675 +
1.676 + case 'custom':
1.677 + eval('$tpl = ' . str_replace('{VALUE}', $value, $options) . ';');
1.678 + break;
1.679 +
1.680 + default:
1.681 + break;
1.682 + }
1.683 +
1.684 + return $tpl;
1.685 + }
1.686 +
1.687 + /**
1.688 + * Generate the drop down of available language packs
1.689 + */
1.690 + function inst_language_select($default = '')
1.691 + {
1.692 + global $phpbb_root_path, $phpEx;
1.693 +
1.694 + $dir = @opendir($phpbb_root_path . 'language');
1.695 +
1.696 + if (!$dir)
1.697 + {
1.698 + $this->error('Unable to access the language directory', __LINE__, __FILE__);
1.699 + }
1.700 +
1.701 + while ($file = readdir($dir))
1.702 + {
1.703 + $path = $phpbb_root_path . 'language/' . $file;
1.704 +
1.705 + if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS')
1.706 + {
1.707 + continue;
1.708 + }
1.709 +
1.710 + if (file_exists($path . '/iso.txt'))
1.711 + {
1.712 + list($displayname, $localname) = @file($path . '/iso.txt');
1.713 + $lang[$localname] = $file;
1.714 + }
1.715 + }
1.716 + closedir($dir);
1.717 +
1.718 + @asort($lang);
1.719 + @reset($lang);
1.720 +
1.721 + $user_select = '';
1.722 + foreach ($lang as $displayname => $filename)
1.723 + {
1.724 + $selected = (strtolower($default) == strtolower($filename)) ? ' selected="selected"' : '';
1.725 + $user_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>';
1.726 + }
1.727 +
1.728 + return $user_select;
1.729 + }
1.730 +}
1.731 +
1.732 +?>
1.733 \ No newline at end of file