]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/ipinfo.cgi
5 # This code is distributed under the terms of the GPL
7 # (c) The SmoothWall Team
9 # (c) 2002 Josh Grubman <jg@false.net> - Multiple registry IP lookup code
11 # $Id: ipinfo.cgi,v 1.4.2.3 2005/02/22 22:21:56 gespinasse Exp $
17 # enable only the following on debugging purpose
19 #use CGI::Carp 'fatalsToBrowser';
21 require 'CONFIG_ROOT/general-functions.pl';
22 require "${General::swroot}/lang.pl";
23 require "${General::swroot}/header.pl";
27 &Header
::showhttpheaders
();
29 &Header
::getcgihash
(\
%cgiparams);
31 $ENV{'QUERY_STRING'} =~s/&//g;
32 my @addrs = split(/ip=/,$ENV{'QUERY_STRING'});
34 my %whois_servers = ("RIPE"=>"whois.ripe.net","APNIC"=>"whois.apnic.net","LACNIC"=>"whois.lacnic.net");
36 &Header
::openpage
($Lang::tr
{'ip info'}, 1, '');
38 &Header
::openbigbox
('100%', 'left');
41 foreach my $addr (@addrs) {
45 my $whoisname = "whois.arin.net";
46 my $iaddr = inet_aton
($addr);
47 my $hostname = gethostbyaddr($iaddr, AF_INET
);
48 if (!$hostname) { $hostname = $Lang::tr
{'lookup failed'}; }
50 my $sock = new IO
::Socket
::INET
( PeerAddr
=> $whoisname, PeerPort
=> 43, Proto
=> 'tcp');
53 print $sock "$addr\n";
55 $extraquery = $1 if (/NetType: Allocated to (\S+)\s+/);
61 $whoisname = $whois_servers{$extraquery};
62 my $sock = new IO
::Socket
::INET
( PeerAddr
=> $whoisname, PeerPort
=> 43, Proto
=> 'tcp');
65 print $sock "$addr\n";
72 @lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
78 @lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
81 &Header
::openbox
('100%', 'left', $addr . ' (' . $hostname . ') : '.$whoisname);
83 foreach my $line (@lines) {
84 print &Header
::cleanhtml
($line,"y");
94 <td align='center'><a href='$ENV{'HTTP_REFERER'}'>$Lang::tr{'back'}</a></td>
101 &Header
::closebigbox
();
103 &Header
::closepage
();