Code

Updated Icon Menu
[gosa.git] / gosa-core / include / functions.inc
index d7921871bec4b6ff74053fbdc5b294c326fde589..8609fab62e3f2236c7a81ea923b6bf1b1e3d5542 100644 (file)
@@ -120,7 +120,7 @@ $REWRITE= array( "รค" => "ae",
  *
  *  \param  string 'class_name' The currently requested class
  */
-function __autoload($class_name) {
+function __gosa_autoload($class_name) {
     global $class_mapping, $BASE_DIR;
 
     if ($class_mapping === NULL){
@@ -135,6 +135,7 @@ function __autoload($class_name) {
       exit;
     }
 }
+spl_autoload_register('__gosa_autoload');
 
 
 /*! \brief Checks if a class is available. 
@@ -320,7 +321,7 @@ function get_template_path($filename= '', $plugin= FALSE, $path= "")
   /* Return plugin dir or root directory? */
   if ($plugin){
     if ($path == ""){
-      $nf= preg_replace("!^".$BASE_DIR."/!", "", session::global_get('plugin_dir'));
+      $nf= preg_replace("!^".$BASE_DIR."/!", "", preg_replace('/^\.\.\//', '', session::global_get('plugin_dir')));
     } else {
       $nf= preg_replace("!^".$BASE_DIR."/!", "", $path);
     }
@@ -569,7 +570,7 @@ function ldap_login_user ($username, $password)
   $allowed_attributes = array("uid","mail");
   $verify_attr = array();
   if($config->get_cfg_value("loginAttribute") != ""){
-    $tmp = split(",", $config->get_cfg_value("loginAttribute")); 
+    $tmp = explode(",", $config->get_cfg_value("loginAttribute")); 
     foreach($tmp as $attr){
       if(in_array($attr,$allowed_attributes)){
         $verify_attr[] = $attr;
@@ -1357,7 +1358,7 @@ function convert_department_dn($dn, $base = NULL)
 
 
   $dep= "";
-  foreach (split(',', $dn) as $rdn){
+  foreach (explode(',', $dn) as $rdn){
     $dep = preg_replace("/^[^=]+=/","",$rdn)."/".$dep;
   }
 
@@ -1978,7 +1979,7 @@ function normalize_netmask($netmask)
  */
 function netmask_to_bits($netmask)
 {
-  list($nm0, $nm1, $nm2, $nm3)= split('\.', $netmask);
+  list($nm0, $nm1, $nm2, $nm3)= explode('.', $netmask);
   $res= 0;
 
   for ($n= 0; $n<4; $n++){
@@ -3069,7 +3070,7 @@ function generate_smb_nt_hash($password)
     }
   }
 
-  list($lm,$nt)= split (":", trim($hash));
+  list($lm,$nt)= explode(":", trim($hash));
 
   $attrs['sambaLMPassword']= $lm;
   $attrs['sambaNTPassword']= $nt;
@@ -3470,9 +3471,9 @@ function get_next_id_traditional($attrib, $dn)
   /* get the ranges */
   $tmp = array('0'=> 1000);
   if (preg_match('/posixAccount/', $oc) && $config->get_cfg_value("uidNumberBase") != ""){
-    $tmp= split('-',$config->get_cfg_value("uidNumberBase"));
+    $tmp= explode('-',$config->get_cfg_value("uidNumberBase"));
   } elseif($config->get_cfg_value("gidNumberBase") != ""){
-    $tmp= split('-',$config->get_cfg_value("gidNumberBase"));
+    $tmp= explode('-',$config->get_cfg_value("gidNumberBase"));
   }
 
   /* Set hwm to max if not set - for backward compatibility */
@@ -3503,5 +3504,18 @@ function get_next_id_traditional($attrib, $dn)
 }
 
 
+/* Mark the occurance of a string with a span */
+function mark($needle, $haystack, $ignorecase= true)
+{
+  $result= "";
+
+  while (preg_match('/^(.*)('.preg_quote($needle).')(.*)$/i', $haystack, $matches)) {
+    $result.= $matches[1]."<span class='mark'>".$matches[2]."</span>";
+    $haystack= $matches[3];
+  }
+
+  return $result.$haystack;
+}
+
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>