From 3dedceddfe2d308d37ab06170cdfb05111d122bb Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Mon, 05 Dec 2005 13:03:58 -0500
Subject: [PATCH]
---
interface/web/dns/soa_edit.php | 54 +++++++++++++++++++++++++++
interface/lib/classes/validate_dns.inc.php | 11 +++++
2 files changed, 64 insertions(+), 1 deletions(-)
diff --git a/interface/lib/classes/validate_dns.inc.php b/interface/lib/classes/validate_dns.inc.php
index 2c6255f..cc3e9ff 100644
--- a/interface/lib/classes/validate_dns.inc.php
+++ b/interface/lib/classes/validate_dns.inc.php
@@ -76,8 +76,11 @@
$parts = explode(".", $field);
$i = 0;
+ $empty = 0;
foreach ($parts as $part){
$i++;
+
+ if(trim($part) == '') $empty += 1;
if(strlen($part) > 63) $error .= $desc." ".$app->tform->wordbook['error_63_characters']."<br>\r\n";
@@ -95,6 +98,12 @@
$error .= $desc." ".$app->tform->wordbook['error_no_wildcard_allowed']."<br>\r\n";
}
}
+ }
+
+ if(substr($field, -1) == '.'){
+ if($i > 2 && $empty > 1) $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
+ } else {
+ if($empty > 0) $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
}
if(substr($field, -1) == '.' && $area == 'Name'){
@@ -176,7 +185,7 @@
} else {
for($n = 0; $n < 4; $n++){
$q = $ip_parts[$n];
- if(!is_numeric($q) || (int)$q < 0 || (int)$q > 255) $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_a']."<br>\r\n";
+ if(!is_numeric($q) || (int)$q < 0 || (int)$q > 255 || trim($q) !== $q) $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_a']."<br>\r\n";
}
}
$rr['data'] = (int)$ip_parts[0].".".(int)$ip_parts[1].".".(int)$ip_parts[2].".".(int)$ip_parts[3];
diff --git a/interface/web/dns/soa_edit.php b/interface/web/dns/soa_edit.php
index 026576d..81f057b 100644
--- a/interface/web/dns/soa_edit.php
+++ b/interface/web/dns/soa_edit.php
@@ -108,11 +108,65 @@
} else {
$app->db->query("UPDATE soa SET serial = '".$new_serial."' WHERE id = ".$update_soa." AND origin NOT LIKE '%.in-addr.arpa.'");
}
+ $increased_serials[] = $u_soa['id'];
}
}
}
}
}
+
+
+ // PTR
+ if($conf['auto_create_ptr'] == 1 && trim($conf['default_ns']) != '' && trim($conf['default_mbox']) != ''){
+
+ if($soa['active'] = 'Y' && $this->dataRecord['active'][0] == 'N'){
+
+ if($soa_rrs = $app->db->queryAllRecords("SELECT * FROM rr WHERE zone = ".$this->dataRecord['id']." AND type = 'A'")){
+ foreach($soa_rrs as $soa_rr){
+ if(substr($soa_rr['name'], -1) == '.'){
+ $fqdn = $soa_rr['name'];
+ } else {
+ $fqdn = $soa_rr['name'].(trim($soa_rr['name']) == '' ? '' : '.').$this->dataRecord['origin'];
+ }
+ list($a, $b, $c, $d) = explode('.', $soa_rr['data']);
+ $ptr_soa = $c.'.'.$b.'.'.$a.'.in-addr.arpa.';
+ if($ptr = $app->db->queryOneRecord("SELECT soa.id, soa.serial FROM soa, rr WHERE rr.type = 'PTR' AND rr.data = '".$fqdn."' AND rr.zone = soa.id AND soa.origin = '".$ptr_soa."'")){
+ ############
+ if($a_rr_with_same_ip = $app->db->queryOneRecord("SELECT rr.*, soa.origin FROM rr, soa WHERE rr.type = 'A' AND rr.data = '".$soa_rr['data']."' AND rr.zone = soa.id AND soa.active = 'Y' AND rr.id != ".$soa_rr["id"]." AND rr.zone != '".$soa_rr['zone']."'")){
+ 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['id']."' AND name = '".$d."' AND type = 'PTR'");
+ } else {
+ $app->db->query("DELETE FROM rr WHERE zone = '".$ptr['id']."' AND name = '".$d."' AND type = 'PTR'");
+
+ if(!$app->db->queryOneRecord("SELECT * FROM rr WHERE zone = '".$ptr['id']."'")){
+ $app->db->query("DELETE FROM soa WHERE id = ".$ptr['id']);
+ } else {
+ // increase serial
+ if(!in_array($ptr['id'], $increased_serials)){
+ $new_serial = $app->validate_dns->increase_serial($ptr['serial']);
+ $app->db->query("UPDATE soa SET serial = '".$new_serial."' WHERE id = ".$ptr['id']);
+ $increased_serials[] = $ptr['id'];
+ }
+ }
+ }
+ ############
+ }
+ }
+ }
+
+ /* */
+
+
+ }
+
+ if($soa['active'] = 'N' && $this->dataRecord['active'][0] == 'Y'){
+
+ }
+ }
}
--
Gitblit v1.9.1