and
http://www.wow-europe.com/realmstatus/index.xml
( or http://www.worldofwarcraft.com/realmstatus/status.xml )
isn't giving any usefull information, like now (when posting this) - Blizzard took the site down for maintenance - some php errors are shown :
realmstatus.php
Notice line 197: Undefined property: SimpleClass::$channel
Notice line 197: Trying to get property of non-object
Warning line 197: Invalid argument supplied for foreach()
Somewhat normal, accessing Blizzard's site doesn't give a "file not found" error now but a nice page that explains that the site is down. Good.
So, urlgrabber is doing it's job, and NOT returning false.
In realmstatus.php, line 117, the $xmlsource is parsed with this info, but it contains anything but a valid XML source.
The XML isn't return an error neither...
Statements like this, just after all this :
foreach( $simpleParser->data->rs->r.....
(for US)
or
foreach( $simpleParser->data->channel->item
(for EU)
will provoke the error as shown, the keys used here ('r' and 'item' and upper keys) do not exists in the class property SimpleParser->data .....
Question : the presence of a key, like 'r' or 'item', should be checked for presence to see if the XML parsing returns a usable result.
Something like
if (array_key_exists_r('item',$simpleParser))
right after the $region == 'US' (same thing goes for the $region == 'EU' case.
Function to add :
- Code: Select all
function array_key_exists_r($needle, $haystack)
{
$result = array_key_exists($needle, $haystack);
if ($result) return $result;
foreach ($haystack as $v) {
if (is_array($v)) {
$result = array_key_exists_r($needle, $v);
}
if ($result) return $result;
}
return $result;
}
More info : http://www.php.net/function.array-key-exists
I confirm that no more php errors are shown right now, and post back when I got the results when the
http://www.wow-europe.com/realmstatus/index.xml
is up again, to see if the check return true in that case (and parsing will continue).
Btw, in "rs_mode = On" mode, the error doesn't show.
Normal, realmstatus is being called as an path to an image, generating it dynamicly, like :
http://www.papy-team.fr/roster/realmsta ... Khaz+Modan