News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Tiny little mini-mod to email admin on unusual forum errors

Started by dcmouser, January 09, 2007, 12:32:58 AM

Previous topic - Next topic

dcmouser

There are two classes of "errors" that get logged on the forum:

One is the expected kind, either an incorrect password, or a warning that they have not yet validated their email.

The other kind is a serious error like a php script error.

This tiny modification will email you whenever an error is logged that is not of the first trivial class.




File Sources\Errors.php:

Near line 85, after:

// Log an error, if the option is on.
function log_error($error_message, $file = null, $line = null)
{
global $db_prefix, $txt, $modSettings, $ID_MEMBER, $sc, $user_info;

// Check if error logging is actually on.
if (empty($modSettings['enableErrorLogging']))
return $error_message;


Add:

// EMAIL ADMIN UNUSUAL ERRORS MINIMOD
// if it is not a standard everyday non-error error then email the admin so they can attend to it right away
if (false || (strpos($error_message,"email address needs to be validated")===false && strpos($error_message,"Password incorrect")===false))
{
global $mbname,$webmaster_email,$sourcedir;
require_once($sourcedir . '/Subs-Post.php');
if (false)
{
// send plaintext email
sendmail($webmaster_email, 'Unexpected Forum Error on ' . $mbname, $error_message);
}
else
{
// send html email
sendmail($webmaster_email, 'Unexpected Forum Error on ' . $mbname, $error_message, null, null, true);
}
}


you can change the false conditions to true to change behavior a bit.
if someone wants to make this into an official mod, please be my guest and let me know.

proud member of donationcoder.com (forum)

Advertisement: