long2ip example

$host      = self::API_HOST;
        $api_key   = self::get_api_key();

        if ( $api_key ) {
            $request = add_query_arg( 'api_key', $api_key$request );
        }

        $http_host = $host;
        // use a specific IP if provided         // needed by Akismet_Admin::check_server_connectivity()         if ( $ip && long2ip( ip2long( $ip ) ) ) {
            $http_host = $ip;
        }

        $http_args = array(
            'body' => $request,
            'headers' => array(
                'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ),
                'Host' => $host,
                'User-Agent' => $akismet_ua,
            ),
            'httpversion' => '1.0',
            
/** * Validates an IPv4 address * * @param string $value */
    protected function _validateIPv4($value) {
        $ip2long = ip2long($value);
        if($ip2long === false) {
            return false;
        }

        return $value == long2ip($ip2long);
    }

    /** * Validates an IPv6 address * * @param string $value Value to check against * @return boolean True when $value is a valid ipv6 address * False otherwise */
    protected function _validateIPv6($value) {
        if (strlen($value) < 3) {
            
Home | Imprint | This part of the site doesn't use cookies.