]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/ipinfo.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
25 # enable only the following on debugging purpose
27 #use CGI::Carp 'fatalsToBrowser';
29 require '/var/ipfire/general-functions.pl';
30 require "${General::swroot}/lang.pl";
31 require "${General::swroot}/header.pl";
35 &Header
::showhttpheaders
();
37 &Header
::getcgihash
(\
%cgiparams);
39 $ENV{'QUERY_STRING'} =~s/&//g;
40 my @addrs = split(/ip=/,$ENV{'QUERY_STRING'});
42 &Header
::openpage
($Lang::tr
{'ip info'}, 1, '');
44 &Header
::openbigbox
('100%', 'left');
47 foreach my $addr (@addrs) {
51 my $whoisname = "whois.arin.net";
52 my $iaddr = inet_aton
($addr);
53 my $hostname = gethostbyaddr($iaddr, AF_INET
);
54 if (!$hostname) { $hostname = $Lang::tr
{'lookup failed'}; }
56 my $sock = new IO
::Socket
::INET
( PeerAddr
=> $whoisname, PeerPort
=> 43, Proto
=> 'tcp');
59 print $sock "n $addr\n";
61 $extraquery = $1 if (/ReferralServer: whois:\/\
/(\S+)\s+/);
67 $whoisname = $extraquery;
68 my $sock = new IO
::Socket
::INET
( PeerAddr
=> $whoisname, PeerPort
=> 43, Proto
=> 'tcp');
71 print $sock "$addr\n";
78 @lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
84 @lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
87 &Header
::openbox
('100%', 'left', $addr . ' (' . $hostname . ') : '.$whoisname);
89 foreach my $line (@lines) {
90 print &Header
::cleanhtml
($line,"y");
100 <td align='center'><a href='$ENV{'HTTP_REFERER'}'>$Lang::tr{'back'}</a></td>
107 &Header
::closebigbox
();
109 &Header
::closepage
();