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