TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-05-2010, 09:16 AM   #1 (permalink)
The Visitor
 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Yanayaya is on a distinguished road
Default Warcarft Project

Hello everyone, tis me, the new guy.

I have been working on a PHP page that talks to the Warcraft Armory. There are a mountain of scripts out there that do this, but I took one and worked on refining it someone to serve my needs for what I was looking to accomplish. None the less my code is not working and I was wondering if you peeps would be kind enough to have a scan through it and help me identify why it is failing to run.

PHP Code:
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 ($chCURLOPT_URL$url);
    
curl_setopt ($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt ($chCURLOPT_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);

PHP Code:
    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>';
    } 
The idea behind this script it to simply get my own guild roster from the armory and display it, with some specific information such as gender and race.

It was working only days ago and today it appears to want to throw up an Internal Server Error 500 and I dont know why so I am hoping to have my code validated. I dont have much control over the server however as it is paid for hosting.

Last edited by Yanayaya : 04-05-2010 at 11:41 AM.
Yanayaya is offline  
Reply With Quote
Old 04-05-2010, 05:20 PM   #2 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,298
Thanks: 17
Village Idiot is on a distinguished road
Default

When a script fails after working it means that it is an external issue. In this instace, it appears that your external factors are the server and the warcraft database, this means that one of the two must be throwing an error. Considering it is a 500 and you have no heard similar situations ariasing with the warcraft API, I would guess that it is a server error. Do other PHP scripts work? If they do try to figure out which command is throwing the fit and go form there.
__________________

Village Idiot is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Planning your project Village Idiot Absolute Beginners 13 06-17-2009 02:46 PM
Freelance Suite: Client & Project Management Software CLCook Show Off 2 09-14-2008 10:50 AM
News - Phlox Project codefreek TalkPHP Developer Team 0 07-08-2008 08:22 PM
a decision has been made read for an update on the project codefreek TalkPHP Developer Team 9 07-02-2008 09:31 PM
Project Manager Nor Show Off 7 12-17-2007 07:51 PM


All times are GMT. The time now is 09:45 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design