Code

Removed accidentially commited translation method
[gosa.git] / gosa-core / include / functions.inc
index ed0491bd325cabd9f927c973a49f87672453bbbd..c7acab6c24524d2180e2d1ff481f6b58189ecb94 100644 (file)
@@ -73,7 +73,7 @@ define('DES3_CBC_MD5',5);
 define('DES3_CBC_SHA1',16);
 
 /* Include required files */
-require_once("class_location.inc");
+include_once("class_location.inc");
 require_once ("functions_debug.inc");
 require_once ("accept-to-gettext.inc");
 
@@ -608,7 +608,7 @@ function ldap_login_user ($username, $password)
   if($config->get_cfg_value("core","loginAttribute") != ""){
     $tmp = explode(",", $config->get_cfg_value("core","loginAttribute")); 
     foreach($tmp as $attr){
-      if(in_array($attr,$allowed_attributes)){
+      if(in_array_strict($attr,$allowed_attributes)){
         $verify_attr[] = $attr;
       }
     }
@@ -2907,9 +2907,14 @@ function change_password ($dn, $password, $mode=FALSE, $hash= "", $old_password
         $attrs= array();
         if (!$mode && !empty($tmp)){
             $attrs= generate_smb_nt_hash($password);
-            $shadow = (isset($attrs["shadowLastChange"][0]))?(int)(date("U") / 86400):0;
-            if ($shadow != 0){
-                $attrs['shadowLastChange']= $shadow;
+            if(!count($attrs) || !is_array($attrs)){
+                msg_dialog::display(_("Error"),_("Cannot generate SAMBA hash!"),ERROR_DIALOG);
+                return(FALSE);    
+            }else{
+                $shadow = (isset($attrs["shadowLastChange"][0]))?(int)(date("U") / 86400):0;
+                if ($shadow != 0){
+                    $attrs['shadowLastChange']= $shadow;
+                }
             }
         }
 
@@ -3063,7 +3068,7 @@ function generate_smb_nt_hash($password)
     $hash = $rpc->mksmbhash($password);
     if(!$rpc->success()){
         msg_dialog::display(_("Error"),msgPool::rpcError($rpc->get_error()),ERROR_DIALOG);
-        return("");
+        return(array());
     }
 
   }elseif ($config->get_cfg_value("core","gosaSupportURI") != ""){
@@ -3093,7 +3098,7 @@ function generate_smb_nt_hash($password)
 
     if ($hash == "") {
       msg_dialog::display(_("Configuration error"), sprintf(_("Generating SAMBA hash by running %s failed: check %s!"), bold($config->get_cfg_value("core",'sambaHashHook'), bold("sambaHashHook"))), ERROR_DIALOG);
-      return ("");
+      return(array());
     }
   }
 
@@ -3515,7 +3520,7 @@ function get_next_id_traditional($attrib, $dn)
     $base= get_base_from_hook($dn, $attrib);
   }
   for ($id= $base; $id++; $id < pow(2,32)){
-    if (!in_array($id, $ids)){
+    if (!in_array_strict($id, $ids)){
       return ($id);
     }
   }
@@ -3550,6 +3555,9 @@ function image($path, $action= "", $title= "", $align= "middle")
   $label= null;
 
   // Bail out, if there's no style file
+  if(!class_exists('session')){
+    return "";    
+  }
   if(!session::global_is_set("img-styles")){
 
     // Get theme
@@ -3941,7 +3949,8 @@ function gosa_fopen($filename, $mode)
 
 /*\brief    Our own in_array method which defaults to a strict mode.
  */
-function in_array_strict($needle, $haystack, $strict = TRUE){
+function in_array_strict($needle, $haystack, $strict = TRUE)
+{
     return(in_array($needle, $haystack, $strict));
 }