Blame Identity/Webenv/phpBB/3.0.4/install/index.php

ef5584
ef5584
/**
ef5584
*
ef5584
* @package install
ef5584
* @version $Id: index.php 8895 2008-09-19 16:54:03Z acydburn $
ef5584
* @copyright (c) 2005 phpBB Group
ef5584
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
ef5584
*
ef5584
*/
ef5584
ef5584
/**#@+
ef5584
* @ignore
ef5584
*/
ef5584
define('IN_PHPBB', true);
ef5584
define('IN_INSTALL', true);
ef5584
/**#@-*/
ef5584
ef5584
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
ef5584
$phpEx = substr(strrchr(__FILE__, '.'), 1);
ef5584
ef5584
// Report all errors, except notices
ef5584
error_reporting(E_ALL ^ E_NOTICE);
ef5584
ef5584
// @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
ef5584
if (version_compare(PHP_VERSION, '4.3.3') < 0)
ef5584
{
ef5584
	die('You are running an unsupported PHP version. Please upgrade to PHP 4.3.3 or higher before trying to install phpBB 3.0');
ef5584
}
ef5584
ef5584
/*
ef5584
* Remove variables created by register_globals from the global scope
ef5584
* Thanks to Matt Kavanagh
ef5584
*/
ef5584
function deregister_globals()
ef5584
{
ef5584
	$not_unset = array(
ef5584
		'GLOBALS'	=> true,
ef5584
		'_GET'		=> true,
ef5584
		'_POST'		=> true,
ef5584
		'_COOKIE'	=> true,
ef5584
		'_REQUEST'	=> true,
ef5584
		'_SERVER'	=> true,
ef5584
		'_SESSION'	=> true,
ef5584
		'_ENV'		=> true,
ef5584
		'_FILES'	=> true,
ef5584
		'phpEx'		=> true,
ef5584
		'phpbb_root_path'	=> true
ef5584
	);
ef5584
ef5584
	// Not only will array_merge and array_keys give a warning if
ef5584
	// a parameter is not an array, array_merge will actually fail.
ef5584
	// So we check if _SESSION has been initialised.
ef5584
	if (!isset($_SESSION) || !is_array($_SESSION))
ef5584
	{
ef5584
		$_SESSION = array();
ef5584
	}
ef5584
ef5584
	// Merge all into one extremely huge array; unset this later
ef5584
	$input = array_merge(
ef5584
		array_keys($_GET),
ef5584
		array_keys($_POST),
ef5584
		array_keys($_COOKIE),
ef5584
		array_keys($_SERVER),
ef5584
		array_keys($_SESSION),
ef5584
		array_keys($_ENV),
ef5584
		array_keys($_FILES)
ef5584
	);
ef5584
ef5584
	foreach ($input as $varname)
ef5584
	{
ef5584
		if (isset($not_unset[$varname]))
ef5584
		{
ef5584
			// Hacking attempt. No point in continuing unless it's a COOKIE
ef5584
			if ($varname !== 'GLOBALS' || isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_SERVER['GLOBALS']) || isset($_SESSION['GLOBALS']) || isset($_ENV['GLOBALS']) || isset($_FILES['GLOBALS']))
ef5584
			{
ef5584
				exit;
ef5584
			}
ef5584
			else
ef5584
			{
ef5584
				$cookie = &$_COOKIE;
ef5584
				while (isset($cookie['GLOBALS']))
ef5584
				{
ef5584
					foreach ($cookie['GLOBALS'] as $registered_var => $value)
ef5584
					{
ef5584
						if (!isset($not_unset[$registered_var]))
ef5584
						{
ef5584
							unset($GLOBALS[$registered_var]);
ef5584
						}
ef5584
					}
ef5584
					$cookie = &$cookie['GLOBALS'];
ef5584
				}
ef5584
			}
ef5584
		}
ef5584
ef5584
		unset($GLOBALS[$varname]);
ef5584
	}
ef5584
ef5584
	unset($input);
ef5584
}
ef5584
ef5584
// If we are on PHP >= 6.0.0 we do not need some code
ef5584
if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
ef5584
{
ef5584
	/**
ef5584
	* @ignore
ef5584
	*/
ef5584
	define('STRIP', false);
ef5584
}
ef5584
else
ef5584
{
ef5584
	@set_magic_quotes_runtime(0);
ef5584
ef5584
	// Be paranoid with passed vars
ef5584
	if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
ef5584
	{
ef5584
		deregister_globals();
ef5584
	}
ef5584
ef5584
	define('STRIP', (get_magic_quotes_gpc()) ? true : false);
ef5584
}
ef5584
ef5584
// Try to override some limits - maybe it helps some...
ef5584
@set_time_limit(0);
ef5584
$mem_limit = @ini_get('memory_limit');
ef5584
if (!empty($mem_limit))
ef5584
{
ef5584
	$unit = strtolower(substr($mem_limit, -1, 1));
ef5584
	$mem_limit = (int) $mem_limit;
ef5584
ef5584
	if ($unit == 'k')
ef5584
	{
ef5584
		$mem_limit = floor($mem_limit / 1024);
ef5584
	}
ef5584
	else if ($unit == 'g')
ef5584
	{
ef5584
		$mem_limit *= 1024;
ef5584
	}
ef5584
	else if (is_numeric($unit))
ef5584
	{
ef5584
		$mem_limit = floor((int) ($mem_limit . $unit) / 1048576);
ef5584
	}
ef5584
	$mem_limit = max(128, $mem_limit) . 'M';
ef5584
}
ef5584
else
ef5584
{
ef5584
	$mem_limit = '128M';
ef5584
}
ef5584
@ini_set('memory_limit', $mem_limit);
ef5584
ef5584
// Include essential scripts
ef5584
require($phpbb_root_path . 'includes/functions.' . $phpEx);
ef5584
ef5584
if (file_exists($phpbb_root_path . 'includes/functions_content.' . $phpEx))
ef5584
{
ef5584
	require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
ef5584
}
ef5584
ef5584
include($phpbb_root_path . 'includes/auth.' . $phpEx);
ef5584
include($phpbb_root_path . 'includes/session.' . $phpEx);
ef5584
include($phpbb_root_path . 'includes/template.' . $phpEx);
ef5584
include($phpbb_root_path . 'includes/acm/acm_file.' . $phpEx);
ef5584
include($phpbb_root_path . 'includes/cache.' . $phpEx);
ef5584
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
ef5584
include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
ef5584
require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
ef5584
ef5584
// Try and load an appropriate language if required
ef5584
$language = basename(request_var('language', ''));
ef5584
ef5584
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !$language)
ef5584
{
ef5584
	$accept_lang_ary = explode(',', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
ef5584
	foreach ($accept_lang_ary as $accept_lang)
ef5584
	{
ef5584
		// Set correct format ... guess full xx_yy form
ef5584
		$accept_lang = substr($accept_lang, 0, 2) . '_' . substr($accept_lang, 3, 2);
ef5584
ef5584
		if (file_exists($phpbb_root_path . 'language/' . $accept_lang))
ef5584
		{
ef5584
			$language = $accept_lang;
ef5584
			break;
ef5584
		}
ef5584
		else
ef5584
		{
ef5584
			// No match on xx_yy so try xx
ef5584
			$accept_lang = substr($accept_lang, 0, 2);
ef5584
			if (file_exists($phpbb_root_path . 'language/' . $accept_lang))
ef5584
			{
ef5584
				$language = $accept_lang;
ef5584
				break;
ef5584
			}
ef5584
		}
ef5584
	}
ef5584
}
ef5584
ef5584
// No appropriate language found ... so let's use the first one in the language
ef5584
// dir, this may or may not be English
ef5584
if (!$language)
ef5584
{
ef5584
	$dir = @opendir($phpbb_root_path . 'language');
ef5584
ef5584
	if (!$dir)
ef5584
	{
ef5584
		die('Unable to access the language directory');
ef5584
		exit;
ef5584
	}
ef5584
ef5584
	while (($file = readdir($dir)) !== false)
ef5584
	{
ef5584
		$path = $phpbb_root_path . 'language/' . $file;
ef5584
ef5584
		if (!is_file($path) && !is_link($path) && file_exists($path . '/iso.txt'))
ef5584
		{
ef5584
			$language = $file;
ef5584
			break;
ef5584
		}
ef5584
	}
ef5584
	closedir($dir);
ef5584
}
ef5584
ef5584
if (!file_exists($phpbb_root_path . 'language/' . $language))
ef5584
{
ef5584
	die('No language found!');
ef5584
}
ef5584
ef5584
// And finally, load the relevant language files
ef5584
include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx);
ef5584
include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx);
ef5584
include($phpbb_root_path . 'language/' . $language . '/acp/board.' . $phpEx);
ef5584
include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx);
ef5584
include($phpbb_root_path . 'language/' . $language . '/posting.' . $phpEx);
ef5584
ef5584
// usually we would need every single constant here - and it would be consistent. For 3.0.x, use a dirty hack... :(
ef5584
ef5584
// Define needed constants
ef5584
define('CHMOD_ALL', 7);
ef5584
define('CHMOD_READ', 4);
ef5584
define('CHMOD_WRITE', 2);
ef5584
define('CHMOD_EXECUTE', 1);
ef5584
ef5584
$mode = request_var('mode', 'overview');
ef5584
$sub = request_var('sub', '');
ef5584
ef5584
// Set PHP error handler to ours
ef5584
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
ef5584
ef5584
$user = new user();
ef5584
$auth = new auth();
ef5584
$cache = new cache();
ef5584
$template = new template();
ef5584
ef5584
// Add own hook handler, if present. :o
ef5584
if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
ef5584
{
ef5584
	require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
ef5584
	$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
ef5584
ef5584
	foreach ($cache->obtain_hooks() as $hook)
ef5584
	{
ef5584
		@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
ef5584
	}
ef5584
}
ef5584
else
ef5584
{
ef5584
	$phpbb_hook = false;
ef5584
}
ef5584
ef5584
// Set some standard variables we want to force
ef5584
$config = array(
ef5584
	'load_tplcompile'	=> '1'
ef5584
);
ef5584
ef5584
$template->set_custom_template('../adm/style', 'admin');
ef5584
$template->assign_var('T_TEMPLATE_PATH', '../adm/style');
ef5584
ef5584
// the acp template is never stored in the database
ef5584
$user->theme['template_storedb'] = false;
ef5584
ef5584
$install = new module();
ef5584
ef5584
$install->create('install', "index.$phpEx", $mode, $sub);
ef5584
$install->load();
ef5584
ef5584
// Generate the page
ef5584
$install->page_header();
ef5584
$install->generate_navigation();
ef5584
ef5584
$template->set_filenames(array(
ef5584
	'body' => $install->get_tpl_name())
ef5584
);
ef5584
ef5584
$install->page_footer();
ef5584
ef5584
/**
ef5584
* @package install
ef5584
*/
ef5584
class module
ef5584
{
ef5584
	var $id = 0;
ef5584
	var $type = 'install';
ef5584
	var $module_ary = array();
ef5584
	var $filename;
ef5584
	var $module_url = '';
ef5584
	var $tpl_name = '';
ef5584
	var $mode;
ef5584
	var $sub;
ef5584
ef5584
	/**
ef5584
	* Private methods, should not be overwritten
ef5584
	*/
ef5584
	function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
ef5584
	{
ef5584
		global $db, $config, $phpEx, $phpbb_root_path;
ef5584
ef5584
		$module = array();
ef5584
ef5584
		// Grab module information using Bart's "neat-o-module" system (tm)
ef5584
		$dir = @opendir('.');
ef5584
ef5584
		if (!$dir)
ef5584
		{
ef5584
			$this->error('Unable to access the installation directory', __LINE__, __FILE__);
ef5584
		}
ef5584
ef5584
		$setmodules = 1;
ef5584
		while (($file = readdir($dir)) !== false)
ef5584
		{
ef5584
			if (preg_match('#^install_(.*?)\.' . $phpEx . '$#', $file))
ef5584
			{
ef5584
				include($file);
ef5584
			}
ef5584
		}
ef5584
		closedir($dir);
ef5584
ef5584
		unset($setmodules);
ef5584
ef5584
		if (!sizeof($module))
ef5584
		{
ef5584
			$this->error('No installation modules found', __LINE__, __FILE__);
ef5584
		}
ef5584
ef5584
		// Order to use and count further if modules get assigned to the same position or not having an order
ef5584
		$max_module_order = 1000;
ef5584
ef5584
		foreach ($module as $row)
ef5584
		{
ef5584
			// Module order not specified or module already assigned at this position?
ef5584
			if (!isset($row['module_order']) || isset($this->module_ary[$row['module_order']]))
ef5584
			{
ef5584
				$row['module_order'] = $max_module_order;
ef5584
				$max_module_order++;
ef5584
			}
ef5584
ef5584
			$this->module_ary[$row['module_order']]['name'] = $row['module_title'];
ef5584
			$this->module_ary[$row['module_order']]['filename'] = $row['module_filename'];
ef5584
			$this->module_ary[$row['module_order']]['subs'] = $row['module_subs'];
ef5584
			$this->module_ary[$row['module_order']]['stages'] = $row['module_stages'];
ef5584
ef5584
			if (strtolower($selected_mod) == strtolower($row['module_title']))
ef5584
			{
ef5584
				$this->id = (int) $row['module_order'];
ef5584
				$this->filename = (string) $row['module_filename'];
ef5584
				$this->module_url = (string) $module_url;
ef5584
				$this->mode = (string) $selected_mod;
ef5584
				// Check that the sub-mode specified is valid or set a default if not
ef5584
				if (is_array($row['module_subs']))
ef5584
				{
ef5584
					$this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_subs'])) ? $selected_submod : $row['module_subs'][0]);
ef5584
				}
ef5584
				else if (is_array($row['module_stages']))
ef5584
				{
ef5584
					$this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_stages'])) ? $selected_submod : $row['module_stages'][0]);
ef5584
				}
ef5584
				else
ef5584
				{
ef5584
					$this->sub = '';
ef5584
				}
ef5584
			}
ef5584
		} // END foreach
ef5584
	} // END create
ef5584
ef5584
	/**
ef5584
	* Load and run the relevant module if applicable
ef5584
	*/
ef5584
	function load($mode = false, $run = true)
ef5584
	{
ef5584
		global $phpbb_root_path, $phpEx;
ef5584
ef5584
		if ($run)
ef5584
		{
ef5584
			if (!empty($mode))
ef5584
			{
ef5584
				$this->mode = $mode;
ef5584
			}
ef5584
ef5584
			$module = $this->filename;
ef5584
			if (!class_exists($module))
ef5584
			{
ef5584
				$this->error('Module "' . htmlspecialchars($module) . '" not accessible.', __LINE__, __FILE__);
ef5584
			}
ef5584
			$this->module = new $module($this);
ef5584
ef5584
			if (method_exists($this->module, 'main'))
ef5584
			{
ef5584
				$this->module->main($this->mode, $this->sub);
ef5584
			}
ef5584
		}
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Output the standard page header
ef5584
	*/
ef5584
	function page_header()
ef5584
	{
ef5584
		if (defined('HEADER_INC'))
ef5584
		{
ef5584
			return;
ef5584
		}
ef5584
ef5584
		define('HEADER_INC', true);
ef5584
		global $template, $lang, $stage, $phpbb_root_path;
ef5584
ef5584
		$template->assign_vars(array(
ef5584
			'L_CHANGE'				=> $lang['CHANGE'],
ef5584
			'L_INSTALL_PANEL'		=> $lang['INSTALL_PANEL'],
ef5584
			'L_SELECT_LANG'			=> $lang['SELECT_LANG'],
ef5584
			'L_SKIP'				=> $lang['SKIP'],
ef5584
			'PAGE_TITLE'			=> $this->get_page_title(),
ef5584
			'T_IMAGE_PATH'			=> $phpbb_root_path . 'adm/images/',
ef5584
ef5584
			'S_CONTENT_DIRECTION' 	=> $lang['DIRECTION'],
ef5584
			'S_CONTENT_FLOW_BEGIN'	=> ($lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
ef5584
			'S_CONTENT_FLOW_END'	=> ($lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
ef5584
			'S_CONTENT_ENCODING' 	=> 'UTF-8',
ef5584
ef5584
			'S_USER_LANG'			=> $lang['USER_LANG'],
ef5584
			)
ef5584
		);
ef5584
ef5584
		header('Content-type: text/html; charset=UTF-8');
ef5584
		header('Cache-Control: private, no-cache="set-cookie"');
ef5584
		header('Expires: 0');
ef5584
		header('Pragma: no-cache');
ef5584
ef5584
		return;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Output the standard page footer
ef5584
	*/
ef5584
	function page_footer()
ef5584
	{
ef5584
		global $db, $template;
ef5584
ef5584
		$template->display('body');
ef5584
ef5584
		// Close our DB connection.
ef5584
		if (!empty($db) && is_object($db))
ef5584
		{
ef5584
			$db->sql_close();
ef5584
		}
ef5584
ef5584
		if (function_exists('exit_handler'))
ef5584
		{
ef5584
			exit_handler();
ef5584
		}
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Returns desired template name
ef5584
	*/
ef5584
	function get_tpl_name()
ef5584
	{
ef5584
		return $this->module->tpl_name . '.html';
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Returns the desired page title
ef5584
	*/
ef5584
	function get_page_title()
ef5584
	{
ef5584
		global $lang;
ef5584
ef5584
		if (!isset($this->module->page_title))
ef5584
		{
ef5584
			return '';
ef5584
		}
ef5584
ef5584
		return (isset($lang[$this->module->page_title])) ? $lang[$this->module->page_title] : $this->module->page_title;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Generate an HTTP/1.1 header to redirect the user to another page
ef5584
	* This is used during the installation when we do not have a database available to call the normal redirect function
ef5584
	* @param string $page The page to redirect to relative to the installer root path
ef5584
	*/
ef5584
	function redirect($page)
ef5584
	{
ef5584
		// HTTP_HOST is having the correct browser url in most cases...
ef5584
		$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
ef5584
		$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
ef5584
		$secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
ef5584
ef5584
		$script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
ef5584
		if (!$script_name)
ef5584
		{
ef5584
			$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
ef5584
		}
ef5584
ef5584
		// Replace backslashes and doubled slashes (could happen on some proxy setups)
ef5584
		$script_name = str_replace(array('\\', '//'), '/', $script_name);
ef5584
		$script_path = trim(dirname($script_name));
ef5584
ef5584
		$url = (($secure) ? 'https://' : 'http://') . $server_name;
ef5584
ef5584
		if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
ef5584
		{
ef5584
			// HTTP HOST can carry a port number...
ef5584
			if (strpos($server_name, ':') === false)
ef5584
			{
ef5584
				$url .= ':' . $server_port;
ef5584
			}
ef5584
		}
ef5584
ef5584
		$url .= $script_path . '/' . $page;
ef5584
		header('Location: ' . $url);
ef5584
		exit;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Generate the navigation tabs
ef5584
	*/
ef5584
	function generate_navigation()
ef5584
	{
ef5584
		global $lang, $template, $phpEx, $language;
ef5584
ef5584
		if (is_array($this->module_ary))
ef5584
		{
ef5584
			@ksort($this->module_ary);
ef5584
			foreach ($this->module_ary as $cat_ary)
ef5584
			{
ef5584
				$cat = $cat_ary['name'];
ef5584
				$l_cat = (!empty($lang['CAT_' . $cat])) ? $lang['CAT_' . $cat] : preg_replace('#_#', ' ', $cat);
ef5584
				$cat = strtolower($cat);
ef5584
				$url = $this->module_url . "?mode=$cat&language=$language";
ef5584
ef5584
				if ($this->mode == $cat)
ef5584
				{
ef5584
					$template->assign_block_vars('t_block1', array(
ef5584
						'L_TITLE'		=> $l_cat,
ef5584
						'S_SELECTED'	=> true,
ef5584
						'U_TITLE'		=> $url,
ef5584
					));
ef5584
ef5584
					if (is_array($this->module_ary[$this->id]['subs']))
ef5584
					{
ef5584
						$subs = $this->module_ary[$this->id]['subs'];
ef5584
						foreach ($subs as $option)
ef5584
						{
ef5584
							$l_option = (!empty($lang['SUB_' . $option])) ? $lang['SUB_' . $option] : preg_replace('#_#', ' ', $option);
ef5584
							$option = strtolower($option);
ef5584
							$url = $this->module_url . '?mode=' . $this->mode . "&sub=$option&language=$language";
ef5584
ef5584
							$template->assign_block_vars('l_block1', array(
ef5584
								'L_TITLE'		=> $l_option,
ef5584
								'S_SELECTED'	=> ($this->sub == $option),
ef5584
								'U_TITLE'		=> $url,
ef5584
							));
ef5584
						}
ef5584
					}
ef5584
ef5584
					if (is_array($this->module_ary[$this->id]['stages']))
ef5584
					{
ef5584
						$subs = $this->module_ary[$this->id]['stages'];
ef5584
						$matched = false;
ef5584
						foreach ($subs as $option)
ef5584
						{
ef5584
							$l_option = (!empty($lang['STAGE_' . $option])) ? $lang['STAGE_' . $option] : preg_replace('#_#', ' ', $option);
ef5584
							$option = strtolower($option);
ef5584
							$matched = ($this->sub == $option) ? true : $matched;
ef5584
ef5584
							$template->assign_block_vars('l_block2', array(
ef5584
								'L_TITLE'		=> $l_option,
ef5584
								'S_SELECTED'	=> ($this->sub == $option),
ef5584
								'S_COMPLETE'	=> !$matched,
ef5584
							));
ef5584
						}
ef5584
					}
ef5584
				}
ef5584
				else
ef5584
				{
ef5584
					$template->assign_block_vars('t_block1', array(
ef5584
						'L_TITLE'		=> $l_cat,
ef5584
						'S_SELECTED'	=> false,
ef5584
						'U_TITLE'		=> $url,
ef5584
					));
ef5584
				}
ef5584
			}
ef5584
		}
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Output an error message
ef5584
	* If skip is true, return and continue execution, else exit
ef5584
	*/
ef5584
	function error($error, $line, $file, $skip = false)
ef5584
	{
ef5584
		global $lang, $db, $template;
ef5584
ef5584
		if ($skip)
ef5584
		{
ef5584
			$template->assign_block_vars('checks', array(
ef5584
				'S_LEGEND'	=> true,
ef5584
				'LEGEND'	=> $lang['INST_ERR'],
ef5584
			));
ef5584
ef5584
			$template->assign_block_vars('checks', array(
ef5584
				'TITLE'		=> basename($file) . ' [ ' . $line . ' ]',
ef5584
				'RESULT'	=> '' . $error . '',
ef5584
			));
ef5584
ef5584
			return;
ef5584
		}
ef5584
ef5584
		echo '';
ef5584
		echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
ef5584
		echo '<head>';
ef5584
		echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
ef5584
		echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
ef5584
		echo '<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
ef5584
		echo '</head>';
ef5584
		echo '<body id="errorpage">';
ef5584
		echo '
';
ef5584
		echo '	
ef5584
		echo '	';
ef5584
		echo '	
';
ef5584
		echo '		
';
ef5584
		echo '		
';
ef5584
		echo '			';
ef5584
		echo '			
';
ef5584
		echo '				

' . $lang['INST_ERR_FATAL'] . '

';
ef5584
		echo '		

' . $lang['INST_ERR_FATAL'] . "

\n";
ef5584
		echo '		

' . basename($file) . ' [ ' . $line . " ]

\n";
ef5584
		echo '		

' . $error . "

\n";
ef5584
		echo '			';
ef5584
		echo '			';
ef5584
		echo '		';
ef5584
		echo '		';
ef5584
		echo '	';
ef5584
		echo '	
ef5584
		echo '		Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group';
ef5584
		echo '	';
ef5584
		echo '';
ef5584
		echo '</body>';
ef5584
		echo '</html>';
ef5584
ef5584
		if (!empty($db) && is_object($db))
ef5584
		{
ef5584
			$db->sql_close();
ef5584
		}
ef5584
ef5584
		exit_handler();
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Output an error message for a database related problem
ef5584
	* If skip is true, return and continue execution, else exit
ef5584
	*/
ef5584
	function db_error($error, $sql, $line, $file, $skip = false)
ef5584
	{
ef5584
		global $lang, $db, $template;
ef5584
ef5584
		if ($skip)
ef5584
		{
ef5584
			$template->assign_block_vars('checks', array(
ef5584
				'S_LEGEND'	=> true,
ef5584
				'LEGEND'	=> $lang['INST_ERR_FATAL'],
ef5584
			));
ef5584
ef5584
			$template->assign_block_vars('checks', array(
ef5584
				'TITLE'		=> basename($file) . ' [ ' . $line . ' ]',
ef5584
				'RESULT'	=> '' . $error . '
» SQL:' . $sql,
ef5584
			));
ef5584
ef5584
			return;
ef5584
		}
ef5584
ef5584
		$template->set_filenames(array(
ef5584
			'body' => 'install_error.html')
ef5584
		);
ef5584
		$this->page_header();
ef5584
		$this->generate_navigation();
ef5584
ef5584
		$template->assign_vars(array(
ef5584
			'MESSAGE_TITLE'		=> $lang['INST_ERR_FATAL_DB'],
ef5584
			'MESSAGE_TEXT'		=> '

' . basename($file) . ' [ ' . $line . ' ]

SQL : ' . $sql . '

' . $error . '

',
ef5584
		));
ef5584
ef5584
		// Rollback if in transaction
ef5584
		if ($db->transaction)
ef5584
		{
ef5584
			$db->sql_transaction('rollback');
ef5584
		}
ef5584
ef5584
		$this->page_footer();
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Generate the relevant HTML for an input field and the associated label and explanatory text
ef5584
	*/
ef5584
	function input_field($name, $type, $value='', $options='')
ef5584
	{
ef5584
		global $lang;
ef5584
		$tpl_type = explode(':', $type);
ef5584
		$tpl = '';
ef5584
ef5584
		switch ($tpl_type[0])
ef5584
		{
ef5584
			case 'text':
ef5584
			case 'password':
ef5584
				$size = (int) $tpl_type[1];
ef5584
				$maxlength = (int) $tpl_type[2];
ef5584
ef5584
				$tpl = '<input id="' . $name . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $value . '" />';
ef5584
			break;
ef5584
ef5584
			case 'textarea':
ef5584
				$rows = (int) $tpl_type[1];
ef5584
				$cols = (int) $tpl_type[2];
ef5584
ef5584
				$tpl = '<textarea id="' . $name . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $value . '</textarea>';
ef5584
			break;
ef5584
ef5584
			case 'radio':
ef5584
				$key_yes	= ($value) ? ' checked="checked" id="' . $name . '"' : '';
ef5584
				$key_no		= (!$value) ? ' checked="checked" id="' . $name . '"' : '';
ef5584
ef5584
				$tpl_type_cond = explode('_', $tpl_type[1]);
ef5584
				$type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
ef5584
ef5584
				$tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $lang['NO'] : $lang['DISABLED']) . '</label>';
ef5584
				$tpl_yes = '<label><input type="radio" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $lang['YES'] : $lang['ENABLED']) . '</label>';
ef5584
ef5584
				$tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . '  ' . $tpl_no : $tpl_no . '  ' . $tpl_yes;
ef5584
			break;
ef5584
ef5584
			case 'select':
ef5584
				eval('$s_options = ' . str_replace('{VALUE}', $value, $options) . ';');
ef5584
				$tpl = '<select id="' . $name . '" name="' . $name . '">' . $s_options . '</select>';
ef5584
			break;
ef5584
ef5584
			case 'custom':
ef5584
				eval('$tpl = ' . str_replace('{VALUE}', $value, $options) . ';');
ef5584
			break;
ef5584
ef5584
			default:
ef5584
			break;
ef5584
		}
ef5584
ef5584
		return $tpl;
ef5584
	}
ef5584
ef5584
	/**
ef5584
	* Generate the drop down of available language packs
ef5584
	*/
ef5584
	function inst_language_select($default = '')
ef5584
	{
ef5584
		global $phpbb_root_path, $phpEx;
ef5584
ef5584
		$dir = @opendir($phpbb_root_path . 'language');
ef5584
ef5584
		if (!$dir)
ef5584
		{
ef5584
			$this->error('Unable to access the language directory', __LINE__, __FILE__);
ef5584
		}
ef5584
ef5584
		while ($file = readdir($dir))
ef5584
		{
ef5584
			$path = $phpbb_root_path . 'language/' . $file;
ef5584
ef5584
			if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS')
ef5584
			{
ef5584
				continue;
ef5584
			}
ef5584
ef5584
			if (file_exists($path . '/iso.txt'))
ef5584
			{
ef5584
				list($displayname, $localname) = @file($path . '/iso.txt');
ef5584
				$lang[$localname] = $file;
ef5584
			}
ef5584
		}
ef5584
		closedir($dir);
ef5584
ef5584
		@asort($lang);
ef5584
		@reset($lang);
ef5584
ef5584
		$user_select = '';
ef5584
		foreach ($lang as $displayname => $filename)
ef5584
		{
ef5584
			$selected = (strtolower($default) == strtolower($filename)) ? ' selected="selected"' : '';
ef5584
			$user_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>';
ef5584
		}
ef5584
ef5584
		return $user_select;
ef5584
	}
ef5584
}
ef5584
ef5584
?>