summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3ab2e98)
raw | patch | inline | side by side (parent: 3ab2e98)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 6 Feb 2006 13:33:29 +0000 (13:33 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 6 Feb 2006 13:33:29 +0000 (13:33 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2628 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/systems/class_servDNS.inc | patch | blob | history | |
plugins/admin/systems/class_servDNSeditZone.inc | patch | blob | history |
index adc3aa6730286c8a310256652a2e9999e552238b..121b4318a4d3f2e93fda3f41e766e18c488cea20 100644 (file)
$this->RecordTypes['nSECRecord'] = "nSECRecord"; // ok
$this->cn = $this->attrs['cn'][0];
-
$types = array();
/* Get all records */
$this->usedDNS[$attrs['dn']] = $attrs['dn'];
if((isset($attrs['tXTRecord'][0]))&&(preg_match("/zoneName\=/",$attrs['tXTRecord'][0]))){
$zoneName= preg_replace("/zoneName\=/","",$attrs['tXTRecord'][0]);
- $types[$zoneName]['ReverseZone'] = preg_replace("/\.in\-addr\.arpa/","",$attrs['zoneName'][0]);
+ $z = preg_replace("/\.in\-addr\.arpa/","",$attrs['zoneName'][0]);
+
+ $z = $this->FlipIp($z);
+
+ $types[$zoneName]['ReverseZone'] = $z;
$types[$zoneName]['ReverseDN'] = $attrs['dn'];
}else{
$this->DNSinitially_was_account = $this->is_account;
}
+ function FlipIp($ip)
+ {
+ $tmp = array_reverse(split("\.",$ip));
+ $new = "";
+ foreach($tmp as $section){
+ $new .= $section.".";
+ }
+ return(preg_replace("/.$/","",$new));
+ }
+
function execute()
{
/* Call parent execute */
return ($display);
}
+ /* Edited or Added zone hould be saved saved */
if(isset($_POST['SaveZoneChanges'])){
$this->dialog->save_object();
+ /* Check if noting went wrong */
if(count($this->dialog->check())){
foreach($this->dialog->check() as $msgs){
print_red($msgs);
}
}else{
-
+
+ /* add new/edited zone */
$ret = $this->dialog->save();
unset($this->Zones[$this->dialog->InitiallyZoneName]);
$this->Zones[$ret['zoneName']] = $ret;
/* 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);
$this->dialog= new servdnseditZone($this->config,$this->dn,$this->RecordTypes,$this->Zones[$tmp]);
}
+ /* check posts for delete zone */
if(preg_match("/^delZone_/",$name)&&!$once){
$once =true;
$tmp = preg_replace("/^delZone_/","",$name);
}
}
+ /* Show dialog */
if($this->dialog!= NULL){
$this->dialog->save_object();
$this->dialog->parent = $this;
return($display);
}
+ /* Remove dns service */
function remove_from_parent()
{
$ldap = $this->config->get_ldap_link();
/* Save to LDAP */
function save()
{
+ /* Ldap conenction / var initialization */
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
-
$actions =array("update"=>array(),"add"=>array(),"delete"=>array());
+ /* Generate entries for all zones, and check if they must be updated deleted added */
foreach($this->Zones as $zone){
+
+ /* Get ldap syntax */
$tmp = $this->generate_LDAP_entries($zone);
+
+ /* Check if dn is new, or if entry was edited */
foreach($tmp as $key => $values){
if(isset($this->usedDNS[$key])){
$actions['update'][$key]=$values;
}
}
}
+
+ /* Check which dns are not used anymore ...*/
foreach($this->usedDNS as $key => $values){
$actions['delete'][$key] = $values;
}
+ /* Remove deleted zones */
foreach($actions['delete'] as $dn => $attrs){
$ldap->cd($dn);
$ldap->rmdir_recursive($dn);
}
+ /* Add new zones */
foreach($actions['add'] as $dn => $attrs){
$ldap->cd($this->config->current['BASE']);
// $ldap->create_missing_trees($dn);
$ldap->add($attrs);
}
+ /* Update existing entries */
foreach($actions['update'] as $dn => $attrs){
$ldap->cd($dn);
$ldap->modify($attrs);
}
+ /* This function generates ldap friendly output
+ of all changes for a single zone (reverse and forward)
+ */
function generate_LDAP_entries($zone)
{
$tmp = array();
$tmp['sOARecord'] = $str;
- /* Generate some attrs */
+ /* Generate Record entries */
$arr = array("SigRecord","KeyRecord","aAAARecord","nSRecord","iaFSDBRecord","mInfoRecord","hInfoRecord","mXRecord","mDRecord","tXTRecord",
"LocRecord","nXTRecord","sRVRecord","nAPTRRecord","kXRecord","certRecord","a6Record","dSRecord","sSHFPRecord","rRSIGRecord","nSECRecord");
$aRecords = array();
}
}
}
+
+ /* Check if there are records removed,
+ if there are some removed records, the append an array
+ to ensure that these record types are deleted
+ */
if((isset($zone['Records']))&&(is_array($zone['Records']))){
foreach($zone['Records'] as $type){
if(isset($type['inittype'])){
}
}
}
+ /* generate forward entry */
$dn = "zoneName=".$zone['zoneName'].",".$this->dn;
$tmp2[$dn] = $tmp;
$tmp2[$dn]['zoneName'] = $zone['zoneName'];
- $dn = "zoneName=".$zone['ReverseZone'].".in-addr.arpa,".$this->dn;
+
+ /* generate reverse entry */
+ $dn = "zoneName=".$this->FlipIp($zone['ReverseZone']).".in-addr.arpa,".$this->dn;
$tmp2[$dn] = $tmp;
$tmp2[$dn]['tXTRecord'] ="zoneName=".$zone['zoneName'];
- $tmp2[$dn]['zoneName'] = $zone['ReverseZone'].".in-addr.arpa";
+ $tmp2[$dn]['zoneName'] = $this->FlipIp($zone['ReverseZone']).".in-addr.arpa";
return($tmp2);
}
diff --git a/plugins/admin/systems/class_servDNSeditZone.inc b/plugins/admin/systems/class_servDNSeditZone.inc
index e8a47f35fb0373fa251ef7c2a3bf4c213a1979a0..49e904d71014f17f1c0fba5573b910628346db4f 100644 (file)
while($attr = $ldap->fetch()){
if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){
$zn = preg_replace("/zoneName\=/","",$attr['tXTRecord'][0]);
- $ret[$zn] = preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0]);
+ $ret[$zn] = $this->FlipIp(preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0]));
}else{
$ret[$attr['zoneName'][0]]="";
}
}
return($ret);
}
-
+
+
+ function FlipIp($ip)
+ {
+ $tmp = array_reverse(split("\.",$ip));
+ $new = "";
+ foreach($tmp as $section){
+ $new .= $section.".";
+ }
+ return(preg_replace("/.$/","",$new));
+ }
+
/* Save to LDAP */
function save()