diff --git a/application/core/ErrorHandler.php b/application/core/ErrorHandler.php index 5c07bd03..fbca7c33 100644 --- a/application/core/ErrorHandler.php +++ b/application/core/ErrorHandler.php @@ -37,38 +37,38 @@ class ErrorHandler { $message .= "Trace: {$ex->getTraceAsString()}" . PHP_EOL; logMessage($message); + $error = array(); $error["Type"] = "Exception"; $error["Message"] = $message; $error['OperatingSystem'] = php_uname(); $error['PHPVersion'] = phpversion(); - if ($this->maniaControl->server != null) { + if ($this->maniaControl->server) { $error['ServerLogin'] = $this->maniaControl->server->login; } else { - $error['ServerLogin'] = null; + $error['ServerLogin'] = ''; } - if ($this->maniaControl->settingManager != null && $this->maniaControl->updateManager != null) { + if ($this->maniaControl->settingManager && $this->maniaControl->updateManager) { $error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager, UpdateManager::SETTING_UPDATECHECK_CHANNEL); $error['ManiaControlVersion'] = $this->maniaControl->updateManager->getCurrentBuildDate(); } else { - $error['UpdateChannel'] = null; + $error['UpdateChannel'] = ''; $error['ManiaControlVersion'] = ManiaControl::VERSION; } $json = json_encode($error); $info = base64_encode($json); - $url = UpdateManager::URL_WEBSERVICE . "errorreport?error=" . urlencode($info); + $url = ManiaControl::URL_WEBSERVICE . "errorreport?error=" . urlencode($info); $success = FileUtil::loadFile($url); if (!json_decode($success)) { - logMessage("Exception-Report failed"); + logMessage("Exception-Report failed!"); } else { logMessage("Exception successfully reported!"); } - $this->maniaControl->restart(); exit(); } @@ -87,6 +87,7 @@ class ErrorHandler { // Error suppressed return false; } + // Log error $errorTag = $this->getErrorTag($errorNumber); $message = "{$errorTag}: {$errorString} in File '{$errorFile}' on Line {$errorLine}!"; @@ -116,7 +117,7 @@ class ErrorHandler { $json = json_encode($error); $info = base64_encode($json); - $url = UpdateManager::URL_WEBSERVICE . "errorreport?error=" . urlencode($info); + $url = ManiaControl::URL_WEBSERVICE . "errorreport?error=" . urlencode($info); $success = FileUtil::loadFile($url); if (!json_decode($success)) { diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 9d2a343a..de4a2aac 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -44,6 +44,7 @@ class ManiaControl implements CommandListener { const OS_WIN = 'Windows'; const CONNECT_TIMEOUT = 20; const SCRIPT_TIMEOUT = 20; + const URL_WEBSERVICE = 'http://ws.maniacontrol.com/'; const SETTING_PERMISSION_SHUTDOWN = 'Shutdown ManiaControl'; const SETTING_PERMISSION_RESTART = 'Restart ManiaControl'; diff --git a/application/core/Server/UsageReporter.php b/application/core/Server/UsageReporter.php index adc6e14d..8cb58625 100644 --- a/application/core/Server/UsageReporter.php +++ b/application/core/Server/UsageReporter.php @@ -9,7 +9,7 @@ use ManiaControl\Update\UpdateManager; use Maniaplanet\DedicatedServer\Xmlrpc\Exception; /** - * Class reports Usage + * Class reporting ManiaControl Usage for the Server * * @author steeffeen & kremsy */ @@ -26,27 +26,27 @@ class UsageReporter implements TimerListener { private $maniaControl = null; /** - * Create a new Server Settings Instance + * Create a new Usage Reporter Instance * * @param ManiaControl $maniaControl */ public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; - + $this->maniaControl->settingManager->initSetting($this, self::SETTING_DISABLE_USAGE_REPORTING, false); $this->maniaControl->timerManager->registerTimerListening($this, 'reportUsage', 1000 * 60 * self::UPDATE_MINUTE_COUNT); - $this->maniaControl->settingManager->initSetting($this, self::SETTING_DISABLE_USAGE_REPORTING, false); } /** * Reports Usage every xx Minutes * - * @param $time + * @param float $time */ public function reportUsage($time) { if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_DISABLE_USAGE_REPORTING)) { return; } + $properties = array(); $properties['ManiaControlVersion'] = ManiaControl::VERSION; @@ -74,7 +74,7 @@ class UsageReporter implements TimerListener { $json = json_encode($properties); $info = base64_encode($json); - $this->maniaControl->fileReader->loadFile(UpdateManager::URL_WEBSERVICE . "/usagereport?info=" . urlencode($info), function ($response, $error) { + $this->maniaControl->fileReader->loadFile(ManiaControl::URL_WEBSERVICE . "/usagereport?info=" . urlencode($info), function ($response, $error) { $response = json_decode($response); if ($error || !$response) { $this->maniaControl->log("Error while Sending data: " . $error); diff --git a/application/core/Update/UpdateManager.php b/application/core/Update/UpdateManager.php index 62355315..5bc1dae2 100644 --- a/application/core/Update/UpdateManager.php +++ b/application/core/Update/UpdateManager.php @@ -28,7 +28,6 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener const SETTING_AUTO_UPDATE = 'Perform update automatically'; const SETTING_PERMISSION_UPDATE = 'Update Core'; const SETTING_PERMISSION_UPDATECHECK = 'Check Core Update'; - const URL_WEBSERVICE = 'http://ws.maniacontrol.com/'; const CHANNEL_RELEASE = 'release'; const CHANNEL_BETA = 'beta'; const CHANNEL_NIGHTLY = 'nightly'; @@ -289,7 +288,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener } /** @var Plugin $pluginClass */ $pluginId = $pluginClass::getId(); - $url = self::URL_WEBSERVICE . 'plugins?id=' . $pluginId; + $url = ManiaControl::URL_WEBSERVICE . 'plugins?id=' . $pluginId; $dataJson = FileUtil::loadFile($url); $pluginVersions = json_decode($dataJson); if (!$pluginVersions || !isset($pluginVersions[0])) { @@ -312,7 +311,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener */ private function checkCoreUpdateAsync($function, $ignoreVersion = false) { $updateChannel = $this->getCurrentUpdateChannelSetting(); - $url = self::URL_WEBSERVICE . 'versions?update=1¤t=1&channel=' . $updateChannel; + $url = ManiaControl::URL_WEBSERVICE . 'versions?update=1¤t=1&channel=' . $updateChannel; $this->maniaControl->fileReader->loadFile($url, function ($dataJson, $error) use (&$function, $ignoreVersion) { $versions = json_decode($dataJson);