1 | <?php
|
---|
2 |
|
---|
3 | include_once('global_function.php');
|
---|
4 |
|
---|
5 | function EmptyErrorHandler($Number, $Message, $Filename, $LineNumber, $Variables)
|
---|
6 | {
|
---|
7 | }
|
---|
8 |
|
---|
9 | function CustomErrorHandler($Number, $Message, $Filename, $LineNumber, $Variables)
|
---|
10 | {
|
---|
11 | global $Config;
|
---|
12 |
|
---|
13 | set_error_handler('EmptyErrorHandler');
|
---|
14 |
|
---|
15 | $Date = date('Y-m-d H:i:s'); // časové razítko položky
|
---|
16 | $ErrorType = array
|
---|
17 | (
|
---|
18 | 1 => 'Error',
|
---|
19 | 2 => 'Warning',
|
---|
20 | 4 => 'Parsing Error',
|
---|
21 | 8 => 'Notice',
|
---|
22 | 16 => 'Core Error',
|
---|
23 | 32 => 'Core Warning',
|
---|
24 | 64 => 'Compile Error',
|
---|
25 | 128 => 'Compile Warning',
|
---|
26 | 256 => 'User Error',
|
---|
27 | 512 => 'User Warning',
|
---|
28 | 1024 => 'User Notice'
|
---|
29 | );
|
---|
30 | $UserErrors = E_ALL; //E_ERROR | E_WARNING | E_PARSE;
|
---|
31 |
|
---|
32 | if(($UserErrors & $Number))
|
---|
33 | {
|
---|
34 | $Error = '# '.$Date.' : '.$Message.' on line '.$LineNumber."\n";
|
---|
35 | $Backtrace = debug_backtrace();
|
---|
36 | $Backtrace[0]['function'] = '';
|
---|
37 | $Backtrace[0]['args'] = '';
|
---|
38 | //$First = array_shift($Backtrace);
|
---|
39 | //print_r($First);
|
---|
40 |
|
---|
41 | //array_unshift($Backtrace, $First);
|
---|
42 | //array_shift($Backtrace);
|
---|
43 | //print_r($Backtrace);
|
---|
44 | foreach($Backtrace as $Item)
|
---|
45 | {
|
---|
46 | //print_r($Item);
|
---|
47 | if(!array_key_exists('line', $Item)) $Item['line'] = '';
|
---|
48 | if(!array_key_exists('file', $Item)) $Item['file'] = '';
|
---|
49 | if(!array_key_exists('function', $Item)) $Item['function'] = '';
|
---|
50 | $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
|
---|
51 | $Arguments = '';
|
---|
52 | if(array_key_exists('args', $Item) and is_array($Item['args']))
|
---|
53 | foreach($Item['args'] as $Item)
|
---|
54 | {
|
---|
55 | if(is_array($Item)) $Arguments .= "'".serialize($Item)."',";
|
---|
56 | else $Arguments .= "'".serialize($Item)."',";
|
---|
57 | }
|
---|
58 | if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
|
---|
59 | $Error .= "\n";
|
---|
60 |
|
---|
61 | }
|
---|
62 | $Error .= "\n";
|
---|
63 | //if($Config['Web']['ErrorLogFile'] != '')
|
---|
64 | //error_log($Error, 3, $Config['Web']['ErrorLogFile']);
|
---|
65 | // Pošli mi zprávu (pokud je to kritická chyba)
|
---|
66 | //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error);
|
---|
67 | // Show error message
|
---|
68 | if($Config['Web']['ShowPHPError'] == true)
|
---|
69 | {
|
---|
70 | echo('<?xml version="1.0" encoding="utf-8"?>'."\n".
|
---|
71 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
|
---|
72 | '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'.
|
---|
73 | '<head>'.
|
---|
74 | '<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />'.
|
---|
75 | '</head><body>'.
|
---|
76 | 'Došlo k vnitřní chybě!<br /> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br /><br />');
|
---|
77 | echo('<pre>'.$Error.'</pre><br />'); // V případě ladění chybu i zobraz
|
---|
78 | echo('</body></html>');
|
---|
79 | }
|
---|
80 | WriteLog($Error, LOG_TYPE_ERROR);
|
---|
81 | if((E_ERROR | E_PARSE) & $Number) die();
|
---|
82 | }
|
---|
83 | set_error_handler('CustomErrorHandler');
|
---|
84 | }
|
---|
85 |
|
---|
86 | set_error_handler('CustomErrorHandler');
|
---|
87 |
|
---|
88 | ?>
|
---|