* 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);
|
||||
}
|
||||
}
|
||||
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() {
|
||||
|
12
xmpp.php
12
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("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>");
|
||||
} elseif($xml->hassub('bind')) {
|
||||
$id = $this->getId();
|
||||
|
Loading…
Reference in New Issue
Block a user