Browse Source
- Split and rewrite the whole administration
- Split and rewrite the whole administration
- Move the administration in the database - Move the DB configuration in a ini file - Clean some stuffspull/16/head
28 changed files with 586 additions and 599 deletions
-
16app/controllers/AdminloginController.php
-
2app/models/postn/Postn.php
-
4app/views/admin.tpl
-
4app/views/page.tpl
-
432app/widgets/Admin/Admin.php
-
75app/widgets/Admin/_admin_db.tpl
-
11app/widgets/Admin/admin.tpl
-
52app/widgets/AdminDB/AdminDB.php
-
62app/widgets/AdminDB/admindb.tpl
-
12app/widgets/AdminDB/locales.ini
-
75app/widgets/AdminMain/AdminMain.php
-
0app/widgets/AdminMain/admin.js
-
172app/widgets/AdminMain/adminmain.tpl
-
23app/widgets/AdminMain/locales.ini
-
51app/widgets/AdminTest/AdminTest.php
-
36app/widgets/AdminTest/admintest.tpl
-
11app/widgets/AdminTest/locales.ini
-
19app/widgets/Api/Api.php
-
13app/widgets/Infos/Infos.php
-
24app/widgets/Login/Login.php
-
4app/widgets/Login/login.tpl
-
8app/widgets/System/System.php
-
38bootstrap.php
-
15config/db.example.ini
-
5system/Sessionx.php
-
5system/User.php
-
8system/controllers/BaseController.php
-
8system/i18n/i18n.php
@ -1,432 +0,0 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* @package Widgets |
|||
* |
|||
* @file Admin.php |
|||
* This file is part of MOVIM. |
|||
* |
|||
* @brief The administration widget. |
|||
* |
|||
* @author Timothée Jaussoin <edhelas@gmail.com> |
|||
* |
|||
* @version 1.0 |
|||
* @date 25 November 2011 |
|||
* |
|||
* Copyright (C)2010 MOVIM project |
|||
* |
|||
* See COPYING for licensing information. |
|||
*/ |
|||
|
|||
class Admin extends WidgetBase { |
|||
private $_conf; |
|||
private $_validatebutton; |
|||
|
|||
function load() |
|||
{ |
|||
$this->addjs('admin.js'); |
|||
$this->_conf = Conf::getServerConf(); |
|||
|
|||
if(isset($_POST)) { |
|||
$this->saveConfig($_POST); |
|||
$_POST = null; |
|||
} |
|||
} |
|||
|
|||
private function saveConfig($form) { |
|||
if($form['pass'] != '' && $form['repass'] != '' |
|||
&& $form['pass'] == $form['repass']) { |
|||
unset($form['repass']); |
|||
$form['pass'] = sha1($form['pass']); |
|||
} else { |
|||
$form['pass'] = $this->_conf['pass']; |
|||
} |
|||
|
|||
foreach($form as $key => $value) { |
|||
$this->_conf[$key] = $value; |
|||
} |
|||
|
|||
Conf::saveConfFile($this->_conf); |
|||
} |
|||
|
|||
private function isValid($what) |
|||
{ |
|||
if($what) |
|||
return "message success"; |
|||
else |
|||
return "message error"; |
|||
} |
|||
|
|||
private function testDir($dir){ |
|||
return (file_exists($dir) && is_dir($dir) && is_writable($dir)); |
|||
} |
|||
|
|||
private function testFile($file) { |
|||
return (file_exists($file) && is_writable($file)); |
|||
} |
|||
|
|||
private function listThemes() |
|||
{ |
|||
$dir = opendir(DOCUMENT_ROOT.'/themes'); |
|||
$themes = array(); |
|||
|
|||
while($theme = readdir($dir)) { |
|||
if(preg_match('/^\.+$/', $theme) |
|||
|| !is_dir(DOCUMENT_ROOT.'/themes/'.$theme)) { |
|||
continue; |
|||
} |
|||
|
|||
$themes[$theme] = $theme; |
|||
} |
|||
|
|||
return $themes; |
|||
} |
|||
|
|||
private function listLangs() |
|||
{ |
|||
return loadLangArray(); |
|||
} |
|||
|
|||
function testBosh($url) |
|||
{ |
|||
return requestURL($url, 2); |
|||
} |
|||
|
|||
public function ajaxUpdateDatabase() |
|||
{ |
|||
$md = \modl\Modl::getInstance(); |
|||
$md->check(true); |
|||
RPC::call('movim_reload_this'); |
|||
} |
|||
|
|||
function prepareAdminComp() |
|||
{ |
|||
$this->_validatebutton = ' |
|||
<div class="clear"></div> |
|||
<input |
|||
type="submit" |
|||
class="button icon yes color green oppose" |
|||
value="'.__('button.submit').'"/>'; |
|||
|
|||
$html = ' |
|||
<fieldset> |
|||
<legend>'.$this->__('admin.compatibility').'</legend> |
|||
<div class="clear"></div>'; |
|||
|
|||
$html .= |
|||
'<p>'. |
|||
$this->__('compatibility.info'). |
|||
'</p><br />'; |
|||
|
|||
$html .= ' |
|||
<div class="'.$this->isValid((version_compare(PHP_VERSION, '5.3.0') >= 0)).'"> |
|||
'.$this->__('compatibility.php', PHP_VERSION).' |
|||
</div> |
|||
<div class="'.$this->isValid(extension_loaded('curl')).'"> |
|||
'.$this->__('compatibility.curl').' |
|||
</div> |
|||
<div class="'.$this->isValid(extension_loaded('gd')).'"> |
|||
'.$this->__('compatibility.gd').' |
|||
</div> |
|||
<div class="'.$this->isValid(extension_loaded('SimpleXml')).'"> |
|||
'.$this->__('compatibility.simplexml').' |
|||
</div> |
|||
<div class="'.$this->isValid($this->testDir(DOCUMENT_ROOT)).'"> |
|||
'.$this->__('compatibility.rights').' |
|||
</div> |
|||
<div class="'.$this->isValid(extension_loaded('OpenSSL')).'"> |
|||
'.$this->__('compatibility.openssl').' |
|||
</div> |
|||
|
|||
</fieldset> |
|||
|
|||
<fieldset> |
|||
<legend>'.$this->__('compatibility.rewrite').'</legend> |
|||
<div class="clear"></div> |
|||
<div class="'.$this->isValid($_SERVER['HTTP_MOD_REWRITE']).'"> |
|||
'.$this->__('compatibility.rewrite').' |
|||
</div>'; |
|||
|
|||
$html .= ' |
|||
</fieldset>'; |
|||
|
|||
return $html; |
|||
} |
|||
|
|||
function prepareAdminGen() { |
|||
$html .= ' |
|||
<fieldset> |
|||
<legend>'.$this->__('admin.general').'</legend> |
|||
<div class="element"> |
|||
<label for="movim" >'.$this->__('general.theme').'</label> |
|||
<div class="select"> |
|||
<select id="theme" name="theme">'; |
|||
foreach($this->listThemes() as $key => $value) { |
|||
if((string)$this->_conf['theme'] == $key) |
|||
$sel = 'selected="selected"'; |
|||
else |
|||
$sel = ''; |
|||
|
|||
$html .= ' |
|||
<option value="'.$key.'" '.$sel.'>'.$value.'</option>'; |
|||
} |
|||
|
|||
$html .= ' </select> |
|||
</div> |
|||
</div>'; |
|||
|
|||
$html .= ' |
|||
<div class="element"> |
|||
<label for="da">'.$this->__('general.language').'</label> |
|||
<div class="select"> |
|||
<select id="defLang" name="defLang"> |
|||
<option value="en">English (default)</option>'; |
|||
foreach($this->listLangs() as $key => $value) { |
|||
if((string)$this->_conf['defLang'] == $key) |
|||
$sel = 'selected="selected"'; |
|||
else |
|||
$sel = ''; |
|||
|
|||
$html .= ' |
|||
<option value="'.$key.'" '.$sel.'>'.$value.'</option>'; |
|||
} |
|||
|
|||
$html .= ' </select> |
|||
</div> |
|||
</div>'; |
|||
|
|||
$env = array( |
|||
'development' => 'Development', |
|||
'production' => 'Production'); |
|||
|
|||
$html .= ' |
|||
<div class="element"> |
|||
<label for="da">'.$this->__('general.environment').'</label> |
|||
<div class="select"> |
|||
<select id="environment" name="environment">'; |
|||
|
|||
foreach($env as $key => $value) { |
|||
if((string)$this->_conf['environment'] == $key) |
|||
$sel = 'selected="selected"'; |
|||
else |
|||
$sel = ''; |
|||
|
|||
$html .= ' |
|||
<option value="'.$key.'" '.$sel.'>'.$value.'</option>'; |
|||
} |
|||
|
|||
$html .= ' </select> |
|||
</div> |
|||
</div>'; |
|||
|
|||
$html .= ' |
|||
<div class="element"> |
|||
<label for="sizeLimit">'.$this->__('general.limit').'</label> |
|||
<input type="text" name="sizeLimit" id="sizeLimit" value="'.$this->_conf['sizeLimit'].'" /> |
|||
</div>'; |
|||
|
|||
$logopts = array( |
|||
0 => t('Empty'), |
|||
1 => t('Syslog'), |
|||
2 => t('Syslog and Files') |
|||
); |
|||
|
|||
$html .= ' |
|||
<div class="element"> |
|||
<label for="logLevel">'.$this->__('general.log_verbosity').'</label> |
|||
<div class="select"> |
|||
<select id="logLevel" name="logLevel">'; |
|||
foreach($logopts as $lognum => $text) { |
|||
if($this->_conf['logLevel'] == $lognum) |
|||
$sel = 'selected="selected"'; |
|||
else |
|||
$sel = ''; |
|||
|
|||
$html .= ' |
|||
<option value="'.$lognum.'" '.$sel.'>'. |
|||
$text.' |
|||
</option>'; |
|||
} |
|||
$html .= ' </select> |
|||
</div> |
|||
</div>'; |
|||
|
|||
|
|||
$timezones = getTimezoneList(); |
|||
|
|||
$html .= ' |
|||
<div class="element"> |
|||
<label for="timezone">'.$this->__('general.timezone').'</label> |
|||
<div class="select"> |
|||
<select id="timezone" name="timezone">'; |
|||
foreach($timezones as $key => $value) { |
|||
|
|||
if($this->_conf['timezone'] == $key) { |
|||
$sel = 'selected="selected"'; |
|||
} else |
|||
$sel = ''; |
|||
|
|||
$html .= ' |
|||
<option value="'.$key.'" '.$sel.'>'. |
|||
$key.' ('.number_format($value, 2).') |
|||
</option>'; |
|||
} |
|||
$html .= ' </select> |
|||
</div> |
|||
<br /><br /> |
|||
<span class="dTimezone">'.date('l jS \of F Y h:i:s A').'</span> |
|||
</div>'; |
|||
|
|||
$html .= $this->_validatebutton; |
|||
|
|||
$html .= ' |
|||
</fieldset>'; |
|||
|
|||
$html .= ' |
|||
<fieldset> |
|||
<legend>'.$this->__('bosh.title').'</legend> |
|||
<div class="clear"></div>'; |
|||
|
|||
$html .= '<p>'. |
|||
$this->__('bosh.info1').' '. |
|||
$this->__('bosh.info2').' '. |
|||
$this->__('bosh.info3').' '. |
|||
$this->__('bosh.info4', '<a href="http://wiki.movim.eu/install">', '</a>'); |
|||
'</p>'; |
|||
|
|||
if(!$this->testBosh($this->_conf['boshUrl'])) { |
|||
$html .= ' |
|||
<div class="message error">'. |
|||
$this->__('bosh.not_recheable').' |
|||
</div>'; |
|||
} |
|||
|
|||
$html .= ' |
|||
<div class="element"> |
|||
<label for="boshUrl">'.$this->__('bosh.label').'</label> |
|||
<input type="text" id="boshUrl" name="boshUrl" value="'.$this->_conf['boshUrl'].'"/> |
|||
</div>'; |
|||
|
|||
$html .= $this->_validatebutton; |
|||
|
|||
$html .= ' |
|||
</fieldset>'; |
|||
|
|||
$html .= ' |
|||
<fieldset> |
|||
<legend>'.$this->__('whitelist.title').'</legend> |
|||
<div class="clear"></div>'; |
|||
|
|||
$html .= |
|||
'<p>'.$this->__('whitelist.info1').'</p>'. |
|||
'<p>'.$this->__('whitelist.info2').'</p>'; |
|||
|
|||
$html .= ' |
|||
<div class="element large"> |
|||
<label for="xmppWhiteList">'.$this->__('whitelist.label').'</label> |
|||
<input type="text" name="xmppWhiteList" id="xmppWhiteList" value="'.$this->_conf['xmppWhiteList'].'" /> |
|||
</div>'; |
|||
|
|||
$html .= $this->_validatebutton; |
|||
|
|||
$html .= ' |
|||
</fieldset>'; |
|||
|
|||
$html .= ' |
|||
<fieldset> |
|||
<legend>'.$this->__('information.title').'</legend> |
|||
<div class="clear"></div>'; |
|||
|
|||
if($this->_conf['description'] == '') |
|||
$description = __('global.description'); |
|||
else |
|||
$description = $this->_conf['description']; |
|||
|
|||
$html .= ' |
|||
<div class="element large"> |
|||
<label for="description">'.$this->__('information.description').'</label> |
|||
<textarea type="text" name="description" id="description" />'.$description.'</textarea> |
|||
</div> |
|||
<div class="clear"></div>'; |
|||
|
|||
$html .= '<p>'. |
|||
$this->__('information.info1'). |
|||
'</p>'. |
|||
'<p>'. |
|||
$this->__('information.info2'). |
|||
'</p>'; |
|||
|
|||
$html .= ' |
|||
<div class="element large"> |
|||
<label for="info">'.$this->__('information.label').'</label> |
|||
<textarea type="text" name="info" id="info" />'.$this->_conf['info'].'</textarea> |
|||
</div>'; |
|||
|
|||
$html .= $this->_validatebutton; |
|||
|
|||
$html .= ' |
|||
</fieldset>'; |
|||
|
|||
$html .= ' |
|||
<fieldset> |
|||
<legend>'.$this->__('credentials.title').'</legend>'; |
|||
|
|||
if($this->_conf['user'] == 'admin' || $this->_conf['pass'] == sha1('password')) { |
|||
$html .= ' |
|||
<div class="message error">'. |
|||
$this->__('credentials.info').' |
|||
</div>'; |
|||
} |
|||
|
|||
$html .= ' |
|||
<div class="element" > |
|||
<label for="username">'.$this->__('credentials.username').'</label> |
|||
<input type="text" id="user" name="user" value="'.$this->_conf['user'].'"/> |
|||
</div> |
|||
<div class="clear"></div> |
|||
|
|||
<div class="element"> |
|||
<label for="pass">'.$this->__('credentials.password').'</label> |
|||
<input type="password" id="pass" name="pass" value=""/> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="repass">'.$this->__('credentials.re_password').'</label> |
|||
<input type="password" id="repass" name="repass" value=""/> |
|||
</div> '; |
|||
|
|||
$html .= $this->_validatebutton; |
|||
|
|||
$html .= ' |
|||
</fieldset><br />'; |
|||
|
|||
return $html; |
|||
} |
|||
|
|||
function prepareAdminDB() { |
|||
$dbview = $this->tpl(); |
|||
|
|||
$md = \modl\Modl::getInstance(); |
|||
$infos = $md->check(); |
|||
|
|||
$errors = ''; |
|||
|
|||
$dbview->assign('infos', $infos); |
|||
$dbview->assign('db_update', $this->genCallAjax('ajaxUpdateDatabase') |
|||
."this.className='button color orange icon loading'; setTimeout(function() {location.reload(false)}, 1000);"); |
|||
try { |
|||
$md->connect(); |
|||
} catch(Exception $e) { |
|||
$errors = $e->getMessage(); |
|||
} |
|||
|
|||
$dbview->assign('connected', $md->_connected); |
|||
$dbview->assign('validatebutton', $this->_validatebutton); |
|||
$dbview->assign('conf', $this->_conf); |
|||
$dbview->assign('supported_db', $md->getSupportedDatabases()); |
|||
$dbview->assign('errors', $errors); |
|||
|
|||
$html = $dbview->draw('_admin_db', true); |
|||
|
|||
return $html; |
|||
} |
|||
} |
@ -1,75 +0,0 @@ |
|||
<fieldset> |
|||
<legend>{$c->__('')}</legend> |
|||
<div class="clear"></div> |
|||
|
|||
{if="!$connected"} |
|||
<div class="message error"> |
|||
{$c->__('db.connect_error')} |
|||
</div> |
|||
<div class="message error"> |
|||
{$errors} |
|||
</div> |
|||
{else} |
|||
<div class="message success"> |
|||
{$c->__('db.connect_success')} |
|||
</div> |
|||
{if="null !== $infos"} |
|||
<p>{$c->__('db.update')}</p> |
|||
<div class="message warning"> |
|||
{loop="$infos"} |
|||
<p>{$value}</p> |
|||
{/loop} |
|||
|
|||
<a class="button color green icon refresh" |
|||
onclick="{$db_update}" |
|||
style="float: right;">{$c->__('button.update')}</a> |
|||
<div class="clear"></div> |
|||
</div> |
|||
{else} |
|||
<div class="message success"> |
|||
{$c->__('db.up_to_date')} |
|||
</div> |
|||
{/if} |
|||
{/if} |
|||
|
|||
<div class="clear"></div> |
|||
<div class="element"> |
|||
<label for="logLevel">{$c->__('db.type')}</label> |
|||
<div class="select"> |
|||
<select id="dbType" name="dbType"> |
|||
{loop="$supported_db"} |
|||
<option value="{$key}" |
|||
{if="$key == $conf.dbType"} |
|||
selected="selected" |
|||
{/if}> |
|||
{$value} |
|||
</option> |
|||
{/loop} |
|||
</select> |
|||
</div> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="dbUsername">{$c->__('db.username')}</label> |
|||
<input type="text" name="dbUsername" id="dbUsername" value="{$conf.dbUsername}" /> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="dbPassword">{$c->__('db.password')}</label> |
|||
<input type="password" name="dbPassword" id="dbPassword" value="{$conf.dbPassword}" /> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="dbHost">{$c->__('db.host')}</label> |
|||
<input type="text" name="dbHost" id="dbHost" value="{$conf.dbHost}" /> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="dbPort">{$c->__('db.port')}</label> |
|||
<input type="text" name="dbPort" id="dbPort" value="{$conf.dbPort}" /> |
|||
<div class="message info"> |
|||
PostgreSQL - 5432 | MySQL - 3306 |
|||
</div> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="dbName">{$c->__('db.name')}</label> |
|||
<input type="text" name="dbName" id="dbName" value="{$conf.dbName}" /> |
|||
</div> |
|||
{$validatebutton} |
|||
</fieldset> |
@ -1,11 +0,0 @@ |
|||
<form name="admin" id="adminform" action="#" method="post"> |
|||
<div id="admincomp" class="tabelem padded" title="{$c->__('admin.compatibility')}"> |
|||
{$c->prepareAdminComp()} |
|||
</div> |
|||
<div id="admingen" class="tabelem padded" title="{$c->__('admin.general')}"> |
|||
{$c->prepareAdminGen()} |
|||
</div> |
|||
<div id="admindb" class="tabelem padded" title="{$c->__('db.legend')}"> |
|||
{$c->prepareAdminDB()} |
|||
</div> |
|||
</form> |
@ -0,0 +1,52 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* @package Widgets |
|||
* |
|||
* @file AdminDB.php |
|||
* This file is part of Movim. |
|||
* |
|||
* @brief The DB Administration widget |
|||
* |
|||
* @author Jaussoin Timothée <edhelas@movim.eu> |
|||
|
|||
* Copyright (C)2014 Movim project |
|||
* |
|||
* See COPYING for licensing information. |
|||
*/ |
|||
|
|||
class AdminDB extends WidgetBase |
|||
{ |
|||
function load() { |
|||
|
|||
} |
|||
|
|||
function display() |
|||
{ |
|||
$md = \modl\Modl::getInstance(); |
|||
$infos = $md->check(); |
|||
|
|||
$errors = ''; |
|||
|
|||
$this->view->assign('infos', $infos); |
|||
$this->view->assign('db_update', $this->genCallAjax('ajaxUpdateDatabase') |
|||
."this.className='button color orange icon loading'; setTimeout(function() {location.reload(false)}, 1000);"); |
|||
try { |
|||
$md->connect(); |
|||
} catch(Exception $e) { |
|||
$errors = $e->getMessage(); |
|||
} |
|||
|
|||
if(file_exists(DOCUMENT_ROOT.'/config/db.ini')) { |
|||
$conf = parse_ini_file(DOCUMENT_ROOT.'/config/db.ini'); |
|||
} |
|||
|
|||
$supported = $md->getSupportedDatabases(); |
|||
|
|||
$this->view->assign('connected', $md->_connected); |
|||
$this->view->assign('validatebutton', $this->_validatebutton); |
|||
$this->view->assign('conf', $conf); |
|||
$this->view->assign('dbtype', $supported[$conf['type']]); |
|||
$this->view->assign('errors', $errors); |
|||
} |
|||
} |
@ -0,0 +1,62 @@ |
|||
<div id="admindb" class="tabelem padded" title="{$c->__('db.legend')}"> |
|||
<fieldset> |
|||
<legend>{$c->__('')}</legend> |
|||
<div class="clear"></div> |
|||
|
|||
{if="!$connected"} |
|||
<div class="message error"> |
|||
{$c->__('db.connect_error')} |
|||
</div> |
|||
<div class="message error"> |
|||
{$errors} |
|||
</div> |
|||
{else} |
|||
<div class="message success"> |
|||
{$c->__('db.connect_success')} |
|||
</div> |
|||
{if="null !== $infos"} |
|||
<p>{$c->__('db.update')}</p> |
|||
<div class="message warning"> |
|||
{loop="$infos"} |
|||
<p>{$value}</p> |
|||
{/loop} |
|||
|
|||
<a class="button color green icon refresh" |
|||
onclick="{$db_update}" |
|||
style="float: right;">{$c->__('button.update')}</a> |
|||
<div class="clear"></div> |
|||
</div> |
|||
{else} |
|||
<div class="message success"> |
|||
{$c->__('db.up_to_date')} |
|||
</div> |
|||
{/if} |
|||
{/if} |
|||
|
|||
<div class="clear"></div> |
|||
<div class="element"> |
|||
<label for="logLevel">{$c->__('db.type')}</label> |
|||
<span>{$dbtype}</span> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="dbUsername">{$c->__('db.username')}</label> |
|||
<span>{$conf.username}</span> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="dbPassword">{$c->__('db.password')}</label> |
|||
<span>Password</span> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="dbHost">{$c->__('db.host')}</label> |
|||
<span>{$conf.host}</span> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="dbPort">{$c->__('db.port')}</label> |
|||
<span>{$conf.port}</span> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="dbName">{$c->__('db.name')}</label> |
|||
<span>{$conf.database}</span> |
|||
</div> |
|||
</fieldset> |
|||
</div> |
@ -0,0 +1,12 @@ |
|||
[db] |
|||
db.legend = 'Database Settings' |
|||
db.connect_error = "Modl wasn't able to connect to the database" |
|||
db.connect_success = 'Movim is connected to the database' |
|||
db.update = 'The database need to be updated' |
|||
db.up_to_date = 'Movim database is up to date' |
|||
db.type = 'Database Type' |
|||
db.username = 'Username' |
|||
db.password = 'Password' |
|||
db.host = 'Host' |
|||
db.port = 'Port' |
|||
db.name = 'Database Name' |
@ -0,0 +1,75 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* @package Widgets |
|||
* |
|||
* @file AdminMain.php |
|||
* This file is part of Movim. |
|||
* |
|||
* @brief The main configuration on Movim |
|||
* |
|||
* @author Jaussoin Timothée <edhelas@movim.eu> |
|||
|
|||
* Copyright (C)2014 Movim project |
|||
* |
|||
* See COPYING for licensing information. |
|||
*/ |
|||
|
|||
class AdminMain extends WidgetBase |
|||
{ |
|||
function load() { |
|||
$this->addjs('admin.js'); |
|||
|
|||
$form = $_POST; |
|||
$cd = new \Modl\ConfigDAO(); |
|||
$config = $cd->get(); |
|||
|
|||
if(isset($form)) { |
|||
if($form['pass'] != '' && $form['repass'] != '' |
|||
&& $form['pass'] == $form['repass']) { |
|||
unset($form['repass']); |
|||
$form['pass'] = sha1($form['pass']); |
|||
} else { |
|||
$form['pass'] = $config->pass; |
|||
} |
|||
|
|||
foreach($form as $key => $value) { |
|||
$config->$key = $value; |
|||
} |
|||
|
|||
$cd->set($config); |
|||
} |
|||
} |
|||
|
|||
public function testBosh($url) |
|||
{ |
|||
return requestURL($url, 2); |
|||
} |
|||
|
|||
public function date() |
|||
{ |
|||
return date('l jS \of F Y h:i:s A'); |
|||
} |
|||
|
|||
function display() |
|||
{ |
|||
$cd = new \Modl\ConfigDAO(); |
|||
$config = $cd->get(); |
|||
|
|||
$this->view->assign('conf', $cd->get()); |
|||
$this->view->assign('logs', |
|||
array( |
|||
0 => t('Empty'), |
|||
1 => t('Syslog'), |
|||
2 => t('Syslog and Files')) |
|||
); |
|||
$this->view->assign('envs', |
|||
array( |
|||
'development' => 'Development', |
|||
'production' => 'Production') |
|||
); |
|||
|
|||
$this->view->assign('timezones', getTimezoneList()); |
|||
$this->view->assign('langs', loadLangArray()); |
|||
} |
|||
} |
@ -0,0 +1,172 @@ |
|||
<form name="admin" id="adminform" action="#" method="post"> |
|||
<div id="admingen" class="tabelem padded" title="{$c->__('admin.general')}"> |
|||
<fieldset> |
|||
<legend>{$c->__('admin.general')}</legend> |
|||
|
|||
<div class="element"> |
|||
<label for="da">{$c->__('general.language')}</label> |
|||
<div class="select"> |
|||
<select id="locale" name="locale"> |
|||
<option value="en">English (default)</option>'; |
|||
{loop="$langs"} |
|||
<option value="{$key}" |
|||
{if="$conf->locale == $key"} |
|||
selected="selected" |
|||
{/if}> |
|||
{$value} |
|||
</option> |
|||
{/loop} |
|||
</select> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="element"> |
|||
<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 class="element"> |
|||
<label for="sizelimit">{$c->__('general.limit')}</label> |
|||
<input type="text" name="sizelimit" id="sizelimit" value="{$conf->sizelimit}" /> |
|||
</div> |
|||
|
|||
<div class="element"> |
|||
<label for="loglevel">{$c->__('general.log_verbosity')}</label> |
|||
<div class="select"> |
|||
<select id="loglevel" name="loglevel"> |
|||
{loop="$logs"} |
|||
<option value="{$key}" |
|||
{if="$conf->loglevel == $key"} |
|||
selected="selected" |
|||
{/if}> |
|||
{$value} |
|||
</option> |
|||
{/loop} |
|||
</select> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="element"> |
|||
<label for="timezone">{$c->__('general.timezone')}</label> |
|||
<div class="select"> |
|||
<select id="timezone" name="timezone"> |
|||
{loop="$timezones"} |
|||
<option value="{$key}" |
|||
{if="$conf->timezone == $key"} |
|||
selected="selected" |
|||
{/if}> |
|||
{$key} ({$value|number_format:2}) |
|||
</option> |
|||
{/loop} |
|||
</select> |
|||
</div> |
|||
<br /><br /> |
|||
<span class="dTimezone">{$c->date()}</span> |
|||
</div> |
|||
</fieldset> |
|||
|
|||
|
|||
<fieldset> |
|||
<legend>{$c->__('bosh.title')}</legend> |
|||
<div class="clear"></div> |
|||
|
|||
<p> |
|||
{$c->__('bosh.info1')}<br /> |
|||
{$c->__('bosh.info2')}<br /> |
|||
{$c->__('bosh.info3')}<br /> |
|||
{$c->__('bosh.info4', '<a href="http://wiki.movim.eu/install">', '</a>')} |
|||
</p> |
|||
|
|||
{if="!$c->testBosh($conf->boshurl)"} |
|||
<div class="message error"> |
|||
{$c->__('bosh.not_recheable')} |
|||
</div> |
|||
{/if} |
|||
|
|||
<div class="element"> |
|||
<label for="boshurl">{$c->__('bosh.label')}</label> |
|||
<input type="text" id="boshurl" name="boshurl" value="{$conf->boshurl}"/> |
|||
</div> |
|||
</fieldset> |
|||
|
|||
|
|||
<fieldset> |
|||
<legend>{$c->__('whitelist.title')}</legend> |
|||
<div class="clear"></div> |
|||
|
|||
<p>{$c->__('whitelist.info1')}</p> |
|||
<p>{$c->__('whitelist.info2')}</p> |
|||
|
|||
|
|||
<div class="element large"> |
|||
<label for="xmppwhiteiist">{$c->__('whitelist.label')}</label> |
|||
<input type="text" name="xmppwhitelist" id="xmppwhitelist" value="{$conf->xmppwhitelist}" /> |
|||
</div> |
|||
</fieldset> |
|||
|
|||
|
|||
<fieldset> |
|||
<legend>{$c->__('information.title')}</legend> |
|||
<div class="clear"></div> |
|||
|
|||
<div class="element large"> |
|||
<label for="description">{$c->__('information.description')}</label> |
|||
<textarea type="text" name="description" id="description" />{$conf->description}</textarea> |
|||
</div> |
|||
<div class="clear"></div> |
|||
|
|||
<p>{$c->__('information.info1')}</p> |
|||
<p>{$c->__('information.info2')}</p> |
|||
|
|||
|
|||
<div class="element large"> |
|||
<label for="info">{$c->__('information.label')}</label> |
|||
<textarea type="text" name="info" id="info" />{$conf->info}</textarea> |
|||
</div> |
|||
</fieldset> |
|||
|
|||
|
|||
<fieldset> |
|||
<legend>{$c->__('credentials.title')}</legend> |
|||
|
|||
{if="$conf->user == 'admin' || $conf->pass == sha1('password')"} |
|||
<div class="message error"> |
|||
{$c->__('credentials.info')} |
|||
</div> |
|||
{/if} |
|||
|
|||
<div class="element" > |
|||
<label for="username">{$c->__('credentials.username')}</label> |
|||
<input type="text" id="user" name="user" value="{$conf->user}"/> |
|||
</div> |
|||
<div class="clear"></div> |
|||
|
|||
<div class="element"> |
|||
<label for="pass">{$c->__('credentials.password')}</label> |
|||
<input type="password" id="pass" name="pass" value=""/> |
|||
</div> |
|||
<div class="element"> |
|||
<label for="repass">{$c->__('credentials.re_password')}</label> |
|||
<input type="password" id="repass" name="repass" value=""/> |
|||
</div> |
|||
</fieldset> |
|||
|
|||
<input |
|||
type="submit" |
|||
class="button icon yes color green oppose" |
|||
value="{$c->__('button.submit')}"/> |
|||
<div class="clear"></div> |
|||
</div> |
|||
</form> |
@ -0,0 +1,51 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* @package Widgets |
|||
* |
|||
* @file AdminTest.php |
|||
* This file is part of Movim. |
|||
* |
|||
* @brief The Admin Pest part |
|||
* |
|||
* @author Jaussoin Timothée <edhelas@movim.eu> |
|||
|
|||
* Copyright (C)2014 Movim project |
|||
* |
|||
* See COPYING for licensing information. |
|||
*/ |
|||
|
|||
class AdminTest extends WidgetBase |
|||
{ |
|||
function load() { |
|||
|
|||
} |
|||
|
|||
public function valid($what) |
|||
{ |
|||
if($what) |
|||
return "message success"; |
|||
else |
|||
return "message error"; |
|||
} |
|||
|
|||
public function version() |
|||
{ |
|||
return (version_compare(PHP_VERSION, '5.3.0') >= 0); |
|||
} |
|||
|
|||
public function testDir($dir) |
|||
{ |
|||
return (file_exists($dir) && is_dir($dir) && is_writable($dir)); |
|||
} |
|||
|
|||
public function testFile($file) |
|||
{ |
|||
return (file_exists($file) && is_writable($file)); |
|||
} |
|||
|
|||
function display() |
|||
{ |
|||
|
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
<div id="admincomp" class="tabelem padded" title="{$c->__('admin.compatibility')}"> |
|||
<fieldset> |
|||
<legend>{$c->__('admin.compatibility')}</legend> |
|||
<div class="clear"></div> |
|||
<p> |
|||
{$c->__('compatibility.info')} |
|||
</p><br /> |
|||
|
|||
<div class="{$c->valid($c->version())}"> |
|||
{$c->__('compatibility.php', PHP_VERSION)} |
|||
</div> |
|||
<div class="{$c->valid(extension_loaded('curl'))}"> |
|||
{$c->__('compatibility.curl')} |
|||
</div> |
|||
<div class="{$c->valid(extension_loaded('gd'))}"> |
|||
{$c->__('compatibility.gd')} |
|||
</div> |
|||
<div class="{$c->valid(extension_loaded('SimpleXml'))}"> |
|||
{$c->__('compatibility.simplexml')} |
|||
</div> |
|||
<div class="{$c->valid($c->testDir(DOCUMENT_ROOT))}"> |
|||
{$c->__('compatibility.rights')} |
|||
</div> |
|||
<div class="{$c->valid(extension_loaded('OpenSSL'))}"> |
|||
{$c->__('compatibility.openssl')} |
|||
</div> |
|||
</fieldset> |
|||
|
|||
<fieldset> |
|||
<legend>{$c->__('compatibility.rewrite')}</legend> |
|||
<div class="clear"></div> |
|||
<div class="{$c->valid($_SERVER['HTTP_MOD_REWRITE'])}"> |
|||
{$c->__('compatibility.rewrite')} |
|||
</div> |
|||
</fieldset> |
|||
</div> |
@ -0,0 +1,11 @@ |
|||
admin.compatibility = 'Compatibility Check' |
|||
|
|||
[compatibility] |
|||
compatibility.info = 'Movim requires certain external components. Please install them before you can succeed:' |
|||
compatibility.php = 'Your PHP-Version: %s <br>Required: 5.3.0' |
|||
compatibility.curl = 'CURL-Library' |
|||
compatibility.gd = 'GD' |
|||
compatibility.simplexml = 'SimpleXML' |
|||
compatibility.rights = "Read and write rights for the webserver in Movim's root directory" |
|||
compatibility.openssl = 'OpenSSL' |
|||
compatibility.rewrite = 'URL Rewriting support' |
@ -0,0 +1,15 @@ |
|||
; This is the database configuration of Movim |
|||
; You need to copy an rename this file to 'db.ini' and complete the values |
|||
[db] |
|||
; The type can be 'pgsql' or 'mysql' |
|||
type = 'mysql' |
|||
; The database username |
|||
username = 'username' |
|||
; The password |
|||
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 = 'movim' |
Write
Preview
Loading…
Cancel
Save
Reference in new issue