· Martin's Expiry Checker v3 Blog ·

M.E.Bush > Misc. > Expiry Checker v3 Blog > 16-Aug-2006

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:

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!