Blame Extras/phpBB/3.0.4/install/index.php

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

' . $lang['INST_ERR_FATAL'] . '

';
4c79b5
		echo '		

' . $lang['INST_ERR_FATAL'] . "

\n";
4c79b5
		echo '		

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

\n";
4c79b5
		echo '		

' . $error . "

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

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

SQL : ' . $sql . '

' . $error . '

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