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