Giving expirychecker.php4 alternative behaviours
After thinking some more about how to verify that a supposedly expired web page is indeed still expired, I had an idea. Given that when using fpassthru the referrer url is the script that invoked it rather than the url of the supposedly expired web page, it occurred to me that the expirychecker.php4 script could use this to distinguish between the two types of page hits.
Here's what I now have in mind. It uses three MySQL tables: expirydata-live, expirydata-temp and expirydata-lastweek, and it has three behaviours:
- From Tuesday to Saturday the script registers expired page hits as normal, in order of occurrence, with normalisation of the page urls and without duplication of entries.
- On Sunday (after 1am, to avoid any possibility of a conflict with another instantiation of the script that was initiated on Saturday just before midnight!) the script stops registering normal page hits, and just tries to detect whether any pages have been updated recently. If a page is found to have been updated then all of the entries for the corresponding page owner are deleted. (This isn't perfect, because the owner may also be responsible for other expired pages, but it's a good enough solution I think.)
- On Monday the script sends out the emails to the page owners, and also to <bcim@lsbu.ac.uk> for any pages that have expired over a month ago.
expirychecker.php4
if today is not a Sunday or a Monday then
if the referring web page has expired then
if the page is an LSBU WWW or MYWEB page then
normalise the page url
add page to expirydata-live, avoiding duplicates
endif
endif
else
if today is a Sunday and it's after 1am then
if expirydata-temp hasn't been updated yet today then
copy expirydata-live to expirydata-temp
delete all entries in expirydata-live
for each expired page recorded in expirydata-temp
use fpassthru to hit the page
endfor
else // for second and all subsequent hits on Sunday >1am
if the referrer url is this script then
if the page has NOT expired then
delete all entries for that owner in expirydata-temp
endif
endif
endif
else
if today is a Monday then
if expirydata-lastweek hasn't been updated yet today
copy expirydata-temp to expirydata-lastweek
delete all entries in expirydata-live
delete all entries in expirydata-temp
for each expired page recorded in expirydata-lastweek
send a reminder message to the page owner
if the page expired over a month ago then
send a reminder message to <bcim@lsbu.ac.uk>
endif
endfor
endif
endif
endif
endif
Perhaps I should have gone for three separate php scripts instead of trying to put everything into one script. I might try to do that later if I get stuck!