Code

Added classes
[gosa.git] / include / php_setup.inc
index a27f032ddedfb989342ca5bda2c2281f0c5e7d4b..e746e41409943bfcd6a84cfe03b0fb610a45713c 100644 (file)
@@ -20,7 +20,7 @@
 
 function gosaRaiseError($errno, $errstr, $errfile, $errline)
 {
-  global $error_collector;
+  global $error_collector,$config;
 
   /* Return if error reporting is set to zero */
   if (error_reporting() == 0){
@@ -53,17 +53,27 @@ function gosaRaiseError($errno, $errstr, $errfile, $errline)
     }
   }
 
+  if((isset($config->data))){ 
+    if((isset($config->data['MAIN']['DISPLAYERRORS']))&&(!preg_match("/^true$/i",$config->data['MAIN']['DISPLAYERRORS']))){
+
+      /* Write to syslog */
+      gosa_log ("PHP error: $errstr ($errfile, line $errline)");
+      return;
+    }
+  }
+
+
   /* Create header as needed */
   if ($error_collector == ""){
     if ($_SESSION['js']==FALSE){
       $error_collector= "<div>";
     } else {
-      $error_collector= "<table width=\"100%\" style='background-color:#E0E0E0;border-bottom:1px solid black'><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:0; visibility: hidden'>";
+      $error_collector= "<table summary=\"\" width=\"100%\" style='background-color:#E0E0E0;border-bottom:1px solid black'><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:0; visibility: hidden'>";
     }
   }
  
   /* Create error header */
-  $error_collector.= "<table 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.= "<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>";
   
   /* Extract traceback data - if available */
   if (function_exists('debug_backtrace')){
@@ -96,8 +106,10 @@ function gosaRaiseError($errno, $errstr, $errfile, $errline)
         $type= "-";
       }
       $args= "";
-      foreach ($ct['args'] as $arg){
-        $args.= htmlentities("\"$arg\", ");
+      if (isset($ct['args'])){
+        foreach ($ct['args'] as $arg){
+          $args.= htmlentities("\"$arg\", ");
+        }
       }
       $args= preg_replace("/, $/", "", $args);
       if ($args == ""){
@@ -115,9 +127,6 @@ function gosaRaiseError($errno, $errstr, $errfile, $errline)
   /* Close error table */
   $error_collector.= "</table>";
 
-  /* Write to syslog */
-  gosa_log ("PHP error: $errstr ($errfile, line $errline)");
-
   /* Flush in case of fatal errors */
   if (preg_match('/^fatal/i', $errstr)){
     echo $error_collector."</div>";