send mail on exception
This commit is contained in:
parent
cf414a437d
commit
aeebdaa71b
@ -181,6 +181,7 @@ try {
|
||||
|
||||
if (isProd())
|
||||
{
|
||||
sendExceptionMail($e);
|
||||
httpError('500 ', 'Internal server error');
|
||||
}
|
||||
else
|
||||
@ -191,11 +192,9 @@ try {
|
||||
}
|
||||
|
||||
|
||||
//TODO printed books 2 hp
|
||||
//TODO fast
|
||||
//TODO gzip (?)
|
||||
//TODO better gh widget
|
||||
//TODO remove db table prefixes
|
||||
//TODO euler insert+show 32bit | 64bit mode
|
||||
//TODO send cache header (?)
|
||||
//TODO global uncached error logger -> send by mail
|
||||
|
@ -289,4 +289,43 @@ function smart_resize_image($file, $string = null, $width = 0, $height = 0, $pro
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function sendMail($subject, $content, $to, $from) {
|
||||
mail($to, $subject, $content, 'From: ' . $from);
|
||||
}
|
||||
|
||||
function ParamServerOrUndef($idx) {
|
||||
return isset($_SERVER[$idx]) ? $_SERVER[$idx] : 'NOT_SET';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Exception $e
|
||||
*/
|
||||
function sendExceptionMail($e)
|
||||
{
|
||||
try {
|
||||
$subject = "Server has encountered an Error at " . date("Y-m-d H:i:s") . "] ";
|
||||
|
||||
$content = "";
|
||||
|
||||
$content .= 'HTTP_HOST: ' . ParamServerOrUndef('HTTP_HOST') . "\n";
|
||||
$content .= 'REQUEST_URI: ' . ParamServerOrUndef('REQUEST_URI') . "\n";
|
||||
$content .= 'TIME: ' . date('Y-m-d H:i:s') . "\n";
|
||||
$content .= 'REMOTE_ADDR: ' . ParamServerOrUndef('REMOTE_ADDR') . "\n";
|
||||
$content .= 'HTTP_X_FORWARDED_FOR: ' . ParamServerOrUndef('HTTP_X_FORWARDED_FOR') . "\n";
|
||||
$content .= 'HTTP_USER_AGENT: ' . ParamServerOrUndef('HTTP_USER_AGENT') . "\n";
|
||||
$content .= 'MESSAGE:' . "\n" . $e->getMessage() . "\n";
|
||||
$content .= 'CODE:' . "\n" . $e->getCode() . "\n";
|
||||
$content .= 'TRACE:' . "\n" . $e->getTraceAsString() . "\n";
|
||||
$content .= '$_GET:' . "\n" . print_r($_GET, true) . "\n";
|
||||
$content .= '$_POST:' . "\n" . print_r($_POST, true) . "\n";
|
||||
$content .= '$_FILES:' . "\n" . print_r($_FILES, true) . "\n";
|
||||
|
||||
sendMail($subject, $content, 'virtualadmin@mikescher.de', 'webserver-error@mikescher.com');
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user