Blame Identity/Webenv/App/phpBB/3.0.4/install/install_install.php

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