Changed mControl to ManiaControl

This commit is contained in:
Steffen Schröder 2013-11-09 11:19:21 +01:00
parent 97f9a6019a
commit 5d166776f8
30 changed files with 126 additions and 122 deletions

View File

@ -0,0 +1,6 @@
REM Set the path to your php.exe here
set phpPath="D:\Programme\xampp\php\php.exe"
REM Start ManiaControl
START "" /B %phpPath% -f "ManiaControl.php" 2>&1

View File

@ -0,0 +1,26 @@
<?php
namespace ManiaControl;
define('ManiaControlDir', __DIR__);
require_once __DIR__ . '/core/core.ManiaControl.php';
// Set process settings
ini_set('memory_limit', '128M');
if (function_exists('date_default_timezone_get') && function_exists('date_default_timezone_set')) {
date_default_timezone_set(@date_default_timezone_get());
}
// Error handling
ini_set('log_errors', 1);
ini_set('error_reporting', -1);
ini_set('error_log', 'ManiaControl_' . getmypid() . '.log');
// Start ManiaControl
error_log('Loading ManiaControl v' . ManiaControl::VERSION . '!');
$maniaControl = new ManiaControl();
$maniaControl->run(true);
?>

View File

@ -0,0 +1,3 @@
#!/bin/sh
php ManiaControl.php 2>&1 &
echo $! > ManiaControl.pid

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Configure how mControl sends chat message -->
<!-- Configure how ManiaControl sends chat message -->
<chat-config>
<!-- Set which codes should be used to compose chat messages -->

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Core configuration for mControl -->
<!-- Core configuration for ManiaControl -->
<core-config>
<!-- Connection timeout -->

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Configure the mysql database used by mControl -->
<!-- Configure the mysql database used by ManiaControl -->
<database-config>
<!-- MySQL Server -->

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Configure the United plugin -->
<!-- Note: You should disable the config server.mControl.xml while using this plugin -->
<!-- Note: You should disable the config server.ManiaControl.xml while using this plugin -->
<united-config>
<!-- Enable the whole plugin -->

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Class handling authentication levels
@ -28,7 +28,7 @@ class Authentication {
$this->mControl = $mControl;
// Load config
$this->config = Tools::loadConfig('authentication.mControl.xml');
$this->config = Tools::loadConfig('authentication.ManiaControl.xml');
}
/**

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Class for handling server callbacks
@ -11,15 +11,15 @@ class Callbacks {
/**
* Constants
*/
// mControl callbacks
const CB_IC_1_SECOND = 'mControl.1Second';
const CB_IC_5_SECOND = 'mControl.5Second';
const CB_IC_1_MINUTE = 'mControl.1Minute';
const CB_IC_3_MINUTE = 'mControl.3Minute';
const CB_IC_ONINIT = 'mControl.OnInit';
const CB_IC_CLIENTUPDATED = 'mControl.ClientUpdated';
const CB_IC_BEGINMAP = 'mControl.BeginMap';
const CB_IC_ENDMAP = 'mControl.EndMap';
// ManiaControl callbacks
const CB_IC_1_SECOND = 'ManiaControl.1Second';
const CB_IC_5_SECOND = 'ManiaControl.5Second';
const CB_IC_1_MINUTE = 'ManiaControl.1Minute';
const CB_IC_3_MINUTE = 'ManiaControl.3Minute';
const CB_IC_ONINIT = 'ManiaControl.OnInit';
const CB_IC_CLIENTUPDATED = 'ManiaControl.ClientUpdated';
const CB_IC_BEGINMAP = 'ManiaControl.BeginMap';
const CB_IC_ENDMAP = 'ManiaControl.EndMap';
// ManiaPlanet callbacks
const CB_MP_SERVERSTART = 'ManiaPlanet.ServerStart';
const CB_MP_SERVERSTOP = 'ManiaPlanet.ServerStop';
@ -92,7 +92,7 @@ class Callbacks {
* Handles the given array of callbacks
*/
public function handleCallbacks() {
// Perform mControl callbacks
// Perform ManiaControl callbacks
if ($this->last1Second <= time() - 1) {
$this->last1Second = time();

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Class for chat methods
@ -16,16 +16,16 @@ class Chat {
private $config = null;
private $prefix = 'mControl>';
private $prefix = 'ManiaControl>';
/**
* Construct mControl chat
* Construct ManiaControl chat
*/
public function __construct($mControl) {
$this->mControl = $mControl;
// Load config
$this->config = Tools::loadConfig('chat.mControl.xml');
$this->config = Tools::loadConfig('chat.ManiaControl.xml');
}
/**

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Class for handling chat commands
@ -31,7 +31,7 @@ class Commands {
$this->mControl = $mControl;
// Load config
$this->config = Tools::loadConfig('commands.mControl.xml');
$this->config = Tools::loadConfig('commands.ManiaControl.xml');
// Register for callbacks
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'each5Seconds');
@ -148,7 +148,7 @@ class Commands {
}
/**
* Send mControl version
* Send ManiaControl version
*/
private function command_version($chat) {
$login = $chat[1][1];
@ -157,7 +157,7 @@ class Commands {
$this->iControl->authentication->sendNotAllowed($login);
return;
}
if (!$this->iControl->chat->sendInformation('This server is using mControl v' . mControl::VERSION . '!', $login)) {
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());
}
}
@ -345,7 +345,7 @@ class Commands {
$this->iControl->authentication->sendNotAllowed($login);
return;
}
$this->iControl->quit("mControl shutdown requested by '" . $login . "'");
$this->iControl->quit("ManiaControl shutdown requested by '" . $login . "'");
}
/**
@ -504,24 +504,24 @@ class Commands {
// TODO: show usage
return;
}
// Check if mControl can even write to the maps dir
// 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("mControl couldn't retrieve the maps directory.", $login);
$this->iControl->chat->sendError("ManiaControl couldn't retrieve the maps directory.", $login);
return;
}
else {
$mapDir = $this->iControl->client->getResponse();
if (!is_dir($mapDir)) {
trigger_error("mControl doesn't have have access to the maps directory in '" . $mapDir . "'.");
$this->iControl->chat->sendError("mControl doesn't have access to the maps directory.", $login);
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);
return;
}
$dlDir = (string) $this->iControl->config->maps_dir;
// Create mx directory if necessary
if (!is_dir($mapDir . $dlDir) && !mkdir($mapDir . $dlDir)) {
trigger_error("mControl doesn't have to rights to save maps in'" . $mapDir . $dlDir, "'.");
$this->iControl->chat->sendError("mControl doesn't have to rights to save maps.", $login);
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);
return;
}
$mapDir .= $dlDir . '/';

View File

@ -1,18 +1,18 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Needed includes
*/
require_once __DIR__ . '/authentication.mControl.php';
require_once __DIR__ . '/callbacks.mControl.php';
require_once __DIR__ . '/chat.mControl.php';
require_once __DIR__ . '/commands.mControl.php';
require_once __DIR__ . '/database.mControl.php';
require_once __DIR__ . '/server.mControl.php';
require_once __DIR__ . '/stats.mControl.php';
require_once __DIR__ . '/tools.mControl.php';
require_once __DIR__ . '/authentication.ManiaControl.php';
require_once __DIR__ . '/callbacks.ManiaControl.php';
require_once __DIR__ . '/chat.ManiaControl.php';
require_once __DIR__ . '/commands.ManiaControl.php';
require_once __DIR__ . '/database.ManiaControl.php';
require_once __DIR__ . '/server.ManiaControl.php';
require_once __DIR__ . '/stats.ManiaControl.php';
require_once __DIR__ . '/tools.ManiaControl.php';
list($endiantest) = array_values(unpack('L1L', pack('V', 1)));
if ($endiantest == 1) {
require_once __DIR__ . '/PhpRemote/GbxRemote.inc.php';
@ -22,11 +22,11 @@ else {
}
/**
* mControl Server Controller for ManiaPlanet Server
* ManiaControl Server Controller for ManiaPlanet Server
*
* @author steeffeen
*/
class mControl {
class ManiaControl {
/**
* Constants
*/
@ -67,11 +67,11 @@ class mControl {
private $shutdownRequested = false;
/**
* Construct mControl
* Construct ManiaControl
*/
public function __construct() {
// Load core
$this->config = Tools::loadConfig('core.mControl.xml');
$this->config = Tools::loadConfig('core.ManiaControl.xml');
$this->startTime = time();
// Load chat tool
@ -113,14 +113,14 @@ class mControl {
}
/**
* Quit mControl and log the given message
* Quit ManiaControl and log the given message
*/
public function quit($message = false) {
if ($this->shutdownRequested) return;
if ($this->client) {
// Announce quit
$this->chat->sendInformation('mControl shutting down.');
$this->chat->sendInformation('ManiaControl shutting down.');
// Hide manialinks
$this->client->query('SendHideManialinkPage');
@ -134,15 +134,15 @@ class mControl {
// Shutdown
if ($this->client) $this->client->Terminate();
error_log("Quitting mControl!");
error_log("Quitting ManiaControl!");
exit();
}
/**
* Run mControl
* Run ManiaControl
*/
public function run($debug = false) {
error_log('Starting mControl v' . self::VERSION . '!');
error_log('Starting ManiaControl v' . self::VERSION . '!');
$this->debug = (bool) $debug;
// Load plugins
@ -154,9 +154,9 @@ class mControl {
// Loading finished
error_log("Loading completed!");
// Announce mControl
if (!$this->chat->sendInformation('mControl v' . self::VERSION . ' successfully started!')) {
trigger_error("Couldn't announce mControl. " . $this->iControl->getClientErrorText());
// Announce ManiaControl
if (!$this->chat->sendInformation('ManiaControl v' . self::VERSION . ' successfully started!')) {
trigger_error("Couldn't announce ManiaControl. " . $this->iControl->getClientErrorText());
}
// OnInit
@ -284,10 +284,10 @@ class mControl {
}
/**
* Load mControl plugins
* Load ManiaControl plugins
*/
private function loadPlugins() {
$pluginsConfig = Tools::loadConfig('plugins.mControl.xml');
$pluginsConfig = Tools::loadConfig('plugins.ManiaControl.xml');
if (!$pluginsConfig || !isset($pluginsConfig->plugin)) {
trigger_error('Invalid plugins config.');
return;
@ -296,7 +296,7 @@ class mControl {
// Load plugin classes
$classes = get_declared_classes();
foreach ($pluginsConfig->xpath('plugin') as $plugin) {
$fileName = mControl . '/plugins/' . $plugin;
$fileName = ManiaControlDir . '/plugins/' . $plugin;
if (!file_exists($fileName)) {
trigger_error("Couldn't load plugin '" . $plugin . "'! File doesn't exist. (/plugins/" . $plugin . ")");
}

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Class for database connection
@ -35,8 +35,8 @@ class Database {
$this->mControl = $mControl;
// Load config
$this->config = Tools::loadConfig('database.mControl.xml');
$this->iControl->checkConfig($this->config, array("host", "user"), 'database.mControl.xml');
$this->config = Tools::loadConfig('database.ManiaControl.xml');
$this->iControl->checkConfig($this->config, array("host", "user"), 'database.ManiaControl.xml');
// Get mysql server information
$host = $this->config->xpath('host');

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Class providing information and commands for the connected maniaplanet server
@ -31,7 +31,7 @@ class Server {
$this->mControl = $mControl;
// Load config
$this->config = Tools::loadConfig('server.mControl.xml');
$this->config = Tools::loadConfig('server.ManiaControl.xml');
$this->iControl->checkConfig($this->config, array('host', 'port', 'login', 'pass'), 'server');
// Register for callbacks
@ -60,7 +60,7 @@ class Server {
}
/**
* Checks if mControl has access to the given directory (server data directory if no param)
* Checks if ManiaControl has access to the given directory (server data directory if no param)
*
* @param string $directory
* @return bool

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Stats class
@ -28,7 +28,7 @@ class Stats {
$this->mControl = $mControl;
// Load config
$this->config = Tools::loadConfig('stats.mControl.xml');
$this->config = Tools::loadConfig('stats.ManiaControl.xml');
$this->loadSettings();
// Init database tables

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Class for basic tools
@ -90,7 +90,7 @@ class Tools {
$query = 'GET ' . $urlData['path'] . ' HTTP/1.0' . PHP_EOL;
$query .= 'Host: ' . $urlData['host'] . PHP_EOL;
$query .= 'Content-Type: UTF-8' . PHP_EOL;
$query .= 'User-Agent: mControl v' . mControl::VERSION . PHP_EOL;
$query .= 'User-Agent: ManiaControl v' . ManiaControl::VERSION . PHP_EOL;
$query .= PHP_EOL;
fwrite($fsock, $query);
@ -205,7 +205,7 @@ class Tools {
*/
public static function loadConfig($fileName) {
// Load config file from configs folder
$fileLocation = mControl . '/configs/' . $fileName;
$fileLocation = ManiaControlDir . '/configs/' . $fileName;
if (!file_exists($fileLocation)) {
trigger_error("Config file doesn't exist! (" . $fileName . ")", E_USER_ERROR);
}

View File

@ -1,2 +0,0 @@
REM set the path to your php.exe here
START "" /B "D:\Programme\xampp\php\php.exe" -f "mControl.php" 2>&1

View File

@ -1,26 +0,0 @@
<?php
namespace mControl;
define('mControl', __DIR__);
require_once __DIR__ . '/core/core.mControl.php';
// Set process settings
ini_set('memory_limit', '128M');
if (function_exists('date_default_timezone_get') && function_exists('date_default_timezone_set')) {
date_default_timezone_set(@date_default_timezone_get());
}
// Error handling
ini_set('log_errors', 1);
ini_set('error_reporting', -1);
ini_set('error_log', 'iControl_' . getmypid() . '.log');
// Start mControl
error_log('Loading mControl v' . mControl::VERSION . '!');
$mControl = new mControl();
$iControl->run(true);
?>

View File

@ -1,3 +0,0 @@
#!/bin/sh
php mControl.php 2>&1 &
echo $! > mControl.pid

View File

@ -1,9 +1,9 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* mControl Chatlog Plugin
* ManiaControl Chatlog Plugin
*
* @author steeffeen
*/
@ -51,7 +51,7 @@ class Plugin_Chatlog {
// File name
$fileName = (string) $this->config->filename;
$this->settings->fileName = mControl . '/' . $fileName;
$this->settings->fileName = ManiaControlDir . '/' . $fileName;
// log_server_messages
$log_server_messages = $this->config->xpath('log_server_messages');
@ -77,7 +77,7 @@ class Plugin_Chatlog {
* @param string $login
*/
private function logText($text, $login = null) {
$message = date(mControl::DATE) . '>> ' . ($login ? $login . ': ' : '') . $text . PHP_EOL;
$message = date(ManiaControl::DATE) . '>> ' . ($login ? $login . ': ' : '') . $text . PHP_EOL;
file_put_contents($this->settings->fileName, $message, FILE_APPEND);
}
}

View File

@ -1,9 +1,9 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* mControl Karma Plugin
* ManiaControl Karma Plugin
*
* @author : steeffeen
*/
@ -72,7 +72,7 @@ class Plugin_Karma {
}
/**
* Handle OnInit mControl callback
* Handle OnInit ManiaControl callback
*
* @param array $callback
*/
@ -82,7 +82,7 @@ class Plugin_Karma {
}
/**
* Handle mControl BeginMap callback
* Handle ManiaControl BeginMap callback
*
* @param array $callback
*/

View File

@ -1,9 +1,9 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* mControl Obstacle Plugin
* ManiaControl Obstacle Plugin
*
* @author steeffeen
*/

View File

@ -1,9 +1,9 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Abstract mControl plugin class
* Abstract ManiaControl plugin class
*/
abstract class Plugin_Name {
/**

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
// TODO: show mix of best and next records (depending on own one)
// TODO: enable keep-alive
@ -11,7 +11,7 @@ namespace mControl;
// TODO: threaded requests
/**
* mControl Records Plugin
* ManiaControl Records Plugin
*
* @author steeffeen
*/
@ -123,7 +123,7 @@ class Plugin_Records {
}
/**
* Handle mControl init
* Handle ManiaControl init
*/
public function handleOnInit($callback = null) {
// Let manialinks update
@ -255,8 +255,8 @@ class Plugin_Records {
$serverVersion = $this->iControl->server->getVersion();
$serverData['ServerVersion'] = $serverVersion['Version'];
$serverData['ServerBuild'] = $serverVersion['Build'];
$serverData['Tool'] = 'mControl';
$serverData['Version'] = mControl::VERSION;
$serverData['Tool'] = 'ManiaControl';
$serverData['Version'] = ManiaControl::VERSION;
$this->dedimaniaData['serverData'] = $serverData;
}
@ -267,7 +267,7 @@ class Plugin_Records {
$header .= 'Accept-Encoding: gzip;' . PHP_EOL;
$header .= 'Content-Type: text/xml; charset=utf-8;' . PHP_EOL;
$header .= 'Keep-Alive: 300;' . PHP_EOL;
$header .= 'User-Agent: mControl v' . mControl::VERSION . ';' . PHP_EOL;
$header .= 'User-Agent: ManiaControl v' . ManiaControl::VERSION . ';' . PHP_EOL;
$this->dedimaniaData['header'] = $header;
}

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
// TODO: Jump message "now playing stadium"
// TODO: put inactive server in idle (keeping same map)
@ -9,7 +9,7 @@ namespace mControl;
// TODO: max players setting
/**
* mControl United Plugin
* ManiaControl United Plugin
*
* @author steeffeen
*/
@ -78,7 +78,7 @@ class Plugin_United {
}
/**
* Handle mControl OnInit callback
* Handle ManiaControl OnInit callback
*
* @param array $callback
*/
@ -303,7 +303,7 @@ class Plugin_United {
}
// Build manialink url
$manialink = 'mControl?favorite';
$manialink = 'iControl?favorite';
foreach ($serverLogins as $serverLogin) {
$manialink .= '&' . $serverLogin;
}
@ -478,9 +478,9 @@ class Plugin_United {
}
// Set api version
if (!$client->query('SetApiVersion', mControl::API_VERSION)) {
if (!$client->query('SetApiVersion', ManiaControl::API_VERSION)) {
trigger_error(
"Couldn't set API version '" . mControl::API_VERSION . "'! This might cause problems. " .
"Couldn't set API version '" . ManiaControl::API_VERSION . "'! This might cause problems. " .
$this->iControl->getClientErrorText($client));
}