diff options
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/acp/acp_board.php | 21 | ||||
| -rw-r--r-- | phpBB/includes/acp/acp_database.php | 1 | ||||
| -rw-r--r-- | phpBB/includes/acp/acp_jabber.php | 7 | ||||
| -rw-r--r-- | phpBB/includes/acp/acp_main.php | 2 | ||||
| -rw-r--r-- | phpBB/includes/acp/acp_prune.php | 4 | ||||
| -rw-r--r-- | phpBB/includes/acp/acp_search.php | 4 | ||||
| -rw-r--r-- | phpBB/includes/bbcode.php | 34 | ||||
| -rw-r--r-- | phpBB/includes/functions.php | 8 | ||||
| -rw-r--r-- | phpBB/includes/functions_acp.php | 7 | ||||
| -rw-r--r-- | phpBB/includes/functions_admin.php | 25 | ||||
| -rw-r--r-- | phpBB/includes/functions_display.php | 73 | ||||
| -rw-r--r-- | phpBB/includes/functions_module.php | 4 | ||||
| -rw-r--r-- | phpBB/includes/functions_posting.php | 2 | ||||
| -rw-r--r-- | phpBB/includes/functions_upload.php | 2 | ||||
| -rw-r--r-- | phpBB/includes/functions_user.php | 35 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_front.php | 37 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 4 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_post.php | 47 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_reports.php | 59 | ||||
| -rw-r--r-- | phpBB/includes/message_parser.php | 35 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_pm_compose.php | 2 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_prefs.php | 2 | 
22 files changed, 367 insertions, 48 deletions
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 63e2647f02..4a1c74fd77 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -500,7 +500,7 @@ class acp_board  		}  		// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... -		foreach ($display_vars['vars'] as $config_name => $null) +		foreach ($display_vars['vars'] as $config_name => $data)  		{  			if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)  			{ @@ -514,7 +514,8 @@ class acp_board  			if ($config_name == 'guest_style')  			{ -				if (isset($cfg_array[$config_name])) { +				if (isset($cfg_array[$config_name])) +				{  					$this->guest_style_set($cfg_array[$config_name]);  				}  				continue; @@ -531,6 +532,13 @@ class acp_board  			if ($submit)  			{ +				if (strpos($data['type'], 'password') === 0 && $config_value === '********') +				{ +					// Do not update password fields if the content is ********, +					// because that is the password replacement we use to not +					// send the password to the output +					continue; +				}  				set_config($config_name, $config_value);  				if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable'])) @@ -559,6 +567,7 @@ class acp_board  			$old_auth_config = array();  			foreach ($auth_providers as $provider)  			{ +				/** @var \phpbb\auth\provider\provider_interface $provider */  				if ($fields = $provider->acp())  				{  					// Check if we need to create config fields for this plugin and save config when submit was pressed @@ -574,6 +583,14 @@ class acp_board  							continue;  						} +						if (substr($field, -9) === '_password' && $cfg_array[$field] === '********') +						{ +							// Do not update password fields if the content is ********, +							// because that is the password replacement we use to not +							// send the password to the output +							continue; +						} +  						$old_auth_config[$field] = $this->new_config[$field];  						$config_value = $cfg_array[$field];  						$this->new_config[$field] = $config_value; diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index 0c52f82459..c5aebf011d 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -1173,6 +1173,7 @@ class postgres_extractor extends base_extractor  				$this->flush($sql_data . ";\n");  			}  		} +		$db->sql_freeresult($result);  		$sql_data = '-- Table: ' . $table_name . "\n";  		$sql_data .= "DROP TABLE $table_name;\n"; diff --git a/phpBB/includes/acp/acp_jabber.php b/phpBB/includes/acp/acp_jabber.php index 8d2e9d41a3..284543acd3 100644 --- a/phpBB/includes/acp/acp_jabber.php +++ b/phpBB/includes/acp/acp_jabber.php @@ -107,7 +107,10 @@ class acp_jabber  			set_config('jab_host', $jab_host);  			set_config('jab_port', $jab_port);  			set_config('jab_username', $jab_username); -			set_config('jab_password', $jab_password); +			if ($jab_password !== '********') +			{ +				set_config('jab_password', $jab_password); +			}  			set_config('jab_package_size', $jab_package_size);  			set_config('jab_use_ssl', $jab_use_ssl); @@ -122,7 +125,7 @@ class acp_jabber  			'JAB_HOST'				=> $jab_host,  			'JAB_PORT'				=> ($jab_port) ? $jab_port : '',  			'JAB_USERNAME'			=> $jab_username, -			'JAB_PASSWORD'			=> $jab_password, +			'JAB_PASSWORD'			=> $jab_password !== '' ? '********' : '',  			'JAB_PACKAGE_SIZE'		=> $jab_package_size,  			'JAB_USE_SSL'			=> $jab_use_ssl,  			'S_CAN_USE_SSL'			=> jabber::can_use_ssl(), diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 48ca05a118..f6d728ffed 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -632,7 +632,7 @@ class acp_main  		{  			$error = false;  			$search_type = $config['search_type']; -			$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); +			$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);  			if (!$search->index_created())  			{ diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index 6eb213fd7a..c68f26fc13 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -507,7 +507,7 @@ class acp_prune  					AND ug.user_id <> ' . ANONYMOUS . '  					AND u.user_type <> ' . USER_FOUNDER . '  					AND ug.user_pending = 0 ' . -					((!empty($user_ids)) ? ' AND ' . $db->sql_in_set('ug.user_id', $user_ids) : '') . ' +					(!empty($user_ids) ? ' AND ' . $db->sql_in_set('ug.user_id', $user_ids) : '') . '  					AND u.user_id = ug.user_id';  			$result = $db->sql_query($sql); @@ -533,7 +533,7 @@ class acp_prune  				FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u  				WHERE u.user_id <> ' . ANONYMOUS . '  					AND u.user_type <> ' . USER_FOUNDER . -					((!empty($user_ids)) ? ' AND ' . $db->sql_in_set('p.poster_id', $user_ids) : '') . ' +					(!empty($user_ids) ? ' AND ' . $db->sql_in_set('p.poster_id', $user_ids) : '') . '  					AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . '  					AND u.user_id = p.poster_id  				GROUP BY p.poster_id diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 9ff999567a..abb8301507 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -598,7 +598,7 @@ class acp_search  	*/  	function init_search($type, &$search, &$error)  	{ -		global $phpbb_root_path, $phpEx, $user, $auth, $config, $db; +		global $phpbb_root_path, $phpEx, $user, $auth, $config, $db, $phpbb_dispatcher;  		if (!class_exists($type) || !method_exists($type, 'keyword_search'))  		{ @@ -607,7 +607,7 @@ class acp_search  		}  		$error = false; -		$search = new $type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); +		$search = new $type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);  		return $error;  	} diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 5f6dcde448..86390c0901 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -182,6 +182,8 @@ class bbcode  			$db->sql_freeresult($result);  		} +		// To perform custom second pass in extension, use $this->bbcode_second_pass_by_extension() +		// method which accepts variable number of parameters  		foreach ($bbcode_ids as $bbcode_id)  		{  			switch ($bbcode_id) @@ -613,4 +615,36 @@ class bbcode  		return $code;  	} + +	/** +	* Function to perform custom bbcode second pass by extensions +	* can be used to assign bbcode pattern replacement +	* Example: '#\[list=([^\[]+):$uid\]#e'	=> "\$this->bbcode_second_pass_by_extension('\$1')" +	* +	* Accepts variable number of parameters +	* +	* @return mixed Second pass result +	*/ +	function bbcode_second_pass_by_extension() +	{ +		global $phpbb_dispatcher; + +		$return = false; +		$params_array = func_get_args(); + +		/** +		* Event to perform bbcode second pass with +		* the custom validating methods provided by extensions +		* +		* @event core.bbcode_second_pass_by_extension +		* @var array	params_array	Array with the function parameters +		* @var mixed	return			Second pass result to return +		* +		* @since 3.1.5-RC1 +		*/ +		$vars = array('params_array', 'return'); +		extract($phpbb_dispatcher->trigger_event('core.bbcode_second_pass_by_extension', compact($vars))); + +		return $return; +	}  } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4fdeb12d3a..705222d66b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1159,7 +1159,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $  	/**  	 * This event is used for performing actions directly before marking forums,  	 * topics or posts as read. -	 *  +	 *  	 * It is also possible to prevent the marking. For that, the $should_markread parameter  	 * should be set to FALSE.  	 * @@ -2309,7 +2309,7 @@ function redirect($url, $return = false, $disable_cd_check = false)  		// Attention: only able to redirect within the same domain if $disable_cd_check is false (yourdomain.com -> www.yourdomain.com will not work)  		if (!$disable_cd_check && $url_parts['host'] !== $user->host)  		{ -			$url = generate_board_url(); +			trigger_error('INSECURE_REDIRECT', E_USER_ERROR);  		}  	}  	else if ($url[0] == '/') @@ -2347,7 +2347,7 @@ function redirect($url, $return = false, $disable_cd_check = false)  	// Clean URL and check if we go outside the forum directory  	$url = $phpbb_path_helper->clean_url($url); -	if (!$disable_cd_check && strpos($url, generate_board_url(true)) === false) +	if (!$disable_cd_check && strpos($url, generate_board_url(true) . '/') !== 0)  	{  		trigger_error('INSECURE_REDIRECT', E_USER_ERROR);  	} @@ -2389,7 +2389,7 @@ function redirect($url, $return = false, $disable_cd_check = false)  	}  	// Redirect via an HTML form for PITA webservers -	if (@preg_match('#Microsoft|WebSTAR|Xitami#', getenv('SERVER_SOFTWARE'))) +	if (@preg_match('#WebSTAR|Xitami#', getenv('SERVER_SOFTWARE')))  	{  		header('Refresh: 0; URL=' . $url); diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index a53a54368e..d566336d26 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -245,8 +245,13 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)  	switch ($tpl_type[0])  	{ -		case 'text':  		case 'password': +			if ($new[$config_key] !== '') +			{ +				// replace passwords with asterixes +				$new[$config_key] = '********'; +			} +		case 'text':  		case 'url':  		case 'email':  		case 'color': diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 79f9db2f3f..afd3dce730 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -500,7 +500,7 @@ function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png')  */  function move_topics($topic_ids, $forum_id, $auto_sync = true)  { -	global $db; +	global $db, $phpbb_dispatcher;  	if (empty($topic_ids))  	{ @@ -534,6 +534,27 @@ function move_topics($topic_ids, $forum_id, $auto_sync = true)  	}  	$table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + +	/** +	 * Perform additional actions before topics move +	 * +	 * @event core.move_topics_before_query +	 * @var	array	table_ary	Array of tables from which forum_id will be updated for all rows that hold the moved topics +	 * @var	array	topic_ids	Array of the moved topic ids +	 * @var	string	forum_id	The forum id from where the topics are moved +	 * @var	array	forum_ids	Array of the forums where the topics are moving (includes also forum_id) +	 * @var bool	auto_sync	Whether or not to perform auto sync +	 * @since 3.1.5-RC1 +	 */ +	$vars = array( +			'table_ary', +			'topic_ids', +			'forum_id', +			'forum_ids', +			'auto_sync', +	); +	extract($phpbb_dispatcher->trigger_event('core.move_topics_before_query', compact($vars))); +  	foreach ($table_ary as $table)  	{  		$sql = "UPDATE $table @@ -920,7 +941,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =  	}  	$error = false; -	$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); +	$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);  	if ($error)  	{ diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index b62b514293..8aee80ba34 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -150,7 +150,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod  	$sql = $db->sql_build_query('SELECT', $sql_ary);  	$result = $db->sql_query($sql); -	$forum_tracking_info = array(); +	$forum_tracking_info = $valid_categories = array();  	$branch_root_id = $root_data['forum_id'];  	$phpbb_content_visibility = $phpbb_container->get('content.visibility'); @@ -250,6 +250,12 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod  			}  		} +		// Fill list of categories with forums +		if (isset($forum_rows[$row['parent_id']])) +		{ +			$valid_categories[$row['parent_id']] = true; +		} +  		//  		if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id)  		{ @@ -267,6 +273,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod  				$branch_root_id = $forum_id;  			}  			$forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id']; +			$forum_rows[$parent_id]['forum_password_last_post'] = $row['forum_password'];  			$forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];  		}  		else if ($row['forum_type'] != FORUM_CAT) @@ -308,6 +315,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod  				$forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];  				$forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour'];  				$forum_rows[$parent_id]['forum_id_last_post'] = $forum_id; +				$forum_rows[$parent_id]['forum_password_last_post'] = $row['forum_password'];  			}  		} @@ -404,6 +412,12 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod  		// Category  		if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT)  		{ +			// Do not display categories without any forums to display +			if (!isset($valid_categories[$row['forum_id']])) +			{ +				continue; +			} +  			$cat_row = array(  				'S_IS_CAT'				=> true,  				'FORUM_ID'				=> $row['forum_id'], @@ -522,8 +536,15 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod  		// Create last post link information, if appropriate  		if ($row['forum_last_post_id'])  		{ -			$last_post_subject = $row['forum_last_post_subject']; -			$last_post_subject_truncated = truncate_string(censor_text($last_post_subject), 30, 255, false, $user->lang['ELLIPSIS']); +			if ($row['forum_password_last_post'] === '' && $auth->acl_get('f_read', $row['forum_id_last_post'])) +			{ +				$last_post_subject = censor_text($row['forum_last_post_subject']); +				$last_post_subject_truncated = truncate_string($last_post_subject, 30, 255, false, $user->lang['ELLIPSIS']); +			} +			else +			{ +				$last_post_subject = $last_post_subject_truncated = ''; +			}  			$last_post_time = $user->format_date($row['forum_last_post_time']);  			$last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id_last_post'] . '&p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];  		} @@ -583,7 +604,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod  			'S_LOCKED_FORUM'	=> ($row['forum_status'] == ITEM_LOCKED) ? true : false,  			'S_LIST_SUBFORUMS'	=> ($row['display_subforum_list']) ? true : false,  			'S_SUBFORUMS'		=> (sizeof($subforums_list)) ? true : false, -			'S_DISPLAY_SUBJECT'	=>	($last_post_subject && $config['display_last_subject'] && !$row['forum_password'] && $auth->acl_get('f_read', $row['forum_id'])) ? true : false, +			'S_DISPLAY_SUBJECT'	=>	($last_post_subject !== '' && $config['display_last_subject']) ? true : false,  			'S_FEED_ENABLED'	=> ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']) && $row['forum_type'] == FORUM_POST) ? true : false,  			'FORUM_ID'				=> $row['forum_id'], @@ -596,8 +617,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod  			'FORUM_FOLDER_IMG_ALT'	=> isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '',  			'FORUM_IMAGE'			=> ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '',  			'FORUM_IMAGE_SRC'		=> ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', -			'LAST_POST_SUBJECT'		=> (!$row['forum_password'] && $auth->acl_get('f_read', $row['forum_id'])) ? censor_text($last_post_subject) : "", -			'LAST_POST_SUBJECT_TRUNCATED'	=> (!$row['forum_password'] && $auth->acl_get('f_read', $row['forum_id'])) ? $last_post_subject_truncated : "", +			'LAST_POST_SUBJECT'		=> $last_post_subject, +			'LAST_POST_SUBJECT_TRUNCATED'	=> $last_post_subject_truncated,  			'LAST_POST_TIME'		=> $last_post_time,  			'LAST_POSTER'			=> get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),  			'LAST_POSTER_COLOUR'	=> get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), @@ -732,13 +753,15 @@ function generate_forum_rules(&$forum_data)  function generate_forum_nav(&$forum_data)  {  	global $db, $user, $template, $auth, $config; -	global $phpEx, $phpbb_root_path; +	global $phpEx, $phpbb_root_path, $phpbb_dispatcher;  	if (!$auth->acl_get('f_list', $forum_data['forum_id']))  	{  		return;  	} +	$navlinks = $navlinks_parents = $forum_template_data = array(); +  	// Get forum parents  	$forum_parents = get_forum_parents($forum_data); @@ -757,35 +780,59 @@ function generate_forum_nav(&$forum_data)  				continue;  			} -			$template->assign_block_vars('navlinks', array( +			$navlinks_parents[] = array(  				'S_IS_CAT'		=> ($parent_type == FORUM_CAT) ? true : false,  				'S_IS_LINK'		=> ($parent_type == FORUM_LINK) ? true : false,  				'S_IS_POST'		=> ($parent_type == FORUM_POST) ? true : false,  				'FORUM_NAME'	=> $parent_name,  				'FORUM_ID'		=> $parent_forum_id,  				'MICRODATA'		=> $microdata_attr . '="' . $parent_forum_id . '"', -				'U_VIEW_FORUM'	=> append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $parent_forum_id)) +				'U_VIEW_FORUM'	=> append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $parent_forum_id),  			);  		}  	} -	$template->assign_block_vars('navlinks', array( +	$navlinks = array(  		'S_IS_CAT'		=> ($forum_data['forum_type'] == FORUM_CAT) ? true : false,  		'S_IS_LINK'		=> ($forum_data['forum_type'] == FORUM_LINK) ? true : false,  		'S_IS_POST'		=> ($forum_data['forum_type'] == FORUM_POST) ? true : false,  		'FORUM_NAME'	=> $forum_data['forum_name'],  		'FORUM_ID'		=> $forum_data['forum_id'],  		'MICRODATA'		=> $microdata_attr . '="' . $forum_data['forum_id'] . '"', -		'U_VIEW_FORUM'	=> append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_data['forum_id'])) +		'U_VIEW_FORUM'	=> append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_data['forum_id']),  	); -	$template->assign_vars(array( +	$forum_template_data = array(  		'FORUM_ID' 		=> $forum_data['forum_id'],  		'FORUM_NAME'	=> $forum_data['forum_name'],  		'FORUM_DESC'	=> generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options']),  		'S_ENABLE_FEEDS_FORUM'	=> ($config['feed_forum'] && $forum_data['forum_type'] == FORUM_POST && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data['forum_options'])) ? true : false, -	)); +	); + +	/** +	* Event to modify the navlinks text +	* +	* @event core.generate_forum_nav +	* @var	array	forum_data				Array with the forum data +	* @var	array	forum_template_data		Array with generic forum template data +	* @var	string	microdata_attr			The microdata attribute +	* @var	array	navlinks_parents		Array with the forum parents navlinks data +	* @var	array	navlinks				Array with the forum navlinks data +	* @since 3.1.5-RC1 +	*/ +	$vars = array( +		'forum_data', +		'forum_template_data', +		'microdata_attr', +		'navlinks_parents', +		'navlinks', +	); +	extract($phpbb_dispatcher->trigger_event('core.generate_forum_nav', compact($vars))); + +	$template->assign_block_vars_array('navlinks', $navlinks_parents); +	$template->assign_block_vars('navlinks', $navlinks); +	$template->assign_vars($forum_template_data);  	return;  } diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index fe9bcdb9d1..90d59cfd1e 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -976,7 +976,7 @@ class p_master  	*  	* @param string $class module class (acp/mcp/ucp)  	* @param string $name module name (class name of the module, or its basename -    *                     phpbb_ext_foo_acp_bar_module, ucp_zebra or zebra) +	*                     phpbb_ext_foo_acp_bar_module, ucp_zebra or zebra)  	* @param string $mode mode, as passed through to the module  	*  	*/ @@ -1086,7 +1086,7 @@ class p_master  			->core_path('language/' . $user->lang_name . '/mods/')  			->find(); -		$lang_files = array_unique(array_merge($user_lang_files, $english_lang_files, $default_lang_files)); +		$lang_files = array_merge($english_lang_files, $default_lang_files, $user_lang_files);  		foreach ($lang_files as $lang_file => $ext_name)  		{  			$user->add_lang_ext($ext_name, $lang_file); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index a06d6f4c35..4f3b7ecfcf 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2209,7 +2209,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u  		}  		$error = false; -		$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); +		$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);  		if ($error)  		{ diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index f179b2fd70..89bc31fa25 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -213,6 +213,8 @@ class filespec  	*/  	static public function get_extension($filename)  	{ +		$filename = utf8_basename($filename); +  		if (strpos($filename, '.') === false)  		{  			return ''; diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 9cd662027e..815f07d2e4 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -500,6 +500,9 @@ function user_delete($mode, $user_ids, $retain_username = true)  	$num_users_delta = 0; +	// Get auth provider collection in case accounts might need to be unlinked +	$provider_collection = $phpbb_container->get('auth.provider_collection'); +  	// Some things need to be done in the loop (if the query changes based  	// on which user is currently being deleted)  	$added_guest_posts = 0; @@ -510,6 +513,38 @@ function user_delete($mode, $user_ids, $retain_username = true)  			avatar_delete('user', $user_row);  		} +		// Unlink accounts +		foreach ($provider_collection as $provider_name => $auth_provider) +		{ +			$provider_data = $auth_provider->get_auth_link_data($user_id); + +			if ($provider_data !== null) +			{ +				$link_data = array( +					'user_id' => $user_id, +					'link_method' => 'user_delete', +				); + +				// BLOCK_VARS might contain hidden fields necessary for unlinking accounts +				if (isset($provider_data['BLOCK_VARS']) && is_array($provider_data['BLOCK_VARS'])) +				{ +					foreach ($provider_data['BLOCK_VARS'] as $provider_service) +					{ +						if (!array_key_exists('HIDDEN_FIELDS', $provider_service)) +						{ +							$provider_service['HIDDEN_FIELDS'] = array(); +						} + +						$auth_provider->unlink_account(array_merge($link_data, $provider_service['HIDDEN_FIELDS'])); +					} +				} +				else +				{ +					$auth_provider->unlink_account($link_data); +				} +			} +		} +  		// Decrement number of users if this user is active  		if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE)  		{ diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 500db55456..629b6fd275 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -41,10 +41,27 @@ function mcp_front_view($id, $mode, $action)  		if (!empty($forum_list))  		{ -			$sql = 'SELECT COUNT(post_id) AS total -				FROM ' . POSTS_TABLE . ' -				WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' -					AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); +			$sql_ary = array( +				'SELECT' => 'COUNT(post_id) AS total', +				'FROM' => array( +						POSTS_TABLE => 'p', +					), +				'WHERE' => $db->sql_in_set('p.forum_id', $forum_list) . ' +					AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) +			); + +			/** +			* Allow altering the query to get the number of unapproved posts +			* +			* @event core.mcp_front_queue_unapproved_total_before +			* @var	int		sql_ary						Query to get the total number of unapproved posts +			* @var	array	forum_list					List of forums to look for unapproved posts +			* @since 3.1.5-RC1 +			*/ +			$vars = array('sql_ary', 'forum_list'); +			extract($phpbb_dispatcher->trigger_event('core.mcp_front_queue_unapproved_total_before', compact($vars))); + +			$sql = $db->sql_build_query('SELECT', $sql_ary);  			$result = $db->sql_query($sql);  			$total = (int) $db->sql_fetchfield('total');  			$db->sql_freeresult($result); @@ -157,6 +174,18 @@ function mcp_front_view($id, $mode, $action)  					AND r.pm_id = 0  					AND r.report_closed = 0  					AND ' . $db->sql_in_set('p.forum_id', $forum_list); + +			/** +			* Alter sql query to count the number of reported posts +			* +			* @event core.mcp_front_reports_count_query_before +			* @var	int		sql				The query string used to get the number of reports that exist +			* @var	array	forum_list		List of forums that contain the posts +			* @since 3.1.5-RC1 +			*/ +			$vars = array('sql', 'forum_list'); +			extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_count_query_before', compact($vars))); +  			$result = $db->sql_query($sql);  			$total = (int) $db->sql_fetchfield('total');  			$db->sql_freeresult($result); diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 10f1a5b8c1..fc28968101 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1144,7 +1144,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',  function mcp_fork_topic($topic_ids)  {  	global $auth, $user, $db, $template, $config; -	global $phpEx, $phpbb_root_path; +	global $phpEx, $phpbb_root_path, $phpbb_dispatcher;  	if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))  	{ @@ -1222,7 +1222,7 @@ function mcp_fork_topic($topic_ids)  				}  				$error = false; -				$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); +				$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);  				$search_mode = 'post';  				if ($error) diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index 1687409198..f0fc0a3f06 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -26,6 +26,7 @@ function mcp_post_details($id, $mode, $action)  {  	global $phpEx, $phpbb_root_path, $config;  	global $template, $db, $user, $auth, $cache; +	global $phpbb_dispatcher;  	$user->add_lang('posting'); @@ -106,6 +107,21 @@ function mcp_post_details($id, $mode, $action)  			}  		break; + +		default: + +			/** +			* This event allows you to handle custom post moderation options +			* +			* @event core.mcp_post_additional_options +			* @var	string	action		Post moderation action name +			* @var	array	post_info	Information on the affected post +			* @since 3.1.5-RC1 +			*/ +			$vars = array('action', 'post_info'); +			extract($phpbb_dispatcher->trigger_event('core.mcp_post_additional_options', compact($vars))); + +		break;  	}  	// Set some vars @@ -197,7 +213,7 @@ function mcp_post_details($id, $mode, $action)  		$l_deleted_by = '';  	} -	$template->assign_vars(array( +	$mcp_post_template_data = array(  		'U_MCP_ACTION'			=> "$url&i=main&quickmod=1&mode=post_details", // Use this for mode paramaters  		'U_POST_ACTION'			=> "$url&i=$id&mode=post_details", // Use this for action parameters  		'U_APPROVE_ACTION'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f={$post_info['forum_id']}"), @@ -249,7 +265,32 @@ function mcp_post_details($id, $mode, $action)  		'U_LOOKUP_IP'			=> ($auth->acl_get('m_info', $post_info['forum_id'])) ? "$url&i=$id&mode=$mode&lookup={$post_info['poster_ip']}#ip" : '',  		'U_WHOIS'				=> ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&mode=$mode&action=whois&p=$post_id&ip={$post_info['poster_ip']}") : '', -	)); +	); + +	$s_additional_opts = false; + +	/** +	* Event to add/modify MCP post template data +	* +	* @event core.mcp_post_template_data +	* @var	array	post_info					Array with the post information +	* @var	array	mcp_post_template_data		Array with the MCP post template data +	* @var	array	attachments					Array with the post attachments, if any +	* @var	bool	s_additional_opts			Must be set to true in extension if additional options are presented in MCP post panel +	* @since 3.1.5-RC1 +	*/ +	$vars = array( +		'post_info', +		'mcp_post_template_data', +		'attachments', +		's_additional_opts', +	); +	extract($phpbb_dispatcher->trigger_event('core.mcp_post_template_data', compact($vars))); + +	$template->assign_vars($mcp_post_template_data); +	$template->assign_var('S_MCP_POST_ADDITIONAL_OPTS', $s_additional_opts); + +	unset($mcp_post_template_data);  	// Get User Notes  	$log_data = array(); @@ -497,7 +538,7 @@ function change_poster(&$post_info, $userdata)  	{  		// We do some additional checks in the module to ensure it can actually be utilised  		$error = false; -		$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); +		$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);  		if (!$error && method_exists($search, 'destroy_cache'))  		{ diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 804d48ea97..fa2fed842f 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -73,18 +73,66 @@ class mcp_reports  				// closed reports are accessed by report id  				$report_id = request_var('r', 0); +				$sql_ary = array( +					'SELECT'	=> 'r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour', -				$sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour -					FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u -					WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' +					'FROM'		=> array( +						REPORTS_TABLE			=> 'r', +						REPORTS_REASONS_TABLE	=> 'rr', +						USERS_TABLE				=> 'u', +					), + +					'WHERE'		=> (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . '  						AND rr.reason_id = r.reason_id  						AND r.user_id = u.user_id -						AND r.pm_id = 0 -					ORDER BY report_closed ASC'; +						AND r.pm_id = 0', + +					'ORDER_BY'	=> 'report_closed ASC', +				); + +				/** +				* Allow changing the query to obtain the user-submitted report. +				* +				* @event core.mcp_reports_report_details_query_before +				* @var	array	sql_ary			The array in the format of the query builder with the query +				* @var	mixed	forum_id		The forum_id, the number in the f GET parameter +				* @var	int		post_id			The post_id of the report being viewed (if 0, it is meaningless) +				* @var	int		report_id		The report_id of the report being viewed +				* @since 3.1.5-RC1 +				*/ +				$vars = array( +					'sql_ary', +					'forum_id', +					'post_id', +					'report_id', +				); +				extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_before', compact($vars))); + +				$sql = $db->sql_build_query('SELECT', $sql_ary);  				$result = $db->sql_query_limit($sql, 1);  				$report = $db->sql_fetchrow($result);  				$db->sql_freeresult($result); +				/** +				* Allow changing the data obtained from the user-submitted report. +				* +				* @event core.mcp_reports_report_details_query_after +				* @var	array	sql_ary		The array in the format of the query builder with the query that had been executted +				* @var	mixed	forum_id	The forum_id, the number in the f GET parameter +				* @var	int		post_id		The post_id of the report being viewed (if 0, it is meaningless) +				* @var	int		report_id	The report_id of the report being viewed +				* @var	int		report		The query's resulting row. +				* @since 3.1.5-RC1 +				*/ +				$vars = array( +					'sql_ary', +					'forum_id', +					'post_id', +					'report_id', +					'report', +				); +				extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_after', compact($vars))); +  				if (!$report)  				{  					trigger_error('NO_REPORT'); @@ -489,6 +537,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)  	{  		$post_id_list[] = $row[$id_column];  	} +	$db->sql_freeresult($result);  	$post_id_list = array_unique($post_id_list);  	if ($pm) diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 63e027cd66..42ca9bf09d 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -128,6 +128,9 @@ class bbcode_firstpass extends bbcode  		// [quote] in second position.  		// To parse multiline URL we enable dotall option setting only for URL text  		// but not for link itself, thus [url][/url] is not affected. +		// +		// To perform custom validation in extension, use $this->validate_bbcode_by_extension() +		// method which accepts variable number of parameters  		$this->bbcodes = array(  			'code'			=> array('bbcode_id' => 8,	'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#uise' => "\$this->bbcode_code('\$1', '\$2')")),  			'quote'			=> array('bbcode_id' => 0,	'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#uise' => "\$this->bbcode_quote('\$0')")), @@ -1875,4 +1878,36 @@ class parse_message extends bbcode_firstpass  	{  		$this->mimetype_guesser = $mimetype_guesser;  	} + +	/** +	* Function to perform custom bbcode validation by extensions +	* can be used in bbcode_init() to assign regexp replacement +	* Example: 'regexp' => array('#\[b\](.*?)\[/b\]#uise' => "\$this->validate_bbcode_by_extension('\$1')") +	* +	* Accepts variable number of parameters +	* +	* @return mixed Validation result +	*/ +	public function validate_bbcode_by_extension() +	{ +		global $phpbb_dispatcher; + +		$return = false; +		$params_array = func_get_args(); + +		/** +		* Event to validate bbcode with the custom validating methods +		* provided by extensions +		* +		* @event core.validate_bbcode_by_extension +		* @var array	params_array	Array with the function parameters +		* @var mixed	return			Validation result to return +		* +		* @since 3.1.5-RC1 +		*/ +		$vars = array('params_array', 'return'); +		extract($phpbb_dispatcher->trigger_event('core.validate_bbcode_by_extension', compact($vars))); + +		return $return; +	}  } diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 51018e3a5d..8b7d42e9c9 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -55,7 +55,6 @@ function compose_pm($id, $mode, $action, $user_folders = array())  	$address_list	= $request->variable('address_list', array('' => array(0 => ''))); -	$submit		= (isset($_POST['post'])) ? true : false;  	$preview	= (isset($_POST['preview'])) ? true : false;  	$save		= (isset($_POST['save'])) ? true : false;  	$load		= (isset($_POST['load'])) ? true : false; @@ -69,6 +68,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())  	$refresh	= isset($_POST['add_file']) || isset($_POST['delete_file']) || $save || $load  		|| $remove_u || $remove_g || $add_to || $add_bcc; +	$submit = $request->is_set_post('post') && !$refresh && !$preview;  	$action		= ($delete && !$preview && !$refresh && $submit) ? 'delete' : $action;  	$select_single = ($config['allow_mass_pm'] && $auth->acl_get('u_masspm')) ? false : true; diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 1d3fb19f67..3c274b53c7 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -69,7 +69,7 @@ class ucp_prefs  				* @var	array	data		Array with current ucp options data  				* @var	array	error		Array with list of errors  				* @since 3.1.0-a1 -				* @changed 3.1.4-rc1 Added error variable to the event +				* @changed 3.1.4-RC1 Added error variable to the event  				*/  				$vars = array('submit', 'data', 'error');  				extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_data', compact($vars)));  | 
