From: cajus Date: Thu, 17 Jan 2008 16:43:21 +0000 (+0000) Subject: Moved dns X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=74976fe9106b80befea8884b10cce32cb0d77f40;p=gosa.git Moved dns git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8479 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/systems/services/dns/class_DNS.inc b/gosa-core/plugins/admin/systems/services/dns/class_DNS.inc deleted file mode 100644 index c560c36ac..000000000 --- a/gosa-core/plugins/admin/systems/services/dns/class_DNS.inc +++ /dev/null @@ -1,686 +0,0 @@ - 45.3.12 - Because some entries (like zones) are store like that 45.3.12.in-addr.arpa - but we want to display 12.3.45. - */ - static function FlipIp($ip) - { - $tmp = array_reverse(split("\.",$ip)); - $new = ""; - foreach($tmp as $section){ - $new .= $section."."; - } - return(preg_replace("/.$/","",$new)); - } - - - /* This static function returns the zones specified for given host - */ - static function getDNSZoneEntries($config,$HostDn,$silent = false) - { - global $RecordTypes; - - $ldap = $config->get_ldap_link(); - $ldap->cd($config->current['BASE']); - - /* Not all records are allowed within a zone entry - */ - $SkipRecords = array("tXTRecord","cNAMERecord","pTRRecord"); - - /* Special sOArecords - */ - $sOAREcords = array("0"=>"sOAprimary","1"=>"sOAmail","2"=>"sOAserial","3"=>"sOArefresh","4"=>"sOAretry","5"=>"sOAexpire","6"=>"sOAttl"); - - /* Create tempalte for all fetched zone Data - */ - $ZoneBase = array(); - $ZoneBase['exists'] = false; - $ZoneBase['RECORDS'] = array(); - $ZoneBase['zoneName'] = array(); - $ZoneBase['dNSClass'] = array(); - - foreach($sOAREcords as $attr){ - $ZoneBase[$attr] = ""; - } - - $Zones = array(); - - /* Get & Parse all zone entries - */ - $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=@))",$HostDn,array("*")); - $tmp_res = array(); - while($attrs = $ldap->fetch()) { - $tmp_res[] = $attrs; - } - - /* Parse fetched zones - */ - foreach($tmp_res as $attrs){ - - $zoneName = $attrs['zoneName'][0]; - $Zones[$zoneName] = $ZoneBase; - $Zones[$zoneName]['exists'] = true; - - /* Set basic attributes - */ - foreach(array("zoneName","dNSClass") as $attr){ - if(isset($attrs[$attr][0])){ - $Zones[$zoneName][$attr] = $attrs[$attr][0]; - } - } - - /* Set initial zone name, to be able to detect if this entry was renamed - */ - $Zones[$zoneName]['InitialzoneName'] = $zoneName; - - /* Generate SOA entry - */ - if(isset($attrs['sOARecord'][0])){ - $tmp = split("\ ",$attrs['sOARecord'][0]) ; - $tmp2 = array(); - - /* Assign soa vars */ - foreach($sOAREcords as $key => $name){ - if(isset($tmp[$key])){ - $Zones[$zoneName][$name] = $tmp[$key]; - }else{ - $Zones[$zoneName][$name] = ""; - } - } - } // ENDE SOA Record - - /* Get record attributes - */ - foreach($RecordTypes as $name => $value){ - - /* Skip some attributes - */ - if(in_array($name,$SkipRecords)) continue; - - /* If there is a record attribute - */ - if(isset($attrs[$name])){ - - /* get all entries - */ - for($i = 0 ; $i < $attrs[$value]['count']; $i ++){ - $Zones[$zoneName]['RECORDS'][] = array("type"=>$name,"value"=>$attrs[$value][$i]); - } - } - } - - /* Get reverse record .. - */ - $ldap->ls("(&(objectClass=dNSZone)(relativeDomainName=@)(zoneName=*))",$attrs['dn'],array("zoneName")); - - if($ldap->count() == 0){ - if(!$silent){ - msg_dialog::display(_("Error"), sprintf(_("Cannot find reverse zone for DNS zone '%s'. Parsing zone aborted."),$zoneName), ERROR_DIALOG); - } - unset($Zones[$zoneName]); - }elseif($ldap->count()>1){ - if(!$silent){ - msg_dialog::display(_("Error"), sprintf(_("Found more than one reverse zone for '%s'. Parsing zone aborted."),$zoneName), ERROR_DIALOG); - } - unset($Zones[$zoneName]); - }else{ - $tmp = $ldap->fetch(); - $Zones[$zoneName]['ReverseZone'] = FlipIp(str_replace(".in-addr.arpa","",$tmp['zoneName'][0])); - $Zones[$zoneName]['InitialReverseZone'] = FlipIp(str_replace(".in-addr.arpa","",$tmp['zoneName'][0])); - } - } - return($Zones); - } - - - /* This static function compares two dns zone objects and returns an - * array with following indexes - * - delete, for dns which must be deleted (only if dns zone is removed) - * - rename, if a dn must be renamed, for example, the zoneName has changed - * - add, if there is a new dns account created - */ - static function getDNSZoneEntriesDiff($config,$newZones,$HostDn) - { - $oldZones = getDNSZoneEntries($config,$HostDn,true); - - $sOAattributes = array("sOAprimary","sOAmail","sOAserial","sOArefresh","sOAretry","sOAexpire","sOAttl"); - - $move = array(); - $add = array(); - $del = array(); - - /* Generate a template for zones with default values - */ - $zoneBase = array(); - $zoneBase['objectClass'] = array("top","dNSZone"); - $zoneBase['zoneName'] = ""; - $zoneBase['relativeDomainName'] = "@"; - $zoneBase['dNSClass'] = "IN"; - $zoneBase['sOARecord'] = ""; - - /* Contains all renamed zoneNames - * For zone entry udpdates - */ - $PrePareZoneEntries = array(); - - /* Walk through all zones and detect renamed/added/deleted zones ... - */ - foreach($newZones as $name => $zone){ - - /* This zone was renamed - */ - if((!empty($zone['InitialzoneName'])) && ($zone['InitialzoneName'] != $zone['zoneName'])){ - - /* Move old zone to new position - */ - $oldDn = "zoneName=".$zone['InitialzoneName'].",".$HostDn; - $newDn = "zoneName=".$zone['zoneName'].",".$HostDn; - $PrePareZoneEntries[$zone['InitialzoneName']] = $zone['zoneName']; - $move [$oldDn] = $newDn; - } - - /* Get old zone if available - */ - $oldZone=array(); - if(!empty($oldZones[$zone['InitialzoneName']])){ - $oldZone = $oldZones[$zone['InitialzoneName']]; - } - - /* Create forward zone entry and put it in our add queue - */ - $newDn = "zoneName=".$zone['zoneName'].",".$HostDn; - $obj = $zoneBase; - $obj['zoneName'] = $zone['zoneName']; - - /* Create sOARecord & add it to the obj - */ - $soa = ""; - foreach($sOAattributes as $attr){ - $soa.=" ".$zone[$attr]; - } - $obj['sOARecord'] = trim($soa); - $obj['nSRecord'] = $zone['sOAprimary']; - - /* If reverse zone was renamed, move entry - */ - if(!empty($zone['InitialReverseZone'])){ - if($zone['InitialReverseZone'] != $zone['ReverseZone']){ - $base = "zoneName=".$zone['zoneName'].",".$HostDn; - $oldRDn = "zoneName=". FlipIp($zone['InitialReverseZone']).".in-addr.arpa,".$base; - $newRDn = "zoneName=". FlipIp($zone['ReverseZone']).".in-addr.arpa,".$base; - $PrePareZoneEntries[FlipIp($zone['InitialReverseZone']).".in-addr.arpa"] = FlipIp($zone['ReverseZone']).".in-addr.arpa"; - $move [$oldRDn] = $newRDn; - } - } - - /* Append record entries - * Set old value to array, to ensure that - * they will be deleted if necessary - */ - if(isset($oldZone['RECORDS'])){ - foreach($oldZone['RECORDS'] as $rec){ - $obj[$rec['type']] = array(); - } - } - - /* Add new Records - */ - foreach($zone['RECORDS'] as $rec){ - if(!isset($obj[$rec['type']])||!is_array($obj[$rec['type']])){ - $obj[$rec['type']] = array(); - } - $obj[$rec['type']][] = $rec['value']; - } - - /* Append udpated Zone Forward Entry to our add queue - */ - $add[$newDn] = $obj; - - /* Create Reverse Entry - * And append it to our add queue - */ - $zone['ReverseZone'] = FlipIp($zone['ReverseZone']).".in-addr.arpa"; - $base = "zoneName=".$zone['zoneName'].",".$HostDn; - $newRDn = "zoneName=".$zone['ReverseZone'].",".$base; - $rObj = $obj; - $rObj['zoneName']= $zone['ReverseZone']; - $add[$newRDn] = $rObj; - - /* Remove currently managed zone from oldZones. - * this gives us the ability to detect removed zones - */ - if(isset($oldZones[$zone['InitialzoneName']])){ - unset($oldZones[$zone['InitialzoneName']]); - } - } - - /* The rest of our oldZones must be deleted - * because they are no longer available in newZones anymore. - */ - foreach($oldZones as $zone) { - $oldDn = "zoneName=".$zone['InitialzoneName'].",".$HostDn; - $del[$oldDn] = $zone; - } - - /* Check for entries which must be updated - */ - $zoneUpdates = array(); - $udpate = array(); - if(count($PrePareZoneEntries)){ - $ldap = $config->get_ldap_link(); - foreach($PrePareZoneEntries as $FromZoneName => $ToZoneName){ - $ldap->cd($HostDn); - $ldap->search("(&(objectClass=dNSZone)(zoneName=".$FromZoneName.")(!(relativeDomainName=@)))",array("zoneName")); - while($attrs = $ldap->fetch()){ - $zoneUpdates[$attrs['dn']] = array("zoneName"=>$ToZoneName); - } - } - } - - $ret = array("del" => $del , "move" => $move , "add" => $add,"zoneUpdates"=>$zoneUpdates); - return($ret); - } - - - /* This static function returns the dns-host eintries for given - * name. - */ - static function getDNSHostEntries($config,$name,$silent = false) - { - global $RecordTypes; - - $types = array(); - $ret = array(); - $ret['RECORDS'] = array(); - $ret['dNSClass'] = "IN"; - $ret['zoneName'] = ""; - $ret['dNSTTL'] = "7440"; - $ret['exists'] = false; - - $ldap = $config->get_ldap_link(); - $ldap->cd($config->current['BASE']); - - /* First check all zones for an entry with the given name. - * If the name occurs in more than one entry alert the user ... - */ - $foundIn = array(); - $zones = DNS::getAvailableZones($config); - - $zonesArr = array(); - foreach($zones as $zoneMix){ - $zoneIndex = split("/",$zoneMix); - if(!array_key_exists($zoneIndex[0],$zonesArr)) { - $zonesArr[$zoneIndex[0]] = array(); - } - array_push($zonesArr[$zoneIndex[0]],$zoneIndex[1]); - } - - foreach($zonesArr as $nameServer => $nameServerArr){ - $foundInTmp = array(); - foreach($nameServerArr as $zoneArr => $zone){ - $zoneMix = $nameServer."/".$zone; - $zoneDn = DNS::getDNSZoneDN($config,$zoneMix); - $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=".$name.")(!(relativeDomainName=@)))", $zoneDn,$attrs = array("*")); - while($attrs = $ldap->fetch()){ - $foundInTmp [$zoneMix] = $attrs['dn']; - $foundIn [$zoneMix] = $attrs['dn']; - } - } - } - - /* No zone found which contains an entry for us - */ - if(count($foundIn) == 0){ - return($ret); - } - - /* Get host informations from zone - */ - $id_tmp = key($foundIn); - $ldap->cd($foundIn[$id_tmp]); - $ldap->search("(&(objectClass=dNSZone)(zoneName=*)(!(relativeDomainName=@)))",array("*")); - while($attrs = $ldap->fetch()){ - - /* If relative domainname == cn - * Try to read dnsclass / TTl / zone - */ - if($attrs['relativeDomainName'][0] == $name){ - $ret['exists'] = true; - $ret['zoneName'] = $id_tmp; - foreach(array("dNSClass","dNSTTL") as $atr){ - if(isset($attrs[$atr][0])){ - $ret[$atr] = $attrs[$atr][0]; - } - } - } - - /* Create list with all used records */ - foreach($RecordTypes as $name => $value){ - - /* If there is a record attribute */ - if(isset($attrs[$name])){ - - /* get all entries */ - for($i = 0 ; $i < $attrs[$value]['count']; $i ++){ - $types[] = array( "type" => $name, - "value" => $attrs[$value][$i]); - } - } - } - $ret['RECORDS'] = $types; - } - return($ret); - } - - - - /* This static function compares two dns settings and returns an - * array with following indexes - * - delete, for dns which must be deleted (only if dns account is removed) - * - rename, if a dn must be renamed, for example, the relativeDomainName has changed - * - add, if there is a new dns account created - */ - static function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName) - { - global $RecordTypes; - - $oldEntry = getDNSHostEntries($config,$oldName); - - $add = array(); - $del = array(); - $move = array(); - - /* Don't go further if there is nothing to do - * Is no account / was no account - */ - if(($newEntry['exists'] == false )&& ($oldEntry['exists'] == false)){ - return(array("move"=>$move,"add"=>$add,"del"=>$del)); - } - - $zones = DNS::getAvailableZones($config); - $specialAttributes = array("cNAMERecord","pTRRecord"); - $newRecords = array(); // Used to remember which records are removed - $zoneNameMix = $newEntry['zoneName']; - $zoneDn = DNS::getDNSZoneDN($config,$zoneNameMix); - $tmp = array_flip($zones); - $zoneName = DNS::getNameFromMix($zoneNameMix); - - /* If reverseZone can't be resolved ... this - * can't be a valid entry, so remove this account - */ - if(isset($tmp[$zoneNameMix])){ - $reverseNameMix = $tmp[$zoneNameMix]; - $reverseDn = DNS::getDNSZoneDN($config,$reverseNameMix); - if(empty($reverseDn)){ - $newEntry['exists'] = false; - } - }else{ - $newEntry['exists'] = false; - } - - /* If account was edited prepare some - * attributes & arrays ... if required add some - * dns to $move - */ - if($oldEntry['exists']){ - - /* Check if the account was removed - */ - if($newEntry['exists'] == false){ - $dn = "relativeDomainName=".$oldName.",".DNS::getDNSZoneDN($config,$oldEntry['zoneName']); - $del[$dn] =""; - return(array("move"=>$move,"add"=>$add,"del"=>$del)); - } - - /* Check if zoneName has changed - */ - if(count($newEntry['RECORDS'])){ - if($oldEntry['zoneName'] != $newEntry['zoneName']){ - $oldzoneDn = DNS::getDNSZoneDN($config,$oldEntry['zoneName']); - $dn = "relativeDomainName=".$oldName.",".$oldzoneDn; - $dn2= "relativeDomainName=".$oldName.",".$zoneDn; - $move[$dn]=$dn2; - } - - /* Check if host name has changed - */ - if($oldName != $newName){ - $dn = "relativeDomainName=".$oldName.",".$zoneDn; - $dn2= "relativeDomainName=".$newName.",".$zoneDn; - $move[$dn]=$dn2; - $dn = "relativeDomainName=".$oldName.",".$dn2; - $dn2= "relativeDomainName=".$newName.",".$dn2; - $move[$dn]=$dn2; - } - } - - /* Prepare record entries - * Fill old records with array(); - * To ensure that they will be deleted if they stay unused - */ - foreach($oldEntry['RECORDS'] as $id => $rec){ - $newRecords[$rec['type']] = array(); - } - } - - /* There must be at least one record in our entry - */ - if((!count($newEntry['RECORDS'])) || (!$newEntry['exists'])){ - $dn = "relativeDomainName=".$newName.",".DNS::getDNSZoneDN($config,$oldEntry['zoneName']); - $del[$dn] =""; - $ret = array("move"=>$move,"add"=>$add,"del"=>$del); - return($ret); - } - - /* Prepare temp obj - */ - $baseObj = array(); - $baseObj['objectClass'] = array("top","dNSZone"); - $baseObj['dNSTTL'] = $newEntry['dNSTTL']; - $baseObj['dNSClass'] = $newEntry['dNSClass']; - $baseObj['zoneName'] = $zoneName; - $baseObj['relativeDomainName']= $newName; - - /* Add Container Object to zone - * (this possibly already exists, check this before writing to ldap) - */ - $baseDn = "relativeDomainName=".$newName.",".$zoneDn; - $add[$baseDn] = $baseObj; - - /* Add base obejct which contains all std records - */ - $stdDn = "relativeDomainName=".$newName.",".$baseDn; - $add[$stdDn] = $baseObj; - - /* Set defaults. Normaly only contains old record names. - * The old names will be set to array, to ensure that they will be deleted. - * Or overwritten and filled with new values. - */ - foreach($newRecords as $name => $def){ - if(!in_array($name,$specialAttributes)){ - $add[$stdDn][$name] = $def; - } - } - - /* Delete all OLD special attributes. - */ - foreach($oldEntry['RECORDS'] as $id => $rec){ - if(in_array($rec['type'],$specialAttributes)){ - $deldn= "relativeDomainName=".$rec['value'].",".$baseDn; - $del[$deldn] = ""; - } - } - - - /* Create new record entries - */ - foreach($newEntry['RECORDS'] as $id => $rec){ - /* Create object which contains special records - * like pTRRecord or CNAMERecord - */ - if($rec['type'] == "pTRRecord"){ - $PTRdn= "relativeDomainName=".DNS::FlipIP($rec['value']).",".$baseDn; - $ptrObj = $baseObj; - $reverseName = DNS::getNameFromMix($reverseNameMix); - $ptrObj['zoneName'] = $reverseName; - if(!preg_match("/\.$/",$newName)){ - $ptrObj['pTRRecord'] = preg_replace("/\.\.$/",".",$newName.".".$zoneName."."); - }else{ - $ptrObj['pTRRecord'] = preg_replace("/\.\.$/",".",$newName."."); - } - $ptrObj['relativeDomainName'] = DNS::FlipIP($rec['value']); - - $add[$PTRdn] = $ptrObj; - }else - if($rec['type'] == "cNAMERecord"){ - $PTRdn= "relativeDomainName=".$rec['value'].",".$baseDn; - $ptrObj = $baseObj; - $ptrObj['zoneName'] = $zoneName; - $ptrObj['cNAMERecord'] = $newName; - $ptrObj['relativeDomainName'] = $rec['value']; - - $add[$PTRdn] = $ptrObj; - }else{ - /* Append basic attributes - */ - $add[$stdDn][$rec['type']][] = $rec['value']; - } - } // foreach record - - $ret = array("move"=>$move,"add"=>$add,"del"=>$del); - return($ret); - } - - static function getNameFromMix($zoneMix){ - $ret = ""; - if(!strstr($zoneMix, '/')) return($ret); - $zoneIndex = split("/",$zoneMix); - return($zoneIndex[1]); - } - - /* returns the dn for a specified zone - */ - static function getDNSZoneDN($config,$zoneNameMix) - { - $ret = ""; - if(!strstr($zoneNameMix, '/')) { - msg_dialog::display(_("Error"), sprintf(_("Undefined zone name '%s'!"),$zoneNameMix), ERROR_DIALOG); - return($ret); - } - - $zoneNameIndex = split("/",$zoneNameMix); - $zoneName = $zoneNameIndex[1]; - $nameServer = strtolower($zoneNameIndex[0]); - $ldap = $config->get_ldap_link(); - - /* search for the nameserver */ - $ldap-> cd($config->current['BASE']); - $ldap->search("(&(objectClass=goServer)(cn=".$nameServer."))",array("cn")); - if($ldap->count()){ - $attr = $ldap->fetch(); - } else { - return($ret); - } - - $ldap-> cd($attr['dn']); - $ldap->search("(&(objectClass=dNSZone)(sOARecord=*)(zoneName=".$zoneName."))",array("zoneName")); - if($ldap->count()){ - $attr = $ldap->fetch(); - return($attr['dn']); - } - - return($ret); - } - - - /* returns all available zones - * array[reverseName] = zoneName; - */ - static function getAvailableZones($config) - { - $ret = array(); - $ldap = $config->get_ldap_link(); - $ldap->cd ($config->current['BASE']); - - /* Search for zones ... - */ - $ldap->search("(&(objectClass=dNSZone)(sOARecord=*))",array("zoneName")); - - $ForwardZones = array(); - $ReverseZones = array(); - $zones = array(); - - while($at = $ldap->fetch()){ - if(preg_match("/\.in\-addr\.arpa/",$at['zoneName'][0])){ - $ReverseZones[$at['dn']] = $at; - }else{ - $ForwardZones[$at['dn']] = $at; - } - } - - foreach($ForwardZones as $dn => $obj){ - - /* try to find reverse - */ - foreach($ReverseZones as $Rdn => $Robj ){ - if(preg_match("/".$dn."/",$Rdn)){ - $zones[strtoupper($ldap->getCn($dn))."/".$Robj['zoneName'][0]] = - strtoupper($ldap->getCn($dn))."/".$obj['zoneName'][0]; - } - } - } - return($zones); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/admin/systems/services/dns/class_servDNS.inc b/gosa-core/plugins/admin/systems/services/dns/class_servDNS.inc deleted file mode 100644 index 9890931ea..000000000 --- a/gosa-core/plugins/admin/systems/services/dns/class_servDNS.inc +++ /dev/null @@ -1,598 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = FALSE; - var $attributes = array(); - var $objectclasses = array("whatever"); - - var $RecordTypes = array(); - var $Zones = array(); - - var $orig_dn = ""; - - var $initially_was_account; - - /* ServerService tab vars */ - var $conflicts = array("servdns"); - var $DisplayName = ""; - var $StatusFlag = ""; - var $view_logged = FALSE; - - var $dns_server_list = array("ENTRIES"=> array(),"FOR_LIST"=> array()); - var $take_over_id = -1; - - - function servdns (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - $this->DisplayName = _("DNS service"); - - $this->orig_dn = $dn; - - /* Get record types for zones - */ - $this->RecordTypes = DNS::getDnsRecordTypes(true); - - /* Get all zone Informations - */ - $this->Zones = DNS::getDNSZoneEntries($config,$dn); - - /* If there is at least one entry in this -> types, we have DNS enabled - */ - if(count($this->Zones) == 0){ - $this->is_account = false; - $this->dns_server_list = $this->get_list_of_dns_servers(); - }else{ - $this->is_account = true; - } - $this->initially_was_account = $this->is_account; - } - - - function get_list_of_dns_servers() - { - $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array()); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=dNSZone)(zoneName=*))",array("dn","zoneName")); - $dns = array(); - while($attrs = $ldap->fetch()){ - /* Skip own config */ - if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){ - continue; - } - $dn = preg_replace("/^zoneName=[^,]+,/","",$attrs['dn']); - if(preg_match("/^cn=/",$dn) && !in_array($dn,$dns)){ - $dns[] = $dn; - } - } - $i = 0; - foreach($dns as $dn){ - $ldap->cat($dn,array('*')); - if($ldap->count()){ - $i ++; - $attrs = $ldap->fetch(); - $ret['ENTRIES'][$i] = $attrs; - $ret['FOR_LIST'][$i] = $attrs['cn'][0]; - } - } - return($ret); - } - - - function get_dns_info_string($id) - { - $ret=""; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->dns_server_list['ENTRIES'][$id]['dn']); - $ldap->search("(|(zoneName=*)(relativeDomainName=*))",array("dn")); - while($attrs = $ldap->fetch()){ - $ret .= $attrs['dn']."\n"; - } - return($ret); - } - - - function execute() - { - /* Call parent execute - */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /* Fill templating stuff - */ - $smarty= get_smarty(); - $smarty->assign("dns_take_over",FALSE); - $smarty->assign("is_createable",$this->acl_is_createable()); - $display= ""; - - - $this->initially_was_account= $this->is_account; - /*****************/ - /* Handle Take Over Actions - /*****************/ - - /* Give smarty the required informations */ - $smarty->assign("dns_server_list", $this->dns_server_list['FOR_LIST']); - $smarty->assign("dns_server_list_cnt", count($this->dns_server_list['FOR_LIST'])); - - /* Take over requested, save id */ - if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){ - $id = $_POST['take_over_src']; - if(isset($this->dns_server_list['ENTRIES'][$id])){ - $this->take_over_id = $id; - } - } - - /* Abort take over action */ - if(isset($_POST['cancel_take_over'])){ - $this->dialog =false; - $this->take_over_id = -1; - $this->dns_server_list = $this->get_list_of_dns_servers(); - } - - /* Display informartion about take over that will be started when saving this server - * and hide default dns output - */ - if($this->take_over_id != -1){ - $this->dialog = FALSE; - $id = $this->take_over_id; - $info = $this->get_dns_info_string($id); - $smarty->assign("dns_take_over",TRUE); - $smarty->assign("info",$info); - $warning = sprintf(_("You are going to migrate the DNS setup from server '%s'."),$this->dns_server_list['ENTRIES'][$id]['cn'][0]); - $warning2 = _("The migration will be startet when you save this system. To cancel this action, use the cancel button below."); - $smarty->assign("warning",$warning); - $smarty->assign("warning2",$warning2); - return($smarty->fetch(get_template_path('servdns.tpl', TRUE))); - } - - - /* Do we need to flip is_account state? - */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove DNS service"), - _("This server has DNS features enabled. You can disable them by clicking below.")); - } else { - $display= $this->show_enable_header(_("Add DNS service"), - _("This server has DNS features disabled. You can enable them by clicking below.")); - return ($display); - } - - - /* Edited or Added zone - */ - if(isset($_POST['SaveZoneChanges'])){ - $this->dialog->save_object(); - - /* Check for errors - */ - if(count($this->dialog->check())){ - foreach($this->dialog->check() as $msgs){ - print_red($msgs); - } - }else{ - /* add new/edited zone - */ - $ret = $this->dialog->save(); - if(!$this->dialog->isNew){ - unset($this->Zones[$this->dialog->OldZoneName]); - } - $this->Zones[$ret['zoneName']] = $ret; - $this->dialog = FALSE; - } - } - - /* Cancel zone edit / new - */ - if(isset($_POST['CancelZoneChanges'])){ - $this->dialog = FALSE; - } - - /* Add empty new zone - */ - if(isset($_POST['AddZone'])){ - $this->dialog = new servdnseditZone($this->config,$this->dn); - } - - /* Check for edit zone request - */ - $once = false; - foreach( $_POST as $name => $value){ - - /* check all post for edit request - */ - if(preg_match("/^editZone_/",$name)&&!$once){ - $once =true; - $tmp = preg_replace("/^editZone_/","",$name); - $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); - $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$tmp]); - } - - /* check posts for delete zone - */ - if(preg_match("/^delZone_/",$name)&&!$once){ - - $once =true; - $tmp = preg_replace("/^delZone_/","",$name); - $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); - - /* Initiate deletion - */ - $this->RemoveZone($tmp); - } - } - - if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){ - $id = base64_decode($_GET['id']); - if(isset($this->Zones[$id])){ - $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]); - } - } - - if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){ - $id = base64_decode($_GET['id']); - if(isset($this->Zones[$id])){ - $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]); - } - } - - /* Show dialog - */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - $this->dialog->parent = $this; - return($this->dialog->execute()); - } - - /* Create Listbox with existing Zones - */ - $ZoneList = new divSelectBox("dNSZones"); - $ZoneList -> SetHeight(254); - - /* Add entries to divlist - */ - $editImg = ""; - if($this->acl_is_removeable()){ - $editImg.= ""; - } - - $link = "%s"; - foreach($this->Zones as $zone => $values ){ - $ZoneList->AddEntry(array( - array("string" => sprintf($link,base64_encode($zone),($zone))), - array("string" => sprintf($link,base64_encode($zone),_("Reverse zone")." : ".($values['ReverseZone']))), - array("string" => _("TTL")." : ".$values['sOAttl']), - array("string" => _("Class")." : ".$values['dNSClass']), - array("string" =>str_replace("%s",base64_encode($zone),$editImg)) - )); - } - - /* Display tempalte - */ - $smarty->assign("ZoneList",$ZoneList->DrawList()); - $display.= $smarty->fetch(get_template_path('servdns.tpl', TRUE)); - return($display); - } - - - /* Delete specified zone - */ - function RemoveZone($id) - { - $zones = $this->getUsedZoneNames(); - - if(isset($this->Zones[$id]['InitialReverseZone'])){ - $rev = DNS::FlipIp($this->Zones[$id]['InitialReverseZone']); - }else{ - $rev = DNS::FlipIp($this->Zones[$id]['ReverseZone']); - } - - $zonename = ""; - if(isset($this->Zones[$id]['InitialzoneName'])){ - $zonename= $this->Zones[$id]['InitialzoneName']; - } - - $used = array(); - - /* Add Records which use this zoneName - */ - if(isset($zones[$zonename])){ - $used = array_merge($used,$zones[$zonename]); - } - - /* Add Records which uses this reverse zone - */ - if(isset($zones[$rev.".in-addr.arpa"])){ - $used = array_merge($used,$zones[$rev.".in-addr.arpa"]); - } - - /* There are still entries using this configuration - * Abort deletion - */ - if(count($used)){ - $i = 2; - $str =""; - foreach($used as $dn){ - if($i > 0 && !preg_match("/,relativeDomainName=/",$dn)){ - $i --; - $name = preg_replace("/^[^=]+=([^,]*),.*$/","\\1",$dn); - $zone = preg_replace("/^.*zoneName=([^,]*),.*$/","\\1",$dn); - $str.= $name.".".$zone." "; - } - } - - /* Only show 2 dns in the error message - */ - if(count($used)> 2) { - $str .=" ... "; - } - print_red(sprintf(_("Can't delete the selected zone, because it is still in use by these entry/entries '%s'"),trim($str))); - return(false); - }else{ - unset($this->Zones[$id]); - return(true); - } - } - - - /* 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")); - while($attr = $ldap->fetch()){ - $ret[$attr['zoneName'][0]][] = $attr['dn']; - } - return($ret); - } - - - /* Remove dns service - */ - function remove_from_parent() - { - if($this->initially_was_account){ - $bool = true; - $this->is_account = FALSE; - foreach($this->Zones as $key => $zone){ - $bool= $bool & $this->RemoveZone($key); - } - - if($bool){ - $this->save(); - } - return($bool); - } - } - - - /* Save to LDAP */ - function save() - { - - /* Take over handling - * - Create list of zones managed by source server - * - Copy ldap entries to destination server - * - Remove old zone entries from source - */ - if($this->take_over_id != -1){ - $del = array(); - $id = $this->take_over_id; - $src = $this->dns_server_list['ENTRIES'][$id]['dn']; - $ldap = $this->config->get_ldap_link(); - $ldap->ls("(objectClass=dnsZone)",$src,array('cn')); - while($attrs = $ldap->fetch()){ - $src_zone = $attrs['dn']; - $dst_zone = preg_replace("/".normalizePreg($src)."$/",$this->dn,$src_zone); - $res = plugin::recursive_move($src_zone, $dst_zone); - - if($res){ - $del [] = $src_zone; - } - } - foreach($del as $src_zone){ - $ldap->rmdir_recursive($src_zone); - } - return; - } - - /* Save zone editor changes now */ - foreach($this->Zones as $name => $zone){ - if(isset($zone['zoneEditor'] ) && $zone['zoneEditor'] != NULL && is_object($zone['zoneEditor'])){ - $zone['zoneEditor']->save(); - unset($this->Zones[$name]['zoneEditor']);; - } - } - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - /* Get differences - */ - $old_dn = $this->orig_dn; - if($old_dn == "new"){ - $old_dn = $this->dn; - } - - $tmp = DNS::getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn); - - /* Update dns to current object dn */ - $tmp = DNS::getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn); - $tmp2 = array(); - foreach($tmp as $key1 => $data1){ - $tmp2[$key1] = array(); - foreach($data1 as $key2 => $data2){ - $tmp2[$key1][preg_replace("/".normalizePreg($old_dn)."$/",$this->dn,$key2)] = $data2; - } - } - $tmp = $tmp2; - - /* Updated zone entries if reverser or forward name has changed - * Must be done before moving entries, else the given dn is invalid - */ - if(isset($tmp['zoneUpdates'])){ - foreach($tmp['zoneUpdates'] as $dn => $attrs){ - $ldap->cd($dn); - $ldap->modify($attrs); - new log("modfiy","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Updating of system server/dns with dn '%s' failed."),$this->dn)); - } - } - - /* Delete dns - */ - foreach($tmp['del'] as $dn => $del){ - - $for = $del['InitialzoneName']; - $rev = DNS::FlipIp($del['InitialReverseZone']).".in-addr.arpa"; - - $ldap->cd($dn); - $ldap->rmdir_recursive($dn); - new log("remove","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/dns with dn '%s' failed."),$this->dn)); - - /* Handle Post events */ - if(preg_match("/^zoneName=/",$dn)){ -# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $for)); -# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $rev)); - } - } - - /* move follwoing entries - */ - foreach($tmp['move'] as $src => $dst){ - $this->recursive_move($src,$dst); - } - - /* Add || Update new DNS entries - */ - foreach($tmp['add'] as $dn => $attrs){ - $ldap->cd($dn); - $ldap->cat($dn, array('dn')); - if($ldap->fetch()){ - $ldap->cd($dn); - $ldap->modify ($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn)); - - /* Handle Post events */ - if(preg_match("/^zoneName=/",$dn)){ -# $this->handle_post_events("modify",array("dn" => $dn,"zoneName" => $attrs['zoneName'])); - } - }else{ - $ldap->cd($dn); - $ldap->add($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn)); - - /* Handle Post events */ - if(preg_match("/^zoneName=/",$dn)){ -# $this->handle_post_events("add",array("dn" => $dn,"zoneName" => $attrs['zoneName'])); - } - } - } - $this->handle_post_events("modify"); - } - - - /* Directly save new status flag */ - function setStatus($value) - { - if($value == "none") return; - if(!$this->initially_was_account) return; - if(empty($this->StatusFlag)) return; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - - $tmp = $ldap->fetch(); - for($i = 0; $i < $tmp['objectClass']['count']; $i ++){ - $attrs['objectClass'][] = $tmp['objectClass'][$i]; - } - $flag = $this->StatusFlag; - $attrs[$flag] = $value; - $this->$flag = $value; - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for system server/dns with dn '%s' failed."),$this->dn)); - $this->action_hook(); - } - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("DNS service"); - $fields['AllowEdit'] = true; - return($fields); - } - - - /* Get updates for status flag */ - function updateStatusState() - { - if(empty($this->StatusFlag)) return; - - $attrs = array(); - $flag = $this->StatusFlag; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->cn); - $ldap->cat($this->dn,array($flag)); - if($ldap->count()){ - $attrs = $ldap->fetch(); - } - if(isset($attrs[$flag][0])){ - $this->$flag = $attrs[$flag][0]; - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("DNS service"), - "plDescription" => _("DNS service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 83, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "zoneName" =>_("Zone name"), - "ReverseZone" =>_("Reverse zone"), - "sOAprimary" =>_("Primary dns server"), - "sOAmail" =>_("Mail address"), - "sOAserial" =>_("Serial"), - "sOArefresh" =>_("Refresh"), - "sOAretry" =>_("Retry"), - "sOAexpire" =>_("Expire"), - "sOAttl" =>_("TTL"), - "zoneRecords" =>_("Zone records")) - )); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZone.inc b/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZone.inc deleted file mode 100644 index 6ccbade69..000000000 --- a/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZone.inc +++ /dev/null @@ -1,603 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("zoneName","ReverseZone","dNSClass", - "sOAprimary","sOAmail","sOAserial","sOArefresh","sOAretry","sOAexpire","sOAttl"); - var $objectclasses = array("whatever"); - - var $RecordTypes = array(); - - var $ReverseZone = ""; - var $zoneName = ""; - var $dNSClass = "IN"; - - var $sOAprimary = ""; - var $sOAmail = ""; - var $sOAserial = ""; - var $sOArefresh = "3600"; - var $sOAretry = "1800"; - var $sOAexpire = "720000"; - var $sOAttl = "6400"; - - var $Records = array(); - var $mXRecords = array(); - - var $OldZoneName = ""; // To detect changes made with this edit - var $OldReverseZone = ""; - - var $InitialReverseZone = ""; - var $InitialzoneName = ""; - var $NetworkClass = "A" ; // One out of A,B,C - - var $dialog = false; - - var $zoneEditor = NULL; - - var $isNew = true; - - var $ZoneObject = array(); - - function servdnseditZone (&$config, $dn= NULL,$attrs = array()) - { - plugin::plugin ($config, $dn); - - /* All types with required attrs */ - $this->RecordTypes = DNS::getDnsRecordTypes(true); - - if(!count($attrs)){ - $this->OldZoneName = ""; - $this->OldReverseZone = ""; - $this->isNew = true; - $this->sOAserial = date("Ymd")."1"; - - $this->InitialzoneName = "";//$attrs['InitialzoneName']; - $this->InitialReverseZone = "";//$attrs['InitialReverseZone']; - }else{ - $this->ZoneObject = $attrs; - - if(isset($attrs['zoneEditor'])){ - $this->zoneEditor = $attrs['zoneEditor']; - } - $this->OldZoneName = $attrs['zoneName']; - $this->OldReverseZone = $attrs['ReverseZone']; - - $this->InitialzoneName = $attrs['InitialzoneName']; - $this->InitialReverseZone = $attrs['InitialReverseZone']; - - $this->isNew = false; - - foreach($this->attributes as $value){ - $this->$value = $attrs[$value]; - } - - $this->sOAmail = preg_replace("/\./","@",$this->sOAmail,1); - $this->sOAmail = preg_replace("/\.$/","",$this->sOAmail); - $this->sOAprimary = preg_replace("/\.$/","",$this->sOAprimary); - $this->zoneName = preg_replace("/\.$/","",$this->zoneName); - - if(isset($attrs['RECORDS'])){ - $this->Records = $attrs['RECORDS']; - - $tmp2 = array(); - $usedPrio = array(); - foreach($this->Records as $key => $rec){ - if($rec['type'] == "mXRecord"){ - $tmp = split(" ",$rec['value']); - $rec['value'] = $tmp[1]; - $tmp2[$tmp[0]] = $rec; - unset($this->Records[$key]); - } - if($rec['type'] == "nSRecord"){ - unset($this->Records[$key]); - } - } - if(count($tmp2) != 0){ - reset($tmp2); - ksort($tmp2); - } - $this->mXRecords = $tmp2; - }else{ - $this->mXRecords = array(); - $this->Records = array(); - } - - $str = date("Ymd"); - if(preg_match("/^".$str."/",$this->sOAserial)){ - $this->sOAserial = $this->sOAserial + 1; - }else{ - $this->sOAserial = date("Ymd")."01"; - } - } - - /* Detect Network class */ - if(!empty($this->ReverseZone)){ - - $dots = count(split("\.",$this->ReverseZone)); - if($dots == 1){ - $this->NetworkClass = "A"; - $this->ReverseZone .= ".0.0.0"; - }elseif($dots == 2){ - $this->NetworkClass = "B"; - $this->ReverseZone .= ".0.0"; - }else{ - $this->NetworkClass = "C"; - $this->ReverseZone .= ".0"; - } - } - } - - /* TRansports the geiven Arraykey one position up*/ - function ArrayUp($atr,$attrs) - { - $ret = $attrs; - $pos = $atr ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == 1)||($pos >$cn))){ - $before = array_slice($attrs,0,($pos-2)); - $mitte = array_reverse(array_slice($attrs,($pos-2),2)); - $unten = array_slice($attrs,$pos); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - - /* TRansports the geiven Arraykey one position up*/ - function ArrayDown($atr,$attrs) - { - $ret = $attrs; - $pos = $atr ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == $cn))){ - $before = array_slice($attrs,0,($pos-1)); - $mitte = array_reverse(array_slice($attrs,($pos-1),2)); - $unten = array_slice($attrs,($pos+1)); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - /* Combine new array */ - function combineArrays($ar0,$ar1,$ar2) - { - $ret = array(); - if(is_array($ar0)) - foreach($ar0 as $ar => $a){ - $ret[]=$a; - } - if(is_array($ar1)) - foreach($ar1 as $ar => $a){ - $ret[]=$a; - } - if(is_array($ar2)) - foreach($ar2 as $ar => $a){ - $ret[]=$a; - } - return($ret); - } - - function getpos($atr,$attrs) - { - $i = 0; - foreach($attrs as $attr => $name) { - $i++; - if($attr == $atr){ - return($i); - } - } - return(-1); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - - - /* Fill templating stuff */ - $smarty= get_smarty(); - $ui = get_userinfo(); - - $smarty->assign("ACLs",$this->parent->getacl("")); - $display= ""; - - /* Open Zone Entry Edit Dialog - */ - if(!count($this->ZoneObject)){ - $smarty->assign("AllowZoneEdit" , false); - }else{ - $smarty->assign("AllowZoneEdit" , true); - if(isset($_POST['EditZoneEntries'])){ - if($this->zoneEditor == NULL){ - $this->zoneEditor= new servDNSeditZoneEntries($this->config,$this->dn,$this->ZoneObject); - $this->zoneEditor->parent = $this; - } - $this->dialog = $this->zoneEditor; - } - } - - /* Save Zone Entry Edit Dialog - */ - if(isset($_POST['SaveZoneEntryChanges'])){ - $this->dialog->save_object(); - if(count($this->dialog->check())){ - $msgs = $this->dialog->check(); - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - $this->zoneEditor = clone $this->dialog; - $this->dialog = FALSE; -# $rev = DNS::FlipIp(DNS::getNameFromMix($this->InitialReverseZone)).".in-addr.arpa"; -# $for = DNS::getNameFromMix($this->InitialzoneName); -# -# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $rev)); -# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $for)); -# $this->dialog = false; - } - } - - /* Cancel Zone Entrie Edit Dialog - */ - if(isset($_POST['CancelZoneEntryChanges'])){ - $this->dialog = false; - } - - /* Display any type of open dialogs - */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - $once =true; - foreach($_POST as $name => $value){ - if((preg_match("/^MXup_/",$name)) && ($once)){ - $once = false; - - $id = preg_replace("/^MXup_/","",$name); - $id = preg_replace("/_.*$/","",$id); - $id = base64_decode($id); - - $this->mXRecords = $this->ArrayUp(($id+1),$this->mXRecords); - } - if((preg_match("/^MXdown_/",$name)) && ($once)){ - $once = false; - - $id = preg_replace("/^MXdown_/","",$name); - $id = preg_replace("/_.*$/","",$id); - $id = base64_decode($id); - - $this->mXRecords = $this->ArrayDown(($id+1),$this->mXRecords); - } - if((preg_match("/^MXdel_/",$name)) && ($once)){ - $once = false; - - $id = preg_replace("/^MXdel_/","",$name); - $id = preg_replace("/_.*$/","",$id); - $id = base64_decode($id); - - unset($this->mXRecords[$id]); - - $tmp =array(); - foreach($this->mXRecords as $entry){ - $tmp[] = $entry; - } - - $this->mXRecords = $tmp; - } - } - - if((isset($_POST['AddMXRecord'])) && (!empty($_POST['StrMXRecord']))){ - $this->mXRecords[] = array("type"=>"mXRecord","value"=>trim($_POST['StrMXRecord'])); - } - - /* Handle Post events */ - $once = true; - foreach($_POST as $name => $value){ - - /* Delete record if requested */ - if((preg_match("/RemoveRecord_/",$name))&&($once)){ - $once = false; - $id= preg_replace("/RemoveRecord_/","",$name); - unset($this->Records[$id]); - } - } - - /* Add new Zonerecord */ - if(isset($_POST['AddNewRecord'])){ - $this->Records[] = array("type"=>"aRecord","value"=>""); - } - - /* Fill in values */ - foreach($this->attributes as $name){ - $smarty->assign($name,$this->$name); - } - - - $div = new divSelectBox("MxRecords"); - $div->setHeight(120); - $recs = $this->mXRecords; - - $oneup = " "; - $onedown = " "; - $onedel = " - "; - - foreach($recs as $key => $rec){ - $div ->AddEntry(array( - array("string"=>$rec['value']), -/* array("string"=>$key, - "attach"=>"style='width:20px;'"),*/ - array("string"=>str_replace("%s",base64_encode($key),$oneup.$onedown.$onedel), - "attach"=>"style='width:70px;border-right:0px;'") - )); - } - - /* Assign records list */ - $smarty->assign("NotNew", false); - $smarty->assign("Mxrecords", $div->DrawList()); - $smarty->assign("records" , $this->generateRecordsList()); - $smarty->assign("NetworkClass", $this->NetworkClass); - $smarty->assign("NetworkClasses", array("A"=>"255.0.0.0 (Class A)","B"=>"255.255.0.0 (Class B)","C"=>"255.255.255.0 (Class C)")); - - /* Display tempalte */ - $display.= $smarty->fetch(get_template_path('servdnseditzone.tpl', TRUE)); - return($display); - } - - function remove_from_parent() - { - } - - /* Save data to object */ - function save_object() - { - //plugin::save_object(); - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - - foreach($this->Records as $id => $value){ - if(isset($_POST['RecordTypeSelectedFor_'.$id])){ - $this->Records[$id]['type'] = $_POST['RecordTypeSelectedFor_'.$id]; - } - if(isset($_POST['RecordValue_'.$id])){ - $this->Records[$id]['value'] = $_POST['RecordValue_'.$id]; - } - } - - if(isset($_POST['NetworkClass'])){ - $this->NetworkClass = $_POST['NetworkClass']; - } - - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Check if zoneName is already in use */ - $usedZones = $this->getUsedZoneNames(); - if(($this->isNew == true)||($this->zoneName != $this->InitialzoneName)||($this->ReverseZone != $this->InitialReverseZone)){ - /* if((isset($usedZones[$this->zoneName]))&&($this->zoneName != $this->InitialzoneName)){ - $message[] =_("This zoneName is already in use"); - } - if((in_array($this->ReverseZone,$usedZones))&&($this->ReverseZone != $this->InitialReverseZone)){ - $message[] =_("This reverse zone is already in use"); - }*/ - } - - if(empty($this->zoneName)){ - $message[] =sprintf(_("Please choose a valid zone name.")); - } - - if(empty($this->ReverseZone)){ - $message[] =sprintf(_("Please choose a valid reverse zone name.")); - } - - if($this->zoneName != strtolower($this->zoneName)){ - $message[] = _("Only lowercase strings are allowed as zone name."); - } - - if(!is_numeric($this->sOAserial)){ - $message[] = _("Please specify a numeric value for serial number."); - } - - if(!is_numeric($this->sOArefresh)){ - $message[] = _("Please specify a numeric value for refresh."); - } - - if(!is_numeric($this->sOAttl)){ - $message[] = _("Please specify a numeric value for ttl."); - } - - if(!is_numeric($this->sOAexpire)){ - $message[] = _("Please specify a numeric value for expire."); - } - - if(!is_numeric($this->sOAretry)){ - $message[] = _("Please specify a numeric value for retry."); - } - - foreach($this->Records as $name => $values){ - /* only lower-case is allowed in record entries ... */ - if($values['value'] != strtolower($values['value'])){ - $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']); - } - } - - /* Check class for given Zone Address */ - $addr = preg_replace("/^[^\/]*+\//","",$this->ReverseZone); - - /* Check for valid&complete IP address */ - if(!tests::is_ip($addr)){ - $message[] = _("The given network address is not a valid, please specify a valid IP address."); - } - - /* Check if given address matches selected network class */ - switch($this->NetworkClass){ - case 'A': { - if(!preg_match("/^[0-9]*\.0\.0\.0$/",$addr)){ - $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.0.0.0")); - } - } - break; - case 'B': { - if(!preg_match("/^[0-9]*\.[0-9]*\.0\.0$/",$addr)){ - $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.0.0")); - } - } - break; - case 'C': { - if(!preg_match("/^[0-9]*\.[0-9]*\.[0-9]*\.0$/",$addr)){ - $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.x.0")); - } - } - break; - default : $message[] =sprintf(_("The given network class '%s' is not valid."),$this->NetworkClass); - } - - return ($message); - } - - /* 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","tXTRecord")); - while($attr = $ldap->fetch()){ - if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){ - if(isset($attr['tXTRecord'][0])){ - $zn = preg_replace("/zoneName\=/","",$attr['tXTRecord'][0]); - $ret[$zn] =DNS::FlipIp(preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0])); - } - }else{ - $ret[$attr['zoneName'][0]]=""; - } - } - return($ret); - } - - /* Save to LDAP */ - function save() - { - $ret =array(); - foreach($this->attributes as $name){ - $ret[$name] = $this->$name; - } - - /* Create mx records - */ - foreach($this->mXRecords as $key => $rec){ - $rec['value']= $key." ".$rec['value']; - $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; - - $ret['sOAmail'] = preg_replace("/\@/",".",$this->sOAmail); - - foreach(array("sOAprimary","zoneName","sOAmail") as $attr){ - if(!preg_match("/\.$/",$ret[$attr])){ - if(!tests::is_ip($ret[$attr])){ - $ret[$attr] = $ret[$attr]."."; - } - } - } - - $ret['RECORDS'][] = array("type" => "nSRecord","value" => $ret['sOAprimary']) ; - - $ret['zoneEditor'] = $this->zoneEditor; - return($ret); - } - - - /* This function generate a table row for each used record. - This table row displays the recordtype in a select box - and the specified value for the record, and a remove button. - The last element of the table also got an 'add' button. - */ - function generateRecordsList($changeStateForRecords="") - { - $changeStateForRecords = ""; - - $str = ""; - foreach($this->Records as $key => $entry){ - - if($entry['type'] == "mXRecord") continue; - - $changeStateForRecords.= "changeState('RecordTypeSelectedFor_".$key."');\n"; - $changeStateForRecords.= "changeState('RecordValue_".$key."');\n"; - $changeStateForRecords.= "changeState('RemoveRecord_".$key."');\n"; - - $str.=" ". - " ". - " ". - " ". - ""; - } - - $str.= " ". - " ". - " ". - "
".$this->generateRecordListBox($entry['type'],"RecordTypeSelectedFor_".$key)."
". - " ". - "
"; - return($str); - } - - /* This function generates a select box out of $this->RecordTypes options. - The Parameter $selected is used to predefine an attribute. - $name is used to specify a post name - */ - function generateRecordListBox($selected,$name) - { - $str = ""; - return($str); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc b/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc deleted file mode 100644 index fffbd1052..000000000 --- a/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc +++ /dev/null @@ -1,498 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array(); - var $objectclasses = array("whatever"); - - var $Devices = array(); - - var $zoneName = ""; // ZoneName of currently edited Zone - var $reverseName = ""; // ReverseZone of the currently edited Zone - - var $RecordTypes = array(); // Possible record type. - - var $disableDialog = false; // Dialog will be disabled, if this zone is new - - function servDNSeditZoneEntries (&$config,$dn, &$zoneObject) - { - plugin::plugin ($config, $dn); - - /* Initialise class - */ - $this->RecordTypes = DNS::getDnsRecordTypes(); - $this->dn = "zoneName=".$zoneObject['InitialzoneName'].",".$dn; - $this->zoneName = $zoneObject['InitialzoneName']; - $this->reverseName = $zoneObject['InitialReverseZone']; - - /* Remove nSRecord from listed types */ - if(isset($this->RecordTypes['nSRecord'])){ - unset($this->RecordTypes['nSRecord']); - } - /* Remove nSRecord from listed types */ - if(isset($this->RecordTypes['pTRRecord'])){ - unset($this->RecordTypes['pTRRecord']); - } - - /* Get ldap connection - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - /* Get zone content - */ - $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$this->dn,array("relativeDomainName")); - - while($attrs = $ldap->fetch()){ - $this->Devices[$attrs['relativeDomainName'][0]] = DNS::getDNSHostEntries($config,$attrs['relativeDomainName'][0],true); - $this->Devices[$attrs['relativeDomainName'][0]]['OrigCn'] = $attrs['relativeDomainName'][0]; - } - - $ldap->cat($this->dn,array("objectClass")); - - $this->disableDialog = true; - if(count($this->Devices)|| $ldap->count()){ - $this->disableDialog = false; - } - } - - function execute() - { - plugin::execute(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - $table = ""; - foreach($this->Devices as $key => $dev){ - $table .= $this->generateRecordConfigurationRow($key); - } - - $smarty->assign("disableDialog",$this->disableDialog); - $smarty->assign("table",$table);; - $display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE)); - return($display); - } - - - function save_object() - { - /* Check posts for operations ... - */ - $once = true; - $ptr_updates = array(); - foreach($_POST as $name => $value){ - - /* Add a new Record in given object - */ - - $tmp = preg_replace("/^.*_(.*)_.*$/","\\1",$name); - $tmp2 = split("\|",$tmp); - - /* Add new host entry - */ - if((preg_match("/^UserRecord_?/",$name)) && ($once)){ - $once = false; - $entry = DNS::getDNSHostEntries($this->config,"",true); - $entry['exists'] = true; - $entry['zoneName'] = strtoupper($this->attrs['cn'][0])."/".$this->zoneName; - $entry['RECORDS'][] = array("type" => "aRecord" , "value"=>""); - $this->Devices[_("New entry")] = $entry; - } - - if(count($tmp2) != 2) continue; - - $Name = base64_decode($tmp2[0]); - $RecordID = $tmp2[1]; - - /* Add new REcord - */ - if((preg_match("/^AddRecord_/",$name)) && ($once)){ - $once = false; - $this->Devices[$Name]['RECORDS'][] = $this->Devices[$Name]['RECORDS'][$RecordID]; - } - - /* Remove record from given dn - */ - if((preg_match("/^RemoveRecord_/",$name)) && ($once)){ - $once = false; - if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ - unset($this->Devices[$Name]['RECORDS'][$RecordID]); - } - - /* Check if there is at least one visible record. Else remove complete entry */ - $visible = false; - foreach($this->Devices[$Name]['RECORDS'] as $rec){ - if(in_array($rec['type'],$this->RecordTypes)){ - $visible = true; - break; - } - } - if(!$visible && isset($this->Devices[$Name]['RECORDS'])){ - $this->Devices[$Name]['RECORDS'] = array(); - } - } - } - - /* Possible attributes posted - */ - foreach($_POST as $name => $value){ - - /* Extract informations out of post name - */ - $tmp = preg_replace("/^.*_/","\\1",$name); - $tmp2 = split("\|",$tmp); - - if(count($tmp2) != 2) continue; - - $Name = base64_decode($tmp2[0]); - $RecordID = $tmp2[1]; - - /* Check for value change - */ - if(preg_match("/ValueSelection_/",$name)){ - if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ - - /* Update value */ - $old = $this->Devices[$Name]['RECORDS'][$RecordID]['value']; - $this->Devices[$Name]['RECORDS'][$RecordID]['value'] = $value; - - /* Handle pTRRecord */ - if(!isset($ptr_updates[$Name]) && $this->Devices[$Name]['RECORDS'][$RecordID]['type'] == "aRecord"){ - - $found = false; - $ip = $value; - $match = preg_replace("/^[^\/]*+\//","",$this->reverseName); - $ip = preg_replace("/^".normalizePreg($match)."/","",$ip); - $ip = preg_replace("/^\./","",$ip); - - foreach($this->Devices[$Name]['RECORDS'] as $key => $dev){ - if($dev['type'] == "pTRRecord"){ - $ptr_updates[$Name] = $Name; - $this->Devices[$Name]['RECORDS'][$key]['value'] = $ip; - $found = true; - break; - } - } - if(!$found){ - $dev = array('type'=> 'pTRRecord', 'value' => $ip); - $this->Devices[$Name]['RECORDS'][] = $dev; - } - } - } - } - - /* record type changed - */ - if(preg_match("/^RecordTypeSelection_/",$name)){ - if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ - $this->Devices[$Name]['RECORDS'][$RecordID]['type'] = $value; - } - } - } - - /* check for renamed entries - */ - foreach($_POST as $name => $value){ - - /* Extract informations out of post name - */ - $tmp = preg_replace("/^.*_/","\\1",$name); - $tmp2 = split("\|",$tmp); - - if(count($tmp2) != 2) continue; - - $Name = base64_decode($tmp2[0]); - $RecordID = $tmp2[1]; - - /* Host renamed - */ - if(preg_match("/RenameHost_/",$name)){ - if((isset($this->Devices[$Name])) && ($Name != $value)){ - - if(isset($this->Devices[$value])){ - print_red(sprintf(_("Can't rename '%s' to '%s' there is already an entry with the same name in our zone editing dialog."),$Name,$value)); - }else{ - $this->Devices[$value] = $this->Devices[$Name]; - unset($this->Devices[$Name]); - } - } - } - } - } - - - /* check something - */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - $names = array(); - foreach($this->Devices as $DevName => $device){ - - /* Don't need to check empty values ... */ - if(!count($device['RECORDS'])) continue; - - /* Checking entry name - */ - if(!preg_match("/^[a-z0-9_\.-]+$/i", $DevName) || (empty($DevName))){ - $message[] = sprintf(_("Entry name '%s' contains invalid characters."), $DevName); - } - - /* Renaming check for existing devices - */ - if(isset($device['OrigCn']) && ($DevName != $device['OrigCn'] )){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); - if($ldap->count()){ - $message[] = sprintf(_("Can not rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$DevName); - } - }elseif(!isset($device['OrigCn'])){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); - if($ldap->count()){ - $message[] = sprintf(_("Can not create '%s',the destination name already exists."),$DevName); - } - } - - /* Check names - */ - if(!isset($names[$DevName])){ - $names[$DevName] = ""; - }else{ - $message[] = sprintf(_("The name '%s' is used more than once."),$DevName); - } - - /* Names should be written in lowercase - */ -# if(strtolower($DevName) != $DevName){ -# $message[] = sprintf(_("The host name '%s' should be written in lowercase."), $DevName); -# } - - /* Check records - */ - $singleEntries = array("cNAMERecord","pTRRecord"); - - $tmp = array(); - $tmp2 = array(); - foreach($device['RECORDS'] as $Num => $Rec){ - - /* Check for multiple use of unique record types - */ - if(in_array($Rec['type'],$singleEntries)){ - if(!isset($tmp[$Rec['type']])){ - $tmp[$Rec['type']] = ""; - }else{ - $message[] = sprintf(_("The record type '%s' is a unique type and can't be defined twice."),$Rec['type']); - } - } - - /* Check for empty / duplicate entries in record array - */ - if(empty($Rec['value'])){ - $message[] = sprintf(_("There is an empty '%s' for host '%s'."),$Rec['type'],$DevName); - } - - /* Check for duplicate record entries - */ - if(!isset($tmp[$Rec['type']][$Rec['value']])){ - $tmp[$Rec['type']][$Rec['value']] = ""; - }else{ - $message[] = sprintf(_("There is a duplicate entry in '%s' for '%s'."),$Rec['type'],$DevName); - } - } - } - return ($message); - } - - function save() - { - if($this->disableDialog) return; - - $todo = array(); - - - - /* Create todolist - */ - foreach($this->Devices as $name => $dev){ - if(isset($dev['OrigCn'])){ - if(count($dev['RECORDS'])){ - $todo[] = DNS::getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name); - }else{ - $dev['exists'] = false; - $todo[] = DNS::getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name); - } - }else{ - if(count($dev['RECORDS'])){ - $todo[] = DNS::getDNSHostEntriesDiff($this->config,"",$dev,$name); - }else{ - $dev['exists'] = false; - $todo[] = DNS::getDNSHostEntriesDiff($this->config,"",$dev,$name); - } - } - } - - $tmp = array(); - $tmp['del'] = array(); - $tmp['add'] = array(); - $tmp['move'] = array(); - foreach($todo as $to){ - foreach($to as $type => $entries){ - $tmp[$type] = array_merge($tmp[$type],$entries); - } - } - - /* Get ldap link - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - - /* move follwoing entries - */ - foreach($tmp['move'] as $src => $dst){ - $this->recursive_move($src,$dst); - } - - /* Delete dns */ - foreach($tmp['del'] as $dn => $del){ - $ldap->cd($dn); - $ldap->rmdir_recursive($dn); - if(is_object($this->parent->parent)){ - $this->parent->parent->handle_post_events("remove",array("dn" => $dn)); - } - } - - /* Add || Update new DNS entries - */ - foreach($tmp['add'] as $dn => $attrs){ - $ldap->cd($dn); - $ldap->cat($dn, array('dn')); - if(count($ldap->fetch())){ - $ldap->cd($dn); - $ldap->modify ($attrs); - if(is_object($this->parent->parent)){ - $this->parent->parent->handle_post_events("modify",array("dn" => $dn)); - } - }else{ - $ldap->cd($dn); - $ldap->add($attrs); - if(is_object($this->parent->parent)){ - $this->parent->parent->handle_post_events("create",array("dn" => $dn)); - } - } - } - } - - - /* Create html table out of given entry - */ - function generateRecordConfigurationRow($objKey){ - - /* Get some basic informations - */ - $obj = $this->Devices[$objKey]; - $objectName = $objKey; - - /* Abort if emtpy - */ - if(count($obj['RECORDS']) == 0) return ""; - - /* Set title - */ - $str= "
"; - - $hostNameOnce = true; - - /* Walk through all defined records - */ - $str.= ""; - foreach($obj['RECORDS'] as $id => $record){ - - /* Skip not selectable entries */ - if(!isset($this->RecordTypes [$record['type']])) { - continue; - } - - /* Create unique post name - */ - $name = base64_encode($objKey)."|".$id; - - $str .= " - - - - "; - } - $str .="
\n"; - - /* Only first host entry name should be editable - */ - if($hostNameOnce){ - $hostNameOnce = false; - $str .="\n"; - } - - /* Create rest. Selectbox, icons ... - */ - $str .=" - - ".$this->createRecordTypeSelection($record['type'],$name)." - - - - - - "; - -# if($record['type'] == "aRecord"){ -# $str .=""; -# }else{ -# $str .= ""; -# } - - $str.= - "
"; - return($str); - } - - - /* Create selectbox with all available option types - */ - function createRecordTypeSelection($id,$refID){ - - $str = "\n"; - return($str); - } - - - function remove_from_parent() - { - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl b/gosa-core/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl deleted file mode 100644 index 9c0428c29..000000000 --- a/gosa-core/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl +++ /dev/null @@ -1,27 +0,0 @@ -

{t}This dialog allows you to configure all components of this DNS zone on a single list.{/t}

-

 

-{if $disableDialog} -
- {t}This dialog can't be used until the currently edited zone was saved or the zone entry exists in the ldap database.{/t} - -{else} -
- {$table} -
- -{/if} - -

 

-
-

- - -

-
- - - diff --git a/gosa-core/plugins/admin/systems/services/dns/servdns.tpl b/gosa-core/plugins/admin/systems/services/dns/servdns.tpl deleted file mode 100644 index 6cfa50f09..000000000 --- a/gosa-core/plugins/admin/systems/services/dns/servdns.tpl +++ /dev/null @@ -1,63 +0,0 @@ -{if $dns_take_over} - - - - -
-

{t}DNS take over initiated{/t}

- {$warning} - {t}This includes 'all' DNS zones that are located within this server. Please double check if your really want to do this.{/t} -

- {$warning2} -
- -

-

- {t}Following objects will be taken over{/t} : -

-

-

{$info}
-

-
-{else} - -{if $dns_server_list_cnt} - - - -{/if} - - - -
- {t}Take over DNS configuration from{/t}  - - -
-

{t}Zones{/t}

- {$ZoneList} - {if $is_createable} - - {else} - - {/if} -
- - - - -{/if} -

 

-

-

- -   - -
-

diff --git a/gosa-core/plugins/admin/systems/services/dns/servdnseditzone.tpl b/gosa-core/plugins/admin/systems/services/dns/servdnseditzone.tpl deleted file mode 100644 index 1136dba53..000000000 --- a/gosa-core/plugins/admin/systems/services/dns/servdnseditzone.tpl +++ /dev/null @@ -1,177 +0,0 @@ -

{t}Generic{/t}

- - - - - -
- - - - - - - - - - - - - -
{t}Zone name{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Network address{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Netmask{/t} - -{render acl=$ACLs} - -{/render} -
-
- - - - - -
- {t}Zone records{/t} -
- {if $AllowZoneEdit == false} - {t}Can't be edited because the zone wasn't saved right now.{/t} - {/if} -
-{render acl=$ACLs} - -{/render} -
-
-

 

-

{t}SOA record{/t}

- - - - - -
- - - - - - - - - - - - - -
{t}Primary dns server for this zone{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Mail address{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Serial number (automatically incremented){/t}{$must} - -{render acl=$ACLs} - -{/render} -
-
- - - - - - - - - - - - - - - - - -
{t}Refresh{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Retry{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Expire{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}TTL{/t}{$must} - -{render acl=$ACLs} - -{/render} -
-
- -

 

-
- - - - - -
-

{t}MxRecords{/t}

- - - - -
-{render acl=$ACLs} - {$Mxrecords} -{/render} -{render acl=$ACLs} - -{/render} -{render acl=$ACLs} - -{/render} -
-
-

{t}Global zone records{/t}

-{render acl=$ACLs} - {$records} -{/render} -
-
-

-{render acl=$ACLs} - -{/render} - -

-
- diff --git a/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc b/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc new file mode 100644 index 000000000..c560c36ac --- /dev/null +++ b/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc @@ -0,0 +1,686 @@ + 45.3.12 + Because some entries (like zones) are store like that 45.3.12.in-addr.arpa + but we want to display 12.3.45. + */ + static function FlipIp($ip) + { + $tmp = array_reverse(split("\.",$ip)); + $new = ""; + foreach($tmp as $section){ + $new .= $section."."; + } + return(preg_replace("/.$/","",$new)); + } + + + /* This static function returns the zones specified for given host + */ + static function getDNSZoneEntries($config,$HostDn,$silent = false) + { + global $RecordTypes; + + $ldap = $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); + + /* Not all records are allowed within a zone entry + */ + $SkipRecords = array("tXTRecord","cNAMERecord","pTRRecord"); + + /* Special sOArecords + */ + $sOAREcords = array("0"=>"sOAprimary","1"=>"sOAmail","2"=>"sOAserial","3"=>"sOArefresh","4"=>"sOAretry","5"=>"sOAexpire","6"=>"sOAttl"); + + /* Create tempalte for all fetched zone Data + */ + $ZoneBase = array(); + $ZoneBase['exists'] = false; + $ZoneBase['RECORDS'] = array(); + $ZoneBase['zoneName'] = array(); + $ZoneBase['dNSClass'] = array(); + + foreach($sOAREcords as $attr){ + $ZoneBase[$attr] = ""; + } + + $Zones = array(); + + /* Get & Parse all zone entries + */ + $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=@))",$HostDn,array("*")); + $tmp_res = array(); + while($attrs = $ldap->fetch()) { + $tmp_res[] = $attrs; + } + + /* Parse fetched zones + */ + foreach($tmp_res as $attrs){ + + $zoneName = $attrs['zoneName'][0]; + $Zones[$zoneName] = $ZoneBase; + $Zones[$zoneName]['exists'] = true; + + /* Set basic attributes + */ + foreach(array("zoneName","dNSClass") as $attr){ + if(isset($attrs[$attr][0])){ + $Zones[$zoneName][$attr] = $attrs[$attr][0]; + } + } + + /* Set initial zone name, to be able to detect if this entry was renamed + */ + $Zones[$zoneName]['InitialzoneName'] = $zoneName; + + /* Generate SOA entry + */ + if(isset($attrs['sOARecord'][0])){ + $tmp = split("\ ",$attrs['sOARecord'][0]) ; + $tmp2 = array(); + + /* Assign soa vars */ + foreach($sOAREcords as $key => $name){ + if(isset($tmp[$key])){ + $Zones[$zoneName][$name] = $tmp[$key]; + }else{ + $Zones[$zoneName][$name] = ""; + } + } + } // ENDE SOA Record + + /* Get record attributes + */ + foreach($RecordTypes as $name => $value){ + + /* Skip some attributes + */ + if(in_array($name,$SkipRecords)) continue; + + /* If there is a record attribute + */ + if(isset($attrs[$name])){ + + /* get all entries + */ + for($i = 0 ; $i < $attrs[$value]['count']; $i ++){ + $Zones[$zoneName]['RECORDS'][] = array("type"=>$name,"value"=>$attrs[$value][$i]); + } + } + } + + /* Get reverse record .. + */ + $ldap->ls("(&(objectClass=dNSZone)(relativeDomainName=@)(zoneName=*))",$attrs['dn'],array("zoneName")); + + if($ldap->count() == 0){ + if(!$silent){ + msg_dialog::display(_("Error"), sprintf(_("Cannot find reverse zone for DNS zone '%s'. Parsing zone aborted."),$zoneName), ERROR_DIALOG); + } + unset($Zones[$zoneName]); + }elseif($ldap->count()>1){ + if(!$silent){ + msg_dialog::display(_("Error"), sprintf(_("Found more than one reverse zone for '%s'. Parsing zone aborted."),$zoneName), ERROR_DIALOG); + } + unset($Zones[$zoneName]); + }else{ + $tmp = $ldap->fetch(); + $Zones[$zoneName]['ReverseZone'] = FlipIp(str_replace(".in-addr.arpa","",$tmp['zoneName'][0])); + $Zones[$zoneName]['InitialReverseZone'] = FlipIp(str_replace(".in-addr.arpa","",$tmp['zoneName'][0])); + } + } + return($Zones); + } + + + /* This static function compares two dns zone objects and returns an + * array with following indexes + * - delete, for dns which must be deleted (only if dns zone is removed) + * - rename, if a dn must be renamed, for example, the zoneName has changed + * - add, if there is a new dns account created + */ + static function getDNSZoneEntriesDiff($config,$newZones,$HostDn) + { + $oldZones = getDNSZoneEntries($config,$HostDn,true); + + $sOAattributes = array("sOAprimary","sOAmail","sOAserial","sOArefresh","sOAretry","sOAexpire","sOAttl"); + + $move = array(); + $add = array(); + $del = array(); + + /* Generate a template for zones with default values + */ + $zoneBase = array(); + $zoneBase['objectClass'] = array("top","dNSZone"); + $zoneBase['zoneName'] = ""; + $zoneBase['relativeDomainName'] = "@"; + $zoneBase['dNSClass'] = "IN"; + $zoneBase['sOARecord'] = ""; + + /* Contains all renamed zoneNames + * For zone entry udpdates + */ + $PrePareZoneEntries = array(); + + /* Walk through all zones and detect renamed/added/deleted zones ... + */ + foreach($newZones as $name => $zone){ + + /* This zone was renamed + */ + if((!empty($zone['InitialzoneName'])) && ($zone['InitialzoneName'] != $zone['zoneName'])){ + + /* Move old zone to new position + */ + $oldDn = "zoneName=".$zone['InitialzoneName'].",".$HostDn; + $newDn = "zoneName=".$zone['zoneName'].",".$HostDn; + $PrePareZoneEntries[$zone['InitialzoneName']] = $zone['zoneName']; + $move [$oldDn] = $newDn; + } + + /* Get old zone if available + */ + $oldZone=array(); + if(!empty($oldZones[$zone['InitialzoneName']])){ + $oldZone = $oldZones[$zone['InitialzoneName']]; + } + + /* Create forward zone entry and put it in our add queue + */ + $newDn = "zoneName=".$zone['zoneName'].",".$HostDn; + $obj = $zoneBase; + $obj['zoneName'] = $zone['zoneName']; + + /* Create sOARecord & add it to the obj + */ + $soa = ""; + foreach($sOAattributes as $attr){ + $soa.=" ".$zone[$attr]; + } + $obj['sOARecord'] = trim($soa); + $obj['nSRecord'] = $zone['sOAprimary']; + + /* If reverse zone was renamed, move entry + */ + if(!empty($zone['InitialReverseZone'])){ + if($zone['InitialReverseZone'] != $zone['ReverseZone']){ + $base = "zoneName=".$zone['zoneName'].",".$HostDn; + $oldRDn = "zoneName=". FlipIp($zone['InitialReverseZone']).".in-addr.arpa,".$base; + $newRDn = "zoneName=". FlipIp($zone['ReverseZone']).".in-addr.arpa,".$base; + $PrePareZoneEntries[FlipIp($zone['InitialReverseZone']).".in-addr.arpa"] = FlipIp($zone['ReverseZone']).".in-addr.arpa"; + $move [$oldRDn] = $newRDn; + } + } + + /* Append record entries + * Set old value to array, to ensure that + * they will be deleted if necessary + */ + if(isset($oldZone['RECORDS'])){ + foreach($oldZone['RECORDS'] as $rec){ + $obj[$rec['type']] = array(); + } + } + + /* Add new Records + */ + foreach($zone['RECORDS'] as $rec){ + if(!isset($obj[$rec['type']])||!is_array($obj[$rec['type']])){ + $obj[$rec['type']] = array(); + } + $obj[$rec['type']][] = $rec['value']; + } + + /* Append udpated Zone Forward Entry to our add queue + */ + $add[$newDn] = $obj; + + /* Create Reverse Entry + * And append it to our add queue + */ + $zone['ReverseZone'] = FlipIp($zone['ReverseZone']).".in-addr.arpa"; + $base = "zoneName=".$zone['zoneName'].",".$HostDn; + $newRDn = "zoneName=".$zone['ReverseZone'].",".$base; + $rObj = $obj; + $rObj['zoneName']= $zone['ReverseZone']; + $add[$newRDn] = $rObj; + + /* Remove currently managed zone from oldZones. + * this gives us the ability to detect removed zones + */ + if(isset($oldZones[$zone['InitialzoneName']])){ + unset($oldZones[$zone['InitialzoneName']]); + } + } + + /* The rest of our oldZones must be deleted + * because they are no longer available in newZones anymore. + */ + foreach($oldZones as $zone) { + $oldDn = "zoneName=".$zone['InitialzoneName'].",".$HostDn; + $del[$oldDn] = $zone; + } + + /* Check for entries which must be updated + */ + $zoneUpdates = array(); + $udpate = array(); + if(count($PrePareZoneEntries)){ + $ldap = $config->get_ldap_link(); + foreach($PrePareZoneEntries as $FromZoneName => $ToZoneName){ + $ldap->cd($HostDn); + $ldap->search("(&(objectClass=dNSZone)(zoneName=".$FromZoneName.")(!(relativeDomainName=@)))",array("zoneName")); + while($attrs = $ldap->fetch()){ + $zoneUpdates[$attrs['dn']] = array("zoneName"=>$ToZoneName); + } + } + } + + $ret = array("del" => $del , "move" => $move , "add" => $add,"zoneUpdates"=>$zoneUpdates); + return($ret); + } + + + /* This static function returns the dns-host eintries for given + * name. + */ + static function getDNSHostEntries($config,$name,$silent = false) + { + global $RecordTypes; + + $types = array(); + $ret = array(); + $ret['RECORDS'] = array(); + $ret['dNSClass'] = "IN"; + $ret['zoneName'] = ""; + $ret['dNSTTL'] = "7440"; + $ret['exists'] = false; + + $ldap = $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); + + /* First check all zones for an entry with the given name. + * If the name occurs in more than one entry alert the user ... + */ + $foundIn = array(); + $zones = DNS::getAvailableZones($config); + + $zonesArr = array(); + foreach($zones as $zoneMix){ + $zoneIndex = split("/",$zoneMix); + if(!array_key_exists($zoneIndex[0],$zonesArr)) { + $zonesArr[$zoneIndex[0]] = array(); + } + array_push($zonesArr[$zoneIndex[0]],$zoneIndex[1]); + } + + foreach($zonesArr as $nameServer => $nameServerArr){ + $foundInTmp = array(); + foreach($nameServerArr as $zoneArr => $zone){ + $zoneMix = $nameServer."/".$zone; + $zoneDn = DNS::getDNSZoneDN($config,$zoneMix); + $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=".$name.")(!(relativeDomainName=@)))", $zoneDn,$attrs = array("*")); + while($attrs = $ldap->fetch()){ + $foundInTmp [$zoneMix] = $attrs['dn']; + $foundIn [$zoneMix] = $attrs['dn']; + } + } + } + + /* No zone found which contains an entry for us + */ + if(count($foundIn) == 0){ + return($ret); + } + + /* Get host informations from zone + */ + $id_tmp = key($foundIn); + $ldap->cd($foundIn[$id_tmp]); + $ldap->search("(&(objectClass=dNSZone)(zoneName=*)(!(relativeDomainName=@)))",array("*")); + while($attrs = $ldap->fetch()){ + + /* If relative domainname == cn + * Try to read dnsclass / TTl / zone + */ + if($attrs['relativeDomainName'][0] == $name){ + $ret['exists'] = true; + $ret['zoneName'] = $id_tmp; + foreach(array("dNSClass","dNSTTL") as $atr){ + if(isset($attrs[$atr][0])){ + $ret[$atr] = $attrs[$atr][0]; + } + } + } + + /* Create list with all used records */ + foreach($RecordTypes as $name => $value){ + + /* If there is a record attribute */ + if(isset($attrs[$name])){ + + /* get all entries */ + for($i = 0 ; $i < $attrs[$value]['count']; $i ++){ + $types[] = array( "type" => $name, + "value" => $attrs[$value][$i]); + } + } + } + $ret['RECORDS'] = $types; + } + return($ret); + } + + + + /* This static function compares two dns settings and returns an + * array with following indexes + * - delete, for dns which must be deleted (only if dns account is removed) + * - rename, if a dn must be renamed, for example, the relativeDomainName has changed + * - add, if there is a new dns account created + */ + static function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName) + { + global $RecordTypes; + + $oldEntry = getDNSHostEntries($config,$oldName); + + $add = array(); + $del = array(); + $move = array(); + + /* Don't go further if there is nothing to do + * Is no account / was no account + */ + if(($newEntry['exists'] == false )&& ($oldEntry['exists'] == false)){ + return(array("move"=>$move,"add"=>$add,"del"=>$del)); + } + + $zones = DNS::getAvailableZones($config); + $specialAttributes = array("cNAMERecord","pTRRecord"); + $newRecords = array(); // Used to remember which records are removed + $zoneNameMix = $newEntry['zoneName']; + $zoneDn = DNS::getDNSZoneDN($config,$zoneNameMix); + $tmp = array_flip($zones); + $zoneName = DNS::getNameFromMix($zoneNameMix); + + /* If reverseZone can't be resolved ... this + * can't be a valid entry, so remove this account + */ + if(isset($tmp[$zoneNameMix])){ + $reverseNameMix = $tmp[$zoneNameMix]; + $reverseDn = DNS::getDNSZoneDN($config,$reverseNameMix); + if(empty($reverseDn)){ + $newEntry['exists'] = false; + } + }else{ + $newEntry['exists'] = false; + } + + /* If account was edited prepare some + * attributes & arrays ... if required add some + * dns to $move + */ + if($oldEntry['exists']){ + + /* Check if the account was removed + */ + if($newEntry['exists'] == false){ + $dn = "relativeDomainName=".$oldName.",".DNS::getDNSZoneDN($config,$oldEntry['zoneName']); + $del[$dn] =""; + return(array("move"=>$move,"add"=>$add,"del"=>$del)); + } + + /* Check if zoneName has changed + */ + if(count($newEntry['RECORDS'])){ + if($oldEntry['zoneName'] != $newEntry['zoneName']){ + $oldzoneDn = DNS::getDNSZoneDN($config,$oldEntry['zoneName']); + $dn = "relativeDomainName=".$oldName.",".$oldzoneDn; + $dn2= "relativeDomainName=".$oldName.",".$zoneDn; + $move[$dn]=$dn2; + } + + /* Check if host name has changed + */ + if($oldName != $newName){ + $dn = "relativeDomainName=".$oldName.",".$zoneDn; + $dn2= "relativeDomainName=".$newName.",".$zoneDn; + $move[$dn]=$dn2; + $dn = "relativeDomainName=".$oldName.",".$dn2; + $dn2= "relativeDomainName=".$newName.",".$dn2; + $move[$dn]=$dn2; + } + } + + /* Prepare record entries + * Fill old records with array(); + * To ensure that they will be deleted if they stay unused + */ + foreach($oldEntry['RECORDS'] as $id => $rec){ + $newRecords[$rec['type']] = array(); + } + } + + /* There must be at least one record in our entry + */ + if((!count($newEntry['RECORDS'])) || (!$newEntry['exists'])){ + $dn = "relativeDomainName=".$newName.",".DNS::getDNSZoneDN($config,$oldEntry['zoneName']); + $del[$dn] =""; + $ret = array("move"=>$move,"add"=>$add,"del"=>$del); + return($ret); + } + + /* Prepare temp obj + */ + $baseObj = array(); + $baseObj['objectClass'] = array("top","dNSZone"); + $baseObj['dNSTTL'] = $newEntry['dNSTTL']; + $baseObj['dNSClass'] = $newEntry['dNSClass']; + $baseObj['zoneName'] = $zoneName; + $baseObj['relativeDomainName']= $newName; + + /* Add Container Object to zone + * (this possibly already exists, check this before writing to ldap) + */ + $baseDn = "relativeDomainName=".$newName.",".$zoneDn; + $add[$baseDn] = $baseObj; + + /* Add base obejct which contains all std records + */ + $stdDn = "relativeDomainName=".$newName.",".$baseDn; + $add[$stdDn] = $baseObj; + + /* Set defaults. Normaly only contains old record names. + * The old names will be set to array, to ensure that they will be deleted. + * Or overwritten and filled with new values. + */ + foreach($newRecords as $name => $def){ + if(!in_array($name,$specialAttributes)){ + $add[$stdDn][$name] = $def; + } + } + + /* Delete all OLD special attributes. + */ + foreach($oldEntry['RECORDS'] as $id => $rec){ + if(in_array($rec['type'],$specialAttributes)){ + $deldn= "relativeDomainName=".$rec['value'].",".$baseDn; + $del[$deldn] = ""; + } + } + + + /* Create new record entries + */ + foreach($newEntry['RECORDS'] as $id => $rec){ + /* Create object which contains special records + * like pTRRecord or CNAMERecord + */ + if($rec['type'] == "pTRRecord"){ + $PTRdn= "relativeDomainName=".DNS::FlipIP($rec['value']).",".$baseDn; + $ptrObj = $baseObj; + $reverseName = DNS::getNameFromMix($reverseNameMix); + $ptrObj['zoneName'] = $reverseName; + if(!preg_match("/\.$/",$newName)){ + $ptrObj['pTRRecord'] = preg_replace("/\.\.$/",".",$newName.".".$zoneName."."); + }else{ + $ptrObj['pTRRecord'] = preg_replace("/\.\.$/",".",$newName."."); + } + $ptrObj['relativeDomainName'] = DNS::FlipIP($rec['value']); + + $add[$PTRdn] = $ptrObj; + }else + if($rec['type'] == "cNAMERecord"){ + $PTRdn= "relativeDomainName=".$rec['value'].",".$baseDn; + $ptrObj = $baseObj; + $ptrObj['zoneName'] = $zoneName; + $ptrObj['cNAMERecord'] = $newName; + $ptrObj['relativeDomainName'] = $rec['value']; + + $add[$PTRdn] = $ptrObj; + }else{ + /* Append basic attributes + */ + $add[$stdDn][$rec['type']][] = $rec['value']; + } + } // foreach record + + $ret = array("move"=>$move,"add"=>$add,"del"=>$del); + return($ret); + } + + static function getNameFromMix($zoneMix){ + $ret = ""; + if(!strstr($zoneMix, '/')) return($ret); + $zoneIndex = split("/",$zoneMix); + return($zoneIndex[1]); + } + + /* returns the dn for a specified zone + */ + static function getDNSZoneDN($config,$zoneNameMix) + { + $ret = ""; + if(!strstr($zoneNameMix, '/')) { + msg_dialog::display(_("Error"), sprintf(_("Undefined zone name '%s'!"),$zoneNameMix), ERROR_DIALOG); + return($ret); + } + + $zoneNameIndex = split("/",$zoneNameMix); + $zoneName = $zoneNameIndex[1]; + $nameServer = strtolower($zoneNameIndex[0]); + $ldap = $config->get_ldap_link(); + + /* search for the nameserver */ + $ldap-> cd($config->current['BASE']); + $ldap->search("(&(objectClass=goServer)(cn=".$nameServer."))",array("cn")); + if($ldap->count()){ + $attr = $ldap->fetch(); + } else { + return($ret); + } + + $ldap-> cd($attr['dn']); + $ldap->search("(&(objectClass=dNSZone)(sOARecord=*)(zoneName=".$zoneName."))",array("zoneName")); + if($ldap->count()){ + $attr = $ldap->fetch(); + return($attr['dn']); + } + + return($ret); + } + + + /* returns all available zones + * array[reverseName] = zoneName; + */ + static function getAvailableZones($config) + { + $ret = array(); + $ldap = $config->get_ldap_link(); + $ldap->cd ($config->current['BASE']); + + /* Search for zones ... + */ + $ldap->search("(&(objectClass=dNSZone)(sOARecord=*))",array("zoneName")); + + $ForwardZones = array(); + $ReverseZones = array(); + $zones = array(); + + while($at = $ldap->fetch()){ + if(preg_match("/\.in\-addr\.arpa/",$at['zoneName'][0])){ + $ReverseZones[$at['dn']] = $at; + }else{ + $ForwardZones[$at['dn']] = $at; + } + } + + foreach($ForwardZones as $dn => $obj){ + + /* try to find reverse + */ + foreach($ReverseZones as $Rdn => $Robj ){ + if(preg_match("/".$dn."/",$Rdn)){ + $zones[strtoupper($ldap->getCn($dn))."/".$Robj['zoneName'][0]] = + strtoupper($ldap->getCn($dn))."/".$obj['zoneName'][0]; + } + } + } + return($zones); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/dns/admin/systems/services/dns/class_servDNS.inc b/gosa-plugins/dns/admin/systems/services/dns/class_servDNS.inc new file mode 100644 index 000000000..9890931ea --- /dev/null +++ b/gosa-plugins/dns/admin/systems/services/dns/class_servDNS.inc @@ -0,0 +1,598 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = FALSE; + var $attributes = array(); + var $objectclasses = array("whatever"); + + var $RecordTypes = array(); + var $Zones = array(); + + var $orig_dn = ""; + + var $initially_was_account; + + /* ServerService tab vars */ + var $conflicts = array("servdns"); + var $DisplayName = ""; + var $StatusFlag = ""; + var $view_logged = FALSE; + + var $dns_server_list = array("ENTRIES"=> array(),"FOR_LIST"=> array()); + var $take_over_id = -1; + + + function servdns (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + $this->DisplayName = _("DNS service"); + + $this->orig_dn = $dn; + + /* Get record types for zones + */ + $this->RecordTypes = DNS::getDnsRecordTypes(true); + + /* Get all zone Informations + */ + $this->Zones = DNS::getDNSZoneEntries($config,$dn); + + /* If there is at least one entry in this -> types, we have DNS enabled + */ + if(count($this->Zones) == 0){ + $this->is_account = false; + $this->dns_server_list = $this->get_list_of_dns_servers(); + }else{ + $this->is_account = true; + } + $this->initially_was_account = $this->is_account; + } + + + function get_list_of_dns_servers() + { + $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array()); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=dNSZone)(zoneName=*))",array("dn","zoneName")); + $dns = array(); + while($attrs = $ldap->fetch()){ + /* Skip own config */ + if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){ + continue; + } + $dn = preg_replace("/^zoneName=[^,]+,/","",$attrs['dn']); + if(preg_match("/^cn=/",$dn) && !in_array($dn,$dns)){ + $dns[] = $dn; + } + } + $i = 0; + foreach($dns as $dn){ + $ldap->cat($dn,array('*')); + if($ldap->count()){ + $i ++; + $attrs = $ldap->fetch(); + $ret['ENTRIES'][$i] = $attrs; + $ret['FOR_LIST'][$i] = $attrs['cn'][0]; + } + } + return($ret); + } + + + function get_dns_info_string($id) + { + $ret=""; + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dns_server_list['ENTRIES'][$id]['dn']); + $ldap->search("(|(zoneName=*)(relativeDomainName=*))",array("dn")); + while($attrs = $ldap->fetch()){ + $ret .= $attrs['dn']."\n"; + } + return($ret); + } + + + function execute() + { + /* Call parent execute + */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* Fill templating stuff + */ + $smarty= get_smarty(); + $smarty->assign("dns_take_over",FALSE); + $smarty->assign("is_createable",$this->acl_is_createable()); + $display= ""; + + + $this->initially_was_account= $this->is_account; + /*****************/ + /* Handle Take Over Actions + /*****************/ + + /* Give smarty the required informations */ + $smarty->assign("dns_server_list", $this->dns_server_list['FOR_LIST']); + $smarty->assign("dns_server_list_cnt", count($this->dns_server_list['FOR_LIST'])); + + /* Take over requested, save id */ + if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){ + $id = $_POST['take_over_src']; + if(isset($this->dns_server_list['ENTRIES'][$id])){ + $this->take_over_id = $id; + } + } + + /* Abort take over action */ + if(isset($_POST['cancel_take_over'])){ + $this->dialog =false; + $this->take_over_id = -1; + $this->dns_server_list = $this->get_list_of_dns_servers(); + } + + /* Display informartion about take over that will be started when saving this server + * and hide default dns output + */ + if($this->take_over_id != -1){ + $this->dialog = FALSE; + $id = $this->take_over_id; + $info = $this->get_dns_info_string($id); + $smarty->assign("dns_take_over",TRUE); + $smarty->assign("info",$info); + $warning = sprintf(_("You are going to migrate the DNS setup from server '%s'."),$this->dns_server_list['ENTRIES'][$id]['cn'][0]); + $warning2 = _("The migration will be startet when you save this system. To cancel this action, use the cancel button below."); + $smarty->assign("warning",$warning); + $smarty->assign("warning2",$warning2); + return($smarty->fetch(get_template_path('servdns.tpl', TRUE))); + } + + + /* Do we need to flip is_account state? + */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove DNS service"), + _("This server has DNS features enabled. You can disable them by clicking below.")); + } else { + $display= $this->show_enable_header(_("Add DNS service"), + _("This server has DNS features disabled. You can enable them by clicking below.")); + return ($display); + } + + + /* Edited or Added zone + */ + if(isset($_POST['SaveZoneChanges'])){ + $this->dialog->save_object(); + + /* Check for errors + */ + if(count($this->dialog->check())){ + foreach($this->dialog->check() as $msgs){ + print_red($msgs); + } + }else{ + /* add new/edited zone + */ + $ret = $this->dialog->save(); + if(!$this->dialog->isNew){ + unset($this->Zones[$this->dialog->OldZoneName]); + } + $this->Zones[$ret['zoneName']] = $ret; + $this->dialog = FALSE; + } + } + + /* Cancel zone edit / new + */ + if(isset($_POST['CancelZoneChanges'])){ + $this->dialog = FALSE; + } + + /* Add empty new zone + */ + if(isset($_POST['AddZone'])){ + $this->dialog = new servdnseditZone($this->config,$this->dn); + } + + /* Check for edit zone request + */ + $once = false; + foreach( $_POST as $name => $value){ + + /* check all post for edit request + */ + if(preg_match("/^editZone_/",$name)&&!$once){ + $once =true; + $tmp = preg_replace("/^editZone_/","",$name); + $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); + $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$tmp]); + } + + /* check posts for delete zone + */ + if(preg_match("/^delZone_/",$name)&&!$once){ + + $once =true; + $tmp = preg_replace("/^delZone_/","",$name); + $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); + + /* Initiate deletion + */ + $this->RemoveZone($tmp); + } + } + + if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){ + $id = base64_decode($_GET['id']); + if(isset($this->Zones[$id])){ + $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]); + } + } + + if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){ + $id = base64_decode($_GET['id']); + if(isset($this->Zones[$id])){ + $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]); + } + } + + /* Show dialog + */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + $this->dialog->parent = $this; + return($this->dialog->execute()); + } + + /* Create Listbox with existing Zones + */ + $ZoneList = new divSelectBox("dNSZones"); + $ZoneList -> SetHeight(254); + + /* Add entries to divlist + */ + $editImg = ""; + if($this->acl_is_removeable()){ + $editImg.= ""; + } + + $link = "%s"; + foreach($this->Zones as $zone => $values ){ + $ZoneList->AddEntry(array( + array("string" => sprintf($link,base64_encode($zone),($zone))), + array("string" => sprintf($link,base64_encode($zone),_("Reverse zone")." : ".($values['ReverseZone']))), + array("string" => _("TTL")." : ".$values['sOAttl']), + array("string" => _("Class")." : ".$values['dNSClass']), + array("string" =>str_replace("%s",base64_encode($zone),$editImg)) + )); + } + + /* Display tempalte + */ + $smarty->assign("ZoneList",$ZoneList->DrawList()); + $display.= $smarty->fetch(get_template_path('servdns.tpl', TRUE)); + return($display); + } + + + /* Delete specified zone + */ + function RemoveZone($id) + { + $zones = $this->getUsedZoneNames(); + + if(isset($this->Zones[$id]['InitialReverseZone'])){ + $rev = DNS::FlipIp($this->Zones[$id]['InitialReverseZone']); + }else{ + $rev = DNS::FlipIp($this->Zones[$id]['ReverseZone']); + } + + $zonename = ""; + if(isset($this->Zones[$id]['InitialzoneName'])){ + $zonename= $this->Zones[$id]['InitialzoneName']; + } + + $used = array(); + + /* Add Records which use this zoneName + */ + if(isset($zones[$zonename])){ + $used = array_merge($used,$zones[$zonename]); + } + + /* Add Records which uses this reverse zone + */ + if(isset($zones[$rev.".in-addr.arpa"])){ + $used = array_merge($used,$zones[$rev.".in-addr.arpa"]); + } + + /* There are still entries using this configuration + * Abort deletion + */ + if(count($used)){ + $i = 2; + $str =""; + foreach($used as $dn){ + if($i > 0 && !preg_match("/,relativeDomainName=/",$dn)){ + $i --; + $name = preg_replace("/^[^=]+=([^,]*),.*$/","\\1",$dn); + $zone = preg_replace("/^.*zoneName=([^,]*),.*$/","\\1",$dn); + $str.= $name.".".$zone." "; + } + } + + /* Only show 2 dns in the error message + */ + if(count($used)> 2) { + $str .=" ... "; + } + print_red(sprintf(_("Can't delete the selected zone, because it is still in use by these entry/entries '%s'"),trim($str))); + return(false); + }else{ + unset($this->Zones[$id]); + return(true); + } + } + + + /* 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")); + while($attr = $ldap->fetch()){ + $ret[$attr['zoneName'][0]][] = $attr['dn']; + } + return($ret); + } + + + /* Remove dns service + */ + function remove_from_parent() + { + if($this->initially_was_account){ + $bool = true; + $this->is_account = FALSE; + foreach($this->Zones as $key => $zone){ + $bool= $bool & $this->RemoveZone($key); + } + + if($bool){ + $this->save(); + } + return($bool); + } + } + + + /* Save to LDAP */ + function save() + { + + /* Take over handling + * - Create list of zones managed by source server + * - Copy ldap entries to destination server + * - Remove old zone entries from source + */ + if($this->take_over_id != -1){ + $del = array(); + $id = $this->take_over_id; + $src = $this->dns_server_list['ENTRIES'][$id]['dn']; + $ldap = $this->config->get_ldap_link(); + $ldap->ls("(objectClass=dnsZone)",$src,array('cn')); + while($attrs = $ldap->fetch()){ + $src_zone = $attrs['dn']; + $dst_zone = preg_replace("/".normalizePreg($src)."$/",$this->dn,$src_zone); + $res = plugin::recursive_move($src_zone, $dst_zone); + + if($res){ + $del [] = $src_zone; + } + } + foreach($del as $src_zone){ + $ldap->rmdir_recursive($src_zone); + } + return; + } + + /* Save zone editor changes now */ + foreach($this->Zones as $name => $zone){ + if(isset($zone['zoneEditor'] ) && $zone['zoneEditor'] != NULL && is_object($zone['zoneEditor'])){ + $zone['zoneEditor']->save(); + unset($this->Zones[$name]['zoneEditor']);; + } + } + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + /* Get differences + */ + $old_dn = $this->orig_dn; + if($old_dn == "new"){ + $old_dn = $this->dn; + } + + $tmp = DNS::getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn); + + /* Update dns to current object dn */ + $tmp = DNS::getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn); + $tmp2 = array(); + foreach($tmp as $key1 => $data1){ + $tmp2[$key1] = array(); + foreach($data1 as $key2 => $data2){ + $tmp2[$key1][preg_replace("/".normalizePreg($old_dn)."$/",$this->dn,$key2)] = $data2; + } + } + $tmp = $tmp2; + + /* Updated zone entries if reverser or forward name has changed + * Must be done before moving entries, else the given dn is invalid + */ + if(isset($tmp['zoneUpdates'])){ + foreach($tmp['zoneUpdates'] as $dn => $attrs){ + $ldap->cd($dn); + $ldap->modify($attrs); + new log("modfiy","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Updating of system server/dns with dn '%s' failed."),$this->dn)); + } + } + + /* Delete dns + */ + foreach($tmp['del'] as $dn => $del){ + + $for = $del['InitialzoneName']; + $rev = DNS::FlipIp($del['InitialReverseZone']).".in-addr.arpa"; + + $ldap->cd($dn); + $ldap->rmdir_recursive($dn); + new log("remove","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/dns with dn '%s' failed."),$this->dn)); + + /* Handle Post events */ + if(preg_match("/^zoneName=/",$dn)){ +# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $for)); +# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $rev)); + } + } + + /* move follwoing entries + */ + foreach($tmp['move'] as $src => $dst){ + $this->recursive_move($src,$dst); + } + + /* Add || Update new DNS entries + */ + foreach($tmp['add'] as $dn => $attrs){ + $ldap->cd($dn); + $ldap->cat($dn, array('dn')); + if($ldap->fetch()){ + $ldap->cd($dn); + $ldap->modify ($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn)); + + /* Handle Post events */ + if(preg_match("/^zoneName=/",$dn)){ +# $this->handle_post_events("modify",array("dn" => $dn,"zoneName" => $attrs['zoneName'])); + } + }else{ + $ldap->cd($dn); + $ldap->add($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn)); + + /* Handle Post events */ + if(preg_match("/^zoneName=/",$dn)){ +# $this->handle_post_events("add",array("dn" => $dn,"zoneName" => $attrs['zoneName'])); + } + } + } + $this->handle_post_events("modify"); + } + + + /* Directly save new status flag */ + function setStatus($value) + { + if($value == "none") return; + if(!$this->initially_was_account) return; + if(empty($this->StatusFlag)) return; + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + + $tmp = $ldap->fetch(); + for($i = 0; $i < $tmp['objectClass']['count']; $i ++){ + $attrs['objectClass'][] = $tmp['objectClass'][$i]; + } + $flag = $this->StatusFlag; + $attrs[$flag] = $value; + $this->$flag = $value; + $ldap->modify($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for system server/dns with dn '%s' failed."),$this->dn)); + $this->action_hook(); + } + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("DNS service"); + $fields['AllowEdit'] = true; + return($fields); + } + + + /* Get updates for status flag */ + function updateStatusState() + { + if(empty($this->StatusFlag)) return; + + $attrs = array(); + $flag = $this->StatusFlag; + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->cn); + $ldap->cat($this->dn,array($flag)); + if($ldap->count()){ + $attrs = $ldap->fetch(); + } + if(isset($attrs[$flag][0])){ + $this->$flag = $attrs[$flag][0]; + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("DNS service"), + "plDescription" => _("DNS service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 83, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "zoneName" =>_("Zone name"), + "ReverseZone" =>_("Reverse zone"), + "sOAprimary" =>_("Primary dns server"), + "sOAmail" =>_("Mail address"), + "sOAserial" =>_("Serial"), + "sOArefresh" =>_("Refresh"), + "sOAretry" =>_("Retry"), + "sOAexpire" =>_("Expire"), + "sOAttl" =>_("TTL"), + "zoneRecords" =>_("Zone records")) + )); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZone.inc b/gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZone.inc new file mode 100644 index 000000000..6ccbade69 --- /dev/null +++ b/gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZone.inc @@ -0,0 +1,603 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("zoneName","ReverseZone","dNSClass", + "sOAprimary","sOAmail","sOAserial","sOArefresh","sOAretry","sOAexpire","sOAttl"); + var $objectclasses = array("whatever"); + + var $RecordTypes = array(); + + var $ReverseZone = ""; + var $zoneName = ""; + var $dNSClass = "IN"; + + var $sOAprimary = ""; + var $sOAmail = ""; + var $sOAserial = ""; + var $sOArefresh = "3600"; + var $sOAretry = "1800"; + var $sOAexpire = "720000"; + var $sOAttl = "6400"; + + var $Records = array(); + var $mXRecords = array(); + + var $OldZoneName = ""; // To detect changes made with this edit + var $OldReverseZone = ""; + + var $InitialReverseZone = ""; + var $InitialzoneName = ""; + var $NetworkClass = "A" ; // One out of A,B,C + + var $dialog = false; + + var $zoneEditor = NULL; + + var $isNew = true; + + var $ZoneObject = array(); + + function servdnseditZone (&$config, $dn= NULL,$attrs = array()) + { + plugin::plugin ($config, $dn); + + /* All types with required attrs */ + $this->RecordTypes = DNS::getDnsRecordTypes(true); + + if(!count($attrs)){ + $this->OldZoneName = ""; + $this->OldReverseZone = ""; + $this->isNew = true; + $this->sOAserial = date("Ymd")."1"; + + $this->InitialzoneName = "";//$attrs['InitialzoneName']; + $this->InitialReverseZone = "";//$attrs['InitialReverseZone']; + }else{ + $this->ZoneObject = $attrs; + + if(isset($attrs['zoneEditor'])){ + $this->zoneEditor = $attrs['zoneEditor']; + } + $this->OldZoneName = $attrs['zoneName']; + $this->OldReverseZone = $attrs['ReverseZone']; + + $this->InitialzoneName = $attrs['InitialzoneName']; + $this->InitialReverseZone = $attrs['InitialReverseZone']; + + $this->isNew = false; + + foreach($this->attributes as $value){ + $this->$value = $attrs[$value]; + } + + $this->sOAmail = preg_replace("/\./","@",$this->sOAmail,1); + $this->sOAmail = preg_replace("/\.$/","",$this->sOAmail); + $this->sOAprimary = preg_replace("/\.$/","",$this->sOAprimary); + $this->zoneName = preg_replace("/\.$/","",$this->zoneName); + + if(isset($attrs['RECORDS'])){ + $this->Records = $attrs['RECORDS']; + + $tmp2 = array(); + $usedPrio = array(); + foreach($this->Records as $key => $rec){ + if($rec['type'] == "mXRecord"){ + $tmp = split(" ",$rec['value']); + $rec['value'] = $tmp[1]; + $tmp2[$tmp[0]] = $rec; + unset($this->Records[$key]); + } + if($rec['type'] == "nSRecord"){ + unset($this->Records[$key]); + } + } + if(count($tmp2) != 0){ + reset($tmp2); + ksort($tmp2); + } + $this->mXRecords = $tmp2; + }else{ + $this->mXRecords = array(); + $this->Records = array(); + } + + $str = date("Ymd"); + if(preg_match("/^".$str."/",$this->sOAserial)){ + $this->sOAserial = $this->sOAserial + 1; + }else{ + $this->sOAserial = date("Ymd")."01"; + } + } + + /* Detect Network class */ + if(!empty($this->ReverseZone)){ + + $dots = count(split("\.",$this->ReverseZone)); + if($dots == 1){ + $this->NetworkClass = "A"; + $this->ReverseZone .= ".0.0.0"; + }elseif($dots == 2){ + $this->NetworkClass = "B"; + $this->ReverseZone .= ".0.0"; + }else{ + $this->NetworkClass = "C"; + $this->ReverseZone .= ".0"; + } + } + } + + /* TRansports the geiven Arraykey one position up*/ + function ArrayUp($atr,$attrs) + { + $ret = $attrs; + $pos = $atr ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == 1)||($pos >$cn))){ + $before = array_slice($attrs,0,($pos-2)); + $mitte = array_reverse(array_slice($attrs,($pos-2),2)); + $unten = array_slice($attrs,$pos); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + + /* TRansports the geiven Arraykey one position up*/ + function ArrayDown($atr,$attrs) + { + $ret = $attrs; + $pos = $atr ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == $cn))){ + $before = array_slice($attrs,0,($pos-1)); + $mitte = array_reverse(array_slice($attrs,($pos-1),2)); + $unten = array_slice($attrs,($pos+1)); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + /* Combine new array */ + function combineArrays($ar0,$ar1,$ar2) + { + $ret = array(); + if(is_array($ar0)) + foreach($ar0 as $ar => $a){ + $ret[]=$a; + } + if(is_array($ar1)) + foreach($ar1 as $ar => $a){ + $ret[]=$a; + } + if(is_array($ar2)) + foreach($ar2 as $ar => $a){ + $ret[]=$a; + } + return($ret); + } + + function getpos($atr,$attrs) + { + $i = 0; + foreach($attrs as $attr => $name) { + $i++; + if($attr == $atr){ + return($i); + } + } + return(-1); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + + + /* Fill templating stuff */ + $smarty= get_smarty(); + $ui = get_userinfo(); + + $smarty->assign("ACLs",$this->parent->getacl("")); + $display= ""; + + /* Open Zone Entry Edit Dialog + */ + if(!count($this->ZoneObject)){ + $smarty->assign("AllowZoneEdit" , false); + }else{ + $smarty->assign("AllowZoneEdit" , true); + if(isset($_POST['EditZoneEntries'])){ + if($this->zoneEditor == NULL){ + $this->zoneEditor= new servDNSeditZoneEntries($this->config,$this->dn,$this->ZoneObject); + $this->zoneEditor->parent = $this; + } + $this->dialog = $this->zoneEditor; + } + } + + /* Save Zone Entry Edit Dialog + */ + if(isset($_POST['SaveZoneEntryChanges'])){ + $this->dialog->save_object(); + if(count($this->dialog->check())){ + $msgs = $this->dialog->check(); + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + $this->zoneEditor = clone $this->dialog; + $this->dialog = FALSE; +# $rev = DNS::FlipIp(DNS::getNameFromMix($this->InitialReverseZone)).".in-addr.arpa"; +# $for = DNS::getNameFromMix($this->InitialzoneName); +# +# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $rev)); +# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $for)); +# $this->dialog = false; + } + } + + /* Cancel Zone Entrie Edit Dialog + */ + if(isset($_POST['CancelZoneEntryChanges'])){ + $this->dialog = false; + } + + /* Display any type of open dialogs + */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + $once =true; + foreach($_POST as $name => $value){ + if((preg_match("/^MXup_/",$name)) && ($once)){ + $once = false; + + $id = preg_replace("/^MXup_/","",$name); + $id = preg_replace("/_.*$/","",$id); + $id = base64_decode($id); + + $this->mXRecords = $this->ArrayUp(($id+1),$this->mXRecords); + } + if((preg_match("/^MXdown_/",$name)) && ($once)){ + $once = false; + + $id = preg_replace("/^MXdown_/","",$name); + $id = preg_replace("/_.*$/","",$id); + $id = base64_decode($id); + + $this->mXRecords = $this->ArrayDown(($id+1),$this->mXRecords); + } + if((preg_match("/^MXdel_/",$name)) && ($once)){ + $once = false; + + $id = preg_replace("/^MXdel_/","",$name); + $id = preg_replace("/_.*$/","",$id); + $id = base64_decode($id); + + unset($this->mXRecords[$id]); + + $tmp =array(); + foreach($this->mXRecords as $entry){ + $tmp[] = $entry; + } + + $this->mXRecords = $tmp; + } + } + + if((isset($_POST['AddMXRecord'])) && (!empty($_POST['StrMXRecord']))){ + $this->mXRecords[] = array("type"=>"mXRecord","value"=>trim($_POST['StrMXRecord'])); + } + + /* Handle Post events */ + $once = true; + foreach($_POST as $name => $value){ + + /* Delete record if requested */ + if((preg_match("/RemoveRecord_/",$name))&&($once)){ + $once = false; + $id= preg_replace("/RemoveRecord_/","",$name); + unset($this->Records[$id]); + } + } + + /* Add new Zonerecord */ + if(isset($_POST['AddNewRecord'])){ + $this->Records[] = array("type"=>"aRecord","value"=>""); + } + + /* Fill in values */ + foreach($this->attributes as $name){ + $smarty->assign($name,$this->$name); + } + + + $div = new divSelectBox("MxRecords"); + $div->setHeight(120); + $recs = $this->mXRecords; + + $oneup = " "; + $onedown = " "; + $onedel = " + "; + + foreach($recs as $key => $rec){ + $div ->AddEntry(array( + array("string"=>$rec['value']), +/* array("string"=>$key, + "attach"=>"style='width:20px;'"),*/ + array("string"=>str_replace("%s",base64_encode($key),$oneup.$onedown.$onedel), + "attach"=>"style='width:70px;border-right:0px;'") + )); + } + + /* Assign records list */ + $smarty->assign("NotNew", false); + $smarty->assign("Mxrecords", $div->DrawList()); + $smarty->assign("records" , $this->generateRecordsList()); + $smarty->assign("NetworkClass", $this->NetworkClass); + $smarty->assign("NetworkClasses", array("A"=>"255.0.0.0 (Class A)","B"=>"255.255.0.0 (Class B)","C"=>"255.255.255.0 (Class C)")); + + /* Display tempalte */ + $display.= $smarty->fetch(get_template_path('servdnseditzone.tpl', TRUE)); + return($display); + } + + function remove_from_parent() + { + } + + /* Save data to object */ + function save_object() + { + //plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + + foreach($this->Records as $id => $value){ + if(isset($_POST['RecordTypeSelectedFor_'.$id])){ + $this->Records[$id]['type'] = $_POST['RecordTypeSelectedFor_'.$id]; + } + if(isset($_POST['RecordValue_'.$id])){ + $this->Records[$id]['value'] = $_POST['RecordValue_'.$id]; + } + } + + if(isset($_POST['NetworkClass'])){ + $this->NetworkClass = $_POST['NetworkClass']; + } + + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Check if zoneName is already in use */ + $usedZones = $this->getUsedZoneNames(); + if(($this->isNew == true)||($this->zoneName != $this->InitialzoneName)||($this->ReverseZone != $this->InitialReverseZone)){ + /* if((isset($usedZones[$this->zoneName]))&&($this->zoneName != $this->InitialzoneName)){ + $message[] =_("This zoneName is already in use"); + } + if((in_array($this->ReverseZone,$usedZones))&&($this->ReverseZone != $this->InitialReverseZone)){ + $message[] =_("This reverse zone is already in use"); + }*/ + } + + if(empty($this->zoneName)){ + $message[] =sprintf(_("Please choose a valid zone name.")); + } + + if(empty($this->ReverseZone)){ + $message[] =sprintf(_("Please choose a valid reverse zone name.")); + } + + if($this->zoneName != strtolower($this->zoneName)){ + $message[] = _("Only lowercase strings are allowed as zone name."); + } + + if(!is_numeric($this->sOAserial)){ + $message[] = _("Please specify a numeric value for serial number."); + } + + if(!is_numeric($this->sOArefresh)){ + $message[] = _("Please specify a numeric value for refresh."); + } + + if(!is_numeric($this->sOAttl)){ + $message[] = _("Please specify a numeric value for ttl."); + } + + if(!is_numeric($this->sOAexpire)){ + $message[] = _("Please specify a numeric value for expire."); + } + + if(!is_numeric($this->sOAretry)){ + $message[] = _("Please specify a numeric value for retry."); + } + + foreach($this->Records as $name => $values){ + /* only lower-case is allowed in record entries ... */ + if($values['value'] != strtolower($values['value'])){ + $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']); + } + } + + /* Check class for given Zone Address */ + $addr = preg_replace("/^[^\/]*+\//","",$this->ReverseZone); + + /* Check for valid&complete IP address */ + if(!tests::is_ip($addr)){ + $message[] = _("The given network address is not a valid, please specify a valid IP address."); + } + + /* Check if given address matches selected network class */ + switch($this->NetworkClass){ + case 'A': { + if(!preg_match("/^[0-9]*\.0\.0\.0$/",$addr)){ + $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.0.0.0")); + } + } + break; + case 'B': { + if(!preg_match("/^[0-9]*\.[0-9]*\.0\.0$/",$addr)){ + $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.0.0")); + } + } + break; + case 'C': { + if(!preg_match("/^[0-9]*\.[0-9]*\.[0-9]*\.0$/",$addr)){ + $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.x.0")); + } + } + break; + default : $message[] =sprintf(_("The given network class '%s' is not valid."),$this->NetworkClass); + } + + return ($message); + } + + /* 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","tXTRecord")); + while($attr = $ldap->fetch()){ + if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){ + if(isset($attr['tXTRecord'][0])){ + $zn = preg_replace("/zoneName\=/","",$attr['tXTRecord'][0]); + $ret[$zn] =DNS::FlipIp(preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0])); + } + }else{ + $ret[$attr['zoneName'][0]]=""; + } + } + return($ret); + } + + /* Save to LDAP */ + function save() + { + $ret =array(); + foreach($this->attributes as $name){ + $ret[$name] = $this->$name; + } + + /* Create mx records + */ + foreach($this->mXRecords as $key => $rec){ + $rec['value']= $key." ".$rec['value']; + $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; + + $ret['sOAmail'] = preg_replace("/\@/",".",$this->sOAmail); + + foreach(array("sOAprimary","zoneName","sOAmail") as $attr){ + if(!preg_match("/\.$/",$ret[$attr])){ + if(!tests::is_ip($ret[$attr])){ + $ret[$attr] = $ret[$attr]."."; + } + } + } + + $ret['RECORDS'][] = array("type" => "nSRecord","value" => $ret['sOAprimary']) ; + + $ret['zoneEditor'] = $this->zoneEditor; + return($ret); + } + + + /* This function generate a table row for each used record. + This table row displays the recordtype in a select box + and the specified value for the record, and a remove button. + The last element of the table also got an 'add' button. + */ + function generateRecordsList($changeStateForRecords="") + { + $changeStateForRecords = ""; + + $str = ""; + foreach($this->Records as $key => $entry){ + + if($entry['type'] == "mXRecord") continue; + + $changeStateForRecords.= "changeState('RecordTypeSelectedFor_".$key."');\n"; + $changeStateForRecords.= "changeState('RecordValue_".$key."');\n"; + $changeStateForRecords.= "changeState('RemoveRecord_".$key."');\n"; + + $str.=" ". + " ". + " ". + " ". + ""; + } + + $str.= " ". + " ". + " ". + "
".$this->generateRecordListBox($entry['type'],"RecordTypeSelectedFor_".$key)."
". + " ". + "
"; + return($str); + } + + /* This function generates a select box out of $this->RecordTypes options. + The Parameter $selected is used to predefine an attribute. + $name is used to specify a post name + */ + function generateRecordListBox($selected,$name) + { + $str = ""; + return($str); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZoneEntries.inc b/gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZoneEntries.inc new file mode 100644 index 000000000..fffbd1052 --- /dev/null +++ b/gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZoneEntries.inc @@ -0,0 +1,498 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array("whatever"); + + var $Devices = array(); + + var $zoneName = ""; // ZoneName of currently edited Zone + var $reverseName = ""; // ReverseZone of the currently edited Zone + + var $RecordTypes = array(); // Possible record type. + + var $disableDialog = false; // Dialog will be disabled, if this zone is new + + function servDNSeditZoneEntries (&$config,$dn, &$zoneObject) + { + plugin::plugin ($config, $dn); + + /* Initialise class + */ + $this->RecordTypes = DNS::getDnsRecordTypes(); + $this->dn = "zoneName=".$zoneObject['InitialzoneName'].",".$dn; + $this->zoneName = $zoneObject['InitialzoneName']; + $this->reverseName = $zoneObject['InitialReverseZone']; + + /* Remove nSRecord from listed types */ + if(isset($this->RecordTypes['nSRecord'])){ + unset($this->RecordTypes['nSRecord']); + } + /* Remove nSRecord from listed types */ + if(isset($this->RecordTypes['pTRRecord'])){ + unset($this->RecordTypes['pTRRecord']); + } + + /* Get ldap connection + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + /* Get zone content + */ + $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$this->dn,array("relativeDomainName")); + + while($attrs = $ldap->fetch()){ + $this->Devices[$attrs['relativeDomainName'][0]] = DNS::getDNSHostEntries($config,$attrs['relativeDomainName'][0],true); + $this->Devices[$attrs['relativeDomainName'][0]]['OrigCn'] = $attrs['relativeDomainName'][0]; + } + + $ldap->cat($this->dn,array("objectClass")); + + $this->disableDialog = true; + if(count($this->Devices)|| $ldap->count()){ + $this->disableDialog = false; + } + } + + function execute() + { + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + $table = ""; + foreach($this->Devices as $key => $dev){ + $table .= $this->generateRecordConfigurationRow($key); + } + + $smarty->assign("disableDialog",$this->disableDialog); + $smarty->assign("table",$table);; + $display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE)); + return($display); + } + + + function save_object() + { + /* Check posts for operations ... + */ + $once = true; + $ptr_updates = array(); + foreach($_POST as $name => $value){ + + /* Add a new Record in given object + */ + + $tmp = preg_replace("/^.*_(.*)_.*$/","\\1",$name); + $tmp2 = split("\|",$tmp); + + /* Add new host entry + */ + if((preg_match("/^UserRecord_?/",$name)) && ($once)){ + $once = false; + $entry = DNS::getDNSHostEntries($this->config,"",true); + $entry['exists'] = true; + $entry['zoneName'] = strtoupper($this->attrs['cn'][0])."/".$this->zoneName; + $entry['RECORDS'][] = array("type" => "aRecord" , "value"=>""); + $this->Devices[_("New entry")] = $entry; + } + + if(count($tmp2) != 2) continue; + + $Name = base64_decode($tmp2[0]); + $RecordID = $tmp2[1]; + + /* Add new REcord + */ + if((preg_match("/^AddRecord_/",$name)) && ($once)){ + $once = false; + $this->Devices[$Name]['RECORDS'][] = $this->Devices[$Name]['RECORDS'][$RecordID]; + } + + /* Remove record from given dn + */ + if((preg_match("/^RemoveRecord_/",$name)) && ($once)){ + $once = false; + if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ + unset($this->Devices[$Name]['RECORDS'][$RecordID]); + } + + /* Check if there is at least one visible record. Else remove complete entry */ + $visible = false; + foreach($this->Devices[$Name]['RECORDS'] as $rec){ + if(in_array($rec['type'],$this->RecordTypes)){ + $visible = true; + break; + } + } + if(!$visible && isset($this->Devices[$Name]['RECORDS'])){ + $this->Devices[$Name]['RECORDS'] = array(); + } + } + } + + /* Possible attributes posted + */ + foreach($_POST as $name => $value){ + + /* Extract informations out of post name + */ + $tmp = preg_replace("/^.*_/","\\1",$name); + $tmp2 = split("\|",$tmp); + + if(count($tmp2) != 2) continue; + + $Name = base64_decode($tmp2[0]); + $RecordID = $tmp2[1]; + + /* Check for value change + */ + if(preg_match("/ValueSelection_/",$name)){ + if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ + + /* Update value */ + $old = $this->Devices[$Name]['RECORDS'][$RecordID]['value']; + $this->Devices[$Name]['RECORDS'][$RecordID]['value'] = $value; + + /* Handle pTRRecord */ + if(!isset($ptr_updates[$Name]) && $this->Devices[$Name]['RECORDS'][$RecordID]['type'] == "aRecord"){ + + $found = false; + $ip = $value; + $match = preg_replace("/^[^\/]*+\//","",$this->reverseName); + $ip = preg_replace("/^".normalizePreg($match)."/","",$ip); + $ip = preg_replace("/^\./","",$ip); + + foreach($this->Devices[$Name]['RECORDS'] as $key => $dev){ + if($dev['type'] == "pTRRecord"){ + $ptr_updates[$Name] = $Name; + $this->Devices[$Name]['RECORDS'][$key]['value'] = $ip; + $found = true; + break; + } + } + if(!$found){ + $dev = array('type'=> 'pTRRecord', 'value' => $ip); + $this->Devices[$Name]['RECORDS'][] = $dev; + } + } + } + } + + /* record type changed + */ + if(preg_match("/^RecordTypeSelection_/",$name)){ + if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ + $this->Devices[$Name]['RECORDS'][$RecordID]['type'] = $value; + } + } + } + + /* check for renamed entries + */ + foreach($_POST as $name => $value){ + + /* Extract informations out of post name + */ + $tmp = preg_replace("/^.*_/","\\1",$name); + $tmp2 = split("\|",$tmp); + + if(count($tmp2) != 2) continue; + + $Name = base64_decode($tmp2[0]); + $RecordID = $tmp2[1]; + + /* Host renamed + */ + if(preg_match("/RenameHost_/",$name)){ + if((isset($this->Devices[$Name])) && ($Name != $value)){ + + if(isset($this->Devices[$value])){ + print_red(sprintf(_("Can't rename '%s' to '%s' there is already an entry with the same name in our zone editing dialog."),$Name,$value)); + }else{ + $this->Devices[$value] = $this->Devices[$Name]; + unset($this->Devices[$Name]); + } + } + } + } + } + + + /* check something + */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + $names = array(); + foreach($this->Devices as $DevName => $device){ + + /* Don't need to check empty values ... */ + if(!count($device['RECORDS'])) continue; + + /* Checking entry name + */ + if(!preg_match("/^[a-z0-9_\.-]+$/i", $DevName) || (empty($DevName))){ + $message[] = sprintf(_("Entry name '%s' contains invalid characters."), $DevName); + } + + /* Renaming check for existing devices + */ + if(isset($device['OrigCn']) && ($DevName != $device['OrigCn'] )){ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); + if($ldap->count()){ + $message[] = sprintf(_("Can not rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$DevName); + } + }elseif(!isset($device['OrigCn'])){ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); + if($ldap->count()){ + $message[] = sprintf(_("Can not create '%s',the destination name already exists."),$DevName); + } + } + + /* Check names + */ + if(!isset($names[$DevName])){ + $names[$DevName] = ""; + }else{ + $message[] = sprintf(_("The name '%s' is used more than once."),$DevName); + } + + /* Names should be written in lowercase + */ +# if(strtolower($DevName) != $DevName){ +# $message[] = sprintf(_("The host name '%s' should be written in lowercase."), $DevName); +# } + + /* Check records + */ + $singleEntries = array("cNAMERecord","pTRRecord"); + + $tmp = array(); + $tmp2 = array(); + foreach($device['RECORDS'] as $Num => $Rec){ + + /* Check for multiple use of unique record types + */ + if(in_array($Rec['type'],$singleEntries)){ + if(!isset($tmp[$Rec['type']])){ + $tmp[$Rec['type']] = ""; + }else{ + $message[] = sprintf(_("The record type '%s' is a unique type and can't be defined twice."),$Rec['type']); + } + } + + /* Check for empty / duplicate entries in record array + */ + if(empty($Rec['value'])){ + $message[] = sprintf(_("There is an empty '%s' for host '%s'."),$Rec['type'],$DevName); + } + + /* Check for duplicate record entries + */ + if(!isset($tmp[$Rec['type']][$Rec['value']])){ + $tmp[$Rec['type']][$Rec['value']] = ""; + }else{ + $message[] = sprintf(_("There is a duplicate entry in '%s' for '%s'."),$Rec['type'],$DevName); + } + } + } + return ($message); + } + + function save() + { + if($this->disableDialog) return; + + $todo = array(); + + + + /* Create todolist + */ + foreach($this->Devices as $name => $dev){ + if(isset($dev['OrigCn'])){ + if(count($dev['RECORDS'])){ + $todo[] = DNS::getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name); + }else{ + $dev['exists'] = false; + $todo[] = DNS::getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name); + } + }else{ + if(count($dev['RECORDS'])){ + $todo[] = DNS::getDNSHostEntriesDiff($this->config,"",$dev,$name); + }else{ + $dev['exists'] = false; + $todo[] = DNS::getDNSHostEntriesDiff($this->config,"",$dev,$name); + } + } + } + + $tmp = array(); + $tmp['del'] = array(); + $tmp['add'] = array(); + $tmp['move'] = array(); + foreach($todo as $to){ + foreach($to as $type => $entries){ + $tmp[$type] = array_merge($tmp[$type],$entries); + } + } + + /* Get ldap link + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + + /* move follwoing entries + */ + foreach($tmp['move'] as $src => $dst){ + $this->recursive_move($src,$dst); + } + + /* Delete dns */ + foreach($tmp['del'] as $dn => $del){ + $ldap->cd($dn); + $ldap->rmdir_recursive($dn); + if(is_object($this->parent->parent)){ + $this->parent->parent->handle_post_events("remove",array("dn" => $dn)); + } + } + + /* Add || Update new DNS entries + */ + foreach($tmp['add'] as $dn => $attrs){ + $ldap->cd($dn); + $ldap->cat($dn, array('dn')); + if(count($ldap->fetch())){ + $ldap->cd($dn); + $ldap->modify ($attrs); + if(is_object($this->parent->parent)){ + $this->parent->parent->handle_post_events("modify",array("dn" => $dn)); + } + }else{ + $ldap->cd($dn); + $ldap->add($attrs); + if(is_object($this->parent->parent)){ + $this->parent->parent->handle_post_events("create",array("dn" => $dn)); + } + } + } + } + + + /* Create html table out of given entry + */ + function generateRecordConfigurationRow($objKey){ + + /* Get some basic informations + */ + $obj = $this->Devices[$objKey]; + $objectName = $objKey; + + /* Abort if emtpy + */ + if(count($obj['RECORDS']) == 0) return ""; + + /* Set title + */ + $str= "
"; + + $hostNameOnce = true; + + /* Walk through all defined records + */ + $str.= ""; + foreach($obj['RECORDS'] as $id => $record){ + + /* Skip not selectable entries */ + if(!isset($this->RecordTypes [$record['type']])) { + continue; + } + + /* Create unique post name + */ + $name = base64_encode($objKey)."|".$id; + + $str .= " + + + + "; + } + $str .="
\n"; + + /* Only first host entry name should be editable + */ + if($hostNameOnce){ + $hostNameOnce = false; + $str .="\n"; + } + + /* Create rest. Selectbox, icons ... + */ + $str .=" + + ".$this->createRecordTypeSelection($record['type'],$name)." + + + + + + "; + +# if($record['type'] == "aRecord"){ +# $str .=""; +# }else{ +# $str .= ""; +# } + + $str.= + "
"; + return($str); + } + + + /* Create selectbox with all available option types + */ + function createRecordTypeSelection($id,$refID){ + + $str = "\n"; + return($str); + } + + + function remove_from_parent() + { + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/dns/admin/systems/services/dns/servDNSeditZoneEntries.tpl b/gosa-plugins/dns/admin/systems/services/dns/servDNSeditZoneEntries.tpl new file mode 100644 index 000000000..9c0428c29 --- /dev/null +++ b/gosa-plugins/dns/admin/systems/services/dns/servDNSeditZoneEntries.tpl @@ -0,0 +1,27 @@ +

{t}This dialog allows you to configure all components of this DNS zone on a single list.{/t}

+

 

+{if $disableDialog} +
+ {t}This dialog can't be used until the currently edited zone was saved or the zone entry exists in the ldap database.{/t} + +{else} +
+ {$table} +
+ +{/if} + +

 

+
+

+ + +

+
+ + + diff --git a/gosa-plugins/dns/admin/systems/services/dns/servdns.tpl b/gosa-plugins/dns/admin/systems/services/dns/servdns.tpl new file mode 100644 index 000000000..6cfa50f09 --- /dev/null +++ b/gosa-plugins/dns/admin/systems/services/dns/servdns.tpl @@ -0,0 +1,63 @@ +{if $dns_take_over} + + + + +
+

{t}DNS take over initiated{/t}

+ {$warning} + {t}This includes 'all' DNS zones that are located within this server. Please double check if your really want to do this.{/t} +

+ {$warning2} +
+ +

+

+ {t}Following objects will be taken over{/t} : +

+

+

{$info}
+

+
+{else} + +{if $dns_server_list_cnt} + + + +{/if} + + + +
+ {t}Take over DNS configuration from{/t}  + + +
+

{t}Zones{/t}

+ {$ZoneList} + {if $is_createable} + + {else} + + {/if} +
+ + + + +{/if} +

 

+

+

+ +   + +
+

diff --git a/gosa-plugins/dns/admin/systems/services/dns/servdnseditzone.tpl b/gosa-plugins/dns/admin/systems/services/dns/servdnseditzone.tpl new file mode 100644 index 000000000..1136dba53 --- /dev/null +++ b/gosa-plugins/dns/admin/systems/services/dns/servdnseditzone.tpl @@ -0,0 +1,177 @@ +

{t}Generic{/t}

+ + + + + +
+ + + + + + + + + + + + + +
{t}Zone name{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Network address{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Netmask{/t} + +{render acl=$ACLs} + +{/render} +
+
+ + + + + +
+ {t}Zone records{/t} +
+ {if $AllowZoneEdit == false} + {t}Can't be edited because the zone wasn't saved right now.{/t} + {/if} +
+{render acl=$ACLs} + +{/render} +
+
+

 

+

{t}SOA record{/t}

+ + + + + +
+ + + + + + + + + + + + + +
{t}Primary dns server for this zone{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Mail address{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Serial number (automatically incremented){/t}{$must} + +{render acl=$ACLs} + +{/render} +
+
+ + + + + + + + + + + + + + + + + +
{t}Refresh{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Retry{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Expire{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}TTL{/t}{$must} + +{render acl=$ACLs} + +{/render} +
+
+ +

 

+
+ + + + + +
+

{t}MxRecords{/t}

+ + + + +
+{render acl=$ACLs} + {$Mxrecords} +{/render} +{render acl=$ACLs} + +{/render} +{render acl=$ACLs} + +{/render} +
+
+

{t}Global zone records{/t}

+{render acl=$ACLs} + {$records} +{/render} +
+
+

+{render acl=$ACLs} + +{/render} + +

+
+