X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fipinfo.cgi;h=b756a24d2a5e97e67434ecdeb2acbe11763f1f9b;hp=bc214f09525d8bb38d0f11d0cc6c573a87f53065;hb=5709768b0bab2b860911fcad66da8e0aec5c4eaa;hpb=70df830214c97a68fcb7e89ae0d7df58c35590be diff --git a/html/cgi-bin/ipinfo.cgi b/html/cgi-bin/ipinfo.cgi index bc214f0952..b756a24d2a 100644 --- a/html/cgi-bin/ipinfo.cgi +++ b/html/cgi-bin/ipinfo.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2010 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -19,6 +19,7 @@ # # ############################################################################### +use CGI; use IO::Socket; use strict; @@ -29,25 +30,20 @@ use strict; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +require "${General::swroot}/geoip-functions.pl"; my %cgiparams=(); &Header::showhttpheaders(); -&Header::getcgihash(\%cgiparams); - -$ENV{'QUERY_STRING'} =~s/&//g; -my @addrs = split(/ip=/,$ENV{'QUERY_STRING'}); - -my %whois_servers = ("RIPE"=>"whois.ripe.net","APNIC"=>"whois.apnic.net","LACNIC"=>"whois.lacnic.net"); - &Header::openpage($Lang::tr{'ip info'}, 1, ''); - &Header::openbigbox('100%', 'left'); my @lines=(); my $extraquery=''; -foreach my $addr (@addrs) { -next if $addr eq ""; + +my $addr = CGI::param("ip") || ""; + +if (&General::validip($addr)) { $extraquery=''; @lines=(); my $whoisname = "whois.arin.net"; @@ -55,18 +51,22 @@ next if $addr eq ""; my $hostname = gethostbyaddr($iaddr, AF_INET); if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; } + # enumerate GeoIP information for IP address... + my $ccode = &GeoIP::lookup($addr); + my $flag_icon = &GeoIP::get_flag_icon($ccode); + my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp'); if ($sock) { - print $sock "$addr\n"; + print $sock "n $addr\n"; while (<$sock>) { - $extraquery = $1 if (/NetType: Allocated to (\S+)\s+/); + $extraquery = $1 if (/ReferralServer: whois:\/\/(\S+)\s+/); push(@lines,$_); } close($sock); if ($extraquery) { undef (@lines); - $whoisname = $whois_servers{$extraquery}; + $whoisname = $extraquery; my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp'); if ($sock) { @@ -86,20 +86,28 @@ next if $addr eq ""; @lines = ( "$Lang::tr{'unable to contact'} $whoisname" ); } - &Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : '.$whoisname); + &Header::openbox('100%', 'left', $addr . " $ccode (" . $hostname . ') : '.$whoisname); print "
\n";
 	foreach my $line (@lines) {
 		print &Header::cleanhtml($line,"y");
 	}
 	print "
\n"; &Header::closebox(); +} else { + &Header::openbox('100%', 'left', $Lang::tr{'invalid ip'}); + print < + $Lang::tr{'invalid ip'} +

+EOF + &Header::closebox(); } print < - +
$Lang::tr{'back'}$Lang::tr{