diff options
Diffstat (limited to 'phpBB/install/database_update.php')
| -rw-r--r-- | phpBB/install/database_update.php | 111 | 
1 files changed, 91 insertions, 20 deletions
| diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 01048520d2..cf611ca951 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2,13 +2,12 @@  /**  *  * @package install -* @version $Id$  * @copyright (c) 2006 phpBB Group  * @license http://opensource.org/licenses/gpl-license.php GNU Public License  *  */ -$updates_to_version = '3.0.9-dev'; +$updates_to_version = '3.1.0-dev';  // Enter any version to update from to test updates. The version within the db will not be updated.  $debug_from_version = false; @@ -60,8 +59,7 @@ if (!empty($load_extensions) && function_exists('dl'))  }  // Include files -require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx); -require($phpbb_root_path . 'includes/cache.' . $phpEx); +require($phpbb_root_path . 'includes/class_loader.' . $phpEx);  require($phpbb_root_path . 'includes/template.' . $phpEx);  require($phpbb_root_path . 'includes/session.' . $phpEx);  require($phpbb_root_path . 'includes/auth.' . $phpEx); @@ -92,10 +90,21 @@ else  	define('STRIP', (get_magic_quotes_gpc()) ? true : false);  } +$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx); +$class_loader->register(); + +// set up caching +$cache_factory = new phpbb_cache_factory($acm_type); +$cache = $cache_factory->get_service(); +$class_loader->set_cache($cache->get_driver()); + +$request = new phpbb_request();  $user = new user(); -$cache = new cache();  $db = new $sql_db(); +// make sure request_var uses this request instance +request_var('', 0, false, false, $request); // "dependency injection" for a function +  // Add own hook handler, if present. :o  if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))  { @@ -118,8 +127,11 @@ $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);  // We do not need this any longer, unset for safety purposes  unset($dbpasswd); -$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 = ''; +if (!empty($_SERVER['REMOTE_ADDR'])) +{ +	$user->ip = (function_exists('phpbb_ip_normalise')) ? phpbb_ip_normalise($_SERVER['REMOTE_ADDR']) : htmlspecialchars($_SERVER['REMOTE_ADDR']); +}  $sql = "SELECT config_value  	FROM " . CONFIG_TABLE . " @@ -152,17 +164,9 @@ include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx);  $inline_update = (request_var('type', 0)) ? true : false;  // To let set_config() calls succeed, we need to make the config array available globally -$config = array(); - -$sql = 'SELECT * -	FROM ' . CONFIG_TABLE; -$result = $db->sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ -	$config[$row['config_name']] = $row['config_value']; -} -$db->sql_freeresult($result); +$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); +set_config(null, null, null, $config); +set_config_count(null, null, null, $config);  // We do not include DB Tools here, because we can not be sure the file is up-to-date ;)  // Instead, this file defines a clean db_tools version (we are also not able to provide a different file, else the database update will not work standalone) @@ -925,6 +929,20 @@ function database_update_info()  				),  			),  		), + +		// Changes from 3.1.0-dev to 3.1.0-A1 +		'3.1.0-dev'		=> array( +			'add_columns'		=> array( +				GROUPS_TABLE		=> array( +					'group_teampage'	=> array('UINT', 0, 'after' => 'group_legend'), +				), +			), +			'change_columns'	=> array( +				GROUPS_TABLE		=> array( +					'group_legend'		=> array('UINT', 0), +				), +			), +		),  	);  } @@ -1891,6 +1909,61 @@ function change_database_data(&$no_updates, $version)  			$no_updates = false;  		break; + +		// Changes from 3.1.0-dev to 3.1.0-A1 +		case '3.1.0-dev': +			set_config('use_system_cron', 0); + +			$sql = 'UPDATE ' . GROUPS_TABLE . ' +				SET group_teampage = 1 +				WHERE group_type = ' . GROUP_SPECIAL . " +					AND group_name = 'ADMINISTRATORS'"; +			_sql($sql, $errored, $error_ary); + +			$sql = 'UPDATE ' . GROUPS_TABLE . ' +				SET group_teampage = 2 +				WHERE group_type = ' . GROUP_SPECIAL . " +					AND group_name = 'GLOBAL_MODERATORS'"; +			_sql($sql, $errored, $error_ary); + +			set_config('legend_sort_groupname', '0'); +			set_config('teampage_multiple', '1'); +			set_config('teampage_forums', '1'); + +			$sql = 'SELECT group_id +				FROM ' . GROUPS_TABLE . ' +				WHERE group_legend = 1 +				ORDER BY group_name ASC'; +			$result = $db->sql_query($sql); + +			$next_legend = 1; +			while ($row = $db->sql_fetchrow($result)) +			{ +				$sql = 'UPDATE ' . GROUPS_TABLE . ' +					SET group_legend = ' . $next_legend . ' +					WHERE group_id = ' . (int) $row['group_id']; +				_sql($sql, $errored, $error_ary); + +				$next_legend++; +			} +			$db->sql_freeresult($result); +			unset($next_legend); + +			// Install modules +			$modules_to_install = array( +				'position'	=> array( +					'base'		=> 'groups', +					'class'		=> 'acp', +					'title'		=> 'ACP_GROUPS_POSITION', +					'auth'		=> 'acl_a_group', +					'cat'		=> 'ACP_GROUPS', +				), +			); + +			_add_modules($modules_to_install); + +			$no_updates = false; +		break;  	}  } @@ -3835,5 +3908,3 @@ class updater_db_tools  		return $this->_sql_run_sql($statements);  	}  } - -?> | 
