install/install_install.php
author indvdum (gotoindvdum[at]gmail[dot]com)
Wed, 07 Mar 2012 23:05:50 +0400
changeset 5 8b13f18d7412
parent 0 ceef6d64c21d
permissions -rw-r--r--
MD5 password fix
     1 <?php
     2 /**
     3 *
     4 * @package install
     5 * @version $Id$
     6 * @copyright (c) 2005 phpBB Group
     7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
     8 *
     9 */
    10 
    11 /**
    12 */
    13 if (!defined('IN_INSTALL'))
    14 {
    15 	// Someone has tried to access the file direct. This is not a good idea, so exit
    16 	exit;
    17 }
    18 
    19 if (!empty($setmodules))
    20 {
    21 	// If phpBB is already installed we do not include this module
    22 	if (@file_exists($phpbb_root_path . 'config.' . $phpEx) && !file_exists($phpbb_root_path . 'cache/install_lock'))
    23 	{
    24 		include_once($phpbb_root_path . 'config.' . $phpEx);
    25 
    26 		if (defined('PHPBB_INSTALLED'))
    27 		{
    28 			return;
    29 		}
    30 	}
    31 
    32 	$module[] = array(
    33 		'module_type'		=> 'install',
    34 		'module_title'		=> 'INSTALL',
    35 		'module_filename'	=> substr(basename(__FILE__), 0, -strlen($phpEx)-1),
    36 		'module_order'		=> 10,
    37 		'module_subs'		=> '',
    38 		'module_stages'		=> array('INTRO', 'REQUIREMENTS', 'DATABASE', 'ADMINISTRATOR', 'CONFIG_FILE', 'ADVANCED', 'CREATE_TABLE', 'FINAL'),
    39 		'module_reqs'		=> ''
    40 	);
    41 }
    42 
    43 /**
    44 * Installation
    45 * @package install
    46 */
    47 class install_install extends module
    48 {
    49 	function install_install(&$p_master)
    50 	{
    51 		$this->p_master = &$p_master;
    52 	}
    53 
    54 	function main($mode, $sub)
    55 	{
    56 		global $lang, $template, $language, $phpbb_root_path;
    57 
    58 		switch ($sub)
    59 		{
    60 			case 'intro':
    61 				$this->page_title = $lang['SUB_INTRO'];
    62 
    63 				$template->assign_vars(array(
    64 					'TITLE'			=> $lang['INSTALL_INTRO'],
    65 					'BODY'			=> $lang['INSTALL_INTRO_BODY'],
    66 					'L_SUBMIT'		=> $lang['NEXT_STEP'],
    67 					'S_LANG_SELECT'	=> '<select id="language" name="language">' . $this->p_master->inst_language_select($language) . '</select>',
    68 					'U_ACTION'		=> $this->p_master->module_url . "?mode=$mode&amp;sub=requirements&amp;language=$language",
    69 				));
    70 
    71 			break;
    72 
    73 			case 'requirements':
    74 				$this->check_server_requirements($mode, $sub);
    75 
    76 			break;
    77 
    78 			case 'database':
    79 				$this->obtain_database_settings($mode, $sub);
    80 
    81 			break;
    82 
    83 			case 'administrator':
    84 				$this->obtain_admin_settings($mode, $sub);
    85 
    86 			break;
    87 
    88 			case 'config_file':
    89 				$this->create_config_file($mode, $sub);
    90 
    91 			break;
    92 
    93 			case 'advanced':
    94 				$this->obtain_advanced_settings($mode, $sub);
    95 
    96 			break;
    97 
    98 			case 'create_table':
    99 				$this->load_schema($mode, $sub);
   100 			break;
   101 
   102 			case 'final':
   103 				$this->build_search_index($mode, $sub);
   104 				$this->add_modules($mode, $sub);
   105 				$this->add_language($mode, $sub);
   106 				$this->add_bots($mode, $sub);
   107 				$this->email_admin($mode, $sub);
   108 
   109 				// Remove the lock file
   110 				@unlink($phpbb_root_path . 'cache/install_lock');
   111 
   112 			break;
   113 		}
   114 
   115 		$this->tpl_name = 'install_install';
   116 	}
   117 
   118 	/**
   119 	* Checks that the server we are installing on meets the requirements for running phpBB
   120 	*/
   121 	function check_server_requirements($mode, $sub)
   122 	{
   123 		global $lang, $template, $phpbb_root_path, $phpEx, $language;
   124 
   125 		$this->page_title = $lang['STAGE_REQUIREMENTS'];
   126 
   127 		$template->assign_vars(array(
   128 			'TITLE'		=> $lang['REQUIREMENTS_TITLE'],
   129 			'BODY'		=> $lang['REQUIREMENTS_EXPLAIN'],
   130 		));
   131 
   132 		$passed = array('php' => false, 'db' => false, 'files' => false, 'pcre' => false, 'imagesize' => false,);
   133 
   134 		// Test for basic PHP settings
   135 		$template->assign_block_vars('checks', array(
   136 			'S_LEGEND'			=> true,
   137 			'LEGEND'			=> $lang['PHP_SETTINGS'],
   138 			'LEGEND_EXPLAIN'	=> $lang['PHP_SETTINGS_EXPLAIN'],
   139 		));
   140 
   141 		// Test the minimum PHP version
   142 		$php_version = PHP_VERSION;
   143 
   144 		if (version_compare($php_version, '4.3.3') < 0)
   145 		{
   146 			$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
   147 		}
   148 		else
   149 		{
   150 			$passed['php'] = true;
   151 
   152 			// We also give feedback on whether we're running in safe mode
   153 			$result = '<strong style="color:green">' . $lang['YES'];
   154 			if (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) == 'on')
   155 			{
   156 				$result .= ', ' . $lang['PHP_SAFE_MODE'];
   157 			}
   158 			$result .= '</strong>';
   159 		}
   160 
   161 		$template->assign_block_vars('checks', array(
   162 			'TITLE'			=> $lang['PHP_VERSION_REQD'],
   163 			'RESULT'		=> $result,
   164 
   165 			'S_EXPLAIN'		=> false,
   166 			'S_LEGEND'		=> false,
   167 		));
   168 
   169 		// Check for register_globals being enabled
   170 		if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
   171 		{
   172 			$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
   173 		}
   174 		else
   175 		{
   176 			$result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
   177 		}
   178 
   179 		$template->assign_block_vars('checks', array(
   180 			'TITLE'			=> $lang['PHP_REGISTER_GLOBALS'],
   181 			'TITLE_EXPLAIN'	=> $lang['PHP_REGISTER_GLOBALS_EXPLAIN'],
   182 			'RESULT'		=> $result,
   183 
   184 			'S_EXPLAIN'		=> true,
   185 			'S_LEGEND'		=> false,
   186 		));
   187 
   188 
   189 		// Check for url_fopen
   190 		if (@ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on')
   191 		{
   192 			$result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
   193 		}
   194 		else
   195 		{
   196 			$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
   197 		}
   198 
   199 		$template->assign_block_vars('checks', array(
   200 			'TITLE'			=> $lang['PHP_URL_FOPEN_SUPPORT'],
   201 			'TITLE_EXPLAIN'	=> $lang['PHP_URL_FOPEN_SUPPORT_EXPLAIN'],
   202 			'RESULT'		=> $result,
   203 
   204 			'S_EXPLAIN'		=> true,
   205 			'S_LEGEND'		=> false,
   206 		));
   207 
   208 
   209 		// Check for getimagesize
   210 		if (@function_exists('getimagesize'))
   211 		{
   212 			$passed['imagesize'] = true;
   213 			$result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
   214 		}
   215 		else
   216 		{
   217 			$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
   218 		}
   219 
   220 		$template->assign_block_vars('checks', array(
   221 			'TITLE'			=> $lang['PHP_GETIMAGESIZE_SUPPORT'],
   222 			'TITLE_EXPLAIN'	=> $lang['PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'],
   223 			'RESULT'		=> $result,
   224 
   225 			'S_EXPLAIN'		=> true,
   226 			'S_LEGEND'		=> false,
   227 		));
   228 
   229 		// Check for PCRE UTF-8 support
   230 		if (@preg_match('//u', ''))
   231 		{
   232 			$passed['pcre'] = true;
   233 			$result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
   234 		}
   235 		else
   236 		{
   237 			$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
   238 		}
   239 
   240 		$template->assign_block_vars('checks', array(
   241 			'TITLE'			=> $lang['PCRE_UTF_SUPPORT'],
   242 			'TITLE_EXPLAIN'	=> $lang['PCRE_UTF_SUPPORT_EXPLAIN'],
   243 			'RESULT'		=> $result,
   244 
   245 			'S_EXPLAIN'		=> true,
   246 			'S_LEGEND'		=> false,
   247 		));
   248 
   249 /**
   250 *		Better not enabling and adding to the loaded extensions due to the specific requirements needed
   251 		if (!@extension_loaded('mbstring'))
   252 		{
   253 			can_load_dll('mbstring');
   254 		}
   255 */
   256 
   257 		$passed['mbstring'] = true;
   258 		if (@extension_loaded('mbstring'))
   259 		{
   260 			// Test for available database modules
   261 			$template->assign_block_vars('checks', array(
   262 				'S_LEGEND'			=> true,
   263 				'LEGEND'			=> $lang['MBSTRING_CHECK'],
   264 				'LEGEND_EXPLAIN'	=> $lang['MBSTRING_CHECK_EXPLAIN'],
   265 			));
   266 
   267 			$checks = array(
   268 				array('func_overload', '&', MB_OVERLOAD_MAIL|MB_OVERLOAD_STRING),
   269 				array('encoding_translation', '!=', 0),
   270 				array('http_input', '!=', 'pass'),
   271 				array('http_output', '!=', 'pass')
   272 			);
   273 
   274 			foreach ($checks as $mb_checks)
   275 			{
   276 				$ini_val = @ini_get('mbstring.' . $mb_checks[0]);
   277 				switch ($mb_checks[1])
   278 				{
   279 					case '&':
   280 						if (intval($ini_val) & $mb_checks[2])
   281 						{
   282 							$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
   283 							$passed['mbstring'] = false;
   284 						}
   285 						else
   286 						{
   287 							$result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
   288 						}
   289 					break;
   290 
   291 					case '!=':
   292 						if ($ini_val != $mb_checks[2])
   293 						{
   294 							$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
   295 							$passed['mbstring'] = false;
   296 						}
   297 						else
   298 						{
   299 							$result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
   300 						}
   301 					break;
   302 				}
   303 				$template->assign_block_vars('checks', array(
   304 					'TITLE'			=> $lang['MBSTRING_' . strtoupper($mb_checks[0])],
   305 					'TITLE_EXPLAIN'	=> $lang['MBSTRING_' . strtoupper($mb_checks[0]) . '_EXPLAIN'],
   306 					'RESULT'		=> $result,
   307 
   308 					'S_EXPLAIN'		=> true,
   309 					'S_LEGEND'		=> false,
   310 				));
   311 			}
   312 		}
   313 
   314 		// Test for available database modules
   315 		$template->assign_block_vars('checks', array(
   316 			'S_LEGEND'			=> true,
   317 			'LEGEND'			=> $lang['PHP_SUPPORTED_DB'],
   318 			'LEGEND_EXPLAIN'	=> $lang['PHP_SUPPORTED_DB_EXPLAIN'],
   319 		));
   320 
   321 		$available_dbms = get_available_dbms(false, true);
   322 		$passed['db'] = $available_dbms['ANY_DB_SUPPORT'];
   323 		unset($available_dbms['ANY_DB_SUPPORT']);
   324 
   325 		foreach ($available_dbms as $db_name => $db_ary)
   326 		{
   327 			if (!$db_ary['AVAILABLE'])
   328 			{
   329 				$template->assign_block_vars('checks', array(
   330 					'TITLE'		=> $lang['DLL_' . strtoupper($db_name)],
   331 					'RESULT'	=> '<span style="color:red">' . $lang['UNAVAILABLE'] . '</span>',
   332 
   333 					'S_EXPLAIN'	=> false,
   334 					'S_LEGEND'	=> false,
   335 				));
   336 			}
   337 			else
   338 			{
   339 				$template->assign_block_vars('checks', array(
   340 					'TITLE'		=> $lang['DLL_' . strtoupper($db_name)],
   341 					'RESULT'	=> '<strong style="color:green">' . $lang['AVAILABLE'] . '</strong>',
   342 
   343 					'S_EXPLAIN'	=> false,
   344 					'S_LEGEND'	=> false,
   345 				));
   346 			}
   347 		}
   348 
   349 		// Test for other modules
   350 		$template->assign_block_vars('checks', array(
   351 			'S_LEGEND'			=> true,
   352 			'LEGEND'			=> $lang['PHP_OPTIONAL_MODULE'],
   353 			'LEGEND_EXPLAIN'	=> $lang['PHP_OPTIONAL_MODULE_EXPLAIN'],
   354 		));
   355 
   356 		foreach ($this->php_dlls_other as $dll)
   357 		{
   358 			if (!@extension_loaded($dll))
   359 			{
   360 				if (!can_load_dll($dll))
   361 				{
   362 					$template->assign_block_vars('checks', array(
   363 						'TITLE'		=> $lang['DLL_' . strtoupper($dll)],
   364 						'RESULT'	=> '<strong style="color:red">' . $lang['UNAVAILABLE'] . '</strong>',
   365 
   366 						'S_EXPLAIN'	=> false,
   367 						'S_LEGEND'	=> false,
   368 					));
   369 					continue;
   370 				}
   371 			}
   372 
   373 			$template->assign_block_vars('checks', array(
   374 				'TITLE'		=> $lang['DLL_' . strtoupper($dll)],
   375 				'RESULT'	=> '<strong style="color:green">' . $lang['AVAILABLE'] . '</strong>',
   376 
   377 				'S_EXPLAIN'	=> false,
   378 				'S_LEGEND'	=> false,
   379 			));
   380 		}
   381 
   382 		// Can we find Imagemagick anywhere on the system?
   383 		$exe = (DIRECTORY_SEPARATOR == '\\') ? '.exe' : '';
   384 
   385 		$magic_home = getenv('MAGICK_HOME');
   386 		$img_imagick = '';
   387 		if (empty($magic_home))
   388 		{
   389 			$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/');
   390 			$path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH'))));
   391 
   392 			$locations = array_merge($path_locations, $locations);
   393 			foreach ($locations as $location)
   394 			{
   395 				// The path might not end properly, fudge it
   396 				if (substr($location, -1, 1) !== '/')
   397 				{
   398 					$location .= '/';
   399 				}
   400 
   401 				if (@file_exists($location) && @is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000)
   402 				{
   403 					$img_imagick = str_replace('\\', '/', $location);
   404 					continue;
   405 				}
   406 			}
   407 		}
   408 		else
   409 		{
   410 			$img_imagick = str_replace('\\', '/', $magic_home);
   411 		}
   412 
   413 		$template->assign_block_vars('checks', array(
   414 			'TITLE'		=> $lang['APP_MAGICK'],
   415 			'RESULT'	=> ($img_imagick) ? '<strong style="color:green">' . $lang['AVAILABLE'] . ', ' . $img_imagick . '</strong>' : '<strong style="color:blue">' . $lang['NO_LOCATION'] . '</strong>',
   416 
   417 			'S_EXPLAIN'	=> false,
   418 			'S_LEGEND'	=> false,
   419 		));
   420 
   421 		// Check permissions on files/directories we need access to
   422 		$template->assign_block_vars('checks', array(
   423 			'S_LEGEND'			=> true,
   424 			'LEGEND'			=> $lang['FILES_REQUIRED'],
   425 			'LEGEND_EXPLAIN'	=> $lang['FILES_REQUIRED_EXPLAIN'],
   426 		));
   427 
   428 		$directories = array('cache/', 'files/', 'store/');
   429 
   430 		umask(0);
   431 
   432 		$passed['files'] = true;
   433 		foreach ($directories as $dir)
   434 		{
   435 			$exists = $write = false;
   436 
   437 			// Try to create the directory if it does not exist
   438 			if (!file_exists($phpbb_root_path . $dir))
   439 			{
   440 				@mkdir($phpbb_root_path . $dir, 0777);
   441 				phpbb_chmod($phpbb_root_path . $dir, CHMOD_READ | CHMOD_WRITE);
   442 			}
   443 
   444 			// Now really check
   445 			if (file_exists($phpbb_root_path . $dir) && is_dir($phpbb_root_path . $dir))
   446 			{
   447 				phpbb_chmod($phpbb_root_path . $dir, CHMOD_READ | CHMOD_WRITE);
   448 				$exists = true;
   449 			}
   450 
   451 			// Now check if it is writable by storing a simple file
   452 			$fp = @fopen($phpbb_root_path . $dir . 'test_lock', 'wb');
   453 			if ($fp !== false)
   454 			{
   455 				$write = true;
   456 			}
   457 			@fclose($fp);
   458 
   459 			@unlink($phpbb_root_path . $dir . 'test_lock');
   460 
   461 			$passed['files'] = ($exists && $write && $passed['files']) ? true : false;
   462 
   463 			$exists = ($exists) ? '<strong style="color:green">' . $lang['FOUND'] . '</strong>' : '<strong style="color:red">' . $lang['NOT_FOUND'] . '</strong>';
   464 			$write = ($write) ? ', <strong style="color:green">' . $lang['WRITABLE'] . '</strong>' : (($exists) ? ', <strong style="color:red">' . $lang['UNWRITABLE'] . '</strong>' : '');
   465 
   466 			$template->assign_block_vars('checks', array(
   467 				'TITLE'		=> $dir,
   468 				'RESULT'	=> $exists . $write,
   469 
   470 				'S_EXPLAIN'	=> false,
   471 				'S_LEGEND'	=> false,
   472 			));
   473 		}
   474 
   475 		// Check permissions on files/directories it would be useful access to
   476 		$template->assign_block_vars('checks', array(
   477 			'S_LEGEND'			=> true,
   478 			'LEGEND'			=> $lang['FILES_OPTIONAL'],
   479 			'LEGEND_EXPLAIN'	=> $lang['FILES_OPTIONAL_EXPLAIN'],
   480 		));
   481 
   482 		$directories = array('config.' . $phpEx, 'images/avatars/upload/');
   483 
   484 		foreach ($directories as $dir)
   485 		{
   486 			$write = $exists = true;
   487 			if (file_exists($phpbb_root_path . $dir))
   488 			{
   489 				if (!phpbb_is_writable($phpbb_root_path . $dir))
   490 				{
   491 					$write = false;
   492 				}
   493 			}
   494 			else
   495 			{
   496 				$write = $exists = false;
   497 			}
   498 
   499 			$exists_str = ($exists) ? '<strong style="color:green">' . $lang['FOUND'] . '</strong>' : '<strong style="color:red">' . $lang['NOT_FOUND'] . '</strong>';
   500 			$write_str = ($write) ? ', <strong style="color:green">' . $lang['WRITABLE'] . '</strong>' : (($exists) ? ', <strong style="color:red">' . $lang['UNWRITABLE'] . '</strong>' : '');
   501 
   502 			$template->assign_block_vars('checks', array(
   503 				'TITLE'		=> $dir,
   504 				'RESULT'	=> $exists_str . $write_str,
   505 
   506 				'S_EXPLAIN'	=> false,
   507 				'S_LEGEND'	=> false,
   508 			));
   509 		}
   510 
   511 		// And finally where do we want to go next (well today is taken isn't it :P)
   512 		$s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . addslashes($img_imagick) . '" />' : '';
   513 
   514 		$url = (!in_array(false, $passed)) ? $this->p_master->module_url . "?mode=$mode&amp;sub=database&amp;language=$language" : $this->p_master->module_url . "?mode=$mode&amp;sub=requirements&amp;language=$language	";
   515 		$submit = (!in_array(false, $passed)) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST'];
   516 
   517 
   518 		$template->assign_vars(array(
   519 			'L_SUBMIT'	=> $submit,
   520 			'S_HIDDEN'	=> $s_hidden_fields,
   521 			'U_ACTION'	=> $url,
   522 		));
   523 	}
   524 
   525 	/**
   526 	* Obtain the information required to connect to the database
   527 	*/
   528 	function obtain_database_settings($mode, $sub)
   529 	{
   530 		global $lang, $template, $phpEx;
   531 
   532 		$this->page_title = $lang['STAGE_DATABASE'];
   533 
   534 		// Obtain any submitted data
   535 		$data = $this->get_submitted_data();
   536 
   537 		$connect_test = false;
   538 		$error = array();
   539 		$available_dbms = get_available_dbms(false, true);
   540 
   541 		// Has the user opted to test the connection?
   542 		if (isset($_POST['testdb']))
   543 		{
   544 			if (!isset($available_dbms[$data['dbms']]) || !$available_dbms[$data['dbms']]['AVAILABLE'])
   545 			{
   546 				$error[] = $lang['INST_ERR_NO_DB'];
   547 				$connect_test = false;
   548 			}
   549 			else if (!preg_match(get_preg_expression('table_prefix'), $data['table_prefix']))
   550 			{
   551 				$error[] = $lang['INST_ERR_DB_INVALID_PREFIX'];
   552 				$connect_test = false;
   553 			}
   554 			else
   555 			{
   556 				$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']);
   557 			}
   558 
   559 			$template->assign_block_vars('checks', array(
   560 				'S_LEGEND'			=> true,
   561 				'LEGEND'			=> $lang['DB_CONNECTION'],
   562 				'LEGEND_EXPLAIN'	=> false,
   563 			));
   564 
   565 			if ($connect_test)
   566 			{
   567 				$template->assign_block_vars('checks', array(
   568 					'TITLE'		=> $lang['DB_TEST'],
   569 					'RESULT'	=> '<strong style="color:green">' . $lang['SUCCESSFUL_CONNECT'] . '</strong>',
   570 
   571 					'S_EXPLAIN'	=> false,
   572 					'S_LEGEND'	=> false,
   573 				));
   574 			}
   575 			else
   576 			{
   577 				$template->assign_block_vars('checks', array(
   578 					'TITLE'		=> $lang['DB_TEST'],
   579 					'RESULT'	=> '<strong style="color:red">' . implode('<br />', $error) . '</strong>',
   580 
   581 					'S_EXPLAIN'	=> false,
   582 					'S_LEGEND'	=> false,
   583 				));
   584 			}
   585 		}
   586 
   587 		if (!$connect_test)
   588 		{
   589 			// Update the list of available DBMS modules to only contain those which can be used
   590 			$available_dbms_temp = array();
   591 			foreach ($available_dbms as $type => $dbms_ary)
   592 			{
   593 				if (!$dbms_ary['AVAILABLE'])
   594 				{
   595 					continue;
   596 				}
   597 
   598 				$available_dbms_temp[$type] = $dbms_ary;
   599 			}
   600 
   601 			$available_dbms = &$available_dbms_temp;
   602 
   603 			// And now for the main part of this page
   604 			$data['table_prefix'] = (!empty($data['table_prefix']) ? $data['table_prefix'] : 'phpbb_');
   605 
   606 			foreach ($this->db_config_options as $config_key => $vars)
   607 			{
   608 				if (!is_array($vars) && strpos($config_key, 'legend') === false)
   609 				{
   610 					continue;
   611 				}
   612 
   613 				if (strpos($config_key, 'legend') !== false)
   614 				{
   615 					$template->assign_block_vars('options', array(
   616 						'S_LEGEND'		=> true,
   617 						'LEGEND'		=> $lang[$vars])
   618 					);
   619 
   620 					continue;
   621 				}
   622 
   623 				$options = isset($vars['options']) ? $vars['options'] : '';
   624 
   625 				$template->assign_block_vars('options', array(
   626 					'KEY'			=> $config_key,
   627 					'TITLE'			=> $lang[$vars['lang']],
   628 					'S_EXPLAIN'		=> $vars['explain'],
   629 					'S_LEGEND'		=> false,
   630 					'TITLE_EXPLAIN'	=> ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '',
   631 					'CONTENT'		=> $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options),
   632 					)
   633 				);
   634 			}
   635 		}
   636 
   637 		// And finally where do we want to go next (well today is taken isn't it :P)
   638 		$s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
   639 		$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
   640 		if ($connect_test)
   641 		{
   642 			foreach ($this->db_config_options as $config_key => $vars)
   643 			{
   644 				if (!is_array($vars))
   645 				{
   646 					continue;
   647 				}
   648 				$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
   649 			}
   650 		}
   651 
   652 		$url = ($connect_test) ? $this->p_master->module_url . "?mode=$mode&amp;sub=administrator" : $this->p_master->module_url . "?mode=$mode&amp;sub=database";
   653 		$s_hidden_fields .= ($connect_test) ? '' : '<input type="hidden" name="testdb" value="true" />';
   654 
   655 		$submit = $lang['NEXT_STEP'];
   656 
   657 		$template->assign_vars(array(
   658 			'L_SUBMIT'	=> $submit,
   659 			'S_HIDDEN'	=> $s_hidden_fields,
   660 			'U_ACTION'	=> $url,
   661 		));
   662 	}
   663 
   664 	/**
   665 	* Obtain the administrator's name, password and email address
   666 	*/
   667 	function obtain_admin_settings($mode, $sub)
   668 	{
   669 		global $lang, $template, $phpEx;
   670 
   671 		$this->page_title = $lang['STAGE_ADMINISTRATOR'];
   672 
   673 		// Obtain any submitted data
   674 		$data = $this->get_submitted_data();
   675 
   676 		if ($data['dbms'] == '')
   677 		{
   678 			// Someone's been silly and tried calling this page direct
   679 			// So we send them back to the start to do it again properly
   680 			$this->p_master->redirect("index.$phpEx?mode=install");
   681 		}
   682 
   683 		$s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
   684 		$passed = false;
   685 
   686 		$data['default_lang'] = ($data['default_lang'] !== '') ? $data['default_lang'] : $data['language'];
   687 
   688 		if (isset($_POST['check']))
   689 		{
   690 			$error = array();
   691 
   692 			// Check the entered email address and password
   693 			if ($data['admin_name'] == '' || $data['admin_pass1'] == '' || $data['admin_pass2'] == '' || $data['board_email1'] == '' || $data['board_email2'] == '')
   694 			{
   695 				$error[] = $lang['INST_ERR_MISSING_DATA'];
   696 			}
   697 
   698 			if ($data['admin_pass1'] != $data['admin_pass2'] && $data['admin_pass1'] != '')
   699 			{
   700 				$error[] = $lang['INST_ERR_PASSWORD_MISMATCH'];
   701 			}
   702 
   703 			// Test against the default username rules
   704 			if ($data['admin_name'] != '' && utf8_strlen($data['admin_name']) < 3)
   705 			{
   706 				$error[] = $lang['INST_ERR_USER_TOO_SHORT'];
   707 			}
   708 
   709 			if ($data['admin_name'] != '' && utf8_strlen($data['admin_name']) > 20)
   710 			{
   711 				$error[] = $lang['INST_ERR_USER_TOO_LONG'];
   712 			}
   713 
   714 			// Test against the default password rules
   715 			if ($data['admin_pass1'] != '' && utf8_strlen($data['admin_pass1']) < 6)
   716 			{
   717 				$error[] = $lang['INST_ERR_PASSWORD_TOO_SHORT'];
   718 			}
   719 
   720 			if ($data['admin_pass1'] != '' && utf8_strlen($data['admin_pass1']) > 30)
   721 			{
   722 				$error[] = $lang['INST_ERR_PASSWORD_TOO_LONG'];
   723 			}
   724 
   725 			if ($data['board_email1'] != $data['board_email2'] && $data['board_email1'] != '')
   726 			{
   727 				$error[] = $lang['INST_ERR_EMAIL_MISMATCH'];
   728 			}
   729 
   730 			if ($data['board_email1'] != '' && !preg_match('/^' . get_preg_expression('email') . '$/i', $data['board_email1']))
   731 			{
   732 				$error[] = $lang['INST_ERR_EMAIL_INVALID'];
   733 			}
   734 
   735 			$template->assign_block_vars('checks', array(
   736 				'S_LEGEND'			=> true,
   737 				'LEGEND'			=> $lang['STAGE_ADMINISTRATOR'],
   738 				'LEGEND_EXPLAIN'	=> false,
   739 			));
   740 
   741 			if (!sizeof($error))
   742 			{
   743 				$passed = true;
   744 				$template->assign_block_vars('checks', array(
   745 					'TITLE'		=> $lang['ADMIN_TEST'],
   746 					'RESULT'	=> '<strong style="color:green">' . $lang['TESTS_PASSED'] . '</strong>',
   747 
   748 					'S_EXPLAIN'	=> false,
   749 					'S_LEGEND'	=> false,
   750 				));
   751 			}
   752 			else
   753 			{
   754 				$template->assign_block_vars('checks', array(
   755 					'TITLE'		=> $lang['ADMIN_TEST'],
   756 					'RESULT'	=> '<strong style="color:red">' . implode('<br />', $error) . '</strong>',
   757 
   758 					'S_EXPLAIN'	=> false,
   759 					'S_LEGEND'	=> false,
   760 				));
   761 			}
   762 		}
   763 
   764 		if (!$passed)
   765 		{
   766 			foreach ($this->admin_config_options as $config_key => $vars)
   767 			{
   768 				if (!is_array($vars) && strpos($config_key, 'legend') === false)
   769 				{
   770 					continue;
   771 				}
   772 
   773 				if (strpos($config_key, 'legend') !== false)
   774 				{
   775 					$template->assign_block_vars('options', array(
   776 						'S_LEGEND'		=> true,
   777 						'LEGEND'		=> $lang[$vars])
   778 					);
   779 
   780 					continue;
   781 				}
   782 
   783 				$options = isset($vars['options']) ? $vars['options'] : '';
   784 
   785 				$template->assign_block_vars('options', array(
   786 					'KEY'			=> $config_key,
   787 					'TITLE'			=> $lang[$vars['lang']],
   788 					'S_EXPLAIN'		=> $vars['explain'],
   789 					'S_LEGEND'		=> false,
   790 					'TITLE_EXPLAIN'	=> ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '',
   791 					'CONTENT'		=> $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options),
   792 					)
   793 				);
   794 			}
   795 		}
   796 		else
   797 		{
   798 			foreach ($this->admin_config_options as $config_key => $vars)
   799 			{
   800 				if (!is_array($vars))
   801 				{
   802 					continue;
   803 				}
   804 				$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
   805 			}
   806 		}
   807 
   808 		$s_hidden_fields .= ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
   809 		$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
   810 
   811 		foreach ($this->db_config_options as $config_key => $vars)
   812 		{
   813 			if (!is_array($vars))
   814 			{
   815 				continue;
   816 			}
   817 			$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
   818 		}
   819 
   820 		$submit = $lang['NEXT_STEP'];
   821 
   822 		$url = ($passed) ? $this->p_master->module_url . "?mode=$mode&amp;sub=config_file" : $this->p_master->module_url . "?mode=$mode&amp;sub=administrator";
   823 		$s_hidden_fields .= ($passed) ? '' : '<input type="hidden" name="check" value="true" />';
   824 
   825 		$template->assign_vars(array(
   826 			'L_SUBMIT'	=> $submit,
   827 			'S_HIDDEN'	=> $s_hidden_fields,
   828 			'U_ACTION'	=> $url,
   829 		));
   830 	}
   831 
   832 	/**
   833 	* Writes the config file to disk, or if unable to do so offers alternative methods
   834 	*/
   835 	function create_config_file($mode, $sub)
   836 	{
   837 		global $lang, $template, $phpbb_root_path, $phpEx;
   838 
   839 		$this->page_title = $lang['STAGE_CONFIG_FILE'];
   840 
   841 		// Obtain any submitted data
   842 		$data = $this->get_submitted_data();
   843 
   844 		if ($data['dbms'] == '')
   845 		{
   846 			// Someone's been silly and tried calling this page direct
   847 			// So we send them back to the start to do it again properly
   848 			$this->p_master->redirect("index.$phpEx?mode=install");
   849 		}
   850 
   851 		$s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
   852 		$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
   853 		$written = false;
   854 
   855 		// Create a list of any PHP modules we wish to have loaded
   856 		$load_extensions = array();
   857 		$available_dbms = get_available_dbms($data['dbms']);
   858 		$check_exts = array_merge(array($available_dbms[$data['dbms']]['MODULE']), $this->php_dlls_other);
   859 
   860 		foreach ($check_exts as $dll)
   861 		{
   862 			if (!@extension_loaded($dll))
   863 			{
   864 				if (!can_load_dll($dll))
   865 				{
   866 					continue;
   867 				}
   868 
   869 				$load_extensions[] = $dll . '.' . PHP_SHLIB_SUFFIX;
   870 			}
   871 		}
   872 
   873 		// Create a lock file to indicate that there is an install in progress
   874 		$fp = @fopen($phpbb_root_path . 'cache/install_lock', 'wb');
   875 		if ($fp === false)
   876 		{
   877 			// We were unable to create the lock file - abort
   878 			$this->p_master->error($lang['UNABLE_WRITE_LOCK'], __LINE__, __FILE__);
   879 		}
   880 		@fclose($fp);
   881 
   882 		@chmod($phpbb_root_path . 'cache/install_lock', 0777);
   883 
   884 		$load_extensions = implode(',', $load_extensions);
   885 
   886 		// Time to convert the data provided into a config file
   887 		$config_data = "<?php\n";
   888 		$config_data .= "// phpBB 3.0.x auto-generated configuration file\n// Do not change anything in this file!\n";
   889 
   890 		$config_data_array = array(
   891 			'dbms'			=> $available_dbms[$data['dbms']]['DRIVER'],
   892 			'dbhost'		=> $data['dbhost'],
   893 			'dbport'		=> $data['dbport'],
   894 			'dbname'		=> $data['dbname'],
   895 			'dbuser'		=> $data['dbuser'],
   896 			'dbpasswd'		=> htmlspecialchars_decode($data['dbpasswd']),
   897 			'table_prefix'	=> $data['table_prefix'],
   898 			'acm_type'		=> 'file',
   899 			'load_extensions'	=> $load_extensions,
   900 		);
   901 
   902 		foreach ($config_data_array as $key => $value)
   903 		{
   904 			$config_data .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n";
   905 		}
   906 		unset($config_data_array);
   907 
   908 		$config_data .= "\n@define('PHPBB_INSTALLED', true);\n";
   909 		$config_data .= "// @define('DEBUG', true);\n";
   910 		$config_data .= "// @define('DEBUG_EXTRA', true);\n";
   911 		$config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused!
   912 
   913 		// Attempt to write out the config file directly. If it works, this is the easiest way to do it ...
   914 		if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) || phpbb_is_writable($phpbb_root_path))
   915 		{
   916 			// Assume it will work ... if nothing goes wrong below
   917 			$written = true;
   918 
   919 			if (!($fp = @fopen($phpbb_root_path . 'config.' . $phpEx, 'w')))
   920 			{
   921 				// Something went wrong ... so let's try another method
   922 				$written = false;
   923 			}
   924 
   925 			if (!(@fwrite($fp, $config_data)))
   926 			{
   927 				// Something went wrong ... so let's try another method
   928 				$written = false;
   929 			}
   930 
   931 			@fclose($fp);
   932 
   933 			if ($written)
   934 			{
   935 				// We may revert back to chmod() if we see problems with users not able to change their config.php file directly
   936 				phpbb_chmod($phpbb_root_path . 'config.' . $phpEx, CHMOD_READ);
   937 			}
   938 		}
   939 
   940 		if (isset($_POST['dldone']))
   941 		{
   942 			// Do a basic check to make sure that the file has been uploaded
   943 			// Note that all we check is that the file has _something_ in it
   944 			// We don't compare the contents exactly - if they can't upload
   945 			// a single file correctly, it's likely they will have other problems....
   946 			if (filesize($phpbb_root_path . 'config.' . $phpEx) > 10)
   947 			{
   948 				$written = true;
   949 			}
   950 		}
   951 
   952 		$config_options = array_merge($this->db_config_options, $this->admin_config_options);
   953 
   954 		foreach ($config_options as $config_key => $vars)
   955 		{
   956 			if (!is_array($vars))
   957 			{
   958 				continue;
   959 			}
   960 			$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
   961 		}
   962 
   963 		if (!$written)
   964 		{
   965 			// OK, so it didn't work let's try the alternatives
   966 
   967 			if (isset($_POST['dlconfig']))
   968 			{
   969 				// They want a copy of the file to download, so send the relevant headers and dump out the data
   970 				header("Content-Type: text/x-delimtext; name=\"config.$phpEx\"");
   971 				header("Content-disposition: attachment; filename=config.$phpEx");
   972 				echo $config_data;
   973 				exit;
   974 			}
   975 
   976 			// The option to download the config file is always available, so output it here
   977 			$template->assign_vars(array(
   978 				'BODY'					=> $lang['CONFIG_FILE_UNABLE_WRITE'],
   979 				'L_DL_CONFIG'			=> $lang['DL_CONFIG'],
   980 				'L_DL_CONFIG_EXPLAIN'	=> $lang['DL_CONFIG_EXPLAIN'],
   981 				'L_DL_DONE'				=> $lang['DONE'],
   982 				'L_DL_DOWNLOAD'			=> $lang['DL_DOWNLOAD'],
   983 				'S_HIDDEN'				=> $s_hidden_fields,
   984 				'S_SHOW_DOWNLOAD'		=> true,
   985 				'U_ACTION'				=> $this->p_master->module_url . "?mode=$mode&amp;sub=config_file",
   986 			));
   987 			return;
   988 		}
   989 		else
   990 		{
   991 			$template->assign_vars(array(
   992 				'BODY'		=> $lang['CONFIG_FILE_WRITTEN'],
   993 				'L_SUBMIT'	=> $lang['NEXT_STEP'],
   994 				'S_HIDDEN'	=> $s_hidden_fields,
   995 				'U_ACTION'	=> $this->p_master->module_url . "?mode=$mode&amp;sub=advanced",
   996 			));
   997 			return;
   998 		}
   999 	}
  1000 
  1001 	/**
  1002 	* Provide an opportunity to customise some advanced settings during the install
  1003 	* in case it is necessary for them to be set to access later
  1004 	*/
  1005 	function obtain_advanced_settings($mode, $sub)
  1006 	{
  1007 		global $lang, $template, $phpEx;
  1008 
  1009 		$this->page_title = $lang['STAGE_ADVANCED'];
  1010 
  1011 		// Obtain any submitted data
  1012 		$data = $this->get_submitted_data();
  1013 
  1014 		if ($data['dbms'] == '')
  1015 		{
  1016 			// Someone's been silly and tried calling this page direct
  1017 			// So we send them back to the start to do it again properly
  1018 			$this->p_master->redirect("index.$phpEx?mode=install");
  1019 		}
  1020 
  1021 		$s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
  1022 		$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
  1023 
  1024 		// HTTP_HOST is having the correct browser url in most cases...
  1025 		$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
  1026 
  1027 		// HTTP HOST can carry a port number...
  1028 		if (strpos($server_name, ':') !== false)
  1029 		{
  1030 			$server_name = substr($server_name, 0, strpos($server_name, ':'));
  1031 		}
  1032 
  1033 		$data['email_enable'] = ($data['email_enable'] !== '') ? $data['email_enable'] : true;
  1034 		$data['server_name'] = ($data['server_name'] !== '') ? $data['server_name'] : $server_name;
  1035 		$data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : ((!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'));
  1036 		$data['server_protocol'] = ($data['server_protocol'] !== '') ? $data['server_protocol'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://');
  1037 		$data['cookie_secure'] = ($data['cookie_secure'] !== '') ? $data['cookie_secure'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false);
  1038 
  1039 		if ($data['script_path'] === '')
  1040 		{
  1041 			$name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
  1042 			if (!$name)
  1043 			{
  1044 				$name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
  1045 			}
  1046 
  1047 			// Replace backslashes and doubled slashes (could happen on some proxy setups)
  1048 			$name = str_replace(array('\\', '//', '/install'), '/', $name);
  1049 			$data['script_path'] = trim(dirname($name));
  1050 		}
  1051 
  1052 		foreach ($this->advanced_config_options as $config_key => $vars)
  1053 		{
  1054 			if (!is_array($vars) && strpos($config_key, 'legend') === false)
  1055 			{
  1056 				continue;
  1057 			}
  1058 
  1059 			if (strpos($config_key, 'legend') !== false)
  1060 			{
  1061 				$template->assign_block_vars('options', array(
  1062 					'S_LEGEND'		=> true,
  1063 					'LEGEND'		=> $lang[$vars])
  1064 				);
  1065 
  1066 				continue;
  1067 			}
  1068 
  1069 			$options = isset($vars['options']) ? $vars['options'] : '';
  1070 
  1071 			$template->assign_block_vars('options', array(
  1072 				'KEY'			=> $config_key,
  1073 				'TITLE'			=> $lang[$vars['lang']],
  1074 				'S_EXPLAIN'		=> $vars['explain'],
  1075 				'S_LEGEND'		=> false,
  1076 				'TITLE_EXPLAIN'	=> ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '',
  1077 				'CONTENT'		=> $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options),
  1078 				)
  1079 			);
  1080 		}
  1081 
  1082 		$config_options = array_merge($this->db_config_options, $this->admin_config_options);
  1083 		foreach ($config_options as $config_key => $vars)
  1084 		{
  1085 			if (!is_array($vars))
  1086 			{
  1087 				continue;
  1088 			}
  1089 			$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
  1090 		}
  1091 
  1092 		$submit = $lang['NEXT_STEP'];
  1093 
  1094 		$url = $this->p_master->module_url . "?mode=$mode&amp;sub=create_table";
  1095 
  1096 		$template->assign_vars(array(
  1097 			'BODY'		=> $lang['STAGE_ADVANCED_EXPLAIN'],
  1098 			'L_SUBMIT'	=> $submit,
  1099 			'S_HIDDEN'	=> $s_hidden_fields,
  1100 			'U_ACTION'	=> $url,
  1101 		));
  1102 	}
  1103 
  1104 	/**
  1105 	* Load the contents of the schema into the database and then alter it based on what has been input during the installation
  1106 	*/
  1107 	function load_schema($mode, $sub)
  1108 	{
  1109 		global $db, $lang, $template, $phpbb_root_path, $phpEx;
  1110 
  1111 		$this->page_title = $lang['STAGE_CREATE_TABLE'];
  1112 		$s_hidden_fields = '';
  1113 
  1114 		// Obtain any submitted data
  1115 		$data = $this->get_submitted_data();
  1116 
  1117 		if ($data['dbms'] == '')
  1118 		{
  1119 			// Someone's been silly and tried calling this page direct
  1120 			// So we send them back to the start to do it again properly
  1121 			$this->p_master->redirect("index.$phpEx?mode=install");
  1122 		}
  1123 
  1124 		// HTTP_HOST is having the correct browser url in most cases...
  1125 		$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
  1126 		$referer = (!empty($_SERVER['HTTP_REFERER'])) ? strtolower($_SERVER['HTTP_REFERER']) : getenv('HTTP_REFERER');
  1127 
  1128 		// HTTP HOST can carry a port number...
  1129 		if (strpos($server_name, ':') !== false)
  1130 		{
  1131 			$server_name = substr($server_name, 0, strpos($server_name, ':'));
  1132 		}
  1133 
  1134 		$cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : $server_name;
  1135 
  1136 		// Try to come up with the best solution for cookie domain...
  1137 		if (strpos($cookie_domain, 'www.') === 0)
  1138 		{
  1139 			$cookie_domain = str_replace('www.', '.', $cookie_domain);
  1140 		}
  1141 
  1142 		// If we get here and the extension isn't loaded it should be safe to just go ahead and load it
  1143 		$available_dbms = get_available_dbms($data['dbms']);
  1144 
  1145 		if (!isset($available_dbms[$data['dbms']]))
  1146 		{
  1147 			// Someone's been silly and tried providing a non-existant dbms
  1148 			$this->p_master->redirect("index.$phpEx?mode=install");
  1149 		}
  1150 
  1151 		$dbms = $available_dbms[$data['dbms']]['DRIVER'];
  1152 
  1153 		// Load the appropriate database class if not already loaded
  1154 		include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
  1155 
  1156 		// Instantiate the database
  1157 		$db = new $sql_db();
  1158 		$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
  1159 
  1160 		// NOTE: trigger_error does not work here.
  1161 		$db->sql_return_on_error(true);
  1162 
  1163 		// If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;)
  1164 		if ($data['dbms'] == 'mysql')
  1165 		{
  1166 			if (version_compare($db->sql_server_info(true), '4.1.3', '>='))
  1167 			{
  1168 				$available_dbms[$data['dbms']]['SCHEMA'] .= '_41';
  1169 			}
  1170 			else
  1171 			{
  1172 				$available_dbms[$data['dbms']]['SCHEMA'] .= '_40';
  1173 			}
  1174 		}
  1175 
  1176 		// Ok we have the db info go ahead and read in the relevant schema
  1177 		// and work on building the table
  1178 		$dbms_schema = 'schemas/' . $available_dbms[$data['dbms']]['SCHEMA'] . '_schema.sql';
  1179 
  1180 		// How should we treat this schema?
  1181 		$remove_remarks = $available_dbms[$data['dbms']]['COMMENTS'];
  1182 		$delimiter = $available_dbms[$data['dbms']]['DELIM'];
  1183 
  1184 		$sql_query = @file_get_contents($dbms_schema);
  1185 
  1186 		$sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query);
  1187 
  1188 		$remove_remarks($sql_query);
  1189 
  1190 		$sql_query = split_sql_file($sql_query, $delimiter);
  1191 
  1192 		foreach ($sql_query as $sql)
  1193 		{
  1194 			//$sql = trim(str_replace('|', ';', $sql));
  1195 			if (!$db->sql_query($sql))
  1196 			{
  1197 				$error = $db->sql_error();
  1198 				$this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
  1199 			}
  1200 		}
  1201 		unset($sql_query);
  1202 
  1203 		// Ok tables have been built, let's fill in the basic information
  1204 		$sql_query = file_get_contents('schemas/schema_data.sql');
  1205 
  1206 		// Deal with any special comments
  1207 		switch ($data['dbms'])
  1208 		{
  1209 			case 'mssql':
  1210 			case 'mssql_odbc':
  1211 			case 'mssqlnative':
  1212 				$sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query);
  1213 			break;
  1214 
  1215 			case 'postgres':
  1216 				$sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query);
  1217 			break;
  1218 		}
  1219 
  1220 		// Change prefix
  1221 		$sql_query = preg_replace('# phpbb_([^\s]*) #i', ' ' . $data['table_prefix'] . '\1 ', $sql_query);
  1222 
  1223 		// Change language strings...
  1224 		$sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback', $sql_query);
  1225 
  1226 		// Since there is only one schema file we know the comment style and are able to remove it directly with remove_remarks
  1227 		remove_remarks($sql_query);
  1228 		$sql_query = split_sql_file($sql_query, ';');
  1229 
  1230 		foreach ($sql_query as $sql)
  1231 		{
  1232 			//$sql = trim(str_replace('|', ';', $sql));
  1233 			if (!$db->sql_query($sql))
  1234 			{
  1235 				$error = $db->sql_error();
  1236 				$this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
  1237 			}
  1238 		}
  1239 		unset($sql_query);
  1240 
  1241 		$current_time = time();
  1242 
  1243 		$user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
  1244 		$user_ip = (stripos($user_ip, '::ffff:') === 0) ? substr($user_ip, 7) : $user_ip;
  1245 
  1246 		if ($data['script_path'] !== '/')
  1247 		{
  1248 			// Adjust destination path (no trailing slash)
  1249 			if (substr($data['script_path'], -1) == '/')
  1250 			{
  1251 				$data['script_path'] = substr($data['script_path'], 0, -1);
  1252 			}
  1253 
  1254 			$data['script_path'] = str_replace(array('../', './'), '', $data['script_path']);
  1255 
  1256 			if ($data['script_path'][0] != '/')
  1257 			{
  1258 				$data['script_path'] = '/' . $data['script_path'];
  1259 			}
  1260 		}
  1261 
  1262 		// Set default config and post data, this applies to all DB's
  1263 		$sql_ary = array(
  1264 			'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value)
  1265 				VALUES ('board_startdate', '$current_time')",
  1266 
  1267 			'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value)
  1268 				VALUES ('default_lang', '" . $db->sql_escape($data['default_lang']) . "')",
  1269 
  1270 			'UPDATE ' . $data['table_prefix'] . "config
  1271 				SET config_value = '" . $db->sql_escape($data['img_imagick']) . "'
  1272 				WHERE config_name = 'img_imagick'",
  1273 
  1274 			'UPDATE ' . $data['table_prefix'] . "config
  1275 				SET config_value = '" . $db->sql_escape($data['server_name']) . "'
  1276 				WHERE config_name = 'server_name'",
  1277 
  1278 			'UPDATE ' . $data['table_prefix'] . "config
  1279 				SET config_value = '" . $db->sql_escape($data['server_port']) . "'
  1280 				WHERE config_name = 'server_port'",
  1281 
  1282 			'UPDATE ' . $data['table_prefix'] . "config
  1283 				SET config_value = '" . $db->sql_escape($data['board_email1']) . "'
  1284 				WHERE config_name = 'board_email'",
  1285 
  1286 			'UPDATE ' . $data['table_prefix'] . "config
  1287 				SET config_value = '" . $db->sql_escape($data['board_email1']) . "'
  1288 				WHERE config_name = 'board_contact'",
  1289 
  1290 			'UPDATE ' . $data['table_prefix'] . "config
  1291 				SET config_value = '" . $db->sql_escape($cookie_domain) . "'
  1292 				WHERE config_name = 'cookie_domain'",
  1293 
  1294 			'UPDATE ' . $data['table_prefix'] . "config
  1295 				SET config_value = '" . $db->sql_escape($lang['default_dateformat']) . "'
  1296 				WHERE config_name = 'default_dateformat'",
  1297 
  1298 			'UPDATE ' . $data['table_prefix'] . "config
  1299 				SET config_value = '" . $db->sql_escape($data['email_enable']) . "'
  1300 				WHERE config_name = 'email_enable'",
  1301 
  1302 			'UPDATE ' . $data['table_prefix'] . "config
  1303 				SET config_value = '" . $db->sql_escape($data['smtp_delivery']) . "'
  1304 				WHERE config_name = 'smtp_delivery'",
  1305 
  1306 			'UPDATE ' . $data['table_prefix'] . "config
  1307 				SET config_value = '" . $db->sql_escape($data['smtp_host']) . "'
  1308 				WHERE config_name = 'smtp_host'",
  1309 
  1310 			'UPDATE ' . $data['table_prefix'] . "config
  1311 				SET config_value = '" . $db->sql_escape($data['smtp_auth']) . "'
  1312 				WHERE config_name = 'smtp_auth_method'",
  1313 
  1314 			'UPDATE ' . $data['table_prefix'] . "config
  1315 				SET config_value = '" . $db->sql_escape($data['smtp_user']) . "'
  1316 				WHERE config_name = 'smtp_username'",
  1317 
  1318 			'UPDATE ' . $data['table_prefix'] . "config
  1319 				SET config_value = '" . $db->sql_escape($data['smtp_pass']) . "'
  1320 				WHERE config_name = 'smtp_password'",
  1321 
  1322 			'UPDATE ' . $data['table_prefix'] . "config
  1323 				SET config_value = '" . $db->sql_escape($data['cookie_secure']) . "'
  1324 				WHERE config_name = 'cookie_secure'",
  1325 
  1326 			'UPDATE ' . $data['table_prefix'] . "config
  1327 				SET config_value = '" . $db->sql_escape($data['force_server_vars']) . "'
  1328 				WHERE config_name = 'force_server_vars'",
  1329 
  1330 			'UPDATE ' . $data['table_prefix'] . "config
  1331 				SET config_value = '" . $db->sql_escape($data['script_path']) . "'
  1332 				WHERE config_name = 'script_path'",
  1333 
  1334 			'UPDATE ' . $data['table_prefix'] . "config
  1335 				SET config_value = '" . $db->sql_escape($data['server_protocol']) . "'
  1336 				WHERE config_name = 'server_protocol'",
  1337 
  1338 			'UPDATE ' . $data['table_prefix'] . "config
  1339 				SET config_value = '" . $db->sql_escape($data['admin_name']) . "'
  1340 				WHERE config_name = 'newest_username'",
  1341 
  1342 			'UPDATE ' . $data['table_prefix'] . "config
  1343 				SET config_value = '" . md5(mt_rand()) . "'
  1344 				WHERE config_name = 'avatar_salt'",
  1345 
  1346 			'UPDATE ' . $data['table_prefix'] . "users
  1347 				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 = " . $db->sql_escape(phpbb_email_hash($data['board_email1'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($data['admin_name'])) . "'
  1348 				WHERE username = 'Admin'",
  1349 
  1350 			'UPDATE ' . $data['table_prefix'] . "moderator_cache
  1351 				SET username = '" . $db->sql_escape($data['admin_name']) . "'
  1352 				WHERE username = 'Admin'",
  1353 
  1354 			'UPDATE ' . $data['table_prefix'] . "forums
  1355 				SET forum_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "'
  1356 				WHERE forum_last_poster_name = 'Admin'",
  1357 
  1358 			'UPDATE ' . $data['table_prefix'] . "topics
  1359 				SET topic_first_poster_name = '" . $db->sql_escape($data['admin_name']) . "', topic_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "'
  1360 				WHERE topic_first_poster_name = 'Admin'
  1361 					OR topic_last_poster_name = 'Admin'",
  1362 
  1363 			'UPDATE ' . $data['table_prefix'] . "users
  1364 				SET user_regdate = $current_time",
  1365 
  1366 			'UPDATE ' . $data['table_prefix'] . "posts
  1367 				SET post_time = $current_time, poster_ip = '" . $db->sql_escape($user_ip) . "'",
  1368 
  1369 			'UPDATE ' . $data['table_prefix'] . "topics
  1370 				SET topic_time = $current_time, topic_last_post_time = $current_time",
  1371 
  1372 			'UPDATE ' . $data['table_prefix'] . "forums
  1373 				SET forum_last_post_time = $current_time",
  1374 
  1375 			'UPDATE ' . $data['table_prefix'] . "config
  1376 				SET config_value = '" . $db->sql_escape($db->sql_server_info(true)) . "'
  1377 				WHERE config_name = 'dbms_version'",
  1378 		);
  1379 
  1380 		if (@extension_loaded('gd') || can_load_dll('gd'))
  1381 		{
  1382 			$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
  1383 				SET config_value = 'phpbb_captcha_gd'
  1384 				WHERE config_name = 'captcha_plugin'";
  1385 
  1386 			$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
  1387 				SET config_value = '1'
  1388 				WHERE config_name = 'captcha_gd'";
  1389 		}
  1390 
  1391 		$ref = substr($referer, strpos($referer, '://') + 3);
  1392 
  1393 		if (!(stripos($ref, $server_name) === 0))
  1394 		{
  1395 			$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
  1396 				SET config_value = '0'
  1397 				WHERE config_name = 'referer_validation'";
  1398 		}
  1399 
  1400 		// We set a (semi-)unique cookie name to bypass login issues related to the cookie name.
  1401 		$cookie_name = 'phpbb3_';
  1402 		$rand_str = md5(mt_rand());
  1403 		$rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35));
  1404 		$rand_str = substr($rand_str, 0, 5);
  1405 		$cookie_name .= strtolower($rand_str);
  1406 
  1407 		$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
  1408 			SET config_value = '" . $db->sql_escape($cookie_name) . "'
  1409 			WHERE config_name = 'cookie_name'";
  1410 
  1411 		foreach ($sql_ary as $sql)
  1412 		{
  1413 			//$sql = trim(str_replace('|', ';', $sql));
  1414 
  1415 			if (!$db->sql_query($sql))
  1416 			{
  1417 				$error = $db->sql_error();
  1418 				$this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
  1419 			}
  1420 		}
  1421 
  1422 		$submit = $lang['NEXT_STEP'];
  1423 
  1424 		$url = $this->p_master->module_url . "?mode=$mode&amp;sub=final";
  1425 
  1426 		$template->assign_vars(array(
  1427 			'BODY'		=> $lang['STAGE_CREATE_TABLE_EXPLAIN'],
  1428 			'L_SUBMIT'	=> $submit,
  1429 			'S_HIDDEN'	=> build_hidden_fields($data),
  1430 			'U_ACTION'	=> $url,
  1431 		));
  1432 	}
  1433 
  1434 	/**
  1435 	* Build the search index...
  1436 	*/
  1437 	function build_search_index($mode, $sub)
  1438 	{
  1439 		global $db, $lang, $phpbb_root_path, $phpEx, $config;
  1440 
  1441 		// Obtain any submitted data
  1442 		$data = $this->get_submitted_data();
  1443 		$table_prefix = $data['table_prefix'];
  1444 
  1445 		// If we get here and the extension isn't loaded it should be safe to just go ahead and load it
  1446 		$available_dbms = get_available_dbms($data['dbms']);
  1447 
  1448 		if (!isset($available_dbms[$data['dbms']]))
  1449 		{
  1450 			// Someone's been silly and tried providing a non-existant dbms
  1451 			$this->p_master->redirect("index.$phpEx?mode=install");
  1452 		}
  1453 
  1454 		$dbms = $available_dbms[$data['dbms']]['DRIVER'];
  1455 
  1456 		// Load the appropriate database class if not already loaded
  1457 		include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
  1458 
  1459 		// Instantiate the database
  1460 		$db = new $sql_db();
  1461 		$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
  1462 
  1463 		// NOTE: trigger_error does not work here.
  1464 		$db->sql_return_on_error(true);
  1465 
  1466 		include_once($phpbb_root_path . 'includes/constants.' . $phpEx);
  1467 		include_once($phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx);
  1468 
  1469 		// Fill the config array - it is needed by those functions we call
  1470 		$sql = 'SELECT *
  1471 			FROM ' . CONFIG_TABLE;
  1472 		$result = $db->sql_query($sql);
  1473 
  1474 		$config = array();
  1475 		while ($row = $db->sql_fetchrow($result))
  1476 		{
  1477 			$config[$row['config_name']] = $row['config_value'];
  1478 		}
  1479 		$db->sql_freeresult($result);
  1480 
  1481 		$error = false;
  1482 		$search = new fulltext_native($error);
  1483 
  1484 		$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
  1485 			FROM ' . POSTS_TABLE;
  1486 		$result = $db->sql_query($sql);
  1487 
  1488 		while ($row = $db->sql_fetchrow($result))
  1489 		{
  1490 			$search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
  1491 		}
  1492 		$db->sql_freeresult($result);
  1493 	}
  1494 
  1495 	/**
  1496 	* Populate the module tables
  1497 	*/
  1498 	function add_modules($mode, $sub)
  1499 	{
  1500 		global $db, $lang, $phpbb_root_path, $phpEx;
  1501 
  1502 		include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
  1503 
  1504 		$_module = new acp_modules();
  1505 		$module_classes = array('acp', 'mcp', 'ucp');
  1506 
  1507 		// Add categories
  1508 		foreach ($module_classes as $module_class)
  1509 		{
  1510 			$categories = array();
  1511 
  1512 			// Set the module class
  1513 			$_module->module_class = $module_class;
  1514 
  1515 			foreach ($this->module_categories[$module_class] as $cat_name => $subs)
  1516 			{
  1517 				$module_data = array(
  1518 					'module_basename'	=> '',
  1519 					'module_enabled'	=> 1,
  1520 					'module_display'	=> 1,
  1521 					'parent_id'			=> 0,
  1522 					'module_class'		=> $module_class,
  1523 					'module_langname'	=> $cat_name,
  1524 					'module_mode'		=> '',
  1525 					'module_auth'		=> '',
  1526 				);
  1527 
  1528 				// Add category
  1529 				$_module->update_module_data($module_data, true);
  1530 
  1531 				// Check for last sql error happened
  1532 				if ($db->sql_error_triggered)
  1533 				{
  1534 					$error = $db->sql_error($db->sql_error_sql);
  1535 					$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
  1536 				}
  1537 
  1538 				$categories[$cat_name]['id'] = (int) $module_data['module_id'];
  1539 				$categories[$cat_name]['parent_id'] = 0;
  1540 
  1541 				// Create sub-categories...
  1542 				if (is_array($subs))
  1543 				{
  1544 					foreach ($subs as $level2_name)
  1545 					{
  1546 						$module_data = array(
  1547 							'module_basename'	=> '',
  1548 							'module_enabled'	=> 1,
  1549 							'module_display'	=> 1,
  1550 							'parent_id'			=> (int) $categories[$cat_name]['id'],
  1551 							'module_class'		=> $module_class,
  1552 							'module_langname'	=> $level2_name,
  1553 							'module_mode'		=> '',
  1554 							'module_auth'		=> '',
  1555 						);
  1556 
  1557 						$_module->update_module_data($module_data, true);
  1558 
  1559 						// Check for last sql error happened
  1560 						if ($db->sql_error_triggered)
  1561 						{
  1562 							$error = $db->sql_error($db->sql_error_sql);
  1563 							$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
  1564 						}
  1565 
  1566 						$categories[$level2_name]['id'] = (int) $module_data['module_id'];
  1567 						$categories[$level2_name]['parent_id'] = (int) $categories[$cat_name]['id'];
  1568 					}
  1569 				}
  1570 			}
  1571 
  1572 			// Get the modules we want to add... returned sorted by name
  1573 			$module_info = $_module->get_module_infos('', $module_class);
  1574 
  1575 			foreach ($module_info as $module_basename => $fileinfo)
  1576 			{
  1577 				foreach ($fileinfo['modes'] as $module_mode => $row)
  1578 				{
  1579 					foreach ($row['cat'] as $cat_name)
  1580 					{
  1581 						if (!isset($categories[$cat_name]))
  1582 						{
  1583 							continue;
  1584 						}
  1585 
  1586 						$module_data = array(
  1587 							'module_basename'	=> $module_basename,
  1588 							'module_enabled'	=> 1,
  1589 							'module_display'	=> (isset($row['display'])) ? (int) $row['display'] : 1,
  1590 							'parent_id'			=> (int) $categories[$cat_name]['id'],
  1591 							'module_class'		=> $module_class,
  1592 							'module_langname'	=> $row['title'],
  1593 							'module_mode'		=> $module_mode,
  1594 							'module_auth'		=> $row['auth'],
  1595 						);
  1596 
  1597 						$_module->update_module_data($module_data, true);
  1598 
  1599 						// Check for last sql error happened
  1600 						if ($db->sql_error_triggered)
  1601 						{
  1602 							$error = $db->sql_error($db->sql_error_sql);
  1603 							$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
  1604 						}
  1605 					}
  1606 				}
  1607 			}
  1608 
  1609 			// Move some of the modules around since the code above will put them in the wrong place
  1610 			if ($module_class == 'acp')
  1611 			{
  1612 				// Move main module 4 up...
  1613 				$sql = 'SELECT *
  1614 					FROM ' . MODULES_TABLE . "
  1615 					WHERE module_basename = 'main'
  1616 						AND module_class = 'acp'
  1617 						AND module_mode = 'main'";
  1618 				$result = $db->sql_query($sql);
  1619 				$row = $db->sql_fetchrow($result);
  1620 				$db->sql_freeresult($result);
  1621 
  1622 				$_module->move_module_by($row, 'move_up', 4);
  1623 
  1624 				// Move permissions intro screen module 4 up...
  1625 				$sql = 'SELECT *
  1626 					FROM ' . MODULES_TABLE . "
  1627 					WHERE module_basename = 'permissions'
  1628 						AND module_class = 'acp'
  1629 						AND module_mode = 'intro'";
  1630 				$result = $db->sql_query($sql);
  1631 				$row = $db->sql_fetchrow($result);
  1632 				$db->sql_freeresult($result);
  1633 
  1634 				$_module->move_module_by($row, 'move_up', 4);
  1635 
  1636 				// Move manage users screen module 5 up...
  1637 				$sql = 'SELECT *
  1638 					FROM ' . MODULES_TABLE . "
  1639 					WHERE module_basename = 'users'
  1640 						AND module_class = 'acp'
  1641 						AND module_mode = 'overview'";
  1642 				$result = $db->sql_query($sql);
  1643 				$row = $db->sql_fetchrow($result);
  1644 				$db->sql_freeresult($result);
  1645 
  1646 				$_module->move_module_by($row, 'move_up', 5);
  1647 			}
  1648 
  1649 			if ($module_class == 'ucp')
  1650 			{
  1651 				// Move attachment module 4 down...
  1652 				$sql = 'SELECT *
  1653 					FROM ' . MODULES_TABLE . "
  1654 					WHERE module_basename = 'attachments'
  1655 						AND module_class = 'ucp'
  1656 						AND module_mode = 'attachments'";
  1657 				$result = $db->sql_query($sql);
  1658 				$row = $db->sql_fetchrow($result);
  1659 				$db->sql_freeresult($result);
  1660 
  1661 				$_module->move_module_by($row, 'move_down', 4);
  1662 			}
  1663 
  1664 			// And now for the special ones
  1665 			// (these are modules which appear in multiple categories and thus get added manually to some for more control)
  1666 			if (isset($this->module_extras[$module_class]))
  1667 			{
  1668 				foreach ($this->module_extras[$module_class] as $cat_name => $mods)
  1669 				{
  1670 					$sql = 'SELECT module_id, left_id, right_id
  1671 						FROM ' . MODULES_TABLE . "
  1672 						WHERE module_langname = '" . $db->sql_escape($cat_name) . "'
  1673 							AND module_class = '" . $db->sql_escape($module_class) . "'";
  1674 					$result = $db->sql_query_limit($sql, 1);
  1675 					$row2 = $db->sql_fetchrow($result);
  1676 					$db->sql_freeresult($result);
  1677 
  1678 					foreach ($mods as $mod_name)
  1679 					{
  1680 						$sql = 'SELECT *
  1681 							FROM ' . MODULES_TABLE . "
  1682 							WHERE module_langname = '" . $db->sql_escape($mod_name) . "'
  1683 								AND module_class = '" . $db->sql_escape($module_class) . "'
  1684 								AND module_basename <> ''";
  1685 						$result = $db->sql_query_limit($sql, 1);
  1686 						$row = $db->sql_fetchrow($result);
  1687 						$db->sql_freeresult($result);
  1688 
  1689 						$module_data = array(
  1690 							'module_basename'	=> $row['module_basename'],
  1691 							'module_enabled'	=> (int) $row['module_enabled'],
  1692 							'module_display'	=> (int) $row['module_display'],
  1693 							'parent_id'			=> (int) $row2['module_id'],
  1694 							'module_class'		=> $row['module_class'],
  1695 							'module_langname'	=> $row['module_langname'],
  1696 							'module_mode'		=> $row['module_mode'],
  1697 							'module_auth'		=> $row['module_auth'],
  1698 						);
  1699 
  1700 						$_module->update_module_data($module_data, true);
  1701 
  1702 						// Check for last sql error happened
  1703 						if ($db->sql_error_triggered)
  1704 						{
  1705 							$error = $db->sql_error($db->sql_error_sql);
  1706 							$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
  1707 						}
  1708 					}
  1709 				}
  1710 			}
  1711 
  1712 			$_module->remove_cache_file();
  1713 		}
  1714 	}
  1715 
  1716 	/**
  1717 	* Populate the language tables
  1718 	*/
  1719 	function add_language($mode, $sub)
  1720 	{
  1721 		global $db, $lang, $phpbb_root_path, $phpEx;
  1722 
  1723 		$dir = @opendir($phpbb_root_path . 'language');
  1724 
  1725 		if (!$dir)
  1726 		{
  1727 			$this->error('Unable to access the language directory', __LINE__, __FILE__);
  1728 		}
  1729 
  1730 		while (($file = readdir($dir)) !== false)
  1731 		{
  1732 			$path = $phpbb_root_path . 'language/' . $file;
  1733 
  1734 			if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS')
  1735 			{
  1736 				continue;
  1737 			}
  1738 
  1739 			if (is_dir($path) && file_exists($path . '/iso.txt'))
  1740 			{
  1741 				$lang_file = file("$path/iso.txt");
  1742 
  1743 				$lang_pack = array(
  1744 					'lang_iso'			=> basename($path),
  1745 					'lang_dir'			=> basename($path),
  1746 					'lang_english_name'	=> trim(htmlspecialchars($lang_file[0])),
  1747 					'lang_local_name'	=> trim(htmlspecialchars($lang_file[1], ENT_COMPAT, 'UTF-8')),
  1748 					'lang_author'		=> trim(htmlspecialchars($lang_file[2], ENT_COMPAT, 'UTF-8')),
  1749 				);
  1750 
  1751 				$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $lang_pack));
  1752 
  1753 				if ($db->sql_error_triggered)
  1754 				{
  1755 					$error = $db->sql_error($db->sql_error_sql);
  1756 					$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
  1757 				}
  1758 
  1759 				$valid_localized = array(
  1760 					'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',
  1761 				);
  1762 
  1763 				$sql_ary = array();
  1764 
  1765 				$sql = 'SELECT *
  1766 					FROM ' . STYLES_IMAGESET_TABLE;
  1767 				$result = $db->sql_query($sql);
  1768 
  1769 				while ($imageset_row = $db->sql_fetchrow($result))
  1770 				{
  1771 					if (@file_exists("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['lang_iso']}/imageset.cfg"))
  1772 					{
  1773 						$cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['lang_iso']}/imageset.cfg");
  1774 						foreach ($cfg_data_imageset_data as $image_name => $value)
  1775 						{
  1776 							if (strpos($value, '*') !== false)
  1777 							{
  1778 								if (substr($value, -1, 1) === '*')
  1779 								{
  1780 									list($image_filename, $image_height) = explode('*', $value);
  1781 									$image_width = 0;
  1782 								}
  1783 								else
  1784 								{
  1785 									list($image_filename, $image_height, $image_width) = explode('*', $value);
  1786 								}
  1787 							}
  1788 							else
  1789 							{
  1790 								$image_filename = $value;
  1791 								$image_height = $image_width = 0;
  1792 							}
  1793 
  1794 							if (strpos($image_name, 'img_') === 0 && $image_filename)
  1795 							{
  1796 								$image_name = substr($image_name, 4);
  1797 								if (in_array($image_name, $valid_localized))
  1798 								{
  1799 									$sql_ary[] = array(
  1800 										'image_name'		=> (string) $image_name,
  1801 										'image_filename'	=> (string) $image_filename,
  1802 										'image_height'		=> (int) $image_height,
  1803 										'image_width'		=> (int) $image_width,
  1804 										'imageset_id'		=> (int) $imageset_row['imageset_id'],
  1805 										'image_lang'		=> (string) $lang_pack['lang_iso'],
  1806 									);
  1807 								}
  1808 							}
  1809 						}
  1810 					}
  1811 				}
  1812 				$db->sql_freeresult($result);
  1813 
  1814 				if (sizeof($sql_ary))
  1815 				{
  1816 					$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
  1817 
  1818 					if ($db->sql_error_triggered)
  1819 					{
  1820 						$error = $db->sql_error($db->sql_error_sql);
  1821 						$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
  1822 					}
  1823 				}
  1824 			}
  1825 		}
  1826 		closedir($dir);
  1827 	}
  1828 
  1829 	/**
  1830 	* Add search robots to the database
  1831 	*/
  1832 	function add_bots($mode, $sub)
  1833 	{
  1834 		global $db, $lang, $phpbb_root_path, $phpEx, $config;
  1835 
  1836 		// Obtain any submitted data
  1837 		$data = $this->get_submitted_data();
  1838 
  1839 		// Fill the config array - it is needed by those functions we call
  1840 		$sql = 'SELECT *
  1841 			FROM ' . CONFIG_TABLE;
  1842 		$result = $db->sql_query($sql);
  1843 
  1844 		$config = array();
  1845 		while ($row = $db->sql_fetchrow($result))
  1846 		{
  1847 			$config[$row['config_name']] = $row['config_value'];
  1848 		}
  1849 		$db->sql_freeresult($result);
  1850 
  1851 		$sql = 'SELECT group_id
  1852 			FROM ' . GROUPS_TABLE . "
  1853 			WHERE group_name = 'BOTS'";
  1854 		$result = $db->sql_query($sql);
  1855 		$group_id = (int) $db->sql_fetchfield('group_id');
  1856 		$db->sql_freeresult($result);
  1857 
  1858 		if (!$group_id)
  1859 		{
  1860 			// If we reach this point then something has gone very wrong
  1861 			$this->p_master->error($lang['NO_GROUP'], __LINE__, __FILE__);
  1862 		}
  1863 
  1864 		if (!function_exists('user_add'))
  1865 		{
  1866 			include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
  1867 		}
  1868 
  1869 		foreach ($this->bot_list as $bot_name => $bot_ary)
  1870 		{
  1871 			$user_row = array(
  1872 				'user_type'				=> USER_IGNORE,
  1873 				'group_id'				=> $group_id,
  1874 				'username'				=> $bot_name,
  1875 				'user_regdate'			=> time(),
  1876 				'user_password'			=> '',
  1877 				'user_colour'			=> '9E8DA7',
  1878 				'user_email'			=> '',
  1879 				'user_lang'				=> $data['default_lang'],
  1880 				'user_style'			=> 1,
  1881 				'user_timezone'			=> 0,
  1882 				'user_dateformat'		=> $lang['default_dateformat'],
  1883 				'user_allow_massemail'	=> 0,
  1884 			);
  1885 
  1886 			$user_id = user_add($user_row);
  1887 
  1888 			if (!$user_id)
  1889 			{
  1890 				// If we can't insert this user then continue to the next one to avoid inconsistent data
  1891 				$this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__, true);
  1892 				continue;
  1893 			}
  1894 
  1895 			$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
  1896 				'bot_active'	=> 1,
  1897 				'bot_name'		=> (string) $bot_name,
  1898 				'user_id'		=> (int) $user_id,
  1899 				'bot_agent'		=> (string) $bot_ary[0],
  1900 				'bot_ip'		=> (string) $bot_ary[1],
  1901 			));
  1902 
  1903 			$result = $db->sql_query($sql);
  1904 		}
  1905 	}
  1906 
  1907 	/**
  1908 	* Sends an email to the board administrator with their password and some useful links
  1909 	*/
  1910 	function email_admin($mode, $sub)
  1911 	{
  1912 		global $auth, $config, $db, $lang, $template, $user, $phpbb_root_path, $phpEx;
  1913 
  1914 		$this->page_title = $lang['STAGE_FINAL'];
  1915 
  1916 		// Obtain any submitted data
  1917 		$data = $this->get_submitted_data();
  1918 
  1919 		$sql = 'SELECT *
  1920 			FROM ' . CONFIG_TABLE;
  1921 		$result = $db->sql_query($sql);
  1922 
  1923 		$config = array();
  1924 		while ($row = $db->sql_fetchrow($result))
  1925 		{
  1926 			$config[$row['config_name']] = $row['config_value'];
  1927 		}
  1928 		$db->sql_freeresult($result);
  1929 
  1930 		$user->session_begin();
  1931 		$auth->login($data['admin_name'], $data['admin_pass1'], false, true, true);
  1932 
  1933 		// OK, Now that we've reached this point we can be confident that everything
  1934 		// is installed and working......I hope :)
  1935 		// So it's time to send an email to the administrator confirming the details
  1936 		// they entered
  1937 
  1938 		if ($config['email_enable'])
  1939 		{
  1940 			include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
  1941 
  1942 			$messenger = new messenger(false);
  1943 
  1944 			$messenger->template('installed', $data['language']);
  1945 
  1946 			$messenger->to($data['board_email1'], $data['admin_name']);
  1947 
  1948 			$messenger->anti_abuse_headers($config, $user);
  1949 
  1950 			$messenger->assign_vars(array(
  1951 				'USERNAME'		=> htmlspecialchars_decode($data['admin_name']),
  1952 				'PASSWORD'		=> htmlspecialchars_decode($data['admin_pass1']))
  1953 			);
  1954 
  1955 			$messenger->send(NOTIFY_EMAIL);
  1956 		}
  1957 
  1958 		// And finally, add a note to the log
  1959 		add_log('admin', 'LOG_INSTALL_INSTALLED', $config['version']);
  1960 
  1961 		$template->assign_vars(array(
  1962 			'TITLE'		=> $lang['INSTALL_CONGRATS'],
  1963 			'BODY'		=> sprintf($lang['INSTALL_CONGRATS_EXPLAIN'], $config['version'], append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=convert&amp;language=' . $data['language']), '../docs/README.html'),
  1964 			'L_SUBMIT'	=> $lang['INSTALL_LOGIN'],
  1965 			'U_ACTION'	=> append_sid($phpbb_root_path . 'adm/index.' . $phpEx, 'i=send_statistics&amp;mode=send_statistics'),
  1966 		));
  1967 	}
  1968 
  1969 	/**
  1970 	* Generate a list of available mail server authentication methods
  1971 	*/
  1972 	function mail_auth_select($selected_method)
  1973 	{
  1974 		global $lang;
  1975 
  1976 		$auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
  1977 		$s_smtp_auth_options = '';
  1978 
  1979 		foreach ($auth_methods as $method)
  1980 		{
  1981 			$s_smtp_auth_options .= '<option value="' . $method . '"' . (($selected_method == $method) ? ' selected="selected"' : '') . '>' . $lang['SMTP_' . str_replace('-', '_', $method)] . '</option>';
  1982 		}
  1983 
  1984 		return $s_smtp_auth_options;
  1985 	}
  1986 
  1987 	/**
  1988 	* Get submitted data
  1989 	*/
  1990 	function get_submitted_data()
  1991 	{
  1992 		return array(
  1993 			'language'		=> basename(request_var('language', '')),
  1994 			'dbms'			=> request_var('dbms', ''),
  1995 			'dbhost'		=> request_var('dbhost', ''),
  1996 			'dbport'		=> request_var('dbport', ''),
  1997 			'dbuser'		=> request_var('dbuser', ''),
  1998 			'dbpasswd'		=> request_var('dbpasswd', '', true),
  1999 			'dbname'		=> request_var('dbname', ''),
  2000 			'table_prefix'	=> request_var('table_prefix', ''),
  2001 			'default_lang'	=> basename(request_var('default_lang', '')),
  2002 			'admin_name'	=> utf8_normalize_nfc(request_var('admin_name', '', true)),
  2003 			'admin_pass1'	=> request_var('admin_pass1', '', true),
  2004 			'admin_pass2'	=> request_var('admin_pass2', '', true),
  2005 			'board_email1'	=> strtolower(request_var('board_email1', '')),
  2006 			'board_email2'	=> strtolower(request_var('board_email2', '')),
  2007 			'img_imagick'	=> request_var('img_imagick', ''),
  2008 			'ftp_path'		=> request_var('ftp_path', ''),
  2009 			'ftp_user'		=> request_var('ftp_user', ''),
  2010 			'ftp_pass'		=> request_var('ftp_pass', ''),
  2011 			'email_enable'	=> request_var('email_enable', ''),
  2012 			'smtp_delivery'	=> request_var('smtp_delivery', ''),
  2013 			'smtp_host'		=> request_var('smtp_host', ''),
  2014 			'smtp_auth'		=> request_var('smtp_auth', ''),
  2015 			'smtp_user'		=> request_var('smtp_user', ''),
  2016 			'smtp_pass'		=> request_var('smtp_pass', ''),
  2017 			'cookie_secure'	=> request_var('cookie_secure', ''),
  2018 			'force_server_vars'	=> request_var('force_server_vars', ''),
  2019 			'server_protocol'	=> request_var('server_protocol', ''),
  2020 			'server_name'	=> request_var('server_name', ''),
  2021 			'server_port'	=> request_var('server_port', ''),
  2022 			'script_path'	=> request_var('script_path', ''),
  2023 		);
  2024 	}
  2025 
  2026 	/**
  2027 	* The information below will be used to build the input fields presented to the user
  2028 	*/
  2029 	var $db_config_options = array(
  2030 		'legend1'				=> 'DB_CONFIG',
  2031 		'dbms'					=> array('lang' => 'DBMS',			'type' => 'select', 'options' => 'dbms_select(\'{VALUE}\')', 'explain' => false),
  2032 		'dbhost'				=> array('lang' => 'DB_HOST',		'type' => 'text:25:100', 'explain' => true),
  2033 		'dbport'				=> array('lang' => 'DB_PORT',		'type' => 'text:25:100', 'explain' => true),
  2034 		'dbname'				=> array('lang' => 'DB_NAME',		'type' => 'text:25:100', 'explain' => false),
  2035 		'dbuser'				=> array('lang' => 'DB_USERNAME',	'type' => 'text:25:100', 'explain' => false),
  2036 		'dbpasswd'				=> array('lang' => 'DB_PASSWORD',	'type' => 'password:25:100', 'explain' => false),
  2037 		'table_prefix'			=> array('lang' => 'TABLE_PREFIX',	'type' => 'text:25:100', 'explain' => true),
  2038 	);
  2039 	var $admin_config_options = array(
  2040 		'legend1'				=> 'ADMIN_CONFIG',
  2041 		'default_lang'			=> array('lang' => 'DEFAULT_LANG',				'type' => 'select', 'options' => '$this->module->inst_language_select(\'{VALUE}\')', 'explain' => false),
  2042 		'admin_name'			=> array('lang' => 'ADMIN_USERNAME',			'type' => 'text:25:100', 'explain' => true),
  2043 		'admin_pass1'			=> array('lang' => 'ADMIN_PASSWORD',			'type' => 'password:25:100', 'explain' => true),
  2044 		'admin_pass2'			=> array('lang' => 'ADMIN_PASSWORD_CONFIRM',	'type' => 'password:25:100', 'explain' => false),
  2045 		'board_email1'			=> array('lang' => 'CONTACT_EMAIL',				'type' => 'text:25:100', 'explain' => false),
  2046 		'board_email2'			=> array('lang' => 'CONTACT_EMAIL_CONFIRM',		'type' => 'text:25:100', 'explain' => false),
  2047 	);
  2048 	var $advanced_config_options = array(
  2049 		'legend1'				=> 'ACP_EMAIL_SETTINGS',
  2050 		'email_enable'			=> array('lang' => 'ENABLE_EMAIL',		'type' => 'radio:enabled_disabled', 'explain' => true),
  2051 		'smtp_delivery'			=> array('lang' => 'USE_SMTP',			'type' => 'radio:yes_no', 'explain' => true),
  2052 		'smtp_host'				=> array('lang' => 'SMTP_SERVER',		'type' => 'text:25:50', 'explain' => false),
  2053 		'smtp_auth'				=> array('lang' => 'SMTP_AUTH_METHOD',	'type' => 'select', 'options' => '$this->module->mail_auth_select(\'{VALUE}\')', 'explain' => true),
  2054 		'smtp_user'				=> array('lang' => 'SMTP_USERNAME',		'type' => 'text:25:255', 'explain' => true),
  2055 		'smtp_pass'				=> array('lang' => 'SMTP_PASSWORD',		'type' => 'password:25:255', 'explain' => true),
  2056 
  2057 		'legend2'				=> 'SERVER_URL_SETTINGS',
  2058 		'cookie_secure'			=> array('lang' => 'COOKIE_SECURE',		'type' => 'radio:enabled_disabled', 'explain' => true),
  2059 		'force_server_vars'		=> array('lang' => 'FORCE_SERVER_VARS',	'type' => 'radio:yes_no', 'explain' => true),
  2060 		'server_protocol'		=> array('lang' => 'SERVER_PROTOCOL',	'type' => 'text:10:10', 'explain' => true),
  2061 		'server_name'			=> array('lang' => 'SERVER_NAME',		'type' => 'text:40:255', 'explain' => true),
  2062 		'server_port'			=> array('lang' => 'SERVER_PORT',		'type' => 'text:5:5', 'explain' => true),
  2063 		'script_path'			=> array('lang' => 'SCRIPT_PATH',		'type' => 'text::255', 'explain' => true),
  2064 	);
  2065 
  2066 	/**
  2067 	* Specific PHP modules we may require for certain optional or extended features
  2068 	*/
  2069 	var $php_dlls_other = array('zlib', 'ftp', 'gd', 'xml');
  2070 
  2071 	/**
  2072 	* A list of the web-crawlers/bots we recognise by default
  2073 	*
  2074 	* Candidates but not included:
  2075 	* 'Accoona [Bot]'				'Accoona-AI-Agent/'
  2076 	* 'ASPseek [Crawler]'			'ASPseek/'
  2077 	* 'Boitho [Crawler]'			'boitho.com-dc/'
  2078 	* 'Bunnybot [Bot]'				'powered by www.buncat.de'
  2079 	* 'Cosmix [Bot]'				'cfetch/'
  2080 	* 'Crawler Search [Crawler]'	'.Crawler-Search.de'
  2081 	* 'Findexa [Crawler]'			'Findexa Crawler ('
  2082 	* 'GBSpider [Spider]'			'GBSpider v'
  2083 	* 'genie [Bot]'					'genieBot ('
  2084 	* 'Hogsearch [Bot]'				'oegp v. 1.3.0'
  2085 	* 'Insuranco [Bot]'				'InsurancoBot'
  2086 	* 'IRLbot [Bot]'				'http://irl.cs.tamu.edu/crawler'
  2087 	* 'ISC Systems [Bot]'			'ISC Systems iRc Search'
  2088 	* 'Jyxobot [Bot]'				'Jyxobot/'
  2089 	* 'Kraehe [Metasuche]'			'-DIE-KRAEHE- META-SEARCH-ENGINE/'
  2090 	* 'LinkWalker'					'LinkWalker'
  2091 	* 'MMSBot [Bot]'				'http://www.mmsweb.at/bot.html'
  2092 	* 'Naver [Bot]'					'nhnbot@naver.com)'
  2093 	* 'NetResearchServer'			'NetResearchServer/'
  2094 	* 'Nimble [Crawler]'			'NimbleCrawler'
  2095 	* 'Ocelli [Bot]'				'Ocelli/'
  2096 	* 'Onsearch [Bot]'				'onCHECK-Robot'
  2097 	* 'Orange [Spider]'				'OrangeSpider'
  2098 	* 'Sproose [Bot]'				'http://www.sproose.com/bot'
  2099 	* 'Susie [Sync]'				'!Susie (http://www.sync2it.com/susie)'
  2100 	* 'Tbot [Bot]'					'Tbot/'
  2101 	* 'Thumbshots [Capture]'		'thumbshots-de-Bot'
  2102 	* 'Vagabondo [Crawler]'			'http://webagent.wise-guys.nl/'
  2103 	* 'Walhello [Bot]'				'appie 1.1 (www.walhello.com)'
  2104 	* 'WissenOnline [Bot]'			'WissenOnline-Bot'
  2105 	* 'WWWeasel [Bot]'				'WWWeasel Robot v'
  2106 	* 'Xaldon [Spider]'				'Xaldon WebSpider'
  2107 	*/
  2108 	var $bot_list = array(
  2109 		'AdsBot [Google]'			=> array('AdsBot-Google', ''),
  2110 		'Alexa [Bot]'				=> array('ia_archiver', ''),
  2111 		'Alta Vista [Bot]'			=> array('Scooter/', ''),
  2112 		'Ask Jeeves [Bot]'			=> array('Ask Jeeves', ''),
  2113 		'Baidu [Spider]'			=> array('Baiduspider+(', ''),
  2114 		'Bing [Bot]'                => array('bingbot/', ''),
  2115 		'Exabot [Bot]'				=> array('Exabot/', ''),
  2116 		'FAST Enterprise [Crawler]'	=> array('FAST Enterprise Crawler', ''),
  2117 		'FAST WebCrawler [Crawler]'	=> array('FAST-WebCrawler/', ''),
  2118 		'Francis [Bot]'				=> array('http://www.neomo.de/', ''),
  2119 		'Gigabot [Bot]'				=> array('Gigabot/', ''),
  2120 		'Google Adsense [Bot]'		=> array('Mediapartners-Google', ''),
  2121 		'Google Desktop'			=> array('Google Desktop', ''),
  2122 		'Google Feedfetcher'		=> array('Feedfetcher-Google', ''),
  2123 		'Google [Bot]'				=> array('Googlebot', ''),
  2124 		'Heise IT-Markt [Crawler]'	=> array('heise-IT-Markt-Crawler', ''),
  2125 		'Heritrix [Crawler]'		=> array('heritrix/1.', ''),
  2126 		'IBM Research [Bot]'		=> array('ibm.com/cs/crawler', ''),
  2127 		'ICCrawler - ICjobs'		=> array('ICCrawler - ICjobs', ''),
  2128 		'ichiro [Crawler]'			=> array('ichiro/', ''),
  2129 		'Majestic-12 [Bot]'			=> array('MJ12bot/', ''),
  2130 		'Metager [Bot]'				=> array('MetagerBot/', ''),
  2131 		'MSN NewsBlogs'				=> array('msnbot-NewsBlogs/', ''),
  2132 		'MSN [Bot]'					=> array('msnbot/', ''),
  2133 		'MSNbot Media'				=> array('msnbot-media/', ''),
  2134 		'NG-Search [Bot]'			=> array('NG-Search/', ''),
  2135 		'Nutch [Bot]'				=> array('http://lucene.apache.org/nutch/', ''),
  2136 		'Nutch/CVS [Bot]'			=> array('NutchCVS/', ''),
  2137 		'OmniExplorer [Bot]'		=> array('OmniExplorer_Bot/', ''),
  2138 		'Online link [Validator]'	=> array('online link validator', ''),
  2139 		'psbot [Picsearch]'			=> array('psbot/0', ''),
  2140 		'Seekport [Bot]'			=> array('Seekbot/', ''),
  2141 		'Sensis [Crawler]'			=> array('Sensis Web Crawler', ''),
  2142 		'SEO Crawler'				=> array('SEO search Crawler/', ''),
  2143 		'Seoma [Crawler]'			=> array('Seoma [SEO Crawler]', ''),
  2144 		'SEOSearch [Crawler]'		=> array('SEOsearch/', ''),
  2145 		'Snappy [Bot]'				=> array('Snappy/1.1 ( http://www.urltrends.com/ )', ''),
  2146 		'Steeler [Crawler]'			=> array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''),
  2147 		'Synoo [Bot]'				=> array('SynooBot/', ''),
  2148 		'Telekom [Bot]'				=> array('crawleradmin.t-info@telekom.de', ''),
  2149 		'TurnitinBot [Bot]'			=> array('TurnitinBot/', ''),
  2150 		'Voyager [Bot]'				=> array('voyager/1.0', ''),
  2151 		'W3 [Sitesearch]'			=> array('W3 SiteSearch Crawler', ''),
  2152 		'W3C [Linkcheck]'			=> array('W3C-checklink/', ''),
  2153 		'W3C [Validator]'			=> array('W3C_*Validator', ''),
  2154 		'WiseNut [Bot]'				=> array('http://www.WISEnutbot.com', ''),
  2155 		'YaCy [Bot]'				=> array('yacybot', ''),
  2156 		'Yahoo MMCrawler [Bot]'		=> array('Yahoo-MMCrawler/', ''),
  2157 		'Yahoo Slurp [Bot]'			=> array('Yahoo! DE Slurp', ''),
  2158 		'Yahoo [Bot]'				=> array('Yahoo! Slurp', ''),
  2159 		'YahooSeeker [Bot]'			=> array('YahooSeeker/', ''),
  2160 	);
  2161 
  2162 	/**
  2163 	* Define the module structure so that we can populate the database without
  2164 	* needing to hard-code module_id values
  2165 	*/
  2166 	var $module_categories = array(
  2167 		'acp'	=> array(
  2168 			'ACP_CAT_GENERAL'		=> array(
  2169 				'ACP_QUICK_ACCESS',
  2170 				'ACP_BOARD_CONFIGURATION',
  2171 				'ACP_CLIENT_COMMUNICATION',
  2172 				'ACP_SERVER_CONFIGURATION',
  2173 			),
  2174 			'ACP_CAT_FORUMS'		=> array(
  2175 				'ACP_MANAGE_FORUMS',
  2176 				'ACP_FORUM_BASED_PERMISSIONS',
  2177 			),
  2178 			'ACP_CAT_POSTING'		=> array(
  2179 				'ACP_MESSAGES',
  2180 				'ACP_ATTACHMENTS',
  2181 			),
  2182 			'ACP_CAT_USERGROUP'		=> array(
  2183 				'ACP_CAT_USERS',
  2184 				'ACP_GROUPS',
  2185 				'ACP_USER_SECURITY',
  2186 			),
  2187 			'ACP_CAT_PERMISSIONS'	=> array(
  2188 				'ACP_GLOBAL_PERMISSIONS',
  2189 				'ACP_FORUM_BASED_PERMISSIONS',
  2190 				'ACP_PERMISSION_ROLES',
  2191 				'ACP_PERMISSION_MASKS',
  2192 			),
  2193 			'ACP_CAT_STYLES'		=> array(
  2194 				'ACP_STYLE_MANAGEMENT',
  2195 				'ACP_STYLE_COMPONENTS',
  2196 			),
  2197 			'ACP_CAT_MAINTENANCE'	=> array(
  2198 				'ACP_FORUM_LOGS',
  2199 				'ACP_CAT_DATABASE',
  2200 			),
  2201 			'ACP_CAT_SYSTEM'		=> array(
  2202 				'ACP_AUTOMATION',
  2203 				'ACP_GENERAL_TASKS',
  2204 				'ACP_MODULE_MANAGEMENT',
  2205 			),
  2206 			'ACP_CAT_DOT_MODS'		=> null,
  2207 		),
  2208 		'mcp'	=> array(
  2209 			'MCP_MAIN'		=> null,
  2210 			'MCP_QUEUE'		=> null,
  2211 			'MCP_REPORTS'	=> null,
  2212 			'MCP_NOTES'		=> null,
  2213 			'MCP_WARN'		=> null,
  2214 			'MCP_LOGS'		=> null,
  2215 			'MCP_BAN'		=> null,
  2216 		),
  2217 		'ucp'	=> array(
  2218 			'UCP_MAIN'			=> null,
  2219 			'UCP_PROFILE'		=> null,
  2220 			'UCP_PREFS'			=> null,
  2221 			'UCP_PM'			=> null,
  2222 			'UCP_USERGROUPS'	=> null,
  2223 			'UCP_ZEBRA'			=> null,
  2224 		),
  2225 	);
  2226 
  2227 	var $module_extras = array(
  2228 		'acp'	=> array(
  2229 			'ACP_QUICK_ACCESS' => array(
  2230 				'ACP_MANAGE_USERS',
  2231 				'ACP_GROUPS_MANAGE',
  2232 				'ACP_MANAGE_FORUMS',
  2233 				'ACP_MOD_LOGS',
  2234 				'ACP_BOTS',
  2235 				'ACP_PHP_INFO',
  2236 			),
  2237 			'ACP_FORUM_BASED_PERMISSIONS' => array(
  2238 				'ACP_FORUM_PERMISSIONS',
  2239 				'ACP_FORUM_PERMISSIONS_COPY',
  2240 				'ACP_FORUM_MODERATORS',
  2241 				'ACP_USERS_FORUM_PERMISSIONS',
  2242 				'ACP_GROUPS_FORUM_PERMISSIONS',
  2243 			),
  2244 		),
  2245 	);
  2246 }
  2247 
  2248 ?>