* 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
This commit is contained in:
parent
2183aed8a5
commit
a85c4ae2f5
@ -184,7 +184,11 @@ class XMLStream {
|
|||||||
xml_parse($this->parser, $buff, False);
|
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]);
|
unset($this->until_payload[$event_key]);
|
||||||
return $payload;
|
return $payload;
|
||||||
}
|
}
|
||||||
@ -317,7 +321,7 @@ class XMLStream {
|
|||||||
function send($msg) {
|
function send($msg) {
|
||||||
#socket_write($this->socket, $msg);
|
#socket_write($this->socket, $msg);
|
||||||
$this->log->log("SENT: $msg", LOGGING_VERBOSE);
|
$this->log->log("SENT: $msg", LOGGING_VERBOSE);
|
||||||
fwrite($this->socket, $msg);
|
@fwrite($this->socket, $msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
|
12
xmpp.php
12
xmpp.php
@ -46,6 +46,7 @@ class XMPP extends XMLStream {
|
|||||||
$this->addHandler('message', 'jabber:client', 'message_handler');
|
$this->addHandler('message', 'jabber:client', 'message_handler');
|
||||||
$this->addHandler('presence', 'jabber:client', 'presence_handler');
|
$this->addHandler('presence', 'jabber:client', 'presence_handler');
|
||||||
$this->authed = False;
|
$this->authed = False;
|
||||||
|
$this->use_encryption = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
function message_handler($xml) {
|
function message_handler($xml) {
|
||||||
@ -68,6 +69,7 @@ class XMPP extends XMLStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function presence($status=Null, $show='available', $to=Null) {
|
function presence($status=Null, $show='available', $to=Null) {
|
||||||
|
$type = '';
|
||||||
$to = htmlspecialchars($to);
|
$to = htmlspecialchars($to);
|
||||||
$status = htmlspecialchars($status);
|
$status = htmlspecialchars($status);
|
||||||
if($show == 'unavailable') $type = 'unavailable';
|
if($show == 'unavailable') $type = 'unavailable';
|
||||||
@ -86,18 +88,16 @@ class XMPP extends XMLStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function presence_handler($xml) {
|
function presence_handler($xml) {
|
||||||
$payload['type'] = $xml->attrs['type'];
|
$payload['type'] = (isset($xml->attrs['type'])) ? $xml->attrs['type'] : 'available';
|
||||||
if(!$payload['type']) $payload['type'] = 'available';
|
$payload['show'] = (isset($xml->sub('show')->data)) ? $xml->sub('show')->data : $payload['type'];
|
||||||
$payload['show'] = $xml->sub('show')->data;
|
|
||||||
if(!$payload['show']) $payload['show'] = $payload['type'];
|
|
||||||
$payload['from'] = $xml->attrs['from'];
|
$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->log->log("Presence: {$payload['from']} [{$payload['show']}] {$payload['status']}", LOGGING_DEBUG);
|
||||||
$this->event('presence', $payload);
|
$this->event('presence', $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
function features_handler($xml) {
|
function features_handler($xml) {
|
||||||
if($xml->hassub('starttls')) {
|
if($xml->hassub('starttls') and $this->use_encryption) {
|
||||||
$this->send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>");
|
$this->send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>");
|
||||||
} elseif($xml->hassub('bind')) {
|
} elseif($xml->hassub('bind')) {
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
Loading…
Reference in New Issue
Block a user