From 12c44058fdcf603853f6b0f43cba20ff4e424ffd Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sun, 7 Sep 2003 13:51:53 +0000 Subject: Re-add transport and other methods git-svn-id: file:///svn/phpbb/trunk@4475 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_jabber.php | 119 +++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_jabber.php') diff --git a/phpBB/includes/functions_jabber.php b/phpBB/includes/functions_jabber.php index 8059f55589..6ed843878a 100644 --- a/phpBB/includes/functions_jabber.php +++ b/phpBB/includes/functions_jabber.php @@ -135,11 +135,53 @@ class Jabber $this->CONNECTOR->CloseSocket(); } + function CruiseControl($seconds = -1) + { + $count = 0; + + while ($count != $seconds) + { + $this->Listen(); + + do + { + $packet = $this->GetFirstFromQueue(); + + if ($packet) + { + $this->CallHandler($packet); + } + + } + while (count($this->packet_queue) > 1); + + $count += 0.25; + usleep(250000); + + if ($this->last_ping_time != date('H:i')) + { + // Modified by Nathan Fritz + if ($this->returned_keep_alive == FALSE) + { + $this->connected = FALSE; + $this->AddToLog('EVENT: Disconnected'); + } + + $this->returned_keep_alive = FALSE; + $this->keep_alive_id = 'keep_alive_' . time(); + $this->SendPacket("", 'CruiseControl'); + $this->last_ping_time = date("H:i"); + } + } + + return TRUE; + } + function SendAuth() { $this->auth_id = 'auth_' . md5(time() . $_SERVER['REMOTE_ADDR']); - $this->resource = 'Class.Jabber.PHP ' . md5($this->auth_id); +// $this->resource = 'Class.Jabber.PHP ' . md5($this->auth_id); $this->jid = "{$this->username}@{$this->server}/{$this->resource}"; // request available authentication methods @@ -224,6 +266,81 @@ class Jabber return ($this->CONNECTOR->WriteToSocket($xml)) ? TRUE : FALSE; } + // 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\n" : ''; + foreach ($details as $element => $value) + { + $payload .= "<$element>$value\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]['#']; + $this->AddToLog('ERROR: TransportRegistration()'); + } + } + + return $return_code; + } + else + { + return 3; + } + } + function Listen() { unset($incoming); -- cgit v1.2.1