added dedibuild to error and usage reporting

This commit is contained in:
kremsy 2017-03-26 13:58:23 +02:00
parent f2ab40a50f
commit d46eb59fb9
5 changed files with 150 additions and 142 deletions

View File

@ -11,7 +11,7 @@
error_reporting(E_ALL); error_reporting(E_ALL);
// Run configuration // Run configuration
define('DEV_MODE', true); // Development mode to not send error reports etc. define('DEV_MODE', false); // Development mode to not send error reports etc.
define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file name in logs folder define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file name in logs folder
define('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder define('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder

View File

@ -144,6 +144,8 @@ class ErrorHandler {
$report['ManiaControlVersion'] = ManiaControl::VERSION; $report['ManiaControlVersion'] = ManiaControl::VERSION;
} }
$report['DedicatedBuildVersion'] = $this->maniaControl->getDedicatedServerBuildVersion();
$json = json_encode(Formatter::utf8($report)); $json = json_encode(Formatter::utf8($report));
$info = base64_encode($json); $info = base64_encode($json);
@ -438,6 +440,8 @@ class ErrorHandler {
$report['ManiaControlVersion'] = ManiaControl::VERSION; $report['ManiaControlVersion'] = ManiaControl::VERSION;
} }
$report['DedicatedBuildVersion'] = $this->maniaControl->getDedicatedServerBuildVersion();
$errorReport = json_encode(Formatter::utf8($report)); $errorReport = json_encode(Formatter::utf8($report));
$url = ManiaControl::URL_WEBSERVICE . 'errorreport'; $url = ManiaControl::URL_WEBSERVICE . 'errorreport';

View File

@ -183,6 +183,8 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
/** @var ModeScriptEventManager $modeScriptEventManager */ /** @var ModeScriptEventManager $modeScriptEventManager */
private $modeScriptEventManager = null; private $modeScriptEventManager = null;
private $dedicatedServerBuildVersion = "";
/** /**
* Construct a new ManiaControl instance * Construct a new ManiaControl instance
*/ */
@ -216,7 +218,6 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
$this->pluginManager = new PluginManager($this); $this->pluginManager = new PluginManager($this);
$this->updateManager = new UpdateManager($this); $this->updateManager = new UpdateManager($this);
$this->getErrorHandler()->init(); $this->getErrorHandler()->init();
// Permissions // Permissions
@ -565,6 +566,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
$this->requestQuitMessage = $message; $this->requestQuitMessage = $message;
} }
/** /**
* Run ManiaControl * Run ManiaControl
*/ */
@ -577,8 +579,9 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
// Check if the version of the server is high enough // Check if the version of the server is high enough
$version = $this->getClient()->getVersion(); $version = $this->getClient()->getVersion();
if ($version->build < self::MIN_DEDIVERSION) { $this->dedicatedServerBuildVersion = $version->build;
$this->quit("The Server has Version '{$version->build}', while at least '" . self::MIN_DEDIVERSION . "' is required!", true); if ($this->dedicatedServerBuildVersion < self::MIN_DEDIVERSION) {
$this->quit("The Server has Version '{$this->dedicatedServerBuildVersion}', while at least '" . self::MIN_DEDIVERSION . "' is required!", true);
} }
// Listen for shutdown // Listen for shutdown
@ -651,6 +654,16 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
$this->getServer()->getScriptManager()->enableScriptCallbacks(); $this->getServer()->getScriptManager()->enableScriptCallbacks();
} }
/**
* Get The Build Version of the Dedicated Server
*
* @return string
*/
public function getDedicatedServerBuildVersion() {
return $this->dedicatedServerBuildVersion;
}
/** /**
* Return the server * Return the server
* *

View File

@ -59,11 +59,13 @@ class UsageReporter implements TimerListener {
$properties['TitleId'] = $this->maniaControl->getServer()->titleId; $properties['TitleId'] = $this->maniaControl->getServer()->titleId;
$properties['ServerName'] = Formatter::stripDirtyCodes($this->maniaControl->getClient()->getServerName()); $properties['ServerName'] = Formatter::stripDirtyCodes($this->maniaControl->getClient()->getServerName());
$properties['UpdateChannel'] = $this->maniaControl->getUpdateManager()->getCurrentUpdateChannelSetting(); $properties['UpdateChannel'] = $this->maniaControl->getUpdateManager()->getCurrentUpdateChannelSetting();
$properties['DedicatedBuildVersion'] = $this->maniaControl->getDedicatedServerBuildVersion();
$properties['PlayerCount'] = $this->maniaControl->getPlayerManager()->getPlayerCount(); $properties['PlayerCount'] = $this->maniaControl->getPlayerManager()->getPlayerCount();
$properties['MemoryUsage'] = memory_get_usage(); $properties['MemoryUsage'] = memory_get_usage();
$properties['MemoryPeakUsage'] = memory_get_peak_usage(); $properties['MemoryPeakUsage'] = memory_get_peak_usage();
$maxPlayers = $this->maniaControl->getClient()->getMaxPlayers(); $maxPlayers = $this->maniaControl->getClient()->getMaxPlayers();
$properties['MaxPlayers'] = $maxPlayers['CurrentValue']; $properties['MaxPlayers'] = $maxPlayers['CurrentValue'];

View File

@ -229,8 +229,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
* Open a Mx Karma Session * Open a Mx Karma Session
*/ */
private function mxKarmaOpenSession() { private function mxKarmaOpenSession() {
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
) {
return; return;
} }
@ -331,8 +330,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
* Fetch the mxKarmaVotes for the current map * Fetch the mxKarmaVotes for the current map
*/ */
public function getMxKarmaVotes(Player $player = null) { public function getMxKarmaVotes(Player $player = null) {
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
) {
return; return;
} }
@ -370,9 +368,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
} }
$content = json_encode($properties); $content = json_encode($properties);
$this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_GET_MAP_RATING . '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey), function ($json, $this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_GET_MAP_RATING . '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey), function ($json, $error) use (
$error) use
(
&$player &$player
) { ) {
if ($error) { if ($error) {
@ -487,8 +483,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$content = json_encode($properties); $content = json_encode($properties);
$this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVE_VOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($json, $this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVE_VOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($json, $error) {
$error) {
if ($error) { if ($error) {
$this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error);
return; return;
@ -754,13 +749,11 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$karmaSettingName = self::buildKarmaSettingName($serverLogin); $karmaSettingName = self::buildKarmaSettingName($serverLogin);
switch ($setting->setting) { switch ($setting->setting) {
case $karmaSettingName: case $karmaSettingName: {
{
$this->mxKarmaOpenSession(); $this->mxKarmaOpenSession();
break; break;
} }
case self::SETTING_WIDGET_ENABLE: case self::SETTING_WIDGET_ENABLE: {
{
if ($setting->value) { if ($setting->value) {
$this->updateManialink = true; $this->updateManialink = true;
$this->handle1Second(time()); $this->handle1Second(time());
@ -803,8 +796,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$voteCount = $votes['count']; $voteCount = $votes['count'];
} }
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE) if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
) {
// Build karma manialink // Build karma manialink
$this->buildManialink(); $this->buildManialink();
@ -968,13 +960,11 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
* @param Map $map * @param Map $map
*/ */
public function importMxKarmaVotes(Map $map) { public function importMxKarmaVotes(Map $map) {
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
) {
return; return;
} }
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_IMPORTING) if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_IMPORTING)) {
) {
return; return;
} }
@ -1039,8 +1029,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
* Save Mx Karma Votes at MapEnd * Save Mx Karma Votes at MapEnd
*/ */
public function sendMxKarmaVotes(Map $map) { public function sendMxKarmaVotes(Map $map) {
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
) {
return; return;
} }