[EMAIL PROTECTED] (Kevin Stone) wrote
Hello Kevin.
> This is just a thought.. I have never employed this method
> personally.. but I suppose you could read the page into a string and
> use the md5() function to generate a hexidecimal value based on that
> string. Store the hex value in a database and compare it against the
> new value generated the next day. If anything on the page has been
> modified the values should not match. Even the most minute change
> should trigger a new value. Obviously you won't know *what* has been
> modified only that the page *has* been modified
>
> There are some pitfalls to keep in mind such as if the page contains
> dynamic content, if there is a server error, or if the page has been
> removed. Thanks to Network Solutions evil Sitefinder you may find it
> difficult if not impossible to predict what will be read by your
> script if the page goes missing. But this will all show up in the hex
> value and you won't know if the page is still relevant until you
> personally visit the links.
Too much pittfals and too slow! Really the socket connection only
retreiving the headers is really the best way.
This function is what you need:
function fileStamp($domain, $file)
{
$file = "/" . $file;
$fp = fsockopen ($domain, 80, $errno, $errstr, 30);
$header = "HEAD $file HTTP/1.0\r\nHost: $domain\r\n\r\n";
if (!$fp){
echo "$errstr ($errno)";
return false;
}
fputs ($fp, $header);
while (!feof($fp)) {
$output .= fgets ($fp,128);
}
fclose ($fp);
$begin = strpos($output, "Last-Modified: ") + 15;
if($begin==15) //no last-modified (like yahoo.com)
return false;
$end = strpos($output, "\n", $begin);
$time = substr($output, $begin, $end-$begin-1);
return strtotime($time);
}
Polleke
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php