| Visar kod: |
1237 |
| Skapad: |
2007-09-18 12:36:21 |
| Senast redigerad: |
2007-09-18 12:36:21 |
| URL: |
http://www.htmlsidan.se/code/?id=1237 |
|
| 1 |
function getcharacter($server, $nick) {
|
| 2 |
$f = @fsockopen("eu.wowarmory.com", 80, $errno, $errstr, 30);
|
| 3 |
if (!$f) {
|
| 4 |
return "could not connect to the armory. detailed information: $errstr ($errno)<br>\n";
|
| 5 |
} else {
|
| 6 |
$send = "get /character-sheet.xml?r=". urlencode($server) ."&n=". urlencode($nick) . " http/1.0\r\n";
|
| 7 |
$send .= "host: eu.wowarmory.com\r\n";
|
| 8 |
$send .= "user-agent: mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.8.1.2) gecko/20070219 firefox/2.0.0.2\r\n";
|
| 9 |
$send .= "connection: close\r\n\r\n";
|
| 10 |
fwrite($f, $send);
|
| 11 |
do {
|
| 12 |
$data .= fgets($f, 128);
|
| 13 |
}
|
| 14 |
while (strpos ($data, "\r\n\r\n") === false);
|
| 15 |
$data = "";
|
| 16 |
while (!feof($f)) {
|
| 17 |
$data .= fgets($f, 128);
|
| 18 |
}
|
| 19 |
fclose($f);
|
| 20 |
$xml = xml2ary($data);
|
| 21 |
}
|
| 22 |
return $xml;
|
| 23 |
}
|