file util bugfix

This commit is contained in:
Steffen Schröder 2014-06-12 16:41:26 +02:00
parent 43a2e6b075
commit c95b08d304

View File

@ -25,14 +25,19 @@ abstract class FileUtil {
return null; return null;
} }
$urlData = parse_url($url); $urlData = parse_url($url);
$host = $urlData['host'];
$port = (isset($urlData['port']) ? $urlData['port'] : 80); $port = (isset($urlData['port']) ? $urlData['port'] : 80);
$urlQuery = (isset($urlData['query']) ? '?' . $urlData['query'] : ''); $urlQuery = (isset($urlData['query']) ? '?' . $urlData['query'] : '');
$fsock = fsockopen($urlData['host'], $port); $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); stream_set_timeout($fsock, 3);
$query = 'GET ' . $urlData['path'] . $urlQuery . ' HTTP/1.0' . PHP_EOL; $query = 'GET ' . $urlData['path'] . $urlQuery . ' HTTP/1.0' . PHP_EOL;
$query .= 'Host: ' . $urlData['host'] . PHP_EOL; $query .= 'Host: ' . $host . PHP_EOL;
$query .= 'Content-Type: ' . $contentType . PHP_EOL; $query .= 'Content-Type: ' . $contentType . PHP_EOL;
$query .= 'User-Agent: ManiaControl v' . ManiaControl::VERSION . PHP_EOL; $query .= 'User-Agent: ManiaControl v' . ManiaControl::VERSION . PHP_EOL;
$query .= PHP_EOL; $query .= PHP_EOL;