From 415d7a5a716726759c30151af11bd588d52acbb2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 22 Dec 2013 16:08:24 +0100 Subject: config.php plutôt que application.ini MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implémente https://github.com/marienfressinaud/FreshRSS/issues/272 --- data/.gitignore | 1 + lib/Minz/Configuration.php | 8 ++--- public/index.php | 2 +- public/install.php | 80 +++++++++++++++++++++++++--------------------- 4 files changed, 48 insertions(+), 43 deletions(-) diff --git a/data/.gitignore b/data/.gitignore index 677c8f58c..a8091901a 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -1,4 +1,5 @@ application.ini +config.php *_user.php *.sqlite touch.txt diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 9fc913964..1b108dcdf 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -8,7 +8,7 @@ * La classe Configuration permet de gérer la configuration de l'application */ class Minz_Configuration { - const CONF_PATH_NAME = '/application.ini'; + const CONF_PATH_NAME = '/config.php'; /** * VERSION est la version actuelle de MINZ @@ -126,10 +126,7 @@ class Minz_Configuration { ); } - $ini_array = parse_ini_file ( - DATA_PATH . self::CONF_PATH_NAME, - true - ); + $ini_array = include(DATA_PATH . self::CONF_PATH_NAME); if (!$ini_array) { throw new Minz_PermissionDeniedException ( @@ -147,7 +144,6 @@ class Minz_Configuration { } $general = $ini_array['general']; - // sel_application est obligatoire if (!isset ($general['sel_application'])) { throw new Minz_BadConfigurationException ( diff --git a/public/index.php b/public/index.php index 829e418f9..c8b15b3d9 100755 --- a/public/index.php +++ b/public/index.php @@ -29,7 +29,7 @@ if (file_exists ('install.php')) { $dateLastModification = max( @filemtime(DATA_PATH . '/touch.txt'), @filemtime(LOG_PATH . '/application.log'), - @filemtime(DATA_PATH . '/application.ini') + @filemtime(DATA_PATH . '/config.php') ); $_SERVER['QUERY_STRING'] .= '&utime=' . file_get_contents(DATA_PATH . '/touch.txt'); //For ETag if (httpConditional($dateLastModification, 0, 0, false, false, true)) { diff --git a/public/install.php b/public/install.php index 7fbae3436..dbbecb1a3 100644 --- a/public/install.php +++ b/public/install.php @@ -261,23 +261,29 @@ function saveStep3 () { $_SESSION['bd_prefix'] = addslashes ($_POST['prefix']); $_SESSION['bd_prefix_user'] = $_SESSION['bd_prefix'] . (empty($_SESSION['default_user']) ? '' : ($_SESSION['default_user'] . '_')); - $file_conf = DATA_PATH . '/application.ini'; - $f = fopen ($file_conf, 'w'); - writeLine ($f, '[general]'); - writeLine ($f, 'environment = "' . empty($_SESSION['environment']) ? 'production' : $_SESSION['environment'] . '"'); - writeLine ($f, 'use_url_rewriting = false'); - writeLine ($f, 'sel_application = "' . $_SESSION['sel_application'] . '"'); - writeLine ($f, 'base_url = ""'); - writeLine ($f, 'title = "' . $_SESSION['title'] . '"'); - writeLine ($f, 'default_user = "' . $_SESSION['default_user'] . '"'); - writeLine ($f, '[db]'); - writeLine ($f, 'type = "' . $_SESSION['bd_type'] . '"'); - writeLine ($f, 'host = "' . $_SESSION['bd_host'] . '"'); - writeLine ($f, 'user = "' . $_SESSION['bd_user'] . '"'); - writeLine ($f, 'password = "' . $_SESSION['bd_password'] . '"'); - writeLine ($f, 'base = "' . $_SESSION['bd_base'] . '"'); - writeLine ($f, 'prefix = "' . $_SESSION['bd_prefix'] . '"'); - fclose ($f); + $ini_array = array( + 'general' => array( + 'environment' => empty($_SESSION['environment']) ? 'production' : $_SESSION['environment'], + 'use_url_rewriting' => false, + 'sel_application' => $_SESSION['sel_application'], + 'base_url' => '', + 'title' => $_SESSION['title'], + 'default_user' => $_SESSION['default_user'], + ), + 'db' => array( + 'type' => $_SESSION['bd_type'], + 'host' => $_SESSION['bd_host'], + 'user' => $_SESSION['bd_user'], + 'password' => $_SESSION['bd_password'], + 'base' => $_SESSION['bd_base'], + 'prefix' => $_SESSION['bd_prefix'], + ), + ); + file_put_contents(DATA_PATH . '/config.php', "