hi guys, check this mama out. getting a page's headers. i've tried the code posted by on www.php.net chopin@csone.kaist.ac.kr on 27-Aug-1999 [at the bottom of this post]...there seems to be a really nasty problem. i want to check downloads before they offered to the user. ie. get the download header and check whether it's a 404 Not Found. it appears some sites (eg. www.fortunecity.com, www.cybercities.com) auto redirect 404s to their home page or something similar, which has a totally different header...this causes the function to return the download to be found when it should not be. however checking the header using telnet (telnet www.fortuncity.com 80, then typing HEAD /download.zip HTTP/1.0\n\n) returns a 404 at correct times.........HELP!!!!!
function get_headers($host, $path)
{
$fp = fsockopen ("$host", 80, &$errnr, &$errstr) or die("$errno: $errstr");
fputs($fp,"GET $path HTTP/1.0\n\n");
while (!$end)
{
$line = fgets($fp, 2048);
if (trim($line) == "") $end = true;
else echo $line;
}
fclose($fp);
}