From 28d927e05e30d7fa7b4f0cf9891ab6d8dce5d518 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 17 Jan 2014 18:58:15 +0100 Subject: [PATCH] usage reporter start --- application/core/ManiaControl.php | 1 + application/core/Players/PlayerList.php | 8 +++ application/core/Server/Server.php | 2 + application/core/Server/UsageReporter.php | 64 +++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 application/core/Server/UsageReporter.php diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 03863201..5e49ccf5 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -44,6 +44,7 @@ require_once __DIR__ . '/Plugins/PluginManager.php'; require_once __DIR__ . '/Server/Server.php'; require_once __DIR__ . '/Settings/SettingManager.php'; require_once __DIR__ . '/UpdateManager.php'; +require_once __DIR__ . '/Server/UsageReporter.php'; /** * ManiaControl Server Controller for ManiaPlanet Server diff --git a/application/core/Players/PlayerList.php b/application/core/Players/PlayerList.php index 232f8fd9..84a89205 100644 --- a/application/core/Players/PlayerList.php +++ b/application/core/Players/PlayerList.php @@ -389,6 +389,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { $backgroundQuad = new Quad(); $frame->add($backgroundQuad); $backgroundQuad->setSize($width, $height); + $backgroundQuad->setImage('https://dl.dropboxusercontent.com/u/105352981/Stuff/CAM%20SM%20BORDER%20PNG.png'); //TODO just a test + //$backgroundQuad->setStyles($quadStyle, $quadSubstyle); + $backgroundQuad->setZ(0.2); + + // Background Quad + $backgroundQuad = new Quad(); + $frame->add($backgroundQuad); + $backgroundQuad->setSize($width - 2, $height - 2); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); $backgroundQuad->setZ(0.1); diff --git a/application/core/Server/Server.php b/application/core/Server/Server.php index d6157505..f1c23525 100644 --- a/application/core/Server/Server.php +++ b/application/core/Server/Server.php @@ -33,6 +33,7 @@ class Server implements CallbackListener { public $titleId = null; public $dataDirectory = ''; public $serverCommands = null; + public $usageReporter = null; /** * Private Properties @@ -49,6 +50,7 @@ class Server implements CallbackListener { $this->initTables(); $this->serverCommands = new ServerCommands($maniaControl); + $this->usageReporter = new UsageReporter($maniaControl); // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'onInit'); diff --git a/application/core/Server/UsageReporter.php b/application/core/Server/UsageReporter.php new file mode 100644 index 00000000..2a251161 --- /dev/null +++ b/application/core/Server/UsageReporter.php @@ -0,0 +1,64 @@ +maniaControl = $maniaControl; + //TODO setting + $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handleEveryMinute'); + + $this->maniaControl->settingManager->initSetting($this, self::SETTING_DISABLE_USAGE_REPORTING, false); + } + + public function handleEveryMinute(array $callback) { + if($this->maniaControl->settingManager->getSetting($this, self::SETTING_DISABLE_USAGE_REPORTING)) { + return; + } + + $this->minuteCount++; + + if($this->minuteCount >= self::UPDATE_MINUTE_COUNT) { + $properties = array(); + $properties['MC_Version'] = ManiaControl::VERSION; + $properties['OperatingSystem'] = php_uname(); + $properties['PHPVersion'] = phpversion(); + $properties['ServerLogin'] = $this->maniaControl->server->login; + $properties['TitleId'] = $this->maniaControl->server->titleId; + $properties['ServerName'] = $this->maniaControl->server->getName(); + $properties['PlayerCount'] = count($this->maniaControl->playerManager->getPlayers()); + $properties['MaxPlayers'] = $this->maniaControl->client->getMaxPlayers(); + + $json = json_encode($properties); + $info = base64_encode($json); + + //TODO send Info + $this->minuteCount = 0; + } + } +} \ No newline at end of file