public static function init($jaxl) { // Requires Bosh Session Manager jaxl_require('JAXL0124', $jaxl); $jaxl->action = $_REQUEST['jaxl']; JAXLog::log("[[JaxlAction]] " . $jaxl->action . "\n" . json_encode($_REQUEST), 5, $jaxl); }
public static function sendBody($xml, $jaxl) { $xml = JAXLPlugin::execute('jaxl_pre_curl', $xml, $jaxl); if ($xml != false) { JAXLog::log("[[XMPPSend]] body\n" . $xml, 4, $jaxl); $payload = JAXLUtil::curl($jaxl->bosh['url'], 'POST', $jaxl->bosh['headers'], $xml); $payload = $payload['content']; XMPPGet::handler($payload, $jaxl); } return $xml; }
public static function startAuth($type, $jaxl) { $jaxl->authType = $type; $xml = '<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="' . $type . '">'; switch ($type) { case 'DIGEST-MD5': break; case 'PLAIN': $xml .= base64_encode("" . $jaxl->user . "" . $jaxl->pass); break; case 'ANONYMOUS': break; case 'X-FACEBOOK-PLATFORM': break; case 'CRAM-MD5': break; case 'SCRAM-SHA-1': $xml .= base64_encode("n,,n=" . $jaxl->user . ",r=" . base64_encode(JAXLUtil::generateNonce())); break; default: break; } $xml .= '</auth>'; JAXLog::log("Performing Auth type: " . $type, 0, $jaxl); return self::xml($xml, $jaxl); }
/** * Logs library core and application debug data into the log file * * @param string $log Datum to be logged * @param integer $level Log level for passed datum */ function log($log, $level = 1) { JAXLog::log($log, $level, $this); }
public static function handleForm($payload) { $id = $payload['iq']['@']['id']; $domain = $payload['iq']['@']['from']; $node = $payload['iq']['#']['command'][0]['@']['node']; $sid = $payload['iq']['#']['command'][0]['@']['sessionid']; $status = $payload['iq']['#']['command'][0]['@']['status']; if ($status == "completed") { $callback = self::$buffer[self::$buffer[$id]]['callback']; unset(self::$buffer[self::$buffer[$id]]); unset(self::$buffer[$id]); call_user_func($callback, $payload); } else { if ($status == "executing") { $fields = JAXL0004::getFormField($payload['iq']['#']['command'][0]['#']['x'][0]['#']['field']); foreach ($fields as $key => $field) { switch ($field['var']) { case 'accountjids': $fields[$key]['value'] = self::$buffer[$id]['user']['jid'] . '@' . $domain; break; case 'accountjid': $fields[$key]['value'] = self::$buffer[$id]['user']['jid'] . '@' . $domain; break; case 'password': $fields[$key]['value'] = self::$buffer[$id]['user']['pass']; break; case 'password-verify': $fields[$key]['value'] = self::$buffer[$id]['user']['pass']; break; case 'email': $fields[$key]['value'] = self::$buffer[$id]['user']['email']; break; case 'given_name': $fields[$key]['value'] = self::$buffer[$id]['user']['fname']; break; case 'surname': $fields[$key]['value'] = self::$buffer[$id]['user']['lname']; break; } } $payload = JAXL0004::setFormField($fields, false, false, 'submit'); self::$buffer[self::submitForm($domain, false, $payload, $node, $sid)] = $id; } else { JAXLog::log("Unhandled form status type..."); } } }
public static function iq($arr, $jaxl) { switch ($arr['type']) { case 'result': $id = $arr['id']; JAXLPlugin::execute('jaxl_get_iq_' . $id, $arr, $jaxl); break; case 'get': JAXLPlugin::execute('jaxl_get_iq_get', $arr, $jaxl); break; case 'set': JAXLPlugin::execute('jaxl_get_iq_set', $arr, $jaxl); break; case 'error': JAXLPlugin::execute('jaxl_get_iq_error', $arr, $jaxl); break; default: JAXLog::log('Unhandled iq type ...' . json_encode($arr), 0, $jaxl); break; } return $arr; }
function connect() { if (!$this->stream) { if ($this->stream = @fsockopen($this->host, $this->port, $this->streamENum, $this->streamEStr, $this->streamTimeout)) { JAXLog::log("Socket opened to the jabber host " . $this->host . ":" . $this->port . " ...", 0, $this); stream_set_blocking($this->stream, $this->streamBlocking); stream_set_timeout($this->stream, $this->streamTimeout); } else { JAXLog::log("Unable to open socket to the jabber host " . $this->host . ":" . $this->port . " ...", 0, $this); } } else { JAXLog::log("Socket already opened to the jabber host " . $this->host . ":" . $this->port . " ...", 0, $this); } JAXLPlugin::execute('jaxl_post_connect', false, $this); if ($this->stream) { return true; } else { return false; } }