Commit b8fe562e authored by tbrehm's avatar tbrehm

- Implemented new range validator for form fields in tform.inc.php

- Implemented: FS#1935 - Add minimum allowed seconds Value for DNS zone records
parent a79341a3
......@@ -551,6 +551,27 @@ class remoting_lib {
}
}
}
break;
case 'RANGE':
//* Checks if the value is within the given range or above / below a value
//* Range examples: < 10 = ":10", between 2 and 10 = "2:10", above 5 = "5:".
$range_parts = explode(':',trim($validator['range']));
$ok = true;
if($range_parts[0] != '' && $field_value < $range_parts[0]) {
$ok = false;
}
if($range_parts[1] != '' && $field_value > $range_parts[1]) {
$ok = false;
}
if($ok != true) {
$errmsg = $validator['errmsg'];
if(isset($this->wordbook[$errmsg])) {
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
} else {
$this->errorMessage .= $errmsg."<br />\r\n";
}
}
unset($range_parts);
break;
case 'CUSTOM':
// Calls a custom class to validate this record
......
......@@ -931,6 +931,27 @@ class tform {
}
}
}
break;
case 'RANGE':
//* Checks if the value is within the given range or above / below a value
//* Range examples: < 10 = ":10", between 2 and 10 = "2:10", above 5 = "5:".
$range_parts = explode(':',trim($validator['range']));
$ok = true;
if($range_parts[0] != '' && $field_value < $range_parts[0]) {
$ok = false;
}
if($range_parts[1] != '' && $field_value > $range_parts[1]) {
$ok = false;
}
if($ok != true) {
$errmsg = $validator['errmsg'];
if(isset($this->wordbook[$errmsg])) {
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
} else {
$this->errorMessage .= $errmsg."<br />\r\n";
}
}
unset($range_parts);
break;
case 'CUSTOM':
// Calls a custom class to validate this record
......
......@@ -135,6 +135,10 @@ $form["tabs"]['dns_soa'] = array (
'refresh' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'RANGE',
'range' => '60:',
'errmsg'=> 'refresh_range_error'),
),
'default' => '7200',
'value' => '',
'width' => '10',
......@@ -143,6 +147,10 @@ $form["tabs"]['dns_soa'] = array (
'retry' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'RANGE',
'range' => '60:',
'errmsg'=> 'retry_range_error'),
),
'default' => '540',
'value' => '',
'width' => '10',
......@@ -151,6 +159,10 @@ $form["tabs"]['dns_soa'] = array (
'expire' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'RANGE',
'range' => '60:',
'errmsg'=> 'expire_range_error'),
),
'default' => '604800',
'value' => '',
'width' => '10',
......@@ -159,6 +171,10 @@ $form["tabs"]['dns_soa'] = array (
'minimum' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'RANGE',
'range' => '60:',
'errmsg'=> 'minimum_range_error'),
),
'default' => '86400',
'value' => '',
'width' => '10',
......@@ -167,6 +183,10 @@ $form["tabs"]['dns_soa'] = array (
'ttl' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'RANGE',
'range' => '60:',
'errmsg'=> 'ttl_range_error'),
),
'default' => '3600',
'value' => '',
'width' => '10',
......
......@@ -29,4 +29,9 @@ $wb['eg_domain_tld'] = 'e.g. domain.tld';
$wb['eg_ns1_domain_tld'] = 'e.g. ns1.domain.tld';
$wb['eg_webmaster_domain_tld'] = 'e.g. webmaster@domain.tld';
$wb['The Domain can not be changed. Please ask your Administrator if you want to change the domain name.'] = 'The Domain can not be changed. Please ask your Administrator if you want to change the domain name.';
$wb['refresh_range_error'] = 'Min. Refresh time is 60 seconds.';
$wb['retry_range_error'] = 'Min. Retry time is 60 seconds.';
$wb['expire_range_error'] = 'Min. Expire time is 60 seconds.';
$wb['minimum_range_error'] = 'Min. Minimum time is 60 seconds.';
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
?>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment