source: includes/error.php

Last change on this file was 1, checked in by george, 15 years ago
  • Import souborů projektu.
File size: 2.6 KB
Line 
1<?
2
3// Obsluha chyb v1.1.1 //
4
5$Error_Email = $WebMasterEmail; // Adresa, kam budou chyby odesílány
6$Error_Subject = 'Chybové hlášení'; // Název zpráv o chybách
7$Error_ShowDetails = '1'; // Zobrazit detajly o chyby
8$ErrorLogFile = 'php_script_error.log';
9$ShowMessage = False; //zobrazovat upozornìní
10
11//error_reporting(0); // Vypni interní obsluhu chyb
12
13function obsluha_chyb($errno,$errmsg,$filename,$linenum,$vars)
14{
15 global $ErrorsDisabled, $Error_ShowDetails, $ErrorLogFile;
16 $dt = date("Y-m-d H:i:s"); // easové razítko polo3ky
17 $errortype = array (
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 $user_errors = E_ALL; //E_ERROR | E_WARNING | E_PARSE;
31
32 if(($user_errors & $errno) and (!$ErrorsDisabled))
33 {
34 $err = '# '.$dt.' : '.$errmsg."\n";
35 $Backtrace = debug_backtrace();
36 array_shift($Backtrace);
37 //array_shift($Backtrace);
38 foreach($Backtrace as $Item)
39 {
40 $err .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
41 $arguments = '';
42 if(array_key_exists('args',$Item))
43 if(is_array($Item['args']))
44 foreach($Item['args'] as $Arg)
45 {
46 if(is_array($Arg)) $arguments .= "'".serialize($Arg)."',";
47 else $arguments .= "'".$Arg."',";
48 }
49 if(strlen($arguments)>0) $err .= '('.substr($arguments,0,-1).")";
50 $err .= "\n";
51
52 }
53 $err .= "\n";
54 //echo('Uvnito'.$errno);
55 // error_log($err, 3, $ErrorLogFile); // Ulo3 do chybového protokolu
56 $err = "Hlášení: ".$errmsg." Skript: ".$filename." øádek: ".$linenum;
57 mail($Error_Email,$Error_Subject,$err); // Po1li mi zprávu (pokud je to kritická chyba)
58 WriteLog($err,'5');
59
60 if ($ShowMessage)
61 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".
62 '<meta http-equiv="Content-Language" content="cs">'."\n".
63 '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"></head><body>'."\n".
64 'Do1lo k vnitoní chybi!<br> O chybi byl uvidomnin správce webu a chybu brzy odstraní.<br><br>');
65 if($Error_ShowDetails==1) echo('<pre>'.$err.'</pre><br>'); // V poípadi ladiní chybu i zobraz
66 echo('</body></html>');
67 if((E_ERROR | E_PARSE) & $errno) die();
68 }// else echo($errmsg.'<br>');
69}
70
71set_error_handler('obsluha_chyb'); // Aktivuj novou obsluhu chyb
72
73?>
Note: See TracBrowser for help on using the repository browser.