Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / install / update.php @ b67d8923

Historique | Voir | Annoter | Télécharger (19,2 ko)

1
<?php
2
/*
3
 * @version $Id: update.php 7909 2009-01-26 20:44:03Z 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

    
37
if (!defined('GLPI_ROOT'))
38
        define('GLPI_ROOT', '..');
39

    
40
include_once (GLPI_ROOT . "/config/define.php");
41

    
42

    
43
include_once (GLPI_ROOT . "/inc/dbmysql.class.php");
44
include_once (GLPI_ROOT . "/inc/common.function.php");
45
include_once (GLPI_ROOT . "/inc/db.function.php");
46
include_once (GLPI_ROOT . "/inc/display.function.php");
47
include_once (GLPI_ROOT . "/config/based_config.php");
48
include_once (GLPI_CONFIG_DIR . "/config_db.php");
49

    
50
// Clean cache if directory is writable
51
if (is_writable(GLPI_CACHE_DIR)){
52
        cleanCache();
53
}
54
// Use default session dir if not writable
55
if (is_writable(GLPI_SESSION_DIR)){
56
        setGlpiSessionPath();
57
}
58

    
59
// Init debug variable
60
$CFG_GLPI["debug"]=DEBUG_MODE;
61
$CFG_GLPI["debug_sql"]=$CFG_GLPI["debug_vars"]=$CFG_GLPI["debug_profile"]=$CFG_GLPI["debug_lang"]=0;
62
$CFG_GLPI["use_errorlog"]=1;
63
$DB=new DB();
64

    
65

    
66
//Load language
67
if(!function_exists('loadLang')) {
68
        function loadLang($LANGuage) {
69
                if (isset($LANG)){ 
70
                        unset($LANG);
71
                }
72
                global $LANG;
73

    
74
                $file = GLPI_ROOT ."/locales/".$LANGuage.".php";
75
                if (file_exists($file)){
76
                        include($file);
77
                } else {
78
                        include(GLPI_ROOT ."/locales/en_GB.php");
79
                }
80
        }
81
}
82

    
83
/* ----------------------------------------------------------------- */
84

    
85
/*---------------------------------------------------------------------*/
86
/**
87
 * Display the form of content update (addslashes compatibility (V0.4))
88
 *
89
 *
90
 * @returns nothing (displays)
91
 */
92
function showContentUpdateForm() {
93

    
94
        global $LANG;
95
        echo "<div align='center'>";
96
        echo "<h3>".$LANG["update"][94]."</h3>";
97
        echo "<p>".$LANG["update"][107]."</p></div>";
98
        echo "<p class='submit'> <a href=\"update_content.php\"><span class='button'>".$LANG["install"][25]."</span></a>";
99
}
100

    
101

    
102
///// FONCTION POUR UPDATE LOCATION
103

    
104
function validate_new_location(){
105
        global $DB;
106
        $query=" DROP TABLE `glpi_dropdown_locations`";        
107
        $DB->query($query);
108
        $query=" ALTER TABLE `glpi_dropdown_locations_new` RENAME `glpi_dropdown_locations`";        
109
        $DB->query($query);
110
}
111

    
112
function display_new_locations(){
113
        global $DB;
114

    
115
        $MAX_LEVEL=10;
116

    
117
        $SELECT_ALL="";
118
        $FROM_ALL="";
119
        $ORDER_ALL="";
120
        $WHERE_ALL="";
121
        for ($i=1;$i<=$MAX_LEVEL;$i++){
122
                $SELECT_ALL.=" , location$i.name AS NAME$i , location$i.parentID AS PARENT$i ";
123
                $FROM_ALL.=" LEFT JOIN glpi_dropdown_locations_new AS location$i ON location".($i-1).".ID = location$i.parentID ";
124
                //$WHERE_ALL.=" AND location$i.level='$i' ";
125
                $ORDER_ALL.=" , NAME$i";
126

    
127
        }
128

    
129
        $query="select location0.name AS NAME0, location0.parentID AS PARENT0 $SELECT_ALL FROM glpi_dropdown_locations_new AS location0 $FROM_ALL  WHERE location0.parentID='0' $WHERE_ALL  ORDER BY NAME0 $ORDER_ALL";
130
        //echo $query;
131
        //echo "<hr>";
132
        $result=$DB->query($query);
133
        $data_old=array();
134
        echo "<table><tr>";
135
        for ($i=0;$i<=$MAX_LEVEL;$i++){
136
                echo "<th>$i</th><th>&nbsp;</th>";
137
        }
138
        echo "</tr>";
139

    
140
        while ($data =  $DB->fetch_array($result)){
141

    
142
                echo "<tr class=tab_bg_1>";
143
                for ($i=0;$i<=$MAX_LEVEL;$i++){
144
                        if (!isset($data_old["NAME$i"])||($data_old["PARENT$i"]!=$data["PARENT$i"])||($data_old["NAME$i"]!=$data["NAME$i"])){
145
                                $name=$data["NAME$i"];
146
                                if (isset($data["NAME".($i+1)])&&!empty($data["NAME".($i+1)]))
147
                                        $arrow="--->";
148
                                else $arrow="";
149
                        } else {
150
                                $name="";
151
                                $arrow="";
152
                        }
153

    
154
                        echo "<td>".$name."</td>";
155
                        echo "<td>$arrow</td>";
156
                }
157

    
158
                echo "</tr>";
159
                $data_old=$data;
160
        }
161
        $DB->free_result($result);
162
        echo "</table>";
163
}
164

    
165
function display_old_locations(){
166
        global $DB;
167
        $query="SELECT * from glpi_dropdown_locations order by name;";
168
        $result=$DB->query($query);
169

    
170
        while ($data =  $DB->fetch_array($result))
171
                echo "<b>".$data['name']."</b> - ";
172

    
173
        $DB->free_result($result);
174
}
175

    
176
function location_create_new($split_char,$add_first){
177

    
178
        global $DB;
179

    
180
        $query_auto_inc= "ALTER TABLE `glpi_dropdown_locations_new` CHANGE `ID` `ID` INT(11) NOT NULL";
181
        $result_auto_inc=$DB->query($query_auto_inc);
182

    
183
        $query="SELECT MAX(ID) AS MAX from glpi_dropdown_locations;";
184
        //echo $query."<br>";
185
        $result=$DB->query($query);
186
        $new_ID=$DB->result($result,0,"MAX");
187
        $new_ID++;
188

    
189

    
190

    
191
        $query="SELECT * from glpi_dropdown_locations;";
192
        $result=$DB->query($query);
193

    
194
        $query_clear_new="TRUNCATE TABLE `glpi_dropdown_locations_new`";
195
        //echo $query_clear_new."<br>";
196

    
197
        $result_clear_new=$DB->query($query_clear_new); 
198

    
199
        if (!empty($add_first)){
200
                $root_ID=$new_ID;
201
                $new_ID++;
202
                $query_insert="INSERT INTO glpi_dropdown_locations_new VALUES ('$root_ID','".addslashes($add_first)."',0,'')";
203

    
204
                $result_insert=$DB->query($query_insert);
205

    
206
        } else {
207
                $root_ID=0;
208
        }
209

    
210
        while ($data =  $DB->fetch_array($result)){
211

    
212
                if (!empty($split_char))
213
                        $splitter=split($split_char,$data['name']);
214
                else $splitter=array($data['name']);
215

    
216
                $up_ID=$root_ID;
217

    
218
                for ($i=0;$i<count($splitter)-1;$i++){
219
                        // Entr� existe deja ??
220
                        $query_search="select ID from glpi_dropdown_locations_new WHERE name='".addslashes($splitter[$i])."'  AND parentID='".$up_ID."'";
221
                        //                                echo $query_search."<br>";
222
                        $result_search=$DB->query($query_search);
223
                        if ($DB->numrows($result_search)==1){        // Found
224
                                $up_ID=$DB->result($result_search,0,"ID");
225
                        } else { // Not FOUND -> INSERT
226
                                $query_insert="INSERT INTO glpi_dropdown_locations_new VALUES ('$new_ID','".addslashes($splitter[$i])."','$up_ID','')";
227
                                //                                        echo $query_insert."<br>";
228
                                $result_insert=$DB->query($query_insert);
229
                                $up_ID=$new_ID++;
230

    
231
                        }
232
                }
233

    
234
                // Ajout du dernier
235
                $query_insert="INSERT INTO glpi_dropdown_locations_new VALUES ('".$data["ID"]."','".addslashes($splitter[count($splitter)-1])."','$up_ID','')";
236
                //                        echo $query_insert."<br>";
237

    
238
                $result_insert=$DB->query($query_insert);
239

    
240
        }
241
        $DB->free_result($result);
242
        $query_auto_inc= "ALTER TABLE `glpi_dropdown_locations_new` CHANGE `ID` `ID` INT(11) NOT NULL AUTO_INCREMENT";
243
        $result_auto_inc=$DB->query($query_auto_inc);
244

    
245
}
246

    
247
///// FIN FONCTIONS POUR UPDATE LOCATION
248

    
249
function showLocationUpdateForm(){
250
        global $DB,$LANG;
251

    
252

    
253
        if (FieldExists("glpi_dropdown_locations", "parentID")) {
254
                updateTreeDropdown();
255
                return true;
256
        }
257

    
258
        if (!isset($_POST['root'])) $_POST['root']='';
259
        if (!isset($_POST['car_sep'])) $_POST['car_sep']='';
260

    
261
        if(!TableExists("glpi_dropdown_locations_new")) {
262
                $query = " CREATE TABLE `glpi_dropdown_locations_new` (
263
                        `ID` INT NOT NULL auto_increment,
264
                        `name` VARCHAR(255) NOT NULL ,
265
                        `parentID` INT NOT NULL ,
266
                        `comments` TEXT NULL ,
267
                        PRIMARY KEY (`ID`),
268
                        UNIQUE KEY (`name`,`parentID`), 
269
                        KEY(`parentID`)) TYPE=MyISAM;";
270
                $DB->query($query) or die("LOCATION ".$DB->error());
271
        }
272

    
273
        if (!isset($_POST["validate_location"])){
274
                echo "<div align='center'>";
275
                echo "<h4>".$LANG["update"][130]."</h4>";
276
                echo "<p>".$LANG["update"][131]."</p>";
277
                echo "<p>".$LANG["update"][132]."<br>".$LANG["update"][133]."</p>";
278
                echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
279
                echo "<p>".$LANG["update"][134].": <input type=\"text\" name=\"car_sep\" value=\"".$_POST['car_sep']."\"></p>";
280
                echo "<p>".$LANG["update"][135].": <input type=\"text\" name=\"root\" value=\"".$_POST['root']."\"></p>";
281
                echo "<input type=\"submit\" class='submit' name=\"new_location\" value=\"".$LANG["buttons"][2]."\">";
282
                echo "<input type=\"hidden\" name=\"from_update\" value=\"from_update\">";
283
                echo "</form>";
284
                echo "</div>";
285
        }
286

    
287

    
288

    
289
        if (isset($_POST["new_location"])){
290
                location_create_new($_POST['car_sep'],$_POST['root']);        
291
                echo "<h4>".$LANG["update"][138].": </h4>";
292
                display_old_locations();        
293
                echo "<h4>".$LANG["update"][137].": </h4>";
294
                display_new_locations();        
295
                echo "<p>".$LANG["update"][136]."</p>";
296
                echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
297
                echo "<input type=\"submit\" class='submit' name=\"validate_location\" value=\"".$LANG["buttons"][2]."\">";
298
                echo "<input type=\"hidden\" name=\"from_update\" value=\"from_update\">";
299
                echo "</form>";
300
        }
301
        else if (isset($_POST["validate_location"])){
302
                validate_new_location();
303
                updateTreeDropdown();
304
                return true;
305
        } else {
306
                display_old_locations();        
307
        }
308
}
309

    
310

    
311
//test la connection a la base de donn�.
312
function test_connect() {
313
        global $DB;
314
        if($DB->error == 0) return true;
315
        else return false;
316
}
317

    
318
//Change table2 from varchar to ID+varchar and update table1.chps with depends
319
function changeVarcharToID($table1, $table2, $chps)
320
{
321

    
322
        global $DB,$LANG;
323

    
324
        if(!FieldExists($table2, "ID")) {
325
                $query = " ALTER TABLE `". $table2 ."` ADD `ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST";
326
                $DB->query($query) or die("".$LANG["update"][90].$DB->error());
327
        }
328
        $query = "ALTER TABLE $table1 ADD `temp` INT";
329
        $DB->query($query) or die($LANG["update"][90].$DB->error());
330

    
331
        $query = "select ". $table1 .".ID as row1, ". $table2 .".ID as row2 from ". $table1 .",". $table2 ." where ". $table2 .".name = ". $table1 .".". $chps." ";
332
        $result = $DB->query($query) or die($LANG["update"][90].$DB->error());
333
        while($line = $DB->fetch_array($result)) {
334
                $query = "update ". $table1 ." set temp = ". $line["row2"] ." where ID = '". $line["row1"] ."'";
335
                $DB->query($query) or die($LANG["update"][90].$DB->error());
336
        }
337
        $DB->free_result($result);
338

    
339
        $query = "ALTER TABLE ". $table1 ." DROP ". $chps."";
340
        $DB->query($query) or die($LANG["update"][90].$DB->error());
341
        $query = "ALTER TABLE ". $table1 ." CHANGE `temp` `". $chps ."` INT";
342
        $DB->query($query) or die($LANG["update"][90].$DB->error());
343
}
344

    
345

    
346

    
347
//update database up to 0.31
348
function updatedbUpTo031()
349
{
350

    
351
        global $DB,$LANG;
352
        $ret = array();
353

    
354

    
355
        if(!TableExists("glpi_config"))
356
        {
357
                $query = "CREATE TABLE `glpi_config` (
358
                        `ID` int(11) NOT NULL auto_increment,
359
                        `num_of_events` varchar(200) NOT NULL default '',
360
                        `jobs_at_login` varchar(200) NOT NULL default '',
361
                        `sendexpire` varchar(200) NOT NULL default '',
362
                        `cut` varchar(200) NOT NULL default '',
363
                        `expire_events` varchar(200) NOT NULL default '',
364
                        `list_limit` varchar(200) NOT NULL default '',
365
                        `version` varchar(200) NOT NULL default '',
366
                        `logotxt` varchar(200) NOT NULL default '',
367
                        `root_doc` varchar(200) NOT NULL default '',
368
                        `event_loglevel` varchar(200) NOT NULL default '',
369
                        `mailing` varchar(200) NOT NULL default '',
370
                        `imap_auth_server` varchar(200) NOT NULL default '',
371
                        `imap_host` varchar(200) NOT NULL default '',
372
                        `ldap_host` varchar(200) NOT NULL default '',
373
                        `ldap_basedn` varchar(200) NOT NULL default '',
374
                        `ldap_rootdn` varchar(200) NOT NULL default '',
375
                        `ldap_pass` varchar(200) NOT NULL default '',
376
                        `admin_email` varchar(200) NOT NULL default '',
377
                        `mailing_signature` varchar(200) NOT NULL default '',
378
                        `mailing_new_admin` varchar(200) NOT NULL default '',
379
                        `mailing_followup_admin` varchar(200) NOT NULL default '',
380
                        `mailing_finish_admin` varchar(200) NOT NULL default '',
381
                        `mailing_new_all_admin` varchar(200) NOT NULL default '',
382
                        `mailing_followup_all_admin` varchar(200) NOT NULL default '',
383
                        `mailing_finish_all_admin` varchar(200) NOT NULL default '',
384
                        `mailing_new_all_normal` varchar(200) NOT NULL default '',
385
                        `mailing_followup_all_normal` varchar(200) NOT NULL default '',
386
                        `mailing_finish_all_normal` varchar(200) NOT NULL default '',
387
                        `mailing_new_attrib` varchar(200) NOT NULL default '',
388
                        `mailing_followup_attrib` varchar(200) NOT NULL default '',
389
                        `mailing_finish_attrib` varchar(200) NOT NULL default '',
390
                        `mailing_new_user` varchar(200) NOT NULL default '',
391
                        `mailing_followup_user` varchar(200) NOT NULL default '',
392
                        `mailing_finish_user` varchar(200) NOT NULL default '',
393
                        `ldap_field_name` varchar(200) NOT NULL default '',
394
                        `ldap_field_email` varchar(200) NOT NULL default '',
395
                        `ldap_field_location` varchar(200) NOT NULL default '',
396
                        `ldap_field_realname` varchar(200) NOT NULL default '',
397
                        `ldap_field_phone` varchar(200) NOT NULL default '',
398
                        PRIMARY KEY  (`ID`)
399
                                ) TYPE=MyISAM AUTO_INCREMENT=2 ";
400
                $DB->query($query) or die($LANG["update"][90].$DB->error());
401

    
402
                $query = "INSERT INTO `glpi_config` VALUES (1, '10', '1', '1', '80', '30', '15', ' 0.31', 'GLPI powered by indepnet', '/glpi', '5', '0', '', '', '', '', '', '', 'admsys@xxxxx.fr', 'SIGNATURE', '1', '1', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0','1', '1', '1', 'uid', 'mail', 'physicaldeliveryofficename', 'cn', 'telephonenumber')";
403
                $DB->query($query) or die($LANG["update"][90].$DB->error());
404

    
405
                echo "<p class='center'>Version > 0.31  </p>";
406
        }
407

    
408
        // Get current version
409
        $query="SELECT version FROM glpi_config";
410
        $result=$DB->query($query) or die("get current version".$DB->error());
411
        $current_version=trim($DB->result($result,0,0));
412

    
413
        switch ($current_version){
414
                case "0.31": 
415
                        include("update_031_04.php");
416
                        update031to04();
417
                case "0.4": 
418
                case "0.41": 
419
                        include("update_04_042.php");
420
                        update04to042();
421
                case "0.42": 
422
                        include("update_042_05.php");
423
                        update042to05();
424
                case "0.5": 
425
                        include("update_05_051.php");
426
                        update05to051();
427
                case "0.51": 
428
                case "0.51a": 
429
                        include("update_051_06.php");
430
                        update051to06();
431
                case "0.6": 
432
                        include("update_06_065.php");
433
                        update06to065();
434
                case "0.65": 
435
                        include("update_065_068.php");
436
                        update065to068();
437
                case "0.68":
438
                        include("update_068_0681.php");
439
                        update068to0681();
440
                case "0.68.1":
441
                case "0.68.2":
442
                case "0.68.3":
443
                        include("update_0681_07.php");
444
                        update0681to07();
445
                case "0.7":
446
                case "0.70.1":
447
                case "0.70.2":
448
                        include("update_07_071.php");
449
                        update07to071();
450
                case "0.71":
451
                case "0.71.1":
452
                        include("update_071_0712.php");
453
                        update071to0712();
454
                case "0.71.2":
455
                        include("update_0712_0713.php");
456
                        update0712to0713();
457
                case "0.71.3":
458
                case "0.71.4":
459
                case "0.71.5":
460
                        break;
461
                default:
462
                        include("update_031_04.php");
463
                        update031to04();
464
                        include("update_04_042.php");
465
                        update04to042();
466
                        include("update_042_05.php");
467
                        update042to05();
468
                        include("update_05_051.php");
469
                        update05to051();
470
                        include("update_051_06.php");
471
                        update051to06();
472
                        include("update_06_065.php");
473
                        update06to065();
474
                        include("update_065_068.php");
475
                        update065to068();
476
                        include("update_068_0681.php");
477
                        update068to0681();
478
                        include("update_0681_07.php");
479
                        update0681to07();
480
                        include("update_07_071.php");
481
                        update07to071();
482
                        include("update_071_0712.php");
483
                        update071to0712();
484
                        break;
485
        }
486

    
487
        // Update version number and default langage and new version_founded ---- LEAVE AT THE END
488
        $query = "UPDATE `glpi_config` SET `version` = ' 0.71.5', default_language='".$_SESSION["glpilanguage"]."',founded_new_version='' ;";
489
        $DB->query($query) or die("0.6 ".$LANG["update"][90].$DB->error());
490

    
491
        optimize_tables();
492

    
493
        return $ret;
494
}
495

    
496

    
497

    
498

    
499

    
500

    
501

    
502

    
503

    
504
function updateTreeDropdown(){
505
        global $DB,$LANG;
506

    
507
        // Update Tree dropdown
508
        if(!FieldExists("glpi_dropdown_locations","completename")) {
509
                $query= "ALTER TABLE `glpi_dropdown_locations` ADD `completename` TEXT NOT NULL ;";
510
                $DB->query($query) or die("0.6 add completename in dropdown_locations ".$LANG["update"][90].$DB->error());        
511
                regenerateTreeCompleteName("glpi_dropdown_locations");
512
        }
513
        if(!FieldExists("glpi_dropdown_kbcategories","completename")) {
514
                $query= "ALTER TABLE `glpi_dropdown_kbcategories` ADD `completename` TEXT NOT NULL ;";
515
                $DB->query($query) or die("0.6 add completename in dropdown_kbcategories ".$LANG["update"][90].$DB->error());        
516
                regenerateTreeCompleteName("glpi_dropdown_kbcategories");
517
        }
518
}
519

    
520
//Debut du script
521
$HEADER_LOADED=true;
522

    
523
startGlpiSession();
524

    
525
if(!isset($_SESSION["glpilanguage"])||empty($_SESSION["glpilanguage"])) $_SESSION["glpilanguage"] = "en_GB";
526

    
527

    
528
loadLang($_SESSION["glpilanguage"]);
529

    
530
// Send UTF8 Headers
531
header("Content-Type: text/html; charset=UTF-8");
532

    
533
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
534
echo "<html>";
535
echo "<head>";
536
echo " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
537
echo "<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\"> ";
538
echo "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"> ";
539
echo "<meta http-equiv=\"Content-Language\" content=\"fr\"> ";
540
echo "<meta name=\"generator\" content=\"\">";
541
echo "<meta name=\"DC.Language\" content=\"fr\" scheme=\"RFC1766\">";
542
echo "<title>Setup GLPI</title>";
543
// CSS
544
echo "<link rel='stylesheet'  href='../css/style_install.css' type='text/css' media='screen' >";
545

    
546
echo "</head>";
547
echo "<body>";
548
echo "<div id='principal'>";
549
echo "<div id='bloc'>";
550
echo "<div class='haut'></div>";
551
echo "<h2>GLPI SETUP</h2>";
552
echo "<br><h3>Update</h3>";
553

    
554
// step 1    avec bouton de confirmation
555

    
556
if(empty($_POST["continuer"]) && empty($_POST["from_update"])) {
557

    
558
        if(empty($from_install)&&!isset($_POST["from_update"])) {
559
                echo "<div align='center'>";
560
                echo "<h3><span class='red'>".$LANG["update"][105]."</span>";
561
                echo "<p class='submit'> <a href=\"../index.php\"><span class='button'>".$LANG["update"][106]."</span></a></p>";
562
                echo "</div>";
563
        }
564
        else {
565
                echo "<div align='center'>";
566
                echo "<h3><span class='red'>".$LANG["update"][91]."</span>".$LANG["update"][92]. $DB->dbdefault ."</h3>";
567

    
568
                echo "<form action=\"update.php\" method=\"post\">";
569
                echo "<input type=\"submit\" class='submit' name=\"continuer\" value=\"".$LANG["install"][25] ."\">";
570
                echo "</form></div>";
571
        }
572
}
573
// Step 2  
574
else {
575
        if(test_connect()) {
576
                echo "<h3>".$LANG["update"][93]."</h3>";
577
                if (!isset($_POST["update_location"])){
578
                        $current_verison="0.31";
579
                        if(!TableExists("glpi_config")) {
580
                                include("update_to_031.php");
581
                                updateDbTo031();
582
                                $tab = updateDbUpTo031();
583
                        } else {
584
                                // Get current version
585
                                $query="SELECT version FROM glpi_config";
586
                                $result=$DB->query($query) or die("get current version".$DB->error());
587
                                $current_version=trim($DB->result($result,0,0));
588

    
589
                                $tab = updateDbUpTo031();
590
                        }
591

    
592
                        echo "<div align='center'>";
593
                        if(!empty($tab) && $tab["adminchange"]) {
594
                                echo "<div align='center'> <h2>". $LANG["update"][96] ."<h2></div>";
595
                        }
596

    
597
                        if (showLocationUpdateForm()){
598
                                switch ($current_version){
599
                                        case "0.31": 
600
                                        case "0.4": 
601
                                        case "0.41": 
602
                                        case "0.42": 
603
                                        case "0.5": 
604
                                        case "0.51": 
605
                                        case "0.51a": 
606
                                        case "0.6": 
607
                                        case "0.65": 
608
                                        case "0.68":
609
                                        case "0.68.1":
610
                                        case "0.68.2":
611
                                        case "0.68.3":
612
                                                showContentUpdateForm();
613
                                        break;
614
                                        default:
615
                                        echo "<a href=\"../index.php\"><span class='button'>".$LANG["install"][64]."</span></a>";
616
                                        break;
617
                                }
618
                        }
619
                        echo "</div>";
620
                }
621
        }
622
        else {
623
                echo "<h3> ";
624
                echo $LANG["update"][95] ."</h3>";
625
        }
626

    
627
}
628

    
629
echo "<div class='bas'></div></div></div></body></html>";
630

    
631
?>
Redmine Appliance - Powered by TurnKey Linux