Code

Updated dns handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jun 2007 08:02:34 +0000 (08:02 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jun 2007 08:02:34 +0000 (08:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6712 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servDNSeditZone.inc

index 3dbfcec3a6b049d9bea13755b9fc12fd39691ff1..212a41bdc7258ca353630152549b0fba0c5e48dc 100644 (file)
@@ -105,15 +105,17 @@ class servdnseditZone extends plugin
 
     /* Detect Network class */
     if(!empty($this->ReverseZone)){
-      $addr = preg_replace("/^[^\/]+\//","",$this->ReverseZone);
-      if(preg_match("/^[0-9]*\.0\.0\.0$/",$addr)){
-        $this->NetworkClass = "A";
-      }
-      if(preg_match("/^[0-9]*\.[0-9]*\.0\.0$/",$addr)){
-        $this->NetworkClass = "B";
-      }
-      if(preg_match("/^[0-9]*\.[0-9]*\.[0-9]*\.0$/",$addr)){
-        $this->NetworkClass = "C";
+
+      $dots = count(split(".",$this->ReverseZone));
+      if($dots == 0){
+        $this->NetworkClass = "A";  
+        $this->ReverseZone .= ".0.0.0"; 
+      }elseif($dots == 1){
+        $this->NetworkClass = "B";  
+        $this->ReverseZone .= ".0.0"; 
+      }else{
+        $this->NetworkClass = "C";  
+        $this->ReverseZone .= ".0"; 
       }
     }
   }
@@ -499,7 +501,15 @@ class servdnseditZone extends plugin
       $this->Records [] = $rec;
     }
 
+  
     $ret['RECORDS'] = $this->Records; 
+    switch($this->NetworkClass){
+      case 'C' : $ret['ReverseZone']= preg_replace("/\.[0-9]*$/","",$this->ReverseZone);break;
+      case 'B' : $ret['ReverseZone']= preg_replace("/\.[0-9]*\.[0-9]*$/","",$this->ReverseZone);break;
+      case 'A' : $ret['ReverseZone']= preg_replace("/\.[0-9]*\.[0-9]*\.[0-9]*$/","",$this->ReverseZone);break;
+      default : trigger_error("Invalid network class given '".$this->NetworkClass."'");
+    }
 
     $ret['InitialReverseZone']=  $this->InitialReverseZone;
     $ret['InitialzoneName']   =  $this->InitialzoneName;