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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<?php
require_once "funktion_jabber.php";
// global array for collected error_messages
$error_messages = array();
// general error handler collecting all messages in an array
function Error_Handler($error_number, $error_string, $error_file, $error_line, $error_context) {
global $error_messages, $con;
// SQL error genauer analysiert
$Temp = "";
foreach ($error_context as $k => $v)
if((strpos( "0$k", "sql") > 0) || (strpos( "0$k", "SQL") > 0))
$Temp .= "Error Context: $k = $v\n";
if((strpos( "0$error_string", "MySQL") > 0))
$Temp .= "Error MySQL: ". mysql_error($con). "\n";
// Uebergeben des arrays
array_push($error_messages, "Error Number: " . $error_number . "\n".
"Error String: " . $error_string . "\n".
"Error File: " . $error_file . "\n".
"Error Line: " . $error_line . "\n".
(strlen($Temp)? "$Temp": ""));
}
// register error handler
set_error_handler("Error_Handler");
error_reporting(E_ALL);
if($debug) {
ini_set("display_errors", "On");
ini_set("display_startup_errors", "On");
ini_set("html_errors", "On");
}
// send errors
function send_errors() {
global $error_messages;
if(!$error_messages)
return;
$message = "";
foreach($error_messages as $value)
$message .= $value."\n";
$message .= "\n";
if(isset($_POST)) {
foreach ($_POST as $k => $v)
$message .= "_POST: $k = ". ( $k!="password"? $v : "???..."). "\n";
$message .= "\n";
}
if(isset($_GET)) {
foreach ($_GET as $k => $v)
$message .= "_GET: $k = $v\n";
$message .= "\n";
}
$message .= "\n\n";
if( isset( $_SESSION))
{
foreach ($_SESSION as $k => $v )
$message .= "_SESSION: $k = $v\n";
$message .= "\n";
}
if( isset( $_SESSION['CVS']))
{
foreach ($_SESSION['CVS'] as $k => $v )
if( strlen($k)>3 )
$message .= "_SESSION['CVS']: $k = $v\n";
$message .= "\n";
}
foreach ($_SERVER as $k => $v )
if( strpos( "0$k", "SERVER_")==0)
$message .= "_SERVER: $k = $v\n";
send_message($message);
// display error messages on screen too for developers
if ($_SESSION['CVS']['admin/debug.php']=='Y')
{
echo "<pre id='error'>\n".$message."</pre>";
}
}
register_shutdown_function("send_errors");
// send jabber message and email
function send_message(&$message)
{
chdir(dirname(__FILE__));
require_once('./config_jabber.php');
if (isset($jabber_recipient) && count($jabber_recipient)) {
$jabber = new Jabber($server, $port, $username, $password, $resource);
if ($jabber->Connect() && $jabber->SendAuth()) {
foreach($jabber_recipient as $value)
{
$jabber->SendMessage($value, "normal", NULL, array("body" => $message, "subject" => "Error in Pentabarf"), NULL);
}
$jabber->Disconnect();
} else {
array_push($message, "Couldn't connect to Jabber Server.");
}
}
if (isset($mail_recipient) && count($mail_recipient)) {
foreach($mail_recipient as $to) {
mail($to, isset($mail_subject) ? $mail_subject : "Pentabarf Error", $message);
}
}
}
?>
|