diff --git a/application/.idea/workspace.xml b/application/.idea/workspace.xml
index 2ed68761..b3b2d00c 100644
--- a/application/.idea/workspace.xml
+++ b/application/.idea/workspace.xml
@@ -23,75 +23,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -111,17 +46,23 @@
-
-
+
+
+
+
+
+
+
+
-
-
+
+
@@ -151,18 +92,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -211,6 +140,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -218,8 +159,8 @@
-
+
@@ -283,29 +224,50 @@
-
+
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
@@ -316,63 +278,26 @@
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
@@ -384,16 +309,86 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/application/ManiaControl.php b/application/ManiaControl.php
index 227202a2..b586154d 100644
--- a/application/ManiaControl.php
+++ b/application/ManiaControl.php
@@ -4,7 +4,7 @@ namespace ManiaControl;
define('ManiaControlDir', __DIR__);
-require_once __DIR__ . '/core/core.ManiaControl.php';
+require_once __DIR__ . '/core/core.php';
// Set process settings
ini_set('memory_limit', '128M');
diff --git a/application/core/authentication.php b/application/core/authentication.php
index a083b215..410dbb40 100644
--- a/application/core/authentication.php
+++ b/application/core/authentication.php
@@ -17,15 +17,15 @@ class Authentication {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $config = null;
/**
* Construct authentication manager
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('authentication.ManiaControl.xml');
@@ -94,8 +94,8 @@ class Authentication {
* @param string $login
*/
public function sendNotAllowed($login) {
- if (!$this->iControl->chat->sendError('You do not have the required rights to perform this command!', $login)) {
- trigger_error("Couldn't send forbidden message to login '" . $login . "'. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->chat->sendError('You do not have the required rights to perform this command!', $login)) {
+ trigger_error("Couldn't send forbidden message to login '" . $login . "'. " . $this->mc->getClientErrorText());
}
}
}
diff --git a/application/core/callbacks.php b/application/core/callbacks.php
index 6a6d7a0f..ac0da0aa 100644
--- a/application/core/callbacks.php
+++ b/application/core/callbacks.php
@@ -49,7 +49,7 @@ class Callbacks {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $callbackHandlers = array();
@@ -64,8 +64,8 @@ class Callbacks {
/**
* Construct callbacks handler
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Init values
$this->last1Second = time();
@@ -82,7 +82,7 @@ class Callbacks {
$this->triggerCallback(self::CB_IC_ONINIT, array(self::CB_IC_ONINIT));
// Simulate begin map
- $map = $this->iControl->server->getMap();
+ $map = $this->mc->server->getMap();
if ($map) {
$this->triggerCallback(self::CB_IC_BEGINMAP, array(self::CB_IC_BEGINMAP, array($map)));
}
@@ -122,12 +122,12 @@ class Callbacks {
}
// Get server callbacks
- if (!$this->iControl->client) return;
- $this->iControl->client->resetError();
- $this->iControl->client->readCB();
- $callbacks = $this->iControl->client->getCBResponses();
- if (!is_array($callbacks) || $this->iControl->client->isError()) {
- trigger_error("Error reading server callbacks. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client) return;
+ $this->mc->client->resetError();
+ $this->mc->client->readCB();
+ $callbacks = $this->mc->client->getCBResponses();
+ if (!is_array($callbacks) || $this->mc->client->isError()) {
+ trigger_error("Error reading server callbacks. " . $this->mc->getClientErrorText());
return;
}
diff --git a/application/core/chat.php b/application/core/chat.php
index 1e4895ae..61f1c3d5 100644
--- a/application/core/chat.php
+++ b/application/core/chat.php
@@ -12,7 +12,7 @@ class Chat {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $config = null;
@@ -21,8 +21,8 @@ class Chat {
/**
* Construct ManiaControl chat
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('chat.ManiaControl.xml');
@@ -36,12 +36,12 @@ class Chat {
* @param bool $prefix
*/
public function sendChat($message, $login = null, $prefix = false) {
- if (!$this->iControl->client) return false;
+ if (!$this->mc->client) return false;
if ($login === null) {
- return $this->iControl->client->query('ChatSendServerMessage', ($prefix ? $this->prefix : '') . $message);
+ return $this->mc->client->query('ChatSendServerMessage', ($prefix ? $this->prefix : '') . $message);
}
else {
- return $this->iControl->client->query('ChatSendServerMessageToLogin', ($prefix ? $this->prefix : '') . $message, $login);
+ return $this->mc->client->query('ChatSendServerMessageToLogin', ($prefix ? $this->prefix : '') . $message, $login);
}
}
diff --git a/application/core/commands.php b/application/core/commands.php
index 2ac5bb22..01ac1c31 100644
--- a/application/core/commands.php
+++ b/application/core/commands.php
@@ -12,7 +12,7 @@ class Commands {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $config = null;
@@ -27,16 +27,16 @@ class Commands {
/**
* Construct commands handler
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('commands.ManiaControl.xml');
// Register for callbacks
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'each5Seconds');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handleChatCallback');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'each5Seconds');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handleChatCallback');
// Register basic commands
$commands = array('help', 'version', 'shutdown', 'shutdownserver', 'networkstats', 'systeminfo', 'getservername',
@@ -102,7 +102,7 @@ class Commands {
{
// Payed
$message = 'Success! Thanks.';
- $this->iControl->chat->sendSuccess($message, $login);
+ $this->mc->chat->sendSuccess($message, $login);
unset($this->openBills[$bill[0]]);
break;
}
@@ -110,14 +110,14 @@ class Commands {
{
// Refused
$message = 'Transaction cancelled.';
- $this->iControl->chat->sendError($message, $login);
+ $this->mc->chat->sendError($message, $login);
unset($this->openBills[$bill[0]]);
break;
}
case 6:
{
// Error
- $this->iControl->chat->sendError($bill[2], $login);
+ $this->mc->chat->sendError($bill[2], $login);
unset($this->openBills[$bill[0]]);
break;
}
@@ -134,7 +134,7 @@ class Commands {
private function getRightsLevel($commandName, $defaultLevel) {
$command_rights = $this->config->xpath('//' . strtolower($commandName) . '/..');
if (empty($command_rights)) return $defaultLevel;
- $rights = $this->iControl->authentication->RIGHTS_LEVELS;
+ $rights = $this->mc->authentication->RIGHTS_LEVELS;
$highest_level = null;
foreach ($command_rights as $right) {
$levelName = $right->getName();
@@ -152,13 +152,13 @@ class Commands {
*/
private function command_version($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('version', 'all'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('version', 'all'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
- if (!$this->iControl->chat->sendInformation('This server is using ManiaControl v' . ManiaControl::VERSION . '!', $login)) {
- trigger_error("Couldn't send version to '" . $login . "'. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->chat->sendInformation('This server is using ManiaControl v' . ManiaControl::VERSION . '!', $login)) {
+ trigger_error("Couldn't send version to '" . $login . "'. " . $this->mc->getClientErrorText());
}
}
@@ -167,9 +167,9 @@ class Commands {
*/
private function command_help($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('help', 'all'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('help', 'all'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
// TODO: improve help command
@@ -178,7 +178,7 @@ class Commands {
$commands = array_keys($this->commandHandlers);
$count = count($commands);
for ($index = 0; $index < $count; $index++) {
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel($commands[$index], 'superadmin'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel($commands[$index], 'superadmin'))) {
unset($commands[$index]);
}
}
@@ -191,8 +191,8 @@ class Commands {
}
$index++;
}
- if (!$this->iControl->chat->sendInformation($list, $login)) {
- trigger_error("Couldn't send help list to '" . $login . "'. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->chat->sendInformation($list, $login)) {
+ trigger_error("Couldn't send help list to '" . $login . "'. " . $this->mc->getClientErrorText());
}
}
@@ -201,18 +201,18 @@ class Commands {
*/
private function command_getplanets($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('getplanets', 'admin'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('getplanets', 'admin'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
- if (!$this->iControl->client->query('GetServerPlanets')) {
- trigger_error("Couldn't retrieve server planets. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('GetServerPlanets')) {
+ trigger_error("Couldn't retrieve server planets. " . $this->mc->getClientErrorText());
}
else {
- $planets = $this->iControl->client->getResponse();
- if (!$this->iControl->chat->sendInformation('This Server has ' . $planets . ' Planets!', $login)) {
- trigger_error("Couldn't send server planets to '" . $login . "'. " . $this->iControl->getClientErrorText());
+ $planets = $this->mc->client->getResponse();
+ if (!$this->mc->chat->sendInformation('This Server has ' . $planets . ' Planets!', $login)) {
+ trigger_error("Couldn't send server planets to '" . $login . "'. " . $this->mc->getClientErrorText());
}
}
}
@@ -222,9 +222,9 @@ class Commands {
*/
private function command_donate($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('donate', 'all'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('donate', 'all'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
$params = explode(' ', $chat[1][2]);
@@ -239,22 +239,22 @@ class Commands {
}
if (count($params) >= 3) {
$receiver = $params[2];
- $receiverPlayer = $this->iControl->database->getPlayer($receiver);
+ $receiverPlayer = $this->mc->database->getPlayer($receiver);
$receiverName = ($receiverPlayer ? $receiverPlayer['NickName'] : $receiver);
}
else {
$receiver = '';
- $receiverName = $this->iControl->server->getName();
+ $receiverName = $this->mc->server->getName();
}
$message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?';
- if (!$this->iControl->client->query('SendBill', $login, $amount, $message, $receiver)) {
+ if (!$this->mc->client->query('SendBill', $login, $amount, $message, $receiver)) {
trigger_error(
"Couldn't create donation of " . $amount . " planets from '" . $login . "' for '" . $receiver . "'. " .
- $this->iControl->getClientErrorText());
- $this->iControl->chat->sendError("Creating donation failed.", $login);
+ $this->mc->getClientErrorText());
+ $this->mc->chat->sendError("Creating donation failed.", $login);
}
else {
- $bill = $this->iControl->client->getResponse();
+ $bill = $this->mc->client->getResponse();
$this->openBills[$bill] = $login;
}
}
@@ -264,9 +264,9 @@ class Commands {
*/
private function command_pay($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('pay', 'superadmin'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('pay', 'superadmin'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
$params = explode(' ', $chat[1][2]);
@@ -285,15 +285,15 @@ class Commands {
else {
$receiver = $login;
}
- $message = 'Payout from $<' . $this->iControl->server->getName() . '$>.';
- if (!$this->iControl->client->query('Pay', $receiver, $amount, $message)) {
+ $message = 'Payout from $<' . $this->mc->server->getName() . '$>.';
+ if (!$this->mc->client->query('Pay', $receiver, $amount, $message)) {
trigger_error(
"Couldn't create payout of" . $amount . " planets by '" . $login . "' for '" . $receiver . "'. " .
- $this->iControl->getClientErrorText());
- $this->iControl->chat->sendError("Creating payout failed.", $login);
+ $this->mc->getClientErrorText());
+ $this->mc->chat->sendError("Creating payout failed.", $login);
}
else {
- $bill = $this->iControl->client->getResponse();
+ $bill = $this->mc->client->getResponse();
$this->openBills[$bill] = $login;
}
}
@@ -303,17 +303,17 @@ class Commands {
*/
private function command_networkstats($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('networkstats', 'superadmin'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('networkstats', 'superadmin'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
- $networkStats = $this->iControl->server->getNetworkStats();
+ $networkStats = $this->mc->server->getNetworkStats();
$message = 'NetworkStats: ' . 'uptime=' . $networkStats['Uptime'] . ', ' . 'nbConn=' . $networkStats['NbrConnection'] . ', ' .
'recvRate=' . $networkStats['RecvNetRate'] . ', ' . 'sendRate=' . $networkStats['SendNetRate'] . ', ' . 'recvTotal=' .
$networkStats['SendNetRate'] . ', ' . 'sentTotal=' . $networkStats['SendNetRate'];
- if (!$this->iControl->chat->sendInformation($message, $login)) {
- trigger_error("Couldn't send network stats to '" . $login . "'. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->chat->sendInformation($message, $login)) {
+ trigger_error("Couldn't send network stats to '" . $login . "'. " . $this->mc->getClientErrorText());
}
}
@@ -322,16 +322,16 @@ class Commands {
*/
private function command_systeminfo($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('systeminfo', 'superadmin'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('systeminfo', 'superadmin'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
- $systemInfo = $this->iControl->server->getSystemInfo();
+ $systemInfo = $this->mc->server->getSystemInfo();
$message = 'SystemInfo: ' . 'ip=' . $systemInfo['PublishedIp'] . ', ' . 'port=' . $systemInfo['Port'] . ', ' . 'p2pPort=' .
$systemInfo['P2PPort'] . ', ' . 'title=' . $systemInfo['TitleId'] . ', ' . 'login=' . $systemInfo['ServerLogin'] . ', ';
- if (!$this->iControl->chat->sendInformation($message, $login)) {
- trigger_error("Couldn't send system info to '" . $login . "'. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->chat->sendInformation($message, $login)) {
+ trigger_error("Couldn't send system info to '" . $login . "'. " . $this->mc->getClientErrorText());
}
}
@@ -340,12 +340,12 @@ class Commands {
*/
private function command_shutdown($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('shutdown', 'superadmin'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('shutdown', 'superadmin'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
- $this->iControl->quit("ManiaControl shutdown requested by '" . $login . "'");
+ $this->mc->quit("ManiaControl shutdown requested by '" . $login . "'");
}
/**
@@ -353,15 +353,15 @@ class Commands {
*/
private function command_startwarmup($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('startwarmup', 'operator'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('startwarmup', 'operator'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
- if (!$this->iControl->client->query("SetWarmUp", true)) {
- trigger_error("Couldn't start warmup. " . $this->iControl->getClientErrorText());
- $player = $this->iControl->database->getPlayer($login);
- $this->iControl->chat->sendInformation('$<' . ($player ? $player['NickName'] : $login) . '$> started WarmUp!');
+ if (!$this->mc->client->query("SetWarmUp", true)) {
+ trigger_error("Couldn't start warmup. " . $this->mc->getClientErrorText());
+ $player = $this->mc->database->getPlayer($login);
+ $this->mc->chat->sendInformation('$<' . ($player ? $player['NickName'] : $login) . '$> started WarmUp!');
}
}
@@ -370,17 +370,17 @@ class Commands {
*/
private function command_stopwarmup($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('stopwarmup', 'operator'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('stopwarmup', 'operator'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
- if (!$this->iControl->client->query("SetWarmUp", false)) {
- trigger_error("Couldn't stop warmup. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query("SetWarmUp", false)) {
+ trigger_error("Couldn't stop warmup. " . $this->mc->getClientErrorText());
}
else {
- $player = $this->iControl->database->getPlayer($login);
- $this->iControl->chat->sendInformation('$<' . ($player ? $player['NickName'] : $login) . '$> stopped WarmUp!');
+ $player = $this->mc->database->getPlayer($login);
+ $this->mc->chat->sendInformation('$<' . ($player ? $player['NickName'] : $login) . '$> stopped WarmUp!');
}
}
@@ -389,9 +389,9 @@ class Commands {
*/
private function command_shutdownserver($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('shutdownserver', 'superadmin'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('shutdownserver', 'superadmin'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
// Check for delayed shutdown
@@ -401,10 +401,10 @@ class Commands {
if ($param == 'empty') {
$this->serverShutdownEmpty = !$this->serverShutdownEmpty;
if ($this->serverShutdownEmpty) {
- $this->iControl->chat->sendInformation("The server will shutdown as soon as it's empty!", $login);
+ $this->mc->chat->sendInformation("The server will shutdown as soon as it's empty!", $login);
}
else {
- $this->iControl->chat->sendInformation("Empty-shutdown cancelled!", $login);
+ $this->mc->chat->sendInformation("Empty-shutdown cancelled!", $login);
}
}
else {
@@ -412,12 +412,12 @@ class Commands {
if ($delay <= 0) {
// Cancel shutdown
$this->serverShutdownTime = -1;
- $this->iControl->chat->sendInformation("Delayed shutdown cancelled!", $login);
+ $this->mc->chat->sendInformation("Delayed shutdown cancelled!", $login);
}
else {
// Trigger delayed shutdown
$this->serverShutdownTime = time() + $delay * 60.;
- $this->iControl->chat->sendInformation("The server will shut down in " . $delay . " minutes!", $login);
+ $this->mc->chat->sendInformation("The server will shut down in " . $delay . " minutes!", $login);
}
}
}
@@ -431,9 +431,9 @@ class Commands {
*/
private function command_kick($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('kick', 'operator'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('kick', 'operator'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
$params = explode(' ', $chat[1][2], 3);
@@ -442,7 +442,7 @@ class Commands {
return;
}
$target = $params[1];
- $players = $this->iControl->server->getPlayers();
+ $players = $this->mc->server->getPlayers();
foreach ($players as $player) {
if ($player['Login'] != $target) continue;
// Kick player
@@ -452,12 +452,12 @@ class Commands {
else {
$message = "";
}
- if (!$this->iControl->client->query('Kick', $target, $message)) {
- trigger_error("Couldn't kick player '" . $target . "'! " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('Kick', $target, $message)) {
+ trigger_error("Couldn't kick player '" . $target . "'! " . $this->mc->getClientErrorText());
}
return;
}
- $this->iControl->chat->sendError("Invalid player login.", $login);
+ $this->mc->chat->sendError("Invalid player login.", $login);
}
/**
@@ -465,26 +465,26 @@ class Commands {
*/
private function command_removemap($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('kick', 'operator'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('kick', 'operator'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
// TODO: allow params
// Get map name
- $map = $this->iControl->server->getMap();
+ $map = $this->mc->server->getMap();
if (!$map) {
- $this->iControl->chat->sendError("Couldn't remove map.", $login);
+ $this->mc->chat->sendError("Couldn't remove map.", $login);
}
else {
$mapName = $map['FileName'];
// Remove map
- if (!$this->iControl->client->query('RemoveMap', $mapName)) {
- trigger_error("Couldn't remove current map. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('RemoveMap', $mapName)) {
+ trigger_error("Couldn't remove current map. " . $this->mc->getClientErrorText());
}
else {
- $this->iControl->chat->sendSuccess('Map removed.', $login);
+ $this->mc->chat->sendSuccess('Map removed.', $login);
}
}
}
@@ -494,9 +494,9 @@ class Commands {
*/
private function command_addmap($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('addmap', 'operator'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('addmap', 'operator'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
$params = explode(' ', $chat[1][2], 2);
@@ -505,36 +505,36 @@ class Commands {
return;
}
// Check if ManiaControl can even write to the maps dir
- if (!$this->iControl->client->query('GetMapsDirectory')) {
- trigger_error("Couldn't get map directory. " . $this->iControl->getClientErrorText());
- $this->iControl->chat->sendError("ManiaControl couldn't retrieve the maps directory.", $login);
+ if (!$this->mc->client->query('GetMapsDirectory')) {
+ trigger_error("Couldn't get map directory. " . $this->mc->getClientErrorText());
+ $this->mc->chat->sendError("ManiaControl couldn't retrieve the maps directory.", $login);
return;
}
else {
- $mapDir = $this->iControl->client->getResponse();
+ $mapDir = $this->mc->client->getResponse();
if (!is_dir($mapDir)) {
trigger_error("ManiaControl doesn't have have access to the maps directory in '" . $mapDir . "'.");
- $this->iControl->chat->sendError("ManiaControl doesn't have access to the maps directory.", $login);
+ $this->mc->chat->sendError("ManiaControl doesn't have access to the maps directory.", $login);
return;
}
- $dlDir = (string) $this->iControl->config->maps_dir;
+ $dlDir = (string) $this->mc->config->maps_dir;
// Create mx directory if necessary
if (!is_dir($mapDir . $dlDir) && !mkdir($mapDir . $dlDir)) {
trigger_error("ManiaControl doesn't have to rights to save maps in'" . $mapDir . $dlDir, "'.");
- $this->iControl->chat->sendError("ManiaControl doesn't have to rights to save maps.", $login);
+ $this->mc->chat->sendError("ManiaControl doesn't have to rights to save maps.", $login);
return;
}
$mapDir .= $dlDir . '/';
// Download the map
if (is_numeric($params[1])) {
- $serverInfo = $this->iControl->server->getSystemInfo();
+ $serverInfo = $this->mc->server->getSystemInfo();
$title = strtolower(substr($serverInfo['TitleId'], 0, 2));
// Check if map exists
$url = 'http://' . $title . '.mania-exchange.com/api/tracks/get_track_info/id/' . $params[1] . '?format=json';
$mapInfo = Tools::loadFile($url);
if (!$mapInfo || strlen($mapInfo) <= 0) {
// Invalid id
- $this->iControl->chat->sendError('Invalid MX-Id!', $login);
+ $this->mc->chat->sendError('Invalid MX-Id!', $login);
return;
}
$mapInfo = json_decode($mapInfo, true);
@@ -542,34 +542,34 @@ class Commands {
$file = Tools::loadFile($url);
if (!$file) {
// Download error
- $this->iControl->chat->sendError('Download failed!', $login);
+ $this->mc->chat->sendError('Download failed!', $login);
return;
}
// Save map
$fileName = $mapDir . $mapInfo['TrackID'] . '_' . $mapInfo['Name'] . '.Map.Gbx';
if (!file_put_contents($fileName, $file)) {
// Save error
- $this->iControl->chat->sendError('Saving map failed!', $login);
+ $this->mc->chat->sendError('Saving map failed!', $login);
return;
}
// Check for valid map
- if (!$this->iControl->client->query('CheckMapForCurrentServerParams', $fileName)) {
- trigger_error("Couldn't check if map is valid. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('CheckMapForCurrentServerParams', $fileName)) {
+ trigger_error("Couldn't check if map is valid. " . $this->mc->getClientErrorText());
}
else {
- $response = $this->iControl->client->getResponse();
+ $response = $this->mc->client->getResponse();
if (!$response) {
// Inalid map type
- $this->iControl->chat->sendError("Invalid map type.", $login);
+ $this->mc->chat->sendError("Invalid map type.", $login);
return;
}
}
// Add map to map list
- if (!$this->iControl->client->query('InsertMap', $fileName)) {
- $this->iControl->chat->sendError("Couldn't add map to match settings!", $login);
+ if (!$this->mc->client->query('InsertMap', $fileName)) {
+ $this->mc->chat->sendError("Couldn't add map to match settings!", $login);
return;
}
- $this->iControl->chat->sendSuccess('Map $<' . $mapInfo['Name'] . '$> successfully added!');
+ $this->mc->chat->sendSuccess('Map $<' . $mapInfo['Name'] . '$> successfully added!');
}
else {
// TODO: check if map exists locally
@@ -583,13 +583,13 @@ class Commands {
*/
private function command_nextmap($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('nextmap', 'operator'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('nextmap', 'operator'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
- if (!$this->iControl->client->query('NextMap')) {
- trigger_error("Couldn't skip map. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('NextMap')) {
+ trigger_error("Couldn't skip map. " . $this->mc->getClientErrorText());
}
}
@@ -598,13 +598,13 @@ class Commands {
*/
private function command_restartmap($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('restartmap', 'operator'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('restartmap', 'operator'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
- if (!$this->iControl->client->query('RestartMap')) {
- trigger_error("Couldn't restart map. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('RestartMap')) {
+ trigger_error("Couldn't restart map. " . $this->mc->getClientErrorText());
}
}
@@ -613,13 +613,13 @@ class Commands {
*/
private function command_getservername($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('getservername', 'operator'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('getservername', 'operator'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
- $serverName = $this->iControl->server->getName();
- $this->iControl->chat->sendInformation("Server Name: " . $serverName, $login);
+ $serverName = $this->mc->server->getName();
+ $this->mc->chat->sendInformation("Server Name: " . $serverName, $login);
}
/**
@@ -627,9 +627,9 @@ class Commands {
*/
private function command_setservername($chat) {
$login = $chat[1][1];
- if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('setservername', 'admin'))) {
+ if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('setservername', 'admin'))) {
// Not allowed!
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
$params = explode(' ', $chat[1][2], 2);
@@ -638,13 +638,13 @@ class Commands {
return;
}
$serverName = $params[1];
- if (!$this->iControl->client->query('SetServerName', $serverName)) {
- trigger_error("Couldn't set server name. " . $this->iControl->getClientErrorText());
- $this->iControl->chat->sendError("Error!");
+ if (!$this->mc->client->query('SetServerName', $serverName)) {
+ trigger_error("Couldn't set server name. " . $this->mc->getClientErrorText());
+ $this->mc->chat->sendError("Error!");
}
else {
- $serverName = $this->iControl->server->getName();
- $this->iControl->chat->sendInformation("New Name: " . $serverName);
+ $serverName = $this->mc->server->getName();
+ $this->mc->chat->sendInformation("New Name: " . $serverName);
}
}
@@ -654,7 +654,7 @@ class Commands {
public function each5Seconds() {
// Empty shutdown
if ($this->serverShutdownEmpty) {
- $players = $this->iControl->server->getPlayers();
+ $players = $this->mc->server->getPlayers();
if (count($players) <= 0) {
$this->shutdownServer('empty');
}
@@ -672,12 +672,12 @@ class Commands {
* Perform server shutdown
*/
private function shutdownServer($login = '#') {
- $this->iControl->client->resetError();
- if (!$this->iControl->client->query('StopServer') || $this->iControl->client->isError()) {
- trigger_error("Server shutdown command from '" . $login . "' failed. " . $this->iControl->getClientErrorText());
+ $this->mc->client->resetError();
+ if (!$this->mc->client->query('StopServer') || $this->mc->client->isError()) {
+ trigger_error("Server shutdown command from '" . $login . "' failed. " . $this->mc->getClientErrorText());
return;
}
- $this->iControl->quit("Server shutdown requested by '" . $login . "'");
+ $this->mc->quit("Server shutdown requested by '" . $login . "'");
}
}
diff --git a/application/core/core.php b/application/core/core.php
index 8089d0ef..1b8598dc 100644
--- a/application/core/core.php
+++ b/application/core/core.php
@@ -13,6 +13,8 @@ require_once __DIR__ . '/database.php';
require_once __DIR__ . '/server.php';
require_once __DIR__ . '/stats.php';
require_once __DIR__ . '/tools.php';
+require_once __DIR__ . '/pluginHandler.php';
+require_once __DIR__ . '/manialinkIdHandler.php';
list($endiantest) = array_values(unpack('L1L', pack('V', 1)));
if ($endiantest == 1) {
require_once __DIR__ . '/PhpRemote/GbxRemote.inc.php';
@@ -164,7 +166,7 @@ class ManiaControl {
// Load plugins
//$this->loadPlugins();
- $this->pluginhandler->loadPlugins();
+ $this->pluginHandler->loadPlugins();
// Connect to server
$this->connect();
@@ -191,12 +193,12 @@ class ManiaControl {
$this->callbacks->handleCallbacks();
// Loop plugins
- foreach ($this->plugins as $plugin) {
+ /*foreach ($this->plugins as $plugin) {
if (!method_exists($plugin, 'loop')) {
continue;
}
$plugin->loop();
- }
+ }*/
// Yield for next tick
$loopEnd = microtime(true);
diff --git a/application/core/database.php b/application/core/database.php
index 57fe8865..5d0b95d8 100644
--- a/application/core/database.php
+++ b/application/core/database.php
@@ -22,7 +22,7 @@ class Database {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $config = null;
@@ -31,12 +31,12 @@ class Database {
/**
* Construct database connection
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('database.ManiaControl.xml');
- $this->mControl->checkConfig($this->config, array("host", "user"), 'database.ManiaControl.xml');
+ $this->mc->checkConfig($this->config, array("host", "user"), 'database.ManiaControl.xml');
// Get mysql server information
$host = $this->config->xpath('host');
@@ -73,8 +73,8 @@ class Database {
$this->initTables();
// Register for callbacks
- $this->mControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Second');
- $this->mControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMap');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Second');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMap');
}
/**
@@ -227,7 +227,7 @@ class Database {
*/
public function handle5Second($callback = null) {
// Save current players in database
- $players = $this->mControl->server->getPlayers();
+ $players = $this->mc->server->getPlayers();
if ($players) {
$query = "";
foreach ($players as $player) {
diff --git a/application/core/plugin.php b/application/core/plugin.php
index 8664ff04..12e664aa 100644
--- a/application/core/plugin.php
+++ b/application/core/plugin.php
@@ -19,13 +19,15 @@ namespace ManiaControl;
private $author;
private $updateUrl;
private $name;
+ private $description;
private $active;
- public function __construct($mc, $name, $version = 0, $author = '', $updateUrl = ''){
+ public function __construct($mc, $name, $version = 0, $author = '', $description = '', $updateUrl = ''){
$this->mc = $mc;
$this->name = $name;
$this->version = $version;
$this->author = $author;
+ $this->description = $description;
$this->updateUrl = $updateUrl;
$this->mc->pluginHandler->registerPlugin($this);
@@ -131,5 +133,22 @@ namespace ManiaControl;
{
return $this->name;
}
+
+ /**
+ * @param string $description
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
}
?>
\ No newline at end of file
diff --git a/application/core/pluginHandler.php b/application/core/pluginHandler.php
index 79635d43..955812b0 100644
--- a/application/core/pluginHandler.php
+++ b/application/core/pluginHandler.php
@@ -18,7 +18,7 @@ namespace ManiaControl;
private $plugins;
public function __construct($mc){
- $this->mControl = $mc;
+ $this->mc = $mc;
$this->plugins = array();
}
diff --git a/application/core/server.php b/application/core/server.php
index 3018bd0e..ff918498 100644
--- a/application/core/server.php
+++ b/application/core/server.php
@@ -22,20 +22,20 @@ class Server {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
/**
* Construct server
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('server.ManiaControl.xml');
- $this->iControl->checkConfig($this->config, array('host', 'port', 'login', 'pass'), 'server');
+ $this->mc->checkConfig($this->config, array('host', 'port', 'login', 'pass'), 'server');
// Register for callbacks
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_SECOND, $this, 'eachSecond');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_SECOND, $this, 'eachSecond');
}
/**
@@ -52,11 +52,11 @@ class Server {
* @return string
*/
public function getDataDirectory() {
- if (!$this->iControl->client->query('GameDataDirectory')) {
- trigger_error("Couldn't get data directory. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('GameDataDirectory')) {
+ trigger_error("Couldn't get data directory. " . $this->mc->getClientErrorText());
return null;
}
- return $this->iControl->client->getResponse();
+ return $this->mc->client->getResponse();
}
/**
@@ -87,54 +87,54 @@ class Server {
public function getInfo($detailed = false) {
if ($detailed) {
$login = $this->getLogin();
- if (!$this->iControl->client->query('GetDetailedPlayerInfo', $login)) {
- trigger_error("Couldn't fetch detailed server player info. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('GetDetailedPlayerInfo', $login)) {
+ trigger_error("Couldn't fetch detailed server player info. " . $this->mc->getClientErrorText());
return null;
}
}
else {
- if (!$this->iControl->client->query('GetMainServerPlayerInfo')) {
- trigger_error("Couldn't fetch server player info. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('GetMainServerPlayerInfo')) {
+ trigger_error("Couldn't fetch server player info. " . $this->mc->getClientErrorText());
return null;
}
}
- return $this->iControl->client->getResponse();
+ return $this->mc->client->getResponse();
}
/**
* Get server options
*/
public function getOptions() {
- if (!$this->iControl->client->query('GetServerOptions')) {
- trigger_error("Couldn't fetch server options. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('GetServerOptions')) {
+ trigger_error("Couldn't fetch server options. " . $this->mc->getClientErrorText());
return null;
}
- return $this->iControl->client->getResponse();
+ return $this->mc->client->getResponse();
}
/**
* Fetch server name
*/
public function getName() {
- if (!$this->iControl->client->query('GetServerName')) {
- trigger_error("Couldn't fetch server name. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('GetServerName')) {
+ trigger_error("Couldn't fetch server name. " . $this->mc->getClientErrorText());
return null;
}
- return $this->iControl->client->getResponse();
+ return $this->mc->client->getResponse();
}
/**
* Fetch server version
*/
public function getVersion($forceRefresh = false) {
- if (isset($this->iControl->client->version) && !$forceRefresh) return $this->iControl->client->version;
- if (!$this->iControl->client->query('GetVersion')) {
- trigger_error("Couldn't fetch server version. " . $this->iControl->getClientErrorText());
+ if (isset($this->mc->client->version) && !$forceRefresh) return $this->mc->client->version;
+ if (!$this->mc->client->query('GetVersion')) {
+ trigger_error("Couldn't fetch server version. " . $this->mc->getClientErrorText());
return null;
}
else {
- $this->iControl->client->version = $this->iControl->client->getResponse();
- return $this->iControl->client->version;
+ $this->mc->client->version = $this->mc->client->getResponse();
+ return $this->mc->client->version;
}
}
@@ -142,11 +142,11 @@ class Server {
* Fetch server system info
*/
public function getSystemInfo($forceRefresh = false, &$client = null) {
- if (!$this->iControl->client && !$client) return null;
- if (!$client) $client = $this->iControl->client;
+ if (!$this->mc->client && !$client) return null;
+ if (!$client) $client = $this->mc->client;
if (isset($client->systemInfo) && !$forceRefresh) return $client->systemInfo;
if (!$client->query('GetSystemInfo')) {
- trigger_error("Couldn't fetch server system info. " . $this->iControl->getClientErrorText($client));
+ trigger_error("Couldn't fetch server system info. " . $this->mc->getClientErrorText($client));
return null;
}
else {
@@ -159,14 +159,14 @@ class Server {
* Fetch network status
*/
public function getNetworkStats($forceRefresh = false) {
- if (isset($this->iControl->client->networkStats) && !$forceRefresh) return $this->iControl->client->networkStats;
- if (!$this->iControl->client->query('GetNetworkStats')) {
- trigger_error("Couldn't fetch network stats. " . $this->iControl->getClientErrorText());
+ if (isset($this->mc->client->networkStats) && !$forceRefresh) return $this->mc->client->networkStats;
+ if (!$this->mc->client->query('GetNetworkStats')) {
+ trigger_error("Couldn't fetch network stats. " . $this->mc->getClientErrorText());
return null;
}
else {
- $this->iControl->client->networkStats = $this->iControl->client->getResponse();
- return $this->iControl->client->networkStats;
+ $this->mc->client->networkStats = $this->mc->client->getResponse();
+ return $this->mc->client->networkStats;
}
}
@@ -182,11 +182,11 @@ class Server {
$gameMode = $parseValue;
}
else {
- if (!$this->iControl->client->query('GetGameMode')) {
- trigger_error("Couldn't fetch current game mode. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('GetGameMode')) {
+ trigger_error("Couldn't fetch current game mode. " . $this->mc->getClientErrorText());
return null;
}
- $gameMode = $this->iControl->client->getResponse();
+ $gameMode = $this->mc->client->getResponse();
}
if ($stringValue) {
switch ($gameMode) {
@@ -236,19 +236,19 @@ class Server {
public function getPlayer($login, $detailed = false) {
if (!$login) return null;
$command = ($detailed ? 'GetDetailedPlayerInfo' : 'GetPlayerInfo');
- if (!$this->iControl->client->query($command, $login)) {
- trigger_error("Couldn't player info for '" . $login . "'. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query($command, $login)) {
+ trigger_error("Couldn't player info for '" . $login . "'. " . $this->mc->getClientErrorText());
return null;
}
- return $this->iControl->client->getResponse();
+ return $this->mc->client->getResponse();
}
/**
* Fetch all players
*/
public function getPlayers(&$client = null, &$purePlayers = null, &$pureSpectators = null) {
- if (!$this->iControl->client && !$client) return null;
- if (!$client) $client = $this->iControl->client;
+ if (!$this->mc->client && !$client) return null;
+ if (!$client) $client = $this->mc->client;
$fetchLength = 30;
$offset = 0;
$players = array();
@@ -257,7 +257,7 @@ class Server {
$tries = 0;
while ($tries < 10) {
if (!$client->query('GetPlayerList', $fetchLength, $offset)) {
- trigger_error("Couldn't get player list. " . $this->iControl->getClientErrorText($client));
+ trigger_error("Couldn't get player list. " . $this->mc->getClientErrorText($client));
$tries++;
}
else {
@@ -297,11 +297,11 @@ class Server {
*/
public function getValidationReplay($login) {
if (!$login) return null;
- if (!$this->iControl->client->query('GetValidationReplay', $login)) {
- trigger_error("Couldn't get validation replay of '" . $login . "'. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('GetValidationReplay', $login)) {
+ trigger_error("Couldn't get validation replay of '" . $login . "'. " . $this->mc->getClientErrorText());
return null;
}
- return $this->iControl->client->getResponse();
+ return $this->mc->client->getResponse();
}
public function getGhostReplay($login) {
@@ -317,8 +317,8 @@ class Server {
$fileName = 'Ghost.' . $login . '.' . $gameMode . '.' . $time . '.' . $map['UId'] . '.Replay.Gbx';
// Save ghost replay
- if (!$this->iControl->client->query('SaveBestGhostsReplay', $login, self::GHOSTREPLAYDIR . $fileName)) {
- trigger_error("Couldn't save ghost replay. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('SaveBestGhostsReplay', $login, self::GHOSTREPLAYDIR . $fileName)) {
+ trigger_error("Couldn't save ghost replay. " . $this->mc->getClientErrorText());
return null;
}
@@ -335,12 +335,12 @@ class Server {
* Fetch current map
*/
public function getMap() {
- if (!$this->iControl->client) return null;
- if (!$this->iControl->client->query('GetCurrentMapInfo')) {
- trigger_error("Couldn't fetch map info. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client) return null;
+ if (!$this->mc->client->query('GetCurrentMapInfo')) {
+ trigger_error("Couldn't fetch map info. " . $this->mc->getClientErrorText());
return null;
}
- return $this->iControl->client->getResponse();
+ return $this->mc->client->getResponse();
}
/**
@@ -353,7 +353,7 @@ class Server {
if ($response['Code'] === 4) return true;
// Server not yet in given status -> Wait for it...
$waitBegin = time();
- $timeoutTags = $this->iControl->config->xpath('timeout');
+ $timeoutTags = $this->mc->config->xpath('timeout');
$maxWaitTime = (!empty($timeoutTags) ? (int) $timeoutTags[0] : 20);
$lastStatus = $response['Name'];
error_log("Waiting for server to reach status " . $statusCode . "...");
@@ -370,7 +370,7 @@ class Server {
// It took too long to reach the status
trigger_error(
"Server couldn't reach status " . $statusCode . " after " . $maxWaitTime . " seconds! " .
- $this->iControl->getClientErrorText());
+ $this->mc->getClientErrorText());
return false;
}
}
diff --git a/application/core/stats.php b/application/core/stats.php
index 8a5e7c52..d2acf0ad 100644
--- a/application/core/stats.php
+++ b/application/core/stats.php
@@ -17,15 +17,15 @@ class Stats {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $config = null;
/**
* Constuct stats manager
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('stats.ManiaControl.xml');
@@ -35,11 +35,11 @@ class Stats {
$this->initTables();
// Register for needed callbacks
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_ENDMAP, $this, 'handleEndMap');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_ENDMAP, $this, 'handleEndMap');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish');
}
/**
@@ -78,7 +78,7 @@ class Stats {
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Tracks player stats' AUTO_INCREMENT=1;";
// Perform queries
- if (!$this->iControl->database->multiQuery($query)) {
+ if (!$this->mc->database->multiQuery($query)) {
trigger_error("Creating stats tables failed.");
}
}
@@ -120,7 +120,7 @@ class Stats {
}
// Perform query
- if (!$this->iControl->database->multiQuery($multiquery)) {
+ if (!$this->mc->database->multiQuery($multiquery)) {
trigger_error("Perform queries on end map failed.");
}
}
@@ -139,7 +139,7 @@ class Stats {
`Login`,
`chatCount`
) VALUES (
- '" . $this->iControl->database->escape($login) . "',
+ '" . $this->mc->database->escape($login) . "',
1
) ON DUPLICATE KEY UPDATE
`chatCount` = `chatCount` + VALUES(`chatCount`)
@@ -147,7 +147,7 @@ class Stats {
}
// Perform query
- if (!$this->iControl->database->multiQuery($multiquery)) {
+ if (!$this->mc->database->multiQuery($multiquery)) {
trigger_error("Perform queries on player chat failed.");
}
}
@@ -174,7 +174,7 @@ class Stats {
// Track server max players
if ($this->settings->track_server_max_players) {
- $players = $this->iControl->server->getPlayers();
+ $players = $this->mc->server->getPlayers();
$multiquery .= "INSERT INTO `" . self::TABLE_STATS_SERVER . "` (
`day`,
`maxPlayerCount`
@@ -193,7 +193,7 @@ class Stats {
`lastJoin`,
`connectCount`
) VALUES (
- '" . $this->iControl->database->escape($login) . "',
+ '" . $this->mc->database->escape($login) . "',
NOW(),
1
) ON DUPLICATE KEY UPDATE
@@ -203,7 +203,7 @@ class Stats {
}
// Perform query
- if (!$this->iControl->database->multiQuery($multiquery)) {
+ if (!$this->mc->database->multiQuery($multiquery)) {
trigger_error("Perform queries on player connect failed.");
}
}
@@ -218,9 +218,9 @@ class Stats {
// Track player playtime
if ($this->settings->track_player_playtime) {
$query = "SELECT `lastJoin` FROM `" . self::TABLE_STATS_PLAYERS . "`
- WHERE `Login` = '" . $this->iControl->database->escape($login) . "'
+ WHERE `Login` = '" . $this->mc->database->escape($login) . "'
;";
- $result = $this->iControl->database->query($query);
+ $result = $this->mc->database->query($query);
if (!$result) {
// Error
trigger_error("Error selecting player join time from '" . $login . "'.");
@@ -230,12 +230,12 @@ class Stats {
while ($row = $result->fetch_object()) {
if (!property_exists($row, 'lastJoin')) continue;
$lastJoin = strtotime($row->lastJoin);
- $lastJoin = ($lastJoin > $this->iControl->startTime ? $lastJoin : $this->iControl->startTime);
+ $lastJoin = ($lastJoin > $this->mc->startTime ? $lastJoin : $this->mc->startTime);
$multiquery .= "INSERT INTO `" . self::TABLE_STATS_PLAYERS . "` (
`Login`,
`playTime`
) VALUES (
- '" . $this->iControl->database->escape($login) . "',
+ '" . $this->mc->database->escape($login) . "',
TIMESTAMPDIFF(SECOND, '" . Tools::timeToTimestamp($lastJoin) . "', NOW())
) ON DUPLICATE KEY UPDATE
`playTime` = `playTime` + VALUES(`playTime`)
@@ -246,7 +246,7 @@ class Stats {
}
// Perform query
- if (!$this->iControl->database->multiQuery($multiquery)) {
+ if (!$this->mc->database->multiQuery($multiquery)) {
trigger_error("Perform queries on player connect failed.");
}
}
@@ -280,7 +280,7 @@ class Stats {
`Login`,
`finishCount`
) VALUES (
- '" . $this->iControl->database->escape($login) . "',
+ '" . $this->mc->database->escape($login) . "',
1
) ON DUPLICATE KEY UPDATE
`finishCount` = `finishCount` + VALUES(`finishCount`)
@@ -288,7 +288,7 @@ class Stats {
}
// Perform query
- if (!$this->iControl->database->multiQuery($multiquery)) {
+ if (!$this->mc->database->multiQuery($multiquery)) {
trigger_error("Perform queries on player finish failed.");
}
}
diff --git a/application/plugins/oldstructure/chatlog.plugin.php b/application/plugins/oldstructure/chatlog.plugin.php
index 8b77449b..61e60bb1 100644
--- a/application/plugins/oldstructure/chatlog.plugin.php
+++ b/application/plugins/oldstructure/chatlog.plugin.php
@@ -16,7 +16,7 @@ class Plugin_Chatlog extends Plugin{
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $config = null;
@@ -25,8 +25,8 @@ class Plugin_Chatlog extends Plugin{
/**
* Constuct chatlog plugin
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('chatlog.plugin.xml');
@@ -38,7 +38,7 @@ class Plugin_Chatlog extends Plugin{
$this->loadSettings();
// Register for callbacksc
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handlePlayerChatCallback');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handlePlayerChatCallback');
error_log('Chatlog Pugin v' . self::VERSION . ' ready!');
}
diff --git a/application/plugins/oldstructure/karma.plugin.php b/application/plugins/oldstructure/karma.plugin.php
index 26b5cf91..f5b89cd7 100644
--- a/application/plugins/oldstructure/karma.plugin.php
+++ b/application/plugins/oldstructure/karma.plugin.php
@@ -18,7 +18,7 @@ class Plugin_Karma {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $config = null;
@@ -27,10 +27,10 @@ class Plugin_Karma {
/**
* Construct plugin
*
- * @param object $mControl
+ * @param object $mc
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('karma.plugin.xml');
@@ -40,10 +40,10 @@ class Plugin_Karma {
$this->initDatabase();
// Register for callbacks
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMapCallback');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnectCallback');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMapCallback');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnectCallback');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
'handleManialinkPageAnswerCallback');
error_log('Karma Pugin v' . self::VERSION . ' ready!');
@@ -57,7 +57,7 @@ class Plugin_Karma {
$this->sendManialinkRequested = -1;
// Send manialink to all players
- $players = $this->iControl->server->getPlayers();
+ $players = $this->mc->server->getPlayers();
foreach ($players as $player) {
$login = $player['Login'];
$manialink = $this->buildManialink($login);
@@ -66,7 +66,7 @@ class Plugin_Karma {
$this->sendManialinkRequested = time() + 5;
continue;
}
- Tools::sendManialinkPage($this->iControl->client, $manialink->asXml(), $login);
+ Tools::sendManialinkPage($this->mc->client, $manialink->asXml(), $login);
}
}
}
@@ -100,7 +100,7 @@ class Plugin_Karma {
$login = $callback[1][0];
$manialink = $this->buildManialink($login);
if (!$manialink) return;
- Tools::sendManialinkPage($this->iControl->client, $manialink->asXml(), $login);
+ Tools::sendManialinkPage($this->mc->client, $manialink->asXml(), $login);
}
/**
@@ -116,9 +116,9 @@ class Plugin_Karma {
PRIMARY KEY (`index`),
UNIQUE KEY `player_map_vote` (`mapIndex`, `playerIndex`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Save players map votes' AUTO_INCREMENT=1;";
- $result = $this->iControl->database->query($query);
- if ($this->iControl->database->mysqli->error) {
- trigger_error('MySQL Error on creating karma table. ' . $this->iControl->database->mysqli->error, E_USER_ERROR);
+ $result = $this->mc->database->query($query);
+ if ($this->mc->database->mysqli->error) {
+ trigger_error('MySQL Error on creating karma table. ' . $this->mc->database->mysqli->error, E_USER_ERROR);
}
}
@@ -158,9 +158,9 @@ class Plugin_Karma {
// Save vote
$login = $callback[1][1];
- $playerIndex = $this->iControl->database->getPlayerIndex($login);
- $map = $this->iControl->server->getMap();
- $mapIndex = $this->iControl->database->getMapIndex($map['UId']);
+ $playerIndex = $this->mc->database->getPlayerIndex($login);
+ $map = $this->mc->server->getMap();
+ $mapIndex = $this->mc->database->getMapIndex($map['UId']);
$query = "INSERT INTO `" . self::TABLE_KARMA . "` (
`mapIndex`,
`playerIndex`,
@@ -171,11 +171,11 @@ class Plugin_Karma {
" . $vote . "
) ON DUPLICATE KEY UPDATE
`vote` = VALUES(`vote`);";
- $result = $this->iControl->database->query($query);
+ $result = $this->mc->database->query($query);
if (!$result) return;
// Send success message
- $this->iControl->chat->sendSuccess('Vote successfully updated!', $login);
+ $this->mc->chat->sendSuccess('Vote successfully updated!', $login);
// Send updated manialink
$this->sendManialinkRequested = time() + 1;
@@ -190,14 +190,14 @@ class Plugin_Karma {
$pos_x = (float) $this->config->pos_x;
$pos_y = (float) $this->config->pos_y;
- $mysqli = $this->iControl->database->mysqli;
+ $mysqli = $this->mc->database->mysqli;
// Get indezes
- $playerIndex = $this->iControl->database->getPlayerIndex($login);
+ $playerIndex = $this->mc->database->getPlayerIndex($login);
if ($playerIndex === null) return null;
- $map = $this->iControl->server->getMap();
+ $map = $this->mc->server->getMap();
if (!$map) return null;
- $mapIndex = $this->iControl->database->getMapIndex($map['UId']);
+ $mapIndex = $this->mc->database->getMapIndex($map['UId']);
if ($mapIndex === null) return null;
// Get votings
diff --git a/application/plugins/oldstructure/obstacle.plugin.php b/application/plugins/oldstructure/obstacle.plugin.php
index 0084b486..b52c6859 100644
--- a/application/plugins/oldstructure/obstacle.plugin.php
+++ b/application/plugins/oldstructure/obstacle.plugin.php
@@ -17,15 +17,15 @@ class Plugin_Obstacle extends Plugin {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $config = null;
/**
* Constuct obstacle plugin
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('obstacle.plugin.xml');
@@ -34,7 +34,7 @@ class Plugin_Obstacle extends Plugin {
if (!Tools::toBool($this->config->enabled)) return;
// Register for jump command
- $this->iControl->commands->registerCommandHandler('jumpto', $this, 'command_jumpto');
+ $this->mc->commands->registerCommandHandler('jumpto', $this, 'command_jumpto');
error_log('Obstacle Pugin v' . self::VERSION . ' ready!');
}
@@ -45,16 +45,16 @@ class Plugin_Obstacle extends Plugin {
public function command_jumpto($chat) {
$login = $chat[1][1];
$rightLevel = (string) $this->config->jumps_rightlevel;
- if (!$this->iControl->authentication->checkRight($login, $rightLevel)) {
+ if (!$this->mc->authentication->checkRight($login, $rightLevel)) {
// Not allowed
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
}
else {
// Send jump callback
$params = explode(' ', $chat[1][2], 2);
$param = $login . ";" . $params[1] . ";";
- if (!$this->iControl->client->query('TriggerModeScriptEvent', self::CB_JUMPTO, $param)) {
- trigger_error("Couldn't send jump callback for '" . $login . "'. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('TriggerModeScriptEvent', self::CB_JUMPTO, $param)) {
+ trigger_error("Couldn't send jump callback for '" . $login . "'. " . $this->mc->getClientErrorText());
}
}
}
diff --git a/application/plugins/oldstructure/plugin.ManiaControl.php b/application/plugins/oldstructure/plugin.ManiaControl.php
index a51d9066..5ea3a62b 100644
--- a/application/plugins/oldstructure/plugin.ManiaControl.php
+++ b/application/plugins/oldstructure/plugin.ManiaControl.php
@@ -14,15 +14,15 @@ abstract class Plugin_Name {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
/**
* Construct plugin
*
- * @param object $mControl
+ * @param object $mc
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
error_log('Pugin v' . self::VERSION . ' ready!');
}
diff --git a/application/plugins/oldstructure/records.plugin.php b/application/plugins/oldstructure/records.plugin.php
index 71dbbefd..40e2b3c7 100644
--- a/application/plugins/oldstructure/records.plugin.php
+++ b/application/plugins/oldstructure/records.plugin.php
@@ -37,7 +37,7 @@ class Plugin_Records {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $settings = null;
@@ -58,8 +58,8 @@ class Plugin_Records {
/**
* Constuct plugin
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('records.plugin.xml');
@@ -74,17 +74,17 @@ class Plugin_Records {
$this->initTables();
// Register for callbacks
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInit');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_SECOND, $this, 'handle1Second');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_MINUTE, $this, 'handle1Minute');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_3_MINUTE, $this, 'handle3Minute');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleMapBegin');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_CLIENTUPDATED, $this, 'handleClientUpdated');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ENDMAP, $this, 'handleMapEnd');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERCHECKPOINT, $this, 'handlePlayerCheckpoint');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInit');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_SECOND, $this, 'handle1Second');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_MINUTE, $this, 'handle1Minute');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_3_MINUTE, $this, 'handle3Minute');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleMapBegin');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_CLIENTUPDATED, $this, 'handleClientUpdated');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ENDMAP, $this, 'handleMapEnd');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERCHECKPOINT, $this, 'handlePlayerCheckpoint');
error_log('Records Pugin v' . self::VERSION . ' ready!');
}
@@ -93,7 +93,7 @@ class Plugin_Records {
* Init needed database tables
*/
private function initTables() {
- $database = $this->iControl->database;
+ $database = $this->mc->database;
// Records table
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_RECORDS . "` (
@@ -227,7 +227,7 @@ class Plugin_Records {
if ($init || !array_key_exists('serverData', $this->dedimaniaData) || !is_array($this->dedimaniaData['serverData'])) {
$serverData = array();
$serverData['Game'] = 'TM2';
- $serverInfo = $this->iControl->server->getInfo(true);
+ $serverInfo = $this->mc->server->getInfo(true);
// Get dedimania account data
$accounts = $this->config->xpath('dedimania_records/account');
@@ -250,9 +250,9 @@ class Plugin_Records {
// Complete seesion data
$serverData['Path'] = $serverInfo['Path'];
- $systemInfo = $this->iControl->server->getSystemInfo();
+ $systemInfo = $this->mc->server->getSystemInfo();
$serverData['Packmask'] = substr($systemInfo['TitleId'], 2);
- $serverVersion = $this->iControl->server->getVersion();
+ $serverVersion = $this->mc->server->getVersion();
$serverData['ServerVersion'] = $serverVersion['Version'];
$serverData['ServerBuild'] = $serverVersion['Build'];
$serverData['Tool'] = 'ManiaControl';
@@ -352,7 +352,7 @@ class Plugin_Records {
if ($this->settings->local_records_enabled) $this->sendManialink($this->manialinks[self::MLID_LOCAL], $login);
if ($this->settings->dedimania_enabled && $this->dedimaniaData['context']) {
- $player = $this->iControl->server->getPlayer($login, true);
+ $player = $this->mc->server->getPlayer($login, true);
if ($player) {
// Send dedimania request
$data = array($this->dedimaniaData['sessionId'], $player['Login'], $player['NickName'], $player['Path'],
@@ -435,7 +435,7 @@ class Plugin_Records {
* Build map info struct for dedimania requests
*/
private function getMapInfo() {
- $map = $this->iControl->server->getMap();
+ $map = $this->mc->server->getMap();
if (!$map) return null;
$mapInfo = array();
$mapInfo['UId'] = $map['UId'];
@@ -528,12 +528,12 @@ class Plugin_Records {
* Build server info struct for callbacks
*/
private function getSrvInfo() {
- $server = $this->iControl->server->getOptions();
+ $server = $this->mc->server->getOptions();
if (!$server) return null;
$client = null;
$players = null;
$spectators = null;
- $this->iControl->server->getPlayers($client, $players, $spectators);
+ $this->mc->server->getPlayers($client, $players, $spectators);
if (!is_array($players) || !is_array($spectators)) return null;
return array('SrvName' => $server['Name'], 'Comment' => $server['Comment'], 'Private' => (strlen($server['Password']) > 0),
'NumPlayers' => count($players), 'MaxPlayers' => $server['CurrentMaxPlayers'], 'NumSpecs' => count($spectators),
@@ -547,7 +547,7 @@ class Plugin_Records {
$client = null;
$players;
$spectators;
- $allPlayers = $this->iControl->server->getPlayers($client, $players, $spectators);
+ $allPlayers = $this->mc->server->getPlayers($client, $players, $spectators);
if (!is_array($players) || !is_array($spectators)) return null;
$playerInfo = array();
foreach ($allPlayers as $player) {
@@ -560,9 +560,9 @@ class Plugin_Records {
* Get dedi string representation of the current game mode
*/
private function getGameModeString() {
- $gameMode = $this->iControl->server->getGameMode();
+ $gameMode = $this->mc->server->getGameMode();
if ($gameMode === null) {
- trigger_error("Couldn't retrieve game mode. " . $this->iControl->getClientErrorText());
+ trigger_error("Couldn't retrieve game mode. " . $this->mc->getClientErrorText());
return null;
}
switch ($gameMode) {
@@ -585,7 +585,7 @@ class Plugin_Records {
* Build votes info struct for callbacks
*/
private function getVotesInfo() {
- $map = $this->iControl->server->getMap();
+ $map = $this->mc->server->getMap();
if (!$map) return null;
$gameMode = $this->getGameModeString();
if (!$gameMode) return null;
@@ -646,14 +646,14 @@ class Plugin_Records {
$login = $data[1];
$time = $data[2];
- $newMap = $this->iControl->server->getMap();
+ $newMap = $this->mc->server->getMap();
if (!$newMap) return;
if (!$this->mapInfo || $this->mapInfo['UId'] !== $newMap['UId']) {
$this->mapInfo = $this->getMapInfo();
}
$map = $newMap;
- $player = $this->iControl->server->getPlayer($login);
+ $player = $this->mc->server->getPlayer($login);
if ($this->settings->local_records_enabled) {
// Get old record of the player
@@ -668,13 +668,13 @@ class Plugin_Records {
// Same time
$message = '$<' . $player['NickName'] . '$> equalized her/his $<$o' . $oldRecord['rank'] . '.$> Local Record: ' .
Tools::formatTime($oldRecord['time']);
- $this->iControl->chat->sendInformation($message);
+ $this->mc->chat->sendInformation($message);
$save = false;
}
}
if ($save) {
// Save time
- $database = $this->iControl->database;
+ $database = $this->mc->database;
$query = "INSERT INTO `" . self::TABLE_RECORDS . "` (
`mapUId`,
`Login`,
@@ -701,7 +701,7 @@ class Plugin_Records {
}
$message = '$<' . $player['NickName'] . '$> ' . $improvement . ' $<$o' . $newRecord['rank'] . '.$> Local Record: ' .
Tools::formatTime($newRecord['time']);
- $this->iControl->chat->sendInformation($message);
+ $this->mc->chat->sendInformation($message);
$this->updateManialinks[self::MLID_LOCAL] = true;
}
}
@@ -745,7 +745,7 @@ class Plugin_Records {
}
$message = '$<' . $player['NickName'] . '$> ' . $improvement . ' $<$o' . $newRecord['Rank'] .
'.$> Dedimania Record: ' . Tools::formatTime($newRecord['Best']);
- $this->iControl->chat->sendInformation($message);
+ $this->mc->chat->sendInformation($message);
$this->updateManialinks[self::MLID_DEDI] = true;
}
}
@@ -859,21 +859,21 @@ class Plugin_Records {
if (!$record || !$this->settings->dedimania_enabled) return;
// Set validation replay
- $validationReplay = $this->iControl->server->getValidationReplay($record['Login']);
+ $validationReplay = $this->mc->server->getValidationReplay($record['Login']);
if ($validationReplay) $record['VReplay'] = $validationReplay;
// Set ghost replay
if ($record['Rank'] <= 1) {
- $dataDirectory = $this->iControl->server->getDataDirectory();
+ $dataDirectory = $this->mc->server->getDataDirectory();
if (!isset($this->dedimaniaData['directoryAccessChecked'])) {
- $access = $this->iControl->server->checkAccess($dataDirectory);
+ $access = $this->mc->server->checkAccess($dataDirectory);
if (!$access) {
trigger_error("No access to the servers data directory. Can't retrieve ghost replays.");
}
$this->dedimaniaData['directoryAccessChecked'] = $access;
}
if ($this->dedimaniaData['directoryAccessChecked']) {
- $ghostReplay = $this->iControl->server->getGhostReplay($record['Login']);
+ $ghostReplay = $this->mc->server->getGhostReplay($record['Login']);
if ($ghostReplay) $record['Top1GReplay'] = $ghostReplay;
}
}
@@ -939,15 +939,15 @@ class Plugin_Records {
* Send manialink to clients
*/
private function sendManialink($manialink, $login = null) {
- if (!$manialink || !$this->iControl->client) return;
+ if (!$manialink || !$this->mc->client) return;
if (!$login) {
- if (!$this->iControl->client->query('SendDisplayManialinkPage', $manialink->asXML(), 0, false)) {
- trigger_error("Couldn't send manialink to players. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('SendDisplayManialinkPage', $manialink->asXML(), 0, false)) {
+ trigger_error("Couldn't send manialink to players. " . $this->mc->getClientErrorText());
}
}
else {
- if (!$this->iControl->client->query('SendDisplayManialinkPageToLogin', $login, $manialink->asXML(), 0, false)) {
- trigger_error("Couldn't send manialink to player '" . $login . "'. " . $this->iControl->getClientErrorText());
+ if (!$this->mc->client->query('SendDisplayManialinkPageToLogin', $login, $manialink->asXML(), 0, false)) {
+ trigger_error("Couldn't send manialink to player '" . $login . "'. " . $this->mc->getClientErrorText());
}
}
}
@@ -967,7 +967,7 @@ class Plugin_Records {
* Update local records manialink
*/
private function buildLocalManialink() {
- $map = $this->iControl->server->getMap();
+ $map = $this->mc->server->getMap();
if (!$map) {
return null;
}
@@ -1146,12 +1146,12 @@ class Plugin_Records {
private function getLocalRecords($mapUId, $limit = -1) {
$query = "SELECT * FROM (
SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra
- WHERE recs.`mapUId` = '" . $this->iControl->database->escape($mapUId) . "'
+ WHERE recs.`mapUId` = '" . $this->mc->database->escape($mapUId) . "'
ORDER BY recs.`time` ASC
" . ($limit > 0 ? "LIMIT " . $limit : "") . ") records
LEFT JOIN `" . Database::TABLE_PLAYERS . "` players
ON records.`Login` = players.`Login`;";
- return $this->iControl->database->query($query);
+ return $this->mc->database->query($query);
}
/**
@@ -1163,7 +1163,7 @@ class Plugin_Records {
*/
private function getLocalRecord($mapUId, $login) {
if (!$mapUId || !$login) return null;
- $database = $this->iControl->database;
+ $database = $this->mc->database;
$query = "SELECT records.* FROM (
SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` `recs`, (SELECT @rank := 0) r
WHERE recs.`mapUid` = '" . $database->escape($mapUId) . "'
diff --git a/application/plugins/oldstructure/united.plugin.php b/application/plugins/oldstructure/united.plugin.php
index f4cdb774..8ec3c2ed 100644
--- a/application/plugins/oldstructure/united.plugin.php
+++ b/application/plugins/oldstructure/united.plugin.php
@@ -23,7 +23,7 @@ class Plugin_United {
/**
* Private properties
*/
- private $mControl = null;
+ private $mc = null;
private $config = null;
@@ -46,8 +46,8 @@ class Plugin_United {
/**
* Constuct plugin
*/
- public function __construct($mControl) {
- $this->mControl = $mControl;
+ public function __construct($mc) {
+ $this->mc = $mc;
// Load config
$this->config = Tools::loadConfig('united.plugin.xml');
@@ -60,14 +60,14 @@ class Plugin_United {
$this->loadClients();
// Register for callbacks
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Seconds');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
- $this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Seconds');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
+ $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
'handleManialinkPageAnswer');
// Register for commands
- $this->iControl->commands->registerCommandHandler('nextserver', $this, 'handleNextServerCommand');
+ $this->mc->commands->registerCommandHandler('nextserver', $this, 'handleNextServerCommand');
if ($this->settings->widgets_enabled) {
// Build addfavorite manialink
@@ -88,9 +88,9 @@ class Plugin_United {
if (Tools::toBool($this->config->widgets->addfavorite->enabled)) {
// Send favorite widget
- if (!$this->iControl->client->query('SendDisplayManialinkPage', $this->manialinks[self::ML_ADDFAVORITE]->asXml(), 0,
+ if (!$this->mc->client->query('SendDisplayManialinkPage', $this->manialinks[self::ML_ADDFAVORITE]->asXml(), 0,
false)) {
- trigger_error("Couldn't send favorite widget! " . $this->iControl->getClientErrorText());
+ trigger_error("Couldn't send favorite widget! " . $this->mc->getClientErrorText());
}
}
}
@@ -106,7 +106,7 @@ class Plugin_United {
$this->settings->enabled = Tools::toBool($this->config->enabled);
// Timeout
- $timeout = $this->iControl->server->config->xpath('timeout');
+ $timeout = $this->mc->server->config->xpath('timeout');
if ($timeout) {
$this->settings->timeout = (int) $timeout[0];
}
@@ -169,7 +169,7 @@ class Plugin_United {
$client->readCB();
$callbacks = $client->getCBResponses();
if (!is_array($callbacks) || $client->isError()) {
- trigger_error("Error reading server callbacks! " . $this->iControl->getClientErrorText($client));
+ trigger_error("Error reading server callbacks! " . $this->mc->getClientErrorText($client));
}
else {
if ($client == $currentServer) {
@@ -189,7 +189,7 @@ class Plugin_United {
$this->lastStatusCheck = time();
if (!$client->query('CheckEndMatchCondition')) {
- trigger_error("Couldn't get game server status. " . $this->iControl->getClientErrorText($client));
+ trigger_error("Couldn't get game server status. " . $this->mc->getClientErrorText($client));
}
else {
$response = $client->getResponse();
@@ -241,7 +241,7 @@ class Plugin_United {
*/
public function handle5Seconds($callback = null) {
// Update lobby infos
- $players = $this->iControl->server->getPlayers();
+ $players = $this->mc->server->getPlayers();
if (is_array($players)) {
$playerCount = count($players);
$playerLevel = 0.;
@@ -253,7 +253,7 @@ class Plugin_United {
}
foreach ($this->lobbies as $lobby) {
if (!$lobby->query('SetLobbyInfo', true, $playerCount, 255, $playerLevel)) {
- trigger_error("Couldn't update lobby info. " . $this->iControl->getClientErrorText($lobby));
+ trigger_error("Couldn't update lobby info. " . $this->mc->getClientErrorText($lobby));
}
}
}
@@ -263,14 +263,14 @@ class Plugin_United {
$joinLink = $this->getJoinLink();
foreach ($clients as $client) {
if ($client == $this->gameServer[$this->currentClientIndex]) continue;
- $players = $this->iControl->server->getPlayers($client);
+ $players = $this->mc->server->getPlayers($client);
if (!is_array($players)) continue;
foreach ($players as $player) {
$login = $player['Login'];
if (!$client->query('SendOpenLinkToLogin', $login, $joinLink, 1)) {
trigger_error(
"Couldn't redirect player '" . $login . "' to active game server. " .
- $this->iControl->getClientErrorText($client));
+ $this->mc->getClientErrorText($client));
}
}
}
@@ -291,28 +291,28 @@ class Plugin_United {
if ($add_all) {
// Add all server
foreach ($this->gameServer as $serverClient) {
- array_push($serverLogins, $this->iControl->server->getLogin($serverClient));
+ array_push($serverLogins, $this->mc->server->getLogin($serverClient));
}
foreach ($this->lobbies as $serverClient) {
- array_push($serverLogins, $this->iControl->server->getLogin($serverClient));
+ array_push($serverLogins, $this->mc->server->getLogin($serverClient));
}
}
else {
// Add only current server
- array_push($serverLogins, $this->iControl->server->getLogin());
+ array_push($serverLogins, $this->mc->server->getLogin());
}
// Build manialink url
- $manialink = 'iControl?favorite';
+ $manialink = 'mc?favorite';
foreach ($serverLogins as $serverLogin) {
$manialink .= '&' . $serverLogin;
}
// Send url to player
- if (!$this->iControl->client->query('SendOpenLinkToLogin', $login, $manialink, 1)) {
+ if (!$this->mc->client->query('SendOpenLinkToLogin', $login, $manialink, 1)) {
trigger_error(
"Couldn't open manialink to add server to favorite for '" . $login . "'! " .
- $this->iControl->getClientErrorText());
+ $this->mc->getClientErrorText());
}
break;
}
@@ -345,39 +345,39 @@ class Plugin_United {
// Restart map on next game server
if (!$newClient->query('RestartMap')) {
- trigger_error("Couldn't restart map on next game server. " . $this->iControl->getClientErrorText($newClient));
+ trigger_error("Couldn't restart map on next game server. " . $this->mc->getClientErrorText($newClient));
}
if ($simulateMapEnd) {
// Simulate EndMap on old client
- $this->iControl->callbacks->triggerCallback(Callbacks::CB_IC_ENDMAP, array(Callbacks::CB_IC_ENDMAP));
+ $this->mc->callbacks->triggerCallback(Callbacks::CB_IC_ENDMAP, array(Callbacks::CB_IC_ENDMAP));
}
// Transfer players to next server
$joinLink = $this->getJoinLink($newClient);
if (!$oldClient->query('GetPlayerList', 255, 0)) {
- trigger_error("Couldn't get player list. " . $this->iControl->getClientErrorText($oldClient));
+ trigger_error("Couldn't get player list. " . $this->mc->getClientErrorText($oldClient));
}
else {
$playerList = $oldClient->getResponse();
foreach ($playerList as $player) {
$login = $player['Login'];
if (!$oldClient->query('SendOpenLinkToLogin', $login, $joinLink, 1)) {
- trigger_error("Couldn't redirect player to next game server. " . $this->iControl->getClientErrorText($oldClient));
+ trigger_error("Couldn't redirect player to next game server. " . $this->mc->getClientErrorText($oldClient));
}
}
- $this->iControl->client = $newClient;
+ $this->mc->client = $newClient;
}
// Trigger client updated callback
- $this->iControl->callbacks->triggerCallback(Callbacks::CB_IC_CLIENTUPDATED, "Plugin_United.SwitchedServer");
+ $this->mc->callbacks->triggerCallback(Callbacks::CB_IC_CLIENTUPDATED, "Plugin_United.SwitchedServer");
if ($simulateMapEnd) {
// Simulate BeginMap on new client
- $map = $this->iControl->server->getMap();
+ $map = $this->mc->server->getMap();
if ($map) {
- $this->iControl->callbacks->triggerCallback(Callbacks::CB_IC_BEGINMAP, array(Callbacks::CB_IC_BEGINMAP, array($map)));
+ $this->mc->callbacks->triggerCallback(Callbacks::CB_IC_BEGINMAP, array(Callbacks::CB_IC_BEGINMAP, array($map)));
}
}
}
@@ -391,9 +391,9 @@ class Plugin_United {
if (!$command) return;
$login = $command[1][1];
- if (!$this->iControl->authentication->checkRight($login, 'operator')) {
+ if (!$this->mc->authentication->checkRight($login, 'operator')) {
// Not allowed
- $this->iControl->authentication->sendNotAllowed($login);
+ $this->mc->authentication->sendNotAllowed($login);
return;
}
@@ -401,7 +401,7 @@ class Plugin_United {
$this->switchServerRequested = time() + 3;
// Send chat message
- $this->iControl->chat->sendInformation("Switching to next server in 3 seconds...");
+ $this->mc->chat->sendInformation("Switching to next server in 3 seconds...");
}
/**
@@ -418,7 +418,7 @@ class Plugin_United {
$joinLink = $this->getJoinLink($gameserver, !$data[1]);
if (!$client->query('SendOpenLinkToLogin', $login, $joinLink, 1)) {
trigger_error(
- "United Plugin: Couldn't redirect player to current game server. " . $this->iControl->getClientErrorText($client));
+ "United Plugin: Couldn't redirect player to current game server. " . $this->mc->getClientErrorText($client));
}
}
@@ -473,7 +473,7 @@ class Plugin_United {
}
// Wait for server to be ready
- if (!$this->iControl->server->waitForStatus($client, 4)) {
+ if (!$this->mc->server->waitForStatus($client, 4)) {
trigger_error("Server couldn't get ready!", E_USER_ERROR);
}
@@ -481,7 +481,7 @@ class Plugin_United {
if (!$client->query('SetApiVersion', ManiaControl::API_VERSION)) {
trigger_error(
"Couldn't set API version '" . ManiaControl::API_VERSION . "'! This might cause problems. " .
- $this->iControl->getClientErrorText($client));
+ $this->mc->getClientErrorText($client));
}
// Set server settings
@@ -489,30 +489,30 @@ class Plugin_United {
$hideServer = ($isGameServer && $this->settings->hide_game_server ? 1 : 0);
// Passwords
if (!$client->query('SetServerPassword', $password)) {
- trigger_error("Couldn't set server join password. " . $this->iControl->getClientErrorText($client));
+ trigger_error("Couldn't set server join password. " . $this->mc->getClientErrorText($client));
}
if (!$client->query('SetServerPasswordForSpectator', $password)) {
- trigger_error("Couldn't set server spec password. " . $this->iControl->getClientErrorText($client));
+ trigger_error("Couldn't set server spec password. " . $this->mc->getClientErrorText($client));
}
// Show/Hide server
if (!$client->query('SetHideServer', $hideServer)) {
trigger_error(
"Couldn't set server '" . ($hideServer == 0 ? 'shown' : 'hidden') . "'. " .
- $this->iControl->getClientErrorText($client));
+ $this->mc->getClientErrorText($client));
}
// Enable service announces
if (!$client->query("DisableServiceAnnounces", false)) {
- trigger_error("Couldn't enable service announces. " . $this->iControl->getClientErrorText($client));
+ trigger_error("Couldn't enable service announces. " . $this->mc->getClientErrorText($client));
}
// Set game mode
if (!$client->query('SetGameMode', $this->settings->gamemode)) {
trigger_error(
- "Couldn't set game mode (" . $this->settings->gamemode . "). " . $this->iControl->getClientErrorText($client));
+ "Couldn't set game mode (" . $this->settings->gamemode . "). " . $this->mc->getClientErrorText($client));
}
else if (!$client->query('RestartMap')) {
- trigger_error("Couldn't restart map to change game mode. " . $this->iControl->getClientErrorText($client));
+ trigger_error("Couldn't restart map to change game mode. " . $this->mc->getClientErrorText($client));
}
// Save client
@@ -520,7 +520,7 @@ class Plugin_United {
if ($isGameServer) {
array_push($this->gameServer, $client);
if (count($this->gameServer) === 1) {
- $this->iControl->client = $client;
+ $this->mc->client = $client;
}
}
else {
@@ -543,9 +543,9 @@ class Plugin_United {
if (Tools::toBool($this->config->widgets->addfavorite->enabled)) {
// Send favorite widget
- if (!$this->iControl->client->query('SendDisplayManialinkPageToLogin', $login,
+ if (!$this->mc->client->query('SendDisplayManialinkPageToLogin', $login,
$this->manialinks[self::ML_ADDFAVORITE]->asXml(), 0, false)) {
- trigger_error("Couldn't send favorite widget to player '" . $login . "'! " . $this->iControl->getClientErrorText());
+ trigger_error("Couldn't send favorite widget to player '" . $login . "'! " . $this->mc->getClientErrorText());
}
}
}
@@ -559,14 +559,14 @@ class Plugin_United {
$client = $this->gameServer[$this->currentClientIndex];
}
if (!$client->query('GetSystemInfo')) {
- trigger_error("Couldn't fetch server system info. " . $this->iControl->getClientErrorText($client));
+ trigger_error("Couldn't fetch server system info. " . $this->mc->getClientErrorText($client));
return null;
}
else {
$systemInfo = $client->getResponse();
$password = '';
if (!$client->query('GetServerPassword')) {
- trigger_error("Couldn't get server password. " . $this->iControl->getClientErrorText($client));
+ trigger_error("Couldn't get server password. " . $this->mc->getClientErrorText($client));
}
else {
$password = $client->getResponse();
diff --git a/application/readme.txt b/application/readme.txt
index 32d9d8d0..26ab8d43 100644
--- a/application/readme.txt
+++ b/application/readme.txt
@@ -1,6 +1,6 @@
**********************************************
* *
-* mControl ManiaPlanet Server Control *
+* mc ManiaPlanet Server Control *
* Written by steeffeen *
* Contact: mail@steeffeen.com *
* *
@@ -12,30 +12,30 @@ SETUP:
2. Configure the needed settings:
- 2.1 Open the file 'configs/server.mControl.xml'.
+ 2.1 Open the file 'configs/server.mc.xml'.
Enter your maniaplanet server information.
- 2.2 Open the file 'configs/database.mControl.xml'
+ 2.2 Open the file 'configs/database.mc.xml'
Enter your mysql server information or disable database usage if you don't have a mysql server available.
- 2.3 Open the file 'configs/authentication.mControl.xml'.
- Add the player logins who should have access to the commands of mControl.
+ 2.3 Open the file 'configs/authentication.mc.xml'.
+ Add the player logins who should have access to the commands of mc.
-3. (Optional) Enable or disable the available plugins in the file 'configs/plugins.mControl.xml'.
+3. (Optional) Enable or disable the available plugins in the file 'configs/plugins.mc.xml'.
-4. (Optional) Edit the other config files in 'configs/' in order to customize your mControl to fit your needs.
+4. (Optional) Edit the other config files in 'configs/' in order to customize your mc to fit your needs.
-5. Run the tool via the shell script 'mControl.sh' (UNIX) or the batch file 'mControl.bat' (Windows)
+5. Run the tool via the shell script 'mc.sh' (UNIX) or the batch file 'mc.bat' (Windows)
6. Enjoy!
INFORMATION:
-- mControl is only tested on UNIX machines
+- mc is only tested on UNIX machines
- even though it might run properly on Windows I can't promise it will work all the time
- - furthermore I can't promise that there won't be a feature in the future that makes it impossible to run mControl under Windows
- - in order to run mControl under Windows you have to alter the file mControl.bat and enter the path to your php.exe
+ - furthermore I can't promise that there won't be a feature in the future that makes it impossible to run mc under Windows
+ - in order to run mc under Windows you have to alter the file mc.bat and enter the path to your php.exe
- Tests were performed using PHP Version 5.4
- If you notice problems with other version please let me know