Code

Implemented php bug submitting
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Jun 2007 13:19:16 +0000 (13:19 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Jun 2007 13:19:16 +0000 (13:19 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6734 594d385d-05f5-0310-b6e9-bd551577e9d8

html/index.php
html/main.php
html/setup.php
include/functions.inc
include/php_setup.inc
plugins/admin/fai/class_faiScript.inc

index 7a947cd583a49b294de1ea13a4b5c2e3157225ce..0ad4f680014782c7d8eae1c48f9645bf8a5771fc 100644 (file)
@@ -366,7 +366,7 @@ if (isset($_SESSION['errors'])){
   $smarty->assign("errors", $_SESSION['errors']);
 }
 if ($error_collector != ""){
-  $smarty->assign("php_errors", $error_collector."</div>");
+  $smarty->assign("php_errors", preg_replace("/%BUGBODY%/",$error_collector_mailto,$error_collector)."</div>");
 } else {
   $smarty->assign("php_errors", "");
 }
index 7e001e122b95b0735204f821156af82bd56c7cca..be5e03e17217dd4e7c87fff3421b1b67ff1f065a 100644 (file)
@@ -373,7 +373,7 @@ if (isset($_SESSION['errors'])){
   $smarty->assign("errors", $_SESSION['errors']);
 }
 if ($error_collector != ""){
-  $smarty->assign("php_errors", $error_collector."</div>");
+  $smarty->assign("php_errors", preg_replace("/%BUGBODY%/",$error_collector_mailto,$error_collector)."</div>");
 } else {
   $smarty->assign("php_errors", "");
 }
index 5adc78a6d1c500e551b33a84c7405af8f0ebf49a..06164aa001de834fed06b04d9f97f7b4463ab10a 100644 (file)
@@ -120,7 +120,7 @@ $smarty->assign("header", $_SESSION['setup']->get_header_html());
 $smarty->assign("bottom", $_SESSION['setup']->get_bottom_html());
 
 if ($error_collector != ""){
-  $smarty->assign("php_errors", $error_collector."</div>");
+  $smarty->assign("php_errors", preg_replace("/%BUGBODY%/",$error_collector_mailto,$error_collector)."</div>");
 } else {
   $smarty->assign("php_errors", "");
 }
index 37bfa9fa06a7a6dc8f27ebc7d1a29056406c2d36..9e0f24c9adfd6dca4f98ff747a6f0b42f0b70863 100644 (file)
@@ -2382,5 +2382,45 @@ function check_schema($cfg,$rfc2307bis = FALSE)
   return($checks);
 }
 
+
+function prepare4mailbody($string)
+{
+  $string = html_entity_decode($string);
+
+  $from = array(
+                "/%/",
+                "/ /",
+                "/\n/",
+                "/\r/",
+                "/!/",
+                "/#/",
+                "/\*/",
+                "/\//",
+                "/</",
+                "/>/",
+                "/\?/",
+                "/\"/");
+
+  $to = array(
+                "%25",
+                "%20",
+                "%0A",
+                "%0D",
+                "%21",
+                "%23",
+                "%2A",
+                "%2F",
+                "%3C",
+                "%3E",
+                "%3F",
+                "%22");
+
+  $string = preg_replace($from,$to,$string);
+
+  return($string);
+}
+
+
+
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index ec13459435faafcdfcb6492c3f538883d69db13b..95fb9a53ef578065893e268a6e9aa0709b1b6459 100644 (file)
@@ -20,7 +20,7 @@
 
 function gosaRaiseError($errno, $errstr, $errfile, $errline)
 {
-  global $error_collector,$config;
+  global $error_collector,$config, $error_collector_mailto;
 
   if(@class_exists("log")){
     new log("debug","all",$errfile,array(),"Type:".$errno.", Message:".$errstr.", File:".$errfile.", Line: ".$errline);
@@ -69,22 +69,67 @@ function gosaRaiseError($errno, $errstr, $errfile, $errline)
 
   /* Create header as needed */
   if ($error_collector == ""){
+
+    /* Mailto body header */
+    $error_collector_mailto .=prepare4mailbody(
+                                "Oups. Seems like you've catched some kind of bug inside GOsa/PHP. You may want to help ".
+                                "us to improve the software stability. If so, please provide some more information below.".
+                                "\n\n".
+                                "*** GOsa bug report ***".
+                                "\nGOsa Version: ".get_gosa_version().
+                                "\nDate: ".date("d.m.Y").
+                                "\nTime: ".date("H:i:s").
+                                "\n\n".
+                                "Please describe what you did to produce this error as detailed as possible. Can you ".
+                                "reproduce this bug using the demo on http://www.gosa-project.org ?".
+                                "\n\n".
+                                "*** PHP error information ***\n\n");
+
     if (isset($_SESSION['js']) && $_SESSION['js']==FALSE){
       $error_collector= "<div>";
     } else {
-      $error_collector= "<table summary=\"\" width=\"100%\" style='background-color:#E0E0E0;border-bottom:1px solid black;z-index:150;'><tr><td><img alt=\"\" align=\"middle\" src='".get_template_path('images/warning.png')."'>&nbsp;<font style='font-size:14px;font-weight:bold'>"._("Generating this page caused the PHP interpreter to raise some errors!")."</font></td><td align=right><button onClick='toggle(\"errorbox\")'>"._("Toggle information")."</button></td></tr></table><div id='errorbox' style='position:absolute; z-index:150; visibility: hidden'>";
+      $error_collector= "
+        <table summary=\"\" width=\"100%\" style='background-color:#E0E0E0;border-bottom:1px solid black;z-index:150;'>
+          <tr>
+            <td>
+              <img alt=\"\" align=\"middle\" src='".get_template_path('images/warning.png')."'>&nbsp;
+              <font style='font-size:14px;font-weight:bold'>".
+                _("Generating this page caused the PHP interpreter to raise some errors!")."
+              </font>
+            </td>
+            <td align=right>
+              <a href=\"mailto:gosa-bugs@oss.gonicus.de?subject=GOsa%20bugreport&amp;body=%BUGBODY%\">
+                <img border='0' src='images/mailto.png' title='"._("Send bug report to the GOsa Team")."' class='center' alt=''>&nbsp;"._("Send bugreport")."
+              </a>
+            </td>
+            <td align=right>
+              <button onClick='toggle(\"errorbox\")'>".
+                _("Toggle information")."
+              </button>
+            </td>
+          </tr>
+        </table>
+        <div id='errorbox' style='position:absolute; z-index:150; visibility: hidden'>";
     }
   }
  
   /* Create error header */
   $error_collector.= "<table summary=\"\" width=\"100%\" cellspacing=0 style='background-color:#402005;color:white;border:2px solid red'><tr><td colspan=3><h1 style='color:white'>"._("PHP error")." \"$errstr\"</h1></td></tr>";
+
+  $error_collector_mailto .= prepare4mailbody("=== Error === \n");
+  $error_collector_mailto .= prepare4mailbody("PHP error: $errstr ($errfile, line $errline)\n");
+  $error_collector_mailto .= prepare4mailbody("=== /Error === \n\n");
   
   /* Extract traceback data - if available */
   if (function_exists('debug_backtrace')){
     $trace= debug_backtrace();
 
+    $error_collector_mailto .= prepare4mailbody("=== Trace ===");
+
     /* Generate trace history */
     for ($index= 0; $index<count($trace); $index++){
+
+
       $ct= $trace[$index];
       $loc= "";
       if (isset($ct['class'])){
@@ -139,9 +184,21 @@ function gosaRaiseError($errno, $errstr, $errfile, $errline)
       $error_collector.= "<tr style='background-color:$color'><td style='padding-left:20px' width=\"30%\">"._("Trace")."[$index]: $loc</td>";
       $error_collector.= "<td>"._("File").": $file ("._('Line')." $line)</td><td width=\"10%\">"._("Type").": $type</td></tr>";
       $error_collector.= "<tr style='background-color:$color'><td colspan=3 style='padding-left:20px;'>"._("Arguments").": $args</td></tr>";
+
+      /* Add trace part to mailto body */
+      $error_collector_mailto .= prepare4mailbody(
+                                   "\nTrace[".$index."]:".$loc.
+                                   "\nFile : ".$file.
+                                   "\nLine : ".$line.
+                                   "\nType : ".$type.
+                                   "\n  ".$args.
+                                   "\n");
+
     }
   }
 
+  $error_collector_mailto .= prepare4mailbody("=== /Trace === \n");
+
   /* Close error table */
   $error_collector.= "</table>";
 
@@ -166,6 +223,7 @@ error_reporting (E_ALL);
 
 /* Register error handler */
 $error_collector= "";
+$error_collector_mailto= "";
 set_error_handler('gosaRaiseError');
 
 $variables_order= "ES";
index 72f2d200960839c07a626ddff540f3ac68a8d5e3..07ccd934d915030fa02fe485d1283f09a0cbfa99 100644 (file)
@@ -141,6 +141,8 @@ class faiScript extends plugin
     /* Call parent execute */
     plugin::execute();
 
+    $a .= $b[cbh];
+
     if($this->is_account && !$this->view_logged){
       $this->view_logged = TRUE;
       new log("view","fai/".get_class($this),$this->dn);