Blame Identity/Models/Html/phpBB/3.0.4/install/install_install.php

d6e8d8
d6e8d8
/**
d6e8d8
*
d6e8d8
* @package install
d6e8d8
* @version $Id: install_install.php 9041 2008-11-02 11:19:12Z acydburn $
d6e8d8
* @copyright (c) 2005 phpBB Group
d6e8d8
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
d6e8d8
*
d6e8d8
*/
d6e8d8
d6e8d8
/**
d6e8d8
*/
d6e8d8
if (!defined('IN_INSTALL'))
d6e8d8
{
d6e8d8
	// Someone has tried to access the file direct. This is not a good idea, so exit
d6e8d8
	exit;
d6e8d8
}
d6e8d8
d6e8d8
if (!empty($setmodules))
d6e8d8
{
d6e8d8
	// If phpBB is already installed we do not include this module
d6e8d8
	if (@file_exists($phpbb_root_path . 'config.' . $phpEx) && !file_exists($phpbb_root_path . 'cache/install_lock'))
d6e8d8
	{
d6e8d8
		include_once($phpbb_root_path . 'config.' . $phpEx);
d6e8d8
d6e8d8
		if (defined('PHPBB_INSTALLED'))
d6e8d8
		{
d6e8d8
			return;
d6e8d8
		}
d6e8d8
	}
d6e8d8
d6e8d8
	$module[] = array(
d6e8d8
		'module_type'		=> 'install',
d6e8d8
		'module_title'		=> 'INSTALL',
d6e8d8
		'module_filename'	=> substr(basename(__FILE__), 0, -strlen($phpEx)-1),
d6e8d8
		'module_order'		=> 10,
d6e8d8
		'module_subs'		=> '',
d6e8d8
		'module_stages'		=> array('INTRO', 'REQUIREMENTS', 'DATABASE', 'ADMINISTRATOR', 'CONFIG_FILE', 'ADVANCED', 'CREATE_TABLE', 'FINAL'),
d6e8d8
		'module_reqs'		=> ''
d6e8d8
	);
d6e8d8
}
d6e8d8
d6e8d8
/**
d6e8d8
* Installation
d6e8d8
* @package install
d6e8d8
*/
d6e8d8
class install_install extends module
d6e8d8
{
d6e8d8
	function install_install(&$p_master)
d6e8d8
	{
d6e8d8
		$this->p_master = &$p_master;
d6e8d8
	}
d6e8d8
d6e8d8
	function main($mode, $sub)
d6e8d8
	{
d6e8d8
		global $lang, $template, $language, $phpbb_root_path;
d6e8d8
d6e8d8
		switch ($sub)
d6e8d8
		{
d6e8d8
			case 'intro':
d6e8d8
				$this->page_title = $lang['SUB_INTRO'];
d6e8d8
d6e8d8
				$template->assign_vars(array(
d6e8d8
					'TITLE'			=> $lang['INSTALL_INTRO'],
d6e8d8
					'BODY'			=> $lang['INSTALL_INTRO_BODY'],
d6e8d8
					'L_SUBMIT'		=> $lang['NEXT_STEP'],
d6e8d8
					'S_LANG_SELECT'	=> '<select id="language" name="language">' . $this->p_master->inst_language_select($language) . '</select>',
d6e8d8
					'U_ACTION'		=> $this->p_master->module_url . "?mode=$mode&sub=requirements&language=$language",
d6e8d8
				));
d6e8d8
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'requirements':
d6e8d8
				$this->check_server_requirements($mode, $sub);
d6e8d8
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'database':
d6e8d8
				$this->obtain_database_settings($mode, $sub);
d6e8d8
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'administrator':
d6e8d8
				$this->obtain_admin_settings($mode, $sub);
d6e8d8
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'config_file':
d6e8d8
				$this->create_config_file($mode, $sub);
d6e8d8
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'advanced':
d6e8d8
				$this->obtain_advanced_settings($mode, $sub);
d6e8d8
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'create_table':
d6e8d8
				$this->load_schema($mode, $sub);
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'final':
d6e8d8
				$this->build_search_index($mode, $sub);
d6e8d8
				$this->add_modules($mode, $sub);
d6e8d8
				$this->add_language($mode, $sub);
d6e8d8
				$this->add_bots($mode, $sub);
d6e8d8
				$this->email_admin($mode, $sub);
d6e8d8
d6e8d8
				// Remove the lock file
d6e8d8
				@unlink($phpbb_root_path . 'cache/install_lock');
d6e8d8
d6e8d8
			break;
d6e8d8
		}
d6e8d8
d6e8d8
		$this->tpl_name = 'install_install';
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Checks that the server we are installing on meets the requirements for running phpBB
d6e8d8
	*/
d6e8d8
	function check_server_requirements($mode, $sub)
d6e8d8
	{
d6e8d8
		global $lang, $template, $phpbb_root_path, $phpEx, $language;
d6e8d8
d6e8d8
		$this->page_title = $lang['STAGE_REQUIREMENTS'];
d6e8d8
d6e8d8
		$template->assign_vars(array(
d6e8d8
			'TITLE'		=> $lang['REQUIREMENTS_TITLE'],
d6e8d8
			'BODY'		=> $lang['REQUIREMENTS_EXPLAIN'],
d6e8d8
		));
d6e8d8
d6e8d8
		$passed = array('php' => false, 'db' => false, 'files' => false, 'pcre' => false, 'imagesize' => false,);
d6e8d8
d6e8d8
		// Test for basic PHP settings
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'S_LEGEND'			=> true,
d6e8d8
			'LEGEND'			=> $lang['PHP_SETTINGS'],
d6e8d8
			'LEGEND_EXPLAIN'	=> $lang['PHP_SETTINGS_EXPLAIN'],
d6e8d8
		));
d6e8d8
d6e8d8
		// Test the minimum PHP version
d6e8d8
		$php_version = PHP_VERSION;
d6e8d8
d6e8d8
		if (version_compare($php_version, '4.3.3') < 0)
d6e8d8
		{
d6e8d8
			$result = '' . $lang['NO'] . '';
d6e8d8
		}
d6e8d8
		else
d6e8d8
		{
d6e8d8
			$passed['php'] = true;
d6e8d8
d6e8d8
			// We also give feedback on whether we're running in safe mode
d6e8d8
			$result = '' . $lang['YES'];
d6e8d8
			if (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) == 'on')
d6e8d8
			{
d6e8d8
				$result .= ', ' . $lang['PHP_SAFE_MODE'];
d6e8d8
			}
d6e8d8
			$result .= '';
d6e8d8
		}
d6e8d8
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'TITLE'			=> $lang['PHP_VERSION_REQD'],
d6e8d8
			'RESULT'		=> $result,
d6e8d8
d6e8d8
			'S_EXPLAIN'		=> false,
d6e8d8
			'S_LEGEND'		=> false,
d6e8d8
		));
d6e8d8
d6e8d8
		// Check for register_globals being enabled
d6e8d8
		if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
d6e8d8
		{
d6e8d8
			$result = '' . $lang['NO'] . '';
d6e8d8
		}
d6e8d8
		else
d6e8d8
		{
d6e8d8
			$result = '' . $lang['YES'] . '';
d6e8d8
		}
d6e8d8
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'TITLE'			=> $lang['PHP_REGISTER_GLOBALS'],
d6e8d8
			'TITLE_EXPLAIN'	=> $lang['PHP_REGISTER_GLOBALS_EXPLAIN'],
d6e8d8
			'RESULT'		=> $result,
d6e8d8
d6e8d8
			'S_EXPLAIN'		=> true,
d6e8d8
			'S_LEGEND'		=> false,
d6e8d8
		));
d6e8d8
d6e8d8
d6e8d8
		// Check for url_fopen
d6e8d8
		if (@ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on')
d6e8d8
		{
d6e8d8
			$result = '' . $lang['YES'] . '';
d6e8d8
		}
d6e8d8
		else
d6e8d8
		{
d6e8d8
			$result = '' . $lang['NO'] . '';
d6e8d8
		}
d6e8d8
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'TITLE'			=> $lang['PHP_URL_FOPEN_SUPPORT'],
d6e8d8
			'TITLE_EXPLAIN'	=> $lang['PHP_URL_FOPEN_SUPPORT_EXPLAIN'],
d6e8d8
			'RESULT'		=> $result,
d6e8d8
d6e8d8
			'S_EXPLAIN'		=> true,
d6e8d8
			'S_LEGEND'		=> false,
d6e8d8
		));
d6e8d8
d6e8d8
d6e8d8
		// Check for getimagesize
d6e8d8
		if (@function_exists('getimagesize'))
d6e8d8
		{
d6e8d8
			$passed['imagesize'] = true;
d6e8d8
			$result = '' . $lang['YES'] . '';
d6e8d8
		}
d6e8d8
		else
d6e8d8
		{
d6e8d8
			$result = '' . $lang['NO'] . '';
d6e8d8
		}
d6e8d8
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'TITLE'			=> $lang['PHP_GETIMAGESIZE_SUPPORT'],
d6e8d8
			'TITLE_EXPLAIN'	=> $lang['PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'],
d6e8d8
			'RESULT'		=> $result,
d6e8d8
d6e8d8
			'S_EXPLAIN'		=> true,
d6e8d8
			'S_LEGEND'		=> false,
d6e8d8
		));
d6e8d8
d6e8d8
		// Check for PCRE UTF-8 support
d6e8d8
		if (@preg_match('//u', ''))
d6e8d8
		{
d6e8d8
			$passed['pcre'] = true;
d6e8d8
			$result = '' . $lang['YES'] . '';
d6e8d8
		}
d6e8d8
		else
d6e8d8
		{
d6e8d8
			$result = '' . $lang['NO'] . '';
d6e8d8
		}
d6e8d8
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'TITLE'			=> $lang['PCRE_UTF_SUPPORT'],
d6e8d8
			'TITLE_EXPLAIN'	=> $lang['PCRE_UTF_SUPPORT_EXPLAIN'],
d6e8d8
			'RESULT'		=> $result,
d6e8d8
d6e8d8
			'S_EXPLAIN'		=> true,
d6e8d8
			'S_LEGEND'		=> false,
d6e8d8
		));
d6e8d8
d6e8d8
/**
d6e8d8
*		Better not enabling and adding to the loaded extensions due to the specific requirements needed
d6e8d8
		if (!@extension_loaded('mbstring'))
d6e8d8
		{
d6e8d8
			can_load_dll('mbstring');
d6e8d8
		}
d6e8d8
*/
d6e8d8
d6e8d8
		$passed['mbstring'] = true;
d6e8d8
		if (@extension_loaded('mbstring'))
d6e8d8
		{
d6e8d8
			// Test for available database modules
d6e8d8
			$template->assign_block_vars('checks', array(
d6e8d8
				'S_LEGEND'			=> true,
d6e8d8
				'LEGEND'			=> $lang['MBSTRING_CHECK'],
d6e8d8
				'LEGEND_EXPLAIN'	=> $lang['MBSTRING_CHECK_EXPLAIN'],
d6e8d8
			));
d6e8d8
d6e8d8
			$checks = array(
d6e8d8
				array('func_overload', '&', MB_OVERLOAD_MAIL|MB_OVERLOAD_STRING),
d6e8d8
				array('encoding_translation', '!=', 0),
d6e8d8
				array('http_input', '!=', 'pass'),
d6e8d8
				array('http_output', '!=', 'pass')
d6e8d8
			);
d6e8d8
d6e8d8
			foreach ($checks as $mb_checks)
d6e8d8
			{
d6e8d8
				$ini_val = @ini_get('mbstring.' . $mb_checks[0]);
d6e8d8
				switch ($mb_checks[1])
d6e8d8
				{
d6e8d8
					case '&':
d6e8d8
						if (intval($ini_val) & $mb_checks[2])
d6e8d8
						{
d6e8d8
							$result = '' . $lang['NO'] . '';
d6e8d8
							$passed['mbstring'] = false;
d6e8d8
						}
d6e8d8
						else
d6e8d8
						{
d6e8d8
							$result = '' . $lang['YES'] . '';
d6e8d8
						}
d6e8d8
					break;
d6e8d8
d6e8d8
					case '!=':
d6e8d8
						if ($ini_val != $mb_checks[2])
d6e8d8
						{
d6e8d8
							$result = '' . $lang['NO'] . '';
d6e8d8
							$passed['mbstring'] = false;
d6e8d8
						}
d6e8d8
						else
d6e8d8
						{
d6e8d8
							$result = '' . $lang['YES'] . '';
d6e8d8
						}
d6e8d8
					break;
d6e8d8
				}
d6e8d8
				$template->assign_block_vars('checks', array(
d6e8d8
					'TITLE'			=> $lang['MBSTRING_' . strtoupper($mb_checks[0])],
d6e8d8
					'TITLE_EXPLAIN'	=> $lang['MBSTRING_' . strtoupper($mb_checks[0]) . '_EXPLAIN'],
d6e8d8
					'RESULT'		=> $result,
d6e8d8
d6e8d8
					'S_EXPLAIN'		=> true,
d6e8d8
					'S_LEGEND'		=> false,
d6e8d8
				));
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		// Test for available database modules
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'S_LEGEND'			=> true,
d6e8d8
			'LEGEND'			=> $lang['PHP_SUPPORTED_DB'],
d6e8d8
			'LEGEND_EXPLAIN'	=> $lang['PHP_SUPPORTED_DB_EXPLAIN'],
d6e8d8
		));
d6e8d8
d6e8d8
		$available_dbms = get_available_dbms(false, true);
d6e8d8
		$passed['db'] = $available_dbms['ANY_DB_SUPPORT'];
d6e8d8
		unset($available_dbms['ANY_DB_SUPPORT']);
d6e8d8
d6e8d8
		foreach ($available_dbms as $db_name => $db_ary)
d6e8d8
		{
d6e8d8
			if (!$db_ary['AVAILABLE'])
d6e8d8
			{
d6e8d8
				$template->assign_block_vars('checks', array(
d6e8d8
					'TITLE'		=> $lang['DLL_' . strtoupper($db_name)],
d6e8d8
					'RESULT'	=> '' . $lang['UNAVAILABLE'] . '',
d6e8d8
d6e8d8
					'S_EXPLAIN'	=> false,
d6e8d8
					'S_LEGEND'	=> false,
d6e8d8
				));
d6e8d8
			}
d6e8d8
			else
d6e8d8
			{
d6e8d8
				$template->assign_block_vars('checks', array(
d6e8d8
					'TITLE'		=> $lang['DLL_' . strtoupper($db_name)],
d6e8d8
					'RESULT'	=> '' . $lang['AVAILABLE'] . '',
d6e8d8
d6e8d8
					'S_EXPLAIN'	=> false,
d6e8d8
					'S_LEGEND'	=> false,
d6e8d8
				));
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		// Test for other modules
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'S_LEGEND'			=> true,
d6e8d8
			'LEGEND'			=> $lang['PHP_OPTIONAL_MODULE'],
d6e8d8
			'LEGEND_EXPLAIN'	=> $lang['PHP_OPTIONAL_MODULE_EXPLAIN'],
d6e8d8
		));
d6e8d8
d6e8d8
		foreach ($this->php_dlls_other as $dll)
d6e8d8
		{
d6e8d8
			if (!@extension_loaded($dll))
d6e8d8
			{
d6e8d8
				if (!can_load_dll($dll))
d6e8d8
				{
d6e8d8
					$template->assign_block_vars('checks', array(
d6e8d8
						'TITLE'		=> $lang['DLL_' . strtoupper($dll)],
d6e8d8
						'RESULT'	=> '' . $lang['UNAVAILABLE'] . '',
d6e8d8
d6e8d8
						'S_EXPLAIN'	=> false,
d6e8d8
						'S_LEGEND'	=> false,
d6e8d8
					));
d6e8d8
					continue;
d6e8d8
				}
d6e8d8
			}
d6e8d8
d6e8d8
			$template->assign_block_vars('checks', array(
d6e8d8
				'TITLE'		=> $lang['DLL_' . strtoupper($dll)],
d6e8d8
				'RESULT'	=> '' . $lang['AVAILABLE'] . '',
d6e8d8
d6e8d8
				'S_EXPLAIN'	=> false,
d6e8d8
				'S_LEGEND'	=> false,
d6e8d8
			));
d6e8d8
		}
d6e8d8
d6e8d8
		// Can we find Imagemagick anywhere on the system?
d6e8d8
		$exe = (DIRECTORY_SEPARATOR == '\\') ? '.exe' : '';
d6e8d8
d6e8d8
		$magic_home = getenv('MAGICK_HOME');
d6e8d8
		$img_imagick = '';
d6e8d8
		if (empty($magic_home))
d6e8d8
		{
d6e8d8
			$locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/');
d6e8d8
			$path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH'))));
d6e8d8
d6e8d8
			$locations = array_merge($path_locations, $locations);
d6e8d8
			foreach ($locations as $location)
d6e8d8
			{
d6e8d8
				// The path might not end properly, fudge it
d6e8d8
				if (substr($location, -1, 1) !== '/')
d6e8d8
				{
d6e8d8
					$location .= '/';
d6e8d8
				}
d6e8d8
d6e8d8
				if (@file_exists($location) && @is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000)
d6e8d8
				{
d6e8d8
					$img_imagick = str_replace('\\', '/', $location);
d6e8d8
					continue;
d6e8d8
				}
d6e8d8
			}
d6e8d8
		}
d6e8d8
		else
d6e8d8
		{
d6e8d8
			$img_imagick = str_replace('\\', '/', $magic_home);
d6e8d8
		}
d6e8d8
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'TITLE'		=> $lang['APP_MAGICK'],
d6e8d8
			'RESULT'	=> ($img_imagick) ? '' . $lang['AVAILABLE'] . ', ' . $img_imagick . '' : '' . $lang['NO_LOCATION'] . '',
d6e8d8
d6e8d8
			'S_EXPLAIN'	=> false,
d6e8d8
			'S_LEGEND'	=> false,
d6e8d8
		));
d6e8d8
d6e8d8
		// Check permissions on files/directories we need access to
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'S_LEGEND'			=> true,
d6e8d8
			'LEGEND'			=> $lang['FILES_REQUIRED'],
d6e8d8
			'LEGEND_EXPLAIN'	=> $lang['FILES_REQUIRED_EXPLAIN'],
d6e8d8
		));
d6e8d8
d6e8d8
		$directories = array('cache/', 'files/', 'store/');
d6e8d8
d6e8d8
		umask(0);
d6e8d8
d6e8d8
		$passed['files'] = true;
d6e8d8
		foreach ($directories as $dir)
d6e8d8
		{
d6e8d8
			$exists = $write = false;
d6e8d8
d6e8d8
			// Try to create the directory if it does not exist
d6e8d8
			if (!file_exists($phpbb_root_path . $dir))
d6e8d8
			{
d6e8d8
				@mkdir($phpbb_root_path . $dir, 0777);
d6e8d8
				phpbb_chmod($phpbb_root_path . $dir, CHMOD_READ | CHMOD_WRITE);
d6e8d8
			}
d6e8d8
d6e8d8
			// Now really check
d6e8d8
			if (file_exists($phpbb_root_path . $dir) && is_dir($phpbb_root_path . $dir))
d6e8d8
			{
d6e8d8
				phpbb_chmod($phpbb_root_path . $dir, CHMOD_READ | CHMOD_WRITE);
d6e8d8
				$exists = true;
d6e8d8
			}
d6e8d8
d6e8d8
			// Now check if it is writable by storing a simple file
d6e8d8
			$fp = @fopen($phpbb_root_path . $dir . 'test_lock', 'wb');
d6e8d8
			if ($fp !== false)
d6e8d8
			{
d6e8d8
				$write = true;
d6e8d8
			}
d6e8d8
			@fclose($fp);
d6e8d8
d6e8d8
			@unlink($phpbb_root_path . $dir . 'test_lock');
d6e8d8
d6e8d8
			$passed['files'] = ($exists && $write && $passed['files']) ? true : false;
d6e8d8
d6e8d8
			$exists = ($exists) ? '' . $lang['FOUND'] . '' : '' . $lang['NOT_FOUND'] . '';
d6e8d8
			$write = ($write) ? ', ' . $lang['WRITABLE'] . '' : (($exists) ? ', ' . $lang['UNWRITABLE'] . '' : '');
d6e8d8
d6e8d8
			$template->assign_block_vars('checks', array(
d6e8d8
				'TITLE'		=> $dir,
d6e8d8
				'RESULT'	=> $exists . $write,
d6e8d8
d6e8d8
				'S_EXPLAIN'	=> false,
d6e8d8
				'S_LEGEND'	=> false,
d6e8d8
			));
d6e8d8
		}
d6e8d8
d6e8d8
		// Check permissions on files/directories it would be useful access to
d6e8d8
		$template->assign_block_vars('checks', array(
d6e8d8
			'S_LEGEND'			=> true,
d6e8d8
			'LEGEND'			=> $lang['FILES_OPTIONAL'],
d6e8d8
			'LEGEND_EXPLAIN'	=> $lang['FILES_OPTIONAL_EXPLAIN'],
d6e8d8
		));
d6e8d8
d6e8d8
		$directories = array('config.' . $phpEx, 'images/avatars/upload/');
d6e8d8
d6e8d8
		foreach ($directories as $dir)
d6e8d8
		{
d6e8d8
			$write = $exists = true;
d6e8d8
			if (file_exists($phpbb_root_path . $dir))
d6e8d8
			{
d6e8d8
				if (!@is_writable($phpbb_root_path . $dir))
d6e8d8
				{
d6e8d8
					$write = false;
d6e8d8
				}
d6e8d8
			}
d6e8d8
			else
d6e8d8
			{
d6e8d8
				$write = $exists = false;
d6e8d8
			}
d6e8d8
d6e8d8
			$exists_str = ($exists) ? '' . $lang['FOUND'] . '' : '' . $lang['NOT_FOUND'] . '';
d6e8d8
			$write_str = ($write) ? ', ' . $lang['WRITABLE'] . '' : (($exists) ? ', ' . $lang['UNWRITABLE'] . '' : '');
d6e8d8
d6e8d8
			$template->assign_block_vars('checks', array(
d6e8d8
				'TITLE'		=> $dir,
d6e8d8
				'RESULT'	=> $exists_str . $write_str,
d6e8d8
d6e8d8
				'S_EXPLAIN'	=> false,
d6e8d8
				'S_LEGEND'	=> false,
d6e8d8
			));
d6e8d8
		}
d6e8d8
d6e8d8
		// And finally where do we want to go next (well today is taken isn't it :P)
d6e8d8
		$s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . addslashes($img_imagick) . '" />' : '';
d6e8d8
d6e8d8
		$url = (!in_array(false, $passed)) ? $this->p_master->module_url . "?mode=$mode&sub=database&language=$language" : $this->p_master->module_url . "?mode=$mode&sub=requirements&language=$language	";
d6e8d8
		$submit = (!in_array(false, $passed)) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST'];
d6e8d8
d6e8d8
d6e8d8
		$template->assign_vars(array(
d6e8d8
			'L_SUBMIT'	=> $submit,
d6e8d8
			'S_HIDDEN'	=> $s_hidden_fields,
d6e8d8
			'U_ACTION'	=> $url,
d6e8d8
		));
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Obtain the information required to connect to the database
d6e8d8
	*/
d6e8d8
	function obtain_database_settings($mode, $sub)
d6e8d8
	{
d6e8d8
		global $lang, $template, $phpEx;
d6e8d8
d6e8d8
		$this->page_title = $lang['STAGE_DATABASE'];
d6e8d8
d6e8d8
		// Obtain any submitted data
d6e8d8
		$data = $this->get_submitted_data();
d6e8d8
d6e8d8
		$connect_test = false;
d6e8d8
		$error = array();
d6e8d8
		$available_dbms = get_available_dbms(false, true);
d6e8d8
d6e8d8
		// Has the user opted to test the connection?
d6e8d8
		if (isset($_POST['testdb']))
d6e8d8
		{
d6e8d8
			if (!isset($available_dbms[$data['dbms']]) || !$available_dbms[$data['dbms']]['AVAILABLE'])
d6e8d8
			{
d6e8d8
				$error['db'][] = $lang['INST_ERR_NO_DB'];
d6e8d8
				$connect_test = false;
d6e8d8
			}
d6e8d8
			else
d6e8d8
			{
d6e8d8
				$connect_test = connect_check_db(true, $error, $available_dbms[$data['dbms']], $data['table_prefix'], $data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport']);
d6e8d8
			}
d6e8d8
d6e8d8
			$template->assign_block_vars('checks', array(
d6e8d8
				'S_LEGEND'			=> true,
d6e8d8
				'LEGEND'			=> $lang['DB_CONNECTION'],
d6e8d8
				'LEGEND_EXPLAIN'	=> false,
d6e8d8
			));
d6e8d8
d6e8d8
			if ($connect_test)
d6e8d8
			{
d6e8d8
				$template->assign_block_vars('checks', array(
d6e8d8
					'TITLE'		=> $lang['DB_TEST'],
d6e8d8
					'RESULT'	=> '' . $lang['SUCCESSFUL_CONNECT'] . '',
d6e8d8
d6e8d8
					'S_EXPLAIN'	=> false,
d6e8d8
					'S_LEGEND'	=> false,
d6e8d8
				));
d6e8d8
			}
d6e8d8
			else
d6e8d8
			{
d6e8d8
				$template->assign_block_vars('checks', array(
d6e8d8
					'TITLE'		=> $lang['DB_TEST'],
d6e8d8
					'RESULT'	=> '' . implode('
', $error) . '
',
d6e8d8
d6e8d8
					'S_EXPLAIN'	=> false,
d6e8d8
					'S_LEGEND'	=> false,
d6e8d8
				));
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		if (!$connect_test)
d6e8d8
		{
d6e8d8
			// Update the list of available DBMS modules to only contain those which can be used
d6e8d8
			$available_dbms_temp = array();
d6e8d8
			foreach ($available_dbms as $type => $dbms_ary)
d6e8d8
			{
d6e8d8
				if (!$dbms_ary['AVAILABLE'])
d6e8d8
				{
d6e8d8
					continue;
d6e8d8
				}
d6e8d8
d6e8d8
				$available_dbms_temp[$type] = $dbms_ary;
d6e8d8
			}
d6e8d8
d6e8d8
			$available_dbms = &$available_dbms_temp;
d6e8d8
d6e8d8
			// And now for the main part of this page
d6e8d8
			$data['table_prefix'] = (!empty($data['table_prefix']) ? $data['table_prefix'] : 'phpbb_');
d6e8d8
d6e8d8
			foreach ($this->db_config_options as $config_key => $vars)
d6e8d8
			{
d6e8d8
				if (!is_array($vars) && strpos($config_key, 'legend') === false)
d6e8d8
				{
d6e8d8
					continue;
d6e8d8
				}
d6e8d8
d6e8d8
				if (strpos($config_key, 'legend') !== false)
d6e8d8
				{
d6e8d8
					$template->assign_block_vars('options', array(
d6e8d8
						'S_LEGEND'		=> true,
d6e8d8
						'LEGEND'		=> $lang[$vars])
d6e8d8
					);
d6e8d8
d6e8d8
					continue;
d6e8d8
				}
d6e8d8
d6e8d8
				$options = isset($vars['options']) ? $vars['options'] : '';
d6e8d8
d6e8d8
				$template->assign_block_vars('options', array(
d6e8d8
					'KEY'			=> $config_key,
d6e8d8
					'TITLE'			=> $lang[$vars['lang']],
d6e8d8
					'S_EXPLAIN'		=> $vars['explain'],
d6e8d8
					'S_LEGEND'		=> false,
d6e8d8
					'TITLE_EXPLAIN'	=> ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '',
d6e8d8
					'CONTENT'		=> $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options),
d6e8d8
					)
d6e8d8
				);
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		// And finally where do we want to go next (well today is taken isn't it :P)
d6e8d8
		$s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
d6e8d8
		$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
d6e8d8
		if ($connect_test)
d6e8d8
		{
d6e8d8
			foreach ($this->db_config_options as $config_key => $vars)
d6e8d8
			{
d6e8d8
				if (!is_array($vars))
d6e8d8
				{
d6e8d8
					continue;
d6e8d8
				}
d6e8d8
				$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		$url = ($connect_test) ? $this->p_master->module_url . "?mode=$mode&sub=administrator" : $this->p_master->module_url . "?mode=$mode&sub=database";
d6e8d8
		$s_hidden_fields .= ($connect_test) ? '' : '<input type="hidden" name="testdb" value="true" />';
d6e8d8
d6e8d8
		$submit = $lang['NEXT_STEP'];
d6e8d8
d6e8d8
		$template->assign_vars(array(
d6e8d8
			'L_SUBMIT'	=> $submit,
d6e8d8
			'S_HIDDEN'	=> $s_hidden_fields,
d6e8d8
			'U_ACTION'	=> $url,
d6e8d8
		));
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Obtain the administrator's name, password and email address
d6e8d8
	*/
d6e8d8
	function obtain_admin_settings($mode, $sub)
d6e8d8
	{
d6e8d8
		global $lang, $template, $phpEx;
d6e8d8
d6e8d8
		$this->page_title = $lang['STAGE_ADMINISTRATOR'];
d6e8d8
d6e8d8
		// Obtain any submitted data
d6e8d8
		$data = $this->get_submitted_data();
d6e8d8
d6e8d8
		if ($data['dbms'] == '')
d6e8d8
		{
d6e8d8
			// Someone's been silly and tried calling this page direct
d6e8d8
			// So we send them back to the start to do it again properly
d6e8d8
			$this->p_master->redirect("index.$phpEx?mode=install");
d6e8d8
		}
d6e8d8
d6e8d8
		$s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
d6e8d8
		$passed = false;
d6e8d8
d6e8d8
		$data['default_lang'] = ($data['default_lang'] !== '') ? $data['default_lang'] : $data['language'];
d6e8d8
d6e8d8
		if (isset($_POST['check']))
d6e8d8
		{
d6e8d8
			$error = array();
d6e8d8
d6e8d8
			// Check the entered email address and password
d6e8d8
			if ($data['admin_name'] == '' || $data['admin_pass1'] == '' || $data['admin_pass2'] == '' || $data['board_email1'] == '' || $data['board_email2'] == '')
d6e8d8
			{
d6e8d8
				$error[] = $lang['INST_ERR_MISSING_DATA'];
d6e8d8
			}
d6e8d8
d6e8d8
			if ($data['admin_pass1'] != $data['admin_pass2'] && $data['admin_pass1'] != '')
d6e8d8
			{
d6e8d8
				$error[] = $lang['INST_ERR_PASSWORD_MISMATCH'];
d6e8d8
			}
d6e8d8
d6e8d8
			// Test against the default username rules
d6e8d8
			if ($data['admin_name'] != '' && utf8_strlen($data['admin_name']) < 3)
d6e8d8
			{
d6e8d8
				$error[] = $lang['INST_ERR_USER_TOO_SHORT'];
d6e8d8
			}
d6e8d8
d6e8d8
			if ($data['admin_name'] != '' && utf8_strlen($data['admin_name']) > 20)
d6e8d8
			{
d6e8d8
				$error[] = $lang['INST_ERR_USER_TOO_LONG'];
d6e8d8
			}
d6e8d8
d6e8d8
			// Test against the default password rules
d6e8d8
			if ($data['admin_pass1'] != '' && utf8_strlen($data['admin_pass1']) < 6)
d6e8d8
			{
d6e8d8
				$error[] = $lang['INST_ERR_PASSWORD_TOO_SHORT'];
d6e8d8
			}
d6e8d8
d6e8d8
			if ($data['admin_pass1'] != '' && utf8_strlen($data['admin_pass1']) > 30)
d6e8d8
			{
d6e8d8
				$error[] = $lang['INST_ERR_PASSWORD_TOO_LONG'];
d6e8d8
			}
d6e8d8
d6e8d8
			if ($data['board_email1'] != $data['board_email2'] && $data['board_email1'] != '')
d6e8d8
			{
d6e8d8
				$error[] = $lang['INST_ERR_EMAIL_MISMATCH'];
d6e8d8
			}
d6e8d8
d6e8d8
			if ($data['board_email1'] != '' && !preg_match('/^' . get_preg_expression('email') . '$/i', $data['board_email1']))
d6e8d8
			{
d6e8d8
				$error[] = $lang['INST_ERR_EMAIL_INVALID'];
d6e8d8
			}
d6e8d8
d6e8d8
			$template->assign_block_vars('checks', array(
d6e8d8
				'S_LEGEND'			=> true,
d6e8d8
				'LEGEND'			=> $lang['STAGE_ADMINISTRATOR'],
d6e8d8
				'LEGEND_EXPLAIN'	=> false,
d6e8d8
			));
d6e8d8
d6e8d8
			if (!sizeof($error))
d6e8d8
			{
d6e8d8
				$passed = true;
d6e8d8
				$template->assign_block_vars('checks', array(
d6e8d8
					'TITLE'		=> $lang['ADMIN_TEST'],
d6e8d8
					'RESULT'	=> '' . $lang['TESTS_PASSED'] . '',
d6e8d8
d6e8d8
					'S_EXPLAIN'	=> false,
d6e8d8
					'S_LEGEND'	=> false,
d6e8d8
				));
d6e8d8
			}
d6e8d8
			else
d6e8d8
			{
d6e8d8
				$template->assign_block_vars('checks', array(
d6e8d8
					'TITLE'		=> $lang['ADMIN_TEST'],
d6e8d8
					'RESULT'	=> '' . implode('
', $error) . '
',
d6e8d8
d6e8d8
					'S_EXPLAIN'	=> false,
d6e8d8
					'S_LEGEND'	=> false,
d6e8d8
				));
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		if (!$passed)
d6e8d8
		{
d6e8d8
			foreach ($this->admin_config_options as $config_key => $vars)
d6e8d8
			{
d6e8d8
				if (!is_array($vars) && strpos($config_key, 'legend') === false)
d6e8d8
				{
d6e8d8
					continue;
d6e8d8
				}
d6e8d8
d6e8d8
				if (strpos($config_key, 'legend') !== false)
d6e8d8
				{
d6e8d8
					$template->assign_block_vars('options', array(
d6e8d8
						'S_LEGEND'		=> true,
d6e8d8
						'LEGEND'		=> $lang[$vars])
d6e8d8
					);
d6e8d8
d6e8d8
					continue;
d6e8d8
				}
d6e8d8
d6e8d8
				$options = isset($vars['options']) ? $vars['options'] : '';
d6e8d8
d6e8d8
				$template->assign_block_vars('options', array(
d6e8d8
					'KEY'			=> $config_key,
d6e8d8
					'TITLE'			=> $lang[$vars['lang']],
d6e8d8
					'S_EXPLAIN'		=> $vars['explain'],
d6e8d8
					'S_LEGEND'		=> false,
d6e8d8
					'TITLE_EXPLAIN'	=> ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '',
d6e8d8
					'CONTENT'		=> $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options),
d6e8d8
					)
d6e8d8
				);
d6e8d8
			}
d6e8d8
		}
d6e8d8
		else
d6e8d8
		{
d6e8d8
			foreach ($this->admin_config_options as $config_key => $vars)
d6e8d8
			{
d6e8d8
				if (!is_array($vars))
d6e8d8
				{
d6e8d8
					continue;
d6e8d8
				}
d6e8d8
				$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		$s_hidden_fields .= ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
d6e8d8
		$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
d6e8d8
d6e8d8
		foreach ($this->db_config_options as $config_key => $vars)
d6e8d8
		{
d6e8d8
			if (!is_array($vars))
d6e8d8
			{
d6e8d8
				continue;
d6e8d8
			}
d6e8d8
			$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
d6e8d8
		}
d6e8d8
d6e8d8
		$submit = $lang['NEXT_STEP'];
d6e8d8
d6e8d8
		$url = ($passed) ? $this->p_master->module_url . "?mode=$mode&sub=config_file" : $this->p_master->module_url . "?mode=$mode&sub=administrator";
d6e8d8
		$s_hidden_fields .= ($passed) ? '' : '<input type="hidden" name="check" value="true" />';
d6e8d8
d6e8d8
		$template->assign_vars(array(
d6e8d8
			'L_SUBMIT'	=> $submit,
d6e8d8
			'S_HIDDEN'	=> $s_hidden_fields,
d6e8d8
			'U_ACTION'	=> $url,
d6e8d8
		));
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Writes the config file to disk, or if unable to do so offers alternative methods
d6e8d8
	*/
d6e8d8
	function create_config_file($mode, $sub)
d6e8d8
	{
d6e8d8
		global $lang, $template, $phpbb_root_path, $phpEx;
d6e8d8
d6e8d8
		$this->page_title = $lang['STAGE_CONFIG_FILE'];
d6e8d8
d6e8d8
		// Obtain any submitted data
d6e8d8
		$data = $this->get_submitted_data();
d6e8d8
d6e8d8
		if ($data['dbms'] == '')
d6e8d8
		{
d6e8d8
			// Someone's been silly and tried calling this page direct
d6e8d8
			// So we send them back to the start to do it again properly
d6e8d8
			$this->p_master->redirect("index.$phpEx?mode=install");
d6e8d8
		}
d6e8d8
d6e8d8
		$s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
d6e8d8
		$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
d6e8d8
		$written = false;
d6e8d8
d6e8d8
		// Create a list of any PHP modules we wish to have loaded
d6e8d8
		$load_extensions = array();
d6e8d8
		$available_dbms = get_available_dbms($data['dbms']);
d6e8d8
		$check_exts = array_merge(array($available_dbms[$data['dbms']]['MODULE']), $this->php_dlls_other);
d6e8d8
d6e8d8
		foreach ($check_exts as $dll)
d6e8d8
		{
d6e8d8
			if (!@extension_loaded($dll))
d6e8d8
			{
d6e8d8
				if (!can_load_dll($dll))
d6e8d8
				{
d6e8d8
					continue;
d6e8d8
				}
d6e8d8
d6e8d8
				$load_extensions[] = $dll . '.' . PHP_SHLIB_SUFFIX;
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		// Create a lock file to indicate that there is an install in progress
d6e8d8
		$fp = @fopen($phpbb_root_path . 'cache/install_lock', 'wb');
d6e8d8
		if ($fp === false)
d6e8d8
		{
d6e8d8
			// We were unable to create the lock file - abort
d6e8d8
			$this->p_master->error($lang['UNABLE_WRITE_LOCK'], __LINE__, __FILE__);
d6e8d8
		}
d6e8d8
		@fclose($fp);
d6e8d8
d6e8d8
		@chmod($phpbb_root_path . 'cache/install_lock', 0777);
d6e8d8
d6e8d8
		$load_extensions = implode(',', $load_extensions);
d6e8d8
d6e8d8
		// Time to convert the data provided into a config file
d6e8d8
		$config_data = "
d6e8d8
		$config_data .= "// phpBB 3.0.x auto-generated configuration file\n// Do not change anything in this file!\n";
d6e8d8
d6e8d8
		$config_data_array = array(
d6e8d8
			'dbms'			=> $available_dbms[$data['dbms']]['DRIVER'],
d6e8d8
			'dbhost'		=> $data['dbhost'],
d6e8d8
			'dbport'		=> $data['dbport'],
d6e8d8
			'dbname'		=> $data['dbname'],
d6e8d8
			'dbuser'		=> $data['dbuser'],
d6e8d8
			'dbpasswd'		=> htmlspecialchars_decode($data['dbpasswd']),
d6e8d8
			'table_prefix'	=> $data['table_prefix'],
d6e8d8
			'acm_type'		=> 'file',
d6e8d8
			'load_extensions'	=> $load_extensions,
d6e8d8
		);
d6e8d8
d6e8d8
		foreach ($config_data_array as $key => $value)
d6e8d8
		{
d6e8d8
			$config_data .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n";
d6e8d8
		}
d6e8d8
		unset($config_data_array);
d6e8d8
d6e8d8
		$config_data .= "\n@define('PHPBB_INSTALLED', true);\n";
d6e8d8
		$config_data .= "// @define('DEBUG', true);\n";
d6e8d8
		$config_data .= "// @define('DEBUG_EXTRA', true);\n";
d6e8d8
		$config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused!
d6e8d8
d6e8d8
		// Attempt to write out the config file directly. If it works, this is the easiest way to do it ...
d6e8d8
		if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && is_writable($phpbb_root_path . 'config.' . $phpEx)) || is_writable($phpbb_root_path))
d6e8d8
		{
d6e8d8
			// Assume it will work ... if nothing goes wrong below
d6e8d8
			$written = true;
d6e8d8
d6e8d8
			if (!($fp = @fopen($phpbb_root_path . 'config.' . $phpEx, 'w')))
d6e8d8
			{
d6e8d8
				// Something went wrong ... so let's try another method
d6e8d8
				$written = false;
d6e8d8
			}
d6e8d8
d6e8d8
			if (!(@fwrite($fp, $config_data)))
d6e8d8
			{
d6e8d8
				// Something went wrong ... so let's try another method
d6e8d8
				$written = false;
d6e8d8
			}
d6e8d8
d6e8d8
			@fclose($fp);
d6e8d8
d6e8d8
			if ($written)
d6e8d8
			{
d6e8d8
				// We may revert back to chmod() if we see problems with users not able to change their config.php file directly
d6e8d8
				phpbb_chmod($phpbb_root_path . 'config.' . $phpEx, CHMOD_READ);
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		if (isset($_POST['dldone']))
d6e8d8
		{
d6e8d8
			// Do a basic check to make sure that the file has been uploaded
d6e8d8
			// Note that all we check is that the file has _something_ in it
d6e8d8
			// We don't compare the contents exactly - if they can't upload
d6e8d8
			// a single file correctly, it's likely they will have other problems....
d6e8d8
			if (filesize($phpbb_root_path . 'config.' . $phpEx) > 10)
d6e8d8
			{
d6e8d8
				$written = true;
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		$config_options = array_merge($this->db_config_options, $this->admin_config_options);
d6e8d8
d6e8d8
		foreach ($config_options as $config_key => $vars)
d6e8d8
		{
d6e8d8
			if (!is_array($vars))
d6e8d8
			{
d6e8d8
				continue;
d6e8d8
			}
d6e8d8
			$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
d6e8d8
		}
d6e8d8
d6e8d8
		if (!$written)
d6e8d8
		{
d6e8d8
			// OK, so it didn't work let's try the alternatives
d6e8d8
d6e8d8
			if (isset($_POST['dlconfig']))
d6e8d8
			{
d6e8d8
				// They want a copy of the file to download, so send the relevant headers and dump out the data
d6e8d8
				header("Content-Type: text/x-delimtext; name=\"config.$phpEx\"");
d6e8d8
				header("Content-disposition: attachment; filename=config.$phpEx");
d6e8d8
				echo $config_data;
d6e8d8
				exit;
d6e8d8
			}
d6e8d8
d6e8d8
			// The option to download the config file is always available, so output it here
d6e8d8
			$template->assign_vars(array(
d6e8d8
				'BODY'					=> $lang['CONFIG_FILE_UNABLE_WRITE'],
d6e8d8
				'L_DL_CONFIG'			=> $lang['DL_CONFIG'],
d6e8d8
				'L_DL_CONFIG_EXPLAIN'	=> $lang['DL_CONFIG_EXPLAIN'],
d6e8d8
				'L_DL_DONE'				=> $lang['DONE'],
d6e8d8
				'L_DL_DOWNLOAD'			=> $lang['DL_DOWNLOAD'],
d6e8d8
				'S_HIDDEN'				=> $s_hidden_fields,
d6e8d8
				'S_SHOW_DOWNLOAD'		=> true,
d6e8d8
				'U_ACTION'				=> $this->p_master->module_url . "?mode=$mode&sub=config_file",
d6e8d8
			));
d6e8d8
			return;
d6e8d8
		}
d6e8d8
		else
d6e8d8
		{
d6e8d8
			$template->assign_vars(array(
d6e8d8
				'BODY'		=> $lang['CONFIG_FILE_WRITTEN'],
d6e8d8
				'L_SUBMIT'	=> $lang['NEXT_STEP'],
d6e8d8
				'S_HIDDEN'	=> $s_hidden_fields,
d6e8d8
				'U_ACTION'	=> $this->p_master->module_url . "?mode=$mode&sub=advanced",
d6e8d8
			));
d6e8d8
			return;
d6e8d8
		}
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Provide an opportunity to customise some advanced settings during the install
d6e8d8
	* in case it is necessary for them to be set to access later
d6e8d8
	*/
d6e8d8
	function obtain_advanced_settings($mode, $sub)
d6e8d8
	{
d6e8d8
		global $lang, $template, $phpEx;
d6e8d8
d6e8d8
		$this->page_title = $lang['STAGE_ADVANCED'];
d6e8d8
d6e8d8
		// Obtain any submitted data
d6e8d8
		$data = $this->get_submitted_data();
d6e8d8
d6e8d8
		if ($data['dbms'] == '')
d6e8d8
		{
d6e8d8
			// Someone's been silly and tried calling this page direct
d6e8d8
			// So we send them back to the start to do it again properly
d6e8d8
			$this->p_master->redirect("index.$phpEx?mode=install");
d6e8d8
		}
d6e8d8
d6e8d8
		$s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
d6e8d8
		$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
d6e8d8
d6e8d8
		// HTTP_HOST is having the correct browser url in most cases...
d6e8d8
		$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
d6e8d8
d6e8d8
		// HTTP HOST can carry a port number...
d6e8d8
		if (strpos($server_name, ':') !== false)
d6e8d8
		{
d6e8d8
			$server_name = substr($server_name, 0, strpos($server_name, ':'));
d6e8d8
		}
d6e8d8
d6e8d8
		$data['email_enable'] = ($data['email_enable'] !== '') ? $data['email_enable'] : true;
d6e8d8
		$data['server_name'] = ($data['server_name'] !== '') ? $data['server_name'] : $server_name;
d6e8d8
		$data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : ((!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'));
d6e8d8
		$data['server_protocol'] = ($data['server_protocol'] !== '') ? $data['server_protocol'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://');
d6e8d8
		$data['cookie_secure'] = ($data['cookie_secure'] !== '') ? $data['cookie_secure'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false);
d6e8d8
d6e8d8
		if ($data['script_path'] === '')
d6e8d8
		{
d6e8d8
			$name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
d6e8d8
			if (!$name)
d6e8d8
			{
d6e8d8
				$name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
d6e8d8
			}
d6e8d8
d6e8d8
			// Replace backslashes and doubled slashes (could happen on some proxy setups)
d6e8d8
			$name = str_replace(array('\\', '//', '/install'), '/', $name);
d6e8d8
			$data['script_path'] = trim(dirname($name));
d6e8d8
		}
d6e8d8
d6e8d8
		foreach ($this->advanced_config_options as $config_key => $vars)
d6e8d8
		{
d6e8d8
			if (!is_array($vars) && strpos($config_key, 'legend') === false)
d6e8d8
			{
d6e8d8
				continue;
d6e8d8
			}
d6e8d8
d6e8d8
			if (strpos($config_key, 'legend') !== false)
d6e8d8
			{
d6e8d8
				$template->assign_block_vars('options', array(
d6e8d8
					'S_LEGEND'		=> true,
d6e8d8
					'LEGEND'		=> $lang[$vars])
d6e8d8
				);
d6e8d8
d6e8d8
				continue;
d6e8d8
			}
d6e8d8
d6e8d8
			$options = isset($vars['options']) ? $vars['options'] : '';
d6e8d8
d6e8d8
			$template->assign_block_vars('options', array(
d6e8d8
				'KEY'			=> $config_key,
d6e8d8
				'TITLE'			=> $lang[$vars['lang']],
d6e8d8
				'S_EXPLAIN'		=> $vars['explain'],
d6e8d8
				'S_LEGEND'		=> false,
d6e8d8
				'TITLE_EXPLAIN'	=> ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '',
d6e8d8
				'CONTENT'		=> $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options),
d6e8d8
				)
d6e8d8
			);
d6e8d8
		}
d6e8d8
d6e8d8
		$config_options = array_merge($this->db_config_options, $this->admin_config_options);
d6e8d8
		foreach ($config_options as $config_key => $vars)
d6e8d8
		{
d6e8d8
			if (!is_array($vars))
d6e8d8
			{
d6e8d8
				continue;
d6e8d8
			}
d6e8d8
			$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
d6e8d8
		}
d6e8d8
d6e8d8
		$submit = $lang['NEXT_STEP'];
d6e8d8
d6e8d8
		$url = $this->p_master->module_url . "?mode=$mode&sub=create_table";
d6e8d8
d6e8d8
		$template->assign_vars(array(
d6e8d8
			'BODY'		=> $lang['STAGE_ADVANCED_EXPLAIN'],
d6e8d8
			'L_SUBMIT'	=> $submit,
d6e8d8
			'S_HIDDEN'	=> $s_hidden_fields,
d6e8d8
			'U_ACTION'	=> $url,
d6e8d8
		));
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Load the contents of the schema into the database and then alter it based on what has been input during the installation
d6e8d8
	*/
d6e8d8
	function load_schema($mode, $sub)
d6e8d8
	{
d6e8d8
		global $db, $lang, $template, $phpbb_root_path, $phpEx;
d6e8d8
d6e8d8
		$this->page_title = $lang['STAGE_CREATE_TABLE'];
d6e8d8
		$s_hidden_fields = '';
d6e8d8
d6e8d8
		// Obtain any submitted data
d6e8d8
		$data = $this->get_submitted_data();
d6e8d8
d6e8d8
		if ($data['dbms'] == '')
d6e8d8
		{
d6e8d8
			// Someone's been silly and tried calling this page direct
d6e8d8
			// So we send them back to the start to do it again properly
d6e8d8
			$this->p_master->redirect("index.$phpEx?mode=install");
d6e8d8
		}
d6e8d8
d6e8d8
		// HTTP_HOST is having the correct browser url in most cases...
d6e8d8
		$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
d6e8d8
		$referer = (!empty($_SERVER['HTTP_REFERER'])) ? strtolower($_SERVER['HTTP_REFERER']) : getenv('HTTP_REFERER');
d6e8d8
d6e8d8
		// HTTP HOST can carry a port number...
d6e8d8
		if (strpos($server_name, ':') !== false)
d6e8d8
		{
d6e8d8
			$server_name = substr($server_name, 0, strpos($server_name, ':'));
d6e8d8
		}
d6e8d8
d6e8d8
		$cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : $server_name;
d6e8d8
d6e8d8
		// Try to come up with the best solution for cookie domain...
d6e8d8
		if (strpos($cookie_domain, 'www.') === 0)
d6e8d8
		{
d6e8d8
			$cookie_domain = str_replace('www.', '.', $cookie_domain);
d6e8d8
		}
d6e8d8
d6e8d8
		// If we get here and the extension isn't loaded it should be safe to just go ahead and load it
d6e8d8
		$available_dbms = get_available_dbms($data['dbms']);
d6e8d8
d6e8d8
		if (!isset($available_dbms[$data['dbms']]))
d6e8d8
		{
d6e8d8
			// Someone's been silly and tried providing a non-existant dbms
d6e8d8
			$this->p_master->redirect("index.$phpEx?mode=install");
d6e8d8
		}
d6e8d8
d6e8d8
		$dbms = $available_dbms[$data['dbms']]['DRIVER'];
d6e8d8
d6e8d8
		// Load the appropriate database class if not already loaded
d6e8d8
		include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
d6e8d8
d6e8d8
		// Instantiate the database
d6e8d8
		$db = new $sql_db();
d6e8d8
		$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
d6e8d8
d6e8d8
		// NOTE: trigger_error does not work here.
d6e8d8
		$db->sql_return_on_error(true);
d6e8d8
d6e8d8
		// If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;)
d6e8d8
		if ($data['dbms'] == 'mysql')
d6e8d8
		{
d6e8d8
			if (version_compare($db->sql_server_info(true), '4.1.3', '>='))
d6e8d8
			{
d6e8d8
				$available_dbms[$data['dbms']]['SCHEMA'] .= '_41';
d6e8d8
			}
d6e8d8
			else
d6e8d8
			{
d6e8d8
				$available_dbms[$data['dbms']]['SCHEMA'] .= '_40';
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		// Ok we have the db info go ahead and read in the relevant schema
d6e8d8
		// and work on building the table
d6e8d8
		$dbms_schema = 'schemas/' . $available_dbms[$data['dbms']]['SCHEMA'] . '_schema.sql';
d6e8d8
d6e8d8
		// How should we treat this schema?
d6e8d8
		$remove_remarks = $available_dbms[$data['dbms']]['COMMENTS'];
d6e8d8
		$delimiter = $available_dbms[$data['dbms']]['DELIM'];
d6e8d8
d6e8d8
		$sql_query = @file_get_contents($dbms_schema);
d6e8d8
d6e8d8
		$sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query);
d6e8d8
d6e8d8
		$remove_remarks($sql_query);
d6e8d8
d6e8d8
		$sql_query = split_sql_file($sql_query, $delimiter);
d6e8d8
d6e8d8
		foreach ($sql_query as $sql)
d6e8d8
		{
d6e8d8
			//$sql = trim(str_replace('|', ';', $sql));
d6e8d8
			if (!$db->sql_query($sql))
d6e8d8
			{
d6e8d8
				$error = $db->sql_error();
d6e8d8
				$this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
d6e8d8
			}
d6e8d8
		}
d6e8d8
		unset($sql_query);
d6e8d8
d6e8d8
		// Ok tables have been built, let's fill in the basic information
d6e8d8
		$sql_query = file_get_contents('schemas/schema_data.sql');
d6e8d8
d6e8d8
		// Deal with any special comments
d6e8d8
		switch ($data['dbms'])
d6e8d8
		{
d6e8d8
			case 'mssql':
d6e8d8
			case 'mssql_odbc':
d6e8d8
				$sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query);
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'postgres':
d6e8d8
				$sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query);
d6e8d8
			break;
d6e8d8
		}
d6e8d8
d6e8d8
		// Change prefix
d6e8d8
		$sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query);
d6e8d8
d6e8d8
		// Change language strings...
d6e8d8
		$sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback', $sql_query);
d6e8d8
d6e8d8
		// Since there is only one schema file we know the comment style and are able to remove it directly with remove_remarks
d6e8d8
		remove_remarks($sql_query);
d6e8d8
		$sql_query = split_sql_file($sql_query, ';');
d6e8d8
d6e8d8
		foreach ($sql_query as $sql)
d6e8d8
		{
d6e8d8
			//$sql = trim(str_replace('|', ';', $sql));
d6e8d8
			if (!$db->sql_query($sql))
d6e8d8
			{
d6e8d8
				$error = $db->sql_error();
d6e8d8
				$this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
d6e8d8
			}
d6e8d8
		}
d6e8d8
		unset($sql_query);
d6e8d8
d6e8d8
		$current_time = time();
d6e8d8
d6e8d8
		$user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
d6e8d8
d6e8d8
		if ($data['script_path'] !== '/')
d6e8d8
		{
d6e8d8
			// Adjust destination path (no trailing slash)
d6e8d8
			if (substr($data['script_path'], -1) == '/')
d6e8d8
			{
d6e8d8
				$data['script_path'] = substr($data['script_path'], 0, -1);
d6e8d8
			}
d6e8d8
d6e8d8
			$data['script_path'] = str_replace(array('../', './'), '', $data['script_path']);
d6e8d8
d6e8d8
			if ($data['script_path'][0] != '/')
d6e8d8
			{
d6e8d8
				$data['script_path'] = '/' . $data['script_path'];
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		// Set default config and post data, this applies to all DB's
d6e8d8
		$sql_ary = array(
d6e8d8
			'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value)
d6e8d8
				VALUES ('board_startdate', '$current_time')",
d6e8d8
d6e8d8
			'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value)
d6e8d8
				VALUES ('default_lang', '" . $db->sql_escape($data['default_lang']) . "')",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['img_imagick']) . "'
d6e8d8
				WHERE config_name = 'img_imagick'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['server_name']) . "'
d6e8d8
				WHERE config_name = 'server_name'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['server_port']) . "'
d6e8d8
				WHERE config_name = 'server_port'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['board_email1']) . "'
d6e8d8
				WHERE config_name = 'board_email'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['board_email1']) . "'
d6e8d8
				WHERE config_name = 'board_contact'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($cookie_domain) . "'
d6e8d8
				WHERE config_name = 'cookie_domain'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($lang['default_dateformat']) . "'
d6e8d8
				WHERE config_name = 'default_dateformat'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['email_enable']) . "'
d6e8d8
				WHERE config_name = 'email_enable'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['smtp_delivery']) . "'
d6e8d8
				WHERE config_name = 'smtp_delivery'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['smtp_host']) . "'
d6e8d8
				WHERE config_name = 'smtp_host'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['smtp_auth']) . "'
d6e8d8
				WHERE config_name = 'smtp_auth_method'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['smtp_user']) . "'
d6e8d8
				WHERE config_name = 'smtp_username'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['smtp_pass']) . "'
d6e8d8
				WHERE config_name = 'smtp_password'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['cookie_secure']) . "'
d6e8d8
				WHERE config_name = 'cookie_secure'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['force_server_vars']) . "'
d6e8d8
				WHERE config_name = 'force_server_vars'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['script_path']) . "'
d6e8d8
				WHERE config_name = 'script_path'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['server_protocol']) . "'
d6e8d8
				WHERE config_name = 'server_protocol'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($data['admin_name']) . "'
d6e8d8
				WHERE config_name = 'newest_username'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . md5(mt_rand()) . "'
d6e8d8
				WHERE config_name = 'avatar_salt'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "users
d6e8d8
				SET username = '" . $db->sql_escape($data['admin_name']) . "', user_password='" . $db->sql_escape(md5($data['admin_pass1'])) . "', user_ip = '" . $db->sql_escape($user_ip) . "', user_lang = '" . $db->sql_escape($data['default_lang']) . "', user_email='" . $db->sql_escape($data['board_email1']) . "', user_dateformat='" . $db->sql_escape($lang['default_dateformat']) . "', user_email_hash = " . (crc32($data['board_email1']) . strlen($data['board_email1'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($data['admin_name'])) . "'
d6e8d8
				WHERE username = 'Admin'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "moderator_cache
d6e8d8
				SET username = '" . $db->sql_escape($data['admin_name']) . "'
d6e8d8
				WHERE username = 'Admin'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "forums
d6e8d8
				SET forum_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "'
d6e8d8
				WHERE forum_last_poster_name = 'Admin'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "topics
d6e8d8
				SET topic_first_poster_name = '" . $db->sql_escape($data['admin_name']) . "', topic_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "'
d6e8d8
				WHERE topic_first_poster_name = 'Admin'
d6e8d8
					OR topic_last_poster_name = 'Admin'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "users
d6e8d8
				SET user_regdate = $current_time",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "posts
d6e8d8
				SET post_time = $current_time, poster_ip = '" . $db->sql_escape($user_ip) . "'",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "topics
d6e8d8
				SET topic_time = $current_time, topic_last_post_time = $current_time",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "forums
d6e8d8
				SET forum_last_post_time = $current_time",
d6e8d8
d6e8d8
			'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '" . $db->sql_escape($db->sql_server_info(true)) . "'
d6e8d8
				WHERE config_name = 'dbms_version'",
d6e8d8
		);
d6e8d8
d6e8d8
		if (@extension_loaded('gd') || can_load_dll('gd'))
d6e8d8
		{
d6e8d8
			$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '1'
d6e8d8
				WHERE config_name = 'captcha_gd'";
d6e8d8
		}
d6e8d8
d6e8d8
		$ref = substr($referer, strpos($referer, '://') + 3);
d6e8d8
d6e8d8
		if (!(stripos($ref, $server_name) === 0))
d6e8d8
		{
d6e8d8
			$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
				SET config_value = '0'
d6e8d8
				WHERE config_name = 'referer_validation'";
d6e8d8
		}
d6e8d8
d6e8d8
		// We set a (semi-)unique cookie name to bypass login issues related to the cookie name.
d6e8d8
		$cookie_name = 'phpbb3_';
d6e8d8
		$rand_str = md5(mt_rand());
d6e8d8
		$rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35));
d6e8d8
		$rand_str = substr($rand_str, 0, 5);
d6e8d8
		$cookie_name .= strtolower($rand_str);
d6e8d8
d6e8d8
		$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
d6e8d8
			SET config_value = '" . $db->sql_escape($cookie_name) . "'
d6e8d8
			WHERE config_name = 'cookie_name'";
d6e8d8
d6e8d8
		foreach ($sql_ary as $sql)
d6e8d8
		{
d6e8d8
			//$sql = trim(str_replace('|', ';', $sql));
d6e8d8
d6e8d8
			if (!$db->sql_query($sql))
d6e8d8
			{
d6e8d8
				$error = $db->sql_error();
d6e8d8
				$this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
d6e8d8
			}
d6e8d8
		}
d6e8d8
d6e8d8
		$submit = $lang['NEXT_STEP'];
d6e8d8
d6e8d8
		$url = $this->p_master->module_url . "?mode=$mode&sub=final";
d6e8d8
d6e8d8
		$template->assign_vars(array(
d6e8d8
			'BODY'		=> $lang['STAGE_CREATE_TABLE_EXPLAIN'],
d6e8d8
			'L_SUBMIT'	=> $submit,
d6e8d8
			'S_HIDDEN'	=> build_hidden_fields($data),
d6e8d8
			'U_ACTION'	=> $url,
d6e8d8
		));
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Build the search index...
d6e8d8
	*/
d6e8d8
	function build_search_index($mode, $sub)
d6e8d8
	{
d6e8d8
		global $db, $lang, $phpbb_root_path, $phpEx, $config;
d6e8d8
d6e8d8
		// Obtain any submitted data
d6e8d8
		$data = $this->get_submitted_data();
d6e8d8
		$table_prefix = $data['table_prefix'];
d6e8d8
d6e8d8
		// If we get here and the extension isn't loaded it should be safe to just go ahead and load it
d6e8d8
		$available_dbms = get_available_dbms($data['dbms']);
d6e8d8
d6e8d8
		if (!isset($available_dbms[$data['dbms']]))
d6e8d8
		{
d6e8d8
			// Someone's been silly and tried providing a non-existant dbms
d6e8d8
			$this->p_master->redirect("index.$phpEx?mode=install");
d6e8d8
		}
d6e8d8
d6e8d8
		$dbms = $available_dbms[$data['dbms']]['DRIVER'];
d6e8d8
d6e8d8
		// Load the appropriate database class if not already loaded
d6e8d8
		include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
d6e8d8
d6e8d8
		// Instantiate the database
d6e8d8
		$db = new $sql_db();
d6e8d8
		$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
d6e8d8
d6e8d8
		// NOTE: trigger_error does not work here.
d6e8d8
		$db->sql_return_on_error(true);
d6e8d8
d6e8d8
		include_once($phpbb_root_path . 'includes/constants.' . $phpEx);
d6e8d8
		include_once($phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx);
d6e8d8
d6e8d8
		// Fill the config array - it is needed by those functions we call
d6e8d8
		$sql = 'SELECT *
d6e8d8
			FROM ' . CONFIG_TABLE;
d6e8d8
		$result = $db->sql_query($sql);
d6e8d8
d6e8d8
		$config = array();
d6e8d8
		while ($row = $db->sql_fetchrow($result))
d6e8d8
		{
d6e8d8
			$config[$row['config_name']] = $row['config_value'];
d6e8d8
		}
d6e8d8
		$db->sql_freeresult($result);
d6e8d8
d6e8d8
		$error = false;
d6e8d8
		$search = new fulltext_native($error);
d6e8d8
d6e8d8
		$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
d6e8d8
			FROM ' . POSTS_TABLE;
d6e8d8
		$result = $db->sql_query($sql);
d6e8d8
d6e8d8
		while ($row = $db->sql_fetchrow($result))
d6e8d8
		{
d6e8d8
			$search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
d6e8d8
		}
d6e8d8
		$db->sql_freeresult($result);
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Populate the module tables
d6e8d8
	*/
d6e8d8
	function add_modules($mode, $sub)
d6e8d8
	{
d6e8d8
		global $db, $lang, $phpbb_root_path, $phpEx;
d6e8d8
d6e8d8
		include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
d6e8d8
d6e8d8
		$_module = new acp_modules();
d6e8d8
		$module_classes = array('acp', 'mcp', 'ucp');
d6e8d8
d6e8d8
		// Add categories
d6e8d8
		foreach ($module_classes as $module_class)
d6e8d8
		{
d6e8d8
			$categories = array();
d6e8d8
d6e8d8
			// Set the module class
d6e8d8
			$_module->module_class = $module_class;
d6e8d8
d6e8d8
			foreach ($this->module_categories[$module_class] as $cat_name => $subs)
d6e8d8
			{
d6e8d8
				$module_data = array(
d6e8d8
					'module_basename'	=> '',
d6e8d8
					'module_enabled'	=> 1,
d6e8d8
					'module_display'	=> 1,
d6e8d8
					'parent_id'			=> 0,
d6e8d8
					'module_class'		=> $module_class,
d6e8d8
					'module_langname'	=> $cat_name,
d6e8d8
					'module_mode'		=> '',
d6e8d8
					'module_auth'		=> '',
d6e8d8
				);
d6e8d8
d6e8d8
				// Add category
d6e8d8
				$_module->update_module_data($module_data, true);
d6e8d8
d6e8d8
				// Check for last sql error happened
d6e8d8
				if ($db->sql_error_triggered)
d6e8d8
				{
d6e8d8
					$error = $db->sql_error($db->sql_error_sql);
d6e8d8
					$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
d6e8d8
				}
d6e8d8
d6e8d8
				$categories[$cat_name]['id'] = (int) $module_data['module_id'];
d6e8d8
				$categories[$cat_name]['parent_id'] = 0;
d6e8d8
d6e8d8
				// Create sub-categories...
d6e8d8
				if (is_array($subs))
d6e8d8
				{
d6e8d8
					foreach ($subs as $level2_name)
d6e8d8
					{
d6e8d8
						$module_data = array(
d6e8d8
							'module_basename'	=> '',
d6e8d8
							'module_enabled'	=> 1,
d6e8d8
							'module_display'	=> 1,
d6e8d8
							'parent_id'			=> (int) $categories[$cat_name]['id'],
d6e8d8
							'module_class'		=> $module_class,
d6e8d8
							'module_langname'	=> $level2_name,
d6e8d8
							'module_mode'		=> '',
d6e8d8
							'module_auth'		=> '',
d6e8d8
						);
d6e8d8
d6e8d8
						$_module->update_module_data($module_data, true);
d6e8d8
d6e8d8
						// Check for last sql error happened
d6e8d8
						if ($db->sql_error_triggered)
d6e8d8
						{
d6e8d8
							$error = $db->sql_error($db->sql_error_sql);
d6e8d8
							$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
d6e8d8
						}
d6e8d8
d6e8d8
						$categories[$level2_name]['id'] = (int) $module_data['module_id'];
d6e8d8
						$categories[$level2_name]['parent_id'] = (int) $categories[$cat_name]['id'];
d6e8d8
					}
d6e8d8
				}
d6e8d8
			}
d6e8d8
d6e8d8
			// Get the modules we want to add... returned sorted by name
d6e8d8
			$module_info = $_module->get_module_infos('', $module_class);
d6e8d8
d6e8d8
			foreach ($module_info as $module_basename => $fileinfo)
d6e8d8
			{
d6e8d8
				foreach ($fileinfo['modes'] as $module_mode => $row)
d6e8d8
				{
d6e8d8
					foreach ($row['cat'] as $cat_name)
d6e8d8
					{
d6e8d8
						if (!isset($categories[$cat_name]))
d6e8d8
						{
d6e8d8
							continue;
d6e8d8
						}
d6e8d8
d6e8d8
						$module_data = array(
d6e8d8
							'module_basename'	=> $module_basename,
d6e8d8
							'module_enabled'	=> 1,
d6e8d8
							'module_display'	=> (isset($row['display'])) ? (int) $row['display'] : 1,
d6e8d8
							'parent_id'			=> (int) $categories[$cat_name]['id'],
d6e8d8
							'module_class'		=> $module_class,
d6e8d8
							'module_langname'	=> $row['title'],
d6e8d8
							'module_mode'		=> $module_mode,
d6e8d8
							'module_auth'		=> $row['auth'],
d6e8d8
						);
d6e8d8
d6e8d8
						$_module->update_module_data($module_data, true);
d6e8d8
d6e8d8
						// Check for last sql error happened
d6e8d8
						if ($db->sql_error_triggered)
d6e8d8
						{
d6e8d8
							$error = $db->sql_error($db->sql_error_sql);
d6e8d8
							$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
d6e8d8
						}
d6e8d8
					}
d6e8d8
				}
d6e8d8
			}
d6e8d8
d6e8d8
			// Move some of the modules around since the code above will put them in the wrong place
d6e8d8
			if ($module_class == 'acp')
d6e8d8
			{
d6e8d8
				// Move main module 4 up...
d6e8d8
				$sql = 'SELECT *
d6e8d8
					FROM ' . MODULES_TABLE . "
d6e8d8
					WHERE module_basename = 'main'
d6e8d8
						AND module_class = 'acp'
d6e8d8
						AND module_mode = 'main'";
d6e8d8
				$result = $db->sql_query($sql);
d6e8d8
				$row = $db->sql_fetchrow($result);
d6e8d8
				$db->sql_freeresult($result);
d6e8d8
d6e8d8
				$_module->move_module_by($row, 'move_up', 4);
d6e8d8
d6e8d8
				// Move permissions intro screen module 4 up...
d6e8d8
				$sql = 'SELECT *
d6e8d8
					FROM ' . MODULES_TABLE . "
d6e8d8
					WHERE module_basename = 'permissions'
d6e8d8
						AND module_class = 'acp'
d6e8d8
						AND module_mode = 'intro'";
d6e8d8
				$result = $db->sql_query($sql);
d6e8d8
				$row = $db->sql_fetchrow($result);
d6e8d8
				$db->sql_freeresult($result);
d6e8d8
d6e8d8
				$_module->move_module_by($row, 'move_up', 4);
d6e8d8
d6e8d8
				// Move manage users screen module 5 up...
d6e8d8
				$sql = 'SELECT *
d6e8d8
					FROM ' . MODULES_TABLE . "
d6e8d8
					WHERE module_basename = 'users'
d6e8d8
						AND module_class = 'acp'
d6e8d8
						AND module_mode = 'overview'";
d6e8d8
				$result = $db->sql_query($sql);
d6e8d8
				$row = $db->sql_fetchrow($result);
d6e8d8
				$db->sql_freeresult($result);
d6e8d8
d6e8d8
				$_module->move_module_by($row, 'move_up', 5);
d6e8d8
			}
d6e8d8
d6e8d8
			if ($module_class == 'ucp')
d6e8d8
			{
d6e8d8
				// Move attachment module 4 down...
d6e8d8
				$sql = 'SELECT *
d6e8d8
					FROM ' . MODULES_TABLE . "
d6e8d8
					WHERE module_basename = 'attachments'
d6e8d8
						AND module_class = 'ucp'
d6e8d8
						AND module_mode = 'attachments'";
d6e8d8
				$result = $db->sql_query($sql);
d6e8d8
				$row = $db->sql_fetchrow($result);
d6e8d8
				$db->sql_freeresult($result);
d6e8d8
d6e8d8
				$_module->move_module_by($row, 'move_down', 4);
d6e8d8
			}
d6e8d8
d6e8d8
			// And now for the special ones
d6e8d8
			// (these are modules which appear in multiple categories and thus get added manually to some for more control)
d6e8d8
			if (isset($this->module_extras[$module_class]))
d6e8d8
			{
d6e8d8
				foreach ($this->module_extras[$module_class] as $cat_name => $mods)
d6e8d8
				{
d6e8d8
					$sql = 'SELECT module_id, left_id, right_id
d6e8d8
						FROM ' . MODULES_TABLE . "
d6e8d8
						WHERE module_langname = '" . $db->sql_escape($cat_name) . "'
d6e8d8
							AND module_class = '" . $db->sql_escape($module_class) . "'";
d6e8d8
					$result = $db->sql_query_limit($sql, 1);
d6e8d8
					$row2 = $db->sql_fetchrow($result);
d6e8d8
					$db->sql_freeresult($result);
d6e8d8
d6e8d8
					foreach ($mods as $mod_name)
d6e8d8
					{
d6e8d8
						$sql = 'SELECT *
d6e8d8
							FROM ' . MODULES_TABLE . "
d6e8d8
							WHERE module_langname = '" . $db->sql_escape($mod_name) . "'
d6e8d8
								AND module_class = '" . $db->sql_escape($module_class) . "'
d6e8d8
								AND module_basename <> ''";
d6e8d8
						$result = $db->sql_query_limit($sql, 1);
d6e8d8
						$row = $db->sql_fetchrow($result);
d6e8d8
						$db->sql_freeresult($result);
d6e8d8
d6e8d8
						$module_data = array(
d6e8d8
							'module_basename'	=> $row['module_basename'],
d6e8d8
							'module_enabled'	=> (int) $row['module_enabled'],
d6e8d8
							'module_display'	=> (int) $row['module_display'],
d6e8d8
							'parent_id'			=> (int) $row2['module_id'],
d6e8d8
							'module_class'		=> $row['module_class'],
d6e8d8
							'module_langname'	=> $row['module_langname'],
d6e8d8
							'module_mode'		=> $row['module_mode'],
d6e8d8
							'module_auth'		=> $row['module_auth'],
d6e8d8
						);
d6e8d8
d6e8d8
						$_module->update_module_data($module_data, true);
d6e8d8
d6e8d8
						// Check for last sql error happened
d6e8d8
						if ($db->sql_error_triggered)
d6e8d8
						{
d6e8d8
							$error = $db->sql_error($db->sql_error_sql);
d6e8d8
							$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
d6e8d8
						}
d6e8d8
					}
d6e8d8
				}
d6e8d8
			}
d6e8d8
d6e8d8
			$_module->remove_cache_file();
d6e8d8
		}
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Populate the language tables
d6e8d8
	*/
d6e8d8
	function add_language($mode, $sub)
d6e8d8
	{
d6e8d8
		global $db, $lang, $phpbb_root_path, $phpEx;
d6e8d8
d6e8d8
		$dir = @opendir($phpbb_root_path . 'language');
d6e8d8
d6e8d8
		if (!$dir)
d6e8d8
		{
d6e8d8
			$this->error('Unable to access the language directory', __LINE__, __FILE__);
d6e8d8
		}
d6e8d8
d6e8d8
		while (($file = readdir($dir)) !== false)
d6e8d8
		{
d6e8d8
			$path = $phpbb_root_path . 'language/' . $file;
d6e8d8
d6e8d8
			if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS')
d6e8d8
			{
d6e8d8
				continue;
d6e8d8
			}
d6e8d8
d6e8d8
			if (is_dir($path) && file_exists($path . '/iso.txt'))
d6e8d8
			{
d6e8d8
				$lang_file = file("$path/iso.txt");
d6e8d8
d6e8d8
				$lang_pack = array(
d6e8d8
					'lang_iso'			=> basename($path),
d6e8d8
					'lang_dir'			=> basename($path),
d6e8d8
					'lang_english_name'	=> trim(htmlspecialchars($lang_file[0])),
d6e8d8
					'lang_local_name'	=> trim(htmlspecialchars($lang_file[1], ENT_COMPAT, 'UTF-8')),
d6e8d8
					'lang_author'		=> trim(htmlspecialchars($lang_file[2], ENT_COMPAT, 'UTF-8')),
d6e8d8
				);
d6e8d8
d6e8d8
				$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $lang_pack));
d6e8d8
d6e8d8
				if ($db->sql_error_triggered)
d6e8d8
				{
d6e8d8
					$error = $db->sql_error($db->sql_error_sql);
d6e8d8
					$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
d6e8d8
				}
d6e8d8
d6e8d8
				$valid_localized = array(
d6e8d8
					'icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply',
d6e8d8
				);
d6e8d8
d6e8d8
				$sql_ary = array();
d6e8d8
d6e8d8
				$sql = 'SELECT *
d6e8d8
					FROM ' . STYLES_IMAGESET_TABLE;
d6e8d8
				$result = $db->sql_query($sql);
d6e8d8
d6e8d8
				while ($imageset_row = $db->sql_fetchrow($result))
d6e8d8
				{
d6e8d8
					if (@file_exists("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['lang_iso']}/imageset.cfg"))
d6e8d8
					{
d6e8d8
						$cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['lang_iso']}/imageset.cfg");
d6e8d8
						foreach ($cfg_data_imageset_data as $image_name => $value)
d6e8d8
						{
d6e8d8
							if (strpos($value, '*') !== false)
d6e8d8
							{
d6e8d8
								if (substr($value, -1, 1) === '*')
d6e8d8
								{
d6e8d8
									list($image_filename, $image_height) = explode('*', $value);
d6e8d8
									$image_width = 0;
d6e8d8
								}
d6e8d8
								else
d6e8d8
								{
d6e8d8
									list($image_filename, $image_height, $image_width) = explode('*', $value);
d6e8d8
								}
d6e8d8
							}
d6e8d8
							else
d6e8d8
							{
d6e8d8
								$image_filename = $value;
d6e8d8
								$image_height = $image_width = 0;
d6e8d8
							}
d6e8d8
d6e8d8
							if (strpos($image_name, 'img_') === 0 && $image_filename)
d6e8d8
							{
d6e8d8
								$image_name = substr($image_name, 4);
d6e8d8
								if (in_array($image_name, $valid_localized))
d6e8d8
								{
d6e8d8
									$sql_ary[] = array(
d6e8d8
										'image_name'		=> (string) $image_name,
d6e8d8
										'image_filename'	=> (string) $image_filename,
d6e8d8
										'image_height'		=> (int) $image_height,
d6e8d8
										'image_width'		=> (int) $image_width,
d6e8d8
										'imageset_id'		=> (int) $imageset_row['imageset_id'],
d6e8d8
										'image_lang'		=> (string) $lang_pack['lang_iso'],
d6e8d8
									);
d6e8d8
								}
d6e8d8
							}
d6e8d8
						}
d6e8d8
					}
d6e8d8
				}
d6e8d8
				$db->sql_freeresult($result);
d6e8d8
d6e8d8
				if (sizeof($sql_ary))
d6e8d8
				{
d6e8d8
					$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
d6e8d8
d6e8d8
					if ($db->sql_error_triggered)
d6e8d8
					{
d6e8d8
						$error = $db->sql_error($db->sql_error_sql);
d6e8d8
						$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
d6e8d8
					}
d6e8d8
				}
d6e8d8
			}
d6e8d8
		}
d6e8d8
		closedir($dir);
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Add search robots to the database
d6e8d8
	*/
d6e8d8
	function add_bots($mode, $sub)
d6e8d8
	{
d6e8d8
		global $db, $lang, $phpbb_root_path, $phpEx, $config;
d6e8d8
d6e8d8
		// Obtain any submitted data
d6e8d8
		$data = $this->get_submitted_data();
d6e8d8
d6e8d8
		// Fill the config array - it is needed by those functions we call
d6e8d8
		$sql = 'SELECT *
d6e8d8
			FROM ' . CONFIG_TABLE;
d6e8d8
		$result = $db->sql_query($sql);
d6e8d8
d6e8d8
		$config = array();
d6e8d8
		while ($row = $db->sql_fetchrow($result))
d6e8d8
		{
d6e8d8
			$config[$row['config_name']] = $row['config_value'];
d6e8d8
		}
d6e8d8
		$db->sql_freeresult($result);
d6e8d8
d6e8d8
		$sql = 'SELECT group_id
d6e8d8
			FROM ' . GROUPS_TABLE . "
d6e8d8
			WHERE group_name = 'BOTS'";
d6e8d8
		$result = $db->sql_query($sql);
d6e8d8
		$group_id = (int) $db->sql_fetchfield('group_id');
d6e8d8
		$db->sql_freeresult($result);
d6e8d8
d6e8d8
		if (!$group_id)
d6e8d8
		{
d6e8d8
			// If we reach this point then something has gone very wrong
d6e8d8
			$this->p_master->error($lang['NO_GROUP'], __LINE__, __FILE__);
d6e8d8
		}
d6e8d8
d6e8d8
		if (!function_exists('user_add'))
d6e8d8
		{
d6e8d8
			include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
d6e8d8
		}
d6e8d8
d6e8d8
		foreach ($this->bot_list as $bot_name => $bot_ary)
d6e8d8
		{
d6e8d8
			$user_row = array(
d6e8d8
				'user_type'				=> USER_IGNORE,
d6e8d8
				'group_id'				=> $group_id,
d6e8d8
				'username'				=> $bot_name,
d6e8d8
				'user_regdate'			=> time(),
d6e8d8
				'user_password'			=> '',
d6e8d8
				'user_colour'			=> '9E8DA7',
d6e8d8
				'user_email'			=> '',
d6e8d8
				'user_lang'				=> $data['default_lang'],
d6e8d8
				'user_style'			=> 1,
d6e8d8
				'user_timezone'			=> 0,
d6e8d8
				'user_dateformat'		=> $lang['default_dateformat'],
d6e8d8
				'user_allow_massemail'	=> 0,
d6e8d8
			);
d6e8d8
d6e8d8
			$user_id = user_add($user_row);
d6e8d8
d6e8d8
			if (!$user_id)
d6e8d8
			{
d6e8d8
				// If we can't insert this user then continue to the next one to avoid inconsistant data
d6e8d8
				$this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__, true);
d6e8d8
				continue;
d6e8d8
			}
d6e8d8
d6e8d8
			$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
d6e8d8
				'bot_active'	=> 1,
d6e8d8
				'bot_name'		=> (string) $bot_name,
d6e8d8
				'user_id'		=> (int) $user_id,
d6e8d8
				'bot_agent'		=> (string) $bot_ary[0],
d6e8d8
				'bot_ip'		=> (string) $bot_ary[1],
d6e8d8
			));
d6e8d8
d6e8d8
			$result = $db->sql_query($sql);
d6e8d8
		}
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Sends an email to the board administrator with their password and some useful links
d6e8d8
	*/
d6e8d8
	function email_admin($mode, $sub)
d6e8d8
	{
d6e8d8
		global $auth, $config, $db, $lang, $template, $user, $phpbb_root_path, $phpEx;
d6e8d8
d6e8d8
		$this->page_title = $lang['STAGE_FINAL'];
d6e8d8
d6e8d8
		// Obtain any submitted data
d6e8d8
		$data = $this->get_submitted_data();
d6e8d8
d6e8d8
		$sql = 'SELECT *
d6e8d8
			FROM ' . CONFIG_TABLE;
d6e8d8
		$result = $db->sql_query($sql);
d6e8d8
d6e8d8
		$config = array();
d6e8d8
		while ($row = $db->sql_fetchrow($result))
d6e8d8
		{
d6e8d8
			$config[$row['config_name']] = $row['config_value'];
d6e8d8
		}
d6e8d8
		$db->sql_freeresult($result);
d6e8d8
d6e8d8
		$user->session_begin();
d6e8d8
		$auth->login($data['admin_name'], $data['admin_pass1'], false, true, true);
d6e8d8
d6e8d8
		// OK, Now that we've reached this point we can be confident that everything
d6e8d8
		// is installed and working......I hope :)
d6e8d8
		// So it's time to send an email to the administrator confirming the details
d6e8d8
		// they entered
d6e8d8
d6e8d8
		if ($config['email_enable'])
d6e8d8
		{
d6e8d8
			include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
d6e8d8
d6e8d8
			$messenger = new messenger(false);
d6e8d8
d6e8d8
			$messenger->template('installed', $data['language']);
d6e8d8
d6e8d8
			$messenger->to($data['board_email1'], $data['admin_name']);
d6e8d8
d6e8d8
			$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
d6e8d8
			$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
d6e8d8
			$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
d6e8d8
			$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
d6e8d8
d6e8d8
			$messenger->assign_vars(array(
d6e8d8
				'USERNAME'		=> htmlspecialchars_decode($data['admin_name']),
d6e8d8
				'PASSWORD'		=> htmlspecialchars_decode($data['admin_pass1']))
d6e8d8
			);
d6e8d8
d6e8d8
			$messenger->send(NOTIFY_EMAIL);
d6e8d8
		}
d6e8d8
d6e8d8
		// And finally, add a note to the log
d6e8d8
		add_log('admin', 'LOG_INSTALL_INSTALLED', $config['version']);
d6e8d8
d6e8d8
		$template->assign_vars(array(
d6e8d8
			'TITLE'		=> $lang['INSTALL_CONGRATS'],
d6e8d8
			'BODY'		=> sprintf($lang['INSTALL_CONGRATS_EXPLAIN'], $config['version'], append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=convert&language=' . $data['language']), '../docs/README.html'),
d6e8d8
			'L_SUBMIT'	=> $lang['INSTALL_LOGIN'],
d6e8d8
			'U_ACTION'	=> append_sid($phpbb_root_path . 'adm/index.' . $phpEx),
d6e8d8
		));
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Generate a list of available mail server authentication methods
d6e8d8
	*/
d6e8d8
	function mail_auth_select($selected_method)
d6e8d8
	{
d6e8d8
		global $lang;
d6e8d8
d6e8d8
		$auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
d6e8d8
		$s_smtp_auth_options = '';
d6e8d8
d6e8d8
		foreach ($auth_methods as $method)
d6e8d8
		{
d6e8d8
			$s_smtp_auth_options .= '<option value="' . $method . '"' . (($selected_method == $method) ? ' selected="selected"' : '') . '>' . $lang['SMTP_' . str_replace('-', '_', $method)] . '</option>';
d6e8d8
		}
d6e8d8
d6e8d8
		return $s_smtp_auth_options;
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* Get submitted data
d6e8d8
	*/
d6e8d8
	function get_submitted_data()
d6e8d8
	{
d6e8d8
		return array(
d6e8d8
			'language'		=> basename(request_var('language', '')),
d6e8d8
			'dbms'			=> request_var('dbms', ''),
d6e8d8
			'dbhost'		=> request_var('dbhost', ''),
d6e8d8
			'dbport'		=> request_var('dbport', ''),
d6e8d8
			'dbuser'		=> request_var('dbuser', ''),
d6e8d8
			'dbpasswd'		=> request_var('dbpasswd', '', true),
d6e8d8
			'dbname'		=> request_var('dbname', ''),
d6e8d8
			'table_prefix'	=> request_var('table_prefix', ''),
d6e8d8
			'default_lang'	=> basename(request_var('default_lang', '')),
d6e8d8
			'admin_name'	=> utf8_normalize_nfc(request_var('admin_name', '', true)),
d6e8d8
			'admin_pass1'	=> request_var('admin_pass1', '', true),
d6e8d8
			'admin_pass2'	=> request_var('admin_pass2', '', true),
d6e8d8
			'board_email1'	=> strtolower(request_var('board_email1', '')),
d6e8d8
			'board_email2'	=> strtolower(request_var('board_email2', '')),
d6e8d8
			'img_imagick'	=> request_var('img_imagick', ''),
d6e8d8
			'ftp_path'		=> request_var('ftp_path', ''),
d6e8d8
			'ftp_user'		=> request_var('ftp_user', ''),
d6e8d8
			'ftp_pass'		=> request_var('ftp_pass', ''),
d6e8d8
			'email_enable'	=> request_var('email_enable', ''),
d6e8d8
			'smtp_delivery'	=> request_var('smtp_delivery', ''),
d6e8d8
			'smtp_host'		=> request_var('smtp_host', ''),
d6e8d8
			'smtp_auth'		=> request_var('smtp_auth', ''),
d6e8d8
			'smtp_user'		=> request_var('smtp_user', ''),
d6e8d8
			'smtp_pass'		=> request_var('smtp_pass', ''),
d6e8d8
			'cookie_secure'	=> request_var('cookie_secure', ''),
d6e8d8
			'force_server_vars'	=> request_var('force_server_vars', ''),
d6e8d8
			'server_protocol'	=> request_var('server_protocol', ''),
d6e8d8
			'server_name'	=> request_var('server_name', ''),
d6e8d8
			'server_port'	=> request_var('server_port', ''),
d6e8d8
			'script_path'	=> request_var('script_path', ''),
d6e8d8
		);
d6e8d8
	}
d6e8d8
d6e8d8
	/**
d6e8d8
	* The information below will be used to build the input fields presented to the user
d6e8d8
	*/
d6e8d8
	var $db_config_options = array(
d6e8d8
		'legend1'				=> 'DB_CONFIG',
d6e8d8
		'dbms'					=> array('lang' => 'DBMS',			'type' => 'select', 'options' => 'dbms_select(\'{VALUE}\')', 'explain' => false),
d6e8d8
		'dbhost'				=> array('lang' => 'DB_HOST',		'type' => 'text:25:100', 'explain' => true),
d6e8d8
		'dbport'				=> array('lang' => 'DB_PORT',		'type' => 'text:25:100', 'explain' => true),
d6e8d8
		'dbname'				=> array('lang' => 'DB_NAME',		'type' => 'text:25:100', 'explain' => false),
d6e8d8
		'dbuser'				=> array('lang' => 'DB_USERNAME',	'type' => 'text:25:100', 'explain' => false),
d6e8d8
		'dbpasswd'				=> array('lang' => 'DB_PASSWORD',	'type' => 'password:25:100', 'explain' => false),
d6e8d8
		'table_prefix'			=> array('lang' => 'TABLE_PREFIX',	'type' => 'text:25:100', 'explain' => false),
d6e8d8
	);
d6e8d8
	var $admin_config_options = array(
d6e8d8
		'legend1'				=> 'ADMIN_CONFIG',
d6e8d8
		'default_lang'			=> array('lang' => 'DEFAULT_LANG',				'type' => 'select', 'options' => '$this->module->inst_language_select(\'{VALUE}\')', 'explain' => false),
d6e8d8
		'admin_name'			=> array('lang' => 'ADMIN_USERNAME',			'type' => 'text:25:100', 'explain' => true),
d6e8d8
		'admin_pass1'			=> array('lang' => 'ADMIN_PASSWORD',			'type' => 'password:25:100', 'explain' => true),
d6e8d8
		'admin_pass2'			=> array('lang' => 'ADMIN_PASSWORD_CONFIRM',	'type' => 'password:25:100', 'explain' => false),
d6e8d8
		'board_email1'			=> array('lang' => 'CONTACT_EMAIL',				'type' => 'text:25:100', 'explain' => false),
d6e8d8
		'board_email2'			=> array('lang' => 'CONTACT_EMAIL_CONFIRM',		'type' => 'text:25:100', 'explain' => false),
d6e8d8
	);
d6e8d8
	var $advanced_config_options = array(
d6e8d8
		'legend1'				=> 'ACP_EMAIL_SETTINGS',
d6e8d8
		'email_enable'			=> array('lang' => 'ENABLE_EMAIL',		'type' => 'radio:enabled_disabled', 'explain' => true),
d6e8d8
		'smtp_delivery'			=> array('lang' => 'USE_SMTP',			'type' => 'radio:yes_no', 'explain' => true),
d6e8d8
		'smtp_host'				=> array('lang' => 'SMTP_SERVER',		'type' => 'text:25:50', 'explain' => false),
d6e8d8
		'smtp_auth'				=> array('lang' => 'SMTP_AUTH_METHOD',	'type' => 'select', 'options' => '$this->module->mail_auth_select(\'{VALUE}\')', 'explain' => true),
d6e8d8
		'smtp_user'				=> array('lang' => 'SMTP_USERNAME',		'type' => 'text:25:255', 'explain' => true),
d6e8d8
		'smtp_pass'				=> array('lang' => 'SMTP_PASSWORD',		'type' => 'password:25:255', 'explain' => true),
d6e8d8
d6e8d8
		'legend2'				=> 'SERVER_URL_SETTINGS',
d6e8d8
		'cookie_secure'			=> array('lang' => 'COOKIE_SECURE',		'type' => 'radio:enabled_disabled', 'explain' => true),
d6e8d8
		'force_server_vars'		=> array('lang' => 'FORCE_SERVER_VARS',	'type' => 'radio:yes_no', 'explain' => true),
d6e8d8
		'server_protocol'		=> array('lang' => 'SERVER_PROTOCOL',	'type' => 'text:10:10', 'explain' => true),
d6e8d8
		'server_name'			=> array('lang' => 'SERVER_NAME',		'type' => 'text:40:255', 'explain' => true),
d6e8d8
		'server_port'			=> array('lang' => 'SERVER_PORT',		'type' => 'text:5:5', 'explain' => true),
d6e8d8
		'script_path'			=> array('lang' => 'SCRIPT_PATH',		'type' => 'text::255', 'explain' => true),
d6e8d8
	);
d6e8d8
d6e8d8
	/**
d6e8d8
	* Specific PHP modules we may require for certain optional or extended features
d6e8d8
	*/
d6e8d8
	var $php_dlls_other = array('zlib', 'ftp', 'gd', 'xml');
d6e8d8
d6e8d8
	/**
d6e8d8
	* A list of the web-crawlers/bots we recognise by default
d6e8d8
	*
d6e8d8
	* Candidates but not included:
d6e8d8
	* 'Accoona [Bot]'				'Accoona-AI-Agent/'
d6e8d8
	* 'ASPseek [Crawler]'			'ASPseek/'
d6e8d8
	* 'Boitho [Crawler]'			'boitho.com-dc/'
d6e8d8
	* 'Bunnybot [Bot]'				'powered by www.buncat.de'
d6e8d8
	* 'Cosmix [Bot]'				'cfetch/'
d6e8d8
	* 'Crawler Search [Crawler]'	'.Crawler-Search.de'
d6e8d8
	* 'Findexa [Crawler]'			'Findexa Crawler ('
d6e8d8
	* 'GBSpider [Spider]'			'GBSpider v'
d6e8d8
	* 'genie [Bot]'					'genieBot ('
d6e8d8
	* 'Hogsearch [Bot]'				'oegp v. 1.3.0'
d6e8d8
	* 'Insuranco [Bot]'				'InsurancoBot'
d6e8d8
	* 'IRLbot [Bot]'				'http://irl.cs.tamu.edu/crawler'
d6e8d8
	* 'ISC Systems [Bot]'			'ISC Systems iRc Search'
d6e8d8
	* 'Jyxobot [Bot]'				'Jyxobot/'
d6e8d8
	* 'Kraehe [Metasuche]'			'-DIE-KRAEHE- META-SEARCH-ENGINE/'
d6e8d8
	* 'LinkWalker'					'LinkWalker'
d6e8d8
	* 'MMSBot [Bot]'				'http://www.mmsweb.at/bot.html'
d6e8d8
	* 'Naver [Bot]'					'nhnbot@naver.com)'
d6e8d8
	* 'NetResearchServer'			'NetResearchServer/'
d6e8d8
	* 'Nimble [Crawler]'			'NimbleCrawler'
d6e8d8
	* 'Ocelli [Bot]'				'Ocelli/'
d6e8d8
	* 'Onsearch [Bot]'				'onCHECK-Robot'
d6e8d8
	* 'Orange [Spider]'				'OrangeSpider'
d6e8d8
	* 'Sproose [Bot]'				'http://www.sproose.com/bot'
d6e8d8
	* 'Susie [Sync]'				'!Susie (http://www.sync2it.com/susie)'
d6e8d8
	* 'Tbot [Bot]'					'Tbot/'
d6e8d8
	* 'Thumbshots [Capture]'		'thumbshots-de-Bot'
d6e8d8
	* 'Vagabondo [Crawler]'			'http://webagent.wise-guys.nl/'
d6e8d8
	* 'Walhello [Bot]'				'appie 1.1 (www.walhello.com)'
d6e8d8
	* 'WissenOnline [Bot]'			'WissenOnline-Bot'
d6e8d8
	* 'WWWeasel [Bot]'				'WWWeasel Robot v'
d6e8d8
	* 'Xaldon [Spider]'				'Xaldon WebSpider'
d6e8d8
	*/
d6e8d8
	var $bot_list = array(
d6e8d8
		'AdsBot [Google]'			=> array('AdsBot-Google', ''),
d6e8d8
		'Alexa [Bot]'				=> array('ia_archiver', ''),
d6e8d8
		'Alta Vista [Bot]'			=> array('Scooter/', ''),
d6e8d8
		'Ask Jeeves [Bot]'			=> array('Ask Jeeves', ''),
d6e8d8
		'Baidu [Spider]'			=> array('Baiduspider+(', ''),
d6e8d8
		'Exabot [Bot]'				=> array('Exabot/', ''),
d6e8d8
		'FAST Enterprise [Crawler]'	=> array('FAST Enterprise Crawler', ''),
d6e8d8
		'FAST WebCrawler [Crawler]'	=> array('FAST-WebCrawler/', ''),
d6e8d8
		'Francis [Bot]'				=> array('http://www.neomo.de/', ''),
d6e8d8
		'Gigabot [Bot]'				=> array('Gigabot/', ''),
d6e8d8
		'Google Adsense [Bot]'		=> array('Mediapartners-Google', ''),
d6e8d8
		'Google Desktop'			=> array('Google Desktop', ''),
d6e8d8
		'Google Feedfetcher'		=> array('Feedfetcher-Google', ''),
d6e8d8
		'Google [Bot]'				=> array('Googlebot', ''),
d6e8d8
		'Heise IT-Markt [Crawler]'	=> array('heise-IT-Markt-Crawler', ''),
d6e8d8
		'Heritrix [Crawler]'		=> array('heritrix/1.', ''),
d6e8d8
		'IBM Research [Bot]'		=> array('ibm.com/cs/crawler', ''),
d6e8d8
		'ICCrawler - ICjobs'		=> array('ICCrawler - ICjobs', ''),
d6e8d8
		'ichiro [Crawler]'			=> array('ichiro/2', ''),
d6e8d8
		'Majestic-12 [Bot]'			=> array('MJ12bot/', ''),
d6e8d8
		'Metager [Bot]'				=> array('MetagerBot/', ''),
d6e8d8
		'MSN NewsBlogs'				=> array('msnbot-NewsBlogs/', ''),
d6e8d8
		'MSN [Bot]'					=> array('msnbot/', ''),
d6e8d8
		'MSNbot Media'				=> array('msnbot-media/', ''),
d6e8d8
		'NG-Search [Bot]'			=> array('NG-Search/', ''),
d6e8d8
		'Nutch [Bot]'				=> array('http://lucene.apache.org/nutch/', ''),
d6e8d8
		'Nutch/CVS [Bot]'			=> array('NutchCVS/', ''),
d6e8d8
		'OmniExplorer [Bot]'		=> array('OmniExplorer_Bot/', ''),
d6e8d8
		'Online link [Validator]'	=> array('online link validator', ''),
d6e8d8
		'psbot [Picsearch]'			=> array('psbot/0', ''),
d6e8d8
		'Seekport [Bot]'			=> array('Seekbot/', ''),
d6e8d8
		'Sensis [Crawler]'			=> array('Sensis Web Crawler', ''),
d6e8d8
		'SEO Crawler'				=> array('SEO search Crawler/', ''),
d6e8d8
		'Seoma [Crawler]'			=> array('Seoma [SEO Crawler]', ''),
d6e8d8
		'SEOSearch [Crawler]'		=> array('SEOsearch/', ''),
d6e8d8
		'Snappy [Bot]'				=> array('Snappy/1.1 ( http://www.urltrends.com/ )', ''),
d6e8d8
		'Steeler [Crawler]'			=> array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''),
d6e8d8
		'Synoo [Bot]'				=> array('SynooBot/', ''),
d6e8d8
		'Telekom [Bot]'				=> array('crawleradmin.t-info@telekom.de', ''),
d6e8d8
		'TurnitinBot [Bot]'			=> array('TurnitinBot/', ''),
d6e8d8
		'Voyager [Bot]'				=> array('voyager/1.0', ''),
d6e8d8
		'W3 [Sitesearch]'			=> array('W3 SiteSearch Crawler', ''),
d6e8d8
		'W3C [Linkcheck]'			=> array('W3C-checklink/', ''),
d6e8d8
		'W3C [Validator]'			=> array('W3C_*Validator', ''),
d6e8d8
		'WiseNut [Bot]'				=> array('http://www.WISEnutbot.com', ''),
d6e8d8
		'YaCy [Bot]'				=> array('yacybot', ''),
d6e8d8
		'Yahoo MMCrawler [Bot]'		=> array('Yahoo-MMCrawler/', ''),
d6e8d8
		'Yahoo Slurp [Bot]'			=> array('Yahoo! DE Slurp', ''),
d6e8d8
		'Yahoo [Bot]'				=> array('Yahoo! Slurp', ''),
d6e8d8
		'YahooSeeker [Bot]'			=> array('YahooSeeker/', ''),
d6e8d8
	);
d6e8d8
d6e8d8
	/**
d6e8d8
	* Define the module structure so that we can populate the database without
d6e8d8
	* needing to hard-code module_id values
d6e8d8
	*/
d6e8d8
	var $module_categories = array(
d6e8d8
		'acp'	=> array(
d6e8d8
			'ACP_CAT_GENERAL'		=> array(
d6e8d8
				'ACP_QUICK_ACCESS',
d6e8d8
				'ACP_BOARD_CONFIGURATION',
d6e8d8
				'ACP_CLIENT_COMMUNICATION',
d6e8d8
				'ACP_SERVER_CONFIGURATION',
d6e8d8
			),
d6e8d8
			'ACP_CAT_FORUMS'		=> array(
d6e8d8
				'ACP_MANAGE_FORUMS',
d6e8d8
				'ACP_FORUM_BASED_PERMISSIONS',
d6e8d8
			),
d6e8d8
			'ACP_CAT_POSTING'		=> array(
d6e8d8
				'ACP_MESSAGES',
d6e8d8
				'ACP_ATTACHMENTS',
d6e8d8
			),
d6e8d8
			'ACP_CAT_USERGROUP'		=> array(
d6e8d8
				'ACP_CAT_USERS',
d6e8d8
				'ACP_GROUPS',
d6e8d8
				'ACP_USER_SECURITY',
d6e8d8
			),
d6e8d8
			'ACP_CAT_PERMISSIONS'	=> array(
d6e8d8
				'ACP_GLOBAL_PERMISSIONS',
d6e8d8
				'ACP_FORUM_BASED_PERMISSIONS',
d6e8d8
				'ACP_PERMISSION_ROLES',
d6e8d8
				'ACP_PERMISSION_MASKS',
d6e8d8
			),
d6e8d8
			'ACP_CAT_STYLES'		=> array(
d6e8d8
				'ACP_STYLE_MANAGEMENT',
d6e8d8
				'ACP_STYLE_COMPONENTS',
d6e8d8
			),
d6e8d8
			'ACP_CAT_MAINTENANCE'	=> array(
d6e8d8
				'ACP_FORUM_LOGS',
d6e8d8
				'ACP_CAT_DATABASE',
d6e8d8
			),
d6e8d8
			'ACP_CAT_SYSTEM'		=> array(
d6e8d8
				'ACP_AUTOMATION',
d6e8d8
				'ACP_GENERAL_TASKS',
d6e8d8
				'ACP_MODULE_MANAGEMENT',
d6e8d8
			),
d6e8d8
			'ACP_CAT_DOT_MODS'		=> null,
d6e8d8
		),
d6e8d8
		'mcp'	=> array(
d6e8d8
			'MCP_MAIN'		=> null,
d6e8d8
			'MCP_QUEUE'		=> null,
d6e8d8
			'MCP_REPORTS'	=> null,
d6e8d8
			'MCP_NOTES'		=> null,
d6e8d8
			'MCP_WARN'		=> null,
d6e8d8
			'MCP_LOGS'		=> null,
d6e8d8
			'MCP_BAN'		=> null,
d6e8d8
		),
d6e8d8
		'ucp'	=> array(
d6e8d8
			'UCP_MAIN'			=> null,
d6e8d8
			'UCP_PROFILE'		=> null,
d6e8d8
			'UCP_PREFS'			=> null,
d6e8d8
			'UCP_PM'			=> null,
d6e8d8
			'UCP_USERGROUPS'	=> null,
d6e8d8
			'UCP_ZEBRA'			=> null,
d6e8d8
		),
d6e8d8
	);
d6e8d8
d6e8d8
	var $module_extras = array(
d6e8d8
		'acp'	=> array(
d6e8d8
			'ACP_QUICK_ACCESS' => array(
d6e8d8
				'ACP_MANAGE_USERS',
d6e8d8
				'ACP_GROUPS_MANAGE',
d6e8d8
				'ACP_MANAGE_FORUMS',
d6e8d8
				'ACP_MOD_LOGS',
d6e8d8
				'ACP_BOTS',
d6e8d8
				'ACP_PHP_INFO',
d6e8d8
			),
d6e8d8
			'ACP_FORUM_BASED_PERMISSIONS' => array(
d6e8d8
				'ACP_FORUM_PERMISSIONS',
d6e8d8
				'ACP_FORUM_MODERATORS',
d6e8d8
				'ACP_USERS_FORUM_PERMISSIONS',
d6e8d8
				'ACP_GROUPS_FORUM_PERMISSIONS',
d6e8d8
			),
d6e8d8
		),
d6e8d8
	);
d6e8d8
}
d6e8d8
d6e8d8
?>