Skip to content

Commit

Permalink
Update F_Network.php
Browse files Browse the repository at this point in the history
  • Loading branch information
yumusb authored Jul 11, 2021
1 parent c1c09f1 commit f0f5045
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions application/function/F_Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ function getClientIP(){
$ip = "Unknown";
}
//只取第一个
$ip_array=explode(',',$ip);
$ip = preg_replace("/^([\d\.]+).*/","\\1",$ip_array[0]);
return $ip;
$ip=explode(',',$ip)[0];

if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)) {
return ip;
}else {
return "invalid ip";
}
#return $ip;
}
}

Expand Down

0 comments on commit f0f5045

Please sign in to comment.