#!/usr/bin/perl # # whois.plx # my $version = '1.05'; # 9-5-04, michael@bizsystems.com # GPL'd, see Copyright notice in the package README file # use strict; #use diagnostics; use Net::DNS::ToolKit::Utilities qw( rlook_send rlook_rcv ); my $ptr_timeout = 15; # PTR record lookup timeout in seconds # fix up the whois routine to get the stuff we want BEGIN { use vars qw($old_d_q $lastresp); use Net::Whois::IP qw(whoisip_query); $old_d_q = \&Net::Whois::IP::_do_query; } sub Net::Whois::IP::_do_query { my @rv = &$old_d_q(@_); $lastresp = $rv[0]; return @rv; } ######################################################### $ENV{SCRIPT_NAME} =~ /whois\.([a-zA-Z_-]+)/; my $action = 'whois.'. $1; my $IP = ($ENV{QUERY_STRING} =~ /query=(\d+\.\d+\.\d+\.\d+)/) ? $1 : ''; my $html = q|
| Whois for IP address |
| >>Close Window<< |
| |. $IP; my $body = q| |
|;
if ($IP) {
if ($ENV{HTTP_REFERER} !~ /$ENV{SERVER_NAME}/i) {
$body .= qq|
Due to the excessive load placed on our system, we have disabled the ability
for third party sites to query the Whois Proxy through the web
interface. Please enter your request manually.
|;
}
else {
my $socket = rlook_send($IP,$ptr_timeout);
$lastresp = '';
eval {whoisip_query($IP)};
my $hostname = rlook_rcv($socket,$ptr_timeout);
if ($hostname) {
$html .= " -- $hostname";
}
if ($lastresp && ! $@) {
$body .= q||. join('',@$lastresp) . q|
|;
} else {
$body .= q|could not connect to whois server, try again later|; } } } $html .= $body . q| |
| >>Close Window<< |