// -*- c++-mode -*-
?>
2-1-2
Doobee R. Tzeck
Last modified: Fri Sep 1 14:25:34 CEST 2000
include("/var/service/httpd/shared.inc");
include("get_http_headers.php");
mysql_pconnect($db_host, $db_user, $db_pass);
$result = mysql_db_query("wwwstats", "SELECT * FROM spider");
while($row = mysql_fetch_array($result))
{
if($row["id"])
{
echo "
" . $row["url"] . "
\n";
flush();
$header = get_http_headers($row["url"], "HTTP/1.0", 60);
$ts = strtotime($header["last-modified"]);
echo "changed= " . $row["changed"] . "
\n";
echo "last-modified header= " . $header["last-modified"] . "
\n";
echo "result = " . $header["result"] . "
\n";
echo "\n";
while (list($key,$item) = each($header))
echo "$key: $item
\n";
echo "
\n";
flush();
if($header["last-modified"] != "")
{
// fine
$r2 = mysql_db_query("wwwstats", "UPDATE spider SET lastmodified = FROM_UNIXTIME($ts), changed = FROM_UNIXTIME($ts) WHERE id = '" . $row["id"]. "'");
if(mysql_errno())
echo " ".mysql_errno().": ".mysql_error()."
";
}
else
{
// damm, there is no last-modified header: we have to checl it out ourselvs
$array = file($row["url"]);
$buf = implode("", $array);
$md5 = md5($buf);
echo "md5 = " . $md5 ."
\n";
if($md5 != $row["md5"])
$r2 = mysql_db_query("wwwstats", "UPDATE spider SET md5 = '$md5', changed = NOW() WHERE id = '" . $row["id"]. "'");
if(mysql_errno())
echo " ".mysql_errno().": ".mysql_error()."
";
}
}
}
?>