From 71fc5a57cda83b76079794c028951f89b06d5a3c Mon Sep 17 00:00:00 2001 From: William T Navarre Date: Sat, 16 Jan 2016 18:58:10 -0500 Subject: [PATCH] Checking in old birthday-reminder script code. --- cron.php | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 cron.php diff --git a/cron.php b/cron.php new file mode 100644 index 0000000..e45f03a --- /dev/null +++ b/cron.php @@ -0,0 +1,57 @@ +query($sql); + if(PEAR::isError($res)) { + error_log($res->getDebugInfo()); + fatal("Could not get chairman's name: ".$res->getMessage()); + } + $chairman = $res->fetchOne(); + $chairtok = explode(" ", $chairman); + $res->free(); + + # Get today's Birthdays + $sql = "SELECT display_name, YEAR(CURDATE()) - YEAR(birthday) AS age FROM " . + "staff WHERE MONTH(CURDATE()) = MONTH(birthday) AND DAY(CURDATE()) = " . + "DAY(birthday) AND active = 'yes' GROUP BY display_name ORDER BY " . + "birthday ASC"; + $res =& $mdb2->query($sql); + if(PEAR::isError($res)) { + error_log($res->getDebugInfo()); + fatal("Could not get today's birthdays: ".$res->getMessage()); + } + $rows = $res->numRows; + if ( $rows == 0 ) { + $res->free(); + return; + } + $res->bindColumn('display_name', $name); + $res->bindColumn('age', $age); + + # Form mail message + $message = "Hi $chairtok[0],\n\n"; + while ($row = $res->fetchRow()) { + $message .= " $name is $age today.\n"; + } + $message .= "\nPlease send them birthday wishes!\n\n"; + $message .= "Sincerely,\n\nThe Masthead and Maillist Maintenance System\n"; + + # Mail the results + mail("$chairman ", "Today's Birthday Reminders", + $message, "From: 3M Birthday Reminder "); +} // end of getBirthdays() + +### Run Commands +getBirthdays();