replaced deprecated fileutil method by webreader
This commit is contained in:
		| @@ -3,10 +3,10 @@ | ||||
| namespace ManiaControl; | ||||
|  | ||||
| use ManiaControl\Callbacks\Callbacks; | ||||
| use ManiaControl\Files\FileUtil; | ||||
| use ManiaControl\Plugins\PluginManager; | ||||
| use ManiaControl\Update\UpdateManager; | ||||
| use ManiaControl\Utils\Formatter; | ||||
| use ManiaControl\Utils\WebReader; | ||||
| use Maniaplanet\DedicatedServer\Xmlrpc\TransportException; | ||||
|  | ||||
| /** | ||||
| @@ -142,12 +142,13 @@ class ErrorHandler { | ||||
| 			$info = base64_encode($json); | ||||
|  | ||||
| 			$url      = ManiaControl::URL_WEBSERVICE . 'errorreport?error=' . urlencode($info); | ||||
| 			$response = FileUtil::loadFile($url); | ||||
| 			$success  = json_decode($response); | ||||
| 			$response = WebReader::loadUrl($url); | ||||
| 			$content  = $response->getContent(); | ||||
| 			$success  = json_decode($content); | ||||
| 			if ($success) { | ||||
| 				Logger::log('Error-Report successful!'); | ||||
| 			} else { | ||||
| 				Logger::log('Error-Report failed! ' . print_r($response, true)); | ||||
| 				Logger::log('Error-Report failed! ' . print_r($content, true)); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| @@ -454,12 +455,13 @@ class ErrorHandler { | ||||
| 			$info = base64_encode($json); | ||||
|  | ||||
| 			$url      = ManiaControl::URL_WEBSERVICE . 'errorreport?error=' . urlencode($info); | ||||
| 			$response = FileUtil::loadFile($url); | ||||
| 			$success  = json_decode($response); | ||||
| 			$response = WebReader::loadUrl($url); | ||||
| 			$content  = $response->getContent(); | ||||
| 			$success  = json_decode($content); | ||||
| 			if ($success) { | ||||
| 				Logger::log('Exception successfully reported!'); | ||||
| 			} else { | ||||
| 				Logger::log('Exception-Report failed! ' . print_r($response, true)); | ||||
| 				Logger::log('Exception-Report failed! ' . print_r($content, true)); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
|   | ||||
| @@ -153,7 +153,7 @@ class PlayerActions { | ||||
| 			} catch (FaultException $exception) { | ||||
| 				// TODO: replace by more specific exception "there are too many ..." | ||||
| 				$this->maniaControl->chat->sendException($exception, $admin); | ||||
| 				return; | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
|   | ||||
| @@ -11,10 +11,10 @@ use FML\Script\Features\Paging; | ||||
| use FML\Script\Script; | ||||
| use ManiaControl\Admin\AuthenticationManager; | ||||
| use ManiaControl\Configurators\ConfiguratorMenu; | ||||
| use ManiaControl\Files\FileUtil; | ||||
| use ManiaControl\ManiaControl; | ||||
| use ManiaControl\Manialinks\ManialinkPageAnswerListener; | ||||
| use ManiaControl\Players\Player; | ||||
| use ManiaControl\Utils\WebReader; | ||||
|  | ||||
| /** | ||||
|  * Configurator for installing Plugins | ||||
| @@ -63,7 +63,8 @@ class PluginInstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener | ||||
| 		$pageFrame   = null; | ||||
|  | ||||
| 		$url        = ManiaControl::URL_WEBSERVICE . 'plugins'; | ||||
| 		$dataJson   = FileUtil::loadFile($url); | ||||
| 		$response   = WebReader::loadUrl($url); | ||||
| 		$dataJson   = $response->getContent(); | ||||
| 		$pluginList = json_decode($dataJson); | ||||
| 		$index      = 0; | ||||
|  | ||||
|   | ||||
| @@ -14,6 +14,7 @@ use ManiaControl\Plugins\Plugin; | ||||
| use ManiaControl\Plugins\PluginInstallMenu; | ||||
| use ManiaControl\Plugins\PluginManager; | ||||
| use ManiaControl\Plugins\PluginMenu; | ||||
| use ManiaControl\Utils\WebReader; | ||||
|  | ||||
| /** | ||||
|  * Manager checking for ManiaControl Plugin Updates | ||||
| @@ -197,7 +198,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis | ||||
| 	 */ | ||||
| 	public function getPluginsUpdates() { | ||||
| 		$url        = ManiaControl::URL_WEBSERVICE . 'plugins'; | ||||
| 		$dataJson   = FileUtil::loadFile($url); | ||||
| 		$response   = WebReader::loadUrl($url); | ||||
| 		$dataJson   = $response->getContent(); | ||||
| 		$pluginData = json_decode($dataJson); | ||||
| 		if (!$pluginData || empty($pluginData)) { | ||||
| 			return false; | ||||
| @@ -234,7 +236,9 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis | ||||
| 	 * @param bool             $update | ||||
| 	 */ | ||||
| 	private function installPlugin(PluginUpdateData $pluginUpdateData, Player $player = null, $update = false) { | ||||
| 		$this->maniaControl->fileReader->loadFile($pluginUpdateData->url, function ($updateFileContent, $error) use (&$pluginUpdateData, &$player, &$update) { | ||||
| 		$this->maniaControl->fileReader->loadFile($pluginUpdateData->url, function ($updateFileContent, $error) use ( | ||||
| 			&$pluginUpdateData, &$player, &$update | ||||
| 		) { | ||||
| 			if (!$updateFileContent || $error) { | ||||
| 				$message = "Error loading Update Data for '{$pluginUpdateData->pluginName}': {$error}!"; | ||||
| 				if ($player) { | ||||
| @@ -379,7 +383,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis | ||||
| 		/** @var Plugin $pluginClass */ | ||||
| 		$pluginId      = $pluginClass::getId(); | ||||
| 		$url           = ManiaControl::URL_WEBSERVICE . 'plugins/' . $pluginId; | ||||
| 		$dataJson      = FileUtil::loadFile($url); | ||||
| 		$response      = WebReader::loadUrl($url); | ||||
| 		$dataJson      = $response->getContent(); | ||||
| 		$pluginVersion = json_decode($dataJson); | ||||
| 		if (!$pluginVersion) { | ||||
| 			return false; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user