Line 50 | Line 50 |
---|
var $log_array;
var $features = array();
|
var $log_array;
var $features = array();
|
| /** @var string Stream close handshake */ private const STREAM_CLOSE_HANDSHAKE = '</stream:stream>';
|
/** * Constructor
| /** * Constructor
|
Line 58 | Line 61 |
---|
* @param int $port Jabber server port * @param string $username Jabber username or JID * @param string $password Jabber password
|
* @param int $port Jabber server port * @param string $username Jabber username or JID * @param string $password Jabber password
|
* @param boold $use_ssl Use ssl
| * @param bool $use_ssl Use ssl
|
* @param bool $verify_peer Verify SSL certificate * @param bool $verify_peer_name Verify Jabber peer name * @param bool $allow_self_signed Allow self signed certificates
| * @param bool $verify_peer Verify SSL certificate * @param bool $verify_peer_name Verify Jabber peer name * @param bool $allow_self_signed Allow self signed certificates
|
Line 183 | Line 186 |
---|
$this->send_presence('offline', '', true); }
|
$this->send_presence('offline', '', true); }
|
$this->send('</stream:stream>');
| $this->send(self::STREAM_CLOSE_HANDSHAKE); // Check stream close handshake reply $stream_close_reply = $this->listen();
if ($stream_close_reply != self::STREAM_CLOSE_HANDSHAKE) { $this->add_to_log("Error: Unexpected stream close handshake reply ”{$stream_close_reply}”"); }
|
$this->session = array(); return fclose($this->connection); }
| $this->session = array(); return fclose($this->connection); }
|
Line 207 | Line 218 |
---|
*/ function login() {
|
*/ function login() {
|
if (!count($this->features))
| if (empty($this->features))
|
{ $this->add_to_log('Error: No feature information from server available.'); return false;
| { $this->add_to_log('Error: No feature information from server available.'); return false;
|
Line 227 | Line 238 |
---|
if ($this->connected()) { $xml = trim($xml);
|
if ($this->connected()) { $xml = trim($xml);
|
$this->add_to_log('SEND: '. $xml);
| |
return fwrite($this->connection, $xml); } else
| return fwrite($this->connection, $xml); } else
|
Line 338 | Line 348 |
---|
if ($data != '') {
|
if ($data != '') {
|
$this->add_to_log('RECV: '. $data);
| |
return $this->xmlize($data); } else
| return $this->xmlize($data); } else
|
Line 419 | Line 428 |
---|
{ // or even multiple elements of the same type? // array('message' => array(0 => ..., 1 => ...))
|
{ // or even multiple elements of the same type? // array('message' => array(0 => ..., 1 => ...))
|
if (count(reset($xml)) > 1)
| if (is_array(reset($xml)) && count(reset($xml)) > 1)
|
{ foreach (reset($xml) as $value) {
| { foreach (reset($xml) as $value) {
|
Line 445 | Line 454 |
---|
}
$second_time = isset($this->session['id']);
|
}
$second_time = isset($this->session['id']);
|
$this->session['id'] = $xml['stream:stream'][0]['@']['id'];
| $this->session['id'] = isset($xml['stream:stream'][0]['@']['id']) ? $xml['stream:stream'][0]['@']['id'] : '';
|
if ($second_time) {
| if ($second_time) {
|
Line 701 | Line 710 |
---|
default: // hm...don't know this response
|
default: // hm...don't know this response
|
$this->add_to_log('Notice: Unknown server response (' . key($xml) . ')');
| $this->add_to_log('Notice: Unknown server response');
|
return false; break; }
| return false; break; }
|