Make configuration more consistent

This commit is contained in:
ruan 2020-05-03 15:24:14 +02:00
parent dd04da174a
commit 317b1d44d0

View File

@ -11,16 +11,16 @@ final class Settings {
$this->host = 'localhost'; $this->host = 'localhost';
$this->port = 3306; $this->port = 3306;
$database = 'litebans'; $this->database = 'litebans';
$username = ''; $this->username = '';
$password = ''; $this->password = '';
// If you set a table prefix in config.yml, set it here as well // If you set a table prefix in config.yml, set it here as well
$this->table_prefix = "litebans_"; $this->table_prefix = "litebans_";
// Supported drivers: mysql, pgsql // Supported drivers: mysql, pgsql
$driver = 'mysql'; $this->driver = 'mysql';
// Server name, shown on the main page and on the header // Server name, shown on the main page and on the header
$this->name = 'LiteBans'; $this->name = 'LiteBans';
@ -136,7 +136,7 @@ final class Settings {
$this->active_query = ""; $this->active_query = "";
if ($driver === "pgsql") { if ($this->driver === "pgsql") {
Settings::$TRUE = "B'1'"; Settings::$TRUE = "B'1'";
Settings::$FALSE = "B'0'"; Settings::$FALSE = "B'0'";
} }
@ -166,13 +166,16 @@ final class Settings {
'config' => "${table_prefix}config", 'config' => "${table_prefix}config",
); );
$this->driver = $driver;
if ($connect) { if ($connect) {
$driver = $this->driver;
$host = $this->host;
$port = $this->port;
$database = $this->database;
$username = $this->username;
$password = $this->password;
if ($username === "" && $password === "") { if ($username === "" && $password === "") {
redirect("error/unconfigured.php"); redirect("error/unconfigured.php");
} }
$host = $this->host;
$port = $this->port;
$dsn = "$driver:dbname=$database;host=$host;port=$port"; $dsn = "$driver:dbname=$database;host=$host;port=$port";
if ($driver === 'mysql') { if ($driver === 'mysql') {