install.php 16.7 KB
Newer Older
lbaaz's avatar
lbaaz committed
1
<?php
2
3
4
/**
 * ---------------------------------------------------------------------
 * GLPI - Gestionnaire Libre de Parc Informatique
5
 * Copyright (C) 2015-2021 Teclib' and contributors.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 *
 * http://glpi-project.org
 *
 * based on GLPI - Gestionnaire Libre de Parc Informatique
 * Copyright (C) 2003-2014 by the INDEPNET Development Team.
 *
 * ---------------------------------------------------------------------
 *
 * 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, see <http://www.gnu.org/licenses/>.
 * ---------------------------------------------------------------------
moyooo's avatar
moyooo committed
31
 */
32

Cédric Anne's avatar
Cédric Anne committed
33
use Glpi\Application\View\TemplateRenderer;
34
use Glpi\Cache\CacheManager;
Cédric Anne's avatar
Cédric Anne committed
35
use Glpi\System\Requirement\DbConfiguration;
Cédric Anne's avatar
Cédric Anne committed
36
37
use Glpi\System\Requirement\DbEngine;
use Glpi\System\RequirementsManager;
Cédric Anne's avatar
Cédric Anne committed
38

remi's avatar
remi committed
39
define('GLPI_ROOT', realpath('..'));
40

41
include_once (GLPI_ROOT . "/inc/based_config.php");
moyooo's avatar
moyooo committed
42
include_once (GLPI_ROOT . "/inc/db.function.php");
moyooo's avatar
moyooo committed
43

44
45
global $GLPI, $GLPI_CACHE;

46
47
$GLPI = new GLPI();
$GLPI->initLogger();
48
$GLPI->initErrorHandler();
moyooo's avatar
moyooo committed
49

50
51
Config::detectRootDoc();

Cédric Anne's avatar
Cédric Anne committed
52
$GLPI_CACHE = (new CacheManager())->getInstallerCacheInstance();
53

lbaaz's avatar
lbaaz committed
54
//Print a correct  Html header for application
yllen's avatar
yllen committed
55
56
57
58
function header_html($etape) {
   // Send UTF8 Headers
   header("Content-Type: text/html; charset=UTF-8");

59
60
   echo "<!DOCTYPE html'>";
   echo "<html lang='fr'>";
Cédric Anne's avatar
Cédric Anne committed
61
62
   echo "<head>";
   echo "<meta charset='utf-8'>";
yllen's avatar
yllen committed
63
64
   echo "<title>Setup GLPI</title>";

65
   // CFG
66
   echo Html::getCoreVariablesForJavascript();
67

Cédric Anne's avatar
Cédric Anne committed
68
    // LIBS
69
70
   echo Html::script("public/lib/base.js");
   echo Html::script("public/lib/fuzzy.js");
Johan Cwiklinski's avatar
Johan Cwiklinski committed
71
   echo Html::script("js/common.js");
Cédric Anne's avatar
Cédric Anne committed
72
   echo Html::script("js/glpi_dialog.js");
Anael Mobilia's avatar
Anael Mobilia committed
73
74

    // CSS
75
   echo Html::css('public/lib/base.css');
Cédric Anne's avatar
Cédric Anne committed
76
   echo Html::scss("css/install");
yllen's avatar
yllen committed
77
78
79
80
   echo "</head>";
   echo "<body>";
   echo "<div id='principal'>";
   echo "<div id='bloc'>";
jmdoleans's avatar
jmdoleans committed
81
   echo "<div id='logo_bloc'></div>";
yllen's avatar
yllen committed
82
83
   echo "<h2>GLPI SETUP</h2>";
   echo "<br><h3>". $etape ."</h3>";
lbaaz's avatar
lbaaz committed
84
85
}

yllen's avatar
yllen committed
86

lbaaz's avatar
lbaaz committed
87
//Display a great footer.
yllen's avatar
yllen committed
88
function footer_html() {
jmdoleans's avatar
jmdoleans committed
89
   echo "</div></div></body></html>";
lbaaz's avatar
lbaaz committed
90
91
}

92

yllen's avatar
yllen committed
93
94
// choose language
function choose_language() {
95
   global $CFG_GLPI;
96

97
98
99
   // fix missing param for js drodpown
   $CFG_GLPI['ajax_limit_count'] = 15;

Cédric Anne's avatar
Cédric Anne committed
100
101
102
103
104
105
106
   TemplateRenderer::getInstance()->display('install/choose_language.html.twig', [
      'languages_dropdown'  => Dropdown::showLanguages('language', [
         'display' => false,
         'value'   => $_SESSION['glpilanguage'],
         'width'   => '100%'
      ])
   ]);
107
108
109
}


yllen's avatar
yllen committed
110
function acceptLicense() {
Cédric Anne's avatar
Cédric Anne committed
111
112
113
   TemplateRenderer::getInstance()->display('install/accept_license.html.twig', [
      'copying' => file_get_contents(GLPI_ROOT . "/COPYING.txt"),
   ]);
114
115
}

116

lbaaz's avatar
lbaaz committed
117
//confirm install form
yllen's avatar
yllen committed
118
function step0() {
Cédric Anne's avatar
Cédric Anne committed
119
   TemplateRenderer::getInstance()->display('install/step0.html.twig');
lbaaz's avatar
lbaaz committed
120
121
}

moyooo's avatar
moyooo committed
122

123
//Step 1 checking some compatibility issue and some write tests.
yllen's avatar
yllen committed
124
function step1($update) {
Cédric Anne's avatar
Cédric Anne committed
125
   $requiremements = (new RequirementsManager())->getCoreRequirementList();
lbaaz's avatar
lbaaz committed
126

Cédric Anne's avatar
Cédric Anne committed
127
128
129
130
   TemplateRenderer::getInstance()->display('install/step1.html.twig', [
      'update'       => $update,
      'requirements' => $requiremements,
   ]);
lbaaz's avatar
lbaaz committed
131
132
}

moyooo's avatar
moyooo committed
133

yllen's avatar
yllen committed
134
135
//step 2 import mysql settings.
function step2($update) {
Cédric Anne's avatar
Cédric Anne committed
136
137
138
   TemplateRenderer::getInstance()->display('install/step2.html.twig', [
      'update' => $update,
   ]);
lbaaz's avatar
lbaaz committed
139
140
}

yllen's avatar
yllen committed
141

lbaaz's avatar
lbaaz committed
142
//step 3 test mysql settings and select database.
yllen's avatar
yllen committed
143
144
145
function step3($host, $user, $password, $update) {

   error_reporting(16);
yllen's avatar
yllen committed
146

147
148
149
   //Check if the port is in url
   $hostport = explode(":", $host);
   if (count($hostport) < 2) {
Anael Mobilia's avatar
Anael Mobilia committed
150
      $link = new mysqli($hostport[0], $user, $password);
151
   } else {
Anael Mobilia's avatar
Anael Mobilia committed
152
      $link = new mysqli($hostport[0], $user, $password, '', $hostport[1]);
153
154
   }

Cédric Anne's avatar
Cédric Anne committed
155
156
157
   $engine_requirement = null;
   $config_requirement = null;
   $databases = [];
yllen's avatar
yllen committed
158

Cédric Anne's avatar
Cédric Anne committed
159
160
161
162
163
164
   if (!$link->connect_error) {
      $_SESSION['db_access'] = [
         'host'     => $host,
         'user'     => $user,
         'password' => $password
      ];
yllen's avatar
yllen committed
165

Cédric Anne's avatar
Cédric Anne committed
166
167
168
169
170
171
      $db = new class($link) extends DBmysql {
         public function __construct($dbh) {
            $this->dbh = $dbh;
         }
      };

Cédric Anne's avatar
Cédric Anne committed
172
173
      $engine_requirement = new DbEngine($db);
      $config_requirement = new DbConfiguration($db);
yllen's avatar
yllen committed
174

Cédric Anne's avatar
Cédric Anne committed
175
176
177
      // get databases
      if ($engine_requirement->isValidated() && $config_requirement->isValidated()
          && $DB_list = $link->query("SHOW DATABASES")) {
moyooo's avatar
moyooo committed
178
         while ($row = $DB_list->fetch_array()) {
Cédric Anne's avatar
Cédric Anne committed
179
180
181
182
183
184
185
            if (!in_array($row['Database'], [
               "information_schema",
               "mysql",
               "performance_schema"
            ])) {
               $databases[] = $row['Database'];
            }
yllen's avatar
yllen committed
186
187
188
         }
      }
   }
Cédric Anne's avatar
Cédric Anne committed
189
190
191
192
193
194
195
196
197
198
199

   // display html
   TemplateRenderer::getInstance()->display('install/step3.html.twig', [
      'update'             => $update,
      'link'               => $link,
      'host'               => $host,
      'user'               => $user,
      'engine_requirement' => $engine_requirement,
      'config_requirement' => $config_requirement,
      'databases'          => $databases,
   ]);
lbaaz's avatar
lbaaz committed
200
201
}

202

lbaaz's avatar
lbaaz committed
203
//Step 4 Create and fill database.
204
205
206
207
208
function step4 ($databasename, $newdatabasename) {

   $host     = $_SESSION['db_access']['host'];
   $user     = $_SESSION['db_access']['user'];
   $password = $_SESSION['db_access']['password'];
moyooo's avatar
moyooo committed
209

yllen's avatar
yllen committed
210
   //display the form to return to the previous step.
yllen's avatar
yllen committed
211
   echo "<h3>".__('Initialization of the database')."</h3>";
moyooo's avatar
moyooo committed
212

yllen's avatar
yllen committed
213
214
215
216
217
218
219
220
221
   function prev_form($host, $user, $password) {

      echo "<br><form action='install.php' method='post'>";
      echo "<input type='hidden' name='db_host' value='". $host ."'>";
      echo "<input type='hidden' name='db_user' value='". $user ."'>";
      echo " <input type='hidden' name='db_pass' value='". rawurlencode($password) ."'>";
      echo "<input type='hidden' name='update' value='no'>";
      echo "<input type='hidden' name='install' value='Etape_2'>";
      echo "<p class='submit'><input type='submit' name='submit' class='submit' value='".
moyooo's avatar
moyooo committed
222
            __s('Back')."'></p>";
223
      Html::closeForm();
yllen's avatar
yllen committed
224
225
226
227
   }

   //Display the form to go to the next page
   function next_form() {
Cédric Anne's avatar
Cédric Anne committed
228
      (new CacheManager())->getInstallerCacheInstance();
yllen's avatar
yllen committed
229
230
231

      echo "<br><form action='install.php' method='post'>";
      echo "<input type='hidden' name='install' value='Etape_4'>";
Cédric Anne's avatar
Cédric Anne committed
232
233
234
235
      echo "<button type='submit' name='submit' class='btn btn-primary'>
         ".__('Continue')."
         <i class='fas fa-chevron-right ms-1'></i>
      </button>";
236
      Html::closeForm();
yllen's avatar
yllen committed
237
238
   }

239
240
   //create security key
   $glpikey = new GLPIKey();
Cédric Anne's avatar
Cédric Anne committed
241
   if (!$glpikey->generate()) {
242
243
244
245
246
      echo "<p><strong>".__('Security key cannot be generated!')."</strong></p>";
      prev_form($host, $user, $password);
      return;
   }

247
248
249
   //Check if the port is in url
   $hostport = explode(":", $host);
   if (count($hostport) < 2) {
Anael Mobilia's avatar
Anael Mobilia committed
250
      $link = new mysqli($hostport[0], $user, $password);
251
   } else {
Anael Mobilia's avatar
Anael Mobilia committed
252
      $link = new mysqli($hostport[0], $user, $password, '', $hostport[1]);
253
   }
yllen's avatar
yllen committed
254

yllen's avatar
yllen committed
255
   $databasename    = $link->real_escape_string($databasename);
256
   $newdatabasename = $link->real_escape_string($newdatabasename);
yllen's avatar
yllen committed
257

yllen's avatar
yllen committed
258
   if (!empty($databasename)) { // use db already created
moyooo's avatar
moyooo committed
259
      $DB_selected = $link->select_db($databasename);
yllen's avatar
yllen committed
260
261

      if (!$DB_selected) {
262
         echo __('Impossible to use the database:');
moyooo's avatar
moyooo committed
263
         echo "<br>".sprintf(__('The server answered: %s'), $link->error);
yllen's avatar
yllen committed
264
265
266
         prev_form($host, $user, $password);

      } else {
267
         if (DBConnection::createMainConfig($host, $user, $password, $databasename, false, true)) {
268
            Toolbox::createSchema($_SESSION["glpilanguage"]);
remi's avatar
remi committed
269
            echo "<p>".__('OK - database was initialized')."</p>";
moyooo's avatar
moyooo committed
270

yllen's avatar
yllen committed
271
272
273
            next_form();

         } else { // can't create config_db file
remi's avatar
remi committed
274
            echo "<p>".__('Impossible to write the database setup file')."</p>";
yllen's avatar
yllen committed
275
276
277
278
            prev_form($host, $user, $password);
         }
      }

yllen's avatar
yllen committed
279
   } else if (!empty($newdatabasename)) { // create new db
yllen's avatar
yllen committed
280
      // Try to connect
moyooo's avatar
moyooo committed
281
      if ($link->select_db($newdatabasename)) {
remi's avatar
remi committed
282
         echo "<p>".__('Database created')."</p>";
yllen's avatar
yllen committed
283

284
         if (DBConnection::createMainConfig($host, $user, $password, $newdatabasename, false, true)) {
285
            Toolbox::createSchema($_SESSION["glpilanguage"]);
remi's avatar
remi committed
286
            echo "<p>".__('OK - database was initialized')."</p>";
yllen's avatar
yllen committed
287
288
289
            next_form();

         } else { // can't create config_db file
remi's avatar
remi committed
290
            echo "<p>".__('Impossible to write the database setup file')."</p>";
yllen's avatar
yllen committed
291
292
293
294
            prev_form($host, $user, $password);
         }

      } else { // try to create the DB
moyooo's avatar
moyooo committed
295
         if ($link->query("CREATE DATABASE IF NOT EXISTS `".$newdatabasename."`")) {
remi's avatar
remi committed
296
            echo "<p>".__('Database created')."</p>";
yllen's avatar
yllen committed
297

moyooo's avatar
moyooo committed
298
            if ($link->select_db($newdatabasename)
299
                && DBConnection::createMainConfig($host, $user, $password, $newdatabasename, false, true)) {
yllen's avatar
yllen committed
300

301
               Toolbox::createSchema($_SESSION["glpilanguage"]);
remi's avatar
remi committed
302
               echo "<p>".__('OK - database was initialized')."</p>";
yllen's avatar
yllen committed
303
304
305
               next_form();

            } else { // can't create config_db file
remi's avatar
remi committed
306
               echo "<p>".__('Impossible to write the database setup file')."</p>";
yllen's avatar
yllen committed
307
308
309
310
               prev_form($host, $user, $password);
            }

         } else { // can't create database
moyooo's avatar
moyooo committed
311
            echo __('Error in creating database!');
moyooo's avatar
moyooo committed
312
            echo "<br>".sprintf(__('The server answered: %s'), $link->error);
yllen's avatar
yllen committed
313
314
315
316
317
            prev_form($host, $user, $password);
         }
      }

   } else { // no db selected
moyooo's avatar
moyooo committed
318
      echo "<p>".__("You didn't select a database!"). "</p>";
yllen's avatar
yllen committed
319
320
321
322
      //prev_form();
      prev_form($host, $user, $password);
   }

moyooo's avatar
moyooo committed
323
   $link->close();
yllen's avatar
yllen committed
324
325
326

}

327
//send telemetry information
Johan Cwiklinski's avatar
Johan Cwiklinski committed
328
329
330
331
332
333
334
function step6() {
   global $DB;

   include_once(GLPI_ROOT . "/inc/dbmysql.class.php");
   include_once(GLPI_CONFIG_DIR . "/config_db.php");
   $DB = new DB();

335
   $_SESSION['telemetry_from_install'] = true;
Johan Cwiklinski's avatar
Johan Cwiklinski committed
336

Cédric Anne's avatar
Cédric Anne committed
337
338
339
340
   TemplateRenderer::getInstance()->display('install/step6.html.twig', [
      'telemetry_info' => Telemetry::showTelemetry(),
      'reference_info' => Telemetry::showReference(),
   ]);
Johan Cwiklinski's avatar
Johan Cwiklinski committed
341
}
yllen's avatar
yllen committed
342
343

function step7() {
Cédric Anne's avatar
Cédric Anne committed
344
345
346
347
   TemplateRenderer::getInstance()->display('install/step7.html.twig', [
      'glpinetwork'     => GLPINetwork::showInstallMessage(),
      'glpinetwork_url' => GLPI_NETWORK_SERVICES,
   ]);
348
349
350
351
}

// finish installation
function step8() {
yllen's avatar
CS    
yllen committed
352
353
   include_once(GLPI_ROOT . "/inc/dbmysql.class.php");
   include_once(GLPI_CONFIG_DIR . "/config_db.php");
yllen's avatar
yllen committed
354
   $DB = new DB();
yllen's avatar
yllen committed
355

Johan Cwiklinski's avatar
Johan Cwiklinski committed
356
357
   if (isset($_POST['send_stats'])) {
      //user has accepted to send telemetry infos; activate cronjob
358
359
360
361
362
      $DB->update(
         'glpi_crontasks',
         ['state' => 1],
         ['name' => 'telemetry']
      );
Johan Cwiklinski's avatar
Johan Cwiklinski committed
363
364
   }

moyooo's avatar
moyooo committed
365
   $url_base = str_replace("/install/install.php", "", $_SERVER['HTTP_REFERER']);
366
367
368
369
370
371
372
   $DB->update(
      'glpi_configs',
      ['value' => $DB->escape($url_base)], [
         'context'   => 'core',
         'name'      => 'url_base'
      ]
   );
yllen's avatar
yllen committed
373

374
   $url_base_api = "$url_base/apirest.php/";
375
376
   $DB->update(
      'glpi_configs',
377
      ['value' => $DB->escape($url_base_api)], [
378
379
380
381
         'context'   => 'core',
         'name'      => 'url_base_api'
      ]
   );
382

383
384
   Session::destroy(); // Remove session data (debug mode for instance) set by web installation

Cédric Anne's avatar
Cédric Anne committed
385
   TemplateRenderer::getInstance()->display('install/step8.html.twig');
yllen's avatar
yllen committed
386
387
388
}


389
390
391
392
393
function update1($DBname) {

   $host     = $_SESSION['db_access']['host'];
   $user     = $_SESSION['db_access']['user'];
   $password = $_SESSION['db_access']['password'];
yllen's avatar
yllen committed
394

Cédric Anne's avatar
Cédric Anne committed
395
396
397
398
   if ($success = DBConnection::createMainConfig($host, $user, $password, $DBname) && !empty($DBname)) {
      include_once (GLPI_CONFIG_DIR . "/config_db.php");
      global $DB;
      $DB = new DB();
399
400

      $success = DBConnection::updateConfigProperties($DB->getComputedConfigBooleanFlags());
Cédric Anne's avatar
Cédric Anne committed
401
402
   }
   if ($success) {
yllen's avatar
yllen committed
403
      $from_install = true;
yllen's avatar
CS    
yllen committed
404
      include_once(GLPI_ROOT ."/install/update.php");
yllen's avatar
yllen committed
405
   } else { // can't create config_db file
406
      header_html('');
407
      echo __("Can't create the database connection file, please verify file permissions.");
moyooo's avatar
moyooo committed
408
      echo "<h3>".__('Do you want to continue?')."</h3>";
yllen's avatar
yllen committed
409
410
411
      echo "<form action='install.php' method='post'>";
      echo "<input type='hidden' name='update' value='yes'>";
      echo "<p class='submit'><input type='hidden' name='install' value='Etape_0'>";
412
413
414
415
      echo "<button type='submit' name='submit' class='btn btn-primary'>
         ".__('Continue')."
         <i class='fas fa-chevron-right ms-1'></i>
      </button>";
416
417
      echo "</p>";
      Html::closeForm();
418
      footer_html();
yllen's avatar
yllen committed
419
420
421
422
423
424
425
426
427
428
   }
}



//------------Start of install script---------------------------


// Use default session dir if not writable
if (is_writable(GLPI_SESSION_DIR)) {
moyooo's avatar
moyooo committed
429
   Session::setPath();
yllen's avatar
yllen committed
430
431
}

moyooo's avatar
moyooo committed
432
Session::start();
yllen's avatar
yllen committed
433
434
435
436
437
438
error_reporting(0); // we want to check system before affraid the user.

if (isset($_POST["language"])) {
   $_SESSION["glpilanguage"] = $_POST["language"];
}

439
Session::loadLanguage('', false);
yllen's avatar
yllen committed
440

yllen's avatar
yllen committed
441
/**
Anael Mobilia's avatar
Anael Mobilia committed
442
 * @since 0.84.2
yllen's avatar
yllen committed
443
**/
moyooo's avatar
moyooo committed
444
function checkConfigFile() {
yllen's avatar
yllen committed
445

yllen's avatar
yllen committed
446
   if (file_exists(GLPI_CONFIG_DIR . "/config_db.php")) {
moyooo's avatar
moyooo committed
447
      Html::redirect($CFG_GLPI['root_doc'] ."/index.php");
yllen's avatar
yllen committed
448
449
      die();
   }
moyooo's avatar
moyooo committed
450
451
}

452
if (!isset($_SESSION['can_process_install']) || !isset($_POST["install"])) {
453
   $_SESSION = [];
moyooo's avatar
moyooo committed
454

455
456
   $_SESSION["glpilanguage"] = Session::getPreferredLanguage();

moyooo's avatar
moyooo committed
457
   checkConfigFile();
458
459
460
461
462
463
464

   // Add a flag that will be used to validate that installation can be processed.
   // This flag is put here just after checking that DB config file does not exist yet.
   // It is mandatory to validate that `Etape_4` to `Etape_6` are not used outside installation process
   // to change GLPI base URL without even being authenticated.
   $_SESSION['can_process_install'] = true;

465
   header_html(__("Select your language"));
moyooo's avatar
moyooo committed
466
   choose_language();
yllen's avatar
yllen committed
467
468

} else {
469
470
   // Check valid Referer :
   Toolbox::checkValidReferer();
471
   // Check CSRF: ensure nobody strap first page that checks if config file exists ...
472
   Session::checkCSRF($_POST);
473

yllen's avatar
yllen committed
474
475
476
477
478
479
480
481
482
   // DB clean
   if (isset($_POST["db_pass"])) {
      $_POST["db_pass"] = stripslashes($_POST["db_pass"]);
      $_POST["db_pass"] = rawurldecode($_POST["db_pass"]);
      $_POST["db_pass"] = stripslashes($_POST["db_pass"]);
   }

   switch ($_POST["install"]) {
      case "lang_select" : // lang ok, go accept licence
moyooo's avatar
moyooo committed
483
         checkConfigFile();
484
         header_html(SoftwareLicense::getTypeName(1));
yllen's avatar
yllen committed
485
         acceptLicense();
yllen's avatar
yllen committed
486
487
         break;

yllen's avatar
yllen committed
488
      case "License" : // licence  ok, go choose installation or Update
moyooo's avatar
moyooo committed
489
         checkConfigFile();
remi's avatar
remi committed
490
         header_html(__('Beginning of the installation'));
yllen's avatar
yllen committed
491
492
493
494
         step0();
         break;

      case "Etape_0" : // choice ok , go check system
moyooo's avatar
moyooo committed
495
         checkConfigFile();
remi's avatar
remi committed
496
497
         //TRANS %s is step number
         header_html(sprintf(__('Step %d'), 0));
yllen's avatar
yllen committed
498
499
500
501
502
         $_SESSION["Test_session_GLPI"] = 1;
         step1($_POST["update"]);
         break;

      case "Etape_1" : // check ok, go import mysql settings.
moyooo's avatar
moyooo committed
503
         checkConfigFile();
remi's avatar
remi committed
504
505
         // check system ok, we can use specific parameters for debug
         Toolbox::setDebugMode(Session::DEBUG_MODE, 0, 0, 1);
yllen's avatar
yllen committed
506

remi's avatar
remi committed
507
         header_html(sprintf(__('Step %d'), 1));
yllen's avatar
yllen committed
508
509
510
511
         step2($_POST["update"]);
         break;

      case "Etape_2" : // mysql settings ok, go test mysql settings and select database.
moyooo's avatar
moyooo committed
512
         checkConfigFile();
remi's avatar
remi committed
513
         header_html(sprintf(__('Step %d'), 2));
Anael Mobilia's avatar
Anael Mobilia committed
514
         step3($_POST["db_host"], $_POST["db_user"], $_POST["db_pass"], $_POST["update"]);
yllen's avatar
yllen committed
515
516
517
         break;

      case "Etape_3" : // Create and fill database
moyooo's avatar
moyooo committed
518
         checkConfigFile();
remi's avatar
remi committed
519
         header_html(sprintf(__('Step %d'), 3));
yllen's avatar
yllen committed
520
521
522
523
524
525
         if (empty($_POST["databasename"])) {
            $_POST["databasename"] = "";
         }
         if (empty($_POST["newdatabasename"])) {
            $_POST["newdatabasename"] = "";
         }
526
527
         step4($_POST["databasename"],
               $_POST["newdatabasename"]);
yllen's avatar
yllen committed
528
529
         break;

530
      case "Etape_4" : // send telemetry information
Johan Cwiklinski's avatar
Johan Cwiklinski committed
531
532
533
534
535
         header_html(sprintf(__('Step %d'), 4));
         step6();
         break;

      case "Etape_5" : // finish installation
536
         header_html(sprintf(__('Step %d'), 5));
yllen's avatar
yllen committed
537
538
539
         step7();
         break;

540
541
542
543
544
      case "Etape_6" : // finish installation
         header_html(sprintf(__('Step %d'), 6));
         step8();
         break;

yllen's avatar
yllen committed
545
      case "update_1" :
moyooo's avatar
moyooo committed
546
         checkConfigFile();
yllen's avatar
yllen committed
547
548
549
         if (empty($_POST["databasename"])) {
            $_POST["databasename"] = "";
         }
550
         update1($_POST["databasename"]);
yllen's avatar
yllen committed
551
552
553
         break;
   }
}
554
footer_html();