diff options
Diffstat (limited to 'phpBB/phpbb')
161 files changed, 3609 insertions, 1311 deletions
| diff --git a/phpBB/phpbb/auth/provider/db.php b/phpBB/phpbb/auth/provider/db.php index 3be1d3873f..142a47247f 100644 --- a/phpBB/phpbb/auth/provider/db.php +++ b/phpBB/phpbb/auth/provider/db.php @@ -78,7 +78,7 @@ class db extends \phpbb\auth\provider\base  		$username_clean = utf8_clean_string($username); -		$sql = 'SELECT user_id, username, user_password, user_passchg, user_pass_convert, user_email, user_type, user_login_attempts +		$sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type, user_login_attempts  			FROM ' . USERS_TABLE . "  			WHERE username_clean = '" . $this->db->sql_escape($username_clean) . "'";  		$result = $this->db->sql_query($sql); @@ -170,72 +170,8 @@ class db extends \phpbb\auth\provider\base  		} -		// If the password convert flag is set we need to convert it -		if ($row['user_pass_convert']) -		{ -			// enable super globals to get literal value -			// this is needed to prevent unicode normalization -			$super_globals_disabled = $this->request->super_globals_disabled(); -			if ($super_globals_disabled) -			{ -				$this->request->enable_super_globals(); -			} - -			// in phpBB2 passwords were used exactly as they were sent, with addslashes applied -			$password_old_format = isset($_REQUEST['password']) ? (string) $_REQUEST['password'] : ''; -			$password_old_format = (!STRIP) ? addslashes($password_old_format) : $password_old_format; -			$password_new_format = $this->request->variable('password', '', true); - -			if ($super_globals_disabled) -			{ -				$this->request->disable_super_globals(); -			} - -			if ($password == $password_new_format) -			{ -				if (!function_exists('utf8_to_cp1252')) -				{ -					include($this->phpbb_root_path . 'includes/utf/data/recode_basic.' . $this->php_ext); -				} - -				// cp1252 is phpBB2's default encoding, characters outside ASCII range might work when converted into that encoding -				// plain md5 support left in for conversions from other systems. -				if ((strlen($row['user_password']) == 34 && ($this->passwords_manager->check(md5($password_old_format), $row['user_password']) || $this->passwords_manager->check(md5(utf8_to_cp1252($password_old_format)), $row['user_password']))) -					|| (strlen($row['user_password']) == 32  && (md5($password_old_format) == $row['user_password'] || md5(utf8_to_cp1252($password_old_format)) == $row['user_password']))) -				{ -					$hash = $this->passwords_manager->hash($password_new_format); - -					// Update the password in the users table to the new format and remove user_pass_convert flag -					$sql = 'UPDATE ' . USERS_TABLE . ' -						SET user_password = \'' . $this->db->sql_escape($hash) . '\', -							user_pass_convert = 0 -						WHERE user_id = ' . $row['user_id']; -					$this->db->sql_query($sql); - -					$row['user_pass_convert'] = 0; -					$row['user_password'] = $hash; -				} -				else -				{ -					// Although we weren't able to convert this password we have to -					// increase login attempt count to make sure this cannot be exploited -					$sql = 'UPDATE ' . USERS_TABLE . ' -						SET user_login_attempts = user_login_attempts + 1 -						WHERE user_id = ' . (int) $row['user_id'] . ' -							AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX; -					$this->db->sql_query($sql); - -					return array( -						'status'		=> LOGIN_ERROR_PASSWORD_CONVERT, -						'error_msg'		=> 'LOGIN_ERROR_PASSWORD_CONVERT', -						'user_row'		=> $row, -					); -				} -			} -		} -  		// Check password ... -		if (!$row['user_pass_convert'] && $this->passwords_manager->check($password, $row['user_password'])) +		if ($this->passwords_manager->check($password, $row['user_password']))  		{  			// Check for old password hash...  			if ($this->passwords_manager->convert_flag || strlen($row['user_password']) == 32) @@ -244,8 +180,7 @@ class db extends \phpbb\auth\provider\base  				// Update the password in the users table to the new format  				$sql = 'UPDATE ' . USERS_TABLE . " -					SET user_password = '" . $this->db->sql_escape($hash) . "', -						user_pass_convert = 0 +					SET user_password = '" . $this->db->sql_escape($hash) . "'  					WHERE user_id = {$row['user_id']}";  				$this->db->sql_query($sql); diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 2230ce15d1..7b71e3c844 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -14,7 +14,6 @@  namespace phpbb\auth\provider\oauth;  use OAuth\Common\Consumer\Credentials; -use OAuth\Common\Http\Uri\Uri;  /**  * OAuth authentication provider for phpBB3 @@ -215,7 +214,7 @@ class oauth extends \phpbb\auth\provider\base  			}  			// Retrieve the user's account -			$sql = 'SELECT user_id, username, user_password, user_passchg, user_pass_convert, user_email, user_type, user_login_attempts +			$sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type, user_login_attempts  				FROM ' . $this->users_table . '  					WHERE user_id = ' . (int) $row['user_id'];  			$result = $this->db->sql_query($sql); @@ -224,7 +223,7 @@ class oauth extends \phpbb\auth\provider\base  			if (!$row)  			{ -				throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY'); +				throw new \Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY');  			}  			// Update token storage to store the user_id @@ -278,9 +277,10 @@ class oauth extends \phpbb\auth\provider\base  	* @param	array	$service_credentials	{@see \phpbb\auth\provider\oauth\oauth::get_service_credentials}  	* @param	string	$query					The query string of the  	*											current_uri used in redirection -	* @param	array	$scope					The scope of the request against +	* @param	array	$scopes					The scope of the request against  	*											the api.  	* @return	\OAuth\Common\Service\ServiceInterface +	* @throws	\Exception  	*/  	protected function get_service($service_name, \phpbb\auth\provider\oauth\token_storage $storage, array $service_credentials, $query, array $scopes = array())  	{ @@ -298,7 +298,7 @@ class oauth extends \phpbb\auth\provider\base  		if (!$service)  		{ -			throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_SERVICE_NOT_CREATED'); +			throw new \Exception('AUTH_PROVIDER_OAUTH_ERROR_SERVICE_NOT_CREATED');  		}  		return $service; @@ -617,7 +617,5 @@ class oauth extends \phpbb\auth\provider\base  		$service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']);  		$storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table);  		$storage->clearToken($service_name); - -		return;  	}  } diff --git a/phpBB/phpbb/auth/provider/oauth/service/facebook.php b/phpBB/phpbb/auth/provider/oauth/service/facebook.php index 31060c4ac4..bb98835e07 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/facebook.php +++ b/phpBB/phpbb/auth/provider/oauth/service/facebook.php @@ -21,22 +21,22 @@ class facebook extends base  	/**  	* phpBB config  	* -	* @var phpbb\config\config +	* @var \phpbb\config\config  	*/  	protected $config;  	/**  	* phpBB request  	* -	* @var phpbb\request\request_interface +	* @var \phpbb\request\request_interface  	*/  	protected $request;  	/**  	* Constructor  	* -	* @param	phpbb\config\config					$config -	* @param	phpbb\request\request_interface 	$request +	* @param	\phpbb\config\config				$config +	* @param	\phpbb\request\request_interface 	$request  	*/  	public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request)  	{ diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index c2d9e1f798..cb9f83a94f 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -21,22 +21,22 @@ class google extends base  	/**  	* phpBB config  	* -	* @var phpbb\config\config +	* @var \phpbb\config\config  	*/  	protected $config;  	/**  	* phpBB request  	* -	* @var phpbb\request\request_interface +	* @var \phpbb\request\request_interface  	*/  	protected $request;  	/**  	* Constructor  	* -	* @param	phpbb\config\config					$config -	* @param	phpbb\request\request_interface 	$request +	* @param	\phpbb\config\config				$config +	* @param	\phpbb\request\request_interface 	$request  	*/  	public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request)  	{ diff --git a/phpBB/phpbb/auth/provider/oauth/service/service_interface.php b/phpBB/phpbb/auth/provider/oauth/service/service_interface.php index 3744582b95..e84eb247b6 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/service_interface.php +++ b/phpBB/phpbb/auth/provider/oauth/service/service_interface.php @@ -67,7 +67,7 @@ interface service_interface  	/**  	* Sets the external library service provider  	* -	* @param	\OAuth\Common\Service\ServiceInterface	$service +	* @param	\OAuth\Common\Service\ServiceInterface	$service_provider  	*/  	public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider);  } diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index b7d32bf246..fe1a376cfe 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -17,7 +17,6 @@ namespace phpbb\auth\provider\oauth;  use OAuth\OAuth1\Token\StdOAuth1Token;  use OAuth\Common\Token\TokenInterface;  use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Storage\Exception\StorageException;  use OAuth\Common\Storage\Exception\TokenNotFoundException;  /** @@ -198,6 +197,7 @@ class token_storage implements TokenStorageInterface  	/**  	* Checks to see if an access token exists solely by the session_id of the user  	* +	* @param	string	$service	The name of the OAuth service  	* @return	bool	true if they have token, false if they don't  	*/  	public function has_access_token_by_session($service) @@ -250,6 +250,7 @@ class token_storage implements TokenStorageInterface  	*  	* @param	array	$data  	* @return	mixed +	* @throws \OAuth\Common\Storage\Exception\TokenNotFoundException  	*/  	protected function _retrieve_access_token($data)  	{ diff --git a/phpBB/phpbb/auth/provider/provider_interface.php b/phpBB/phpbb/auth/provider/provider_interface.php index 140353c88b..613297cefc 100644 --- a/phpBB/phpbb/auth/provider/provider_interface.php +++ b/phpBB/phpbb/auth/provider/provider_interface.php @@ -148,7 +148,7 @@ interface provider_interface  	* user_id of an account needed to successfully link an external account to  	* a forum account.  	* -	* @param	array	$link_data	Any data needed to link a phpBB account to +	* @param	array	$login_link_data	Any data needed to link a phpBB account to  	*								an external account.  	* @return	string|null	Returns a string with a language constant if there  	*						is data missing or null if there is no error. diff --git a/phpBB/phpbb/auth/provider_collection.php b/phpBB/phpbb/auth/provider_collection.php new file mode 100644 index 0000000000..a74a2135dc --- /dev/null +++ b/phpBB/phpbb/auth/provider_collection.php @@ -0,0 +1,65 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\auth; + +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** +* Collection of auth providers to be configured at container compile time. +*/ +class provider_collection extends \phpbb\di\service_collection +{ +	/** @var \phpbb\config\config phpBB Config */ +	protected $config; + +	/** +	* Constructor +	* +	* @param ContainerInterface $container Container object +	* @param \phpbb\config\config $config phpBB config +	*/ +	public function __construct(ContainerInterface $container, \phpbb\config\config $config) +	{ +		$this->container = $container; +		$this->config = $config; +	} + +	/** +	* Get an auth provider. +	* +	* @return object	Default auth provider selected in config if it +	*			does exist. Otherwise the standard db auth +	*			provider. +	* @throws \RuntimeException If neither the auth provider that +	*			is specified by the phpBB config nor the db +	*			auth provider exist. The db auth provider +	*			should always exist in a phpBB installation. +	*/ +	public function get_provider() +	{ +		if ($this->offsetExists('auth.provider.' . basename(trim($this->config['auth_method'])))) +		{ +			return $this->offsetGet('auth.provider.' . basename(trim($this->config['auth_method']))); +		} +		// Revert to db auth provider if selected method does not exist +		else if ($this->offsetExists('auth.provider.db')) +		{ +			return $this->offsetGet('auth.provider.db'); +		} +		else +		{ +			throw new \RuntimeException(sprintf('The authentication provider for the authentication method "%1$s" does not exist. It was not possible to recover from this by reverting to the database authentication provider.', $this->config['auth_method'])); +		} +	} +} diff --git a/phpBB/phpbb/avatar/driver/driver.php b/phpBB/phpbb/avatar/driver/driver.php index 9c769071d4..b3ced7edf7 100644 --- a/phpBB/phpbb/avatar/driver/driver.php +++ b/phpBB/phpbb/avatar/driver/driver.php @@ -73,10 +73,9 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface  	* Construct a driver object  	*  	* @param \phpbb\config\config $config phpBB configuration -	* @param \phpbb\request\request $request Request object  	* @param string $phpbb_root_path Path to the phpBB root  	* @param string $php_ext PHP file extension -	* @param \phpbb_path_helper $path_helper phpBB path helper +	* @param \phpbb\path_helper $path_helper phpBB path helper  	* @param \phpbb\cache\driver\driver_interface $cache Cache driver  	*/  	public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface $cache = null) @@ -89,7 +88,7 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_custom_html($user, $row, $alt = '')  	{ @@ -97,7 +96,7 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function prepare_form_acp($user)  	{ @@ -105,7 +104,7 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function delete($row)  	{ @@ -113,7 +112,7 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_name()  	{ diff --git a/phpBB/phpbb/avatar/driver/gravatar.php b/phpBB/phpbb/avatar/driver/gravatar.php index 34b894c2a7..4aa7445d20 100644 --- a/phpBB/phpbb/avatar/driver/gravatar.php +++ b/phpBB/phpbb/avatar/driver/gravatar.php @@ -24,7 +24,7 @@ class gravatar extends \phpbb\avatar\driver\driver  	const GRAVATAR_URL = '//secure.gravatar.com/avatar/';  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_data($row)  	{ @@ -36,7 +36,7 @@ class gravatar extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_custom_html($user, $row, $alt = '')  	{ @@ -47,7 +47,7 @@ class gravatar extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function prepare_form($request, $template, $user, $row, &$error)  	{ @@ -61,7 +61,7 @@ class gravatar extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function process_form($request, $template, $user, $row, &$error)  	{ @@ -81,7 +81,8 @@ class gravatar extends \phpbb\avatar\driver\driver  			array(  				'email' => array(  					array('string', false, 6, 60), -					array('email')) +					array('email'), +				),  			)  		); @@ -150,7 +151,7 @@ class gravatar extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_template_name()  	{ @@ -160,6 +161,8 @@ class gravatar extends \phpbb\avatar\driver\driver  	/**  	* Build gravatar URL for output on page  	* +	* @param array $row User data or group data that has been cleaned with +	*        \phpbb\avatar\manager::clean_row  	* @return string Gravatar URL  	*/  	protected function get_gravatar_url($row) diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php index 00e519e3f2..ff1996854b 100644 --- a/phpBB/phpbb/avatar/driver/local.php +++ b/phpBB/phpbb/avatar/driver/local.php @@ -19,7 +19,7 @@ namespace phpbb\avatar\driver;  class local extends \phpbb\avatar\driver\driver  {  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_data($row)  	{ @@ -31,12 +31,12 @@ class local extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function prepare_form($request, $template, $user, $row, &$error)  	{  		$avatar_list = $this->get_avatar_list($user); -		$category = $request->variable('avatar_local_cat', ''); +		$category = $request->variable('avatar_local_cat', key($avatar_list));  		foreach ($avatar_list as $cat => $null)  		{ @@ -99,7 +99,7 @@ class local extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function prepare_form_acp($user)  	{ @@ -109,7 +109,7 @@ class local extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function process_form($request, $template, $user, $row, &$error)  	{ @@ -131,14 +131,14 @@ class local extends \phpbb\avatar\driver\driver  		}  		return array( -			'avatar' => ($category != $user->lang['MAIN']) ? $category . '/' . $file : $file, +			'avatar' => ($category != $user->lang['NO_AVATAR_CATEGORY']) ? $category . '/' . $file : $file,  			'avatar_width' => $avatar_list[$category][urldecode($file)]['width'],  			'avatar_height' => $avatar_list[$category][urldecode($file)]['height'],  		);  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_template_name()  	{ @@ -179,9 +179,9 @@ class local extends \phpbb\avatar\driver\driver  					{  						$dims = array(0, 0);  					} -					$cat = ($path == $file_path) ? $user->lang['MAIN'] : str_replace("$path/", '', $file_path); +					$cat = ($path == $file_path) ? $user->lang['NO_AVATAR_CATEGORY'] : str_replace("$path/", '', $file_path);  					$avatar_list[$cat][$image] = array( -						'file'      => ($cat != $user->lang['MAIN']) ? rawurlencode($cat) . '/' . rawurlencode($image) : rawurlencode($image), +						'file'      => ($cat != $user->lang['NO_AVATAR_CATEGORY']) ? rawurlencode($cat) . '/' . rawurlencode($image) : rawurlencode($image),  						'filename'  => rawurlencode($image),  						'name'      => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))),  						'width'     => $dims[0], diff --git a/phpBB/phpbb/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php index d97093ae24..455ddebf62 100644 --- a/phpBB/phpbb/avatar/driver/remote.php +++ b/phpBB/phpbb/avatar/driver/remote.php @@ -19,7 +19,7 @@ namespace phpbb\avatar\driver;  class remote extends \phpbb\avatar\driver\driver  {  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_data($row)  	{ @@ -31,7 +31,7 @@ class remote extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function prepare_form($request, $template, $user, $row, &$error)  	{ @@ -45,7 +45,7 @@ class remote extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function process_form($request, $template, $user, $row, &$error)  	{ @@ -191,7 +191,7 @@ class remote extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_template_name()  	{ diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index bef75d61c1..c43004f340 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -19,7 +19,7 @@ namespace phpbb\avatar\driver;  class upload extends \phpbb\avatar\driver\driver  {  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_data($row, $ignore_config = false)  	{ @@ -31,7 +31,7 @@ class upload extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function prepare_form($request, $template, $user, $row, &$error)  	{ @@ -49,7 +49,7 @@ class upload extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function process_form($request, $template, $user, $row, &$error)  	{ @@ -72,7 +72,7 @@ class upload extends \phpbb\avatar\driver\driver  		{  			$file = $upload->form_upload('avatar_upload_file');  		} -		elseif (!empty($this->config['allow_avatar_remote_upload']) && !empty($url)) +		else if (!empty($this->config['allow_avatar_remote_upload']) && !empty($url))  		{  			if (!preg_match('#^(http|https|ftp)://#i', $url))  			{ @@ -143,7 +143,7 @@ class upload extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function prepare_form_acp($user)  	{ @@ -155,7 +155,7 @@ class upload extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function delete($row)  	{ @@ -171,7 +171,7 @@ class upload extends \phpbb\avatar\driver\driver  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_template_name()  	{ diff --git a/phpBB/phpbb/cache/driver/driver_interface.php b/phpBB/phpbb/cache/driver/driver_interface.php index 7d08362ed8..9ac9ca0c59 100644 --- a/phpBB/phpbb/cache/driver/driver_interface.php +++ b/phpBB/phpbb/cache/driver/driver_interface.php @@ -142,7 +142,7 @@ interface driver_interface  	* Fetch a field from the current row of a cached database result (database)  	*  	* @param int $query_id -	* @param $field 				The name of the column. +	* @param string $field 			The name of the column.  	* @return string|bool 			The field of the query result if found in the cache,  	* 								otherwise false.  	*/ diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 57890cc3a2..b32af32d25 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -28,6 +28,8 @@ class file extends \phpbb\cache\driver\base  	/**  	* Set cache path +	* +	* @param string $cache_dir Define the path to the cache directory (default: $phpbb_root_path . 'cache/')  	*/  	function __construct($cache_dir = null)  	{ @@ -222,7 +224,7 @@ class file extends \phpbb\cache\driver\base  			{  				$this->remove_dir($fileInfo->getPathname());  			} -			elseif (strpos($filename, 'container_') === 0 || +			else if (strpos($filename, 'container_') === 0 ||  				strpos($filename, 'url_matcher') === 0 ||  				strpos($filename, 'sql_') === 0 ||  				strpos($filename, 'data_') === 0) diff --git a/phpBB/phpbb/cache/service.php b/phpBB/phpbb/cache/service.php index c9aa6525c0..e47177758a 100644 --- a/phpBB/phpbb/cache/service.php +++ b/phpBB/phpbb/cache/service.php @@ -316,13 +316,6 @@ class service  					ORDER BY LEN(bot_agent) DESC';  				break; -				case 'firebird': -					$sql = 'SELECT user_id, bot_agent, bot_ip -						FROM ' . BOTS_TABLE . ' -						WHERE bot_active = 1 -					ORDER BY CHAR_LENGTH(bot_agent) DESC'; -				break; -  				// LENGTH supported by MySQL, IBM DB2 and Oracle for sure...  				default:  					$sql = 'SELECT user_id, bot_agent, bot_ip diff --git a/phpBB/phpbb/config/config.php b/phpBB/phpbb/config/config.php index 8cbe1e1e2d..aaad333006 100644 --- a/phpBB/phpbb/config/config.php +++ b/phpBB/phpbb/config/config.php @@ -37,7 +37,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable  	/**  	* Retrieves an ArrayIterator over the configuration values.  	* -	* @return ArrayIterator An iterator over all config data +	* @return \ArrayIterator An iterator over all config data  	*/  	public function getIterator()  	{ diff --git a/phpBB/phpbb/config/db_text.php b/phpBB/phpbb/config/db_text.php index fb8588334e..b1e3ef5da4 100644 --- a/phpBB/phpbb/config/db_text.php +++ b/phpBB/phpbb/config/db_text.php @@ -105,8 +105,8 @@ class db_text  			if (!$this->db->sql_affectedrows($result))  			{  				$sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', array( -					'config_name'	=> $key, -					'config_value'	=> $value, +					'config_name'	=> (string) $key, +					'config_value'	=> (string) $value,  				));  				$this->db->sql_query($sql);  			} diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index da2bfbb49a..b1f0635913 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -13,15 +13,93 @@  namespace phpbb\console; +use Symfony\Component\Console\Shell; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface;  use Symfony\Component\DependencyInjection\TaggedContainerInterface;  class application extends \Symfony\Component\Console\Application  { -	function register_container_commands(TaggedContainerInterface $container, $tag = 'console.command') +	/** +	* @var bool Indicates whether or not we are in a shell +	*/ +	protected $in_shell = false; + +	/** +	* @var \phpbb\user User object +	*/ +	protected $user; + +	/** +	* @param string			$name		The name of the application +	* @param string			$version	The version of the application +	* @param \phpbb\user	$user		The user which runs the application (used for translation) +	*/ +	public function __construct($name, $version, \phpbb\user $user) +	{ +		parent::__construct($name, $version); + +		$this->user = $user; +	} + +	/** +	* Gets the help message. +	* +	* It's a hack of the default help message to display the --shell +	* option only for the application and not for all the commands. +	* +	* @return string A help message. +	*/ +	public function getHelp() +	{ +		// If we are already in a shell +		// we do not want to have the --shell option available +		if ($this->in_shell) +		{ +			return parent::getHelp(); +		} + +		$this->getDefinition()->addOption(new InputOption( +			'--shell', +			'-s', +			InputOption::VALUE_NONE, +			$this->user->lang('CLI_DESCRIPTION_OPTION_SHELL') +		)); + +		return parent::getHelp(); +	} + +	/** +	* Register a set of commands from the container +	* +	* @param TaggedContainerInterface	$container	The container +	* @param string						$tag		The tag used to register the commands +	*/ +	public function register_container_commands(TaggedContainerInterface $container, $tag = 'console.command')  	{  		foreach($container->findTaggedServiceIds($tag) as $id => $void)  		{  			$this->add($container->get($id));  		}  	} + +	/** +	* {@inheritdoc} +	*/ +	public function doRun(InputInterface $input, OutputInterface $output) +	{ +		// Run a shell if the --shell (or -s) option is set and if no command name is specified +		// Also, we do not want to have the --shell option available if we are already in a shell +		if (!$this->in_shell && $this->getCommandName($input) === null && $input->hasParameterOption(array('--shell', '-s'))) +		{ +			$shell = new Shell($this); +			$this->in_shell = true; +			$shell->run(); + +			return 0; +		} + +		return parent::doRun($input, $output); +	}  } diff --git a/phpBB/phpbb/console/command/cache/purge.php b/phpBB/phpbb/console/command/cache/purge.php index 1e2adaeb4d..379d2aa1ca 100644 --- a/phpBB/phpbb/console/command/cache/purge.php +++ b/phpBB/phpbb/console/command/cache/purge.php @@ -35,6 +35,16 @@ class purge extends \phpbb\console\command\command  	/** @var \phpbb\config\config */  	protected $config; +	/** +	* Constructor +	* +	* @param \phpbb\cache\driver\driver_interface	$cache	Cache instance +	* @param \phpbb\db\driver\driver_interface		$db		Database connection +	* @param \phpbb\auth\auth						$auth	Auth instance +	* @param \phpbb\log\log							$log	Logger instance +	* @param \phpbb\user							$user	User instance +	* @param \phpbb\config\config					$config	Config instance +	*/  	public function __construct(\phpbb\cache\driver\driver_interface $cache, \phpbb\db\driver\driver_interface $db, \phpbb\auth\auth $auth, \phpbb\log\log $log, \phpbb\user $user, \phpbb\config\config $config)  	{  		$this->cache = $cache; @@ -43,10 +53,12 @@ class purge extends \phpbb\console\command\command  		$this->log = $log;  		$this->user = $user;  		$this->config = $config; -		$this->user->add_lang(array('acp/common'));  		parent::__construct();  	} +	/** +	* {@inheritdoc} +	*/  	protected function configure()  	{  		$this @@ -55,6 +67,16 @@ class purge extends \phpbb\console\command\command  		;  	} +	/** +	* Executes the command cache:purge. +	* +	* Purge the cache (including permissions) and increment the asset_version number +	* +	* @param InputInterface  $input  An InputInterface instance +	* @param OutputInterface $output An OutputInterface instance +	* +	* @return null +	*/  	protected function execute(InputInterface $input, OutputInterface $output)  	{  		$this->config->increment('assets_version', 1); diff --git a/phpBB/phpbb/console/command/config/delete.php b/phpBB/phpbb/console/command/config/delete.php index e29afdbf82..1310bb18b4 100644 --- a/phpBB/phpbb/console/command/config/delete.php +++ b/phpBB/phpbb/console/command/config/delete.php @@ -14,11 +14,13 @@ namespace phpbb\console\command\config;  use Symfony\Component\Console\Input\InputArgument;  use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption;  use Symfony\Component\Console\Output\OutputInterface;  class delete extends command  { +	/** +	* {@inheritdoc} +	*/  	protected function configure()  	{  		$this @@ -32,6 +34,17 @@ class delete extends command  		;  	} +	/** +	* Executes the command config:delete. +	* +	* Removes a configuration option +	* +	* @param InputInterface  $input  An InputInterface instance +	* @param OutputInterface $output An OutputInterface instance +	* +	* @return null +	* @see \phpbb\config\config::delete() +	*/  	protected function execute(InputInterface $input, OutputInterface $output)  	{  		$key = $input->getArgument('key'); diff --git a/phpBB/phpbb/console/command/config/get.php b/phpBB/phpbb/console/command/config/get.php index 0ed2a12608..ee8c65110e 100644 --- a/phpBB/phpbb/console/command/config/get.php +++ b/phpBB/phpbb/console/command/config/get.php @@ -19,6 +19,9 @@ use Symfony\Component\Console\Output\OutputInterface;  class get extends command  { +	/** +	* {@inheritdoc} +	*/  	protected function configure()  	{  		$this @@ -38,6 +41,17 @@ class get extends command  		;  	} +	/** +	* Executes the command config:get. +	* +	* Retrieves a configuration value. +	* +	* @param InputInterface  $input  An InputInterface instance +	* @param OutputInterface $output An OutputInterface instance +	* +	* @return null +	* @see \phpbb\config\config::offsetGet() +	*/  	protected function execute(InputInterface $input, OutputInterface $output)  	{  		$key = $input->getArgument('key'); @@ -46,7 +60,7 @@ class get extends command  		{  			$output->write($this->config[$key]);  		} -		elseif (isset($this->config[$key])) +		else if (isset($this->config[$key]))  		{  			$output->writeln($this->config[$key]);  		} diff --git a/phpBB/phpbb/console/command/config/increment.php b/phpBB/phpbb/console/command/config/increment.php index 64b5d42b9d..21f0660e61 100644 --- a/phpBB/phpbb/console/command/config/increment.php +++ b/phpBB/phpbb/console/command/config/increment.php @@ -19,6 +19,9 @@ use Symfony\Component\Console\Output\OutputInterface;  class increment extends command  { +	/** +	* {@inheritdoc} +	*/  	protected function configure()  	{  		$this @@ -43,6 +46,17 @@ class increment extends command  		;  	} +	/** +	* Executes the command config:increment. +	* +	* Increments an integer configuration value. +	* +	* @param InputInterface  $input  An InputInterface instance +	* @param OutputInterface $output An OutputInterface instance +	* +	* @return null +	* @see \phpbb\config\config::increment() +	*/  	protected function execute(InputInterface $input, OutputInterface $output)  	{  		$key = $input->getArgument('key'); diff --git a/phpBB/phpbb/console/command/config/set.php b/phpBB/phpbb/console/command/config/set.php index fce1edb93e..587b7fb0de 100644 --- a/phpBB/phpbb/console/command/config/set.php +++ b/phpBB/phpbb/console/command/config/set.php @@ -19,6 +19,9 @@ use Symfony\Component\Console\Output\OutputInterface;  class set extends command  { +	/** +	* {@inheritdoc} +	*/  	protected function configure()  	{  		$this @@ -43,6 +46,17 @@ class set extends command  		;  	} +	/** +	* Executes the command config:set. +	* +	* Sets a configuration option's value. +	* +	* @param InputInterface  $input  An InputInterface instance +	* @param OutputInterface $output An OutputInterface instance +	* +	* @return null +	* @see \phpbb\config\config::set() +	*/  	protected function execute(InputInterface $input, OutputInterface $output)  	{  		$key = $input->getArgument('key'); diff --git a/phpBB/phpbb/console/command/config/set_atomic.php b/phpBB/phpbb/console/command/config/set_atomic.php index 4df2d90722..a7a52155f9 100644 --- a/phpBB/phpbb/console/command/config/set_atomic.php +++ b/phpBB/phpbb/console/command/config/set_atomic.php @@ -19,6 +19,9 @@ use Symfony\Component\Console\Output\OutputInterface;  class set_atomic extends command  { +	/** +	* {@inheritdoc} +	*/  	protected function configure()  	{  		$this @@ -48,6 +51,18 @@ class set_atomic extends command  		;  	} +	/** +	* Executes the command config:set-atomic. +	* +	* Sets a configuration option's value only if the old_value matches the +	* current configuration value or the configuration value does not exist yet. +	* +	* @param InputInterface  $input  An InputInterface instance +	* @param OutputInterface $output An OutputInterface instance +	* +	* @return bool True if the value was changed, false otherwise. +	* @see \phpbb\config\config::set_atomic() +	*/  	protected function execute(InputInterface $input, OutputInterface $output)  	{  		$key = $input->getArgument('key'); diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php new file mode 100644 index 0000000000..4f4228d9b3 --- /dev/null +++ b/phpBB/phpbb/console/command/cron/cron_list.php @@ -0,0 +1,115 @@ +<?php +/** +* +* 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. +* +*/ +namespace phpbb\console\command\cron; + +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class cron_list extends \phpbb\console\command\command +{ +	/** @var \phpbb\cron\manager */ +	protected $cron_manager; + +	/** @var \phpbb\user */ +	protected $user; + +	/** +	* Constructor +	* +	* @param \phpbb\cron\manager	$cron_manager	Cron manager +	* @param \phpbb\user			$user			User instance +	*/ +	public function __construct(\phpbb\cron\manager $cron_manager, \phpbb\user $user) +	{ +		$this->cron_manager = $cron_manager; +		$this->user = $user; +		parent::__construct(); +	} + +	/** +	* {@inheritdoc} +	*/ +	protected function configure() +	{ +		$this +			->setName('cron:list') +			->setDescription($this->user->lang('CLI_DESCRIPTION_CRON_LIST')) +		; +	} + +	/** +	* Executes the command cron:list. +	* +	* Prints a list of ready and unready cron jobs. +	* +	* @param InputInterface  $input  An InputInterface instance +	* @param OutputInterface $output An OutputInterface instance +	* +	* @return null +	*/ +	protected function execute(InputInterface $input, OutputInterface $output) +	{ +		$tasks = $this->cron_manager->get_tasks(); + +		if (empty($tasks)) +		{ +			$output->writeln($this->user->lang('CRON_NO_TASKS')); +			return; +		} + +		$ready_tasks = array(); +		$not_ready_tasks = array(); +		foreach ($tasks as $task) +		{ +			if ($task->is_ready()) +			{ +				$ready_tasks[] = $task; +			} +			else +			{ +				$not_ready_tasks[] = $task; +			} +		} + +		if (!empty($ready_tasks)) +		{ +			$output->writeln('<info>' . $this->user->lang('TASKS_READY') . '</info>'); +			$this->print_tasks_names($ready_tasks, $output); +		} + +		if (!empty($ready_tasks) && !empty($not_ready_tasks)) +		{ +			$output->writeln(''); +		} + +		if (!empty($not_ready_tasks)) +		{ +			$output->writeln('<info>' . $this->user->lang('TASKS_NOT_READY') . '</info>'); +			$this->print_tasks_names($not_ready_tasks, $output); +		} +	} + +	/** +	* Print a list of cron jobs +	* +	* @param array				$tasks A list of task to display +	* @param OutputInterface	$output An OutputInterface instance +	*/ +	protected function print_tasks_names(array $tasks, OutputInterface $output) +	{ +		foreach ($tasks as $task) +		{ +			$output->writeln($task->get_name()); +		} +	} +} diff --git a/phpBB/phpbb/console/command/cron/run.php b/phpBB/phpbb/console/command/cron/run.php index 1029a2e085..0b365ece67 100644 --- a/phpBB/phpbb/console/command/cron/run.php +++ b/phpBB/phpbb/console/command/cron/run.php @@ -3,7 +3,7 @@  *  * This file is part of the phpBB Forum Software package.  * -* @copyright (c) phpBB Limited +* @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 @@ -15,7 +15,6 @@ namespace phpbb\console\command\cron;  use Symfony\Component\Console\Input\InputInterface;  use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption;  use Symfony\Component\Console\Output\OutputInterface;  class run extends \phpbb\console\command\command @@ -35,7 +34,7 @@ class run extends \phpbb\console\command\command  	* @param \phpbb\cron\manager $cron_manager The cron manager containing  	*		the cron tasks to be executed.  	* @param \phpbb\lock\db $lock_db The lock for accessing database. -	* @param \phobb\user $user The user object (used to get language information) +	* @param \phpbb\user $user The user object (used to get language information)  	*/  	public function __construct(\phpbb\cron\manager $cron_manager, \phpbb\lock\db $lock_db, \phpbb\user $user)  	{ @@ -102,7 +101,7 @@ class run extends \phpbb\console\command\command  		}  	} -	/* +	/**  	* Executes all ready cron tasks.  	*  	* If verbose mode is set, an info message will be printed if there is no task to @@ -140,7 +139,7 @@ class run extends \phpbb\console\command\command  		return 0;  	} -	/* +	/**  	* Executes a given cron task, if it is ready.  	*  	* If there is a task whose name matches $task_name, it is run and 0 is returned. diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 0f74664095..2abeaf5268 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -43,7 +43,7 @@ class migrate extends \phpbb\console\command\command  		$this->cache = $cache;  		$this->log = $log;  		$this->user = $user; -		$this->user->add_lang(array('common', 'acp/common', 'install', 'migrator')); +		$this->user->add_lang(array('common', 'install', 'migrator'));  		parent::__construct();  	} diff --git a/phpBB/phpbb/console/command/dev/migration_tips.php b/phpBB/phpbb/console/command/dev/migration_tips.php new file mode 100644 index 0000000000..c2f61568ea --- /dev/null +++ b/phpBB/phpbb/console/command/dev/migration_tips.php @@ -0,0 +1,64 @@ +<?php +/** +* +* 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. +* +*/ +namespace phpbb\console\command\dev; + +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class migration_tips extends \phpbb\console\command\command +{ +	/** @var \phpbb\extension\manager */ +	protected $extension_manager; + +	function __construct(\phpbb\extension\manager $extension_manager) +	{ +		$this->extension_manager = $extension_manager; +		parent::__construct(); +	} + +	protected function configure() +	{ +		$this +			->setName('dev:migration-tips') +			->setDescription('Finds migrations that are not depended on.') +		; +	} + +	protected function execute(InputInterface $input, OutputInterface $output) +	{ +		$migrations = $this->extension_manager->get_finder() +			->set_extensions(array()) +			->core_path('phpbb/db/migration/data/') +			->get_classes(); +		$tips = $migrations; + +		foreach ($migrations as $migration_class) +		{ +			foreach ($migration_class::depends_on() as $dependency) +			{ +				$tips_key = array_search($dependency, $tips); +				if ($tips_key !== false) +				{ +					unset($tips[$tips_key]); +				} +			} +		} + +		$output->writeln("\t\tarray("); +		foreach ($tips as $migration) +		{ +			$output->writeln("\t\t\t'{$migration}',"); +		} +		$output->writeln("\t\t);"); +	} +} diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 380a479e4a..1f50032f26 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -54,10 +54,13 @@ class content_visibility  	*  	* @param	\phpbb\auth\auth		$auth	Auth object  	* @param	\phpbb\db\driver\driver_interface	$db		Database object -	* @param	\phpbb\user		$user	User object +	* @param	\phpbb\user		$user			User object  	* @param	string		$phpbb_root_path	Root path  	* @param	string		$php_ext			PHP Extension -	* @return	null +	* @param	string		$forums_table		Forums table name +	* @param	string		$posts_table		Posts table name +	* @param	string		$topics_table		Topics table name +	* @param	string		$users_table		Users table name  	*/  	public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table)  	{ diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 7b232294f0..930bc42a98 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -101,7 +101,7 @@ class helper  	* @param string	$route		Name of the route to travel  	* @param array	$params		String or array of additional url parameters  	* @param bool	$is_amp		Is url using & (true) or & (false) -	* @param string	$session_id	Possibility to use a custom session id instead of the global one +	* @param string|bool	$session_id	Possibility to use a custom session id instead of the global one  	* @return string The URL already passed through append_sid()  	*/  	public function route($route, array $params = array(), $is_amp = true, $session_id = false) @@ -139,8 +139,8 @@ class helper  	* Output an error, effectively the same thing as trigger_error  	*  	* @param string $message The error message -	* @param string $code The error code (e.g. 404, 500, 503, etc.) -	* @return Response A Reponse instance +	* @param int $code The error code (e.g. 404, 500, 503, etc.) +	* @return Response A Response instance  	*/  	public function error($message, $code = 500)  	{ diff --git a/phpBB/phpbb/controller/provider.php b/phpBB/phpbb/controller/provider.php index 91f3a07fb1..fffd4f0428 100644 --- a/phpBB/phpbb/controller/provider.php +++ b/phpBB/phpbb/controller/provider.php @@ -37,7 +37,7 @@ class provider  	/**  	* Construct method  	* -	* @param array() $routing_files Array of strings containing paths +	* @param array $routing_files Array of strings containing paths  	*							to YAML files holding route information  	*/  	public function __construct($routing_files = array()) @@ -46,10 +46,12 @@ class provider  	}  	/** -	* @param \phpbb\extension\finder $finder +	* Find the list of routing files +	* +	* @param \phpbb\finder $finder  	* @return null  	*/ -	public function find_routing_files(\phpbb\extension\finder $finder) +	public function find_routing_files(\phpbb\finder $finder)  	{  		// We hardcode the path to the core config directory  		// because the finder cannot find it @@ -61,10 +63,10 @@ class provider  	}  	/** -	* Find a list of controllers and return it +	* Find a list of controllers  	*  	* @param string $base_path Base path to prepend to file paths -	* @return null +	* @return provider  	*/  	public function find($base_path = '')  	{ diff --git a/phpBB/phpbb/controller/resolver.php b/phpBB/phpbb/controller/resolver.php index 77532767fc..efab34b701 100644 --- a/phpBB/phpbb/controller/resolver.php +++ b/phpBB/phpbb/controller/resolver.php @@ -122,7 +122,7 @@ class resolver implements ControllerResolverInterface  	*  	* @param \Symfony\Component\HttpFoundation\Request $request Symfony Request object  	* @param mixed $controller A callable (controller class, method) -	* @return bool False +	* @return array An array of arguments to pass to the controller  	* @throws \phpbb\controller\exception  	*/  	public function getArguments(Request $request, $controller) diff --git a/phpBB/phpbb/cron/manager.php b/phpBB/phpbb/cron/manager.php index 1eb8edf033..b0601e641a 100644 --- a/phpBB/phpbb/cron/manager.php +++ b/phpBB/phpbb/cron/manager.php @@ -34,7 +34,7 @@ class manager  	/**  	* Constructor. Loads all available tasks.  	* -	* @param array|Traversable $tasks Provides an iterable set of task names +	* @param array|\Traversable $tasks Provides an iterable set of task names  	*/  	public function __construct($tasks, $phpbb_root_path, $php_ext)  	{ @@ -48,7 +48,7 @@ class manager  	* Loads tasks given by name, wraps them  	* and puts them into $this->tasks.  	* -	* @param array|Traversable $tasks		Array of instances of \phpbb\cron\task\task +	* @param array|\Traversable $tasks		Array of instances of \phpbb\cron\task\task  	*  	* @return null  	*/ @@ -122,6 +122,16 @@ class manager  	}  	/** +	* Find all tasks and return them. +	* +	* @return array List of all tasks. +	*/ +	public function get_tasks() +	{ +		return $this->tasks; +	} + +	/**  	* Wraps a task inside an instance of \phpbb\cron\task\wrapper.  	*  	* @param  \phpbb\cron\task\task 			$task The task. diff --git a/phpBB/phpbb/cron/task/core/prune_shadow_topics.php b/phpBB/phpbb/cron/task/core/prune_shadow_topics.php index ca5044343f..381483c798 100644 --- a/phpBB/phpbb/cron/task/core/prune_shadow_topics.php +++ b/phpBB/phpbb/cron/task/core/prune_shadow_topics.php @@ -164,6 +164,7 @@ class prune_shadow_topics extends \phpbb\cron\task\base implements \phpbb\cron\t  	* @param int $forum_id Forum ID of forum that should be pruned  	* @param string $prune_mode Prune mode  	* @param int $prune_flags Prune flags +	* @param int $prune_days Prune date in days  	* @param int $prune_freq Prune frequency  	* @return null  	*/ diff --git a/phpBB/phpbb/datetime.php b/phpBB/phpbb/datetime.php index 47f742f802..9c9292a8e4 100644 --- a/phpBB/phpbb/datetime.php +++ b/phpBB/phpbb/datetime.php @@ -39,8 +39,8 @@ class datetime extends \DateTime  	* the user context and modify the timezone to the users selected timezone if one is not set.  	*  	* @param string $time String in a format accepted by strtotime(). -	* @param DateTimeZone $timezone Time zone of the time. -	* @param user User object for context. +	* @param \DateTimeZone $timezone Time zone of the time. +	* @param user $user object for context.  	*/  	public function __construct($user, $time = 'now', \DateTimeZone $timezone = null)  	{ @@ -120,7 +120,7 @@ class datetime extends \DateTime  	/**  	* Magic method to convert DateTime object to string  	* -	* @return Formatted date time, according to the users default settings. +	* @return string Formatted date time, according to the users default settings.  	*/  	public function __toString()  	{ diff --git a/phpBB/phpbb/db/driver/firebird.php b/phpBB/phpbb/db/driver/firebird.php deleted file mode 100644 index c7b185a577..0000000000 --- a/phpBB/phpbb/db/driver/firebird.php +++ /dev/null @@ -1,526 +0,0 @@ -<?php -/** -* -* 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. -* -*/ - -namespace phpbb\db\driver; - -/** -* Firebird/Interbase Database Abstraction Layer -* Minimum Requirement is Firebird 2.1 -*/ -class firebird extends \phpbb\db\driver\driver -{ -	var $last_query_text = ''; -	var $service_handle = false; -	var $affected_rows = 0; -	var $connect_error = ''; - -	/** -	* {@inheritDoc} -	*/ -	function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) -	{ -		$this->persistency = $persistency; -		$this->user = $sqluser; -		$this->server = $sqlserver . (($port) ? ':' . $port : ''); -		$this->dbname = str_replace('\\', '/', $database); - -		// There are three possibilities to connect to an interbase db -		if (!$this->server) -		{ -			$use_database = $this->dbname; -		} -		else if (strpos($this->server, '//') === 0) -		{ -			$use_database = $this->server . $this->dbname; -		} -		else -		{ -			$use_database = $this->server . ':' . $this->dbname; -		} - -		if ($this->persistency) -		{ -			if (!function_exists('ibase_pconnect')) -			{ -				$this->connect_error = 'ibase_pconnect function does not exist, is interbase extension installed?'; -				return $this->sql_error(''); -			} -			$this->db_connect_id = @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3); -		} -		else -		{ -			if (!function_exists('ibase_connect')) -			{ -				$this->connect_error = 'ibase_connect function does not exist, is interbase extension installed?'; -				return $this->sql_error(''); -			} -			$this->db_connect_id = @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3); -		} - -		// Do not call ibase_service_attach if connection failed, -		// otherwise error message from ibase_(p)connect call will be clobbered. -		if ($this->db_connect_id && function_exists('ibase_service_attach') && $this->server) -		{ -			$this->service_handle = @ibase_service_attach($this->server, $this->user, $sqlpassword); -		} -		else -		{ -			$this->service_handle = false; -		} - -		return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); -	} - -	/** -	* {@inheritDoc} -	*/ -	function sql_server_info($raw = false, $use_cache = true) -	{ -		/** -		* force $use_cache false.  I didn't research why the caching code there is no caching code -		* but I assume its because the IB extension provides a direct method to access it -		* without a query. -		*/ - -		$use_cache = false; - -		if ($this->service_handle !== false && function_exists('ibase_server_info')) -		{ -			return @ibase_server_info($this->service_handle, IBASE_SVC_SERVER_VERSION); -		} - -		return ($raw) ? '2.1' : 'Firebird/Interbase'; -	} - -	/** -	* SQL Transaction -	* @access private -	*/ -	function _sql_transaction($status = 'begin') -	{ -		switch ($status) -		{ -			case 'begin': -				return true; -			break; - -			case 'commit': -				return @ibase_commit(); -			break; - -			case 'rollback': -				return @ibase_rollback(); -			break; -		} - -		return true; -	} - -	/** -	* {@inheritDoc} -	*/ -	function sql_query($query = '', $cache_ttl = 0) -	{ -		if ($query != '') -		{ -			global $cache; - -			// EXPLAIN only in extra debug mode -			if (defined('DEBUG')) -			{ -				$this->sql_report('start', $query); -			} - -			$this->last_query_text = $query; -			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; -			$this->sql_add_num_queries($this->query_result); - -			if ($this->query_result === false) -			{ -				$array = array(); -				// We overcome Firebird's 32767 char limit by binding vars -				if (strlen($query) > 32767) -				{ -					if (preg_match('/^(INSERT INTO[^(]++)\\(([^()]+)\\) VALUES[^(]++\\((.*?)\\)$/s', $query, $regs)) -					{ -						if (strlen($regs[3]) > 32767) -						{ -							preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER); - -							$inserts = $vals[0]; -							unset($vals); - -							foreach ($inserts as $key => $value) -							{ -								if (!empty($value) && $value[0] === "'" && strlen($value) > 32769) // check to see if this thing is greater than the max + 'x2 -								{ -									$inserts[$key] = '?'; -									$array[] = str_replace("''", "'", substr($value, 1, -1)); -								} -							} - -							$query = $regs[1] . '(' . $regs[2] . ') VALUES (' . implode(', ', $inserts) . ')'; -						} -					} -					else if (preg_match('/^(UPDATE ([\\w_]++)\\s+SET )([\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|\\d+)(?:,\\s*[\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+))*+)\\s+(WHERE.*)$/s', $query, $data)) -					{ -						if (strlen($data[3]) > 32767) -						{ -							$update = $data[1]; -							$where = $data[4]; -							preg_match_all('/(\\w++)\\s*=\\s*(\'(?:[^\']++|\'\')*+\'|[\d-.]++)/', $data[3], $temp, PREG_SET_ORDER); -							unset($data); - -							$cols = array(); -							foreach ($temp as $value) -							{ -								if (!empty($value[2]) && $value[2][0] === "'" && strlen($value[2]) > 32769) // check to see if this thing is greater than the max + 'x2 -								{ -									$array[] = str_replace("''", "'", substr($value[2], 1, -1)); -									$cols[] = $value[1] . '=?'; -								} -								else -								{ -									$cols[] = $value[1] . '=' . $value[2]; -								} -							} - -							$query = $update . implode(', ', $cols) . ' ' . $where; -							unset($cols); -						} -					} -				} - -				if (!function_exists('ibase_affected_rows') && (preg_match('/^UPDATE ([\w_]++)\s+SET [\w_]++\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+)(?:,\s*[\w_]++\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+))*+\s+(WHERE.*)?$/s', $query, $regs) || preg_match('/^DELETE FROM ([\w_]++)\s*(WHERE\s*.*)?$/s', $query, $regs))) -				{ -					$affected_sql = 'SELECT COUNT(*) as num_rows_affected FROM ' . $regs[1]; -					if (!empty($regs[2])) -					{ -						$affected_sql .= ' ' . $regs[2]; -					} - -					if (!($temp_q_id = @ibase_query($this->db_connect_id, $affected_sql))) -					{ -						return false; -					} - -					$temp_result = @ibase_fetch_assoc($temp_q_id); -					@ibase_free_result($temp_q_id); - -					$this->affected_rows = ($temp_result) ? $temp_result['NUM_ROWS_AFFECTED'] : false; -				} - -				if (sizeof($array)) -				{ -					$p_query = @ibase_prepare($this->db_connect_id, $query); -					array_unshift($array, $p_query); -					$this->query_result = call_user_func_array('ibase_execute', $array); -					unset($array); - -					if ($this->query_result === false) -					{ -						$this->sql_error($query); -					} -				} -				else if (($this->query_result = @ibase_query($this->db_connect_id, $query)) === false) -				{ -					$this->sql_error($query); -				} - -				if (defined('DEBUG')) -				{ -					$this->sql_report('stop', $query); -				} - -				if (!$this->transaction) -				{ -					if (function_exists('ibase_commit_ret')) -					{ -						@ibase_commit_ret(); -					} -					else -					{ -						// way cooler than ibase_commit_ret :D -						@ibase_query('COMMIT RETAIN;'); -					} -				} - -				if ($cache && $cache_ttl) -				{ -					$this->open_queries[(int) $this->query_result] = $this->query_result; -					$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); -				} -				else if (strpos($query, 'SELECT') === 0 && $this->query_result) -				{ -					$this->open_queries[(int) $this->query_result] = $this->query_result; -				} -			} -			else if (defined('DEBUG')) -			{ -				$this->sql_report('fromcache', $query); -			} -		} -		else -		{ -			return false; -		} - -		return $this->query_result; -	} - -	/** -	* Build LIMIT query -	*/ -	function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) -	{ -		$this->query_result = false; - -		$query = 'SELECT FIRST ' . $total . ((!empty($offset)) ? ' SKIP ' . $offset : '') . substr($query, 6); - -		return $this->sql_query($query, $cache_ttl); -	} - -	/** -	* {@inheritDoc} -	*/ -	function sql_affectedrows() -	{ -		// PHP 5+ function -		if (function_exists('ibase_affected_rows')) -		{ -			return ($this->db_connect_id) ? @ibase_affected_rows($this->db_connect_id) : false; -		} -		else -		{ -			return $this->affected_rows; -		} -	} - -	/** -	* {@inheritDoc} -	*/ -	function sql_fetchrow($query_id = false) -	{ -		global $cache; - -		if ($query_id === false) -		{ -			$query_id = $this->query_result; -		} - -		if ($cache && $cache->sql_exists($query_id)) -		{ -			return $cache->sql_fetchrow($query_id); -		} - -		if ($query_id === false) -		{ -			return false; -		} - -		$row = array(); -		$cur_row = @ibase_fetch_object($query_id, IBASE_TEXT); - -		if (!$cur_row) -		{ -			return false; -		} - -		foreach (get_object_vars($cur_row) as $key => $value) -		{ -			$row[strtolower($key)] = (is_string($value)) ? trim(str_replace(array("\\0", "\\n"), array("\0", "\n"), $value)) : $value; -		} - -		return (sizeof($row)) ? $row : false; -	} - -	/** -	* {@inheritDoc} -	*/ -	function sql_nextid() -	{ -		$query_id = $this->query_result; - -		if ($query_id !== false && $this->last_query_text != '') -		{ -			if ($this->query_result && preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#i', $this->last_query_text, $tablename)) -			{ -				$sql = 'SELECT GEN_ID(' . $tablename[1] . '_gen, 0) AS new_id FROM RDB$DATABASE'; - -				if (!($temp_q_id = @ibase_query($this->db_connect_id, $sql))) -				{ -					return false; -				} - -				$temp_result = @ibase_fetch_assoc($temp_q_id); -				@ibase_free_result($temp_q_id); - -				return ($temp_result) ? $temp_result['NEW_ID'] : false; -			} -		} - -		return false; -	} - -	/** -	* {@inheritDoc} -	*/ -	function sql_freeresult($query_id = false) -	{ -		global $cache; - -		if ($query_id === false) -		{ -			$query_id = $this->query_result; -		} - -		if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) -		{ -			return $cache->sql_freeresult($query_id); -		} - -		if (isset($this->open_queries[(int) $query_id])) -		{ -			unset($this->open_queries[(int) $query_id]); -			return @ibase_free_result($query_id); -		} - -		return false; -	} - -	/** -	* {@inheritDoc} -	*/ -	function sql_escape($msg) -	{ -		return str_replace(array("'", "\0"), array("''", ''), $msg); -	} - -	/** -	* Build LIKE expression -	* @access private -	*/ -	function _sql_like_expression($expression) -	{ -		return $expression . " ESCAPE '\\'"; -	} - -	/** -	* Build db-specific query data -	* @access private -	*/ -	function _sql_custom_build($stage, $data) -	{ -		return $data; -	} - -	function _sql_bit_and($column_name, $bit, $compare = '') -	{ -		return 'BIN_AND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); -	} - -	function _sql_bit_or($column_name, $bit, $compare = '') -	{ -		return 'BIN_OR(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); -	} - -	/** -	* {@inheritDoc} -	*/ -	function cast_expr_to_bigint($expression) -	{ -		// Precision must be from 1 to 18 -		return 'CAST(' . $expression . ' as DECIMAL(18, 0))'; -	} - -	/** -	* {@inheritDoc} -	*/ -	function cast_expr_to_string($expression) -	{ -		return 'CAST(' . $expression . ' as VARCHAR(255))'; -	} - -	/** -	* return sql error array -	* @access private -	*/ -	function _sql_error() -	{ -		// Need special handling here because ibase_errmsg returns -		// connection errors, however if the interbase extension -		// is not installed then ibase_errmsg does not exist and -		// we cannot call it. -		if (function_exists('ibase_errmsg')) -		{ -			$msg = @ibase_errmsg(); -			if (!$msg) -			{ -				$msg = $this->connect_error; -			} -		} -		else -		{ -			$msg = $this->connect_error; -		} -		return array( -			'message'	=> $msg, -			'code'		=> (@function_exists('ibase_errcode') ? @ibase_errcode() : '') -		); -	} - -	/** -	* Close sql connection -	* @access private -	*/ -	function _sql_close() -	{ -		if ($this->service_handle !== false) -		{ -			@ibase_service_detach($this->service_handle); -		} - -		return @ibase_close($this->db_connect_id); -	} - -	/** -	* Build db-specific report -	* @access private -	*/ -	function _sql_report($mode, $query = '') -	{ -		switch ($mode) -		{ -			case 'start': -			break; - -			case 'fromcache': -				$endtime = explode(' ', microtime()); -				$endtime = $endtime[0] + $endtime[1]; - -				$result = @ibase_query($this->db_connect_id, $query); -				while ($void = @ibase_fetch_object($result, IBASE_TEXT)) -				{ -					// Take the time spent on parsing rows into account -				} -				@ibase_free_result($result); - -				$splittime = explode(' ', microtime()); -				$splittime = $splittime[0] + $splittime[1]; - -				$this->sql_report('record_fromcache', $query, $endtime, $splittime); - -			break; -		} -	} -} diff --git a/phpBB/phpbb/db/driver/mssql.php b/phpBB/phpbb/db/driver/mssql.php index 2e56638617..268463a151 100644 --- a/phpBB/phpbb/db/driver/mssql.php +++ b/phpBB/phpbb/db/driver/mssql.php @@ -137,6 +137,10 @@ class mssql extends \phpbb\db\driver\driver  			{  				$this->sql_report('start', $query);  			} +			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			{ +				$this->curtime = microtime(true); +			}  			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result); @@ -152,6 +156,10 @@ class mssql extends \phpbb\db\driver\driver  				{  					$this->sql_report('stop', $query);  				} +				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				{ +					$this->sql_time += microtime(true) - $this->curtime; +				}  				if ($cache && $cache_ttl)  				{ diff --git a/phpBB/phpbb/db/driver/mssql_odbc.php b/phpBB/phpbb/db/driver/mssql_odbc.php index de90d878e7..8e5d4c7a4c 100644 --- a/phpBB/phpbb/db/driver/mssql_odbc.php +++ b/phpBB/phpbb/db/driver/mssql_odbc.php @@ -156,6 +156,10 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  			{  				$this->sql_report('start', $query);  			} +			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			{ +				$this->curtime = microtime(true); +			}  			$this->last_query_text = $query;  			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; @@ -172,6 +176,10 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  				{  					$this->sql_report('stop', $query);  				} +				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				{ +					$this->sql_time += microtime(true) - $this->curtime; +				}  				if ($cache && $cache_ttl)  				{ diff --git a/phpBB/phpbb/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php index 9639bfa988..46a9b3a477 100644 --- a/phpBB/phpbb/db/driver/mssqlnative.php +++ b/phpBB/phpbb/db/driver/mssqlnative.php @@ -127,6 +127,10 @@ class mssqlnative extends \phpbb\db\driver\mssql_base  			{  				$this->sql_report('start', $query);  			} +			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			{ +				$this->curtime = microtime(true); +			}  			$this->last_query_text = $query;  			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; @@ -145,6 +149,10 @@ class mssqlnative extends \phpbb\db\driver\mssql_base  				{  					$this->sql_report('stop', $query);  				} +				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				{ +					$this->sql_time += microtime(true) - $this->curtime; +				}  				if ($cache && $cache_ttl)  				{ @@ -319,10 +327,10 @@ class mssqlnative extends \phpbb\db\driver\mssql_base  			{  				foreach ($errors as $error)  				{ -					$error_message .= "SQLSTATE: " . $error[ 'SQLSTATE'] . "\n"; -					$error_message .= "code: " . $error[ 'code'] . "\n"; +					$error_message .= "SQLSTATE: " . $error['SQLSTATE'] . "\n"; +					$error_message .= "code: " . $error['code'] . "\n";  					$code = $error['code']; -					$error_message .= "message: " . $error[ 'message'] . "\n"; +					$error_message .= "message: " . $error['message'] . "\n";  				}  				$this->last_error_result = $error_message;  				$error = $this->last_error_result; diff --git a/phpBB/phpbb/db/driver/mysql.php b/phpBB/phpbb/db/driver/mysql.php index 569bd4f10a..e93c7239e8 100644 --- a/phpBB/phpbb/db/driver/mysql.php +++ b/phpBB/phpbb/db/driver/mysql.php @@ -166,6 +166,10 @@ class mysql extends \phpbb\db\driver\mysql_base  			{  				$this->sql_report('start', $query);  			} +			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			{ +				$this->curtime = microtime(true); +			}  			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result); @@ -181,6 +185,10 @@ class mysql extends \phpbb\db\driver\mysql_base  				{  					$this->sql_report('stop', $query);  				} +				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				{ +					$this->sql_time += microtime(true) - $this->curtime; +				}  				if ($cache && $cache_ttl)  				{ diff --git a/phpBB/phpbb/db/driver/mysqli.php b/phpBB/phpbb/db/driver/mysqli.php index 58361ff0f8..8fc306b2cc 100644 --- a/phpBB/phpbb/db/driver/mysqli.php +++ b/phpBB/phpbb/db/driver/mysqli.php @@ -71,10 +71,17 @@ class mysqli extends \phpbb\db\driver\mysql_base  			if (version_compare($this->sql_server_info(true), '5.0.2', '>='))  			{  				$result = @mysqli_query($this->db_connect_id, 'SELECT @@session.sql_mode AS sql_mode'); -				$row = @mysqli_fetch_assoc($result); -				@mysqli_free_result($result); +				if ($result !== null) +				{ +					$row = @mysqli_fetch_assoc($result); -				$modes = array_map('trim', explode(',', $row['sql_mode'])); +					$modes = array_map('trim', explode(',', $row['sql_mode'])); +				} +				else +				{ +					$modes = array(); +				} +				@mysqli_free_result($result);  				// TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES  				if (!in_array('TRADITIONAL', $modes)) @@ -109,15 +116,18 @@ class mysqli extends \phpbb\db\driver\mysql_base  		if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false)  		{  			$result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version'); -			$row = @mysqli_fetch_assoc($result); -			@mysqli_free_result($result); +			if ($result !== null) +			{ +				$row = @mysqli_fetch_assoc($result); -			$this->sql_server_version = $row['version']; +				$this->sql_server_version = $row['version']; -			if (!empty($cache) && $use_cache) -			{ -				$cache->put('mysqli_version', $this->sql_server_version); +				if (!empty($cache) && $use_cache) +				{ +					$cache->put('mysqli_version', $this->sql_server_version); +				}  			} +			@mysqli_free_result($result);  		}  		return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version; @@ -165,6 +175,10 @@ class mysqli extends \phpbb\db\driver\mysql_base  			{  				$this->sql_report('start', $query);  			} +			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			{ +				$this->curtime = microtime(true); +			}  			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result); @@ -180,6 +194,10 @@ class mysqli extends \phpbb\db\driver\mysql_base  				{  					$this->sql_report('stop', $query);  				} +				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				{ +					$this->sql_time += microtime(true) - $this->curtime; +				}  				if ($cache && $cache_ttl)  				{ @@ -224,7 +242,7 @@ class mysqli extends \phpbb\db\driver\mysql_base  			return $cache->sql_fetchrow($query_id);  		} -		if ($query_id !== false) +		if ($query_id !== false && $query_id !== null)  		{  			$result = @mysqli_fetch_assoc($query_id);  			return $result !== null ? $result : false; @@ -434,9 +452,12 @@ class mysqli extends \phpbb\db\driver\mysql_base  				$endtime = $endtime[0] + $endtime[1];  				$result = @mysqli_query($this->db_connect_id, $query); -				while ($void = @mysqli_fetch_assoc($result)) +				if ($result !== null)  				{ -					// Take the time spent on parsing rows into account +					while ($void = @mysqli_fetch_assoc($result)) +					{ +						// Take the time spent on parsing rows into account +					}  				}  				@mysqli_free_result($result); diff --git a/phpBB/phpbb/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php index bfc5373e35..d1a186f1ba 100644 --- a/phpBB/phpbb/db/driver/oracle.php +++ b/phpBB/phpbb/db/driver/oracle.php @@ -253,6 +253,10 @@ class oracle extends \phpbb\db\driver\driver  			{  				$this->sql_report('start', $query);  			} +			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			{ +				$this->curtime = microtime(true); +			}  			$this->last_query_text = $query;  			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; @@ -430,6 +434,10 @@ class oracle extends \phpbb\db\driver\driver  				{  					$this->sql_report('stop', $query);  				} +				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				{ +					$this->sql_time += microtime(true) - $this->curtime; +				}  				if ($cache && $cache_ttl)  				{ diff --git a/phpBB/phpbb/db/driver/postgres.php b/phpBB/phpbb/db/driver/postgres.php index a4aa9497ed..a67cd9f7c2 100644 --- a/phpBB/phpbb/db/driver/postgres.php +++ b/phpBB/phpbb/db/driver/postgres.php @@ -179,6 +179,10 @@ class postgres extends \phpbb\db\driver\driver  			{  				$this->sql_report('start', $query);  			} +			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			{ +				$this->curtime = microtime(true); +			}  			$this->last_query_text = $query;  			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; @@ -195,6 +199,10 @@ class postgres extends \phpbb\db\driver\driver  				{  					$this->sql_report('stop', $query);  				} +				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				{ +					$this->sql_time += microtime(true) - $this->curtime; +				}  				if ($cache && $cache_ttl)  				{ diff --git a/phpBB/phpbb/db/driver/sqlite.php b/phpBB/phpbb/db/driver/sqlite.php index f4c5e240fc..2112e5ba2f 100644 --- a/phpBB/phpbb/db/driver/sqlite.php +++ b/phpBB/phpbb/db/driver/sqlite.php @@ -121,6 +121,10 @@ class sqlite extends \phpbb\db\driver\driver  			{  				$this->sql_report('start', $query);  			} +			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			{ +				$this->curtime = microtime(true); +			}  			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result); @@ -136,6 +140,10 @@ class sqlite extends \phpbb\db\driver\driver  				{  					$this->sql_report('stop', $query);  				} +				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				{ +					$this->sql_time += microtime(true) - $this->curtime; +				}  				if ($cache && $cache_ttl)  				{ diff --git a/phpBB/phpbb/db/driver/sqlite3.php b/phpBB/phpbb/db/driver/sqlite3.php index 2c6bf99497..6511c755a0 100644 --- a/phpBB/phpbb/db/driver/sqlite3.php +++ b/phpBB/phpbb/db/driver/sqlite3.php @@ -121,6 +121,10 @@ class sqlite3 extends \phpbb\db\driver\driver  			{  				$this->sql_report('start', $query);  			} +			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			{ +				$this->curtime = microtime(true); +			}  			$this->last_query_text = $query;  			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; @@ -137,6 +141,10 @@ class sqlite3 extends \phpbb\db\driver\driver  				{  					$this->sql_report('stop', $query);  				} +				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				{ +					$this->sql_time += microtime(true) - $this->curtime; +				}  				if ($cache && $cache_ttl)  				{ diff --git a/phpBB/phpbb/db/migration/data/v30x/local_url_bbcode.php b/phpBB/phpbb/db/migration/data/v30x/local_url_bbcode.php index 139dc95b28..edcc69e1bf 100644 --- a/phpBB/phpbb/db/migration/data/v30x/local_url_bbcode.php +++ b/phpBB/phpbb/db/migration/data/v30x/local_url_bbcode.php @@ -44,9 +44,16 @@ class local_url_bbcode extends \phpbb\db\migration\migration  		{  			if (!class_exists('acp_bbcodes'))  			{ -				global $phpEx; -				phpbb_require_updated('includes/acp/acp_bbcodes.' . $phpEx); +				if (function_exists('phpbb_require_updated')) +				{ +					phpbb_require_updated('includes/acp/acp_bbcodes.' . $this->php_ext); +				} +				else +				{ +					require($this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext); +				}  			} +  			$bbcode_match = $row['bbcode_match'];  			$bbcode_tpl = $row['bbcode_tpl']; diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php new file mode 100644 index 0000000000..20bd547ac3 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php @@ -0,0 +1,31 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class contact_admin_acp_module extends \phpbb\db\migration\migration +{ +	public function update_data() +	{ +		return array( +			array('module.add', array( +				'acp', +				'ACP_BOARD_CONFIGURATION', +				array( +					'module_basename'	=> 'acp_contact', +					'modes'				=> array('contact'), +				), +			)), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php new file mode 100644 index 0000000000..c2dd09ddf6 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php @@ -0,0 +1,41 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class contact_admin_form extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		return isset($this->config['contact_admin_form_enable']); +	} + +	public function update_data() +	{ +		return array( +			array('config.add', array('contact_admin_form_enable', 1)), +			array('custom', array(array($this, 'contact_admin_info'))), +		); +	} + +	public function contact_admin_info() +	{ +		$text_config = new \phpbb\config\db_text($this->db, $this->table_prefix . 'config_text'); +		$text_config->set_array(array( +			'contact_admin_info'			=> '', +			'contact_admin_info_uid'		=> '', +			'contact_admin_info_bitfield'	=> '', +			'contact_admin_info_flags'		=> OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS, +		)); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php new file mode 100644 index 0000000000..aad8e44681 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php @@ -0,0 +1,84 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class passwords_convert_p1 extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v310\passwords_p2'); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'update_passwords'))), +		); +	} + +	public function update_passwords($start) +	{ +		// Nothing to do if user_pass_convert column doesn't exist +		if (!$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_pass_convert')) +		{ +			return; +		} + +		$start = (int) $start; +		$limit = 1000; +		$converted_users = 0; + +		$sql = 'SELECT user_password, user_id +			FROM ' . $this->table_prefix . 'users +			WHERE user_pass_convert = 1 +			ORDER BY user_id'; +		$result = $this->db->sql_query_limit($sql, $limit, $start); + +		$update_users = array(); +		while ($row = $this->db->sql_fetchrow($result)) +		{ +			$converted_users++; + +			$user_id = (int) $row['user_id']; +			// Only prefix passwords without proper prefix +			if (!isset($update_users[$user_id]) && !preg_match('#^\$([a-zA-Z0-9\\\]*?)\$#', $row['user_password'])) +			{ +				// Use $CP$ prefix for passwords that need to +				// be converted and set pass convert to false. +				$update_users[$user_id] = array( +					'user_password'		=> '$CP$' . $row['user_password'], +					'user_pass_convert'	=> 0, +				); +			} +		} +		$this->db->sql_freeresult($result); + +		foreach ($update_users as $user_id => $user_data) +		{ +			$sql = 'UPDATE ' . $this->table_prefix . 'users +				SET ' . $this->db->sql_build_array('UPDATE', $user_data) . ' +				WHERE user_id = ' . $user_id; +			$this->sql_query($sql); +		} + +		if ($converted_users < $limit) +		{ +			// There are no more users to be converted +			return; +		} + +		// There are still more users to query, return the next start value +		return $start + $limit; +	} +} diff --git a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php new file mode 100644 index 0000000000..26a99184a6 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p2.php @@ -0,0 +1,49 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class passwords_convert_p2 extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_pass_convert'); +	} + +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v310\passwords_convert_p1'); +	} + +	public function update_schema() +	{ +		return array( +			'drop_columns'		=> array( +				$this->table_prefix . 'users'		=> array( +					'user_pass_convert', +				), +			), +		); +	} + +	public function revert_schema() +	{ +		return array( +			'add_columns'		=> array( +				$this->table_prefix . 'users'		=> array( +					'user_pass_convert'	=> array('BOOL', 0, 'after' => 'user_passchg'), +				), +			), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_facebook.php b/phpBB/phpbb/db/migration/data/v310/profilefield_facebook.php new file mode 100644 index 0000000000..5964e7a997 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_facebook.php @@ -0,0 +1,60 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_facebook extends \phpbb\db\migration\profilefield_base_migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v310\profilefield_types', +			'\phpbb\db\migration\data\v310\profilefield_show_novalue', +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	protected $profilefield_name = 'phpbb_facebook'; + +	protected $profilefield_database_type = array('VCHAR', ''); + +	protected $profilefield_data = array( +		'field_name'			=> 'phpbb_facebook', +		'field_type'			=> 'profilefields.type.string', +		'field_ident'			=> 'phpbb_facebook', +		'field_length'			=> '20', +		'field_minlen'			=> '5', +		'field_maxlen'			=> '50', +		'field_novalue'			=> '', +		'field_default_value'	=> '', +		'field_validation'		=> '[\w.]+', +		'field_required'		=> 0, +		'field_show_novalue'	=> 0, +		'field_show_on_reg'		=> 0, +		'field_show_on_pm'		=> 1, +		'field_show_on_vt'		=> 1, +		'field_show_profile'	=> 1, +		'field_hide'			=> 0, +		'field_no_view'			=> 0, +		'field_active'			=> 1, +		'field_is_contact'		=> 1, +		'field_contact_desc'	=> 'VIEW_FACEBOOK_PROFILE', +		'field_contact_url'		=> 'http://facebook.com/%s/', +	); +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_googleplus.php b/phpBB/phpbb/db/migration/data/v310/profilefield_googleplus.php new file mode 100644 index 0000000000..9bef0a4c0b --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_googleplus.php @@ -0,0 +1,60 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_googleplus extends \phpbb\db\migration\profilefield_base_migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v310\profilefield_types', +			'\phpbb\db\migration\data\v310\profilefield_show_novalue', +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	protected $profilefield_name = 'phpbb_googleplus'; + +	protected $profilefield_database_type = array('VCHAR', ''); + +	protected $profilefield_data = array( +		'field_name'			=> 'phpbb_googleplus', +		'field_type'			=> 'profilefields.type.googleplus', +		'field_ident'			=> 'phpbb_googleplus', +		'field_length'			=> '20', +		'field_minlen'			=> '3', +		'field_maxlen'			=> '255', +		'field_novalue'			=> '', +		'field_default_value'	=> '', +		'field_validation'		=> '[\w]+', +		'field_required'		=> 0, +		'field_show_novalue'	=> 0, +		'field_show_on_reg'		=> 0, +		'field_show_on_pm'		=> 1, +		'field_show_on_vt'		=> 1, +		'field_show_profile'	=> 1, +		'field_hide'			=> 0, +		'field_no_view'			=> 0, +		'field_active'			=> 1, +		'field_is_contact'		=> 1, +		'field_contact_desc'	=> 'VIEW_GOOGLEPLUS_PROFILE', +		'field_contact_url'		=> 'http://plus.google.com/%s', +	); +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_skype.php b/phpBB/phpbb/db/migration/data/v310/profilefield_skype.php new file mode 100644 index 0000000000..9a5de9d0eb --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_skype.php @@ -0,0 +1,60 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_skype extends \phpbb\db\migration\profilefield_base_migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v310\profilefield_types', +			'\phpbb\db\migration\data\v310\profilefield_show_novalue', +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	protected $profilefield_name = 'phpbb_skype'; + +	protected $profilefield_database_type = array('VCHAR', ''); + +	protected $profilefield_data = array( +		'field_name'			=> 'phpbb_skype', +		'field_type'			=> 'profilefields.type.string', +		'field_ident'			=> 'phpbb_skype', +		'field_length'			=> '20', +		'field_minlen'			=> '6', +		'field_maxlen'			=> '32', +		'field_novalue'			=> '', +		'field_default_value'	=> '', +		'field_validation'		=> '[a-zA-Z][\w\.,\-_]+', +		'field_required'		=> 0, +		'field_show_novalue'	=> 0, +		'field_show_on_reg'		=> 0, +		'field_show_on_pm'		=> 1, +		'field_show_on_vt'		=> 1, +		'field_show_profile'	=> 1, +		'field_hide'			=> 0, +		'field_no_view'			=> 0, +		'field_active'			=> 1, +		'field_is_contact'		=> 1, +		'field_contact_desc'	=> 'VIEW_SKYPE_PROFILE', +		'field_contact_url'		=> 'skype:%s?userinfo', +	); +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_twitter.php b/phpBB/phpbb/db/migration/data/v310/profilefield_twitter.php new file mode 100644 index 0000000000..68d038f609 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_twitter.php @@ -0,0 +1,60 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_twitter extends \phpbb\db\migration\profilefield_base_migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v310\profilefield_types', +			'\phpbb\db\migration\data\v310\profilefield_show_novalue', +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	protected $profilefield_name = 'phpbb_twitter'; + +	protected $profilefield_database_type = array('VCHAR', ''); + +	protected $profilefield_data = array( +		'field_name'			=> 'phpbb_twitter', +		'field_type'			=> 'profilefields.type.string', +		'field_ident'			=> 'phpbb_twitter', +		'field_length'			=> '20', +		'field_minlen'			=> '1', +		'field_maxlen'			=> '15', +		'field_novalue'			=> '', +		'field_default_value'	=> '', +		'field_validation'		=> '[\w_]+', +		'field_required'		=> 0, +		'field_show_novalue'	=> 0, +		'field_show_on_reg'		=> 0, +		'field_show_on_pm'		=> 1, +		'field_show_on_vt'		=> 1, +		'field_show_profile'	=> 1, +		'field_hide'			=> 0, +		'field_no_view'			=> 0, +		'field_active'			=> 1, +		'field_is_contact'		=> 1, +		'field_contact_desc'	=> 'VIEW_TWITTER_PROFILE', +		'field_contact_url'		=> 'http://twitter.com/%s', +	); +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_youtube.php b/phpBB/phpbb/db/migration/data/v310/profilefield_youtube.php new file mode 100644 index 0000000000..bb90c0aa5c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_youtube.php @@ -0,0 +1,60 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_youtube extends \phpbb\db\migration\profilefield_base_migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v310\profilefield_types', +			'\phpbb\db\migration\data\v310\profilefield_show_novalue', +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	protected $profilefield_name = 'phpbb_youtube'; + +	protected $profilefield_database_type = array('VCHAR', ''); + +	protected $profilefield_data = array( +		'field_name'			=> 'phpbb_youtube', +		'field_type'			=> 'profilefields.type.string', +		'field_ident'			=> 'phpbb_youtube', +		'field_length'			=> '20', +		'field_minlen'			=> '3', +		'field_maxlen'			=> '60', +		'field_novalue'			=> '', +		'field_default_value'	=> '', +		'field_validation'		=> '[a-zA-Z][\w\.,\-_]+', +		'field_required'		=> 0, +		'field_show_novalue'	=> 0, +		'field_show_on_reg'		=> 0, +		'field_show_on_pm'		=> 1, +		'field_show_on_vt'		=> 1, +		'field_show_profile'	=> 1, +		'field_hide'			=> 0, +		'field_no_view'			=> 0, +		'field_active'			=> 1, +		'field_is_contact'		=> 1, +		'field_contact_desc'	=> 'VIEW_YOUTUBE_CHANNEL', +		'field_contact_url'		=> 'http://youtube.com/user/%s', +	); +} diff --git a/phpBB/phpbb/db/migration/schema_generator.php b/phpBB/phpbb/db/migration/schema_generator.php index 818e27a362..91d8307d91 100644 --- a/phpBB/phpbb/db/migration/schema_generator.php +++ b/phpBB/phpbb/db/migration/schema_generator.php @@ -217,7 +217,7 @@ class schema_generator  	* Check if one of the migrations files' dependencies can't be resolved  	* by the supplied list of migrations  	* -	* @throws UnexpectedValueException If a dependency can't be resolved +	* @throws \UnexpectedValueException If a dependency can't be resolved  	*/  	protected function check_dependencies()  	{ diff --git a/phpBB/phpbb/db/migration/tool/config.php b/phpBB/phpbb/db/migration/tool/config.php index 1027b425ff..f93e7118c4 100644 --- a/phpBB/phpbb/db/migration/tool/config.php +++ b/phpBB/phpbb/db/migration/tool/config.php @@ -66,6 +66,7 @@ class config implements \phpbb\db\migration\tool\tool_interface  	* 	like to update  	* @param mixed $config_value The value of the config setting  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function update($config_name, $config_value)  	{ @@ -87,6 +88,7 @@ class config implements \phpbb\db\migration\tool\tool_interface  	* 	like to update  	* @param mixed $config_value The value of the config setting  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function update_if_equals($compare, $config_name, $config_value)  	{ diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index 17deb1b19c..db43046a95 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -167,6 +167,7 @@ class module implements \phpbb\db\migration\tool\tool_interface  	* 			modules in that info file.  	* 	path, specify that here  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function add($class, $parent = 0, $data = array())  	{ @@ -331,6 +332,7 @@ class module implements \phpbb\db\migration\tool\tool_interface  	* @param int|string $module The module id|module_langname  	* 	specify that here  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function remove($class, $parent = 0, $module = '')  	{ @@ -466,6 +468,7 @@ class module implements \phpbb\db\migration\tool\tool_interface  	* @param string $class Module Class  	* @param string $basename Module Basename  	* @return array Module Information +	* @throws \phpbb\db\migration\exception  	*/  	protected function get_module_info($class, $basename)  	{ diff --git a/phpBB/phpbb/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php index ba856fbeda..d2df27613a 100644 --- a/phpBB/phpbb/db/migration/tool/permission.php +++ b/phpBB/phpbb/db/migration/tool/permission.php @@ -283,6 +283,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface  	* @param string $old_role_name The old role name  	* @param string $new_role_name The new role name  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function role_update($old_role_name, $new_role_name)  	{ @@ -345,6 +346,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface  	* @param bool $has_permission True if you want to give them permission,  	* 	false if you want to deny them permission  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function permission_set($name, $auth_option, $type = 'role', $has_permission = true)  	{ @@ -490,6 +492,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface  	* 	auth_options you would like to set  	* @param string $type The type (role|group)  	* @return null +	* @throws \phpbb\db\migration\exception  	*/  	public function permission_unset($name, $auth_option, $type = 'role')  	{ diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index 9b9532a7ad..c2f7b5ab23 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -167,8 +167,9 @@ class migrator  	/**  	* Attempts to apply a step of the given migration or one of its dependencies  	* -	* @param	string	The class name of the migration +	* @param	string	$name The class name of the migration  	* @return	bool	Whether any update step was successfully run +	* @throws \phpbb\db\migration\exception  	*/  	protected function try_apply($name)  	{ @@ -302,7 +303,7 @@ class migrator  	/**  	* Attempts to revert a step of the given migration or one of its dependencies  	* -	* @param	string	The class name of the migration +	* @param	string	$name The class name of the migration  	* @return	bool	Whether any update step was successfully run  	*/  	protected function try_revert($name) @@ -368,6 +369,7 @@ class migrator  	* @param bool|string $state Current state of the migration  	* @param bool $revert true to revert a data step  	* @return bool|string migration state. True if completed, serialized array if not finished +	* @throws \phpbb\db\migration\exception  	*/  	protected function process_data_step($steps, $state, $revert = false)  	{ @@ -464,6 +466,7 @@ class migrator  	* @param mixed $last_result Result to pass to the callable (only for 'custom' method)  	* @param bool $reverse False to install, True to attempt uninstallation by reversing the call  	* @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters +	* @throws \phpbb\db\migration\exception  	*/  	protected function get_callable_from_step(array $step, $last_result = 0, $reverse = false)  	{ @@ -714,7 +717,7 @@ class migrator  	/**  	* Load migration data files from a directory  	* -	* @param \phpbb\extension\finder $finder +	* @param \phpbb\finder $finder  	* @param string $path Path to migration data files  	* @param bool $check_fulfillable If TRUE (default), we will check  	* 	if all of the migrations are fulfillable after loading them. @@ -722,8 +725,9 @@ class migrator  	* 	to prevent errors (if including multiple directories, check  	* 	with the last call to prevent throwing errors unnecessarily).  	* @return array Array of migration names +	* @throws \phpbb\db\migration\exception  	*/ -	public function load_migrations(\phpbb\extension\finder $finder, $path, $check_fulfillable = true) +	public function load_migrations(\phpbb\finder $finder, $path, $check_fulfillable = true)  	{  		if (!is_dir($path))  		{ diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 3d065ede8e..2ec46ed239 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -109,36 +109,6 @@ class tools  				'VARBINARY'	=> 'varbinary(255)',  			), -			'firebird'	=> array( -				'INT:'		=> 'INTEGER', -				'BINT'		=> 'DOUBLE PRECISION', -				'UINT'		=> 'INTEGER', -				'UINT:'		=> 'INTEGER', -				'TINT:'		=> 'INTEGER', -				'USINT'		=> 'INTEGER', -				'BOOL'		=> 'INTEGER', -				'VCHAR'		=> 'VARCHAR(255) CHARACTER SET NONE', -				'VCHAR:'	=> 'VARCHAR(%d) CHARACTER SET NONE', -				'CHAR:'		=> 'CHAR(%d) CHARACTER SET NONE', -				'XSTEXT'	=> 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', -				'STEXT'		=> 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', -				'TEXT'		=> 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', -				'MTEXT'		=> 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', -				'XSTEXT_UNI'=> 'VARCHAR(100) CHARACTER SET UTF8', -				'STEXT_UNI'	=> 'VARCHAR(255) CHARACTER SET UTF8', -				'TEXT_UNI'	=> 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', -				'MTEXT_UNI'	=> 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', -				'TIMESTAMP'	=> 'INTEGER', -				'DECIMAL'	=> 'DOUBLE PRECISION', -				'DECIMAL:'	=> 'DOUBLE PRECISION', -				'PDECIMAL'	=> 'DOUBLE PRECISION', -				'PDECIMAL:'	=> 'DOUBLE PRECISION', -				'VCHAR_UNI'	=> 'VARCHAR(255) CHARACTER SET UTF8', -				'VCHAR_UNI:'=> 'VARCHAR(%d) CHARACTER SET UTF8', -				'VCHAR_CI'	=> 'VARCHAR(255) CHARACTER SET UTF8', -				'VARBINARY'	=> 'CHAR(255) CHARACTER SET NONE', -			), -  			'mssql'		=> array(  				'INT:'		=> '[int]',  				'BINT'		=> '[float]', @@ -331,7 +301,7 @@ class tools  	* A list of supported DBMS. We change this class to support more DBMS, the DBMS itself only need to follow some rules.  	* @var array  	*/ -	var $supported_dbms = array('firebird', 'mssql', 'mssqlnative', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite', 'sqlite3'); +	var $supported_dbms = array('mssql', 'mssqlnative', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite', 'sqlite3');  	/**  	* This is set to true if user only wants to return the 'to-be-executed' SQL statement(s) (as an array). @@ -441,13 +411,6 @@ class tools  					FROM pg_stat_user_tables';  			break; -			case 'firebird': -				$sql = 'SELECT rdb$relation_name -					FROM rdb$relations -					WHERE rdb$view_source is null -						AND rdb$system_flag = 0'; -			break; -  			case 'oracle':  				$sql = 'SELECT table_name  					FROM USER_TABLES'; @@ -580,7 +543,6 @@ class tools  		// Close the table for two DBMS and add to the statements  		switch ($this->sql_layer)  		{ -			case 'firebird':  			case 'mssql':  			case 'mssqlnative':  				$table_sql .= "\n);"; @@ -610,7 +572,6 @@ class tools  						$table_sql .= ",\n\t PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')';  					break; -					case 'firebird':  					case 'mssql':  					case 'mssqlnative':  						// We need the data here @@ -685,19 +646,6 @@ class tools  					$statements[] = $trigger;  				}  			break; - -			case 'firebird': -				if ($create_sequence) -				{ -					$statements[] = "CREATE GENERATOR {$table_name}_gen;"; -					$statements[] = "SET GENERATOR {$table_name}_gen TO 0;"; - -					$trigger = "CREATE TRIGGER t_$table_name FOR $table_name\n"; -					$trigger .= "BEFORE INSERT\nAS\nBEGIN\n"; -					$trigger .= "\tNEW.{$create_sequence} = GEN_ID({$table_name}_gen, 1);\nEND;"; -					$statements[] = $trigger; -				} -			break;  		}  		// Write Keys @@ -1174,12 +1122,6 @@ class tools  					WHERE LOWER(table_name) = '" . strtolower($table) . "'";  			break; -			case 'firebird': -				$sql = "SELECT RDB\$FIELD_NAME as FNAME -					FROM RDB\$RELATION_FIELDS -					WHERE RDB\$RELATION_NAME = '" . strtoupper($table) . "'"; -			break; -  			case 'sqlite':  			case 'sqlite3':  				$sql = "SELECT sql @@ -1278,15 +1220,6 @@ class tools  		switch ($this->sql_layer)  		{ -			case 'firebird': -				$sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name -					FROM RDB\$INDICES -					WHERE RDB\$RELATION_NAME = '" . strtoupper($table_name) . "' -						AND RDB\$UNIQUE_FLAG IS NULL -						AND RDB\$FOREIGN_KEY IS NULL"; -				$col = 'index_name'; -			break; -  			case 'postgres':  				$sql = "SELECT ic.relname as index_name  					FROM pg_class bc, pg_class ic, pg_index i @@ -1332,7 +1265,6 @@ class tools  			// These DBMS prefix index name with the table name  			switch ($this->sql_layer)  			{ -				case 'firebird':  				case 'oracle':  				case 'postgres':  				case 'sqlite': @@ -1385,15 +1317,6 @@ class tools  		switch ($this->sql_layer)  		{ -			case 'firebird': -				$sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name -					FROM RDB\$INDICES -					WHERE RDB\$RELATION_NAME = '" . strtoupper($table_name) . "' -						AND RDB\$UNIQUE_FLAG IS NOT NULL -						AND RDB\$FOREIGN_KEY IS NULL"; -				$col = 'index_name'; -			break; -  			case 'postgres':  				$sql = "SELECT ic.relname as index_name, i.indisunique  					FROM pg_class bc, pg_class ic, pg_index i @@ -1460,7 +1383,6 @@ class tools  					}  				break; -				case 'firebird':  				case 'postgres':  				case 'sqlite':  				case 'sqlite3': @@ -1536,32 +1458,6 @@ class tools  		switch ($this->sql_layer)  		{ -			case 'firebird': -				$sql .= " {$column_type} "; -				$return_array['column_type_sql_type'] = " {$column_type} "; - -				if (!is_null($column_data[1])) -				{ -					$sql .= 'DEFAULT ' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; -					$return_array['column_type_sql_default'] = ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; -				} - -				$sql .= 'NOT NULL'; - -				// This is a UNICODE column and thus should be given it's fair share -				if (preg_match('/^X?STEXT_UNI|VCHAR_(CI|UNI:?)/', $column_data[0])) -				{ -					$sql .= ' COLLATE UNICODE'; -				} - -				$return_array['auto_increment'] = false; -				if (isset($column_data[2]) && $column_data[2] == 'auto_increment') -				{ -					$return_array['auto_increment'] = true; -				} - -			break; -  			case 'mssql':  			case 'mssqlnative':  				$sql .= " {$column_type} "; @@ -1772,11 +1668,6 @@ class tools  		switch ($this->sql_layer)  		{ -			case 'firebird': -				// Does not support AFTER statement, only POSITION (and there you need the column position) -				$statements[] = 'ALTER TABLE ' . $table_name . ' ADD "' . strtoupper($column_name) . '" ' . $column_data['column_type_sql']; -			break; -  			case 'mssql':  			case 'mssqlnative':  				// Does not support AFTER, only through temporary table @@ -1894,10 +1785,6 @@ class tools  		switch ($this->sql_layer)  		{ -			case 'firebird': -				$statements[] = 'ALTER TABLE ' . $table_name . ' DROP "' . strtoupper($column_name) . '"'; -			break; -  			case 'mssql':  			case 'mssqlnative':  				// We need the data here @@ -1996,7 +1883,7 @@ class tools  				$columns = implode(',', $column_list); -				$new_table_cols = trim(preg_replace('/' . $column_name . '[^,]+(?:,|$)/m', '', $new_table_cols)); +				$new_table_cols = trim(preg_replace('/' . $column_name . '\b[^,]+(?:,|$)/m', '', $new_table_cols));  				if (substr($new_table_cols, -1) === ',')  				{  					// Remove the comma from the last entry again @@ -2036,7 +1923,6 @@ class tools  				$statements[] = 'DROP INDEX ' . $index_name . ' ON ' . $table_name;  			break; -			case 'firebird':  			case 'oracle':  			case 'postgres':  			case 'sqlite': @@ -2065,21 +1951,6 @@ class tools  		switch ($this->sql_layer)  		{ -			case 'firebird': -				$sql = 'SELECT RDB$GENERATOR_NAME as gen -					FROM RDB$GENERATORS -					WHERE RDB$SYSTEM_FLAG = 0 -						AND RDB$GENERATOR_NAME = \'' . strtoupper($table_name) . "_GEN'"; -				$result = $this->db->sql_query($sql); - -				// does a generator exist? -				if ($row = $this->db->sql_fetchrow($result)) -				{ -					$statements[] = "DROP GENERATOR {$row['gen']};"; -				} -				$this->db->sql_freeresult($result); -			break; -  			case 'oracle':  				$sql = 'SELECT A.REFERENCED_NAME  					FROM USER_DEPENDENCIES A, USER_TRIGGERS B @@ -2125,7 +1996,6 @@ class tools  		switch ($this->sql_layer)  		{ -			case 'firebird':  			case 'postgres':  			case 'mysql_40':  			case 'mysql_41': @@ -2217,7 +2087,6 @@ class tools  		switch ($this->sql_layer)  		{ -			case 'firebird':  			case 'postgres':  			case 'oracle':  			case 'sqlite': @@ -2261,7 +2130,6 @@ class tools  		switch ($this->sql_layer)  		{ -			case 'firebird':  			case 'postgres':  			case 'oracle':  			case 'sqlite': @@ -2320,15 +2188,6 @@ class tools  		{  			switch ($this->sql_layer)  			{ -				case 'firebird': -					$sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name -						FROM RDB\$INDICES -						WHERE RDB\$RELATION_NAME = '" . strtoupper($table_name) . "' -							AND RDB\$UNIQUE_FLAG IS NULL -							AND RDB\$FOREIGN_KEY IS NULL"; -					$col = 'index_name'; -				break; -  				case 'postgres':  					$sql = "SELECT ic.relname as index_name  						FROM pg_class bc, pg_class ic, pg_index i @@ -2373,7 +2232,6 @@ class tools  				switch ($this->sql_layer)  				{ -					case 'firebird':  					case 'oracle':  					case 'postgres':  					case 'sqlite': @@ -2400,20 +2258,6 @@ class tools  		switch ($this->sql_layer)  		{ -			case 'firebird': -				// Change type... -				if (!empty($column_data['column_type_sql_default'])) -				{ -					$statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql_type']; -					$statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" SET DEFAULT ' . ' ' . $column_data['column_type_sql_default']; -				} -				else -				{ -					// TODO: try to change pkey without removing trigger, generator or constraints. ATM this query may fail. -					$statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql_type']; -				} -			break; -  			case 'mssql':  			case 'mssqlnative':  				// We need the data here @@ -2561,7 +2405,18 @@ class tools  				foreach ($old_table_cols as $key => $declaration)  				{ -					$entities = preg_split('#\s+#', trim($declaration)); +					$declaration = trim($declaration); + +					// Check for the beginning of the constraint section and stop +					if (preg_match('/[^\(]*\s*PRIMARY KEY\s+\(/', $declaration) || +						preg_match('/[^\(]*\s*UNIQUE\s+\(/', $declaration) || +						preg_match('/[^\(]*\s*FOREIGN KEY\s+\(/', $declaration) || +						preg_match('/[^\(]*\s*CHECK\s+\(/', $declaration)) +					{ +						break; +					} + +					$entities = preg_split('#\s+#', $declaration);  					$column_list[] = $entities[0];  					if ($entities[0] == $column_name)  					{ diff --git a/phpBB/phpbb/di/extension/config.php b/phpBB/phpbb/di/extension/config.php index 403c9d50e7..a7d7284f85 100644 --- a/phpBB/phpbb/di/extension/config.php +++ b/phpBB/phpbb/di/extension/config.php @@ -15,8 +15,6 @@ namespace phpbb\di\extension;  use Symfony\Component\DependencyInjection\ContainerBuilder;  use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\Config\FileLocator;  /**  * Container config extension @@ -34,7 +32,7 @@ class config extends Extension  	* @param array            $config    An array of configuration values  	* @param ContainerBuilder $container A ContainerBuilder instance  	* -	* @throws InvalidArgumentException When provided tag is not defined in this extension +	* @throws \InvalidArgumentException When provided tag is not defined in this extension  	*/  	public function load(array $config, ContainerBuilder $container)  	{ @@ -68,7 +66,7 @@ class config extends Extension  	* Convert 3.0 ACM type to 3.1 cache driver class name  	*  	* @param string $acm_type ACM type -	* @return cache driver class +	* @return string cache driver class  	*/  	protected function convert_30_acm_type($acm_type)  	{ diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 72026f3b54..ca4fa5c082 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -45,7 +45,7 @@ class core extends Extension  	* @param array            $config    An array of configuration values  	* @param ContainerBuilder $container A ContainerBuilder instance  	* -	* @throws InvalidArgumentException When provided tag is not defined in this extension +	* @throws \InvalidArgumentException When provided tag is not defined in this extension  	*/  	public function load(array $config, ContainerBuilder $container)  	{ diff --git a/phpBB/phpbb/di/extension/ext.php b/phpBB/phpbb/di/extension/ext.php index 1205dffb53..718c992d2e 100644 --- a/phpBB/phpbb/di/extension/ext.php +++ b/phpBB/phpbb/di/extension/ext.php @@ -39,7 +39,7 @@ class ext extends Extension  	* @param array            $config    An array of configuration values  	* @param ContainerBuilder $container A ContainerBuilder instance  	* -	* @throws InvalidArgumentException When provided tag is not defined in this extension +	* @throws \InvalidArgumentException When provided tag is not defined in this extension  	*/  	public function load(array $config, ContainerBuilder $container)  	{ diff --git a/phpBB/phpbb/di/pass/kernel_pass.php b/phpBB/phpbb/di/pass/kernel_pass.php index 44d4fcd07f..c154c7532d 100644 --- a/phpBB/phpbb/di/pass/kernel_pass.php +++ b/phpBB/phpbb/di/pass/kernel_pass.php @@ -23,6 +23,7 @@ class kernel_pass implements CompilerPassInterface  	*  	* @param ContainerBuilder $container ContainerBuilder object  	* @return null +	* @throws \InvalidArgumentException  	*/  	public function process(ContainerBuilder $container)  	{ diff --git a/phpBB/phpbb/di/service_collection.php b/phpBB/phpbb/di/service_collection.php index 3a18644891..82ca9bf679 100644 --- a/phpBB/phpbb/di/service_collection.php +++ b/phpBB/phpbb/di/service_collection.php @@ -21,6 +21,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;  class service_collection extends \ArrayObject  {  	/** +	* @var \Symfony\Component\DependencyInjection\ContainerInterface +	*/ +	protected $container; + +	/**  	* Constructor  	*  	* @param ContainerInterface $container Container object @@ -31,6 +36,37 @@ class service_collection extends \ArrayObject  	}  	/** +	* {@inheritdoc} +	*/ +	public function getIterator() +	{ +		return new service_collection_iterator($this); +	} + +	// Because of a PHP issue we have to redefine offsetExists +	// (even with a call to the parent): +	// 		https://bugs.php.net/bug.php?id=66834 +	// 		https://bugs.php.net/bug.php?id=67067 +	// But it triggers a sniffer issue that we have to skip +	// @codingStandardsIgnoreStart +	/** +	* {@inheritdoc} +	*/ +	public function offsetExists($index) +	{ +		return parent::offsetExists($index); +	} +	// @codingStandardsIgnoreEnd + +	/** +	* {@inheritdoc} +	*/ +	public function offsetGet($index) +	{ +		return $this->container->get($index); +	} + +	/**  	* Add a service to the collection  	*  	* @param string $name The service name @@ -38,8 +74,6 @@ class service_collection extends \ArrayObject  	*/  	public function add($name)  	{ -		$task = $this->container->get($name); - -		$this->offsetSet($name, $task); +		$this->offsetSet($name, null);  	}  } diff --git a/phpBB/phpbb/di/service_collection_iterator.php b/phpBB/phpbb/di/service_collection_iterator.php new file mode 100644 index 0000000000..0d031ab52d --- /dev/null +++ b/phpBB/phpbb/di/service_collection_iterator.php @@ -0,0 +1,46 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\di; + +/** +* Iterator which loads the services when they are requested +*/ +class service_collection_iterator extends \ArrayIterator +{ +	/** +	* @var \phpbb\di\service_collection +	*/ +	protected $collection; + +	/** +	* Construct an ArrayIterator for service_collection +	* +	* @param \phpbb\di\service_collection $collection The collection to iterate over +	* @param int $flags Flags to control the behaviour of the ArrayObject object. +	* @see ArrayObject::setFlags() +	*/ +	public function __construct(service_collection $collection, $flags = 0) +	{ +		parent::__construct($collection, $flags); +		$this->collection = $collection; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function current() +	{ +		return $this->collection->offsetGet($this->key()); +	} +} diff --git a/phpBB/phpbb/event/recursive_event_filter_iterator.php b/phpBB/phpbb/event/recursive_event_filter_iterator.php index f65feff448..64e2e56f6a 100644 --- a/phpBB/phpbb/event/recursive_event_filter_iterator.php +++ b/phpBB/phpbb/event/recursive_event_filter_iterator.php @@ -39,7 +39,8 @@ class recursive_event_filter_iterator extends \RecursiveFilterIterator  	*  	* @return recursive_event_filter_iterator  	*/ -	public function getChildren() { +	public function getChildren() +	{  		return new self($this->getInnerIterator()->getChildren(), $this->root_path);  	} diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index eb306aeb72..cbbd7bc622 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -23,7 +23,7 @@ class base implements \phpbb\extension\extension_interface  	/** @var ContainerInterface */  	protected $container; -	/** @var \phpbb\extension\finder */ +	/** @var \phpbb\finder */  	protected $finder;  	/** @var \phpbb\db\migrator */ @@ -39,11 +39,11 @@ class base implements \phpbb\extension\extension_interface  	* Constructor  	*  	* @param ContainerInterface $container Container object -	* @param \phpbb\extension\finder $extension_finder +	* @param \phpbb\finder $extension_finder  	* @param string $extension_name Name of this extension (from ext.manager)  	* @param string $extension_path Relative path to this extension  	*/ -	public function __construct(ContainerInterface $container, \phpbb\extension\finder $extension_finder, \phpbb\db\migrator $migrator, $extension_name, $extension_path) +	public function __construct(ContainerInterface $container, \phpbb\finder $extension_finder, \phpbb\db\migrator $migrator, $extension_name, $extension_path)  	{  		$this->container = $container;  		$this->extension_finder = $extension_finder; diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php index cd7289e085..4130e8455a 100644 --- a/phpBB/phpbb/extension/manager.php +++ b/phpBB/phpbb/extension/manager.php @@ -148,7 +148,7 @@ class manager  	* Instantiates the metadata manager for the extension with the given name  	*  	* @param string $name The extension name -	* @param string $template The template manager +	* @param \phpbb\template\template $template The template manager  	* @return \phpbb\extension\metadata_manager Instance of the metadata manager  	*/  	public function create_extension_metadata_manager($name, \phpbb\template\template $template) @@ -423,7 +423,7 @@ class manager  		foreach ($iterator as $file_info)  		{ -			if ($file_info->isFile() && $file_info->getFilename() == 'ext.' . $this->php_ext) +			if ($file_info->isFile() && $file_info->getFilename() == 'composer.json')  			{  				$ext_name = $iterator->getInnerIterator()->getSubPath();  				$composer_file = $iterator->getPath() . '/composer.json'; @@ -532,12 +532,22 @@ class manager  	}  	/** -	* Instantiates a \phpbb\extension\finder. +	* Instantiates a \phpbb\finder.  	* -	* @return \phpbb\extension\finder An extension finder instance +	* @param bool $use_all_available Should we load all extensions, or just enabled ones +	* @return \phpbb\finder An extension finder instance  	*/ -	public function get_finder() +	public function get_finder($use_all_available = false)  	{ -		return new \phpbb\extension\finder($this, $this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); +		$finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); +		if ($use_all_available) +		{ +			$finder->set_extensions(array_keys($this->all_available())); +		} +		else +		{ +			$finder->set_extensions(array_keys($this->all_enabled())); +		} +		return $finder;  	}  } diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php index 5c4e8fbf00..014d8c79c7 100644 --- a/phpBB/phpbb/extension/metadata_manager.php +++ b/phpBB/phpbb/extension/metadata_manager.php @@ -90,11 +90,11 @@ class metadata_manager  	}  	/** -	 * Processes and gets the metadata requested -	 * -	 * @param  string $element			All for all metadata that it has and is valid, otherwise specify which section you want by its shorthand term. -	 * @return array					Contains all of the requested metadata, throws an exception on failure -	 */ +	* Processes and gets the metadata requested +	* +	* @param  string $element			All for all metadata that it has and is valid, otherwise specify which section you want by its shorthand term. +	* @return array					Contains all of the requested metadata, throws an exception on failure +	*/  	public function get_metadata($element = 'all')  	{  		$this->set_metadata_file(); @@ -136,10 +136,10 @@ class metadata_manager  	}  	/** -	 * Sets the filepath of the metadata file -	 * -	 * @return boolean  Set to true if it exists, throws an exception on failure -	 */ +	* Sets the filepath of the metadata file +	* +	* @throws \phpbb\extension\exception +	*/  	private function set_metadata_file()  	{  		$ext_filepath = $this->extension_manager->get_extension_path($this->ext_name); @@ -154,10 +154,11 @@ class metadata_manager  	}  	/** -	 * Gets the contents of the composer.json file -	 * -	 * @return bool True if success, throws an exception on failure -	 */ +	* Gets the contents of the composer.json file +	* +	* @return bool True if success, throws an exception on failure +	* @throws \phpbb\extension\exception +	*/  	private function fetch_metadata()  	{  		if (!file_exists($this->metadata_file)) @@ -183,10 +184,10 @@ class metadata_manager  	}  	/** -	 * This array handles the cleaning of the array -	 * -	 * @return array Contains the cleaned metadata array -	 */ +	* This array handles the cleaning of the array +	* +	* @return array Contains the cleaned metadata array +	*/  	private function clean_metadata_array()  	{  		return $this->metadata; @@ -199,6 +200,7 @@ class metadata_manager  	* 						"display" for name, type, and authors  	* 						"name", "type")  	* @return Bool True if valid, throws an exception if invalid +	* @throws \phpbb\extension\exception  	*/  	public function validate($name = 'display')  	{ @@ -247,10 +249,11 @@ class metadata_manager  	}  	/** -	 * Validates the contents of the authors field -	 * -	 * @return boolean True when passes validation, throws exception if invalid -	 */ +	* Validates the contents of the authors field +	* +	* @return boolean True when passes validation, throws exception if invalid +	* @throws \phpbb\extension\exception +	*/  	public function validate_authors()  	{  		if (empty($this->metadata['authors'])) @@ -270,10 +273,10 @@ class metadata_manager  	}  	/** -	 * This array handles the verification that this extension can be enabled on this board -	 * -	 * @return bool True if validation succeeded, False if failed -	 */ +	* This array handles the verification that this extension can be enabled on this board +	* +	* @return bool True if validation succeeded, False if failed +	*/  	public function validate_enable()  	{  		// Check for valid directory & phpBB, PHP versions @@ -286,10 +289,10 @@ class metadata_manager  	}  	/** -	 * Validates the most basic directory structure to ensure it follows <vendor>/<ext> convention. -	 * -	 * @return boolean True when passes validation -	 */ +	* Validates the most basic directory structure to ensure it follows <vendor>/<ext> convention. +	* +	* @return boolean True when passes validation +	*/  	public function validate_dir()  	{  		return (substr_count($this->ext_name, '/') === 1 && $this->ext_name == $this->get_metadata('name')); @@ -297,10 +300,10 @@ class metadata_manager  	/** -	 * Validates the contents of the phpbb requirement field -	 * -	 * @return boolean True when passes validation -	 */ +	* Validates the contents of the phpbb requirement field +	* +	* @return boolean True when passes validation +	*/  	public function validate_require_phpbb()  	{  		if (!isset($this->metadata['require']['phpbb/phpbb'])) @@ -312,10 +315,10 @@ class metadata_manager  	}  	/** -	 * Validates the contents of the php requirement field -	 * -	 * @return boolean True when passes validation -	 */ +	* Validates the contents of the php requirement field +	* +	* @return boolean True when passes validation +	*/  	public function validate_require_php()  	{  		if (!isset($this->metadata['require']['php'])) @@ -348,10 +351,10 @@ class metadata_manager  	}  	/** -	 * Outputs the metadata into the template -	 * -	 * @return null -	 */ +	* Outputs the metadata into the template +	* +	* @return null +	*/  	public function output_template_data()  	{  		$this->template->assign_vars(array( diff --git a/phpBB/phpbb/extension/provider.php b/phpBB/phpbb/extension/provider.php index e1d854df64..1c42cf7b5e 100644 --- a/phpBB/phpbb/extension/provider.php +++ b/phpBB/phpbb/extension/provider.php @@ -58,7 +58,7 @@ abstract class provider implements \IteratorAggregate  	/**  	* Retrieve an iterator over all items  	* -	* @return ArrayIterator An iterator for the array of template paths +	* @return \ArrayIterator An iterator for the array of template paths  	*/  	public function getIterator()  	{ diff --git a/phpBB/phpbb/feed/base.php b/phpBB/phpbb/feed/base.php index 36ecbbcc2e..e31854160a 100644 --- a/phpBB/phpbb/feed/base.php +++ b/phpBB/phpbb/feed/base.php @@ -70,15 +70,14 @@ abstract class base  	/**  	* Constructor  	* -	* @param \phpbb\feed\helper $helper Feed helper -	* @param \phpbb\config\config		$config		Config object +	* @param \phpbb\feed\helper					$helper		Feed helper +	* @param \phpbb\config\config				$config		Config object  	* @param \phpbb\db\driver\driver_interface	$db			Database connection -	* @param \phpbb\cache\driver\driver_interface	$cache			Cache object -	* @param \phpbb\user			$user		User object -	* @param \phpbb\auth\auth			$auth		Auth object -	* @param \phpbb\content_visibility	$content_visibility		Auth object -	* @param string				$phpEx		php file extension -	* @return	null +	* @param \phpbb\cache\driver\driver_interface	$cache	Cache object +	* @param \phpbb\user						$user		User object +	* @param \phpbb\auth\auth					$auth		Auth object +	* @param \phpbb\content_visibility			$content_visibility		Auth object +	* @param string								$phpEx		php file extension  	*/  	function __construct(\phpbb\feed\helper $helper, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\content_visibility $content_visibility, $phpEx)  	{ @@ -133,6 +132,9 @@ abstract class base  	/**  	* Set key +	* +	* @param string $key Key +	* @param mixed $value Value  	*/  	function set($key, $value)  	{ @@ -141,6 +143,9 @@ abstract class base  	/**  	* Get key +	* +	* @param string $key Key +	* @return mixed  	*/  	function get($key)  	{ diff --git a/phpBB/phpbb/feed/factory.php b/phpBB/phpbb/feed/factory.php index 84b4d5d560..f364f06d03 100644 --- a/phpBB/phpbb/feed/factory.php +++ b/phpBB/phpbb/feed/factory.php @@ -13,6 +13,8 @@  namespace phpbb\feed; +use Symfony\Component\DependencyInjection\ContainerInterface; +  /**  * Factory class to return correct object  */ @@ -20,7 +22,7 @@ class factory  {  	/**  	* Service container object -	* @var object +	* @var ContainerInterface  	*/  	protected $container; @@ -33,12 +35,11 @@ class factory  	/**  	* Constructor  	* -	* @param objec				$container	Container object -	* @param \phpbb\config\config		$config		Config object +	* @param ContainerInterface					$container	Container object +	* @param \phpbb\config\config				$config		Config object  	* @param \phpbb\db\driver\driver_interface	$db			Database connection -	* @return	null  	*/ -	public function __construct($container, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db) +	public function __construct(ContainerInterface $container, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db)  	{  		$this->container = $container;  		$this->config = $config; diff --git a/phpBB/phpbb/feed/helper.php b/phpBB/phpbb/feed/helper.php index ed78f4893e..9741b752af 100644 --- a/phpBB/phpbb/feed/helper.php +++ b/phpBB/phpbb/feed/helper.php @@ -36,7 +36,7 @@ class helper  	* @param	\phpbb\config\config	$config		Config object  	* @param	\phpbb\user		$user		User object  	* @param	string	$phpbb_root_path	Root path -	* @return	null +	* @param	string	$phpEx				PHP extension  	*/  	public function __construct(\phpbb\config\config $config, \phpbb\user $user, $phpbb_root_path, $phpEx)  	{ diff --git a/phpBB/phpbb/feed/post_base.php b/phpBB/phpbb/feed/post_base.php index fe11fd2a79..011775b6af 100644 --- a/phpBB/phpbb/feed/post_base.php +++ b/phpBB/phpbb/feed/post_base.php @@ -48,8 +48,8 @@ abstract class post_base extends \phpbb\feed\attachments_base  		{  			$item_row['statistics'] = $this->user->lang['POSTED'] . ' ' . $this->user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row)  				. ' ' . $this->separator_stats . ' ' . $this->user->format_date($row[$this->get('published')]) -				. (($this->is_moderator_approve_forum($row['forum_id']) && (int)$row['post_visibility'] === ITEM_UNAPPROVED) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_UNAPPROVED'] : '') -				. (($this->is_moderator_approve_forum($row['forum_id']) && (int)$row['post_visibility'] === ITEM_DELETED) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_DELETED'] : ''); +				. (($this->is_moderator_approve_forum($row['forum_id']) && (int) $row['post_visibility'] === ITEM_UNAPPROVED) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_UNAPPROVED'] : '') +				. (($this->is_moderator_approve_forum($row['forum_id']) && (int) $row['post_visibility'] === ITEM_DELETED) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_DELETED'] : '');  		}  	}  } diff --git a/phpBB/phpbb/feed/topic_base.php b/phpBB/phpbb/feed/topic_base.php index 4fbb498272..f9ff368cba 100644 --- a/phpBB/phpbb/feed/topic_base.php +++ b/phpBB/phpbb/feed/topic_base.php @@ -52,11 +52,11 @@ abstract class topic_base extends \phpbb\feed\attachments_base  			if ($this->is_moderator_approve_forum($row['forum_id']))  			{ -				if ( (int)$row['topic_visibility'] === ITEM_DELETED) +				if ((int) $row['topic_visibility'] === ITEM_DELETED)  				{  					$item_row['statistics'] .= ' ' . $this->separator_stats . ' ' . $this->user->lang['TOPIC_DELETED'];  				} -				else if ((int)$row['topic_visibility'] === ITEM_UNAPPROVED) +				else if ((int) $row['topic_visibility'] === ITEM_UNAPPROVED)  				{  					$item_row['statistics'] .= ' ' . $this->separator_stats . ' ' . $this->user->lang['TOPIC_UNAPPROVED'];  				} diff --git a/phpBB/phpbb/extension/finder.php b/phpBB/phpbb/finder.php index 6f2408094e..28f28825ba 100644 --- a/phpBB/phpbb/extension/finder.php +++ b/phpBB/phpbb/finder.php @@ -11,14 +11,14 @@  *  */ -namespace phpbb\extension; +namespace phpbb;  /** -* The extension finder provides a simple way to locate files in active extensions +* The finder provides a simple way to locate files in the core and a set of extensions  */  class finder  { -	protected $extension_manager; +	protected $extensions;  	protected $filesystem;  	protected $phpbb_root_path;  	protected $cache; @@ -48,9 +48,6 @@ class finder  	/**  	* Creates a new finder instance with its dependencies  	* -	* @param \phpbb\extension\manager $extension_manager An extension manager -	*            instance that provides the finder with a list of active -	*            extensions and their locations  	* @param \phpbb\filesystem $filesystem Filesystem instance  	* @param string $phpbb_root_path Path to the phpbb root directory  	* @param \phpbb\cache\driver\driver_interface $cache A cache instance or null @@ -58,9 +55,8 @@ class finder  	* @param string $cache_name The name of the cache variable, defaults to  	*                           _ext_finder  	*/ -	public function __construct(\phpbb\extension\manager $extension_manager, \phpbb\filesystem $filesystem, $phpbb_root_path = '', \phpbb\cache\driver\driver_interface $cache = null, $php_ext = 'php', $cache_name = '_ext_finder') +	public function __construct(\phpbb\filesystem $filesystem, $phpbb_root_path = '', \phpbb\cache\driver\driver_interface $cache = null, $php_ext = 'php', $cache_name = '_ext_finder')  	{ -		$this->extension_manager = $extension_manager;  		$this->filesystem = $filesystem;  		$this->phpbb_root_path = $phpbb_root_path;  		$this->cache = $cache; @@ -76,15 +72,37 @@ class finder  			'extension_prefix' => false,  			'extension_directory' => false,  		); +		$this->extensions = array();  		$this->cached_queries = ($this->cache) ? $this->cache->get($this->cache_name) : false;  	}  	/** +	* Set the array of extensions +	* +	* @param array $extensions		A list of extensions that should be searched aswell +	* @param bool $replace_list		Should the list be emptied before adding the extensions +	* @return \phpbb\finder This object for chaining calls +	*/ +	public function set_extensions(array $extensions, $replace_list = true) +	{ +		if ($replace_list) +		{ +			$this->extensions = array(); +		} + +		foreach ($extensions as $ext_name) +		{ +			$this->extensions[$ext_name] = $this->phpbb_root_path . 'ext/' . $ext_name . '/'; +		} +		return $this; +	} + +	/**  	* Sets a core path to be searched in addition to extensions  	*  	* @param string $core_path The path relative to phpbb_root_path -	* @return \phpbb\extension\finder This object for chaining calls +	* @return \phpbb\finder This object for chaining calls  	*/  	public function core_path($core_path)  	{ @@ -100,7 +118,7 @@ class finder  	* file extension is automatically added to suffixes.  	*  	* @param string $suffix A filename suffix -	* @return \phpbb\extension\finder This object for chaining calls +	* @return \phpbb\finder This object for chaining calls  	*/  	public function suffix($suffix)  	{ @@ -117,7 +135,7 @@ class finder  	* file extension is automatically added to suffixes.  	*  	* @param string $extension_suffix A filename suffix -	* @return \phpbb\extension\finder This object for chaining calls +	* @return \phpbb\finder This object for chaining calls  	*/  	public function extension_suffix($extension_suffix)  	{ @@ -133,7 +151,7 @@ class finder  	* file extension is automatically added to suffixes.  	*  	* @param string $core_suffix A filename suffix -	* @return \phpbb\extension\finder This object for chaining calls +	* @return \phpbb\finder This object for chaining calls  	*/  	public function core_suffix($core_suffix)  	{ @@ -145,7 +163,7 @@ class finder  	* Sets the prefix all files found in extensions and core must match  	*  	* @param string $prefix A filename prefix -	* @return \phpbb\extension\finder This object for chaining calls +	* @return \phpbb\finder This object for chaining calls  	*/  	public function prefix($prefix)  	{ @@ -158,7 +176,7 @@ class finder  	* Sets a prefix all files found in extensions must match  	*  	* @param string $extension_prefix A filename prefix -	* @return \phpbb\extension\finder This object for chaining calls +	* @return \phpbb\finder This object for chaining calls  	*/  	public function extension_prefix($extension_prefix)  	{ @@ -170,7 +188,7 @@ class finder  	* Sets a prefix all files found in the core path must match  	*  	* @param string $core_prefix A filename prefix -	* @return \phpbb\extension\finder This object for chaining calls +	* @return \phpbb\finder This object for chaining calls  	*/  	public function core_prefix($core_prefix)  	{ @@ -185,7 +203,7 @@ class finder  	* the current directory.  	*  	* @param string $directory -	* @return \phpbb\extension\finder This object for chaining calls +	* @return \phpbb\finder This object for chaining calls  	*/  	public function directory($directory)  	{ @@ -198,7 +216,7 @@ class finder  	* Sets a directory all files found in extensions must be contained in  	*  	* @param string $extension_directory -	* @return \phpbb\extension\finder This object for chaining calls +	* @return \phpbb\finder This object for chaining calls  	*/  	public function extension_directory($extension_directory)  	{ @@ -210,7 +228,7 @@ class finder  	* Sets a directory all files found in the core path must be contained in  	*  	* @param string $core_directory -	* @return \phpbb\extension\finder This object for chaining calls +	* @return \phpbb\finder This object for chaining calls  	*/  	public function core_directory($core_directory)  	{ @@ -246,16 +264,14 @@ class finder  	* phpBB naming rules an incorrect class name will be returned.  	*  	* @param bool $cache Whether the result should be cached -	* @param bool $use_all_available Use all available instead of just all -	* 						enabled extensions  	* @return array An array of found class names  	*/ -	public function get_classes($cache = true, $use_all_available = false) +	public function get_classes($cache = true)  	{  		$this->query['extension_suffix'] .= '.' . $this->php_ext;  		$this->query['core_suffix'] .= '.' . $this->php_ext; -		$files = $this->find($cache, false, $use_all_available); +		$files = $this->find($cache, false);  		return $this->get_classes_from_files($files);  	} @@ -290,27 +306,23 @@ class finder  	* Finds all directories matching the configured options  	*  	* @param bool $cache Whether the result should be cached -	* @param bool $use_all_available Use all available instead of just all -	* 						enabled extensions  	* @param bool $extension_keys Whether the result should have extension name as array key  	* @return array An array of paths to found directories  	*/ -	public function get_directories($cache = true, $use_all_available = false, $extension_keys = false) +	public function get_directories($cache = true, $extension_keys = false)  	{ -		return $this->find_with_root_path($cache, true, $use_all_available, $extension_keys); +		return $this->find_with_root_path($cache, true, $extension_keys);  	}  	/**  	* Finds all files matching the configured options.  	*  	* @param bool $cache Whether the result should be cached -	* @param bool $use_all_available Use all available instead of just all -	* 						enabled extensions  	* @return array An array of paths to found files  	*/ -	public function get_files($cache = true, $use_all_available = false) +	public function get_files($cache = true)  	{ -		return $this->find_with_root_path($cache, false, $use_all_available); +		return $this->find_with_root_path($cache, false);  	}  	/** @@ -318,16 +330,14 @@ class finder  	*  	* @param bool $cache Whether the result should be cached  	* @param bool $is_dir Directories will be returned when true, only files -	*                     otherwise -	* @param bool $use_all_available Use all available instead of just all -	* 						enabled extensions +	*					otherwise  	* @param bool $extension_keys If true, result will be associative array  	*					with extension name as key  	* @return array An array of paths to found items  	*/ -	protected function find_with_root_path($cache = true, $is_dir = false, $use_all_available = false, $extension_keys = false) +	protected function find_with_root_path($cache = true, $is_dir = false, $extension_keys = false)  	{ -		$items = $this->find($cache, $is_dir, $use_all_available); +		$items = $this->find($cache, $is_dir);  		$result = array();  		foreach ($items as $item => $ext_name) @@ -351,21 +361,11 @@ class finder  	* @param bool $cache Whether the result should be cached  	* @param bool $is_dir Directories will be returned when true, only files  	*                     otherwise -	* @param bool $use_all_available Use all available instead of just all -	* 						enabled extensions  	* @return array An array of paths to found items  	*/ -	public function find($cache = true, $is_dir = false, $use_all_available = false) +	public function find($cache = true, $is_dir = false)  	{ -		if ($use_all_available) -		{ -			$extensions = $this->extension_manager->all_available(); -		} -		else -		{ -			$extensions = $this->extension_manager->all_enabled(); -		} - +		$extensions = $this->extensions;  		if ($this->query['core_path'])  		{  			$extensions['/'] = $this->phpbb_root_path . $this->query['core_path']; diff --git a/phpBB/phpbb/groupposition/legend.php b/phpBB/phpbb/groupposition/legend.php index af903e363e..efea3389d4 100644 --- a/phpBB/phpbb/groupposition/legend.php +++ b/phpBB/phpbb/groupposition/legend.php @@ -53,7 +53,9 @@ class legend implements \phpbb\groupposition\groupposition_interface  	/**  	* Returns the group_legend for a given group, if the group exists.  	* -	* {@inheritDoc} +	* @param	int		$group_id	group_id of the group to be selected +	* @return	int			position of the group +	* @throws \phpbb\groupposition\exception  	*/  	public function get_group_value($group_id)  	{ @@ -76,7 +78,7 @@ class legend implements \phpbb\groupposition\groupposition_interface  	/**  	* Get number of groups, displayed on the legend  	* -	* {@inheritDoc} +	* @return	int		value of the last item displayed  	*/  	public function get_group_count()  	{ @@ -91,8 +93,6 @@ class legend implements \phpbb\groupposition\groupposition_interface  	}  	/** -	* Adds a group by group_id -	*  	* {@inheritDoc}  	*/  	public function add_group($group_id) @@ -118,7 +118,9 @@ class legend implements \phpbb\groupposition\groupposition_interface  	/**  	* Deletes a group by setting the field to self::GROUP_DISABLED and closing the gap in the list.  	* -	* {@inheritDoc} +	* @param	int		$group_id		group_id of the group to be deleted +	* @param	bool	$skip_group		Skip setting the value for this group, to save the query, when you need to update it anyway. +	* @return	bool		True if the group was deleted successfully  	*/  	public function delete_group($group_id, $skip_group = false)  	{ @@ -150,8 +152,6 @@ class legend implements \phpbb\groupposition\groupposition_interface  	}  	/** -	* Moves a group up by group_id -	*  	* {@inheritDoc}  	*/  	public function move_up($group_id) @@ -160,8 +160,6 @@ class legend implements \phpbb\groupposition\groupposition_interface  	}  	/** -	* Moves a group down by group_id -	*  	* {@inheritDoc}  	*/  	public function move_down($group_id) @@ -170,8 +168,6 @@ class legend implements \phpbb\groupposition\groupposition_interface  	}  	/** -	* Moves a group up/down -	*  	* {@inheritDoc}  	*/  	public function move($group_id, $delta) diff --git a/phpBB/phpbb/groupposition/teampage.php b/phpBB/phpbb/groupposition/teampage.php index 3e675549bf..2985c51525 100644 --- a/phpBB/phpbb/groupposition/teampage.php +++ b/phpBB/phpbb/groupposition/teampage.php @@ -65,7 +65,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	/**  	* Returns the teampage position for a given group, if the group exists.  	* -	* {@inheritDoc} +	* @param	int		$group_id	group_id of the group to be selected +	* @return	int			position of the group +	* @throws \phpbb\groupposition\exception  	*/  	public function get_group_value($group_id)  	{ @@ -93,6 +95,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	*  	* @param	int		$group_id	group_id of the group to be selected  	* @return	array			Data row of the group +	* @throws \phpbb\groupposition\exception  	*/  	public function get_group_values($group_id)  	{ @@ -120,6 +123,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	*  	* @param	int		$teampage_id	Teampage_id of the selected item  	* @return	int			Teampage position of the item +	* @throws \phpbb\groupposition\exception  	*/  	public function get_teampage_value($teampage_id)  	{ @@ -144,6 +148,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	*  	* @param	int		$teampage_id	Teampage_id of the selected item  	* @return	array			Teampage row of the item +	* @throws \phpbb\groupposition\exception  	*/  	public function get_teampage_values($teampage_id)  	{ @@ -165,8 +170,6 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	/** -	* Get number of items displayed -	*  	* {@inheritDoc}  	*/  	public function get_group_count() @@ -182,8 +185,6 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	}  	/** -	* Adds a group by group_id -	*  	* {@inheritDoc}  	*/  	public function add_group($group_id) @@ -288,7 +289,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	/**  	* Deletes a group from the list and closes the gap in the position list.  	* -	* {@inheritDoc} +	* @param	int		$group_id		group_id of the group to be deleted +	* @param	bool	$skip_group		Skip setting the value for this group, to save the query, when you need to update it anyway. +	* @return	bool		True if the group was deleted successfully  	*/  	public function delete_group($group_id, $skip_group = false)  	{ @@ -347,8 +350,6 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	}  	/** -	* Moves a group up by group_id -	*  	* {@inheritDoc}  	*/  	public function move_up($group_id) @@ -359,7 +360,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	/**  	* Moves an item up by teampage_id  	* -	* @param	int		$group_id	group_id of the group to be moved +	* @param	int		$teampage_id	teampage_id of the item to be move  	* @return	bool		True if the group was moved successfully  	*/  	public function move_up_teampage($teampage_id) @@ -368,8 +369,6 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	}  	/** -	* Moves a group down by group_id -	*  	* {@inheritDoc}  	*/  	public function move_down($group_id) @@ -378,9 +377,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	}  	/** -	* Movesan item down by teampage_id +	* Moves an item down by teampage_id  	* -	* @param	int		$group_id	group_id of the group to be moved +	* @param	int		$teampage_id	teampage_id of the item to be moved  	* @return	bool		True if the group was moved successfully  	*/  	public function move_down_teampage($teampage_id) @@ -389,8 +388,6 @@ class teampage implements \phpbb\groupposition\groupposition_interface  	}  	/** -	* Moves a group up/down -	*  	* {@inheritDoc}  	*/  	public function move($group_id, $delta) diff --git a/phpBB/phpbb/lock/db.php b/phpBB/phpbb/lock/db.php index e3c7e97792..85ba9a7aa3 100644 --- a/phpBB/phpbb/lock/db.php +++ b/phpBB/phpbb/lock/db.php @@ -54,8 +54,8 @@ class db  	*  	* You have to call acquire() to actually create the lock.  	* -	* @param	string	$config_name	A config variable to be used for locking -	* @param	array	$config			The phpBB configuration +	* @param	string								$config_name	A config variable to be used for locking +	* @param	\phpbb\config\config				$config			The phpBB configuration  	* @param	\phpbb\db\driver\driver_interface	$db				A database connection  	*/  	public function __construct($config_name, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db) diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 453cb740bb..bf0bfe0ae1 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -70,7 +70,7 @@ class log implements \phpbb\log\log_interface  	/**  	* Event dispatcher object -	* @var phpbb_dispatcher +	* @var \phpbb\event\dispatcher  	*/  	protected $dispatcher; @@ -103,7 +103,6 @@ class log implements \phpbb\log\log_interface  	* @param	string		$relative_admin_path	Relative admin root path  	* @param	string		$php_ext			PHP Extension  	* @param	string		$log_table		Name of the table we use to store our logs -	* @return	null  	*/  	public function __construct($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, $relative_admin_path, $php_ext, $log_table)  	{ @@ -159,8 +158,6 @@ class log implements \phpbb\log\log_interface  	}  	/** -	* This function returns the state of the log system. -	*  	* {@inheritDoc}  	*/  	public function is_enabled($type = '') @@ -173,12 +170,6 @@ class log implements \phpbb\log\log_interface  	}  	/** -	* Disable log -	* -	* This function allows disabling the log system or parts of it, for this -	* page call. When add_log is called and the type is disabled, -	* the log will not be added to the database. -	*  	* {@inheritDoc}  	*/  	public function disable($type = '') @@ -201,10 +192,6 @@ class log implements \phpbb\log\log_interface  	}  	/** -	* Enable log -	* -	* This function allows re-enabling the log system. -	*  	* {@inheritDoc}  	*/  	public function enable($type = '') @@ -227,8 +214,6 @@ class log implements \phpbb\log\log_interface  	}  	/** -	* Adds a log to the database -	*  	* {@inheritDoc}  	*/  	public function add($mode, $user_id, $log_ip, $log_operation, $log_time = false, $additional_data = array()) @@ -391,28 +376,29 @@ class log implements \phpbb\log\log_interface  		}  		$sql_where = 'WHERE log_type = ' . $log_type; + +		if (isset($conditions['keywords'])) +		{ +			$sql_where .= $this->generate_sql_keyword($conditions['keywords'], ''); + +			unset($conditions['keywords']); +		} +  		foreach ($conditions as $field => $field_value)  		{  			$sql_where .= ' AND '; -			if ($field == 'keywords') +			if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1]))  			{ -				$sql_where .= $this->generate_sql_keyword($field_value, '', ''); +				$sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; +			} +			else if (is_array($field_value) && isset($field_value['IN']) && is_array($field_value['IN'])) +			{ +				$sql_where .= $this->db->sql_in_set($field, $field_value['IN']);  			}  			else  			{ -				if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1])) -				{ -					$sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; -				} -				else if (is_array($field_value) && isset($field_value['IN']) && is_array($field_value['IN'])) -				{ -					$sql_where .= $this->db->sql_in_set($field, $field_value['IN']); -				} -				else -				{ -					$sql_where .= $field . ' = ' . $field_value; -				} +				$sql_where .= $field . ' = ' . $field_value;  			}  		} @@ -424,8 +410,6 @@ class log implements \phpbb\log\log_interface  	}  	/** -	* Grab the logs from the database -	*  	* {@inheritDoc}  	*/  	public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = '') @@ -781,7 +765,7 @@ class log implements \phpbb\log\log_interface  				}  			} -			$sql_keywords = $statement_operator . ' ('; +			$sql_keywords = ' ' . $statement_operator . ' (';  			if (!empty($operations))  			{  				$sql_keywords .= $this->db->sql_in_set($table_alias . 'log_operation', $operations) . ' OR '; @@ -862,8 +846,6 @@ class log implements \phpbb\log\log_interface  	}  	/** -	* Get total log count -	*  	* {@inheritDoc}  	*/  	public function get_log_count() @@ -872,8 +854,6 @@ class log implements \phpbb\log\log_interface  	}  	/** -	* Get offset of the last valid log page -	*  	* {@inheritDoc}  	*/  	public function get_valid_offset() diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php new file mode 100644 index 0000000000..93db59880c --- /dev/null +++ b/phpBB/phpbb/message/admin_form.php @@ -0,0 +1,191 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\message; + +/** +* Class admin_form +* Displays a message to the user and allows him to send an email +*/ +class admin_form extends form +{ +	/** @var \phpbb\config\db_text */ +	protected $config_text; + +	/** @var string */ +	protected $subject; +	/** @var string */ +	protected $sender_name; +	/** @var string */ +	protected $sender_address; + +	/** +	* Construct +	* +	* @param \phpbb\auth\auth $auth +	* @param \phpbb\config\config $config +	* @param \phpbb\config\db_text $config_text +	* @param \phpbb\db\driver\driver_interface $db +	* @param \phpbb\user $user +	* @param string $phpbb_root_path +	* @param string $phpEx +	*/ +	public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx) +	{ +		parent::__construct($auth, $config, $db, $user, $phpbb_root_path, $phpEx); +		$this->config_text = $config_text; +	} + +	/** +	* {inheritDoc} +	*/ +	public function check_allow() +	{ +		$error = parent::check_allow(); +		if ($error) +		{ +			return $error; +		} + +		if (!$this->config['contact_admin_form_enable']) +		{ +			return 'NO_CONTACT_PAGE'; +		} + +		return false; +	} + +	/** +	* {inheritDoc} +	*/ +	public function bind(\phpbb\request\request_interface $request) +	{ +		parent::bind($request); + +		$this->subject = $request->variable('subject', '', true); +		$this->sender_address = $request->variable('email', ''); +		$this->sender_name = $request->variable('name', '', true); +	} + +	/** +	* {inheritDoc} +	*/ +	public function submit(\messenger $messenger) +	{ +		if (!$this->subject) +		{ +			$this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL']; +		} +		if (!$this->body) +		{ +			$this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL']; +		} + +		if ($this->user->data['is_registered']) +		{ +			$this->message->set_sender_from_user($this->user); +			$this->sender_name = $this->user->data['username']; +			$this->sender_address = $this->user->data['user_email']; +		} +		else +		{ +			if (!$this->sender_name) +			{ +				$this->errors[] = $this->user->lang['EMPTY_SENDER_NAME']; +			} + +			if (!function_exists('validate_data')) +			{ +				require($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx); +			} + +			$validate_array = validate_data( +				array( +					'email' => $this->sender_address, +				), +				array( +					'email' => array( +						array('string', false, 6, 60), +						array('email'), +					), +				) +			); + +			foreach ($validate_array as $error) +			{ +				$this->errors[] = $this->user->lang[$error]; +			} + +			$this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name); +			$this->message->set_sender_notify_type(NOTIFY_EMAIL); +		} + +		$this->message->set_template('contact_admin'); +		$this->message->set_subject($this->subject); +		$this->message->set_body($this->body); +		$this->message->add_recipient( +			$this->user->lang['ADMINISTRATOR'], +			$this->config['board_contact'], +			$this->config['default_lang'], +			NOTIFY_EMAIL +		); + +		$this->message->set_template_vars(array( +			'FROM_EMAIL_ADDRESS'	=> $this->sender_address, +			'FROM_IP_ADDRESS'		=> $this->user->ip, +			'S_IS_REGISTERED'		=> $this->user->data['is_registered'], + +			'U_FROM_PROFILE'		=> generate_board_url() . '/memberlist.' . $this->phpEx . '?mode=viewprofile&u=' . $this->user->data['user_id'], +		)); + +		parent::submit($messenger); +	} + +	/** +	* {inheritDoc} +	*/ +	public function render(\phpbb\template\template $template) +	{ +		$l_admin_info = $this->config_text->get('contact_admin_info'); +		if ($l_admin_info) +		{ +			$contact_admin_data			= $this->config_text->get_array(array( +				'contact_admin_info', +				'contact_admin_info_uid', +				'contact_admin_info_bitfield', +				'contact_admin_info_flags', +			)); + +			$l_admin_info = generate_text_for_display( +				$contact_admin_data['contact_admin_info'], +				$contact_admin_data['contact_admin_info_uid'], +				$contact_admin_data['contact_admin_info_bitfield'], +				$contact_admin_data['contact_admin_info_flags'] +			); +		} + +		$template->assign_vars(array( +			'S_CONTACT_ADMIN'	=> true, +			'S_CONTACT_FORM'	=> $this->config['contact_admin_form_enable'], +			'S_IS_REGISTERED'	=> $this->user->data['is_registered'], + +			'CONTACT_INFO'		=> $l_admin_info, +			'MESSAGE'			=> $this->body, +			'SUBJECT'			=> $this->subject, +			'NAME'				=> $this->sender_name, +			'EMAIL'				=> $this->sender_address, +		)); + +		parent::render($template); +	} +} diff --git a/phpBB/phpbb/message/form.php b/phpBB/phpbb/message/form.php new file mode 100644 index 0000000000..076b41dc07 --- /dev/null +++ b/phpBB/phpbb/message/form.php @@ -0,0 +1,175 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\message; + +/** +* Abstract class form +*/ +abstract class form +{ +	/** @var \phpbb\auth\auth */ +	protected $auth; +	/** @var \phpbb\config\config */ +	protected $config; +	/** @var \phpbb\db\driver\driver_interface */ +	protected $db; +	/** @var \phpbb\message\message */ +	protected $message; +	/** @var \phpbb\user */ +	protected $user; + +	/** @var string */ +	protected $phpbb_root_path; +	/** @var string */ +	protected $phpEx; + +	/** @var array */ +	protected $errors = array(); +	/** @var bool */ +	protected $cc_sender; +	/** @var string */ +	protected $body; + +	/** +	* Construct +	* +	* @param \phpbb\auth\auth $auth +	* @param \phpbb\config\config $config +	* @param \phpbb\db\driver\driver_interface $db +	* @param \phpbb\user $user +	* @param string $phpbb_root_path +	* @param string $phpEx +	*/ +	public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx) +	{ +		$this->phpbb_root_path = $phpbb_root_path; +		$this->phpEx = $phpEx; +		$this->user = $user; +		$this->auth = $auth; +		$this->config = $config; +		$this->db = $db; + +		$this->message = new message($config['server_name']); +		$this->message->set_sender_from_user($this->user); +	} + +	/** +	* Returns the title for the email form page +	* +	* @return string +	*/ +	public function get_page_title() +	{ +		return $this->user->lang['SEND_EMAIL']; +	} + +	/** +	* Returns the file name of the form template +	* +	* @return string +	*/ +	public function get_template_file() +	{ +		return 'memberlist_email.html'; +	} + +	/** +	* Checks whether the user is allowed to use the form +	* +	* @return false|string	Error string if not allowed, false otherwise +	*/ +	public function check_allow() +	{ +		if (!$this->config['email_enable']) +		{ +			return 'EMAIL_DISABLED'; +		} + +		if (time() - $this->user->data['user_emailtime'] < $this->config['flood_interval']) +		{ +			return 'FLOOD_EMAIL_LIMIT'; +		} + +		return false; +	} + +	/** +	* Get the return link after the message has been sent +	* +	* @return string +	*/ +	public function get_return_message() +	{ +		return sprintf($this->user->lang['RETURN_INDEX'], '<a href="' . append_sid($this->phpbb_root_path . 'index.' . $this->phpEx) . '">', '</a>'); +	} + +	/** +	* Bind the values of the request to the form +	* +	* @param \phpbb\request\request_interface $request +	* @return null +	*/ +	public function bind(\phpbb\request\request_interface $request) +	{ +		$this->cc_sender = $request->is_set_post('cc_sender'); +		$this->body = $request->variable('message', '', true); +	} + +	/** +	* Submit form, generate the email and send it +	* +	* @param \messenger $messenger +	* @return null +	*/ +	public function submit(\messenger $messenger) +	{ +		if (!check_form_key('memberlist_email')) +		{ +			$this->errors[] = 'FORM_INVALID'; +		} + +		if (!sizeof($this->errors)) +		{ +			$sql = 'UPDATE ' . USERS_TABLE . ' +				SET user_emailtime = ' . time() . ' +				WHERE user_id = ' . $this->user->data['user_id']; +			$this->db->sql_query($sql); + +			if ($this->cc_sender) +			{ +				$this->message->cc_sender(); +			} + +			$this->message->send($messenger, phpbb_get_board_contact($this->config, $this->phpEx)); + +			meta_refresh(3, append_sid($this->phpbb_root_path . 'index.' . $this->phpEx)); +			trigger_error($this->user->lang['EMAIL_SENT'] . '<br /><br />' . $this->get_return_message()); +		} +	} + +	/** +	* Render the template of the form +	* +	* @param \phpbb\template\template $template +	* @return null +	*/ +	public function render(\phpbb\template\template $template) +	{ +		add_form_key('memberlist_email'); + +		$template->assign_vars(array( +			'ERROR_MESSAGE'		=> (sizeof($this->errors)) ? implode('<br />', $this->errors) : '', +		)); +	} +} diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php new file mode 100644 index 0000000000..5fd24b542e --- /dev/null +++ b/phpBB/phpbb/message/message.php @@ -0,0 +1,282 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\message; + +/** +* Class message +* Holds all information for an email and sends it in the end +*/ +class message +{ +	/** @var string */ +	protected $server_name; + +	/** @var string */ +	protected $subject = ''; +	/** @var string */ +	protected $body = ''; +	/** @var string */ +	protected $template = ''; +	/** @var array */ +	protected $template_vars = array(); + +	/** @var string */ +	protected $sender_ip = ''; +	/** @var string */ +	protected $sender_name = ''; +	/** @var string */ +	protected $sender_address = ''; +	/** @var string */ +	protected $sender_lang = ''; +	/** @var string */ +	protected $sender_id = ''; +	/** @var string */ +	protected $sender_username = ''; +	/** @var string */ +	protected $sender_jabber = ''; +	/** @var int */ +	protected $sender_notify_type = NOTIFY_EMAIL; + +	/** @var array */ +	protected $recipients; + +	/** +	* Construct +	* +	* @param string $server_name	Used for AntiAbuse header +	*/ +	public function __construct($server_name) +	{ +		$this->server_name = $server_name; +	} + +	/** +	* Set the subject of the email +	* +	* @param string $subject +	* @return null +	*/ +	public function set_subject($subject) +	{ +		$this->subject = $subject; +	} + +	/** +	* Set the body of the email text +	* +	* @param string $body +	* @return null +	*/ +	public function set_body($body) +	{ +		$this->body = $body; +	} + +	/** +	* Set the name of the email template to use +	* +	* @param string $template +	* @return null +	*/ +	public function set_template($template) +	{ +		$this->template = $template; +	} + +	/** +	* Set the array with the "template" data for the email +	* +	* @param array $template_vars +	* @return null +	*/ +	public function set_template_vars($template_vars) +	{ +		$this->template_vars = $template_vars; +	} + +	/** +	* Add a recipient from \phpbb\user +	* +	* @param array $user +	* @return null +	*/ +	public function add_recipient_from_user_row(array $user) +	{ +		$this->add_recipient( +			$user['username'], +			$user['user_email'], +			$user['user_lang'], +			$user['user_notify_type'], +			$user['username'], +			$user['user_jabber'] +		); +	} + +	/** +	* Add a recipient +	* +	* @param string $recipient_name		Displayed sender name +	* @param string $recipient_address	Email address +	* @param string $recipient_lang +	* @param int $recipient_notify_type	Used notification methods (Jabber, Email, ...) +	* @param string $recipient_username	User Name (used for AntiAbuse header) +	* @param string $recipient_jabber +	* @return null +	*/ +	public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '') +	{ +		$this->recipients[] = array( +			'name'			=> $recipient_name, +			'address'		=> $recipient_address, +			'lang'			=> $recipient_lang, +			'username'		=> $recipient_username, +			'jabber'		=> $recipient_jabber, +			'notify_type'	=> $recipient_notify_type, +			'to_name'		=> $recipient_name, +		); +	} + +	/** +	* Set the senders data from \phpbb\user object +	* +	* @param \phpbb\user $user +	* @return null +	*/ +	public function set_sender_from_user($user) +	{ +		$this->set_sender( +			$user->ip, +			$user->data['username'], +			$user->data['user_email'], +			$user->lang_name, +			$user->data['user_id'], +			$user->data['username'], +			$user->data['user_jabber'] +		); + +		$this->set_sender_notify_type($user->data['user_notify_type']); +	} + +	/** +	* Set the senders data +	* +	* @param string $sender_ip +	* @param string $sender_name		Displayed sender name +	* @param string $sender_address		Email address +	* @param string $sender_lang +	* @param int $sender_id				User ID +	* @param string $sender_username	User Name (used for AntiAbuse header) +	* @param string $sender_jabber +	* @return null +	*/ +	public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '', $sender_jabber = '') +	{ +		$this->sender_ip = $sender_ip; +		$this->sender_name = $sender_name; +		$this->sender_address = $sender_address; +		$this->sender_lang = $sender_lang; +		$this->sender_id = $sender_id; +		$this->sender_username = $sender_username; +		$this->sender_jabber = $sender_jabber; +	} + +	/** +	* Which notification type should be used? Jabber, Email, ...? +	* +	* @param int $sender_notify_type +	* @return null +	*/ +	public function set_sender_notify_type($sender_notify_type) +	{ +		$this->sender_notify_type = $sender_notify_type; +	} + +	/** +	* Ok, now the same email if CC specified, but without exposing the user's email address +	* +	* @return null +	*/ +	public function cc_sender() +	{ +		if (!sizeof($this->recipients)) +		{ +			trigger_error('No email recipients specified'); +		} +		if (!$this->sender_address) +		{ +			trigger_error('No email sender specified'); +		} + +		$this->recipients[] = array( +			'lang'			=> $this->sender_lang, +			'address'		=> $this->sender_address, +			'name'			=> $this->sender_name, +			'username'		=> $this->sender_username, +			'jabber'		=> $this->sender_jabber, +			'notify_type'	=> $this->sender_notify_type, +			'to_name'		=> $this->recipients[0]['to_name'], +		); +	} + +	/** +	* Send the email +	* +	* @param \messenger $messenger +	* @param string $contact +	* @return null +	*/ +	public function send(\messenger $messenger, $contact) +	{ +		if (!sizeof($this->recipients)) +		{ +			return; +		} + +		foreach ($this->recipients as $recipient) +		{ +			$messenger->template($this->template, $recipient['lang']); +			$messenger->replyto($this->sender_address); +			$messenger->to($recipient['address'], $recipient['name']); +			$messenger->im($recipient['jabber'], $recipient['username']); + +			$messenger->headers('X-AntiAbuse: Board servername - ' . $this->server_name); +			$messenger->headers('X-AntiAbuse: User IP - ' . $this->sender_ip); + +			if ($this->sender_id) +			{ +				$messenger->headers('X-AntiAbuse: User_id - ' . $this->sender_id); +			} +			if ($this->sender_username) +			{ +				$messenger->headers('X-AntiAbuse: Username - ' . $this->sender_username); +			} + +			$messenger->subject(htmlspecialchars_decode($this->subject)); + +			$messenger->assign_vars(array( +				'BOARD_CONTACT'	=> $contact, +				'TO_USERNAME'	=> htmlspecialchars_decode($recipient['to_name']), +				'FROM_USERNAME'	=> htmlspecialchars_decode($this->sender_name), +				'MESSAGE'		=> htmlspecialchars_decode($this->body)) +			); + +			if (sizeof($this->template_vars)) +			{ +				$messenger->assign_vars($this->template_vars); +			} + +			$messenger->send($recipient['notify_type']); +		} +	} +} diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php new file mode 100644 index 0000000000..1e0f2a1945 --- /dev/null +++ b/phpBB/phpbb/message/topic_form.php @@ -0,0 +1,158 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\message; + +/** +* Class topic_form +* Form used to send topics as notification emails +*/ +class topic_form extends form +{ +	/** @var int */ +	protected $topic_id; +	/** @var array */ +	protected $topic_row; +	/** @var string */ +	protected $recipient_address; +	/** @var string */ +	protected $recipient_name; +	/** @var string */ +	protected $recipient_lang; + +	/** +	* Get the data of the topic +	* +	* @param int $topic_id +	* @return	false|array		false if the topic does not exist, array otherwise +	*/ +	protected function get_topic_row($topic_id) +	{ +		$sql = 'SELECT forum_id, topic_title +			FROM ' . TOPICS_TABLE . ' +			WHERE topic_id = ' . (int) $topic_id; +		$result = $this->db->sql_query($sql); +		$row = $this->db->sql_fetchrow($result); +		$this->db->sql_freeresult($result); + +		return $row; +	} + +	/** +	* {inheritDoc} +	*/ +	public function check_allow() +	{ +		$error = parent::check_allow(); +		if ($error) +		{ +			return $error; +		} + +		if (!$this->auth->acl_get('u_sendemail')) +		{ +			return 'NO_EMAIL'; +		} + +		if (!$this->topic_row) +		{ +			return 'NO_TOPIC'; +		} + +		if (!$this->auth->acl_get('f_read', $this->topic_row['forum_id'])) +		{ +			return 'SORRY_AUTH_READ'; +		} + +		if (!$this->auth->acl_get('f_email', $this->topic_row['forum_id'])) +		{ +			return 'NO_EMAIL'; +		} + +		return false; +	} + +	/** +	* {inheritDoc} +	*/ +	public function bind(\phpbb\request\request_interface $request) +	{ +		parent::bind($request); + +		$this->topic_id = $request->variable('t', 0); +		$this->recipient_address = $request->variable('email', ''); +		$this->recipient_name = $request->variable('name', '', true); +		$this->recipient_lang = $request->variable('lang', $this->config['default_lang']); + +		$this->topic_row = $this->get_topic_row($this->topic_id); +	} + +	/** +	* {inheritDoc} +	*/ +	public function submit(\messenger $messenger) +	{ +		if (!$this->recipient_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->recipient_address)) +		{ +			$this->errors[] = $this->user->lang['EMPTY_ADDRESS_EMAIL']; +		} + +		if (!$this->recipient_name) +		{ +			$this->errors[] = $this->user->lang['EMPTY_NAME_EMAIL']; +		} + +		$this->message->set_template('email_notify'); +		$this->message->set_template_vars(array( +			'TOPIC_NAME'	=> htmlspecialchars_decode($this->topic_row['topic_title']), +			'U_TOPIC'		=> generate_board_url() . '/viewtopic.' . $this->phpEx . '?f=' . $this->topic_row['forum_id'] . '&t=' . $this->topic_id, +		)); + +		$this->message->add_recipient( +			$this->recipient_name, +			$this->recipient_address, +			$this->recipient_lang, +			NOTIFY_EMAIL +		); +		$this->message->set_sender_notify_type(NOTIFY_EMAIL); + +		parent::submit($messenger); +	} + +	/** +	* {inheritDoc} +	*/ +	public function get_return_message() +	{ +		return sprintf($this->user->lang['RETURN_TOPIC'],  '<a href="' . append_sid($this->phpbb_root_path . 'viewtopic.' . $this->phpEx, 'f=' . $this->topic_row['forum_id'] . '&t=' . $this->topic_id) . '">', '</a>'); +	} + +	/** +	* {inheritDoc} +	*/ +	public function render(\phpbb\template\template $template) +	{ +		parent::render($template); + +		$this->user->add_lang('viewtopic'); +		$template->assign_vars(array( +			'EMAIL'				=> $this->recipient_address, +			'NAME'				=> $this->recipient_name, +			'S_LANG_OPTIONS'	=> language_select($this->recipient_lang), +			'MESSAGE'			=> $this->body, + +			'L_EMAIL_BODY_EXPLAIN'	=> $this->user->lang['EMAIL_TOPIC_EXPLAIN'], +			'S_POST_ACTION'			=> append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&t=' . $this->topic_id)) +		); +	} +} diff --git a/phpBB/phpbb/message/user_form.php b/phpBB/phpbb/message/user_form.php new file mode 100644 index 0000000000..007e575407 --- /dev/null +++ b/phpBB/phpbb/message/user_form.php @@ -0,0 +1,136 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\message; + +/** +* Class user_form +* Allows users to send emails to other users +*/ +class user_form extends form +{ +	/** @var int */ +	protected $recipient_id; +	/** @var array */ +	protected $recipient_row; +	/** @var string */ +	protected $subject; + +	/** +	* Get the data of the recipient +	* +	* @param int $user_id +	* @return	false|array		false if the user does not exist, array otherwise +	*/ +	protected function get_user_row($user_id) +	{ +		$sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type +			FROM ' . USERS_TABLE . ' +			WHERE user_id = ' . (int) $user_id . ' +				AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; +		$result = $this->db->sql_query($sql); +		$row = $this->db->sql_fetchrow($result); +		$this->db->sql_freeresult($result); + +		return $row; +	} + +	/** +	* {inheritDoc} +	*/ +	public function check_allow() +	{ +		$error = parent::check_allow(); +		if ($error) +		{ +			return $error; +		} + +		if (!$this->auth->acl_get('u_sendemail')) +		{ +			return 'NO_EMAIL'; +		} + +		if ($this->recipient_id == ANONYMOUS || !$this->config['board_email_form']) +		{ +			return 'NO_EMAIL'; +		} + +		if (!$this->recipient_row) +		{ +			return 'NO_USER'; +		} + +		// Can we send email to this user? +		if (!$this->recipient_row['user_allow_viewemail'] && !$this->auth->acl_get('a_user')) +		{ +			return 'NO_EMAIL'; +		} + +		return false; +	} + +	/** +	* {inheritDoc} +	*/ +	public function bind(\phpbb\request\request_interface $request) +	{ +		parent::bind($request); + +		$this->recipient_id = $request->variable('u', 0); +		$this->subject = $request->variable('subject', '', true); + +		$this->recipient_row = $this->get_user_row($this->recipient_id); +	} + +	/** +	* {inheritDoc} +	*/ +	public function submit(\messenger $messenger) +	{ +		if (!$this->subject) +		{ +			$this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL']; +		} + +		if (!$this->body) +		{ +			$this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL']; +		} + +		$this->message->set_template('profile_send_email'); +		$this->message->set_subject($this->subject); +		$this->message->set_body($this->body); +		$this->message->add_recipient_from_user_row($this->recipient_row); + +		parent::submit($messenger); +	} + +	/** +	* {inheritDoc} +	*/ +	public function render(\phpbb\template\template $template) +	{ +		parent::render($template); + +		$template->assign_vars(array( +			'S_SEND_USER'			=> true, +			'S_POST_ACTION'			=> append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&u=' . $this->recipient_id), + +			'L_SEND_EMAIL_USER'		=> $this->user->lang('SEND_EMAIL_USER', $this->recipient_row['username']), +			'USERNAME_FULL'			=> get_username_string('full', $this->recipient_row['user_id'], $this->recipient_row['username'], $this->recipient_row['user_colour']), +			'SUBJECT'				=> $this->subject, +			'MESSAGE'				=> $this->body, +		)); +	} +} diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index 7c0177b57b..9c83e8dd73 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -16,7 +16,7 @@ namespace phpbb\mimetype;  class content_guesser extends guesser_base  {  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function is_supported()  	{ @@ -24,7 +24,7 @@ class content_guesser extends guesser_base  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function guess($file, $file_name = '')  	{ diff --git a/phpBB/phpbb/mimetype/extension_guesser.php b/phpBB/phpbb/mimetype/extension_guesser.php index 74bfeb97b6..9e36c07f91 100644 --- a/phpBB/phpbb/mimetype/extension_guesser.php +++ b/phpBB/phpbb/mimetype/extension_guesser.php @@ -470,7 +470,7 @@ class extension_guesser extends guesser_base  	);  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function is_supported()  	{ @@ -478,7 +478,7 @@ class extension_guesser extends guesser_base  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function guess($file, $file_name = '')  	{ diff --git a/phpBB/phpbb/mimetype/guesser.php b/phpBB/phpbb/mimetype/guesser.php index 6eb924b584..87b164b561 100644 --- a/phpBB/phpbb/mimetype/guesser.php +++ b/phpBB/phpbb/mimetype/guesser.php @@ -21,7 +21,7 @@ class guesser  	const PRIORITY_DEFAULT = 0;  	/** -	* @var mimetype guessers +	* @var array guessers  	*/  	protected $guessers; diff --git a/phpBB/phpbb/mimetype/guesser_base.php b/phpBB/phpbb/mimetype/guesser_base.php index f26f207aff..225dfd57dc 100644 --- a/phpBB/phpbb/mimetype/guesser_base.php +++ b/phpBB/phpbb/mimetype/guesser_base.php @@ -21,7 +21,7 @@ abstract class guesser_base implements guesser_interface  	protected $priority;  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_priority()  	{ @@ -29,7 +29,7 @@ abstract class guesser_base implements guesser_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function set_priority($priority)  	{ diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index c3539e76df..74ef980445 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -13,6 +13,8 @@  namespace phpbb\notification; +use Symfony\Component\DependencyInjection\ContainerInterface; +  /**  * Notifications service class  */ @@ -24,7 +26,7 @@ class manager  	/** @var array */  	protected $notification_methods; -	/** @var ContainerBuilder */ +	/** @var ContainerInterface */  	protected $phpbb_container;  	/** @var \phpbb\user_loader */ @@ -62,7 +64,7 @@ class manager  	*  	* @param array $notification_types  	* @param array $notification_methods -	* @param ContainerBuilder $phpbb_container +	* @param ContainerInterface $phpbb_container  	* @param \phpbb\user_loader $user_loader  	* @param \phpbb\config\config $config  	* @param \phpbb\db\driver\driver_interface $db @@ -74,7 +76,7 @@ class manager  	* @param string $user_notifications_table  	* @return \phpbb\notification\manager  	*/ -	public function __construct($notification_types, $notification_methods, $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) +	public function __construct($notification_types, $notification_methods, ContainerInterface $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)  	{  		$this->notification_types = $notification_types;  		$this->notification_methods = $notification_methods; @@ -574,6 +576,34 @@ class manager  		return $subscription_methods;  	} + +	/** +	* Get user's notification data +	* +	* @param int $user_id The user_id of the user to get the notifications for +	* +	* @return array User's notification +	*/ +	protected function get_user_notifications($user_id) +	{ +		$sql = 'SELECT method, notify, item_type +				FROM ' . $this->user_notifications_table . ' +				WHERE user_id = ' . (int) $user_id . ' +					AND item_id = 0'; + +		$result = $this->db->sql_query($sql); +		$user_notifications = array(); + +		while ($row = $this->db->sql_fetchrow($result)) +		{ +			$user_notifications[$row['item_type']][] = $row; +		} + +		$this->db->sql_freeresult($result); + +		return $user_notifications; +	} +  	/**  	* Get global subscriptions (item_id = 0)  	* @@ -587,28 +617,23 @@ class manager  		$subscriptions = array(); -		foreach ($this->get_subscription_types() as $group_name => $types) +		$user_notifications = $this->get_user_notifications($user_id); + +		foreach ($this->get_subscription_types() as $types)  		{  			foreach ($types as $id => $type)  			{ -				$sql = 'SELECT method, notify -					FROM ' . $this->user_notifications_table . ' -					WHERE user_id = ' . (int) $user_id . " -						AND item_type = '" . $this->db->sql_escape($id) . "' -						AND item_id = 0"; -				$result = $this->db->sql_query($sql); - -				$row = $this->db->sql_fetchrow($result); -				if (!$row) + +				if (empty($user_notifications[$id]))  				{  					// No rows at all, default to ''  					$subscriptions[$id] = array('');  				}  				else  				{ -					do +					foreach ($user_notifications[$id] as $user_notification)  					{ -						if (!$row['notify']) +						if (!$user_notification['notify'])  						{  							continue;  						} @@ -618,12 +643,9 @@ class manager  							$subscriptions[$id] = array();  						} -						$subscriptions[$id][] = $row['method']; +						$subscriptions[$id][] = $user_notification['method'];  					} -					while ($row = $this->db->sql_fetchrow($result));  				} - -				$this->db->sql_freeresult($result);  			}  		} @@ -866,6 +888,7 @@ class manager  	*  	* @param string $notification_type_name The name  	* @return int the notification_type_id +	* @throws \phpbb\notification\exception  	*/  	public function get_notification_type_id($notification_type_name)  	{ diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index c1d4d0e257..910f51b3a6 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -308,16 +308,15 @@ abstract class base implements \phpbb\notification\type\type_interface  		return array(  			'NOTIFICATION_ID'	=> $this->notification_id, - +			'STYLING'			=> $this->get_style_class(),  			'AVATAR'			=> $this->get_avatar(), -  			'FORMATTED_TITLE'	=> $this->get_title(), - +			'REFERENCE'			=> $this->get_reference(), +			'FORUM'				=> $this->get_forum(), +			'REASON'			=> $this->get_reason(),  			'URL'				=> $this->get_url(),  			'TIME'	   			=> $this->user->format_date($this->notification_time), -  			'UNREAD'			=> !$this->notification_read, -  			'U_MARK_READ'		=> (!$this->notification_read) ? $u_mark_read : '',  		);  	} @@ -337,6 +336,16 @@ abstract class base implements \phpbb\notification\type\type_interface  	}  	/** +	* Get the CSS style class of the notification (fall back) +	* +	* @return string +	*/ +	public function get_style_class() +	{ +		return ''; +	} + +	/**  	* Get the user's avatar (fall back)  	*  	* @return string @@ -347,6 +356,36 @@ abstract class base implements \phpbb\notification\type\type_interface  	}  	/** +	* Get the reference of the notifcation (fall back) +	* +	* @return string +	*/ +	public function get_reference() +	{ +		return ''; +	} + +	/** +	* Get the forum of the notification reference (fall back) +	* +	* @return string +	*/ +	public function get_forum() +	{ +		return ''; +	} + +	/** +	* Get the reason for the notifcation (fall back) +	* +	* @return string +	*/ +	public function get_reason() +	{ +		return ''; +	} + +	/**  	* Get the special items to load (fall back)  	*  	* @return array diff --git a/phpBB/phpbb/notification/type/disapprove_post.php b/phpBB/phpbb/notification/type/disapprove_post.php index b5f94f404f..7b18ed70ea 100644 --- a/phpBB/phpbb/notification/type/disapprove_post.php +++ b/phpBB/phpbb/notification/type/disapprove_post.php @@ -31,6 +31,16 @@ class disapprove_post extends \phpbb\notification\type\approve_post  	}  	/** +	* Get the CSS style class of the notification +	* +	* @return string +	*/ +	public function get_style_class() +	{ +		return 'notification-disapproved'; +	} + +	/**  	* Language key used to output the text  	*  	* @var string @@ -63,9 +73,31 @@ class disapprove_post extends \phpbb\notification\type\approve_post  	*/  	public function get_title()  	{ +		return $this->user->lang($this->language_key); +	} + +	/** +	* Get the HTML formatted reference of the notification +	* +	* @return string +	*/ +	public function get_reference() +	{ +		return $this->user->lang( +			'NOTIFICATION_REFERENCE', +			censor_text($this->get_data('topic_title')) +		); +	} + +	/** +	* Get the reason for the disapproval notification +	* +	* @return string +	*/ +	public function get_reason() +	{  		return $this->user->lang( -			$this->language_key, -			censor_text($this->get_data('topic_title')), +			'NOTIFICATION_REASON',  			$this->get_data('disapprove_reason')  		);  	} diff --git a/phpBB/phpbb/notification/type/disapprove_topic.php b/phpBB/phpbb/notification/type/disapprove_topic.php index 8883c53294..3f87741807 100644 --- a/phpBB/phpbb/notification/type/disapprove_topic.php +++ b/phpBB/phpbb/notification/type/disapprove_topic.php @@ -31,6 +31,16 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic  	}  	/** +	* Get the CSS style class of the notification +	* +	* @return string +	*/ +	public function get_style_class() +	{ +		return 'notification-disapproved'; +	} + +	/**  	* Language key used to output the text  	*  	* @var string @@ -63,9 +73,31 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic  	*/  	public function get_title()  	{ +		return $this->user->lang($this->language_key); +	} + +	/** +	* Get the HTML formatted reference of the notification +	* +	* @return string +	*/ +	public function get_reference() +	{ +		return $this->user->lang( +			'NOTIFICATION_REFERENCE', +			censor_text($this->get_data('topic_title')) +		); +	} + +	/** +	* Get the reason for the disapproval notification +	* +	* @return string +	*/ +	public function get_reason() +	{  		return $this->user->lang( -			$this->language_key, -			censor_text($this->get_data('topic_title')), +			'NOTIFICATION_REASON',  			$this->get_data('disapprove_reason')  		);  	} diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php index 955d121cc6..4f54e93e06 100644 --- a/phpBB/phpbb/notification/type/pm.php +++ b/phpBB/phpbb/notification/type/pm.php @@ -111,7 +111,20 @@ class pm extends \phpbb\notification\type\base  	{  		$username = $this->user_loader->get_username($this->get_data('from_user_id'), 'no_profile'); -		return $this->user->lang('NOTIFICATION_PM', $username, $this->get_data('message_subject')); +		return $this->user->lang('NOTIFICATION_PM', $username); +	} + +	/** +	* Get the HTML formatted reference of the notification +	* +	* @return string +	*/ +	public function get_reference() +	{ +		return $this->user->lang( +			'NOTIFICATION_REFERENCE', +			$this->get_data('message_subject') +		);  	}  	/** diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index c8760f904e..ee3a253e0f 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -225,12 +225,24 @@ class post extends \phpbb\notification\type\base  		return $this->user->lang(  			$this->language_key,  			phpbb_generate_string_list($usernames, $this->user), -			censor_text($this->get_data('topic_title')),  			$responders_cnt  		);  	}  	/** +	* Get the HTML formatted reference of the notification +	* +	* @return string +	*/ +	public function get_reference() +	{ +		return $this->user->lang( +			'NOTIFICATION_REFERENCE', +			censor_text($this->get_data('topic_title')) +		); +	} + +	/**  	* Get email template  	*  	* @return string|bool diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php index 03e89dd28e..2eb802eb4b 100644 --- a/phpBB/phpbb/notification/type/report_pm.php +++ b/phpBB/phpbb/notification/type/report_pm.php @@ -31,6 +31,16 @@ class report_pm extends \phpbb\notification\type\pm  	}  	/** +	* Get the CSS style class of the notification +	* +	* @return string +	*/ +	public function get_style_class() +	{ +		return 'notification-reported'; +	} + +	/**  	* Language key used to output the text  	*  	* @var string @@ -159,12 +169,36 @@ class report_pm extends \phpbb\notification\type\pm  		$username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile'); +		return $this->user->lang( +			$this->language_key, +			$username +		); +	} + +	/** +	* Get the HTML formatted reference of the notification +	* +	* @return string +	*/ +	public function get_reference() +	{ +		return $this->user->lang( +			'NOTIFICATION_REFERENCE', +			censor_text($this->get_data('message_subject')) +		); +	} + +	/** +	* Get the reason for the notification +	* +	* @return string +	*/ +	public function get_reason() +	{  		if ($this->get_data('report_text'))  		{  			return $this->user->lang( -				$this->language_key, -				$username, -				censor_text($this->get_data('message_subject')), +				'NOTIFICATION_REASON',  				$this->get_data('report_text')  			);  		} @@ -172,17 +206,13 @@ class report_pm extends \phpbb\notification\type\pm  		if (isset($this->user->lang[$this->get_data('reason_title')]))  		{  			return $this->user->lang( -				$this->language_key, -				$username, -				censor_text($this->get_data('message_subject')), +				'NOTIFICATION_REASON',  				$this->user->lang[$this->get_data('reason_title')]  			);  		}  		return $this->user->lang( -			$this->language_key, -			$username, -			censor_text($this->get_data('message_subject')), +			'NOTIFICATION_REASON',  			$this->get_data('reason_description')  		);  	} diff --git a/phpBB/phpbb/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php index a646996f75..ed40df67f3 100644 --- a/phpBB/phpbb/notification/type/report_pm_closed.php +++ b/phpBB/phpbb/notification/type/report_pm_closed.php @@ -107,7 +107,19 @@ class report_pm_closed extends \phpbb\notification\type\pm  		return $this->user->lang(  			$this->language_key, -			$username, +			$username +		); +	} + +	/** +	* Get the HTML formatted reference of the notification +	* +	* @return string +	*/ +	public function get_reference() +	{ +		return $this->user->lang( +			'NOTIFICATION_REFERENCE',  			censor_text($this->get_data('message_subject'))  		);  	} diff --git a/phpBB/phpbb/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php index d5589a6756..024c8d9d42 100644 --- a/phpBB/phpbb/notification/type/report_post.php +++ b/phpBB/phpbb/notification/type/report_post.php @@ -30,6 +30,16 @@ class report_post extends \phpbb\notification\type\post_in_queue  	}  	/** +	* Get the CSS style class of the notification +	* +	* @return string +	*/ +	public function get_style_class() +	{ +		return 'notification-reported'; +	} + +	/**  	* Language key used to output the text  	*  	* @var string @@ -132,12 +142,36 @@ class report_post extends \phpbb\notification\type\post_in_queue  		$username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile'); +		return $this->user->lang( +			$this->language_key, +			$username +		); +	} + +	/** +	* Get the HTML formatted reference of the notification +	* +	* @return string +	*/ +	public function get_reference() +	{ +		return $this->user->lang( +			'NOTIFICATION_REFERENCE', +			censor_text($this->get_data('post_subject')) +		); +	} + +	/** +	* Get the reason for the notification +	* +	* @return string +	*/ +	public function get_reason() +	{  		if ($this->get_data('report_text'))  		{  			return $this->user->lang( -				$this->language_key, -				$username, -				censor_text($this->get_data('post_subject')), +				'NOTIFICATION_REASON',  				$this->get_data('report_text')  			);  		} @@ -145,17 +179,13 @@ class report_post extends \phpbb\notification\type\post_in_queue  		if (isset($this->user->lang[$this->get_data('reason_title')]))  		{  			return $this->user->lang( -				$this->language_key, -				$username, -				censor_text($this->get_data('post_subject')), +				'NOTIFICATION_REASON',  				$this->user->lang[$this->get_data('reason_title')]  			);  		}  		return $this->user->lang( -			$this->language_key, -			$username, -			censor_text($this->get_data('post_subject')), +			'NOTIFICATION_REASON',  			$this->get_data('reason_description')  		);  	} diff --git a/phpBB/phpbb/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php index e76fa57036..a979af1fb0 100644 --- a/phpBB/phpbb/notification/type/report_post_closed.php +++ b/phpBB/phpbb/notification/type/report_post_closed.php @@ -114,7 +114,19 @@ class report_post_closed extends \phpbb\notification\type\post  		return $this->user->lang(  			$this->language_key, -			$username, +			$username +		); +	} + +	/** +	* Get the HTML formatted reference of the notification +	* +	* @return string +	*/ +	public function get_reference() +	{ +		return $this->user->lang( +			'NOTIFICATION_REFERENCE',  			censor_text($this->get_data('post_subject'))  		);  	} diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php index 144c4e58a0..a512a12f20 100644 --- a/phpBB/phpbb/notification/type/topic.php +++ b/phpBB/phpbb/notification/type/topic.php @@ -151,8 +151,32 @@ class topic extends \phpbb\notification\type\base  		return $this->user->lang(  			$this->language_key, -			$username, -			censor_text($this->get_data('topic_title')), +			$username +		); +	} + +	/** +	* Get the HTML formatted reference of the notification +	* +	* @return string +	*/ +	public function get_reference() +	{ +		return $this->user->lang( +			'NOTIFICATION_REFERENCE', +			censor_text($this->get_data('topic_title')) +		); +	} + +	/** +	* Get the forum of the notification reference +	* +	* @return string +	*/ +	public function get_forum() +	{ +		return $this->user->lang( +			'NOTIFICATION_FORUM',  			$this->get_data('forum_name')  		);  	} diff --git a/phpBB/phpbb/notification/type/type_interface.php b/phpBB/phpbb/notification/type/type_interface.php index c91c7078ad..5c5a110836 100644 --- a/phpBB/phpbb/notification/type/type_interface.php +++ b/phpBB/phpbb/notification/type/type_interface.php @@ -88,6 +88,13 @@ interface type_interface  	public function load_special($data, $notifications);  	/** +	* Get the CSS style class of the notification +	* +	* @return string +	*/ +	public function get_style_class(); + +	/**  	* Get the HTML formatted title of this notification  	*  	* @return string @@ -95,6 +102,20 @@ interface type_interface  	public function get_title();  	/** +	* Get the HTML formatted reference of the notification +	* +	* @return string +	*/ +	public function get_reference(); + +	/** +	* Get the forum of the notification reference +	* +	* @return string +	*/ +	public function get_forum(); + +	/**  	* Get the url to this item  	*  	* @return string URL diff --git a/phpBB/phpbb/pagination.php b/phpBB/phpbb/pagination.php index 927d711f4b..8aba41d651 100644 --- a/phpBB/phpbb/pagination.php +++ b/phpBB/phpbb/pagination.php @@ -46,7 +46,7 @@ class pagination  	*							If you use page numbers inside your controller route, start name should be the string  	*							that should be removed for the first page (example: /page/%d)  	* @param int $per_page the number of items, posts, etc. to display per page, used to determine the number of pages to produce -	* @return URL for the requested page +	* @return string URL for the requested page  	*/  	protected function generate_page_link($base_url, $on_page, $start_name, $per_page)  	{ @@ -126,8 +126,8 @@ class pagination  				// determine this number. Again at most five pages? Then just display them all. More than  				// five and we first (min) determine whether we'd end up listing more pages than exist.  				// We then (max) ensure we're displaying the minimum number of pages. -				$start_page = ($total_pages > 5) ? min(max(1, $on_page - 3), $total_pages - 4) : 1; -				$end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 3), 5) : $total_pages; +				$start_page = ($total_pages > 5) ? min(max(1, $on_page - 2), $total_pages - 4) : 1; +				$end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 2), 5) : $total_pages;  			}  			if ($on_page != 1) diff --git a/phpBB/phpbb/passwords/driver/base.php b/phpBB/phpbb/passwords/driver/base.php index fffc9d1461..fd07a61bf4 100644 --- a/phpBB/phpbb/passwords/driver/base.php +++ b/phpBB/phpbb/passwords/driver/base.php @@ -15,10 +15,10 @@ namespace phpbb\passwords\driver;  abstract class base implements driver_interface  { -	/** @var phpbb\config\config */ +	/** @var \phpbb\config\config */  	protected $config; -	/** @var phpbb\passwords\driver\helper */ +	/** @var \phpbb\passwords\driver\helper */  	protected $helper;  	/** @var driver name */ @@ -37,10 +37,26 @@ abstract class base implements driver_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function is_supported()  	{  		return true;  	} + +	/** +	* {@inheritdoc} +	*/ +	public function is_legacy() +	{ +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_settings_only($hash, $full = false) +	{ +		return false; +	}  } diff --git a/phpBB/phpbb/passwords/driver/bcrypt.php b/phpBB/phpbb/passwords/driver/bcrypt.php index 3edf7255c0..23add37a56 100644 --- a/phpBB/phpbb/passwords/driver/bcrypt.php +++ b/phpBB/phpbb/passwords/driver/bcrypt.php @@ -18,7 +18,7 @@ class bcrypt extends base  	const PREFIX = '$2a$';  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_prefix()  	{ @@ -26,7 +26,7 @@ class bcrypt extends base  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function hash($password, $salt = '')  	{ @@ -58,9 +58,9 @@ class bcrypt extends base  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/ -	public function check($password, $hash) +	public function check($password, $hash, $user_row = array())  	{  		$salt = substr($hash, 0, 29);  		if (strlen($salt) != 29) @@ -86,7 +86,7 @@ class bcrypt extends base  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_settings_only($hash, $full = false)  	{ diff --git a/phpBB/phpbb/passwords/driver/bcrypt_2y.php b/phpBB/phpbb/passwords/driver/bcrypt_2y.php index 8b59037fca..c710e0d04a 100644 --- a/phpBB/phpbb/passwords/driver/bcrypt_2y.php +++ b/phpBB/phpbb/passwords/driver/bcrypt_2y.php @@ -18,7 +18,7 @@ class bcrypt_2y extends bcrypt  	const PREFIX = '$2y$';  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_prefix()  	{ @@ -26,7 +26,7 @@ class bcrypt_2y extends bcrypt  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function is_supported()  	{ diff --git a/phpBB/phpbb/passwords/driver/bcrypt_wcf2.php b/phpBB/phpbb/passwords/driver/bcrypt_wcf2.php new file mode 100644 index 0000000000..2d6f897a7b --- /dev/null +++ b/phpBB/phpbb/passwords/driver/bcrypt_wcf2.php @@ -0,0 +1,84 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\passwords\driver; + +class bcrypt_wcf2 extends base +{ +	const PREFIX = '$wcf2$'; + +	/** @var \phpbb\passwords\driver\bcrypt */ +	protected $bcrypt; + +	/** @var \phpbb\passwords\driver\helper */ +	protected $helper; + +	/** +	* Constructor of passwords driver object +	* +	* @param \phpbb\passwords\driver\bcrypt $bcrypt Salted md5 driver +	* @param \phpbb\passwords\driver\helper $helper Password driver helper +	*/ +	public function __construct(\phpbb\passwords\driver\bcrypt $bcrypt, helper $helper) +	{ +		$this->bcrypt = $bcrypt; +		$this->helper = $helper; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_prefix() +	{ +		return self::PREFIX; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function is_legacy() +	{ +		return true; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function hash($password, $user_row = '') +	{ +		// Do not support hashing +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function check($password, $hash, $user_row = array()) +	{ +		if (empty($hash) || strlen($hash) != 60) +		{ +			return false; +		} +		else +		{ +			$salt = substr($hash, 0, 29); + +			if (strlen($salt) != 29) +			{ +				return false; +			} +			// Works for standard WCF 2.x, i.e. WBB4 and similar +			return $hash === $this->bcrypt->hash($this->bcrypt->hash($password, $salt), $salt); +		} +	} +} diff --git a/phpBB/phpbb/passwords/driver/convert_password.php b/phpBB/phpbb/passwords/driver/convert_password.php new file mode 100644 index 0000000000..eb70434df2 --- /dev/null +++ b/phpBB/phpbb/passwords/driver/convert_password.php @@ -0,0 +1,43 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\passwords\driver; + +class convert_password extends base +{ +	const PREFIX = '$CP$'; + +	/** +	* {@inheritdoc} +	*/ +	public function get_prefix() +	{ +		return self::PREFIX; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function hash($password, $user_row = '') +	{ +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function check($password, $hash, $user_row = array()) +	{ +		return false; +	} +} diff --git a/phpBB/phpbb/passwords/driver/driver_interface.php b/phpBB/phpbb/passwords/driver/driver_interface.php index 54c9d6500e..3974484f13 100644 --- a/phpBB/phpbb/passwords/driver/driver_interface.php +++ b/phpBB/phpbb/passwords/driver/driver_interface.php @@ -23,6 +23,13 @@ interface driver_interface  	public function is_supported();  	/** +	* Check if hash type is a legacy hash type +	* +	* @return bool		True if it's a legacy hash type, false if not +	*/ +	public function is_legacy(); + +	/**  	* Returns the hash prefix  	*  	* @return string	Hash prefix @@ -44,10 +51,11 @@ interface driver_interface  	*  	* @param string		$password The password to check  	* @param string		$hash The password hash to check against +	* @param array		$user_row User's row in users table  	*  	* @return bool		True if password is correct, else false  	*/ -	public function check($password, $hash); +	public function check($password, $hash, $user_row = array());  	/**  	* Get only the settings of the specified hash diff --git a/phpBB/phpbb/passwords/driver/helper.php b/phpBB/phpbb/passwords/driver/helper.php index 85019bd5c9..2b3ebce53a 100644 --- a/phpBB/phpbb/passwords/driver/helper.php +++ b/phpBB/phpbb/passwords/driver/helper.php @@ -16,7 +16,7 @@ namespace phpbb\passwords\driver;  class helper  {  	/** -	* @var phpbb\config\config +	* @var \phpbb\config\config  	*/  	protected $config; @@ -29,7 +29,7 @@ class helper  	/**  	* Construct a driver helper object  	* -	* @param phpbb\config\config $config phpBB configuration +	* @param \phpbb\config\config $config phpBB configuration  	*/  	public function __construct(\phpbb\config\config $config)  	{ diff --git a/phpBB/phpbb/passwords/driver/md5_mybb.php b/phpBB/phpbb/passwords/driver/md5_mybb.php new file mode 100644 index 0000000000..61ea8dafd8 --- /dev/null +++ b/phpBB/phpbb/passwords/driver/md5_mybb.php @@ -0,0 +1,60 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\passwords\driver; + +class md5_mybb extends base +{ +	const PREFIX = '$md5_mybb$'; + +	/** +	* {@inheritdoc} +	*/ +	public function get_prefix() +	{ +		return self::PREFIX; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function is_legacy() +	{ +		return true; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function hash($password, $user_row = '') +	{ +		// Do not support hashing +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function check($password, $hash, $user_row = array()) +	{ +		if (empty($hash) || strlen($hash) != 32 || !isset($user_row['user_passwd_salt'])) +		{ +			return false; +		} +		else +		{ +			// Works for myBB 1.1.x, 1.2.x, 1.4.x, 1.6.x +			return $hash === md5(md5($user_row['user_passwd_salt']) . md5($password)); +		} +	} +} diff --git a/phpBB/phpbb/passwords/driver/md5_phpbb2.php b/phpBB/phpbb/passwords/driver/md5_phpbb2.php new file mode 100644 index 0000000000..86a4b62ea5 --- /dev/null +++ b/phpBB/phpbb/passwords/driver/md5_phpbb2.php @@ -0,0 +1,118 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\passwords\driver; + +class md5_phpbb2 extends base +{ +	const PREFIX = '$md5_phpbb2$'; + +	/** @var \phpbb\request\request phpBB request object */ +	protected $request; + +	/** @var \phpbb\passwords\driver\salted_md5 */ +	protected $salted_md5; + +	/** @var string phpBB root path */ +	protected $phpbb_root_path; + +	/** @var string php file extension */ +	protected $php_ext; + +	/** +	* Constructor of passwords driver object +	* +	* @param \phpbb\request\request $request phpBB request object +	* @param \phpbb\passwords\driver\salted_md5 $salted_md5 Salted md5 driver +	* @param string $phpbb_root_path phpBB root path +	* @param string $php_ext PHP file extension +	*/ +	public function __construct($request, \phpbb\passwords\driver\salted_md5 $salted_md5, $phpbb_root_path, $php_ext) +	{ +		$this->request = $request; +		$this->salted_md5 = $salted_md5; +		$this->phpbb_root_path = $phpbb_root_path; +		$this->php_ext = $php_ext; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_prefix() +	{ +		return self::PREFIX; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function is_legacy() +	{ +		return true; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function hash($password, $user_row = '') +	{ +		// Do not support hashing +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function check($password, $hash, $user_row = array()) +	{ +		if (strlen($hash) != 32 && strlen($hash) != 34) +		{ +			return false; +		} + +		// enable super globals to get literal value +		// this is needed to prevent unicode normalization +		$super_globals_disabled = $this->request->super_globals_disabled(); +		if ($super_globals_disabled) +		{ +			$this->request->enable_super_globals(); +		} + +		// in phpBB2 passwords were used exactly as they were sent, with addslashes applied +		$password_old_format = isset($_REQUEST['password']) ? (string) $_REQUEST['password'] : ''; +		$password_old_format = (!STRIP) ? addslashes($password_old_format) : $password_old_format; +		$password_new_format = $this->request->variable('password', '', true); + +		if ($super_globals_disabled) +		{ +			$this->request->disable_super_globals(); +		} + +		if ($password == $password_new_format) +		{ +			if (!function_exists('utf8_to_cp1252')) +			{ +				include($this->phpbb_root_path . 'includes/utf/data/recode_basic.' . $this->php_ext); +			} + +			if (md5($password_old_format) === $hash || md5(\utf8_to_cp1252($password_old_format)) === $hash +				|| $this->salted_md5->check(md5($password_old_format), $hash) === true +				|| $this->salted_md5->check(md5(\utf8_to_cp1252($password_old_format)), $hash) === true) +			{ +				return true; +			} +		} + +		return false; +	} +} diff --git a/phpBB/phpbb/passwords/driver/md5_vb.php b/phpBB/phpbb/passwords/driver/md5_vb.php new file mode 100644 index 0000000000..c83c32a596 --- /dev/null +++ b/phpBB/phpbb/passwords/driver/md5_vb.php @@ -0,0 +1,60 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\passwords\driver; + +class md5_vb extends base +{ +	const PREFIX = '$md5_vb$'; + +	/** +	* {@inheritdoc} +	*/ +	public function get_prefix() +	{ +		return self::PREFIX; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function is_legacy() +	{ +		return true; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function hash($password, $user_row = '') +	{ +		// Do not support hashing +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function check($password, $hash, $user_row = array()) +	{ +		if (empty($hash) || strlen($hash) != 32 || !isset($user_row['user_passwd_salt'])) +		{ +			return false; +		} +		else +		{ +			// Works for vB 3.8.x, 4.x.x, 5.0.x +			return $hash === md5(md5($password) . $user_row['user_passwd_salt']); +		} +	} +} diff --git a/phpBB/phpbb/passwords/driver/phpass.php b/phpBB/phpbb/passwords/driver/phpass.php index 44d9dc8fab..bef8355276 100644 --- a/phpBB/phpbb/passwords/driver/phpass.php +++ b/phpBB/phpbb/passwords/driver/phpass.php @@ -18,7 +18,7 @@ class phpass extends salted_md5  	const PREFIX = '$P$';  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_prefix()  	{ diff --git a/phpBB/phpbb/passwords/driver/salted_md5.php b/phpBB/phpbb/passwords/driver/salted_md5.php index a9f6712751..97a2b9154b 100644 --- a/phpBB/phpbb/passwords/driver/salted_md5.php +++ b/phpBB/phpbb/passwords/driver/salted_md5.php @@ -46,7 +46,7 @@ class salted_md5 extends base  	const PREFIX = '$H$';  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_prefix()  	{ @@ -54,7 +54,15 @@ class salted_md5 extends base  	}  	/** -	* @inheritdoc +	* {@inheritdoc} +	*/ +	public function is_legacy() +	{ +		return true; +	} + +	/** +	* {@inheritdoc}  	*/  	public function hash($password, $setting = '')  	{ @@ -90,9 +98,9 @@ class salted_md5 extends base  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/ -	public function check($password, $hash) +	public function check($password, $hash, $user_row = array())  	{  		if (strlen($hash) !== 34)  		{ @@ -152,7 +160,7 @@ class salted_md5 extends base  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_settings_only($hash, $full = false)  	{ diff --git a/phpBB/phpbb/passwords/driver/sha1.php b/phpBB/phpbb/passwords/driver/sha1.php new file mode 100644 index 0000000000..0852fd32fc --- /dev/null +++ b/phpBB/phpbb/passwords/driver/sha1.php @@ -0,0 +1,52 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\passwords\driver; + +class sha1 extends base +{ +	const PREFIX = '$sha1$'; + +	/** +	* {@inheritdoc} +	*/ +	public function get_prefix() +	{ +		return self::PREFIX; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function is_legacy() +	{ +		return true; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function hash($password, $user_row = '') +	{ +		// Do not support hashing +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function check($password, $hash, $user_row = array()) +	{ +		return (strlen($hash) == 40) ? $hash === sha1($password) : false; +	} +} diff --git a/phpBB/phpbb/passwords/driver/sha1_smf.php b/phpBB/phpbb/passwords/driver/sha1_smf.php new file mode 100644 index 0000000000..ec64bd6afb --- /dev/null +++ b/phpBB/phpbb/passwords/driver/sha1_smf.php @@ -0,0 +1,51 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\passwords\driver; + +class sha1_smf extends base +{ +	const PREFIX = '$smf$'; + +	/** +	* {@inheritdoc} +	*/ +	public function get_prefix() +	{ +		return self::PREFIX; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function is_legacy() +	{ +		return true; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function hash($password, $user_row = '') +	{ +		return (isset($user_row['login_name'])) ? sha1(strtolower($user_row['login_name']) . $password) : false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function check($password, $hash, $user_row = array()) +	{ +		return (strlen($hash) == 40) ? $hash === $this->hash($password, $user_row) : false; +	} +} diff --git a/phpBB/phpbb/passwords/driver/sha1_wcf1.php b/phpBB/phpbb/passwords/driver/sha1_wcf1.php new file mode 100644 index 0000000000..919fa2bb71 --- /dev/null +++ b/phpBB/phpbb/passwords/driver/sha1_wcf1.php @@ -0,0 +1,60 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\passwords\driver; + +class sha1_wcf1 extends base +{ +	const PREFIX = '$wcf1$'; + +	/** +	* {@inheritdoc} +	*/ +	public function get_prefix() +	{ +		return self::PREFIX; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function is_legacy() +	{ +		return true; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function hash($password, $user_row = '') +	{ +		// Do not support hashing +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function check($password, $hash, $user_row = array()) +	{ +		if (empty($hash) || strlen($hash) != 40 || !isset($user_row['user_passwd_salt'])) +		{ +			return false; +		} +		else +		{ +			// Works for standard WCF 1.x, i.e. WBB3 and similar +			return $hash === sha1($user_row['user_passwd_salt'] . sha1($user_row['user_passwd_salt'] . sha1($password))); +		} +	} +} diff --git a/phpBB/phpbb/passwords/driver/sha_xf1.php b/phpBB/phpbb/passwords/driver/sha_xf1.php new file mode 100644 index 0000000000..7a1ea1450a --- /dev/null +++ b/phpBB/phpbb/passwords/driver/sha_xf1.php @@ -0,0 +1,68 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\passwords\driver; + +class sha_xf1 extends base +{ +	const PREFIX = '$xf1$'; + +	/** +	* {@inheritdoc} +	*/ +	public function get_prefix() +	{ +		return self::PREFIX; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function is_legacy() +	{ +		return true; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function hash($password, $user_row = '') +	{ +		// Do not support hashing +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function check($password, $hash, $user_row = array()) +	{ +		if (empty($hash) || (strlen($hash) != 40 && strlen($hash) != 64) || !isset($user_row['user_passwd_salt'])) +		{ +			return false; +		} +		else +		{ +			// Works for xenforo 1.0, 1.1 +			if ($hash === sha1(sha1($password) . $user_row['user_passwd_salt']) +				|| $hash === hash('sha256', hash('sha256', $password) . $user_row['user_passwd_salt'])) +			{ +				return true; +			} +			else +			{ +				return false; +			} +		} +	} +} diff --git a/phpBB/phpbb/passwords/helper.php b/phpBB/phpbb/passwords/helper.php index c6c5fb6d02..c2a49202cd 100644 --- a/phpBB/phpbb/passwords/helper.php +++ b/phpBB/phpbb/passwords/helper.php @@ -60,7 +60,7 @@ class helper  			$data[$type] .= ($data[$type] !== '$') ? '\\' : '';  			$data[$type] .= str_replace('$', '', $value);  		} -		elseif ($type == 'settings') +		else if ($type == 'settings')  		{  			$data[$type] .= ($data[$type] !== '$') ? '$' : '';  			$data[$type] .= $value; diff --git a/phpBB/phpbb/passwords/manager.php b/phpBB/phpbb/passwords/manager.php index 8b16cf55dd..fbb49d86a0 100644 --- a/phpBB/phpbb/passwords/manager.php +++ b/phpBB/phpbb/passwords/manager.php @@ -39,23 +39,23 @@ class manager  	/**  	* Passwords helper -	* @var phpbb\passwords\helper +	* @var \phpbb\passwords\helper  	*/  	protected $helper;  	/**  	* phpBB configuration -	* @var phpbb\config\config +	* @var \phpbb\config\config  	*/  	protected $config;  	/**  	* Construct a passwords object  	* -	* @param phpbb\config\config $config phpBB configuration +	* @param \phpbb\config\config $config phpBB configuration  	* @param array $hashing_algorithms Hashing driver  	*			service collection -	* @param phpbb\passwords\helper $helper Passwords helper object +	* @param \phpbb\passwords\helper $helper Passwords helper object  	* @param string $defaults List of default driver types  	*/  	public function __construct(\phpbb\config\config $config, $hashing_algorithms, helper $helper, $defaults) @@ -89,7 +89,7 @@ class manager  	/**  	* Fill algorithm type map  	* -	* @param phpbb\di\service_collection $hashing_algorithms +	* @param \phpbb\di\service_collection $hashing_algorithms  	*/  	protected function fill_type_map($hashing_algorithms)  	{ @@ -141,7 +141,7 @@ class manager  		*/  		if (!preg_match('#^\$([a-zA-Z0-9\\\]*?)\$#', $hash, $match))  		{ -			return $this->get_algorithm('$H$'); +			return false;  		}  		// Be on the lookout for multiple hashing algorithms @@ -224,9 +224,10 @@ class manager  	*  	* @param string $password Password that should be checked  	* @param string $hash Stored hash +	* @param array	$user_row User's row in users table  	* @return string|bool True if password is correct, false if not  	*/ -	public function check($password, $hash) +	public function check($password, $hash, $user_row = array())  	{  		if (strlen($password) > 4096)  		{ @@ -235,11 +236,19 @@ class manager  			return false;  		} +		// Empty hashes can't be checked +		if (empty($hash)) +		{ +			return false; +		} +  		// First find out what kind of hash we're dealing with  		$stored_hash_type = $this->detect_algorithm($hash);  		if ($stored_hash_type == false)  		{ -			return false; +			// Still check MD5 hashes as that is what the installer +			// will default to for the admin user +			return $this->get_algorithm('$H$')->check($password, $hash);  		}  		// Multiple hash passes needed @@ -259,6 +268,21 @@ class manager  			$this->convert_flag = false;  		} +		// Check all legacy hash types if prefix is $CP$ +		if ($stored_hash_type->get_prefix() === '$CP$') +		{ +			// Remove $CP$ prefix for proper checking +			$hash = substr($hash, 4); + +			foreach ($this->type_map as $algorithm) +			{ +				if ($algorithm->is_legacy() && $algorithm->check($password, $hash, $user_row) === true) +				{ +					return true; +				} +			} +		} +  		return $stored_hash_type->check($password, $hash);  	} diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php index 0d83e7447e..a5314d2ce1 100644 --- a/phpBB/phpbb/path_helper.php +++ b/phpBB/phpbb/path_helper.php @@ -317,7 +317,7 @@ class path_helper  	*  	* @param string $url URL to append parameters to  	* @param array $new_params Parameters to add in the form of array(name => value) -	* @param string $is_amp Is the parameter separator &. Defaults to true. +	* @param bool $is_amp Is the parameter separator &. Defaults to true.  	* @return string Returns the new URL.  	*/  	public function append_url_params($url, $new_params, $is_amp = true) diff --git a/phpBB/phpbb/permissions.php b/phpBB/phpbb/permissions.php index 72d85cb094..3f51016c93 100644 --- a/phpBB/phpbb/permissions.php +++ b/phpBB/phpbb/permissions.php @@ -32,7 +32,6 @@ class permissions  	*  	* @param	\phpbb\event\dispatcher	$phpbb_dispatcher	Event dispatcher  	* @param	\phpbb\user				$user				User Object -	* @return	null  	*/  	public function __construct(\phpbb\event\dispatcher $phpbb_dispatcher, \phpbb\user $user)  	{ diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php index 99278d40df..c610d49a63 100644 --- a/phpBB/phpbb/plupload/plupload.php +++ b/phpBB/phpbb/plupload/plupload.php @@ -69,8 +69,6 @@ class plupload  	* @param \phpbb\user $user  	* @param \phpbb\php\ini $php_ini  	* @param \phpbb\mimetype\guesser $mimetype_guesser -	* -	* @return null  	*/  	public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\user $user, \phpbb\php\ini $php_ini, \phpbb\mimetype\guesser $mimetype_guesser)  	{ diff --git a/phpBB/phpbb/profilefields/type/type_base.php b/phpBB/phpbb/profilefields/type/type_base.php index 3ca1274458..c770a0d93c 100644 --- a/phpBB/phpbb/profilefields/type/type_base.php +++ b/phpBB/phpbb/profilefields/type/type_base.php @@ -39,7 +39,6 @@ abstract class type_base implements type_interface  	* @param	\phpbb\request\request		$request	Request object  	* @param	\phpbb\template\template	$template	Template object  	* @param	\phpbb\user					$user		User object -	* @param	string		$language_table		Table where the language strings are stored  	*/  	public function __construct(\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)  	{ diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php index 8d3c0cad93..eb8d3e47d6 100644 --- a/phpBB/phpbb/profilefields/type/type_bool.php +++ b/phpBB/phpbb/profilefields/type/type_bool.php @@ -46,7 +46,6 @@ class type_bool extends type_base  	* @param	\phpbb\request\request		$request	Request object  	* @param	\phpbb\template\template	$template	Template object  	* @param	\phpbb\user					$user		User object -	* @param	string		$language_table		Table where the language strings are stored  	*/  	public function __construct(\phpbb\profilefields\lang_helper $lang_helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)  	{ diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php index aedd6a56d6..158eec6a0c 100644 --- a/phpBB/phpbb/profilefields/type/type_date.php +++ b/phpBB/phpbb/profilefields/type/type_date.php @@ -39,7 +39,6 @@ class type_date extends type_base  	* @param	\phpbb\request\request		$request	Request object  	* @param	\phpbb\template\template	$template	Template object  	* @param	\phpbb\user					$user		User object -	* @param	string		$language_table		Table where the language strings are stored  	*/  	public function __construct(\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)  	{ diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php index 053a02d593..52c9fcf86a 100644 --- a/phpBB/phpbb/profilefields/type/type_dropdown.php +++ b/phpBB/phpbb/profilefields/type/type_dropdown.php @@ -46,7 +46,6 @@ class type_dropdown extends type_base  	* @param	\phpbb\request\request		$request	Request object  	* @param	\phpbb\template\template	$template	Template object  	* @param	\phpbb\user					$user		User object -	* @param	string		$language_table		Table where the language strings are stored  	*/  	public function __construct(\phpbb\profilefields\lang_helper $lang_helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)  	{ diff --git a/phpBB/phpbb/profilefields/type/type_googleplus.php b/phpBB/phpbb/profilefields/type/type_googleplus.php new file mode 100644 index 0000000000..df1bcc7f4b --- /dev/null +++ b/phpBB/phpbb/profilefields/type/type_googleplus.php @@ -0,0 +1,58 @@ +<?php +/** +* +* 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. +* +*/ + +namespace phpbb\profilefields\type; + +class type_googleplus extends type_string +{ +	/** +	* {@inheritDoc} +	*/ +	public function get_service_name() +	{ +		return 'profilefields.type.googleplus'; +	} + +	/** +	* {@inheritDoc} +	*/ +	public function get_default_option_values() +	{ +		return array( +			'field_length'			=> 20, +			'field_minlen'			=> 3, +			'field_maxlen'			=> 255, +			'field_validation'		=> '[\w]+', +			'field_novalue'			=> '', +			'field_default_value'	=> '', +		); +	} + +	/** +	* {@inheritDoc} +	*/ +	public function get_profile_contact_value($field_value, $field_data) +	{ +		if (!$field_value && !$field_data['field_show_novalue']) +		{ +			return null; +		} + +		if (!is_numeric($field_value)) +		{ +			$field_value = '+' . $field_value; +		} + +		return $field_value; +	} +} diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php index 8cbcf62b8c..78f1c7d2c9 100644 --- a/phpBB/phpbb/profilefields/type/type_int.php +++ b/phpBB/phpbb/profilefields/type/type_int.php @@ -39,7 +39,6 @@ class type_int extends type_base  	* @param	\phpbb\request\request		$request	Request object  	* @param	\phpbb\template\template	$template	Template object  	* @param	\phpbb\user					$user		User object -	* @param	string		$language_table		Table where the language strings are stored  	*/  	public function __construct(\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)  	{ diff --git a/phpBB/phpbb/profilefields/type/type_string.php b/phpBB/phpbb/profilefields/type/type_string.php index 7e994d700b..67befc457d 100644 --- a/phpBB/phpbb/profilefields/type/type_string.php +++ b/phpBB/phpbb/profilefields/type/type_string.php @@ -39,7 +39,6 @@ class type_string extends type_string_common  	* @param	\phpbb\request\request		$request	Request object  	* @param	\phpbb\template\template	$template	Template object  	* @param	\phpbb\user					$user		User object -	* @param	string		$language_table		Table where the language strings are stored  	*/  	public function __construct(\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)  	{ diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php index 7d0cb04d7c..b48e3c5add 100644 --- a/phpBB/phpbb/profilefields/type/type_string_common.php +++ b/phpBB/phpbb/profilefields/type/type_string_common.php @@ -20,7 +20,9 @@ abstract class type_string_common extends type_base  		'NUMBERS_ONLY'		=> '[0-9]+',  		'ALPHA_ONLY'		=> '[\w]+',  		'ALPHA_UNDERSCORE'	=> '[\w_]+', +		'ALPHA_DOTS'        => '[\w.]+',  		'ALPHA_SPACERS'		=> '[\w_\+\. \-\[\]]+', +		'ALPHA_PUNCTUATION' => '[a-zA-Z][\w\.,\-_]+',  	);  	/** diff --git a/phpBB/phpbb/profilefields/type/type_text.php b/phpBB/phpbb/profilefields/type/type_text.php index 856573292f..bacf60a213 100644 --- a/phpBB/phpbb/profilefields/type/type_text.php +++ b/phpBB/phpbb/profilefields/type/type_text.php @@ -39,7 +39,6 @@ class type_text extends type_string_common  	* @param	\phpbb\request\request		$request	Request object  	* @param	\phpbb\template\template	$template	Template object  	* @param	\phpbb\user					$user		User object -	* @param	string		$language_table		Table where the language strings are stored  	*/  	public function __construct(\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)  	{ diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index f7b1751a51..2fbff57990 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -1485,7 +1485,6 @@ class fulltext_native extends \phpbb\search\base  		{  			case 'sqlite':  			case 'sqlite3': -			case 'firebird':  				$this->db->sql_query('DELETE FROM ' . SEARCH_WORDLIST_TABLE);  				$this->db->sql_query('DELETE FROM ' . SEARCH_WORDMATCH_TABLE);  				$this->db->sql_query('DELETE FROM ' . SEARCH_RESULTS_TABLE); diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index 49d528c8ba..bdb5a86009 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -263,12 +263,12 @@ class fulltext_postgres extends \phpbb\search\base  					$this->search_query .= $word . ' ';  					$this->tsearch_query .= '&' . substr($word, 1) . ' ';  				} -				elseif (strpos($word, '-') === 0) +				else if (strpos($word, '-') === 0)  				{  					$this->search_query .= $word . ' ';  					$this->tsearch_query .= '&!' . substr($word, 1) . ' ';  				} -				elseif (strpos($word, '|') === 0) +				else if (strpos($word, '|') === 0)  				{  					$this->search_query .= $word . ' ';  					$this->tsearch_query .= '|' . substr($word, 1) . ' '; diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php index c6c636562e..9008af338b 100644 --- a/phpBB/phpbb/search/fulltext_sphinx.php +++ b/phpBB/phpbb/search/fulltext_sphinx.php @@ -693,7 +693,7 @@ class fulltext_sphinx  	{  		if ($mode == 'edit')  		{ -			$this->sphinx->UpdateAttributes($this->indexes, array('forum_id', 'poster_id'), array((int)$post_id => array((int)$forum_id, (int)$poster_id))); +			$this->sphinx->UpdateAttributes($this->indexes, array('forum_id', 'poster_id'), array((int) $post_id => array((int) $forum_id, (int) $poster_id)));  		}  		else if ($mode != 'post' && $post_id)  		{ @@ -718,7 +718,7 @@ class fulltext_sphinx  			$post_time = time();  			while ($row = $this->db->sql_fetchrow($result))  			{ -				$post_updates[(int)$row['post_id']] = array($post_time); +				$post_updates[(int) $row['post_id']] = array($post_time);  			}  			$this->db->sql_freeresult($result); diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index d286dc9cfc..59b7ec2029 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -408,9 +408,8 @@ class session  					$session_expired = false;  					// Check whether the session is still valid if we have one -					$method = basename(trim($config['auth_method'])); - -					$provider = $phpbb_container->get('auth.provider.' . $method); +					$provider_collection = $phpbb_container->get('auth.provider_collection'); +					$provider = $provider_collection->get_provider();  					if (!($provider instanceof \phpbb\auth\provider\provider_interface))  					{ @@ -577,9 +576,8 @@ class session  			}  		} -		$method = basename(trim($config['auth_method'])); - -		$provider = $phpbb_container->get('auth.provider.' . $method); +		$provider_collection = $phpbb_container->get('auth.provider_collection'); +		$provider = $provider_collection->get_provider();  		$this->data = $provider->autologin();  		if (sizeof($this->data)) @@ -898,9 +896,8 @@ class session  		$db->sql_query($sql);  		// Allow connecting logout with external auth method logout -		$method = basename(trim($config['auth_method'])); - -		$provider = $phpbb_container->get('auth.provider.' . $method); +		$provider_collection = $phpbb_container->get('auth.provider_collection'); +		$provider = $provider_collection->get_provider();  		$provider->logout($this->data, $new_session);  		if ($this->data['user_id'] != ANONYMOUS) @@ -1075,7 +1072,7 @@ class session  	{  		global $config, $db; -		if (defined('IN_CHECK_BAN')) +		if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN'))  		{  			return;  		} @@ -1189,7 +1186,7 @@ class session  		if ($banned && !$return)  		{ -			global $template; +			global $template, $phpbb_root_path, $phpEx;  			// If the session is empty we need to create a valid one...  			if (empty($this->session_id)) @@ -1210,8 +1207,6 @@ class session  			// We show a login box here to allow founders accessing the board if banned by IP  			if (defined('IN_LOGIN') && $this->data['user_id'] == ANONYMOUS)  			{ -				global $phpEx; -  				$this->setup('ucp');  				$this->data['is_registered'] = $this->data['is_bot'] = false; @@ -1235,7 +1230,8 @@ class session  			$till_date = ($ban_row['ban_end']) ? $this->format_date($ban_row['ban_end']) : '';  			$message = ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM'; -			$message = sprintf($this->lang[$message], $till_date, '<a href="mailto:' . $config['board_contact'] . '">', '</a>'); +			$contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx); +			$message = sprintf($this->lang[$message], $till_date, '<a href="' . $contact_link . '">', '</a>');  			$message .= ($ban_row['ban_give_reason']) ? '<br /><br />' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['ban_give_reason']) : '';  			$message .= '<br /><br /><em>' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . '</em>'; diff --git a/phpBB/phpbb/symfony_request.php b/phpBB/phpbb/symfony_request.php index 62e155aa23..bf9ddec493 100644 --- a/phpBB/phpbb/symfony_request.php +++ b/phpBB/phpbb/symfony_request.php @@ -20,7 +20,7 @@ class symfony_request extends Request  	/**  	* Constructor  	* -	* @param phpbb\request\request_interface $phpbb_request +	* @param \phpbb\request\request_interface $phpbb_request  	*/  	public function __construct(\phpbb\request\request_interface $phpbb_request)  	{ diff --git a/phpBB/phpbb/template/context.php b/phpBB/phpbb/template/context.php index 8df6c8b492..0a32879943 100644 --- a/phpBB/phpbb/template/context.php +++ b/phpBB/phpbb/template/context.php @@ -55,6 +55,7 @@ class context  	*  	* @param string $varname Variable name  	* @param string $varval Value to assign to variable +	* @return true  	*/  	public function assign_var($varname, $varval)  	{ @@ -70,6 +71,7 @@ class context  	*  	* @param string $varname Variable name  	* @param string $varval Value to append to variable +	* @return true  	*/  	public function append_var($varname, $varval)  	{ @@ -117,6 +119,7 @@ class context  	*  	* @param string $blockname Name of block to assign $vararray to  	* @param array $vararray A hash of variable name => value pairs +	* @return true  	*/  	public function assign_block_vars($blockname, array $vararray)  	{ @@ -206,6 +209,7 @@ class context  	*  	* @param string $blockname Name of block to assign $block_vars_array to  	* @param array $block_vars_array An array of hashes of variable name => value pairs +	* @return true  	*/  	public function assign_block_vars_array($blockname, array $block_vars_array)  	{ @@ -374,6 +378,7 @@ class context  	* Reset/empty complete block  	*  	* @param string $blockname Name of block to destroy +	* @return true  	*/  	public function destroy_block_vars($blockname)  	{ diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 374f9e9359..041ecb12e4 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -175,6 +175,7 @@ interface template  	/**  	* Get path to template for handle (required for BBCode parser)  	* +	* @param string $handle Handle to retrieve the source file  	* @return string  	*/  	public function get_source_file_for_handle($handle); diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php index d71c02967c..8d25153e14 100644 --- a/phpBB/phpbb/template/twig/environment.php +++ b/phpBB/phpbb/template/twig/environment.php @@ -40,7 +40,7 @@ class environment extends \Twig_Environment  	* @param \phpbb\path_helper  	* @param \phpbb\extension\manager  	* @param string $phpbb_root_path -	* @param Twig_LoaderInterface $loader +	* @param \Twig_LoaderInterface $loader  	* @param array $options Array of options to pass to Twig  	*/  	public function __construct($phpbb_config, \phpbb\path_helper $path_helper, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array()) @@ -122,7 +122,7 @@ class environment extends \Twig_Environment  	* Set the namespace look up order to load templates from  	*  	* @param array $namespace -	* @return Twig_Environment +	* @return \Twig_Environment  	*/  	public function setNamespaceLookUpOrder($namespace)  	{ @@ -132,12 +132,13 @@ class environment extends \Twig_Environment  	}  	/** -	 * Loads a template by name. -	 * -	 * @param string  $name  The template name -	 * @param integer $index The index if it is an embedded template -	 * @return Twig_TemplateInterface A template instance representing the given template name -	 */ +	* Loads a template by name. +	* +	* @param string  $name  The template name +	* @param integer $index The index if it is an embedded template +	* @return \Twig_TemplateInterface A template instance representing the given template name +	* @throws \Twig_Error_Loader +	*/  	public function loadTemplate($name, $index = null)  	{  		if (strpos($name, '@') === false) @@ -168,11 +169,12 @@ class environment extends \Twig_Environment  	}  	/** -	 * Finds a template by name. -	 * -	 * @param string  $name  The template name -	 * @return string -	 */ +	* Finds a template by name. +	* +	* @param string  $name  The template name +	* @return string +	* @throws \Twig_Error_Loader +	*/  	public function findTemplate($name)  	{  		if (strpos($name, '@') === false) @@ -188,7 +190,7 @@ class environment extends \Twig_Environment  					return parent::getLoader()->getCacheKey('@' . $namespace . '/' . $name);  				} -				catch (Twig_Error_Loader $e) +				catch (\Twig_Error_Loader $e)  				{  				}  			} diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php index a357db30a5..8f523684dd 100644 --- a/phpBB/phpbb/template/twig/extension.php +++ b/phpBB/phpbb/template/twig/extension.php @@ -127,7 +127,7 @@ class extension extends \Twig_Extension  	/**  	* Grabs a subset of a loop  	* -	* @param Twig_Environment $env          A Twig_Environment instance +	* @param \Twig_Environment $env          A Twig_Environment instance  	* @param mixed            $item         A variable  	* @param integer          $start        Start of the subset  	* @param integer          $end   	     End of the subset diff --git a/phpBB/phpbb/template/twig/loader.php b/phpBB/phpbb/template/twig/loader.php index 851eb9ddd0..2f8ffaa776 100644 --- a/phpBB/phpbb/template/twig/loader.php +++ b/phpBB/phpbb/template/twig/loader.php @@ -24,7 +24,7 @@ class loader extends \Twig_Loader_Filesystem  	* Set safe directories  	*  	* @param array $directories Array of directories that are safe (empty to clear) -	* @return Twig_Loader_Filesystem +	* @return \Twig_Loader_Filesystem  	*/  	public function setSafeDirectories($directories = array())  	{ @@ -45,7 +45,7 @@ class loader extends \Twig_Loader_Filesystem  	* Add safe directory  	*  	* @param string $directory Directory that should be added -	* @return Twig_Loader_Filesystem +	* @return \Twig_Loader_Filesystem  	*/  	public function addSafeDirectory($directory)  	{ @@ -110,7 +110,7 @@ class loader extends \Twig_Loader_Filesystem  			// Try validating the name (which may throw an exception)  			parent::validateName($name);  		} -		catch (Twig_Error_Loader $e) +		catch (\Twig_Error_Loader $e)  		{  			if (strpos($e->getRawMessage(), 'Looks like you try to load a template outside configured directories') === 0)  			{ diff --git a/phpBB/phpbb/template/twig/node/definenode.php b/phpBB/phpbb/template/twig/node/definenode.php index fe336d4129..695ec4281f 100644 --- a/phpBB/phpbb/template/twig/node/definenode.php +++ b/phpBB/phpbb/template/twig/node/definenode.php @@ -23,10 +23,10 @@ class definenode extends \Twig_Node  	}  	/** -	 * Compiles the node to PHP. -	 * -	 * @param Twig_Compiler A Twig_Compiler instance -	 */ +	* Compiles the node to PHP. +	* +	* @param \Twig_Compiler A Twig_Compiler instance +	*/  	public function compile(\Twig_Compiler $compiler)  	{  		$compiler->addDebugInfo($this); diff --git a/phpBB/phpbb/template/twig/node/event.php b/phpBB/phpbb/template/twig/node/event.php index b551d7a75e..8fc4ba4775 100644 --- a/phpBB/phpbb/template/twig/node/event.php +++ b/phpBB/phpbb/template/twig/node/event.php @@ -17,12 +17,12 @@ namespace phpbb\template\twig\node;  class event extends \Twig_Node  {  	/** -	 * The subdirectory in which all template listener files must be placed -	 * @var string -	 */ +	* The subdirectory in which all template listener files must be placed +	* @var string +	*/  	protected $listener_directory = 'event/'; -	/** @var Twig_Environment */ +	/** @var \Twig_Environment */  	protected $environment;  	public function __construct(\Twig_Node_Expression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null) @@ -33,10 +33,10 @@ class event extends \Twig_Node  	}  	/** -	 * Compiles the node to PHP. -	 * -	 * @param Twig_Compiler A Twig_Compiler instance -	 */ +	* Compiles the node to PHP. +	* +	* @param \Twig_Compiler A Twig_Compiler instance +	*/  	public function compile(\Twig_Compiler $compiler)  	{  		$compiler->addDebugInfo($this); diff --git a/phpBB/phpbb/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php index c41d4d03f3..15195a226b 100644 --- a/phpBB/phpbb/template/twig/node/includeasset.php +++ b/phpBB/phpbb/template/twig/node/includeasset.php @@ -15,7 +15,7 @@ namespace phpbb\template\twig\node;  abstract class includeasset extends \Twig_Node  { -	/** @var Twig_Environment */ +	/** @var \Twig_Environment */  	protected $environment;  	public function __construct(\Twig_Node_Expression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null) @@ -25,10 +25,10 @@ abstract class includeasset extends \Twig_Node  		parent::__construct(array('expr' => $expr), array(), $lineno, $tag);  	}  	/** -	 * Compiles the node to PHP. -	 * -	 * @param Twig_Compiler A Twig_Compiler instance -	 */ +	* Compiles the node to PHP. +	* +	* @param \Twig_Compiler A Twig_Compiler instance +	*/  	public function compile(\Twig_Compiler $compiler)  	{  		$compiler->addDebugInfo($this); @@ -74,7 +74,7 @@ abstract class includeasset extends \Twig_Node  	/**  	* Append the output code for the asset  	* -	* @param Twig_Compiler A Twig_Compiler instance +	* @param \Twig_Compiler A Twig_Compiler instance  	* @return null  	*/  	abstract protected function append_asset(\Twig_Compiler $compiler); diff --git a/phpBB/phpbb/template/twig/node/includenode.php b/phpBB/phpbb/template/twig/node/includenode.php index 141c9ffe66..42428b6106 100644 --- a/phpBB/phpbb/template/twig/node/includenode.php +++ b/phpBB/phpbb/template/twig/node/includenode.php @@ -17,10 +17,10 @@ namespace phpbb\template\twig\node;  class includenode extends \Twig_Node_Include  {  	/** -	 * Compiles the node to PHP. -	 * -	 * @param Twig_Compiler A Twig_Compiler instance -	 */ +	* Compiles the node to PHP. +	* +	* @param \Twig_Compiler A Twig_Compiler instance +	*/  	public function compile(\Twig_Compiler $compiler)  	{  		$compiler->addDebugInfo($this); diff --git a/phpBB/phpbb/template/twig/node/includephp.php b/phpBB/phpbb/template/twig/node/includephp.php index e7df11c74e..826617e8e8 100644 --- a/phpBB/phpbb/template/twig/node/includephp.php +++ b/phpBB/phpbb/template/twig/node/includephp.php @@ -17,7 +17,7 @@ namespace phpbb\template\twig\node;  class includephp extends \Twig_Node  { -	/** @var Twig_Environment */ +	/** @var \Twig_Environment */  	protected $environment;  	public function __construct(\Twig_Node_Expression $expr, \phpbb\template\twig\environment $environment, $lineno, $ignoreMissing = false, $tag = null) @@ -28,10 +28,10 @@ class includephp extends \Twig_Node  	}  	/** -	 * Compiles the node to PHP. -	 * -	 * @param Twig_Compiler A Twig_Compiler instance -	 */ +	* Compiles the node to PHP. +	* +	* @param \Twig_Compiler A Twig_Compiler instance +	*/  	public function compile(\Twig_Compiler $compiler)  	{  		$compiler->addDebugInfo($this); diff --git a/phpBB/phpbb/template/twig/node/php.php b/phpBB/phpbb/template/twig/node/php.php index de3a8a4af1..3a24513dca 100644 --- a/phpBB/phpbb/template/twig/node/php.php +++ b/phpBB/phpbb/template/twig/node/php.php @@ -16,7 +16,7 @@ namespace phpbb\template\twig\node;  class php extends \Twig_Node  { -	/** @var Twig_Environment */ +	/** @var \Twig_Environment */  	protected $environment;  	public function __construct(\Twig_Node_Text $text, \phpbb\template\twig\environment $environment, $lineno, $tag = null) @@ -27,10 +27,10 @@ class php extends \Twig_Node  	}  	/** -	 * Compiles the node to PHP. -	 * -	 * @param Twig_Compiler A Twig_Compiler instance -	 */ +	* Compiles the node to PHP. +	* +	* @param \Twig_Compiler A Twig_Compiler instance +	*/  	public function compile(\Twig_Compiler $compiler)  	{  		$compiler->addDebugInfo($this); diff --git a/phpBB/phpbb/template/twig/tokenparser/defineparser.php b/phpBB/phpbb/template/twig/tokenparser/defineparser.php index 48c4853fe8..cfee84a363 100644 --- a/phpBB/phpbb/template/twig/tokenparser/defineparser.php +++ b/phpBB/phpbb/template/twig/tokenparser/defineparser.php @@ -18,12 +18,14 @@ namespace phpbb\template\twig\tokenparser;  class defineparser extends \Twig_TokenParser  {  	/** -	 * Parses a token and returns a node. -	 * -	 * @param Twig_Token $token A Twig_Token instance -	 * -	 * @return Twig_NodeInterface A Twig_NodeInterface instance -	 */ +	* Parses a token and returns a node. +	* +	* @param \Twig_Token $token A Twig_Token instance +	* +	* @return \Twig_NodeInterface A Twig_NodeInterface instance +	* @throws \Twig_Error_Syntax +	* @throws \phpbb\template\twig\node\definenode +	*/  	public function parse(\Twig_Token $token)  	{  		$lineno = $token->getLine(); @@ -61,10 +63,10 @@ class defineparser extends \Twig_TokenParser  	}  	/** -	 * Gets the tag name associated with this token parser. -	 * -	 * @return string The tag name -	 */ +	* Gets the tag name associated with this token parser. +	* +	* @return string The tag name +	*/  	public function getTag()  	{  		return 'DEFINE'; diff --git a/phpBB/phpbb/template/twig/tokenparser/event.php b/phpBB/phpbb/template/twig/tokenparser/event.php index 05b963f3e8..4c7c8e07d9 100644 --- a/phpBB/phpbb/template/twig/tokenparser/event.php +++ b/phpBB/phpbb/template/twig/tokenparser/event.php @@ -17,12 +17,12 @@ namespace phpbb\template\twig\tokenparser;  class event extends \Twig_TokenParser  {  	/** -	 * Parses a token and returns a node. -	 * -	 * @param Twig_Token $token A Twig_Token instance -	 * -	 * @return Twig_NodeInterface A Twig_NodeInterface instance -	 */ +	* Parses a token and returns a node. +	* +	* @param \Twig_Token $token A Twig_Token instance +	* +	* @return \Twig_NodeInterface A Twig_NodeInterface instance +	*/  	public function parse(\Twig_Token $token)  	{  		$expr = $this->parser->getExpressionParser()->parseExpression(); @@ -34,10 +34,10 @@ class event extends \Twig_TokenParser  	}  	/** -	 * Gets the tag name associated with this token parser. -	 * -	 * @return string The tag name -	 */ +	* Gets the tag name associated with this token parser. +	* +	* @return string The tag name +	*/  	public function getTag()  	{  		return 'EVENT'; diff --git a/phpBB/phpbb/template/twig/tokenparser/includecss.php b/phpBB/phpbb/template/twig/tokenparser/includecss.php index c7d2bb712e..1f30811754 100644 --- a/phpBB/phpbb/template/twig/tokenparser/includecss.php +++ b/phpBB/phpbb/template/twig/tokenparser/includecss.php @@ -16,12 +16,12 @@ namespace phpbb\template\twig\tokenparser;  class includecss extends \Twig_TokenParser  {  	/** -	 * Parses a token and returns a node. -	 * -	 * @param Twig_Token $token A Twig_Token instance -	 * -	 * @return Twig_NodeInterface A Twig_NodeInterface instance -	 */ +	* Parses a token and returns a node. +	* +	* @param \Twig_Token $token A Twig_Token instance +	* +	* @return \Twig_NodeInterface A Twig_NodeInterface instance +	*/  	public function parse(\Twig_Token $token)  	{  		$expr = $this->parser->getExpressionParser()->parseExpression(); @@ -33,10 +33,10 @@ class includecss extends \Twig_TokenParser  	}  	/** -	 * Gets the tag name associated with this token parser. -	 * -	 * @return string The tag name -	 */ +	* Gets the tag name associated with this token parser. +	* +	* @return string The tag name +	*/  	public function getTag()  	{  		return 'INCLUDECSS'; diff --git a/phpBB/phpbb/template/twig/tokenparser/includejs.php b/phpBB/phpbb/template/twig/tokenparser/includejs.php index 0c32692209..4156048e42 100644 --- a/phpBB/phpbb/template/twig/tokenparser/includejs.php +++ b/phpBB/phpbb/template/twig/tokenparser/includejs.php @@ -17,12 +17,12 @@ namespace phpbb\template\twig\tokenparser;  class includejs extends \Twig_TokenParser  {  	/** -	 * Parses a token and returns a node. -	 * -	 * @param Twig_Token $token A Twig_Token instance -	 * -	 * @return Twig_NodeInterface A Twig_NodeInterface instance -	 */ +	* Parses a token and returns a node. +	* +	* @param \Twig_Token $token A Twig_Token instance +	* +	* @return \Twig_NodeInterface A Twig_NodeInterface instance +	*/  	public function parse(\Twig_Token $token)  	{  		$expr = $this->parser->getExpressionParser()->parseExpression(); @@ -34,10 +34,10 @@ class includejs extends \Twig_TokenParser  	}  	/** -	 * Gets the tag name associated with this token parser. -	 * -	 * @return string The tag name -	 */ +	* Gets the tag name associated with this token parser. +	* +	* @return string The tag name +	*/  	public function getTag()  	{  		return 'INCLUDEJS'; diff --git a/phpBB/phpbb/template/twig/tokenparser/includeparser.php b/phpBB/phpbb/template/twig/tokenparser/includeparser.php index e9f4db0890..6ee78e5562 100644 --- a/phpBB/phpbb/template/twig/tokenparser/includeparser.php +++ b/phpBB/phpbb/template/twig/tokenparser/includeparser.php @@ -18,12 +18,12 @@ namespace phpbb\template\twig\tokenparser;  class includeparser extends \Twig_TokenParser_Include  {  	/** -	 * Parses a token and returns a node. -	 * -	 * @param Twig_Token $token A Twig_Token instance -	 * -	 * @return Twig_NodeInterface A Twig_NodeInterface instance -	 */ +	* Parses a token and returns a node. +	* +	* @param \Twig_Token $token A Twig_Token instance +	* +	* @return \Twig_NodeInterface A Twig_NodeInterface instance +	*/  	public function parse(\Twig_Token $token)  	{  		$expr = $this->parser->getExpressionParser()->parseExpression(); @@ -34,10 +34,10 @@ class includeparser extends \Twig_TokenParser_Include  	}  	/** -	 * Gets the tag name associated with this token parser. -	 * -	 * @return string The tag name -	 */ +	* Gets the tag name associated with this token parser. +	* +	* @return string The tag name +	*/  	public function getTag()  	{  		return 'INCLUDE'; diff --git a/phpBB/phpbb/template/twig/tokenparser/includephp.php b/phpBB/phpbb/template/twig/tokenparser/includephp.php index f745c320c2..38196c5290 100644 --- a/phpBB/phpbb/template/twig/tokenparser/includephp.php +++ b/phpBB/phpbb/template/twig/tokenparser/includephp.php @@ -18,12 +18,12 @@ namespace phpbb\template\twig\tokenparser;  class includephp extends \Twig_TokenParser  {  	/** -	 * Parses a token and returns a node. -	 * -	 * @param Twig_Token $token A Twig_Token instance -	 * -	 * @return Twig_NodeInterface A Twig_NodeInterface instance -	 */ +	* Parses a token and returns a node. +	* +	* @param \Twig_Token $token A Twig_Token instance +	* +	* @return \Twig_NodeInterface A Twig_NodeInterface instance +	*/  	public function parse(\Twig_Token $token)  	{  		$expr = $this->parser->getExpressionParser()->parseExpression(); @@ -44,10 +44,10 @@ class includephp extends \Twig_TokenParser  	}  	/** -	 * Gets the tag name associated with this token parser. -	 * -	 * @return string The tag name -	 */ +	* Gets the tag name associated with this token parser. +	* +	* @return string The tag name +	*/  	public function getTag()  	{  		return 'INCLUDEPHP'; diff --git a/phpBB/phpbb/template/twig/tokenparser/php.php b/phpBB/phpbb/template/twig/tokenparser/php.php index 0546a2d93f..557a70cca1 100644 --- a/phpBB/phpbb/template/twig/tokenparser/php.php +++ b/phpBB/phpbb/template/twig/tokenparser/php.php @@ -17,12 +17,12 @@ namespace phpbb\template\twig\tokenparser;  class php extends \Twig_TokenParser  {  	/** -	 * Parses a token and returns a node. -	 * -	 * @param Twig_Token $token A Twig_Token instance -	 * -	 * @return Twig_NodeInterface A Twig_NodeInterface instance -	 */ +	* Parses a token and returns a node. +	* +	* @param \Twig_Token $token A Twig_Token instance +	* +	* @return \Twig_NodeInterface A Twig_NodeInterface instance +	*/  	public function parse(\Twig_Token $token)  	{  		$stream = $this->parser->getStream(); @@ -42,10 +42,10 @@ class php extends \Twig_TokenParser  	}  	/** -	 * Gets the tag name associated with this token parser. -	 * -	 * @return string The tag name -	 */ +	* Gets the tag name associated with this token parser. +	* +	* @return string The tag name +	*/  	public function getTag()  	{  		return 'PHP'; diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index bf27dd5f20..5e2057f818 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -67,7 +67,7 @@ class twig extends \phpbb\template\base  	/**  	* Twig Environment  	* -	* @var Twig_Environment +	* @var \Twig_Environment  	*/  	protected $twig; @@ -347,9 +347,7 @@ class twig extends \phpbb\template\base  	}  	/** -	* Get path to template for handle (required for BBCode parser) -	* -	* @return string +	* {@inheritdoc}  	*/  	public function get_source_file_for_handle($handle)  	{ diff --git a/phpBB/phpbb/tree/nestedset.php b/phpBB/phpbb/tree/nestedset.php index 7a26c81b0e..57d109652e 100644 --- a/phpBB/phpbb/tree/nestedset.php +++ b/phpBB/phpbb/tree/nestedset.php @@ -103,7 +103,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	*  	* @return bool	True if the lock was acquired, false if it has been acquired previously  	* -	* @throws RuntimeException If the lock could not be acquired +	* @throws \RuntimeException If the lock could not be acquired  	*/  	protected function acquire_lock()  	{ @@ -121,7 +121,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function insert(array $additional_data)  	{ @@ -176,6 +176,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	*  	* @param int	$item_id	The item to be deleted  	* @return array		Item ids that have been removed +	* @throws \OutOfBoundsException  	*/  	protected function remove_item_from_nestedset($item_id)  	{ @@ -199,7 +200,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function delete($item_id)  	{ @@ -214,7 +215,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function move($item_id, $delta)  	{ @@ -332,7 +333,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function move_down($item_id)  	{ @@ -340,7 +341,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function move_up($item_id)  	{ @@ -348,7 +349,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function move_children($current_parent_id, $new_parent_id)  	{ @@ -454,7 +455,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function change_parent($item_id, $new_parent_id)  	{ @@ -553,7 +554,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_path_and_subtree_data($item_id, $order_asc = true, $include_item = true)  	{ @@ -564,7 +565,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_path_data($item_id, $order_asc = true, $include_item = true)  	{ @@ -574,7 +575,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface  	}  	/** -	* @inheritdoc +	* {@inheritdoc}  	*/  	public function get_subtree_data($item_id, $order_asc = true, $include_item = true)  	{ diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index f4cc26cc9a..4e90044395 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -317,7 +317,7 @@ class user extends \phpbb\session  		}  		// Is board disabled and user not an admin or moderator? -		if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) +		if ($config['board_disable'] && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))  		{  			if ($this->data['is_bot'])  			{ | 
