single config file
This commit is contained in:
parent
5d4cf86f61
commit
2c5a7a52e2
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Configure Server Administrators -->
|
||||
<authentication-config>
|
||||
|
||||
<!-- MasterAdmins that can't be removed ingame -->
|
||||
<masteradmins>
|
||||
<login>steeffeen</login>
|
||||
<login>kremsy</login>
|
||||
</masteradmins>
|
||||
|
||||
<!-- You can add other admins and moderators ingame -->
|
||||
|
||||
</authentication-config>
|
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Configure the MySQL Database used by ManiaControl -->
|
||||
<database-config>
|
||||
|
||||
<!-- MySQL Server -->
|
||||
<host>localhost</host>
|
||||
<port>3306</port>
|
||||
|
||||
<!-- MySQL User -->
|
||||
<user>maniacontrol</user>
|
||||
<pass>kjhgvhbjnfih2394ugnjk</pass>
|
||||
|
||||
<!-- Database Name -->
|
||||
<database>maniacontrol_dev</database>
|
||||
|
||||
</database-config>
|
@ -48,7 +48,6 @@ class AuthenticationManager {
|
||||
* @return bool
|
||||
*/
|
||||
private function loadConfig() {
|
||||
$config = FileUtil::loadConfig('authentication.xml');
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
|
||||
// Remove all MasterAdmins
|
||||
@ -61,8 +60,8 @@ class AuthenticationManager {
|
||||
return false;
|
||||
}
|
||||
$adminLevel = self::AUTH_LEVEL_SUPERADMIN;
|
||||
$xAdminLevel = self::AUTH_LEVEL_MASTERADMIN;
|
||||
$adminStatement->bind_param('ii', $adminLevel, $xAdminLevel);
|
||||
$masterAdminLevel = self::AUTH_LEVEL_MASTERADMIN;
|
||||
$adminStatement->bind_param('ii', $adminLevel, $masterAdminLevel);
|
||||
$adminStatement->execute();
|
||||
if ($adminStatement->error) {
|
||||
trigger_error($adminStatement->error);
|
||||
@ -70,7 +69,7 @@ class AuthenticationManager {
|
||||
$adminStatement->close();
|
||||
|
||||
// Set MasterAdmins
|
||||
$xAdmins = $config->masteradmins->xpath('login');
|
||||
$masterAdmins = $this->maniaControl->config->masteradmins->xpath('login');
|
||||
$adminQuery = "INSERT INTO `" . PlayerManager::TABLE_PLAYERS . "` (
|
||||
`login`,
|
||||
`authLevel`
|
||||
@ -83,13 +82,10 @@ class AuthenticationManager {
|
||||
trigger_error($mysqli->error, E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
$adminStatement->bind_param('si', $login, $xAdminLevel);
|
||||
$adminStatement->bind_param('si', $login, $masterAdminLevel);
|
||||
$success = true;
|
||||
foreach ($xAdmins as $xAdmin) {
|
||||
/**
|
||||
* @noinspection PhpUnusedLocalVariableInspection
|
||||
*/
|
||||
$login = (string) $xAdmin;
|
||||
foreach ($masterAdmins as $masterAdmin) {
|
||||
$login = (string) $masterAdmin;
|
||||
$adminStatement->execute();
|
||||
if ($adminStatement->error) {
|
||||
trigger_error($adminStatement->error);
|
||||
|
@ -17,7 +17,6 @@ class Database {
|
||||
* Private properties
|
||||
*/
|
||||
private $maniaControl = null;
|
||||
private $config = null;
|
||||
|
||||
/**
|
||||
* Construct database connection
|
||||
@ -25,27 +24,16 @@ class Database {
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Load config
|
||||
$this->config = FileUtil::loadConfig('database.xml');
|
||||
|
||||
// Get mysql server information
|
||||
$host = $this->config->xpath('host');
|
||||
$port = $this->config->xpath('port');
|
||||
$user = $this->config->xpath('user');
|
||||
$pass = $this->config->xpath('pass');
|
||||
$host = $this->maniaControl->config->database->xpath('host');
|
||||
$port = $this->maniaControl->config->database->xpath('port');
|
||||
$user = $this->maniaControl->config->database->xpath('user');
|
||||
$pass = $this->maniaControl->config->database->xpath('pass');
|
||||
|
||||
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);
|
||||
}
|
||||
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];
|
||||
@ -76,18 +64,16 @@ class Database {
|
||||
* @return bool
|
||||
*/
|
||||
private function initDatabase() {
|
||||
$dbName = $this->config->xpath('database');
|
||||
$dbName = $this->maniaControl->config->database->xpath('db_name');
|
||||
if (!$dbName) {
|
||||
trigger_error("Invalid database configuration (database).", E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
$dbName = (string) $dbName[0];
|
||||
$dbName = (string) $dbName[0];
|
||||
|
||||
// Try to connect
|
||||
$result = $this->mysqli->select_db($dbName);
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
if ($result) return true;
|
||||
|
||||
// Create database
|
||||
$databaseQuery = "CREATE DATABASE ?;";
|
||||
|
@ -8,6 +8,7 @@ namespace ManiaControl;
|
||||
* @author steeffeen & kremsy
|
||||
*/
|
||||
abstract class FileUtil {
|
||||
|
||||
/**
|
||||
* Load a remote file
|
||||
*
|
||||
@ -56,6 +57,7 @@ abstract class FileUtil {
|
||||
|
||||
return $result[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Load config xml-file
|
||||
*
|
||||
|
@ -74,6 +74,7 @@ class ManiaControl implements CommandListener {
|
||||
public $authenticationManager = null;
|
||||
public $callbackManager = null;
|
||||
public $chat = null;
|
||||
public $config = null;
|
||||
public $configurator = null;
|
||||
/**
|
||||
*
|
||||
@ -102,6 +103,9 @@ class ManiaControl implements CommandListener {
|
||||
public function __construct() {
|
||||
$this->log('Loading ManiaControl v' . self::VERSION . '...');
|
||||
|
||||
// Load config
|
||||
$this->config = FileUtil::loadConfig('server.xml');
|
||||
|
||||
// Load ManiaControl Modules
|
||||
$this->database = new Database($this);
|
||||
$this->callbackManager = new CallbackManager($this);
|
||||
@ -329,10 +333,10 @@ class ManiaControl implements CommandListener {
|
||||
// Load remote client
|
||||
$this->client = new \IXR_ClientMulticall_Gbx();
|
||||
|
||||
$host = $this->server->config->xpath('host');
|
||||
$host = $this->config->server->xpath('host');
|
||||
if (!$host) trigger_error("Invalid server configuration (host).", E_USER_ERROR);
|
||||
$host = (string) $host[0];
|
||||
$port = $this->server->config->xpath('port');
|
||||
$port = $this->config->server->xpath('port');
|
||||
if (!$host) trigger_error("Invalid server configuration (port).", E_USER_ERROR);
|
||||
$port = (string) $port[0];
|
||||
|
||||
@ -343,10 +347,10 @@ class ManiaControl implements CommandListener {
|
||||
trigger_error("Couldn't connect to server! " . $this->getClientErrorText(), E_USER_ERROR);
|
||||
}
|
||||
|
||||
$login = $this->server->config->xpath('login');
|
||||
$login = $this->config->server->xpath('login');
|
||||
if (!$login) trigger_error("Invalid server configuration (login).", E_USER_ERROR);
|
||||
$login = (string) $login[0];
|
||||
$pass = $this->server->config->xpath('pass');
|
||||
$pass = $this->config->server->xpath('pass');
|
||||
if (!$pass) trigger_error("Invalid server configuration (password).", E_USER_ERROR);
|
||||
$pass = (string) $pass[0];
|
||||
|
||||
|
@ -22,11 +22,6 @@ class Server implements CallbackListener {
|
||||
*/
|
||||
const TABLE_SERVERS = 'mc_servers';
|
||||
|
||||
/**
|
||||
* Public Properties
|
||||
*/
|
||||
public $config = null;
|
||||
|
||||
/**
|
||||
* Private Properties
|
||||
*/
|
||||
@ -44,9 +39,6 @@ class Server implements CallbackListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
$this->initTables();
|
||||
|
||||
// Load config
|
||||
$this->config = FileUtil::loadConfig('server.xml');
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'onInit');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user