function check_url($url) {
if (eregi( '^http://', $url)) {
$urlArray = parse_url($url);
if (!$urlArray[port]) $urlArray[port] = '80';
if (!$urlArray[path]) $urlArray[path] = '/';
$sock = fsockopen($urlArray[host], $urlArray[port], &$errnum, &$errstr);
if (!$sock) $res = 'DNS';
else {
$dump .= "GET $urlArray[path] HTTP/1.1\r\n";
$dump .= "Host: $urlArray[host]\r\nConnection: close\r\n";
$dump .= "Connection: close\r\n\r\n";
fputs($sock, $dump);
while ($str = fgets($sock, 1024)) {
if (eregi("^http/[0-9]+.[0-9]+ ([0-9]{3}) [a-z ]*", $str))
$res[code] = trim(eregi_replace('^http/[0-9]+.[0-9]+
([0-9]{3})
[a-z ]*', "\\1", $str));
if (eregi("^Content-Type: ", $str))
$res[contentType] = trim(eregi_replace("^Content-Type: ",
"",
$str));
}
fclose($sock);
flush();
return $res[code];
}
} else $res = "N/A";
return $res;
}