Code

Added new function to get available languages.
[gosa.git] / include / functions.inc
index 5ee56ebfcd37be5e75f0a07d520cf4bd08a7a0ff..ab5f5db9d9559d7c97daae9e5727480e6da31204 100644 (file)
@@ -189,6 +189,9 @@ function get_browser_language()
   if (preg_match('/zh/', $lang)){
     return ("zh_CN");
   }
+  if (preg_match('/sv/', $lang)){
+    return ("sv_SE");
+  }
 
   return (strtolower($lang)."_".strtoupper($lang));
 }
@@ -1132,28 +1135,62 @@ function print_red()
         }
       
         if(isset($_SESSION['errors']) && strlen($_SESSION['errors'])==0) {
+
+
+  if(preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])){
+
+            $_SESSION['errors'].= "
+              <iframe id='e_layer3'
+                style=\"  position:absolute;
+                          width:100%;
+                          height:100%;
+                          top:0px;
+                          left:0px;
+                          border:none;
+                          display:block;
+                          allowtransparency='true';
+                          background-color: #FFFFFF;
+                          filter:chroma(color=#FFFFFF);
+                          z-index:0; \">
+              </iframe>
+              <div  id='e_layer2'
+                style=\"
+                  position: absolute;
+                  left: 0px;
+                  top: 0px;
+                  right:0px;
+                  bottom:0px;
+                  z-index:0;
+                  width:100%;
+                  height:100%;
+                  filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='images/opacity_black.png'); \">
+              </div>";
+              $hide = "hide(\"e_layer\");hide(\"e_layer2\");hide(\"e_layer3\");";
+          }else{
+
+            $_SESSION['errors'].= "
+              <div  id='e_layer2'
+                style=\"
+                  position: absolute;
+                  left: 0px;
+                  top: 0px;
+                  right:0px;
+                  bottom:0px;
+                  z-index:0;
+                  background-image: url(images/opacity_black.png);\">
+               </div>";
+              $hide = "hide(\"e_layer\");hide(\"e_layer2\");";
+          }
+
           $_SESSION['errors'].= "
- <div  id='e_layer2'
-                style='
-                      position: absolute;
-                      left: 0px;
-                      top: 0px;
-                      right:0px;
-                      bottom:0px;
-                      z-index:149;
-                      background-image: url(images/opacity_black_75.png);
-'
->
-          </div>
           <div style='left:20%;right:20%;top:30%;".
             "background-color:white;padding:5px;border:5px solid red;z-index:150;".
             "position:absolute' id='e_layer'><table style='width:100%' summary='' border=0>".
             "<tr><td style='vertical-align:top;padding:10px'><img alt='' src='".
             get_template_path($img)."'></td>".
-            "<td style='width:100%'><h1>"._("An error occurred while processing your request").
-            "</h1><b>$string</b><br><br>$addmsg</td></tr><tr><td colspan='2' align='center'><br><button ".
+            "<td style='width:100%'><b>$string</b><br><br>$addmsg</td></tr><tr><td colspan='2' align='center'><br><button ".
             (($_SESSION['js']==FALSE)?"type='submit'":"type='button' name='error_accept'").
-            " style='width:80px' onClick='hide(\"e_layer\");hide(\"e_layer2\");'>".
+            " style='width:80px' onClick='".$hide."'>".
             _("OK")."</button></td></tr></table></div>";
         }
 
@@ -1397,9 +1434,9 @@ function print_header($image, $headline, $info= "")
     $display.= "&nbsp;";
     $display.= "</div>\n";
   }
-  if (isset($_SESSION['errors'])){
-    $display.= $_SESSION['errors'];
-  }
+#  if (isset($_SESSION['errors'])){
+#    $display.= $_SESSION['errors'];
+#  }
 
   return ($display);
 }
@@ -1677,7 +1714,7 @@ function gen_uids($rule, $attributes)
 
     if ($rule[$pos] == "}" ){
       $variables[$pos]= expand_id($part, $attributes);
-      $stripped.= "\{$pos}";
+      $stripped.= "{".$pos."}";
       $trigger= false;
       continue;
     }
@@ -2417,7 +2454,109 @@ function get_base_from_hook($dn, $attrib)
   }
 
 
+function prepare4mailbody($string)
+{
+  $string = html_entity_decode($string);
 
+  $from = array(
+                "/%/",
+                "/ /",
+                "/\n/",  
+                "/\r/",
+                "/!/",
+                "/#/",
+                "/\*/",
+                "/\//",
+                "/</",
+                "/>/",
+                "/\?/",
+                "/\&/",
+                "/\(/",
+                "/\)/",
+                "/\"/");
+  
+  $to = array(  
+                "%25",
+                "%20",
+                "%0A",
+                "%0D",
+                "%21",
+                "%23",
+                "%2A",
+                "%2F",
+                "%3C",
+                "%3E",
+                "%3F",
+                "%38",
+                "%28",
+                "%29",
+                "%22");
+
+  $string = preg_replace($from,$to,$string);
+
+  return($string);
+}
+
+
+function mac2company($mac)
+{
+  $vendor= "";
+
+  /* Generate a normailzed mac... */
+  $mac= substr(preg_replace('/[:-]/', '', $mac), 0, 6);
+
+  /* Check for existance of the oui file */
+  if (!is_readable(CONFIG_DIR."/oui.txt")){
+    return ("");
+  }
+
+  /* Open file and look for mac addresses... */
+  $handle = @fopen(CONFIG_DIR."/oui.txt", "r");
+  if ($handle) {
+    while (!feof($handle)) {
+      $line = fgets($handle, 4096);
+
+      if (preg_match("/^$mac/i", $line)){
+        $vendor= substr($line, 32);
+      }
+    }
+    fclose($handle);
+  }
+
+  return ($vendor);
+}
+
+
+function get_languages($languages_in_own_language = FALSE)
+{
+  $tmp = array(
+        "de_DE" => "German",
+        "fr_FR" => "French",
+        "it_IT" => "Italian",
+        "es_ES" => "Spanish",
+        "en_EN" => "English",
+        "nl_NL" => "Dutch",
+        "pl_PL" => "Polish",
+        "sv_SE" => "Swedish",
+        "zh_CN" => "Chinese",
+        "ru_RU" => "Russian");
+
+  $ret = array();
+  if($languages_in_own_language){
+    $old_lang = setlocale(LC_ALL, 0);
+    foreach($tmp as $key => $name){
+      $lang = $key.".UTF-8";
+      setlocale(LC_ALL, $lang);
+      $ret[$key] = _($name);
+    }
+    setlocale(LC_ALL, $old_lang);
+  }else{
+    foreach($tmp as $key => $name){
+      $ret[$key] = _($name);
+    }
+  }
+  return($ret);
+}
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>