writeLog('ERROR', $e->getMessage()); return false; } } function closeSocket() { $this->close($this->_socket); } function disconnect() { $this->_disconnect(); } final function readSocket() { return $this->read(); } final function writeSocket($pData) { return $this->write($pData); } /* * Jabber - Functions */ final function addRoster($pRoster) { if ( !$this->connected ) return "disconnected"; if ( trim($pRoster['uid']) ) { $jid = $pRoster['uid'] . "@" . $this->_server; $newroster = ""; if ( $this->iq('set', "addroster_" . time(), NULL, NULL, "jabber:iq:roster", $newroster) ) { $this->getContacts(); return true; } } return false; } final function addContact($pContact) { $this->addRoster($pContact); $this->subscription($pContact['uid'] . "@" . $this->_server, 'subscribe'); } final function getContacts() { if ( !$this->isConnected() ) return "disconnected"; $this->iq('get', 'contacts', NULL, NULL, 'jabber:iq:roster'); } final function getVcard($pJid) { if ( is_array($pJid) ) { $jid = ( trim($pJid['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pJid['jid']; $vcard = (trim($pJid['jid']) == "this") ? 'vCard_user' : 'vCard'; if ( !$this->connected ) { echo "disconnected"; } else { $this->iq('get', $vcard, $jid, NULL, "vcard-temp", ""); } } else { $this->iq('get', 'vCard', $pJid, NULL, "vcard-temp", ""); } } final function newVcard($NewVcard) { $id = $this->_user; if ( !$this->connected ) echo "disconnected"; else { $this->iq('set', $id, NULL, NULL, "vcard-temp", "".$NewVcard['vcard'].""); echo "OK"; } } final function removeContact($pContact) { if ( !$this->isConnected() ) return "disconnected"; if ( $this->iq('set', 'delroster_' . time(), NULL, NULL, 'jabber:iq:roster',"") ) { $this->getContacts(); return true; } return false; } function allowContact($pRoster) { $this->addRoster($pRoster); $jid = $pRoster['uid'] . "@" . $this->_server; $this->subscription($jid, 'subscribed'); $this->subscription($jid, 'subscribe'); } final function subscription($pTo, $pType = false) { $jid = (is_array($pTo)) ? $pTo['jid'] : $pTo ; $type = (is_array($pTo)) ? $pTo['type'] : $pType ; if ( !$this->connected ) return false; else { $this->writeSocket(""); return true; } } final function setPresence($pPresence = false) { if ( !$this->isConnected() ) return "disconnected"; if ( !$pPresence ) $this->presence(); else { $type = ( isset($pPresence['type']) ) ? $pPresence['type'] : NULL; $to = ( isset($pPresence['to']) ) ? $pPresence['to'] : NULL; $show = ( isset($pPresence['show']) ) ? $pPresence['show'] : NULL; $status = ( isset($pPresence['status']) ) ? $pPresence['status'] : NULL; $priority = ( isset($pPresence['priority']) ) ? $pPresence['priority'] : NULL; $this->presence($type, $to, $show, $status, $priority); } } final function get_last_access_user($pUser = array("jid" => "this")) { $id = "last_time_user"; $jid = ( trim($pUser['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pUser['jid']; $this->iq('get', $id, $jid, NULL, "jabber:iq:last"); } final function setStatus() { $this->setPresence(array("type" => "unavailable")); $this->setPresence(array("type" => "available")); } final function updateContact($pContact) { $jid = $pContact['jid']; $name = $pContact['name']; $group = $pContact['group']; if ( $jid ) { $updatecontact = ""; } $upid = 'updateuser_' . time(); if ( !$this->connected ) echo "disconnected"; else { $this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact); $this->getContacts(); echo "OK"; } } } ?>