Code

Fixed Post Problems
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 4 May 2007 13:47:11 +0000 (13:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 4 May 2007 13:47:11 +0000 (13:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6268 594d385d-05f5-0310-b6e9-bd551577e9d8

setup/class_setup.inc
setup/class_setupStep_Config1.inc
setup/class_setupStep_Config2.inc
setup/class_setupStep_Config3.inc
setup/class_setupStep_Ldap.inc
setup/setup_ldap.tpl

index a774c50433de1fa5c51b85feecaab7ba36f5da96..ec662d910671333d27d37ce41e1a016d75936060 100644 (file)
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+
+/* Returns contents of the given POST variable and check magic quotes settings */
+function get_post($name)
+{
+  if(!isset($_POST[$name])){
+    trigger_error("Requested POST value (".$name.") does not exists, you should add a check to prevent this message.");
+    return(FALSE);
+  }
+  if(get_magic_quotes_gpc()){
+    return(stripcslashes($_POST[$name]));
+  }else{
+    return($_POST[$name]);
+  }
+}
+
 require_once("class_setupStep.inc");
 
+
 class setup 
 {
   var $i_steps  = 9;  // Number of setup steps 
index f5f0c5a56fa4f17ef870f158b994b6ff26c9c929..a1e9c0b6b664a08867b5d44f883cb68a26c0d648 100644 (file)
@@ -145,7 +145,7 @@ class Step_Config1 extends setup_step
       /* Get attributes */
       foreach($this->attributes as $attr){
         if(isset($_POST[$attr])){
-          $this->$attr = validate($_POST[$attr]);
+          $this->$attr = validate(get_post($attr));
         }
       }
 
@@ -163,7 +163,7 @@ class Step_Config1 extends setup_step
       if(isset($_POST['minid_active'])){
         $this->id_settings['minid_active'] = TRUE;
         if(isset($_POST['minid'])){
-          $this->id_settings['minid'] = $_POST['minid'];
+          $this->id_settings['minid'] = get_post('minid');
         }
       }else{
         $this->id_settings['minid_active'] = FALSE;
@@ -173,7 +173,7 @@ class Step_Config1 extends setup_step
       if(isset($_POST['idgen_active'])){
         $this->id_settings['idgen_active'] = TRUE;
         if(isset($_POST['idgen'])){
-          $this->id_settings['idgen'] = $_POST['idgen'];
+          $this->id_settings['idgen'] = get_post('idgen');
         }
       }else{
         $this->id_settings['idgen_active'] = FALSE;
@@ -183,7 +183,7 @@ class Step_Config1 extends setup_step
       if(isset($_POST['pwdiffer_active'])){
         $this->pwd_rules['pwdiffer_active'] = TRUE;
         if(isset($_POST['pwdiffer'])){
-          $this->pwd_rules['pwdiffer'] = $_POST['pwdiffer'];
+          $this->pwd_rules['pwdiffer'] = get_post('pwdiffer');
         }
       }else{
         $this->pwd_rules['pwdiffer_active'] = FALSE;
@@ -193,7 +193,7 @@ class Step_Config1 extends setup_step
       if(isset($_POST['pwminlen_active'])){
         $this->pwd_rules['pwminlen_active'] = TRUE;
         if(isset($_POST['pwminlen'])){
-          $this->pwd_rules['pwminlen'] = $_POST['pwminlen'];
+          $this->pwd_rules['pwminlen'] = get_post('pwminlen');
         }
       }else{
         $this->pwd_rules['pwminlen_active'] = FALSE;
@@ -203,7 +203,7 @@ class Step_Config1 extends setup_step
       if(isset($_POST['externalpwdhook_active'])){
         $this->pwd_rules['externalpwdhook_active'] = TRUE;
         if(isset($_POST['externalpwdhook'])){
-          $this->pwd_rules['externalpwdhook'] = $_POST['externalpwdhook'];
+          $this->pwd_rules['externalpwdhook'] = get_post('externalpwdhook');
         }
       }else{
         $this->pwd_rules['externalpwdhook_active'] = FALSE;
@@ -213,7 +213,7 @@ class Step_Config1 extends setup_step
       if(isset($_POST['base_hook_active'])){
         $this->pwd_rules['base_hook_active'] = TRUE;
         if(isset($_POST['base_hook'])){
-          $this->pwd_rules['base_hook'] = $_POST['base_hook'];
+          $this->pwd_rules['base_hook'] = get_post('base_hook');
         }
       }else{
         $this->pwd_rules['base_hook_active'] = FALSE;
index 31a430f55737b0b6c5095d4f40f73f30fe4c73c8..d238af0455f89790251f38bde337ef73bef07166 100644 (file)
@@ -140,7 +140,7 @@ class Step_Config2 extends setup_step
       /* Get attributes */
       foreach($this->attributes as $attr){
         if(isset($_POST[$attr])){
-          $this->$attr = validate($_POST[$attr]);
+          $this->$attr = validate(get_post($attr));
         }
       }
 
@@ -148,20 +148,20 @@ class Step_Config2 extends setup_step
       if(isset($_POST['vacationdir_active'])){
         $this->mail_settings['vacationdir_active'] = TRUE;
         if(isset($_POST['vacationdir'])){
-          $this->mail_settings['vacationdir'] = $_POST['vacationdir'];
+          $this->mail_settings['vacationdir'] = get_post('vacationdir');
         }
       }else{
         $this->mail_settings['vacationdir_active'] = FALSE;
       }
 
       if(isset($_POST['enableCopyPaste'])){
-        $this->generic_settings['enableCopyPaste'] = $_POST['enableCopyPaste'];
+        $this->generic_settings['enableCopyPaste'] = get_post('enableCopyPaste');
       }
 
       if(isset($_POST['wws_ou_active'])){
         $this->generic_settings['wws_ou_active'] = TRUE;
         if(isset($_POST['wws_ou'])){
-          $this->generic_settings['wws_ou'] = $_POST['wws_ou'];
+          $this->generic_settings['wws_ou'] = get_post('wws_ou');
         }
       }else{
         $this->generic_settings['wws_ou_active'] = FALSE;
@@ -170,16 +170,16 @@ class Step_Config2 extends setup_step
       if(isset($_POST['snapshot_active'])){
         $this->generic_settings['snapshot_active'] = TRUE;
         if(isset($_POST['snapshot_base'])){
-          $this->generic_settings['snapshot_base'] = $_POST['snapshot_base'];
+          $this->generic_settings['snapshot_base'] = get_post('snapshot_base');
         }
         if(isset($_POST['snapshot_user'])){
-          $this->generic_settings['snapshot_user'] = $_POST['snapshot_user'];
+          $this->generic_settings['snapshot_user'] = get_post('snapshot_user');
         }
         if(isset($_POST['snapshot_password'])){
-          $this->generic_settings['snapshot_password'] = $_POST['snapshot_password'];
+          $this->generic_settings['snapshot_password'] = get_post('snapshot_password');
         }
         if(isset($_POST['snapshot_server'])){
-          $this->generic_settings['snapshot_server'] = $_POST['snapshot_server'];
+          $this->generic_settings['snapshot_server'] = get_post('snapshot_server');
         }
       }else{
         $this->generic_settings['snapshot_active'] = FALSE;
@@ -189,7 +189,7 @@ class Step_Config2 extends setup_step
       if(isset($_POST['samba_sid_active'])){
         $this->samba_settings['samba_sid_active'] = TRUE;
         if(isset($_POST['samba_sid'])){
-          $this->samba_settings['samba_sid'] = $_POST['samba_sid'];
+          $this->samba_settings['samba_sid'] = get_post('samba_sid');
         }
       }else{
         $this->samba_settings['samba_sid_active'] = FALSE;
@@ -197,13 +197,13 @@ class Step_Config2 extends setup_step
       if(isset($_POST['samba_rid_active'])){
         $this->samba_settings['samba_rid_active'] = TRUE;
         if(isset($_POST['samba_rid'])){
-          $this->samba_settings['samba_rid'] = $_POST['samba_rid'];
+          $this->samba_settings['samba_rid'] = get_post('samba_rid');
         }
       }else{
         $this->samba_settings['samba_rid_active'] = FALSE;
       }
       if(isset($_POST['smbhash'])){
-        $this->samba_settings['smbhash'] = $_POST['smbhash'];
+        $this->samba_settings['smbhash'] = get_post('smbhash');
       }
 
       if(!$this->sambaDomain_found){
index 88828512d533612881bc5d391477174575abbc40..6140cd22a4bd78f4a55983200d014e3d29feeafb 100644 (file)
@@ -89,20 +89,20 @@ class Step_Config3 extends setup_step
       /* Get attributes */
       foreach($this->attributes as $attr){
         if(isset($_POST[$attr])){
-          $this->$attr = validate($_POST[$attr]);
+          $this->$attr = validate(get_post($attr));
         }
       }
       
       foreach(array("strict_units","noprimarygroup","forceglobals","forcessl","ldapstats","warnssl","compile","debuglevel","session_lifetime") as $name){
         if(isset($_POST[$name])){
-          $this->optional[$name] = stripslashes($_POST[$name]);
+          $this->optional[$name] = get_post($name);
         }
       } 
 
       if(isset($_POST['ppd_path_active'])){
         $this->optional['ppd_path_active'] = TRUE;
         if(isset($_POST['ppd_path'])){
-          $this->optional['ppd_path'] = $_POST['ppd_path'];
+          $this->optional['ppd_path'] = get_post('ppd_path');
         }
       }else{
         $this->optional['ppd_path_active'] = FALSE;
@@ -111,7 +111,7 @@ class Step_Config3 extends setup_step
       if(isset($_POST['max_ldap_query_time_active'])){
         $this->optional['max_ldap_query_time_active'] = TRUE;
         if(isset($_POST['max_ldap_query_time'])){
-          $this->optional['max_ldap_query_time'] = $_POST['max_ldap_query_time'];
+          $this->optional['max_ldap_query_time'] = get_post('max_ldap_query_time');
         }
       }else{
         $this->optional['max_ldap_query_time_active'] = FALSE;
@@ -120,7 +120,7 @@ class Step_Config3 extends setup_step
       if(isset($_POST['mailQueueScriptPath_active'])){
         $this->optional['mailQueueScriptPath_active'] = TRUE;
         if(isset($_POST['mailQueueScriptPath'])){
-          $this->optional['mailQueueScriptPath'] = $_POST['mailQueueScriptPath'];
+          $this->optional['mailQueueScriptPath'] = get_post('mailQueueScriptPath');
         }
       }else{
         $this->optional['mailQueueScriptPath_active'] = FALSE;
@@ -129,7 +129,7 @@ class Step_Config3 extends setup_step
       if(isset($_POST['kioskpath_active'])){
         $this->optional['kioskpath_active'] = TRUE;
         if(isset($_POST['kioskpath'])){
-          $this->optional['kioskpath'] = $_POST['kioskpath'];
+          $this->optional['kioskpath'] = get_post('kioskpath');
         }
       }else{
         $this->optional['kioskpath_active'] = FALSE;
@@ -138,7 +138,7 @@ class Step_Config3 extends setup_step
       if(isset($_POST['auto_network_hook_active'])){
         $this->optional['auto_network_hook_active'] = TRUE;
         if(isset($_POST['auto_network_hook'])){
-          $this->optional['auto_network_hook'] = $_POST['auto_network_hook'];
+          $this->optional['auto_network_hook'] = get_post('auto_network_hook');
         }
       }else{
         $this->optional['auto_network_hook_active'] = FALSE;
@@ -147,7 +147,7 @@ class Step_Config3 extends setup_step
       if(isset($_POST['notifydir_active'])){
         $this->optional['notifydir_active'] = TRUE;
         if(isset($_POST['notifydir'])){
-          $this->optional['notifydir'] = $_POST['notifydir'];
+          $this->optional['notifydir'] = get_post('notifydir');
         }
       }else{
         $this->optional['notifydir_active'] = FALSE;
index 429c4f16439b020fa68ba116ac143360c91d540d..79238f2ce50513a127911b34eaafd18defa961a2 100644 (file)
@@ -132,7 +132,7 @@ class Step_Ldap extends setup_step
   {
     foreach($this->attributes as $attr){
       if(isset($_POST[$attr])){
-        $this->$attr = $_POST[$attr];
+        $this->$attr = get_post($attr);
       }
     }
 
@@ -147,13 +147,13 @@ class Step_Ldap extends setup_step
     $this->dialog = $this->resolve_user;
  
     if(isset($_POST['resolve_filter'])){
-      $this->resolve_filter = $_POST['resolve_filter'];
+      $this->resolve_filter = get_post('resolve_filter');
     }
 
     if(isset($_POST['use_selected_user'])){
 
       if(isset($_POST['admin_to_use'])){
-        $this->admin = base64_decode($_POST['admin_to_use']);
+        $this->admin = base64_decode(get_post('admin_to_use'));
         $this->resolve_user = false;
       }
     }
index 93ec3dc6322b56181295616d6f6d80928b86894b..57b2ec93c3e15fdba73f153b66d2e82fc8271772 100644 (file)
@@ -60,7 +60,7 @@
                                        {html_options values=$namingContexts output=$namingContexts selected=$base}
                                </select>
                        {else}
-                               <input type='text' name='base_given' maxlength='80' size='40' value='{$base_given}'>
+                               <input type='text' name='base' maxlength='80' size='40' value='{$base}'>
                        {/if}
                        <input type='image' class='center' src='images/list_reload.png' title='{t}Reload{/t}' name='reload' alt='{t}Reload{/t}'>
                </div>