]>
git.ipfire.org Git - people/pmueller/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 ###############################################################################
26 # enable only the following on debugging purpose
28 #use CGI::Carp 'fatalsToBrowser';
30 require '/var/ipfire/general-functions.pl';
31 require "${General::swroot}/lang.pl";
32 require "${General::swroot}/header.pl";
33 require "${General::swroot}/geoip-functions.pl";
37 &Header
::showhttpheaders
();
39 &Header
::openpage
($Lang::tr
{'ip info'}, 1, '');
40 &Header
::openbigbox
('100%', 'left');
44 my $addr = CGI
::param
("ip") || "";
46 if (&General
::validip
($addr)) {
49 my $whoisname = "whois.arin.net";
50 my $iaddr = inet_aton
($addr);
51 my $hostname = gethostbyaddr($iaddr, AF_INET
);
52 if (!$hostname) { $hostname = $Lang::tr
{'lookup failed'}; }
54 # enumerate GeoIP information for IP address...
55 my $ccode = &GeoIP
::lookup
($addr);
56 my $flag_icon = &GeoIP
::get_flag_icon
($ccode);
58 my $sock = new IO
::Socket
::INET
( PeerAddr
=> $whoisname, PeerPort
=> 43, Proto
=> 'tcp');
61 print $sock "n $addr\n";
63 $extraquery = $1 if (/ReferralServer: whois:\/\
/(\S+)\s+/);
69 $whoisname = $extraquery;
70 my $sock = new IO
::Socket
::INET
( PeerAddr
=> $whoisname, PeerPort
=> 43, Proto
=> 'tcp');
73 print $sock "$addr\n";
80 @lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
86 @lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
89 &Header
::openbox
('100%', 'left', $addr . " <a href='country.cgi#$ccode'><img src='$flag_icon' border='0' align='absmiddle' alt='$ccode' title='$ccode' /></a> (" . $hostname . ') : '.$whoisname);
91 foreach my $line (@lines) {
92 print &Header
::cleanhtml
($line,"y");
97 &Header
::openbox
('100%', 'left', $Lang::tr
{'invalid ip'});
99 <p style="text-align: center;">
100 $Lang::tr{'invalid ip'}
110 <td align='center'><a href='$ENV{'HTTP_REFERER'}'><img src='/images/back.png' alt='$Lang::tr{'back'}' title='$Lang::tr{'back'}' /></a></td>
117 &Header
::closebigbox
();
119 &Header
::closepage
();