diff options
Diffstat (limited to 'phpBB/install/install_install.php')
| -rw-r--r-- | phpBB/install/install_install.php | 523 | 
1 files changed, 289 insertions, 234 deletions
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index cb63c70e11..5b818f9475 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package install -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -19,14 +22,9 @@ if (!defined('IN_INSTALL'))  if (!empty($setmodules))  {  	// If phpBB is already installed we do not include this module -	if (@file_exists($phpbb_root_path . 'config.' . $phpEx) && !file_exists($phpbb_root_path . 'cache/install_lock')) +	if (phpbb_check_installation_exists($phpbb_root_path, $phpEx) && !file_exists($phpbb_root_path . 'cache/install_lock'))  	{ -		include_once($phpbb_root_path . 'config.' . $phpEx); - -		if (defined('PHPBB_INSTALLED')) -		{ -			return; -		} +		return;  	}  	$module[] = array( @@ -42,7 +40,6 @@ if (!empty($setmodules))  /**  * Installation -* @package install  */  class install_install extends module  { @@ -53,12 +50,13 @@ class install_install extends module  	function main($mode, $sub)  	{ -		global $lang, $template, $language, $phpbb_root_path, $cache; +		global $lang, $template, $language, $phpbb_root_path, $phpEx; +		global $phpbb_container, $cache, $phpbb_log, $request, $phpbb_config_php_file;  		switch ($sub)  		{  			case 'intro': -				$cache->purge(); +				$phpbb_container->get('cache.driver')->purge();  				$this->page_title = $lang['SUB_INTRO']; @@ -102,12 +100,24 @@ class install_install extends module  			break;  			case 'final': +				// Enable super globals to prevent issues with the new \phpbb\request\request object +				$request->enable_super_globals(); + +				// Create a normal container now +				$phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); +				$phpbb_container = $phpbb_container_builder->get_container(); + +				// Sets the global variables +				$cache = $phpbb_container->get('cache'); +				$phpbb_log = $phpbb_container->get('log'); +  				$this->build_search_index($mode, $sub);  				$this->add_modules($mode, $sub);  				$this->add_language($mode, $sub);  				$this->add_bots($mode, $sub);  				$this->email_admin($mode, $sub);  				$this->disable_avatars_if_unwritable(); +				$this->populate_migrations($phpbb_container->get('ext.manager'), $phpbb_container->get('migrator'));  				// Remove the lock file  				@unlink($phpbb_root_path . 'cache/install_lock'); @@ -132,7 +142,7 @@ class install_install extends module  			'BODY'		=> $lang['REQUIREMENTS_EXPLAIN'],  		)); -		$passed = array('php' => false, 'db' => false, 'files' => false, 'pcre' => false, 'imagesize' => false,); +		$passed = array('php' => false, 'db' => false, 'files' => false, 'pcre' => false, 'imagesize' => false, 'json' => false,);  		// Test for basic PHP settings  		$template->assign_block_vars('checks', array( @@ -144,7 +154,7 @@ class install_install extends module  		// Test the minimum PHP version  		$php_version = PHP_VERSION; -		if (version_compare($php_version, '4.3.3') < 0) +		if (version_compare($php_version, '5.3.3') < 0)  		{  			$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';  		} @@ -211,7 +221,6 @@ class install_install extends module  			'S_LEGEND'		=> false,  		)); -  		// Check for getimagesize  		if (@function_exists('getimagesize'))  		{ @@ -252,13 +261,25 @@ class install_install extends module  			'S_LEGEND'		=> false,  		)); -/** -*		Better not enabling and adding to the loaded extensions due to the specific requirements needed -		if (!@extension_loaded('mbstring')) +		// Check for php json support +		if (@extension_loaded('json'))  		{ -			can_load_dll('mbstring'); +			$passed['json'] = true; +			$result = '<strong style="color:green">' . $lang['YES'] . '</strong>';  		} -*/ +		else +		{ +			$result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; +		} + +		$template->assign_block_vars('checks', array( +			'TITLE'			=> $lang['PHP_JSON_SUPPORT'], +			'TITLE_EXPLAIN'	=> $lang['PHP_JSON_SUPPORT_EXPLAIN'], +			'RESULT'		=> $result, + +			'S_EXPLAIN'		=> true, +			'S_LEGEND'		=> false, +		));  		$passed['mbstring'] = true;  		if (@extension_loaded('mbstring')) @@ -364,17 +385,14 @@ class install_install extends module  		{  			if (!@extension_loaded($dll))  			{ -				if (!can_load_dll($dll)) -				{ -					$template->assign_block_vars('checks', array( -						'TITLE'		=> $lang['DLL_' . strtoupper($dll)], -						'RESULT'	=> '<strong style="color:red">' . $lang['UNAVAILABLE'] . '</strong>', +				$template->assign_block_vars('checks', array( +					'TITLE'		=> $lang['DLL_' . strtoupper($dll)], +					'RESULT'	=> '<strong style="color:red">' . $lang['UNAVAILABLE'] . '</strong>', -						'S_EXPLAIN'	=> false, -						'S_LEGEND'	=> false, -					)); -					continue; -				} +					'S_EXPLAIN'	=> false, +					'S_LEGEND'	=> false, +				)); +				continue;  			}  			$template->assign_block_vars('checks', array( @@ -521,7 +539,6 @@ class install_install extends module  		$url = (!in_array(false, $passed)) ? $this->p_master->module_url . "?mode=$mode&sub=database&language=$language" : $this->p_master->module_url . "?mode=$mode&sub=requirements&language=$language	";  		$submit = (!in_array(false, $passed)) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST']; -  		$template->assign_vars(array(  			'L_SUBMIT'	=> $submit,  			'S_HIDDEN'	=> $s_hidden_fields, @@ -697,7 +714,7 @@ class install_install extends module  			$error = array();  			// Check the entered email address and password -			if ($data['admin_name'] == '' || $data['admin_pass1'] == '' || $data['admin_pass2'] == '' || $data['board_email1'] == '' || $data['board_email2'] == '') +			if ($data['admin_name'] == '' || $data['admin_pass1'] == '' || $data['admin_pass2'] == '' || $data['board_email'] == '')  			{  				$error[] = $lang['INST_ERR_MISSING_DATA'];  			} @@ -729,12 +746,7 @@ class install_install extends module  				$error[] = $lang['INST_ERR_PASSWORD_TOO_LONG'];  			} -			if ($data['board_email1'] != $data['board_email2'] && $data['board_email1'] != '') -			{ -				$error[] = $lang['INST_ERR_EMAIL_MISMATCH']; -			} - -			if ($data['board_email1'] != '' && !preg_match('/^' . get_preg_expression('email') . '$/i', $data['board_email1'])) +			if ($data['board_email'] != '' && !preg_match('/^' . get_preg_expression('email') . '$/i', $data['board_email']))  			{  				$error[] = $lang['INST_ERR_EMAIL_INVALID'];  			} @@ -860,22 +872,7 @@ class install_install extends module  		$written = false;  		// Create a list of any PHP modules we wish to have loaded -		$load_extensions = array();  		$available_dbms = get_available_dbms($data['dbms']); -		$check_exts = array_merge(array($available_dbms[$data['dbms']]['MODULE']), $this->php_dlls_other); - -		foreach ($check_exts as $dll) -		{ -			if (!@extension_loaded($dll)) -			{ -				if (!can_load_dll($dll)) -				{ -					continue; -				} - -				$load_extensions[] = $dll . '.' . PHP_SHLIB_SUFFIX; -			} -		}  		// Create a lock file to indicate that there is an install in progress  		$fp = @fopen($phpbb_root_path . 'cache/install_lock', 'wb'); @@ -889,7 +886,7 @@ class install_install extends module  		@chmod($phpbb_root_path . 'cache/install_lock', 0777);  		// Time to convert the data provided into a config file -		$config_data = phpbb_create_config_file_data($data, $available_dbms[$data['dbms']]['DRIVER'], $load_extensions); +		$config_data = phpbb_create_config_file_data($data, $available_dbms[$data['dbms']]['DRIVER']);  		// Attempt to write out the config file directly. If it works, this is the easiest way to do it ...  		if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) || phpbb_is_writable($phpbb_root_path)) @@ -985,7 +982,7 @@ class install_install extends module  	*/  	function obtain_advanced_settings($mode, $sub)  	{ -		global $lang, $template, $phpEx; +		global $lang, $template, $phpEx, $request;  		$this->page_title = $lang['STAGE_ADVANCED']; @@ -1003,7 +1000,7 @@ class install_install extends module  		$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';  		// HTTP_HOST is having the correct browser url in most cases... -		$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); +		$server_name = strtolower(htmlspecialchars_decode($request->header('Host', $request->server('SERVER_NAME'))));  		// HTTP HOST can carry a port number...  		if (strpos($server_name, ':') !== false) @@ -1013,16 +1010,16 @@ class install_install extends module  		$data['email_enable'] = ($data['email_enable'] !== '') ? $data['email_enable'] : true;  		$data['server_name'] = ($data['server_name'] !== '') ? $data['server_name'] : $server_name; -		$data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : ((!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT')); -		$data['server_protocol'] = ($data['server_protocol'] !== '') ? $data['server_protocol'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'); -		$data['cookie_secure'] = ($data['cookie_secure'] !== '') ? $data['cookie_secure'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false); +		$data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : $request->server('SERVER_PORT', 0); +		$data['server_protocol'] = ($data['server_protocol'] !== '') ? $data['server_protocol'] : ($request->is_secure() ? 'https://' : 'http://'); +		$data['cookie_secure'] = ($data['cookie_secure'] !== '') ? $data['cookie_secure'] : $request->is_secure();  		if ($data['script_path'] === '')  		{ -			$name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF'); +			$name = htmlspecialchars_decode($request->server('PHP_SELF'));  			if (!$name)  			{ -				$name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); +				$name = htmlspecialchars_decode($request->server('REQUEST_URI'));  			}  			// Replace backslashes and doubled slashes (could happen on some proxy setups) @@ -1087,7 +1084,7 @@ class install_install extends module  	*/  	function load_schema($mode, $sub)  	{ -		global $db, $lang, $template, $phpbb_root_path, $phpEx; +		global $db, $lang, $template, $phpbb_root_path, $phpEx, $request;  		$this->page_title = $lang['STAGE_CREATE_TABLE'];  		$s_hidden_fields = ''; @@ -1103,8 +1100,8 @@ class install_install extends module  		}  		// HTTP_HOST is having the correct browser url in most cases... -		$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); -		$referer = (!empty($_SERVER['HTTP_REFERER'])) ? strtolower($_SERVER['HTTP_REFERER']) : getenv('HTTP_REFERER'); +		$server_name = strtolower(htmlspecialchars_decode($request->header('Host', $request->server('SERVER_NAME')))); +		$referer = strtolower($request->header('Referer'));  		// HTTP HOST can carry a port number...  		if (strpos($server_name, ':') !== false) @@ -1131,11 +1128,8 @@ class install_install extends module  		$dbms = $available_dbms[$data['dbms']]['DRIVER']; -		// Load the appropriate database class if not already loaded -		include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); -  		// Instantiate the database -		$db = new $sql_db(); +		$db = new $dbms();  		$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);  		// NOTE: trigger_error does not work here. @@ -1161,29 +1155,71 @@ class install_install extends module  		// How should we treat this schema?  		$delimiter = $available_dbms[$data['dbms']]['DELIM']; -		$sql_query = @file_get_contents($dbms_schema); - -		$sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query); - -		$sql_query = phpbb_remove_comments($sql_query); +		if (file_exists($dbms_schema)) +		{ +			$sql_query = @file_get_contents($dbms_schema); +			$sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query); +			$sql_query = phpbb_remove_comments($sql_query); +			$sql_query = split_sql_file($sql_query, $delimiter); -		$sql_query = split_sql_file($sql_query, $delimiter); +			foreach ($sql_query as $sql) +			{ +				// Ignore errors when the functions or types already exist +				// to allow installing phpBB twice in the same database with +				// a different prefix +				$db->sql_query($sql); +			} +			unset($sql_query); +		} -		foreach ($sql_query as $sql) +		// Ok we have the db info go ahead and work on building the table +		if (file_exists('schemas/schema.json'))  		{ -			//$sql = trim(str_replace('|', ';', $sql)); -			if (!$db->sql_query($sql)) +			$db_table_schema = @file_get_contents('schemas/schema.json'); +			$db_table_schema = json_decode($db_table_schema, true); +		} +		else +		{ +			global $phpbb_root_path, $phpEx, $table_prefix; +			$table_prefix = 'phpbb_'; + +			if (!defined('CONFIG_TABLE'))  			{ -				$error = $db->sql_error(); -				$this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); +				// We need to include the constants file for the table constants +				// when we generate the schema from the migration files. +				include($phpbb_root_path . 'includes/constants.' . $phpEx);  			} + +			$finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx); +			$classes = $finder->core_path('phpbb/db/migration/data/') +				->get_classes(); + +			$sqlite_db = new \phpbb\db\driver\sqlite(); +			$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $sqlite_db, new \phpbb\db\tools($sqlite_db, true), $phpbb_root_path, $phpEx, $table_prefix); +			$db_table_schema = $schema_generator->get_schema(); +		} + +		if (!defined('CONFIG_TABLE')) +		{ +			// CONFIG_TABLE is required by sql_create_index() to check the +			// length of index names. However table_prefix is not defined +			// here yet, so we need to create the constant ourselves. +			define('CONFIG_TABLE', $data['table_prefix'] . 'config'); +		} + +		$db_tools = new \phpbb\db\tools($db); +		foreach ($db_table_schema as $table_name => $table_data) +		{ +			$db_tools->sql_create_table( +				$data['table_prefix'] . substr($table_name, 6), +				$table_data +			);  		} -		unset($sql_query);  		// Ok tables have been built, let's fill in the basic information  		$sql_query = file_get_contents('schemas/schema_data.sql'); -		// Deal with any special comments +		// Deal with any special comments and characters  		switch ($data['dbms'])  		{  			case 'mssql': @@ -1195,6 +1231,11 @@ class install_install extends module  			case 'postgres':  				$sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query);  			break; + +			case 'mysql': +			case 'mysqli': +				$sql_query = str_replace('\\', '\\\\', $sql_query); +			break;  		}  		// Change prefix @@ -1219,8 +1260,7 @@ class install_install extends module  		$current_time = time(); -		$user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; -		$user_ip = (stripos($user_ip, '::ffff:') === 0) ? substr($user_ip, 7) : $user_ip; +		$user_ip = $request->server('REMOTE_ADDR') ? phpbb_ip_normalise($request->server('REMOTE_ADDR')) : '';  		if ($data['script_path'] !== '/')  		{ @@ -1259,11 +1299,11 @@ class install_install extends module  				WHERE config_name = 'server_port'",  			'UPDATE ' . $data['table_prefix'] . "config -				SET config_value = '" . $db->sql_escape($data['board_email1']) . "' +				SET config_value = '" . $db->sql_escape($data['board_email']) . "'  				WHERE config_name = 'board_email'",  			'UPDATE ' . $data['table_prefix'] . "config -				SET config_value = '" . $db->sql_escape($data['board_email1']) . "' +				SET config_value = '" . $db->sql_escape($data['board_email']) . "'  				WHERE config_name = 'board_contact'",  			'UPDATE ' . $data['table_prefix'] . "config @@ -1322,8 +1362,12 @@ class install_install extends module  				SET config_value = '" . md5(mt_rand()) . "'  				WHERE config_name = 'avatar_salt'", +			'UPDATE ' . $data['table_prefix'] . "config +				SET config_value = '" . md5(mt_rand()) . "' +				WHERE config_name = 'plupload_salt'", +  			'UPDATE ' . $data['table_prefix'] . "users -				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'])) . "' +				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_email']) . "', user_dateformat='" . $db->sql_escape($lang['default_dateformat']) . "', user_email_hash = " . $db->sql_escape(phpbb_email_hash($data['board_email'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($data['admin_name'])) . "'  				WHERE username = 'Admin'",  			'UPDATE ' . $data['table_prefix'] . "moderator_cache @@ -1356,10 +1400,10 @@ class install_install extends module  				WHERE config_name = 'dbms_version'",  		); -		if (@extension_loaded('gd') || can_load_dll('gd')) +		if (@extension_loaded('gd'))  		{  			$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config -				SET config_value = 'phpbb_captcha_gd' +				SET config_value = 'core.captcha.plugins.gd'  				WHERE config_name = 'captcha_plugin'";  			$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config @@ -1415,7 +1459,7 @@ class install_install extends module  	*/  	function build_search_index($mode, $sub)  	{ -		global $db, $lang, $phpbb_root_path, $phpEx, $config; +		global $db, $lang, $phpbb_root_path, $phpbb_dispatcher, $phpEx, $config, $auth, $user;  		// Obtain any submitted data  		$data = $this->get_submitted_data(); @@ -1432,33 +1476,23 @@ class install_install extends module  		$dbms = $available_dbms[$data['dbms']]['DRIVER']; -		// Load the appropriate database class if not already loaded -		include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); -  		// Instantiate the database -		$db = new $sql_db(); +		$db = new $dbms();  		$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);  		// NOTE: trigger_error does not work here.  		$db->sql_return_on_error(true);  		include_once($phpbb_root_path . 'includes/constants.' . $phpEx); -		include_once($phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx); +		include_once($phpbb_root_path . 'phpbb/search/fulltext_native.' . $phpEx); -		// Fill the config array - it is needed by those functions we call -		$sql = 'SELECT * -			FROM ' . CONFIG_TABLE; -		$result = $db->sql_query($sql); - -		$config = array(); -		while ($row = $db->sql_fetchrow($result)) -		{ -			$config[$row['config_name']] = $row['config_value']; -		} -		$db->sql_freeresult($result); +		// We need to fill the config to let internal functions correctly work +		$config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); +		set_config(null, null, null, $config); +		set_config_count(null, null, null, $config);  		$error = false; -		$search = new fulltext_native($error); +		$search = new \phpbb\search\fulltext_native($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);  		$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id  			FROM ' . POSTS_TABLE; @@ -1476,7 +1510,13 @@ class install_install extends module  	*/  	function add_modules($mode, $sub)  	{ -		global $db, $lang, $phpbb_root_path, $phpEx; +		global $db, $lang, $phpbb_root_path, $phpEx, $phpbb_extension_manager, $config, $phpbb_container; + +		// modules require an extension manager +		if (empty($phpbb_extension_manager)) +		{ +			$phpbb_extension_manager = $phpbb_container->get('ext.manager'); +		}  		include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); @@ -1493,8 +1533,14 @@ class install_install extends module  			foreach ($this->module_categories[$module_class] as $cat_name => $subs)  			{ +				$basename = ''; +				// Check if this sub-category has a basename. If it has, use it. +				if (isset($this->module_categories_basenames[$cat_name])) +				{ +					$basename = $this->module_categories_basenames[$cat_name]; +				}  				$module_data = array( -					'module_basename'	=> '', +					'module_basename'	=> $basename,  					'module_enabled'	=> 1,  					'module_display'	=> 1,  					'parent_id'			=> 0, @@ -1508,10 +1554,10 @@ class install_install extends module  				$_module->update_module_data($module_data, true);  				// Check for last sql error happened -				if ($db->sql_error_triggered) +				if ($db->get_sql_error_triggered())  				{ -					$error = $db->sql_error($db->sql_error_sql); -					$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); +					$error = $db->sql_error($db->get_sql_error_sql()); +					$this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);  				}  				$categories[$cat_name]['id'] = (int) $module_data['module_id']; @@ -1522,8 +1568,14 @@ class install_install extends module  				{  					foreach ($subs as $level2_name)  					{ +						$basename = ''; +						// Check if this sub-category has a basename. If it has, use it. +						if (isset($this->module_categories_basenames[$level2_name])) +						{ +							$basename = $this->module_categories_basenames[$level2_name]; +						}  						$module_data = array( -							'module_basename'	=> '', +							'module_basename'	=> $basename,  							'module_enabled'	=> 1,  							'module_display'	=> 1,  							'parent_id'			=> (int) $categories[$cat_name]['id'], @@ -1536,10 +1588,10 @@ class install_install extends module  						$_module->update_module_data($module_data, true);  						// Check for last sql error happened -						if ($db->sql_error_triggered) +						if ($db->get_sql_error_triggered())  						{ -							$error = $db->sql_error($db->sql_error_sql); -							$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); +							$error = $db->sql_error($db->get_sql_error_sql()); +							$this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);  						}  						$categories[$level2_name]['id'] = (int) $module_data['module_id']; @@ -1576,10 +1628,10 @@ class install_install extends module  						$_module->update_module_data($module_data, true);  						// Check for last sql error happened -						if ($db->sql_error_triggered) +						if ($db->get_sql_error_triggered())  						{ -							$error = $db->sql_error($db->sql_error_sql); -							$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); +							$error = $db->sql_error($db->get_sql_error_sql()); +							$this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);  						}  					}  				} @@ -1591,7 +1643,7 @@ class install_install extends module  				// Move main module 4 up...  				$sql = 'SELECT *  					FROM ' . MODULES_TABLE . " -					WHERE module_basename = 'main' +					WHERE module_basename = 'acp_main'  						AND module_class = 'acp'  						AND module_mode = 'main'";  				$result = $db->sql_query($sql); @@ -1603,7 +1655,7 @@ class install_install extends module  				// Move permissions intro screen module 4 up...  				$sql = 'SELECT *  					FROM ' . MODULES_TABLE . " -					WHERE module_basename = 'permissions' +					WHERE module_basename = 'acp_permissions'  						AND module_class = 'acp'  						AND module_mode = 'intro'";  				$result = $db->sql_query($sql); @@ -1615,7 +1667,7 @@ class install_install extends module  				// Move manage users screen module 5 up...  				$sql = 'SELECT *  					FROM ' . MODULES_TABLE . " -					WHERE module_basename = 'users' +					WHERE module_basename = 'acp_users'  						AND module_class = 'acp'  						AND module_mode = 'overview'";  				$result = $db->sql_query($sql); @@ -1623,6 +1675,19 @@ class install_install extends module  				$db->sql_freeresult($result);  				$_module->move_module_by($row, 'move_up', 5); + +				// Move extension management module 1 up... +				$sql = 'SELECT * +					FROM ' . MODULES_TABLE . " +					WHERE module_langname = 'ACP_EXTENSION_MANAGEMENT' +						AND module_class = 'acp' +						AND module_mode = '' +						AND module_basename = ''"; +				$result = $db->sql_query($sql); +				$row = $db->sql_fetchrow($result); +				$db->sql_freeresult($result); + +				$_module->move_module_by($row, 'move_up', 1);  			}  			if ($module_class == 'mcp') @@ -1630,7 +1695,7 @@ class install_install extends module  				// Move pm report details module 3 down...  				$sql = 'SELECT *  					FROM ' . MODULES_TABLE . " -					WHERE module_basename = 'pm_reports' +					WHERE module_basename = 'mcp_pm_reports'  						AND module_class = 'mcp'  						AND module_mode = 'pm_report_details'";  				$result = $db->sql_query($sql); @@ -1642,7 +1707,7 @@ class install_install extends module  				// Move closed pm reports module 3 down...  				$sql = 'SELECT *  					FROM ' . MODULES_TABLE . " -					WHERE module_basename = 'pm_reports' +					WHERE module_basename = 'mcp_pm_reports'  						AND module_class = 'mcp'  						AND module_mode = 'pm_reports_closed'";  				$result = $db->sql_query($sql); @@ -1654,7 +1719,7 @@ class install_install extends module  				// Move open pm reports module 3 down...  				$sql = 'SELECT *  					FROM ' . MODULES_TABLE . " -					WHERE module_basename = 'pm_reports' +					WHERE module_basename = 'mcp_pm_reports'  						AND module_class = 'mcp'  						AND module_mode = 'pm_reports'";  				$result = $db->sql_query($sql); @@ -1669,7 +1734,7 @@ class install_install extends module  				// Move attachment module 4 down...  				$sql = 'SELECT *  					FROM ' . MODULES_TABLE . " -					WHERE module_basename = 'attachments' +					WHERE module_basename = 'ucp_attachments'  						AND module_class = 'ucp'  						AND module_mode = 'attachments'";  				$result = $db->sql_query($sql); @@ -1677,6 +1742,30 @@ class install_install extends module  				$db->sql_freeresult($result);  				$_module->move_module_by($row, 'move_down', 4); + +				// Move notification options module 4 down... +				$sql = 'SELECT * +					FROM ' . MODULES_TABLE . " +					WHERE module_basename = 'ucp_notifications' +						AND module_class = 'ucp' +						AND module_mode = 'notification_options'"; +				$result = $db->sql_query($sql); +				$row = $db->sql_fetchrow($result); +				$db->sql_freeresult($result); + +				$_module->move_module_by($row, 'move_down', 4); + +				// Move OAuth module 5 down... +				$sql = 'SELECT * +					FROM ' . MODULES_TABLE . " +					WHERE module_basename = 'ucp_auth_link' +						AND module_class = 'ucp' +						AND module_mode = 'auth_link'"; +				$result = $db->sql_query($sql); +				$row = $db->sql_fetchrow($result); +				$db->sql_freeresult($result); + +				$_module->move_module_by($row, 'move_down', 5);  			}  			// And now for the special ones @@ -1718,10 +1807,10 @@ class install_install extends module  						$_module->update_module_data($module_data, true);  						// Check for last sql error happened -						if ($db->sql_error_triggered) +						if ($db->get_sql_error_triggered())  						{ -							$error = $db->sql_error($db->sql_error_sql); -							$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); +							$error = $db->sql_error($db->get_sql_error_sql()); +							$this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);  						}  					}  				} @@ -1745,6 +1834,7 @@ class install_install extends module  			$this->error('Unable to access the language directory', __LINE__, __FILE__);  		} +		$installed_languages = array();  		while (($file = readdir($dir)) !== false)  		{  			$path = $phpbb_root_path . 'language/' . $file; @@ -1768,80 +1858,38 @@ class install_install extends module  				$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $lang_pack)); -				if ($db->sql_error_triggered) +				$installed_languages[] = (int) $db->sql_nextid(); +				if ($db->get_sql_error_triggered())  				{ -					$error = $db->sql_error($db->sql_error_sql); -					$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); +					$error = $db->sql_error($db->get_sql_error_sql()); +					$this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);  				} +			} +		} +		closedir($dir); -				$valid_localized = array( -					'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', -				); - -				$sql_ary = array(); - -				$sql = 'SELECT * -					FROM ' . STYLES_IMAGESET_TABLE; -				$result = $db->sql_query($sql); - -				while ($imageset_row = $db->sql_fetchrow($result)) -				{ -					if (@file_exists("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['lang_iso']}/imageset.cfg")) -					{ -						$cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['lang_iso']}/imageset.cfg"); -						foreach ($cfg_data_imageset_data as $image_name => $value) -						{ -							if (strpos($value, '*') !== false) -							{ -								if (substr($value, -1, 1) === '*') -								{ -									list($image_filename, $image_height) = explode('*', $value); -									$image_width = 0; -								} -								else -								{ -									list($image_filename, $image_height, $image_width) = explode('*', $value); -								} -							} -							else -							{ -								$image_filename = $value; -								$image_height = $image_width = 0; -							} - -							if (strpos($image_name, 'img_') === 0 && $image_filename) -							{ -								$image_name = substr($image_name, 4); -								if (in_array($image_name, $valid_localized)) -								{ -									$sql_ary[] = array( -										'image_name'		=> (string) $image_name, -										'image_filename'	=> (string) $image_filename, -										'image_height'		=> (int) $image_height, -										'image_width'		=> (int) $image_width, -										'imageset_id'		=> (int) $imageset_row['imageset_id'], -										'image_lang'		=> (string) $lang_pack['lang_iso'], -									); -								} -							} -						} -					} -				} -				$db->sql_freeresult($result); - -				if (sizeof($sql_ary)) -				{ -					$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary); +		$sql = 'SELECT * +			FROM ' . PROFILE_FIELDS_TABLE; +		$result = $db->sql_query($sql); -					if ($db->sql_error_triggered) -					{ -						$error = $db->sql_error($db->sql_error_sql); -						$this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); -					} -				} +		$profile_fields = array(); +		$insert_buffer = new \phpbb\db\sql_insert_buffer($db, PROFILE_LANG_TABLE); +		while ($row = $db->sql_fetchrow($result)) +		{ +			foreach ($installed_languages as $lang_id) +			{ +				$insert_buffer->insert(array( +					'field_id'				=> $row['field_id'], +					'lang_id'				=> $lang_id, +					'lang_name'				=> strtoupper(substr($row['field_name'], 6)),// Remove phpbb_ from field name +					'lang_explain'			=> '', +					'lang_default_value'	=> '', +				));  			}  		} -		closedir($dir); +		$db->sql_freeresult($result); + +		$insert_buffer->flush();  	}  	/** @@ -1854,17 +1902,10 @@ class install_install extends module  		// Obtain any submitted data  		$data = $this->get_submitted_data(); -		// Fill the config array - it is needed by those functions we call -		$sql = 'SELECT * -			FROM ' . CONFIG_TABLE; -		$result = $db->sql_query($sql); - -		$config = array(); -		while ($row = $db->sql_fetchrow($result)) -		{ -			$config[$row['config_name']] = $row['config_value']; -		} -		$db->sql_freeresult($result); +		// We need to fill the config to let internal functions correctly work +		$config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); +		set_config(null, null, null, $config); +		set_config_count(null, null, null, $config);  		$sql = 'SELECT group_id  			FROM ' . GROUPS_TABLE . " @@ -1896,7 +1937,7 @@ class install_install extends module  				'user_email'			=> '',  				'user_lang'				=> $data['default_lang'],  				'user_style'			=> 1, -				'user_timezone'			=> 0, +				'user_timezone'			=> 'UTC',  				'user_dateformat'		=> $lang['default_dateformat'],  				'user_allow_massemail'	=> 0,  				'user_allow_pm'			=> 0, @@ -1907,7 +1948,7 @@ class install_install extends module  			if (!$user_id)  			{  				// If we can't insert this user then continue to the next one to avoid inconsistent data -				$this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__, true); +				$this->p_master->db_error('Unable to insert bot into users table', $db->get_sql_error_sql(), __LINE__, __FILE__, true);  				continue;  			} @@ -1919,7 +1960,7 @@ class install_install extends module  				'bot_ip'		=> (string) $bot_ary[1],  			)); -			$result = $db->sql_query($sql); +			$db->sql_query($sql);  		}  	} @@ -1928,23 +1969,17 @@ class install_install extends module  	*/  	function email_admin($mode, $sub)  	{ -		global $auth, $config, $db, $lang, $template, $user, $phpbb_root_path, $phpEx; +		global $auth, $config, $db, $lang, $template, $user, $phpbb_root_path, $phpbb_admin_path, $phpEx;  		$this->page_title = $lang['STAGE_FINAL'];  		// Obtain any submitted data  		$data = $this->get_submitted_data(); -		$sql = 'SELECT * -			FROM ' . CONFIG_TABLE; -		$result = $db->sql_query($sql); - -		$config = array(); -		while ($row = $db->sql_fetchrow($result)) -		{ -			$config[$row['config_name']] = $row['config_value']; -		} -		$db->sql_freeresult($result); +		// We need to fill the config to let internal functions correctly work +		$config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); +		set_config(null, null, null, $config); +		set_config_count(null, null, null, $config);  		$user->session_begin();  		$auth->login($data['admin_name'], $data['admin_pass1'], false, true, true); @@ -1962,7 +1997,7 @@ class install_install extends module  			$messenger->template('installed', $data['language']); -			$messenger->to($data['board_email1'], $data['admin_name']); +			$messenger->to($data['board_email'], $data['admin_name']);  			$messenger->anti_abuse_headers($config, $user); @@ -1981,7 +2016,7 @@ class install_install extends module  			'TITLE'		=> $lang['INSTALL_CONGRATS'],  			'BODY'		=> sprintf($lang['INSTALL_CONGRATS_EXPLAIN'], $config['version'], append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=convert&language=' . $data['language']), '../docs/README.html'),  			'L_SUBMIT'	=> $lang['INSTALL_LOGIN'], -			'U_ACTION'	=> append_sid($phpbb_root_path . 'adm/index.' . $phpEx, 'i=send_statistics&mode=send_statistics'), +			'U_ACTION'	=> append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=send_statistics&mode=send_statistics'),  		));  	} @@ -2001,6 +2036,26 @@ class install_install extends module  	}  	/** +	* Populate migrations for the installation +	* +	* This "installs" all migrations from (root path)/phpbb/db/migrations/data. +	* "installs" means it adds all migrations to the migrations table, but does not +	* perform any of the actions in the migrations. +	* +	* @param \phpbb\extension\manager $extension_manager +	* @param \phpbb\db\migrator $migrator +	*/ +	function populate_migrations($extension_manager, $migrator) +	{ +		$finder = $extension_manager->get_finder(); + +		$migrations = $finder +			->core_path('phpbb/db/migration/data/') +			->get_classes(); +		$migrator->populate_migrations($migrations); +	} + +	/**  	* Generate a list of available mail server authentication methods  	*/  	function mail_auth_select($selected_method) @@ -2026,7 +2081,7 @@ class install_install extends module  		return array(  			'language'		=> basename(request_var('language', '')),  			'dbms'			=> request_var('dbms', ''), -			'dbhost'		=> request_var('dbhost', ''), +			'dbhost'		=> request_var('dbhost', '', true),  			'dbport'		=> request_var('dbport', ''),  			'dbuser'		=> request_var('dbuser', ''),  			'dbpasswd'		=> request_var('dbpasswd', '', true), @@ -2036,8 +2091,7 @@ class install_install extends module  			'admin_name'	=> utf8_normalize_nfc(request_var('admin_name', '', true)),  			'admin_pass1'	=> request_var('admin_pass1', '', true),  			'admin_pass2'	=> request_var('admin_pass2', '', true), -			'board_email1'	=> strtolower(request_var('board_email1', '')), -			'board_email2'	=> strtolower(request_var('board_email2', '')), +			'board_email'	=> strtolower(request_var('board_email', '')),  			'img_imagick'	=> request_var('img_imagick', ''),  			'ftp_path'		=> request_var('ftp_path', ''),  			'ftp_user'		=> request_var('ftp_user', ''), @@ -2076,8 +2130,7 @@ class install_install extends module  		'admin_name'			=> array('lang' => 'ADMIN_USERNAME',			'type' => 'text:25:100', 'explain' => true),  		'admin_pass1'			=> array('lang' => 'ADMIN_PASSWORD',			'type' => 'password:25:100', 'explain' => true),  		'admin_pass2'			=> array('lang' => 'ADMIN_PASSWORD_CONFIRM',	'type' => 'password:25:100', 'explain' => false), -		'board_email1'			=> array('lang' => 'CONTACT_EMAIL',				'type' => 'text:25:100', 'explain' => false), -		'board_email2'			=> array('lang' => 'CONTACT_EMAIL_CONFIRM',		'type' => 'text:25:100', 'explain' => false), +		'board_email'			=> array('lang' => 'CONTACT_EMAIL',				'type' => 'email:25:100', 'explain' => false),  	);  	var $advanced_config_options = array(  		'legend1'				=> 'ACP_EMAIL_SETTINGS', @@ -2218,9 +2271,10 @@ class install_install extends module  				'ACP_PERMISSION_ROLES',  				'ACP_PERMISSION_MASKS',  			), -			'ACP_CAT_STYLES'		=> array( +			'ACP_CAT_CUSTOMISE'		=> array(  				'ACP_STYLE_MANAGEMENT', -				'ACP_STYLE_COMPONENTS', +				'ACP_EXTENSION_MANAGEMENT', +				'ACP_LANGUAGE',  			),  			'ACP_CAT_MAINTENANCE'	=> array(  				'ACP_FORUM_LOGS', @@ -2251,6 +2305,9 @@ class install_install extends module  			'UCP_ZEBRA'			=> null,  		),  	); +	var $module_categories_basenames = array( +		'UCP_PM' => 'ucp_pm', +	);  	var $module_extras = array(  		'acp'	=> array( @@ -2272,5 +2329,3 @@ class install_install extends module  		),  	);  } - -?>
\ No newline at end of file  | 
