Commit 571ca4e3 authored by Thom's avatar Thom 🛠
Browse files

Allow subnet for xfer and also notify (#3122)

parent 077c5704
......@@ -283,33 +283,52 @@ class validate_dns {
}
return $new_serial;
}
function validate_xfer($field_name, $field_value, $validator) {
function validate_ip($field_name, $field_value, $validator) {
global $app;
$errorMessage = '';
if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n';
if($validator['allowempty'] == 'y' && $field_value == '') {
//* Do nothing
} elseif ($field_value == 'any') {
//* Do nothing
} else {
//* Check if its a IPv4 or IPv6 address
//* Check if its a IPv4 or IPv6 address/range
if(isset($validator['separator']) && $validator['separator'] != '') {
//* When the field may contain several IP addresses, split them by the char defined as separator
$field_value_array = explode($validator['separator'], $field_value);
} else {
$field_value_array[] = $field_value;
}
// Check if it's a valid input
foreach($field_value_array as $field_value) {
$field_value = trim($field_value);
// Check if the IP is valid without range
$ip = strstr($field_value, '/', true) ?: $field_value;
if (strpos($field_value, '/') !== false) {
$subnet = strstr($field_value, '/', false);
$subnet = ltrim($subnet, "/");
}
if(function_exists('filter_var')) {
if(!filter_var($field_value, FILTER_VALIDATE_IP)) {
if(!filter_var($ip, FILTER_VALIDATE_IP)) {
$errmsg = $validator['errmsg'];
$errorMessage .= $app->tform->lng($errmsg)."<br />\r\n";
}
} else $this->errorMessage .= "function filter_var missing <br />\r\n";
// Check if the range is valid
if ($subnet !== '') {
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
if ($subnet < 1 || $subnet > 128) {
$errmsg = $validator['errmsg'];
$errorMessage .= $app->tform->lng($errmsg)."<br />\r\n";
}
}
elseif ($subnet < 1 || $subnet > 32) {
$errmsg = $validator['errmsg'];
$errorMessage .= $app->tform->lng($errmsg)."<br />\r\n";
}
}
}
}
return $errorMessage;
......
......@@ -244,18 +244,11 @@ $form["tabs"]['dns_soa'] = array (
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
'class' => 'validate_dns',
'function' => 'validate_xfer',
'function' => 'validate_ip',
'allowempty' => 'y',
'separator' => ',',
'errmsg'=> 'xfer_error_regex'),
),
/*
'validators' => array ( 0 => array ( 'type' => 'ISIP',
'allowempty' => 'y',
'separator' => ',',
'errmsg'=> 'xfer_error_regex'),
),
*/
'default' => '',
'value' => '',
'width' => '30',
......@@ -264,7 +257,9 @@ $form["tabs"]['dns_soa'] = array (
'also_notify' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'ISIP',
'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
'class' => 'validate_dns',
'function' => 'validate_ip',
'allowempty' => 'y',
'separator' => ',',
'errmsg'=> 'also_notify_error_regex'
......
......@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'NS has a invalid format.';
$wb['mbox_error_empty'] = 'Email is empty.';
$wb['mbox_error_regex'] = 'Email format invalid.';
$wb['also_notify_txt'] = 'Also Notify';
$wb['also_notify_error_regex'] = 'Please use an IP address.';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['update_acl_txt'] = 'Update ACL';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -23,7 +23,7 @@ $wb['mbox_error_empty'] = 'Полето с емайл е празно.';
$wb['mbox_error_regex'] = 'Полето е емайл е в грешен формат.';
$wb['also_notify_txt'] = 'Also Notify';
$wb['update_acl_txt'] = 'Обнови ACL';
$wb['also_notify_error_regex'] = 'Please use an IP address.';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
$wb['eg_ns1_domain_tld'] = 'e.g. ns1.domain.tld';
......@@ -34,7 +34,7 @@ $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'] = 'Минималния TTL е 60 секунди.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -25,8 +25,8 @@ $wb['ns_error_regex'] = 'NS has a invalid format.';
$wb['mbox_error_empty'] = 'Email is empty.';
$wb['mbox_error_regex'] = 'Email format invalid.';
$wb['also_notify_txt'] = 'Also Notify';
$wb['also_notify_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Xfer: Please use one or more IP addresses, separated by , or use the keyword: any';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['update_acl_txt'] = 'Update ACL';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
......
......@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'Nimipalvelin-kenttä on tyhjä.';
$wb['mbox_error_empty'] = 'Sähköpostiosoite on tyhjä.';
$wb['mbox_error_regex'] = 'Sähköpostiosoite on vääränlainen';
$wb['also_notify_txt'] = 'Läheta ilmoitus';
$wb['also_notify_error_regex'] = 'Please use an IP address.';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['update_acl_txt'] = 'Päivitä ACL';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'NS has a invalid format.';
$wb['mbox_error_empty'] = 'Email is empty.';
$wb['mbox_error_regex'] = 'Email format invalid.';
$wb['also_notify_txt'] = 'Also Notify';
$wb['also_notify_error_regex'] = 'Please use an IP address.';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['update_acl_txt'] = 'Update ACL';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'Format NS salah.';
$wb['mbox_error_empty'] = 'Email kosong.';
$wb['mbox_error_regex'] = 'Format Email tidak valid.';
$wb['also_notify_txt'] = 'Notifikasi Juga';
$wb['also_notify_error_regex'] = 'Please use an IP address.';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['update_acl_txt'] = 'Mutakhirkan ACL';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'NS が不正な文字を含んでいます。';
$wb['mbox_error_empty'] = 'メールアドレスを指定してください';
$wb['mbox_error_regex'] = 'メールアドレスの形式が不正です。';
$wb['also_notify_txt'] = 'Also Notify';
$wb['also_notify_error_regex'] = 'Please use an IP address.';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['update_acl_txt'] = 'Update ACL';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'NS heeft een ongeldig format.';
$wb['mbox_error_empty'] = 'E-mail is niet ingvuld.';
$wb['mbox_error_regex'] = 'E-mail formaat ongeldig.';
$wb['also_notify_txt'] = 'ook notifcatie';
$wb['also_notify_error_regex'] = 'Please use an IP address.';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['update_acl_txt'] = 'Update ACL';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'NS tem um formato inválido.';
$wb['mbox_error_empty'] = 'Correio está em branco.';
$wb['mbox_error_regex'] = 'Correio com formato inválido.';
$wb['also_notify_txt'] = 'Also Notify';
$wb['also_notify_error_regex'] = 'Please use an IP address.';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['update_acl_txt'] = 'Actualizar ACL';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'NS are un format invalid';
$wb['mbox_error_empty'] = 'Email-ul este gol';
$wb['mbox_error_regex'] = 'Format email invalid.';
$wb['also_notify_txt'] = 'Also Notify';
$wb['also_notify_error_regex'] = 'Please use an IP address.';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['update_acl_txt'] = 'Update ACL';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
......@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'NS má neplatný formát.';
$wb['mbox_error_empty'] = 'Email je prázdny.';
$wb['mbox_error_regex'] = 'Email má neplatný formát.';
$wb['also_notify_txt'] = 'Also Notify';
$wb['also_notify_error_regex'] = 'Please use an IP address.';
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['update_acl_txt'] = 'Update ACL';
$wb['seconds_txt'] = 'Seconds';
$wb['eg_domain_tld'] = 'e.g. domain.tld';
......@@ -34,7 +34,7 @@ $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.';
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';
......
Supports Markdown
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