Skip to content
Snippets Groups Projects
Commit 3dedcedd authored by Falko Timme's avatar Falko Timme
Browse files

No commit message

No commit message
parent 4cfd9d0e
No related branches found
No related tags found
No related merge requests found
...@@ -76,9 +76,12 @@ function validate_field($field, $area, $zoneid, $wildcard_allowed = 1){ ...@@ -76,9 +76,12 @@ function validate_field($field, $area, $zoneid, $wildcard_allowed = 1){
$parts = explode(".", $field); $parts = explode(".", $field);
$i = 0; $i = 0;
$empty = 0;
foreach ($parts as $part){ foreach ($parts as $part){
$i++; $i++;
if(trim($part) == '') $empty += 1;
if(strlen($part) > 63) $error .= $desc." ".$app->tform->wordbook['error_63_characters']."<br>\r\n"; if(strlen($part) > 63) $error .= $desc." ".$app->tform->wordbook['error_63_characters']."<br>\r\n";
if(strspn($part, $valid_characters) != strlen($part)) $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n"; if(strspn($part, $valid_characters) != strlen($part)) $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
...@@ -97,6 +100,12 @@ function validate_field($field, $area, $zoneid, $wildcard_allowed = 1){ ...@@ -97,6 +100,12 @@ function validate_field($field, $area, $zoneid, $wildcard_allowed = 1){
} }
} }
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'){ if(substr($field, -1) == '.' && $area == 'Name'){
$soa = $app->db->queryOneRecord("SELECT * FROM soa WHERE id = ".$zoneid); $soa = $app->db->queryOneRecord("SELECT * FROM soa WHERE id = ".$zoneid);
if(substr($field, (strlen($field) - strlen($soa['origin']))) != $soa['origin']) $error .= $desc." ".$app->tform->wordbook['error_out_of_zone']."<br>\r\n"; if(substr($field, (strlen($field) - strlen($soa['origin']))) != $soa['origin']) $error .= $desc." ".$app->tform->wordbook['error_out_of_zone']."<br>\r\n";
...@@ -176,7 +185,7 @@ function validate_rr(&$rr){ ...@@ -176,7 +185,7 @@ function validate_rr(&$rr){
} else { } else {
for($n = 0; $n < 4; $n++){ for($n = 0; $n < 4; $n++){
$q = $ip_parts[$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]; $rr['data'] = (int)$ip_parts[0].".".(int)$ip_parts[1].".".(int)$ip_parts[2].".".(int)$ip_parts[3];
......
...@@ -108,11 +108,65 @@ class page_action extends tform_actions { ...@@ -108,11 +108,65 @@ class page_action extends tform_actions {
} else { } else {
$app->db->query("UPDATE soa SET serial = '".$new_serial."' WHERE id = ".$update_soa." AND origin NOT LIKE '%.in-addr.arpa.'"); $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'){
}
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment