2008-09-10 05:42:44 +02:00
|
|
|
<?php
|
2011-06-01 12:13:39 +02:00
|
|
|
require_once "funktion_jabber.php";
|
2008-09-10 05:42:44 +02:00
|
|
|
|
|
|
|
// global array for collected error_messages
|
|
|
|
$error_messages = array();
|
|
|
|
|
|
|
|
// general error handler collecting all messages in an array
|
2011-06-01 12:13:39 +02:00
|
|
|
function Error_Handler($error_number, $error_string, $error_file, $error_line, $error_context) {
|
2008-09-10 05:42:44 +02:00
|
|
|
global $error_messages, $con;
|
|
|
|
|
2011-06-01 12:13:39 +02:00
|
|
|
// SQL error genauer analysiert
|
2008-09-10 05:42:44 +02:00
|
|
|
$Temp = "";
|
2011-06-01 12:13:39 +02:00
|
|
|
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": ""));
|
2008-09-10 05:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// register error handler
|
|
|
|
set_error_handler("Error_Handler");
|
|
|
|
|
2011-06-01 12:13:39 +02:00
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
|
|
|
if($debug) {
|
|
|
|
ini_set("display_errors", "On");
|
|
|
|
ini_set("display_startup_errors", "On");
|
|
|
|
ini_set("html_errors", "On");
|
2008-09-10 05:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// send errors
|
2011-06-01 12:13:39 +02:00
|
|
|
function send_errors() {
|
2008-09-10 05:42:44 +02:00
|
|
|
global $error_messages;
|
|
|
|
|
2011-06-01 12:13:39 +02:00
|
|
|
if(!$error_messages)
|
|
|
|
return;
|
|
|
|
|
2008-09-10 05:42:44 +02:00
|
|
|
$message = "";
|
|
|
|
foreach($error_messages as $value)
|
|
|
|
$message .= $value."\n";
|
2011-06-01 12:13:39 +02:00
|
|
|
|
2008-09-10 05:42:44 +02:00
|
|
|
$message .= "\n";
|
2011-06-01 12:13:39 +02:00
|
|
|
|
|
|
|
if(isset($_POST)) {
|
|
|
|
foreach ($_POST as $k => $v)
|
2008-09-10 05:42:44 +02:00
|
|
|
$message .= "_POST: $k = ". ( $k!="password"? $v : "???..."). "\n";
|
2011-06-01 12:13:39 +02:00
|
|
|
|
2008-09-10 05:42:44 +02:00
|
|
|
$message .= "\n";
|
|
|
|
}
|
2011-06-01 12:13:39 +02:00
|
|
|
|
|
|
|
if(isset($_GET)) {
|
|
|
|
foreach ($_GET as $k => $v)
|
|
|
|
$message .= "_GET: $k = $v\n";
|
|
|
|
|
2008-09-10 05:42:44 +02:00
|
|
|
$message .= "\n";
|
|
|
|
}
|
2011-06-01 12:13:39 +02:00
|
|
|
|
2008-09-10 05:42:44 +02:00
|
|
|
$message .= "\n\n";
|
|
|
|
|
|
|
|
if( isset( $_SESSION))
|
|
|
|
{
|
2011-06-01 12:13:39 +02:00
|
|
|
foreach ($_SESSION as $k => $v )
|
2008-09-10 05:42:44 +02:00
|
|
|
$message .= "_SESSION: $k = $v\n";
|
|
|
|
$message .= "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if( isset( $_SESSION['CVS']))
|
|
|
|
{
|
2011-06-01 12:13:39 +02:00
|
|
|
foreach ($_SESSION['CVS'] as $k => $v )
|
2008-09-10 05:42:44 +02:00
|
|
|
if( strlen($k)>3 )
|
|
|
|
$message .= "_SESSION['CVS']: $k = $v\n";
|
|
|
|
$message .= "\n";
|
|
|
|
}
|
2011-06-01 12:13:39 +02:00
|
|
|
|
|
|
|
foreach ($_SERVER as $k => $v )
|
2008-09-10 05:42:44 +02:00
|
|
|
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__));
|
2008-09-10 17:43:25 +02:00
|
|
|
require_once('./config_jabber.php');
|
2008-09-10 05:42:44 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|