function display() { $this->view->assign('subscriptionconfig', Route::urlize('conf', false, 'groupsubscribedlistconfig')); $this->view->assign('getbookmark', $this->call("ajaxGetBookmark")); $this->view->assign('setbookmark', $this->call("ajaxSetBookmark", "''")); $this->view->assign('preparebookmark', $this->prepareBookmark()); }
function prepareList($list) { //0:data 1:server 2:node $affiliation = array("owner", "member", "none"); $html = '<form id="affiliationsManaging">'; foreach ($list[0] as $item) { //0:jid 1:affiliation 2:subid $html .= ' <div class="element"> <label for="' . $item[0] . '_' . $item[2] . '"> <a href="' . Route::urlize('friend', $item[0]) . '">' . $item[0] . '</a> </label> <div class="select"> <select name="' . $item[0] . '_' . $item[2] . '">'; foreach ($affiliation as $status) { $status == $item[1] ? $selected = "selected" : ($selected = ""); $html .= '<option ' . $selected . '>' . t($status) . '</option>'; } $html .= ' </select> </div> </div>'; } $ok = $this->call('ajaxChangeAffiliation', "'" . $list[1] . "'", "'" . $list[2] . "'", "movim_parse_form('affiliationsManaging')"); $html .= ' <hr /> <br /> <a class="button color green oppose" onclick="' . $ok . '"> <i class="fa fa-check"></i> ' . __('button.validate') . ' </a></form><div class="clear"></div>'; return $html; }
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')); } }
function onPublish($packet) { list($to, $node, $id, $repost) = array_values($packet->content); if (!$repost) { $this->ajaxCreateComments($to, $id); } RPC::call('MovimUtils.redirect', Route::urlize('news', [$to, $node, $id])); }
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); } }
function prepareList($list) { $configlist = $this->tpl(); $sd = new \Modl\SubscriptionDAO(); $listhtml = ''; //if($sd != null && $sd->getSubscribed() != null) { foreach ($sd->getSubscribed() as $s) { if ($s->name != null) { $name = $s->name; } else { $name = $s->node; } if (isset($list[$s->server . $s->node])) { $checked = 'checked'; } else { $checked = ''; } $switch = $this->call('ajaxChangeSubscribed', "'" . $s->server . "'", "'" . $s->node . "'", "this.checked", "'" . $name . "'"); $listhtml .= ' <li class="action"> <span class="icon bubble color ' . stringToColor($s->node) . '"> ' . firstLetterCapitalize($s->node) . ' </span> <form> <div class="action"> <div class="checkbox"> <input type="checkbox" id="privacy' . $s->node . '" name="privacy' . $s->node . '" ' . $checked . ' onchange="' . $switch . '"/> <label for="privacy' . $s->node . '"></label> </div> </div> </form> <a href="' . Route::urlize('node', array($s->server, $s->node)) . '">' . $name . ' </a> </li>'; } $configlist->assign('list', $listhtml); return $configlist->draw('_pubsubsubscriptionconfig_list', true); //} else return t('No public groups found'); }
function display() { $this->view->assign('base_uri', BASE_URI); $this->view->assign('base_host', BASE_HOST); $this->view->assign('error_uri', Route::urlize('disconnect')); $r = new Route(); $this->view->assign('current_page', $r->find()); if (!isset($_SERVER['HTTP_MOD_REWRITE']) || !$_SERVER['HTTP_MOD_REWRITE']) { $this->view->assign('page_key_uri', '?q='); } else { $this->view->assign('page_key_uri', ''); } $this->view->assign('secure_websocket', file_get_contents(CACHE_PATH . 'websocket')); // And we load some public values of the system configuration $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $public_conf = array('bosh_url' => $config->boshurl, 'timezone' => $config->timezone); $this->view->assign('server_conf', json_encode($public_conf)); }
function ajaxLogin($form) { // We get the Server Configuration $cd = new \Modl\ConfigDAO(); $config = $cd->get(); // First we check the form $validate_login = Validator::email()->length(6, 40); $validate_password = Validator::string()->length(4, 40); $login = $form->login->value; $password = $form->pass->value; if (!$validate_login->validate($login)) { $this->showErrorBlock('login_format'); return; } if (!$validate_password->validate($password)) { $this->showErrorBlock('password_format'); return; } list($username, $host) = explode('@', $login); // Check whitelisted server if ($config->xmppwhitelist != '' && !in_array($host, explode(',', $config->xmppwhitelist))) { $this->showErrorBlock('unauthorized'); return; } // We check if we already have an open session $sd = new \Modl\SessionxDAO(); $here = $sd->getHash(sha1($username . $password . $host)); if ($here) { RPC::call('Login.setCookie', $here->session); RPC::call('movim_redirect', Route::urlize('main')); $this->showErrorBlock('conflict'); return; } // We try to get the domain $domain = \Moxl\Utils::getDomain($host); // We launch the XMPP socket RPC::call('register', $host); // We create a new session or clear the old one $s = Sessionx::start(); $s->init($username, $password, $host, $domain); \Moxl\Stanza\Stream::init($host); }
private function doLogin($login, $password) { // We get the Server Configuration $cd = new \Modl\ConfigDAO(); $config = $cd->get(); // First we check the form $validate_login = Validator::email()->length(1, 254); $validate_password = Validator::stringType()->length(1, 128); if (!$validate_login->validate($login)) { $this->showErrorBlock('login_format'); return; } if (!$validate_password->validate($password)) { $this->showErrorBlock('password_format'); return; } list($username, $host) = explode('@', $login); // Check whitelisted server if ($config->xmppwhitelist != '' && !in_array($host, explode(',', $config->xmppwhitelist))) { $this->showErrorBlock('unauthorized'); return; } // We check if we already have an open session $sd = new \Modl\SessionxDAO(); $here = $sd->getHash(sha1($username . $password . $host)); if ($here) { //if($s->get('hash') == sha1($username.$password.$host)) { RPC::call('Login.setCookie', $here->session); RPC::call('MovimUtils.redirect', Route::urlize('main')); $this->showErrorBlock('conflict'); return; } $s = Session::start(); // We create a new session or clear the old one $s->set('password', $password); $s->set('username', $username); $s->set('host', $host); $s->set('jid', $login); $s->set('hash', sha1($username . $password . $host)); $s = Sessionx::start(); $s->init($username, $password, $host); // We launch the XMPP socket RPC::call('register', $host); \Moxl\Stanza\Stream::init($host); }
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); } } }
function redirect($page, $params = false) { $url = \Route::urlize($page, $params); header('Location: ' . $url); }
/** * @brief Search for a contact to add */ function ajaxSearchContact($jid) { if (filter_var($jid, FILTER_VALIDATE_EMAIL)) { RPC::call('movim_redirect', Route::urlize('contact', $jid)); RPC::commit(); } else { Notification::append(null, $this->__('roster.jid_error')); } }
function accountNext($server) { return Route::urlize('accountnext', array($server)); }
function redirect($page) { $url = Route::urlize($page, array($this->fetchGet('err'))); header('Location: ' . $url); }
function onPostDisconnect($data) { RPC::call('movim_reload', Route::urlize('disconnect')); }
public function create() { switch ($this->stream->getName()) { case "stream": $node = $this->stream->iq->query->x; break; case "pubsub": $node = $this->stream->configure->x; break; case "command": $node = $this->stream->x; break; default: $node = $this->stream->x; break; } foreach ($this->inputs as $key => $value) { if ($value === '' && $this->stream->getName() == "stream") { RPC::call('movim_reload', Route::urlize('account', 'datamissing')); RPC::commit(); exit; } elseif (substr($key, 0, 8) == 'generic_') { $key = str_replace('generic_', '', $key); if (!is_string($value)) { $value = $value->value; } $node->addChild($key, $value); } elseif ($value->attributes) { $field = $node->addChild('field'); if ($value == 'true' || $value === 1) { $value = '1'; } if ($value == 'false' || $value === 0) { $value = '0'; } $field->addChild('value', trim($value->value)); if (isset($value->attributes->required)) { $field->addChild('required', ''); } $field->addAttribute('var', $value->attributes->name); $field->addAttribute('type', $value->attributes->xmpptype); $field->addAttribute('label', $value->attributes->xmpplabel); } else { $field = $node->addChild('field'); if ($value == 'true') { $value = '1'; } if ($value == 'false') { $value = '0'; } if (is_bool($value)) { $value = $value ? '1' : '0'; } $field->addChild('value', trim($value)); $field->addAttribute('var', trim($key)); } } }
public function getPublicUrl() { if ($this->isMicroblog()) { return \Route::urlize('blog', array($this->origin)); } else { return \Route::urlize('node', array($this->origin, $this->node)); } }
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; }
function redirect($page) { $url = Route::urlize($page); header('Location: ' . $url); }