Main Program - v1


15/10/04
 

Main Program - v1

Now for the main program; a refinement of my pseudo-code, also based on version 1.7...
 
/*
// MAIN PROGRAM
*/

$file = "ExpiryData.xml";

// parse query_string to get $owner, $expirydate and $message
parse_str($QUERY_STRING);

// discover url of referring web page
$url = $GLOBALS["HTTP_REFERER"];

// Use ConvertExpiryDateToYYMMDD to re-format $expirydate
$expirydateYYMMDD = ConvertExpiryDateToYYMMDD($expirydate);

// Get today's date in dd/mm/yy format
$today = date("d/m/y");
// Convert to yymmdd format - e.g. 24/08/02 becomes 020824
// *** End-of-century bug - will fail in the year 2100! ***
$today_day = substr($today,-8,2);
$today_month = substr($today,-5,2);
$today_year = substr($today,-2,2);
$today_yymmdd = $today_year.$today_month.$today_day;

// If the referring page has expired then
if ( $expirydateYYMMDD <= $today_yymmdd ) {

  // If the referring page is a valid LSBU myweb page then
  if ((substr($url, 0, 23) == "http://myweb.lsbu.ac.uk")) {

    // Append Expiry Data to ExpiryData.xml
    AppendExpiryDataToFile($url, $owner, $expirydate, $message, $file);

(*) - see below

    // If ((today is a Monday) but (ExpiryData file is pre-today)) then
    if ((date("D") == "Mon") &&  ***(file date is pre-today)***  ) {

      // Email the expiry messages
      EmailExpiryMessages($file);

      // Copy ExpiryData.xml to ExpiryDataLastWeek.xml
      copy($file, "ExpiryDataLastWeek.xml");

      // Create a fresh (empty, formatted) ExpiryData.xml file
      CreateFreshExpiryDataFile();

    }
  }
}


(*) It would be very convenient if the AppendExpiryDataToFile function 
    returned the date of the ExpiryData.xml file; I'll make it do that.
 
 
 

<<contents ^top^