diff --git a/app/controllers/AdminloginController.php b/app/controllers/AdminloginController.php index c73fb74fc..86ca34fa0 100644 --- a/app/controllers/AdminloginController.php +++ b/app/controllers/AdminloginController.php @@ -1,20 +1,24 @@ session_only = false; } - function dispatch() { + function dispatch() + { $this->page->setTitle(__('title.administration', APP_TITLE)); $this->page->menuAddLink(__('page.home'), 'main'); $this->page->menuAddLink(__('page.administration'), 'admin', true); - $conf = Conf::getServerConf(); + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); - if($conf['user'] == $_POST['username'] - && $conf['pass'] == sha1($_POST['password'])) { + if($config->user == $_POST['username'] + && $config->pass == sha1($_POST['password'])) { $_SESSION['admin'] = true; $this->name = 'admin'; } diff --git a/app/models/postn/Postn.php b/app/models/postn/Postn.php index f5e5fb9a1..95f5652a9 100644 --- a/app/models/postn/Postn.php +++ b/app/models/postn/Postn.php @@ -1,6 +1,6 @@
- widget('Admin');?> + widget('AdminMain');?> + widget('AdminDB');?> + widget('AdminTest');?> widget('Statistics');?> widget('Api');?>
diff --git a/app/views/page.tpl b/app/views/page.tpl index 3ded3ade6..70b35ba0a 100644 --- a/app/views/page.tpl +++ b/app/views/page.tpl @@ -1,11 +1,13 @@ get(); ?> <?php $this->title();?> - + diff --git a/app/widgets/Admin/Admin.php b/app/widgets/Admin/Admin.php deleted file mode 100644 index a9c4fd0ef..000000000 --- a/app/widgets/Admin/Admin.php +++ /dev/null @@ -1,432 +0,0 @@ - - * - * @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 = ' -
- '; - - $html = ' -
- '.$this->__('admin.compatibility').' -
'; - - $html .= - '

'. - $this->__('compatibility.info'). - '


'; - - $html .= ' -
- '.$this->__('compatibility.php', PHP_VERSION).' -
-
- '.$this->__('compatibility.curl').' -
-
- '.$this->__('compatibility.gd').' -
-
- '.$this->__('compatibility.simplexml').' -
-
- '.$this->__('compatibility.rights').' -
-
- '.$this->__('compatibility.openssl').' -
- -
- -
- '.$this->__('compatibility.rewrite').' -
-
- '.$this->__('compatibility.rewrite').' -
'; - - $html .= ' -
'; - - return $html; - } - - function prepareAdminGen() { - $html .= ' -
- '.$this->__('admin.general').' -
- -
- -
-
'; - - $html .= ' -
- -
- -
-
'; - - $env = array( - 'development' => 'Development', - 'production' => 'Production'); - - $html .= ' -
- -
- -
-
'; - - $html .= ' -
- - -
'; - - $logopts = array( - 0 => t('Empty'), - 1 => t('Syslog'), - 2 => t('Syslog and Files') - ); - - $html .= ' -
- -
- -
-
'; - - - $timezones = getTimezoneList(); - - $html .= ' -
- -
- -
-

- '.date('l jS \of F Y h:i:s A').' -
'; - - $html .= $this->_validatebutton; - - $html .= ' -
'; - - $html .= ' -
- '.$this->__('bosh.title').' -
'; - - $html .= '

'. - $this->__('bosh.info1').' '. - $this->__('bosh.info2').' '. - $this->__('bosh.info3').' '. - $this->__('bosh.info4', '', ''); - '

'; - - if(!$this->testBosh($this->_conf['boshUrl'])) { - $html .= ' -
'. - $this->__('bosh.not_recheable').' -
'; - } - - $html .= ' -
- - -
'; - - $html .= $this->_validatebutton; - - $html .= ' -
'; - - $html .= ' -
- '.$this->__('whitelist.title').' -
'; - - $html .= - '

'.$this->__('whitelist.info1').'

'. - '

'.$this->__('whitelist.info2').'

'; - - $html .= ' -
- - -
'; - - $html .= $this->_validatebutton; - - $html .= ' -
'; - - $html .= ' -
- '.$this->__('information.title').' -
'; - - if($this->_conf['description'] == '') - $description = __('global.description'); - else - $description = $this->_conf['description']; - - $html .= ' -
- - -
-
'; - - $html .= '

'. - $this->__('information.info1'). - '

'. - '

'. - $this->__('information.info2'). - '

'; - - $html .= ' -
- - -
'; - - $html .= $this->_validatebutton; - - $html .= ' -
'; - - $html .= ' -
- '.$this->__('credentials.title').''; - - if($this->_conf['user'] == 'admin' || $this->_conf['pass'] == sha1('password')) { - $html .= ' -
'. - $this->__('credentials.info').' -
'; - } - - $html .= ' -
- - -
-
- -
- - -
-
- - -
'; - - $html .= $this->_validatebutton; - - $html .= ' -

'; - - 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; - } -} diff --git a/app/widgets/Admin/_admin_db.tpl b/app/widgets/Admin/_admin_db.tpl deleted file mode 100644 index 593218b57..000000000 --- a/app/widgets/Admin/_admin_db.tpl +++ /dev/null @@ -1,75 +0,0 @@ -
- {$c->__('')} -
- - {if="!$connected"} -
- {$c->__('db.connect_error')} -
-
- {$errors} -
- {else} -
- {$c->__('db.connect_success')} -
- {if="null !== $infos"} -

{$c->__('db.update')}

-
- {loop="$infos"} -

{$value}

- {/loop} - - {$c->__('button.update')} -
-
- {else} -
- {$c->__('db.up_to_date')} -
- {/if} - {/if} - -
-
- -
- -
-
-
- - -
-
- - -
-
- - -
-
- - -
- PostgreSQL - 5432 | MySQL - 3306 -
-
-
- - -
- {$validatebutton} -
diff --git a/app/widgets/Admin/admin.tpl b/app/widgets/Admin/admin.tpl deleted file mode 100644 index d54501ad2..000000000 --- a/app/widgets/Admin/admin.tpl +++ /dev/null @@ -1,11 +0,0 @@ -
-
- {$c->prepareAdminComp()} -
-
- {$c->prepareAdminGen()} -
-
- {$c->prepareAdminDB()} -
-
diff --git a/app/widgets/AdminDB/AdminDB.php b/app/widgets/AdminDB/AdminDB.php new file mode 100644 index 000000000..f54ed3096 --- /dev/null +++ b/app/widgets/AdminDB/AdminDB.php @@ -0,0 +1,52 @@ + + + * 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); + } +} diff --git a/app/widgets/AdminDB/admindb.tpl b/app/widgets/AdminDB/admindb.tpl new file mode 100644 index 000000000..38a0bfc1e --- /dev/null +++ b/app/widgets/AdminDB/admindb.tpl @@ -0,0 +1,62 @@ +
+
+ {$c->__('')} +
+ + {if="!$connected"} +
+ {$c->__('db.connect_error')} +
+
+ {$errors} +
+ {else} +
+ {$c->__('db.connect_success')} +
+ {if="null !== $infos"} +

{$c->__('db.update')}

+
+ {loop="$infos"} +

{$value}

+ {/loop} + + {$c->__('button.update')} +
+
+ {else} +
+ {$c->__('db.up_to_date')} +
+ {/if} + {/if} + +
+
+ + {$dbtype} +
+
+ + {$conf.username} +
+
+ + Password +
+
+ + {$conf.host} +
+
+ + {$conf.port} +
+
+ + {$conf.database} +
+
+
diff --git a/app/widgets/AdminDB/locales.ini b/app/widgets/AdminDB/locales.ini new file mode 100644 index 000000000..ac0740cb3 --- /dev/null +++ b/app/widgets/AdminDB/locales.ini @@ -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' diff --git a/app/widgets/AdminMain/AdminMain.php b/app/widgets/AdminMain/AdminMain.php new file mode 100644 index 000000000..00f0e7120 --- /dev/null +++ b/app/widgets/AdminMain/AdminMain.php @@ -0,0 +1,75 @@ + + + * 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()); + } +} diff --git a/app/widgets/Admin/admin.js b/app/widgets/AdminMain/admin.js similarity index 100% rename from app/widgets/Admin/admin.js rename to app/widgets/AdminMain/admin.js diff --git a/app/widgets/AdminMain/adminmain.tpl b/app/widgets/AdminMain/adminmain.tpl new file mode 100644 index 000000000..f6404d1ba --- /dev/null +++ b/app/widgets/AdminMain/adminmain.tpl @@ -0,0 +1,172 @@ +
+
+
+ {$c->__('admin.general')} + +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+

+ {$c->date()} +
+
+ + +
+ {$c->__('bosh.title')} +
+ +

+ {$c->__('bosh.info1')}
+ {$c->__('bosh.info2')}
+ {$c->__('bosh.info3')}
+ {$c->__('bosh.info4', '', '')} +

+ + {if="!$c->testBosh($conf->boshurl)"} +
+ {$c->__('bosh.not_recheable')} +
+ {/if} + +
+ + +
+
+ + +
+ {$c->__('whitelist.title')} +
+ +

{$c->__('whitelist.info1')}

+

{$c->__('whitelist.info2')}

+ + +
+ + +
+
+ + +
+ {$c->__('information.title')} +
+ +
+ + +
+
+ +

{$c->__('information.info1')}

+

{$c->__('information.info2')}

+ + +
+ + +
+
+ + +
+ {$c->__('credentials.title')} + + {if="$conf->user == 'admin' || $conf->pass == sha1('password')"} +
+ {$c->__('credentials.info')} +
+ {/if} + +
+ + +
+
+ +
+ + +
+
+ + +
+
+ + +
+
+
diff --git a/app/widgets/Admin/locales.ini b/app/widgets/AdminMain/locales.ini similarity index 64% rename from app/widgets/Admin/locales.ini rename to app/widgets/AdminMain/locales.ini index 149bb3eea..cd4c6e000 100644 --- a/app/widgets/Admin/locales.ini +++ b/app/widgets/AdminMain/locales.ini @@ -1,4 +1,3 @@ -admin.compatibility = 'Compatibility Check' admin.general = 'General Settings' [general] @@ -38,25 +37,3 @@ information.info1 = 'This message will be displayed on the login page' information.info2 = "Leave this field blank if you don't want to show any message." information.label = 'Information Message' -[compatibility] -compatibility.info = 'Movim requires certain external components. Please install them before you can succeed:' -compatibility.php = 'Your PHP-Version: %s
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' - -[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' diff --git a/app/widgets/AdminTest/AdminTest.php b/app/widgets/AdminTest/AdminTest.php new file mode 100644 index 000000000..9f09b5e64 --- /dev/null +++ b/app/widgets/AdminTest/AdminTest.php @@ -0,0 +1,51 @@ + + + * 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() + { + + } +} diff --git a/app/widgets/AdminTest/admintest.tpl b/app/widgets/AdminTest/admintest.tpl new file mode 100644 index 000000000..aad68c820 --- /dev/null +++ b/app/widgets/AdminTest/admintest.tpl @@ -0,0 +1,36 @@ +
+
+ {$c->__('admin.compatibility')} +
+

+ {$c->__('compatibility.info')} +


+ +
+ {$c->__('compatibility.php', PHP_VERSION)} +
+
+ {$c->__('compatibility.curl')} +
+
+ {$c->__('compatibility.gd')} +
+
+ {$c->__('compatibility.simplexml')} +
+
+ {$c->__('compatibility.rights')} +
+
+ {$c->__('compatibility.openssl')} +
+
+ +
+ {$c->__('compatibility.rewrite')} +
+
+ {$c->__('compatibility.rewrite')} +
+
+
diff --git a/app/widgets/AdminTest/locales.ini b/app/widgets/AdminTest/locales.ini new file mode 100644 index 000000000..bbdfd4e65 --- /dev/null +++ b/app/widgets/AdminTest/locales.ini @@ -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
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' diff --git a/app/widgets/Api/Api.php b/app/widgets/Api/Api.php index 464ae57ef..bf81bf84e 100644 --- a/app/widgets/Api/Api.php +++ b/app/widgets/Api/Api.php @@ -34,16 +34,17 @@ class Api extends WidgetBase { $json = requestURL(MOVIM_API.'status', 1, array('uri' => BASE_URI)); $json = json_decode($json); - $conf = Conf::getServerConf(); + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); if(isset($json)) { $this->view->assign('json', $json); if($json->status == 200) { $this->view->assign('unregister', $this->genCallAjax('ajaxUnregister')); - $this->view->assign('unregister_status', $conf['unregister']); + $this->view->assign('unregister_status', $config->unregister); } else { - $conf['unregister'] = false; - Conf::saveConfFile($conf); + $config->unregister = false; + $cd->set($config); $this->view->assign('register', $this->genCallAjax('ajaxRegister')); } } else { @@ -74,12 +75,12 @@ class Api extends WidgetBase { function ajaxUnregister() { - $conf = Conf::getServerConf(); - $conf['unregister'] = !$conf['unregister']; - Conf::saveConfFile($conf); - - sleep(2); + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); + $config->unregister = !$config->unregister; + $cd->set($config); + RPC::call('movim_reload_this'); RPC::commit(); } diff --git a/app/widgets/Infos/Infos.php b/app/widgets/Infos/Infos.php index 36fbdc33c..63e18902f 100644 --- a/app/widgets/Infos/Infos.php +++ b/app/widgets/Infos/Infos.php @@ -31,7 +31,8 @@ class Infos extends WidgetBase $pop = $pop-2; // We get the global configuration - $conf = Conf::getServerConf(); + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); $sd = new \Modl\SessionxDAO(); @@ -43,11 +44,11 @@ class Infos extends WidgetBase $infos = array( 'url' => BASE_URI, - 'language' => $conf['defLang'], - 'whitelist' => $conf['xmppWhiteList'], - 'timezone' => $conf['timezone'], - 'description' => $conf['description'], - 'unregister' => $conf['unregister'], + 'language' => $config->locale, + 'whitelist' => $config->xmppwhitelist, + 'timezone' => $config->timezone, + 'description' => $config->description, + 'unregister' => $config->unregister, 'php_version' => phpversion(), 'rewrite' => $rewrite, 'version' => APP_VERSION, diff --git a/app/widgets/Login/Login.php b/app/widgets/Login/Login.php index 45de2f827..21b6b9504 100644 --- a/app/widgets/Login/Login.php +++ b/app/widgets/Login/Login.php @@ -17,8 +17,8 @@ * See COPYING for licensing information. */ -class Login extends WidgetBase { - +class Login extends WidgetBase +{ function load() { $this->addcss('login.css'); @@ -30,8 +30,12 @@ class Login extends WidgetBase { function display() { $submit = $this->genCallAjax('ajaxLogin', "movim_parse_form('login')"); + + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); + $this->view->assign('submit', $submit); - $this->view->assign('conf', Conf::getServerConf($submit)); + $this->view->assign('info', $config->info); $this->view->assign('submit_event', 'document.getElementById(\'submitb\').click(); '.$submit.' @@ -68,9 +72,10 @@ class Login extends WidgetBase { $this->view->assign('facebook', $this->__('account.facebook', '', '')); - - $conf = Conf::getServerConf(); - $whitelist = $conf['xmppWhiteList']; + + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); + $whitelist = $config->xmppwhitelist; if(isset($whitelist) && $whitelist!=''){ $this->view->assign('whitelist', $whitelist); @@ -206,7 +211,8 @@ class Login extends WidgetBase { function ajaxLogin($element) { // We get the Server Configuration - $serverconfig = Conf::getServerConf(); + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); $warning = false; @@ -227,12 +233,12 @@ class Login extends WidgetBase { // Check whitelisted server if( - $serverconfig['xmppWhiteList'] != '' &&! + $config->xmppwhitelist != '' &&! in_array( end( explode('@', $element['login']) ), - explode(',',$serverconfig['xmppWhiteList']) + explode(',',$config->xmppwhitelist) ) ) $warning = 'serverunauthorized'; diff --git a/app/widgets/Login/login.tpl b/app/widgets/Login/login.tpl index 34ded524b..5281b43fe 100644 --- a/app/widgets/Login/login.tpl +++ b/app/widgets/Login/login.tpl @@ -4,9 +4,9 @@ {$c->__('error.too_old')} {else} - {if="isset($conf.info) && $conf.info != ''"} + {if="isset($info) && $info != ''"}
- {$conf.info} + {$info}
{/if}
view->assign('fail_safe', ''); // And we load some public values of the system configuration - $conf = Conf::getServerConf(); + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); + $public_conf = array( - 'bosh_url' => $conf['boshUrl'], - 'timezone' => $conf['timezone'] + 'bosh_url' => $config->boshurl, + 'timezone' => $config->timezone ); $this->view->assign('server_conf', json_encode($public_conf)); } diff --git a/bootstrap.php b/bootstrap.php index eb06faa55..d04a67128 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -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')); @@ -42,10 +42,10 @@ class Bootstrap { $this->loadDispatcher(); $this->loadHelpers(); - $this->setTimezone(); - $loadmodlsuccess = $this->loadModl(); - + + $this->setTimezone(); + if($loadmodlsuccess) { $this->startingSession(); } else { @@ -115,7 +115,7 @@ class Bootstrap { define('HELPERS_PATH', DOCUMENT_ROOT . '/app/helpers/'); define('WIDGETS_PATH', DOCUMENT_ROOT . '/app/widgets/'); - define('MOVIM_API', 'https://api.movim.eu/'); + define('MOVIM_API', 'http://localhost/api/public/'); if (!defined('DOCTYPE')) { define('DOCTYPE','text/html'); @@ -202,11 +202,15 @@ class Bootstrap { } private function setLogs() { + /*$cd = new \Modl\ConfigDAO(); + $config = $cd->get(); + try { - define('ENVIRONMENT', Conf::getServerConfElement('environment')); + 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 @@ -219,7 +223,7 @@ class Bootstrap { 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); @@ -230,14 +234,15 @@ class Bootstrap { } set_error_handler('systemErrorHandler', E_ALL); - define('LOG_LEVEL', (int)Conf::getServerConfElement('logLevel')); + define('LOG_LEVEL', 1); } private function setTimezone() { // We set the default timezone to the server timezone - $conf = Conf::getServerConf(); - if(isset($conf['timezone'])) - date_default_timezone_set($conf['timezone']); + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); + + date_default_timezone_set($config->timezone); } private function loadModl() { @@ -245,6 +250,7 @@ class Bootstrap { $db = Modl\Modl::getInstance(); $db->setModelsPath(APP_PATH.'models'); + Modl\Utils::loadModel('Config'); Modl\Utils::loadModel('Presence'); Modl\Utils::loadModel('Contact'); Modl\Utils::loadModel('Privacy'); @@ -258,8 +264,14 @@ class Bootstrap { Modl\Utils::loadModel('Message'); Modl\Utils::loadModel('Sessionx'); Modl\Utils::loadModel('Conference'); + + if(file_exists(DOCUMENT_ROOT.'/config/db.ini')) { + $conf = parse_ini_file(DOCUMENT_ROOT.'/config/db.ini'); + } else { + echo 'Cannot find config/db.ini file'; + } - $db->setConnectionArray(Conf::getServerConf()); + $db->setConnectionArray($conf); $db->connect(); return true; diff --git a/config/db.example.ini b/config/db.example.ini new file mode 100644 index 000000000..6e924a7ca --- /dev/null +++ b/config/db.example.ini @@ -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' diff --git a/system/Sessionx.php b/system/Sessionx.php index f91e17a5c..0eecde5b0 100644 --- a/system/Sessionx.php +++ b/system/Sessionx.php @@ -95,9 +95,10 @@ class Sessionx { } public function init($user, $pass, $host, $domain) { - $serverconfig = Conf::getServerConf(); + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); - $this->_url = $serverconfig['boshUrl']; + $this->_url = $config->boshurl; $this->_port = 5222; $this->_host = $host; $this->_domain = $domain; diff --git a/system/User.php b/system/User.php index 4558e0b1c..4bcc4d923 100644 --- a/system/User.php +++ b/system/User.php @@ -40,7 +40,10 @@ class User { if($session->config) $this->config = $session->config; - $this->sizelimit = (int)Conf::getServerConfElement('sizeLimit'); + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); + + $this->sizelimit = (int)$config->sizelimit; $this->userdir = DOCUMENT_ROOT.'/users/'.$this->username.'/'; $this->useruri = BASE_URI.'users/'.$this->username.'/'; diff --git a/system/controllers/BaseController.php b/system/controllers/BaseController.php index cd7088cea..8aecff379 100644 --- a/system/controllers/BaseController.php +++ b/system/controllers/BaseController.php @@ -23,20 +23,24 @@ class BaseController { */ function loadLanguage() { $user = new User(); + + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); + if($user->isLogged()) { $lang = $user->getConfig('language'); if(isset($lang)) { loadLanguage($lang); } else { // Load default language. - loadLanguage(Conf::getServerConfElement('defLang')); + loadLanguage($config->locale); } } else if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { loadLanguageAuto(); } else { - loadLanguage(Conf::getServerConfElement('defLang')); + loadLanguage($config->locale); } } diff --git a/system/i18n/i18n.php b/system/i18n/i18n.php index 68afc3f52..36636b297 100644 --- a/system/i18n/i18n.php +++ b/system/i18n/i18n.php @@ -70,7 +70,7 @@ function __() { global $translationshash; $args = func_get_args(); - if(array_key_exists($args[0], $translationshash)) { + if(is_array($translationshash) && array_key_exists($args[0], $translationshash)) { $args[0] = $translationshash[$args[0]]; return call_user_func_array('t', $args); } else { @@ -158,8 +158,12 @@ function loadLanguageAuto() 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(Conf::getServerConfElement('defLang')); + loadLanguage($config->locale); $langNotFound = false; } elseif(file_exists(LOCALES_PATH . $key . '.po')) { loadLanguage($key);