function EmailExpiryMessages($FileName) {
// open and lock the expiry data file
$theFile_fp = fopen($FileName, "r+");
$lock = flock($theFile_fp, 2);
// continue when lock is obtained
if ($lock) {
$db = readDatabase($FileName);
// Pop each ExpiredPage object and send the email
while ($poppedExpiredPage = (array_pop($db))):
$pageURL = $poppedExpiredPage->url;
$pageOwner = $poppedExpiredPage->owner;
$pageExpiryDate = $poppedExpiredPage->expired;
$pageMessage = $poppedExpiredPage->message;
// Prepare the email
$mail_message = "This is to remind you that this web page...
\n $pageURL
\n...expired on $pageExpiryDate. Here is the reminder message (if any):
\n*** $pageMessage ***
\nYou will receive a reminder each day that this page is hit.
Please update the page as necessary, and remember to specify a new
expiry date.";
// Now send the email
mail($pageOwner, "Expiry Checker: $pageURL", $mail_message);
endwhile;
} // unlock and close reminders file
$lock = flock($theFile_fp, 3);
fclose($theFile_fp);
}
|