Code

Fixed typo
[gosa.git] / include / functions.inc
index 41a4bc310df07536d16dc0e42b3196af8465b337..ddb9e1465caa15c773d0e9bd1c572256ab62065a 100644 (file)
@@ -2468,7 +2468,7 @@ function prepare4mailbody($string)
                 "/</",
                 "/>/",
                 "/\?/",
-                "/(\'|\")/");
+                "/\"/");
   
   $to = array(  
                 "%25",
@@ -2490,5 +2490,34 @@ function prepare4mailbody($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:
 ?>