index 121b4318a4d3f2e93fda3f41e766e18c488cea20..13c2956007036ade69e71bf3cef73de14f1d76d7 100644 (file)
var $dialog = NULL;
var $usedDNS = array();
+
+ var $orig_dn = "";
+
+ var $DNSinitially_was_account;
+
+
function servdns ($config, $dn= NULL)
{
plugin::plugin ($config, $dn);
+ $this->orig_dn = $dn;
+
/* All types with required attrs */
$this->RecordTypes['aRecord'] = "aRecord"; // ok
$this->RecordTypes['mDRecord'] = "mDRecord"; // ok
$this->RecordTypes['rRSIGRecord'] = "rRSIGRecord"; // ok
$this->RecordTypes['nSECRecord'] = "nSECRecord"; // ok
- $this->cn = $this->attrs['cn'][0];
$types = array();
/* Get all records */
$ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@))",array("*"));
while($attrs = $ldap->fetch()){
- /* If relative domainname == cn
+ /* If relative domainname
* Try to read dnsclass / TTl / zone
*/
$this->usedDNS[$attrs['dn']] = $attrs['dn'];
$this->DNSinitially_was_account = $this->is_account;
}
+
+ /* this is used to flip the ip address for example
+ 12.3.45 -> 54.3.12
+ Because some entries (like zones) are store like that 54.3.12.in-addr.arpa
+ but we want to display 12.3.45.
+ */
function FlipIp($ip)
{
$tmp = array_reverse(split("\.",$ip));
/* check posts for delete zone */
if(preg_match("/^delZone_/",$name)&&!$once){
+
+
$once =true;
$tmp = preg_replace("/^delZone_/","",$name);
$tmp = base64_decode(preg_replace("/_.*$/","",$tmp));
- unset($this->Zones[$tmp]);
+
+ $zones = $this->getUsedZoneNames();
+ $rev = $this->Zones[$tmp]['ReverseZone'];
+ $res = array_merge(($zones[$tmp]),($zones[$rev.".in-addr.arpa"]));
+
+ if(count($res)){
+ $i = 2;
+ $str ="";
+ foreach($res as $dn){
+ if($i > 0 ){
+ $i --;
+ $str.=$dn." ";
+ }
+ }
+ if(count($res)> 2) $str .=" ... ";
+ print_red(sprintf(_("Can't delete the selected zone, because it is still in use by these entry/entries '%s'"),trim($str)));
+ }else{
+ unset($this->Zones[$tmp]);
+ }
}
}
return($display);
}
+
+ /* This funtion returns all used Zonenames */
+ function getUsedZoneNames()
+ {
+ $ret = array();
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=dNSZone)(!(relativeDomainName=@))(zoneName=*))",array("zoneName","relativeDomainName","tXTRecord"));
+ while($attr = $ldap->fetch()){
+ if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){
+ $ret[$attr['zoneName'][0]][] = $attr['dn'];
+ }else{
+ $ret[$attr['zoneName'][0]][] = $attr['dn'];
+ }
+ }
+ return($ret);
+ }
+
+
/* Remove dns service */
function remove_from_parent()
{
+ if(!$this->DNSinitially_was_account){
+ return;
+ }
+
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
foreach($this->usedDNS as $dn){
$ldap->cd($dn);
$ldap->rmdir_recursive($dn);
}
+
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->orig_dn);
+ $ldap->search("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=@))",array("relativeDomainName","zoneName"));
+ while($attr = $ldap->fetch()){
+ $ldap->cd($attr['dn']);
+ $ldap->rmDir($attr['dn']);
+ }
+
+
show_ldap_error($ldap->get_error());
}
}
}
}
-
+
/* Check if there are records removed,
if there are some removed records, the append an array
to ensure that these record types are deleted
*/
if((isset($zone['Records']))&&(is_array($zone['Records']))){
foreach($zone['Records'] as $type){
- if(isset($type['inittype'])){
+ if((isset($type['inittype']))&&($type['inittype']!="")){
if($type['type'] != $type['inittype']){
$tmp[$type['inittype']] = array();
}
}
}
}
+
/* generate forward entry */
$dn = "zoneName=".$zone['zoneName'].",".$this->dn;
$tmp2[$dn] = $tmp;