Create GLPI main configuration file
static public createMainConfig ( $host, $user, $password, $DBname ) : boolean | ||
$user | ||
$password | ||
$DBname | ||
Результат | boolean |
function update1($DBname) { $host = $_SESSION['db_access']['host']; $user = $_SESSION['db_access']['user']; $password = $_SESSION['db_access']['password']; if (DBConnection::createMainConfig($host, $user, $password, $DBname) && !empty($DBname)) { $from_install = true; include_once GLPI_ROOT . "/install/update.php"; } else { // can't create config_db file _e("Can't create the database connection file, please verify file permissions."); echo "<h3>" . __('Do you want to continue?') . "</h3>"; 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'>"; echo "<input type='submit' name='submit' class='submit' value=\"" . __('Continue') . "\">"; echo "</p>"; Html::closeForm(); } }
if (file_exists(GLPI_CONFIG_DIR . '/config_db.php') && !isset($args['force'])) { die("Already installed (see --force option)\n"); } $_SESSION = ['glpilanguage' => isset($args['lang']) ? $args['lang'] : 'en_GB']; Toolbox::setDebugMode(Session::DEBUG_MODE, 0, 0, 1); echo "Connect to the DB...\n"; //Check if the port is in url $hostport = explode(':', $args['host']); if (count($hostport) < 2) { $link = new mysqli($hostport[0], $args['user'], $args['pass']); } else { $link = new mysqli($hostport[0], $args['user'], $args['pass'], '', $hostport[1]); } if (!$link || mysqli_connect_error()) { die("DB connection failed\n"); } $args['db'] = $link->real_escape_string($args['db']); echo "Create the DB...\n"; if (!$link->query("CREATE DATABASE IF NOT EXISTS `" . $args['db'] . "`")) { die("Can't create the DB\n"); } if (!$link->select_db($args['db'])) { die("Can't select the DB\n"); } echo "Save configuration file...\n"; if (!DBConnection::createMainConfig($args['host'], $args['user'], $args['pass'], $args['db'])) { die("Can't write configuration file\n"); } echo "Load default schema...\n"; Toolbox::createSchema($_SESSION['glpilanguage']); echo "Done\n";