diff options
| author | 2015-07-20 15:59:33 +0200 | |
|---|---|---|
| committer | 2015-07-20 15:59:33 +0200 | |
| commit | 7925a5125b6a095cde4b2c92846dac384d66d20e (patch) | |
| tree | 1579fadd297b31cbd750ebc7f67d34a0984a076d /app/install.php | |
| parent | 3dd2d56867db8aea8049c4b398e6ca2e1814cf67 (diff) | |
Detect previous FreshRSS installation
See https://github.com/FreshRSS/FreshRSS/issues/909
Diffstat (limited to 'app/install.php')
| -rw-r--r-- | app/install.php | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/app/install.php b/app/install.php index 75a211064..3312208c0 100644 --- a/app/install.php +++ b/app/install.php @@ -9,6 +9,7 @@ session_name('FreshRSS'); session_set_cookie_params(0, dirname(empty($_SERVER['REQUEST_URI']) ? '/' : dirname($_SERVER['REQUEST_URI'])), null, false, true); session_start(); +// TODO: use join_path() instead Minz_Configuration::register('default_system', DATA_PATH . '/config.default.php'); Minz_Configuration::register('default_user', USERS_PATH . '/_/config.default.php'); @@ -80,6 +81,7 @@ function saveLanguage() { } function saveStep1() { + // TODO: rename reinstall in install if (isset($_POST['freshrss-keep-reinstall']) && $_POST['freshrss-keep-reinstall'] === '1') { // We want to keep our previous installation of FreshRSS @@ -87,6 +89,7 @@ function saveStep1() { // with values from the previous installation // First, we try to get previous configurations + // TODO: use join_path() instead Minz_Configuration::register('system', DATA_PATH . '/config.php', DATA_PATH . '/config.default.php'); @@ -100,9 +103,11 @@ function saveStep1() { // Then, we set $_SESSION vars $_SESSION['title'] = $system_conf->title; + $_SESSION['auth_type'] = $system_conf->auth_type; $_SESSION['old_entries'] = $user_conf->old_entries; $_SESSION['mail_login'] = $user_conf->mail_login; $_SESSION['default_user'] = $current_user; + $_SESSION['passwordHash'] = $user_conf->passwordHash; $db = $system_conf->db; $_SESSION['bd_type'] = $db['type']; @@ -341,7 +346,30 @@ function checkStep1() { } function freshrss_already_installed() { - return false; + $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() { |
