prepare($sql);
$stmt->bindValue(1, is_numeric($currentuser->id) ? $currentuser->id : 'NULL');
$stmt->bindValue(2, $section);
$stmt->bindValue(3, $action);
$stmt->bindValue(4, $level);
$stmt->bindValue(5, $msg);
$stmt->execute() or die($sql . '
' . $stmt->errorCode() . '
' . var_export(debug_backtrace()));
// Log all important sorts of messages in the Apache log
if( $level & (E_USER_WARNING | E_USER_ERROR) )
{
error_log($msg, 0);
}
// Email critical messages and those for which email is requested
if($email || E_USER_ERROR == $level || E_ERROR == $level)
{
// Pretty printing
switch($level)
{
case E_USER_NOTICE:
case E_NOTICE:
$importance = 'Notice';
break;
case E_USER_WARNING:
case E_WARNING:
$importance = 'Warning';
break;
case E_USER_ERROR:
case E_ERROR:
$importance = 'Error';
break;
default:
$importance = "Other - $level";
break;
}
switch($section)
{
case MTS_LOGIN: $area = 'User login'; break;
case MTS_USER: $area = 'Modify user'; break;
case MTS_PAGE: $area = 'Modify page'; break;
case MTS_RANT: $area = 'Modify rant'; break;
case MTS_SCRATCH: $area = 'Modify scratchpd'; break;
case MTS_STRIP: $area = 'Modify strips'; break;
case MTS_TYPE: $area = 'Modify strip types'; break;
case MTS_TYPE_META: $area = 'Modify strip metatypes'; break;
case MTS_TWITTER: $area = 'Modify Twitter'; break;
default:
$area = 'Undefined Area'; break;
}
error_log("Megatokyo Administrative Notice\r\nPriority level: $importance\r\nReported by: ".$currentuser->name."\r\nSection: $area\r\n$msg", 1, SITE_CONTACT);
}
}
?>