From 6ecc560ffd21faac2efd8dec1999c026af8f1393 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Thu, 29 Dec 2005 11:45:39 -0500
Subject: [PATCH]
---
interface/web/dns/soa_edit.php | 2 +-
interface/web/dns/rr_edit.php | 28 +++++++++++++++++++++-------
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/interface/web/dns/rr_edit.php b/interface/web/dns/rr_edit.php
index 3b08dd1..7a5ea61 100644
--- a/interface/web/dns/rr_edit.php
+++ b/interface/web/dns/rr_edit.php
@@ -76,13 +76,13 @@
$update = 0;
if($old_record = $app->db->queryOneRecord("SELECT * FROM rr WHERE id = ".$this->dataRecord["id"])){
foreach($old_record as $key => $val){
- if($this->dataRecord[$key] != $val) $update += 1;
+ if($this->dataRecord[$key] != $val && isset($this->dataRecord[$key])) $update += 1;
}
} else { // new record
$update = 1;
}
- if($update > 0){
+ if($update > 0 && !in_array($soa['id'], $increased_serials)){
$new_serial = $app->validate_dns->increase_serial($serial);
$increased_serials[] = $soa['id'];
$app->db->query("UPDATE soa SET serial = '".$new_serial."' WHERE id = ".$this->dataRecord["zone"]);
@@ -119,24 +119,38 @@
// if IP address changes, delete/change old PTR record
if(!empty($old_record)){
list($oa, $ob, $oc, $od) = explode('.', $old_record['data']);
- if($a_rr_with_same_ip = $app->db->queryOneRecord("SELECT rr.*, soa.origin FROM rr, soa WHERE rr.type = 'A' AND rr.data = '".$old_record['data']."' AND rr.zone = soa.id AND soa.active = 'Y' AND rr.id != ".$this->dataRecord["id"])){
+
+ if($old_record['data'] == $this->dataRecord['data']){
+ $a_rr_with_same_ip = $this->dataRecord;
+ $a_rr_with_same_ip['origin'] = $soa['origin'];
+ } else {
+ $a_rr_with_same_ip = $app->db->queryOneRecord("SELECT rr.*, soa.origin FROM rr, soa WHERE rr.type = 'A' AND rr.data = '".$old_record['data']."' AND rr.zone = soa.id AND soa.active = 'Y' AND rr.id != ".$this->dataRecord["id"]);
+ }
+ $old_ptr_soa = $oc.'.'.$ob.'.'.$oa.'.in-addr.arpa.';
+ $old_ptr_soa_exist = $app->db->queryOneRecord("SELECT * FROM soa WHERE origin = '".$old_ptr_soa."'");
+
+ if($a_rr_with_same_ip){
if(substr($a_rr_with_same_ip['name'], -1) == '.'){
$new_ptr_soa_rr_data = $a_rr_with_same_ip['name'];
} else {
$new_ptr_soa_rr_data = $a_rr_with_same_ip['name'].(trim($a_rr_with_same_ip['name']) == '' ? '' : '.').$a_rr_with_same_ip['origin'];
}
- $app->db->query("UPDATE rr SET data = '".$new_ptr_soa_rr_data."' WHERE zone = '".$ptr_soa_exist['id']."' AND name = '".$od."' AND type = 'PTR'");
+ $app->db->query("UPDATE rr SET data = '".$new_ptr_soa_rr_data."' WHERE zone = '".$old_ptr_soa_exist['id']."' AND name = '".$od."' AND type = 'PTR'");
+ // increase serial
+ if(!in_array($old_ptr_soa_exist['id'], $increased_serials)){
+ $new_serial = $app->validate_dns->increase_serial($old_ptr_soa_exist['serial']);
+ $increased_serials[] = $old_ptr_soa_exist['id'];
+ $app->db->query("UPDATE soa SET serial = '".$new_serial."' WHERE id = ".$old_ptr_soa_exist['id']);
+ }
} else {
- $old_ptr_soa = $oc.'.'.$ob.'.'.$oa.'.in-addr.arpa.';
- $old_ptr_soa_exist = $app->db->queryOneRecord("SELECT * FROM soa WHERE origin = '".$old_ptr_soa."'");
$app->db->query("DELETE FROM rr WHERE zone = '".$old_ptr_soa_exist['id']."' AND name = '".$od."' AND type = 'PTR'");
- //die("DELETE FROM rr WHERE zone = '".$old_record['zone']."' AND name = '".$od."' AND type = 'PTR'");
if(!$app->db->queryOneRecord("SELECT * FROM rr WHERE zone = '".$old_ptr_soa_exist['id']."'")){
$app->db->query("DELETE FROM soa WHERE id = ".$old_ptr_soa_exist['id']);
} else {
// increase serial
if(!in_array($old_ptr_soa_exist['id'], $increased_serials)){
$new_serial = $app->validate_dns->increase_serial($old_ptr_soa_exist['serial']);
+ $increased_serials[] = $old_ptr_soa_exist['id'];
$app->db->query("UPDATE soa SET serial = '".$new_serial."' WHERE id = ".$old_ptr_soa_exist['id']);
}
}
diff --git a/interface/web/dns/soa_edit.php b/interface/web/dns/soa_edit.php
index ba9cf9f..dd4b180 100644
--- a/interface/web/dns/soa_edit.php
+++ b/interface/web/dns/soa_edit.php
@@ -77,7 +77,7 @@
$update = 0;
if($soa){
foreach($soa as $key => $val){
- if($this->dataRecord[$key] != $val && $key != 'active') $update += 1;
+ if($this->dataRecord[$key] != $val && $key != 'active' && isset($this->dataRecord[$key])) $update += 1;
}
} else { // new record
$update = 1;
--
Gitblit v1.9.1