 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
|
 |
|
 |
08-06-2009, 05:53 PM
|
#121 (permalink)
|
|
The Visitor
Join Date: Aug 2009
Posts: 3
Thanks: 3
|
Hello,
Can you send a part of the script to tray it ?
Thank you in advance.
|
|
|
|
08-16-2009, 12:43 AM
|
#122 (permalink)
|
|
The Visitor
Join Date: Aug 2009
Posts: 1
Thanks: 0
|
Very interesting thread, a lot of useful scripts here!
I'm trying to make a guild-bank system, but I can't seem to get a workaround the cUrl authentication.
I used Kirks' script, and after a few modification it looks like this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
</head>
<body>
<?php
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$loginvars = 'accountName=' . $username . '&password=' . $password;
$url = 'https://eu.battle.net/login/login.xml?ref=http%3A%2F%2Feu.wowarmory.com%2Fvault%2Fguild-bank-contents.xml%3Fr%3DTalnivarr%26gn%3DVrede&app=armory';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $loginvars);
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");
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_COOKIEJAR, '../hidden/cookie.txt');
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,15);
curl_setopt ($ch, CURLOPT_TIMEOUT,30);
$results = curl_exec($ch);
curl_close($ch);
if (($results) == ('')){
echo 'Failed to get XML!';
}
else
{
$xml = new SimpleXMLElement($results); // line 34
foreach ($xml->guildInfo->guildBank->items->children() as $items) {
$name = $items['name'];
$icon = $items['icon'];
$id = $items['id'];
$quantity = $items['quantity'];
$subtypeLoc = $items['subtypeLoc'];
$type = $items['type'];
echo $name;
echo '<br/>';
}
/*
// $xml = simplexml_load_file('xml.xml');
// $results = simplexml_load_string($results);
// $guildxml = new SimpleXMLElement($results);
*/
if (strstr($results, "Invalid account name or password")) {
echo "Invalid account name or password<br>";
}
elseif (strstr($results, "Account name required")) {
echo "Invalid account name or password<br>";
}
elseif (strstr($results, "Password required")) {
echo "Invalid account name or password<br>";
}
elseif (strstr($results, "Authenticator code required")) {
echo "Invalid Authenticator code<br>";
}
elseif (strstr($results, "Login failed")) {
echo "Invalid account name or password<br>";
}
else {
echo $results;
}
}
}
else {
?>
<form action="#" id="loginForm" method="post">
Account Name<input id="username"name="username" type="text" /><br>
Password<input id="password" name="password" type="password" /><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
}
?>
</body>
</html>
The $results variable is emtpy. If I run the script without the IF, I get this errormessage:
Code:
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\xampp\htdocs\bank\test.php:34 Stack trace: #0 C:\xampp\htdocs\bank\test.php(34): SimpleXMLElement->__construct('') #1 {main} thrown in C:\xampp\htdocs\bank\test.php on line 34
Now my experience with cUrl is pretty limited, so I might do some obvious mistake here..
Any ideas?
|
|
|
|
08-19-2009, 01:21 PM
|
#123 (permalink)
|
|
The Visitor
Join Date: Aug 2009
Posts: 1
Thanks: 0
|
Very helpful thread, thanks a bunch!
I just have one small problem, I choose to load the entire XML into a DB text-field, and only update it every 12 hours.
Only problem is; I'm having trouble sorting the outcome of the list by rank, since its still one piece of text, I don't want to split up the XML before loading it into the DB.
I just want to know if there's a easy way to sort my list by rank.
Here's what I got so far:
Code:
//Show the XML from the db on the site
$doc2 = DOMDocument::loadXML($writeData['xml_document']);
$memberList = $doc2->getElementsByTagName('character'); //Find members
foreach($memberList as $toon){
$data = array(
'NAME' => $toon->getAttribute("name"),
'RACE' => $toon->getAttribute("raceId"),
'LEVEL' => $toon->getAttribute("level"),
'CLASS' => $toon->getAttribute("class"),
'GENDER' => $toon->getAttribute("genderId"),
'RANK' => $toon->getAttribute("rank"),
'ACHPOINTS' => $toon->getAttribute("achPoints"),
'URI' => $toon->getAttribute("url"),
);
if ($data['LEVEL'] > 79){
array($data);
echo "Name: <a href=http://eu.wowarmory.com/character-sheet.xml?".$data['URI']." target='new'>".$data['NAME']."</a>";
echo " // Race: ".$data['RACE'];
echo " // Rank: ".$data['RANK'];
echo " // Sex: ".$data['GENDER'];
echo " // Achievement Points: ".$data['ACHPOINTS'];
echo " // Level: ".$data['LEVEL']."<br/>";
}}
I hope some can help me, thanks in advance.
|
|
|
|
08-21-2009, 01:56 PM
|
#124 (permalink)
|
|
The Visitor
Join Date: Feb 2009
Posts: 2
Thanks: 0
|
Quick question, how can I make so my gear outputs like on blizzards armory? So your head is on the headplace on the background picture etc etc? =/ Can't really get it to work.
|
|
|
|
09-08-2009, 01:32 PM
|
#125 (permalink)
|
|
The Visitor
Join Date: Sep 2009
Posts: 1
Thanks: 0
|
wow glad i found this thread, saved me a lot of time thanks!
anyone get the login script working? ive tinkered with it a bit and im not getting anywere yet. im wanting to login and grab motd, cant seem to get past the login tho.
|
|
|
|
11-05-2009, 02:24 PM
|
#126 (permalink)
|
|
The Visitor
Join Date: Nov 2009
Posts: 1
Thanks: 0
|
hey all, i have the following code, but it seems like it doesn't fetch the data from the wow armory. Anyone can see what it is?
thanks.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
1
<?php
$url = 'http://eu.wowarmory.com/guild-info.xml?r=Frostmane&gn=Our+Sick+Story&p=1';
$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);
foreach ($xml->guildInfo->guild->members->children() as $char) {
echo '<b>Name:</b> ' . $char['name'] . ' ';
echo '<b>Class:</b> ' . $char['class'] . ' ';
echo '<b>Level:</b> ' . $char['level'] . ' <br>';
}
}
else{
echo 'empty roster';
}
?>
2
</body>
</html>
|
|
|
|
11-06-2009, 08:30 AM
|
#127 (permalink)
|
|
The Acquainted
Join Date: Nov 2009
Location: nr Stratford-Upon-Avon
Posts: 136
Thanks: 3
|
Good, bad or just plain WRONG
Well, I've been lurking in the background watching this thread with interest as there are lots of elements I have been wanting to do being discussed here, and have slowly, with my nose in books and lots of head scratching got a working Roster :D (even if you are not impressed, I'm pleased)
Code:
<?php
function return_class($classid) {
switch ($classid) {
case 1:
$class = "Warrior";
break;
case 2:
$class = "Paladin";
break;
case 3:
$class = "Hunter";
break;
case 4:
$class = "Rogue";
break;
case 5:
$class = "Priest";
break;
case 6:
$class = "Death Knight";
break;
case 7:
$class = "Shaman";
break;
case 8:
$class = "Mage";
break;
case 9:
$class = "Warlock";
break;
case 11:
$class = "Druid";
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 = "Guild Manager";
break;
case 1:
$class = "Guild Manager";
break;
case 2:
$class = "Bank Access";
break;
case 3:
$class = "Advisor";
break;
case 4:
$class = "Raider";
break;
case 5:
$class = "Member";
break;
case 6:
$class = "Recruit";
break;
case 7:
$class = "Alt";
break;
}
return $class;
}
function return_race($raceid, $sex) {
switch ($raceid) {
case 1:
if ($sex == "0") {$race = "Human Male";}
if ($sex == "1") {$race = "Human Female";}
break;
case 2:
if ($sex == "0") {$race = "Orc Male";}
if ($sex == "1") {$race = "Orc Female";}
break;
case 3:
if ($sex == "0") {$race = "Dwarf Male";}
if ($sex == "1") {$race = "Dwarf Female";}
break;
case 4:
if ($sex == "0") {$race = "Night Elf Male";}
if ($sex == "1") {$race = "Night Elf Female";}
break;
case 5:
if ($sex == "0") {$race = "Undead Male";}
if ($sex == "1") {$race = "Undead Female";}
break;
case 6:
if ($sex == "0") {$race = "Tauren Male";}
if ($sex == "1") {$race = "Tauren Female";}
break;
case 7:
if ($sex == "0") {$race = "Gnome Male";}
if ($sex == "1") {$race = "Gnome Female";}
break;
case 8:
if ($sex == "0") {$race = "Troll Male";}
if ($sex == "1") {$race = "Troll Female";}
break;
case 10:
if ($sex == "0") {$race = "Blood Elf Male";}
if ($sex == "1") {$race = "Blood Elf Female";}
break;
case 11:
if ($sex == "0") {$race = "Draenei Male";}
if ($sex == "1") {$race = "Draenei Female";}
break;
}
return $race;
}
class armory {
const BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";
public $query;
public $server;
public $guild;
public $guildie;
public $page;
public function __construct ( $query, $server, $guild, $guildie, $page ) {
$this->query = $query;
$this->server = $server;
$this->guild = $guild;
$this->guildie = $guildie;
$this->page = $page;
} // end of __construct()
public function pull_xml() {
// change the first part of the $url to the armory link that you need
if( $this->query === 'roster' ){
$url = 'http://eu.wowarmory.com/guild-info.xml?r=' . urlencode($this->server) . '&n=' . urlencode($this->guild) . '&p=' . $this->page;
}elseif( $this->query === 'character' ){
$url = 'http://eu.wowarmory.com/character-sheet.xml?r=' . urlencode($this->server) . '&n=' . $this->guildie;
}
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt ($ch, CURLOPT_USERAGENT, self::BROWSER);
$url_string = curl_exec($ch);
curl_close($ch);
return simplexml_load_string($url_string);
} // end of pull_xml()
} // end class
$xml_obj = simplexml_load_string($xml);
$armory = new armory('roster', 'Khadgar', 'Aeturnus Recuso', NULL, NULL);
$xml = $armory->pull_xml();
?>
<HTML>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<table border=1 align=center width=50%>
<tr>
<th>Name</th><th>Class</th><th>Race</th><th>Level</th><th>Achievement Points</th>
</tr>
<?
foreach ($xml->guildInfo->guild->members->character as $char) {
$toonclass = return_class($char['classId']);
$toonrace = return_race($char['raceId'], $char['genderId']);
echo '<td>' . $char['name'] . '</td> ';
echo '<td>' . $toonclass . '</td> ';
echo '<td>' . $toonrace . '</td> ';
echo '<td>' . $char['level'] . '</td> ';
echo '<td>' . $char['achPoints'] . '</td></tr>';
// foreach ($xml->characterInfo->characterTab->professions as $prof);
// {
// echo $prof['name'];
// }
}
echo '</table>'
?>
The following bit of code for me is a handy one, but I cann't figure out how to get it working...
Code:
foreach ($xml->characterInfo->characterTab->professions as $prof);
{
echo $prof['name'];
}
With my limited understanding, the loop it runs in is looking at Guild info, and for the "profs" part to work I need to be in the char info ?
Code:
// change the first part of the $url to the armory link that you need
if( $this->query === 'roster' ){
$url = 'http://eu.wowarmory.com/guild-info.xml?r=' . urlencode($this->server) . '&n=' . urlencode($this->guild) . '&p=' . $this->page;
}elseif( $this->query === 'character' ){
$url = 'http://eu.wowarmory.com/character-sheet.xml?r=' . urlencode($this->server) . '&n=' . $this->guildie;
Now, not sure if am reading it wrong, (I must be) I need to set a var "$this->query" to "character" which would be $char['name'] withing the foreach loop so that I could pull the proffession info from the armoury....
Or, maybe I should just give up and go sit in a corner
Sooo, anyone any ideas ?
TIA
|
|
|
|
The Following User Says Thank You to maeltar For This Useful Post:
|
|
11-06-2009, 08:35 AM
|
#128 (permalink)
|
|
The Acquainted
Join Date: Nov 2009
Location: nr Stratford-Upon-Avon
Posts: 136
Thanks: 3
|
Quote:
Originally Posted by LeftRight
hey all, i have the following code, but it seems like it doesn't fetch the data from the wow armory. Anyone can see what it is?
thanks.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
1
<?php
$url = 'http://eu.wowarmory.com/guild-info.xml?r=Frostmane&gn=Our+Sick+Story&p=1';
$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);
foreach ($xml->guildInfo->guild->members->children() as $char) {
echo '<b>Name:</b> ' . $char['name'] . ' ';
echo '<b>Class:</b> ' . $char['class'] . ' ';
echo '<b>Level:</b> ' . $char['level'] . ' <br>';
}
}
else{
echo 'empty roster';
}
?>
2
</body>
</html>
|
Amazing, I can help you out !!!!
You are trying to grab an element
Code:
foreach ($xml->guildInfo->guild->members->children() as $char) {
change it to :-
Code:
foreach ($xml->guildInfo->guild->members->character as $char) {
And it will work..
|
|
|
11-06-2009, 08:39 AM
|
#129 (permalink)
|
|
The Acquainted
Join Date: Nov 2009
Location: nr Stratford-Upon-Avon
Posts: 136
Thanks: 3
|
Quote:
Originally Posted by deef
Very helpful thread, thanks a bunch!
I just have one small problem, I choose to load the entire XML into a DB text-field, and only update it every 12 hours.
Only problem is; I'm having trouble sorting the outcome of the list by rank, since its still one piece of text, I don't want to split up the XML before loading it into the DB.
I just want to know if there's a easy way to sort my list by rank.
Here's what I got so far:
Code:
//Show the XML from the db on the site
$doc2 = DOMDocument::loadXML($writeData['xml_document']);
$memberList = $doc2->getElementsByTagName('character'); //Find members
foreach($memberList as $toon){
$data = array(
'NAME' => $toon->getAttribute("name"),
'RACE' => $toon->getAttribute("raceId"),
'LEVEL' => $toon->getAttribute("level"),
'CLASS' => $toon->getAttribute("class"),
'GENDER' => $toon->getAttribute("genderId"),
'RANK' => $toon->getAttribute("rank"),
'ACHPOINTS' => $toon->getAttribute("achPoints"),
'URI' => $toon->getAttribute("url"),
);
if ($data['LEVEL'] > 79){
array($data);
echo "Name: <a href=http://eu.wowarmory.com/character-sheet.xml?".$data['URI']." target='new'>".$data['NAME']."</a>";
echo " // Race: ".$data['RACE'];
echo " // Rank: ".$data['RANK'];
echo " // Sex: ".$data['GENDER'];
echo " // Achievement Points: ".$data['ACHPOINTS'];
echo " // Level: ".$data['LEVEL']."<br/>";
}}
I hope some can help me, thanks in advance.
|
So you are throwing each toon's info into ONE field in a DB ?
Surely you would be much better off putting each element into it's own field in a table, you can then do so much more, so much easier...
|
|
|
12-30-2009, 10:39 PM
|
#130 (permalink)
|
|
The Visitor
Join Date: Dec 2009
Posts: 1
Thanks: 0
|
Special Characters Problem
Characters' names which containts special characters/symbols are not shown correctly...
For example:
Xö is shown as XΓΆ
Link to his profile
How can i fix it???
|
|
|
|
12-31-2009, 07:07 PM
|
#131 (permalink)
|
|
The Acquainted
Join Date: Nov 2009
Location: nr Stratford-Upon-Avon
Posts: 136
Thanks: 3
|
Set your HTML header to UTF-8
__________________
Thanks... Simon
Sex, Drugs & Linux Rules
|
|
|
01-11-2010, 05:50 PM
|
#132 (permalink)
|
|
The Visitor
Join Date: Jan 2010
Posts: 2
Thanks: 1
|
Sort the XML data?
Hey everyone! I've been following this thread and have developed a pretty killer roster/armory combo. However, i have one issue: I don't know how to sort the roster. I'd like to sort it by rank, then by character name.
What I've got so far populates the table with a link (the link being the name with a hyperlink pointing to my little character armory script in a greybox popup). I can share the stuff I put together to pull in the charact's gear/stats/etc if someone can help me out with the table sorting lol.
Here's the code:
Code:
<?php
echo '<head>';
echo '<script type="text/javascript">';
echo ' var GB_ROOT_DIR = "http://boundbybrotherhood.org/greybox/";';
echo '</script>';
echo '<script type="text/javascript" src="http://boundbybrotherhood.org/greybox/AJS.js"></script>';
echo '<script type="text/javascript" src="http://boundbybrotherhood.org/greybox/AJS_fx.js"></script>';
echo '<script type="text/javascript" src="http://boundbybrotherhood.org/greybox/gb_scripts.js"></script>';
echo '<link href="http://boundbybrotherhood.org/greybox//gb_styles.css" rel="stylesheet" type="text/css" ';
echo '</head>';
echo '<body bgcolor="#000000" link="#FF8000"> <font COLOR="#FFFFFF">';
function return_class($classid) {
switch ($classid) {
case 1:
$class = "Warrior";
break;
case 2:
$class = "Paladin";
break;
case 3:
$class = "Hunter";
break;
case 4:
$class = "Rogue";
break;
case 5:
$class = "Priest";
break;
case 6:
$class = "Death Knight";
break;
case 7:
$class = "Shaman";
break;
case 8:
$class = "Mage";
break;
case 9:
$class = "Warlock";
break;
case 11:
$class = "Druid";
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 = "-Grand Poobah";
break;
case 1:
$class = "-Poobah";
break;
case 2:
$class = "-Minor Poobah";
break;
case 3:
$class = "-Knight";
break;
case 4:
$class = "- ";
break;
case 5:
$class = "- ";
break;
case 6:
$class = "- ";
break;
case 7:
$class = "- ";
break;
}
return $class;
}
function return_race($raceid, $sex) {
switch ($raceid) {
case 1:
if ($sex == "0") {$race = "Human";}
if ($sex == "1") {$race = "Human";}
break;
case 2:
if ($sex == "0") {$race = "Orc";}
if ($sex == "1") {$race = "Orc";}
break;
case 3:
if ($sex == "0") {$race = "Dwarf";}
if ($sex == "1") {$race = "Dwarf";}
break;
case 4:
if ($sex == "0") {$race = "Night Elf";}
if ($sex == "1") {$race = "Night Elf";}
break;
case 5:
if ($sex == "0") {$race = "Undead";}
if ($sex == "1") {$race = "Undead";}
break;
case 6:
if ($sex == "0") {$race = "Tauren";}
if ($sex == "1") {$race = "Tauren";}
break;
case 7:
if ($sex == "0") {$race = "Gnome";}
if ($sex == "1") {$race = "Gnome";}
break;
case 8:
if ($sex == "0") {$race = "Troll";}
if ($sex == "1") {$race = "Troll";}
break;
case 10:
if ($sex == "0") {$race = "Blood Elf";}
if ($sex == "1") {$race = "Blood Elf";}
break;
case 11:
if ($sex == "0") {$race = "Draenei";}
if ($sex == "1") {$race = "Draenei";}
break;
}
return $race;
}
class armory {
const BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";
public $query;
public $server;
public $guild;
public $guildie;
public $page;
public function __construct ( $query, $server, $guild, $guildie, $page ) {
$this->query = $query;
$this->server = $server;
$this->guild = $guild;
$this->guildie = $guildie;
$this->page = $page;
} // end of __construct()
public function pull_xml() {
// change the first part of the $url to the armory link that you need
if( $this->query === 'roster' ){
$url = 'http://us.wowarmory.com/guild-info.xml?r=' . urlencode($this->server) . '&n=' . urlencode($this->guild) . '&p=' . $this->page;
}elseif( $this->query === 'character' ){
$url = 'http://us.wowarmory.com/character-sheet.xml?r=' . urlencode($this->server) . '&n=' . $this->guildie;
}
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt ($ch, CURLOPT_USERAGENT, self::BROWSER);
$url_string = curl_exec($ch);
curl_close($ch);
return simplexml_load_string($url_string);
} // end of pull_xml()
} // end class
$xml_obj = simplexml_load_string($xml);
$armory = new armory('roster', 'Perenolde', 'Bound by Brotherhood', NULL, NULL);
$xml = $armory->pull_xml();
echo '<table border=1 align=center width=100% class="sortable" id="sorter" >';
echo '<tr bgcolor="#333333"><FONT COLOR="#FF8000">';
echo '<th bgcolor="#333333"><FONT COLOR="#FF8000">Name</th><th bgcolor="#333333"><FONT COLOR="#FF8000">Rank</th><th bgcolor="#333333"><FONT COLOR="#FF8000">Level</th><th bgcolor="#333333"><FONT COLOR="#FF8000">Race</th><th bgcolor="#333333"><FONT COLOR="#FF8000">Class</th></tr>';
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 '<td><FONT COLOR="#FF8000"><A Href="http://www.boundbybrotherhood.org/armory/char_armory.php?guildie=' . $char['name'] . '" title="BBB Armory" rel="gb_page_center[523, 468]">' . $char['name'] . '</td> ';
echo '<td><FONT COLOR="#FFFFFF">' . $char['rank'] . $toonrank . '</td> ';
echo '<td><FONT COLOR="#FFFFFF">' . $char['level'] . '</td> ';
echo '<td><FONT COLOR="#FFFFFF">' . $toonrace . '</td> ';
echo '<td><FONT COLOR="#FFFFFF">' . $toonclass . '</td></tr>';
// foreach ($xml->characterInfo->characterTab->professions as $prof);
// {
// echo $prof['name'];
// }
}
echo '</table>';
?>
Note: I've tried a few of the table sorting javascripts out there to no avail. Any help would be greatly appreciated. and oh yeah... Thanks to everyone on here for the guidance. Couldn't have done it without you.
http://www.boundbybrotherhood.org/armory.php
if you'd like to see it in action.
|
|
|
|
01-11-2010, 06:04 PM
|
#133 (permalink)
|
|
The Visitor
Join Date: Jan 2010
Posts: 2
Thanks: 1
|
Quote:
Originally Posted by maeltar
Well, I've been lurking in the background watching this thread with interest as there are lots of elements I have been wanting to do being discussed here, and have slowly, with my nose in books and lots of head scratching got a working Roster :D (even if you are not impressed, I'm pleased)
Code:
<?php
function return_class($classid) {
switch ($classid) {
case 1:
$class = "Warrior";
break;
case 2:
$class = "Paladin";
break;
case 3:
$class = "Hunter";
break;
case 4:
$class = "Rogue";
break;
case 5:
$class = "Priest";
break;
case 6:
$class = "Death Knight";
break;
case 7:
$class = "Shaman";
break;
case 8:
$class = "Mage";
break;
case 9:
$class = "Warlock";
break;
case 11:
$class = "Druid";
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 = "Guild Manager";
break;
case 1:
$class = "Guild Manager";
break;
case 2:
$class = "Bank Access";
break;
case 3:
$class = "Advisor";
break;
case 4:
$class = "Raider";
break;
case 5:
$class = "Member";
break;
case 6:
$class = "Recruit";
break;
case 7:
$class = "Alt";
break;
}
return $class;
}
function return_race($raceid, $sex) {
switch ($raceid) {
case 1:
if ($sex == "0") {$race = "Human Male";}
if ($sex == "1") {$race = "Human Female";}
break;
case 2:
if ($sex == "0") {$race = "Orc Male";}
if ($sex == "1") {$race = "Orc Female";}
break;
case 3:
if ($sex == "0") {$race = "Dwarf Male";}
if ($sex == "1") {$race = "Dwarf Female";}
break;
case 4:
if ($sex == "0") {$race = "Night Elf Male";}
if ($sex == "1") {$race = "Night Elf Female";}
break;
case 5:
if ($sex == "0") {$race = "Undead Male";}
if ($sex == "1") {$race = "Undead Female";}
break;
case 6:
if ($sex == "0") {$race = "Tauren Male";}
if ($sex == "1") {$race = "Tauren Female";}
break;
case 7:
if ($sex == "0") {$race = "Gnome Male";}
if ($sex == "1") {$race = "Gnome Female";}
break;
case 8:
if ($sex == "0") {$race = "Troll Male";}
if ($sex == "1") {$race = "Troll Female";}
break;
case 10:
if ($sex == "0") {$race = "Blood Elf Male";}
if ($sex == "1") {$race = "Blood Elf Female";}
break;
case 11:
if ($sex == "0") {$race = "Draenei Male";}
if ($sex == "1") {$race = "Draenei Female";}
break;
}
return $race;
}
class armory {
const BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";
public $query;
public $server;
public $guild;
public $guildie;
public $page;
public function __construct ( $query, $server, $guild, $guildie, $page ) {
$this->query = $query;
$this->server = $server;
$this->guild = $guild;
$this->guildie = $guildie;
$this->page = $page;
} // end of __construct()
public function pull_xml() {
// change the first part of the $url to the armory link that you need
if( $this->query === 'roster' ){
$url = 'http://eu.wowarmory.com/guild-info.xml?r=' . urlencode($this->server) . '&n=' . urlencode($this->guild) . '&p=' . $this->page;
}elseif( $this->query === 'character' ){
$url = 'http://eu.wowarmory.com/character-sheet.xml?r=' . urlencode($this->server) . '&n=' . $this->guildie;
}
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt ($ch, CURLOPT_USERAGENT, self::BROWSER);
$url_string = curl_exec($ch);
curl_close($ch);
return simplexml_load_string($url_string);
} // end of pull_xml()
} // end class
$xml_obj = simplexml_load_string($xml);
$armory = new armory('roster', 'Khadgar', 'Aeturnus Recuso', NULL, NULL);
$xml = $armory->pull_xml();
?>
<HTML>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<table border=1 align=center width=50%>
<tr>
<th>Name</th><th>Class</th><th>Race</th><th>Level</th><th>Achievement Points</th>
</tr>
<?
foreach ($xml->guildInfo->guild->members->character as $char) {
$toonclass = return_class($char['classId']);
$toonrace = return_race($char['raceId'], $char['genderId']);
echo '<td>' . $char['name'] . '</td> ';
echo '<td>' . $toonclass . '</td> ';
echo '<td>' . $toonrace . '</td> ';
echo '<td>' . $char['level'] . '</td> ';
echo '<td>' . $char['achPoints'] . '</td></tr>';
// foreach ($xml->characterInfo->characterTab->professions as $prof);
// {
// echo $prof['name'];
// }
}
echo '</table>'
?>
The following bit of code for me is a handy one, but I cann't figure out how to get it working...
Code:
foreach ($xml->characterInfo->characterTab->professions as $prof);
{
echo $prof['name'];
}
With my limited understanding, the loop it runs in is looking at Guild info, and for the "profs" part to work I need to be in the char info ?
Code:
// change the first part of the $url to the armory link that you need
if( $this->query === 'roster' ){
$url = 'http://eu.wowarmory.com/guild-info.xml?r=' . urlencode($this->server) . '&n=' . urlencode($this->guild) . '&p=' . $this->page;
}elseif( $this->query === 'character' ){
$url = 'http://eu.wowarmory.com/character-sheet.xml?r=' . urlencode($this->server) . '&n=' . $this->guildie;
Now, not sure if am reading it wrong, (I must be) I need to set a var "$this->query" to "character" which would be $char['name'] withing the foreach loop so that I could pull the proffession info from the armoury....
Or, maybe I should just give up and go sit in a corner
Sooo, anyone any ideas ?
TIA
|
Profession Name:
$xml->characterInfo->characterTab->professions->skill[0][name]
Profession level:
$xml->characterInfo->characterTab->professions->skill[0][value]
Profession max level:
$xml->characterInfo->characterTab->professions->skill[0][max]
IE:
echo $xml->characterInfo->characterTab->professions->skill[0][name].':'. $xml->characterInfo->characterTab->professions->skill[0][value].'/'. $xml->characterInfo->characterTab->professions->skill[0][max];
would end up being something like:
Leatherworking: 439/450
I shortened mine with a variable though to $charinfo->professions->skill[0][name] etc.
Btw- skill[0] would be the first profession they picked up. skill[1] would be their second.
|
|
|
|
03-17-2010, 01:08 PM
|
#134 (permalink)
|
|
The Wanderer
Join Date: Jun 2009
Posts: 5
Thanks: 0
|
Another Update
Hey all,
UPDATE:
I have been really busy with a lot of IRL things lately, but I thought I would post this updated script. There are a lot of things I still haven't had time to implement.
STILL NEED TO DO:
- Complete character statistics retrieval.
- Updated the retrieval of the 50 last achievements.
- If there has been any structure changes to the official wow armory xml, I have not updated them. But in my tests everything is still working ok.
- Many more...
OK, ONTO THE REAL CODING...
I firstly want to say thank you for all this preliminary work...
It has been a tremendous help during the development of my own xml grabber...
Ok, so I wanted to share my own development with everyone..
What this script will do:- Connect to the Official WoW Armory
- Download an XML List of all the Characters in your guild
- With each Character in the Guild, it will download Info & Achievements
- Store the accumulated data as a PHP array, ready for export into a number of databases
- Displays the Array as raw XML, a SQL import Statement and a Sortable HTML Table
Here are a few notes on what I have accomplished...
- I had issues using the '->children()' object, so this solution does not use that feature...
- Due to loading limits imposed by the wow armory, I have written a XML caching system to attempt to download and save a new XML stream to a cache file. If you get a trashed response (like you have reached the quota or the site is offline for maintenance), it will load the last valid XML document you have cached...
- Every XML request is cached by default in the 'cache' directory...
- There are 3 outputs via the html. the raw XML, a SQL import statement and a sortable processed html grid with data from the XML... [SEE THE LIVE DEMO LINK]
- Inside the code I have parsed the xml into a multi-dimensional array for ease of sorting...
- The Last 5 Achievements are processed...
- All Gear / Items are parsed and stored correctly...
- I have managed to handle the special characters like 'å'... Read the comments below...
- If you want to store the data in a SQL server I would recommend using the language setting of 'utf8_general_ci'...
- When SELECT'ing the data from the SQL server, make sure you use "SET NAMES 'utf8'; SET CHARACTER SET 'utf8'; " before the SELECT statement. This way you get the same text encoding outputted by the SQL server.
LIVE DEMO [Only 3 Characters]: http://www.wingsofthefallen.com/wotf/roster.test.php
LIVE DEMO [All Characters, Takes time to load]: http://www.wingsofthefallen.com/wotf...t.php?all=true
///////////////////////////////////////////////////////////////////////////////////////
// Script: roster.test.php
// Author: Collective [ World of Warcraft Armory xml Grabber with cURL]
// Modified: DJRavine aka Adan Rehtla [DJRavine@WoWps.org]
// Date: 28/06/2009 11:29:54 PM
// Live Demo: http://www.wingsofthefallen.com/wotf/roster.test.php
// Guild Site: http://WingsOfTheFallen.com
// Guild Dev Site: http://WingsOfTheFallen.com/index2.php
///////////////////////////////////////////////////////////////////////////////////////
-------------------------------------------------------------------------
STEPS TO SUCCESSFULLY USE THIS SCRIPT
-------------------------------------------------------------------------- Make sure you have a webserver with PHP v5.x.x.
- Save both 'roster.test.php' and 'roster_functions.php' each to their own file and upload to your webserver.
- In the same directory as 'roster.php' and 'roster_functions.test.php' create a directory called 'cache'. This will be used to cache the XML files you stream from the wow armory.
- Set the permissions for the 'cache' directory to 775, or anything to allow the script to write files to that folder.
- Edit the $configs['blah'] in the top of the 'roster_functions.test.php' file to your discretion and save the file.
- Browse to the file with you favorite browser and it should look like my live demo.
NOTE: For Debug and Testing purposes, I have limited the script to only retrieve 3 characters. To correct this, just append this to the URL '?all=true'.
EG. http://www.wingsofthefallen.com/wotf...t.php?all=true
NOTE: This script has been minimally tested and may need tweaking for complete functionality, it is supplied in an 'as is' basis to aide your own development.
DON'T FORGET TO CLICK THE
'SAY THANKS' BUTTON BELOW
IF YOU FIND THIS POST USEFUL
roster.test.php
PHP Code:
<?php
///////////////////////////////////////////////////////////////////////////////////////
// Script: roster.test.php
// Author: Collective [http://www.talkphp.com/show-off/3281-world-warcraft-armory-xml-grabber-curl.html]
// Modified: DJRavine aka Adan Rehtla [DJRavine@WoWps.org]
// Date: 28/06/2009 11:29:54 PM
// Live Demo: http://www.wingsofthefallen.com/wotf/roster.test.php
// Guild Site: http://WingsOfTheFallen.com
// Guild Dev Site: http://WingsOfTheFallen.com/index2.php
///////////////////////////////////////////////////////////////////////////////////////
// INTERNAL PHP CHARSET TO UTF-8
mb_internal_encoding( 'UTF-8' );
header( 'Content-Type: text/html; charset=UTF-8' );
// INCLUDE EXTRA FUNCTIONS
include 'roster_functions.test.php';
// --- START: GET $_GET[""] VARIABLES ----------------------------
// GET: SORT FIELD
$sort_field = $_GET["sort"];
if($sort_field == ''){ $sort_field = 'level'; }
// GET: SORT DIRECTION
$sort_direction = $_GET["direction"];
if($sort_direction == ''){ $sort_direction = 'desc'; }
// GET: SORT DIRECTION
$override_process_all = $_GET["all"];
if($override_process_all == 'true') { $config['chars_to_process'] = -1; }
// --- END: GET $_GET[""] VARIABLES ----------------------------
// --- START: MAIN PHP PROCESSING ----------------------------
// PRINT THE HTML HEADER
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Guild XML Parser - '.htmlentities($config['guild_name']).' from '.htmlentities($config['server_name']).'</title>
</head><body><P><b> PLEASE WAIT FOR THE PAGE TO LOAD... DEPENDING ON THE OPTIONS SELECTED IT COULD TAKE A WHILE...</b><P>';
//alert( $config['server_name']." - ".$config['guild_name']);
// INITIALIZE THE ARMORY CLASS
$armory = new armory('roster', $config['server_name'], $config['guild_name'], NULL, NULL);
$xml_guild = $armory->pull_xml(); // PULL THE GUILD XML FROM THE WOW ARMORY
echo '<span style="font-size:75%;"><b>LOADED IN '.printLoadTime().'s</b></span><P>';
// XML SOURCE TEXT AREA
if ( $config['show_xml_source'] ) {
$latestGuildXMLfile = getXMLfile('guild-info'); // GET THE LATEST CACHE GUILD XML FILE
$cachedFile = $config['DIR_cache'].$latestGuildXMLfile['filename'];
$fh = fopen($cachedFile, 'r');
$theData = fread($fh, filesize($cachedFile));
fclose($fh);
echo '<br /><P><b>GUILD XML:</b><BR/><textarea rows="30" cols="180" wrap="off">';
echo $theData;
echo'</textarea><P>';
echo '<span style="font-size:75%;"><b>LOADED IN '.sec2hms(printLoadTime()).'s</b></span><P>';
}
// BUILD GUILD ARRAY FROM XML SOURCE
$array_Members_Basic = buildCharacterArray($xml_guild);
// PULL THE XML FOR EVERY CHARACTER IN THE GUILD AND ADD TO THE ARRAY
$array_Members = pullCharacterXML($armory, $array_Members_Basic);
// SORT GUILD ARRAY
$array_Members_sorted = sortCharacterArray($array_Members, $sort_field, $sort_direction);
// PRINT SQL IMPORT STATEMENT INSIDE A TEXTAREA
printSQLCharacterArray($array_Members_sorted,$xml_guild->guildInfo->guildHeader['count'],$xml_guild->guildInfo->guildHeader['battleGroup']);
echo '<span style="font-size:75%;"><b>LOADED IN '.sec2hms(printLoadTime()).'s</b></span><P>';
// PRINT GUILD ARRAY AS A TABLE
if ( $config['show_html_data_table'] ) {
if ( $config['show_html_data_sort'] ) {
printCharacterArray($array_Members_sorted, $sort_field, $sort_direction);
} else {
printCompleteCharacterArray($array_Members_sorted);
}
echo '<b>Showing '.count($array_Members_sorted).' / '.(string)$xml_guild->guildInfo->guildHeader['count'].' Guild Members...<br/></b> [NOTE: Only showing characters above level 10]<P>';
}
// PRINT TOTAL LOAD TIME
echo '<span style="font-size:75%;"><b>TOTAL LOAD TIME: '.sec2hms(printLoadTime()).'s</b></span><P>';
echo '</body></html>';
// --- END: MAIN PHP PROCESSING ----------------------------
// FOR DEBUG PURPOSES
//print_r($array_Members);
//print_r($array_Members_sorted);
?>
roster_functions.test.php
PHP Code:
<?php
///////////////////////////////////////////////////////////////////////////////////////
// Script: roster_functions.test.php
// Author: Collective [http://www.talkphp.com/show-off/3281-world-warcraft-armory-xml-grabber-curl.html]
// Modified: DJRavine aka Adan Rehtla [DJRavine@WoWps.org]
// Date: 28/06/2009 11:29:54 PM
// Live Demo: http://www.wingsofthefallen.com/wotf/roster.php
// Guild Site: http://WingsOfTheFallen.com
// Guild Dev Site: http://WingsOfTheFallen.com/index2.php
///////////////////////////////////////////////////////////////////////////////////////
// LOAD TIME VARS - !! DONT TOUCH !!
$m_time = explode(" ",microtime());
$m_time = $m_time[0] + $m_time[1];
$config['starttime'] = $m_time;
$config['round'] = 3; // The number of decimal places to round the micro time to.
// ---------------- EDIT THE BELOW SETTINGS ----------------
// SERVER AND GUILD SETTINGS
$config['server_name'] = 'Elune'; // Name of the WoW Realm
$config['guild_name'] = 'Wings of the Fallen'; // Name of your Guild
// $config['server_name'] = 'Marécage de Zangar'; // Name of the WoW Realm
// $config['guild_name'] = 'Lenwë Linwëlin'; // Name of your Guild
// THESE WILL BE STORED AS HTML ENTITIES FOR EASE OF DISPLAYING
// SETTINGS FOR THE GENERAL WEBSITE
$config['live_system'] = true; // 'TRUE' = Download XML & Cache; 'FALSE' = Cache Only
$config['base_filename'] = 'roster.test.php'; // Base script file name
$config['base_url'] = 'http://wingsofthefallen.com/wotf/'; // Base URL
$config['url_prefix_armory'] = 'http://www.wowarmory.com/'; // URL for the AMERICAN armory
// $config['url_prefix_armory'] = 'http://eu.wowarmory.com/'; // URL for the EUROPEAN armory
$config['url_prefix_char']=$config['url_prefix_armory'].'character-sheet.xml?'; // Use for Char links
// NOTE: THE BELOW DIRECTORY NEEDS TO HAVE WRITE ACCESS IN ORDER TO CACHE THE XML
$config['DIR_cache'] = 'cache/'; // Directory where the XML cache files are stored
// NOTE: THE ABOVE DIRECTORY NEEDS TO HAVE WRITE ACCESS IN ORDER TO CACHE THE XML
$config['days_to_cache'] = 3; // How many days to keep cached files for
$config['DIR_sql'] = 'sql/'; // Directory where the SQL files are stored
// LOADING BAR
$config['loading_bar'] = 100; // How many characters in the loading bar
$config['loading_bar_mask'] = "="; // The loading bar symbol
// OUTPUT DISPLAY SETTING
// WARNING: TURNING ALL OF THESE SETTINGS ON WILL TAKE A LOOONG TIME TO PROCESS AND WILL CONSUME A FAIR AMOUNT OF SERVER RESOURCES
// WARNING: I ONLY HAVE OVER 150 MEMBERS IN MY GUILD, WITH ALL THESE SETTINGS ON IT CAN TAKE UPTO AN HOUR TO PROCESS AND LOAD.
$config['show_xml_source'] = true; // 'TRUE' = Show XML Source; 'FALSE' = Hide XML Source
$config['show_sql_import_structure'] = true; // 'TRUE' = Show SQL Import Structure; 'FALSE' = Hide SQL Import Structure
$config['show_sql_import_data'] = true; // 'TRUE' = Show SQL Import Data; 'FALSE' = Hide SQL Import Data
$config['show_html_data_table'] = true; // 'TRUE' = Show HTML Data Table; 'FALSE' = Hide HTML Data Table
$config['show_html_data_sort'] = false; // 'TRUE' = Show HTML Data Table with sort functionality and only limited fields; 'FALSE' = Show HTML Data Table with every field
// SETTINGS FOR SQL STATEMENT GENERATION
$config['sql_database'] = 'wotf_character'; // SQL Database Name
$config['sql_table'] = 'guild_characters_test'; // SQL Table Name
// XML PARSING SETTINGS
// $config['min_char_level'] = 75; // Limits display parsing of Characters beyond a certain level. NOTE: Use '0' to process all characters. NOTE: Requires "$config['chars_to_process'] = -1;"
// $config['min_char_rank'] = 1; // Limits display to Guild Rank NOTE: Requires "$config['chars_to_process'] = -1;"
$config['equipable_items_number'] = 18; // How many equipable items on a character. !! DO NOT EDIT THIS !!
// DEBUG SETTINGS
$config['chars_to_process'] = 3; // How many characters to pull xml data for. NOTE: Use '-1' to process all characters.
$config['use_char_selction_list'] = false; // Select this option to only process characters names found in the "$config['char_selction_list']" array.
$config['char_selction_list'] = array( "Demoral", "Kyrå", "Orayn" ); // A list of characters to process, excluding all others. NOTE: Requires "$config['chars_to_process'] = -1;"
// ---------------- EDIT THE ABOVE SETTINGS ----------------
// -----------------------------------------------
// DO NOT EDIT BELOW THIS LINE
// -----------------------------------------------
//---------------------------------------------------
// CLASSES AND FUNCTIONS
//---------------------------------------------------
// DEFINE THE ARMORY CLASS
class armory {
// DEFINE THE ARMORY VARIABLES
const BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";
public $query;
public $server;
public $guild;
public $guildie;
public $page;
// CONSTRUCTOR FOR THE ARMORY OBJECT
public function __construct ( $query, $server, $guild, $guildie, $page ) {
$this->query = $query;
$this->server = $server;
$this->guild = $guild;
$this->guildie = $guildie;
$this->page = $page;
} // end of __construct()
// THIS WILL NOW DOWNLOAD AND CACHE THE XML FEED
// THEN IT WILL SEARCH THE XML CACHE FOR THE LATEST VALID XML FEED
public function pull_xml() {
global $config;
// change the first part of the $url to the armory link that you need
if( $this->query === 'roster' ){
$filename_type = 'guild-info';
$url = $config['url_prefix_armory'].$filename_type.'.xml?r=' . urlencode( utf8_encode( $this->server ) ) . '&n=' . urlencode( utf8_encode( $this->guild ) ) . '&p=' . $this->page;
} elseif( $this->query === 'character' ){
$filename_type = 'character-sheet';
$url = $config['url_prefix_armory'].$filename_type.'.xml?r=' . urlencode( utf8_encode( $this->server ) ) . '&n=' . $this->guildie;
} elseif( $this->query === 'achievement' ){
$filename_type = 'character-achievements';
$url = $config['url_prefix_armory'].$filename_type.'.xml?r=' . urlencode( utf8_encode( $this->server ) ) . '&n=' . $this->guildie;
}
//alert($url);
if ( $config['live_system'] ) {
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt ($ch, CURLOPT_USERAGENT, self::BROWSER);
$url_string = curl_exec($ch);
curl_close($ch);
echo ' -> <b>'.strtoupper($filename_type).'.XML LIVE FEED:</b> <a href="'.$url.'" target="_BLANK">'.$url.'</a><P>';
} else {
if( $this->query === 'roster' ){
echo '<b>NOTE: USING XML CACHE ONLY!!!</b><P>';
}
}
//alert($url_string);
// change the first part of the $url to the armory link that you need
if( $this->query === 'roster' ){
if ( $config['live_system'] ) {
cacheXMLfile($filename_type, $url_string); // CACHE THE GUILD XML STREAM
}
$latestGuildXMLfile = getXMLfile('guild-info'); // GET THE LATEST CACHE GUILD XML FILE
$url = $config['base_url'].$config['DIR_cache'].$latestGuildXMLfile['filename'];
$url_filesize = $latestGuildXMLfile['filesize'];
//echo "<P>RESULT -> ".$latestGuildXMLfile['filename']." - ".$latestGuildXMLfile['filesize']." - ".$latestGuildXMLfile['filetime']." <br /><br /><br /><br />";
} elseif( $this->query === 'character' ) {
$char_cache_filename = $filename_type.'-'.$this->guildie; // BUILD THE CHRACTER XML CACHE FILENAME
if ( $config['live_system'] ) {
cacheXMLfile($char_cache_filename, $url_string); // CACHE THE CHARACTER XML STREAM
}
$latestCharacterXMLfile = getXMLfile($char_cache_filename); // GET THE LATEST CACHE GUILD XML FILE
$url = $config['base_url'].$config['DIR_cache'].$latestCharacterXMLfile['filename'];
$url_filesize = $latestCharacterXMLfile['filesize'];
//echo "<P>RESULT -> ".$latestCharacterXMLfile['filename']." - ".$latestCharacterXMLfile['filesize']." - ".$latestCharacterXMLfile['filetime']." <br /><br /><br /><br />";
} elseif( $this->query === 'achievement' ) {
$char_cache_filename = $filename_type.'-'.$this->guildie; // BUILD THE CHRACTER XML CACHE FILENAME
if ( $config['live_system'] ) {
cacheXMLfile($char_cache_filename, $url_string); // CACHE THE CHARACTER XML STREAM
}
$latestCharacterXMLfile = getXMLfile($char_cache_filename); // GET THE LATEST CACHE GUILD XML FILE
$url = $config['base_url'].$config['DIR_cache'].$latestCharacterXMLfile['filename'];
$url_filesize = $latestCharacterXMLfile['filesize'];
//echo "<P>RESULT -> ".$latestCharacterXMLfile['filename']." - ".$latestCharacterXMLfile['filesize']." - ".$latestCharacterXMLfile['filetime']." <br /><br /><br /><br />";
}
//
if ( $url_filesize > 0 ) {
$url_string = simplexml_load_file($url) or die ("ERROR: Unable to load XML file! URL: ".$url);
echo ' -> <b>'.strtoupper($filename_type).'.XML CACHE:</b> <a href="'.$url.'" target="_BLANK">'.$url.'</a> - '.fileSizeInfo($url_filesize).' read...<P>';
} else {
$url_string = "";
}
return $url_string;
} // end of pull_xml()
} // end class
//------------------------------------------------------------------
// Display a Javascript Alert Box [FOR DEBUG PURPOSES]
function alert($textMessage) {
global $config;
print('<script language="javascript">alert("'.$textMessage.'")</script>');
}
//------------------------------------------------------------------
// Return the current load time
function printLoadTime() {
global $config;
$m_time = explode(" ",microtime());
$m_time = $m_time[0] + $m_time[1];
$endtime = $m_time;
$totaltime = ($endtime - $config['starttime']);
return (string)round($totaltime,$config['round']);
}
//------------------------------------------------------------------
// Convert seconds to '0h 0m 0s'
function sec2hms ($sec, $padHours = false) {
$hms = "";
$hours = intval(intval($sec) / 3600);
$hms .= ($padHours)
? str_pad($hours, 2, "0", STR_PAD_LEFT). ':'
: $hours. ':';
$minutes = intval(($sec / 60) % 60);
$hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';
$seconds = intval($sec % 60);
$hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
return $hms;
}
//------------------------------------------------------------------
// Convert bytes to '0TB 0GB 0MB 0MB 0kb'
function fileSizeInfo($size){
$i=0;
$iec = array("b", "kb", "mb", "gb", "tb", "pb", "eb", "zb", "yb");
while (($size/1024)>1) {
$size=$size/1024;
$i++;
}
return substr($size,0,strpos($size,'.')+4).$iec[$i];
}
//------------------------------------------------------------------
// Get the latest cached XML file from the cache directory
function getXMLfile( $XMLtype ) {
global $config;
// GET LATEST XML FILE
$new_file_size = 0;
$new_file_time = 0;
$new_file_name = "";
$old_file_date = time() - ($config['days_to_cache'] * 24 * 60 * 60);
$dir = opendir ("./".$config['DIR_cache']);
echo " <b>-> CHECKING XML CACHE [";
$filecount = count(glob("./".$config['DIR_cache']."*.xml"));
$filecount_current=0;
$loading_bar_list = array();
for( $i=1; $i<$config['loading_bar']; $i++ ) { $loading_bar_list[] = round($filecount/$i); }
while (false !== ($file = readdir($dir))) {
if (strpos($file, $XMLtype ) === false ) {
} else {
$file_size = filesize($config['DIR_cache'].$file);
$file_time = filemtime($config['DIR_cache'].$file);
if ( $file_size > 614 ) { // 614 BYTES 503 ERROR DOCUMENT // 651 BYTES CHAR ERROR PAGE
//echo "COMPARE -> '".$new_file_name."' '".$file."' <br /> ".$new_file_size."<=".$file_size." | ".$new_file_time."<".$file_time." |";
if ( $file_time >= $new_file_time ) { // CHECK IF ITS A NEWER FILE
//echo " [newer file]";
$new_file_size = $file_size;
$new_file_time = $file_time;
$new_file_name = $file;
}
//echo "<br />";
}
// REMOVE FILES OLDER THAN THE SPECIFIED TIME
if( $file_time < $old_file_date ) {
unlink($config['DIR_cache'].$file); //alert($config['DIR_cache'].$file);
}
}
if (in_array($filecount_current,$loading_bar_list)) echo $config['loading_bar_mask'];
$filecount_current++;
}
echo "] - DONE</b><P>";
return array( "filename" => $new_file_name, "filesize" => $new_file_size, "filetime" => $new_file_time );
}
//------------------------------------------------------------------
// Save XML Stream to the cache directory
function cacheXMLfile($filename, $XMLstream) {
global $config;
$XML_filename = $config['DIR_cache'].$filename.'-'.date('Y.m.d-H.i.s').'.xml';
$handle = fopen($XML_filename, "wb");
$numbytes = fwrite($handle, $XMLstream);
fclose($handle);
$url_filesize_obj = fileSizeInfo($numbytes);
echo ' -> <b>LIVE XML FEED CACHED TO XML FILE:</b> ./'.$XML_filename.' - '.fileSizeInfo($numbytes).' written...<P>';
}
//------------------------------------------------------------------
// For each of the characters in the supplied array, pull the XML for each and populate the character array.
function pullCharacterXML($armory, $charArray) {
global $config;
$countCharaters = 0;
$extendCharArray = array();
foreach ($charArray as $char) {
echo '<b>[ '.($countCharaters+1).' / '.count($charArray).' - '.sec2hms(printLoadTime()).'s ] PROCESSING CHARACTER -> \''.$char['name'].'\'...</b><P>';
// CHARACTER INFO
$char_armory = new armory('character', $config['server_name'], $config['guild_name'], $char['name'], NULL);
$xml_armory = $char_armory->pull_xml(); // PULL THE CHARACTER XML FROM THE WOW ARMORY
// ACHIEVEMENT INFO
$char_achievement = new armory('achievement', $config['server_name'], $config['guild_name'], $char['name'], NULL);
$xml_achievement = $char_achievement->pull_xml(); // PULL THE CHARACTER XML FROM THE WOW ARMORY
// BUILD CHARACTER ARRAY FROM XML SOURCE
$charArray[$countCharaters] = extendCharacterArray($xml_armory, $xml_achievement, $charArray[$countCharaters]);
$countCharaters++;
}
return $charArray;
}
//------------------------------------------------------------------
// Extend the Character Array from the supplied character XML stream
function extendCharacterArray($XMLstream, $XMLstreamAchievement, $char) {
global $config;
// PARSE DATA FROM THE CHAR XML SOURCE
// TITLES STRINGS
$char_obj = $XMLstream->characterInfo->character;
$current_title = $char_obj['prefix'].$char['name'].$char_obj['suffix'];
// DEPRECIATED - 1st JULY 2009
// $count_knowntitles = 0;
// $knowntitles_string = "";
// if ( count($XMLstream->characterInfo->characterTab->knownTitles->title) != 0 ) {
// foreach ($XMLstream->characterInfo->characterTab->knownTitles->title as $knowntitles) {
// if ( $count_knowntitles == 0 ) { $knowntitles_string .= $knowntitles['value'];
// } else { $knowntitles_string .= ", ".$knowntitles['value']; }
// $count_knowntitles++;
// }
// }
// REPLACE '%s' WITH CHARACTER NAME IN THE TITLES
// $current_title = str_replace("%s", $char['name'], $current_title);
// $knowntitles_string = str_replace("%s", $char['name'], $knowntitles_string);
// TALENT SPECS ARRAYS
$talentspec1 = $XMLstream->characterInfo->characterTab->talentSpecs->talentSpec[0];
$talentspec2 = $XMLstream->characterInfo->characterTab->talentSpecs->talentSpec[1];
// PROFESSIONS ARRAYS
$profession1 = $XMLstream->characterInfo->characterTab->professions->skill[0];
$profession2 = $XMLstream->characterInfo->characterTab->professions->skill[1];
// CHARACTER BARS ARRAYS
$characterbars = $XMLstream->characterInfo->characterTab->characterBars->secondBar;
// BASE STATS ARRAYS
$basestats_strength = $XMLstream->characterInfo->characterTab->baseStats->strength;
$basestats_agility = $XMLstream->characterInfo->characterTab->baseStats->agility;
$basestats_stamina = $XMLstream->characterInfo->characterTab->baseStats->stamina;
$basestats_intellect = $XMLstream->characterInfo->characterTab->baseStats->intellect;
$basestats_spirit = $XMLstream->characterInfo->characterTab->baseStats->spirit;
$basestats_armor = $XMLstream->characterInfo->characterTab->baseStats->armor;
// MELEE ARRAYS
$melee_mainHandDamage = $XMLstream->characterInfo->characterTab->melee->mainHandDamage;
$melee_offHandDamage = $XMLstream->characterInfo->characterTab->melee->offHandDamage;
$melee_mainHandSpeed = $XMLstream->characterInfo->characterTab->melee->mainHandSpeed;
$melee_offHandSpeed = $XMLstream->characterInfo->characterTab->melee->offHandSpeed;
$melee_power = $XMLstream->characterInfo->characterTab->melee->power;
$melee_hitRating = $XMLstream->characterInfo->characterTab->melee->hitRating;
$melee_critChance = $XMLstream->characterInfo->characterTab->melee->critChance;
$melee_expertise = $XMLstream->characterInfo->characterTab->melee->expertise;
// RANGED ARRAYS
$ranged_weaponSkill = $XMLstream->characterInfo->characterTab->ranged->weaponSkill;
$ranged_damage = $XMLstream->characterInfo->characterTab->ranged->damage;
$ranged_speed = $XMLstream->characterInfo->characterTab->ranged->speed;
$ranged_power = $XMLstream->characterInfo->characterTab->ranged->power;
$ranged_hitRating = $XMLstream->characterInfo->characterTab->ranged->hitRating;
$ranged_critChance = $XMLstream->characterInfo->characterTab->ranged->critChance;
// SPELL ARRAYS
$spell_bonusDamage = $XMLstream->characterInfo->characterTab->spell->bonusDamage;
$spell_critChance = $XMLstream->characterInfo->characterTab->spell->critChance;
$spell_hitRating = $XMLstream->characterInfo->characterTab->spell->hitRating;
$spell_manaRegen = $XMLstream->characterInfo->characterTab->spell->manaRegen;
$spell_hasteRating = $XMLstream->characterInfo->characterTab->spell->hasteRating;
// DEFENSES ARRAYS
$defenses_armor = $XMLstream->characterInfo->characterTab->defenses->armor;
$defenses_defense = $XMLstream->characterInfo->characterTab->defenses->defense;
$defenses_dodge = $XMLstream->characterInfo->characterTab->defenses->dodge;
$defenses_parry = $XMLstream->characterInfo->characterTab->defenses->parry;
$defenses_block = $XMLstream->characterInfo->characterTab->defenses->block;
$defenses_resilience = $XMLstream->characterInfo->characterTab->defenses->resilience;
// ITEMS ARRAYS
$items = array();
for( $i=0; $i<=$config['equipable_items_number']; $i++ ) { // SEED THE ITEMS ARRAY WITH '0' VALUES
$items[] = array(
"durability" => 0,
"gem0Id" => 0,
"gem1Id" => 0,
"gem2Id" => 0,
"icon" => 0,
"id" => 0,
"maxDurability" => 0,
"permanentenchant" => 0,
"randomPropertiesId" => 0,
"seed" => 0,
"slot" => $i
);
}
if( count($XMLstream->characterInfo->characterTab->items->item) != 0 ) {
foreach ( $XMLstream->characterInfo->characterTab->items->item as $item ) { // POPULATE THE KNOWN ITEMS
$items[((int)$item['slot'])] = array( // POPULATE THE ITEM VALUES TO THE ITEMS ARRAY
"durability" => $item['durability'],
"gem0Id" => $item['gem0Id'],
"gem1Id" => $item['gem1Id'],
"gem2Id" => $item['gem2Id'],
"icon" => $item['icon'],
"id" => $item['id'],
"maxDurability" => $item['maxDurability'],
"permanentenchant" => $item['permanentenchant'],
"randomPropertiesId" => $item['randomPropertiesId'],
"seed" => $item['seed'],
"slot" => $item['slot']
);
}
}
// GLYPHS
$glyphs0 = $XMLstream->characterInfo->characterTab->glyphs->glyph[0];
$glyphs1 = $XMLstream->characterInfo->characterTab->glyphs->glyph[1];
$glyphs2 = $XMLstream->characterInfo->characterTab->glyphs->glyph[2];
$glyphs3 = $XMLstream->characterInfo->characterTab->glyphs->glyph[3];
$glyphs4 = $XMLstream->characterInfo->characterTab->glyphs->glyph[4];
$glyphs5 = $XMLstream->characterInfo->characterTab->glyphs->glyph[5];
// ACHIEVEMENT SUMMARY
$achSummary = $XMLstream->characterInfo->summary;
// ACHIEVEMENT - LAST 5
$achievements = array();
$count_achievements = 0;
if( count($XMLstreamAchievement->achievements->summary->achievement) != 0 ) {
foreach ( $XMLstreamAchievement->achievements->summary->achievement as $achievement ) { // POPULATE THE KNOWN ACHIEVEMENTS
$achievements[$count_achievements] = array( // POPULATE THE ACHIEVEMENT VALUES TO THE ACHIEVEMENTS ARRAY
"categoryId" => $achievement['categoryId'],
"dateCompleted" => $achievement['dateCompleted'],
"desc" => $achievement['desc'],
"icon" => $achievement['icon'],
"id" => $achievement['id'],
"points" => $achievement['points'],
"title" => $achievement['title']
);
$count_achievements++;
}
}
// REBUILD THE CHARACTER ARRAY
$char_Array = array(
// BASIC INNFORMATION
"name" => $char['name'],
"level" => $char['level'],
"class" => $char['class'],
"gender" => $char['gender'],
"race" => $char['race'],
"rank" => $char['rank'],
"achPoints" => $char['achPoints'],
"url" => $char['url'],
// GET BATTLEGROUP & LAST MODIFIED TIME
"battleGroup" => $XMLstream->characterInfo->character['battleGroup'],
"lastModified" => $XMLstream->characterInfo->character['lastModified'],
// TITLES
"current_title" => addslashes($current_title),
// "known_titles" => $knowntitles_string,
// TALENT SPECS
"talent1_active" => $talentspec1['active'],
"talent1_group" => $talentspec1['group'],
"talent1_icon" => $talentspec1['icon'],
"talent1_prim" => $talentspec1['prim'],
"talent1_treeOne" => $talentspec1['treeOne'],
"talent1_treeTwo" => $talentspec1['treeTwo'],
"talent1_treeThree" => $talentspec1['treeThree'],
"talent2_active" => $talentspec2['active'],
"talent2_group" => $talentspec2['group'],
"talent2_icon" => $talentspec2['icon'],
"talent2_prim" => $talentspec2['prim'],
"talent2_treeOne" => $talentspec2['treeOne'],
"talent2_treeTwo" => $talentspec2['treeTwo'],
"talent2_treeThree" => $talentspec2['treeThree'],
// PROFESSIONS
"profession1_key" => $profession1['key'],
"profession1_name" => $profession1['name'],
"profession1_max" => $profession1['max'],
"profession1_value" => $profession1['value'],
"profession2_key" => $profession2['key'],
"profession2_name" => $profession2['name'],
"profession2_max" => $profession2['max'],
"profession2_value" => $profession2['value'],
// PVP
"pvp_honorable_kills" => $XMLstream->characterInfo->characterTab->pvp->lifetimehonorablekills['value'],
"pvp_arena_currency" => $XMLstream->characterInfo->characterTab->pvp->arenacurrency['value'],
// CHARACTER BARS
"characterbars1_value" => $XMLstream->characterInfo->characterTab->characterBars->health['effective'],
"characterbars2_value" => $characterbars['effective'],
"characterbars2_casting" => $characterbars['casting'],
"characterbars2_notCasting" => $characterbars['notCasting'],
"characterbars2_type" => $characterbars['type'],
// BASE STATS
"basestats_strength_attack" => $basestats_strength['attack'],
"basestats_strength_base" => $basestats_strength['base'],
"basestats_strength_block" => $basestats_strength['block'],
"basestats_strength_effective" => $basestats_strength['effective'],
"basestats_agility_armor" => $basestats_agility['armor'],
"basestats_agility_attack" => $basestats_agility['attack'],
"basestats_agility_base" => $basestats_agility['base'],
"basestats_agility_critHitPercent" => $basestats_agility['critHitPercent'],
"basestats_agility_effective" => $basestats_agility['effective'],
"basestats_stamina_base" => $basestats_stamina['base'],
"basestats_stamina_effective" => $basestats_stamina['effective'],
"basestats_stamina_health" => $basestats_stamina['health'],
"basestats_stamina_petBonus" => $basestats_stamina['petBonus'],
"basestats_intellect_base" => $basestats_intellect['base'],
"basestats_intellect_critHitPercent" => $basestats_intellect['critHitPercent'],
"basestats_intellect_effective" => $basestats_intellect['effective'],
"basestats_intellect_mana" => $basestats_intellect['mana'],
"basestats_intellect_petBonus" => $basestats_intellect['petBonus'],
"basestats_spirit_base" => $basestats_spirit['base'],
"basestats_spirit_effective" => $basestats_spirit['effective'],
"basestats_spirit_healthRegen" => $basestats_spirit['healthRegen'],
"basestats_spirit_manaRegen" => $basestats_spirit['manaRegen'],
"basestats_armor_base" => $basestats_armor['base'],
"basestats_armor_effective" => $basestats_armor['effective'],
"basestats_armor_percent" => $basestats_armor['percent'],
"basestats_armor_petBonus" => $basestats_armor['petBonus'],
// RESISTANCES
"resistances_arcane_value" => $XMLstream->characterInfo->characterTab->resistances->arcane['value'],
"resistances_arcane_petBonus" => $XMLstream->characterInfo->characterTab->resistances->arcane['petBonus'],
"resistances_fire_value" => $XMLstream->characterInfo->characterTab->resistances->fire['value'],
"resistances_fire_petBonus" => $XMLstream->characterInfo->characterTab->resistances->fire['petBonus'],
"resistances_frost_value" => $XMLstream->characterInfo->characterTab->resistances->frost['value'],
"resistances_frost_petBonus" => $XMLstream->characterInfo->characterTab->resistances->frost['petBonus'],
"resistances_holy_value" => $XMLstream->characterInfo->characterTab->resistances->holy['value'],
"resistances_holy_petBonus" => $XMLstream->characterInfo->characterTab->resistances->holy['petBonus'],
"resistances_nature_value" => $XMLstream->characterInfo->characterTab->resistances->nature['value'],
"resistances_nature_petBonus" => $XMLstream->characterInfo->characterTab->resistances->nature['petBonus'],
"resistances_shadow_value" => $XMLstream->characterInfo->characterTab->resistances->shadow['value'],
"resistances_shadow_petBonus" => $XMLstream->characterInfo->characterTab->resistances->shadow['petBonus'],
// MELEE
"melee_mainHandDamage_dps" => $melee_mainHandDamage['dps'],
"melee_mainHandDamage_max" => $melee_mainHandDamage['max'],
"melee_mainHandDamage_min" => $melee_mainHandDamage['min'],
"melee_mainHandDamage_percent" => $melee_mainHandDamage['percent'],
"melee_mainHandDamage_speed" => $melee_mainHandDamage['speed'],
"melee_offHandDamage_dps" => $melee_offHandDamage['dps'],
"melee_offHandDamage_max" => $melee_offHandDamage['max'],
"melee_offHandDamage_min" => $melee_offHandDamage['min'],
"melee_offHandDamage_percent" => $melee_offHandDamage['percent'],
"melee_offHandDamage_speed" => $melee_offHandDamage['speed'],
"melee_mainHandSpeed_hastePercent" => $melee_mainHandSpeed['hastePercent'],
"melee_mainHandSpeed_hasteRating" => $melee_mainHandSpeed['hasteRating'],
"melee_mainHandSpeed_value" => $melee_mainHandSpeed['value'],
"melee_offHandSpeed_hastePercent" => $melee_offHandSpeed['hastePercent'],
"melee_offHandSpeed_hasteRating" => $melee_offHandSpeed['hasteRating'],
"melee_offHandSpeed_value" => $melee_offHandSpeed['value'],
"melee_power_base" => $melee_power['base'],
"melee_power_effective" => $melee_power['effective'],
"melee_power_increasedDps" => $melee_power['increasedDps'],
"melee_hitRating_increasedHitPercent" => $melee_hitRating['increasedHitPercent'],
"melee_hitRating_penetration" => $melee_hitRating['penetration'],
"melee_hitRating_reducedArmorPercent" => $melee_hitRating['reducedArmorPercent'],
"melee_hitRating_value" => $melee_hitRating['value'],
"melee_critChance_percent" => $melee_critChance['percent'],
"melee_critChance_plusPercent" => $melee_critChance['plusPercent'],
"melee_critChance_rating" => $melee_critChance['rating'],
"melee_expertise_additional" => $melee_expertise['additional'],
"melee_expertise_percent" => $melee_expertise['percent'],
"melee_expertise_rating" => $melee_expertise['rating'],
"melee_expertise_value" => $melee_expertise['value'],
// RANGED
"ranged_weaponSkill_rating" => $ranged_weaponSkill['rating'],
"ranged_weaponSkill_value" => $ranged_weaponSkill['value'],
"ranged_damage_dps" => $ranged_damage['dps'],
"ranged_damage_max" => $ranged_damage['max'],
"ranged_damage_min" => $ranged_damage['min'],
"ranged_damage_percent" => $ranged_damage['percent'],
"ranged_damage_speed" => $ranged_damage['speed'],
"ranged_speed_hastePercent" => $ranged_speed['hastePercent'],
"ranged_speed_hasteRating" => $ranged_speed['hasteRating'],
"ranged_speed_value" => $ranged_speed['value'],
"ranged_power_base" => $ranged_power['base'],
"ranged_power_effective" => $ranged_power['effective'],
"ranged_power_increasedDps" => $ranged_power['increasedDps'],
"ranged_power_petAttack" => $ranged_power['petAttack'],
"ranged_power_petSpell" => $ranged_power['petSpell'],
"ranged_hitRating_increasedHitPercent" => $ranged_hitRating['increasedHitPercent'],
"ranged_hitRating_penetration" => $ranged_hitRating['penetration'],
"ranged_hitRating_reducedArmorPercent" => $ranged_hitRating['reducedArmorPercent'],
"ranged_hitRating_value" => $ranged_hitRating['value'],
"ranged_critChance_percent" => $ranged_critChance['percent'],
"ranged_critChance_plusPercent" => $ranged_critChance['plusPercent'],
"ranged_critChance_rating" => $ranged_critChance['rating'],
// SPELL
"spell_bonusDamage_arcane" => $spell_bonusDamage->arcane['value'],
"spell_bonusDamage_fire" => $spell_bonusDamage->fire['value'],
"spell_bonusDamage_frost" => $spell_bonusDamage->frost['value'],
"spell_bonusDamage_holy" => $spell_bonusDamage->holy['value'],
"spell_bonusDamage_nature" => $spell_bonusDamage->nature['value'],
"spell_bonusDamage_shadow" => $spell_bonusDamage->shadow['value'],
"spell_bonusDamage_petBonus_attack" => $spell_bonusDamage->petBonus['attack'],
"spell_bonusDamage_petBonus_damage" => $spell_bonusDamage->petBonus['damage'],
"spell_bonusDamage_petBonus_fromType" => $spell_bonusDamage->petBonus['fromType'],
"spell_bonusHealing" => $XMLstream->characterInfo->characterTab->spell->bonusHealing['value'],
"spell_hitRating_increasedHitPercent" => $spell_hitRating['increasedHitPercent'],
"spell_hitRating_penetration" => $spell_hitRating['penetration'],
"spell_hitRating_reducedResist" => $spell_hitRating['reducedResist'],
"spell_hitRating_value" => $spell_hitRating['value'],
"spell_critChance_rating" => $spell_critChance['rating'],
"spell_critChance_arcane_percent" => $spell_critChance->arcane['percent'],
"spell_critChance_fire_percent" => $spell_critChance->fire['percent'],
"spell_critChance_frost_percent" => $spell_critChance->frost['percent'],
"spell_critChance_holy_percent" => $spell_critChance->holy['percent'],
"spell_critChance_nature_percent" => $spell_critChance->nature['percent'],
"spell_critChance_shadow_percent" => $spell_critChance->shadow['percent'],
"spell_penetration" => $XMLstream->characterInfo->characterTab->spell->penetration['value'],
"spell_manaRegen_casting" => $spell_manaRegen['casting'],
"spell_manaRegen_notCasting" => $spell_manaRegen['notCasting'],
"spell_hastePercent" => $spell_hasteRating['hastePercent'],
"spell_hasteRating" => $spell_hasteRating['hasteRating'],
// DEFENSES
"defenses_armor_base" => $defenses_armor['base'],
"defenses_armor_effective" => $defenses_armor['effective'],
"defenses_armor_percent" => $defenses_armor['percent'],
"defenses_armor_petBonus" => $defenses_armor['petBonus'],
"defenses_defense_decreasePercent" => $defenses_defense['decreasePercent'],
"defenses_defense_increasePercent" => $defenses_defense['increasePercent'],
"defenses_defense_plusDefense" => $defenses_defense['plusDefense'],
"defenses_defense_rating" => $defenses_defense['rating'],
"defenses_defense_value" => $defenses_defense['value'],
"defenses_dodge_increasePercent" => $defenses_dodge['increasePercent'],
"defenses_dodge_percent" => $defenses_dodge['percent'],
"defenses_dodge_rating" => $defenses_dodge['rating'],
"defenses_parry_increasePercent" => $defenses_parry['increasePercent'],
"defenses_parry_percent" => $defenses_parry['percent'],
"defenses_parry_rating" => $defenses_parry['rating'],
"defenses_block_increasePercent" => $defenses_block['increasePercent'],
"defenses_block_percent" => $defenses_block['percent'],
"defenses_block_rating" => $defenses_block['rating'],
"defenses_resilience_damagePercent" => $defenses_resilience['damagePercent'],
"defenses_resilience_hitPercent" => $defenses_resilience['hitPercent'],
"defenses_resilience_value" => $defenses_resilience['value'],
// ITEMS
"item0_durability" => $items[0]['durability'], // ITEMS - SLOT 0
"item0_gem0Id" => $items[0]['gem0Id'],
"item0_gem1Id" => $items[0]['gem1Id'],
"item0_gem2Id" => $items[0]['gem2Id'],
"item0_icon" => $items[0]['icon'],
"item0_id" => $items[0]['id'],
"item0_maxDurability" => $items[0]['maxDurability'],
"item0_permanentenchant" => $items[0]['permanentenchant'],
"item0_randomPropertiesId" => $items[0]['randomPropertiesId'],
"item0_seed" => $items[0]['seed'],
"item0_slot" => $items[0]['slot'],
"item1_durability" => $items[1]['durability'], // ITEMS - SLOT 1
"item1_gem0Id" => $items[1]['gem0Id'],
"item1_gem1Id" => $items[1]['gem1Id'],
"item1_gem2Id" => $items[1]['gem2Id'],
"item1_icon" => $items[1]['icon'],
"item1_id" => $items[1]['id'],
"item1_maxDurability" => $items[1]['maxDurability'],
"item1_permanentenchant" => $items[1]['permanentenchant'],
"item1_randomPropertiesId" => $items[1]['randomPropertiesId'],
"item1_seed" => $items[1]['seed'],
"item1_slot" => $items[1]['slot'],
"item2_durability" => $items[2]['durability'], // ITEMS - SLOT 2
"item2_gem0Id" => $items[2]['gem0Id'],
"item2_gem1Id" => $items[2]['gem1Id'],
"item2_gem2Id" => $items[2]['gem2Id'],
"item2_icon" => $items[2]['icon'],
"item2_id" => $items[2]['id'],
"item2_maxDurability" => $items[2]['maxDurability'],
"item2_permanentenchant" => $items[2]['permanentenchant'],
"item2_randomPropertiesId" => $items[2]['randomPropertiesId'],
"item2_seed" => $items[2]['seed'],
"item2_slot" => $items[2]['slot'],
"item3_durability" => $items[3]['durability'], // ITEMS - SLOT 3
"item3_gem0Id" => $items[3]['gem0Id'],
"item3_gem1Id" => $items[3]['gem1Id'],
"item3_gem2Id" => $items[3]['gem2Id'],
"item3_icon" => $items[3]['icon'],
"item3_id" => $items[3]['id'],
"item3_maxDurability" => $items[3]['maxDurability'],
"item3_permanentenchant" => $items[3]['permanentenchant'],
"item3_randomPropertiesId" => $items[3]['randomPropertiesId'],
"item3_seed" => $items[3]['seed'],
"item3_slot" => $items[3]['slot'],
"item4_durability" => $items[4]['durability'], // ITEMS - SLOT 4
"item4_gem0Id" => $items[4]['gem0Id'],
"item4_gem1Id" => $items[4]['gem1Id'],
"item4_gem2Id" => $items[4]['gem2Id'],
"item4_icon" => $items[4]['icon'],
"item4_id" => $items[4]['id'],
"item4_maxDurability" => $items[4]['maxDurability'],
"item4_permanentenchant" => $items[4]['permanentenchant'],
"item4_randomPropertiesId" => $items[4]['randomPropertiesId'],
"item4_seed" => $items[4]['seed'],
"item4_slot" => $items[4]['slot'],
"item5_durability" => $items[5]['durability'], // ITEMS - SLOT 5
"item5_gem0Id" => $items[5]['gem0Id'],
"item5_gem1Id" => $items[5]['gem1Id'],
"item5_gem2Id" => $items[5]['gem2Id'],
"item5_icon" => $items[5]['icon'],
"item5_id" => $items[5]['id'],
"item5_maxDurability" => $items[5]['maxDurability'],
"item5_permanentenchant" => $items[5]['permanentenchant'],
"item5_randomPropertiesId" => $items[5]['randomPropertiesId'],
"item5_seed" => $items[5]['seed'],
"item5_slot" => $items[5]['slot'],
"item6_durability" => $items[6]['durability'], // ITEMS - SLOT 6
"item6_gem0Id" => $items[6]['gem0Id'],
"item6_gem1Id" => $items[6]['gem1Id'],
"item6_gem2Id" => $items[6]['gem2Id'],
"item6_icon" => $items[6]['icon'],
"item6_id" => $items[6]['id'],
"item6_maxDurability" => $items[6]['maxDurability'],
"item6_permanentenchant" => $items[6]['permanentenchant'],
"item6_randomPropertiesId" => $items[6]['randomPropertiesId'],
"item6_seed" => $items[6]['seed'],
"item6_slot" => $items[6]['slot'],
"item7_durability" => $items[7]['durability'], // ITEMS - SLOT 7
"item7_gem0Id" => $items[7]['gem0Id'],
"item7_gem1Id" => $items[7]['gem1Id'],
"item7_gem2Id" => $items[7]['gem2Id'],
"item7_icon" => $items[7]['icon'],
"item7_id" => $items[7]['id'],
"item7_maxDurability" => $items[7]['maxDurability'],
"item7_permanentenchant" => $items[7]['permanentenchant'],
"item7_randomPropertiesId" => $items[7]['randomPropertiesId'],
"item7_seed" => $items[7]['seed'],
"item7_slot" => $items[7]['slot'],
"item8_durability" => $items[8]['durability'], // ITEMS - SLOT 8
"item8_gem0Id" => $items[8]['gem0Id'],
"item8_gem1Id" => $items[8]['gem1Id'],
"item8_gem2Id" => $items[8]['gem2Id'],
"item8_icon" => $items[8]['icon'],
"item8_id" => $items[8]['id'],
"item8_maxDurability" => $items[8]['maxDurability'],
"item8_permanentenchant" => $items[8]['permanentenchant'],
"item8_randomPropertiesId" => $items[8]['randomPropertiesId'],
"item8_seed" => $items[8]['seed'],
"item8_slot" => $items[8]['slot'],
"item9_durability" => $items[9]['durability'], // ITEMS - SLOT 9
"item9_gem0Id" => $items[9]['gem0Id'],
"item9_gem1Id" => $items[9]['gem1Id'],
"item9_gem2Id" => $items[9]['gem2Id'],
"item9_icon" => $items[9]['icon'],
"item9_id" => $items[9]['id'],
"item9_maxDurability" => $items[9]['maxDurability'],
"item9_permanentenchant" => $items[9]['permanentenchant'],
"item9_randomPropertiesId" => $items[9]['randomPropertiesId'],
"item9_seed" => $items[9]['seed'],
"item9_slot" => $items[9]['slot'],
"item10_durability" => $items[10]['durability'], // ITEMS - SLOT 10
"item10_gem0Id" => $items[10]['gem0Id'],
"item10_gem1Id" => $items[10]['gem1Id'],
"item10_gem2Id" => $items[10]['gem2Id'],
"item10_icon" => $items[10]['icon'],
"item10_id" => $items[10]['id'],
"item10_maxDurability" => $items[10]['maxDurability'],
"item10_permanentenchant" => $items[10]['permanentenchant'],
"item10_randomPropertiesId" => $items[10]['randomPropertiesId'],
"item10_seed" => $items[10]['seed'],
"item10_slot" => $items[10]['slot'],
"item11_durability" => $items[11]['durability'], // ITEMS - SLOT 11
"item11_gem0Id" => $items[11]['gem0Id'],
"item11_gem1Id" => $items[11]['gem1Id'],
"item11_gem2Id" => $items[11]['gem2Id'],
"item11_icon" => $items[11]['icon'],
"item11_id" => $items[11]['id'],
"item11_maxDurability" => $items[11]['maxDurability'],
"item11_permanentenchant" => $items[11]['permanentenchant'],
"item11_randomPropertiesId" => $items[11]['randomPropertiesId'],
"item11_seed" => $items[11]['seed'],
"item11_slot" => $items[11]['slot'],
"item12_durability" => $items[12]['durability'], // ITEMS - SLOT 12
"item12_gem0Id" => $items[12]['gem0Id'],
"item12_gem1Id" => $items[12]['gem1Id'],
"item12_gem2Id" => $items[12]['gem2Id'],
"item12_icon" => $items[12]['icon'],
"item12_id" => $items[12]['id'],
"item12_maxDurability" => $items[12]['maxDurability'],
"item12_permanentenchant" => $items[12]['permanentenchant'],
"item12_randomPropertiesId" => $items[12]['randomPropertiesId'],
"item12_seed" => $items[12]['seed'],
"item12_slot" => $items[12]['slot'],
"item13_durability" => $items[13]['durability'], // ITEMS - SLOT 13
"item13_gem0Id" => $items[13]['gem0Id'],
"item13_gem1Id" => $items[13]['gem1Id'],
"item13_gem2Id" => $items[13]['gem2Id'],
"item13_icon" => $items[13]['icon'],
"item13_id" => $items[13]['id'],
"item13_maxDurability" => $items[13]['maxDurability'],
"item13_permanentenchant" => $items[13]['permanentenchant'],
"item13_randomPropertiesId" => $items[13]['randomPropertiesId'],
"item13_seed" => $items[13]['seed'],
"item13_slot" => $items[13]['slot'],
"item14_durability" => $items[14]['durability'], // ITEMS - SLOT 14
"item14_gem0Id" => $items[14]['gem0Id'],
"item14_gem1Id" => $items[14]['gem1Id'],
"item14_gem2Id" => $items[14]['gem2Id'],
"item14_icon" => $items[14]['icon'],
"item14_id" => $items[14]['id'],
"item14_maxDurability" => $items[14]['maxDurability'],
"item14_permanentenchant" => $items[14]['permanentenchant'],
"item14_randomPropertiesId" => $items[14]['randomPropertiesId'],
"item14_seed" => $items[14]['seed'],
"item14_slot" => $items[14]['slot'],
"item15_durability" => $items[15]['durability'], // ITEMS - SLOT 15
"item15_gem0Id" => $items[15]['gem0Id'],
"item15_gem1Id" => $items[15]['gem1Id'],
"item15_gem2Id" => $items[15]['gem2Id'],
"item15_icon" => $items[15]['icon'],
"item15_id" => $items[15]['id'],
"item15_maxDurability" => $items[15]['maxDurability'],
"item15_permanentenchant" => $items[15]['permanentenchant'],
"item15_randomPropertiesId" => $items[15]['randomPropertiesId'],
"item15_seed" => $items[15]['seed'],
"item15_slot" => $items[15]['slot'],
"item16_durability" => $items[16]['durability'], // ITEMS - SLOT 16
"item16_gem0Id" => $items[16]['gem0Id'],
"item16_gem1Id" => $items[16]['gem1Id'],
"item16_gem2Id" => $items[16]['gem2Id'],
"item16_icon" => $items[16]['icon'],
"item16_id" => $items[16]['id'],
"item16_maxDurability" => $items[16]['maxDurability'],
"item16_permanentenchant" => $items[16]['permanentenchant'],
"item16_randomPropertiesId" => $items[16]['randomPropertiesId'],
"item16_seed" => $items[16]['seed'],
"item16_slot" => $items[16]['slot'],
"item17_durability" => $items[17]['durability'], // ITEMS - SLOT 17
"item17_gem0Id" => $items[17]['gem0Id'],
"item17_gem1Id" => $items[17]['gem1Id'],
"item17_gem2Id" => $items[17]['gem2Id'],
"item17_icon" => $items[17]['icon'],
"item17_id" => $items[17]['id'],
"item17_maxDurability" => $items[17]['maxDurability'],
"item17_permanentenchant" => $items[17]['permanentenchant'],
"item17_randomPropertiesId" => $items[17]['randomPropertiesId'],
"item17_seed" => $items[17]['seed'],
"item17_slot" => $items[17]['slot'],
"item18_durability" => $items[18]['durability'], // ITEMS - SLOT 18
"item18_gem0Id" => $items[18]['gem0Id'],
"item18_gem1Id" => $items[18]['gem1Id'],
"item18_gem2Id" => $items[18]['gem2Id'],
"item18_icon" => $items[18]['icon'],
"item18_id" => $items[18]['id'],
"item18_maxDurability" => $items[18]['maxDurability'],
"item18_permanentenchant" => $items[18]['permanentenchant'],
"item18_randomPropertiesId" => $items[18]['randomPropertiesId'],
"item18_seed" => $items[18]['seed'],
"item18_slot" => $items[18]['slot'],
// GLYPHS
"glyph0_effect" => addslashes($glyphs0['effect']),
"glyph0_icon" => $glyphs0['icon'],
"glyph0_name" => addslashes($glyphs0['name']),
"glyph0_type" => $glyphs0['type'],
"glyph1_effect" => addslashes($glyphs1['effect']),
"glyph1_icon" => $glyphs1['icon'],
"glyph1_name" => addslashes($glyphs1['name']),
"glyph1_type" => $glyphs1['type'],
"glyph2_effect" => addslashes($glyphs2['effect']),
"glyph2_icon" => $glyphs2['icon'],
"glyph2_name" => addslashes($glyphs2['name']),
"glyph2_type" => $glyphs2['type'],
"glyph3_effect" => addslashes($glyphs3['effect']),
"glyph3_icon" => $glyphs3['icon'],
"glyph3_name" => addslashes($glyphs3['name']),
"glyph3_type" => $glyphs3['type'],
"glyph4_effect" => addslashes($glyphs4['effect']),
"glyph4_icon" => $glyphs4['icon'],
"glyph4_name" => addslashes($glyphs4['name']),
"glyph4_type" => $glyphs4['type'],
"glyph5_effect" => addslashes($glyphs5['effect']),
"glyph5_icon" => $glyphs5['icon'],
"glyph5_name" => addslashes($glyphs5['name']),
"glyph5_type" => $glyphs5['type'],
// ACHIEVEMENT SUMMARY
"summary_total_earned" => $achSummary->c['earned'],
"summary_total_points" => $achSummary->c['points'],
"summary_total_total" => $achSummary->c['total'],
"summary_total_totalPoints" => $achSummary->c['totalPoints'],
"summary_General_earned" => $achSummary->category[0]->c['earned'],
"summary_General_points" => $achSummary->category[0]->c['earnedPoints'],
"summary_General_total" => $achSummary->category[0]->c['total'],
"summary_General_totalPoints" => $achSummary->category[0]->c['totalPoints'],
"summary_Quests_earned" => $achSummary->category[1]->c['earned'],
"summary_Quests_points" => $achSummary->category[1]->c['earnedPoints'],
"summary_Quests_total" => $achSummary->category[1]->c['total'],
"summary_Quests_totalPoints" => $achSummary->category[1]->c['totalPoints'],
"summary_Exploration_earned" => $achSummary->category[2]->c['earned'],
"summary_Exploration_points" => $achSummary->category[2]->c['earnedPoints'],
"summary_Exploration_total" => $achSummary->category[2]->c['total'],
"summary_Exploration_totalPoints" => $achSummary->category[2]->c['totalPoints'],
"summary_PvP_earned" => $achSummary->category[3]->c['earned'],
"summary_PvP_points" => $achSummary->category[3]->c['earnedPoints'],
"summary_PvP_total" => $achSummary->category[3]->c['total'],
"summary_PvP_totalPoints" => $achSummary->category[3]->c['totalPoints'],
"summary_Dungeons_earned" => $achSummary->category[4]->c['earned'],
"summary_Dungeons_points" => $achSummary->category[4]->c['earnedPoints'],
"summary_Dungeons_total" => $achSummary->category[4]->c['total'],
"summary_Dungeons_totalPoints" => $achSummary->category[4]->c['totalPoints'],
"summary_Professions_earned" => $achSummary->category[5]->c['earned'],
"summary_Professions_points" => $achSummary->category[5]->c['earnedPoints'],
"summary_Professions_total" => $achSummary->category[5]->c['total'],
"summary_Professions_totalPoints" => $achSummary->category[5]->c['totalPoints'],
"summary_Reputation_earned" => $achSummary->category[6]->c['earned'],
"summary_Reputation_points" => $achSummary->category[6]->c['earnedPoints'],
"summary_Reputation_total" => $achSummary->category[6]->c['total'],
"summary_Reputation_totalPoints" => $achSummary->category[6]->c['totalPoints'],
"summary_WorldEvents_earned" => $achSummary->category[7]->c['earned'],
"summary_WorldEvents_points" => $achSummary->category[7]->c['earnedPoints'],
"summary_WorldEvents_total" => $achSummary->category[7]->c['total'],
"summary_WorldEvents_totalPoints" => $achSummary->category[7]->c['totalPoints'],
"summary_Feats_earned" => $achSummary->category[8]->c['earned'],
// ACHIEVEMENT SUMMARY - LAST 5
"summary_last0_categoryId" => $achievements[0]['categoryId'],
"summary_last0_dateCompleted" => $achievements[0]['dateCompleted'],
"summary_last0_desc" => addslashes($achievements[0]['desc']),
"summary_last0_icon" => addslashes($achievements[0]['icon']),
"summary_last0_id" => $achievements[0]['id'],
"summary_last0_points" => $achievements[0]['points'],
"summary_last0_title" => addslashes($achievements[0]['title']),
"summary_last1_categoryId" => $achievements[1]['categoryId'],
"summary_last1_dateCompleted" => $achievements[1]['dateCompleted'],
"summary_last1_desc" => addslashes($achievements[1]['desc']),
"summary_last1_icon" => addslashes($achievements[1]['icon']),
"summary_last1_id" => $achievements[1]['id'],
"summary_last1_points" => $achievements[1]['points'],
"summary_last1_title" => addslashes($achievements[1]['title']),
"summary_last2_categoryId" => $achievements[2]['categoryId'],
"summary_last2_dateCompleted" => $achievements[2]['dateCompleted'],
"summary_last2_desc" => addslashes($achievements[2]['desc']),
"summary_last2_icon" => addslashes($achievements[2]['icon']),
"summary_last2_id" => $achievements[2]['id'],
"summary_last2_points" => $achievements[2]['points'],
"summary_last2_title" => addslashes($achievements[2]['title']),
"summary_last3_categoryId" => $achievements[3]['categoryId'],
"summary_last3_dateCompleted" => $achievements[3]['dateCompleted'],
"summary_last3_desc" => addslashes($achievements[3]['desc']),
"summary_last3_icon" => addslashes($achievements[3]['icon']),
"summary_last3_id" => $achievements[3]['id'],
"summary_last3_points" => $achievements[3]['points'],
"summary_last3_title" => addslashes($achievements[3]['title']),
"summary_last4_categoryId" => $achievements[4]['categoryId'],
"summary_last4_dateCompleted" => $achievements[4]['dateCompleted'],
"summary_last4_desc" => addslashes($achievements[4]['desc']),
"summary_last4_icon" => addslashes($achievements[4]['icon']),
"summary_last4_id" => $achievements[4]['id'],
"summary_last4_points" => $achievements[4]['points'],
"summary_last4_title" => addslashes($achievements[4]['title'])
);
return $char_Array;
}
//------------------------------------------------------------------
// Build the Character Array from the supplied guild XML stream
function buildCharacterArray($XMLstream) {
global $config;
$count_Members = 0;
$char_Array = array();
foreach ($XMLstream->guildInfo->guild->members->character as $char) {
$process_char = false;
$process_char_list = false;
if( $config['chars_to_process'] == -1 ) {
if ( $config['use_char_selction_list'] ) {
if (in_array($char['name'],$config['char_selction_list'])) $process_char = true;
} else { $process_char = true; }
} else {
if( $count_Members < $config['chars_to_process'] ) $process_char = true;
}
// BUGGY if ( $char['level'] >= $config['min_char_level'] ) $process_char = false; // Limits display Chars beyond a certain level
// BUGGY if ( $char['rank'] <= $config['min_char_rank'] ) $process_char = false; // Limits display to Guild Rank (depending on your guild ranks)
if( $process_char ) {
$toonrace = return_race($char['raceId'], $char['genderId']); // Maps Race and Sex
$toongender = return_gender($char['genderId']); // Maps Sex
$toonclass = return_class($char['classId']); // Maps class name
$toonrank = return_rank($char['rank']); // Maps guild rank name
$char_info_Array = array(
"name" => (string)$char['name'],
"level" => (string)$char['level'],
"class" => $toonclass,
"gender" => $toongender,
"race" => $toonrace,
"rank" => $char['rank'].' - '.$toonrank,
"achPoints" => (string)$char['achPoints'],
"url" => $config['url_prefix_char'].(string)$char['url'] );
$char_Array[] = $char_info_Array;
}
$count_Members++;
}
return $char_Array;
}
//------------------------------------------------------------------
// Print the supplied Character Array
function printCharacterArray($charArray, $array_sort_field, $array_sort_direction) {
global $config;
if ( count($charArray) != 0 ) {
switch($array_sort_direction){
case 'asc' : $sortDir = 'desc'; break;
case 'desc' : $sortDir = 'asc'; break;
}
switch($array_sort_field){
case 'name' : $sortFieldname = ' ['.$array_sort_direction.']'; break;
case 'level' : $sortFieldlevel = ' ['.$array_sort_direction.']'; break;
case 'class' : $sortFieldclass = ' ['.$array_sort_direction.']'; break;
case 'gender' : $sortFieldgender = ' ['.$array_sort_direction.']'; break;
case 'race' : $sortFieldrace = ' ['.$array_sort_direction.']'; break;
case 'rank' : $sortFieldrank = ' ['.$array_sort_direction.']'; break;
case 'achPoints' : $sortFieldachPoints = ' ['.$array_sort_direction.']'; break;
case 'url' : $sortFieldlink = ' ['.$array_sort_direction.']'; break;
}
echo '<b>DISPLAY GUILD DATA:</b><BR/><table width="100%" border="1">';
echo '<td width=""><a href="'.$config['base_filename'].'?sort=name&direction='.$sortDir.'">NAME'.$sortFieldname.'</a></td>';
echo '<td width=""><a href="'.$config['base_filename'].'?sort=level&direction='.$sortDir.'">LEVEL'.$sortFieldlevel.'</a></td>';
echo '<td width=""><a href="'.$config['base_filename'].'?sort=class&direction='.$sortDir.'">CLASS'.$sortFieldclass.'</a></td>';
echo '<td width=""><a href="'.$config['base_filename'].'?sort=gender&direction='.$sortDir.'">GENDER'.$sortFieldgender.'</a></td>';
echo '<td width=""><a href="'.$config['base_filename'].'?sort=race&direction='.$sortDir.'">RACE'.$sortFieldrace.'</a></td>';
echo '<td width=""><a href="'.$config['base_filename'].'?sort=rank&direction='.$sortDir.'">RANK'.$sortFieldrank.'</a></td>';
echo '<td width=""><a href="'.$config['base_filename'].'?sort=achPoints&direction='.$sortDir.'">POINTS'.$sortFieldachPoints.'</a></td>';
echo '<td width=""><a href="'.$config['base_filename'].'?sort=url&direction='.$sortDir.'">URL'.$sortFieldlink.'</a></td>';
echo '</tr>';
foreach ($charArray as $char) {
echo '<tr id="'.$char['name'].'">';
echo '<td>'.$char['name'].' </td>';
echo '<td>'.$char['level'].' </td>';
echo '<td>'.$char['class'].' </td>';
echo '<td>'.$char['gender'].' </td>';
echo '<td>'.$char['race'].' </td>';
echo '<td>'.$char['rank'].' </td>';
echo '<td>'.$char['achPoints'].' </td>';
echo '<td><a href="'.$char['url'].'" target="_blank">'.$char['url'].'</a></td>';
echo '</tr>';
$count_Members++;
}
echo '</table>';
}
}
//------------------------------------------------------------------
// Prints everything in the supplied Character Array
function printCompleteCharacterArray($charArray) {
global $config;
echo '<br /><P><b>DISPLAY GUILD DATA:</b><BR/><table width="100%" border="1">';
foreach ($charArray[0] as $key => $value ) {
echo '<td width=""><b>'.$key.'</b></td>';
}
echo '</tr>';
foreach ($charArray as $char) {
echo '<tr id="'.$char['name'].'">';
foreach ($char as $value) {
echo '<td>'.$value.' </td>';
}
echo '</tr>';
}
echo '</table>';
}
//------------------------------------------------------------------
// Dynamically builds the supplied Character Array as a SQL IMPORT Statement
function printSQLCharacterArray($charArray,$guildCount,$guildBG) {
global $config;
if ( count($charArray) != 0 ) {
if ( ($config['show_sql_import_structure']) || ($config['show_sql_import_data']) ) {
// BUILD THE TABLE STRUCTURE
$sql_import_structure = "";
$sql_table_structure_row = "CREATE TABLE `".$config['sql_table']."` (
`ID` bigint(255) NOT NULL AUTO_INCREMENT,
";
$countKey = 0;
foreach ($charArray[0] as $key => $value ) {
if ( $countKey == 0 ) {
$sql_import_structure .= $key;
} else {
$sql_import_structure .= ", ".$key;
}
$sql_table_structure_row .= " `".$key."` text(600) CHARACTER SET utf8 DEFAULT NULL,
";
$countKey++;
}
$sql_table_structure_row .= " PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;";
// START BUILDING THE SQL IMPORT STATEMENT
$sql_table_structure = "SET NAMES utf8;
SET CHARACTER SET utf8;
SET SQL_MODE='';
USE ".$config['sql_database'].";
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
/*Table structure for table `".$config['sql_table']."` */
DROP TABLE IF EXISTS `".$config['sql_table']."`;
".$sql_table_structure_row."
SET SQL_MODE=@OLD_SQL_MODE;";
$sql_string = "USE ".$config['sql_database']."; TRUNCATE TABLE ".$config['sql_table'].";
UPDATE guild_information SET guild_members = '".$guildCount."', battlegroup = '".$guildBG."' WHERE guild_name='".$config['guild_name']."';
";
// BUILD THE CHARACTER INSERT STATEMENTS
$countChar = 0;
foreach ($charArray as $char) {
// BUILD VALUE STRING
$sql_import_values = "";
$countValue = 0;
foreach ($charArray[$countChar] as $key => $value ) {
if ( $countValue == 0 ) {
$sql_import_values .= "'".$value."'";
} else {
$sql_import_values .= ", '".$value."'";
}
$countValue++;
}
$sql_row = "INSERT INTO ".$config['sql_table']." (".$sql_import_structure.") VALUES (".$sql_import_values.");
";
$sql_string .= $sql_row;
$countChar++;
}
}
if ( $config['show_sql_import_structure'] ) {
echo '<br /><P><b>SQL TABLE STRUCTURE IMPORT STATEMENT:</b> '.$countKey.' keys with Text(600) limit each, equals '.($countKey*600).' total potential characters...<BR/><textarea rows="20" cols="180" wrap="off">'.$sql_table_structure.'</textarea><P>';
}
if ( $config['show_sql_import_data'] ) {
echo '<br /><P><b>SQL TABLE DATA IMPORT STATEMENT:</b><BR/><textarea rows="30" cols="180" wrap="off">'.$sql_string.'</textarea><P>';
}
// SAVE SQL TO FILE
$newSQLfile = $config['DIR_sql'].'guild_sql-'.date('Y.m.d-H.i.s').'.sql'; // GET THE LATEST CACHE GUILD XML FILE
$fh = fopen($newSQLfile, 'wb');
$numbytes = fwrite($fh, $sql_string);
fclose($fh);
}
}
//------------------------------------------------------------------
// Sort the supplied Character Array
function sortCharacterArray($charArray, $array_sort_field, $array_sort_direction) {
// OBTAIN A LIST OF COLUMNS TO SORT
foreach ($charArray as $key => $row) {
$name[] = $row['name'];
$level[] = $row['level'];
$class[] = $row['class'];
$gender[] = $row['gender'];
$race[] = $row['race'];
$rank[] = $row['rank'];
$achPoints[] = $row['achPoints'];
$url[] = $row['url'];
}
// SETUP SORT SETTINGS
switch($array_sort_field){
case 'name' : $sortField = $name; $sortType = SORT_STRING; break;
case 'level' : $sortField = $level; $sortType = SORT_NUMERIC; break;
case 'class' : $sortField = $class; $sortType = SORT_STRING; break;
case 'gender' : $sortField = $gender; $sortType = SORT_STRING; break;
case 'race' : $sortField = $race; $sortType = SORT_STRING; break;
case 'rank' : $sortField = $rank; $sortType = SORT_NUMERIC; break;
case 'achPoints' : $sortField = $achPoints; $sortType = SORT_NUMERIC; break;
case 'url' : $sortField = $url; $sortType = SORT_STRING; break;
}
// SORT THE ARRAY
switch($array_sort_direction){
case 'asc' : array_multisort($sortField, SORT_ASC, $sortType, $level, SORT_DESC, SORT_NUMERIC, $name, SORT_ASC, SORT_STRING, $charArray); break;
case 'desc' : array_multisort($sortField, SORT_DESC, $sortType, $level, SORT_DESC, SORT_NUMERIC, $name, SORT_ASC, SORT_STRING, $charArray); break;
}
return $charArray ;
}
// PREVIOUSLY DECLARED CLASSES
static $browser_user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
function return_class($classid) {
switch ($classid) {
case 1:
$class = "Warrior";
break;
case 2:
$class = "Paladin";
break;
case 3:
$class = "Hunter";
break;
case 4:
$class = "Rogue";
break;
case 5:
$class = "Priest";
break;
case 6:
$class = "Death Knight";
break;
case 7:
$class = "Shaman";
break;
case 8:
$class = "Mage";
break;
case 9:
$class = "Warlock";
break;
case 11:
$class = "Druid";
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 = "Guild Master";
break;
case 1:
$class = "Guild Leader";
break;
case 2:
$class = "VIP";
break;
case 3:
$class = "Member";
break;
case 4:
$class = "Initiate";
break;
case 5:
$class = "-";
break;
case 6:
$class = "-";
break;
case 7:
$class = "-";
break;
case 8:
$class = "-";
break;
}
return $class;
}
function return_race2($raceid, $sex) {
switch ($raceid) {
case 1:
if ($sex == "0") {$race = "Human Male";}
if ($sex == "1") {$race = "Human Female";}
break;
case 2:
if ($sex == "0") {$race = "Orc Male";}
if ($sex == "1") {$race = "Orc Female";}
break;
case 3:
if ($sex == "0") {$race = "Dwarf Male";}
if ($sex == "1") {$race = "Dwarf Female";}
break;
case 4:
if ($sex == "0") {$race = "Night Elf Male";}
if ($sex == "1") {$race = "Night Elf Female";}
break;
case 5:
if ($sex == "0") {$race = "Undead Male";}
if ($sex == "1") {$race = "Undead Female";}
break;
case 6:
if ($sex == "0") {$race = "Tauren Male";}
if ($sex == "1") {$race = "Tauren Female";}
break;
case 7:
if ($sex == "0") {$race = "Gnome Male";}
if ($sex == "1") {$race = "Gnome Female";}
break;
case 8:
if ($sex == "0") {$race = "Troll Male";}
if ($sex == "1") {$race = "Troll Female";}
break;
case 10:
if ($sex == "0") {$race = "Blood Elf Male";}
if ($sex == "1") {$race = "Blood Elf Female";}
break;
case 11:
if ($sex == "0") {$race = "Draenei Male";}
if ($sex == "1") {$race = "Draenei Female";}
break;
}
return $race;
}
function return_race($raceid, $sex) {
switch ($raceid) {
case 1:
$race = "Human";
break;
case 2:
$race = "Orc";
break;
case 3:
$race = "Dwarf";
break;
case 4:
$race = "Night Elf";
break;
case 5:
$race = "Undead";
break;
case 6:
$race = "Tauren";
break;
case 7:
$race = "Gnome";
break;
case 8:
$race = "Troll";
break;
case 10:
$race = "Blood Elf";
break;
case 11:
$race = "Draenei";
break;
}
return $race;
}
function return_gender($genderid) {
if ($genderid == "0") {$gender = "Male";}
if ($genderid == "1") {$gender = "Female";}
return $gender;
}
?>
Last edited by DJRavine : 03-18-2010 at 01:28 PM.
Reason: Added link to my guild.. hehe... :D
|
|
|
|
|
The Following User Says Thank You to DJRavine For This Useful Post:
|
|
03-18-2010, 01:27 PM
|
#135 (permalink)
|
|
The Wanderer
Join Date: Jun 2009
Posts: 5
Thanks: 0
|
Yet Another Update
Hey all,
UPDATE:
Hey all, After I made last nights post on this thread I was in the mood to work on a few of the other things needed. After a few hours work, I have this to release to everyone. This is an updated version of the same script, BUT with complete Statistics and Achievement parsing. For the time being the Character Data, the Achievement Data, and the Statistic data is all separated into unique tables.
STILL NEED TO DO:
- Retrieval of the 'Talent Build'.
- Retrieval of the 'Activity Feed'.
- Retrieval of the 'Guild Bank'.
- Retrieval of the 'Guild Calendar'.
- If there has been any structure changes to the official wow armory xml, I have not updated them. But in my tests everything is still working ok.
- Many more...
MY GUILD WEBSITE:
LINK: http://www.wingsofthefallen.com/
- I would like to publish a link to my guild website.
- My girlfriend and I have spent a lot of time building and stylizing this complete package.
- We are thinking of possibly releasing it in the future as a "Host-It-Yourself WoW Guild Website".
- This is basically a 'Front-End' for the 'Back-End' script I am freely releasing.
- So please check it out and send your comments to DJRavine@WoWps.org.
Here are a few features:- Front-End WoW Guild CMS
- Back-End phpBB Forum
- Written in PHP / AJAX / MySQL
- 'Admin Control Panel' Not Implemented
- 'User Control Panel' Implemented in Forum Account Options
- Full, Sortable Guild Roster List [DEMO]
- Collapsible Character Profile Page [DEMO]
- 3D Flash Interactive Character Display
- Profession Icons link to Profession Guides
- Gear Icons have [+] Icons to find Gear Upgrades
- Links to other websites with WoW Character Profiles
- Gear score calculation still in developement
- Character Profiles Link to Forum Accounts [DEMO]
- Full AJAX Dynamic Character Updates [DEMO]
- Each Character Profile Page has its own manual update link
- Dynamically remembers Character Profile Page views
- Many, Many More...
OK, ONTO THE REAL CODING...
I firstly want to say thank you for all this preliminary work...
It has been a tremendous help during the development of my own xml grabber...
Ok, so I wanted to share my own development with everyone..
What this script will do:- Connect to the Official WoW Armory
- Download an XML List of all the Characters in your guild
- With each Character in the Guild, it will download Gear, Information, Statistics, Achievements and other things
- Store the accumulated data as a PHP array, ready for export into a number of databases
- Displays the Array as raw XML, a SQL import Statement and a Sortable HTML Table
Here are a few notes on what I have accomplished...
- All Gear / Items are parsed and stored...
- ALL Character's Achievements are processed...
- ALL Character's Statistics are processed...
- Every XML request is cached by default in the 'cache' directory...
- There are 3 outputs via the html. the raw XML, a SQL import statement and a sortable processed html grid with data from the XML... [SEE THE LIVE DEMO LINK]
- I had issues using the '->children()' object, so this solution does not use that feature...
- Due to loading limits imposed by the wow armory, I have written a XML caching system to attempt to download and save a new XML stream to a cache file. If you get a trashed response (like you have reached the quota or the site is offline for maintenance), it will load the last valid XML document you have cached...
- Inside the code I have parsed the xml into a multi-dimensional array for ease of sorting...
- I have managed to handle the special characters like 'å'... Read the comments below...
- If you want to store the data in a SQL server I would recommend using the language setting of 'utf8_general_ci'...
- When SELECT'ing the data from the SQL server, make sure you use "SET NAMES 'utf8'; SET CHARACTER SET 'utf8'; " before the SELECT statement. This way you get the same text encoding outputted by the SQL server.
--------------------------------------------------------------------------
STEPS TO SUCCESSFULLY USE THIS SCRIPT
--------------------------------------------------------------------------- Make sure you have a webserver with PHP v5.x.x.
- Save both 'roster.test2.php' and 'roster_functions.test2.php' each to their own file and upload to your webserver.
- In the same directory as 'roster.test2.php' and 'roster_functions.test2.php' create a directory called 'cache' and 'sql'. This will be used to cache the XML files you stream from the wow armory and SQL files which you will generate.
- Set the permissions for the 'cache' and 'sql' directory to 775, or anything to allow the script to write files to that folder.
- Edit the $configs['blah'] in the top of the 'roster_functions.test2.php' file to your discretion and save the file.
- Browse to the file with you favorite browser and it should look like my live demo.
LIVE DEMO [Only 3 Characters, 2 Minute Load Time ]:
http://www.wingsofthefallen.com/wotf/roster.test2.php
LIVE DEMO [All Characters, VERY Long Load Time]:
http://www.wingsofthefallen.com/wotf...2.php?all=true
NOTE: For Debug and Testing purposes, I have limited the script to only retrieve 3 characters. To correct this, just append this to the URL '?all=true'. Or check the configuration options in 'roster_functions.test2.php'.
EG. http://www.wingsofthefallen.com/wotf...t.php?all=true
NOTE: You may notice the following in my GUILD MEMBER SQL Output:
PHP Code:
UPDATE guild_information SET guild_members = '49', battlegroup = 'Ruin' WHERE guild_name='Wings of the Fallen';
- This is another table I have setup just to store the number of characters in the guild. [Remember that the characters shown on the armory must be above level 10.]
NOTE: This script has been minimally tested and may need tweaking for complete functionality, it is supplied in an 'as is' basis to aide your own development.
DON'T FORGET TO CLICK THE
'SAY THANKS' BUTTON BELOW
IF YOU FIND THIS POST USEFUL
roster.test2.php
PHP Code:
<?php
/////////////////////////////////////////////////////////////////////////////////////// // Script: roster.test2.php // Author: Collective [http://www.talkphp.com/show-off/3281-world-warcraft-armory-xml-grabber-curl.html] // Modified: DJRavine aka Adan Rehtla [DJRavine@WoWps.org] // Date: 18/03/2010 11:13:18 AM // Live Demo: http://WingsOfTheFallen.com/wotf/roster.test2.php // Guild Site: http://WingsOfTheFallen.com // Guild Dev Site: http://WingsOfTheFallen.com/index2.php ///////////////////////////////////////////////////////////////////////////////////////
// INTERNAL PHP CHARSET TO UTF-8 mb_internal_encoding( 'UTF-8' ); set_time_limit(1200); header( 'Content-Type: text/html; charset=UTF-8' );
// INCLUDE EXTRA FUNCTIONS include 'roster_functions.test2.php';
// --- START: GET $_GET[""] VARIABLES ---------------------------- // GET: SORT FIELD $sort_field = $_GET["sort"]; if($sort_field == ''){ $sort_field = 'level'; }
// GET: SORT DIRECTION $sort_direction = $_GET["direction"]; if($sort_direction == ''){ $sort_direction = 'desc'; }
// GET: SORT DIRECTION $override_process_all = $_GET["all"]; if($override_process_all == 'true') { $config['chars_to_process'] = -1; }
// --- END: GET $_GET[""] VARIABLES ----------------------------
// --- START: MAIN PHP PROCESSING ----------------------------
// PRINT THE HTML HEADER echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Guild XML Parser - \''.htmlentities($config['guild_name']).'\' from \''.htmlentities($config['server_name']).'\'</title> </head><body><P><b> PLEASE WAIT FOR THE PAGE TO LOAD... DEPENDING ON THE OPTIONS SELECTED IT COULD TAKE A WHILE...</b><P>';
if ( !$override_process_all ) { echo '<b>NOTE: ONLY PROCESSING '.$config['chars_to_process'].' CHARACTERS FOR TESTING / DEBUG...</b><P>'; } else { echo '<b>NOTE: PROCESSING ALL CHARACTERS...</b><P>'; }
echo '<b>STARTING PROCESSING -><br/> -> REALM: '.$config['server_name'].' <br/> -> GUILD: '.$config['guild_name'].'...</b><P>'; echo '<P><B> -> [ '.sec2hms(printLoadTime()).' ] - GETTING GUILD MEMBERS...</B><br/>'; $armory = new armory('roster', $config['server_name'], $config['guild_name'], NULL, NULL, NULL); // INITIALIZE THE ARMORY CLASS $xml_guild = $armory->pull_xml(); // PULL THE GUILD XML FROM THE WOW ARMORY
echo '<P><span style="font-size:75%;"><b>LOADED IN '.printLoadTime().'s</b></span><P>';
// XML SOURCE TEXT AREA if ( $config['show_xml_source'] ) { $latestGuildXMLfile = getXMLfile('guild-info'); // GET THE LATEST CACHE GUILD XML FILE $cachedFile = $config['DIR_cache'].$latestGuildXMLfile['filename']; $fh = fopen($cachedFile, 'r'); $theData = fread($fh, filesize($cachedFile)); fclose($fh); echo '<br /><P><b>GUILD XML:</b><BR/><textarea rows="30" cols="180" wrap="off">'; echo $theData; echo'</textarea><P>'; echo '<span style="font-size:75%;"><b>LOADED IN '.sec2hms(printLoadTime()).'</b></span><P>'; }
// BUILD GUILD ARRAY FROM XML SOURCE $array_Members_Basic = buildCharacterArray($xml_guild);
// PULL THE XML FOR EVERY CHARACTER IN THE GUILD AND ADD TO THE ARRAY $array_Members_All = pullCharacterXML($armory, $array_Members_Basic); $array_Members = $array_Members_All[0]; $array_Members_Achievements = $array_Members_All[1]; $array_Members_Statistics = $array_Members_All[2];
echo '<span style="font-size:75%;"><b>LOADED IN '.sec2hms(printLoadTime()).'</b></span><P>';
// SORT GUILD MEMBER ARRAY [FOR HTML TABLE OUTPUT] $array_Members_sorted = sortCharacterArray($array_Members, $sort_field, $sort_direction);
// PRINT GUILD MEMBER SQL IMPORT STATEMENT INSIDE A TEXTAREA printSQLArray($array_Members_sorted,$xml_guild->guildInfo->guildHeader['count'],$xml_guild->guildInfo->guildHeader['battleGroup'],'GUILD MEMBERS','',$config['sql_table'],$config['show_sql_import_structure'],$config['show_sql_import_data']); echo '<span style="font-size:75%;"><b>LOADED IN '.sec2hms(printLoadTime()).'</b></span><P>';
// PRINT ACHIEVEMENTS SQL IMPORT STATEMENT INSIDE A TEXTAREA printSQLArray($array_Members_Achievements,'','','ACHIEVEMENTS','achievements',$config['sql_table_achievements'],$config['show_sql_import_structure_achievements'],$config['show_sql_import_data_achievements']); echo '<span style="font-size:75%;"><b>LOADED IN '.sec2hms(printLoadTime()).'</b></span><P>';
// PRINT STATISTICS SQL IMPORT STATEMENT INSIDE A TEXTAREA printSQLArray($array_Members_Statistics,'','','STATISTICS','statistics',$config['sql_table_statistics'],$config['show_sql_import_structure_statistics'],$config['show_sql_import_data_statistics']); echo '<span style="font-size:75%;"><b>LOADED IN '.sec2hms(printLoadTime()).'</b></span><P>';
// PRINT GUILD ARRAY AS A TABLE if ( $config['show_html_data_table'] ) { if ( $config['show_html_data_sort'] ) { printCharacterArray($array_Members_sorted, $sort_field, $sort_direction); } else { printCompleteCharacterArray($array_Members_sorted); } echo '<b>Showing '.count($array_Members_sorted).' / '.(string)$xml_guild->guildInfo->guildHeader['count'].' Guild Members...<br/></b> [NOTE: Only showing characters above level 10]<P>'; }
// PRINT TOTAL LOAD TIME echo '<span style="font-size:75%;"><b>TOTAL LOAD TIME: '.sec2hms(printLoadTime()).'</b></span><P>';
echo '</body></html>';
// --- END: MAIN PHP PROCESSING ----------------------------
// FOR DEBUG PURPOSES
//echo '<b> OUTPUT GUILD MEMBERS: </b><PRE>'; //print_r($array_Members); //echo '</PRE>';
//echo '<b> OUTPUT GUILD MEMBERS [SORTED]: </b><PRE>'; //print_r($array_Members_sorted); //echo '</PRE>';
//echo '<b> OUTPUT ACHIEVEMENTS: </b><PRE>'; //print_r($array_Members_Achievements); //echo '</PRE>';
//echo '<b> OUTPUT STATISTICS: </b><PRE>'; //print_r($array_Members_Statistics); //echo '</PRE>';
?>
roster_functions.test2.php
PHP Code:
<?php
/////////////////////////////////////////////////////////////////////////////////////// // Script: roster_functions.test2.php // Author: Collective [http://www.talkphp.com/show-off/3281-world-warcraft-armory-xml-grabber-curl.html] // Modified: DJRavine aka Adan Rehtla [DJRavine@WoWps.org] // Date: 18/03/2010 11:13:18 AM // Live Demo: http://WingsOfTheFallen.com/wotf/roster.test2.php // Guild Site: http://WingsOfTheFallen.com // Guild Dev Site: http://WingsOfTheFallen.com/index2.php ///////////////////////////////////////////////////////////////////////////////////////
// LOAD TIME VARS - !! DONT TOUCH !! $m_time = explode(" ",microtime()); $m_time = $m_time[0] + $m_time[1]; $config['starttime'] = $m_time; $config['round'] = 3; // The number of decimal places to round the micro time to.
// ---------------- EDIT THE BELOW SETTINGS ----------------
// SERVER AND GUILD SETTINGS $config['server_name'] = 'Elune'; // Name of the WoW Realm $config['guild_name'] = 'Wings of the Fallen'; // Name of your Guild // $config['server_name'] = 'Marécage de Zangar'; // Name of the WoW Realm // $config['guild_name'] = 'Lenwë Linwëlin'; // Name of your Guild // THESE WILL BE STORED AS HTML ENTITIES FOR EASE OF DISPLAYING // SETTINGS FOR THE GENERAL WEBSITE $config['live_system'] = true; // 'TRUE' = Download XML & Cache; 'FALSE' = Cache Only $config['base_filename'] = 'roster.test2.php'; // Base script file name $config['base_url'] = 'http://wingsofthefallen.com/wotf/'; // Base URL $config['url_prefix_armory'] = 'http://www.wowarmory.com/'; // URL for the AMERICAN armory // $config['url_prefix_armory'] = 'http://eu.wowarmory.com/'; // URL for the EUROPEAN armory $config['url_prefix_char']=$config['url_prefix_armory'].'character-sheet.xml?'; // Use for Char links $config['days_to_cache'] = 3; // How many days to keep cached files for // NOTE: THE BELOW DIRECTORIES NEED TO HAVE WRITE ACCESS $config['DIR_cache'] = 'cache/'; // Directory where the XML cache files are stored $config['DIR_sql'] = 'sql/'; // Directory where the SQL files are stored // NOTE: THE ABOVE DIRECTORIES NEED TO HAVE WRITE ACCESS
// LOADING BAR $config['loading_bar'] = 100; // How many characters in the loading bar $config['loading_bar_mask'] = "="; // The loading bar symbol // OUTPUT DISPLAY SETTING // WARNING: TURNING ALL OF THESE SETTINGS ON WILL TAKE A LOOONG TIME TO PROCESS AND WILL CONSUME A FAIR AMOUNT OF SERVER RESOURCES // WARNING: I ONLY HAVE ABOUT 50 MEMBERS IN MY GUILD, WITH ALL THESE SETTINGS ON IT CAN TAKE A FEW HOURS TO PROCESS ALL THE DATA. $config['show_xml_source'] = true; // 'TRUE' = Show XML Source; 'FALSE' = Hide XML Source $config['show_html_data_table'] = true; // 'TRUE' = Show Guild Members HTML Data Table; 'FALSE' = Hide Guild Members HTML Data Table $config['show_html_data_sort'] = false; // 'TRUE' = Show HTML Data Table with sort functionality and only limited fields; 'FALSE' = Show HTML Data Table with every field $config['show_sql_import_structure'] = true; // 'TRUE' = Show Guild Members SQL Import Structure; 'FALSE' = Hide Guild Members SQL Import Structure $config['show_sql_import_data'] = true; // 'TRUE' = Show Guild Members SQL Import Data; 'FALSE' = Hide Guild Members SQL Import Data $config['show_sql_import_structure_achievements'] = true; // 'TRUE' = Show Achievements SQL Import Structure; 'FALSE' = Hide Achievements SQL Import Structure $config['show_sql_import_data_achievements'] = true; // 'TRUE' = Show Achievements SQL Import Data; 'FALSE' = Hide Achievements SQL Import Data $config['show_sql_import_structure_statistics'] = true; // 'TRUE' = Show Statistics SQL Import Structure; 'FALSE' = Hide Statistics SQL Import Structure $config['show_sql_import_data_statistics'] = true; // 'TRUE' = Show Statistics SQL Import Data; 'FALSE' = Hide Statistics SQL Import Data // SETTINGS FOR SQL STATEMENT GENERATION $config['sql_database'] = 'wotf_forum'; // SQL Database Name $config['sql_table'] = 'guild_characters_test'; // SQL Table Name $config['sql_table_achievements'] = 'guild_characters_achievements'; // SQL Table Name $config['sql_table_statistics'] = 'guild_characters_statistics'; // SQL Table Name // XML PARSING SETTINGS // $config['min_char_level'] = 75; // Limits display parsing of Characters beyond a certain level. NOTE: Use '0' to process all characters. NOTE: Requires "$config['chars_to_process'] = -1;" // $config['min_char_rank'] = 1; // Limits display to Guild Rank NOTE: Requires "$config['chars_to_process'] = -1;" $config['equipable_items_number'] = 18; // How many equipable items on a character. !! DO NOT EDIT THIS !! May ONLY be needed for later updates from Blizzard
// DEBUG SETTINGS $config['chars_to_process'] = 3; // How many characters to pull xml data for. NOTE: Use '-1' to process all characters. $config['use_char_selction_list'] = false; // Select this option to only process characters names found in the "$config['char_selction_list']" array. $config['char_selction_list'] = array( "Demoral", "Kyrå", "Orayn" ); // A list of characters to process, excluding all others. NOTE: Requires "$config['chars_to_process'] = -1;"
// ---------------- EDIT THE ABOVE SETTINGS ----------------
// ----------------------------------------------- // DO NOT EDIT BELOW THIS LINE // -----------------------------------------------
//--------------------------------------------------- // CLASSES AND FUNCTIONS //---------------------------------------------------
// DEFINE THE ARMORY CLASS class armory {
// DEFINE THE ARMORY VARIABLES const BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3"; public $query; public $server; public $guild; public $guildie; public $category; public $page;
// CONSTRUCTOR FOR THE ARMORY OBJECT public function __construct ( $query, $server, $guild, $guildie, $category, $page ) { $this->query = $query; $this->server = $server; $this->guild = $guild; $this->guildie = $guildie; $this->category = $category; $this->page = $page; } // end of __construct()
// THIS WILL NOW DOWNLOAD AND CACHE THE XML FEED // THEN IT WILL SEARCH THE XML CACHE FOR THE LATEST VALID XML FEED public function pull_xml() { global $config;
// change the first part of the $url to the armory link that you need if( $this->query === 'roster' ){ $filename_type = 'guild-info'; $url = $config['url_prefix_armory'].$filename_type.'.xml?r=' . urlencode( utf8_encode( $this->server ) ) . '&n=' . urlencode( utf8_encode( $this->guild ) ) . '&p=' . $this->page; } elseif( $this->query === 'character' ){ $filename_type = 'character-sheet'; $url = $config['url_prefix_armory'].$filename_type.'.xml?r=' . urlencode( utf8_encode( $this->server ) ) . '&n=' . $this->guildie; } elseif( $this->query === 'achievement' ){ $filename_type = 'character-achievements'; $url = $config['url_prefix_armory'].$filename_type.'.xml?r=' . urlencode( utf8_encode( $this->server ) ) . '&n=' . $this->guildie; } elseif( $this->query === 'achievementc' ){ $filename_type = 'character-achievements'; $url = $config['url_prefix_armory'].$filename_type.'.xml?r=' . urlencode( utf8_encode( $this->server ) ) . '&n=' . $this->guildie . '&c=' . $this->category; } elseif( $this->query === 'statistics' ){ $filename_type = 'character-statistics'; $url = $config['url_prefix_armory'].$filename_type.'.xml?r=' . urlencode( utf8_encode( $this->server ) ) . '&n=' . $this->guildie; } elseif( $this->query === 'statisticsc' ){ $filename_type = 'character-statistics'; $url = $config['url_prefix_armory'].$filename_type.'.xml?r=' . urlencode( utf8_encode( $this->server ) ) . '&n=' . $this->guildie . '&c=' . $this->category; }
//alert($url);
if ( $config['live_system'] ) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt ($ch, CURLOPT_USERAGENT, self::BROWSER); $url_string = curl_exec($ch); curl_close($ch); echo ' -> <b>'.strtoupper($filename_type).'.XML LIVE FEED:</b> <a href="'.$url.'" target="_BLANK">'.$url.'</a><br/>'; } else { if( $this->query === 'roster' ){ echo '<b>NOTE: USING XML CACHE ONLY!!!</b><P>'; } }
//alert($url_string);
if( $this->query === 'roster' ){ // GET GUILD if ( $config['live_system'] ) { cacheXMLfile($filename_type, $url_string); } // CACHE THE GUILD XML STREAM $latestGuildXMLfile = getXMLfile('guild-info'); // GET THE LATEST CACHE GUILD XML FILE $url = $config['base_url'].$config['DIR_cache'].$latestGuildXMLfile['filename']; $url_filesize = $latestGuildXMLfile['filesize']; //echo "<P>RESULT -> ".$latestGuildXMLfile['filename']." - ".$latestGuildXMLfile['filesize']." - ".$latestGuildXMLfile['filetime']." <br /><br /><br /><br />";
} elseif( $this->query === 'character' ) { // GET CHARACTER $char_cache_filename = $filename_type.'-'.$this->guildie; // BUILD THE CHRACTER XML CACHE FILENAME if ( $config['live_system'] ) { cacheXMLfile($char_cache_filename, $url_string); } // CACHE THE GUILD XML STREAM $latestCharacterXMLfile = getXMLfile($char_cache_filename); // GET THE LATEST CACHE GUILD XML FILE $url = $config['base_url'].$config['DIR_cache'].$latestCharacterXMLfile['filename']; $url_filesize = $latestCharacterXMLfile['filesize']; //echo "<P>RESULT -> ".$latestCharacterXMLfile['filename']." - ".$latestCharacterXMLfile['filesize']." - ".$latestCharacterXMLfile['filetime']." <br /><br /><br /><br />";
} elseif( $this->query === 'achievement' ) { // GET ACHIEVEMENTS $char_cache_filename = $filename_type.'-'.$this->guildie; // BUILD THE CHRACTER XML CACHE FILENAME if ( $config['live_system'] ) { cacheXMLfile($char_cache_filename, $url_string); } // CACHE THE GUILD XML STREAM $latestCharacterXMLfile = getXMLfile($char_cache_filename); // GET THE LATEST CACHE GUILD XML FILE $url = $config['base_url'].$config['DIR_cache'].$latestCharacterXMLfile['filename']; $url_filesize = $latestCharacterXMLfile['filesize']; //echo "<P>RESULT -> ".$latestCharacterXMLfile['filename']." - ".$latestCharacterXMLfile['filesize']." - ".$latestCharacterXMLfile['filetime']." <br /><br /><br /><br />";
} elseif( $this->query === 'achievementc' ) { // GET ACHIEVEMENTS CATEGORY $char_cache_filename = $filename_type.'-'.$this->guildie.'-categoryid'.$this->category; // BUILD THE CHRACTER XML CACHE FILENAME if ( $config['live_system'] ) { cacheXMLfile($char_cache_filename, $url_string); } // CACHE THE GUILD XML STREAM $latestCharacterXMLfile = getXMLfile($char_cache_filename); // GET THE LATEST CACHE GUILD XML FILE $url = $config['base_url'].$config['DIR_cache'].$latestCharacterXMLfile['filename']; $url_filesize = $latestCharacterXMLfile['filesize']; //echo "<P>RESULT -> ".$latestCharacterXMLfile['filename']." - ".$latestCharacterXMLfile['filesize']." - ".$latestCharacterXMLfile['filetime']." <br /><br /><br /><br />";
} elseif( $this->query === 'statistics' ) { // GET STATISTICS $char_cache_filename = $filename_type.'-'.$this->guildie; // BUILD THE CHRACTER XML CACHE FILENAME if ( $config['live_system'] ) { cacheXMLfile($char_cache_filename, $url_string); } // CACHE THE GUILD XML STREAM $latestCharacterXMLfile = getXMLfile($char_cache_filename); // GET THE LATEST CACHE GUILD XML FILE $url = $config['base_url'].$config['DIR_cache'].$latestCharacterXMLfile['filename']; $url_filesize = $latestCharacterXMLfile['filesize']; //echo "<P>RESULT -> ".$latestCharacterXMLfile['filename']." - ".$latestCharacterXMLfile['filesize']." - ".$latestCharacterXMLfile['filetime']." <br /><br /><br /><br />";
} elseif( $this->query === 'statisticsc' ) { // GET STATISTICS CATEGORY $char_cache_filename = $filename_type.'-'.$this->guildie.'-categoryid'.$this->category; // BUILD THE CHRACTER XML CACHE FILENAME if ( $config['live_system'] ) { cacheXMLfile($char_cache_filename, $url_string); } // CACHE THE GUILD XML STREAM $latestCharacterXMLfile = getXMLfile($char_cache_filename); // GET THE LATEST CACHE GUILD XML FILE $url = $config['base_url'].$config['DIR_cache'].$latestCharacterXMLfile['filename']; $url_filesize = $latestCharacterXMLfile['filesize']; //echo "<P>RESULT -> ".$latestCharacterXMLfile['filename']." - ".$latestCharacterXMLfile['filesize']." - ".$latestCharacterXMLfile['filetime']." <br /><br /><br /><br />"; }
// if ( $url_filesize > 0 ) { $url_string = simplexml_load_file($url) or die ("ERROR: Unable to load XML file! URL: ".$url); echo ' -> <b>'.strtoupper($filename_type).'.XML CACHE:</b> <a href="'.$url.'" target="_BLANK">'.$url.'</a> - '.fileSizeInfo($url_filesize).' read...<br/>'; } else { $url_string = ""; echo ' -> <b>ERROR: '.strtoupper($filename_type).'.XML CACHE NOT READ:</b><br/>'; } return $url_string; } // end of pull_xml()
} // end class
//------------------------------------------------------------------ // Display a Javascript Alert Box [FOR DEBUG PURPOSES] function alert($textMessage) { global $config; print('<script language="javascript">alert("'.$textMessage.'")</script>'); }
//------------------------------------------------------------------ // Return the current load time function printLoadTime() { global $config; $m_time = explode(" ",microtime()); $m_time = $m_time[0] + $m_time[1]; $endtime = $m_time; $totaltime = ($endtime - $config['starttime']); return (string)round($totaltime,$config['round']); }
//------------------------------------------------------------------ // Convert seconds to '0:0:0:0 [H:M:S:SS]' function sec2hms ($sec, $padHours = false) { $hms = ""; $hours = intval(intval($sec) / 3600); $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':' : $hours. ':'; $minutes = intval(($sec / 60) % 60); $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':'; $seconds = intval($sec % 60); $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT). 's'; // '.'; //$splitseconds = intval($sec); //$hms .= str_pad($splitseconds, 4, "0", STR_PAD_LEFT); return $hms; }
//------------------------------------------------------------------ // Convert bytes to '0TB 0GB 0MB 0MB 0kb' function fileSizeInfo($size){ $i=0; $iec = array("b", "kb", "mb", "gb", "tb", "pb", "eb", "zb", "yb"); while (($size/1024)>1) { $size=$size/1024; $i++; } return substr($size,0,strpos($size,'.')+4).$iec[$i]; }
//------------------------------------------------------------------ // Get the latest cached XML file from the cache directory function getXMLfile( $XMLtype ) { global $config;
// GET LATEST XML FILE $new_file_size = 0; $new_file_time = 0; $new_file_name = ""; $old_file_date = time() - ($config['days_to_cache'] * 24 * 60 * 60); $dir = opendir ("./".$config['DIR_cache']); //echo " <b>-> CHECKING XML CACHE ["; $filecount = count(glob("./".$config['DIR_cache']."*.xml")); $filecount_current=0; $loading_bar_list = array(); for( $i=1; $i<$config['loading_bar']; $i++ ) { $loading_bar_list[] = round($filecount/$i); } while (false !== ($file = readdir($dir))) { if (strpos($file, $XMLtype ) === false ) { } else { $file_size = filesize($config['DIR_cache'].$file); $file_time = filemtime($config['DIR_cache'].$file); if ( preg_match("/categoryid/", $XMLtype) ) { if ( $file_time >= $new_file_time ) { // CHECK IF ITS A NEWER FILE //echo " [newer file]"; $new_file_size = $file_size; $new_file_time = $file_time; $new_file_name = $file; } } else { if ( $file_size > 614 ) { // 614 BYTES 503 ERROR DOCUMENT // 651 BYTES CHAR ERROR PAGE //echo "COMPARE -> '".$new_file_name."' '".$file."' <br /> ".$new_file_size."<=".$file_size." | ".$new_file_time."<".$file_time." |"; if ( $file_time >= $new_file_time ) { // CHECK IF ITS A NEWER FILE //echo " [newer file]"; $new_file_size = $file_size; $new_file_time = $file_time; $new_file_name = $file; } //echo "<br />"; } } // REMOVE FILES OLDER THAN THE SPECIFIED TIME if( $file_time < $old_file_date ) { unlink($config['DIR_cache'].$file); //alert($config['DIR_cache'].$file); } } //if (in_array($filecount_current,$loading_bar_list)) echo $config['loading_bar_mask']; $filecount_current++; } //echo "] - DONE</b><P>"; return array( "filename" => $new_file_name, "filesize" => $new_file_size, "filetime" => $new_file_time ); }
//------------------------------------------------------------------ // Save XML Stream to the cache directory function cacheXMLfile($filename, $XMLstream) { global $config;
$XML_filename = $config['DIR_cache'].$filename.'-'.date('Y.m.d-H.i.s').'.xml'; $handle = fopen($XML_filename, "wb"); $numbytes = fwrite($handle, $XMLstream); fclose($handle); $url_filesize_obj = fileSizeInfo($numbytes); echo ' -> <b>LIVE XML FEED CACHED TO XML FILE:</b> ./'.$XML_filename.' - '.fileSizeInfo($numbytes).' written...<br/>'; }
//------------------------------------------------------------------ // For each of the characters in the supplied array, pull the XML for each and populate the character array. function pullCharacterXML($armory, $charArray) { global $config;
$countCharaters = 0; $extendCharArray = array(); $charArray_Achievements = array(); $charArray_Statistics = array(); $returnArray = array(); foreach ($charArray as $char) { echo '<P><b>[ '.($countCharaters+1).' / '.count($charArray).' - '.sec2hms(printLoadTime()).' ] PROCESSING CHARACTER -> \''.$char['name'].'\'...</b><br/>';
// CHARACTER INFO echo '<P><B> -> [ '.sec2hms(printLoadTime()).' ] - '.$char['name'].'\'s CHARACTER INFORMATION...</B><br/>'; $char_armory = new armory('character', $config['server_name'], $config['guild_name'], $char['name'], NULL, NULL); $xml_armory = $char_armory->pull_xml(); // PULL THE CHARACTER XML FROM THE WOW ARMORY
// ACHIEVEMENT INFO [LAST 5] echo '<P><B> -> [ '.sec2hms(printLoadTime()).' ] - '.$char['name'].'\'s ACHIEVEMENTS...</B><br/>'; $char_achievement = new armory('achievement', $config['server_name'], $config['guild_name'], $char['name'], NULL, NULL); $xml_achievement = $char_achievement->pull_xml(); // PULL THE CHARACTER XML FROM THE WOW ARMORY
// BUILD CHARACTER ARRAY FROM XML SOURCE WITH LAST 5 ACHIEVEMENTS $charArray[$countCharaters] = extendCharacterArray($xml_armory, $xml_achievement, $charArray[$countCharaters]); $countCharaters++;
// ACHIEVEMENT INFO [COMPLETE] $charArray_Achievements = array_merge( $charArray_Achievements, getAllAchievements($xml_achievement,$char['name']) ); //echo '<b> OUTPUT ACHIEVEMENTS: </b><PRE>'; //print_r($charArray_Achievements); //echo '</PRE>';
// STATISTICS INFO [COMPLETE] echo '<P><B> -> [ '.sec2hms(printLoadTime()).' ] - '.$char['name'].'\'s STATISTICS...</B><br/>'; $char_statistics = new armory('statistics', $config['server_name'], $config['guild_name'], $char['name'], NULL, NULL); $xml_statistics = $char_statistics->pull_xml(); // PULL THE CHARACTER XML FROM THE WOW ARMORY $charArray_Statistics = array_merge( $charArray_Statistics, getAllStatistics($xml_statistics,$char['name']) ); //echo '<b> OUTPUT STATISTICS: </b><PRE>'; //print_r($charArray_Statistics); //echo '</PRE>'; }
$returnArray[] = $charArray; $returnArray[] = $charArray_Achievements; $returnArray[] = $charArray_Statistics; return $returnArray; }
//------------------------------------------------------------------ // function getAllStatistics($XMLstream,$charname) { global $config;
$charArray_Statistics = array();
foreach ($XMLstream->statistics->summary->statistic as $statistic) { $charArray_Statistics[] = array( "charName" => addslashes((string)$charname), "statid" => addslashes((string)$statistic['id']), "categoryId" => (string)'', "maincategoryName" => (string)'', "categoryName" => (string)'', "name" => addslashes((string)$statistic['name']), "highest" => addslashes((string)$statistic['highest']), "quantity" => addslashes((string)$statistic['quantity']) ); }
foreach ($XMLstream->statistics->rootCategories->category as $category) { echo '<B> -> [ '.sec2hms(printLoadTime()).' ] - STATISTICS CATEGORY #['.$category['id'].'] -> \''.$category['name'].'\'...</B><br/>';
$char_statistics = new armory('statisticsc', $config['server_name'], $config['guild_name'], $charname, $category['id'], NULL); $xml_statistics = $char_statistics->pull_xml(); // PULL THE CHARACTER XML FROM THE WOW ARMORY $charArray_Statistics = extendStatisticsArray($xml_statistics, $charArray_Statistics, $charname, $category['id'], $category['name']); }
return $charArray_Statistics; }
//------------------------------------------------------------------ // function extendStatisticsArray($XMLstream,$aStatistics,$charname,$categoryid,$categoryname) { global $config;
if ( strlen($XMLstream) != 0 ) { foreach ($XMLstream->statistic as $statistic) { $aStatistics[] = array( "charName" => addslashes((string)$charname), "statid" => addslashes((string)$statistic['id']), "categoryId" => addslashes((string)$categoryid), "maincategoryName" => addslashes((string)$categoryname), "categoryName" => (string)'', "name" => addslashes((string)$statistic['name']), "highest" => addslashes((string)$statistic['highest']), "quantity" => addslashes((string)$statistic['quantity']) ); } foreach ($XMLstream->category as $category) { foreach ($category->statistic as $statistic) { $aStatistics[] = array( "charName" => addslashes((string)$charname), "statid" => addslashes((string)$statistic['id']), "categoryId" => addslashes((string)$categoryid), "maincategoryName" => addslashes((string)$categoryname), "categoryName" => addslashes((string)$category['name']), "name" => addslashes((string)$statistic['name']), "highest" => addslashes((string)$statistic['highest']), "quantity" => addslashes((string)$statistic['quantity']) ); } } }
return $aStatistics; }
//------------------------------------------------------------------ // function getAllAchievements($XMLstream,$charname) { global $config;
$charArray_Achievements = array(); foreach ($XMLstream->achievements->rootCategories->category as $category) {
echo '<B> -> [ '.sec2hms(printLoadTime()).' ] - ACHIEVEMENT CATEGORY #['.$category['id'].'] -> \''.$category['name'].'\'...</B><br/>';
$charArray_Subcategories = array(); foreach ($category->category as $subcategory) { $charArray_Subcategories[] = addslashes((string)$subcategory['name']); }
$char_achievement = new armory('achievementc', $config['server_name'], $config['guild_name'], $charname, $category['id'], NULL); $xml_achievement = $char_achievement->pull_xml(); // PULL THE CHARACTER XML FROM THE WOW ARMORY $charArray_Achievements = extendAchievementsArray($xml_achievement, $charArray_Achievements, $charname, $category['name'], $charArray_Subcategories); }
return $charArray_Achievements; }
//------------------------------------------------------------------ // function extendAchievementsArray($XMLstream,$aAchievements,$charname,$categoryname,$subcategories) { global $config;
if ( strlen($XMLstream) != 0 ) { $category_count = 0; foreach ($XMLstream->category as $category) { foreach ($category->achievement as $achievement) { $aAchievements[] = array( "charName" => addslashes((string)$charname), "achid" => addslashes((string)$achievement['id']), "categoryId" => addslashes((string)$achievement['categoryId']), "maincategoryName" => addslashes((string)$categoryname), "categoryName" => addslashes((string)$subcategories[$category_count]), "name" => addslashes((string)$achievement['name']), "dateCompleted" => addslashes((string)$achievement['dateCompleted']), "descript" => addslashes((string)$achievement['desc']), "icon" => addslashes((string)$achievement['icon']), "points" => addslashes((string)$achievement['points']), "reward" => addslashes((string)$achievement['reward']), "title" => addslashes((string)$achievement['title']), "maxQuantity" => (string)'', "quantity" => (string)'' ); foreach ($achievement->criteria as $criteria) { $aAchievements[] = array( "charName" => addslashes((string)$charname), "achid" => addslashes((string)$criteria['id']), "categoryId" => addslashes((string)$achievement['categoryId']), "maincategoryName" => addslashes((string)$categoryname), "categoryName" => addslashes((string)$subcategories[$category_count]), "name" => addslashes((string)$criteria['name']), "dateCompleted" => addslashes((string)$criteria['date']), "descript" => (string)'', "icon" => (string)'', "points" => (string)'', "reward" => (string)'', "title" => (string)'', "maxQuantity" => addslashes((string)$criteria['maxQuantity']), "quantity" => addslashes((string)$criteria['quantity']) ); } } $category_count++; } }
return $aAchievements; }
//------------------------------------------------------------------ // Extend the Character Array from the supplied character XML stream function extendCharacterArray($XMLstream, $XMLstreamAchievement, $char) { global $config;
// PARSE DATA FROM THE CHAR XML SOURCE
// TITLES STRINGS $char_obj = $XMLstream->characterInfo->character; $current_title = $char_obj['prefix'].$char['name'].$char_obj['suffix'];
// DEPRECIATED - 1st JULY 2009 // $count_knowntitles = 0; // $knowntitles_string = ""; // if ( count($XMLstream->characterInfo->characterTab->knownTitles->title) != 0 ) { // foreach ($XMLstream->characterInfo->characterTab->knownTitles->title as $knowntitles) { // if ( $count_knowntitles == 0 ) { $knowntitles_string .= $knowntitles['value']; // } else { $knowntitles_string .= ", ".$knowntitles['value']; } // $count_knowntitles++; // } // } // REPLACE '%s' WITH CHARACTER NAME IN THE TITLES // $current_title = str_replace("%s", $char['name'], $current_title); // $knowntitles_string = str_replace("%s", $char['name'], $knowntitles_string);
// TALENT SPECS ARRAYS $talentspec1 = $XMLstream->characterInfo->characterTab->talentSpecs->talentSpec[0]; $talentspec2 = $XMLstream->characterInfo->characterTab->talentSpecs->talentSpec[1];
// PROFESSIONS ARRAYS $profession1 = $XMLstream->characterInfo->characterTab->professions->skill[0]; $profession2 = $XMLstream->characterInfo->characterTab->professions->skill[1];
// CHARACTER BARS ARRAYS $characterbars = $XMLstream->characterInfo->characterTab->characterBars->secondBar;
// BASE STATS ARRAYS $basestats_strength = $XMLstream->characterInfo->characterTab->baseStats->strength; $basestats_agility = $XMLstream->characterInfo->characterTab->baseStats->agility; $basestats_stamina = $XMLstream->characterInfo->characterTab->baseStats->stamina; $basestats_intellect = $XMLstream->characterInfo->characterTab->baseStats->intellect; $basestats_spirit = $XMLstream->characterInfo->characterTab->baseStats->spirit; $basestats_armor = $XMLstream->characterInfo->characterTab->baseStats->armor;
// MELEE ARRAYS $melee_mainHandDamage = $XMLstream->characterInfo->characterTab->melee->mainHandDamage; $melee_offHandDamage = $XMLstream->characterInfo->characterTab->melee->offHandDamage; $melee_mainHandSpeed = $XMLstream->characterInfo->characterTab->melee->mainHandSpeed; $melee_offHandSpeed = $XMLstream->characterInfo->characterTab->melee->offHandSpeed; $melee_power = $XMLstream->characterInfo->characterTab->melee->power; $melee_hitRating = $XMLstream->characterInfo->characterTab->melee->hitRating; $melee_critChance = $XMLstream->characterInfo->characterTab->melee->critChance; $melee_expertise = $XMLstream->characterInfo->characterTab->melee->expertise;
// RANGED ARRAYS $ranged_weaponSkill = $XMLstream->characterInfo->characterTab->ranged->weaponSkill; $ranged_damage = $XMLstream->characterInfo->characterTab->ranged->damage; $ranged_speed = $XMLstream->characterInfo->characterTab->ranged->speed; $ranged_power = $XMLstream->characterInfo->characterTab->ranged->power; $ranged_hitRating = $XMLstream->characterInfo->characterTab->ranged->hitRating; $ranged_critChance = $XMLstream->characterInfo->characterTab->ranged->critChance;
// SPELL ARRAYS $spell_bonusDamage = $XMLstream->characterInfo->characterTab->spell->bonusDamage; $spell_critChance = $XMLstream->characterInfo->characterTab->spell->critChance; $spell_hitRating = $XMLstream->characterInfo->characterTab->spell->hitRating; $spell_manaRegen = $XMLstream->characterInfo->characterTab->spell->manaRegen; $spell_hasteRating = $XMLstream->characterInfo->characterTab->spell->hasteRating;
// DEFENSES ARRAYS $defenses_armor = $XMLstream->characterInfo->characterTab->defenses->armor; $defenses_defense = $XMLstream->characterInfo->characterTab->defenses->defense; $defenses_dodge = $XMLstream->characterInfo->characterTab->defenses->dodge; $defenses_parry = $XMLstream->characterInfo->characterTab->defenses->parry; $defenses_block = $XMLstream->characterInfo->characterTab->defenses->block; $defenses_resilience = $XMLstream->characterInfo->characterTab->defenses->resilience;
// ITEMS ARRAYS $items = array(); for( $i=0; $i<=$config['equipable_items_number']; $i++ ) { // SEED THE ITEMS ARRAY WITH '0' VALUES $items[] = array( "durability" => 0, "gem0Id" => 0, "gem1Id" => 0, "gem2Id" => 0, "icon" => 0, "id" => 0, "maxDurability" => 0, "permanentenchant" => 0, "randomPropertiesId" => 0, "seed" => 0, "slot" => $i ); } if( count($XMLstream->characterInfo->characterTab->items->item) != 0 ) { foreach ( $XMLstream->characterInfo->characterTab->items->item as $item ) { // POPULATE THE KNOWN ITEMS $items[((int)$item['slot'])] = array( // POPULATE THE ITEM VALUES TO THE ITEMS ARRAY "durability" => $item['durability'], "gem0Id" => $item['gem0Id'], "gem1Id" => $item['gem1Id'], "gem2Id" => $item['gem2Id'], "icon" => $item['icon'], "id" => $item['id'], "maxDurability" => $item['maxDurability'], "permanentenchant" => $item['permanentenchant'], "randomPropertiesId" => $item['randomPropertiesId'], "seed" => $item['seed'], "slot" => $item['slot'] ); } }
// GLYPHS $glyphs0 = $XMLstream->characterInfo->characterTab->glyphs->glyph[0]; $glyphs1 = $XMLstream->characterInfo->characterTab->glyphs->glyph[1]; $glyphs2 = $XMLstream->characterInfo->characterTab->glyphs->glyph[2]; $glyphs3 = $XMLstream->characterInfo->characterTab->glyphs->glyph[3]; $glyphs4 = $XMLstream->characterInfo->characterTab->glyphs->glyph[4]; $glyphs5 = $XMLstream->characterInfo->characterTab->glyphs->glyph[5];
// ACHIEVEMENT SUMMARY $achSummary = $XMLstream->characterInfo->summary;
// ACHIEVEMENT - LAST 5 $achievements = array(); $count_achievements = 0; if( count($XMLstreamAchievement->achievements->summary->achievement) != 0 ) { foreach ( $XMLstreamAchievement->achievements->summary->achievement as $achievement ) { // POPULATE THE KNOWN ACHIEVEMENTS $achievements[$count_achievements] = array( // POPULATE THE ACHIEVEMENT VALUES TO THE ACHIEVEMENTS ARRAY "categoryId" => $achievement['categoryId'], "dateCompleted" => $achievement['dateCompleted'], "desc" => $achievement['desc'], "icon" => $achievement['icon'], "id" => $achievement['id'], "points" => $achievement['points'], "title" => $achievement['title'] ); $count_achievements++; } }
// REBUILD THE CHARACTER ARRAY $char_Array = array(
// BASIC INNFORMATION "name" => $char['name'], "level" => $char['level'], "class" => $char['class'], "gender" => $char['gender'], "race" => $char['race'], "rank" => $char['rank'], "achPoints" => $char['achPoints'], "url" => $char['url'],
// GET BATTLEGROUP & LAST MODIFIED TIME "battleGroup" => $XMLstream->characterInfo->character['battleGroup'], "lastModified" => $XMLstream->characterInfo->character['lastModified'],
// TITLES "current_title" => addslashes($current_title), // "known_titles" => $knowntitles_string,
// TALENT SPECS "talent1_active" => $talentspec1['active'], "talent1_group" => $talentspec1['group'], "talent1_icon" => $talentspec1['icon'], "talent1_prim" => $talentspec1['prim'], "talent1_treeOne" => $talentspec1['treeOne'], "talent1_treeTwo" => $talentspec1['treeTwo'], "talent1_treeThree" => $talentspec1['treeThree'], "talent2_active" => $talentspec2['active'], "talent2_group" => $talentspec2['group'], "talent2_icon" => $talentspec2['icon'], "talent2_prim" => $talentspec2['prim'], "talent2_treeOne" => $talentspec2['treeOne'], "talent2_treeTwo" => $talentspec2['treeTwo'], "talent2_treeThree" => $talentspec2['treeThree'],
// PROFESSIONS "profession1_key" => $profession1['key'], "profession1_name" => $profession1['name'], "profession1_max" => $profession1['max'], "profession1_value" => $profession1['value'], "profession2_key" => $profession2['key'], "profession2_name" => $profession2['name'], "profession2_max" => $profession2['max'], "profession2_value" => $profession2['value'],
// PVP "pvp_honorable_kills" => $XMLstream->characterInfo->characterTab->pvp->lifetimehonorablekills['value'], "pvp_arena_currency" => $XMLstream->characterInfo->characterTab->pvp->arenacurrency['value'],
// CHARACTER BARS "characterbars1_value" => $XMLstream->characterInfo->characterTab->characterBars->health['effective'], "characterbars2_value" => $characterbars['effective'], "characterbars2_casting" => $characterbars['casting'], "characterbars2_notCasting" => $characterbars['notCasting'], "characterbars2_type" => $characterbars['type'],
// BASE STATS "basestats_strength_attack" => $basestats_strength['attack'], "basestats_strength_base" => $basestats_strength['base'], "basestats_strength_block" => $basestats_strength['block'], "basestats_strength_effective" => $basestats_strength['effective'], "basestats_agility_armor" => $basestats_agility['armor'], "basestats_agility_attack" => $basestats_agility['attack'], "basestats_agility_base" => $basestats_agility['base'], "basestats_agility_critHitPercent" => $basestats_agility['critHitPercent'], "basestats_agility_effective" => $basestats_agility['effective'], "basestats_stamina_base" => $basestats_stamina['base'], "basestats_stamina_effective" => $basestats_stamina['effective'], "basestats_stamina_health" => $basestats_stamina['health'], "basestats_stamina_petBonus" => $basestats_stamina['petBonus'], "basestats_intellect_base" => $basestats_intellect['base'], "basestats_intellect_critHitPercent" => $basestats_intellect['critHitPercent'], "basestats_intellect_effective" => $basestats_intellect['effective'], "basestats_intellect_mana" => $basestats_intellect['mana'], "basestats_intellect_petBonus" => $basestats_intellect['petBonus'], "basestats_spirit_base" => $basestats_spirit['base'], "basestats_spirit_effective" => $basestats_spirit['effective'], "basestats_spirit_healthRegen" => $basestats_spirit['healthRegen'], "basestats_spirit_manaRegen" => $basestats_spirit['manaRegen'], "basestats_armor_base" => $basestats_armor['base'], "basestats_armor_effective" => $basestats_armor['effective'], "basestats_armor_percent" => $basestats_armor['percent'], "basestats_armor_petBonus" => $basestats_armor['petBonus'],
// RESISTANCES "resistances_arcane_value" => $XMLstream->characterInfo->characterTab->resistances->arcane['value'], "resistances_arcane_petBonus" => $XMLstream->characterInfo->characterTab->resistances->arcane['petBonus'], "resistances_fire_value" => $XMLstream->characterInfo->characterTab->resistances->fire['value'], "resistances_fire_petBonus" => $XMLstream->characterInfo->characterTab->resistances->fire['petBonus'], "resistances_frost_value" => $XMLstream->characterInfo->characterTab->resistances->frost['value'], "resistances_frost_petBonus" => $XMLstream->characterInfo->characterTab->resistances->frost['petBonus'], "resistances_holy_value" => $XMLstream->characterInfo->characterTab->resistances->holy['value'], "resistances_holy_petBonus" => $XMLstream->characterInfo->characterTab->resistances->holy['petBonus'], "resistances_nature_value" => $XMLstream->characterInfo->characterTab->resistances->nature['value'], "resistances_nature_petBonus" => $XMLstream->characterInfo->characterTab->resistances->nature['petBonus'], "resistances_shadow_value" => $XMLstream->characterInfo->characterTab->resistances->shadow['value'], "resistances_shadow_petBonus" => $XMLstream->characterInfo->characterTab->resistances->shadow['petBonus'],
// MELEE "melee_mainHandDamage_dps" => $melee_mainHandDamage['dps'], "melee_mainHandDamage_max" => $melee_mainHandDamage['max'], "melee_mainHandDamage_min" => $melee_mainHandDamage['min'], "melee_mainHandDamage_percent" => $melee_mainHandDamage['percent'], "melee_mainHandDamage_speed" => $melee_mainHandDamage['speed'], "melee_offHandDamage_dps" => $melee_offHandDamage['dps'], "melee_offHandDamage_max" => $melee_offHandDamage['max'], "melee_offHandDamage_min" => $melee_offHandDamage['min'], "melee_offHandDamage_percent" => $melee_offHandDamage['percent'], "melee_offHandDamage_speed" => $melee_offHandDamage['speed'], "melee_mainHandSpeed_hastePercent" => $melee_mainHandSpeed['hastePercent'], "melee_mainHandSpeed_hasteRating" => $melee_mainHandSpeed['hasteRating'], "melee_mainHandSpeed_value" => $melee_mainHandSpeed['value'], "melee_offHandSpeed_hastePercent" => $melee_offHandSpeed['hastePercent'], "melee_offHandSpeed_hasteRating" => $melee_offHandSpeed['hasteRating'], "melee_offHandSpeed_value" => $melee_offHandSpeed['value'], "melee_power_base" => $melee_power['base'], "melee_power_effective" => $melee_power['effective'], "melee_power_increasedDps" => $melee_power['increasedDps'], "melee_hitRating_increasedHitPercent" => $melee_hitRating['increasedHitPercent'], "melee_hitRating_penetration" => $melee_hitRating['penetration'], "melee_hitRating_reducedArmorPercent" => $melee_hitRating['reducedArmorPercent'], "melee_hitRating_value" => $melee_hitRating['value'], "melee_critChance_percent" => $melee_critChance['percent'], "melee_critChance_plusPercent" => $melee_critChance['plusPercent'], "melee_critChance_rating" => $melee_critChance['rating'], "melee_expertise_additional" => $melee_expertise['additional'], "melee_expertise_percent" => $melee_expertise['percent'], "melee_expertise_rating" => $melee_expertise['rating'], "melee_expertise_value" => $melee_expertise['value'],
// RANGED "ranged_weaponSkill_rating" => $ranged_weaponSkill['rating'], "ranged_weaponSkill_value" => $ranged_weaponSkill['value'], "ranged_damage_dps" => $ranged_damage['dps'], "ranged_damage_max" => $ranged_damage['max'], "ranged_damage_min" => $ranged_damage['min'], "ranged_damage_percent" => $ranged_damage['percent'], "ranged_damage_speed" => $ranged_damage['speed'], "ranged_speed_hastePercent" => $ranged_speed['hastePercent'], "ranged_speed_hasteRating" => $ranged_speed['hasteRating'], "ranged_speed_value" => $ranged_speed['value'], "ranged_power_base" => $ranged_power['base'], "ranged_power_effective" => $ranged_power['effective'], "ranged_power_increasedDps" => $ranged_power['increasedDps'], "ranged_power_petAttack" => $ranged_power['petAttack'], "ranged_power_petSpell" => $ranged_power['petSpell'], "ranged_hitRating_increasedHitPercent" => $ranged_hitRating['increasedHitPercent'], "ranged_hitRating_penetration" => $ranged_hitRating['penetration'], "ranged_hitRating_reducedArmorPercent" => $ranged_hitRating['reducedArmorPercent'], "ranged_hitRating_value" => $ranged_hitRating['value'], "ranged_critChance_percent" => $ranged_critChance['percent'], "ranged_critChance_plusPercent" => $ranged_critChance['plusPercent'], "ranged_critChance_rating" => $ranged_critChance['rating'],
// SPELL "spell_bonusDamage_arcane" => $spell_bonusDamage->arcane['value'], "spell_bonusDamage_fire" => $spell_bonusDamage->fire['value'], "spell_bonusDamage_frost" => $spell_bonusDamage->frost['value'], "spell_bonusDamage_holy" => $spell_bonusDamage->holy['value'], "spell_bonusDamage_nature" => $spell_bonusDamage->nature['value'], "spell_bonusDamage_shadow" => $spell_bonusDamage->shadow['value'], "spell_bonusDamage_petBonus_attack" => $spell_bonusDamage->petBonus['attack'], "spell_bonusDamage_petBonus_damage" => $spell_bonusDamage->petBonus['damage'], "spell_bonusDamage_petBonus_fromType" => $spell_bonusDamage->petBonus['fromType'], "spell_bonusHealing" => $XMLstream->characterInfo->characterTab->spell->bonusHealing['value'], "spell_hitRating_increasedHitPercent" => $spell_hitRating['increasedHitPercent'], "spell_hitRating_penetration" => $spell_hitRating['penetration'], "spell_hitRating_reducedResist" => $spell_hitRating['reducedResist'], "spell_hitRating_value" => $spell_hitRating['value'], "spell_critChance_rating" => $spell_critChance['rating'], "spell_critChance_arcane_percent" => $spell_critChance->arcane['percent'], "spell_critChance_fire_percent" => $spell_critChance->fire['percent'], "spell_critChance_frost_percent" => $spell_critChance->frost['percent'], "spell_critChance_holy_percent" => $spell_critChance->holy['percent'], "spell_critChance_nature_percent" => $spell_critChance->nature['percent'], "spell_critChance_shadow_percent" => $spell_critChance->shadow['percent'], "spell_penetration" => $XMLstream->characterInfo->characterTab->spell->penetration['value'], "spell_manaRegen_casting" => $spell_manaRegen['casting'], "spell_manaRegen_notCasting" => $spell_manaRegen['notCasting'], "spell_hastePercent" => $spell_hasteRating['hastePercent'], "spell_hasteRating" => $spell_hasteRating['hasteRating'],
// DEFENSES "defenses_armor_base" => $defenses_armor['base'], "defenses_armor_effective" => $defenses_armor['effective'], "defenses_armor_percent" => $defenses_armor['percent'], "defenses_armor_petBonus" => $defenses_armor['petBonus'], "defenses_defense_decreasePercent" => $defenses_defense['decreasePercent'], "defenses_defense_increasePercent" => $defenses_defense['increasePercent'], "defenses_defense_plusDefense" => $defenses_defense['plusDefense'], "defenses_defense_rating" => $defenses_defense['rating'], "defenses_defense_value" => $defenses_defense['value'], "defenses_dodge_increasePercent" => $defenses_dodge['increasePercent'], "defenses_dodge_percent" => $defenses_dodge['percent'], "defenses_dodge_rating" => $defenses_dodge['rating'], "defenses_parry_increasePercent" => $defenses_parry['increasePercent'], "defenses_parry_percent" => $defenses_parry['percent'], "defenses_parry_rating" => $defenses_parry['rating'], "defenses_block_increasePercent" => $defenses_block['increasePercent'], "defenses_block_percent" => $defenses_block['percent'], "defenses_block_rating" => $defenses_block['rating'], "defenses_resilience_damagePercent" => $defenses_resilience['damagePercent'], "defenses_resilience_hitPercent" => $defenses_resilience['hitPercent'], "defenses_resilience_value" => $defenses_resilience['value'],
// ITEMS "item0_durability" => $items[0]['durability'], // ITEMS - SLOT 0 "item0_gem0Id" => $items[0]['gem0Id'], "item0_gem1Id" => $items[0]['gem1Id'], "item0_gem2Id" => $items[0]['gem2Id'], "item0_icon" => $items[0]['icon'], "item0_id" => $items[0]['id'], "item0_maxDurability" => $items[0]['maxDurability'], "item0_permanentenchant" => $items[0]['permanentenchant'], "item0_randomPropertiesId" => $items[0]['randomPropertiesId'], "item0_seed" => $items[0]['seed'], "item0_slot" => $items[0]['slot'], "item1_durability" => $items[1]['durability'], // ITEMS - SLOT 1 "item1_gem0Id" => $items[1]['gem0Id'], "item1_gem1Id" => $items[1]['gem1Id'], "item1_gem2Id" => $items[1]['gem2Id'], "item1_icon" => $items[1]['icon'], "item1_id" => $items[1]['id'], "item1_maxDurability" => $items[1]['maxDurability'], "item1_permanentenchant" => $items[1]['permanentenchant'], "item1_randomPropertiesId" => $items[1]['randomPropertiesId'], "item1_seed" => $items[1]['seed'], "item1_slot" => $items[1]['slot'], "item2_durability" => $items[2]['durability'], // ITEMS - SLOT 2 "item2_gem0Id" => $items[2]['gem0Id'], "item2_gem1Id" => $items[2]['gem1Id'], "item2_gem2Id" => $items[2]['gem2Id'], "item2_icon" => $items[2]['icon'], "item2_id" => $items[2]['id'], "item2_maxDurability" => $items[2]['maxDurability'], "item2_permanentenchant" => $items[2]['permanentenchant'], "item2_randomPropertiesId" => $items[2]['randomPropertiesId'], "item2_seed" => $items[2]['seed'], "item2_slot" => $items[2]['slot'], "item3_durability" => $items[3]['durability'], // ITEMS - SLOT 3 "item3_gem0Id" => $items[3]['gem0Id'], "item3_gem1Id" => $items[3]['gem1Id'], "item3_gem2Id" => $items[3]['gem2Id'], "item3_icon" => $items[3]['icon'], "item3_id" => $items[3]['id'], "item3_maxDurability" => $items[3]['maxDurability'], "item3_permanentenchant" => $items[3]['permanentenchant'], "item3_randomPropertiesId" => $items[3]['randomPropertiesId'], "item3_seed" => $items[3]['seed'], "item3_slot" => $items[3]['slot'], "item4_durability" => $items[4]['durability'], // ITEMS - SLOT 4 "item4_gem0Id" => $items[4]['gem0Id'], "item4_gem1Id" => $items[4]['gem1Id'], "item4_gem2Id" => $items[4]['gem2Id'], "item4_icon" => $items[4]['icon'], "item4_id" => $items[4]['id'], "item4_maxDurability" => $items[4]['maxDurability'], "item4_permanentenchant" => $items[4]['permanentenchant'], "item4_randomPropertiesId" => $items[4]['randomPropertiesId'], "item4_seed" => $items[4]['seed'], "item4_slot" => $items[4]['slot'], "item5_durability" => $items[5]['durability'], // ITEMS - SLOT 5 "item5_gem0Id" => $items[5]['gem0Id'], "item5_gem1Id" => $items[5]['gem1Id'], "item5_gem2Id" => $items[5]['gem2Id'], "item5_icon" => $items[5]['icon'], "item5_id" => $items[5]['id'], "item5_maxDurability" => $items[5]['maxDurability'], "item5_permanentenchant" => $items[5]['permanentenchant'], "item5_randomPropertiesId" => $items[5]['randomPropertiesId'], "item5_seed" => $items[5]['seed'], "item5_slot" => $items[5]['slot'], "item6_durability" => $items[6]['durability'], // ITEMS - SLOT 6 "item6_gem0Id" => $items[6]['gem0Id'], "item6_gem1Id" => $items[6]['gem1Id'], "item6_gem2Id" => $items[6]['gem2Id'], "item6_icon" => $items[6]['icon'], "item6_id" => $items[6]['id'], "item6_maxDurability" => $items[6]['maxDurability'], "item6_permanentenchant" => $items[6]['permanentenchant'], "item6_randomPropertiesId" => $items[6]['randomPropertiesId'], "item6_seed" => $items[6]['seed'], "item6_slot" => $items[6]['slot'], "item7_durability" => $items[7]['durability'], // ITEMS - SLOT 7 "item7_gem0Id" => $items[7]['gem0Id'], "item7_gem1Id" => $items[7]['gem1Id'], "item7_gem2Id" => $items[7]['gem2Id'], "item7_icon" => $items[7]['icon'], "item7_id" => $items[7]['id'], "item7_maxDurability" => $items[7]['maxDurability'], "item7_permanentenchant" => $items[7]['permanentenchant'], "item7_randomPropertiesId" => $items[7]['randomPropertiesId'], "item7_seed" => $items[7]['seed'], "item7_slot" => $items[7]['slot'], "item8_durability" => $items[8]['durability'], // ITEMS - SLOT 8 "item8_gem0Id" => $items[8]['gem0Id'], "item8_gem1Id" => $items[8]['gem1Id'], "item8_gem2Id" => $items[8]['gem2Id'], "item8_icon" => $items[8]['icon'], "item8_id" => $items[8]['id'], "item8_maxDurability" => $items[8]['maxDurability'], "item8_permanentenchant" => $items[8]['permanentenchant'], "item8_randomPropertiesId" => $items[8]['randomPropertiesId'], "item8_seed" => $items[8]['seed'], "item8_slot" => $items[8]['slot'], "item9_durability" => $items[9]['durability'], // ITEMS - SLOT 9 "item9_gem0Id" => $items[9]['gem0Id'], "item9_gem1Id" => $items[9]['gem1Id'], "item9_gem2Id" => $items[9]['gem2Id'], "item9_icon" => $items[9]['icon'], "item9_id" => $items[9]['id'], "item9_maxDurability" => $items[9]['maxDurability'], "item9_permanentenchant" => $items[9]['permanentenchant'], "item9_randomPropertiesId" => $items[9]['randomPropertiesId'], "item9_seed" => $items[9]['seed'], "item9_slot" => $items[9]['slot'], "item10_durability" => $items[10]['durability'], // ITEMS - SLOT 10 "item10_gem0Id" => $items[10]['gem0Id'], "item10_gem1Id" => $items[10]['gem1Id'], "item10_gem2Id" => $items[10]['gem2Id'], "item10_icon" => $items[10]['icon'], "item10_id" => $items[10]['id'], "item10_maxDurability" => $items[10]['maxDurability'], "item10_permanentenchant" => $items[10]['permanentenchant'], "item10_randomPropertiesId" => $items[10]['randomPropertiesId'], "item10_seed" => $items[10]['seed'], "item10_slot" => $items[10]['slot'], "item11_durability" => $items[11]['durability'], // ITEMS - SLOT 11 "item11_gem0Id" => $items[11]['gem0Id'], "item11_gem1Id" => $items[11]['gem1Id'], "item11_gem2Id" => $items[11]['gem2Id'], "item11_icon" => $items[11]['icon'], "item11_id" => $items[11]['id'], "item11_maxDurability" => $items[11]['maxDurability'], "item11_permanentenchant" => $items[11]['permanentenchant'], "item11_randomPropertiesId" => $items[11]['randomPropertiesId'], "item11_seed" => $items[11]['seed'], "item11_slot" => $items[11]['slot'], "item12_durability" => $items[12]['durability'], // ITEMS - SLOT 12 "item12_gem0Id" => $items[12]['gem0Id'], "item12_gem1Id" => $items[12]['gem1Id'], "item12_gem2Id" => $items[12]['gem2Id'], "item12_icon" => $items[12]['icon'], "item12_id" => $items[12]['id'], "item12_maxDurability" => $items[12]['maxDurability'], "item12_permanentenchant" => $items[12]['permanentenchant'], "item12_randomPropertiesId" => $items[12]['randomPropertiesId'], "item12_seed" => $items[12]['seed'], "item12_slot" => $items[12]['slot'], "item13_durability" => $items[13]['durability'], // ITEMS - SLOT 13 "item13_gem0Id" => $items[13]['gem0Id'], "item13_gem1Id" => $items[13]['gem1Id'], "item13_gem2Id" => $items[13]['gem2Id'], "item13_icon" => $items[13]['icon'], "item13_id" => $items[13]['id'], "item13_maxDurability" => $items[13]['maxDurability'], "item13_permanentenchant" => $items[13]['permanentenchant'], "item13_randomPropertiesId" => $items[13]['randomPropertiesId'], "item13_seed" => $items[13]['seed'], "item13_slot" => $items[13]['slot'], "item14_durability" => $items[14]['durability'], // ITEMS - SLOT 14 "item14_gem0Id" => $items[14]['gem0Id'], "item14_gem1Id" => $items[14]['gem1Id'], "item14_gem2Id" => $items[14]['gem2Id'], "item14_icon" => $items[14]['icon'], "item14_id" => $items[14]['id'], "item14_maxDurability" => $items[14]['maxDurability'], "item14_permanentenchant" => $items[14]['permanentenchant'], "item14_randomPropertiesId" => $items[14]['randomPropertiesId'], "item14_seed" => $items[14]['seed'], "item14_slot" => $items[14]['slot'], "item15_durability" => $items[15]['durability'], // ITEMS - SLOT 15 "item15_gem0Id" => $items[15]['gem0Id'], "item15_gem1Id" => $items[15]['gem1Id'], "item15_gem2Id" => $items[15]['gem2Id'], "item15_icon" => $items[15]['icon'], "item15_id" => $items[15]['id'], "item15_maxDurability" => $items[15]['maxDurability'], "item15_permanentenchant" => $items[15]['permanentenchant'], "item15_randomPropertiesId" => $items[15]['randomPropertiesId'], "item15_seed" => $items[15]['seed'], "item15_slot" => $items[15]['slot'], "item16_durability" => $items[16]['durability'], // ITEMS - SLOT 16 "item16_gem0Id" => $items[16]['gem0Id'], "item16_gem1Id" => $items[16]['gem1Id'], "item16_gem2Id" => $items[16]['gem2Id'], "item16_icon" => $items[16]['icon'], "item16_id" => $items[16]['id'], "item16_maxDurability" => $items[16]['maxDurability'], "item16_permanentenchant" => $items[16]['permanentenchant'], "item16_randomPropertiesId" => $items[16]['randomPropertiesId'], "item16_seed" => $items[16]['seed'], "item16_slot" => $items[16]['slot'], "item17_durability" => $items[17]['durability'], // ITEMS - SLOT 17 "item17_gem0Id" => $items[17]['gem0Id'], "item17_gem1Id" => $items[17]['gem1Id'], "item17_gem2Id" => $items[17]['gem2Id'], "item17_icon" => $items[17]['icon'], "item17_id" => $items[17]['id'], "item17_maxDurability" => $items[17]['maxDurability'], "item17_permanentenchant" => $items[17]['permanentenchant'], "item17_randomPropertiesId" => $items[17]['randomPropertiesId'], "item17_seed" => $items[17]['seed'], "item17_slot" => $items[17]['slot'], "item18_durability" => $items[18]['durability'], // ITEMS - SLOT 18 "item18_gem0Id" => $items[18]['gem0Id'], "item18_gem1Id" => $items[18]['gem1Id'], "item18_gem2Id" => $items[18]['gem2Id'], "item18_icon" => $items[18]['icon'], "item18_id" => $items[18]['id'], "item18_maxDurability" => $items[18]['maxDurability'], "item18_permanentenchant" => $items[18]['permanentenchant'], "item18_randomPropertiesId" => $items[18]['randomPropertiesId'], "item18_seed" => $items[18]['seed'], "item18_slot" => $items[18]['slot'],
// GLYPHS "glyph0_effect" => addslashes($glyphs0['effect']), "glyph0_icon" => $glyphs0['icon'], "glyph0_name" => addslashes($glyphs0['name']), "glyph0_type" => $glyphs0['type'], "glyph1_effect" => addslashes($glyphs1['effect']), "glyph1_icon" => $glyphs1['icon'], "glyph1_name" => addslashes($glyphs1['name']), "glyph1_type" => $glyphs1['type'], "glyph2_effect" => addslashes($glyphs2['effect']), "glyph2_icon" => $glyphs2['icon'], "glyph2_name" => addslashes($glyphs2['name']), "glyph2_type" => $glyphs2['type'], "glyph3_effect" => addslashes($glyphs3['effect']), "glyph3_icon" => $glyphs3['icon'], "glyph3_name" => addslashes($glyphs3['name']), "glyph3_type" => $glyphs3['type'], "glyph4_effect" => addslashes($glyphs4['effect']), "glyph4_icon" => $glyphs4['icon'], "glyph4_name" => addslashes($glyphs4['name']), "glyph4_type" => $glyphs4['type'], "glyph5_effect" => addslashes($glyphs5['effect']), "glyph5_icon" => $glyphs5['icon'], "glyph5_name" => addslashes($glyphs5['name']), "glyph5_type" => $glyphs5['type'],
// ACHIEVEMENT SUMMARY "summary_total_earned" => $achSummary->c['earned'], "summary_total_points" => $achSummary->c['points'], "summary_total_total" => $achSummary->c['total'], "summary_total_totalPoints" => $achSummary->c['totalPoints'], "summary_General_earned" => $achSummary->category[0]->c['earned'], "summary_General_points" => $achSummary->category[0]->c['earnedPoints'], "summary_General_total" => $achSummary->category[0]->c['total'], "summary_General_totalPoints" => $achSummary->category[0]->c['totalPoints'], "summary_Quests_earned" => $achSummary->category[1]->c['earned'], "summary_Quests_points" => $achSummary->category[1]->c['earnedPoints'], "summary_Quests_total" => $achSummary->category[1]->c['total'], "summary_Quests_totalPoints" => $achSummary->category[1]->c['totalPoints'], "summary_Exploration_earned" => $achSummary->category[2]->c['earned'], "summary_Exploration_points" => $achSummary->category[2]->c['earnedPoints'], "summary_Exploration_total" => $achSummary->category[2]->c['total'], "summary_Exploration_totalPoints" => $achSummary->category[2]->c['totalPoints'], "summary_PvP_earned" => $achSummary->category[3]->c['earned'], "summary_PvP_points" => $achSummary->category[3]->c['earnedPoints'], "summary_PvP_total" => $achSummary->category[3]->c['total'], "summary_PvP_totalPoints" => $achSummary->category[3]->c['totalPoints'], "summary_Dungeons_earned" => $achSummary->category[4]->c['earned'], "summary_Dungeons_points" => $achSummary->category[4]->c['earnedPoints'], "summary_Dungeons_total" => $achSummary->category[4]->c['total'], "summary_Dungeons_totalPoints" => $achSummary->category[4]->c['totalPoints'], "summary_Professions_earned" => $achSummary->category[5]->c['earned'], "summary_Professions_points" => $achSummary->category[5]->c['earnedPoints'], "summary_Professions_total" => $achSummary->category[5]->c['total'], "summary_Professions_totalPoints" => $achSummary->category[5]->c['totalPoints'], "summary_Reputation_earned" => $achSummary->category[6]->c['earned'], "summary_Reputation_points" => $achSummary->category[6]->c['earnedPoints'], "summary_Reputation_total" => $achSummary->category[6]->c['total'], "summary_Reputation_totalPoints" => $achSummary->category[6]->c['totalPoints'], "summary_WorldEvents_earned" => $achSummary->category[7]->c['earned'], "summary_WorldEvents_points" => $achSummary->category[7]->c['earnedPoints'], "summary_WorldEvents_total" => $achSummary->category[7]->c['total'], "summary_WorldEvents_totalPoints" => $achSummary->category[7]->c['totalPoints'], "summary_Feats_earned" => $achSummary->category[8]->c['earned'],
// ACHIEVEMENT SUMMARY - LAST 5 "summary_last0_categoryId" => $achievements[0]['categoryId'], "summary_last0_dateCompleted" => $achievements[0]['dateCompleted'], "summary_last0_desc" => addslashes($achievements[0]['desc']), "summary_last0_icon" => addslashes($achievements[0]['icon']), "summary_last0_id" => $achievements[0]['id'], "summary_last0_points" => $achievements[0]['points'], "summary_last0_title" => addslashes($achievements[0]['title']),
"summary_last1_categoryId" => $achievements[1]['categoryId'], "summary_last1_dateCompleted" => $achievements[1]['dateCompleted'], "summary_last1_desc" => addslashes($achievements[1]['desc']), "summary_last1_icon" => addslashes($achievements[1]['icon']), "summary_last1_id" => $achievements[1]['id'], "summary_last1_points" => $achievements[1]['points'], "summary_last1_title" => addslashes($achievements[1]['title']),
"summary_last2_categoryId" => $achievements[2]['categoryId'], "summary_last2_dateCompleted" => $achievements[2]['dateCompleted'], "summary_last2_desc" => addslashes($achievements[2]['desc']), "summary_last2_icon" => addslashes($achievements[2]['icon']), "summary_last2_id" => $achievements[2]['id'], "summary_last2_points" => $achievements[2]['points'], "summary_last2_title" => addslashes($achievements[2]['title']),
"summary_last3_categoryId" => $achievements[3]['categoryId'], "summary_last3_dateCompleted" => $achievements[3]['dateCompleted'], "summary_last3_desc" => addslashes($achievements[3]['desc']), "summary_last3_icon" => addslashes($achievements[3]['icon']), "summary_last3_id" => $achievements[3]['id'], "summary_last3_points" => $achievements[3]['points'], "summary_last3_title" => addslashes($achievements[3]['title']),
"summary_last4_categoryId" => $achievements[4]['categoryId'], "summary_last4_dateCompleted" => $achievements[4]['dateCompleted'], "summary_last4_desc" => addslashes($achievements[4]['desc']), "summary_last4_icon" => addslashes($achievements[4]['icon']), "summary_last4_id" => $achievements[4]['id'], "summary_last4_points" => $achievements[4]['points'], "summary_last4_title" => addslashes($achievements[4]['title'])
);
return $char_Array; }
//------------------------------------------------------------------ // Build the Character Array from the supplied guild XML stream function buildCharacterArray($XMLstream) { global $config;
$count_Members = 0; $char_Array = array(); foreach ($XMLstream->guildInfo->guild->members->character as $char) { $process_char = false; $process_char_list = false; if( $config['chars_to_process'] == -1 ) { if ( $config['use_char_selction_list'] ) { if (in_array($char['name'],$config['char_selction_list'])) $process_char = true; } else { $process_char = true; } } else { if( $count_Members < $config['chars_to_process'] ) $process_char = true; }
// BUGGY if ( $char['level'] >= $config['min_char_level'] ) $process_char = false; // Limits display Chars beyond a certain level // BUGGY if ( $char['rank'] <= $config['min_char_rank'] ) $process_char = false; // Limits display to Guild Rank (depending on your guild ranks)
if( $process_char ) { $toonrace = return_race($char['raceId'], $char['genderId']); // Maps Race and Sex $toongender = return_gender($char['genderId']); // Maps Sex $toonclass = return_class($char['classId']); // Maps class name $toonrank = return_rank($char['rank']); // Maps guild rank name $char_info_Array = array( "name" => (string)$char['name'], "level" => (string)$char['level'], "class" => $toonclass, "gender" => $toongender, "race" => $toonrace, "rank" => $char['rank'].' - '.$toonrank, "achPoints" => (string)$char['achPoints'], "url" => $config['url_prefix_char'].(string)$char['url'] ); $char_Array[] = $char_info_Array; } $count_Members++; } return $char_Array; }
//------------------------------------------------------------------ // Print the supplied Character Array function printCharacterArray($charArray, $array_sort_field, $array_sort_direction) { global $config;
if ( count($charArray) != 0 ) { switch($array_sort_direction){ case 'asc' : $sortDir = 'desc'; break; case 'desc' : $sortDir = 'asc'; break; } switch($array_sort_field){ case 'name' : $sortFieldname = ' ['.$array_sort_direction.']'; break; case 'level' : $sortFieldlevel = ' ['.$array_sort_direction.']'; break; case 'class' : $sortFieldclass = ' ['.$array_sort_direction.']'; break; case 'gender' : $sortFieldgender = ' ['.$array_sort_direction.']'; break; case 'race' : $sortFieldrace = ' ['.$array_sort_direction.']'; break; case 'rank' : $sortFieldrank = ' ['.$array_sort_direction.']'; break; case 'achPoints' : $sortFieldachPoints = ' ['.$array_sort_direction.']'; break; case 'url' : $sortFieldlink = ' ['.$array_sort_direction.']'; break; } echo '<b>DISPLAY GUILD DATA:</b><BR/><table width="100%" border="1">'; echo '<td width=""><a href="'.$config['base_filename'].'?sort=name&direction='.$sortDir.'">NAME'.$sortFieldname.'</a></td>'; echo '<td width=""><a href="'.$config['base_filename'].'?sort=level&direction='.$sortDir.'">LEVEL'.$sortFieldlevel.'</a></td>'; echo '<td width=""><a href="'.$config['base_filename'].'?sort=class&direction='.$sortDir.'">CLASS'.$sortFieldclass.'</a></td>'; echo '<td width=""><a href="'.$config['base_filename'].'?sort=gender&direction='.$sortDir.'">GENDER'.$sortFieldgender.'</a></td>'; echo '<td width=""><a href="'.$config['base_filename'].'?sort=race&direction='.$sortDir.'">RACE'.$sortFieldrace.'</a></td>'; echo '<td width=""><a href="'.$config['base_filename'].'?sort=rank&direction='.$sortDir.'">RANK'.$sortFieldrank.'</a></td>'; echo '<td width=""><a href="'.$config['base_filename'].'?sort=achPoints&direction='.$sortDir.'">POINTS'.$sortFieldachPoints.'</a></td>'; echo '<td width=""><a href="'.$config['base_filename'].'?sort=url&direction='.$sortDir.'">URL'.$sortFieldlink.'</a></td>'; echo '</tr>'; foreach ($charArray as $char) { echo '<tr id="'.$char['name'].'">'; echo '<td>'.$char['name'].' </td>'; echo '<td>'.$char['level'].' </td>'; echo '<td>'.$char['class'].' </td>'; echo '<td>'.$char['gender'].' </td>'; echo '<td>'.$char['race'].' </td>'; echo '<td>'.$char['rank'].' </td>'; echo '<td>'.$char['achPoints'].' </td>'; echo '<td><a href="'.$char['url'].'" target="_blank">'.$char['url'].'</a></td>'; echo '</tr>'; $count_Members++; } echo '</table>'; } }
//------------------------------------------------------------------ // Prints everything in the supplied Character Array function printCompleteCharacterArray($charArray) { global $config;
echo '<br /><P><b>DISPLAY GUILD DATA:</b><BR/><table width="100%" border="1">'; foreach ($charArray[0] as $key => $value ) { echo '<td width=""><b>'.$key.'</b></td>'; } echo '</tr>';
foreach ($charArray as $char) { echo '<tr id="'.$char['name'].'">'; foreach ($char as $value) { echo '<td>'.$value.' </td>'; } echo '</tr>'; }
echo '</table>'; }
//------------------------------------------------------------------ // Dynamically builds the supplied Array as a SQL IMPORT Statement function printSQLArray($charArray,$guildCount,$guildBG,$config_title,$config_filename,$config_sql_table,$config_show_structure,$config_show_data) { global $config;
if ( count($charArray) != 0 ) {
// BUILD THE TABLE STRUCTURE $sql_import_structure = ""; $sql_table_structure_row = "CREATE TABLE `".$config_sql_table."` ( `ID` bigint(255) NOT NULL AUTO_INCREMENT, "; $countKey = 0; foreach ($charArray[0] as $key => $value ) { if ( $countKey == 0 ) { $sql_import_structure .= $key; } else { $sql_import_structure .= ", ".$key; } $sql_table_structure_row .= " `".$key."` text(600) CHARACTER SET utf8 DEFAULT NULL, "; $countKey++; }
$sql_table_structure_row .= " PRIMARY KEY (`ID`) ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;";
// INSERT GUILD COUNT INFORMATION UPDATE $guild_count_sql = ""; if ( $guildCount != '' ) { $guild_count_sql = "UPDATE guild_information SET guild_members = '".$guildCount."', battlegroup = '".$guildBG."' WHERE guild_name='".$config['guild_name']."';
"; }
// START BUILDING THE SQL IMPORT STATEMENT $sql_table_structure = "SET NAMES utf8; SET CHARACTER SET utf8; SET SQL_MODE='';
USE ".$config['sql_database']."; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
/*Table structure for table `".$config_sql_table."` */
DROP TABLE IF EXISTS `".$config_sql_table."`;
".$sql_table_structure_row."
SET SQL_MODE=@OLD_SQL_MODE;";
$sql_string = "USE ".$config['sql_database']."; TRUNCATE TABLE ".$config_sql_table.";
".$guild_count_sql;
// BUILD THE CHARACTER INSERT STATEMENTS $countChar = 0; foreach ($charArray as $char) {
// BUILD VALUE STRING $sql_import_values = ""; $countValue = 0; foreach ($charArray[$countChar] as $key => $value ) { if ( $countValue == 0 ) { $sql_import_values .= "'".$value."'"; } else { $sql_import_values .= ", '".$value."'"; } $countValue++; } $sql_row = "INSERT INTO ".$config_sql_table." (".$sql_import_structure.") VALUES (".$sql_import_values."); "; $sql_string .= $sql_row; $countChar++; }
if ( $config_show_structure ) { echo '<br /><P><b>['.$config_title.'] SQL TABLE STRUCTURE IMPORT STATEMENT:</b> '.$countKey.' keys with Text(600) limit each, equals '.($countKey*600).' total potential characters...<BR/><textarea rows="20" cols="180" wrap="off">'.$sql_table_structure.'</textarea><P>'; }
if ( $config_show_data ) { echo '<br /><P><b>['.$config_title.'] SQL TABLE DATA IMPORT STATEMENT:</b><BR/><textarea rows="30" cols="180" wrap="off">'.$sql_string.'</textarea><P>'; }
// SAVE SQL TO FILE $newSQLfile = $config['DIR_sql'].'guild'.$config_filename.'_sql-'.date('Y.m.d-H.i.s').'.sql'; // SAVE TO SQL TO FILE $fh = fopen($newSQLfile, 'wb'); $numbytes = fwrite($fh, $sql_string); fclose($fh); } }
//------------------------------------------------------------------ // Sort the supplied Character Array function sortCharacterArray($charArray, $array_sort_field, $array_sort_direction) {
// OBTAIN A LIST OF COLUMNS TO SORT foreach ($charArray as $key => $row) { $name[] = $row['name']; $level[] = $row['level']; $class[] = $row['class']; $gender[] = $row['gender']; $race[] = $row['race']; $rank[] = $row['rank']; $achPoints[] = $row['achPoints']; $url[] = $row['url']; } // SETUP SORT SETTINGS switch($array_sort_field){ case 'name' : $sortField = $name; $sortType = SORT_STRING; break; case 'level' : $sortField = $level; $sortType = SORT_NUMERIC; break; case 'class' : $sortField = $class; $sortType = SORT_STRING; break; case 'gender' : $sortField = $gender; $sortType = SORT_STRING; break; case 'race' : $sortField = $race; $sortType = SORT_STRING; break; case 'rank' : $sortField = $rank; $sortType = SORT_NUMERIC; break; case 'achPoints' : $sortField = $achPoints; $sortType = SORT_NUMERIC; break; case 'url' : $sortField = $url; $sortType = SORT_STRING; break; } // SORT THE ARRAY switch($array_sort_direction){ case 'asc' : array_multisort($sortField, SORT_ASC, $sortType, $level, SORT_DESC, SORT_NUMERIC, $name, SORT_ASC, SORT_STRING, $charArray); break; case 'desc' : array_multisort($sortField, SORT_DESC, $sortType, $level, SORT_DESC, SORT_NUMERIC, $name, SORT_ASC, SORT_STRING, $charArray); break; } return $charArray ; }
// PREVIOUSLY DECLARED CLASSES
static $browser_user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
function return_class($classid) { switch ($classid) { case 1: $class = "Warrior"; break; case 2: $class = "Paladin"; break; case 3: $class = "Hunter"; break; case 4: $class = "Rogue"; break; case 5: $class = "Priest"; break; case 6: $class = "Death Knight"; break; case 7: $class = "Shaman"; break; case 8: $class = "Mage"; break; case 9: $class = "Warlock"; break; case 11: $class = "Druid"; 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 = "Guild Master"; break; case 1: $class = "Guild Leader"; break; case 2: $class = "VIP"; break; case 3: $class = "Member"; break; case 4: $class = "Initiate"; break; case 5: $class = "-"; break; case 6: $class = "-"; break; case 7: $class = "-"; break; case 8: $class = "-"; break; } return $class; }
function return_race2($raceid, $sex) { switch ($raceid) { case 1: if ($sex == "0") {$race = "Human Male";} if ($sex == "1") {$race = "Human Female";} break; case 2: if ($sex == "0") {$race = "Orc Male";} if ($sex == "1") {$race = "Orc Female";} break; case 3: if ($sex == "0") {$race = "Dwarf Male";} if ($sex == "1") {$race = "Dwarf Female";} break; case 4: if ($sex == "0") {$race = "Night Elf Male";} if ($sex == "1") {$race = "Night Elf Female";} break; case 5: if ($sex == "0") {$race = "Undead Male";} if ($sex == "1") {$race = "Undead Female";} break; case 6: if ($sex == "0") {$race = "Tauren Male";} if ($sex == "1") {$race = "Tauren Female";} break; case 7: if ($sex == "0") {$race = "Gnome Male";} if ($sex == "1") {$race = "Gnome Female";} break; case 8: if ($sex == "0") {$race = "Troll Male";} if ($sex == "1") {$race = "Troll Female";} break; case 10: if ($sex == "0") {$race = "Blood Elf Male";} if ($sex == "1") {$race = "Blood Elf Female";} break; case 11: if ($sex == "0") {$race = "Draenei Male";} if ($sex == "1") {$race = "Draenei Female";} break; } return $race; }
function return_race($raceid, $sex) { switch ($raceid) { case 1: $race = "Human"; break; case 2: $race = "Orc"; break; case 3: $race = "Dwarf"; break; case 4: $race = "Night Elf"; break; case 5: $race = "Undead"; break; case 6: $race = "Tauren"; break; case 7: $race = "Gnome"; break; case 8: $race = "Troll"; break; case 10: $race = "Blood Elf"; break; case 11: $race = "Draenei"; break; } return $race; }
function return_gender($genderid) { if ($genderid == "0") {$gender = "Male";} if ($genderid == "1") {$gender = "Female";} return $gender; } ?>
|
|
|
|
|
The Following 2 Users Say Thank You to DJRavine For This Useful Post:
|
|
05-21-2010, 05:29 AM
|
#136 (permalink)
|
|
The Visitor
Join Date: May 2010
Posts: 1
Thanks: 0
|
DJRavine,
First of all, I want to say I am a fan of the work you have done and I am thoroughly impressed with your work for probably the past few years even in the private server sector :)
Your system is very very well done, the one thing I would like to suggest though, to save bandwidth, is perhaps divide the amount of parsing it is doing initially. To go into depth on this, perhaps have it just parse the guild member list, and then on demand, load an individual's profile upon click of a member's name.
The main reason is that with your code, some guilds have well over 100 members in their ranks, to load/parse all of that data would take a substantial amount of time(maybe about 30-40 mins dependent on person's connection)
Maybe even cache data to drop the demand on the wowarmory site?
I could be entirely wrong, just trying to help :)
|
|
|
|
06-16-2010, 04:26 PM
|
#137 (permalink)
|
|
The Visitor
Join Date: Jun 2010
Posts: 1
Thanks: 0
|
Hi guys, i'm new to parsing in php/xml and couldn't get the codes listed here to do what i want.
I want a simple thing , to parse my armory character and store his lvl in a php variable (using cache system so i dont get to parse it always i reload - 1 day cache or something like that) and print it after, what code should i use?
|
|
|
|
08-21-2010, 04:35 AM
|
#138 (permalink)
|
|
The Visitor
Join Date: Aug 2010
Posts: 1
Thanks: 1
|
I've been reading up on this topic for a few days now, and I got my roster script to work, however I have a question, does anyone have a code for linking and item WITH gems and enchants from a specific player?
|
|
|
|
09-07-2010, 07:56 AM
|
#139 (permalink)
|
|
The Visitor
Join Date: Apr 2010
Posts: 3
Thanks: 0
|
I am loving the work that has been done so far on the cURL scripts. I have been viewing and using this topic myself and have produced my own data grabber for the Armory, I really want to take it a stage further than what it is and grab item info and also professions and specs of my character. I was wondering how this could be achived? I note that there are comments about about how to get the profession data and such but for the life of me I cannot get them to work and could use some help.
Here is my code for what I am doing, I have opted not to use the switches and case functions ofr this example to keep the code short in the thread :)
PHP Code:
function fetchXML($url)
{
//initialize library
$ch = curl_init();
//used to make us look like a browser
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
//set the url
curl_setopt ($ch, CURLOPT_URL, $url);
//set that I want to wait for a response
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
//make us look like a web browser
curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
//get data
$data = curl_exec($ch);
//clean up
curl_close($ch);
///return xml data
return $data;
}
define("USE_CURL", true);
//set character and realm info
$realm = "Nordrassil";
$character = "Necroshen";
$url = "http://eu.wowarmory.com/character-sheet.xml?r=" . $realm . "&n=" . $character ;
//get xml doc with character info
$data = fetchXML($url);
//create a SimpleXML object to parse the xml
$profile_xml = new SimpleXmlElement($data);
Where to look for the data
PHP Code:
foreach ($profile_xml->characterInfo->character as $char){
$charclass = return_class($char['classId']);
$charrace = return_race($char['raceId'], $char['genderId']);
$charrank = return_rank($char['rank']);
}
Display the data
PHP Code:
{
echo "<li>{$char['name']}</li>";
echo "<li>{$char['level']}</li>";
echo "<li>{$char['battleGroup']}</li>";
echo "<li>{$char['faction']}</li>";
echo "<li>{$char['prefix']}</li>";
echo "<li>{$char['guildName']}</li>";
echo "<li>{$char['race']}</li>";
echo "<li>{$char['realm']}</li>";
echo "<li>{$char['class']}</li>";
}
What I am looking to do now is pull item data and also profession and spec data as well and I need to know how do to that as I cannot get the above examples to work. 
|
|
|
|
11-11-2010, 09:23 PM
|
#140 (permalink)
|
|
The Contributor
Join Date: Sep 2007
Location: London, UK
Posts: 47
Thanks: 4
|
Uh oh! Misread the dates
Ignore me..
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|