summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 306cf5d)
raw | patch | inline | side by side (parent: 306cf5d)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 21 Dec 2009 13:26:12 +0000 (13:26 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 21 Dec 2009 13:26:12 +0000 (13:26 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14919 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZoneEntries.inc | patch | blob | history |
diff --git a/gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZoneEntries.inc b/gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZoneEntries.inc
index 3303f9b9fac07ee28b7a4ed1392df18144701531..20d00699e4f2934d89df2c29e70b5d751f1a81a1 100644 (file)
foreach($device['RECORDS'] as $Num => $Rec){
/* Check values */
- if ($Rec['type'] != "pTRRecord") {
- $msg= $this->checkRecordType($DevName, $Rec['type'], $Rec['value']);
- if ($msg != "") {
- $message[]= $msg;
- }
- }
+ $message += $this->checkRecordType($DevName, $Rec['type'], $Rec['value']);
/* Check for multiple use of unique record types
*/
/* Check record types for strange inputs */
function checkRecordType($name, $type, $value)
{
- $checks= array(
- "aRecord" => "/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"
- );
-
- /* No check for entry */
- if (!isset($checks[$type])) {
- return "";
+ $template = _("The syntax of entry %s (record type %s, value %s) is invalid!")." %s<br><br><i>"._("Example").":</i> %s";
+
+ $message = Array();
+ switch($type) {
+ case 'aAAARecord': // RFC 3596
+ if(!tests::is_dns_name($name)) {
+ $message[] = sprintf($template, $name, $type, $value, _("Entry should be a DNS name."), "example");
+ }
+ if(!tests::is_ipv6($value)) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value should be an IPv6 address."), "1fff:0000:0a88:85a3:0000:0000:ac1f:8001");
+ }
+ break;
+ case 'aRecord': // RFC 1035
+ if(!tests::is_dns_name($name)) {
+ $message[] = sprintf($template, $name, $type, $value, _("Entry should be a DNS name."), "example");
+ }
+ if(!tests::is_ip($value)) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value should be an IPv4 address."), "192.168.1.10");
+ }
+ break;
+ case 'cNAMERecord': // RFC 1035
+ if(!tests::is_dns_name($name)) {
+ $message[] = sprintf($template, $name, $type, $value, _("Entry should be a DNS name."), "example");
+ }
+ if(!tests::is_dns_name($value)) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value should be a DNS name."), "example");
+ }
+ break;
+ case 'mXRecord': // RFC 1035
+ //value: preference target
+ if(preg_match('/^(\S+)\s+(\S+)$/', $value, $matches)) {
+ if(!tests::is_id($matches[1])) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value 1 should be a number."), "10 example");
+ }
+ if(!tests::is_dns_name($matches[2])) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value 2 should be a DNS name."), "10 example");
+ }
+ } else {
+ $message[] = sprintf($template, $name, $type, $value, _("Value should be composed of 'preference target'."), "10 example");
+ }
+ break;
+ case 'nSRecord': // RFC 1035
+ if(!tests::is_dns_name($value)) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value should be a DNS name."), "example");
+ }
+ break;
+ case 'pTRRecord': // RFC 1035
+ if(!tests::is_dns_name($value)) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value should be a DNS name."), "example");
+ }
+ break;
+ case 'sRVRecord': // RFC 2782
+ if(!tests::is_dns_name($name)) {
+ $message[] = sprintf($template, $name, $type, $value, _("Entry should be a DNS name."), "example");
+ }
+ //value: priority weight port target
+ if(preg_match('/^([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(\S+)$/', $value, $matches)) {
+ if(!tests::is_id($matches[1])) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value 1 (priority) should be a number."), "0 5 5060 example");
+ }
+ if(!tests::is_id($matches[2])) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value 2 (weight) should be a number."), "0 5 5060 example");
+ }
+ if(!tests::is_id($matches[3])) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value 3 (port) should be a number."), "0 5 5060 example");
+ }
+ if(!tests::is_dns_name($matches[4])) {
+ $message[] = sprintf($template, $name, $type, $value, _("Value 4 (target) should be a DNS name."), "0 5 5060 example");
+ }
+ } else {
+ $message[] = sprintf($template, $name, $type, $value, _("Value should be composed of 'priority weight port target'."), "0 5 5060 example");
+ }
+ break;
}
-
- /* Else check ;-) */
- if (!preg_match($checks[$type], $value)) {
- return (sprintf("The syntax of entry %s (record type %s, value %s) is invalid!", $name, $type, $value));
- }
+ return $message;
}