display GeoIP information on ipinfo.cgi

Display GeoIP information on ipinfo.cgi and use newly implemented
function in /var/ipfire/geoip-functions.pl .

Signed-off-by: Peter Müller <peter.mueller@link38.eu>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Peter Müller
2017-11-15 22:56:36 +01:00
committed by Michael Tremer
parent e5efd99893
commit 9b5a17bf94

View File

@@ -30,6 +30,7 @@ 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=();
@@ -50,6 +51,10 @@ if (&General::validip($addr)) {
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)
{
@@ -81,7 +86,7 @@ if (&General::validip($addr)) {
@lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
}
&Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : '.$whoisname);
&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);
print "<pre>\n";
foreach my $line (@lines) {
print &Header::cleanhtml($line,"y");