コード例 #1
0
ファイル: Avatar.php プロジェクト: movim/moxl
 static function setMetadata($data)
 {
     $decoded = base64_decode($data);
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $pubsub = $dom->createElement('pubsub');
     $pubsub->setAttribute('xmlns', 'http://jabber.org/protocol/pubsub');
     $publish = $dom->createElement('publish');
     $publish->setAttribute('node', 'urn:xmpp:avatar:metadata');
     $pubsub->appendChild($publish);
     $item = $dom->createElement('item');
     $item->setAttribute('id', sha1($decoded));
     $publish->appendChild($item);
     $metadata = $dom->createElement('metadata');
     $metadata->setAttribute('xmlns', 'http://jabber.org/protocol/pubsub');
     $item->appendChild($metadata);
     $info = $dom->createElement('info');
     $info->setAttribute('height', '410');
     $info->setAttribute('width', '410');
     $info->setAttribute('type', 'image/jpeg');
     $info->setAttribute('id', sha1($decoded));
     $info->setAttribute('bytes', strlen($decoded));
     $metadata->appendChild($info);
     $xml = \Moxl\API::iqWrapper($pubsub, false, 'set');
     \Moxl\API::request($xml);
 }
コード例 #2
0
ファイル: Carbons.php プロジェクト: Hywan/moxl
 static function disable()
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $xml = $dom->createElementNS('urn:xmpp:carbons:2', 'disable');
     $xml = \Moxl\API::iqWrapper($xml, false, 'set');
     \Moxl\API::request($xml);
 }
コード例 #3
0
ファイル: Vcard.php プロジェクト: Hywan/moxl
 static function set($data)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $vcard = $dom->createElementNS('vcard-temp', 'vCard');
     $vcard->appendChild($dom->createElement('FN', $data->fn->value));
     $vcard->appendChild($dom->createElement('NICKNAME', $data->name->value));
     $vcard->appendChild($dom->createElement('URL', $data->url->value));
     $vcard->appendChild($dom->createElement('BDAY', $data->date->value));
     $email = $dom->createElement('EMAIL');
     $email->appendChild($dom->createElement('USERID', $data->email->value));
     $vcard->appendChild($email);
     $adr = $dom->createElement('ADR');
     $adr->appendChild($dom->createElement('LOCALITY', $data->locality->value));
     $adr->appendChild($dom->createElement('PCODE', $data->postalcode->value));
     $adr->appendChild($dom->createElement('CTRY', $data->country->value));
     $vcard->appendChild($adr);
     $vcard->appendChild($dom->createElement('DESC', $data->desc->value));
     $vcard->appendChild($dom->createElement('X-GENDER', $data->gender->value));
     $marital = $dom->createElement('MARITAL');
     $marital->appendChild($dom->createElement('STATUS', $data->marital->value));
     $vcard->appendChild($marital);
     $photo = $dom->createElement('PHOTO');
     $photo->appendChild($dom->createElement('TYPE', $data->phototype->value));
     $photo->appendChild($dom->createElement('BINVAL', $data->photobin->value));
     $vcard->appendChild($photo);
     $xml = \Moxl\API::iqWrapper($vcard, false, 'set');
     \Moxl\API::request($xml);
 }
コード例 #4
0
ファイル: Message.php プロジェクト: Hywan/moxl
 static function maker($to, $content = false, $html = false, $type = 'chat', $chatstates = false, $receipts = false)
 {
     $session = \Sessionx::start();
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $root = $dom->createElementNS('jabber:client', 'message');
     $dom->appendChild($root);
     $root->setAttribute('to', str_replace(' ', '\\40', $to));
     $root->setAttribute('id', $session->id);
     $root->setAttribute('type', $type);
     if ($content != false) {
         $body = $dom->createElement('body', $content);
         $root->appendChild($body);
     }
     if ($html != false) {
         $xhtml = $dom->createElementNS('http://jabber.org/protocol/xhtml-im', 'html');
         $body = $dom->createElement('http://www.w3.org/1999/xhtml', 'body', $html);
         $xhtml->appendChild($body);
         $root->appendChild($xhtml);
     }
     if ($chatstates != false) {
         $chatstate = $dom->createElementNS('http://jabber.org/protocol/chatstates', $chatstates);
         $root->appendChild($chatstate);
     }
     if ($receipts != false) {
         if ($receipts == 'request') {
             $request = $dom->createElement('request');
         } else {
             $request = $dom->createElement('received');
             $request->setAttribute('id', $receipts);
         }
         $request->setAttribute('xmlns', 'urn:xmpp:receipts');
         $root->appendChild($request);
     }
     \Moxl\API::request($dom->saveXML($dom->documentElement));
 }
コード例 #5
0
ファイル: Location.php プロジェクト: Hywan/moxl
 static function publish($to, $geo)
 {
     $xml = '
         <pubsub xmlns="http://jabber.org/protocol/pubsub">
             <publish node="http://jabber.org/protocol/geoloc">
                 <item>
                     <geoloc xmlns="http://jabber.org/protocol/geoloc">
                         <lat>' . $geo['latitude'] . '</lat>
                         <lon>' . $geo['longitude'] . '</lon>
                         <altitude>' . $geo['altitude'] . '</altitude>
                         <country>' . $geo['country'] . '</country>
                         <countrycode>' . $geo['countrycode'] . '</countrycode>
                         <region>' . $geo['region'] . '</region>
                         <postalcode>' . $geo['postalcode'] . '</postalcode>
                         <locality>' . $geo['locality'] . '</locality>
                         <street>' . $geo['street'] . '</street>
                         <building>' . $geo['building'] . '</building>
                         <text>' . $geo['text'] . '</text>
                         <uri>' . $geo['uri'] . '</uri>
                         <timestamp>' . date('c') . '</timestamp>
                     </geoloc>
                 </item>
             </publish>
         </pubsub>';
     $xml = \Moxl\API::iqWrapper($xml, $to, 'set');
     \Moxl\API::request($xml);
 }
コード例 #6
0
ファイル: Vcard4.php プロジェクト: Hywan/moxl
 static function set($data)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');
     $publish = $dom->createElement('publish');
     $publish->setAttribute('node', 'urn:xmpp:vcard4');
     $pubsub->appendChild($publish);
     $item = $dom->createElement('item');
     $item->setAttribute('id', 'current');
     $publish->appendChild($item);
     $vcard = $dom->createElementNS('urn:ietf:params:xml:ns:vcard-4.0', 'vcard');
     $item->appendChild($vcard);
     $fn = $dom->createElement('fn');
     $fn->appendChild($dom->createElement('text', $data->fn));
     $vcard->appendChild($fn);
     $nickname = $dom->createElement('nickname');
     $nickname->appendChild($dom->createElement('text', $data->name));
     $vcard->appendChild($nickname);
     $bday = $dom->createElement('bday');
     $bday->appendChild($dom->createElement('date', $data->date));
     $vcard->appendChild($bday);
     $url = $dom->createElement('url');
     $url->appendChild($dom->createElement('uri', $data->url));
     $vcard->appendChild($url);
     $note = $dom->createElement('note');
     $note->appendChild($dom->createElement('text', $data->description));
     $vcard->appendChild($note);
     $gender = $dom->createElement('gender');
     $sex = $dom->createElement('sex');
     $gender->appendChild($sex);
     $sex->appendChild($dom->createElement('text', $data->gender));
     $vcard->appendChild($gender);
     $marital = $dom->createElement('marital');
     $status = $dom->createElement('status');
     $marital->appendChild($status);
     $status->appendChild($dom->createElement('text', $data->marital));
     $vcard->appendChild($marital);
     $impp = $dom->createElement('impp');
     $impp->appendChild($dom->createElement('uri', 'xmpp:' . $data->jid));
     if ($data->twitter) {
         $impp->appendChild($dom->createElement('uri', 'twitter:' . $data->twitter));
     }
     if ($data->yahoo) {
         $impp->appendChild($dom->createElement('uri', 'ymsgr:' . $data->yahoo));
     }
     if ($data->skype) {
         $impp->appendChild($dom->createElement('uri', 'skype:' . $data->skype));
     }
     $vcard->appendChild($impp);
     $email = $dom->createElement('email');
     $email->appendChild($dom->createElement('text', $data->email));
     $vcard->appendChild($email);
     $adr = $dom->createElement('adr');
     $adr->appendChild($dom->createElement('locality', $data->adrlocality));
     $adr->appendChild($dom->createElement('code', $data->adrpostalcode));
     $adr->appendChild($dom->createElement('country', $data->adrcountry));
     $vcard->appendChild($adr);
     $xml = \Moxl\API::iqWrapper($pubsub, false, 'set');
     \Moxl\API::request($xml);
 }
コード例 #7
0
ファイル: Stream.php プロジェクト: Hywan/moxl
 static function sessionStart($to)
 {
     $dom = new \DOMDocument('1.0', 'utf-8');
     $session = $dom->createElementNS('urn:ietf:params:xml:ns:xmpp-session', 'session');
     $xml = \Moxl\API::iqWrapper($session, $to, 'set');
     \Moxl\API::request($xml);
 }
コード例 #8
0
ファイル: MAM.php プロジェクト: Hywan/moxl
 static function get($jid, $start = false, $end = false, $limit = false)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $query = $dom->createElementNS('urn:xmpp:mam:0', 'query');
     $x = $dom->createElementNS('jabber:x:data', 'x');
     $query->appendChild($x);
     $field_type = $dom->createElement('field');
     $field_type->setAttribute('var', 'FORM_TYPE');
     $field_type->appendChild($dom->createElement('value', 'urn:xmpp:mam:0'));
     $x->appendChild($field_type);
     $field_with = $dom->createElement('field');
     $field_with->setAttribute('var', 'with');
     $field_with->appendChild($dom->createElement('value', $jid));
     $x->appendChild($field_with);
     if ($start) {
         $field_start = $dom->createElement('field');
         $field_start->setAttribute('var', 'start');
         $field_start->appendChild($dom->createElement('value', date('Y-m-d\\TH:i:s\\Z', $start + 1)));
         $x->appendChild($field_start);
     }
     if ($end) {
         $field_end = $dom->createElement('field');
         $field_end->setAttribute('var', 'end');
         $field_end->appendChild($dom->createElement('value', date('Y-m-d\\TH:i:s\\Z', $end + 1)));
         $x->appendChild($field_end);
     }
     if ($limit) {
         $field_limit = $dom->createElement('field');
         $field_limit->setAttribute('var', 'limit');
         $field_limit->appendChild($dom->createElement($limit));
         $x->appendChild($field_limit);
     }
     $xml = \Moxl\API::iqWrapper($query, null, 'set');
     \Moxl\API::request($xml);
 }
コード例 #9
0
ファイル: Roster.php プロジェクト: Hywan/moxl
 static function remove($to)
 {
     $xml = '
         <item jid="' . $to . '" subscription="remove"/>';
     $xml = self::builder($xml, false, 'set');
     \Moxl\API::request($xml);
 }
コード例 #10
0
ファイル: PubsubSubscription.php プロジェクト: movim/moxl
 static function listGetOwned()
 {
     $xml = '<pubsub xmlns="http://jabber.org/protocol/pubsub">
             <affiliations/>
         </pubsub>';
     $xml = \Moxl\API::iqWrapper($xml, false, 'get');
     \Moxl\API::request($xml);
 }
コード例 #11
0
ファイル: Storage.php プロジェクト: Hywan/moxl
 static function get($xmlns)
 {
     $dom = new \DOMDocument('1.0', 'utf-8');
     $query = $dom->createElementNS('jabber:iq:private', 'query');
     $data = $dom->createElementNS($xmlns, 'data');
     $query->appendchild($data);
     $xml = \Moxl\API::iqWrapper($query, false, 'get');
     \Moxl\API::request($xml);
 }
コード例 #12
0
ファイル: BOB.php プロジェクト: movim/moxl
 static function answer($to, $id, $cid, $type, $base64)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $data = $dom->createElementNS('urn:xmpp:bob', 'data', $base64);
     $data->setAttribute('cid', $cid);
     $data->setAttribute('type', $type);
     $data->setAttribute('max-age', '86400');
     \Moxl\API::request(\Moxl\API::iqWrapper($data, $to, 'result', $id));
 }
コード例 #13
0
ファイル: Register.php プロジェクト: Hywan/moxl
 static function changePassword($to, $username, $password)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $query = $dom->createElementNS('jabber:iq:register', 'query');
     $query->appendChild($dom->createElement('username', $username));
     $query->appendChild($dom->createElement('password', $password));
     $xml = \Moxl\API::iqWrapper($query, $to, 'set');
     \Moxl\API::request($xml);
 }
コード例 #14
0
ファイル: Version.php プロジェクト: Hywan/moxl
 static function send($to, $id, $name, $version, $os)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $query = $dom->createElementNS('jabber:iq:version', 'query');
     $query->appendChild($dom->createElement('name', $name));
     $query->appendChild($dom->createElement('version', $version));
     $query->appendChild($dom->createElement('os', $os));
     $xml = \Moxl\API::iqWrapper($query, $to, 'result', $id);
     \Moxl\API::request($xml);
 }
コード例 #15
0
ファイル: Upload.php プロジェクト: Hywan/moxl
 static function request($to, $name, $size, $type)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $request = $dom->createElementNS('urn:xmpp:http:upload', 'request');
     $request->appendChild($dom->createElement('filename', $name));
     $request->appendChild($dom->createElement('size', $size));
     $request->appendChild($dom->createElement('content-type', $type));
     $xml = \Moxl\API::iqWrapper($request, $to, 'get');
     \Moxl\API::request($xml);
 }
コード例 #16
0
ファイル: Disco.php プロジェクト: Hywan/moxl
 static function items($to, $node = false)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $query = $dom->createElementNS('http://jabber.org/protocol/disco#items', 'query');
     if ($node != false) {
         $query->setAttribute('node', $node);
     }
     $xml = \Moxl\API::iqWrapper($query, $to, 'get');
     \Moxl\API::request($xml);
 }
コード例 #17
0
ファイル: Roster.php プロジェクト: movim/moxl
 static function remove($to)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $roster = $dom->createElementNS('jabber:iq:roster', 'query');
     $item = $dom->createElement('item');
     $item->setAttribute('jid', $to);
     $item->setAttribute('subscription', 'remove');
     $roster->appendChild($item);
     $xml = \Moxl\API::iqWrapper($roster, false, 'set');
     \Moxl\API::request($xml);
 }
コード例 #18
0
ファイル: Jingle.php プロジェクト: Hywan/moxl
 static function sessionTerminate($to, $sid, $reason)
 {
     $xml = '<jingle xmlns="urn:xmpp:jingle:1"
           action="session-terminate"
           sid="' . $sid . '">
         <reason>
             <' . $reason . '/>
         </reason>
     </jingle>';
     $xml = \Moxl\API::iqWrapper($xml, $to, 'set');
     \Moxl\API::request($xml);
 }
コード例 #19
0
ファイル: Jingle.php プロジェクト: movim/moxl
 static function sessionTerminate($to, $sid, $value)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $jingle = $dom->createElementNS('urn:xmpp:jingle:1', 'jingle');
     $jingle->setAttribute('action', 'session-terminate');
     $jingle->setAttribute('sid', $sid);
     $reason = $dom->createElement('reason');
     $jingle->appendChild($reason);
     $item = $dom->createElement($value);
     $reason->appendChild($item);
     $xml = \Moxl\API::iqWrapper($jingle, $to, 'set');
     \Moxl\API::request($xml);
 }
コード例 #20
0
ファイル: Auth.php プロジェクト: movim/moxl
 static function mechanismSCRAMSHA1()
 {
     $s = new SASL2();
     $fa = $s->factory('SCRAM-SHA1');
     $session = \Session::start();
     Utils::log("/// INITIAL MESSAGE");
     $response = base64_encode($fa->getResponse($session->get('username'), $session->get('password')));
     $session->set('saslfa', $fa);
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $auth = $dom->createElementNS('urn:ietf:params:xml:ns:xmpp-sasl', 'auth', $response);
     $auth->setAttribute('mechanism', 'SCRAM-SHA-1');
     $dom->appendChild($auth);
     API::request($dom->saveXML($dom->documentElement));
 }
コード例 #21
0
ファイル: Auth.php プロジェクト: Hywan/moxl
 static function mechanismSCRAMSHA1()
 {
     $s = new SASL2();
     $fa = $s->factory('SCRAM-SHA1');
     $session = \Sessionx::start();
     Utils::log("/// INITIAL MESSAGE");
     $response = base64_encode($fa->getResponse($session->user, $session->password));
     $sess = \Session::start();
     $sess->set('saslfa', $fa);
     $xml = '<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="SCRAM-SHA-1">
                 ' . $response . '
             </auth>';
     API::request($xml);
 }
コード例 #22
0
ファイル: Notification.php プロジェクト: Hywan/moxl
 static function itemDelete($to, $id)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');
     $retract = $dom->createElement('retract');
     $retract->setAttribute('node', 'urn:xmpp:inbox');
     $retract->setAttribute('notify', 'true');
     $item = $dom->createElement('item');
     $item->setAttribute('id', $id);
     $retract->appendChild($item);
     $pubsub->appendChild($retract);
     $xml = \Moxl\API::iqWrapper($pubsub, $to, 'set');
     \Moxl\API::request($xml);
 }
コード例 #23
0
ファイル: Muc.php プロジェクト: Hywan/moxl
 static function setConfig($to, $data)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $query = $dom->createElementNS('http://jabber.org/protocol/muc#owner', 'query');
     $dom->appendChild($query);
     $x = $dom->createElementNS('jabber:x:data', 'x');
     $x->setAttribute('type', 'submit');
     $query->appendChild($x);
     $xmpp = new \FormtoXMPP($data);
     $xmpp->create();
     $xmpp->appendToX($dom);
     $xml = \Moxl\API::iqWrapper($query, $to, 'set');
     \Moxl\API::request($xml);
 }
コード例 #24
0
ファイル: Bookmark.php プロジェクト: Hywan/moxl
 static function set($arr)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');
     $publish = $dom->createElement('publish');
     $pubsub->appendChild($publish);
     $item = $dom->createElement('item');
     $publish->appendChild($item);
     $storage = $dom->createElement('storage');
     $item->appendChild($storage);
     $storage->setAttribute('xmlns', 'storage:bookmarks');
     $publish->setAttribute('node', 'storage:bookmarks');
     $item->setAttribute('id', 'current');
     foreach ($arr as $elt) {
         switch ($elt['type']) {
             case 'conference':
                 $conference = $dom->createElement('conference');
                 $nick = $dom->createElement('nick', $elt['nick']);
                 $conference->appendChild($nick);
                 $conference->setAttribute('name', $elt['name']);
                 $conference->setAttribute('autojoin', $elt['autojoin']);
                 $conference->setAttribute('jid', $elt['jid']);
                 $storage->appendChild($conference);
                 break;
                 /*case 'url':
                   $xml .= '
                       <url name="'.$elt['name'].'"
                            url="'.$elt['url'].'"/>';
                   break;*/
             /*case 'url':
               $xml .= '
                   <url name="'.$elt['name'].'"
                        url="'.$elt['url'].'"/>';
               break;*/
             case 'subscription':
                 $subscription = $dom->createElement('subscription');
                 $storage->appendChild($subscription);
                 $subscription->setAttribute('xmlns', 'urn:xmpp:pubsub:subscription:0');
                 $title = $dom->createElement('title', $elt['title']);
                 $subscription->appendChild($title);
                 $subscription->setAttribute('server', $elt['server']);
                 $subscription->setAttribute('node', $elt['node']);
                 $subscription->setAttribute('subid', $elt['subid']);
                 break;
         }
     }
     $xml = \Moxl\API::iqWrapper($pubsub, false, 'set');
     \Moxl\API::request($xml);
 }
コード例 #25
0
ファイル: Message.php プロジェクト: movim/moxl
 static function maker($to, $content = false, $html = false, $type = 'chat', $chatstates = false, $receipts = false, $id = false, $replace = false)
 {
     $session = \Session::start();
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $root = $dom->createElementNS('jabber:client', 'message');
     $dom->appendChild($root);
     $root->setAttribute('to', str_replace(' ', '\\40', $to));
     $root->setAttribute('type', $type);
     if ($id != false) {
         $root->setAttribute('id', $id);
     } else {
         $root->setAttribute('id', $session->get('id'));
     }
     if ($content != false) {
         $body = $dom->createElement('body', $content);
         $root->appendChild($body);
     }
     if ($replace != false) {
         $rep = $dom->createElementNS('urn:xmpp:message-correct:0', 'replace');
         $rep->setAttribute('id', $replace);
         $root->appendChild($rep);
     }
     if ($html != false) {
         $xhtml = $dom->createElementNS('http://jabber.org/protocol/xhtml-im', 'html');
         $body = $dom->createElementNS('http://www.w3.org/1999/xhtml', 'body');
         $dom2 = new \DOMDocument('1.0', 'UTF-8');
         $dom2->loadXml('<root>' . $html . '</root>');
         $bar = $dom2->documentElement->firstChild;
         // we want to import the bar tree
         $body->appendChild($dom->importNode($bar, TRUE));
         $xhtml->appendChild($body);
         $root->appendChild($xhtml);
     }
     if ($chatstates != false) {
         $chatstate = $dom->createElementNS('http://jabber.org/protocol/chatstates', $chatstates);
         $root->appendChild($chatstate);
     }
     if ($receipts != false) {
         if ($receipts == 'request') {
             $request = $dom->createElement('request');
         } else {
             $request = $dom->createElement('received');
             $request->setAttribute('id', $receipts);
         }
         $request->setAttribute('xmlns', 'urn:xmpp:receipts');
         $root->appendChild($request);
     }
     \Moxl\API::request($dom->saveXML($dom->documentElement));
 }
コード例 #26
0
ファイル: Nickname.php プロジェクト: movim/moxl
 static function set($nickname)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');
     $publish = $dom->createElement('publish');
     $publish->setAttribute('node', 'http://jabber.org/protocol/nick');
     $pubsub->appendChild($publish);
     $item = $dom->createElement('item');
     $publish->appendChild($item);
     $nick = $dom->createElement('nick', $nickname);
     $nick->setAttribute('xmlns', 'http://jabber.org/protocol/nick');
     $item->appendChild($nick);
     $xml = \Moxl\API::iqWrapper($pubsub, false, 'set');
     \Moxl\API::request($xml);
 }
コード例 #27
0
ファイル: AdHoc.php プロジェクト: Hywan/moxl
 static function submit($to, $node, $data, $sessionid)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $command = $dom->createElementNS('http://jabber.org/protocol/commands', 'command');
     $dom->appendChild($command);
     $command->setAttribute('sessionid', $sessionid);
     $command->setAttribute('node', $node);
     $x = $dom->createElementNS('jabber:x:data', 'x');
     $x->setAttribute('type', 'submit');
     $command->appendChild($x);
     $xmpp = new \FormtoXMPP($data);
     $xmpp->create();
     $xmpp->appendToX($dom);
     $xml = \Moxl\API::iqWrapper($command, $to, 'set');
     \Moxl\API::request($xml);
 }
コード例 #28
0
ファイル: SASLChallenge.php プロジェクト: Hywan/moxl
 public function handle($stanza, $parent = false)
 {
     $sess = \Session::start();
     $session = \Sessionx::start();
     $s = new SASL2();
     switch ($sess->get('mecchoice')) {
         case 'SCRAMSHA1':
             $fa = $sess->get('saslfa');
             $sess->remove('saslfa');
             $challenge = base64_decode((string) $stanza);
             \Moxl\Utils::log("/// SECOND MESSAGE - PROOF");
             $response = base64_encode($fa->getResponse($session->user, $session->password, $challenge));
             $xml = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">' . $response . '</response>';
             \Moxl\API::request($xml);
             break;
         case 'DIGESTMD5':
             $decoded = base64_decode((string) $stanza);
             $s = new SASL2();
             $d = $s->factory('digest-md5');
             if (!$sess->get('saslfirst')) {
                 \Moxl\Utils::log("/// CHALLENGE");
                 $response = $d->getResponse($session->user, $session->password, $decoded, $session->host, 'xmpp');
                 $response = base64_encode($response);
                 $xml = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">' . $response . '</response>';
                 $sess->set('saslfirst', 1);
             } else {
                 $xml = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>';
             }
             \Moxl\API::request($xml);
             break;
         case 'CRAMMD5':
             $decoded = base64_decode((string) $stanza);
             $s = new SASL2();
             $c = $s->factory('cram-md5');
             $session = \Sessionx::start();
             $response = $c->getResponse($session->user, $session->pass, $decoded);
             $response = base64_encode($response);
             \Moxl\Utils::log("/// CHALLENGE");
             $xml = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">' . $response . '</response>';
             \Moxl\API::request($xml);
             break;
     }
 }
コード例 #29
0
ファイル: linker.php プロジェクト: ajira86/movim
             fwrite(STDERR, colorize(getenv('sid'), 'yellow') . " " . $parser->getError() . "\n");
         }
         if ($restart) {
             $session = \Sessionx::start();
             \Moxl\Stanza\Stream::init($session->host);
             stream_set_blocking($conn->stream, 0);
             $restart = false;
         }
         $msg = \RPC::commit();
         \RPC::clear();
         if (!empty($msg)) {
             echo base64_encode(gzcompress(json_encode($msg), 9)) . "";
             #fwrite(STDERR, colorize($msg.' '.strlen($msg), 'yellow')." : ".colorize('sent to browser', 'green')."\n");
         }
         $xml = \Moxl\API::commit();
         \Moxl\API::clear();
         if (!empty($xml)) {
             $conn->write(trim($xml));
             #fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
         }
     }
     // Two ticks to be sure that we get everything from the socket, sic…
     $loop->tick();
     $loop->tick();
 });
 $conn->on('error', function ($msg) use($conn, $loop) {
     #fwrite(STDERR, colorize(serialize($msg), 'red')." : ".colorize('error', 'green')."\n");
     $loop->stop();
 });
 $conn->on('close', function ($msg) use($conn, $loop) {
     #fwrite(STDERR, colorize(serialize($msg), 'red')." : ".colorize('closed', 'green')."\n");
コード例 #30
0
ファイル: Ping.php プロジェクト: movim/moxl
 static function pong($to, $id)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $ping = $dom->createElementNS('urn:xmpp:ping', 'ping');
     \Moxl\API::request(\Moxl\API::iqWrapper($ping, $to, 'result', $id));
 }