diff --git a/application/core/commands.php b/application/core/commands.php index 9f36fba8..9a18dbc4 100644 --- a/application/core/commands.php +++ b/application/core/commands.php @@ -5,7 +5,7 @@ namespace ManiaControl; /** * Class for handling chat commands * - * @author steeffeen + * @author steeffeen & kremsy */ class Commands { diff --git a/application/core/database.php b/application/core/database.php index a0d16195..2d993eac 100644 --- a/application/core/database.php +++ b/application/core/database.php @@ -3,9 +3,9 @@ namespace ManiaControl; /** - * Class for database connection + * Database connection class * - * @author steeffeen + * @author steeffeen & kremsy */ class Database { /** @@ -36,19 +36,26 @@ class Database { // Get mysql server information $host = $this->config->xpath('host'); - if (!$host) trigger_error("Invalid database configuration (host).", E_USER_ERROR); - $host = (string) $host[0]; - $port = $this->config->xpath('port'); - if (!$port) trigger_error("Invalid database configuration (port).", E_USER_ERROR); - $port = (int) $port[0]; - $user = $this->config->xpath('user'); - if (!$user) trigger_error("Invalid database configuration (user).", E_USER_ERROR); - $user = (string) $user[0]; - $pass = $this->config->xpath('pass'); - if (!$pass) trigger_error("Invalid database configuration (pass).", E_USER_ERROR); + + if (!$host) { + trigger_error("Invalid database configuration (host).", E_USER_ERROR); + } + if (!$port) { + trigger_error("Invalid database configuration (port).", E_USER_ERROR); + } + if (!$user) { + trigger_error("Invalid database configuration (user).", E_USER_ERROR); + } + if (!$pass) { + trigger_error("Invalid database configuration (pass).", E_USER_ERROR); + } + + $host = (string) $host[0]; + $port = (int) $port[0]; + $user = (string) $user[0]; $pass = (string) $pass[0]; // Open database connection @@ -76,7 +83,10 @@ class Database { */ private function initDatabase() { $dbname = $this->config->xpath('database'); - if (!$dbname) trigger_error("Invalid database configuration (database).", E_USER_ERROR); + if (!$dbname) { + trigger_error("Invalid database configuration (database).", E_USER_ERROR); + return false; + } $dbname = (string) $dbname[0]; // Try to connect diff --git a/application/core/manialinkUtil.php b/application/core/manialinkUtil.php index ec80b9bd..d293c531 100644 --- a/application/core/manialinkUtil.php +++ b/application/core/manialinkUtil.php @@ -1,9 +1,11 @@