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