home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 February
/
PCWorld_2000-02_cd.bin
/
Komunik
/
Webscr
/
Scrptw
/
_SETUP.1
/
Whois.cgi
< prev
next >
Wrap
Text File
|
1999-10-06
|
4KB
|
138 lines
#!/usr/bin/perl
# CONFIGURATION
$title = "Soft Lite Network: International Whois Service";
# HTML (feel free to change)
# FORM (If query_string is blank)
$form_html = qq~
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>$title</title>
</head>
<body bgcolor=ffffff>
<p><FONT FACE="Verdana,Arial" SIZE="5"><h2>$title</h2></p>
<form action="/cgi-bin/whois.cgi" method="get">
<FONT FACE="Verdana,Arial" SIZE="1">Search for domain name; NIC handle; host IP or lastname, firstname:
<input type="text" name="query">
<input type="submit" value="Whois">
</form>
<p>
<div align="center">
<table width="75%" border=0>
<tr><td>Domain Name - </td><td>softlite.net</td></tr>
<tr><td>NIC handle -</td><td>FI61-ORG</td></tr>
<tr><td>Lastname, Firstname:</td><td>Doe, John</td></tr>
<tr><td>Hosting Servers</td><td>DNS1.DOMAIN.COM</td></tr>
</table>
</div>
<p>
Supported TLDs:
(.COM, .ORG, .NET, .EDU, .GOV, .MIL, .CA, .UK, .MX, .FR, .DK, .DE, .CH, .BE, .AT, .AU, .CZ)
</p>
</body></html>
~;
$result_html_top = qq~
<html>
<head>
<title>$title</title>
</head>
<body bgcolor=ffffff>
<p><FONT FACE="Verdana,Arial" SIZE="1"><h2>$title Query Result</h2></p>
<hr>
~;
$result_html_bottom = qq~
</body>
</html>
~;
##########################
# DON'T EDIT ANYTHING ELSE
use IO::Socket;
&pQuery;
if ($query{'query'} eq "") {
print "Content-type: text/html\n\n";
print $form_html;
} else {
&get_data;
print "Content-type: text/html\n\n";
print $result_html_top;
&print_result;
print $result_html_bottom;
}
sub print_result {
foreach $_ (@out) {
print $_;
}
return;
}
sub pQuery {
my($in, @in, $entry, $var, $val);
$in = $ENV{'QUERY_STRING'};
@in = split(/\&/, $in);
foreach $entry (@in) {
$entry =~ s/\+/ /g;
($var, $val) = split(/=/, $entry, 2);
$var =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
$val =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
$query{$var} = $val;
}
}
sub get_data {
$whois_port = "43";
$whois_serv = "whois.internic.net";
$t = $query{'query'};
if ($t !~ /co.uk/i && $t !~ /org.uk/i && $t !~ /net.uk/i && $t !~ /ltd.uk/i && $t !~ /plc.uk/i) {
@NICS = split(/\./,$query{'query'});
foreach $_ (@NICS) {
$nic = $_;
}
} else {
$whois_serv = "whois.nic.uk";
}
if ($nic eq "mil") { $whois_serv = "whois.nic.mil"; }
elsif ($nic eq "gov") { $whois_serv = "whois.nic.gov"; }
elsif ($nic eq "us") { $whois_serv = "whois.isi.edu"; }
elsif ($nic eq "mx") { $whois_serv = "whois.nic.mx"; }
elsif ($nic eq "ca") { $whois_serv = "whois.cdnnet.ca"; }
elsif ($nic eq "uk") { $whois_serv = "whois.ripe.net"; }
elsif ($nic eq "dk") { $whois_serv = "whois.ripe.net"; }
elsif ($nic eq "de") { $whois_serv = "whois.ripe.net"; }
elsif ($nic eq "be") { $whois_serv = "whois.ripe.net"; }
elsif ($nic eq "at") { $whois_serv = "whois.ripe.net"; }
elsif ($nic eq "cz") { $whois_serv = "whois.ripe.net"; }
elsif ($nic eq "fr") { $whois_serv = "whois.nic.fr"; }
elsif ($nic eq "ch") { $whois_serv = "whois.nic.ch"; }
elsif ($nic eq "au") { $whois_serv = "whois.aunic.net"; }
$next = "\015\012";
$socket = IO::Socket::INET->new(Proto=>"tcp",
PeerAddr=>$whois_serv,PeerPort=>$whois_port,);
unless ($socket) { die "can't connect to $whois_serv" }
print $socket "$query{'query'}" . $next;
@out = <$socket>;
close $remote;
return;
}