more validation for NS and SRV records; fix display of long records
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -18,7 +18,7 @@ if (! defined('AREA'))
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// This file is being included in admin_domains and customer_domains
|
// This file is being included in admin_domains and customer_domains
|
||||||
// and therefore does not need to require lib/init.php
|
// and therefore does not need to require lib/init.php
|
||||||
|
|
||||||
$domain_id = isset($_GET['domain_id']) ? (int) $_GET['domain_id'] : null;
|
$domain_id = isset($_GET['domain_id']) ? (int) $_GET['domain_id'] : null;
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ $domain = Database::pexecute_first($dom_stmt, array(
|
|||||||
'did' => $domain_id
|
'did' => $domain_id
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($domain['isbinddomain'] != '0') {
|
if ($domain['isbinddomain'] != '1') {
|
||||||
standard_error('dns_domain_nodns');
|
standard_error('dns_domain_nodns');
|
||||||
}
|
}
|
||||||
$domain = $idna_convert->decode($domain['domain']);
|
$domain = $idna_convert->decode($domain['domain']);
|
||||||
@@ -114,6 +114,17 @@ if ($action == 'add_record' && ! empty($_POST)) {
|
|||||||
}
|
}
|
||||||
// append trailing dot (again)
|
// append trailing dot (again)
|
||||||
$content .= '.';
|
$content .= '.';
|
||||||
|
} elseif ($type == 'NS') {
|
||||||
|
// check for trailing dot
|
||||||
|
if (substr($content, - 1) == '.') {
|
||||||
|
// remove it for checks
|
||||||
|
$content = substr($content, 0, - 1);
|
||||||
|
}
|
||||||
|
if (! validateDomain($content)) {
|
||||||
|
$errors[] = $lng['error']['dns_ns_invaliddom'];
|
||||||
|
}
|
||||||
|
// append trailing dot (again)
|
||||||
|
$content .= '.';
|
||||||
} elseif ($type == 'TXT' && ! empty($content)) {
|
} elseif ($type == 'TXT' && ! empty($content)) {
|
||||||
// check that TXT content is enclosed in " "
|
// check that TXT content is enclosed in " "
|
||||||
if (substr($content, 0, 1) != '"') {
|
if (substr($content, 0, 1) != '"') {
|
||||||
@@ -123,6 +134,9 @@ if ($action == 'add_record' && ! empty($_POST)) {
|
|||||||
$content .= '"';
|
$content .= '"';
|
||||||
}
|
}
|
||||||
} elseif ($type == 'SRV') {
|
} elseif ($type == 'SRV') {
|
||||||
|
if ($prio === null || $prio < 0) {
|
||||||
|
$errors[] = $lng['error']['dns_srv_prioempty'];
|
||||||
|
}
|
||||||
// check for trailing dot
|
// check for trailing dot
|
||||||
if (substr($content, - 1) == '.') {
|
if (substr($content, - 1) == '.') {
|
||||||
// remove it for checks
|
// remove it for checks
|
||||||
@@ -131,7 +145,11 @@ if ($action == 'add_record' && ! empty($_POST)) {
|
|||||||
// check only last part of content, as it can look like:
|
// check only last part of content, as it can look like:
|
||||||
// _service._proto.name. TTL class SRV priority weight port target.
|
// _service._proto.name. TTL class SRV priority weight port target.
|
||||||
$_split_content = explode(" ", $content);
|
$_split_content = explode(" ", $content);
|
||||||
$target = trim($_split_content[count($_split_content)-1]);
|
// SRV content must be [weight] [port] [target]
|
||||||
|
if (count($_split_content) != 3) {
|
||||||
|
$errors[] = $lng['error']['dns_srv_invalidcontent'];
|
||||||
|
}
|
||||||
|
$target = trim($_split_content[count($_split_content) - 1]);
|
||||||
if (! validateDomain($target)) {
|
if (! validateDomain($target)) {
|
||||||
$errors[] = $lng['error']['dns_srv_needdom'];
|
$errors[] = $lng['error']['dns_srv_needdom'];
|
||||||
} else {
|
} else {
|
||||||
@@ -167,9 +185,9 @@ if ($action == 'add_record' && ! empty($_POST)) {
|
|||||||
// sort by key
|
// sort by key
|
||||||
ksort($check_entry);
|
ksort($check_entry);
|
||||||
// format integer fields to real integer (as they are read as string from the DB)
|
// format integer fields to real integer (as they are read as string from the DB)
|
||||||
$check_entry['prio'] = (int)$check_entry['prio'];
|
$check_entry['prio'] = (int) $check_entry['prio'];
|
||||||
$check_entry['ttl'] = (int)$check_entry['ttl'];
|
$check_entry['ttl'] = (int) $check_entry['ttl'];
|
||||||
$check_entry['domain_id'] = (int)$check_entry['domain_id'];
|
$check_entry['domain_id'] = (int) $check_entry['domain_id'];
|
||||||
// serialize both
|
// serialize both
|
||||||
$check_entry = serialize($check_entry);
|
$check_entry = serialize($check_entry);
|
||||||
$new = serialize($new_entry);
|
$new = serialize($new_entry);
|
||||||
@@ -202,6 +220,12 @@ if ($action == 'add_record' && ! empty($_POST)) {
|
|||||||
|
|
||||||
// success message (inline)
|
// success message (inline)
|
||||||
$success_message = $lng['success']['dns_record_added'];
|
$success_message = $lng['success']['dns_record_added'];
|
||||||
|
|
||||||
|
unset($record);
|
||||||
|
unset($type);
|
||||||
|
unset($prio);
|
||||||
|
unset($content);
|
||||||
|
unset($ttl);
|
||||||
} else {
|
} else {
|
||||||
// show $errors
|
// show $errors
|
||||||
$errors = implode("<br>", $errors);
|
$errors = implode("<br>", $errors);
|
||||||
@@ -238,6 +262,7 @@ $entriescount = 0;
|
|||||||
if (! empty($dom_entries)) {
|
if (! empty($dom_entries)) {
|
||||||
$entriescount = count($dom_entries);
|
$entriescount = count($dom_entries);
|
||||||
foreach ($dom_entries as $entry) {
|
foreach ($dom_entries as $entry) {
|
||||||
|
$entry['content'] = wordwrap($entry['content'], 100, '<br>', true);
|
||||||
eval("\$existing_entries.=\"" . getTemplate("dns_editor/entry_bit", true) . "\";");
|
eval("\$existing_entries.=\"" . getTemplate("dns_editor/entry_bit", true) . "\";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1999,6 +1999,9 @@ $lng['error']['dns_mx_needdom'] = 'The MX content value must be a valid domain-n
|
|||||||
$lng['error']['dns_mx_noalias'] = 'The MX-content value cannot be an CNAME entry.';
|
$lng['error']['dns_mx_noalias'] = 'The MX-content value cannot be an CNAME entry.';
|
||||||
$lng['error']['dns_cname_invaliddom'] = 'Invalid domain-name for CNAME record';
|
$lng['error']['dns_cname_invaliddom'] = 'Invalid domain-name for CNAME record';
|
||||||
$lng['error']['dns_cname_nomorerr'] = 'There already exists a resource-record with the same record-name. It cannot be used as CNAME.';
|
$lng['error']['dns_cname_nomorerr'] = 'There already exists a resource-record with the same record-name. It cannot be used as CNAME.';
|
||||||
|
$lng['error']['dns_ns_invaliddom'] = 'Invalid domain-name for NS record';
|
||||||
|
$lng['error']['dns_srv_prioempty'] = 'Invalid SRV priority given';
|
||||||
|
$lng['error']['dns_srv_invalidcontent'] = 'Invalid SRV content, must contain of fields weight, port and target, e.g.: 5 5060 sipserver.example.com.';
|
||||||
$lng['error']['dns_srv_needdom'] = 'The SRV target value must be a valid domain-name';
|
$lng['error']['dns_srv_needdom'] = 'The SRV target value must be a valid domain-name';
|
||||||
$lng['error']['dns_srv_noalias'] = 'The SRV-target value cannot be an CNAME entry.';
|
$lng['error']['dns_srv_noalias'] = 'The SRV-target value cannot be an CNAME entry.';
|
||||||
$lng['error']['dns_duplicate_entry'] = 'Record already exists';
|
$lng['error']['dns_duplicate_entry'] = 'Record already exists';
|
||||||
|
|||||||
2
templates/Sparkle/dns_editor/entry_bit.tpl
vendored
2
templates/Sparkle/dns_editor/entry_bit.tpl
vendored
@@ -1,7 +1,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{$entry['record']}</td>
|
<td>{$entry['record']}</td>
|
||||||
<td>{$entry['type']}</td>
|
<td>{$entry['type']}</td>
|
||||||
<td><if $entry['prio'] <= 0> <else>{$entry['prio']}</if></td>
|
<td><if ($entry['prio'] <= 0 && $entry['type'] != 'MX' && $entry['type'] != 'SRV')> <else>{$entry['prio']}</if></td>
|
||||||
<td>{$entry['content']}</td>
|
<td>{$entry['content']}</td>
|
||||||
<td>{$entry['ttl']}</td>
|
<td>{$entry['ttl']}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user