<?php
/* -------- Configuration -------- */
define('VERSION', '1.0');
define('USERAGENT', 'sPing/'.VERSION);
define('TIMEOUT', 10); // seconds
$sites = array(
'http://www.johnrouda.com',
'http://www.yahoo.com',
'http://www.msn.com',
'http://www.google.com',
);
/* ------------------------------- */
if ( ! function_exists('curl_init')) { die("cURL is not available and is required.n"); }
$ch = curl_init();
$options = array(
CURLOPT_USERAGENT => USERAGENT,
CURLOPT_TIMEOUT => TIMEOUT,
CURLOPT_VERBOSE => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FRESH_CONNECT => true
);
curl_setopt_array($ch, $options);
foreach($sites as $site)
{
curl_setopt ($ch, CURLOPT_URL, $site);
$output = curl_exec($ch);
$status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status == '301' || $status == '200' || $status == '302')
{
$status = 'UP';
}
else {
$status = 'DOWN';
}
echo $site." returned ".$status."<br>\n\r";
}