default_user, false); // Then, we set $_SESSION vars Minz_Session::_params([ 'title' => FreshRSS_Context::systemConf()->title, 'auth_type' => FreshRSS_Context::systemConf()->auth_type, 'default_user' => Minz_User::name() ?? '', 'passwordHash' => FreshRSS_Context::userConf()->passwordHash, 'bd_type' => FreshRSS_Context::systemConf()->db['type'] ?? '', 'bd_host' => FreshRSS_Context::systemConf()->db['host'] ?? '', 'bd_user' => FreshRSS_Context::systemConf()->db['user'] ?? '', 'bd_password' => FreshRSS_Context::systemConf()->db['password'] ?? '', 'bd_base' => FreshRSS_Context::systemConf()->db['base'] ?? '', 'bd_prefix' => FreshRSS_Context::systemConf()->db['prefix'] ?? '', 'bd_error' => false, ]); header('Location: index.php?step=4'); } } function saveStep2(): void { if (!empty($_POST)) { if (Minz_Session::paramString('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']) || !is_string($_POST['type']) || empty($_POST['host']) || !is_string($_POST['host']) || empty($_POST['user']) || !is_string($_POST['user']) || empty($_POST['base']) || !is_string($_POST['base']) || !is_string($_POST['pass'] ?? null) || !is_string($_POST['prefix'] ?? null) ) { Minz_Session::_param('bd_error', 'Missing parameters!'); } else { 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), ]); } } // 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::paramString('bd_type'), 'host' => Minz_Session::paramString('bd_host'), 'user' => Minz_Session::paramString('bd_user'), 'password' => Minz_Session::paramString('bd_password'), 'base' => Minz_Session::paramString('bd_base'), 'prefix' => Minz_Session::paramString('bd_prefix'), 'pdo_options' => [], ], 'pubsubhubbub_enabled' => Minz_Request::serverIsPublic($base_url), ]; if (Minz_Session::paramString('title') != '') { $config_array['title'] = Minz_Session::paramString('title'); } $customConfigPath = DATA_PATH . '/config.custom.php'; if (file_exists($customConfigPath)) { $customConfig = include $customConfigPath; if (is_array($customConfig)) { $config_array = array_merge($customConfig, $config_array); if (!is_string($config_array['default_user'] ?? null)) { $config_array['default_user'] = '_'; } } } @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::paramString('bd_error') == '') { Minz_Session::_param('bd_error', 'Unknown error!'); } } invalidateHttpCache(); } function saveStep3(): bool { FreshRSS_Context::initSystem(); Minz_Translate::init(Minz_Session::paramString('language')); if (!empty($_POST)) { $auth_type = param('auth_type', 'form'); if (in_array($auth_type, ['form', 'http_auth', 'none'], true)) { FreshRSS_Context::systemConf()->auth_type = $auth_type; Minz_Session::_param('auth_type', FreshRSS_Context::systemConf()->auth_type); } else { return false; } $password_plain = param('passwordPlain', ''); if (FreshRSS_Context::systemConf()->auth_type === 'form' && $password_plain == '') { return false; } if (FreshRSS_user_Controller::checkUsername(param('default_user', ''))) { FreshRSS_Context::systemConf()->default_user = param('default_user', ''); Minz_Session::_param('default_user', FreshRSS_Context::systemConf()->default_user); } else { return false; } if (FreshRSS_Context::systemConf()->auth_type === 'http_auth' && Minz_Request::connectionRemoteAddress() !== '' && empty($_SERVER['REMOTE_USER']) && empty($_SERVER['REDIRECT_REMOTE_USER']) && // No safe authentication HTTP headers (!empty($_SERVER['HTTP_REMOTE_USER']) || !empty($_SERVER['HTTP_X_WEBAUTH_USER'])) // but has unsafe authentication HTTP headers ) { // Trust by default the remote IP address (e.g. last proxy) used during install to provide remote user name via unsafe HTTP header FreshRSS_Context::systemConf()->trusted_sources[] = Minz_Request::connectionRemoteAddress(); FreshRSS_Context::systemConf()->trusted_sources = array_unique(FreshRSS_Context::systemConf()->trusted_sources); } // Create default user files but first, we delete previous data to // avoid access right problems. recursive_unlink(USERS_PATH . '/' . Minz_Session::paramString('default_user')); $ok = false; try { Minz_ModelPdo::$usesSharedPdo = false; $databaseDAO = FreshRSS_Factory::createDatabaseDAO(Minz_User::INTERNAL_USER); if (!$databaseDAO->testTyping()) { $message = 'Invalid PDO driver behaviour for selected database type!'; if (Minz_Session::paramString('bd_type') === 'mysql') { $message .= ' MySQL requires mysqlnd.'; } throw new Exception($message); } Minz_ModelPdo::$usesSharedPdo = true; $ok = FreshRSS_user_Controller::createUser( Minz_Session::paramString('default_user'), '', //TODO: Add e-mail $password_plain, [ 'language' => Minz_Session::paramString('language'), 'is_admin' => true, 'enabled' => true, ] ); } catch (Exception $e) { Minz_Session::_param('bd_error', $e->getMessage()); $ok = false; } if (!$ok) { checkStep(); return false; } FreshRSS_Context::systemConf()->save(); header('Location: index.php?step=4'); } return true; } /*** VÉRIFICATIONS ***/ function checkStep(): void { $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); } /** @return array */ function checkStep0(): array { $languages = Minz_Translate::availableLanguages(); $language = Minz_Session::paramString('language') != '' && in_array(Minz_Session::paramString('language'), $languages, true); $sessionWorking = Minz_Session::paramString('sessionWorking') === 'ok'; return [ 'language' => $language ? 'ok' : 'ko', 'sessionWorking' => $sessionWorking ? 'ok' : 'ko', 'all' => $language && $sessionWorking ? 'ok' : 'ko', ]; } function freshrss_already_installed(): bool { $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 { $system_conf = FreshRSS_SystemConfiguration::init($conf_path); } catch (Minz_FileNotExistException $e) { return false; } // ok, the global conf exists… but what about default user conf? $current_user = $system_conf->default_user; try { FreshRSS_UserConfiguration::init(USERS_PATH . '/' . $current_user . '/config.php'); } catch (Minz_FileNotExistException $e) { return false; } // ok, ok, default user exists too! return true; } /** @return array */ function checkStep2(): array { $conf = is_writable(join_path(DATA_PATH, 'config.php')); $bd = Minz_Session::paramString('bd_type') != ''; $conn = Minz_Session::paramString('bd_error') == ''; return [ 'bd' => $bd ? 'ok' : 'ko', 'conn' => $conn ? 'ok' : 'ko', 'conf' => $conf ? 'ok' : 'ko', 'all' => $bd && $conn && $conf ? 'ok' : 'ko', ]; } /** @return array */ function checkStep3(): array { $conf = Minz_Session::paramString('default_user') != ''; $form = Minz_Session::paramString('auth_type') != ''; $defaultUser = is_string($_POST['default_user'] ?? null) ? trim($_POST['default_user']) : ''; if ($defaultUser === '') { $defaultUser = Minz_Session::paramString('default_user') == '' ? '' : Minz_Session::paramString('default_user'); } $data = is_writable(USERS_PATH . '/' . $defaultUser . '/config.php'); return [ 'conf' => $conf ? 'ok' : 'ko', 'form' => $form ? 'ok' : 'ko', 'data' => $data ? 'ok' : 'ko', 'all' => $conf && $form && $data ? 'ok' : 'ko', ]; } /* select language */ function printStep0(): void { $actual = Minz_Translate::language(); $languages = Minz_Translate::availableLanguages(); $s0 = checkStep0(); ?>

$messageParams * */ function printStep1Template(string $key, string $value, array $messageParams = []): void { if ('ok' === $value) { $message = _t("install.check.{$key}.ok", ...$messageParams); ?>

= 7.52 for CURLPROXY_HTTPS printStep1Template('json', $res['json']); printStep1Template('pcre', $res['pcre']); printStep1Template('ctype', $res['ctype']); printStep1Template('dom', $res['dom']); printStep1Template('xml', $res['xml']); printStep1Template('mbstring', $res['mbstring']); printStep1Template('intl', $res['intl']); printStep1Template('fileinfo', $res['fileinfo']); printStep1Template('zip', $res['zip']); ?>

tabindex="3" />

> <?= _t('install.title') ?>: <?= _t('install.step', STEP + 1) ?>

: