Esempio n. 1
0
 function install()
 {
     if (!$this->firstDbExec()) {
         return;
     }
     // ---  install table for session storage if needed
     $sessionStorage = $this->config->getValue("storage", "sessions");
     $sessionDao = $this->config->getValue("dao_selector", "sessions");
     $sessionProfile = $this->config->getValue("dao_db_profile", "sessions");
     if ($sessionStorage == "dao" && $sessionDao == "jelix~jsession") {
         $this->execSQLScript('sql/install_jsession.schema');
     }
     // --- install table for jCache if needed
     $cachefile = jApp::configPath('profiles.ini.php');
     if (file_exists($cachefile)) {
         $ini = new jIniFileModifier($cachefile);
         foreach ($ini->getSectionList() as $section) {
             if (substr($section, 0, 7) != 'jcache:') {
                 continue;
             }
             $driver = $ini->getValue('driver', $section);
             $dao = $ini->getValue('dao', $section);
             $this->useDbProfile($ini->getValue('dbprofile', $section));
             if ($driver == 'db' && $dao == 'jelix~jcache' && $this->firstExec('cachedb:' . $this->dbProfile)) {
                 $this->execSQLScript('sql/install_jcache.schema');
             }
         }
     }
 }
 /**
  * return the value of an option from the ini files. If the option doesn't exist,
  * it returns null.
  * @param string $name    the name of the option to retrieve
  * @param string $section the section where the option is. 0 is the global section
  * @param string $key     for option which is an item of array, the key in the array
  * @param boolean $masterOnly if true, get the value from the master file, else
  *                        get the value from the overrider file or from the master file
  *                        if the value doesn't exists in the overrider file (default)
  * @return mixed the value
  */
 public function getValue($name, $section = 0, $key = null, $masterOnly = false)
 {
     if ($masterOnly) {
         return $this->master->getValue($name, $section, $key);
     } else {
         $val = $this->overrider->getValue($name, $section, $key);
         if ($val === null) {
             $val = $this->master->getValue($name, $section, $key);
         }
         return $val;
     }
 }
 /**
  * @param jIniFileModifier $ini
  */
 protected function modifyIni($ini)
 {
     if ($ini->isSection('mailLogger')) {
         // in a previous update (newerrormanager), emailHeaders was
         // moved with the value of email, so we should delete it
         // except if it has been changed since..
         $logEmail = $ini->getValue('email', 'mailLogger');
         $logEmailHeaders = $ini->getValue('emailHeaders', 'mailLogger');
         if ($logEmail == $logEmailHeaders) {
             $ini->removeValue('emailHeaders', 'mailLogger');
         }
     }
 }
Esempio n. 4
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();
         }
     }
 }
 /**
  * @param jIniFileModifier $ini
  */
 protected function modifyIni($ini)
 {
     $ini->removeValue('minifyCheckCacheFiletime', 'jResponseHtml');
     $ini->removeValue('jsUniqueUrlId', 'jResponseHtml');
     $ini->removeValue('cssUniqueUrlId', 'jResponseHtml');
     if ($ini->getValue('minifyCSS', 'jResponseHtml') || $ini->getValue('minifyJS', 'jResponseHtml')) {
         $plugin = $ini->getValue('plugins', 'jResponseHtml');
         if ($plugin == '') {
             $plugin .= "minify";
         } else {
             $plugin .= ",minify";
         }
         $ini->setValue('plugins', $plugin, 'jResponseHtml');
     }
 }
Esempio n. 6
0
 /**
  * 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;
 }
Esempio n. 7
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) . " , '*****@*****.**')");
             }
         }
     }
 }
 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();
         }
     }
 }
Esempio n. 9
0
 /**
  *
  */
 function search()
 {
     $localConfig = jApp::configPath('localconfig.ini.php');
     $ini = new jIniFileModifier($localConfig);
     $jdbParams = array("driver" => $ini->getValue('db_driver', 'localiz_plugin') ?: 'pgsql', "host" => $ini->getValue('db_host', 'localiz_plugin'), "port" => $ini->getValue('db_port', 'localiz_plugin') ?: 5432, "database" => $ini->getValue('db_database', 'localiz_plugin'), "user" => $ini->getValue('db_user', 'localiz_plugin') ?: 'postgres', "password" => $ini->getValue('db_password', 'localiz_plugin'));
     jProfiles::createVirtualProfile('jdb', 'localiz_plugin', $jdbParams);
     $cnx = jDb::getConnection('localiz_plugin');
     $sql = sprintf($ini->getValue('db_query', 'localiz_plugin'), $this->param('term'));
     $res = $cnx->query($sql);
     $rep = $this->getResponse('json');
     $rep->data = array();
     foreach ($res as $record) {
         $rep->data[] = array('oid' => $record->oid, 'typcode' => $record->typcode, 'value' => $record->value, 'label' => $record->label, 'longlabel' => $record->longlabel, 'geometrytype' => $record->geometrytype, 'xmin' => $record->xmin, 'ymin' => $record->ymin, 'xmax' => $record->xmax, 'ymax' => $record->ymax);
     }
     return $rep;
 }
Esempio n. 10
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();
 }
Esempio n. 12
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);
     }
 }
Esempio n. 13
0
 public function run()
 {
     jxs_init_jelix_env();
     // note: since module name are used for name of generated name,
     // only this characters are allowed
     if (preg_match('/([^a-zA-Z_0-9])/', $this->_parameters['module'])) {
         throw new Exception("the name '" . $this->_parameters['module'] . "' is not valid for a module");
     }
     $path = $this->getModulePath($this->_parameters['module'], false);
     if (file_exists($path)) {
         throw new Exception("module '" . $this->_parameters['module'] . "' already exists");
     }
     $this->createDir($path);
     $param = array();
     $param['name'] = $this->_parameters['module'];
     $param['default_id'] = $this->_parameters['module'] . JELIXS_INFO_DEFAULT_IDSUFFIX;
     $this->createFile($path . 'module.xml', 'module.xml.tpl', $param);
     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/');
     }
     if (!$this->getOption('-nocontroller')) {
         $agcommand = jxs_load_command('createctrl');
         $options = array();
         if ($this->getOption('-cmdline')) {
             $options = array('-cmdline' => true);
         }
         if ($this->getOption('-addinstallzone')) {
             $options = array('-addinstallzone' => true);
         }
         $agcommand->init($options, array('module' => $this->_parameters['module'], 'name' => 'default', 'method' => 'index'));
         $agcommand->run();
     }
     $inifiles = array(JELIX_APP_CONFIG_PATH . 'index/config.ini.php', JELIX_APP_CONFIG_PATH . 'cmdline/config.ini.php', JELIX_APP_CONFIG_PATH . 'jsonrpc/config.ini.php', JELIX_APP_CONFIG_PATH . 'xmlrpc/config.ini.php');
     $isdefault = $this->getOption('-defaultmodule');
     foreach ($inifiles as $k => $filename) {
         if (!file_exists($filename)) {
             continue;
         }
         try {
             $ini = new jIniFileModifier($filename);
             if ($isdefault && $k == 0) {
                 $ini->setValue('startModule', $this->_parameters['module']);
                 $ini->setValue('startAction', 'default:index');
             } else {
                 if ($ini->getValue('startModule') == '') {
                     $ini->setValue('startModule', $this->_parameters['module']);
                 }
             }
             $ini->save();
         } catch (Exception $e) {
             echo "Error during the modification of an ini file: " . $e->getMessage() . "\n";
         }
     }
 }
Esempio n. 14
0
 protected function loadconf()
 {
     $ini = new jIniFileModifier(jApp::configPath() . 'defaultconfig.ini.php');
     $config = array('theme' => $ini->getValue('theme'), 'title' => $ini->getValue('title', 'havefnubb'), 'description' => $ini->getValue('description', 'havefnubb'), 'errors' => array());
     return $config;
 }
Esempio n. 15
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');
 }
Esempio n. 16
0
 public function run()
 {
     jxs_init_jelix_env();
     $type = $this->getOption('-type');
     if (!$type) {
         $type = 'classic';
     }
     if (!in_array($type, array('classic', 'jsonrpc', 'xmlrpc', 'rdf', 'soap', 'cmdline'))) {
         throw new Exception("invalid type");
     }
     if ($type == 'classic') {
         $type = 'index';
     }
     $name = $this->getParam('name');
     $inifile = new jIniMultiFilesModifier(JELIX_APP_CONFIG_PATH . 'defaultconfig.ini.php', JELIX_APP_CONFIG_PATH . 'index/config.ini.php');
     $param = array();
     $param['modulename'] = $inifile->getValue('startModule');
     if ($type == 'cmdline') {
         if (file_exists(JELIX_APP_CMD_PATH . $name . '.php')) {
             throw new Exception("the entry point already exists");
         }
         if (!file_exists(JELIX_APP_PATH . 'application-cli.init.php')) {
             $this->createDir(substr(JELIX_APP_TEMP_PATH, -1) . '-cli');
             $param2['rp_temp'] = jxs_getRelativePath(JELIX_APP_PATH, substr(JELIX_APP_TEMP_PATH, 0, -1) . '-cli', true);
             $param2['rp_var'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_VAR_PATH, true);
             $param2['rp_log'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_LOG_PATH, true);
             $param2['rp_conf'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CONFIG_PATH, true);
             $param2['rp_www'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_WWW_PATH, true);
             $param2['rp_cmd'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CMD_PATH, true);
             $param2['rp_jelix'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_LIB_PATH, true);
             $param2['rp_app'] = jxs_getRelativePath(JELIX_APP_WWW_PATH, JELIX_APP_PATH, true);
             $param2['php_rp_temp'] = $this->convertRp($param2['rp_temp']);
             $param2['php_rp_var'] = $this->convertRp($param2['rp_var']);
             $param2['php_rp_log'] = $this->convertRp($param2['rp_log']);
             $param2['php_rp_conf'] = $this->convertRp($param2['rp_conf']);
             $param2['php_rp_www'] = $this->convertRp($param2['rp_www']);
             $param2['php_rp_cmd'] = $this->convertRp($param2['rp_cmd']);
             $this->createFile(JELIX_APP_PATH . 'application-cli.init.php', 'application.init.php.tpl', $param2);
         }
         $this->createDir(JELIX_APP_CONFIG_PATH . 'cmdline');
         $this->createDir(JELIX_APP_CMD_PATH);
         $this->createFile(JELIX_APP_CONFIG_PATH . 'cmdline/' . $name . '.ini.php', 'var/config/cmdline/config.ini.php.tpl', $param);
         $param['rp_cmd'] = jxs_getRelativePath(JELIX_APP_CMD_PATH, JELIX_APP_PATH, true);
         $param['config_file'] = 'cmdline/' . $name . '.ini.php';
         $this->createFile(JELIX_APP_CMD_PATH . $name . '.php', 'scripts/cmdline.php.tpl', $param);
         return;
     }
     if (file_exists(JELIX_APP_WWW_PATH . $name . '.php')) {
         throw new Exception("the entry point already exists");
     }
     $param['rp_app'] = jxs_getRelativePath(JELIX_APP_WWW_PATH, JELIX_APP_PATH, true);
     $param['config_file'] = $name . '/config.ini.php';
     $this->createDir(JELIX_APP_CONFIG_PATH . $name);
     $this->createFile(JELIX_APP_CONFIG_PATH . $name . '/config.ini.php', 'var/config/index/config.ini.php.tpl', $param);
     $this->createFile(JELIX_APP_WWW_PATH . $name . '.php', 'www/' . $type . '.php.tpl', $param);
     $inifile = new jIniFileModifier(JELIX_APP_CONFIG_PATH . 'defaultconfig.ini.php');
     if (null === $inifile->getValue($name, 'simple_urlengine_entrypoints')) {
         $inifile->setValue($name, '', 'simple_urlengine_entrypoints');
     }
     if (null === $inifile->getValue($name, 'basic_significant_urlengine_entrypoints')) {
         $inifile->setValue($name, '1', 'basic_significant_urlengine_entrypoints');
     }
     $doc = new DOMDocument();
     if (!$doc->load(JELIX_APP_PATH . 'project.xml')) {
         throw new Exception("cannot load project.xml");
     }
     if ($doc->documentElement->namespaceURI != JELIX_NAMESPACE_BASE . 'project/1.0') {
         throw new Exception("bad namespace in project.xml");
     }
     $elem = $doc->createElementNS(JELIX_NAMESPACE_BASE . 'project/1.0', 'entry');
     $elem->setAttribute("file", $name . ".php");
     $elem->setAttribute("config", $name . "/config.ini.php");
     $ep = $doc->documentElement->getElementsByTagName("entrypoints");
     if (!$ep->length) {
         $ep = $doc->createElementNS(JELIX_NAMESPACE_BASE . 'project/1.0', 'entrypoints');
         $doc->documentElement->appendChild($ep);
         $ep->appendChild($elem);
     } else {
         $ep->item(0)->appendChild($elem);
     }
     $doc->save(JELIX_APP_PATH . 'project.xml');
 }
 /**
  * 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;
 }
Esempio n. 18
0
 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();
 }
Esempio n. 19
0
 protected function loadProfiles()
 {
     $file = jApp::configPath('profiles.ini.php');
     if (file_exists($file)) {
     } elseif (file_exists(jApp::configPath('profiles.ini.php.dist'))) {
         copy(jApp::configPath('profiles.ini.php.dist'), $file);
     } else {
         file_put_contents($file, ";<?php die(''); ?>\n;for security reasons, don't remove or modify the first line\n\n[jdb:default]\ndriver=mysql\ndatabase=\nhost=localhost\nuser=\npassword=\npersistent = on\nforce_encoding = on\ntable_prefix=\n");
     }
     $ini = new jIniFileModifier($file);
     $data = array('driver' => array(), 'database' => array(), 'host' => array(), 'port' => array(), 'user' => array(), 'password' => array(), 'passwordconfirm' => array(), 'persistent' => array(), 'table_prefix' => array(), 'force_encoding' => array(), 'search_path' => array());
     $profiles = $ini->getSectionList();
     $dbprofileslist = array();
     foreach ($profiles as $profile) {
         if (strpos($profile, 'jdb:') !== 0) {
             continue;
         }
         $dbprofileslist[] = $profile;
         $driver = $ini->getValue('driver', $profile);
         if ($driver == 'pdo') {
             $dsn = $ini->getValue('dsn', $profile);
             $data['driver'][$profile] = substr($dsn, 0, strpos($dsn, ':')) . '_pdo';
             if (preg_match("/host=([^;]*)(;|\$)/", $dsn, $m)) {
                 $data['host'][$profile] = $m[1];
             } else {
                 $host = $ini->getValue('host', $profile);
                 $data['host'][$profile] = $host === null ? '' : $host;
             }
             if (preg_match("/dbname=([^;]*)(;|\$)/", $dsn, $m)) {
                 $data['database'][$profile] = $m[1];
             } else {
                 $host = $ini->getValue('database', $profile);
                 $data['database'][$profile] = $host === null ? '' : $host;
             }
             if (preg_match("/port=([^;]*)(;|\$)/", $dsn, $m)) {
                 $data['port'][$profile] = $m[1];
             } else {
                 $port = $ini->getValue('port', $profile);
                 $data['port'][$profile] = $port === null ? '' : $port;
             }
         } else {
             $usepdo = (bool) $ini->getValue('usepdo', $profile);
             $data['driver'][$profile] = $ini->getValue('driver', $profile) . ($usepdo ? '_pdo' : '');
             $data['database'][$profile] = $ini->getValue('database', $profile);
             $data['host'][$profile] = $ini->getValue('host', $profile);
             $data['port'][$profile] = $ini->getValue('port', $profile);
         }
         $data['user'][$profile] = $ini->getValue('user', $profile);
         $data['password'][$profile] = $ini->getValue('password', $profile);
         $data['passwordconfirm'][$profile] = $data['password'][$profile];
         $data['persistent'][$profile] = $ini->getValue('persistent', $profile);
         $force_encoding = $ini->getValue('force_encoding', $profile);
         if ($force_encoding === null) {
             $force_encoding = true;
         }
         $data['force_encoding'][$profile] = $force_encoding;
         $data['table_prefix'][$profile] = $ini->getValue('table_prefix', $profile);
         $data['search_path'][$profile] = $ini->getValue('search_path', $profile);
         $data['errors'][$profile] = array();
     }
     $_SESSION['dbprofiles']['profiles'] = $dbprofileslist;
     $_SESSION['dbprofiles']['data'] = $data;
 }
 /**
  * @param jIniFileModifier $ini
  */
 protected function addValue($ini, $name, $section, $val)
 {
     $oldval = $ini->getValue($name, $section);
     if (!is_null($oldval)) {
         $list = preg_split('/ *, */', $oldval);
         if (!in_array($val, $list)) {
             $val = $oldval . ',' . $val;
         }
     }
     $ini->setValue($name, $val, $section);
 }
Esempio n. 21
0
    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';
Esempio n. 22
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'));
     $createdConfFile = false;
     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);
             $createdConfFile = true;
         }
     }
     $conf = new jIniFileModifier(jApp::configPath($authconfig));
     $usedStandardDao = $conf->getValue('dao', 'Db') == 'jauthdb~jelixuser';
     $this->useDbProfile($conf->getValue('profile', 'Db'));
     if ($createdConfFile) {
         mt_srand();
         $conf->setValue('persistant_crypt_key', sha1("jelix" . time() . mt_rand()));
         $conf->save();
     }
     if ($this->firstExec($authconfig) && $this->getParameter('rewriteconfig')) {
         $conf->setValue('driver', 'Db');
         $conf->setValue('dao', 'jcommunity~user', 'Db');
         $conf->setValue('form', 'jcommunity~account_admin', '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_logout', 'jcommunity~login:index');
         $conf->setValue('enable_after_login_override', 'on');
         $conf->setValue('enable_after_logout_override', 'on');
         $conf->setValue('after_login', 'jcommunity~account:show');
         $conf->save();
     }
     if ($this->getParameter('masteradmin')) {
         $conf->setValue('after_login', 'master_admin~default:index');
         $conf->save();
         $this->config->setValue('loginResponse', 'htmlauth', 'jcommunity');
     }
     if ($this->firstDbExec() && !$this->getParameter('notjcommunitytable')) {
         $conf->setValue('dao', 'jcommunity~user', 'Db');
         $conf->setValue('form', 'jcommunity~account_admin', 'Db');
         $conf->save();
         $this->execSQLScript('sql/install');
         $cn = $this->dbConnection();
         if ($usedStandardDao && $this->getParameter('migratejauthdbusers')) {
             $cn->exec("INSERT INTO " . $cn->prefixTable('community_users') . "\n                            (login, password, email, nickname, status, create_date)\n                         SELECT usr_login, usr_password, usr_email, usr_login, 1, '" . date('Y-m-d H:i:s') . "'\n                         FROM " . $cn->prefixTable('jlx_user'));
         } else {
             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->exec("INSERT INTO " . $cn->prefixTable('community_users') . " (login, password, email, nickname, status, create_date) VALUES\n                            ('admin', " . $cn->quote($passwordHash) . ", '*****@*****.**', 'admin', 1, '" . date('Y-m-d H:i:s') . "')");
             }
         }
     }
     if ($this->firstExec('acl2') && class_exists('jAcl2DbManager')) {
         jAcl2DbManager::addSubjectGroup('jcommunity.admin', 'jcommunity~prefs.admin.jcommunity');
         jAcl2DbManager::addSubject('jcommunity.prefs.change', 'jcommunity~prefs.admin.prefs.change', 'jprefs.prefs.management');
         jAcl2DbManager::addRight('admins', 'jcommunity.prefs.change');
         // for admin group
     }
     if ($this->firstExec('preferences')) {
         $prefIni = new jIniFileModifier(__DIR__ . '/prefs.ini');
         $prefFile = jApp::configPath('preferences.ini.php');
         if (file_exists($prefFile)) {
             $mainPref = new jIniFileModifier($prefFile);
             //import this way to not erase changed value.
             $prefIni->import($mainPref);
         }
         $prefIni->saveAs($prefFile);
     }
 }
Esempio n. 23
0
 protected function loadconf()
 {
     $ini = new jIniFileModifier(jApp::configPath('defaultconfig.ini.php'));
     $emailConfig = array('webmasterEmail' => $ini->getValue('webmasterEmail', 'mailer'), 'webmasterName' => $ini->getValue('webmasterName', 'mailer'), 'mailerType' => $ini->getValue('mailerType', 'mailer'), 'hostname' => $ini->getValue('hostname', 'mailer'), 'sendmailPath' => $ini->getValue('sendmailPath', 'mailer'), 'smtpHost' => $ini->getValue('smtpHost', 'mailer'), 'smtpPort' => $ini->getValue('smtpPort', 'mailer'), 'smtpSecure' => $ini->getValue('smtpSecure', 'mailer'), 'smtpHelo' => $ini->getValue('smtpHelo', 'mailer'), 'smtpAuth' => $ini->getValue('smtpAuth', 'mailer'), 'smtpUsername' => $ini->getValue('smtpUsername', 'mailer'), 'smtpPassword' => $ini->getValue('smtpPassword', 'mailer'), 'smtpTimeout' => $ini->getValue('smtpTimeout', 'mailer'), 'errors' => array());
     if (!in_array($emailConfig['mailerType'], array('mail', 'sendmail', 'smtp'))) {
         $emailConfig['mailerType'] = 'mail';
     }
     return $emailConfig;
 }
Esempio n. 24
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);
         }
     }
 }