From a85c4ae2f5a37c145a9f587b6760c85527f65596 Mon Sep 17 00:00:00 2001 From: fritzy Date: Wed, 16 Apr 2008 22:46:38 +0000 Subject: [PATCH] * encryption now optional * fixed presence type bugs * fixed more undesirable notice/warnings git-svn-id: svn://netflint.net/xmpphp@21 ef36c318-a008-4979-b6e8-6b496270793b --- xmlstream.php | 8 ++++++-- xmpp.php | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/xmlstream.php b/xmlstream.php index 690c3c3..aae46f0 100644 --- a/xmlstream.php +++ b/xmlstream.php @@ -184,7 +184,11 @@ class XMLStream { xml_parse($this->parser, $buff, False); } } - $payload = $this->until_payload[$event_key]; + if(array_key_exists($event_key, $this->until_payload)) { + $payload = $this->until_payload[$event_key]; + } else { + $payload = array(); + } unset($this->until_payload[$event_key]); return $payload; } @@ -317,7 +321,7 @@ class XMLStream { function send($msg) { #socket_write($this->socket, $msg); $this->log->log("SENT: $msg", LOGGING_VERBOSE); - fwrite($this->socket, $msg); + @fwrite($this->socket, $msg); } function reset() { diff --git a/xmpp.php b/xmpp.php index da56b9c..fcb0904 100644 --- a/xmpp.php +++ b/xmpp.php @@ -46,6 +46,7 @@ class XMPP extends XMLStream { $this->addHandler('message', 'jabber:client', 'message_handler'); $this->addHandler('presence', 'jabber:client', 'presence_handler'); $this->authed = False; + $this->use_encryption = True; } function message_handler($xml) { @@ -68,6 +69,7 @@ class XMPP extends XMLStream { } function presence($status=Null, $show='available', $to=Null) { + $type = ''; $to = htmlspecialchars($to); $status = htmlspecialchars($status); if($show == 'unavailable') $type = 'unavailable'; @@ -86,18 +88,16 @@ class XMPP extends XMLStream { } function presence_handler($xml) { - $payload['type'] = $xml->attrs['type']; - if(!$payload['type']) $payload['type'] = 'available'; - $payload['show'] = $xml->sub('show')->data; - if(!$payload['show']) $payload['show'] = $payload['type']; + $payload['type'] = (isset($xml->attrs['type'])) ? $xml->attrs['type'] : 'available'; + $payload['show'] = (isset($xml->sub('show')->data)) ? $xml->sub('show')->data : $payload['type']; $payload['from'] = $xml->attrs['from']; - $payload['status'] = $xml->sub('status')->data; + $payload['status'] = (isset($xml->sub('status')->data)) ? $xml->sub('status')->data : ''; $this->log->log("Presence: {$payload['from']} [{$payload['show']}] {$payload['status']}", LOGGING_DEBUG); $this->event('presence', $payload); } function features_handler($xml) { - if($xml->hassub('starttls')) { + if($xml->hassub('starttls') and $this->use_encryption) { $this->send(""); } elseif($xml->hassub('bind')) { $id = $this->getId();