Ejemplo n.º 1
0
 static function get()
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $query = $dom->createElementNS('jabber:iq:roster', 'query');
     $xml = \Moxl\API::iqWrapper($query, false, 'get');
     \Moxl\API::request($xml);
 }
Ejemplo n.º 2
0
Archivo: MAM.php Proyecto: 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);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
Archivo: Vcard.php Proyecto: 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);
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 static function listGetOwned()
 {
     $xml = '<pubsub xmlns="http://jabber.org/protocol/pubsub">
             <affiliations/>
         </pubsub>';
     $xml = \Moxl\API::iqWrapper($xml, false, 'get');
     \Moxl\API::request($xml);
 }
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
Archivo: BOB.php Proyecto: 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));
 }
Ejemplo n.º 12
0
 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);
 }
Ejemplo n.º 13
0
 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);
 }
Ejemplo n.º 14
0
 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);
 }
Ejemplo n.º 15
0
Archivo: Disco.php Proyecto: 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);
 }
Ejemplo n.º 16
0
 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);
 }
Ejemplo n.º 17
0
 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);
 }
Ejemplo n.º 18
0
 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);
 }
Ejemplo n.º 19
0
Archivo: Muc.php Proyecto: 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);
 }
Ejemplo n.º 20
0
 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);
 }
Ejemplo n.º 21
0
 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);
 }
Ejemplo n.º 22
0
 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);
 }
Ejemplo n.º 23
0
Archivo: AdHoc.php Proyecto: 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);
 }
Ejemplo n.º 24
0
Archivo: Ping.php Proyecto: 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));
 }
Ejemplo n.º 25
0
 static function setAffiliations($to, $node, $data)
 {
     $affiliations = "";
     foreach ($data as $jid_subid => $affiliation) {
         $split = split("_", $jid_subid);
         $affiliations .= '
             <affiliation
                 jid="' . $split[0] . '"
                 subid="' . $split[1] . '"
                 affiliation="' . $affiliation . '" />';
     }
     $xml = '<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
             <affiliations node="' . $node . '">
             ' . $affiliations . '
             </affiliations>
         </pubsub>';
     $xml = \Moxl\API::iqWrapper($xml, $to, 'set');
     \Moxl\API::request($xml);
 }
Ejemplo n.º 26
0
    static function commentNodeCreate($to, $parentid)
    {
        $xml = '
            <pubsub xmlns="http://jabber.org/protocol/pubsub">
                <create node="urn:xmpp:microblog:0:comments/' . $parentid . '"/>
                <configure>
                    <x xmlns="jabber:x:data" type="submit">
                        <field var="FORM_TYPE" type="hidden">
                            <value>http://jabber.org/protocol/pubsub#node_config</value>
                        </field>

                        <field var="pubsub#deliver_notifications">
                            <value>1</value>
                        </field>

                        <field var="pubsub#deliver_payloads">
                            <value>0</value>
                        </field>

                        <field var="pubsub#persist_items">
                            <value>1</value>
                        </field>

                        <field var="pubsub#max_items">
                            <value>100</value>
                        </field>

                        <field var="pubsub#item_expire">
                            <value>604800</value>
                        </field>

                        <field var="pubsub#access_model">
                            <value>open</value>
                        </field>

                        <field var="pubsub#publish_model">
                            <value>open</value>
                        </field>

                        <field var="pubsub#purge_offline">
                            <value>0</value>
                        </field>

                        <field var="pubsub#notify_config">
                            <value>0</value>
                        </field>

                        <field var="pubsub#notify_delete">
                            <value>0</value>
                        </field>

                        <field var="pubsub#notify_retract">
                            <value>0</value>
                        </field>
                        
                        
                        <field var="pubsub#subscribe" type="boolean">
                            <value>1</value>
                        </field>

                        <field var="pubsub#send_last_published_item" type="list-single">
                            <value>on_sub_and_presence</value>
                        </field>


                        <field var="pubsub#notify_sub">
                            <value>1</value>
                        </field>

                        <field var="pubsub#type">
                            <value>http://www.w3.org/2005/Atom</value>
                        </field>

                        <field var="pubsub#body_xslt">
                            <value>http://jabxslt.jabberstudio.org/atom_body.xslt</value>
                        </field>
                    </x>
                </configure>
            </pubsub>';
        $xml = \Moxl\API::iqWrapper($xml, $to, 'set');
        \Moxl\API::request($xml);
    }
Ejemplo n.º 27
0
Archivo: Ack.php Proyecto: movim/moxl
 static function send($to, $id)
 {
     \Moxl\API::request(\Moxl\API::iqWrapper(false, $to, 'result', $id));
 }
Ejemplo n.º 28
0
 static function listGetFriends($to)
 {
     $xml = '
         <pubsub xmlns="http://jabber.org/protocol/pubsub">
             <items node="urn:xmpp:pubsub:subscription"/>
         </pubsub>';
     $xml = \Moxl\API::iqWrapper($xml, $to, 'get');
     \Moxl\API::request($xml);
 }