replaced deprecated fileutil method by webreader

This commit is contained in:
Steffen Schröder 2014-06-27 01:18:55 +02:00
parent 2d78c75155
commit fc73510e8d
4 changed files with 21 additions and 13 deletions

View File

@ -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));
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;