ipv4验证

@param string $value
@return bool
426301
public static function ipv4(string $value):bool
    {
        $value = (string)$value;
        $valid = filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
        return $valid !== false;
    }
1236942
public function ipValidateV4($ip)
    {
        $this->debug->info(__FUNCTION__, 'IP: ' . json_encode($ip));
        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE) {
            $this->debug->info(__FUNCTION__, 'Valid is FALSE');

            return FALSE;
        }

        $this->debug->info(__FUNCTION__, 'Valid is TRUE');

        return TRUE;
    }
153355
public function isValid($value)
    {
        $result = (boolean) filter_var($value, FILTER_VALIDATE_URL);
        if (!$result) {
            $this->addMessage('url');
        }
        return $result;
    }
726026
public static function proxyType($value = null)
    {
        if (empty($value)) {
            return self::$global->getProxyType();
        }
        self::$global->setProxyType($value);
    }
575846
public static function isIpAddress($value): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        return filter_var((string) $value, FILTER_VALIDATE_IP) !== false;
    }
361288
public function denyIp( $value, $rule )
	{
		return !in_array( $value, is_array( $rule ) ? $rule : explode( ',', $rule ) );
	}
887708
public function server($value)
    {
        if (!isset($this->server[$value])) {
            return false;
        } else {
            return $this->server[$value];
        }
    }
296277
private function validatePrivateRange(string $value = ''): bool
    {
        $isValid = true;
        if ($this->options['allow-private-range'] === false) {
            $flags = FILTER_FLAG_NO_PRIV_RANGE;
            $isValid = \filter_var($value, FILTER_VALIDATE_IP, ['flags' => $flags]) !== false ? true : false;
        }
        if (!$isValid) {
            $this->setError(self::VALIDATOR_ERROR_IP_PRIVATE_RANGE_NOT_ALLOWED);
        }

        return $isValid;
    }
272528
public static function emailDomain($value)
    {
        if ( ! self::notEmpty($value))
        {
            return false;
        }

        // 检查MX记录
        return (bool) checkdnsrr(preg_replace('/^[^@]++@/', '', $value), 'MX');
    }
639656
public static function url(string $value):bool
    {
        $value = (string)$value;
        $valid = filter_var($value, FILTER_VALIDATE_URL);
        return $valid !== false;
    }
240212
protected function validate_url($value) {
        if (empty($value) && !is_numeric($value)) {
            return true;
        }
        if (!preg_match('@^https?://.+@', $value)) {
            return new lang_string('invalidurl', 'core_competency');
        }
        return true;
    }
788406
public function request($value)
    {
        if (!isset($this->request[$value])) {
            return false;
        } else {
            return $this->request[$value];
        }
    }
182996
private function check($value) {

		$ipv4 = new Ipv4();
		$ipv4 -> setValue($value);

		$ipv6 = new Ipv6();
		$ipv6 -> setValue($value);

		return true === $ipv4 -> isValid() || $ipv6 -> isValid();
	}
1090800
public function encrypt($value)
    {
        $iv = substr(md5(random_bytes(16)), 0, 16);
        $encrypted = openssl_encrypt($value, $this->encoding, $this->password, null, $iv);

        return $this->url_encode($iv.$encrypted);
    }
1073523
public static function validateIP( $v ) {
		// if integer then convert to string
		if( $ip = filter_var($v, FILTER_VALIDATE_INT) )
			$v = long2ip($ip);
		return filter_var($v, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
	}
1345688
public function plus($value): IP
    {
        if ($value < 0) {
            return $this->minus(-1 * $value);
        }

        if ($value == 0) {
            return clone $this;
        }

        if (!$value instanceof self) {
            $value = new static($value);
        }

        $result = gmp_add($this->ip, $value->ip);

        if (!self::isValid($result)) {
            throw new \OutOfBoundsException(sprintf(
                'The sum of "%s" and "%s" is not a valid IPv%d address.',
                $this->humanReadable(),
                $value->humanReadable(),
                static::IP_VERSION
            ));
        }

        return new static($result);
    }
771648
public static boolean isIPv4(final String ip) {
        if (StringUtils.isBlank(ip)) {
            return false;
        }

        final String regex = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
        final Pattern pattern = Pattern.compile(regex);
        final Matcher matcher = pattern.matcher(ip);

        return matcher.matches();
    }