Skip to content

Commit 99c8a21

Browse files
author
fantu
committed
improve of ip validator
1 parent 0b6b1e4 commit 99c8a21

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

interface/lib/classes/tform.inc.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,15 @@ function validateField($field_name, $field_value, $validators) {
632632
}
633633
break;
634634
case 'ISIPV4':
635-
if(!preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)) {
635+
$vip=1;
636+
if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
637+
$groups=explode(".",$field_value);
638+
foreach($groups as $group){
639+
if($group<0 OR $group>255)
640+
$vip=0;
641+
}
642+
}else{$vip=0;}
643+
if($vip==0) {
636644
$errmsg = $validator['errmsg'];
637645
if(isset($this->wordbook[$errmsg])) {
638646
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";

0 commit comments

Comments
 (0)