diff options
Diffstat (limited to 'phpBB/includes')
24 files changed, 462 insertions, 178 deletions
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index c8df21f5a9..cffe296651 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -201,7 +201,7 @@ class acp_main  						// No maximum post id? :o  						if (!$max_post_id)  						{ -							$sql = 'SELECT MAX(post_id) +							$sql = 'SELECT MAX(post_id) as max_post_id  								FROM ' . POSTS_TABLE;  							$result = $db->sql_query($sql);  							$max_post_id = (int) $db->sql_fetchfield('max_post_id'); @@ -398,11 +398,11 @@ class acp_main  		// Version check  		$user->add_lang('install'); -		if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.2.0', '<')) +		if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.3.2', '<'))  		{  			$template->assign_vars(array(  				'S_PHP_VERSION_OLD'	=> true, -				'L_PHP_VERSION_OLD'	=> sprintf($user->lang['PHP_VERSION_OLD'], '<a href="http://www.phpbb.com/community/viewtopic.php?f=14&t=1958605">', '</a>'), +				'L_PHP_VERSION_OLD'	=> sprintf($user->lang['PHP_VERSION_OLD'], '<a href="http://www.phpbb.com/community/viewtopic.php?f=14&t=2152375">', '</a>'),  			));  		} diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 2e43b0545a..a591474fce 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -504,11 +504,34 @@ class acp_profile  							}  						}  					} -					/* else if ($field_type == FIELD_BOOL && $key == 'field_default_value') +					else if ($field_type == FIELD_BOOL && $key == 'field_default_value')  					{ -						// Get the number of options if this key is 'field_maxlen' -						$var = request_var('field_default_value', 0); -					}*/ +						// 'field_length' == 1 defines radio buttons. Possible values are 1 or 2 only. +						// 'field_length' == 2 defines checkbox. Possible values are 0 or 1 only. +						// If we switch the type on step 2, we have to adjust field value. +						// 1 is a common value for the checkbox and radio buttons. + +						// Adjust unchecked checkbox value. +						// If we return or save settings from 2nd/3rd page +						// and the checkbox is unchecked, set the value to 0. +						if (isset($_REQUEST['step']) && !isset($_REQUEST[$key])) +						{ +							$var = 0; +						} + +						// If we switch to the checkbox type but former radio buttons value was 2, +						// which is not the case for the checkbox, set it to 0 (unchecked). +						if ($cp->vars['field_length'] == 2 && $var == 2) +						{ +							$var = 0; +						} +						// If we switch to the radio buttons but the former checkbox value was 0, +						// which is not the case for the radio buttons, set it to 0. +						else if ($cp->vars['field_length'] == 1 && $var == 0) +						{ +							$var = 2; +						} +					}  					else if ($field_type == FIELD_INT && $key == 'field_default_value')  					{  						// Permit an empty string @@ -676,6 +699,10 @@ class acp_profile  						{  							$_new_key_ary[$key] = utf8_normalize_nfc(request_var($key, array(array('')), true));  						} +						else if ($field_type == FIELD_BOOL && $key == 'field_default_value') +						{ +							$_new_key_ary[$key] =  request_var($key, $cp->vars[$key]); +						}  						else  						{  							if (!isset($_REQUEST[$key])) diff --git a/phpBB/includes/acp/acp_ranks.php b/phpBB/includes/acp/acp_ranks.php index dfd7511427..ea057cd84c 100644 --- a/phpBB/includes/acp/acp_ranks.php +++ b/phpBB/includes/acp/acp_ranks.php @@ -52,7 +52,7 @@ class acp_ranks  				}  				$rank_title = utf8_normalize_nfc(request_var('title', '', true));  				$special_rank = request_var('special_rank', 0); -				$min_posts = ($special_rank) ? 0 : request_var('min_posts', 0); +				$min_posts = ($special_rank) ? 0 : max(0, request_var('min_posts', 0));  				$rank_image = request_var('rank_image', '');  				// The rank image has to be a jpg, gif or png diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php index c20196d019..1c6cdf7832 100644 --- a/phpBB/includes/auth/auth_db.php +++ b/phpBB/includes/auth/auth_db.php @@ -163,7 +163,7 @@ function login_db($username, $password, $ip = '', $browser = '', $forwarded_for  		$password_old_format = (!STRIP) ? addslashes($password_old_format) : $password_old_format;  		$password_new_format = ''; -		set_var($password_new_format, stripslashes($password_old_format), 'string'); +		set_var($password_new_format, stripslashes($password_old_format), 'string', true);  		if ($password == $password_new_format)  		{ diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 2cba11133a..c6dd23e6bd 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -2115,7 +2115,7 @@ class phpbb_db_tools  			case 'mysql_40':  			case 'mysql_41': -				$statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX (' . implode(', ', $column) . ')'; +				$statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX ' . $index_name . '(' . implode(', ', $column) . ')';  			break;  			case 'mssql': diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 230c9c8ed7..358df50402 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -195,6 +195,49 @@ class dbal  	}  	/** +	* Seek to given row number +	* rownum is zero-based +	*/ +	function sql_rowseek($rownum, &$query_id) +	{ +		global $cache; + +		if ($query_id === false) +		{ +			$query_id = $this->query_result; +		} + +		if (isset($cache->sql_rowset[$query_id])) +		{ +			return $cache->sql_rowseek($rownum, $query_id); +		} + +		if ($query_id === false) +		{ +			return false; +		} + +		$this->sql_freeresult($query_id); +		$query_id = $this->sql_query($this->last_query_text); + +		if ($query_id === false) +		{ +			return false; +		} + +		// We do not fetch the row for rownum == 0 because then the next resultset would be the second row +		for ($i = 0; $i < $rownum; $i++) +		{ +			if (!$this->sql_fetchrow($query_id)) +			{ +				return false; +			} +		} + +		return true; +	} + +	/**  	* Fetch field  	* if rownum is false, the current row is used, else it is pointing to the row (zero-based)  	*/ @@ -900,6 +943,41 @@ class dbal  		return true;  	} + +	/** +	* Gets the estimated number of rows in a specified table. +	* +	* @param string $table_name		Table name +	* +	* @return string				Number of rows in $table_name. +	*								Prefixed with ~ if estimated (otherwise exact). +	* +	* @access public +	*/ +	function get_estimated_row_count($table_name) +	{ +		return $this->get_row_count($table_name); +	} + +	/** +	* Gets the exact number of rows in a specified table. +	* +	* @param string $table_name		Table name +	* +	* @return string				Exact number of rows in $table_name. +	* +	* @access public +	*/ +	function get_row_count($table_name) +	{ +		$sql = 'SELECT COUNT(*) AS rows_total +			FROM ' . $this->sql_escape($table_name); +		$result = $this->sql_query($sql); +		$rows_total = $this->sql_fetchfield('rows_total'); +		$this->sql_freeresult($result); + +		return $rows_total; +	}  }  /** diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index 7e3f15ed1d..7072c58ac0 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -360,49 +360,6 @@ class dbal_firebird extends dbal  	}  	/** -	* Seek to given row number -	* rownum is zero-based -	*/ -	function sql_rowseek($rownum, &$query_id) -	{ -		global $cache; - -		if ($query_id === false) -		{ -			$query_id = $this->query_result; -		} - -		if (isset($cache->sql_rowset[$query_id])) -		{ -			return $cache->sql_rowseek($rownum, $query_id); -		} - -		if ($query_id === false) -		{ -			return; -		} - -		$this->sql_freeresult($query_id); -		$query_id = $this->sql_query($this->last_query_text); - -		if ($query_id === false) -		{ -			return false; -		} - -		// We do not fetch the row for rownum == 0 because then the next resultset would be the second row -		for ($i = 0; $i < $rownum; $i++) -		{ -			if (!$this->sql_fetchrow($query_id)) -			{ -				return false; -			} -		} - -		return true; -	} - -	/**  	* Get last inserted id after insert statement  	*/  	function sql_nextid() diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 75a080b1b7..34f7a87337 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -256,49 +256,6 @@ class dbal_mssql_odbc extends dbal  	}  	/** -	* Seek to given row number -	* rownum is zero-based -	*/ -	function sql_rowseek($rownum, &$query_id) -	{ -		global $cache; - -		if ($query_id === false) -		{ -			$query_id = $this->query_result; -		} - -		if (isset($cache->sql_rowset[$query_id])) -		{ -			return $cache->sql_rowseek($rownum, $query_id); -		} - -		if ($query_id === false) -		{ -			return false; -		} - -		$this->sql_freeresult($query_id); -		$query_id = $this->sql_query($this->last_query_text); - -		if ($query_id === false) -		{ -			return false; -		} - -		// We do not fetch the row for rownum == 0 because then the next resultset would be the second row -		for ($i = 0; $i < $rownum; $i++) -		{ -			if (!$this->sql_fetchrow($query_id)) -			{ -				return false; -			} -		} - -		return true; -	} - -	/**  	* Get last inserted id after insert statement  	*/  	function sql_nextid() diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index 7fbc374e77..92ac9b1fb9 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -440,24 +440,6 @@ class dbal_mssqlnative extends dbal  	}  	/** -	* Seek to given row number -	* rownum is zero-based -	*/ -	function sql_rowseek($rownum, &$query_id) -	{ -		global $cache; - -		if (isset($cache->sql_rowset[$query_id])) -		{ -			return $cache->sql_rowseek($rownum, $query_id); -		} - -		$seek = new result_mssqlnative($query_id); -		$row = $seek->seek($rownum); -		return ($row = $seek->fetch()) ? $row : false; -	} - -	/**  	* Get last inserted id after insert statement  	*/  	function sql_nextid() diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 1e24c79577..1ccb785150 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -319,6 +319,76 @@ class dbal_mysql extends dbal  	}  	/** +	* Gets the estimated number of rows in a specified table. +	* +	* @param string $table_name		Table name +	* +	* @return string				Number of rows in $table_name. +	*								Prefixed with ~ if estimated (otherwise exact). +	* +	* @access public +	*/ +	function get_estimated_row_count($table_name) +	{ +		$table_status = $this->get_table_status($table_name); + +		if (isset($table_status['Engine'])) +		{ +			if ($table_status['Engine'] === 'MyISAM') +			{ +				return $table_status['Rows']; +			} +			else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000) +			{ +				return '~' . $table_status['Rows']; +			} +		} + +		return parent::get_row_count($table_name); +	} + +	/** +	* Gets the exact number of rows in a specified table. +	* +	* @param string $table_name		Table name +	* +	* @return string				Exact number of rows in $table_name. +	* +	* @access public +	*/ +	function get_row_count($table_name) +	{ +		$table_status = $this->get_table_status($table_name); + +		if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM') +		{ +			return $table_status['Rows']; +		} + +		return parent::get_row_count($table_name); +	} + +	/** +	* Gets some information about the specified table. +	* +	* @param string $table_name		Table name +	* +	* @return array +	* +	* @access protected +	*/ +	function get_table_status($table_name) +	{ +		$sql = "SHOW TABLE STATUS +			LIKE '" . $this->sql_escape($table_name) . "'"; +		$result = $this->sql_query($sql); +		$table_status = $this->sql_fetchrow($result); +		$this->sql_freeresult($result); + +		return $table_status; +	} + +	/**  	* Build LIKE expression  	* @access private  	*/ diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index 456ce906d0..a311b8cda6 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -316,6 +316,76 @@ class dbal_mysqli extends dbal  	}  	/** +	* Gets the estimated number of rows in a specified table. +	* +	* @param string $table_name		Table name +	* +	* @return string				Number of rows in $table_name. +	*								Prefixed with ~ if estimated (otherwise exact). +	* +	* @access public +	*/ +	function get_estimated_row_count($table_name) +	{ +		$table_status = $this->get_table_status($table_name); + +		if (isset($table_status['Engine'])) +		{ +			if ($table_status['Engine'] === 'MyISAM') +			{ +				return $table_status['Rows']; +			} +			else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000) +			{ +				return '~' . $table_status['Rows']; +			} +		} + +		return parent::get_row_count($table_name); +	} + +	/** +	* Gets the exact number of rows in a specified table. +	* +	* @param string $table_name		Table name +	* +	* @return string				Exact number of rows in $table_name. +	* +	* @access public +	*/ +	function get_row_count($table_name) +	{ +		$table_status = $this->get_table_status($table_name); + +		if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM') +		{ +			return $table_status['Rows']; +		} + +		return parent::get_row_count($table_name); +	} + +	/** +	* Gets some information about the specified table. +	* +	* @param string $table_name		Table name +	* +	* @return array +	* +	* @access protected +	*/ +	function get_table_status($table_name) +	{ +		$sql = "SHOW TABLE STATUS +			LIKE '" . $this->sql_escape($table_name) . "'"; +		$result = $this->sql_query($sql); +		$table_status = $this->sql_fetchrow($result); +		$this->sql_freeresult($result); + +		return $table_status; +	} + +	/**  	* Build LIKE expression  	* @access private  	*/ diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0320230a7d..ce80dc4a66 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4738,6 +4738,7 @@ function page_footer($run_cron = true)  	$template->assign_vars(array(  		'DEBUG_OUTPUT'			=> (defined('DEBUG')) ? $debug_output : '',  		'TRANSLATION_INFO'		=> (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', +		'CREDIT_LINE'			=> $user->lang('POWERED_BY', '<a href="http://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Group'),  		'U_ACP' => ($auth->acl_get('a_') && !empty($user->data['is_registered'])) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", false, true, $user->session_id) : '')  	); diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 6caa5c943f..633b2755f0 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -512,4 +512,56 @@ function adjust_language_keys_callback($matches)  	}  } +/** +* Creates the output to be stored in a phpBB config.php file +* +* @param	array	$data Array containing the database connection information +* @param	string	$dbms The name of the DBAL class to use +* @param	array	$load_extensions Array of additional extensions that should be loaded +* @param	bool	$debug If the debug constants should be enabled by default or not +* +* @return	string	The output to write to the file +*/ +function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false) +{ +	$load_extensions = implode(',', $load_extensions); + +	$config_data = "<?php\n"; +	$config_data .= "// phpBB 3.0.x auto-generated configuration file\n// Do not change anything in this file!\n"; + +	$config_data_array = array( +		'dbms'			=> $dbms, +		'dbhost'		=> $data['dbhost'], +		'dbport'		=> $data['dbport'], +		'dbname'		=> $data['dbname'], +		'dbuser'		=> $data['dbuser'], +		'dbpasswd'		=> htmlspecialchars_decode($data['dbpasswd']), +		'table_prefix'	=> $data['table_prefix'], +		'acm_type'		=> 'file', +		'load_extensions'	=> $load_extensions, +	); + +	foreach ($config_data_array as $key => $value) +	{ +		$config_data .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n"; +	} + +	$config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; + +	if ($debug) +	{ +		$config_data .= "@define('DEBUG', true);\n"; +		$config_data .= "@define('DEBUG_EXTRA', true);\n"; +	} +	else +	{ +		$config_data .= "// @define('DEBUG', true);\n"; +		$config_data .= "// @define('DEBUG_EXTRA', true);\n"; +	} + +	$config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused! + +	return $config_data; +} +  ?>
\ No newline at end of file diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 77d92e26e2..68b6199cf5 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -497,7 +497,14 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage  	{  		if ($free_space <= $file->get('filesize'))  		{ -			$filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED']; +			if ($auth->acl_get('a_')) +			{ +				$filedata['error'][] = $user->lang['ATTACH_DISK_FULL']; +			} +			else +			{ +				$filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED']; +			}  			$filedata['post_attach'] = false;  			$file->remove(); @@ -1180,36 +1187,32 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id  	$topic_title = ($topic_notification) ? $topic_title : $subject;  	$topic_title = censor_text($topic_title); -	// Get banned User ID's -	$sql = 'SELECT ban_userid -		FROM ' . BANLIST_TABLE . ' -		WHERE ban_userid <> 0 -			AND ban_exclude <> 1'; -	$result = $db->sql_query($sql); - -	$sql_ignore_users = ANONYMOUS . ', ' . $user->data['user_id']; -	while ($row = $db->sql_fetchrow($result)) +	// Exclude guests, current user and banned users from notifications +	if (!function_exists('phpbb_get_banned_user_ids'))  	{ -		$sql_ignore_users .= ', ' . (int) $row['ban_userid']; +		include($phpbb_root_path . 'includes/functions_user.' . $phpEx);  	} -	$db->sql_freeresult($result); +	$sql_ignore_users = phpbb_get_banned_user_ids(); +	$sql_ignore_users[ANONYMOUS] = ANONYMOUS; +	$sql_ignore_users[$user->data['user_id']] = $user->data['user_id'];  	$notify_rows = array();  	// -- get forum_userids	|| topic_userids  	$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber  		FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u -		WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . " -			AND w.user_id NOT IN ($sql_ignore_users) -			AND w.notify_status = " . NOTIFY_YES . ' +		WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . ' +			AND ' . $db->sql_in_set('w.user_id', $sql_ignore_users, true) . ' +			AND w.notify_status = ' . NOTIFY_YES . '  			AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')  			AND u.user_id = w.user_id';  	$result = $db->sql_query($sql);  	while ($row = $db->sql_fetchrow($result))  	{ -		$notify_rows[$row['user_id']] = array( -			'user_id'		=> $row['user_id'], +		$notify_user_id = (int) $row['user_id']; +		$notify_rows[$notify_user_id] = array( +			'user_id'		=> $notify_user_id,  			'username'		=> $row['username'],  			'user_email'	=> $row['user_email'],  			'user_jabber'	=> $row['user_jabber'], @@ -1219,30 +1222,29 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id  			'method'		=> $row['user_notify_type'],  			'allowed'		=> false  		); + +		// Add users who have been already notified to ignore list +		$sql_ignore_users[$notify_user_id] = $notify_user_id;  	}  	$db->sql_freeresult($result);  	// forum notification is sent to those not already receiving topic notifications  	if ($topic_notification)  	{ -		if (sizeof($notify_rows)) -		{ -			$sql_ignore_users .= ', ' . implode(', ', array_keys($notify_rows)); -		} -  		$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber  			FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u  			WHERE fw.forum_id = $forum_id -				AND fw.user_id NOT IN ($sql_ignore_users) -				AND fw.notify_status = " . NOTIFY_YES . ' +				AND " . $db->sql_in_set('fw.user_id', $sql_ignore_users, true) . ' +				AND fw.notify_status = ' . NOTIFY_YES . '  				AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')  				AND u.user_id = fw.user_id';  		$result = $db->sql_query($sql);  		while ($row = $db->sql_fetchrow($result))  		{ -			$notify_rows[$row['user_id']] = array( -				'user_id'		=> $row['user_id'], +			$notify_user_id = (int) $row['user_id']; +			$notify_rows[$notify_user_id] = array( +				'user_id'		=> $notify_user_id,  				'username'		=> $row['username'],  				'user_email'	=> $row['user_email'],  				'user_jabber'	=> $row['user_jabber'], @@ -1273,7 +1275,6 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id  		}  	} -  	// Now, we have to do a little step before really sending, we need to distinguish our users a little bit. ;)  	$msg_users = $delete_ids = $update_notification = array();  	foreach ($notify_rows as $user_id => $row) @@ -1286,6 +1287,20 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id  		{  			$msg_users[] = $row;  			$update_notification[$row['notify_type']][] = $row['user_id']; + +			/* +			* We also update the forums watch table for this user when we are +			* sending out a topic notification to prevent sending out another +			* notification in case this user is also subscribed to the forum +			* this topic was posted in. +			* Since an UPDATE query is used, this has no effect on users only +			* subscribed to the topic (i.e. no row is created) and should not +			* be a performance issue. +			*/ +			if ($row['notify_type'] === 'topic') +			{ +				$update_notification['forum'][] = $row['user_id']; +			}  		}  	}  	unset($notify_rows); diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 00bec11569..d2fce000aa 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1782,6 +1782,7 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i  	$subject = censor_text($subject); +	// Exclude guests, current user and banned users from notifications  	unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]);  	if (!sizeof($recipients)) @@ -1789,18 +1790,12 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i  		return;  	} -	// Get banned User ID's -	$sql = 'SELECT ban_userid -		FROM ' . BANLIST_TABLE . ' -		WHERE ' . $db->sql_in_set('ban_userid', array_map('intval', array_keys($recipients))) . ' -			AND ban_exclude = 0'; -	$result = $db->sql_query($sql); - -	while ($row = $db->sql_fetchrow($result)) +	if (!function_exists('phpbb_get_banned_user_ids'))  	{ -		unset($recipients[$row['ban_userid']]); +		include($phpbb_root_path . 'includes/functions_user.' . $phpEx);  	} -	$db->sql_freeresult($result); +	$banned_users = phpbb_get_banned_user_ids(array_keys($recipients)); +	$recipients = array_diff(array_keys($recipients), $banned_users);  	if (!sizeof($recipients))  	{ @@ -1809,7 +1804,7 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i  	$sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber  		FROM ' . USERS_TABLE . ' -		WHERE ' . $db->sql_in_set('user_id', array_map('intval', array_keys($recipients))); +		WHERE ' . $db->sql_in_set('user_id', $recipients);  	$result = $db->sql_query($sql);  	$msg_list_ary = array(); diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index 1eae2a9ad6..16c193c15a 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -571,7 +571,12 @@ class custom_profile  					$this->get_option_lang($field_id, $lang_id, FIELD_DROPDOWN, false);  				} -				if ($value == $ident_ary['data']['field_novalue']) +				// If a dropdown field is required, users +				// cannot choose the "no value" option. +				// They must choose one of the other options. +				// Therefore, here we treat a value equal to +				// the "no value" as a lack of value, i.e. NULL. +				if ($value == $ident_ary['data']['field_novalue'] && $ident_ary['data']['field_required'])  				{  					return NULL;  				} @@ -625,10 +630,10 @@ class custom_profile  		$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];  		$user_ident = $profile_row['field_ident']; -		// checkbox - only testing for isset +		// checkbox - set the value to "true" if it has been set to 1  		if ($profile_row['field_type'] == FIELD_BOOL && $profile_row['field_length'] == 2)  		{ -			$value = (isset($_REQUEST[$profile_row['field_ident']])) ? true : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]); +			$value = (isset($_REQUEST[$profile_row['field_ident']]) && request_var($profile_row['field_ident'], $default_value) == 1) ? true : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]);  		}  		else if ($profile_row['field_type'] == FIELD_INT)  		{ diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 92a7b8e0e9..5a6a0b4a05 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1899,6 +1899,27 @@ function validate_jabber($jid)  }  /** +* Verifies whether a style ID corresponds to an active style. +* +* @param int $style_id The style_id of a style which should be checked if activated or not. +* @return boolean +*/ +function phpbb_style_is_active($style_id) +{ +	global $db; + +	$sql = 'SELECT style_active +		FROM ' . STYLES_TABLE . ' +		WHERE style_id = '. (int) $style_id; +	$result = $db->sql_query($sql); + +	$style_is_active = (bool) $db->sql_fetchfield('style_active'); +	$db->sql_freeresult($result); + +	return $style_is_active; +} + +/**  * Remove avatar  */  function avatar_delete($mode, $row, $clean_db = false) @@ -3537,4 +3558,37 @@ function remove_newly_registered($user_id, $user_data = false)  	return $user_data['group_id'];  } +/** +* Gets user ids of currently banned registered users. +* +* @param array $user_ids Array of users' ids to check for banning, +*						leave empty to get complete list of banned ids +* @return array	Array of banned users' ids if any, empty array otherwise +*/ +function phpbb_get_banned_user_ids($user_ids = array()) +{ +	global $db; + +	$sql_user_ids = (!empty($user_ids)) ? $db->sql_in_set('ban_userid', $user_ids) : 'ban_userid <> 0'; + +	// Get banned User ID's +	// Ignore stale bans which were not wiped yet +	$banned_ids_list = array(); +	$sql = 'SELECT ban_userid +		FROM ' . BANLIST_TABLE . " +		WHERE $sql_user_ids +			AND ban_exclude <> 1 +			AND (ban_end > " . time() . ' +				OR ban_end = 0)'; +	$result = $db->sql_query($sql); +	while ($row = $db->sql_fetchrow($result)) +	{ +		$user_id = (int) $row['ban_userid']; +		$banned_ids_list[$user_id] = $user_id; +	} +	$db->sql_freeresult($result); + +	return $banned_ids_list; +} +  ?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index d7cc1e795a..7d4edaf362 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -50,6 +50,16 @@ function mcp_topic_view($id, $mode, $action)  	$submitted_id_list	= request_var('post_ids', array(0));  	$checked_ids = $post_id_list = request_var('post_id_list', array(0)); +	// Resync Topic? +	if ($action == 'resync') +	{ +		if (!function_exists('mcp_resync_topics')) +		{ +			include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx); +		} +		mcp_resync_topics(array($topic_id)); +	} +  	// Split Topic?  	if ($action == 'split_all' || $action == 'split_beyond')  	{ @@ -320,6 +330,7 @@ function mcp_topic_view($id, $mode, $action)  		'S_CAN_APPROVE'		=> ($has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false,  		'S_CAN_LOCK'		=> ($auth->acl_get('m_lock', $topic_info['forum_id'])) ? true : false,  		'S_CAN_REPORT'		=> ($auth->acl_get('m_report', $topic_info['forum_id'])) ? true : false, +		'S_CAN_SYNC'		=> $auth->acl_get('m_', $topic_info['forum_id']),  		'S_REPORT_VIEW'		=> ($action == 'reports') ? true : false,  		'S_MERGE_VIEW'		=> ($action == 'merge') ? true : false,  		'S_SPLIT_VIEW'		=> ($action == 'split') ? true : false, diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 63e5b19155..1016204ff8 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -308,7 +308,7 @@ class mcp_warn  			include($phpbb_root_path . 'includes/functions_display.' . $phpEx);  		} -		$rank_title = $rank_img = ''; +		get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src);  		$avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']);  		$template->assign_vars(array( @@ -413,7 +413,7 @@ class mcp_warn  			include($phpbb_root_path . 'includes/functions_display.' . $phpEx);  		} -		$rank_title = $rank_img = ''; +		get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src);  		$avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']);  		// OK, they didn't submit a warning so lets build the page for them to do so diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 29cdd8ee9a..779ec1d216 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -707,7 +707,7 @@ class fulltext_mysql extends search_backend  	*/  	function index_remove($post_ids, $author_ids, $forum_ids)  	{ -		$this->destroy_cache(array(), $author_ids); +		$this->destroy_cache(array(), array_unique($author_ids));  	}  	/** @@ -896,11 +896,7 @@ class fulltext_mysql extends search_backend  		}  		$db->sql_freeresult($result); -		$sql = 'SELECT COUNT(post_id) as total_posts -			FROM ' . POSTS_TABLE; -		$result = $db->sql_query($sql); -		$this->stats['total_posts'] = (int) $db->sql_fetchfield('total_posts'); -		$db->sql_freeresult($result); +		$this->stats['total_posts'] = empty($this->stats) ? 0 : $db->get_estimated_row_count(POSTS_TABLE);  	}  	/** diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 727e3aaffb..dc961f3c8a 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -1334,7 +1334,7 @@ class fulltext_native extends search_backend  			$db->sql_query($sql);  		} -		$this->destroy_cache(array_unique($word_texts), $author_ids); +		$this->destroy_cache(array_unique($word_texts), array_unique($author_ids));  	}  	/** @@ -1461,17 +1461,8 @@ class fulltext_native extends search_backend  	{  		global $db; -		$sql = 'SELECT COUNT(*) as total_words -			FROM ' . SEARCH_WORDLIST_TABLE; -		$result = $db->sql_query($sql); -		$this->stats['total_words'] = (int) $db->sql_fetchfield('total_words'); -		$db->sql_freeresult($result); - -		$sql = 'SELECT COUNT(*) as total_matches -			FROM ' . SEARCH_WORDMATCH_TABLE; -		$result = $db->sql_query($sql); -		$this->stats['total_matches'] = (int) $db->sql_fetchfield('total_matches'); -		$db->sql_freeresult($result); +		$this->stats['total_words']		= $db->get_estimated_row_count(SEARCH_WORDLIST_TABLE); +		$this->stats['total_matches']	= $db->get_estimated_row_count(SEARCH_WORDMATCH_TABLE);  	}  	/** diff --git a/phpBB/includes/search/search.php b/phpBB/includes/search/search.php index 2f20d11495..df7c8a0892 100644 --- a/phpBB/includes/search/search.php +++ b/phpBB/includes/search/search.php @@ -295,7 +295,7 @@ class search_backend  			$sql_where = '';  			foreach ($authors as $author)  			{ -				$sql_where .= (($sql_where) ? ' OR ' : '') . 'search_authors LIKE \'% ' . (int) $author . ' %\''; +				$sql_where .= (($sql_where) ? ' OR ' : '') . 'search_authors ' . $db->sql_like_expression($db->any_char . ' ' . (int) $author . ' ' . $db->any_char);  			}  			$sql = 'SELECT search_key diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index bbe2f127f1..cf216a65db 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -19,7 +19,23 @@ if (!defined('E_DEPRECATED'))  {  	define('E_DEPRECATED', 8192);  } -error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); +$level = E_ALL & ~E_NOTICE & ~E_DEPRECATED; +if (version_compare(PHP_VERSION, '5.4.0-dev', '>=')) +{ +	// PHP 5.4 adds E_STRICT to E_ALL. +	// Our utf8 normalizer triggers E_STRICT output on PHP 5.4. +	// Unfortunately it cannot be made E_STRICT-clean while +	// continuing to work on PHP 4. +	// Therefore, in phpBB 3.0.x we disable E_STRICT on PHP 5.4+, +	// while phpBB 3.1 will fix utf8 normalizer. +	// E_STRICT is defined starting with PHP 5 +	if (!defined('E_STRICT')) +	{ +		define('E_STRICT', 2048); +	} +	$level &= ~E_STRICT; +} +error_reporting($level);  /*  * Remove variables created by register_globals from the global scope diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 13167b2b3d..17d7d23f02 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -61,7 +61,14 @@ class ucp_prefs  				if ($submit)  				{ -					$data['style'] = ($config['override_user_style']) ? $config['default_style'] : $data['style']; +					if ($config['override_user_style']) +					{ +						$data['style'] = (int) $config['default_style']; +					} +					else if (!phpbb_style_is_active($data['style'])) +					{ +						$data['style'] = (int) $user->data['user_style']; +					}  					$error = validate_data($data, array(  						'dateformat'	=> array('string', false, 1, 30),  | 
