Changeset 501 for trunk/Common/Error.php
- Timestamp:
- Mar 10, 2013, 8:15:46 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Error.php
r476 r501 4 4 { 5 5 var $Encoding; 6 var $ShowError; 7 var $UserErrors; 6 8 7 9 function __construct() 8 10 { 9 11 $this->Encoding = 'utf-8'; 12 $this->ShowError = false; 13 $this->UserErrors = E_ALL; //E_ERROR | E_WARNING | E_PARSE; 10 14 } 11 15 … … 17 21 function Handle($Number, $Message, $FileName, $LineNumber, $Variables) 18 22 { 19 global $Config; 23 $Date = date('Y-m-d H:i:s'); // časové razítko položky 24 $ErrorType = array 25 ( 26 1 => 'Error', 27 2 => 'Warning', 28 4 => 'Parsing Error', 29 8 => 'Notice', 30 16 => 'Core Error', 31 32 => 'Core Warning', 32 64 => 'Compile Error', 33 128 => 'Compile Warning', 34 256 => 'User Error', 35 512 => 'User Warning', 36 1024 => 'User Notice' 37 ); 20 38 21 $Date = date('Y-m-d H:i:s'); // časové razítko položky 22 $ErrorType = array 23 ( 24 1 => 'Error', 25 2 => 'Warning', 26 4 => 'Parsing Error', 27 8 => 'Notice', 28 16 => 'Core Error', 29 32 => 'Core Warning', 30 64 => 'Compile Error', 31 128 => 'Compile Warning', 32 256 => 'User Error', 33 512 => 'User Warning', 34 1024 => 'User Notice' 35 ); 36 $UserErrors = E_ALL; //E_ERROR | E_WARNING | E_PARSE; 37 38 if(($UserErrors & $Number)) 39 { 40 $Error = '# '.$Date."\n"; 41 $Backtrace = debug_backtrace(); 42 $Backtrace[0]['function'] = $Message; 43 $Backtrace[0]['args'] = ''; 44 $Backtrace[0]['file'] = $FileName; 45 $Backtrace[0]['line'] = $LineNumber; 46 //$First = array_shift($Backtrace); 47 //print_r($Backtrace); 39 if(($this->UserErrors & $Number)) 40 { 41 $Error = '# '.$Date."\n"; 42 $Backtrace = debug_backtrace(); 43 $Backtrace[0]['function'] = $Message; 44 $Backtrace[0]['args'] = ''; 45 $Backtrace[0]['file'] = $FileName; 46 $Backtrace[0]['line'] = $LineNumber; 47 //$First = array_shift($Backtrace); 48 48 49 //array_unshift($Backtrace, $First); 50 //array_shift($Backtrace); 51 //print_r($Backtrace); 52 foreach($Backtrace as $Item) 53 { 54 $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function']; 55 $Arguments = ''; 56 if(array_key_exists('args', $Item) and is_array($Item['args'])) 49 //array_unshift($Backtrace, $First); 50 //array_shift($Backtrace); 51 foreach($Backtrace as $Item) 52 { 53 $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function']; 54 $Arguments = ''; 55 if(array_key_exists('args', $Item) and is_array($Item['args'])) 57 56 foreach($Item['args'] as $Item) 58 57 { … … 61 60 else $Arguments .= "'".$Item."',"; 62 61 } 63 if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')'; 62 if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')'; 63 $Error .= "\n"; 64 } 64 65 $Error .= "\n"; 65 66 67 $this->System->Modules['Log']->NewRecord('Error', 'Log', $Error); 68 69 //if($Config['Web']['ErrorLogFile'] != '') 70 // error_log($Error, 3, $Config['Web']['ErrorLogFile']); 71 // Pošli mi zprávu (pokud je to kritická chyba) 72 //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error); 73 // Show error message 74 if($this->ShowError == true) 75 { 76 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n". 77 '<meta http-equiv="Content-Language" content="cs">'."\n". 78 '<meta http-equiv="Content-Type" content="text/html; charset='.$this->Encoding.'"></head><body>'."\n". 79 'Došlo k vnitřní chybě!<br/> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br/><br/>'); 80 echo('<pre>'.$Error.'</pre><br/>'); // V případě ladění chybu i zobraz 81 echo('</body></html>'); 82 } 83 if((E_ERROR | E_PARSE) & $Number) die(); 66 84 } 67 $Error .= "\n";68 69 $this->System->Modules['Log']->NewRecord('Error', 'Log', $Error);70 71 //if($Config['Web']['ErrorLogFile'] != '')72 //error_log($Error, 3, $Config['Web']['ErrorLogFile']);73 // Pošli mi zprávu (pokud je to kritická chyba)74 //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error);75 // Show error message76 if($Config['Web']['ShowPHPError'] == true)77 {78 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".79 '<meta http-equiv="Content-Language" content="cs">'."\n".80 '<meta http-equiv="Content-Type" content="text/html; charset='.$this->Encoding.'"></head><body>'."\n".81 'Došlo k vnitřní chybě!<br/> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br/><br/>');82 echo('<pre>'.$Error.'</pre><br/>'); // V případě ladění chybu i zobraz83 echo('</body></html>');84 }85 if((E_ERROR | E_PARSE) & $Number) die();86 }87 85 } 88 86 }
Note:
See TracChangeset
for help on using the changeset viewer.