Code

Updated password methods
[gosa.git] / include / class_log.inc
index e10b25ad468965d348e9cdf4904a87bbf4d68f63..d9c3565f0df6f1c8a21b4823a4ccfbe2351f4a27 100644 (file)
@@ -45,8 +45,20 @@ class log {
    */
   function log($action,$objecttype,$object,$changes_array = array(),$result = TRUE)
   {
-    $this->config = $_SESSION['config'];
-    $ui   = get_userinfo(); 
+    if(!is_array($changes_array)){
+      trigger_error("log(string,string,string,array(),bool). Forth parameter must be an array.");
+      $changes_array = array();
+    }
+
+    $entry = array(); 
+    if(!isset($_SESSION['config'])){
+      $entry['user']= "unkown";
+    }else{
+
+      $this->config = &$_SESSION['config'];
+      $ui           = get_userinfo(); 
+      $entry['user']= @$ui->dn;
+    }
 
     /* Create string out of changes */
     $changes  ="";
@@ -56,9 +68,7 @@ class log {
     $changes = preg_replace("/,$/","",$changes );
     
     /* Create data object */
-    $entry = array(); 
     $entry['timestamp'] = time();
-    $entry['user']      = @$ui->dn;
     $entry['action']    = $action;
     $entry['objecttype']= $objecttype;
     $entry['object']    = $object;
@@ -102,7 +112,7 @@ class log {
   #    $msgs[] = "Currently active user is empty.";
   #  }
 
-    if(!isset($entry['action']) || !in_array($entry['action'],array("modify","create","remove","copy","snapshot","view","security"))){
+    if(!isset($entry['action']) || !in_array($entry['action'],array("modify","create","remove","copy","snapshot","view","security","debug"))){
       $msgs[] = "Invalid option specified '".$entry['action']."'";
     }
 
@@ -133,14 +143,14 @@ class log {
     }
 
     foreach($servers as $server_name => $server){
-  
-      $con = mysql_pconnect($server_name,$server['USER'],$server['PWD']);
+      $con = @mysql_pconnect($server_name,$server['USER'],$server['PWD']);
       if(!$con){
-        print_red(sprintf(_("Could not connect to logging server %s."),$server['SERVER']));
+        print_red(sprintf(_("Could not connect to logging server %s."),$server_name));
       }else{
         $db = mysql_select_db($server['DB'],$con);
         if(!$db){
-          print_red(sprintf(_("Could not select database %s on server %s. Server ssys :%s"),$server['DB'],$server['SERVER'],mysql_error($con)));
+          print_red(sprintf(_("Could not select database %s on server %s. Server says :%s"),$server['DB'],$server['SERVER'],mysql_error($con)));
         }else{
 
           /* Create mysql syntax */
@@ -163,6 +173,7 @@ class log {
             
           } 
         }
+        mysql_close($con);
       }
     }
   }