source: trunk/error.php

Last change on this file was 37, checked in by george, 16 years ago
  • Upraveno: Aktualizace inicializační databáze.
File size: 2.4 KB
Line 
1<?php
2
3function CustomErrorHandler($Number, $Message, $Filename, $LineNumber, $Variables)
4{
5 global $Config;
6
7 $Date = date("Y-m-d H:i:s"); // časové razítko položky
8 $ErrorType = array
9 (
10 1 => 'Error',
11 2 => 'Warning',
12 4 => 'Parsing Error',
13 8 => 'Notice',
14 16 => 'Core Error',
15 32 => 'Core Warning',
16 64 => 'Compile Error',
17 128 => 'Compile Warning',
18 256 => 'User Error',
19 512 => 'User Warning',
20 1024 => 'User Notice'
21 );
22 $UserErrors = E_ALL; //E_ERROR | E_WARNING | E_PARSE;
23
24 if(($UserErrors & $Number))
25 {
26 $Error = '# '.$Date.' : '.$Message.' on line '.$LineNumber."\n";
27 $Backtrace = debug_backtrace();
28 $Backtrace[0]['function'] = '';
29 $Backtrace[0]['args'] = '';
30 //$First = array_shift($Backtrace);
31 print_r($First);
32
33 //array_unshift($Backtrace, $First);
34 //array_shift($Backtrace);
35 //print_r($Backtrace);
36 foreach($Backtrace as $Item)
37 {
38 $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
39 $Arguments = '';
40 if(array_key_exists('args', $Item) and is_array($Item['args']))
41 foreach($Item['args'] as $Item)
42 {
43 if(is_array($Item)) $Arguments .= "'".serialize($Item)."',";
44 else $Arguments .= "'".$Item."',";
45 }
46 if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
47 $Error .= "\n";
48
49 }
50 $Error .= "\n";
51 //if($Config['Web']['ErrorLogFile'] != '')
52 //error_log($Error, 3, $Config['Web']['ErrorLogFile']);
53 // Pošli mi zprávu (pokud je to kritická chyba)
54 //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error);
55 // Show error message
56 if($Config['Web']['ShowPHPError'] == true)
57 {
58 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".
59 '<meta http-equiv="Content-Language" content="cs">'."\n".
60 '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"></head><body>'."\n".
61 'Došlo k vnitřní chybě!<br> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br><br>');
62 echo('<pre>'.$Error.'</pre><br>'); // V případě ladění chybu i zobraz
63 echo('</body></html>');
64 }
65 if((E_ERROR | E_PARSE) & $Number) die();
66 }
67}
68
69set_error_handler('CustomErrorHandler');
70
71?>
Note: See TracBrowser for help on using the repository browser.