Example #1
0
 public function handle($stanza, $parent = false)
 {
     $from = current(explode('/', (string) $stanza->attributes()->from));
     $cd = new \modl\ContactDAO();
     $c = $cd->get($from);
     if ($c == null) {
         $c = new \modl\Contact();
         $c->jid = $from;
     }
     $c->loclatitude = $this->_geo['latitude'];
     $c->loclongitude = $this->_geo['longitude'];
     $c->localtitude = $this->_geo['altitude'];
     $c->loccountry = $this->_geo['country'];
     $c->loccountrycode = $this->_geo['countrycode'];
     $c->locregion = $this->_geo['region'];
     $c->locpostalcode = $this->_geo['postalcode'];
     $c->loclocality = $this->_geo['locality'];
     $c->locstreet = $this->_geo['street'];
     $c->locbuilding = $this->_geo['building'];
     $c->loctext = $this->_geo['text'];
     $c->locuri = $this->_geo['uri'];
     $c->loctimestamp = date('Y-m-d H:i:s', time());
     $cd->set($c);
     $this->event('locationpublished', $c);
 }
Example #2
0
File: Blog.php Project: Trim/movim
 function display()
 {
     /*if(!$this->get('f')) {
           return;
       }*/
     if ($this->_view == 'grouppublic') {
         $from = $this->get('s');
         $node = $this->get('n');
         $this->view->assign('mode', 'group');
         $this->view->assign('server', $from);
         $this->view->assign('node', $node);
         $pd = new \Modl\ItemDAO();
         $this->view->assign('item', $pd->getItem($from, $node));
     } else {
         $from = $this->get('f');
         $cd = new \modl\ContactDAO();
         $c = $cd->get($from, true);
         $this->view->assign('contact', $c);
         if (filter_var($from, FILTER_VALIDATE_EMAIL)) {
             $node = 'urn:xmpp:microblog:0';
         } else {
             return;
         }
         $this->view->assign('mode', 'blog');
     }
     $pd = new \modl\PostnDAO();
     if ($id = $this->get('i')) {
         $messages = $pd->getPublicItem($from, $node, $id, 10, 0);
     } else {
         $messages = $pd->getPublic($from, $node, 10, 0);
     }
     $this->view->assign('posts', $messages);
 }
Example #3
0
 function display()
 {
     ob_clean();
     if (!$this->get('f')) {
         return;
     }
     $from = $this->get('f');
     if (filter_var($from, FILTER_VALIDATE_EMAIL)) {
         $node = 'urn:xmpp:microblog:0';
     } else {
         return;
     }
     $pd = new \modl\PostnDAO();
     $cd = new \modl\ContactDAO();
     $this->view->assign('contact', $cd->get($from, true));
     $this->view->assign('uri', Route::urlize('blog', array($from)));
     if (isset($from) && isset($node)) {
         $messages = $pd->getPublic($from, $node, 10, 0);
         $this->view->assign('messages', $messages);
     }
     if (isset($messages[0])) {
         header("Content-Type: application/atom+xml; charset=UTF-8");
         $this->view->assign('date', date('c'));
     }
 }
Example #4
0
File: Blog.php Project: vijo/movim
 function load()
 {
     if ($this->_view == 'node') {
         $this->_from = $this->get('s');
         $this->_node = $this->get('n');
         if (!$this->validateServerNode($this->_from, $this->_node)) {
             return;
         }
         $pd = new \Modl\ItemDAO();
         $this->_item = $pd->getItem($this->_from, $this->_node);
         $this->_mode = 'group';
         $this->url = Route::urlize('node', array($this->_from, $this->_node));
     } else {
         $this->_from = $this->get('f');
         $cd = new \modl\ContactDAO();
         $this->_contact = $cd->get($this->_from, true);
         if (filter_var($this->_from, FILTER_VALIDATE_EMAIL)) {
             $this->_node = 'urn:xmpp:microblog:0';
         } else {
             return;
         }
         $this->_mode = 'blog';
         $this->url = Route::urlize('blog', $this->_from);
     }
     $pd = new \modl\PostnDAO();
     if ($this->_id = $this->get('i')) {
         if (Validator::int()->between(0, 100)->validate($this->_id)) {
             $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, $this->_id * $this->_paging, $this->_paging + 1);
             $this->_page = $this->_id + 1;
         } elseif (Validator::string()->length(5, 100)->validate($this->_id)) {
             $this->_messages = $pd->getPublicItem($this->_from, $this->_node, $this->_id);
             if (is_object($this->_messages[0])) {
                 $this->title = $this->_messages[0]->title;
                 $description = stripTags($this->_messages[0]->contentcleaned);
                 if (!empty($description)) {
                     $this->description = $description;
                 }
                 $attachements = $this->_messages[0]->getAttachements();
                 if ($attachements && array_key_exists('pictures', $attachements)) {
                     $this->image = urldecode($attachements['pictures'][0]['href']);
                 }
             }
             if ($this->_view == 'node') {
                 $this->url = Route::urlize('node', array($this->_from, $this->_node, $this->_id));
             } else {
                 $this->url = Route::urlize('blog', array($this->_from, $this->_id));
             }
         }
     } else {
         $this->_page = 1;
         $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, 0, $this->_paging + 1);
     }
     if (count($this->_messages) == $this->_paging + 1) {
         array_pop($this->_messages);
     }
 }
Example #5
0
 function display()
 {
     $cd = new \modl\ContactDAO();
     $me = $cd->get();
     $p = new Picture();
     if (!$p->get($this->user->getLogin())) {
         $this->view->assign('getavatar', $this->call('ajaxGetAvatar'));
         $this->view->assign('form', $this->prepareForm(new \modl\Contact()));
     } else {
         $this->view->assign('getavatar', '');
         $this->view->assign('form', $this->prepareForm($me));
     }
 }
Example #6
0
 public function handle($stanza, $parent = false)
 {
     $to = current(explode('/', (string) $parent->attributes()->to));
     $from = current(explode('/', (string) $parent->attributes()->from));
     if (isset($stanza->items->item->geoloc) && $stanza->items->item->geoloc->count() > 0) {
         $cd = new \modl\ContactDAO();
         $c = $cd->get($from);
         if ($c != null) {
             $c->setLocation($stanza);
             $cd->set($c);
         }
     }
 }
Example #7
0
 public function handle($stanza, $parent = false)
 {
     $jid = current(explode('/', (string) $parent->attributes()->from));
     $evt = new \Event();
     $cd = new \modl\ContactDAO();
     $c = $cd->get($jid);
     if ($c == null) {
         $c = new \modl\Contact();
     }
     $p = new \Picture();
     $p->fromBase((string) $stanza->items->item->data);
     $p->set($jid);
     $evt->runEvent('vcard', $c);
 }
Example #8
0
File: Get.php Project: Hywan/moxl
 public function handle($stanza, $parent = false)
 {
     $cd = new \modl\ContactDAO();
     $c = $cd->get($this->_to);
     if ($c == null) {
         $c = new \modl\Contact();
     }
     $c->jid = $this->_to;
     $c->photobin = (string) $stanza->pubsub->items->item->data;
     $c->createThumbnails();
     $cd->set($c);
     $this->pack($c);
     $this->deliver();
 }
Example #9
0
File: Tune.php Project: Hywan/moxl
 public function handle($stanza, $parent = false)
 {
     $to = current(explode('/', (string) $parent->attributes()->to));
     $from = current(explode('/', (string) $parent->attributes()->from));
     if (isset($stanza->items->item->tune) && $stanza->items->item->tune->count() > 0) {
         $cd = new \modl\ContactDAO();
         $c = $cd->get($from);
         if ($c != null) {
             $c->setTune($stanza);
             $cd->set($c);
         }
         $evt = new \Event();
         $evt->runEvent('tune', $from);
     }
 }
Example #10
0
 public function handle($stanza, $parent = false)
 {
     $to = current(explode('/', (string) $parent->attributes()->to));
     $from = current(explode('/', (string) $parent->attributes()->from));
     if ($stanza->items->item->nick) {
         $cd = new \modl\ContactDAO();
         $c = $cd->get($from);
         if ($c == null) {
             $c = new \modl\Contact();
             $c->jid = $from;
         }
         $c->nickname = (string) $stanza->items->item->nick;
         $cd->set($c);
     }
 }
Example #11
0
 public function handle($stanza, $parent = false)
 {
     $jid = current(explode('/', (string) $parent->attributes()->from));
     $evt = new \Event();
     $cd = new \modl\ContactDAO();
     $c = $cd->get($jid);
     if (isset($stanza->items->item->metadata->info)) {
         $info = $stanza->items->item->metadata->info->attributes();
         if ($info->id != $c->avatarhash) {
             $c->avatarhash = $info->id;
             $cd->set($c);
             $g = new Get();
             $g->setTo($jid)->request();
         }
     }
 }
Example #12
0
 public function handle($stanza, $parent = false)
 {
     $jid = current(explode('/', (string) $parent->attributes()->from));
     $evt = new \Event();
     $cd = new \modl\ContactDAO();
     $c = $cd->get($jid);
     if ($c == null) {
         $c = new \modl\Contact();
     }
     $c->jid = $jid;
     $vcard = $stanza->items->item->vcard;
     $c->setVcard4($vcard);
     $c->createThumbnails();
     $cd->set($c);
     $evt->runEvent('vcard', $c);
 }
Example #13
0
File: Get.php Project: Hywan/moxl
 public function handle($stanza, $parent = false)
 {
     $cd = new \modl\ContactDAO();
     $c = $cd->get($this->_to);
     if ($c == null) {
         $c = new \modl\Contact();
     }
     $c->jid = $this->_to;
     if ($vcard = $stanza->pubsub->items->item) {
         $vcard = $stanza->pubsub->items->item->vcard;
         $c->setVcard4($vcard);
         $c->createThumbnails();
         $cd->set($c);
         $this->pack($c);
         $this->deliver();
     } else {
         $this->error(false);
     }
 }
Example #14
0
File: Mood.php Project: Hywan/moxl
 public function handle($stanza, $parent = false)
 {
     $from = current(explode('/', (string) $parent->attributes()->from));
     if (isset($stanza->items->item->mood) && $stanza->items->item->mood->count() > 0) {
         $arrmood = array();
         foreach ($stanza->items->item->mood->children() as $mood) {
             if ($mood->getName() != 'text') {
                 array_push($arrmood, $mood->getName());
             }
         }
         if (count($arrmood) > 0) {
             $cd = new \modl\ContactDAO();
             $c = $cd->get($from);
             if ($c != null) {
                 $c->mood = serialize($arrmood);
                 $cd->set($c);
             }
         }
     }
 }
Example #15
0
File: Get.php Project: Hywan/moxl
 public function handle($stanza, $parent = false)
 {
     if ($stanza->attributes()->from) {
         $jid = current(explode('/', (string) $stanza->attributes()->from));
     } else {
         $jid = $this->_to;
     }
     if ($jid) {
         $evt = new \Event();
         $cd = new \modl\ContactDAO();
         $c = $cd->get($this->_to);
         if ($c == null) {
             $c = new \modl\Contact();
         }
         $c->set($stanza, $this->_to);
         $cd->set($c);
         $c->createThumbnails();
         $this->pack($c);
         $this->deliver();
     }
 }
Example #16
0
File: Blog.php Project: Nyco/movim
 function display()
 {
     if (!$this->get('f')) {
         return;
     }
     $from = $this->get('f');
     if (filter_var($from, FILTER_VALIDATE_EMAIL)) {
         $node = 'urn:xmpp:microblog:0';
     } else {
         return;
     }
     $cd = new \modl\ContactDAO();
     $c = $cd->get($from, true);
     $this->view->assign('contact', $c);
     $pd = new \modl\PostnDAO();
     if ($id = $this->get('i')) {
         $messages = $pd->getPublicItem($from, $node, $id, 10, 0);
     } else {
         $messages = $pd->getPublic($from, $node, 10, 0);
     }
     $this->view->assign('posts', $messages);
 }
Example #17
0
 function ajaxGetForm()
 {
     $cd = new \modl\ContactDAO();
     $me = $cd->get();
     RPC::call('MovimTpl.fill', '#avatar_form', $this->prepareForm($me));
 }
Example #18
0
 function display()
 {
     ob_clean();
     $pd = new \modl\PostnDAO();
     $cd = new \modl\ContactDAO();
     $id = new \Modl\ItemDAO();
     if (!$this->get('s')) {
         return;
     }
     $from = $this->get('s');
     $item = $contact = null;
     if (filter_var($from, FILTER_VALIDATE_EMAIL)) {
         $node = 'urn:xmpp:microblog:0';
         $contact = $cd->get($from);
     } elseif (!$this->get('n')) {
         return;
     } else {
         $node = $this->get('n');
         $item = $id->getItem($from, $node);
     }
     $messages = $pd->getPublic($from, $node, 0, 20);
     header("Content-Type: application/atom+xml; charset=UTF-8");
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->formatOutput = true;
     $feed = $dom->createElementNS('http://www.w3.org/2005/Atom', 'feed');
     $dom->appendChild($feed);
     $feed->appendChild($dom->createElement('updated', date('c')));
     $feed->appendChild($self = $dom->createElement('link'));
     $self->setAttribute('rel', 'self');
     if ($contact != null) {
         $feed->appendChild($dom->createElement('title', __('feed.title', $contact->getTrueName())));
         $feed->appendChild($author = $dom->createElement('author'));
         $author->appendChild($dom->createElement('name', $contact->getTrueName()));
         $author->appendChild($dom->createElement('uri', Route::urlize('blog', [$from])));
         $feed->appendChild($dom->createElement('logo', $contact->getPhoto('l')));
         $self->setAttribute('href', Route::urlize('feed', [$from]));
     }
     if ($item != null) {
         if ($item->name) {
             $feed->appendChild($dom->createElement('title', $item->name));
         } else {
             $feed->appendChild($dom->createElement('title', $item->node));
         }
         if ($item->description) {
             $feed->appendChild($dom->createElement('subtitle', $item->description));
         } else {
             $feed->appendChild($dom->createElement('subtitle', $item->server));
         }
         $self->setAttribute('href', Route::urlize('feed', [$from, $node]));
     }
     $feed->appendChild($generator = $dom->createElement('generator', 'Movim'));
     $generator->setAttribute('uri', 'https://movim.eu');
     $generator->setAttribute('version', APP_VERSION);
     foreach ($messages as $message) {
         $feed->appendChild($entry = $dom->createElement('entry'));
         if ($message->title) {
             $entry->appendChild($dom->createElement('title', $message->title));
         } else {
             $entry->appendChild($dom->createElement('title', __('post.default_title')));
         }
         $entry->appendChild($dom->createElement('id', $message->getUUID()));
         $entry->appendChild($dom->createElement('updated', date('c', strtotime($message->updated))));
         $entry->appendChild($content = $dom->createElement('content'));
         $content->appendChild($div = $dom->createElementNS('http://www.w3.org/1999/xhtml', 'div'));
         $content->setAttribute('type', 'xhtml');
         $f = $dom->createDocumentFragment();
         $f->appendXML($message->contentcleaned);
         $div->appendChild($f);
         $attachments = $message->getAttachments();
         if (isset($attachments['pictures'])) {
             foreach ($attachments['pictures'] as $value) {
                 $entry->appendChild($link = $dom->createElement('link'));
                 $link->setAttribute('rel', 'enclosure');
                 $link->setAttribute('type', $value['type']);
                 $link->setAttribute('href', $value['href']);
             }
         }
         if (isset($attachments['files'])) {
             foreach ($attachments['files'] as $value) {
                 $entry->appendChild($link = $dom->createElement('link'));
                 $link->setAttribute('rel', 'enclosure');
                 $link->setAttribute('type', $value['type']);
                 $link->setAttribute('href', $value['href']);
             }
         }
         if (isset($attachments['links'])) {
             foreach ($attachments['links'] as $value) {
                 $entry->appendChild($link = $dom->createElement('link'));
                 $link->setAttribute('rel', 'alternate');
                 $link->setAttribute('href', $value['href']);
             }
         }
         $entry->appendChild($link = $dom->createElement('link'));
         $link->setAttribute('rel', 'alternate');
         $link->setAttribute('type', 'text/html');
         $link->setAttribute('href', $message->getPublicUrl());
     }
     echo $dom->saveXML();
     exit;
 }
Example #19
0
 public function getContact($username, $host)
 {
     $jid = $username . '@' . $host;
     $cd = new modl\ContactDAO();
     return $cd->get($jid);
 }
Example #20
0
 function load()
 {
     if ($this->_view == 'node') {
         $this->_from = $this->get('s');
         $this->_node = $this->get('n');
         if (!$this->validateServerNode($this->_from, $this->_node)) {
             return;
         }
         $pd = new \Modl\ItemDAO();
         $this->_item = $pd->getItem($this->_from, $this->_node);
         $this->_mode = 'group';
         $this->url = Route::urlize('node', array($this->_from, $this->_node));
     } elseif ($this->_view == 'tag' && $this->validateTag($this->get('t'))) {
         $this->_mode = 'tag';
         $this->_tag = $this->get('t');
         $this->title = '#' . $this->_tag;
     } else {
         $this->_from = $this->get('f');
         $cd = new \modl\ContactDAO();
         $this->_contact = $cd->get($this->_from, true);
         if (filter_var($this->_from, FILTER_VALIDATE_EMAIL)) {
             $this->_node = 'urn:xmpp:microblog:0';
         } else {
             return;
         }
         $this->_mode = 'blog';
         $this->url = Route::urlize('blog', $this->_from);
     }
     $pd = new \modl\PostnDAO();
     if ($this->_id = $this->get('i')) {
         if (Validator::stringType()->between('1', '100')->validate($this->_id)) {
             if (isset($this->_tag)) {
                 $this->_messages = $pd->getPublicTag($this->get('t'), $this->_id * $this->_paging, $this->_paging + 1);
             } else {
                 $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, $this->_id * $this->_paging, $this->_paging + 1);
             }
             $this->_page = $this->_id + 1;
         } elseif (Validator::stringType()->length(5, 100)->validate($this->_id)) {
             $this->_messages[0] = $pd->getPublicItem($this->_from, $this->_node, $this->_id);
             if (is_object($this->_messages[0])) {
                 $this->title = $this->_messages[0]->title;
                 $description = stripTags($this->_messages[0]->contentcleaned);
                 if (!empty($description)) {
                     $this->description = truncate($description, 100);
                 }
                 $attachments = $this->_messages[0]->getAttachments();
                 if ($attachments && array_key_exists('pictures', $attachments)) {
                     $this->image = urldecode($attachments['pictures'][0]['href']);
                 }
             }
             if ($this->_view == 'node') {
                 $this->url = Route::urlize('node', array($this->_from, $this->_node, $this->_id));
             } else {
                 $this->url = Route::urlize('blog', array($this->_from, $this->_id));
             }
         }
     } else {
         $this->_page = 1;
         if (isset($this->_tag)) {
             $this->_messages = $pd->getPublicTag($this->get('t'), 0, $this->_paging + 1);
         } else {
             $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, 0, $this->_paging + 1);
         }
     }
     if (count($this->_messages) == $this->_paging + 1) {
         array_pop($this->_messages);
     }
     if ($this->_node == 'urn:xmpp:microblog:0') {
         $this->user = new User($this->_from);
         $cssurl = $this->user->getDumpedConfig('cssurl');
         if (isset($cssurl) && $cssurl != '' && Validator::url()->validate($cssurl)) {
             $this->addrawcss($cssurl);
         }
     }
 }
Example #21
0
 function prepareEmpty()
 {
     $view = $this->tpl();
     $nd = new \modl\PostnDAO();
     $cd = new modl\ContactDAO();
     $view = $this->tpl();
     $view->assign('presencestxt', getPresencesTxt());
     $view->assign('top', $cd->getTop(6));
     $view->assign('blogs', $nd->getLastBlogPublic(0, 6));
     $view->assign('posts', $nd->getLastPublished(0, 4));
     $view->assign('me', $cd->get($this->user->getLogin()), true);
     $view->assign('jid', $this->user->getLogin());
     return $view->draw('_post_empty', true);
 }