From 99c8a21fe1a2602715d68eb5bdc989c5f4745c49 Mon Sep 17 00:00:00 2001
From: fantu <fantu@ispconfig3>
Date: Sat, 20 Dec 2008 23:11:28 +0000
Subject: [PATCH] improve of ip validator

---
 interface/lib/classes/tform.inc.php | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php
index 813ff80d9b..1f80db27ca 100644
--- a/interface/lib/classes/tform.inc.php
+++ b/interface/lib/classes/tform.inc.php
@@ -632,7 +632,15 @@ class tform {
                                         }
                                 break;
 								case 'ISIPV4':
-                                        if(!preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)) {
+								$vip=1;
+								if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
+								$groups=explode(".",$field_value);
+								foreach($groups as $group){
+									if($group<0 OR $group>255)
+									$vip=0;
+								}
+								}else{$vip=0;}
+                                        if($vip==0) {
                                                 $errmsg = $validator['errmsg'];
                                                 if(isset($this->wordbook[$errmsg])) {
                                                     $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
-- 
GitLab