Code

Added tweaked support for umlauts
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 19 Jul 2006 13:45:12 +0000 (13:45 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 19 Jul 2006 13:45:12 +0000 (13:45 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4239 594d385d-05f5-0310-b6e9-bd551577e9d8

html/index.php
plugins/admin/systems/class_servNfs.inc
plugins/personal/environment/class_environment.inc

index c5bea796f15b49532b4aa7366a9afe170bb65c0c..0e24c6709f35392ba409aac396dcc7de25dbe501 100644 (file)
@@ -123,7 +123,7 @@ if (!is_readable(CONFIG_DIR."/gosa.conf")){
 }
 
 /* Parse configuration file */
-$config= new config(CONFIG_DIR."/gosa.conf", $BASE_DIR);
+$config= new config(CONFIG_DIR."/gosa.conf-trunk", $BASE_DIR);
 $_SESSION['DEBUGLEVEL']= $config->data['MAIN']['DEBUGLEVEL'];
 if ($_SERVER["REQUEST_METHOD"] != "POST"){
   @DEBUG (DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config");
index c695e4b632acfce004c42ce19bf3407db1d5e799..ca8b1f09d73e941fef5457c6279db7bdb79618fb 100644 (file)
@@ -32,7 +32,7 @@ class servnfs extends plugin
   {
     plugin::plugin ($config, $dn);
     
-    $this->types   = array("NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP");
+    $this->types   = array("CIFS" => "CIFS", "NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP");
     if($dn){
       $this->host = substr($dn, 3, strpos($dn, ',')-3);
     }
@@ -71,10 +71,16 @@ class servnfs extends plugin
       list($this->name, $this->description, $this->type, $this->charset,
            $this->path, $this->option, $this->volume)= split("\|",$entry."|");
       $this->is_edit          = true;
+
+      /* Decode if path is base64 */
+      if (!preg_match('%/%', $this->path)){
+        $this->path= base64_decode($this->path);
+      }
       
     }else{
       $this->attributes[] = "name";
     }
+
     
     $this->create_mount_init = $mount;
   }
@@ -181,7 +187,7 @@ class servnfs extends plugin
 
     // only 0-9a-z
     if(!$this->is_edit){
-      if(preg_match("/[^a-z0-9\.\-_]/i",$this->name)){
+      if(!preg_match("/^[a-z0-9\.\-_]+$/i",$this->name)){
         $message[]=_("Please specify a valid name for your share.");
       }
       if(empty($this->name)){
@@ -189,11 +195,11 @@ class servnfs extends plugin
       }
     }
 
-    if(preg_match("/\|/",$this->description)){
+    if(preg_match("/[^a-z0-9._+ \|-]+/i",$this->description)){
       $message[]=_("Description contains invalid characters.");
     }
 
-    if(preg_match("/\|/",$this->volume)){
+    if(preg_match("/[^a-z0-9._+ |-]/i",$this->volume)){
       $message[]=_("Volume contains invalid characters.");
     }
   
@@ -201,7 +207,11 @@ class servnfs extends plugin
       $message[]=_("Path contains invalid characters.");
     }
 
-    if(preg_match("/\|/",$this->option)){
+    if(!preg_match("%/%",$this->path)){
+      $message[]=_("Path must contain at least one slash.");
+    }
+
+    if(preg_match("/[^a-z0-9._+ \|-]/i",$this->option)){
       $message[]=_("Option contains invalid characters.");
     }
 
@@ -244,7 +254,14 @@ class servnfs extends plugin
     $s_return.= $this->description."|";     
     $s_return.= $this->type."|";     
     $s_return.= $this->charset."|";     
-    $s_return.= $this->path."|";     
+
+    /* Encode path if it contains non ascii letters */
+    $path= $this->path;
+    if (!preg_match('=^[a-z0-9+_/%-]+$=i', $path)){
+      $path= base64_encode($this->path);
+    }
+
+    $s_return.= $path."|";     
     $s_return.= $this->option."|";     
     $s_return.= $this->volume;     
 
index 3dac6a487a5d3d8f43ebf42ced057542b03cd471..86ec869e64ccb72973a34d0713d51a1accb3aa4c 100644 (file)
@@ -162,7 +162,14 @@ class environment extends plugin
         $tmp = split("\|",$share);
         $tmp2['server']      =$tmp[0];
         $tmp2['name']        =$tmp[1];
-        $tmp2['mountPoint']  =$tmp[2];
+        
+        /* Decode base64 if needed */
+        if (!preg_match('%/%', $tmp[2])){
+          $tmp2['mountPoint']  =base64_decode($tmp[2]);
+        } else {
+          $tmp2['mountPoint']  =$tmp[2];
+        }
+
         if(isset($tmp[3])){
           $tmp2['PwdHash']  =$tmp[3];
         }else{
@@ -1019,7 +1026,11 @@ class environment extends plugin
     /* Prepare Shares */
     $this->attrs['gotoShare']=array();
     foreach($this->gotoShares as $name => $share){
-      $this->attrs['gotoShare'][] =$share['server']."|".$share['name']."|".$share['mountPoint']."|".$share['PwdHash']."|".$share['Username'];
+      $mntp= $share['mountPoint'];
+      if (!preg_match('=^[a-z0-9+_/%-]+$=i', $mntp)){
+        $mntp= base64_encode($mntp);
+      }
+      $this->attrs['gotoShare'][] =$share['server']."|".$share['name']."|".$mntp."|".$share['PwdHash']."|".$share['Username'];
     }