note 51214 deleted from function.curl-setopt by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 17:32:34 +0000 |
| Subject: | note 51214 deleted from function.curl-setopt by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154997@lists.php.net to get a copy of this message | ||
Note Submitter: azcappy at azcappy dot com
----
AZAds is a traffic exchange that we wrote. We wanted to come up with a way to check the UP or DOWN
status of a submitted URL. Here is the solution we came up with. Can also be used for a site
monitoring service.
<?
$uServer="$url";
@$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$uServer");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
@curl_exec($ch);
$errnum=curl_errno($ch);
@curl_close($ch);
if($errnum != "0") {
print "Remote Site Status: DOWN";
} else {
print "Remote Site Status: UP";
}
?>
Simply feed the URL to be tested into $url. The code will check the site and return the error code
if there is one and display to appropriate message.
Hope this is useful.
Keith
www.azads.net