[codebox]?php
/*
Detect Site Changes
Author: Nick Sylvester
Written: Friday, March 09, 2007
Last Saved: 1:41 PM
*/
$url = 'INSERT THE URL HERE';
$file_open = fopen('cache_file.txt', 'r'
;
$read_file = fread($file_open, 99999);
fclose($file_open); //saving resources
//If the website has ads on it, and it's written in server-side dynamic scripting, the AD code may change. So to prevent this, do an explode(); wherever necessary, or do a preg_match_all()
//Save the File md5() hash to speed up comparison
$read_file_md5 = md5($read_file);
//Open the file you need
$file_source = view_source($URL);
$file_source_md5 = md5($file_source);
$file_open = fopen('cache_file.txt', 'w'
;
$read_file = fwrite($file_open, $file_source);
fclose($file_open); //saving resources
//Compare the source
if ($read_file_md5 == $file_source_md5) {
//No changes to the site made.
echo "<meta http-equiv='refresh' content='5; url=" . $_SERVER['PHP_SELF'] . "'>";
echo 'No changes detected to the website.';
} else {
//Insert code here that you want to alert you. To do a bell, uncomment the line below. Of course, you'd have to add telephone.wav to your server.
//echo '<EMBED SRC="telephone.wav" LOOP=TRUE AUTOSTART="TRUE" HIDDEN="TRUE">';
echo 'Change detected in the website.';
}
?>[/codebox][/b]
Bookmarks