/** * 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; }
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'); } } } }
/** * 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; }
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(); } } }
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(); } }
/** * @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'); } } }
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(); }
/** * 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; }
/** * 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 ($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'); } }
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'); }
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(); }
function install() { if ($this->getParameter('masteradmin')) { $this->config->setValue('loginResponse', 'htmlauth', 'jcommunity'); } 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); } }
/** * @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'); } }
/** * */ 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; }
public function update($data) { // Get access to the ini file $iniFile = jApp::configPath('lizmapConfig.ini.php'); $ini = new jIniFileModifier($iniFile); // Set section $section = 'repository:' . $this->key; $modified = false; // Modify the ini data for the repository foreach ($data as $k => $v) { if (in_array($k, self::$properties)) { // Set values in ini file $ini->setValue($k, $v, $section); // Modify lizmapConfigData $this->data[$k] = $v; $modified = true; } } // Save the ini file if ($modified) { $ini->save(); } return $modified; }
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(); } } }
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) . " , '*****@*****.**')"); } } } }
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); } }
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(); } }
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(); } }
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; }
/** * says if the ini content has been modified * @return boolean * @since 1.2 */ public function isModified() { return $this->master->isModified() || $this->overrider->isModified(); }
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; }
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(); }
/** * 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; }
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'); }