summaryrefslogtreecommitdiff
path: root/www-ssl/inc
diff options
context:
space:
mode:
authorcookie <cookie@29ba0400-6e00-0410-a75a-ca02368028f8>2006-08-19 23:05:11 +0000
committercookie <cookie@29ba0400-6e00-0410-a75a-ca02368028f8>2006-08-19 23:05:11 +0000
commit06d39de5c8bd94386d0389152ddaf8521047aea5 (patch)
tree7a1215714d63dd51c737dedd88432b4ccb801bd4 /www-ssl/inc
parentd01dbe4b2c13295da9ae140928d7ddf9e454db8f (diff)
add error handler ins system, mit jabba und mail versand (entnomme aus pentabarf)
git-svn-id: svn://svn.cccv.de/engel-system@132 29ba0400-6e00-0410-a75a-ca02368028f8
Diffstat (limited to 'www-ssl/inc')
-rwxr-xr-xwww-ssl/inc/error_handler.php86
1 files changed, 86 insertions, 0 deletions
diff --git a/www-ssl/inc/error_handler.php b/www-ssl/inc/error_handler.php
new file mode 100755
index 00000000..95a2ea84
--- /dev/null
+++ b/www-ssl/inc/error_handler.php
@@ -0,0 +1,86 @@
+<?php
+
+ require_once("./inc/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;
+ array_push($error_messages, "Error Number: ".$error_number."\nError String: ".$error_string."\nError File: ".$error_file."\nError Line: ".$error_line."\n");
+ }
+
+ // register error handler
+// set_error_handler("Error_Handler", E_ALL);
+ set_error_handler("Error_Handler");
+
+
+ // send errors
+ function send_errors()
+ {
+ global $error_messages;
+
+ if (!$error_messages) return;
+
+ $url = $_SERVER['PHP_SELF'];
+
+ $message = "";
+ if (isset($_SERVER['PHP_AUTH_USER']))
+ $message .= "Person: ".$_SERVER['PHP_AUTH_USER']."\n";
+ $message .= "URL: $url\n";
+ if (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'Firefox') === false)
+ $message .= "UA: ".$_SERVER['HTTP_USER_AGENT']."\n";
+ if (isset($_SERVER['HTTP_REFERER']))
+ $message .= "Referer: ".$_SERVER['HTTP_REFERER']."\n";
+ foreach($error_messages as $value)
+ $message .= $value."\n";
+ foreach ($_SERVER as $k => $v )
+ $message .= "_SERVER: $k = $v\n";
+ if( isset( $_POST))
+ foreach ($_POST as $k => $v )
+ $message .= "_POST: $k = $v\n";
+ if( isset( $_GET))
+ foreach ($_GET as $k => $v )
+ $message .= "_GET: $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('../inc/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);
+ }
+ }
+ }
+
+?>