Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post

    Checking to see if a site is updated using sha1_file()

    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:
    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
    	}else{
    		// 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?
    Last edited by Bobafart; 01-11-2008 at 01:10 AM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •