Code

Udpated PHP error box, added a mailto link
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Jun 2007 09:27:36 +0000 (09:27 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Jun 2007 09:27:36 +0000 (09:27 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6725 594d385d-05f5-0310-b6e9-bd551577e9d8

html/index.php
html/main.php
html/setup.php
include/functions.inc
include/php_setup.inc

index b7f1ae83ae8f5e79290d66e38ef82b44a4d5725c..756d503782033ee7c98f871ab4e123477114ae3c 100644 (file)
@@ -70,7 +70,7 @@ function displayLogin()
       $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 ffb834262b423289f2d2e5e4d0a3d836d0fef5f3..57996e0df2b13922e41eb0acae1d11db3ca4b89d 100644 (file)
@@ -374,8 +374,9 @@ $smarty->assign("contents", $display);
 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 544fb6352346c90f38aca7d48f6707628e1adcef..4cac0b7c7580ce08eae29e9f90d9c5742344011c 100644 (file)
@@ -2452,6 +2452,17 @@ function get_base_from_hook($dn, $attrib)
   }
 
 
+function prepare4mailbody($string)
+{
+  $string = $string;
+
+  $from = array("/\n/" , "/&/" ,"/(\'|\")/");
+  $to   = array("%0A"  , "%26" ,"");
+
+  $string = preg_replace($from,$to,$string);
+
+  return($string);
+}
 
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index ebddd810af024e1c61becb511f2a490a52ca3e42..f443562eb5378ada1172bbbf02ee2783e7f0f8ff 100644 (file)
@@ -20,7 +20,7 @@
 
 function gosaRaiseError($errno, $errstr, $errfile, $errline)
 {
-  global $error_collector,$config;
+  global $error_collector,$error_collector_mailto,$config;
 
   /* Return if error reporting is set to zero */
   if (error_reporting() == 0){
@@ -65,10 +65,39 @@ function gosaRaiseError($errno, $errstr, $errfile, $errline)
 
   /* Create header as needed */
   if ($error_collector == ""){
+   
+    /* Mailto body header */ 
+    $error_collector_mailto .=prepare4mailbody(
+                                "GOsa bug report".
+                                "\nGOsa Version : ".get_gosa_version().
+                                "\nDate : ".date("H:i:s d.m.Y").
+                                "\n".
+                                "\nTrace : ".
+                                "\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>
+              <button onClick='toggle(\"errorbox\")'>".
+                _("Toggle information")."
+              </button>
+              <a href=\"mailto:gosa-bugs@oss.gonicus.de?subject=GOsa%20bugreport&body=%BUGBODY%\">
+                <img src='images/mailto.png' title='"._("Send bug report to the GOsa Team")."' class='center'>&nbsp;"._("Send bugreport")."
+              </a>
+            </td>
+          </tr>
+        </table>
+        <div id='errorbox' style='position:absolute; z-index:150; visibility: hidden'>";
     }
   }
  
@@ -135,7 +164,16 @@ 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");
+      }
   }
 
   /* Close error table */
@@ -162,6 +200,7 @@ error_reporting (E_ALL);
 
 /* Register error handler */
 $error_collector= "";
+$error_collector_mailto= "";
 set_error_handler('gosaRaiseError');
 
 $variables_order= "ES";