Code

Update ptr record.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Aug 2007 10:16:26 +0000 (10:16 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Aug 2007 10:16:26 +0000 (10:16 +0000)
Automatically add systems ptr record.

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

plugins/admin/systems/class_termDNS.inc

index de022df190782325ccd281775a946365edca00b5..52085344260c021228343d77ca7056f6106e7e77 100644 (file)
@@ -121,10 +121,14 @@ class termDNS extends plugin
 
       /* Remove A record which equals $this->ipHostNumber
        */
+      $ptr = $this->get_pTRRecord();
       foreach($this->dnsEntry['RECORDS'] as $key => $rec){
         if(($rec['type'] == "aRecord") && ($rec['value'] == $this->ipHostNumber)){
           unset($this->dnsEntry['RECORDS'][$key]);
         }
+        if(($rec['type'] == "pTRRecord") && ($rec['value'] == $ptr)){
+          unset($this->dnsEntry['RECORDS'][$key]);
+        }
       }
 
       /* Get Record types 
@@ -602,10 +606,10 @@ class termDNS extends plugin
        */
       if(!empty($this->ipHostNumber)){
         $this->dnsEntry['RECORDS'][] = array("type"=>"aRecord","value"=>$this->ipHostNumber);
-        $ldap->cat(getDNSZoneDN($this->config,$this->dnsEntry['zoneName']));
-        $attrs = $ldap->fetch();
-        $str = trim(preg_replace("/(^[^ ]*).*$/","\\1",$attrs['sOARecord'][0]));
-        $this->dnsEntry['RECORDS'][] = array("type"=>"nsRecord","value"=>$str);
+        $ptr = $this->get_pTRRecord();
+        if(!empty($ptr)){
+          $this->dnsEntry['RECORDS'][] = array("type"=>"pTRRecord","value"=>$ptr);
+        }
       }
 
       /* Create diff and follow instructions 
@@ -782,6 +786,24 @@ class termDNS extends plugin
   }
 
   
+  /* this function returns the default ptr record entry */
+  function get_pTRRecord()
+  {
+    if(!empty($this->ipHostNumber) && isset($this->dnsEntry['zoneName'])){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cat(getDNSZoneDN($this->config,$this->dnsEntry['zoneName']));
+      $attrs = $ldap->fetch();
+      $tmp = array_flip($this->Zones);
+      $tmp = preg_replace("/^[^\/]*+\//","",$tmp[$this->dnsEntry['zoneName']]);
+      $tmp = trim(preg_replace("/\.in-addr.arpa$/","",$tmp));
+      $ptr = preg_replace("/^".normalizePreg(FlipIp($tmp))."\./","",$this->ipHostNumber);
+      return($ptr);
+    }else{
+      return(FALSE);
+    }
+  }
+
+  
   function create_tree($arr,$base,$current = "")
   {
     $ret = array();