index 21f4fe60541445810b09db8205d8cb7ef31c5731..1eeba0c359f2dd7ab00bb277ed32162e8b8f42bb 100644 (file)
$RecordTypes['rRSIGRecord'] = "rRSIGRecord";
$RecordTypes['nSECRecord'] = "nSECRecord";
$RecordTypes['rRSIGRecord'] = "rRSIGRecord";
$RecordTypes['nSECRecord'] = "nSECRecord";
+
/* Return all record types
*/
function getDnsRecordTypes($ForZones = false)
/* Return all record types
*/
function getDnsRecordTypes($ForZones = false)
}
}
-/* this is used to flip the ip address for example
- 12.3.45 -> 54.3.12
- Because some entries (like zones) are store like that 54.3.12.in-addr.arpa
+/* This fucntion is used to flip the ip address, for example
+ 12.3.45 -> 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.
*/
function FlipIp($ip)
but we want to display 12.3.45.
*/
function FlipIp($ip)
*/
function getDNSZoneEntries($config,$HostDn,$silent = false)
{
*/
function getDNSZoneEntries($config,$HostDn,$silent = false)
{
-
global $RecordTypes;
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
global $RecordTypes;
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
- /* Not all records are allowen within a zone entry
+ /* Not all records are allowed within a zone entry
*/
$SkipRecords = array("tXTRecord","cNAMERecord","pTRRecord");
*/
$SkipRecords = array("tXTRecord","cNAMERecord","pTRRecord");
*/
foreach($tmp_res as $attrs){
*/
foreach($tmp_res as $attrs){
- $zoneName = $attrs['zoneName'][0];
+ $zoneName = $attrs['zoneName'][0];
$Zones[$zoneName] = $ZoneBase;
$Zones[$zoneName]['exists'] = true;
$Zones[$zoneName] = $ZoneBase;
$Zones[$zoneName]['exists'] = true;
}
}
}
}
- /* Set initial zone name, to be able to detect if this entry is renamed
+ /* Set initial zone name, to be able to detect if this entry was renamed
*/
$Zones[$zoneName]['InitialzoneName'] = $zoneName;
*/
$Zones[$zoneName]['InitialzoneName'] = $zoneName;
unset($Zones[$zoneName]);
}else{
$tmp = $ldap->fetch();
unset($Zones[$zoneName]);
}else{
$tmp = $ldap->fetch();
- $Zones[$zoneName]['ReverseZone'] = FlipIp(str_replace(".in-addr.arpa","",$tmp['zoneName'][0]));
+ $Zones[$zoneName]['ReverseZone'] = FlipIp(str_replace(".in-addr.arpa","",$tmp['zoneName'][0]));
$Zones[$zoneName]['InitialReverseZone'] = FlipIp(str_replace(".in-addr.arpa","",$tmp['zoneName'][0]));
}
}
$Zones[$zoneName]['InitialReverseZone'] = FlipIp(str_replace(".in-addr.arpa","",$tmp['zoneName'][0]));
}
}
$zoneBase['dNSClass'] = "IN";
$zoneBase['sOARecord'] = "";
$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 ...
$PrePareZoneEntries = array();
/* Walk through all zones and detect renamed/added/deleted zones ...
/* Get old zone if available
*/
$oldZone=array();
/* Get old zone if available
*/
$oldZone=array();
- if(isset($oldZones[$zone['InitialzoneName']])){
+ if(!empty($oldZones[$zone['InitialzoneName']])){
$oldZone = $oldZones[$zone['InitialzoneName']];
}
$oldZone = $oldZones[$zone['InitialzoneName']];
}
}
/* The rest of our oldZones must be deleted
}
/* The rest of our oldZones must be deleted
- * because they wern't available in newZones anymore.
+ * because they are no longer available in newZones anymore.
*/
foreach($oldZones as $zone) {
$oldDn = "zoneName=".$zone['InitialzoneName'].",".$HostDn;
*/
foreach($oldZones as $zone) {
$oldDn = "zoneName=".$zone['InitialzoneName'].",".$HostDn;
$move = array();
$zones = getAvailableZones($config);
$move = array();
$zones = getAvailableZones($config);
-
$specialAttributes = array("cNAMERecord","pTRRecord");
$specialAttributes = array("cNAMERecord","pTRRecord");
-
$newRecords = array(); // Used to remember which records are removed
$newRecords = array(); // Used to remember which records are removed
-
- $zoneName = $newEntry['zoneName'];
- $zoneDn = getDNSZoneDN($config,$zoneName);
-
- $tmp = array_flip($zones);
-
+ $zoneName = $newEntry['zoneName'];
+ $zoneDn = getDNSZoneDN($config,$zoneName);
+ $tmp = array_flip($zones);
+
+ /* If reverseZone can't be resolved ... this
+ * can't be a valid entry, so remove this account
+ */
if(isset($tmp[$zoneName])){
$reverseName = $tmp[$zoneName];
$reverseDn = getDNSZoneDN($config,$reverseName);
if(isset($tmp[$zoneName])){
$reverseName = $tmp[$zoneName];
$reverseDn = getDNSZoneDN($config,$reverseName);
+ if(empty($reverseDn)){
+ $newEntry['exists'] = false;
+ }
}else{
$newEntry['exists'] = false;
}
/* Don't go further if there is nothing to do
}else{
$newEntry['exists'] = false;
}
/* 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));
*/
if(($newEntry['exists'] == false )&& ($oldEntry['exists'] == false)){
return(array("move"=>$move,"add"=>$add,"del"=>$del));
/* Check if zoneName has changed
*/
/* Check if zoneName has changed
*/
- if($oldEntry['zoneName'] != $newEntry['zoneName']){
- $oldzoneDn = getDNSZoneDN($config,$oldEntry['zoneName']);
- $dn = "relativeDomainName=".$oldName.",".$oldzoneDn;
- $dn2= "relativeDomainName=".$oldName.",".$zoneDn;
- $move[$dn]=$dn2;
- }
+ if(count($newEntry['RECORDS'])){
+ if($oldEntry['zoneName'] != $newEntry['zoneName']){
+ $oldzoneDn = 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;
+ /* 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
- */
+
+ /* 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();
}
}
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'])){
/* There must be at least one record in our entry
*/
if((!count($newEntry['RECORDS'])) || (!$newEntry['exists'])){
- $dn = "relativeDomainName=".$oldName.",".getDNSZoneDN($config,$oldEntry['zoneName']);
+ $dn = "relativeDomainName=".$newName.",".getDNSZoneDN($config,$oldEntry['zoneName']);
$del[$dn] ="";
$ret = array("move"=>$move,"add"=>$add,"del"=>$del);
return($ret);
$del[$dn] ="";
$ret = array("move"=>$move,"add"=>$add,"del"=>$del);
return($ret);
$ldap = $config->get_ldap_link();
$ldap->cd ($config->current['BASE']);
$ldap = $config->get_ldap_link();
$ldap->cd ($config->current['BASE']);
- restore_error_handler();
-
/* Search for zones ...
*/
$ldap->search("(&(objectClass=dNSZone)(sOARecord=*))",array("zoneName"));
/* Search for zones ...
*/
$ldap->search("(&(objectClass=dNSZone)(sOARecord=*))",array("zoneName"));