Code

Added additional filter
[gosa.git] / gosa-core / include / functions.inc
index 48bf1b87130c5f83763b4f82ae0f0cff25651520..20d09e27e2d7750d3b8b21898d1a8ef0d0c789f1 100644 (file)
@@ -309,14 +309,14 @@ function gosa_log ($message)
   global $ui;
 
   /* Preset to something reasonable */
-  $username= " unauthenticated";
+  $username= "[unauthenticated]";
 
   /* Replace username if object is present */
   if (isset($ui)){
     if ($ui->username != ""){
       $username= "[$ui->username]";
     } else {
-      $username= "unknown";
+      $username= "[unknown]";
     }
   }
 
@@ -1743,7 +1743,7 @@ function gen_uids($rule, $attributes)
       $size= preg_replace('/^.*{id(:|!)(\d+)}.*$/', '\\2', $uid);
 
       $start= $m[1]==":"?0:-1;
-      for ($i= $start, $p= pow(10,$size); $i < $p; $i++){
+      for ($i= $start, $p= pow(10,$size)-1; $i < $p; $i++){
         if ($i == -1) {
           $number= "";
         } else {
@@ -1757,6 +1757,9 @@ function gen_uids($rule, $attributes)
           break;
         }
       }
+
+      /* Remove link if nothing has been found */
+      $uid= preg_replace('/{id(:|!)\d+}/', '', $uid);
     }
 
     if(preg_match('/\{id#\d+}/',$uid)){
@@ -1772,6 +1775,9 @@ function gen_uids($rule, $attributes)
           break;
         }
       }
+
+      /* Remove link if nothing has been found */
+      $uid= preg_replace('/{id#\d+}/', '', $uid);
     }
 
     /* Don't assign used ones */
@@ -2414,10 +2420,11 @@ function get_post($name)
     trigger_error("Requested POST value (".$name.") does not exists, you should add a check to prevent this message.");
     return(FALSE);
   }
+
   if(get_magic_quotes_gpc()){
-    return(stripcslashes($_POST[$name]));
+    return(stripcslashes(validate($_POST[$name])));
   }else{
-    return($_POST[$name]);
+    return(validate($_POST[$name]));
   }
 }
 
@@ -2926,7 +2933,7 @@ function get_next_id_pool($attrib) {
       msg_dialog::display(_("Error"), _("Cannot allocate a free ID:")." ".$ldap->get_error(), ERROR_DIALOG);
       return null;
     } else {
-      return $newAttr;
+      return $oldAttr;
     }
   }