-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhpErrorHandler.inc.php
More file actions
111 lines (103 loc) · 3.44 KB
/
Copy pathPhpErrorHandler.inc.php
File metadata and controls
111 lines (103 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
function IPSLogger_PhpErrorHandler ($ErrType, $ErrMsg, $FileName, $LineNum)
{
if (error_reporting() == 0) {return false;} // No Reporting of suppressed Erros (suppressed @)
require_once "IPSLogger.inc.php";
$ErrorDetails = "\n Error in Script ".$FileName." on Line ".$LineNum;
$FatalError = false;
switch ($ErrType) {
case E_ERROR:
IPSLogger_Err("PHP", 'Error: '.$ErrMsg.$ErrorDetails);
$FatalError = true;
break;
case E_WARNING:
IPSLogger_Err("PHP", 'Warning: '.$ErrMsg.$ErrorDetails);
break;
case E_PARSE:
IPSLogger_Err("PHP", 'Parsing Error: '.$ErrMsg.$ErrorDetails);
$FatalError = true;
break;
case E_NOTICE:
IPSLogger_Err("PHP", 'Notice: '.$ErrMsg.$ErrorDetails);
break;
case E_CORE_ERROR:
IPSLogger_Err("PHP", 'Core Error: '.$ErrMsg.$ErrorDetails);
$FatalError = true;
break;
case E_CORE_WARNING:
IPSLogger_Err("PHP", 'Core Warning: '.$ErrMsg.$ErrorDetails);
$FatalError = true;
break;
case E_COMPILE_ERROR:
IPSLogger_Err("PHP", 'Compile Error: '.$ErrMsg.$ErrorDetails);
$FatalError = true;
break;
case E_COMPILE_WARNING:
IPSLogger_Err("PHP", 'Compile Warning: '.$ErrMsg.$ErrorDetails);
$FatalError = true;
break;
case E_USER_ERROR:
IPSLogger_Err("PHP", 'User Error: '.$ErrMsg.$ErrorDetails);
$FatalError = true;
break;
case E_USER_WARNING:
IPSLogger_Err("PHP", 'User Warning: '.$ErrMsg.$ErrorDetails);
break;
case E_USER_NOTICE:
IPSLogger_Err("PHP", 'User Notice: '.$ErrMsg.$ErrorDetails);
break;
case E_STRICT:
$FatalError = true;
IPSLogger_Err("PHP", 'Runtime Notice: '.$ErrMsg.$ErrorDetails);
break;
default:
IPSLogger_Err("PHP", 'Unknown Error: '.$ErrMsg.$ErrorDetails);
$FatalError = true;
break;
}
global $_IPS;
if (array_key_exists('ERROR_COUNT', $_IPS)) {
$errorCount=$_IPS['ERROR_COUNT'] + 1;
} else {
$errorCount=1;
}
$_IPS['ERROR_COUNT'] = $errorCount;
// Abort Processing during "Abort Flag"
if (array_key_exists('ABORT_ON_ERROR', $_IPS) and $_IPS['ABORT_ON_ERROR']) {
exit('Abort Processing during Error: '.$ErrMsg.$ErrorDetails);
// Abort Processing during "FATAL Error"
} elseif ($FatalError) {
exit('Abort Processing during Fatal-Error: '.$ErrMsg.$ErrorDetails);
// Abort Processing during maximal Error Counter
} elseif ($errorCount > 10) {
IPSLogger_Err("PHP", 'Maximal ErrorCount exceeded for this Session --> Abort Processing');
exit('Abort Processing during exceed of maximal ErrorCount: '.$ErrMsg.$ErrorDetails);
} else {
return false;
}
}
$old_error_handler = set_error_handler("IPSLogger_PhpErrorHandler", E_ERROR | E_PARSE);
function IPSLogger_PhpFatalErrorHandler() {
if (@is_array($e = @error_get_last())) {
//print_r($e); echo "Reporting=".error_reporting()."\n";
$code = isset($e['type']) ? $e['type'] : 0;
$msg = isset($e['message']) ? $e['message'] : '';
$file = isset($e['file']) ? $e['file'] : '';
$line = isset($e['line']) ? $e['line'] : '';
switch($code) {
case E_ERROR:
case E_PARSE:
case E_CORE_ERROR:
case E_CORE_WARNING:
case E_COMPILE_ERROR:
case E_COMPILE_WARNING:
IPSLogger_PhpErrorHandler ($code, $msg, $file, $line, null);
break;
default:
break;
}
}
}
register_shutdown_function('IPSLogger_PhpFatalErrorHandler');
/** @}*/
?>