/** * Constructor. Determines whether to show the login page to the user or the * Movim interface. */ function __construct(&$user = NULL) { $this->user = $user; $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $this->theme = $config->theme; }
protected function __construct() { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $this->_theme = $config->theme; $this->_emoji = new Emoji(new EmojiIndex(), $this->getPath()); }
function display() { $sd = new SessionxDAO(); $this->view->assign('sessions', $sd->getAll()); $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $this->view->assign('hash', $config->password); $tmp = array(); foreach (scandir(USERS_PATH) as $f) { if (is_dir(USERS_PATH . '/' . $f)) { $time = filemtime(USERS_PATH . '/' . $f . '/index.html'); if ($time) { array_push($tmp, $time); } } } sort($tmp); $days = array(); $pattern = "Y-m"; foreach ($tmp as $k => $time) { $key = date($pattern, $time); if (isset($days[$key])) { $days[$key]++; } else { $days[$key] = 1; } } $this->renderTimeLineChart($days, $this->__('statistics.monthly_sub'), "monthly.png"); $sum = 0; foreach ($days as $key => $value) { $sum = $sum + $value; $days[$key] = $sum; } $this->renderTimeLineChart($days, $this->__('statistics.monthly_sub_cum'), "monthly_cumulated.png"); }
function display() { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $l = Movim\i18n\Locale::start(); $this->view->assign('conf', $cd->get()); $this->view->assign('logs', array(0 => $this->__('log.empty'), 1 => $this->__('log.syslog'), 2 => $this->__('log.syslog_files'))); $this->view->assign('bosh_info4', $this->__('bosh.info4', '<a href="http://wiki.movim.eu/en:install">', '</a>')); $json = requestURL(MOVIM_API . 'websockets', 1); $json = json_decode($json); if (isset($json) && $json->status != 404) { $this->view->assign('websockets', $json); } $this->view->assign('timezones', getTimezoneList()); $this->view->assign('langs', $l->getList()); }
public static function urlize($page, $params = false, $tab = false) { $r = new Route(); $routes = $r->_routes; $cd = new \Modl\ConfigDAO(); $config = $cd->get(); if ($page === 'root') { return BASE_URI; } if (isset($routes[$page])) { if ($tab != false) { $tab = '#' . $tab; } // Here we got a beautiful rewriten URL ! if ($config->rewrite == true) { $uri = BASE_URI . $page; } else { $uri = BASE_URI . 'index.php/' . $page; } if ($params != false && is_array($params)) { foreach ($params as $value) { $uri .= '/' . $value; } } elseif ($params != false) { $uri .= '/' . $params; } return $uri . $tab; } else { throw new Exception(__('Route not set for the page %s', $page)); } }
function ajaxUnregister() { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $config->unregister = !$config->unregister; $cd->set($config); RPC::call('MovimUtils.reloadThis'); RPC::commit(); }
function dispatch() { $this->page->setTitle(__('page.administration')); $cd = new \Modl\ConfigDAO(); $config = $cd->get(); if ($config->username == $_POST['username'] && $config->password == sha1($_POST['password'])) { $_SESSION['admin'] = true; $this->name = 'admin'; } }
function display() { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $this->view->assign('conf', $cd->get()); $this->view->assign('logs', array(0 => $this->__('log.empty'), 1 => $this->__('log.syslog'), 2 => $this->__('log.syslog_files'))); $this->view->assign('bosh_info4', $this->__('bosh.info4', '<a href="http://wiki.movim.eu/en:install">', '</a>')); $json = requestURL(MOVIM_API . 'websockets', 1); $json = json_decode($json); if (isset($json) && $json->status != 404) { $this->view->assign('websockets', $json); } $this->view->assign('server_rewrite', false); if (isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) { $this->view->assign('server_rewrite', true); } $this->view->assign('timezones', getTimezoneList()); $this->view->assign('langs', loadLangArray()); }
function display() { $json = requestURL(MOVIM_API . 'servers', 3); $json = json_decode($json); $cd = new \Modl\ConfigDAO(); $this->view->assign('config', $cd->get()); if (is_object($json) && $json->status == 200) { $this->view->assign('servers', $json->servers); } }
function display() { $md = \modl\Modl::getInstance(); $supported = $md->getSupportedDatabases(); $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $this->view->assign('dbconnected', $md->_connected); $this->view->assign('dbtype', $supported[$config->type]); $this->view->assign('dbinfos', sizeof($md->check())); $this->view->assign('websocketurl', $config->websocketurl); }
function display() { // We get the informations $pop = 0; foreach (scandir(USERS_PATH) as $f) { if (is_dir(USERS_PATH . '/' . $f)) { $pop++; } } $pop = $pop - 2; // We get the global configuration $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $connected = (int) requestURL('http://localhost:1560/started/', 2); $infos = array('url' => BASE_URI, 'language' => $config->locale, 'whitelist' => $config->xmppwhitelist, 'timezone' => $config->timezone, 'description' => $config->description, 'unregister' => $config->unregister, 'php_version' => phpversion(), 'version' => APP_VERSION, 'population' => $pop, 'linked' => (int) requestURL('http://localhost:1560/linked/', 2), 'started' => $connected, 'connected' => $connected); $this->view->assign('json', json_encode($infos)); }
public static function urlize($page, $params = false, $tab = false) { $r = new Route(); $routes = $r->_routes; $cd = new \Modl\ConfigDAO(); $config = $cd->get(); if ($page === 'root') { return BASE_URI; } if (isset($routes[$page])) { //if($params != false && count($routes[$page]) != count($params)) { //throw new Exception(__('error.route', $page)); //} else { if ($tab != false) { $tab = '#' . $tab; } // Here we got a beautiful rewriten URL ! if ($config->rewrite == true && isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) { $uri = BASE_URI . $page; if ($params != false && is_array($params)) { foreach ($params as $value) { $uri .= '/' . $value; } } elseif ($params != false) { $uri .= '/' . $params; } } else { $uri = BASE_URI . '?q=' . $page; if ($params != false && is_array($params)) { $i = 0; foreach ($params as $value) { $uri .= '&' . $routes[$page][$i] . '=' . $value; $i++; } } elseif ($params != false) { $uri .= '&' . $routes[$page][0] . '=' . $params; } } return $uri . $tab; //} } else { throw new Exception(__('Route not set for the page %s', $page)); } }
function config($values) { echo colorize("Movim configuration setter\n", 'green'); $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $values = explode(',', $values); foreach ($values as $value) { $exp = explode(':', $value); $key = $exp[0]; array_shift($exp); $value = implode(':', $exp); if (property_exists($config, $key)) { $old = $config->{$key}; $config->{$key} = $value; $cd->set($config); echo colorize("The configuration key ", 'yellow') . colorize($key, 'red') . colorize(" has been updated from ", 'yellow') . colorize($old, 'blue') . colorize(" to ", 'yellow') . colorize($value, 'blue') . "\n"; } } }
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 display() { // We get the informations $pop = 0; foreach (scandir(USERS_PATH) as $f) { if (is_dir(USERS_PATH . '/' . $f)) { $pop++; } } $pop = $pop - 2; // We get the global configuration $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $sd = new \Modl\SessionxDAO(); // We see if we have the url rewriting $rewrite = false; if (isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) { $rewrite = true; } $infos = array('url' => BASE_URI, 'language' => $config->locale, 'whitelist' => $config->xmppwhitelist, 'timezone' => $config->timezone, 'description' => $config->description, 'unregister' => $config->unregister, 'php_version' => phpversion(), 'rewrite' => $rewrite, 'version' => APP_VERSION, 'population' => $pop, 'connected' => $sd->getConnected()); $this->view->assign('json', json_encode($infos)); }
function ajaxLogin($username) { $validate_user = Validator::string()->length(4, 40); if (!$validate_user->validate($username)) { Notification::append(null, $this->__('login_anonymous.bad_username')); return; } // We get the Server Configuration $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $host = 'anonymous.jappix.com'; $password = '******'; // We try to get the domain $domain = \Moxl\Utils::getDomain($host); // We launch the XMPP socket RPC::call('register', $host); // We set the username in the session $s = Session::start(); $s->set('username', $username); // We create a new session or clear the old one $s = Sessionx::start(); $s->init($username, $password, $host, $domain); \Moxl\Stanza\Stream::init($host); }
$buffer = ''; $stdin_behaviour = function ($data) use(&$conn, $loop, &$buffer, &$connector, &$xmpp_behaviour, &$parser) { if (substr($data, -1) == "") { $messages = explode("", $buffer . substr($data, 0, -1)); $buffer = ''; foreach ($messages as $message) { #fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received from the browser', 'green')."\n"); $msg = json_decode($message); if (isset($msg)) { if ($msg->func == 'message' && $msg->body != '') { $msg = $msg->body; } elseif ($msg->func == 'unregister') { \Moxl\Stanza\Stream::end(); } elseif ($msg->func == 'register') { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $domain = \Moxl\Utils::getDomain($msg->host); #fwrite(STDERR, colorize('open a socket to '.$domain, 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); $connector->create($domain, 5222)->then($xmpp_behaviour); } } else { return; } $rpc = new \RPC(); $rpc->handle_json($msg); $msg = json_encode(\RPC::commit()); \RPC::clear(); if (!empty($msg)) { echo base64_encode(gzcompress($msg, 9)) . ""; #fwrite(STDERR, colorize($msg, 'yellow')." : ".colorize('sent to the browser', 'green')."\n"); }
/** * Auto-detects and loads the language. */ function loadLanguageAuto() { $langs = array(); $langNotFound = true; preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\\s*(;\\s*q\\s*=\\s*(1|0\\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse); if (count($lang_parse[1])) { $langs = array_combine($lang_parse[1], $lang_parse[4]); foreach ($langs as $lang => $val) { if ($val === '') { $langs[$lang] = 1; } } arsort($langs, SORT_NUMERIC); } while ((list($key, $value) = each($langs)) && $langNotFound == true) { $exploded = explode('-', $key); $key = reset($exploded); $cd = new \Modl\ConfigDAO(); $config = $cd->get(); if ($key == 'en') { loadLanguage($config->locale); $langNotFound = false; } elseif (file_exists(LOCALES_PATH . $key . '.po')) { loadLanguage($key); $langNotFound = false; } } }
/** * Display some meta tag defined in the widgets using Facebook OpenGraph */ function meta() { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->formatOutput = true; $metas = $dom->createElement('xml'); $dom->appendChild($metas); $widgets = Wrapper::getInstance(); if (isset($widgets->title)) { $meta = $dom->createElement('meta'); $meta->setAttribute('property', 'og:title'); $meta->setAttribute('content', $widgets->title); $metas->appendChild($meta); $meta = $dom->createElement('meta'); $meta->setAttribute('name', 'twitter:title'); $meta->setAttribute('content', $widgets->title); $metas->appendChild($meta); } if (isset($widgets->image)) { $meta = $dom->createElement('meta'); $meta->setAttribute('property', 'og:image'); $meta->setAttribute('content', $widgets->image); $metas->appendChild($meta); $meta = $dom->createElement('meta'); $meta->setAttribute('name', 'twitter:image'); $meta->setAttribute('content', $widgets->image); $metas->appendChild($meta); } if (isset($widgets->description)) { $meta = $dom->createElement('meta'); $meta->setAttribute('property', 'og:description'); $meta->setAttribute('content', $widgets->description); $metas->appendChild($meta); $meta = $dom->createElement('meta'); $meta->setAttribute('name', 'twitter:description'); $meta->setAttribute('content', $widgets->description); $metas->appendChild($meta); $meta = $dom->createElement('meta'); $meta->setAttribute('name', 'description'); $meta->setAttribute('content', $widgets->description); $metas->appendChild($meta); } else { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $meta = $dom->createElement('meta'); $meta->setAttribute('name', 'description'); $meta->setAttribute('content', $config->description); $metas->appendChild($meta); } if (isset($widgets->url)) { $meta = $dom->createElement('meta'); $meta->setAttribute('property', 'og:url'); $meta->setAttribute('content', $widgets->url); $metas->appendChild($meta); } $meta = $dom->createElement('meta'); $meta->setAttribute('property', 'og:type'); $meta->setAttribute('content', 'article'); $metas->appendChild($meta); $meta = $dom->createElement('meta'); $meta->setAttribute('property', 'twitter:card'); $meta->setAttribute('content', 'summary_large_image'); $metas->appendChild($meta); $meta = $dom->createElement('meta'); $meta->setAttribute('property', 'twitter:site'); $meta->setAttribute('content', 'MovimNetwork'); $metas->appendChild($meta); echo strip_tags($dom->saveXML($dom->documentElement), '<meta>'); }
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); }
private function setLogLevel() { // We set the default timezone to the server timezone $cd = new \Modl\ConfigDAO(); $config = $cd->get(); define('LOG_LEVEL', (int) $config->loglevel); }