public static function CleantalkHelper::ip_validate in Anti Spam by CleanTalk 7.5
Same name and namespace in other branches
- 7.4 src/CleantalkHelper.php \CleantalkHelper::ip_validate()
2 calls to CleantalkHelper::ip_validate()
File
- src/
CleantalkHelper.php, line 222
Class
- CleantalkHelper
- Cleantalk's hepler class
Code
public static function ip_validate($ip) {
if (!$ip) {
return false;
}
// NULL || FALSE || '' || so on...
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && $ip != '0.0.0.0') {
return 'v4';
}
// IPv4
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && self::ip_v6_reduce($ip) != '0::0') {
return 'v6';
}
// IPv6
return false;
// Unknown
}