User:Pcj/LoadArmoryData.php
From WoWWiki
< User:Pcj
<?php
header('Content-type: text/javascript');
ini_set('user_agent','Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070101 Firefox/2.0.0.4');
switch ($_GET["l"]) {
case "eu":
$loc = "eu";
break;
default:
$loc = "www";
}
$realm = $_GET["r"];
$character = $_GET["n"];
$charUrl = 'http://' . $loc . '.wowarmory.com/character-sheet.xml?r=' . $realm . '&n=' . $character;
$attributes = "";
if ($_GET["a"]) {
$attributes = explode(",", $_GET["a"]);
}
echo "// Retrieved from ",$charUrl,"\n\n";
echo "items = new Array();\n";
$charXml = simplexml_load_file($charUrl);
foreach($charXml->xpath("//item") as $item) {
$itemXml = simplexml_load_file("http://www.wowarmory.com/item-info.xml?i=" . $item['id']);
$itemName = reset($itemXml->xpath("//itemInfo/item/@name"));
echo "items[\"slot ".$item['slot']."\"] = \"".$itemName[0]."\";\n";
if ($attributes) {
foreach($attributes as $attribute) echo "items[\"slot ".$item['slot']."-".$attribute."\"] = \"".$item[$attribute]."\";\n";
}
}
?>