The website is http://www.ipalaces.org/support/
The code I use for the status indicators is
<img src="http://big.oscar.aol.com/imperialpalaces?on_url=http://www.ipalaces.org/support/widget/status_green.gif&off_url=http://www.ipalaces.org/support/widget/status_offline.gif">
which is a neat thing that big.oscar.aol.com lets you do, it redirects it to whatever image you have set for the on_url if they are online, and same for off_url for offline. However, I want to use this in an if statement in PHP or javascript to display different things. Currently I am using this:
function getaim($screenname) {
$ch = curl_init();
$url = "http://big.oscar.aol.com/$screenname?on_url=true&off_url=false";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
// added to fix php 5.1.6 issue:
curl_setopt($ch, CURLOPT_HEADER, 1);
$result = curl_exec($ch);
curl_close($ch);
if(eregi("true",$result)) {
return true;
} else {
return false;
}
}
If (getaim("ImperialPalaces")) { print "Online"; } else { print "Offline"; }
The problem with this code is that for some reason, at random times it can take up to 12 seconds for it to actually retrieve the results. Whereas the standard img trick is almost instant.
Is there a known issue with curl? Is there a faster way?
I've seen someone try to read the .src of the img tag and do an if statement like that, but I couldnt get it to work.