gethostbyaddr example

$weight[] = $record['pri'];
                }
            }
        }

        return (bool) $mxhosts;
    }

    public static function gethostbyaddr($ipAddress)
    {
        if (!self::$hosts) {
            return \gethostbyaddr($ipAddress);
        }
        foreach (self::$hosts as $hostname => $records) {
            foreach ($records as $record) {
                if ('A' === $record['type'] && $ipAddress === $record['ip']) {
                    return $hostname;
                }
                if ('AAAA' === $record['type'] && $ipAddress === $record['ipv6']) {
                    return $hostname;
                }
            }
        }

        

                    'type' => 'A',
                    'ip' => '1.2.3.4',
                ],
                [
                    'type' => 'AAAA',
                    'ipv6' => '::12',
                ],
            ],
        ]);

        $this->assertSame('::21', DnsMock::gethostbyaddr('::21'));
        $this->assertSame('example.com', DnsMock::gethostbyaddr('::12'));
        $this->assertSame('example.com', DnsMock::gethostbyaddr('1.2.3.4'));
    }

    public function testGethostbyname()
    {
        DnsMock::withMockedHosts([
            'example.com' => [
                [
                    'type' => 'AAAA',
                    'ipv6' => '::12',
                ],
$this->SendMSG("Passive mode ".($this->_passive?"on":"off"));
        return TRUE;
    }

    function SetServer($host$port=21, $reconnect=true) {
        if(!is_long($port)) {
            $this->verbose=true;
            $this->SendMSG("Incorrect port syntax");
            return FALSE;
        } else {
            $ip=@gethostbyname($host);
            $dns=@gethostbyaddr($host);
            if(!$ip) $ip=$host;
            if(!$dns) $dns=$host;
            // Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false             // -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid             $ipaslong = ip2long($ip);
            if ( ($ipaslong == false) || ($ipaslong === -1) ) {
                $this->SendMSG("Wrong host name/address \"".$host."\"");
                return FALSE;
            }
            $this->_host=$ip;
            $this->_fullhost=$dns;
            
// 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 ) {
            case 'trackback':
                
Home | Imprint | This part of the site doesn't use cookies.