Code

Updated ALL FAI classes - hopefully I havn't missed one - Will test tomorrow
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 Jul 2010 16:22:19 +0000 (16:22 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 Jul 2010 16:22:19 +0000 (16:22 +0000)
-There is no need to handle add_slashes/strip_slashes , encoding anymore.
 I've replaced all occurences by set_post and get_post and voila, it also work wioth utf9 chars.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18970 594d385d-05f5-0310-b6e9-bd551577e9d8

15 files changed:
gosa-plugins/fai/admin/fai/class_askClassName.inc
gosa-plugins/fai/admin/fai/class_debconfTemplate.inc
gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc
gosa-plugins/fai/admin/fai/class_faiHook.inc
gosa-plugins/fai/admin/fai/class_faiHookEntry.inc
gosa-plugins/fai/admin/fai/class_faiManagement.inc
gosa-plugins/fai/admin/fai/class_faiPackage.inc
gosa-plugins/fai/admin/fai/class_faiPartition.inc
gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc
gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc
gosa-plugins/fai/admin/fai/class_faiProfile.inc
gosa-plugins/fai/admin/fai/class_faiTemplate.inc
gosa-plugins/fai/admin/fai/class_faiTemplateEdit.inc
gosa-plugins/fai/admin/fai/class_faiVariable.inc
gosa-plugins/fai/admin/fai/class_faiVariableEntry.inc

index 945c0d54f4a3dd7c23e43592494a3c756580b7c3..2203198ea2d0d6688bb468eb541f80a9ab1c68c6 100644 (file)
@@ -120,14 +120,14 @@ class askClassName extends plugin
   {
     if(isset($_POST['classSelector']) && $_POST['classSelector'] == 1 
        && isset($_POST['edit_continue'])){
-      $this->ClassName          = $_POST['UseTextInputName'];
+      $this->ClassName          = get_post('UseTextInputName');
       $this->ClassAlreadyExists = true;
     }
   
     if(isset($_POST['classSelector']) && $_POST['classSelector'] == 2 
        && isset($_POST['edit_continue'])){
       $this->ClassAlreadyExists = false;
-      $this->ClassName          = $_POST['SelectedClass'];
+      $this->ClassName          = get_post('SelectedClass');
     }
   }
 
index ef20d1346adf2f91a7c01a1508c1390ef5aadbe7..f5bb9ad758bd1bfc7c9ecfab1a72e9b94b6a8711 100644 (file)
@@ -143,7 +143,7 @@ class debconf
           $str = preg_replace("/\,\ $/","",$str);
           $this->template[$post_name]['Default'] = $str;
         }else{
-          $this->template[$post_name]['Default'] = $_POST[$entry['post_name']];
+          $this->template[$post_name]['Default'] = get_post($entry['post_name']);
         }
       }
     }
@@ -263,9 +263,9 @@ class debconf
       $defs = explode(", ",$data['Default']);
       foreach($choices as $value){
         if(in_array($value,$defs)){
-          $result.="\n<input name='".$post_name."-multi-".$value."' type='checkbox' value='".htmlentities($value)."' checked>".$value."<br>";
+          $result.="\n<input name='".$post_name."-multi-".$value."' type='checkbox' value='".set_post($value)."' checked>".$value."<br>";
         }else{
-          $result.="\n<input name='".$post_name."-multi-".$value."' type='checkbox' value='".htmlentities($value)."'>".$value."<br>";
+          $result.="\n<input name='".$post_name."-multi-".$value."' type='checkbox' value='".set_post($value)."'>".$value."<br>";
         }
       }
 
@@ -321,9 +321,9 @@ class debconf
 
       foreach($choices as $value){
         if($data['Default'] == $value){
-          $result.="\n<input type='radio' name='".$post_name."' value='".htmlentities($value)."' checked >".htmlentities($value)."<br>";
+          $result.="\n<input type='radio' name='".$post_name."' value='".set_post($value)."' checked >".set_post($value)."<br>";
         }else{
-          $result.="\n<input type='radio' name='".$post_name."' value='".htmlentities($value)."'>".htmlentities($value)."<br>";
+          $result.="\n<input type='radio' name='".$post_name."' value='".set_post($value)."'>".set_post($value)."<br>";
         }
       }
 
index 3beb2426f8a9afbe5c00240b7784ad1a2cd99113..965bdb2422feacadae43688fba3099b7bfe43221 100644 (file)
@@ -177,7 +177,7 @@ class faiDiskEntry extends plugin
 
     // Remove partition from lvm compilation.
     if(isset($_POST['delLvmPartition']) && isset($_POST['physicalPartition'])){
-      $names = $_POST['physicalPartition'];
+      $names = get_post('physicalPartition');
       foreach($names as $name){
         if(isset($this->lvmDevices[$name])){
           unset($this->lvmDevices[$name]);
@@ -234,7 +234,7 @@ class faiDiskEntry extends plugin
 
     // Assign checkbox related values.
     foreach($this->attributes as $attrs){
-      $smarty->assign($attrs,$this->$attrs);
+      $smarty->assign($attrs,set_post($this->$attrs));
       if($this->$attrs){
         $smarty->assign($attrs."CHK"," ");
       }else{
@@ -249,15 +249,11 @@ class faiDiskEntry extends plugin
     $smarty->assign("fstabkeys", array("device" => _("Device"), "label" => _("Label"), "uuid" => _("UUID")));
     $smarty->assign("disklabels", array("msdos" => "MSDOS", "gpt" => "GPT"));
     $smarty->assign("fstabkey", $this->fstabkey);
-    $smarty->assign("disklabel", $this->disklabel);
+    $smarty->assign("disklabel", set_post($this->disklabel));
     $smarty->assign("FAIdiskType", $this->FAIdiskType);
     $smarty->assign("plist", $this->getPartitionList());
     $smarty->assign("physicalPartitionList", $this->getAvailablePartitions());
 
-    foreach($this->attributes as $attr){
-      $smarty->assign($attr,$this->$attr);
-    }
-
     // Assign partitions
     $tmp = $this->plInfo();
     $sacl = "";
@@ -628,10 +624,10 @@ class faiDiskEntry extends plugin
 
       // Save posted disk label and fstab key
       if (isset($_POST['disklabel']) && preg_match("/^(msdos|gpt)$/", $_POST['disklabel'])){
-        $this->disklabel= $_POST['disklabel'];
+        $this->disklabel= get_post('disklabel');
       }
       if (isset($_POST['fstabkey']) && preg_match("/^(device|label|uuid)$/", $_POST['fstabkey'])){
-        $this->fstabkey= $_POST['fstabkey'];
+        $this->fstabkey= get_post('fstabkey');
       }
     }
   }
index 7b4b5d14e0612750dcacf4bffcce73ddeb14044f..950ee0c75e7c350b5eeb53af9069f67d57d6565a 100644 (file)
@@ -114,8 +114,6 @@ class faiHook extends plugin
           $var = $ldap->get_attribute($object['dn'], $attrs,$r_array=0);
         }
 
-        /* Fix slashes */
-        $var = addslashes($var);
         $object[$attrs] = $var;
       }
     }
@@ -295,11 +293,7 @@ class faiHook extends plugin
      * If we post the escaped strings they will be escaped again
      */
     foreach($this->attributes as $attrs){
-      if(get_magic_quotes_gpc()){
-        $smarty->assign($attrs,stripslashes($this->$attrs));
-      }else{
-        $smarty->assign($attrs,($this->$attrs));
-      }
+        $smarty->assign($attrs,set_post($this->$attrs));
     }
 
     $tmp = $this->plInfo();
@@ -314,31 +308,6 @@ class faiHook extends plugin
     return($display);
   }
 
-  /* Generate listbox friendly SubObject list
-   */
-  function getList($use_dns=false){
-    $a_return=array();
-    foreach($this->SubObjects as $obj){
-      if($obj['status'] != "delete"){
-
-        $cn   = stripslashes($obj['cn']);
-        $desc = "";
-
-        if((isset($obj['description']))&&(!empty($obj['description']))){
-          $desc = " [".stripslashes($obj['description'])."]"; 
-        }
-
-        if($use_dns){
-          $a_return[$obj['cn']]['name']= $cn.$desc;
-          $a_return[$obj['cn']]['dn']= $obj['dn'];
-        }else{
-          $a_return[$obj['cn']] =  $cn.$desc;
-        }
-      }
-    }
-    return($a_return);
-  }
-
 
   /* Delete me, and all my subtrees
    */
@@ -426,7 +395,7 @@ class faiHook extends plugin
     foreach($Objects as $name => $obj){
 
       foreach($this->sub64coded as $codeIt){
-        $obj[$codeIt]=base64_encode(stripslashes($obj[$codeIt]));
+        $obj[$codeIt]=base64_encode($obj[$codeIt]);
       }
 
       $tmp = array();
@@ -436,11 +405,7 @@ class faiHook extends plugin
         if($obj[$attrs] == ""){
           $obj[$attrs] = array();
         }
-        if(!is_array($obj[$attrs])){
-          $tmp[$attrs] = stripslashes($obj[$attrs]);
-        }else{
-          $tmp[$attrs] = $obj[$attrs];
-        }
+        $tmp[$attrs] = $obj[$attrs];
       }    
 
       $tmp['objectClass'] = $this->subClasses;
@@ -533,7 +498,7 @@ class faiHook extends plugin
   {
     $vars = array("cn");
     $smarty = get_smarty();
-    $smarty->assign("cn", htmlentities($this->cn));
+    $smarty->assign("cn", set_post($this->cn));
     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
     $ret = array();
     $ret['string'] = $str;
index c6003f604db6f2dd142f79fc4995837f17a3ba01..850a07a005d0e9ff45d5edde10e7b9af68345a21 100644 (file)
@@ -64,14 +64,14 @@ class faiHookEntry extends plugin
       if(($_FILES['ImportFile']['size']==0)){
         msg_dialog::display(_("Error"), msgPool::incorrectUpload(_("file is empty")), ERROR_DIALOG);
       }else{
-        $str = utf8_encode(file_get_contents($_FILES['ImportFile']['tmp_name']));
-        $this->FAIscript = addslashes ($str);
+        $str = file_get_contents($_FILES['ImportFile']['tmp_name']);
+        $this->FAIscript = $str;
       }
     }
 
     /* File download requested */
     if(isset($_POST['download'])){
-      send_binary_content(stripslashes($this->FAIscript),$this->cn.".FAIhook");
+      send_binary_content($this->FAIscript,$this->cn.".FAIhook");
     }
 
     /* Create download button*/
@@ -94,11 +94,7 @@ class faiHookEntry extends plugin
      * If we post the escaped strings they will be escaped again
      */
     foreach($this->attributes as $attrs){
-      if(get_magic_quotes_gpc()){
-        $smarty->assign($attrs,(stripslashes($this->$attrs)));
-      }else{
-        $smarty->assign($attrs,($this->$attrs));
-      }
+        $smarty->assign($attrs,set_post($this->$attrs));
     }
 
     $tmp = $this->plInfo();
@@ -107,11 +103,7 @@ class faiHookEntry extends plugin
       $smarty->assign($name."ACL",$acl);
     }
    
-    if(get_magic_quotes_gpc()){
-      $smarty->assign("FAIscript" , htmlentities(stripslashes($this->FAIscript)));
-    }else{
-      $smarty->assign("FAIscript" , htmlentities($this->FAIscript));
-    }
+    $smarty->assign("FAIscript" , set_post($this->FAIscript));
     $smarty->assign("freeze" , preg_match("/freeze/",$this->FAIstate));
     $display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE));
     return($display);
@@ -124,7 +116,7 @@ class faiHookEntry extends plugin
       foreach($this->attributes as $attrs){
         if($this->acl_is_writeable($attrs)){
           if(isset($_POST[$attrs])){
-            $this->$attrs = $_POST[$attrs];
+            $this->$attrs = get_post($attrs);
           }else{
             $this->$attrs = "";
           }
index 0c77ef80ae04264c2df25debe86d5654214e7fe9..2ac9586db93d7bc8e0891d4766888e0cea1acdb6 100644 (file)
@@ -685,7 +685,7 @@ class faiManagement extends management
       $this->dispNewFreeze=false;
       $smarty->assign("iframe",false);
       if(isset($_POST['BranchName'])){
-        $smarty->assign("BranchName", $_POST['BranchName']);
+        $smarty->assign("BranchName", get_post('BranchName'));
       }else{
         $smarty->assign("BranchName","");
       }
@@ -708,7 +708,7 @@ class faiManagement extends management
       $this->dispNewBranch=false;
       $smarty->assign("iframe",false);
       if(isset($_POST['BranchName'])){
-        $smarty->assign("BranchName", $_POST['BranchName']);
+        $smarty->assign("BranchName", get_post('BranchName'));
       }else{
         $smarty->assign("BranchName","");
       }
index 2e17931d31e810904e9d4013624614fa293196f6..0d797a13d3f0475c6233f05d028db44efcbf8f65 100644 (file)
@@ -460,7 +460,7 @@ class faiPackage extends plugin
             $lData[$usedName] = array('data'=>
                     array(
                         $configured."&nbsp;".$removal,
-                        $usedName ,$version,htmlentities($description), $actions));
+                        $usedName ,$version,set_post($description), $actions));
         }
     }
     $this->packageList->setAcl($this->getacl("FAIpackage",preg_match('/^freeze/', $this->FAIstate)));
@@ -469,7 +469,7 @@ class faiPackage extends plugin
 
     /* Assign variables */
     foreach($this->attributes as $attrs){
-      $smarty->assign($attrs,$this->$attrs);
+      $smarty->assign($attrs,set_post($this->$attrs));
     }
     $smarty->assign( "FAIinstallMethods", $this->FAIinstallMethods );
 
@@ -805,7 +805,7 @@ class faiPackage extends plugin
   {
     $vars = array("cn");
     $smarty = get_smarty();
-    $smarty->assign("cn", htmlentities($this->cn));
+    $smarty->assign("cn", set_post($this->cn));
     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
     $ret = array();
     $ret['string'] = $str;
index 2f3999eba51dcdf82394c49b804edb3a925d014e..73f201c1c2fe4ce51f7e135b23468456b27f8379 100644 (file)
@@ -144,7 +144,7 @@ class faiPartition extends plugin
 
     // Remove partition
     if(isset($_POST['addPhysicalPartition']) && isset($_POST['physicalPartitionAdd'])){
-      $name = $_POST['physicalPartitionAdd'];
+      $name =get_post('physicalPartitionAdd');
       $this->raidDevices[$name] = array("name" => $name,"spare"=>false,"missing"=>false);     
     }
 
@@ -210,11 +210,11 @@ class faiPartition extends plugin
 
     $smarty->assign("sizeStart_Type", $this->sizeStart_Type);
     $smarty->assign("sizeStop_Type", $this->sizeStop_Type);
-    $smarty->assign("sizeStart", $this->sizeStart);
-    $smarty->assign("sizeStop", $this->sizeStop);
+    $smarty->assign("sizeStart", set_post($this->sizeStart));
+    $smarty->assign("sizeStop", set_post($this->sizeStop));
 
     $smarty->assign("preserveTypes", $preserveTypes);
-    $smarty->assign("preserveType", $this->preserveType);
+    $smarty->assign("preserveType", set_post($this->preserveType));
 
     $smarty->assign("FAIfsTypes", $FAIfsTypes);
     $smarty->assign("cn", $this->cn);
@@ -225,7 +225,7 @@ class faiPartition extends plugin
     $smarty->assign("disablePrimary", $this->disablePrimary);
 
     foreach($this->attributes as $attr){
-      $smarty->assign($attr,$this->$attr);
+      $smarty->assign($attr,set_post($this->$attr));
     }
     return($smarty->fetch(get_template_path("faiPartition.tpl", TRUE, dirname(__FILE__))));
   }
index 0665a1c6c3aaec44183bfc676451e062c79ec432..f6eff626790daee32fc690fe2d367f44ede2645b 100644 (file)
@@ -340,7 +340,7 @@ class faiPartitionTable extends plugin
     /* Assign all attributes to smarty engine
      */
     foreach($this->attributes as $attrs){
-      $smarty->assign($attrs,$this->$attrs);
+      $smarty->assign($attrs,set_post($this->$attrs));
       if($this->$attrs){
         $smarty->assign($attrs."CHK"," ");
       }else{
@@ -455,11 +455,6 @@ class faiPartitionTable extends plugin
     if(isset($_POST['FAIpartitionTablePosted'])){
       if (preg_match("/freeze/", $this->FAIstate)) return;
       plugin::save_object();
-#     foreach($this->attributes as $attrs){
-#       if(isset($_POST[$attrs])){
-#         $this->$attrs = $_POST[$attrs];
-#       }
-#     }
       if(!count($this->disks)){
         if(isset($_POST['mode'])){
           $this->FAIpartitionMethod = "setup-storage";
@@ -812,7 +807,7 @@ class faiPartitionTable extends plugin
   {
     $vars = array("cn");
     $smarty = get_smarty();
-    $smarty->assign("cn", htmlentities($this->cn));
+    $smarty->assign("cn", set_post($this->cn));
     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
     $ret = array();
     $ret['string'] = $str;
@@ -853,8 +848,6 @@ class faiPartitionTable extends plugin
           $var = $ldap->get_attribute($object['dn'], $attrs,$r_array=0);
         }
 
-        /* Fix slashes */
-        $var = addslashes($var);
         $object[$attrs] = $var;
       }
     }
index dc743d1725b331d7b56cf8f6433b83a5ce7ba079..b194beff1bb75ef6b4ab09f66bbd499d917aad67 100644 (file)
@@ -69,7 +69,7 @@ class faiPartitionTableEntry extends plugin
      * And Checkbox selection
      */
     foreach($this->attributes as $attrs){
-      $smarty->assign($attrs,$this->$attrs);
+      $smarty->assign($attrs,set_post($this->$attrs));
       if($this->$attrs){
         $smarty->assign($attrs."CHK"," ");
       }else{
@@ -117,7 +117,7 @@ class faiPartitionTableEntry extends plugin
      */
     $smarty->assign("setup", $this->generateParts());
     foreach($this->attributes as $attr){
-      $smarty->assign($attr,$this->$attr);
+      $smarty->assign($attr,set_post($this->$attr));
     }
 
     $tmp = $this->plInfo();
@@ -300,7 +300,7 @@ class faiPartitionTableEntry extends plugin
           if($this->acl_is_writeable($attrs)){
 
             if(isset($_POST[$attrs."_".$key])){
-              $this->partitions[$key][$attrs] = $_POST[$attrs."_".$key];
+              $this->partitions[$key][$attrs] = get_post($attrs."_".$key);
             }else{
               $this->partitions[$key][$attrs] = false;
             }
index 796189f15dea4e706d0fef97e6f488850b2e1f87..bb8a8ab73e2021d6f879936843192db327754282 100644 (file)
@@ -212,11 +212,7 @@ class faiProfile extends plugin
          * If we post the escaped strings they will be escaped again
          */
         foreach($this->attributes as $attrs){
-            if(get_magic_quotes_gpc()){
-                $smarty->assign($attrs,stripslashes($this->$attrs));
-            }else{
-                $smarty->assign($attrs,($this->$attrs));
-            }
+           $smarty->assign($attrs,set_post($this->$attrs));
         }
 
 
@@ -389,7 +385,7 @@ class faiProfile extends plugin
     {
         $vars = array("cn");
         $smarty = get_smarty();
-        $smarty->assign("cn", htmlentities($this->cn));
+        $smarty->assign("cn", set_post($this->cn));
         $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
         $ret = array();
         $ret['string'] = $str;
index c3c99f607c7aa757e1f472c8684a649ba9afeb34..1653586f02e44cb36ef8823de52ef0e56e493619 100644 (file)
@@ -96,7 +96,6 @@ class faiTemplate extends plugin
         if(in_array_ics($attrs,$this->sub64coded)){
           $var = base64_decode($var);
         }
-        $var = stripslashes($var);
 
         /*  check if this is a binary entry */
         if(in_array_ics($attrs,$this->subBinary)){
index 9cb844e0815d5f8e50764124f3c08b803eb05f21..dfad479570ab9f388af4c40e7f59bba8c42990c4 100644 (file)
@@ -34,7 +34,7 @@ class faiTemplateEdit extends plugin
 
     /* We now split cn/FAItemplatePath to make things more clear... */
     $smarty     = get_smarty();
-    $smarty->assign("templateValue",htmlspecialchars(($this->value)));
+    $smarty->assign("templateValue",set_post(($this->value)));
     $smarty->assign("write_protect",$this->write_protect);
     $smarty->assign("mb_extension",$this->mb_extension);
     return($smarty->fetch(get_template_path('faiTemplateEdit.tpl', TRUE)));
index 870028dba0f569ea28e8e26fbd78e228d72bae8d..ca3438e3f3879d8299ac3c95e0a03200d8047e6c 100644 (file)
@@ -203,11 +203,7 @@ class faiVariable extends plugin
      * If we post the escaped strings they will be escaped again
      */
     foreach($this->attributes as $attrs){
-      if(get_magic_quotes_gpc()){
-        $smarty->assign($attrs,htmlentities (stripslashes(utf8_decode($this->$attrs))));
-      }else{
-        $smarty->assign($attrs,htmlentities (utf8_decode($this->$attrs)));
-      }
+        $smarty->assign($attrs,set_post($this->$attrs));
     }
 
     $c_dn = $this->acl_base_for_current_object($this->dn);
@@ -421,7 +417,7 @@ class faiVariable extends plugin
   {
     $vars = array("cn");
     $smarty = get_smarty();
-    $smarty->assign("cn", htmlentities($this->cn));
+    $smarty->assign("cn", set_post($this->cn));
     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
     $ret = array();
     $ret['string'] = $str;
@@ -462,8 +458,6 @@ class faiVariable extends plugin
           $var = $ldap->get_attribute($object['dn'], $attrs,$r_array=0);
         }
 
-        /* Fix slashes */
-        $var = addslashes($var);
         $object[$attrs] = $var;
       }
     }
index dd88739559bbda247393bf731682347c82ecd506..aa3159dd9d866bf201ae33190bd8aaf73ff651a0 100644 (file)
@@ -24,7 +24,7 @@ class faiVariableEntry extends plugin
       $this->dn=$object['dn'];
       foreach($object as $name=>$value){
         $oname = $name;
-        $this->$oname=addslashes($value);
+        $this->$oname=($value);
       }
     }else{
       $this->status = "new";
@@ -45,11 +45,7 @@ class faiVariableEntry extends plugin
      * If we post the escaped strings they will be escaped again
      */
     foreach($this->attributes as $attrs){
-      if(get_magic_quotes_gpc()){
-        $smarty->assign($attrs,htmlentities (stripslashes(utf8_decode($this->$attrs))));
-      }else{
-        $smarty->assign($attrs,htmlentities (utf8_decode($this->$attrs)));
-      }
+      $smarty->assign($attrs,set_post($this->$attrs));
     }
 
     $tmp = $this->plInfo();
@@ -71,7 +67,7 @@ class faiVariableEntry extends plugin
       foreach($this->attributes as $attrs){
         if($this->acl_is_writeable($attrs)){
           if(isset($_POST[$attrs])){
-            $this->$attrs = $_POST[$attrs];
+            $this->$attrs = get_post($attrs);
           }else{
             $this->$attrs = "";
           }
@@ -109,7 +105,7 @@ class faiVariableEntry extends plugin
   {
     $tmp=array();
     foreach($this->attributes as $attrs){ 
-      $tmp[$attrs] = stripslashes( $this->$attrs);
+      $tmp[$attrs] = $this->$attrs;
     }
 
     if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){