Beispiel #1
0
 /**
  * Main page
  */
 public function index()
 {
     $submit = $this->param('validate');
     if ($submit == jLocale::get('hfnucontact~contact.form.saveBt')) {
         $form = jForms::fill('hfnucontact~admincontact');
         $rep = $this->getResponse('redirect');
         if (!$form->check()) {
             $rep->action = 'hfnucontact~admin:index';
             return $rep;
         }
         $HfnucontactConfig = new jIniFileModifier(jApp::configPath('defaultconfig.ini.php'));
         $HfnucontactConfig->setValue('email_contact', $this->param('contact'), 'hfnucontact');
         $HfnucontactConfig->save();
         jMessage::add(jLocale::get('hfnucontact~contact.admin.form.email.saved'), 'ok');
         jForms::destroy('hfnucontact~admincontact');
         $rep->action = 'hfnucontact~admin:index';
         return $rep;
     } else {
         $form = jForms::create('hfnucontact~admincontact');
     }
     $form->setData('contact', jApp::config()->hfnucontact['email_contact']);
     $rep = $this->getResponse('html');
     $tpl = new jTpl();
     $tpl->assign('form', $form);
     $rep->body->assign('MAIN', $tpl->fetch('hfnucontact~admincontact'));
     $rep->body->assign('selectedMenuItem', 'contact');
     return $rep;
 }
 /**
  * action to process the page after the submit
  */
 function process()
 {
     $configFile = jApp::configPath('localconfig.ini.php');
     if (!file_exists($configFile)) {
         copy(jApp::configPath('localconfig.ini.php.dist'), $configFile);
     }
     $ini = new jIniFileModifier($configFile);
     $_SESSION['installdemo'] = $_POST['installdemo'] == 'on';
     $parameters = $ini->getValue('lizmap.installparam', 'modules');
     if ($parameters === null) {
         $parameters = '';
     }
     if (strpos($parameters, 'demo') === false) {
         if ($_SESSION['installdemo']) {
             $parameters .= trim($parameters) == '' ? 'demo' : ',demo';
         }
     } else {
         if (!$_SESSION['installdemo']) {
             $parameters = str_replace('demo', '', $parameters);
         }
     }
     $ini->setValue('lizmap.installparam', $parameters, 'modules');
     $ini->save();
     unset($_SESSION['installdemo']);
     return 0;
 }
Beispiel #3
0
 function install()
 {
     // installer le CSS
     $cssFile = jApp::wwwPath('css/localiz.css');
     if (!file_exists($cssFile)) {
         $this->copyFile('css/localiz.css', $cssFile);
     }
     // installer le JS
     $jsFile = jApp::wwwPath('js/localiz.js');
     if (!file_exists($jsFile)) {
         $this->copyFile('js/localiz.js', $jsFile);
     }
     // conf DB
     $localConfFile = jApp::configPath('localconfig.ini.php');
     if (file_exists($localConfFile)) {
         $ini = new jIniFileModifier($localConfFile);
         $ini->setValue('db_driver', 'pgsql', 'localiz_plugin');
         $ini->setValue('db_host', 'pgpool', 'localiz_plugin');
         $ini->setValue('db_port', '5432', 'localiz_plugin');
         $ini->setValue('db_database', 'refgeo2', 'localiz_plugin');
         $ini->setValue('db_user', 'visu', 'localiz_plugin');
         $ini->setValue('db_password', 'visu', 'localiz_plugin');
         $ini->setValue('db_query', "select oid, geometrytype, value, label, longlabel, xmin, ymin, xmax, ymax from MYTABLE where label like '%s%%'", 'localiz_plugin');
         /* Ex with plain text search
            "select oid, typcode, geometrytype(geom) as geometrytype, code as value, lib || complement as label, 
            typ || ' ' || lib || complement || ' (' || code || ')' as longlabel, 
            st_xmin(st_transform(bbox, 4326)) xmin, st_ymin(st_transform(bbox, 4326)) ymin, st_xmax(st_transform(bbox, 4326)) xmax, st_ymax(st_transform(bbox, 4326)) ymax
            from services.ref_search
            where (v @@ to_tsquery('fr', regexp_replace('%1$s', '\\s+', '&', 'g')) )
            order by st_area(bbox) desc"            */
         $ini->save();
     }
 }
Beispiel #4
0
 /**
  * action to process the page after the submit
  */
 function process()
 {
     $ini = new jIniFileModifier(jApp::configPath() . 'defaultconfig.ini.php');
     $errors = array();
     $_SESSION['hfnconf']['theme'] = trim($_POST['theme']);
     if ($_SESSION['hfnconf']['theme'] == '') {
         $errors[] = $this->locales['error.missing.theme'];
     } else {
         $ini->setValue('theme', $_SESSION['hfnconf']['theme']);
     }
     $_SESSION['hfnconf']['title'] = trim($_POST['title']);
     if ($_SESSION['hfnconf']['title'] == '') {
         $errors[] = $this->locales['error.missing.title'];
     } else {
         $ini->setValue('title', $_SESSION['hfnconf']['title'], 'havefnubb');
     }
     $_SESSION['hfnconf']['description'] = trim($_POST['description']);
     $ini->setValue('description', $_SESSION['hfnconf']['description'], 'havefnubb');
     if (count($errors)) {
         $_SESSION['hfnconf']['errors'] = $errors;
         return false;
     }
     $ini->save();
     unset($_SESSION['hfnconf']);
     return 0;
 }
 function install()
 {
     if ($this->firstExec('cacheqgis')) {
         $profiles = new jIniFileModifier(jApp::configPath('profiles.ini.php'));
         if (!$profiles->isSection('jcache:qgisprojects')) {
             $profiles->setValues(array('enabled' => 1, 'driver' => 'file', 'ttl' => 0), 'jcache:qgisprojects');
             $profiles->save();
         }
     }
 }
 /**
  * Let use one of the available theme
  */
 function useit()
 {
     $theme = (string) $this->param('theme');
     $mainConfig = new jIniFileModifier(jApp::configPath() . 'defaultconfig.ini.php');
     $mainConfig->setValue('theme', strtolower($theme));
     $mainConfig->setValue('datepicker', strtolower($theme), 'forms');
     $mainConfig->save();
     jFile::removeDir(jApp::tempPath(), false);
     jMessage::add(jLocale::get('theme.selected'), 'information');
     $rep = $this->getResponse('redirect');
     $rep->action = 'default:index';
     return $rep;
 }
Beispiel #7
0
 function install()
 {
     $doc = new DOMDocument();
     $doc->Load(dirname(__FILE__) . '/../module.xml');
     $xpath = new DOMXPath($doc);
     $xpath->registerNamespace('jelix', "http://jelix.org/ns/module/1.0");
     $query = "//jelix:module/jelix:info/jelix:version/text()";
     $entries = $xpath->evaluate($query);
     $version = $entries->item(0)->nodeValue;
     $ini = new jIniFileModifier(jApp::configPath() . 'defaultconfig.ini.php');
     $ini->setValue('version', $version, 'havefnubb');
     $ini->save();
 }
Beispiel #8
0
 function install()
 {
     $authconfig = $this->config->getValue('auth', 'coordplugins');
     if ($authconfig && $this->entryPoint->type != 'cmdline' && $this->firstExec($authconfig)) {
         $conf = new jIniFileModifier(jApp::configPath($authconfig));
         $driver = $conf->getValue('driver');
         $daoName = $conf->getValue('dao', 'Db');
         $formName = $conf->getValue('form', 'Db');
         if ($driver == 'Db' && $daoName == 'jauthdb~jelixuser' && $formName == '') {
             $conf->setValue('form', 'jauthdb_admin~jelixuser', 'Db');
             $conf->save();
         }
     }
 }
 function install()
 {
     $authconfig = $this->config->getValue('auth', 'coordplugins');
     if ($authconfig && $this->firstExec($authconfig)) {
         $conf = new jIniFileModifier(jApp::configPath($authconfig));
         $driver = $conf->getValue('driver');
         if ($driver == '') {
             $driver = 'Db';
             $conf->setValue('driver', 'Db');
             $conf->setValue('dao', 'jauthdb~jelixuser', 'Db');
             $conf->save();
         } else {
             if ($driver != 'Db') {
                 return;
             }
         }
         $daoName = $conf->getValue('dao', 'Db');
         if ($daoName == 'jauth~jelixuser') {
             $conf->setValue('dao', 'jauthdb~jelixuser', 'Db');
             $conf->save();
         }
     }
 }
 /**
  * save the global configuration data.
  */
 public function save()
 {
     // Get access to the ini file
     $iniFile = jApp::configPath('lizmapLogConfig.ini.php');
     $ini = new jIniFileModifier($iniFile);
     foreach ($this->properties as $prop) {
         if ($this->{$prop} != '') {
             $ini->setValue($prop, $this->{$prop}, 'general');
         } else {
             $ini->removeValue($prop, 'general');
         }
     }
     // Save the ini file
     $ini->save();
     return $ini->isModified();
 }
 function install()
 {
     if (self::$key === null) {
         self::$key = jAuth::getRandomPassword(30, true);
     }
     $conf = $this->config->getValue('auth', 'coordplugins');
     if ($conf != '1') {
         $conff = jApp::configPath($conf);
         if (file_exists($conff)) {
             $ini = new jIniFileModifier($conff);
             $ini->removeValue('persistant_crypt_key');
             $ini->save();
         }
     }
     $localConfigIni = $this->entryPoint->localConfigIni;
     $localConfigIni->getMaster()->setValue('persistant_crypt_key', self::$key, 'coordplugin_auth');
 }
Beispiel #12
0
 function install()
 {
     if ($this->entryPoint->type == 'cmdline') {
         return;
     }
     $aclconfig = $this->config->getValue('jacl2', 'coordplugins');
     $aclconfigMaster = $this->config->getValue('jacl2', 'coordplugins', null, true);
     $forWS = in_array($this->entryPoint->type, array('json', 'jsonrpc', 'soap', 'xmlrpc'));
     $ownConfig = false;
     if (!$aclconfig || $forWS && $aclconfigMaster == $aclconfig) {
         $pluginIni = 'jacl2.coord.ini.php';
         $configDir = dirname($this->entryPoint->configFile) . '/';
         $ownConfig = true;
         $aclconfig = $configDir . $pluginIni;
         if ($this->firstExec('jacl2:' . $aclconfig)) {
             // no configuration, let's install the plugin for the entry point
             $this->config->setValue('jacl2', $aclconfig, 'coordplugins');
             if (!file_exists(jApp::configPath($aclconfig))) {
                 $this->copyFile('var/config/' . $pluginIni, jApp::configPath($aclconfig));
             }
         }
     }
     if ($forWS && $ownConfig && $this->firstExec('jacl2:' . $aclconfig)) {
         $cf = new jIniFileModifier(jApp::configPath($aclconfig));
         $cf->setValue('on_error', 1);
         $cf->save();
     }
     $this->declarePluginsPath('module:jacl2db');
     if (!$this->firstDbExec()) {
         return;
     }
     $this->declareDbProfile('jacl2_profile', null, false);
     $driver = $this->config->getValue('driver', 'acl2');
     if ($driver != 'db') {
         $this->config->setValue('driver', 'db', 'acl2');
     }
     $this->execSQLScript('install_jacl2.schema');
     $this->execSQLScript('data.sql');
     if ($this->getParameter('defaultuser') || $this->getParameter('defaultgroups')) {
         // declare some groups
         $this->execSQLScript('groups.sql');
     }
     if ($this->getParameter('defaultuser')) {
         $this->execSQLScript('user.sql');
     }
 }
Beispiel #13
0
 function install()
 {
     $authconfig = $this->config->getValue('auth', 'coordplugins');
     $authconfigMaster = $this->config->getValue('auth', 'coordplugins', null, true);
     $forWS = in_array($this->entryPoint->type, array('json', 'jsonrpc', 'soap', 'xmlrpc'));
     if (!$authconfig || $forWS && $authconfig == $authconfigMaster) {
         //if ($this->entryPoint->type == 'cmdline') {
         //    return;
         //}
         if ($forWS) {
             $pluginIni = 'authsw.coord.ini.php';
         } else {
             $pluginIni = 'auth.coord.ini.php';
         }
         $authconfig = dirname($this->entryPoint->configFile) . '/' . $pluginIni;
         if ($this->firstExec($authconfig)) {
             // no configuration, let's install the plugin for the entry point
             $this->config->setValue('auth', $authconfig, 'coordplugins');
             $this->copyFile('var/config/' . $pluginIni, 'epconfig:' . $pluginIni);
         }
     }
     $conf = new jIniFileModifier(jApp::configPath() . $authconfig);
     $this->useDbProfile($conf->getValue('profile', 'Db'));
     if ($this->firstExec($authconfig) && $this->getParameter('rewriteconfig')) {
         $conf->setValue('driver', 'Db');
         $conf->setValue('dao', 'jcommunity~user', 'Db');
         $conf->setValue('error_message', 'jcommunity~login.error.notlogged');
         $conf->setValue('on_error_action', 'jcommunity~login:out');
         $conf->setValue('bad_ip_action', 'jcommunity~login:out');
         $conf->setValue('after_login', 'jcommunity~account:show');
         $conf->setValue('after_logout', 'jcommunity~login:index');
         $conf->setValue('enable_after_login_override', 'on');
         $conf->setValue('enable_after_logout_override', 'on');
         $conf->save();
     }
     if ($this->firstDbExec()) {
         $this->execSQLScript('sql/install');
         if ($this->getParameter('defaultuser')) {
             $cn = $this->dbConnection();
             $cn->exec("INSERT INTO " . $cn->prefixTable('community_users') . " (login, password, email ) VALUES\n                            ('admin', '" . sha1('admin') . "' , '*****@*****.**')");
         }
     }
 }
 function install()
 {
     $isMaster = false;
     $autoLocaleFile = $this->config->getOverrider()->getValue('autolocale', 'coordplugins');
     if ($autoLocaleFile == '') {
         $autoLocaleFile = $this->config->getMaster()->getValue('autolocale', 'coordplugins');
         $isMaster = true;
     }
     if ($autoLocaleFile == '' || !$this->firstExec('autolocale:' . $autoLocaleFile)) {
         return;
     }
     $ini = new jIniFileModifier(jApp::configPath($autoLocaleFile));
     $availableLocales = $ini->getValue('availableLanguageCode');
     if ($isMaster) {
         $this->config->getMaster()->setValue('availableLocales', $availableLocales);
     } else {
         $this->config->getOverrider()->setValue('availableLocales', $availableLocales);
     }
     $ini->removeValue('availableLanguageCode');
     $ini->save();
 }
Beispiel #15
0
 function install()
 {
     //if ($this->entryPoint->type == 'cmdline')
     //    return;
     $authconfig = $this->config->getValue('auth', 'coordplugins');
     if ($authconfig && $this->firstExec($authconfig)) {
         // a config file for the auth plugin exists, so we can install
         // the module, else we ignore it
         $conf = new jIniFileModifier(jApp::configPath($authconfig));
         $driver = $conf->getValue('driver');
         if ($driver == '') {
             $driver = 'Db';
             $conf->setValue('driver', 'Db');
             $conf->setValue('dao', 'jauthdb~jelixuser', 'Db');
             $conf->save();
         } else {
             if ($driver != 'Db') {
                 return;
             }
         }
         $this->useDbProfile($conf->getValue('profile', 'Db'));
         // FIXME: should use the given dao to create the table
         $daoName = $conf->getValue('dao', 'Db');
         if ($daoName == 'jauthdb~jelixuser' && $this->firstDbExec()) {
             $this->execSQLScript('install_jauth.schema');
             if ($this->getParameter('defaultuser')) {
                 require_once JELIX_LIB_PATH . 'auth/jAuth.class.php';
                 require_once JELIX_LIB_PATH . 'plugins/auth/db/db.auth.php';
                 $confIni = parse_ini_file(jApp::configPath($authconfig), true);
                 $authConfig = jAuth::loadConfig($confIni);
                 $driver = new dbAuthDriver($authConfig['Db']);
                 $passwordHash = $driver->cryptPassword('admin');
                 $cn = $this->dbConnection();
                 $cn->exec("INSERT INTO " . $cn->prefixTable('jlx_user') . " (usr_login, usr_password, usr_email ) VALUES\n                                ('admin', " . $cn->quote($passwordHash) . " , '*****@*****.**')");
             }
         }
     }
 }
Beispiel #16
0
 public function run()
 {
     jxs_init_jelix_env();
     $entrypoint = $this->getParam('entrypoint');
     if (!file_exists(JELIX_APP_WWW_PATH . $entrypoint . '.php')) {
         try {
             $cmd = jxs_load_command('createentrypoint');
             $cmd->init(array(), array('name' => $entrypoint));
             $cmd->run();
         } catch (Exception $e) {
             echo "The entrypoint has not been created because of this error: " . $e->getMessage() . ". No other files have been created.\n";
         }
     }
     $inifile = new jIniMultiFilesModifier(JELIX_APP_CONFIG_PATH . 'defaultconfig.ini.php', JELIX_APP_CONFIG_PATH . $entrypoint . '/config.ini.php');
     $inifile->setValue('html', 'adminHtmlResponse', 'responses');
     $inifile->setValue('htmlauth', 'adminLoginHtmlResponse', 'responses');
     $inifile->setValue('auth', $entrypoint . '/auth.coord.ini.php', 'coordplugins');
     $inifile->setValue('jacl2', $entrypoint . '/jacl2.coord.ini.php', 'coordplugins');
     $inifile->setValue('startModule', 'master_admin');
     $inifile->setValue('startAction', 'default:index');
     $modulePath = $inifile->getValue("modulesPath");
     if (strpos($modulePath, 'lib:jelix-admin-modules') === false) {
         $inifile->setValue('modulesPath', 'lib:jelix-admin-modules/,' . $modulePath);
     }
     $inifile->setValue('driver', 'db', 'acl2');
     $urlconf = $inifile->getValue($entrypoint, 'simple_urlengine_entrypoints', null, true);
     if ($urlconf === null || $urlconf == '') {
         // in defaultconfig
         $inifile->setValue($entrypoint, 'jacl2db_admin~*@classic, jauthdb_admin~*@classic, master_admin~*@classic', 'simple_urlengine_entrypoints', null, true);
         // in the config of the entry point
         $inifile->setValue($entrypoint, 'jacl2db~*@classic, jauth~*@classic, jacl2db_admin~*@classic, jauthdb_admin~*@classic, master_admin~*@classic', 'simple_urlengine_entrypoints');
     } else {
         $urlconf2 = $inifile->getValue($entrypoint, 'simple_urlengine_entrypoints');
         if (strpos($urlconf, 'jacl2db_admin~*@classic') === false) {
             $urlconf .= ',jacl2db_admin~*@classic';
         }
         if (strpos($urlconf, 'jauthdb_admin~*@classic') === false) {
             $urlconf .= ',jauthdb_admin~*@classic';
         }
         if (strpos($urlconf, 'master_admin~*@classic') === false) {
             $urlconf .= ',master_admin~*@classic';
         }
         if (strpos($urlconf2, 'jacl2db_admin~*@classic') === false) {
             $urlconf2 .= ',jacl2db_admin~*@classic';
         }
         if (strpos($urlconf2, 'jauthdb_admin~*@classic') === false) {
             $urlconf2 .= ',jauthdb_admin~*@classic';
         }
         if (strpos($urlconf2, 'master_admin~*@classic') === false) {
             $urlconf2 .= ',master_admin~*@classic';
         }
         if (strpos($urlconf2, 'jacl2db~*@classic') === false) {
             $urlconf2 .= ',jacl2db~*@classic';
         }
         if (strpos($urlconf2, 'jauth~*@classic') === false) {
             $urlconf2 .= ',jauth~*@classic';
         }
         $inifile->setValue($entrypoint, $urlconf, 'simple_urlengine_entrypoints', null, true);
         $inifile->setValue($entrypoint, $urlconf2, 'simple_urlengine_entrypoints');
     }
     if (null == $inifile->getValue($entrypoint, 'basic_significant_urlengine_entrypoints', null, true)) {
         $inifile->setValue($entrypoint, '1', 'basic_significant_urlengine_entrypoints', null, true);
     }
     $params = array();
     $this->createFile(JELIX_APP_PATH . 'responses/adminHtmlResponse.class.php', 'responses/adminHtmlResponse.class.php.tpl', $params);
     $this->createFile(JELIX_APP_PATH . 'responses/adminLoginHtmlResponse.class.php', 'responses/adminLoginHtmlResponse.class.php.tpl', $params);
     $this->createFile(JELIX_APP_PATH . 'var/config/' . $entrypoint . '/auth.coord.ini.php', 'var/config/auth.coord.ini.php.tpl', $params);
     $this->createFile(JELIX_APP_PATH . 'var/config/' . $entrypoint . '/jacl2.coord.ini.php', 'var/config/jacl2.coord.ini.php.tpl', $params);
     $authini = new jIniFileModifier(JELIX_APP_CONFIG_PATH . $entrypoint . '/auth.coord.ini.php');
     $authini->setValue('after_login', 'master_admin~default:index');
     $authini->setValue('timeout', '30');
     $profile = $this->getOption('-profile');
     if (!$this->getOption('-noauthdb')) {
         $authini->setValue('dao', 'jauth~jelixuser', 'Db');
         $authini->setValue('form', 'jauthdb_admin~jelixuser', 'Db');
         if ($profile != '') {
             $authini->setValue('profile', $profile, 'Db');
         }
         $tools = jDb::getTools($profile);
         $db = jDb::getConnection($profile);
         $path = JELIX_LIB_PATH . 'core-modules/jelix/install/sql/';
         if (file_exists($path . 'install_jauth.schema.' . $db->dbms . '.sql')) {
             try {
                 $tools->execSQLScript($path . 'install_jauth.schema.' . $db->dbms . '.sql');
                 $rs = $db->query("SELECT usr_login FROM jlx_user WHERE usr_login='******'");
                 if (!$rs || !$rs->fetch()) {
                     $db->exec("INSERT INTO jlx_user (usr_login , usr_password , usr_email) VALUES ('admin', '" . md5('admin') . "', '*****@*****.**')");
                 }
                 $rs = null;
             } catch (Exception $e) {
                 echo "An error has occured during the execution of SQL script to install jAuth: " . $e->getMessage() . "\n";
             }
         } else {
             echo "Tables and datas for jAuth.db couldn't be created because SQL scripts are not available for the database declared in the profile.\nYou should initialize the database by hand.\n";
         }
     } else {
         $inifile->setValue('unusedModules', $inifile->getValue('unusedModules') . ', jauthdb_admin');
     }
     if (!$this->getOption('-noacl2db')) {
         $tools = jDb::getTools($profile);
         $db = jDb::getConnection($profile);
         $path = JELIX_LIB_PATH . 'core-modules/jelix/install/sql/';
         $tables = $tools->getTableList();
         if (in_array('jacl2_rights', $tables)) {
             ob_start();
             try {
                 $cmd = jxs_load_command('acl2group');
                 $cmd->init(array(), array('action' => 'createuser', '...' => array('admin')));
                 $cmd->run();
             } catch (Exception $e) {
             }
             try {
                 $cmd = jxs_load_command('acl2group');
                 $cmd->init(array(), array('action' => 'adduser', '...' => array('admins', 'admin')));
                 $cmd->run();
             } catch (Exception $e) {
             }
             $subjects = array('auth.users.list' => 'jelix~auth.acl.users.list', 'auth.users.view' => 'jelix~auth.acl.users.view', 'auth.users.modify' => 'jelix~auth.acl.users.modify', 'auth.users.create' => 'jelix~auth.acl.users.create', 'auth.users.delete' => 'jelix~auth.acl.users.delete', 'auth.users.change.password' => 'jelix~auth.acl.users.change.password', 'auth.user.view' => 'jelix~auth.acl.user.view', 'auth.user.modify' => 'jelix~auth.acl.user.modify', 'auth.user.change.password' => 'jelix~auth.acl.user.change.password');
             foreach ($subjects as $subject => $label) {
                 try {
                     $cmd = jxs_load_command('acl2right');
                     $cmd->init(array(), array('action' => 'subject_create', '...' => array($subject, $label)));
                     $cmd->run();
                 } catch (Exception $e) {
                 }
             }
             $rights = array(array('auth.users.list', 'admins'), array('auth.users.view', 'admins'), array('auth.users.modify', 'admins'), array('auth.users.create', 'admins'), array('auth.users.delete', 'admins'), array('auth.users.change.password', 'admins'), array('auth.user.view', 'admins'), array('auth.user.modify', 'admins'), array('auth.user.change.password', 'admins'), array('auth.user.view', 'users'), array('auth.user.modify', 'users'), array('auth.user.change.password', 'users'));
             foreach ($rights as $right) {
                 try {
                     $cmd = jxs_load_command('acl2right');
                     $cmd->init(array(), array('action' => 'add', '...' => array($right[1], $right[0])));
                     $cmd->run();
                 } catch (Exception $e) {
                 }
             }
             ob_end_clean();
         } else {
             if (file_exists($path . 'install_jauth.schema.' . $db->dbms . '.sql')) {
                 try {
                     $tools->execSQLScript($path . 'install_jacl2.schema.' . $db->dbms . '.sql');
                     $tools->execSQLScript($path . 'install_jacl2.data.' . $db->dbms . '.sql');
                 } catch (Exception $e) {
                     echo "An error has occured during the execution of SQL script to install jAcl2.db: " . $e->getMessage() . "\n";
                 }
             } else {
                 echo "Tables and datas for jAcl2.db couldn't be created because SQL scripts are not available for the database declared in the profile.\nYou should initialize the database by hand.\n";
             }
         }
     } else {
         $inifile->setValue('unusedModules', $inifile->getValue('unusedModules') . ', jacl2db_admin');
     }
     $authini->save();
     $inifile->save();
 }
 /**
  * save the ini files
  */
 public function save()
 {
     $this->master->save();
     $this->overrider->save();
 }
Beispiel #18
0
 /**
  * private function to handle the configuration migration
  */
 private function _updateConfig()
 {
     /**
      *
      * DataBase CONFIG FILE : dbprofils.ini.php
      *
      */
     $dBini = new jIniFileModifier(jApp::configPath() . 'dbprofils.ini.php');
     $dBini->setValue('jacl2_profile', 'havefnubb');
     $dBini->save();
     /**
      *
      * Main CONFIG FILE : defaultconfig.ini.php
      *
      */
     $iniDef = new jIniFileModifier(jApp::configPath() . 'defaultconfig.ini.php');
     $this->defaultModulesPath = $iniDef->getValue('modulesPath');
     //need to add app:admin-modules to the modulesPath
     if (strpos($this->defaultModulesPath, 'app:admin-modules/') === false) {
         $this->defaultModulesPath .= ',app:admin-modules/';
     }
     // need to add jelix-admin-modules to user jauthdb_admin
     if (strpos($this->defaultModulesPath, 'lib:jelix-admin-modules/') === false) {
         $this->defaultModulesPath = 'lib:jelix-admin-modules/,' . $this->defaultModulesPath;
     }
     // let's migrate config, section by section
     $this->defaultCheckTrustedModules = $iniDef->getValue('checkTrustedModules');
     if ($this->defaultCheckTrustedModules === null) {
         $this->defaultCheckTrustedModules = false;
     }
     $this->defaultTrustedModules = $iniDef->getValue('trustedModules');
     if ($this->defaultTrustedModules === null) {
         $this->defaultTrustedModules = '';
     }
     $allModulePath = $this->getModulesPath($this->defaultModulesPath, $this->defaultCheckTrustedModules ? 1 : 2);
     if ($this->defaultCheckTrustedModules) {
         $list = preg_split('/ *, */', $this->defaultTrustedModules);
         foreach ($list as $module) {
             if (isset($allModulePath[$module])) {
                 $allModulePath[$module]->access = 2;
             }
         }
     }
     $this->defaultUnusedModules = $iniDef->getValue('unusedModules');
     if ($this->defaultUnusedModules) {
         $list = preg_split('/ *, */', $this->defaultUnusedModules);
         foreach ($list as $module) {
             if (isset($allModulePath[$module])) {
                 $allModulePath[$module]->access = 0;
             }
         }
     }
     foreach ($allModulePath as $name => $module) {
         $iniDef->setValue($name . '.access', $module->access, 'modules');
     }
     $iniDef->removeValue('checkTrustedModules');
     $iniDef->removeValue('trustedModules');
     $iniDef->removeValue('unusedModules');
     $iniDef->removeValue('hiddenModules');
     //modulesPath
     $iniDef->setValue('modulesPath', $this->defaultModulesPath);
     //section [coordplugins]
     $iniDef->removeValue('hfnuinstalled', 'coordplugins');
     //[basic_significant_urlengine_entrypoints]
     $iniDef->setValue('forums', 'on', 'basic_significant_urlengine_entrypoints');
     $iniDef->setValue('install', 'on', 'basic_significant_urlengine_entrypoints');
     //section [simple_urlengine_entrypoints]
     $iniDef->setValue('forums', '@classic', 'simple_urlengine_entrypoints');
     //section [datepickers]
     $iniDef->setValue('green', 'jelix/js/jforms/datepickers/green/init.js', 'datepickers');
     $iniDef->setValue('dust', 'jelix/js/jforms/datepickers/dust/init.js', 'datepickers');
     $iniDef->setValue('emplode', 'jelix/js/jforms/datepickers/emplode/init.js', 'datepickers');
     $iniDef->setValue('default', 'jelix/js/jforms/datepickers/default/init.js', 'datepickers');
     //section [wikieditors]
     $iniDef->setValue('default.engine.name', 'wr3', 'wikieditors');
     $iniDef->setValue('default.wiki.rules', 'wr3_to_xhtml', 'wikieditors');
     $iniDef->setValue('default.engine.file', 'jelix/markitup/jquery.markitup.js', 'wikieditors');
     $iniDef->setValue('default.image.path', 'jelix/markitup/sets/wr3/images/', 'wikieditors');
     $iniDef->setValue('default.skin', 'jelix/markitup/skins/simple/style.css', 'wikieditors');
     //section [havefnubb]
     $iniDef->setValue('version', '1.4.0', 'havefnubb');
     $iniDef->save();
     /**
      *
      * Flood CONFIG FILE : havefnubb/flood.coord.ini.php
      *
      */
     //floodcoord.ini.php of the forums entrypoint
     $floodCoordIni = new jIniFileModifier(jApp::configPath() . 'havefnubb/flood.coord.ini.php');
     //drop deprecated parms
     $floodCoordIni->removeValue('elapsed_time_between_two_post_by_same_ip');
     $floodCoordIni->removeValue('elapsed_time_after_posting_before_editing');
     //add new parms
     $floodCoordIni->setValue('only_same_ip', 0);
     $floodCoordIni->setValue('time_interval', 30);
     $floodCoordIni->setValue('elapsed_time_between_two_post', 0);
     $floodCoordIni->save();
     /**
      *
      * ACL CONFIG FILE : havefnubb/jacl2.coord.ini.php
      *
      */
     $jacl2Config = new jIniFileModifier(jApp::configPath() . 'havefnubb/jacl2.coord.ini.php');
     $jacl2Config->setValue('on_error_action', 'havefnubb~hfnuerror:badright');
     $jacl2Config->save();
     /**
      *
      * AUTH CONFIG FILE : hfnuadmin/auth.coord.ini.php
      *
      */
     $adminAuthConfig = new jIniFileModifier(jApp::configPath() . 'hfnuadmin/auth.coord.ini.php');
     $adminAuthConfig->setValue('timeout', 0);
     $adminAuthConfig->setValue('dao', 'jcommunity~user', 'Db');
     $adminAuthConfig->save();
     /**
      *
      * CONFIG FILE of each entry point : havefnubb/config.ini.php  +
      *                                   hfnuadmin/config.ini.php
      *
      */
     $entryPointConfigFiles = array(jApp::configPath() . 'havefnubb/config.ini.php', jApp::configPath() . 'hfnuadmin/config.ini.php');
     $help = "<p>In each config files of your entry points, fill this parameters:<br/>" . "<ul><li> checkTrustedModules=on</li>" . "<li>trustedModules: list of modules accessible from the web</li>" . "<li> unusedModules: those you don't use at all</li>" . "<li>For other modules you use but which should not be accessible from the web, nothing to do.</li></ul>";
     $otherModulePath = array();
     foreach ($entryPointConfigFiles as $currentIni) {
         $iniConfig = new jIniFileModifier($currentIni);
         //common tasks
         $modulesPath = $iniConfig->getValue('modulesPath');
         if (!$modulesPath) {
             $modulesPath = $this->defaultModulesPath;
         }
         //need to add app:admin-modules to the modulesPath of the admin entrypoint
         if (strpos($modulesPath, 'app:admin-modules/') === false) {
             $modulesPath .= ',app:admin-modules/';
         }
         if (strpos($modulesPath, 'lib:jelix-admin-modules/') === false) {
             $modulesPath = 'lib:jelix-admin-modules/,' . $modulesPath;
         }
         $checkTrustedModules = $iniConfig->getValue('checkTrustedModules');
         if ($checkTrustedModules === null) {
             $checkTrustedModules = $this->defaultCheckTrustedModules;
         }
         if (!$checkTrustedModules) {
             throw new Exception("checkTrustedModules should be set to 'on' in config files.\n{$help}");
             return "checkTrustedModules should be set to 'on' in config files.\n{$help}";
         }
         $trustedModules = $iniConfig->getValue('trustedModules');
         if (!$trustedModules) {
             $trustedModules = $this->defaultTrustedModules;
         }
         if ($trustedModules == '') {
             throw new Exception("trustedModules should be filled in config files.\n{$help}");
             return "trustedModules should be filled in config files.\n{$help}";
         }
         // add the new admin module to the $trustedModules
         if ($currentIni == jApp::configPath() . 'hfnuadmin/config.ini.php') {
             $trustedModules .= 'activeusers_admin, hfnuadmin, jelixcache, modulesinfo, servinfo';
         }
         $unusedModules = $iniConfig->getValue('unusedModules');
         if (!$unusedModules) {
             $unusedModules = $this->defaultUnusedModules;
         }
         $epModulePath = $this->getModulesPath($modulesPath, 1);
         $list = preg_split('/ *, */', $trustedModules);
         foreach ($list as $module) {
             if (isset($epModulePath[$module])) {
                 $epModulePath[$module]->access = 2;
             }
         }
         if ($unusedModules) {
             $list = preg_split('/ *, */', $unusedModules);
             foreach ($list as $module) {
                 if (isset($epModulePath[$module])) {
                     $epModulePath[$module]->access = 0;
                 }
             }
         }
         foreach ($epModulePath as $name => $module) {
             if (!isset($allModulePath[$name]) || $allModulePath[$name]->access != $module->access) {
                 $iniConfig->setValue($name . '.access', $module->access, 'modules');
             }
             if (!isset($allModulePath[$name]) && !isset($otherModulePath[$name])) {
                 $otherModulePath[$name] = $module;
             }
         }
         $iniConfig->removeValue('checkTrustedModules');
         $iniConfig->removeValue('trustedModules');
         $iniConfig->removeValue('unusedModules');
         $iniConfig->removeValue('hiddenModules');
         // end common tasks
         //specific tasks
         if ($currentIni == jApp::configPath() . 'havefnubb/config.ini.php') {
             //[coordplugins]
             //drop deprecated parms
             $iniConfig->removeValue('hfnuinstalled', 'coordplugins');
             $iniConfig->removeValue('timeout', 'coordplugins');
             //add new parms
             $iniConfig->setValue('activeusers', 'activeusers.coord.ini.php', 'coordplugins');
             //[urlengine]
             //remove this unuseful section
             $iniConfig->removeValue('engine', 'urlengine');
             $iniConfig->removeValue('enableParser', 'urlengine');
             $iniConfig->removeValue('multiview', 'urlengine');
             $iniConfig->removeValue('defaultEntrypoint', 'urlengine');
             $iniConfig->removeValue('entrypointExtension', 'urlengine');
             $iniConfig->removeValue('notfoundAct', 'urlengine');
         } elseif ($currentIni == jApp::configPath() . 'hfnuadmin/config.ini.php') {
             $iniConfig->removeValue('engine', 'urlengine');
             //add a new section [activeusers_admin]
             $iniConfig->setValue('pluginconf', 'activeusers.coord.ini.php', 'activeusers_admin');
         }
         $iniConfig->save();
     }
     /**
      *
      * DROP DEPRECATED FILE
      *
      */
     @unlink(jApp::configPath() . 'havefnubb/timeout.coord.ini.php');
     @unlink(jApp::configPath() . 'havefnubb/hfnuinstalled.coord.ini.php');
     //this file has been integrated inside the defaultconfig.ini.php
     //in the section [wikieditor]
     //so drop it
     @unlink(jApp::configPath() . 'wikitoolbar.ini.php');
 }
 /**
  * declare a new db profile. if the content of the section is not given,
  * it will declare an alias to the default profile
  * @param string $name  the name of the new section/alias
  * @param null|string|array  $sectionContent the content of the new section, or null
  *     to create an alias.
  * @param boolean $force true:erase the existing profile
  * @return boolean true if the ini file has been changed
  */
 protected function declareDbProfile($name, $sectionContent = null, $force = true)
 {
     $profiles = new jIniFileModifier(jApp::configPath('profiles.ini.php'));
     if ($sectionContent == null) {
         if (!$profiles->isSection('jdb:' . $name)) {
             // no section
             if ($profiles->getValue($name, 'jdb') && !$force) {
                 // already a name
                 return false;
             }
         } else {
             if ($force) {
                 // existing section, and no content provided : we erase the section
                 // and add an alias
                 $profiles->removeValue('', 'jdb:' . $name);
             } else {
                 return false;
             }
         }
         $default = $profiles->getValue('default', 'jdb');
         if ($default) {
             $profiles->setValue($name, $default, 'jdb');
         } else {
             // default is a section
             $profiles->setValue($name, 'default', 'jdb');
         }
     } else {
         if ($profiles->getValue($name, 'jdb') !== null) {
             if (!$force) {
                 return false;
             }
             $profiles->removeValue($name, 'jdb');
         }
         if (is_array($sectionContent)) {
             foreach ($sectionContent as $k => $v) {
                 $profiles->setValue($k, $v, 'jdb:' . $name);
             }
         } else {
             $profile = $profiles->getValue($sectionContent, 'jdb');
             if ($profile !== null) {
                 $profiles->setValue($name, $profile, 'jdb');
             } else {
                 $profiles->setValue($name, $sectionContent, 'jdb');
             }
         }
     }
     $profiles->save();
     jProfiles::clear();
     return true;
 }
 /**
  * Removes a repository
  */
 public static function removeRepository($key)
 {
     if (!in_array($key, self::$repositories)) {
         if (!in_array($key, self::getRepositoryList())) {
             return false;
         }
     }
     // Get access to the ini file
     $iniFile = jApp::configPath('lizmapConfig.ini.php');
     $ini = new jIniFileModifier($iniFile);
     // Remove the section corresponding to the repository
     $section = 'repository:' . $key;
     if ($ini->isSection($section)) {
         $ini->removeValue(null, $section);
         $ini->save();
         self::getRepositoryList();
         if (array_key_exists($key, self::$repositoryInstances)) {
             unset(self::$repositoryInstances[$key]);
         }
         return true;
     }
     return false;
 }
Beispiel #21
0
 /**
  * update configuration files
  */
 protected function updateConfig()
 {
     // retrieve the default config
     $defaultconfig = new jIniFileModifier(jApp::configPath('defaultconfig.ini.php'));
     $this->defaultModulesPath = $defaultconfig->getValue('modulesPath');
     if (!$this->defaultModulesPath) {
         $this->defaultModulesPath = 'lib:jelix-modules/,app:modules/';
     }
     if ($this->checkStep("Update configuration files")) {
         $configList = array();
         $this->defaultCheckTrustedModules = $defaultconfig->getValue('checkTrustedModules');
         if ($this->defaultCheckTrustedModules === null) {
             $this->defaultCheckTrustedModules = false;
         }
         $this->defaultTrustedModules = $defaultconfig->getValue('trustedModules');
         if ($this->defaultTrustedModules === null) {
             $this->defaultTrustedModules = '';
         }
         $allModulePath = $this->getModulesPath($this->defaultModulesPath, $this->defaultCheckTrustedModules ? 1 : 2);
         if ($this->defaultCheckTrustedModules) {
             $list = preg_split('/ *, */', $this->defaultTrustedModules);
             foreach ($list as $module) {
                 if (isset($allModulePath[$module])) {
                     $allModulePath[$module]->access = 2;
                 }
             }
         }
         $this->defaultUnusedModules = $defaultconfig->getValue('unusedModules');
         if ($this->defaultUnusedModules) {
             $list = preg_split('/ *, */', $this->defaultUnusedModules);
             foreach ($list as $module) {
                 if (isset($allModulePath[$module])) {
                     $allModulePath[$module]->access = 0;
                 }
             }
         }
         foreach ($allModulePath as $name => $module) {
             $defaultconfig->setValue($name . '.access', $module->access, 'modules');
         }
         $defaultconfig->removeValue('checkTrustedModules');
         $defaultconfig->removeValue('trustedModules');
         $defaultconfig->removeValue('unusedModules');
         $defaultconfig->removeValue('hiddenModules');
         $configList['defaultconfig.ini.php'] = $defaultconfig;
         // read each entry point configuration
         $eplist = $this->getEntryPointsList();
         $help = "In each config files of your entry points, fill this parameters:\n" . "* checkTrustedModules=on\n" . "* trustedModules: list of modules accessible from the web\n" . "* unusedModules: those you don't use at all\n" . "For other modules you use but which should not be accessible from the web, nothing to do.\n";
         // list of modules which are not declared into the default config
         $otherModulePath = array();
         foreach ($eplist as $ep) {
             if (isset($configList[$ep['config']])) {
                 continue;
             }
             $config = new jIniFileModifier(jApp::configPath($ep['config']));
             $modulesPath = $config->getValue('modulesPath');
             if (!$modulesPath) {
                 $modulesPath = $this->defaultModulesPath;
             }
             $checkTrustedModules = $config->getValue('checkTrustedModules');
             if ($checkTrustedModules === null) {
                 $checkTrustedModules = $this->defaultCheckTrustedModules;
             }
             if (!$checkTrustedModules) {
                 throw new Exception("checkTrustedModules should be set to 'on' in config files.\n{$help}");
             }
             $trustedModules = $config->getValue('trustedModules');
             if (!$trustedModules) {
                 $trustedModules = $this->defaultTrustedModules;
             }
             if ($trustedModules == '') {
                 throw new Exception("trustedModules should be filled in config files.\n{$help}");
             }
             $unusedModules = $config->getValue('unusedModules');
             if (!$unusedModules) {
                 $unusedModules = $this->defaultUnusedModules;
             }
             $epModulePath = $this->getModulesPath($modulesPath, 1);
             $list = preg_split('/ *, */', $trustedModules);
             foreach ($list as $module) {
                 if (isset($epModulePath[$module])) {
                     $epModulePath[$module]->access = 2;
                 }
             }
             if ($unusedModules) {
                 $list = preg_split('/ *, */', $unusedModules);
                 foreach ($list as $module) {
                     if (isset($epModulePath[$module])) {
                         $epModulePath[$module]->access = 0;
                     }
                 }
             }
             foreach ($epModulePath as $name => $module) {
                 if (!isset($allModulePath[$name]) || $allModulePath[$name]->access != $module->access) {
                     $config->setValue($name . '.access', $module->access, 'modules');
                 }
                 if (!isset($allModulePath[$name]) && !isset($otherModulePath[$name])) {
                     $otherModulePath[$name] = $module;
                 }
             }
             $config->removeValue('checkTrustedModules');
             $config->removeValue('trustedModules');
             $config->removeValue('unusedModules');
             $config->removeValue('hiddenModules');
             $configList[$ep['config']] = $config;
         }
         // we save at the end, because an error could appear during the previous loop
         // and we don't want to save change if there are errors
         $defaultconfig->save();
         foreach ($configList as $config) {
             $config->save();
         }
     } else {
         // load list of modules for the next step
         $allModulePath = $this->getModulesPath($this->defaultModulesPath, 2);
         $eplist = $this->getEntryPointsList();
         // list of modules which are not declared into the default config
         $otherModulePath = array();
         foreach ($eplist as $ep) {
             if (isset($configList[$ep['config']])) {
                 continue;
             }
             $config = new jIniFileModifier(jApp::configPath($ep['config']));
             $modulesPath = $config->getValue('modulesPath');
             if (!$modulesPath) {
                 $modulesPath = $this->defaultModulesPath;
             }
             $epModulePath = $this->getModulesPath($modulesPath, 1);
             foreach ($epModulePath as $name => $module) {
                 if (!isset($allModulePath[$name]) && !isset($otherModulePath[$name])) {
                     $otherModulePath[$name] = $module;
                 }
             }
         }
     }
     if ($this->checkStep("Update module.xml files")) {
         foreach ($allModulePath as $name => $module) {
             $this->updateModuleXml($module);
         }
         foreach ($otherModulePath as $name => $module) {
             $this->updateModuleXml($module);
         }
     }
 }
 function install()
 {
     $profilesfile = jApp::configPath('profiles.ini.php');
     if (!file_exists($profilesfile)) {
         file_put_contents($profilesfile, ";<?php die(''); ?>\n;for security reasons, don't remove or modify the first line");
     }
     $profiles = new jIniFileModifier($profilesfile);
     $profilesdistfile = jApp::configPath('profiles.ini.php.dist');
     $distcreated = false;
     if (!file_exists($profilesdistfile)) {
         file_put_contents($profilesdistfile, ";<?php die(''); ?>\n;for security reasons, don't remove or modify the first line");
         $distcreated = true;
     }
     $profilesdist = new jIniFileModifier($profilesdistfile);
     $dbprofile = $this->config->getValue('dbProfils');
     if (!$dbprofile) {
         $dbprofile = 'dbprofils.ini.php';
     }
     $dbprofilefile = jApp::configPath($dbprofile);
     if (file_exists($dbprofilefile)) {
         $dbProfiles = new jIniFileModifier($dbprofilefile);
         $profiles->import($dbProfiles, 'jdb', ':');
         unlink($dbprofilefile);
     }
     $dbprofilefile = jApp::configPath('dbprofils.ini.php.dist');
     if (file_exists($dbprofilefile)) {
         $dbProfiles = new jIniFileModifier($dbprofilefile);
         $profilesdist->import($dbProfiles, 'jdb', ':');
         unlink($dbprofilefile);
     }
     $kvprofilefile = jApp::configPath('kvprofiles.ini.php');
     if (file_exists($kvprofilefile)) {
         $dbProfiles = new jIniFileModifier($kvprofilefile);
         $profiles->import($dbProfiles, 'jkvdb', ':');
         unlink($kvprofilefile);
     }
     $kvprofilefile = jApp::configPath('kvprofiles.ini.php.dist');
     if (file_exists($kvprofilefile)) {
         $dbProfiles = new jIniFileModifier($kvprofilefile);
         $profilesdist->import($dbProfiles, 'jkvdb', ':');
         unlink($kvprofilefile);
     }
     $soapprofilefile = jApp::configPath('soapprofiles.ini.php');
     if (file_exists($soapprofilefile)) {
         $soapProfiles = new jIniFileModifier($soapprofilefile);
         $profiles->import($soapProfiles, 'jsoapclient', ':');
         unlink($soapprofilefile);
     }
     $soapprofilefile = jApp::configPath('soapprofiles.ini.php.dist');
     if (file_exists($soapprofilefile)) {
         $soapProfiles = new jIniFileModifier($soapprofilefile);
         $profilesdist->import($soapProfiles, 'jsoapclient', ':');
         unlink($soapprofilefile);
     }
     $cacheprofilefile = jApp::configPath('cache.ini.php');
     if (file_exists($cacheprofilefile)) {
         $cacheProfiles = new jIniFileModifier($cacheprofilefile);
         $profiles->import($cacheProfiles, 'jcache', ':');
         unlink($cacheprofilefile);
     }
     $cacheprofilefile = jApp::configPath('cache.ini.php.dist');
     if (file_exists($cacheprofilefile)) {
         $cacheProfiles = new jIniFileModifier($cacheprofilefile);
         $profilesdist->import($cacheProfiles, 'jcache', ':');
         unlink($cacheprofilefile);
     }
     $profiles->save();
     if ($profilesdist->isModified()) {
         $profilesdist->save();
     } else {
         if ($distcreated) {
             unlink($profilesdistfile);
         }
     }
     $this->config->getMaster()->removeValue('dbProfils');
     $this->config->getOverrider()->removeValue('dbProfils');
     $this->config->getMaster()->removeValue('cacheProfiles');
     $this->config->getOverrider()->removeValue('cacheProfiles');
 }
Beispiel #23
0
 public function run()
 {
     $this->loadAppConfig();
     $entrypoint = $this->getParam('entrypoint');
     if (($p = strpos($entrypoint, '.php')) !== false) {
         $entrypoint = substr($entrypoint, 0, $p);
     }
     $ep = $this->getEntryPointInfo($entrypoint);
     if ($ep == null) {
         try {
             $cmd = JelixScript::getCommand('createentrypoint', $this->config);
             $cmd->initOptParam(array(), array('name' => $entrypoint));
             $cmd->run();
             $this->projectXml = null;
             $ep = $this->getEntryPointInfo($entrypoint);
         } catch (Exception $e) {
             throw new Exception("The entrypoint has not been created because of this error: " . $e->getMessage() . ". No other files have been created.\n");
         }
     }
     $installConfig = new jIniFileModifier(jApp::configPath('installer.ini.php'));
     $inifile = new jIniMultiFilesModifier(jApp::configPath('defaultconfig.ini.php'), jApp::configPath($ep['config']));
     $params = array();
     $this->createFile(jApp::appPath('responses/adminHtmlResponse.class.php'), 'responses/adminHtmlResponse.class.php.tpl', $params);
     $this->createFile(jApp::appPath('responses/adminLoginHtmlResponse.class.php'), 'responses/adminLoginHtmlResponse.class.php.tpl', $params);
     $inifile->setValue('html', 'adminHtmlResponse', 'responses');
     $inifile->setValue('htmlauth', 'adminLoginHtmlResponse', 'responses');
     $inifile->setValue('startModule', 'master_admin');
     $inifile->setValue('startAction', 'default:index');
     $modulePath = $inifile->getValue("modulesPath", 0, null, true);
     if (strpos($modulePath, 'lib:jelix-admin-modules') === false) {
         // we set it on defaultconfig.ini.php, so if the url engine is "significant"
         // it could know the admin modules during the parsing of modules
         $inifile->setValue('modulesPath', 'lib:jelix-admin-modules/,' . $modulePath, 0, null, true);
     }
     $installConfig->setValue('jacldb.installed', '0', $entrypoint);
     $inifile->setValue('jacldb.access', '0', 'modules');
     $installConfig->setValue('junittests.installed', '0', $entrypoint);
     $inifile->setValue('junittests.access', '0', 'modules');
     $installConfig->setValue('jWSDL.installed', '0', $entrypoint);
     $inifile->setValue('jWSDL.access', '0', 'modules');
     $urlconf = $inifile->getValue($entrypoint, 'simple_urlengine_entrypoints', null, true);
     if ($urlconf === null || $urlconf == '') {
         // in defaultconfig
         $inifile->setValue($entrypoint, 'jacl2db_admin~*@classic, jauthdb_admin~*@classic, master_admin~*@classic', 'simple_urlengine_entrypoints', null, true);
         // in the config of the entry point
         $inifile->setValue($entrypoint, 'jacl2db~*@classic, jauth~*@classic, jacl2db_admin~*@classic, jauthdb_admin~*@classic, master_admin~*@classic', 'simple_urlengine_entrypoints');
     } else {
         $urlconf2 = $inifile->getValue($entrypoint, 'simple_urlengine_entrypoints');
         if (strpos($urlconf, 'jacl2db_admin~*@classic') === false) {
             $urlconf .= ',jacl2db_admin~*@classic';
         }
         if (strpos($urlconf, 'jauthdb_admin~*@classic') === false) {
             $urlconf .= ',jauthdb_admin~*@classic';
         }
         if (strpos($urlconf, 'master_admin~*@classic') === false) {
             $urlconf .= ',master_admin~*@classic';
         }
         if (strpos($urlconf2, 'jacl2db_admin~*@classic') === false) {
             $urlconf2 .= ',jacl2db_admin~*@classic';
         }
         if (strpos($urlconf2, 'jauthdb_admin~*@classic') === false) {
             $urlconf2 .= ',jauthdb_admin~*@classic';
         }
         if (strpos($urlconf2, 'master_admin~*@classic') === false) {
             $urlconf2 .= ',master_admin~*@classic';
         }
         if (strpos($urlconf2, 'jacl2db~*@classic') === false) {
             $urlconf2 .= ',jacl2db~*@classic';
         }
         if (strpos($urlconf2, 'jauth~*@classic') === false) {
             $urlconf2 .= ',jauth~*@classic';
         }
         $inifile->setValue($entrypoint, $urlconf, 'simple_urlengine_entrypoints', null, true);
         $inifile->setValue($entrypoint, $urlconf2, 'simple_urlengine_entrypoints');
     }
     if (null == $inifile->getValue($entrypoint, 'basic_significant_urlengine_entrypoints', null, true)) {
         $inifile->setValue($entrypoint, '1', 'basic_significant_urlengine_entrypoints', null, true);
     }
     $inifile->save();
     require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php';
     $verbose = $this->getOption("-v");
     $reporter = new textInstallReporter($verbose ? 'notice' : 'warning');
     $installer = new jInstaller($reporter);
     $installer->installModules(array('master_admin'), $entrypoint . '.php');
     $authini = new jIniFileModifier(jApp::configPath($entrypoint . '/auth.coord.ini.php'));
     $authini->setValue('after_login', 'master_admin~default:index');
     $authini->setValue('timeout', '30');
     $authini->save();
     $profile = $this->getOption('-profile');
     if (!$this->getOption('-noauthdb')) {
         if ($profile != '') {
             $authini->setValue('profile', $profile, 'Db');
         }
         $authini->save();
         $installer->setModuleParameters('jauthdb', array('defaultuser' => true));
         $installer->installModules(array('jauthdb', 'jauthdb_admin'), $entrypoint . '.php');
     } else {
         $installConfig->setValue('jauthdb_admin.installed', '0', $entrypoint);
         $installConfig->save();
         $inifile->setValue('jauthdb_admin.access', '0', 'modules');
         $inifile->save();
     }
     if (!$this->getOption('-noacl2db')) {
         if ($profile != '') {
             $dbini = new jIniFileModifier(jApp::configPath('profiles.ini.php'));
             $dbini->setValue('jacl2_profile', $profile, 'jdb');
             $dbini->save();
         }
         $installer = new jInstaller($reporter);
         $installer->setModuleParameters('jacl2db', array('defaultuser' => true));
         $installer->installModules(array('jacl2db', 'jacl2db_admin'), $entrypoint . '.php');
     } else {
         $installConfig->setValue('jacl2db_admin.installed', '0', $entrypoint);
         $installConfig->save();
         $inifile->setValue('jacl2db_admin.access', '0', 'modules');
         $inifile->save();
     }
 }
Beispiel #24
0
 function process()
 {
     $ini = new jIniFileModifier(jApp::configPath('defaultconfig.ini.php'));
     $errors = array();
     $_SESSION['confmail']['webmasterEmail'] = trim($_POST['webmasterEmail']);
     if ($_SESSION['confmail']['webmasterEmail'] == '') {
         $errors[] = $this->locales['error.missing.webmasterEmail'];
     } else {
         $ini->setValue('webmasterEmail', $_SESSION['confmail']['webmasterEmail'], 'mailer');
     }
     $_SESSION['confmail']['webmasterName'] = trim($_POST['webmasterName']);
     $mailerType = $_SESSION['confmail']['mailerType'] = $_POST['mailerType'];
     $ini->setValue('mailerType', $mailerType, 'mailer');
     if ($mailerType == 'sendmail') {
         $_SESSION['confmail']['sendmailPath'] = trim($_POST['sendmailPath']);
         if ($_SESSION['confmail']['sendmailPath'] == '') {
             $errors[] = $this->locales['error.missing.sendmailPath'];
         } else {
             $ini->setValue('sendmailPath', $_SESSION['confmail']['sendmailPath'], 'mailer');
         }
     } elseif ($mailerType == 'smtp') {
         $_SESSION['confmail']['smtpHost'] = trim($_POST['smtpHost']);
         if ($_SESSION['confmail']['smtpHost'] == '') {
             $errors[] = $this->locales['error.missing.smtpHost'];
         } else {
             $ini->setValue('smtpHost', $_SESSION['confmail']['smtpHost'], 'mailer');
         }
         $smtpPort = $_SESSION['confmail']['smtpPort'] = trim($_POST['smtpPort']);
         if ($smtpPort != '' && intval($smtpPort) == 0) {
             $errors[] = $this->locales['error.smtpPort'];
         } else {
             $ini->setValue('smtpPort', $smtpPort, 'mailer');
         }
         $_SESSION['confmail']['smtpSecure'] = trim($_POST['smtpSecure']);
         if (isset($_POST['smtpAuth'])) {
             $smtpAuth = $_SESSION['confmail']['smtpAuth'] = trim($_POST['smtpAuth']);
             $smtpAuth = $smtpAuth != '';
         } else {
             $smtpAuth = false;
         }
         $ini->setValue('smtpAuth', $smtpAuth, 'mailer');
         if ($smtpAuth) {
             $_SESSION['confmail']['smtpUsername'] = trim($_POST['smtpUsername']);
             if ($_SESSION['confmail']['smtpUsername'] == '') {
                 $errors[] = $this->locales['error.missing.smtpUsername'];
             } else {
                 $ini->setValue('smtpUsername', $_SESSION['confmail']['smtpUsername'], 'mailer');
             }
             $_SESSION['confmail']['smtpPassword'] = trim($_POST['smtpPassword']);
             if ($_SESSION['confmail']['smtpPassword'] == '') {
                 $errors[] = $this->locales['error.missing.smtpPassword'];
             } else {
                 $ini->setValue('smtpPassword', $_SESSION['confmail']['smtpPassword'], 'mailer');
             }
         }
     }
     if (count($errors)) {
         $_SESSION['confmail']['errors'] = $errors;
         return false;
     }
     $ini->save();
     unset($_SESSION['confmail']);
     return 0;
 }
 /**
  * save the ini files
  */
 public function save($chmod = null)
 {
     $this->master->save($chmod);
     $this->overrider->save($chmod);
 }
    echo "Error: var/config/installer.ini.php is not found";
    exit(1);
}
try {
    $profiles = new jIniFileModifier(__DIR__ . '/../var/config/profiles.ini.php');
} catch (Exception $e) {
    echo "Error: var/config/profiles.ini.php is not found";
    exit(1);
}
if (null === $installerIni->getValue('admin.contexts', '__modules_data')) {
    $installerIni->setValue('admin.contexts', 'acl2', '__modules_data');
}
if (null === $installerIni->getValue('lizmap.contexts', '__modules_data')) {
    $installerIni->setValue('lizmap.contexts', 'db:default,acl2', '__modules_data');
}
if (null === $installerIni->getValue('view.contexts', '__modules_data')) {
    $installerIni->setValue('view.contexts', 'db:default', '__modules_data');
}
$installerIni->save();
if ($profiles->getValue('dsn', 'jdb:jauth') == 'sqlite:var:jauth.db') {
    $profiles->setValue('dsn', Null, 'jdb:jauth');
    $profiles->setValue('driver', 'sqlite3', 'jdb:jauth');
    $profiles->setValue('database', 'var:db/jauth.db', 'jdb:jauth');
}
if ($profiles->getValue('dsn', 'jdb:lizlog') == 'sqlite:var:logs.db') {
    $profiles->setValue('dsn', Null, 'jdb:lizlog');
    $profiles->setValue('driver', 'sqlite3', 'jdb:lizlog');
    $profiles->setValue('database', 'var:db/logs.db', 'jdb:lizlog');
}
$profiles->save();
require __DIR__ . '/installer.php';
Beispiel #27
0
 function install()
 {
     $lizmapConfFile = jApp::configPath('lizmapConfig.ini.php');
     if (!file_exists($lizmapConfFile)) {
         $lizmapConfFileDist = jApp::configPath('lizmapConfig.ini.php.dist');
         if (file_exists($lizmapConfFileDist)) {
             copy($lizmapConfFileDist, $lizmapConfFile);
         } else {
             $this->copyFile('config/lizmapConfig.ini.php', $lizmapConfFile);
         }
     }
     $localConfig = jApp::configPath('localconfig.ini.php');
     if (!file_exists($localConfig)) {
         $localConfigDist = jApp::configPath('localconfig.ini.php.dist');
         if (file_exists($localConfigDist)) {
             copy($localConfigDist, $localConfig);
         } else {
             file_put_contents($localConfig, ';<' . '?php die(\'\');?' . '>');
         }
     }
     $ini = new jIniFileModifier($localConfig);
     $ini->setValue('lizmap', 'lizmapConfig.ini.php', 'coordplugins');
     $ini->save();
     if ($this->firstDbExec()) {
         // Add log table
         $this->useDbProfile('lizlog');
         $this->execSQLScript('sql/lizlog');
         // Add geobookmark table
         $this->useDbProfile('jauth');
         $this->execSQLScript('sql/lizgeobookmark');
     }
     if ($this->firstExec('acl2') && $this->getParameter('demo')) {
         $this->useDbProfile('auth');
         // create group
         jAcl2DbUserGroup::createGroup('lizadmins');
         jAcl2DbUserGroup::createGroup('Intranet demos group', 'intranet');
         // create user in jAuth
         require_once JELIX_LIB_PATH . 'auth/jAuth.class.php';
         require_once JELIX_LIB_PATH . 'plugins/auth/db/db.auth.php';
         $authconfig = $this->config->getValue('auth', 'coordplugins');
         $confIni = parse_ini_file(jApp::configPath($authconfig), true);
         $authConfig = jAuth::loadConfig($confIni);
         $driver = new dbAuthDriver($authConfig['Db']);
         $passwordHash1 = $driver->cryptPassword('lizadmin');
         $passwordHash2 = $driver->cryptPassword('logintranet');
         $cn = $this->dbConnection();
         $cn->exec("INSERT INTO " . $cn->prefixTable('jlx_user') . " (usr_login, usr_password, usr_email ) VALUES\n                        ('lizadmin', " . $cn->quote($passwordHash1) . " , '*****@*****.**')");
         $cn->exec("INSERT INTO " . $cn->prefixTable('jlx_user') . " (usr_login, usr_password, usr_email ) VALUES\n                        ('logintranet', " . $cn->quote($passwordHash2) . " , '*****@*****.**')");
         // declare users in jAcl2
         jAcl2DbUserGroup::createUser('lizadmin', true);
         jAcl2DbUserGroup::createUser('logintranet', true);
         jAcl2DbUserGroup::addUserToGroup('lizadmin', 'lizadmins');
         jAcl2DbUserGroup::addUserToGroup('logintranet', 'intranet');
         jAcl2DbManager::setRightsOnGroup('lizadmins', array('lizmap.admin.access' => true, 'lizmap.admin.services.update' => true, 'lizmap.admin.repositories.create' => true, 'lizmap.admin.repositories.delete' => true, 'lizmap.admin.repositories.update' => true, 'lizmap.admin.repositories.view' => true, 'lizmap.admin.services.view' => true));
         // admins
         jAcl2DbManager::addRight('admins', 'lizmap.tools.edition.use', 'intranet');
         jAcl2DbManager::addRight('admins', 'lizmap.repositories.view', 'intranet');
         jAcl2DbManager::addRight('admins', 'lizmap.tools.loginFilteredLayers.override', 'intranet');
         jAcl2DbManager::addRight('admins', 'lizmap.tools.displayGetCapabilitiesLinks', 'intranet');
         jAcl2DbManager::addRight('admins', 'lizmap.tools.edition.use', 'montpellier');
         jAcl2DbManager::addRight('admins', 'lizmap.repositories.view', 'montpellier');
         jAcl2DbManager::addRight('admins', 'lizmap.tools.loginFilteredLayers.override', 'montpellier');
         jAcl2DbManager::addRight('admins', 'lizmap.tools.displayGetCapabilitiesLinks', 'montpellier');
         // lizadmins
         jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.edition.use', 'intranet');
         jAcl2DbManager::addRight('lizadmins', 'lizmap.repositories.view', 'intranet');
         jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.loginFilteredLayers.override', 'intranet');
         jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.displayGetCapabilitiesLinks', 'intranet');
         jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.edition.use', 'montpellier');
         jAcl2DbManager::addRight('lizadmins', 'lizmap.repositories.view', 'montpellier');
         jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.loginFilteredLayers.override', 'montpellier');
         jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.displayGetCapabilitiesLinks', 'montpellier');
         // intranet
         jAcl2DbManager::addRight('intranet', 'lizmap.tools.edition.use', 'intranet');
         jAcl2DbManager::addRight('intranet', 'lizmap.repositories.view', 'intranet');
         jAcl2DbManager::addRight('intranet', 'lizmap.tools.loginFilteredLayers.override', 'intranet');
         jAcl2DbManager::addRight('intranet', 'lizmap.tools.displayGetCapabilitiesLinks', 'intranet');
         jAcl2DbManager::addRight('intranet', 'lizmap.tools.edition.use', 'montpellier');
         jAcl2DbManager::addRight('intranet', 'lizmap.repositories.view', 'montpellier');
         jAcl2DbManager::addRight('intranet', 'lizmap.tools.loginFilteredLayers.override', 'montpellier');
         jAcl2DbManager::addRight('intranet', 'lizmap.tools.displayGetCapabilitiesLinks', 'montpellier');
         // anonymous
         jAcl2DbManager::addRight('__anonymous', 'lizmap.tools.edition.use', 'montpellier');
         jAcl2DbManager::addRight('__anonymous', 'lizmap.repositories.view', 'montpellier');
         jAcl2DbManager::addRight('__anonymous', 'lizmap.tools.loginFilteredLayers.override', 'montpellier');
         jAcl2DbManager::addRight('__anonymous', 'lizmap.tools.displayGetCapabilitiesLinks', 'montpellier');
         // declare the repositories of demo in the configuration
         $ini = new jIniFileModifier($lizmapConfFile);
         $ini->setValues(array('label' => 'LizMap Demo', 'path' => '../install/qgis/', 'allowUserDefinedThemes' => 1), 'repository:montpellier');
         $ini->setValues(array('label' => 'Lizmap Demo - Intranet', 'path' => '../install/qgis_intranet/', 'allowUserDefinedThemes' => ''), 'repository:intranet');
         $ini->setValue('defaultRepository', 'montpellier', 'services');
         $ini->save();
     }
 }
 function removeConfig($module)
 {
     //edit default config
     $defaultConfig = jApp::configPath('mainconfig.ini.php');
     $ini = new jIniFileModifier($defaultConfig);
     $ini->removeValue($module . '.access', 'modules');
     $ini->save();
     $ep = $ini->getValue("defaultEntrypoint", "urlengine");
     //edit installer file
     $installerConfig = jApp::configPath('installer.ini.php');
     $ini = new jIniFileModifier($installerConfig);
     $ini->removeValue($module . '.installed', $ep);
     $ini->removeValue($module . '.version', $ep);
     $ini->save();
     //entry point file
     //only for index
     $epConfig = jApp::configPath($ep . '/config.ini.php');
     $ini = new jIniFileModifier($epConfig);
     $ini->removeValue($module . '.access', 'modules');
     $ini->save();
 }
Beispiel #29
0
 public function run()
 {
     $this->loadAppConfig();
     global $gJConfig;
     $module = $this->getParam('module');
     $initialVersion = $this->getOption('-ver');
     if ($initialVersion === false) {
         $initialVersion = '0.1pre';
     }
     // note: since module name are used for name of generated name,
     // only this characters are allowed
     if ($module == null || preg_match('/([^a-zA-Z_0-9])/', $module)) {
         throw new Exception("'" . $module . "' is not a valid name for a module");
     }
     // check if the module already exist or not
     $path = '';
     try {
         $path = $this->getModulePath($module);
     } catch (Exception $e) {
     }
     if ($path != '') {
         throw new Exception("module '" . $module . "' already exists");
     }
     // verify the given repository
     $repository = $this->getParam('repository', 'app:modules/');
     if (substr($repository, -1) != '/') {
         $repository .= '/';
     }
     $repositoryPath = str_replace(array('lib:', 'app:'), array(LIB_PATH, jApp::appPath()), $repository);
     $iniDefault = new jIniFileModifier(jApp::configPath('defaultconfig.ini.php'));
     $this->updateModulePath($iniDefault, $iniDefault->getValue('modulesPath'), $repository, $repositoryPath);
     if (!$this->allEntryPoint) {
         $list = $this->getEntryPointsList();
         foreach ($list as $k => $entryPoint) {
             if ($entryPoint['file'] == $this->entryPointName) {
                 $ini = new jIniFileModifier(jApp::configPath($entryPoint['config']));
                 break;
             }
         }
         if (!$ini) {
             throw new Exception("entry point is unknown");
         }
         $this->updateModulePath($ini, $gJConfig->modulesPath, $repository, $repositoryPath);
     }
     $path = $repositoryPath . $module . '/';
     $this->createDir($path);
     $gJConfig = null;
     if ($this->getOption('-admin')) {
         $this->removeOption('-nosubdir');
         $this->removeOption('-addinstallzone');
     }
     $param = array();
     $param['module'] = $module;
     $param['default_id'] = $module . $this->config->infoIDSuffix;
     $param['version'] = $initialVersion;
     $this->createFile($path . 'module.xml', 'module/module.xml.tpl', $param);
     // create all sub directories of a module
     if (!$this->getOption('-nosubdir')) {
         $this->createDir($path . 'classes/');
         $this->createDir($path . 'zones/');
         $this->createDir($path . 'controllers/');
         $this->createDir($path . 'templates/');
         $this->createDir($path . 'classes/');
         $this->createDir($path . 'daos/');
         $this->createDir($path . 'forms/');
         $this->createDir($path . 'locales/');
         $this->createDir($path . 'locales/en_EN/');
         $this->createDir($path . 'locales/fr_FR/');
         $this->createDir($path . 'install/');
         $this->createFile($path . 'install/install.php', 'module/install.tpl', $param);
     }
     $isdefault = $this->getOption('-defaultmodule');
     // activate the module in the application
     if ($isdefault) {
         $iniDefault->setValue('startModule', $module);
         $iniDefault->setValue('startAction', 'default:index');
     }
     $iniDefault->setValue($module . '.access', $this->allEntryPoint ? 2 : 1, 'modules');
     $iniDefault->save();
     $list = $this->getEntryPointsList();
     $install = new jIniFileModifier(jApp::configPath('installer.ini.php'));
     // install the module for all needed entry points
     foreach ($list as $k => $entryPoint) {
         $configFile = jApp::configPath($entryPoint['config']);
         $epconfig = new jIniFileModifier($configFile);
         if ($this->allEntryPoint) {
             $access = 2;
         } else {
             $access = $entryPoint['file'] == $this->entryPointName ? 2 : 0;
         }
         $epconfig->setValue($module . '.access', $access, 'modules');
         $epconfig->save();
         if ($this->allEntryPoint || $entryPoint['file'] == $this->entryPointName) {
             $install->setValue($module . '.installed', 1, $entryPoint['id']);
             $install->setValue($module . '.version', $initialVersion, $entryPoint['id']);
         }
         if ($isdefault) {
             // we set the module as default module for one or all entry points.
             // we set the startModule option for all entry points except
             // if an entry point is indicated on the command line
             if ($this->allEntryPoint || $entryPoint['file'] == $this->entryPointName) {
                 if ($epconfig->getValue('startModule') != '') {
                     $epconfig->setValue('startModule', $module);
                     $epconfig->setValue('startAction', 'default:index');
                     $epconfig->save();
                 }
             }
         }
     }
     $install->save();
     // create a default controller
     if (!$this->getOption('-nocontroller')) {
         $agcommand = JelixScript::getCommand('createctrl', $this->config);
         $options = array();
         if ($this->getOption('-cmdline')) {
             $options = array('-cmdline' => true);
         }
         if ($this->getOption('-addinstallzone')) {
             $options = array('-addinstallzone' => true);
         }
         $agcommand->initOptParam($options, array('module' => $module, 'name' => 'default', 'method' => 'index'));
         $agcommand->run();
     }
     if ($this->getOption('-admin')) {
         $this->createFile($path . 'classes/admin' . $module . '.listener.php', 'module/admin.listener.php.tpl', $param);
         $this->createFile($path . 'events.xml', 'module/events.xml.tpl', $param);
         file_put_contents($path . 'locales/en_EN/interface.UTF-8.properties', 'menu.item=' . $module);
         file_put_contents($path . 'locales/fr_FR/interface.UTF-8.properties', 'menu.item=' . $module);
     }
 }
Beispiel #30
0
 function process()
 {
     $ini = new jIniFileModifier(jApp::configPath('profiles.ini.php'));
     $hasErrors = false;
     $_SESSION['dbprofiles']['data'] = $_POST;
     foreach ($_SESSION['dbprofiles']['profiles'] as $profile) {
         $errors = array();
         $params = array();
         $driver = $_POST['driver'][$profile];
         $usepdo = false;
         if (substr($driver, -4) == '_pdo') {
             $ini->setValue('usepdo', true, $profile);
             $usepdo = true;
             $realdriver = substr($driver, 0, -4);
         } else {
             $ini->removeValue('usepdo', $profile);
             $realdriver = $driver;
         }
         $ini->removeValue('dsn', $profile);
         if (isset($_POST['persistent'][$profile]) && $_POST['persistent'][$profile] == 'on') {
             $ini->setValue('persistent', true, $profile);
         } else {
             $ini->removeValue('persistent', $profile);
         }
         if (isset($_POST['force_encoding'][$profile]) && $_POST['force_encoding'][$profile] == 'on') {
             $ini->setValue('force_encoding', true, $profile);
         } else {
             $ini->removeValue('force_encoding', $profile);
         }
         $ini->setValue('table_prefix', $_POST['table_prefix'][$profile], $profile);
         $database = trim($_POST['database'][$profile]);
         if ($database == '') {
             $errors[] = $this->locales['error.missing.database'];
             continue;
         }
         $params['database'] = $database;
         $ini->setValue('database', $database, $profile);
         $params['driver'] = $realdriver;
         $ini->setValue('driver', $realdriver, $profile);
         if ($realdriver != 'sqlite') {
             $host = trim($_POST['host'][$profile]);
             if ($host == '' && $realdriver != 'pgsql') {
                 $errors[] = $this->locales['error.missing.host'];
             } else {
                 $ini->setValue('host', $host, $profile);
                 $params['host'] = $host;
             }
             $port = trim($_POST['port'][$profile]);
             if ($port != '') {
                 $ini->setValue('port', $port, $profile);
                 $params['port'] = $port;
             }
             $user = trim($_POST['user'][$profile]);
             if ($user == '') {
                 $errors[] = $this->locales['error.missing.user'];
             } else {
                 $ini->setValue('user', $user, $profile);
                 $params['user'] = $user;
             }
             $password = trim($_POST['password'][$profile]);
             $passwordRequired = isset($this->config['passwordRequired']) && $this->config['passwordRequired'];
             if ($password == '' && $passwordRequired) {
                 $errors[] = $this->locales['error.missing.password'];
             } else {
                 $ini->setValue('password', $password, $profile);
                 $params['password'] = $password;
             }
             if (trim($_POST['passwordconfirm'][$profile]) != $password) {
                 $errors[] = $this->locales['error.invalid.confirm.password'];
             }
             if ($realdriver == 'pgsql') {
                 $search_path = trim($_POST['search_path'][$profile]);
                 $params['search_path'] = $search_path;
                 if ($search_path != '') {
                     $ini->setValue('search_path', $search_path, $profile);
                 }
             }
         }
         if (!count($errors)) {
             try {
                 if ($usepdo) {
                     $m = 'check_PDO';
                 } else {
                     $m = 'check_' . $realdriver;
                 }
                 $this->{$m}($params);
             } catch (Exception $e) {
                 $errors[] = $e->getMessage();
             }
         }
         if (count($errors)) {
             $hasErrors = true;
         }
         $_SESSION['dbprofiles']['data']['errors'][$profile] = $errors;
     }
     if ($hasErrors) {
         return false;
     }
     $ini->save();
     unset($_SESSION['dbprofiles']);
     return 0;
 }