Page 1 of 1

Wacraft Project

Posted: Mon Apr 05, 2010 4:44 am
by Yanayaya
Oh the joys. Well I have been given a project to carry out and the project is to make a PHP page that talks to Wacrafts Armory. With the armoy being XML the obvious choice is of course cURL. Anyways there are a mountain of scripts out there for talking to the armory. Which is fine. I took one and refined it a bit and cut it down to serve my own needs in terms of reporting the roster for my own guild and also some specific stats for my guild members too.

The problem is that, it was working....now it is not. In fact what I get now is an Internal Server Error 500 although I was hoping that I could perhaps have you kind people just have a quick look over my code and just confirm that it looks as it should do. I host my php script on paid for hosting, so I dont have control of htacces files or anything. Like I said it was actually working and it seems to have hit the floor over night and I am not sure why. I cannot remember if I was making changes last week so hence...I have posted my code for review.

Thank you very much in advance.

Code priot to <body>

Code: Select all

function return_class($classid) {
    switch ($classid) {
        case 1: $class = "<img src=\"http://eu.wowarmory.com/_images/icons/class/1.gif\">"; break;
        case 2: $class = "<img src=\"http://eu.wowarmory.com/_images/icons/class/2.gif\">"; break;
        case 3: $class = "<img src=\"http://eu.wowarmory.com/_images/icons/class/3.gif\">"; break;
        case 4: $class = "<img src=\"http://eu.wowarmory.com/_images/icons/class/4.gif\">"; break;
        case 5: $class = "<img src=\"http://eu.wowarmory.com/_images/icons/class/5.gif\">"; break;
        case 6: $class = "<img src=\"http://eu.wowarmory.com/_images/icons/class/6.gif\">"; break;
        case 7: $class = "<img src=\"http://eu.wowarmory.com/_images/icons/class/7.gif\">"; break;
        case 8: $class = "<img src=\"http://eu.wowarmory.com/_images/icons/class/8.gif\">"; break;
        case 9: $class = "<img src=\"http://eu.wowarmory.com/_images/icons/class/9.gif\">"; break;
		case 11: $class = "<img src=\"http://eu.wowarmory.com/_images/icons/class/11.gif\">"; break;
    }
    return $class;
}
function return_rank($rankid) {        // Adjust the names here for the guild rank names.  0 is always the Guild owner
    switch ($rankid) {
        case 0: $class = "not the Messiah"; break;
        case 1: $class = "Black Knight"; break;
        case 2: $class = "HolyHandgrenade"; break;
        case 3: $class = "Lumberjack"; break;
        case 4: $class = "Mr Creosote"; break;
		case 5: $class = "Assface"; break;
        case 6: $class = "Dead Fish"; break;
    }
    return $class;
}  

function return_race($raceid, $sex) {
    switch ($raceid) {
        case 1: 
			if ($sex == "0") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/1-0.gif\">M";} 
			if ($sex == "1") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/1-1.gif\">F";} 
			break;
		case 2: 
			if ($sex == "0") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/2-0.gif\">M";} 
			if ($sex == "1") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/2-1.gif\">F";} 
			break;
        case 3: 
			if ($sex == "0") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/3-0.gif\">M";}
			if ($sex == "1") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/3-1.gif\">F";} 
			break;
        case 4: 
			if ($sex == "0") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/4-0.gif\">M";} 
			if ($sex == "1") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/4-1.gif\">F";} 
			break;
        case 5: 
			if ($sex == "0") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/5-0.gif\">M";} 
			if ($sex == "1") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/5-1.gif\">F";} 
			break;
        case 6: 
			if ($sex == "0") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/6-0.gif\">M";} 
			if ($sex == "1") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/6-1.gif\">F";} 
			break;
        case 7: 
			if ($sex == "0") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/7-0.gif\">M";} 
			if ($sex == "1") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/7-1.gif\">F";} 
			break;
        case 8: 
			if ($sex == "0") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/8-0.gif\">M";} 
			if ($sex == "1") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/8-1.gif\">F";} 
			break;
        case 10:
			if ($sex == "0") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/10-0.gif\">M";} 
			if ($sex == "1") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/10-1.gif\">F";} 
			break;
        case 11: 
			if ($sex == "0") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/11-0.gif\">M";}
			if ($sex == "1") {$race = "<img src=\"http://eu.wowarmory.com/_images/icons/race/11-1.gif\">F";} 
			break;
    }
    return $race;
}
	$url = 'http://eu.wowarmory.com/guild-info.xml?r=Agamaggan&gn=Ministry+of+Silly+Walks';
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt ($ch, CURLOPT_USERAGENT,  "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
	$rosterxml = curl_exec($ch);  
	if($rosterxml != ""){$xml = new SimpleXMLElement($rosterxml);
}

Code inside <body></body>

Code: Select all

foreach ($xml->guildInfo->guild->members->character as $char) {
    $toonclass = return_class($char['classId']);
    $toonrace = return_race($char['raceId'], $char['genderId']);
    $toonrank = return_rank($char['rank']);
	echo "\n<td><a class=\"link\" href=\"http://eu.wowarmory.com/character-sheet.xml?r=Agamaggan&cn={$char['name']}\">{$char['name']}</a></td>";
    echo '<td>' . $toonclass . '</td> ';
    echo '<td>' . $toonrace . '</td> ';
    echo '<td>' . $char['level'] . '</td> ';
    echo "\n<td><a class=\"link\" href=\"http://eu.wowarmory.com/character-achievements.xml?r=Agamaggan&cn={$char['name']}&gn=Ministry+of+Silly+Walks\">{$char['achPoints']}</a></td>";
	echo '<td><p>' . $toonrank . '</p></td></tr>';
	}	

Re: Wacraft Project

Posted: Mon Apr 05, 2010 10:37 am
by Technocrat
Sounds like a hosting issue. I took your code and pasted it on my server and it worked as expected.