If you want one of these cool things that I have, a button that attempts to ascertain if
or
, here's the code I used:
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://www.metafilter.com');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt ($ch, CURLOPT_USERAGENT, $_ENV['HTTP_USER_AGENT']);
$file = curl_exec($ch);
curl_close($ch);
if (ereg("MetaTalk", $file)) {
print "path_to_MEFIUP.png";
die;
}
print "path_to_MEFIDOWN.png";
if you're on a server that allows filegetcontents() and/or doesn't have curl you can just do this:
$file = file_get_contents("http://metafilter.com");
if (ereg("MetaTalk", $file)) {
print "path_to_MEFIUP.png";
die;
}
print "path_to_MEFIDOWN.png";
You can grab the .pngs from up there and it needs to be in a php file, between php tags. And you need to replace the path_to_png parts with valid urls.
As you can see, the way it works is if I can see the word MetaTalk on mefi front page, I assume the site is up.
Heh.