[script] Whois-Abfrage

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • [script] Whois-Abfrage

    Irgenwie komme ich nicht weiter. Ich habe mir aus Matts whois-Script ein paar Funktionen raus genommen, bekomme aber keine Ausgabe hin. Das komplette Whois-Script von Matt habe ich mal als zip angehangen.

    Und hier nun mein Script:
    PHP-Code:
    <?
    $dom = "yahoo";
    $ex = "com";
    load_server_info();
    //choose_info_server($dom, $ex);

    // some extensions (com/net/org) have a server which contains the name of the server which should be used for the information, this simply tells the script to use the whois server as a source for the server info... ;)
    $whois_si_servers = array();

    // an array of the `whois' servers
    $whois_servers = array();

    // default whois servers for info
    $whois_info_servers = array();

    // the backup whois servers to try
    $whois_info_servers_backup = array();

    function my_in_array($val,$array_)
        {
        for($l=0; $l<sizeof($array_); $l++)
            {
            if($array_[$l] == $val)
                {
                return 1;
                }
            }
        return 0;
        }

    // in case the theme can't be found
    function fatal_servers_lst()
        {
        echo '<HTML><BODY><FONT FACE=VERDANA SIZE=2>MWhois could not locate the servers.lst\ file in the current directory!</FONT></BODY></HTML>';
        exit();
        }

    function load_server_info()
        {
        global $whois_si_servers;
        global $whois_servers;
        global $whois_info_servers;
        global $whois_info_servers_backup;
        global $whois_avail_strings;
        // load the servers.lst file
        $tlds = @file("servers.lst");
        if(!$tlds)
            {
            fatal_servers_lst();
            }
        for($l=0; $l<count($tlds); $l++)
            {
            // time leading spaces or trailing spaces
            $tlds[$l] = chop($tlds[$l]);
            // filter out the commented lines (begin with #)
            if(substr($tlds[$l], 0, 1) == "#" || !strlen($tlds[$l]))
                {
                continue;
                }
            // explode via the seperation char `|'
            $es = explode("|", $tlds[$l]);
            // check to see whether we want this TLD
            if(!my_in_array($es[0], $whois_exts)) { continue; }
            // yes we do, so store the details in the appropriate arrays
            $whois_servers[$es[0]] = $es[1];
            $whois_si_servers[$es[0]] = $es[5];
            $whois_info_servers[$es[0]] = $es[3];
            $whois_info_servers_backup[$es[0]] = $es[4];
            $whois_avail_strings[$es[1]] = $es[2];
            // thats it!
            }
        }

    function choose_info_server($domain, $ext)
        {
        global $whois_info_servers;
        global $whois_si_servers;
        global $whois_server;
        global $whois_servers;
        $whois_server = "";
        if($whois_si_servers[$ext])
            {
            if(($co = fsockopen($whois_servers[$ext], 43)) == false)
                {
                echo "\n choose_info_server() : unable to connect to ".$whois_servers[$ext];
                $whois_server = $whois_servers[$ext];
                }
            else
                {
                echo "\n choose_info_servers() : connected to ".$whois_servers[$ext]." looking for `".$whois_si_servers[$ext];
                fputs($co, $domain.".".$ext."\r\n");
                while(!feof($co)) { $output .= fgets($co,128); }
                fclose($co);
                $he = strpos($output, $whois_si_servers[$ext]) + strlen($whois_si_servers[$ext]);
                $le = strpos($output, "\n", $he);
                $whois_server = substr($output, $he, $le-$he);
                echo "\n choose_info_servers() : found '".$whois_server."' using for whois info server";
                }
            }
        else
            {
            $whois_server = $whois_info_servers[$ext];
            echo "\n choose_info_servers() : not found '".$whois_server."' using for whois info server";
            }
        $whois_server = trim($whois_server);
        }
    choose_info_server($dom, $ex);
    echo"<p>&nbsp;</p>Ausgabe:<pre>$whois_server</pre>
    Whois-Server:<pre>$whois_servers[$ext]</pre>";
    echo "<hr>";
    //show_source("domain.1.php");
    ?>
    Angehängte Dateien
    Zuletzt geändert von Wotan; 13.05.2003, 21:14.
    *winks*
    Gilbert
    ------------------------------------------------
    Hilfe für eine Vielzahl von Problemen!!!
    http://www.1st-rootserver.de/

  • #2
    Da fehlten noch zwei Funktionen. Jetzt ist es vollständig und macht auch eine Ausgabe.
    PHP-Code:
    <?
    //$d_name    = "google";
    //$TDL    = "de";

    // some extensions (com/net/org) have a server which contains the name of the server which should be used for the information, this simply tells the script to use the whois server as a source for the server info... ;)
    $whois_si_servers = array();

    // an array of the `whois' servers
    $whois_servers = array();

    // default whois servers for info
    $whois_servers = array();

    // the backup whois servers to try
    $whois_info_servers_backup = array();

    // Erlaubte TDL´s
    $whois_exts = array("de","com","net","org","info","biz","at","ch","li","us","uk","tv","cc","dk","it","ws","ag","cn","be","fm","nu","bz","cd");

    function my_in_array($val,$array_)
        {
        for($l=0; $l<sizeof($array_); $l++)
            {
            if($array_[$l] == $val)
                {
                return 1;
                }
            }
        return 0;
        }

    // in case the theme can't be found
    function fatal_servers_lst()
        {
        echo "<HTML><BODY><FONT FACE=\"VERDANA\" SIZE=\"2>MWhois could not locate the servers.lst\ file in the current directory!</FONT></BODY></HTML>";
        exit();
        }

    function load_server_info()
        {
        global $whois_si_servers;
        global $whois_servers;
        global $whois_info_servers;
        global $whois_info_servers_backup;
        global $whois_avail_strings;
        global $whois_exts;
        // load the servers.lst file
        $tlds = @file("servers.lst");
        if(!$tlds)
            {
            fatal_servers_lst();
            }
        for($l=0; $l<count($tlds); $l++)
            {
            // time leading spaces or trailing spaces
            $tlds[$l] = chop($tlds[$l]);
            // explode via the seperation char `|'
            $es = explode("|", $tlds[$l]);
            // check to see whether we want this TLD
            if(!my_in_array($es[0], $whois_exts))
                {
                continue;
                }
            // yes we do, so store the details in the appropriate arrays
            $whois_servers[$es[0]] = $es[1];
            $whois_si_servers[$es[0]] = $es[5];
            $whois_info_servers[$es[0]] = $es[3];
            $whois_info_servers_backup[$es[0]] = $es[4];
            $whois_avail_strings[$es[1]] = $es[2];
            // thats it!
            }
        }

    function choose_info_server($domain, $ext)
        {
        global $whois_info_servers;
        global $whois_si_servers;
        global $whois_server;
        global $whois_servers;
        global $whois_exts;
        $whois_server = "";
        if($whois_si_servers[$ext])
            {
            if(($co = fsockopen($whois_servers[$ext], 43)) == false)
                {
                //echo "\n choose_info_server() : unable to connect to ".$whois_servers[$ext]."<br>";
                $whois_server = $whois_servers[$ext];
                }
            else
                {
                //echo "\n choose_info_servers() : connected to ".$whois_servers[$ext]." looking for `".$whois_si_servers[$ext]."<br>";
                fputs($co, $domain.".".$ext."\r\n");
                while(!feof($co))
                    {
                    $output .= fgets($co,128);
                    }
                fclose($co);
                $he = strpos($output, $whois_si_servers[$ext]) + strlen($whois_si_servers[$ext]);
                $le = strpos($output, "\n", $he);
                $whois_server = substr($output, $he, $le-$he);
                //echo "\n choose_info_servers() : found '".$whois_server."' using for whois info server<br>";
                }
            }
        else
            {
            $whois_server = $whois_info_servers[$ext];
            //echo "\n choose_info_servers() : not found '".$whois_server."' using for whois info server<br>";
            }
        $whois_server = trim($whois_server);
        }
    function do_raw($domainname, $ext)
        {
        global $whois_info_servers;
        global $whois_servers;
        global $rawoutput;
        global $whois_info_servers_backup;
        global $whois_avail_strings;
        global $whois_server;
        choose_info_server($domainname, $ext);
        if(($ns = fsockopen($whois_server,43)) == false)
            {
            if(($ns = fsockopen($whois_info_servers[$ext],43)) == false)
                {
                if(($ns = fsockopen($whois_info_servers_backup[$ext], 43)) == false)
                    {
                    return -1;
                    }
                else
                    {
                    $whois_server = $whois_info_servers_backup[$ext];
                    }
                }
            else
                {
                $whois_server = $whois_info_servers[$ext];
                }
            }
        //echo "\n do_raw() : using `".$whois_server."' for whois query <br>";
        fputs($ns, $domainname.".".$ext."\r\n");
        while(!feof($ns))
            {
            $rawoutput .= fgets($ns, 128);
            }
        fclose($ns);
        echo "<pre>$rawoutput</pre>";
        exit();
        }

    load_server_info();
    do_raw($d_name, $TDL);
    //show_source("domain.1.php");
    ?>
    Zuletzt geändert von Wotan; 13.05.2003, 21:15.
    *winks*
    Gilbert
    ------------------------------------------------
    Hilfe für eine Vielzahl von Problemen!!!
    http://www.1st-rootserver.de/

    Kommentar

    Lädt...
    X