Removed duplicate methods, tidied some code

git-svn-id: file:///svn/phpbb/trunk@4554 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2003-10-11 23:52:46 +00:00
parent dd39be7f51
commit 19f03aa6b7

View file

@ -181,7 +181,6 @@ class Jabber
{
$this->auth_id = 'auth_' . md5(time() . $_SERVER['REMOTE_ADDR']);
// $this->resource = 'Class.Jabber.PHP ' . md5($this->auth_id);
$this->jid = "{$this->username}@{$this->server}/{$this->resource}";
// request available authentication methods
@ -190,20 +189,20 @@ class Jabber
// was a result returned?
if ($this->GetInfoFromIqType($packet) == 'result' && $this->GetInfoFromIqId($packet) == $this->auth_id)
{
if (@function_exists('mhash') && isset($packet['iq']['#']['query'][0]['#']['sequence'][0]['#']) && isset($packet['iq']['#']['query'][0]['#']['token'][0]['#']))
{
// auth_0k
if (@function_exists(mhash) && isset($packet['iq']['#']['query'][0]['#']['sequence'][0]["#"]) && isset($packet['iq']['#']['query'][0]['#']['token'][0]["#"]))
{
return $this->_sendauth_0k($packet['iq']['#']['query'][0]['#']['token'][0]["#"], $packet['iq']['#']['query'][0]['#']['sequence'][0]["#"]);
return $this->_sendauth_0k($packet['iq']['#']['query'][0]['#']['token'][0]['#'], $packet['iq']['#']['query'][0]['#']['sequence'][0]['#']);
}
// digest
elseif (@function_exists(mhash) && isset($packet['iq']['#']['query'][0]['#']['digest']))
elseif (@function_exists('mhash') && isset($packet['iq']['#']['query'][0]['#']['digest']))
{
// digest
return $this->_sendauth_digest();
}
// plain text
elseif ($packet['iq']['#']['query'][0]['#']['password'])
{
// plain text
return $this->_sendauth_plaintext();
}
}
@ -536,79 +535,6 @@ class Jabber
}
}
// get the transport registration fields
// method written by Steve Blinch, http://www.blitzaffe.com
function TransportRegistrationDetails($transport)
{
$this->txnid++;
$packet = $this->SendIq($transport, 'get', "reg_{$this->txnid}", 'jabber:iq:register', NULL, $this->jid);
if ($packet)
{
$res = array();
foreach ($packet['iq']['#']['query'][0]['#'] as $element => $data)
{
if ($element != 'instructions' && $element != 'key')
{
$res[] = $element;
}
}
return $res;
}
else
{
return 3;
}
}
// register with the transport
// method written by Steve Blinch, http://www.blitzaffe.com
function TransportRegistration($transport, $details)
{
$this->txnid++;
$packet = $this->SendIq($transport, 'get', "reg_{$this->txnid}", 'jabber:iq:register', NULL, $this->jid);
if ($packet)
{
$key = $this->GetInfoFromIqKey($packet); // just in case a key was passed back from the server
unset($packet);
$payload = ($key) ? "<key>$key</key>\n" : '';
foreach ($details as $element => $value)
{
$payload .= "<$element>$value</$element>\n";
}
$packet = $this->SendIq($transport, 'set', "reg_{$this->txnid}", 'jabber:iq:register', $payload);
if ($this->GetInfoFromIqType($packet) == 'result')
{
if (isset($packet['iq']['#']['query'][0]['#']['registered'][0]['#']))
{
$return_code = 1;
}
else
{
$return_code = 2;
}
}
elseif ($this->GetInfoFromIqType($packet) == 'error')
{
if (isset($packet['iq']['#']['error'][0]['#']))
{
$return_code = "Error " . $packet['iq']['#']['error'][0]['@']['code'] . ': ' . $packet['iq']['#']['error'][0]['#'];
}
}
return $return_code;
}
else
{
return 3;
}
}
// ======================================================================
// private methods