Hello development-list,
I was just wondering if something is wrong with the patch (code error/bad style?) because there was no answer within ~ two weeks.
Best regards, Timmothy Wilson
IT Superhack:
Add the GeoIP information to the general ip information (address, reverse dns name) on the ipinfo.cgi.
The ip address is given to Geo::IP::PurePerl first, then the country code and the flag icon path are queried.
Fixes a feature request filed under bug #10946
Signed-off-by: Timmothy Wilson itsuperhack@web.de
diff --git a/html/cgi-bin/ipinfo.cgi b/html/cgi-bin/ipinfo.cgi index 71098a2..cebce23 100644 --- a/html/cgi-bin/ipinfo.cgi +++ b/html/cgi-bin/ipinfo.cgi @@ -20,6 +20,7 @@ ###############################################################################
use IO::Socket; +use Geo::IP::PurePerl; use strict;
# enable only the following on debugging purpose @@ -27,10 +28,13 @@ use strict; #use CGI::Carp 'fatalsToBrowser';
require '/var/ipfire/general-functions.pl'; +require "${General::swroot}/geoip-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl";
my %cgiparams=(); +my $s; +my @key;
&Header::showhttpheaders();
@@ -52,6 +56,14 @@ next if $addr eq ""; my $iaddr = inet_aton($addr); my $hostname = gethostbyaddr($iaddr, AF_INET); if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; }
# geoip lookup
my $geoaddr = Geo::IP::PurePerl->new();
my $ccode = $geoaddr->country_code_by_name($addr);
my $fcode = lc($ccode);
# Get flag icon for of the country.
my $flag_icon = &GeoIP::get_flag_icon($ccode);
my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp'); if ($sock)
@@ -84,7 +96,9 @@ next if $addr eq ""; @lines = ( "$Lang::tr{'unable to contact'} $whoisname" ); }
- &Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : '.$whoisname);
- # include geoip information here
- &Header::openbox('100%', 'left', $addr . ' <a href='/cgi-bin/country.cgi#' . $fcode . ''><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");