default_user; Minz_Configuration::register('user', join_path(USERS_PATH, $current_user, 'config.php'), join_path(FRESHRSS_PATH, 'config-user.default.php')); $user_conf = Minz_Configuration::get('user'); // Then, we set $_SESSION vars Minz_Session::_params([ 'title' => $system_conf->title, 'auth_type' => $system_conf->auth_type, 'default_user' => $current_user, 'passwordHash' => $user_conf->passwordHash, 'bd_type' => $system_conf->db['type'], 'bd_host' => $system_conf->db['host'], 'bd_user' => $system_conf->db['user'], 'bd_password' => $system_conf->db['password'], 'bd_base' => $system_conf->db['base'], 'bd_prefix' => $system_conf->db['prefix'], 'bd_error' => false, ]); header('Location: index.php?step=4'); } } function saveStep2() { if (!empty($_POST)) { if (Minz_Session::param('bd_type') === 'sqlite') { Minz_Session::_params([ 'bd_base' => false, 'bd_host' => false, 'bd_user' => false, 'bd_password' => false, 'bd_prefix' => false, ]); } else { if (empty($_POST['type']) || empty($_POST['host']) || empty($_POST['user']) || empty($_POST['base'])) { Minz_Session::_param('bd_error', 'Missing parameters!'); } Minz_Session::_params([ 'bd_base' => substr($_POST['base'], 0, 64), 'bd_host' => $_POST['host'], 'bd_user' => $_POST['user'], 'bd_password' => $_POST['pass'], 'bd_prefix' => substr($_POST['prefix'], 0, 16), ]); } if (Minz_Session::param('bd_type') === 'pgsql') { Minz_Session::_param('bd_base', strtolower(Minz_Session::param('bd_base'))); } // We use dirname to remove the /i part $base_url = dirname(Minz_Request::guessBaseUrl()); $config_array = [ 'salt' => generateSalt(), 'base_url' => $base_url, 'default_user' => '_', 'db' => [ 'type' => Minz_Session::param('bd_type'), 'host' => Minz_Session::param('bd_host'), 'user' => Minz_Session::param('bd_user'), 'password' => Minz_Session::param('bd_password'), 'base' => Minz_Session::param('bd_base'), 'prefix' => Minz_Session::param('bd_prefix'), 'pdo_options' => [], ], 'pubsubhubbub_enabled' => Minz_Request::serverIsPublic($base_url), ]; if (Minz_Session::param('title') != '') { $config_array['title'] = Minz_Session::param('title'); } if (Minz_Session::param('auth_type') != '') { $config_array['auth_type'] = Minz_Session::param('auth_type'); } @unlink(DATA_PATH . '/config.php'); //To avoid access-rights problems file_put_contents(DATA_PATH . '/config.php', "getMessage()); $ok = false; } if (!$ok) { @unlink(join_path(DATA_PATH, 'config.php')); } if ($ok) { Minz_Session::_param('bd_error'); header('Location: index.php?step=3'); } elseif (Minz_Session::param('bd_error') == '') { Minz_Session::_param('bd_error', 'Unknown error!'); } } invalidateHttpCache(); } function saveStep3() { $user_default_config = Minz_Configuration::get('default_user'); if (!empty($_POST)) { $system_default_config = Minz_Configuration::get('default_system'); Minz_Session::_params([ 'title' => $system_default_config->title, 'auth_type' => param('auth_type', 'form'), ]); if (FreshRSS_user_Controller::checkUsername(param('default_user', ''))) { Minz_Session::_param('default_user', param('default_user', '')); } if (Minz_Session::param('auth_type') == '' || Minz_Session::param('default_user') == '') { return false; } $password_plain = param('passwordPlain', false); if (Minz_Session::param('auth_type') === 'form' && $password_plain == '') { return false; } Minz_Configuration::register('system', DATA_PATH . '/config.php', FRESHRSS_PATH . '/config.default.php'); FreshRSS_Context::$system_conf = Minz_Configuration::get('system'); Minz_Translate::init(Minz_Session::param('language')); FreshRSS_Context::$system_conf->default_user = Minz_Session::param('default_user'); FreshRSS_Context::$system_conf->save(); // Create default user files but first, we delete previous data to // avoid access right problems. recursive_unlink(USERS_PATH . '/' . Minz_Session::param('default_user')); $ok = false; try { $ok = FreshRSS_user_Controller::createUser( Minz_Session::param('default_user'), '', //TODO: Add e-mail $password_plain, [ 'language' => Minz_Session::param('language'), 'is_admin' => true, 'enabled' => true, ] ); } catch (Exception $e) { Minz_Session::_param('bd_error', $e->getMessage()); $ok = false; } if (!$ok) { return false; } header('Location: index.php?step=4'); } } /*** VÉRIFICATIONS ***/ function checkStep() { $s0 = checkStep0(); $s1 = checkRequirements(); $s2 = checkStep2(); $s3 = checkStep3(); if (STEP > 0 && $s0['all'] != 'ok') { header('Location: index.php?step=0'); } elseif (STEP > 1 && $s1['all'] != 'ok') { header('Location: index.php?step=1'); } elseif (STEP > 2 && $s2['all'] != 'ok') { header('Location: index.php?step=2'); } elseif (STEP > 3 && $s3['all'] != 'ok') { header('Location: index.php?step=3'); } Minz_Session::_param('actualize_feeds', true); } function checkStep0() { $languages = Minz_Translate::availableLanguages(); $language = Minz_Session::param('language') != '' && in_array(Minz_Session::param('language'), $languages); return array( 'language' => $language ? 'ok' : 'ko', 'all' => $language ? 'ok' : 'ko' ); } function freshrss_already_installed() { $conf_path = join_path(DATA_PATH, 'config.php'); if (!file_exists($conf_path)) { return false; } // A configuration file already exists, we try to load it. $system_conf = null; try { Minz_Configuration::register('system', $conf_path); $system_conf = Minz_Configuration::get('system'); } catch (Minz_FileNotExistException $e) { return false; } // ok, the global conf exists... but what about default user conf? $current_user = $system_conf->default_user; try { Minz_Configuration::register('user', join_path(USERS_PATH, $current_user, 'config.php')); } catch (Minz_FileNotExistException $e) { return false; } // ok, ok, default user exists too! return true; } function checkStep2() { $conf = is_writable(join_path(DATA_PATH, 'config.php')); $bd = Minz_Session::param('bd_type') != ''; $conn = Minz_Session::param('bd_error') == ''; return [ 'bd' => $bd ? 'ok' : 'ko', 'conn' => $conn ? 'ok' : 'ko', 'conf' => $conf ? 'ok' : 'ko', 'all' => $bd && $conn && $conf ? 'ok' : 'ko', ]; } function checkStep3() { $conf = Minz_Session::param('default_user') != ''; $form = Minz_Session::param('auth_type') != ''; $defaultUser = empty($_POST['default_user']) ? null : $_POST['default_user']; if ($defaultUser === null) { $defaultUser = Minz_Session::param('default_user') == '' ? '' : Minz_Session::param('default_user'); } $data = is_writable(join_path(USERS_PATH, $defaultUser, 'config.php')); return [ 'conf' => $conf ? 'ok' : 'ko', 'form' => $form ? 'ok' : 'ko', 'data' => $data ? 'ok' : 'ko', 'all' => $conf && $form && $data ? 'ok' : 'ko', ]; } /*** AFFICHAGE ***/ function printStep0() { $actual = Minz_Translate::language(); $languages = Minz_Translate::availableLanguages(); ?>

tabindex="5" />

> <?= _t('install.title') ?>