From 1aa143238453f5fda2895ece1b15b9906cf42c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Fri, 27 Jun 2014 00:42:19 +0200 Subject: [PATCH] deprecated FileUtil loadFile() method --- application/core/Files/FileUtil.php | 56 +++-------------------------- 1 file changed, 5 insertions(+), 51 deletions(-) diff --git a/application/core/Files/FileUtil.php b/application/core/Files/FileUtil.php index 0c7a222a..1905db01 100644 --- a/application/core/Files/FileUtil.php +++ b/application/core/Files/FileUtil.php @@ -3,7 +3,6 @@ namespace ManiaControl\Files; use ManiaControl\Logger; -use ManiaControl\ManiaControl; use ManiaControl\Utils\Formatter; /** @@ -16,57 +15,12 @@ use ManiaControl\Utils\Formatter; abstract class FileUtil { /** - * Load a remote file - * - * @param string $url - * @param string $contentType - * @return string + * @deprecated + * @see \ManiaControl\Files\WebReader */ - public static function loadFile($url, $contentType = 'UTF-8') { - if (!$url) { - return null; - } - $urlData = parse_url($url); - $host = $urlData['host']; - $port = (isset($urlData['port']) ? $urlData['port'] : 80); - $urlQuery = (isset($urlData['query']) ? '?' . $urlData['query'] : ''); - - $fsock = fsockopen($host, $port); - if (!is_resource($fsock)) { - trigger_error("Couldn't open socket connection to '{$host}' on port '{$port}'!"); - return null; - } - stream_set_timeout($fsock, 3); - - $query = 'GET ' . $urlData['path'] . $urlQuery . ' HTTP/1.0' . PHP_EOL; - $query .= 'Host: ' . $host . PHP_EOL; - $query .= 'Content-Type: ' . $contentType . PHP_EOL; - $query .= 'User-Agent: ManiaControl v' . ManiaControl::VERSION . PHP_EOL; - $query .= PHP_EOL; - - fwrite($fsock, $query); - - $buffer = ''; - $info = array('timed_out' => false); - while (!feof($fsock) && !$info['timed_out']) { - $buffer .= fread($fsock, 1024); - $info = stream_get_meta_data($fsock); - } - fclose($fsock); - - if ($info['timed_out'] || !$buffer) { - return null; - } - if (substr($buffer, 9, 3) !== '200') { - return null; - } - - $result = explode("\r\n\r\n", $buffer, 2); - if (count($result) < 2) { - return null; - } - - return $result[1]; + public static function loadFile($url) { + $response = WebReader::loadUrl($url); + return $response->getContent(); } /**