phpBB

Code Changes

File: includes/functions_jabber.php

  Unmodified   Added   Modified   Removed
Line 20Line 20
*
* Jabber class from Flyspray project
*

*
* Jabber class from Flyspray project
*

* @version class.jabber2.php 1488 2007-11-25

* @version class.jabber2.php 1595 2008-09-19 (0.9.9)

* @copyright 2006 Flyspray.org
* @author Florian Schmitz (floele)
*

* @copyright 2006 Flyspray.org
* @author Florian Schmitz (floele)
*

Line 35Line 35
	var $timeout = 10;

var $server;

	var $timeout = 10;

var $server;

 
	var $connect_server;

	var $port;
var $username;
var $password;

	var $port;
var $username;
var $password;

Line 50Line 51
	*/
function jabber($server, $port, $username, $password, $use_ssl = false)
{

	*/
function jabber($server, $port, $username, $password, $use_ssl = false)
{

		$this->server				= ($server) ? $server : 'localhost';

		$this->connect_server		= ($server) ? $server : 'localhost';

		$this->port					= ($port) ? $port : 5222;

		$this->port					= ($port) ? $port : 5222;

		$this->username				= $username;
















// Get the server and the username
if (strpos($username, '@') === false)
{
$this->server = $this->connect_server;
$this->username = $username;
}
else
{
$jid = explode('@', $username, 2);

$this->username = $jid[0];
$this->server = $jid[1];
}


		$this->password				= $password;
$this->use_ssl = ($use_ssl && $this->can_use_ssl()) ? true : false;


		$this->password				= $password;
$this->use_ssl = ($use_ssl && $this->can_use_ssl()) ? true : false;


Line 123Line 138

$this->session['ssl'] = $this->use_ssl;



$this->session['ssl'] = $this->use_ssl;


		if ($this->open_socket($this->server, $this->port, $this->use_ssl))

		if ($this->open_socket($this->connect_server, $this->port, $this->use_ssl))

		{
$this->send("<?xml version='1.0' encoding='UTF-8' ?" . ">\n");
$this->send("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");

		{
$this->send("<?xml version='1.0' encoding='UTF-8' ?" . ">\n");
$this->send("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");

Line 235Line 250
			return true;
}


			return true;
}


		// Apparently an error occured...

		// Apparently an error occurred...

		$this->add_to_log('Error: open_socket() - ' . $errorstr);
return false;
}

		$this->add_to_log('Error: open_socket() - ' . $errorstr);
return false;
}

Line 399Line 414
				$second_time = isset($this->session['id']);
$this->session['id'] = $xml['stream:stream'][0]['@']['id'];


				$second_time = isset($this->session['id']);
$this->session['id'] = $xml['stream:stream'][0]['@']['id'];


				/** Currently commented out due to problems with some jabber server - reason unknown

 
				if ($second_time)
{
// If we are here for the second time after TLS, we need to continue logging in

				if ($second_time)
{
// If we are here for the second time after TLS, we need to continue logging in

					$this->login();
return;
}*/

					return $this->login();
}



// go on with authentication?
if (isset($this->features['stream:features'][0]['#']['bind']) || !empty($this->session['tls']))


// go on with authentication?
if (isset($this->features['stream:features'][0]['#']['bind']) || !empty($this->session['tls']))

Line 463Line 476
					}
else if (in_array('PLAIN', $methods) && ($this->session['ssl'] || !empty($this->session['tls'])))
{

					}
else if (in_array('PLAIN', $methods) && ($this->session['ssl'] || !empty($this->session['tls'])))
{

 
						// http://www.ietf.org/rfc/rfc4616.txt (PLAIN SASL Mechanism)

						$this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>"

						$this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>"

							. base64_encode(chr(0) . $this->username . '@' . $this->server . chr(0) . $this->password) .

							. base64_encode($this->username . '@' . $this->server . chr(0) . $this->username . chr(0) . $this->password) .

							'</auth>');
}
else if (in_array('ANONYMOUS', $methods))

							'</auth>');
}
else if (in_array('ANONYMOUS', $methods))

Line 501Line 515
				}

// better generate a cnonce, maybe it's needed

				}

// better generate a cnonce, maybe it's needed

				$str = '';
mt_srand((double)microtime()*10000000);

for ($i = 0; $i < 32; $i++)
{
$str .= chr(mt_rand(0, 255));
}
$decoded['cnonce'] = base64_encode($str);

				$decoded['cnonce'] = base64_encode(md5(uniqid(mt_rand(), true)));









// second challenge?
if (isset($decoded['rspauth']))


// second challenge?
if (isset($decoded['rspauth']))