Published under the terms of the BSD License
<?php
function html_head($server, $path, $referrer = false, $ua = false) {
$response="";
$ip = @gethostbyname($server);
if($ip==$server){ return false; }
else {
$fp = fsockopen($ip, 80, $errno, $errstr, 30);
if (!$fp) {
echo "($errstr) ";
return false;
}
else {
fputs($fp, "HEAD $path HTTP/1.1\r\n");
fputs($fp, "Host: $server\r\n");
if ($referrer !== false) { fputs($fp, "Referer: $referrer\r\n"); }
if ($ua !== false) { fputs($fp, "User-Agent: $ua\r\n"); }
fputs($fp, "Connection: close\r\n");
fputs($fp, "\r\n");
while (!feof($fp)) {
$response .= fread($fp,128);
}
}
fclose ($fp);
}
$temp = explode("\r\n", trim($response));
foreach($temp as $header) {
$field = substr($header, 0, strpos($header, ": "));
$value = substr($header, strpos($header, ": ")+2);
if($field=="") { $field = 0; $value = "HT".$value; }
$headers[strtolower($field)] = $value;
}
return $headers;
}
?>
Last updated: Sat Jun 14 20:02:44 CEST 2008