public function __construct($login, $password, $security = SECURITY_NONE, $port = 5222, $host = '') { // Can we use Jabber at all? // Note: Maybe replace with SimpleXML in the future if (!extension_loaded('xml')) { $this->log('Error: No XML functions available, Jabber functions can not operate.'); return false; } //bug in php 5.2.1 renders this stuff more or less useless. if (version_compare(phpversion(), '5.2.1', '>=') && version_compare(phpversion(), '5.2.3RC2', '<') && $security != SECURITY_NONE) { $this->log('Error: PHP ' . phpversion() . ' + SSL is incompatible with jabber, see http://bugs.php.net/41236'); return false; } if (!Jabber::check_jid($login)) { $this->log('Error: Jabber ID is not valid: ' . $login); return false; } // Extract data from user@server.org list($username, $server) = explode('@', $login); // Decide whether or not to use encryption if ($security == SECURITY_SSL && !Jabber::can_use_ssl()) { $this->log('Warning: SSL encryption is not supported (openssl required). Falling back to no encryption.'); $security = SECURITY_NONE; } if ($security == SECURITY_TLS && !Jabber::can_use_tls()) { $this->log('Warning: TLS encryption is not supported (openssl and stream_socket_enable_crypto() required). Falling back to no encryption.'); $security = SECURITY_NONE; } $this->session['security'] = $security; $this->server = $server; $this->user = $username; $this->password = $password; if ($this->open_socket($host != '' ? $host : $server, $port, $security == SECURITY_SSL)) { $this->send("<?xml version='1.0' encoding='UTF-8' ?" . ">\n"); $this->send("<stream:stream to='{$server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n"); } else { return false; } // Now we listen what the server has to say...and give appropriate responses $this->response($this->listen()); }