- <?php
- /*
- * Lokorin.com
- * Copyright 2004-2006
- * Licensed under the GNU LGPL. See COPYING for full terms.
- */
- /**
- * A library that contains functions for digesting information about important
- * events and relaying it to the webmaster.
- * @author Andreas Launila
- * @version $Revision: 1.6 $
- * @package com.lokorin.lokorin.lib
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
- */
-
- /**
- * For access to common constants and functions.
- */
- require_once('common.php');
-
- /**
- * Performs all the event digest work available.
- * @throws Exception If something goes wrong.
- * @access public
- */
- function doEventDigest() {
- checkErrors();
- checkMplfArchive();
- return true;
- }
-
- /**
- * Checks if there are any unresolved errors that should be sent to the
- * webmaster.
- * @access private
- */
- function checkErrors() {
- global $db;
-
- $mailMessage = '';
- $mailTitle = 'Digest: ';
-
- //Check for errors
- $rows = $db->querySelect(TABLE_ERRORS,
- array('message', 'timestamp'),
- "WHERE investigated != 1");
- if(count($rows) > 0) {
- $mailTitle .= sizeof($rows).' Errors';
- foreach($rows as $row) {
- $mailMessage .= 'Error ('.date(DATE_LONG, $row['timestamp']).
- '): "'.$row['message'].'"'."\r\n\r\n";
- }
- sendDigestEmail($mailTitle, $mailMessage);
- }
- }
-
- /**
- * Checks if there are any filters or suggested modifications awaiting
- * approval.
- * @access private
- */
- function checkMplfArchive() {
- global $db;
-
- //Check for filters
- $count = $db->queryCount(TABLE_MPLF_FILTERS,
- $db->buildSqlSelector(array('moderator_id' => 0)));
- if($count != 0) {
- sendDigestEmail('Digest: '.$count.' filter awaiting approval',
- 'There are currently '.$count.' filters that need approval ' .
- 'at http://www.lokorin.com/mplf/mod/approve.php .');
- }
-
- //Check for changes
- $count = $db->queryCount(TABLE_MPLF_CHANGES);
- if($count != 0) {
- sendDigestEmail('Digest: '.$count.' changes awaiting approval',
- 'There are currently '.$count.' changes that need approval ' .
- 'at http://www.lokorin.com/mplf/mod/changes.php .');
- }
- }
-
- /**
- * Sends a digest email to the webmaster.
- * @param string $title The title of the email.
- * @param string $message The message body of the email.
- * @access private
- */
- function sendDigestEmail($title, $message) {
- doInclude('lib_util');
- sendEmail($title, $message, 'lokobot@lokorin.com');
- }
- ?>