summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-22 16:08:24 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-22 16:08:24 +0100
commit415d7a5a716726759c30151af11bd588d52acbb2 (patch)
tree2c0eb625c93516f257ab039a055b2585549a8809
parent3a4260b8744a0deb331e78cff43567a386c8d9a8 (diff)
config.php plutôt que application.ini
Implémente https://github.com/marienfressinaud/FreshRSS/issues/272
-rw-r--r--data/.gitignore1
-rw-r--r--lib/Minz/Configuration.php8
-rwxr-xr-xpublic/index.php2
-rw-r--r--public/install.php80
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', "<?php\n return " . var_export($ini_array, true));
+
+ if (file_exists(DATA_PATH . '/config.php') && file_exists(DATA_PATH . '/application.ini')) {
+ @unlink(DATA_PATH . '/application.ini'); //v0.6
+ }
$res = checkBD ();
@@ -474,25 +480,27 @@ function checkStep () {
function checkStep0 () {
moveOldFiles() && removeOldFiles();
- if (file_exists(DATA_PATH . '/application.ini')) {
+ if (file_exists(DATA_PATH . '/config.php')) {
+ $ini_array = include(DATA_PATH . '/config.php');
+ elseif (file_exists(DATA_PATH . '/application.ini')) {
$ini_array = parse_ini_file(DATA_PATH . '/application.ini', true);
- if ($ini_array) {
- $ini_general = isset($ini_array['general']) ? $ini_array['general'] : null;
- if ($ini_general) {
- $keys = array('environment', 'sel_application', 'title', 'default_user');
- foreach ($keys as $key) {
- if ((empty($_SESSION[$key])) && isset($ini_general[$key])) {
- $_SESSION[$key] = $ini_general[$key];
- }
+ }
+ if ($ini_array) {
+ $ini_general = isset($ini_array['general']) ? $ini_array['general'] : null;
+ if ($ini_general) {
+ $keys = array('environment', 'sel_application', 'title', 'default_user');
+ foreach ($keys as $key) {
+ if ((empty($_SESSION[$key])) && isset($ini_general[$key])) {
+ $_SESSION[$key] = $ini_general[$key];
}
}
- $ini_db = isset($ini_array['db']) ? $ini_array['db'] : null;
- if ($ini_db) {
- $keys = array('type', 'host', 'user', 'password', 'base', 'prefix');
- foreach ($keys as $key) {
- if ((!isset($_SESSION['bd_' . $key])) && isset($ini_db[$key])) {
- $_SESSION['bd_' . $key] = $ini_db[$key];
- }
+ }
+ $ini_db = isset($ini_array['db']) ? $ini_array['db'] : null;
+ if ($ini_db) {
+ $keys = array('type', 'host', 'user', 'password', 'base', 'prefix');
+ foreach ($keys as $key) {
+ if ((!isset($_SESSION['bd_' . $key])) && isset($ini_db[$key])) {
+ $_SESSION['bd_' . $key] = $ini_db[$key];
}
}
}
@@ -569,7 +577,7 @@ function checkStep2 () {
);
}
function checkStep3 () {
- $conf = file_exists (DATA_PATH . '/application.ini');
+ $conf = file_exists (DATA_PATH . '/config.php');
$bd = isset ($_SESSION['bd_type']) &&
isset ($_SESSION['bd_host']) &&
@@ -651,8 +659,8 @@ function checkBD () {
$error = true;
}
- if ($error && file_exists (DATA_PATH . '/application.ini')) {
- unlink (DATA_PATH . '/application.ini');
+ if ($error && file_exists (DATA_PATH . '/config.php')) {
+ unlink (DATA_PATH . '/config.php');
}
return !$error;