Code

Fixed typo
[gosa.git] / include / functions.inc
index 3a1661ea4a77448910dd290e11b99c4380ccc57f..ddb9e1465caa15c773d0e9bd1c572256ab62065a 100644 (file)
@@ -1162,6 +1162,7 @@ function print_red()
                   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'].= "
@@ -1173,8 +1174,9 @@ function print_red()
                   right:0px;
                   bottom:0px;
                   z-index:0;
-                  background-image: url(images/opacity_black.png);\"
+                  background-image: url(images/opacity_black.png);\">
                </div>";
+              $hide = "hide(\"e_layer\");hide(\"e_layer2\");";
           }
 
           $_SESSION['errors'].= "
@@ -1186,7 +1188,7 @@ function print_red()
             "<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 ".
             (($_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>";
         }
 
@@ -2450,6 +2452,71 @@ 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",
+                "%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);
+}
 
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: