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

    Checking to see if a site is updated

    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 arises that even if the website isn't changed the script ends up emailing me telling me that the site has changed. No changes have occurred, even the sha1 hash is the same.. what gives?

  • #2
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Thanked 19 Times in 18 Posts
    The only thing I can see there is that $encryptedContent == $siteHash evaluates to FALSE .. perhaps put some more trace in to see what the values of $encryptedContent and $siteHash actually are?


    Posting Permissions

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