My favorites | Sign in
Project Logo
          
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?

header('Content-Type: text/html; charset=utf-8');

$self = $_SERVER[PHP_SELF];
$eol = "\n";

// FUNCTIONS

function show_header() {
echo '
<html>
<head>
<title>Getting data from WoW-Armory with XML,PHP,AJAX and CURL</title>
<script type="text/javascript" src="armory.js"></script>
</head>
<body>
';
}

function show_footer() {
echo '
</body>
</html>
';
}

function show_form() {

echo '<form>';
echo '<table>';
echo '<tr>';
echo '<th>Server</th>';
echo '<th>Guild</th>';
echo '<th>Region</th>';
echo '<th>Language</th>';
echo '</tr>';
echo '<tr>';
echo '<td><input name="guild_server" value="'.$_GET[guild_server].'" type="text"></td>';
echo '<td><input name="guild_name" value="'.$_GET[guild_name].'" type="text"></td>';
echo '<td><select name="region">
<option value="us">North America</option>
<option value="eu">Europe</option>
</select>
</td>';
echo '<td><select name="lang">
<option value="en">English (GB)</option>
<option value="us">English (US)</option>
<option value="de">German (DE)</option>
</select>
</td>';
echo '<td><input type="submit"></td>';
echo '</tr>';
echo '</table>';
echo '</form>'.$eol;

}

function replace_space($str) {
return str_replace(" ","+",$str);
}

// BUILD THE PAGE

show_header();

//show the form
show_form();

$guild_name = replace_space($_GET[guild_name]);
$guild_server = replace_space($_GET[guild_server]);

if(($guild_name != "") && ($guild_server != ""))
{

$lang = $_GET[lang];
$region = $_GET[region];

echo '<h2>'.$guild_name.' on '.$guild_server.' - Region: '.$region.', Lang: '.$lang.'</h2>';

if($region == "us") {
$armory_server = 'http://www.wowarmory.com/';
} elseif($region == "eu") {
$armory_server = 'http://eu.wowarmory.com/';
}

$armory_url = $armory_server.'guild-info.xml?r='.$guild_server.'&gn='.$guild_name;

class guild_data
{
public function get_xml($lang,$url)
{
$ch = curl_init();
if ($lang == 'de')
$header[] = 'Accept-Language: de-de';
elseif ($lang == 'en')
$header[] = 'Accept-Language: en-gb';
elseif ($lang == 'us')
$header[] = 'Accept-Language: en-us';
$browser = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt ($ch, CURLOPT_USERAGENT, $browser);
$url_string = curl_exec($ch);
return simplexml_load_string($url_string);
curl_close($ch);
}
}


$guild_data = new guild_data();
$xml_guild_data = $guild_data->get_xml($lang,$armory_url);

echo '<p>Click on the character name to retrieve information via AJAX.</p>';

echo '<table border="1">';
echo '<tr>';
echo ' <th><a href="'.$self.'?o=1">#</a></th>';
echo ' <th><a href="'.$self.'?o=2">level</a></th>';
echo ' <th><a href="'.$self.'?o=3">name</a></th>';
echo ' <th><a href="'.$self.'?o=4">genderId</a></th>';
echo ' <th><a href="'.$self.'?o=5">raceId</a></th>';
echo ' <th><a href="'.$self.'?o=6">classId</a></th>';
echo ' <th><a href="'.$self.'?o=7">rank</a></th>';
echo ' <th><a href="'.$self.'?o=8">achPoints</a></th>';
echo ' <th><a href="'.$self.'?o=9">armory</a></th>';
echo ' <th><a href="'.$self.'?o=9">ajax field</a></th>';
echo '</tr>'.$eol;

$i=1;
foreach($xml_guild_data->guildInfo->guild->members->character as $char) {
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>'.$char['level'].'</td>';
echo '<td><a href="#'.$char['name'].'" onclick="getAjax(\''.$armory_server.'\',\''.$guild_server.'\',\''.$char['name'].'\',\'tab'.$i.'\',\''.$lang.'\');return false;">'.$char['name'].'</a></td>';
echo '<td>'.$char['genderId'].'</td>';
echo '<td>'.$char['raceId'].'</td>';
echo '<td>'.$char['classId'].'</td>';
echo '<td>'.$char['rank'].'</td>';
echo '<td>'.$char['achPoints'].'</td>';
echo '<td><a target="_blank" href="'.$armory_server.'character-sheet.xml?'.$char['url'].'">Armory</a></td>';
echo '<td id="tab'.$i.'"></td>';
echo '</tr>'.$eol;
$i++;
}
echo '</table>';

//show dump
//echo '<pre>';
//var_dump($xml_guild_data);
//echo '</pre>';

}

show_footer();

?>
Show details Hide details

Change log

r428 by erik.raetz on Jul 15, 2009   Diff
[No log message]
Go to: 

Older revisions

All revisions of this file

File info

Size: 4879 bytes, 159 lines
Powered by Google Project Hosting