From 1e45da277b6e28ff65967d38c12b298872efb059 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Fri, 01 Aug 2008 17:37:59 -0400
Subject: [PATCH] Added translation functions for the tabs of forms.

---
 interface/lib/classes/validate_dns.inc.php |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/interface/lib/classes/validate_dns.inc.php b/interface/lib/classes/validate_dns.inc.php
index bca195f..a161510 100644
--- a/interface/lib/classes/validate_dns.inc.php
+++ b/interface/lib/classes/validate_dns.inc.php
@@ -76,8 +76,11 @@
 
   $parts = explode(".", $field);
   $i = 0;
+  $empty = 0;
   foreach ($parts as $part){
     $i++;
+
+    if(trim($part) == '') $empty += 1;
 
     if(strlen($part) > 63) $error .= $desc." ".$app->tform->wordbook['error_63_characters']."<br>\r\n";
 
@@ -95,6 +98,12 @@
         $error .= $desc." ".$app->tform->wordbook['error_no_wildcard_allowed']."<br>\r\n";
       }
     }
+  }
+
+  if(substr($field, -1) == '.'){
+    if($i > 2 && $empty > 1) $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
+  } else {
+    if($empty > 0 && $field != '') $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
   }
 
   if(substr($field, -1) == '.' && $area == 'Name'){
@@ -176,7 +185,7 @@
     } else {
       for($n = 0; $n < 4; $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];
@@ -197,6 +206,7 @@
     break;
   case "MX":
     $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
+    $error .= $this->is_integer($rr['aux'], $app->tform->wordbook['aux_txt'], 1);
     break;
   case "NS":
     $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
@@ -210,12 +220,11 @@
     break;
   case "SRV":
     $error .= $this->validate_srv_data($rr['data'], $rr['zone']);
+    $error .= $this->is_integer($rr['aux'], $app->tform->wordbook['aux_txt'], 1);
     break;
   case "TXT":
     break;
   }
-
-  $error .= $this->is_integer($rr['aux'], $app->tform->wordbook['aux_txt'], 1);
 
   $error .= $this->is_integer($rr['ttl'], $app->tform->wordbook['ttl_txt']);
 
@@ -257,4 +266,21 @@
   return $error;
 }
 
+function increase_serial($serial){
+  global $app, $conf;
+
+  // increase serial
+  $serial_date = substr($serial, 0, 8);
+  $count = intval(substr($serial, 8, 2));
+  $current_date = date("Ymd");
+  if($serial_date >= $current_date){
+    $count += 1;
+    $count = str_pad($count, 2, "0", STR_PAD_LEFT);
+    $new_serial = $serial_date.$count;
+  } else {
+    $new_serial = $current_date.'01';
+  }
+  return $new_serial;
+}
+
 }
\ No newline at end of file

--
Gitblit v1.9.1