Second prototype


22/8/02
 

Second prototype

I re-read the script after a break of 8 days. I spotted a number of problems, and now had the feeling that I understood the script better than before. I produced the following pseudocode as the basis for a second prototype:
<?php

// "Expiry Checker"

// A script to automatically remind FaCES web page owners...
// ...when their web pages are older than their expiry dates.

// author = Martin Bush, South Bank University
// date = 22 August 2002
// filename = expirychecker.php3
// version = prototype 2.1
// history = in this version it is assumed that the reminders file
//           either doesn't exist, or it exists and contains the
//           date_of_file plus *at least one* reminder records

parse query_string to get $url, $expiry, $owner and $message
if ($expiry <= today's date) then
  if (reminders file doesn't exist) then
    create and lock reminders file
    write today's date followed by reminder record
    unlock and close reminders file
  else (means: reminders file exists)
    open and lock reminders file
    read $date_of_file
    if ($date_of_file < today's date) then
      delete reminders file
      create and lock reminders file
      write today's date followed by reminder record
      unlock and close reminders file
    else (means: $date_of_file = today's date)
      parse first entry to get $filed_url, $filed_expiry, etc.
      if ($filed_url = $url) then
        set $need_next_entry = false
      else
        set $need_next_entry = true
        start accumulating reminder records
      endif
      while ($need_next_entry) do
        get and parse next entry if there is one
          if (next enrty doesn't exist) then
            set $need_next_entry = false
          else
            if ($filed_url = $url) then
              add to accumulating reminder records
              set $need_next_entry = true
            endif
          endif
        endwhile
        if ($url not found in file) then
          read remaining contents of file
        rewind the file
          write accumulate entries up to point of insertion
          prepare new reminder entry for insertion
          insert new reminder entry
          write remaining contents of file
          email URL and message to owner
        endif
      endif ($filed_url = $url)
    endif ($date_of_file < today's date)
    unlock and close remainders file
  endif (reminders file doesn't exist)
endif ($expiry <= today's date)
 
 
 

<<contents ^top^ next>>