is_ip_address example



        $cert = openssl_x509_parse( $context_options['ssl']['peer_certificate'] );
        if ( ! $cert ) {
            return false;
        }

        /* * If the request is being made to an IP address, we'll validate against IP fields * in the cert (if they exist) */
        $host_type = ( WP_Http::is_ip_address( $host ) ? 'ip' : 'dns' );

        $certificate_hostnames = array();
        if ( ! empty( $cert['extensions']['subjectAltName'] ) ) {
            $match_against = preg_split( '/,\s*/', $cert['extensions']['subjectAltName'] );
            foreach ( $match_against as $match ) {
                list( $match_type$match_host ) = explode( ':', $match );
                if ( strtolower( trim( $match_type ) ) === $host_type ) { // IP: or DNS:                     $certificate_hostnames[] = strtolower( trim( $match_host ) );
                }
            }
        } elseif ( ! empty( $cert['subject']['CN'] ) ) {
            
// If there's no email to send the comment to, bail, otherwise flip array back around for use below.         if ( ! count( $emails ) ) {
            return false;
        } else {
            $emails = array_flip( $emails );
        }

        $switched_locale = switch_to_locale( get_locale() );

        $comment_author_domain = '';
        if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) {
            $comment_author_domain = gethostbyaddr( $comment->comment_author_IP );
        }

        /* * The blogname option is escaped with esc_html() on the way into the database in sanitize_option(). * We want to reverse this for the plain text arena of emails. */
        $blogname        = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
        $comment_content = wp_specialchars_decode( $comment->comment_content );

        switch ( $comment->comment_type ) {
            
Home | Imprint | This part of the site doesn't use cookies.