From dd2486d45d50b1d0c763592818b3340642bfbfb7 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 22 Oct 2009 12:46:03 +0000 Subject: [PATCH] Added method to touch a dnsZone - which then encreases the zones SOA Number git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14616 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/services/dns/class_DNS.inc | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc b/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc index 5976e813a..1e7c288e4 100644 --- a/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc +++ b/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc @@ -694,6 +694,62 @@ class DNS } return($runtime_cache['DNS']['getAvailableZones']); } + + + static function touchDNSZone($config,$zoneName) + { + if(empty($zoneName)){ + return null; + } + + preg_match('@(?[^/]*)/(?.*)@',$zoneName,$matches); + $name = $matches['name']; + $server = strtolower($matches['server']); + + // Search for the zone entry and its reverse entry. + $ldap = $config->get_ldap_link(); + $ldap-> cd($config->current['BASE']); + $ldap->search("(&(objectClass=dNSZone)(zoneName=$name)(sOARecord=*))",array("sOARecord")); + if($ldap->count() != 1){ + trigger_error("Invalid Zone ".$zoneName); + }else{ + $to_update= array(); + $forward = $ldap->fetch(); + $to_update[$forward['dn']] = $forward; + $ldap->cd($forward['dn']); + $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@)(sOARecord=*))",array("sOARecord")); + + // We may have multiple reverse zones later. + while($attrs = $ldap->fetch()){ + $to_update[$attrs['dn']] = $attrs; + } + + // Increase the sAONumber for each zone + foreach($to_update as $zone){ + $tmp = explode(' ',$zone['sOARecord'][0]); + $sOA = $tmp[2]; + $sOAdate = substr($sOA,0,8); + $sOAnumber = substr($sOA,-2); + $date = date('Ymd'); + $number = '01'; + if($sOAdate < $date){ + $sOA = $date.$number; + } else { + $number = sprintf("%02d", $sOAnumber+1); + $sOA = $sOAdate.$number; + } + $tmp[2] = $sOA; + $zone['sOARecord'][0] = implode(' ', $tmp); + $attrs = array('sOARecord' => $zone['sOARecord'][0]); + $ldap = $config->get_ldap_link(); + $ldap->cd($zone['dn']); + $ldap->modify($attrs); + if (!$ldap->success()){ + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_DEL, get_class())); + } + } + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> -- 2.30.2