I’m trying to automatically detect changes to several web pages that uses PHP. I have downloaded several ‘web page monitor’ programs but I don’t think they detect changes on the pages I want to watch. They work fine on HTML based pages but not PHP pages. I am not a programmer or web site builder so my technical knowledge is limted but I am desperate to find a solution to my problem.
Can anyone help? Please note I’m Mac based so software options are limited.
All PHP is executed server-side, so if you’re looking to monitor changes in the PHP source of a file, it’s not going to happen unless you have access to the actual file itself, rather than what a web browser shows you if you run it.
If you’re looking for changes in the HTML output given by a PHP file, however, then it’s probably a different matter.
Well possibly if you are looking for content changes… Maybe checking the md5 checksum and seeing if they match up with a previously recorded checksum… possibly run it in a chron job every… few hours (depending on how much you want to check, and how accurate you want to be on the ‘check to see if its updated’)…
<?php
$handle = fopen("http://www.example.com/", "rb");
$contents = stream_get_contents($handle);
fclose($handle);
$newChecksum = md5($contents);
#You can insert this into a table... you can retrieve a stored md5 checksum from a mysql table if you have it, then compare the two..
if($newChecksum == $oldChecksum) {
echo "---WEBSITE UPDATED---";
} else {
echo "---WEBSITE HAS NOT BEEN UPDATED---";
}
?>
how do I have it the wrong way around? Doesn’t matter, its comparing two values to see if they are equal… how exactly can I get that ‘wrong way around’… ?
It compares the new checksum to the old checksum, and if they match (which would mean the page was the same) then it would say that the page has been updated.
Surely if the page hasn’t change, the checksum would be the same as previously recorded. If the page changed, then the checksum would be different.