public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: "Peter Müller" <peter.mueller@link38.eu>
To: development@lists.ipfire.org
Subject: [PATCH v2] display GeoIP information on ipinfo.cgi
Date: Wed, 15 Nov 2017 22:56:36 +0100	[thread overview]
Message-ID: <20171115225636.63e93c18.peter.mueller@link38.eu> (raw)

[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]

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(a)link38.eu>
---
 html/cgi-bin/ipinfo.cgi | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/html/cgi-bin/ipinfo.cgi b/html/cgi-bin/ipinfo.cgi
index 16541f126..b756a24d2 100644
--- a/html/cgi-bin/ipinfo.cgi
+++ b/html/cgi-bin/ipinfo.cgi
@@ -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");
-- 
2.13.6


                 reply	other threads:[~2017-11-15 21:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171115225636.63e93c18.peter.mueller@link38.eu \
    --to=peter.mueller@link38.eu \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox