1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00

Upgrade to movim 20150810

This commit is contained in:
src386 2015-08-10 23:42:45 +02:00
parent b72c9e176c
commit ca10b3e3df
42 changed files with 348 additions and 325 deletions

View file

@ -8,4 +8,4 @@ DO NOT USE
**Changelog**
Current Movim version : 20150731.
Current Movim version : 20150810.

View file

@ -49,10 +49,9 @@ sudo su -c "cd $final_path && php composer.phar install" -s /bin/sh www-data
# Movim configuration
sudo cp $final_path/config/db.example.inc.php $final_path/config/db.inc.php
sudo sed -i "s/yhuser/$db_user/g" $final_path/config/db.inc.php
sudo sed -i "s/yhpwd/$db_pwd/g" $final_path/config/db.inc.php
sudo sed -i "s/yhdb/$db_user/g" $final_path/config/db.inc.php
sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/app/assets/js/movim_websocket.js
sudo sed -i "s@username@$db_user@g" $final_path/config/db.inc.php
sudo sed -i "s@password@$db_pwd@g" $final_path/config/db.inc.php
sudo sed -i "s@/ws/@$path/ws/" $final_path/app/assets/js/movim_websocket.js
sudo su -c "cd $final_path && php mud.php db set" -s /bin/sh www-data
sudo su -c "cd $final_path && php mud.php config locale:$language"
sudo su -c "cd $final_path && php mud.php config loglevel:1"

14
sources/.bzrignore Executable file
View file

@ -0,0 +1,14 @@
*~
*#*
cache.tmp
log/*
locales/files.list
*.pdf
*.swp
./cache
./config/*
./lib/Modl
./lib/Moxl
./users/*
./log

4
sources/.dir-locals.el Executable file
View file

@ -0,0 +1,4 @@
((nil . ((indent-tabs-mode . nil)
(tab-width . 4)
(fill-column . 80)))
(c-mode . ((c-file-style . "stroustrup"))))

8
sources/.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
/vendor
/log
/users
/cache
*~
/config/db.inc.php
/composer.lock
/composer.phar

22
sources/.htaccess Executable file
View file

@ -0,0 +1,22 @@
Options -Indexes
AddType application/x-web-app-manifest+json .webapp
<IfModule mod_rewrite.c>
# Tell PHP that the mod_rewrite module is ENABLED.
SetEnv HTTP_MOD_REWRITE 1
# If you have troubles or use VirtualDocumentRoot
# uncomment this and set it to the path where your Movim installation is
# i.e.:
# Movim url: http://example.com
# RewriteBase /
# Movim url: http://some.example.com/movim
# RewriteBase /movim/
RewriteBase /0.9/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?query=$1 [L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

View file

@ -1,6 +1,6 @@
/**
* Movim Javascript Template functions
*
*
* These are the default callback functions that users may (or may not) use.
*
* Note that all of them take only one parameter. Don't be fooled by this, the
@ -86,6 +86,13 @@ var MovimTpl = {
return false;
}
},
isPanelScrolled : function() {
var selector = document.querySelector('main section > div:first-child:nth-last-child(2) ~ div div');
if(selector != null) {
return (selector.scrollHeight - selector.scrollTop === selector.clientHeight);
}
},
scrollPanel : function() {
var selector = document.querySelector('main section > div:first-child:nth-last-child(2) ~ div div');
@ -116,9 +123,12 @@ var MovimTpl = {
return;
}
//if(!document.querySelector(element).contains(e.target))
//if(!document.querySelector(element).contains(e.target))
movim_remove_class(element, classname);
},
toggleActionButton : function() {
movim_toggle_class('.button.action', 'active');
},
hideContextMenu : function() {
movim_remove_class('ul.context_menu', 'shown');
},

View file

@ -41,9 +41,9 @@ var MovimWebsocket = {
init : function() {
if(SECURE_WEBSOCKET) {
var uri = 'wss://' + BASE_HOST + 'PATHTOCHANGE/ws/';
var uri = 'wss://' + BASE_HOST + '/ws/';
} else {
var uri = 'ws://' + BASE_HOST + 'PATHTOCHANGE/ws/';
var uri = 'ws://' + BASE_HOST + '/ws/';
}
this.connection = new WebSocket(uri);

View file

@ -309,7 +309,7 @@ function stringToColor($string) {
}
/**
* Return the first letter of a string
* Return the first two letters of a string
* @param string
* @return string
*/

View file

@ -2,8 +2,7 @@
namespace Modl;
class Config extends Model {
public $environment;
class Config extends Model {
public $description;
public $theme;
public $locale;
@ -17,43 +16,40 @@ class Config extends Model {
public $password;
public $rewrite;
public $sizelimit;
public function __construct() {
$this->_struct = '
{
"environment" :
{"type":"string", "size":64, "mandatory":true },
"description" :
"description" :
{"type":"text" },
"theme" :
"theme" :
{"type":"string", "size":32, "mandatory":true },
"locale" :
"locale" :
{"type":"string", "size":8, "mandatory":true },
"maxusers" :
"maxusers" :
{"type":"int", "size":16 },
"loglevel" :
"loglevel" :
{"type":"string", "size":16, "mandatory":true },
"timezone" :
"timezone" :
{"type":"string", "size":16, "mandatory":true },
"xmppwhitelist" :
"xmppwhitelist" :
{"type":"text" },
"info" :
"info" :
{"type":"text" },
"unregister" :
"unregister" :
{"type":"int", "size":1 },
"username" :
"username" :
{"type":"string", "size":32, "mandatory":true },
"password" :
"password" :
{"type":"string", "size":64, "mandatory":true },
"rewrite" :
"rewrite" :
{"type":"int", "size":1 },
"sizelimit" :
"sizelimit" :
{"type":"int", "size":16 }
}';
parent::__construct();
$this->environment = 'development';
$this->description = __('global.description');
$this->theme = 'material';
$this->locale = 'en';

View file

@ -6,8 +6,7 @@ class ConfigDAO extends SQL {
function set(Config $c) {
$this->_sql = '
update config
set environment = :environment,
description = :description,
set description = :description,
theme = :theme,
locale = :locale,
maxusers = :maxusers,
@ -20,11 +19,10 @@ class ConfigDAO extends SQL {
password = :password,
rewrite = :rewrite,
sizelimit = :sizelimit';
$this->prepare(
'Config',
array(
'environment' => $c->environment,
'Config',
array(
'description' => $c->description,
'theme' => $c->theme,
'locale' => $c->locale,
@ -40,25 +38,24 @@ class ConfigDAO extends SQL {
'sizelimit' => $c->sizelimit
)
);
$this->run('Config');
if(!$this->_effective) {
$this->_sql = '
truncate table config;';
$this->prepare(
'Config',
'Config',
array(
)
);
$this->run('Config');
$this->_sql = '
insert into config
(
environment,
description,
theme,
locale,
@ -75,7 +72,6 @@ class ConfigDAO extends SQL {
)
values
(
:environment,
:description,
:theme,
:locale,
@ -91,11 +87,10 @@ class ConfigDAO extends SQL {
:sizelimit
)
';
$this->prepare(
'Config',
'Config',
array(
'environment' => $c->environment,
'description' => $c->description,
'theme' => $c->theme,
'locale' => $c->locale,
@ -111,7 +106,7 @@ class ConfigDAO extends SQL {
'sizelimit' => $c->sizelimit
)
);
$this->run('Config');
}
}
@ -121,7 +116,7 @@ class ConfigDAO extends SQL {
select * from config';
$this->prepare('Config', array());
$conf = $this->run('Config', 'item');
if(!isset($conf))

View file

@ -84,6 +84,24 @@ class Postn extends Model {
parent::__construct();
}
private function getContent($contents) {
$content = '';
foreach($contents as $c) {
switch($c->attributes()->type) {
case 'html':
case 'xhtml':
return (string)$c->asXML();
break;
case 'text':
default :
$content = (string)$c;
break;
}
}
return $content;
}
public function set($item, $from, $delay = false, $node = false) {
if($item->item)
$entry = $item->item;
@ -125,16 +143,7 @@ class Postn extends Model {
$summary = '';
if($entry->entry && $entry->entry->content) {
if((string)$entry->entry->content->attributes()->type == 'text')
$content = (string)$entry->entry->content;
elseif(
(string)$entry->entry->content->attributes()->type == ('html' || 'xhtml')
//&& $entry->entry->content->html
//&& $entry->entry->content->html->body
) {
$content = (string)$entry->entry->content/*->html->body*/->asXML();
} else
$content = (string)$entry->entry->content;
$content = $this->getContent($entry->entry->content);
} elseif($summary == '')
$content = __('');
else

View file

@ -14,7 +14,7 @@
*
* See COPYING for licensing information.
*/
class AdminMain extends WidgetBase
{
function load() {
@ -46,7 +46,7 @@ class AdminMain extends WidgetBase
}
$cd->set($config);
//set timezone
if(isset($form['timezone'])) {
date_default_timezone_set($form['timezone']);
@ -71,7 +71,7 @@ class AdminMain extends WidgetBase
{
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
$this->view->assign('conf', $cd->get());
$this->view->assign('logs',
array(
@ -79,11 +79,6 @@ class AdminMain extends WidgetBase
1 => $this->__('log.syslog'),
2 => $this->__('log.syslog_files'))
);
$this->view->assign('envs',
array(
'development' => 'Development',
'production' => 'Production')
);
$this->view->assign('bosh_info4',
$this->__('bosh.info4', '<a href="http://wiki.movim.eu/en:install">', '</a>'));
@ -99,7 +94,7 @@ class AdminMain extends WidgetBase
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());
}

View file

@ -7,7 +7,7 @@
<div class="select">
<select id="locale" name="locale">
<option value="en">English (default)</option>';
{loop="$langs"}
{loop="$langs"}
<option value="{$key}"
{if="$conf->locale == $key"}
selected="selected"
@ -19,22 +19,6 @@
</div>
</div>
<div>
<label for="da">{$c->__('general.environment')}</label>
<div class="select">
<select id="environment" name="environment">';
{loop="$envs"}
<option value="{$key}"
{if="$conf->environment == $key"}
selected="selected"
{/if}>
{$value}
</option>
{/loop}
</select>
</div>
</div>
<!--
<div>
<input type="text" name="sizelimit" id="sizelimit" value="{$conf->sizelimit}" />
@ -44,7 +28,7 @@
<div>
<div class="select">
<select id="loglevel" name="loglevel">
{loop="$logs"}
{loop="$logs"}
<option value="{$key}"
{if="$conf->loglevel == $key"}
selected="selected"
@ -122,7 +106,7 @@
<br />
<h3>{$c->__('rewrite.title')}</h3>
<div>
<ul class="thick simple">
<li class="action">
@ -146,7 +130,7 @@
<br />
<h3>{$c->__('credentials.title')}</h3>
{if="$conf->user == 'admin' || $conf->pass == sha1('password')"}
<div class="message error">
{$c->__('credentials.info')}
@ -158,19 +142,19 @@
<input type="text" id="username" name="username" value="{$conf->username}"/>
</div>
<div class="clear"></div>
<div>
<input type="password" id="password" name="password" value=""/>
<label for="password">{$c->__('credentials.password')}</label>
</div>
</div>
<div>
<input type="password" id="repassword" name="repassword" value=""/>
<label for="repassword">{$c->__('credentials.re_password')}</label>
</div>
<input
type="submit"
class="button color green oppose"
<input
type="submit"
class="button color green oppose"
value="{$c->__('button.submit')}"/>
<div class="clear"></div>
</form>

View file

@ -4,7 +4,6 @@ general = General Settings
[general]
theme = Theme
language = Default language
environment = Environment
log_verbosity = Log verbosity
timezone = Server Timezone
limit = User folder size limit (in bytes)

View file

@ -37,7 +37,7 @@
<li class="subheader">
{$c->__('compatibility.info')}
</li>
{if="$dbconnected"}
{if="$dbinfos > 0"}
<li>
@ -56,22 +56,13 @@
{/if}
<li id="websocket_error">
<span class="icon bubble color red">
<i class="zmdi zmdi-code-setting"></i>
</span>
<span>
{$c->__('compatibility.websocket')}
</span>
</li>
<!--<li id="xmpp_websocket_error">
<span class="icon bubble color red">
<i class="zmdi zmdi-code-setting"></i>
</span>
<span>
{$c->__('compatibility.xmpp_websocket')} <code>{$websocketurl}</code>
{$c->__('compatibility.websocket')}
</span>
</li>-->
</li>
{if="!$c->version()"}
<li class="condensed">
@ -121,11 +112,10 @@
{if="!$_SERVER['HTTP_MOD_REWRITE']"}
<li>
<span class="icon bubble color orange">
<i class="zmdi zmdi-mode-edit"></i>
<i class="zmdi zmdi-edit"></i>
</span>
<span>{$c->__('compatibility.rewrite')}</span>
</li>
{/if}
</ul>
<!--<script type="text/javascript">AdminTest.testXMPPWebsocket('{$websocketurl}');</script>-->
</div>

View file

@ -14,7 +14,7 @@
*
* See COPYING for licensing information.
*/
class Api extends WidgetBase {
function load()
{
@ -30,7 +30,7 @@ class Api extends WidgetBase {
'</a>',
'<a href="'.$this->route('pods').'">',
'</a>'));
$json = requestURL(MOVIM_API.'status', 1, array('uri' => BASE_URI));
$json = json_decode($json);
@ -55,10 +55,15 @@ class Api extends WidgetBase {
function ajaxRegister()
{
$rewrite = false;
if(isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) {
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
if($config->rewrite/*isset($_SERVER['HTTP_MOD_REWRITE'])
&& $_SERVER['HTTP_MOD_REWRITE']*/) {
$rewrite = true;
}
}
$json = requestURL(
MOVIM_API.'register',
1,
@ -78,7 +83,7 @@ class Api extends WidgetBase {
{
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
$config->unregister = !$config->unregister;
$cd->set($config);

View file

@ -75,7 +75,7 @@ class Chat extends WidgetBase
Notification::append('chat|'.$from, $contact->getTrueName(), $message->body, $avatar, 4);
}
RPC::call('movim_fill', $from.'_state', '');
RPC::call('movim_fill', $from.'_state', $contact->jid);
// If the message is from me
} /*else {
$from = $message->jidto;
@ -90,7 +90,6 @@ class Chat extends WidgetBase
if(!preg_match('#^\?OTR#', $message->body)) {
RPC::call('Chat.appendMessage', $this->prepareMessage($message));
}
RPC::call('MovimTpl.scrollPanel');
}
function onComposing($array)
@ -154,7 +153,7 @@ class Chat extends WidgetBase
$html = $view->draw('_chat_state', true);
RPC::call('movim_fill', $jid.'_state', $html);
RPC::call('MovimTpl.scrollPanel');
//RPC::call('MovimTpl.scrollPanel');
}
/**

View file

@ -2,7 +2,6 @@
<section id="{$jid}_messages">
<ul class="{if="$muc"}thin simple{else}middle{/if}" id="{$jid}_conversation"></ul>
</section>
<div id="{$jid}_state"></div>
</div>
<div class="chat_box">
<ul class="thin">
@ -15,7 +14,7 @@
</div>
<form>
<div>
<textarea
<textarea
rows="1"
id="chat_textarea"
data-jid="{$jid}"

View file

@ -17,7 +17,7 @@
</span>
</li>
</ul>
<div id="chat_header" class="return active r1" onclick="MovimTpl.hidePanel(); Chat_ajaxGet();">
<div id="chat_header" class="return active r1 condensed" onclick="MovimTpl.hidePanel(); Chat_ajaxGet();">
<span id="back" class="icon"><i class="zmdi zmdi-arrow-back"></i></span>
<h2>
{if="$contact != null"}
@ -26,5 +26,6 @@
{$jid|echapJS}
{/if}
</h2>
<h4 id="{$jid}_state">{$contact->jid}</h4>
</h2>
</div>

View file

@ -1,5 +1 @@
<ul class="simple thin">
<li>
<p>{$message}</p>
</li>
</ul>
{$message}

View file

@ -54,6 +54,8 @@ var Chat = {
var bubble = null;
var id = null;
var scrolled = MovimTpl.isPanelScrolled();
if(message.type == 'groupchat') {
bubble = Chat.room.cloneNode(true);
@ -115,7 +117,7 @@ var Chat = {
}
}
MovimTpl.scrollPanel();
if(scrolled) MovimTpl.scrollPanel();
}
}

View file

@ -4,7 +4,15 @@
<h1>{$c->__('chats.empty_title')}</h1>
<h4>{$c->__('chats.empty')}</h4>
</div>
<a onclick="Chats_ajaxAdd()" class="button action color">
<a class="button action color" onclick="MovimTpl.toggleActionButton()">
<i class="zmdi zmdi-plus"></i>
<ul class="actions">
<li onclick="Chats_ajaxAdd()">
<i class="zmdi zmdi-account-add"></i>
</li>
<li onclick="Rooms_ajaxAdd()">
<i class="zmdi zmdi-accounts-add"></i>
</li>
</ul>
</a>

View file

@ -39,7 +39,9 @@
</ul>
</header>
<section>
{$value->contentcleaned}
<content>
{$value->contentcleaned}
</content>
</section>
<footer>
<ul class="thin">

View file

@ -1,12 +1,5 @@
<div>
<ul class="active">
<li onclick="Rooms_ajaxAdd()">
<span class="icon">
<i class="zmdi zmdi-accounts-add"></i>
</span>
</li>
</ul>
<span id="menu" class="on_mobile icon active" onclick="MovimTpl.toggleMenu()"><i class="zmdi zmdi-menu"></i></span>
<span class="on_desktop icon"><i class="zmdi zmdi-comments"></i></span>
<h2 class="r1">{$c->__('page.chats')}</h2>
<h2>{$c->__('page.chats')}</h2>
</div>

View file

@ -77,14 +77,27 @@
{else}
<span>{$c->__('hello.contact_post')}</span>
{/if}
<span class="info">{$value->published|strtotime|prepareDate}</span>
<p class="more">
{if="current(explode('.', $value->origin)) != 'nsfw'"}
{$value->contentcleaned|strip_tags:'<img><img/>'}
<p>
{if="$value->node == 'urn:xmpp:microblog:0'"}
<a href="{$c->route('contact', $value->getContact()->jid)}">
<i class="zmdi zmdi-account"></i> {$value->getContact()->getTrueName()}
</a>
{else}
{$value->origin} /
<a href="{$c->route('group', array($value->origin, $value->node))}">
<i class="zmdi zmdi-pages"></i> {$value->node}
</a>
{/if}
{$value->published|strtotime|prepareDate}
</p>
{if="$value->privacy"}
<span class="info" title="{$c->__('menu.public')}">
<i class="zmdi zmdi-portable-wifi"></i>
</span>
{/if}
<p>{$value->contentcleaned|strip_tags}</p>
</li>
{/loop}
<a href="{$c->route('news')}">

View file

@ -37,6 +37,7 @@
{else}
<span class="icon thumb color {$value->node|stringToColor}">{$value->node|firstLetterCapitalize}</span>
{/if}
{if="$value->title != null"}
<span>{$value->title}</span>
{else}
@ -48,6 +49,7 @@
<i class="zmdi zmdi-account"></i> {$value->getContact()->getTrueName()}
</a>
{else}
{$value->origin} /
<a href="{$c->route('group', array($value->origin, $value->node))}">
<i class="zmdi zmdi-pages"></i> {$value->node}
</a>

View file

@ -47,6 +47,7 @@
</a>
{/if}
{if="$post->node != 'urn:xmpp:microblog:0'"}
{$post->origin} /
<a href="{$c->route('group', array($post->origin, $post->node))}">
<i class="zmdi zmdi-pages"></i> {$post->node}
</a>
@ -58,7 +59,9 @@
</header>
<section>
{$post->contentcleaned}
<content>
{$post->contentcleaned}
</content>
</section>
<footer>
@ -127,7 +130,7 @@
</div>
</form>
<span class="icon gray">
<i class="zmdi zmdi-public"></i>
<i class="zmdi zmdi-portable-wifi"></i>
</span>
<span>
<a target="_blank" href="{$c->route('blog', array($post->origin))}">

View file

@ -28,6 +28,7 @@
{/if}
</span>
<p>
{$value->origin} /
<a href="{$c->route('group', array($value->origin, $value->node))}">
<i class="zmdi zmdi-pages"></i> {$value->node}
</a>

View file

@ -144,6 +144,7 @@ class Publish extends WidgetBase
$p = new PostPublish;
$p->setFrom($this->user->getLogin())
->setTo($form->to->value)
->setContent($form->content->value)
->setNode($form->node->value);
//->setLocation($geo)
//->enableComments()

View file

@ -25,23 +25,18 @@ class System extends WidgetBase {
$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', '');
if(FAIL_SAFE != null)
$this->view->assign('fail_safe', FAIL_SAFE);
else
$this->view->assign('fail_safe', '');
$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

View file

@ -3,7 +3,6 @@
var BASE_HOST = '{$base_host}';
var ERROR_URI = '{$error_uri}';
var PAGE_KEY_URI = '{$page_key_uri}';
var FAIL_SAFE = '{$fail_safe}';
var CURRENT_PAGE = '{$current_page}';
var SERVER_CONF = {$server_conf};
var SECURE_WEBSOCKET= {$secure_websocket};

View file

@ -9,7 +9,7 @@ use Monolog\Handler\SyslogHandler;
/**
* Error Handler...
*/
function systemErrorHandler($errno, $errstr, $errfile, $errline, $errcontext = null)
function systemErrorHandler($errno, $errstr, $errfile, $errline, $errcontext = null)
{
$log = new Logger('movim');
$log->pushHandler(new SyslogHandler('movim'));
@ -17,6 +17,29 @@ function systemErrorHandler($errno, $errstr, $errfile, $errline, $errcontext = n
return false;
}
function fatalErrorShutdownHandler()
{
$last_error = error_get_last();
if($last_error['type'] === E_ERROR) {
systemErrorHandler(
E_ERROR,
$last_error['message'],
$last_error['file'],
$last_error['line']);
if (ob_get_contents()) ob_clean();
?>
<div style="font-family: Arial; text-align: center;">
<h2>Oops... something went wrong.</h2>
<p>But don't panic. The NSA is on the case.</p>
</div>
<?php
if (ob_get_contents()) ob_end_clean();
}
}
/**
* Manage boot order
*/
@ -24,22 +47,22 @@ class Bootstrap {
function boot($light = false) {
//define all needed constants
$this->setConstants();
mb_internal_encoding("UTF-8");
//First thing to do, define error management (in case of error forward)
$this->setLogs();
//Check if vital system need is OK
$this->checkSystem();
if(!$light) $this->setBrowserSupport();
$this->loadSystem();
$this->loadCommonLibraries();
$this->loadDispatcher();
$this->loadHelpers();
$loadmodlsuccess = $this->loadModl();
$this->setTimezone();
@ -59,7 +82,7 @@ class Bootstrap {
DOCUMENT_ROOT.'/cache/test.tmp',
);
$errors=array();
if(!is_writable(DOCUMENT_ROOT))
$errors[] = 'We\'re unable to write to folder '.DOCUMENT_ROOT.': check rights';
else {
@ -78,12 +101,12 @@ class Bootstrap {
touch(DOCUMENT_ROOT.'/users/index.html');
}
}
foreach($listWritableFile as $fileName) {
if (!file_exists($fileName)) {
if (touch($fileName) !== true) {
$errors[] = 'We\'re unable to write to '.$fileName.': check rights';
}
}
}else if (is_writable($fileName) !== true) {
$errors[] = 'We\'re unable to write to file '.$fileName.': check rights';
}
@ -111,9 +134,9 @@ class Bootstrap {
define('BASE_URI', $this->getBaseUri());
define('CACHE_URI', $this->getBaseUri() . 'cache/');
define('SESSION_ID', getenv('sid'));
define('THEMES_PATH', DOCUMENT_ROOT . '/themes/');
define('USERS_PATH', DOCUMENT_ROOT . '/users/');
define('APP_PATH', DOCUMENT_ROOT . '/app/');
@ -122,13 +145,13 @@ class Bootstrap {
define('LOCALES_PATH', DOCUMENT_ROOT . '/locales/');
define('CACHE_PATH', DOCUMENT_ROOT . '/cache/');
define('LOG_PATH', DOCUMENT_ROOT . '/log/');
define('VIEWS_PATH', DOCUMENT_ROOT . '/app/views/');
define('HELPERS_PATH', DOCUMENT_ROOT . '/app/helpers/');
define('WIDGETS_PATH', DOCUMENT_ROOT . '/app/widgets/');
define('MOVIM_API', 'https://api.movim.eu/');
if (!defined('DOCTYPE')) {
define('DOCTYPE','text/html');
}
@ -136,7 +159,7 @@ class Bootstrap {
private function isServerSecured() {
if((
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "")
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "")
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https")) {
return true;
}
@ -150,7 +173,7 @@ class Bootstrap {
return trim(fgets($f));
}
}
private function getBaseUri() {
$dirname = dirname($_SERVER['PHP_SELF']);
$path = (($dirname == DIRECTORY_SEPARATOR) ? '' : $dirname).'/';
@ -175,7 +198,7 @@ class Bootstrap {
return $uri;
}
}
private function loadSystem() {
// Loads up all system libraries.
require_once(SYSTEM_PATH . "/i18n/i18n.php");
@ -186,16 +209,15 @@ class Bootstrap {
require_once(SYSTEM_PATH . "UtilsPicture.php");
require_once(SYSTEM_PATH . "Cache.php");
require_once(SYSTEM_PATH . "Event.php");
require_once(SYSTEM_PATH . "MovimException.php");
require_once(SYSTEM_PATH . "RPC.php");
require_once(SYSTEM_PATH . "User.php");
require_once(SYSTEM_PATH . "Picture.php");
}
private function loadCommonLibraries() {
// XMPPtoForm lib
require_once(LIB_PATH . "XMPPtoForm.php");
// SDPtoJingle and JingletoSDP lib :)
require_once(LIB_PATH . "SDPtoJingle.php");
require_once(LIB_PATH . "JingletoSDP.php");
@ -206,7 +228,7 @@ class Bootstrap {
require $file;
}
}
private function loadDispatcher() {
require_once(SYSTEM_PATH . "template/TplPageBuilder.php");
require_once(SYSTEM_PATH . "controllers/BaseController.php");
@ -232,7 +254,7 @@ class Bootstrap {
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
if($user->isLogged()) {
$lang = $user->getConfig('language');
if(isset($lang)) {
@ -249,41 +271,15 @@ class Bootstrap {
loadLanguage($config->locale);
}
}
private function setLogs() {
/*$cd = new \Modl\ConfigDAO();
$config = $cd->get();
try {
define('ENVIRONMENT', $config->environment);
} catch (Exception $e) {
define('ENVIRONMENT','development');//default environment is production
}*/
define('ENVIRONMENT','development');//default environment is production
/**
* LOG_MANAGEMENT: define where logs are saved, prefer error_log, or log_folder if you use mutual server.
* 'error_log' : save in file defined on your file server
* 'log_folder' : save in log folder, in DOCUMENT_ROOT.'/log'
* 'syslog' : save in global system logs (not in file server logs)
*/
define('LOG_MANAGEMENT','log_folder');
if (ENVIRONMENT === 'development') {
ini_set('log_errors', 1);
ini_set('display_errors', 0);
ini_set('error_reporting', E_ALL );
} else {
ini_set('log_errors', 1);
ini_set('display_errors', 0);
ini_set('error_reporting', E_ALL ^ E_DEPRECATED ^ E_NOTICE);
}
if (LOG_MANAGEMENT === 'log_folder') {
ini_set('error_log', DOCUMENT_ROOT.'/log/php.log');
}
ini_set('display_errors', 0);
ini_set('error_log', DOCUMENT_ROOT.'/log/php.log');
set_error_handler('systemErrorHandler', E_ALL);
register_shutdown_function('fatalErrorShutdownHandler');
}
private function setTimezone() {
// We set the default timezone to the server timezone
$cd = new \Modl\ConfigDAO();
@ -291,7 +287,7 @@ class Bootstrap {
// And we set a global offset
define('TIMEZONE_OFFSET', getTimezoneOffset($config->timezone));
date_default_timezone_set($config->timezone);
}
@ -307,7 +303,7 @@ class Bootstrap {
// We load Movim Data Layer
$db = Modl\Modl::getInstance();
$db->setModelsPath(APP_PATH.'models');
Modl\Utils::loadModel('Config');
Modl\Utils::loadModel('Presence');
Modl\Utils::loadModel('Contact');
@ -327,13 +323,13 @@ class Bootstrap {
} else {
throw new MovimException('Cannot find config/db.inc.php file');
}
$db->setConnectionArray($conf);
$db->connect();
return true;
}
private function setBrowserSupport() {
if(isset( $_SERVER['HTTP_USER_AGENT'])) {
$useragent = $_SERVER['HTTP_USER_AGENT'];
@ -366,7 +362,7 @@ class Bootstrap {
switch($browser) {
case 'Firefox':
if($browser_version > 3.5)
if($browser_version > 30.0)
$compatible = true;
break;
case 'IE':
@ -385,7 +381,7 @@ class Bootstrap {
define('BROWSER_COMP', $compatible);
}
private function startingSession() {
$s = \Sessionx::start();
$s->load();

View file

@ -5,13 +5,13 @@ $conf = array(
# The type can be 'pgsql' or 'mysql'
'type' => 'mysql',
# The database username
'username' => 'yhuser',
'username' => 'username',
# The password
'password' => 'yhpwd',
'password' => 'password',
# Where can we find the database ?
'host' => 'localhost',
# The port number, 3306 for MySQL and 5432 for PostGreSQL
'port' => 3306,
# The database name
'database' => 'yhdb'
'database' => 'movim'
);

View file

@ -30,7 +30,7 @@ if($argsize == 2) {
}
$md = Modl\Modl::getInstance();
$infos = $md->check();
$infos = $md->check();
if($infos != null) {
echo colorize("The database need to be updated before running the daemon\n", 'green');
@ -40,7 +40,7 @@ if($infos != null) {
echo colorize("\nTo update the database run\n", 'green');
echo colorize("php mud.php db set\n", 'purple');
exit;
break;
}

View file

@ -40,52 +40,13 @@
define('DOCUMENT_ROOT', dirname(__FILE__));
require_once(DOCUMENT_ROOT.'/bootstrap.php');
use Monolog\Logger;
use Monolog\Handler\SyslogHandler;
$bootstrap = new Bootstrap();
try {
if((isset($_GET['q']) && $_GET['q'] == 'admin') ||
(isset($_GET['query']) && $_GET['query'] == 'admin')
)
define('FAIL_SAFE', true);
else
define('FAIL_SAFE', false);
$bootstrap = new Bootstrap();
$bootstrap->boot();
$bootstrap->boot();
$rqst = new FrontController();
$rqst->handle();
$rqst = new FrontController();
$rqst->handle();
WidgetWrapper::getInstance(false);
// Closing stuff
WidgetWrapper::destroyInstance();
} catch (Exception $e) {
$log = new Logger('movim');
$log->pushHandler(new SyslogHandler('movim'));
$log->addInfo($e->getMessage());
if (ENVIRONMENT === 'development' && !FAIL_SAFE) {
?>
<div id="final_exception" class="error debug">
<h2>An error happened</h2>
<p><?php print $e->getMessage();?></p>
</div>
<?php
} elseif(!FAIL_SAFE) {
?>
<div class="carreful">
<h2> Oops... something went wrong.</h2>
<p>But don't panic. The NSA is on the case.</p>
</div>
<?php
}
if(FAIL_SAFE) {
$r = new Route;
$rqst = new FrontController();
$rqst->handle();
}
}
WidgetWrapper::getInstance(false);
// Closing stuff
WidgetWrapper::destroyInstance();

View file

@ -50,9 +50,13 @@ $stdin_behaviour = function ($data) use (&$conn, $loop, &$buffer, &$connector, &
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
$domain = \Moxl\Utils::getDomain($msg->host);
$port = 5222;
$dns = \Moxl\Utils::resolveHost($msg->host);
if(isset($dns[0]['target']) && $dns[0]['target'] != null) $msg->host = $dns[0]['target'];
if(isset($dns[0]['port']) && $dns[0]['port'] != null) $port = $dns[0]['port'];
#fwrite(STDERR, colorize('open a socket to '.$domain, 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
$connector->create($domain, 5222)->then($xmpp_behaviour);
$connector->create($msg->host, $port)->then($xmpp_behaviour);
}
} else {
return;

View file

@ -1,26 +0,0 @@
<?php
/**
* \brief Movim's custom exception class.
*
* Merely adds a line break to the messages so far. Is expected to become more
* useful in the future.
*/
class MovimException extends Exception
{
/**
* Forces to add a message.
*/
public function __construct($message, $code = 0) {
parent::__construct('Error: ' . $message, $code);
}
/**
* Output proper html error reports.
*/
function __toString() {
return $this->code . ' - ' . $this->message . '<br />';
}
}
?>

View file

@ -1,8 +1,8 @@
<?php
<?php
class Route extends \BaseController {
public $_routes;
private $_page;
public function __construct() {
$this->_routes = array(
'about' => array('x'),
@ -29,7 +29,7 @@ class Route extends \BaseController {
'visio' => false
);
}
public function find() {
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
@ -43,13 +43,13 @@ class Route extends \BaseController {
if(isset($this->_routes[$this->_page]))
$route = $this->_routes[$this->_page];
if(count($request) && isset($route)) {
$i = 0;
foreach($route as $key) {
if (isset($request[$i])) {
$_GET[$key] = $request[$i];
}
}
$i++;
}
}
@ -65,7 +65,7 @@ class Route extends \BaseController {
return $this->_page;
}
public static function urlize($page, $params = false, $tab = false) {
$r = new Route();
$routes = $r->_routes;
@ -75,8 +75,8 @@ class Route extends \BaseController {
if($page === 'root')
return BASE_URI;
if(isset($routes[$page])) {
if(isset($routes[$page])) {
//if($params != false && count($routes[$page]) != count($params)) {
//throw new Exception(__('error.route', $page));
//} else {
@ -84,8 +84,8 @@ class Route extends \BaseController {
$tab = '#'.$tab;
// Here we got a beautiful rewriten URL !
if($config->rewrite == true
&& isset($_SERVER['HTTP_MOD_REWRITE'])
&& $_SERVER['HTTP_MOD_REWRITE']) {
/*&& isset($_SERVER['HTTP_MOD_REWRITE'])
&& $_SERVER['HTTP_MOD_REWRITE']*/) {
$uri = BASE_URI . $page;
if($params != false && is_array($params))
foreach($params as $value)
@ -96,7 +96,7 @@ class Route extends \BaseController {
//We construct a classic URL if the rewriting is disabled
else {
$uri = BASE_URI . '?q=' . $page;
if($params != false && is_array($params)) {
$i = 0;
foreach($params as $value) {

View file

@ -21,7 +21,7 @@ class Sessionx {
protected static $_instance;
private $_max_age = 86400; // 24hour
private $_timestamp;
private $_rid;
private $_id;
@ -49,8 +49,8 @@ class Sessionx {
self::$_sessionid = $_COOKIE['MOVIM_SESSION_ID'];
} elseif(SESSION_ID) {
self::$_sessionid = SESSION_ID;
} else {
$key = generateKey(32);
} elseif(!headers_sent()) {
$key = generateKey(32);
setcookie("MOVIM_SESSION_ID", $key, time()+$this->_max_age, '/', false, APP_SECURED);
self::$_sessionid = $key;
}
@ -85,11 +85,11 @@ class Sessionx {
$s->rid = $this->_rid;
$s->sid = $this->_sid;
$s->id = $this->_id;
$s->port = $this->_port;
$s->host = $this->_host;
$s->domain = $this->_domain;
$s->config = serialize($this->_config);
$s->active = $this->_active;
$s->port = $this->_port;
$s->host = $this->_host;
$s->domain = $this->_domain;
$s->config = serialize($this->_config);
$s->active = $this->_active;
$s->start = $this->_start;
$s->timestamp = $this->_timestamp;
$s->mechanism = $this->_mechanism;
@ -104,10 +104,10 @@ class Sessionx {
$this->_password = $pass;
$this->_resource = 'moxl'.\generateKey(6);
$this->_start = date(DATE_ISO8601);
$this->_rid = rand(1, 2048);
$this->_id = 0;
$sd = new modl\SessionxDAO();
$s = $this->inject();
$sd->init($s);
@ -116,7 +116,7 @@ class Sessionx {
public function load() {
$sd = new modl\SessionxDAO();
$session = $sd->get(self::$_sessionid);
if(isset($session)) {
$this->_user = $session->username;
$this->_password = $session->password;

View file

@ -1,19 +1,19 @@
<?php
/*
* @file WidgetWraper.php
*
*
* @brief Handle the Widgets
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
@ -39,13 +39,13 @@ class WidgetWrapper
public function registerAll($load = false)
{
$widgets_dir = scandir(APP_PATH ."widgets/");
foreach($widgets_dir as $widget_dir) {
if(is_dir(APP_PATH ."widgets/".$widget_dir) &&
if(is_dir(APP_PATH ."widgets/".$widget_dir) &&
$widget_dir != '..' &&
$widget_dir != '.') {
if($load) $this->loadWidget($widget_dir, true);
array_push($this->_widgets, $widget_dir);
array_push($this->_widgets, $widget_dir);
}
}
}
@ -85,7 +85,7 @@ class WidgetWrapper
$path = APP_PATH . "widgets/$name/$name.php";
}
else {
throw new MovimException(
throw new Exception(
__('error.widget_load_error', $name));
}
@ -136,7 +136,7 @@ class WidgetWrapper
if(!is_array($params))
$params = array();
$result = call_user_func_array(array($widget, $method), $params);
$widget = $method = $params = null;

View file

@ -290,7 +290,6 @@ input[type=button].flat:focus {
position: fixed;
bottom: 2rem;
right: 2rem;
border-radius: 10rem;
min-height: 0rem;
min-width: 0rem;
line-height: 7rem;
@ -298,19 +297,33 @@ input[type=button].flat:focus {
width: 7rem;
z-index: 1;
font-size: 3.5rem;
transition: all 0.15s ease 0s;
}
.button.action,
.button.action .actions li {
border-radius: 10rem;
box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.23), 0 0.5rem 1.25rem rgba(0, 0, 0, 0.16);
}
.button.action:hover {
transform: scale(1.1);
/*transform: scale(1.1);*/
background-image: linear-gradient(to bottom, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.1) 100%);
}
/*
.button.action:active {
transform: scale(0.95);
background-image: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.1) 100%);
}
*/
.button.action,
.button.action .actions li,
.button.action > i {
transition: all 0.15s ease 0s;
}
.button.action.active > i {
transform: rotate(135deg);
}
li.action div.action .button {
margin: 0.5rem;
@ -329,3 +342,34 @@ header.big ~ .button.action {
right: calc(70% + 3rem);
}
}
.button.action .actions {
position: absolute;
bottom: 7rem;
left: 0;
padding: 0;
}
.button.action .actions li {
background-color: white;
color: #888;
font-size: 3rem;
line-height: 6rem;
margin: -4rem 0.5rem;
width: 6rem;
height: 6rem;
padding: 0;
opacity: 0;
transition: all 0.15s ease 0s;
pointer-events: none;
}
.button.action.active .actions li {
opacity: 1;
pointer-events: auto;
margin: 2rem 0.5rem;
}
.button.action .actions li:hover {
background-color: white;
}