Le Dimanche 27 Novembre 2005 02:21, DOMBRE Julien a écrit :
> > Le Vendredi 25 Novembre 2005 19:28, dombre a écrit :
> >> Olivier Thauvin a écrit :

> >> >WDYT ? Should I start to make a patch or should I deal with the current
> >> >settings ?
> >>
> >> Hi,
> >>
> >> you could make a patch but using the latest CVS version in order to be
> >> easy to include.

Done, attached the patch, not intrusive, but working (except if I forgot some 
files).

My own relocation, for testing purpose. The glpi cvs is in my ~/public_html, 
data are elsewhere, I chmod 777 the directory, this is bad of course, but 
real sys admin will properly setup this :)

$ cat glpi/config/config_path.php
<?php

// Default location for based configuration
$cfg_install["config_dir"] = "/home/users/olivier/glpicvs/config/";

// Default location for backup dump
$cfg_install["dump_dir"] = "/home/users/olivier/glpicvs/dump/";

// Path for documents storage
$cfg_install["doc_dir"] = "/home/users/olivier/glpicvs/docs/";

?>

Of course this files can not exists, that's why it is include in my patch.

Comments welcome. I now have an account and ask for cvs access, so if 
devellopers want to allow to improve and fix the patch my self, you know what 
to do :)
Index: index.php
===================================================================
RCS file: /cvs/glpi/glpi/index.php,v
retrieving revision 1.32
diff -u -b -B -w -p -r1.32 index.php
--- index.php	28 Oct 2005 12:03:53 -0000	1.32
+++ index.php	27 Nov 2005 18:12:48 -0000
@@ -35,7 +35,8 @@
 // Test si config_db n'existe pas on lance l'installation
 
 include ("_relpos.php");
-if(!file_exists($phproot ."/glpi/config/config_db.php")) {
+include ($phproot . "/glpi/config/based_config.php");
+if(!file_exists($cfg_install['config_dir'] . "/config_db.php")) {
 	include($phproot ."/install.php");
 	die();
 }
Index: install.php
===================================================================
RCS file: /cvs/glpi/glpi/install.php,v
retrieving revision 1.90
diff -u -b -B -w -p -r1.90 install.php
--- install.php	27 Nov 2005 00:04:05 -0000	1.90
+++ install.php	27 Nov 2005 18:12:49 -0000
@@ -242,6 +244,7 @@ echo "</form>";
 function step1($update)
 {
 	global $lang;
+    global $cfg_install;
 	$error = 0;
 	echo "<h3>".$lang["install"][5]."</h3>";
 	echo "<table class='tab_cadre'>";
@@ -368,7 +371,7 @@ function step1($update)
 
 	echo "<tr class='tab_bg_1'><td><b>".$lang["install"][16]."</b></td>";
 	
-	$fp = fopen("backups/dump/test_glpi.txt",'w');
+	$fp = fopen($cfg_install["dump_dir"] . "/test_glpi.txt",'w');
 	if (empty($fp)) {
 		echo "<td><p class='red'>".$lang["install"][17]."</p> ".$lang["install"][18]."</td></tr>";
 		$error = 2;
@@ -376,7 +379,7 @@ function step1($update)
 	else {
 		$fw = fwrite($fp,"This file was created for testing reasons. ");
 		fclose($fp);
-		$delete = unlink("backups/dump/test_glpi.txt");
+		$delete = unlink($cfg_install["dump_dir"] . "/test_glpi.txt");
 		if (!$delete) {
 			echo "<td  class='red'>".$lang["install"][19]."</td></tr>";
 			if($error != 2) $error = 1;
@@ -389,7 +392,7 @@ function step1($update)
 	
 		
 	echo "<tr class='tab_bg_1'><td><b>".$lang["install"][21]."</b></td>";	
-		$fp = fopen("docs/test_glpi.txt",'w');
+		$fp = fopen($cfg_install['doc_dir'] . "/test_glpi.txt",'w');
 	if (empty($fp)) {
 		echo "<td><p class='red'>".$lang["install"][17]."</p> ".$lang["install"][22]."</td></tr>";
 		$error = 2;
@@ -397,7 +400,7 @@ function step1($update)
 	else {
 		$fw = fwrite($fp,"This file was created for testing reasons. ");
 		fclose($fp);
-		$delete = unlink("docs/test_glpi.txt");
+		$delete = unlink($cfg_install['doc_dir'] . "/test_glpi.txt");
 		if (!$delete) {
 			echo "<td  class='red'>".$lang["install"][19]."</td></tr>";
 			if($error != 2) $error = 1;
@@ -415,15 +418,15 @@ function step1($update)
 	
 	
 	echo "<tr class='tab_bg_1'><td><b>".$lang["install"][23]."</b></td>";
-	$fp = fopen("glpi/config/test_glpi.txt",'w');
+	$fp = fopen($cfg_install['config_dir'] . "/test_glpi.txt",'w');
 	if (empty($fp)) {
-		echo "<td><p class='red'>".$lang["install"][17]."</p>". $lang["install"][24]."</td></tr>";
+		echo "<td><p class='red'>".$lang["install"][17]. " " . $cfg_install['config_dir'] . "/test_glpi.txt" ."</p>". $lang["install"][24]."</td></tr>";
 		$error = 2;
 	}
 	else {
 		$fw = fwrite($fp,"This file was created for testing reasons. ");
 		fclose($fp);
-		$delete = unlink("glpi/config/test_glpi.txt");
+		$delete = unlink($cfg_install['config_dir'] . "/test_glpi.txt");
 		if (!$delete) {
 			echo "<td>".$lang["install"][19]."</td></tr>";
 			if($error != 2) $error = 1;
@@ -580,11 +583,13 @@ function step4 ($host,$user,$password,$d
 	function fill_db()
 	{
 		global $lang;
+        global $cfg_install;
 		
 		include ("_relpos.php");
 		include ($phproot . "/glpi/common/classes.php");
 		include ($phproot . "/glpi/common/functions.php");
-		include ($phproot . "/glpi/config/config_db.php");
+        // (Nanar) Why, it is allready included at startup
+		include ($cfg_install['config_dir'] . "/config_db.php");
 		
 		$db = new DB;
 		$db_file = $phproot ."/mysql/glpi-0.65-empty.sql";
@@ -670,10 +675,12 @@ function step4 ($host,$user,$password,$d
 function step7() {
 
 	global $lang;
+    global $cfg_install;
 	include ("_relpos.php");
 	require_once ($phproot . "/glpi/common/classes.php");
 	require_once ($phproot . "/glpi/common/functions.php");
-	require_once ($phproot . "/glpi/config/config_db.php");
+    // (Nanar) Why, the file is allready include, and do require_once will not reload it
+	require_once ($cfg_install['config_dir'] . "/config_db.php");
 	$db = new DB;
 	
 	// hack pour IIS qui ne connait pas $_SERVER['REQUEST_URI']  grrrr
@@ -701,13 +708,14 @@ function step7() {
 	echo "<p class='submit'> <a href=\"index.php\"><span class='button'>".$lang["install"][64]."</span></a></p>";
 	}
 
-//Create the file glpi/config/config_db.php
+//Create the file config_db.php
 // an fill it with user connections info.
 function create_conn_file($host,$user,$password,$dbname)
 {
+    global $cfg_install;
 	$db_str = "<?php \n class DB extends DBmysql { \n var \$dbhost	= '". $host ."'; \n var \$dbuser 	= '". $user ."'; \n var \$dbpassword= '". $password ."'; \n var \$dbdefault	= '". $dbname ."'; \n } \n ?>";
 	include ("_relpos.php");
-	$fp = fopen($phproot ."/glpi/config/config_db.php",'wt');
+	$fp = fopen($cfg_install['config_dir'] . "/config_db.php",'wt');
 	if($fp) {
 		$fw = fwrite($fp,$db_str);
 		fclose($fp);
@@ -746,10 +752,18 @@ if(!session_id()) session_start();
 include ("_relpos.php");
 if(empty($_SESSION["dict"])) $_SESSION["dict"] = "french";
 if(isset($_POST["language"])) $_SESSION["dict"] = $_POST["language"];
+
+include("glpi/config/based_config.php");
+
+# If this file exists, it is load, allow to set configdir/dumpdir elsewhere
+if(file_exists($cfg_install['config_dir'] . "/config_path.php")) {
+            include($cfg_install['config_dir'] . "/config_path.php");
+}
+
 loadLang($_SESSION["dict"]);
 	if(!isset($_POST["install"])) {
 		$_SESSION = array();
-		if(file_exists($phproot ."/glpi/config/config_db.php")) {
+		if(file_exists($cfg_install["config_dir"] . "/config_db.php")) {
 			include($phproot ."/index.php");
 			die();
 		}
Index: update.php
===================================================================
RCS file: /cvs/glpi/glpi/update.php,v
retrieving revision 1.216
diff -u -b -B -w -p -r1.216 update.php
--- update.php	27 Nov 2005 00:48:05 -0000	1.216
+++ update.php	27 Nov 2005 18:12:50 -0000
@@ -36,7 +36,8 @@
 include ("_relpos.php");
 include ($phproot . "/glpi/common/classes.php");
 include ($phproot . "/glpi/common/functions.php");
-include ($phproot . "/glpi/config/config_db.php");
+include ($phproot . "/glpi/config/based_config.php");
+include ($cfg_install['config_dir'] . "/config_db.php");
 
 // ITEMS TYPE
 define("GENERAL_TYPE","0");
Index: update_content.php
===================================================================
RCS file: /cvs/glpi/glpi/update_content.php,v
retrieving revision 1.23
diff -u -b -B -w -p -r1.23 update_content.php
--- update_content.php	11 Aug 2005 14:57:31 -0000	1.23
+++ update_content.php	27 Nov 2005 18:12:50 -0000
@@ -36,10 +36,11 @@
 include ("_relpos.php");
 include ($phproot . "/glpi/common/classes.php");
 include ($phproot . "/glpi/common/functions.php");
-include ($phproot . "/glpi/config/config_db.php");
+include ($phproot . "/glpi/config/based_config.php");
 
-if(!session_id())[EMAIL PROTECTED]();}
+include($cfg["config_dir"] . "/config_db.php");
 
+if(!session_id())[EMAIL PROTECTED]();}
 
 
 //################################ Functions ################################
Index: backups/index.php
===================================================================
RCS file: /cvs/glpi/glpi/backups/index.php,v
retrieving revision 1.54
diff -u -b -B -w -p -r1.54 index.php
--- backups/index.php	31 Oct 2005 15:42:11 -0000	1.54
+++ backups/index.php	27 Nov 2005 18:12:50 -0000
@@ -36,12 +36,12 @@
 <?php
 include ("_relpos.php");
 include ($phproot . "/glpi/includes.php");
+include ($phproot . "/glpi/config/based_config");
 
 checkauthentication("super-admin");
 
 // full path 
-$path=$phproot."/backups/";
-$path = $path . "dump/";
+$path = $cfg_install['dump_dir'] ;
 if (!is_dir($path)) mkdir($path, 0777);
 if (isset($_GET["sendFile"])){
 sendFile($path.$_GET["sendFile"],$_GET["sendFile"]);
Index: glpi/config/config.php
===================================================================
RCS file: /cvs/glpi/glpi/glpi/config/config.php,v
retrieving revision 1.98
diff -u -b -B -w -p -r1.98 config.php
--- glpi/config/config.php	20 Nov 2005 19:07:32 -0000	1.98
+++ glpi/config/config.php	27 Nov 2005 18:12:51 -0000
@@ -40,16 +40,15 @@
  
 include ("_relpos.php");
 
+include ($phproot . '/glpi/config/based_config.php');
 
-if(!file_exists($phproot ."/glpi/config/config_db.php")) {
-	echo "<p>Error : GLPI seems to not be installed properly.</p><p> Config_db.php file is missing.</p><p>Please restart the install process.</p>";
+if(!file_exists($cfg_install['config_dir'] . "/config_db.php")) {
+	echo "<p>Error : GLPI seems to not be installed properly.</p><p> config_db.php file is missing.</p><p>Please restart the install process.</p>";
 	die();
 }
 else
 {
-
-require_once ($phproot ."/glpi/config/config_db.php");
-
+require_once ($cfg_install["config_dir"] . "/config_db.php");
 
 // *************************** Statics config options **********************
 // ********************options d'installation statiques*********************
@@ -156,9 +155,6 @@ $cfg_install["root"] = $db->result($resu
 
 // Path for icon of document type
 $cfg_install["typedoc_icon_dir"] = "/pics/icones";
-
-// Path for documents storage
-$cfg_install["doc_dir"] = "/docs";
 
 // Default language
 $cfg_install["default_language"] = $db->result($result,0,"default_language");
--- glpi/config/based_config.php.	1970-01-01 01:00:00.000000000 +0100
+++ glpi/config/based_config.php	2005-11-27 15:44:13.575460450 +0100
@@ -0,0 +1,49 @@
+<?php
+
+/*
+ ----------------------------------------------------------------------
+ GLPI - Gestionnaire Libre de Parc Informatique
+ Copyright (C) 2003-2005 by the INDEPNET Development Team.
+
+ http://indepnet.net/   http://glpi.indepnet.org
+ ----------------------------------------------------------------------
+
+ LICENSE
+
+    This file is part of GLPI.
+
+    GLPI is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    GLPI is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with GLPI; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+// $Id$
+
+include ("_relpos.php");
+
+// Default location for based configuration
+$cfg_install["config_dir"] = $phproot . "/glpi/config/";
+
+// Default location for backup dump
+$cfg_install["dump_dir"] = $phproot . "backups/dump";
+
+// Path for documents storage
+$cfg_install["doc_dir"] = $phproot . "/docs";
+
+
+# If this file exists, it is load, allow to set configdir/dumpdir elsewhere
+if(file_exists($phproot ."/glpi/config/config_path.php")) {
+    include($phproot ."/glpi/config/config_path.php");
+}
+
+?>

Attachment: pgphiXuDwHbw2.pgp
Description: PGP signature

Reply via email to