View Full Version : Checking to see if a site is updated using sha1_file()

01-11-2008, 12:49 AM
I am using sha1_file() to see if a website has been updated. I have a bunch of website URLs stored in a mySQL db.

I have never done this before.. I thought if I ran a crontab every 24 hours and checked to see if the sha1_file($siteURL) encryption has changed then I will be able to inform myself that the website has been updated.

The code:

$sql = "SELECT siteURL, encryptedContent FROM acheckWebsite WHERE userid = {$_SESSION[userid]}";
// echo '<p>'.$sqlCountBkmark.'<p>';
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)){
$siteURL = $row[siteURL];
echo '<p>siteURL is: '.$siteURL.'</p>';
$encryptedContent = $row[encryptedContent];
$siteHash = sha1_file($siteURL);
echo '<p>siteHas is: '.$siteHash.'</p>';
if($encryptedContent == $siteHash){
// don't do anything, since nothing has not changed
// update the table with the new hash and email the user
$updateSiteHash = "UPDATE acheckWebsite SET encryptedContent='$siteHash' WHERE userid = {$_SESSION[userid]}";
echo '<p>'.$updateSiteHash.'</p>';
$resultSiteHash = mysql_query($updateSiteHash);
echo '<p>table updated with new hash</p>';
// mail notification to me that someone submitted a comment:
$fromnameComm = "myemail@yahoo.com";
$headers .= "From: \"".$fromnameComm."\" <".$fromaddressComm.">\n";
$email = "myemail@yahoo.com";
mail("$email","Website Update Notification","The following website has been changed. $siteURL ", $headers);


The problem is that the siteHash encryption is always the same for each site... shouldn't it be different since the sites are all different?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum