ryxeo-glpi-git / config / config.php @ 15ef2b99
Historique | Voir | Annoter | Télécharger (7,33 ko)
1 | b67d8923 | Eric Seigne | <?php
|
---|---|---|---|
2 | /*
|
||
3 | * @version $Id: config.php 7763 2009-01-06 18:44:50Z moyo $
|
||
4 | -------------------------------------------------------------------------
|
||
5 | GLPI - Gestionnaire Libre de Parc Informatique
|
||
6 | Copyright (C) 2003-2009 by the INDEPNET Development Team.
|
||
7 | |||
8 | http://indepnet.net/ http://glpi-project.org
|
||
9 | -------------------------------------------------------------------------
|
||
10 | |||
11 | LICENSE
|
||
12 | |||
13 | This file is part of GLPI.
|
||
14 | |||
15 | GLPI is free software; you can redistribute it and/or modify
|
||
16 | it under the terms of the GNU General Public License as published by
|
||
17 | the Free Software Foundation; either version 2 of the License, or
|
||
18 | (at your option) any later version.
|
||
19 | |||
20 | GLPI is distributed in the hope that it will be useful,
|
||
21 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
23 | GNU General Public License for more details.
|
||
24 | |||
25 | You should have received a copy of the GNU General Public License
|
||
26 | along with GLPI; if not, write to the Free Software
|
||
27 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
28 | --------------------------------------------------------------------------
|
||
29 | */
|
||
30 | |||
31 | // ----------------------------------------------------------------------
|
||
32 | // Original Author of file:
|
||
33 | // Purpose of file:
|
||
34 | // ----------------------------------------------------------------------
|
||
35 | |||
36 | if (!defined('GLPI_ROOT')){ |
||
37 | die("Sorry. You can't access directly to this file"); |
||
38 | } |
||
39 | include_once (GLPI_ROOT."/config/based_config.php"); |
||
40 | include_once (GLPI_ROOT."/inc/dbreplicate.function.php"); |
||
41 | include (GLPI_ROOT."/config/define.php"); |
||
42 | |||
43 | setGlpiSessionPath(); |
||
44 | startGlpiSession(); |
||
45 | |||
46 | if(!file_exists(GLPI_CONFIG_DIR . "/config_db.php")) { |
||
47 | nullHeader("DB Error",$_SERVER['PHP_SELF']); |
||
48 | if (!isCommandLine()){
|
||
49 | echo "<div align='center'>"; |
||
50 | 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>"; |
||
51 | echo "</div>"; |
||
52 | } else {
|
||
53 | echo "Error : GLPI seems to not be installed properly.</p><p> config_db.php file is missing.\n"; |
||
54 | echo "Please restart the install process.\n"; |
||
55 | } |
||
56 | nullFooter("DB Error",$_SERVER['PHP_SELF']); |
||
57 | |||
58 | die();
|
||
59 | } else {
|
||
60 | |||
61 | require_once (GLPI_CONFIG_DIR . "/config_db.php"); |
||
62 | include_once (GLPI_CACHE_LITE_DIR."/Lite/Output.php"); |
||
63 | include_once (GLPI_CACHE_LITE_DIR."/Lite/File.php"); |
||
64 | |||
65 | //Database connection
|
||
66 | establishDBConnection((isset($USEDBREPLICATE)?$USEDBREPLICATE:0), |
||
67 | (isset($DBCONNECTION_REQUIRED)?$DBCONNECTION_REQUIRED:0)); |
||
68 | |||
69 | |||
70 | // *************************** Statics config options **********************
|
||
71 | // ********************options d'installation statiques*********************
|
||
72 | // ***********************************************************************
|
||
73 | |||
74 | //Options gerees dynamiquement, ne pas toucher cette partie.
|
||
75 | //Options from DB, do not touch this part.
|
||
76 | $CFG_GLPI["debug"]=$CFG_GLPI["debug_sql"]=$CFG_GLPI["debug_vars"]=$CFG_GLPI["debug_profile"]=$CFG_GLPI["debug_lang"]=0; |
||
77 | $config_object=new Config(); |
||
78 | |||
79 | if($config_object->getFromDB(1)){ |
||
80 | $CFG_GLPI=array_merge($CFG_GLPI,$config_object->fields); |
||
81 | |||
82 | if ( !isset($_SERVER['REQUEST_URI']) ) { |
||
83 | $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF']; |
||
84 | } |
||
85 | $currentdir=getcwd(); |
||
86 | chdir(GLPI_ROOT); |
||
87 | $glpidir=str_replace(str_replace('\\', '/',getcwd()),"",str_replace('\\', '/',$currentdir)); |
||
88 | chdir($currentdir); |
||
89 | |||
90 | $globaldir=preg_replace("/\/[0-9a-zA-Z\.\-\_]+\.php/","",$_SERVER['REQUEST_URI']); |
||
91 | $globaldir=preg_replace("/\?.*/","",$globaldir); |
||
92 | $CFG_GLPI["root_doc"]=str_replace($glpidir,"",$globaldir); |
||
93 | $CFG_GLPI["root_doc"]=preg_replace("/\/$/","",$CFG_GLPI["root_doc"]); |
||
94 | // urldecode for space redirect to encoded URL : change entity
|
||
95 | $CFG_GLPI["root_doc"]=urldecode($CFG_GLPI["root_doc"]); |
||
96 | |||
97 | // Path for icon of document type
|
||
98 | $CFG_GLPI["typedoc_icon_dir"] = GLPI_ROOT."/pics/icones"; |
||
99 | |||
100 | |||
101 | // *************************** Mode NORMAL / TRALATION /DEBUG **********************
|
||
102 | // *********************************************************************************
|
||
103 | |||
104 | // Mode debug ou traduction
|
||
105 | //$CFG_GLPI["debug"]=DEBUG_MODE;
|
||
106 | $CFG_GLPI["debug_sql"]=($CFG_GLPI["debug"]==DEBUG_MODE?1:0); // affiche les requetes |
||
107 | $CFG_GLPI["debug_vars"]=($CFG_GLPI["debug"]==DEBUG_MODE?1:0); // affiche les variables |
||
108 | $CFG_GLPI["debug_profile"]=($CFG_GLPI["debug"]==DEBUG_MODE?1:0); // Profile les requetes |
||
109 | $CFG_GLPI["debug_lang"]=($CFG_GLPI["debug"]==TRANSLATION_MODE?1:0); // affiche les variables de trads |
||
110 | |||
111 | } else {
|
||
112 | echo "Error accessing config table"; |
||
113 | exit();
|
||
114 | } |
||
115 | |||
116 | if (!isset($CFG_GLPI["use_cache"])){ |
||
117 | $CFG_GLPI["use_cache"]=0; |
||
118 | } |
||
119 | $cache_options = array( |
||
120 | 'cacheDir' => GLPI_CACHE_DIR, |
||
121 | 'lifeTime' => DEFAULT_CACHE_LIFETIME, |
||
122 | 'automaticSerialization' => true, |
||
123 | 'caching' => $CFG_GLPI["use_cache"], |
||
124 | 'hashedDirectoryLevel' => 2, |
||
125 | 'fileLocking' => CACHE_FILELOCKINGCONTROL, |
||
126 | 'writeControl' => CACHE_WRITECONTROL, |
||
127 | 'readControl' => CACHE_READCONTROL, |
||
128 | ); |
||
129 | |||
130 | $GLPI_CACHE = new Cache_Lite_Output($cache_options); |
||
131 | $CFG_GLPI["cache"]=$GLPI_CACHE; |
||
132 | |||
133 | |||
134 | // Mode debug activé on affiche un certains nombres d'informations
|
||
135 | if ($CFG_GLPI["debug"]==DEBUG_MODE){ |
||
136 | ini_set('display_errors','On'); |
||
137 | error_reporting(E_ALL); |
||
138 | //ini_set('error_prepend_string','<div style="position:fload-left; background-color:red; z-index:10000">PHP ERROR : ');
|
||
139 | //ini_set('error_append_string','</div>');
|
||
140 | set_error_handler("userErrorHandler"); |
||
141 | }else{
|
||
142 | //Pas besoin des warnings de PHP en mode normal : on va eviter de faire peur ;)
|
||
143 | error_reporting(0); |
||
144 | } |
||
145 | |||
146 | if (isset($_SESSION["glpiroot"])&&$CFG_GLPI["root_doc"]!=$_SESSION["glpiroot"]) { |
||
147 | glpi_header($_SESSION["glpiroot"]); |
||
148 | } |
||
149 | |||
150 | |||
151 | |||
152 | // Override cfg_features by session value
|
||
153 | if (!isset($_SESSION['glpilist_limit'])||$_SESSION['glpilist_limit']<5) $_SESSION["glpilist_limit"]=$CFG_GLPI['list_limit']; |
||
154 | |||
155 | if ((!isset($CFG_GLPI["version"])||trim($CFG_GLPI["version"])!=GLPI_VERSION)&&!isset($_GET["donotcheckversion"])){ |
||
156 | loadLanguage(); |
||
157 | |||
158 | if (isCommandLine()){
|
||
159 | echo $LANG["update"][88] . "\n"; |
||
160 | } else {
|
||
161 | nullHeader("UPDATE NEEDED",$_SERVER['PHP_SELF']); |
||
162 | echo "<div align='center'>"; |
||
163 | |||
164 | |||
165 | echo "<table class='tab_cadre' style='width:700px'>"; |
||
166 | echo "<tr><th>".$LANG["install"][6]."</th><th >".$LANG["install"][7]."</th></tr>"; |
||
167 | |||
168 | $error=commonCheckForUseGLPI();
|
||
169 | |||
170 | echo "</table><br>"; |
||
171 | |||
172 | if (!$error){ |
||
173 | if (!isset($CFG_GLPI["version"])||trim($CFG_GLPI["version"])<GLPI_VERSION){ |
||
174 | echo "<form method='post' action='".$CFG_GLPI["root_doc"]."/install/update.php'>"; |
||
175 | echo "<table class='tab_cadre' style='width:500px'><tr><th>"; |
||
176 | echo $LANG["update"][88]; |
||
177 | echo "</th></tr>"; |
||
178 | echo "<tr class='tab_bg_1'><td align='center'>"; |
||
179 | echo "<input type='submit' name='from_update' value='".$LANG["install"][4]."' class='submit'>"; |
||
180 | echo "</td></tr>"; |
||
181 | echo "</table></form>"; |
||
182 | } else if (trim($CFG_GLPI["version"])>GLPI_VERSION){ |
||
183 | echo "<table class='tab_cadre' style='width:500px'><tr><th>"; |
||
184 | echo $LANG["update"][89]; |
||
185 | echo "</th></tr>"; |
||
186 | echo "</table>"; |
||
187 | } |
||
188 | } else {
|
||
189 | echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">"; |
||
190 | echo "<input type=\"submit\" name=\"submit\" class=\"submit\" value=\"".$LANG["install"][27]."\" />"; |
||
191 | echo "</form>"; |
||
192 | } |
||
193 | echo "</div>"; |
||
194 | nullFooter(); |
||
195 | } |
||
196 | exit();
|
||
197 | } |
||
198 | } |
||
199 | |||
200 | 15ef2b99 | Eric Seigne | //erics -- pseudo debug mode
|
201 | //error_reporting(E_ALL);
|
||
202 | b67d8923 | Eric Seigne | ?> |