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 \Jelix\IniFile\IniModifier(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->getConfigIni()->getValue('auth', 'coordplugins'); if ($authconfig && $this->entryPoint->type != 'cmdline' && $this->firstExec($authconfig)) { $conf = new \Jelix\IniFile\IniModifier(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(); } } }
/** * 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 \Jelix\IniFile\IniModifier(App::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(); \Jelix\Core\Profiles::clear(); return true; }
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->appInfos = 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 \Jelix\IniFile\IniModifier(App::configPath('installer.ini.php')); $inifile = new \Jelix\IniFile\MultiIniModifier(App::mainConfigFile(), App::configPath($ep['config'])); $params = array(); $this->createFile(App::appPath('responses/adminHtmlResponse.class.php'), 'responses/adminHtmlResponse.class.php.tpl', $params, "Response for admin interface"); $this->createFile(App::appPath('responses/adminLoginHtmlResponse.class.php'), 'responses/adminLoginHtmlResponse.class.php.tpl', $params, "Response for login page"); $inifile->setValue('html', 'adminHtmlResponse', 'responses'); $inifile->setValue('htmlauth', 'adminLoginHtmlResponse', 'responses'); $inifile->setValue('startModule', 'master_admin'); $inifile->setValue('startAction', 'default:index'); $repositoryPath = jFile::parseJelixPath('lib:jelix-admin-modules'); $this->registerModulesDir('lib:jelix-admin-modules', $repositoryPath); $installConfig->setValue('jacl.installed', '0', $entrypoint); $inifile->setValue('jacl.access', '0', 'modules'); $installConfig->setValue('jacldb.installed', '0', $entrypoint); $inifile->setValue('jacldb.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, jpref_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, jpref_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'; } if (strpos($urlconf2, 'jpref_admin~*@classic') === false) { $urlconf2 .= ',jpref_admin~*@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(); $verbose = $this->verbose(); $reporter = new \Jelix\Installer\Reporter\Console($verbose ? 'notice' : 'warning'); $installer = new \Jelix\Installer\Installer($reporter); $installer->installModules(array('master_admin'), $entrypoint . '.php'); $authini = new \Jelix\IniFile\IniModifier(App::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 \Jelix\IniFile\IniModifier(App::configPath('profiles.ini.php')); $dbini->setValue('jacl2_profile', $profile, 'jdb'); $dbini->save(); } $installer = new \Jelix\Installer\Installer($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(); } $installer->installModules(array('jpref_admin'), $entrypoint . '.php'); }
protected function _execute(InputInterface $input, OutputInterface $output) { $module = $input->getArgument('module'); $initialVersion = $input->getOption('ver'); if (!$initialVersion) { $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 = $input->getArgument('repository'); if (substr($repository, -1) != '/') { $repository .= '/'; } $repositoryPath = \jFile::parseJelixPath($repository); if (!$input->getOption('noregistration')) { $this->registerModulesDir($repository, $repositoryPath); } $path = $repositoryPath . $module . '/'; $this->createDir($path); App::setConfig(null); $noSubDir = $input->getOption('nosubdir'); $addInstallZone = $input->getOption('addinstallzone'); $isdefault = $input->getOption('defaultmodule'); if ($input->getOption('admin')) { $noSubDir = false; $addInstallZone = false; } $param = array(); $param['module'] = $module; $param['version'] = $initialVersion; $this->createFile($path . 'jelix-module.json', 'module/jelix-module.json.tpl', $param); // create all sub directories of a module if (!$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_US/'); $this->createDir($path . 'locales/fr_FR/'); $this->createDir($path . 'install/'); if ($this->verbose()) { $output->writeln("Sub directories have been created in the new module {$module}."); } $this->createFile($path . 'install/install.php', 'module/install.tpl', $param); $this->createFile($path . 'urls.xml', 'module/urls.xml.tpl', array()); } $iniDefault = new \Jelix\IniFile\IniModifier(App::mainConfigFile()); $urlsFile = App::appConfigPath($iniDefault->getValue('significantFile', 'urlengine')); $xmlMap = new \Jelix\Routing\UrlMapping\XmlMapModifier($urlsFile, true); // activate the module in the application if ($isdefault) { if ($this->allEntryPoint) { $xmlEp = $xmlMap->getDefaultEntryPoint($type); } else { $xmlEp = $xmlMap->getEntryPoint($this->entryPointId); } if ($xmlEp) { $xmlEp->addUrlAction('/', $module, 'default:index', null, null, array('default' => true)); $xmlEp->addUrlModule('', $module); if ($this->verbose()) { $output->writeln("The new module {$module} becomes the default module"); } } else { if ($this->verbose()) { $output->writeln("No default entry point found: the new module cannot be the default module"); } } } $xmlMap->save(); $iniDefault->setValue($module . '.access', $this->allEntryPoint ? 2 : 1, 'modules'); $iniDefault->save(); $list = $this->getEntryPointsList(); $install = new \Jelix\IniFile\IniModifier(App::configPath('installer.ini.php')); // install the module for all needed entry points foreach ($list as $entryPoint) { $configFile = App::appConfigPath($entryPoint['config']); $epconfig = new \Jelix\IniFile\IniModifier($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 ($this->verbose()) { $output->writeln("The module is initialized for the entry point " . $entryPoint['file']); } } $install->save(); App::declareModule($path); // create a default controller if (!$input->getOption('nocontroller')) { $arguments = array('module' => $module, 'controller' => 'default', 'method' => 'index'); if ($input->getOption('entry-point')) { $arguments['--entry-point'] = $input->getOption('entry-point'); } if ($input->getOption('cmdline')) { $arguments['--cmdline'] = true; } if ($addInstallZone) { $arguments['--addinstallzone'] = true; } if ($output->isVerbose()) { $arguments['-v'] = true; } $this->executeSubCommand('module:create-ctrl', $arguments, $output); } if ($input->getOption('admin')) { $this->createFile($path . 'classes/admin' . $module . '.listener.php', 'module/admin.listener.php.tpl', $param, "Listener"); $this->createFile($path . 'events.xml', 'module/events.xml.tpl', $param); file_put_contents($path . 'locales/en_US/interface.UTF-8.properties', 'menu.item=' . $module); file_put_contents($path . 'locales/fr_FR/interface.UTF-8.properties', 'menu.item=' . $module); } }
function process() { $ini = new \Jelix\IniFile\IniModifier(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 ($_POST['dbtype'][$profile] != '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 ($_POST['dbtype'][$profile] == '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)) { $options = $ini->getValues($profile); $dbparam = new jDbParameters($options); $options = $dbparam->getParameters(); try { if ($usepdo) { $m = 'check_PDO'; } else { $m = 'check_' . $options['driver']; } $this->{$m}($options); } 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; }
/** * action to process the page after the submit */ function process() { $ini = new \Jelix\IniFile\IniModifier(jApp::mainConfigFile()); $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; }
public function store() { $input = Input::all(); $rules = ['c' => 'required', 'cn' => 'required', 'cns' => 'required', 'root_password' => 'required']; $v = Validator::make($input, $rules); if ($v->fails()) { return Redirect::route('certs-path')->withInput(Input::except('root_password'))->with('error', 'Please provide at least the country, a common name and the password of your Root CA.'); } if (!in_array('*' . $input['cns'], Auth::user()->domains)) { return Redirect::route('certs-path')->withInput(Input::except('root_password'))->with('error', 'You are not allowed to create a certificate for this domain.'); } $sluggedDomain = Str::slug(str_replace('.', '_', $input['cn'] . $input['cns'])); if (!File::exists($this->certDir . $sluggedDomain . '.crt')) { // Get field $c = Input::get('c'); $st = Input::get('st'); $l = Input::get('l'); $o = Input::get('o'); $ou = Input::get('ou'); $cn = $input['cn'] . $input['cns']; $san = Input::get('san'); $email = Input::get('email'); $root_pw = Input::get('root_password'); $extension = 'v3_emp'; // Prepare subject $subj = "'/C={$c}"; $subj .= !empty($st) ? "/ST={$st}" : ''; $subj .= !empty($l) ? "/L={$l}" : ''; $subj .= !empty($o) ? "/O={$o}" : ''; $subj .= !empty($ou) ? "/OU={$ou}" : ''; $subj .= "/CN={$cn}"; $subj .= !empty($email) ? "/Email={$email}" : ''; $subj .= "'"; // copy config openssl $tmpcnf = tempnam(sys_get_temp_dir(), 'ssl'); file_put_contents($tmpcnf, file_get_contents($this->cnfPath)); $ini = new \Jelix\IniFile\IniModifier($tmpcnf); // Add alternate name if (!empty($san)) { $altNames = array_filter(explode(',', str_replace(array(',', ' ', ';'), ',', $san . ','))); foreach ($altNames as $index => $altName) { $ini->setValue('DNS.' . ($index + 1), $altName, 'alt_names'); } $extension = 'v3_req'; } $ini->save(); // Create private key and CSR $process = new Process("cd {$this->certDir} && openssl req -nodes -new -newkey rsa:2048 -sha256 " . "-reqexts {$extension} -extensions {$extension} -config {$tmpcnf} -keyout {$sluggedDomain}.key " . "-out {$sluggedDomain}.csr -days 365 -subj {$subj}"); $process->run(); if (!$process->isSuccessful()) { File::delete($this->certDir . $sluggedDomain . '.csr'); // cleanup File::delete($this->certDir . $sluggedDomain . '.pem'); File::delete($this->certDir . $sluggedDomain . '.key'); File::delete($tmpcnf); return Redirect::route('certs-path')->withInput(Input::except('root_password'))->with('error', 'Could not create private key or CSR. ' . $process->getErrorOutput()); } // Sign cert, convert into DES and remove CSR $process = new Process("cd {$this->certDir} && openssl x509 -passin pass:{$root_pw} -CA rootCA.pem " . "-CAkey rootCA.key -CAcreateserial -days 365 -sha256 -req -extensions {$extension} " . "-extfile {$tmpcnf} -in {$sluggedDomain}.csr -out {$sluggedDomain}.pem && openssl x509 " . "-extensions {$extension} -extfile {$tmpcnf} -in {$sluggedDomain}.pem -out {$sluggedDomain}.crt"); $process->run(); if (!$process->isSuccessful()) { File::delete($this->certDir . $sluggedDomain . '.csr'); // cleanup File::delete($this->certDir . $sluggedDomain . '.pem'); File::delete($this->certDir . $sluggedDomain . '.key'); File::delete($tmpcnf); return Redirect::route('certs-path')->withInput(Input::except('root_password'))->with('error', 'Could not sign certificate. Is the provided Root CA password correct? ' . nl2br($process->getErrorOutput())); } File::delete($this->certDir . $sluggedDomain . '.csr'); File::delete($tmpcnf); // Create database entry Cert::create(['user_id' => Auth::user()->id, 'domain' => $cn, 'csr' => 0]); return Redirect::route('certs-path')->with('success', 'Certificate has been created.'); } else { return Redirect::route('certs-path')->withInput(Input::except('root_password'))->with('warning', 'Certificate already exists.'); } }
public function run() { $this->loadAppConfig(); $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 = jFile::parseJelixPath($repository); if (!$this->getOption('-noregistration')) { $this->registerModulesDir($repository, $repositoryPath); } $path = $repositoryPath . $module . '/'; $this->createDir($path); App::setConfig(null); if ($this->getOption('-admin')) { $this->removeOption('-nosubdir'); $this->removeOption('-addinstallzone'); } $param = array(); $param['module'] = $module; $param['version'] = $initialVersion; $this->createFile($path . 'jelix-module.json', 'module/jelix-module.json.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_US/'); $this->createDir($path . 'locales/fr_FR/'); $this->createDir($path . 'install/'); if ($this->verbose()) { echo "Sub directories have been created in the new module {$module}.\n"; } $this->createFile($path . 'install/install.php', 'module/install.tpl', $param); $this->createFile($path . 'urls.xml', 'module/urls.xml.tpl', array()); } $isdefault = $this->getOption('-defaultmodule'); $iniDefault = new \Jelix\IniFile\IniModifier(App::mainConfigFile()); // activate the module in the application if ($isdefault) { $iniDefault->setValue('startModule', $module); $iniDefault->setValue('startAction', 'default:index'); if ($this->verbose()) { echo "The new module {$module} becomes the default module\n"; } } $iniDefault->setValue($module . '.access', $this->allEntryPoint ? 2 : 1, 'modules'); $iniDefault->save(); $list = $this->getEntryPointsList(); $install = new \Jelix\IniFile\IniModifier(App::configPath('installer.ini.php')); // install the module for all needed entry points foreach ($list as $entryPoint) { $configFile = App::configPath($entryPoint['config']); $epconfig = new \Jelix\IniFile\IniModifier($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(); } } } if ($this->verbose()) { echo "The module is initialized for the entry point " . $entryPoint['file'] . ".\n"; } } $install->save(); // create a default controller if (!$this->getOption('-nocontroller')) { $agcommand = JelixScript::getCommand('createctrl', $this->config); $options = $this->getCommonActiveOption(); if ($this->getOption('-cmdline')) { $options['-cmdline'] = true; } if ($this->getOption('-addinstallzone')) { $options['-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, "Listener"); $this->createFile($path . 'events.xml', 'module/events.xml.tpl', $param); file_put_contents($path . 'locales/en_US/interface.UTF-8.properties', 'menu.item=' . $module); file_put_contents($path . 'locales/fr_FR/interface.UTF-8.properties', 'menu.item=' . $module); } }
protected function _execute(InputInterface $input, OutputInterface $output) { $entrypoint = $input->getArgument('entrypoint'); if (($p = strpos($entrypoint, '.php')) !== false) { $entrypoint = substr($entrypoint, 0, $p); } $ep = $this->getEntryPointInfo($entrypoint); if ($ep == null) { try { $options = array('entrypoint' => $entrypoint); $this->executeSubCommand('app:createentrypoint', $options, $output); $this->appInfos = 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 \Jelix\IniFile\IniModifier(App::configPath('installer.ini.php')); $inifile = new \Jelix\IniFile\MultiIniModifier(App::mainConfigFile(), App::appConfigPath($ep['config'])); $params = array(); $this->createFile(App::appPath('app/responses/adminHtmlResponse.class.php'), 'app/responses/adminHtmlResponse.class.php.tpl', $params, "Response for admin interface"); $this->createFile(App::appPath('app/responses/adminLoginHtmlResponse.class.php'), 'app/responses/adminLoginHtmlResponse.class.php.tpl', $params, "Response for login page"); $inifile->setValue('html', 'adminHtmlResponse', 'responses'); $inifile->setValue('htmlauth', 'adminLoginHtmlResponse', 'responses'); $repositoryPath = \jFile::parseJelixPath('lib:jelix-admin-modules'); $this->registerModulesDir('lib:jelix-admin-modules', $repositoryPath); $installConfig->setValue('jacl.installed', '0', $entrypoint); $inifile->setValue('jacl.access', '0', 'modules'); $installConfig->setValue('jacldb.installed', '0', $entrypoint); $inifile->setValue('jacldb.access', '0', 'modules'); $inifile->save(); $urlsFile = jApp::appConfigPath($inifile->getValue('significantFile', 'urlengine')); $xmlMap = new \Jelix\Routing\UrlMapping\XmlMapModifier($urlsFile, true); $xmlEp = $xmlMap->getEntryPoint($entrypoint); $xmlEp->addUrlAction('/', 'master_admin', 'default:index', null, null, array('default' => true)); $xmlEp->addUrlModule('', 'master_admin'); $xmlEp->addUrlInclude('/admin/acl', 'jacl2db_admin', 'urls.xml'); $xmlEp->addUrlInclude('/admin/auth', 'jauthdb_admin', 'urls.xml'); $xmlEp->addUrlInclude('/admin/pref', 'jpref_admin', 'urls.xml'); $xmlEp->addUrlInclude('/auth', 'jauth', 'urls.xml'); $xmlMap->save(); $reporter = new \Jelix\Installer\Reporter\Console($output->isVerbose() ? 'notice' : 'warning'); $installer = new \Jelix\Installer\Installer($reporter); $installer->installModules(array('jauth', 'master_admin'), $entrypoint . '.php'); $authini = new \Jelix\IniFile\IniModifier(App::configPath($entrypoint . '/auth.coord.ini.php')); $authini->setValue('after_login', 'master_admin~default:index'); $authini->setValue('timeout', '30'); $authini->save(); $profile = $input->getOption('profile'); if (!$input->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 (!$input->getOption('noacl2db')) { if ($profile != '') { $dbini = new \Jelix\IniFile\IniModifier(App::configPath('profiles.ini.php')); $dbini->setValue('jacl2_profile', $profile, 'jdb'); $dbini->save(); } $installer = new \Jelix\Installer\Installer($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(); } $installer->installModules(array('jpref_admin'), $entrypoint . '.php'); }