src/Utils.php
public function showHTML($result, $link_myself = true, $params = 'query=$0&amp;output=nice')
    {

        // adds links for HTML output

        $email_regex = "/([-_\w\.]+)(@)([-_\w\.]+)\b/i";
        $html_regex = "/(?:^|\b)((((http|https|ftp):\/\/)|(www\.))([\w\.]+)([,:%#&\/?~=\w+\.-]+))(?:\b|$)/is";
        $ip_regex = "/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/i";

        $out = '';
        $lempty = true;

        foreach ($result['rawdata'] as $line) {
            $line = trim($line);

            if ($line == '') {
                if ($lempty) {
                    continue;
                } else {
                    $lempty = true;
                }
            } else {
                $lempty = false;
            }

            $out .= $line . "\n";
        }

        if ($lempty) {
            $out = trim($out);
        }

        $out = strip_tags($out);
        $out = preg_replace($email_regex, '<a href="mailto:$0">$0</a>', $out);
        $out = preg_replace_callback(
            $html_regex,
            function ($matches) {
                if (substr($matches[0], 0, 4) == 'www.') {
                    $web = $matches[0];
                    $url = 'http://' . $web;
                } else {
                    $web = $matches[0];
                    $url = $web;
                }

                return '<a href="' . $url . '" target="_blank">' . $web . '</a>';
            },
            $out
        );

        if ($link_myself) {
            if ($params[0] == '/') {
                $link = $params;
            } else {
                $link = $_SERVER['PHP_SELF'] . '?' . $params;
            }

            $out = preg_replace($ip_regex, '<a href="' . $link . '">$0</a>', $out);

            if (isset($result['regrinfo']['domain']['nserver'])) {
                $nserver = $result['regrinfo']['domain']['nserver'];
            } else {
                $nserver = false;
            }

            if (isset($result['regrinfo']['network']['nserver'])) {
                $nserver = $result['regrinfo']['network']['nserver'];
            }

            if (is_array($nserver)) {
                reset($nserver);
                while (list($host, $ip) = each($nserver)) {
                    $url = '<a href="' . str_replace('$0', $ip, $link) . "\">$host</a>";
                    $out = str_replace($host, $url, $out);
                    $out = str_replace(strtoupper($host), $url, $out);
                }
            }
        }

        // Add bold field names
        $out = preg_replace("/(?m)^([-\s\.&;'\w\t\(\)\/]+:\s*)/", '<b>$1</b>', $out);

        // Add italics for disclaimer
        $out = preg_replace("/(?m)^(%.*)/", '<i>$0</i>', $out);

        return str_replace("\n", "<br/>\n", $out);
    }
public function showHTML($result, $link_myself = true, $params = 'query=$0&amp;output=nice')
    {

        // adds links for HTML output

        $email_regex = "/([-_\w\.]+)(@)([-_\w\.]+)\b/i";
        $html_regex = "/(?:^|\b)((((http|https|ftp):\/\/)|(www\.))([\w\.]+)([,:%#&\/?~=\w+\.-]+))(?:\b|$)/is";
        $ip_regex = "/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/i";

        $out = '';
        $lempty = true;

        foreach ($result['rawdata'] as $line) {
            $line = trim($line);

            if ($line == '') {
                if ($lempty) {
                    continue;
                } else {
                    $lempty = true;
                }
            } else {
                $lempty = false;
            }

            $out .= $line . "\n";
        }

        if ($lempty) {
            $out = trim($out);
        }

        $out = strip_tags($out);
        $out = preg_replace($email_regex, '<a href="mailto:$0">$0</a>', $out);
        $out = preg_replace_callback(
            $html_regex,
            function ($matches) {
                if (substr($matches[0], 0, 4) == 'www.') {
                    $web = $matches[0];
                    $url = 'http://' . $web;
                } else {
                    $web = $matches[0];
                    $url = $web;
                }

                return '<a href="' . $url . '" target="_blank">' . $web . '</a>';
            },
            $out
        );

        if ($link_myself) {
            if ($params[0] == '/') {
                $link = $params;
            } else {
                $link = $_SERVER['PHP_SELF'] . '?' . $params;
            }

            $out = preg_replace($ip_regex, '<a href="' . $link . '">$0</a>', $out);

            if (isset($result['regrinfo']['domain']['nserver'])) {
                $nserver = $result['regrinfo']['domain']['nserver'];
            } else {
                $nserver = false;
            }

            if (isset($result['regrinfo']['network']['nserver'])) {
                $nserver = $result['regrinfo']['network']['nserver'];
            }

            if (is_array($nserver)) {
                reset($nserver);
                while (list($host, $ip) = each($nserver)) {
                    $url = '<a href="' . str_replace('$0', $ip, $link) . "\">$host</a>";
                    $out = str_replace($host, $url, $out);
                    $out = str_replace(strtoupper($host), $url, $out);
                }
            }
        }

        // Add bold field names
        $out = preg_replace("/(?m)^([-\s\.&;'\w\t\(\)\/]+:\s*)/", '<b>$1</b>', $out);

        // Add italics for disclaimer
        $out = preg_replace("/(?m)^(%.*)/", '<i>$0</i>', $out);

        return str_replace("\n", "<br/>\n", $out);
    }
public function showHTML ( $ result , $ link_myself = true , $ params = 'query=$0&amp;output=nice' ) { // adds links for HTML output $ email_regex = "/([-_\w\.]+)(@)([-_\w\.]+)\b/i" ; $ html_regex = "/(?:^|\b)((((http|https|ftp):\/\/)|(www\.))([\w\.]+)([,:%#&\/?~=\w+\.-]+))(?:\b|$)/is" ; $ ip_regex = "/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/i" ; $ out = '' ; $ lempty = true ; foreach ( $ result [ 'rawdata' ] as $ line ) { $ line = trim ( $ line ) ; if ( $ line == '' ) { if ( $ lempty ) { continue ; } else { $ lempty = true ; } } else { $ lempty = false ; } $ out .= $ line . "\n" ; } if ( $ lempty ) { $ out = trim ( $ out ) ; } $ out = strip_tags ( $ out ) ; $ out = preg_replace ( $ email_regex , '<a href="mailto:$0">$0</a>' , $ out ) ; $ out = preg_replace_callback ( $ html_regex , function ( $ matches ) { if ( substr ( $ matches [ 0 ] , 0 , 4 ) == 'www.' ) { $ web = $ matches [ 0 ] ; $ url = 'http://' . $ web ; } else { $ web = $ matches [ 0 ] ; $ url = $ web ; } return '<a href="' . $ url . '" target="_blank">' . $ web . '</a>' ; } , $ out ) ; if ( $ link_myself ) { if ( $ params [ 0 ] == '/' ) { $ link = $ params ; } else { $ link = $ _SERVER [ 'PHP_SELF' ] . '?' . $ params ; } $ out = preg_replace ( $ ip_regex , '<a href="' . $ link . '">$0</a>' , $ out ) ; if ( isset ( $ result [ 'regrinfo' ] [ 'domain' ] [ 'nserver' ] ) ) { $ nserver = $ result [ 'regrinfo' ] [ 'domain' ] [ 'nserver' ] ; } else { $ nserver = false ; } if ( isset ( $ result [ 'regrinfo' ] [ 'network' ] [ 'nserver' ] ) ) { $ nserver = $ result [ 'regrinfo' ] [ 'network' ] [ 'nserver' ] ; } if ( is_array ( $ nserver ) ) { reset ( $ nserver ) ; while ( list ( $ host , $ ip ) = each ( $ nserver ) ) { $ url = '<a href="' . str_replace ( '$0' , $ ip , $ link ) . "\">$host</a>" ; $ out = str_replace ( $ host , $ url , $ out ) ; $ out = str_replace ( strtoupper ( $ host ) , $ url , $ out ) ; } } } // Add bold field names $ out = preg_replace ( "/(?m)^([-\s\.&;'\w\t\(\)\/]+:\s*)/" , '<b>$1</b>' , $ out ) ; // Add italics for disclaimer $ out = preg_replace ( "/(?m)^(%.*)/" , '<i>$0</i>' , $ out ) ; return str_replace ( "\n" , "<br/>\n" , $ out ) ; }
Get nice HTML output
Get nice HTML output