* added auto-authorize
git-svn-id: svn://netflint.net/xmpphp@31 ef36c318-a008-4979-b6e8-6b496270793b
This commit is contained in:
parent
a0f0173d55
commit
99f91b0e17
@ -27,7 +27,9 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream {
|
||||
protected $password;
|
||||
protected $resource;
|
||||
protected $fulljid;
|
||||
protected $basejid;
|
||||
protected $authed;
|
||||
public $auto_subscribe = False;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -48,7 +50,8 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream {
|
||||
$this->password = $password;
|
||||
$this->resource = $resource;
|
||||
if(!$server) $server = $host;
|
||||
|
||||
$this->basejid = $this->user . '@' . $this->host;
|
||||
|
||||
$this->stream_start = '<stream:stream to="' . $server . '" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" version="1.0">';
|
||||
$this->stream_end = '</stream:stream>';
|
||||
$this->addHandler('features', 'http://etherx.jabber.org/streams', 'features_handler');
|
||||
@ -63,6 +66,13 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream {
|
||||
$this->use_encryption = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn on auto-authorization of subscription requests.
|
||||
*/
|
||||
public function autoSubscribe() {
|
||||
$this->auto_subscribe = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send XMPP Message
|
||||
*
|
||||
@ -139,7 +149,14 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream {
|
||||
$payload['from'] = $xml->attrs['from'];
|
||||
$payload['status'] = (isset($xml->sub('status')->data)) ? $xml->sub('status')->data : '';
|
||||
$this->log->log("Presence: {$payload['from']} [{$payload['show']}] {$payload['status']}", XMPPHP_Log::LEVEL_DEBUG);
|
||||
$this->event('presence', $payload);
|
||||
if($xml->attrs['type'] == 'subscribe') {
|
||||
if($this->auto_subscribe) $this->send("<presence type='subscribed' to='{$xml->attrs['from']}' from='{$this->basejid}' /><presence type='subscribe' to='{$xml->attrs['from']}' from='{$this->basejid}' />");
|
||||
$this->event('subscription_requested', $payload);
|
||||
} elseif($xml->attrs['type'] == 'subscribed') {
|
||||
$this->event('subscription_accepted', $payload);
|
||||
} else {
|
||||
$this->event('presence', $payload);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user