The following wored on my test machine, so if someone else is having the issue as well it may fix it.
The issue is that the non-curl method of getting the data leaves a header before the XML returned from the Blizz servers. This needs to be stripped off before it's passed back up for processing.
I've modified the function getContentFileSocket in functions.general.php:
- Code: Select all
function getContentFileSocket($host, $page, $args, $sendAsBrowser = true) {
global $addon_conf;
$request = "/" . $page . "?" . $args;
$useragent = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2";
// $useragent = "User-Agent: Firefox/2";
$cookie = "cookieLangId=".$addon_conf['ArmorySync']['ArmoryLocale'].";";
$content = '';
if ($addon_conf['ArmorySync']['DebugLevel'] >= 1) {
print "GetContentFileSocket: " . $request. ", " . $sendAsBrowser . ", " . $useragent . "<br>";
}
if ($fp = fsockopen($host, 80, $errno, $errstr, 30)) {
stream_set_timeout($fp, 30);
$buffer = '';
$headers =
"GET $request HTTP/1.0\r\n" .
"Host: $host\r\n".
(($sendAsBrowser) ? $useragent : "") .
//"Content-Length: " . strlen($request) . "\r\n" .
"\r\nConnection: close\r\n".
"Cookie: $cookie\r\n".
"\r\n";
if ($addon_conf['ArmorySync']['DebugLevel'] >= 1) {
print $headers . "<br>";
}
fwrite($fp, $headers);
while (!feof($fp)) {
$content .= fread($fp, 8192);
}
fclose($fp);
} else {
//Throw Error
print "CRITICAL ERROR - socket not connected";
}
if ($addon_conf['ArmorySync']['DebugLevel'] >= 2) {
print $content. "<br>";
}
//Now split off the HTML header..
//anything up to the first <?xml need to go
$pos = stripos ($content, '<?xml');
if ($pos != 0){
//Need to trim header off..
$content = substr ($content, $pos);
}
// print "<br><br><hr><textarea>$content</textarea><hr><br><br>";
return $content;
}
As usual, I'm not a HUGE php developer, so I looked up the functions to do what I needed, if there's a better way, let me know!
Pugs_