public static function ping($jaxl, $to, $from, $callback) { if ($jaxl->auth) { $payload = "<ping xmlns='urn:xmpp:ping'/>"; return XMPPSend::iq($jaxl, 'get', $payload, $to, $from, $callback); } }
public static function submitSearchRequest($jaxl, $field, $callback) { $payload = '<query xmlns="' . self::$ns . '">'; $payload .= $field; $payload .= '</query>'; return XMPPSend::iq($jaxl, 'set', false, false, $callback); }
public static function handshake($id, $jaxl) { $pass = JAXLPlugin::execute('jaxl_pre_handshake'); $hash = strtolower(sha1($id . $pass)); $xml = '<handshake>' . $hash . '</handshake>'; XMPPSend::xml($xml, $jaxl); }
public static function getXML($jaxl, $xml, $callback) { $payload = '<query xmlns="' . self::$ns . '">'; $payload .= $xml; $payload .= '</query>'; return XMPPSend::iq($jaxl, 'get', $payload, false, false, $callback); }
public static function register($jaxl, $from, $to, $callback, $fields) { $payload = '<query xmlns="' . self::$ns . '">'; foreach ($fields as $field => $value) { $payload .= '<' . $field . '>' . $value . '</' . $field . '>'; } $payload .= '</query>'; return XMPPSend::iq($jaxl, 'set', $payload, $to, $from, $callback); }
public static function handleIq($payload, $jaxl) { if ($payload['time'] == self::$ns) { $entityTime = '<time xmlns="' . self::$ns . '">'; $entityTime .= '<tzo>' . date('P') . '</tzo>'; $entityTime .= '<utc>' . date('Y-m-d') . 'T' . date('H:i:s') . 'Z</utc>'; $entityTime .= '</time>'; return XMPPSend::iq('result', $entityTime, $payload['from'], $payload['to'], false, $jaxl); } }
public static function handleMessage($payloads, $jaxl) { foreach ($payloads as $payload) { if ($payload['request'] == self::$ns) { $child = array(); $child['payload'] = '<received xmlns="' . self::$ns . '" id="' . $payload['id'] . '"/>'; XMPPSend::message($jaxl, $payload['from'], $payload['to'], $child, false, false); } } return $payloads; }
public static function getIq($arr) { if (isset($arr['queryXmlns']) && $arr['queryXmlns'] == self::$ns) { $payload = ''; $payload .= '<query xmlns="' . self::$ns . '" seconds="0">'; $payload .= '</query>'; return XMPPSend::iq('result', $payload, $arr['from'], $arr['to'], FALSE, $arr['id']); } else { return $arr; } }
public static function invite($toJid, $fromJid, $roomJid, $roomPass = false, $reason = false, $jaxl) { $child = array(); $child['payload'] = ''; $child['payload'] .= '<x xmlns="' . self::$ns . '"'; $child['payload'] .= ' jid="' . $roomJid . '"'; if ($roomPass) { $child['payload'] .= ' password="******"'; } if ($reason) { $child['payload'] .= ' reason="' . $reason . '"'; } $child['payload'] .= '/>'; XMPPSend::message($toJid, $fromJid, $child, 'chat', $jaxl, false); }
public static function updateAffiliation($jaxl, $to, $from, $node, $jid, $affiliation) { if (!is_array($jid) && !is_array($affiliation)) { $jid[] = $jid; $affiliation[] = $affiliation; } $payload = ''; $payload .= '<pubsub xmlns="' . self::$ns . '">'; $payload .= '<affiliations node="' . $node . '">'; foreach ($jid as $k => $v) { $payload .= '<affiliation jid="' . $jid[$k] . '" affiliation="' . $affiliation[$k] . '"/>'; } $payload .= '</affiliations>'; $payload .= '</pubsub>'; return XMPPSend::iq($jaxl, 'set', $payload, $to, $from, $callback); }
public static function success($arr, $jaxl) { if ($arr['xmlns'] == "urn:ietf:params:xml:ns:xmpp-sasl") { if ($jaxl->mode == "cgi") { JAXL0206::restartStream($jaxl); } else { XMPPSend::startStream($jaxl); } } }
public static function transferFile($payload, $jaxl) { if (!isset(self::$id[$payload['id']])) { return $payload; } // iq id buffered for file transfer, transmit data $fp = fopen(self::$id[$payload['id']]['file'], 'r'); fseek($fp, self::$id[$payload['id']]['seq'] * self::$id[$payload['id']]['block-size']); $data = fread($fp, self::$id[$payload['id']]['block-size']); fclose($fp); if (self::$id[$payload['id']]['seq'] == -1) { $jaxl->log("[[JAXL0047]] File transfer complete for siId " . self::$id[$payload['id']]['siId']); $jaxl->executePlugin('jaxl_post_file_transfer', self::$id[$payload['id']]); unset(self::$id[$payload['id']]); return; } else { if (strlen($data) == 0) { $jaxl->log("[[JAXL0047]] File transfer closed for siId " . self::$id[$payload['id']]['siId']); $xml = '<close xmlns="' . self::$ns . '" sid="' . self::$id[$payload['id']]['siId'] . '"/>'; $id = XMPPSend::iq($jaxl, 'set', $xml, self::$id[$payload['id']]['to'], false, array('JAXL0047', 'transferFile')); self::$id[$id] = self::$id[$payload['id']]; self::$id[$id]['seq'] = -1; unset(self::$id[$payload['id']]); return $id; } else { $jaxl->log("[[JAXL0047]] Transfering file data for seq " . self::$id[$payload['id']]['seq'] . " for siId " . self::$id[$payload['id']]['siId']); $xml = '<data xmlns="' . self::$ns . '" seq="' . self::$id[$payload['id']]['seq'] . '" sid="' . self::$id[$payload['id']]['siId'] . '">'; $xml .= base64_encode($data); $xml .= '</data>'; $id = XMPPSend::iq($jaxl, 'set', $xml, self::$id[$payload['id']]['to'], false, array('JAXL0047', 'transferFile')); self::$id[$id] = self::$id[$payload['id']]; self::$id[$id]['seq'] = self::$id[$id]['seq'] + 1; unset(self::$id[$payload['id']]); return $id; } } }
/** * Send an XMPP iq stanza * * @param string $type Type of iq stanza to send * @param string $payload (Optional) XML string to be transmitted * @param string $to (Optional) JID to whom this iq stanza should be send * @param string $from (Optional) JID from whom this presence stanza should originate * @param string|array $callback (Optional) Callback method which will handle "result" type stanza rcved * @param integer $id (Optional) Add an id attribute to transmitted stanza (auto-generated if not provided) */ function sendIQ($type, $payload = false, $to = false, $from = false, $callback = false, $id = false) { return XMPPSend::iq($this, $type, $payload, $to, $from, $callback, $id); }
public static function activateS5B($streamHost, $sid, $tJid, $jaxl) { $xml = '<query xmlns="' . self::$ns . '" sid="' . $sid . '">'; $xml .= '<activate>' . $tJid . '</activate>'; $xml .= '</query>'; return XMPPSend::iq($jaxl, 'set', $xml, $streamHost, false, array('JAXL0065', 'transferFile')); }
public static function executeCommand($to, $from, $node, $callback, $jaxl) { $payload = '<command xmlns="' . self::$ns . '" node="' . $node . '" action="execute"/>'; return XMPPSend::iq('set', $payload, $to, $from, $callback, $jaxl); }
/** * Perform pre-choosen auth type for the Jaxl instance */ function doAuth($mechanism) { return XMPPSend::startAuth($this); }
public static function ping($jaxl) { $xml = ''; $xml .= '<body rid="' . ++$jaxl->bosh['rid'] . '"'; $xml .= ' sid="' . $jaxl->bosh['sid'] . '"'; $xml .= ' xmlns="http://jabber.org/protocol/httpbind"/>'; $_SESSION['auth'] = true; XMPPSend::xml($xml, $jaxl); }
public static function setDefaultList($jaxl, $list, $callback) { $payload = '<query xmlns="' . self::$ns . '">'; if ($list) { $payload .= '<default name="' . $list . '"/>'; } else { $payload .= '<default/>'; } $payload .= '</query>'; return XMPPSend::iq($jaxl, 'set', false, false, $callback); }
public static function unblockAll($jaxl, $callback) { $payload = '<unblock xmlns="' . self::$ns . '"/>'; return XMPPSend::iq($jaxl, 'set', $payload, false, false, $callback); }
public static function removeAdminPrivileges($jaxl, $fromJid, $toJid, $roomJid, $reason = false, $callback = false) { $payload = '<query xmlns="' . self::$ns . '#admin">'; $payload .= '<item affiliation="member" jid="' . $toJid . '">'; if ($reason) { $payload .= '<reason>' . $reason . '</reason>'; } $payload .= '</item>'; $payload .= '</query>'; return XMPPSend::iq($jaxl, "set", $payload, $roomJid, $fromJid, $callback); }
protected static function submitForm($to, $from, $payload, $node, $sid, $jaxl) { $payload = '<command xmlns="http://jabber.org/protocol/commands" node="' . $node . '" sessionid="' . $sid . '">' . $payload . '</command>'; return XMPPSend::iq('set', $payload, $to, $from, array('JAXL0133', 'handleForm'), $jaxl); }
public static function accept($jaxl, $to, $id, $payload) { $payload = '<si xmlns="' . self::$ns . '">' . $payload . '</si>'; return XMPPSend::iq($jaxl, 'result', $payload, $to, false, false, $id); }
/** * Bind connected Jaxl instance to a resource */ function startBind() { return XMPPSend::startBind($this, array('XMPPGet', 'postBind')); }
public static function getVersion($jaxl, $fromJid, $toJid, $callback) { $payload = '<query xmlns="' . self::$ns . '">'; return XMPPSend::iq($jaxl, 'get', $payload, $fromJid, $toJid, $callback); }
public static function ping($to, $from, $callback, $jaxl) { $payload = "<ping xmlns='urn:xmpp:ping'/>"; return XMPPSend::iq('get', $payload, $to, $from, $callback, $jaxl); }
public static function sendInfoMessage($jaxl, $to, $payload, $sid, $initiator, $callback) { $xml = self::getJingleElement($payload, 'session-info', $sid, $initiator); return XMPPSend::iq($jaxl, 'set', $xml, $to, false, $callback); }
public static function handleIq($payload, $jaxl) { if ($payload['queryXmlns'] == self::$ns['info']) { $xml = '<query xmlns="' . $payload['queryXmlns'] . '"'; if (isset($payload['queryNode'])) { $xml .= ' node="' . $payload['queryNode'] . '"'; } $xml .= '>'; $xml .= '<identity xml:lang="' . $jaxl->lang . '"'; $xml .= ' name="' . $jaxl->getName() . '"'; $xml .= ' category="' . $jaxl->category . '"'; $xml .= ' type="' . $jaxl->type . '"/>'; foreach ($jaxl->features as $feature) { $xml .= '<feature var="' . $feature . '"/>'; } $xml .= '</query>'; XMPPSend::iq($jaxl, 'result', $xml, $payload['from'], $payload['to'], false, $payload['id']); } else { if ($payload['queryXmlns'] == self::$ns['items']) { } } return $payload; }
function sendPresence($to, $from, $child, $type) { XMPPSend::presence($to, $from, $child, $type, $this); }
public static function getVCard($jaxl, $to, $from, $callback) { $payload = '<vCard xmlns="' . self::$ns . '"/>'; return XMPPSend::iq($jaxl, 'get', $payload, $to, $from, $callback); }
function startBind() { $payload = ''; $payload .= '<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">'; $payload .= '<resource>' . $this->resource . '</resource>'; $payload .= '</bind>'; return XMPPSend::iq("set", $payload, false, false, array('XMPPGet', 'postBind'), $this); }