diff options
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/acp/acp_jabber.php | 8 | ||||
| -rw-r--r-- | phpBB/includes/functions_jabber.php | 39 | ||||
| -rw-r--r-- | phpBB/includes/functions_messenger.php | 8 | 
3 files changed, 34 insertions, 21 deletions
diff --git a/phpBB/includes/acp/acp_jabber.php b/phpBB/includes/acp/acp_jabber.php index d216ff7f9b..d58fef14f1 100644 --- a/phpBB/includes/acp/acp_jabber.php +++ b/phpBB/includes/acp/acp_jabber.php @@ -58,7 +58,7 @@ class acp_jabber  			{  				if (!$jabber->connect())  				{ -					trigger_error($user->lang['ERR_JAB_CONNECT'] . adm_back_link($this->u_action), E_USER_WARNING); +					trigger_error($user->lang['ERR_JAB_CONNECT'] . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);  				}  				// First we'll try to authorise using this account, if that fails we'll try to create it. @@ -87,16 +87,16 @@ class acp_jabber  			{  				if (!$jabber->connect())  				{ -					trigger_error($user->lang['ERR_JAB_CONNECT'] . adm_back_link($this->u_action), E_USER_WARNING); +					trigger_error($user->lang['ERR_JAB_CONNECT'] . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);  				}  				if (!$jabber->send_auth())  				{ -					trigger_error($user->lang['ERR_JAB_AUTH'] . adm_back_link($this->u_action), E_USER_WARNING); +					trigger_error($user->lang['ERR_JAB_AUTH'] . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);  				}  				$jabber->send_presence(NULL, NULL, 'online'); -				if (($result = $jabber->change_password($jab_password))  <> 2) +				if (($result = $jabber->change_password($jab_password)) <> 2)  				{  					$error[] = ($result == 1) ? $user->lang['ERR_JAB_PASSCHG'] : sprintf($user->lang['ERR_JAB_PASSFAIL'], $result);  				} diff --git a/phpBB/includes/functions_jabber.php b/phpBB/includes/functions_jabber.php index 726985e631..b0a7e09c08 100644 --- a/phpBB/includes/functions_jabber.php +++ b/phpBB/includes/functions_jabber.php @@ -20,7 +20,7 @@  *	last modified: 24.03.2004 13:01:53   *  *	Modified by phpBB Development Team -*	version: v0.4.3a +*	version: v0.4.3a1  *  * @package phpBB3  */ @@ -113,7 +113,7 @@ class jabber  		if ($this->connector->open_socket($this->server, $this->port))  		{  			$this->send_packet("<?xml version='1.0' encoding='UTF-8' ?" . ">\n"); -			$this->send_packet("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n"); +			$this->send_packet("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='0.9'>\n");  			sleep(2); @@ -672,7 +672,7 @@ class jabber  	{  		if ($this->enable_logging && sizeof($this->log_array))  		{ -			return implode("\n\n", $this->log_array); +			return implode("<br /><br />", $this->log_array);  		}  		return ''; @@ -805,7 +805,7 @@ class jabber  	* Check if connected  	* @access private  	*/ -	function _check_connected() +	function _check_connected($in_tls = false)  	{  		$incoming_array = $this->_listen_incoming(); @@ -815,14 +815,16 @@ class jabber  			{  				$this->stream_id = $incoming_array['stream:stream']['@']['id']; -				if (!empty($incoming_array['stream:stream']['#']['stream:features'][0]['#']['starttls'][0]['@']['xmlns']) && $incoming_array['stream:stream']['#']['stream:features'][0]['#']['starttls'][0]['@']['xmlns'] == 'urn:ietf:params:xml:ns:xmpp-tls') +				// We only start TLS authentication if not called within TLS authentication itself, which may produce a never ending loop... +				if (!$in_tls)  				{ -					return $this->_starttls(); -				} -				else -				{ -					return true; +					if (!empty($incoming_array['stream:stream']['#']['stream:features'][0]['#']['starttls'][0]['@']['xmlns']) && $incoming_array['stream:stream']['#']['stream:features'][0]['#']['starttls'][0]['@']['xmlns'] == 'urn:ietf:params:xml:ns:xmpp-tls') +					{ +						return $this->_starttls(); +					}  				} + +				return true;  			}  			else  			{ @@ -843,12 +845,21 @@ class jabber  	*/  	function _starttls()  	{ -		if (!function_exists('stream_socket_enable_crypto') || !function_exists('stream_get_meta_data') || !function_exists('socket_set_blocking')) +		if (!function_exists('stream_socket_enable_crypto') || !function_exists('stream_get_meta_data') || !function_exists('socket_set_blocking') || !function_exists('stream_get_wrappers'))  		{  			$this->add_to_log('WARNING: TLS is not available');  			return true;  		} +		// Make sure the encryption stream is supported +		$streams = stream_get_wrappers(); + +		if (!in_array('streams.crypto', $streams)) +		{ +			$this->add_to_log('WARNING: SSL/crypto stream not supported'); +			return true; +		} +  		$this->send_packet("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\n");  		sleep(2);  		$incoming_array = $this->_listen_incoming(); @@ -868,19 +879,21 @@ class jabber  		$meta = stream_get_meta_data($this->connector->active_socket);  		socket_set_blocking($this->connector->active_socket, 1); -		if (!stream_socket_enable_crypto($this->connector->active_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) +		$result = @stream_socket_enable_crypto($this->connector->active_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); +		if (!$result)  		{  			socket_set_blocking($this->connector->active_socket, $meta['blocked']);  			$this->add_to_log('ERROR: _starttls() #3');  			return false;  		} +  		socket_set_blocking($this->connector->active_socket, $meta['blocked']);  		$this->send_packet("<?xml version='1.0' encoding='UTF-8' ?" . ">\n");  		$this->send_packet("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");  		sleep(2); -		if (!$this->_check_connected()) +		if (!$this->_check_connected(true))  		{  			$this->add_to_log('ERROR: _starttls() #4');  			return false; diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 650deb6a0d..b6af4ef12f 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -453,18 +453,18 @@ class messenger  		if (!$use_queue)  		{ -			include_once($phpbb_root_path . 'includes/functions_jabber.'.$phpEx); +			include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);  			$this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], $config['jab_password'], $config['jab_resource']);  			if (!$this->jabber->connect())  			{ -				$this->error('JABBER', 'Could not connect to Jabber server'); +				$this->error('JABBER', 'Could not connect to Jabber server<br />' . $this->jabber->get_log());  				return false;  			}  			if (!$this->jabber->send_auth())  			{ -				$this->error('JABBER', 'Could not authorise on Jabber server'); +				$this->error('JABBER', 'Could not authorise on Jabber server<br />' . $this->jabber->get_log());  				return false;  			}  			$this->jabber->send_presence(NULL, NULL, 'online'); @@ -636,7 +636,7 @@ class queue  						{  							if ($this->jabber->send_message($address, 'normal', NULL, array('body' => $msg)) === false)  							{ -								messenger::error('JABBER', $this->jabber_get_log()); +								messenger::error('JABBER', $this->jabber->get_log());  								continue 3;  							}  						}  | 
