From patchwork Thu Nov 16 08:56:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Peter_M=C3=BCller?= X-Patchwork-Id: 1539 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id A5EA16129C for ; Wed, 15 Nov 2017 22:56:46 +0100 (CET) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 3B35310D1; Wed, 15 Nov 2017 22:56:46 +0100 (CET) Received: from mx.link38.eu (mx.link38.eu [IPv6:2a03:4000:17:39a::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx.link38.eu", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 812207D1 for ; Wed, 15 Nov 2017 22:56:43 +0100 (CET) X-Virus-Scanned: ClamAV at mx.link38.eu Received: from mx-fra.brokers.link38.eu (mx-fra.brokers.link38.eu [10.141.75.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx.link38.eu (Postfix) with ESMTPS id 89DB94016A for ; Wed, 15 Nov 2017 22:56:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx-fra.brokers.link38.eu (Postfix) with ESMTPSA id 095C79F4A5 for ; Wed, 15 Nov 2017 22:56:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=link38.eu; s=201711; t=1510782997; bh=Ds49DQPwapPBD2Vq6ENcF4KhY6vYeO69elngnZmV6Vk=; h=Date:From:To:Subject:From; b=Nyw4gt1DJzbgwQP0xPrIKOP6yzHh4LgvLiK9N0JDVBwlbp7+EzUkbvxNP0ubPw3NY 2X6WpLz95GyR72/nPGOm8xvBAG6zdXi4K/dnRBEi9ySJ4AuqnYRX9lay7JkaJiV7Do 7VXLoZbQbXI3O5mHFWStP+8mVDwZj+RfGVWE463/Qem7NAc9MGSxdVuh0oNPZEkH9a z84t0uOs4RTvzxUOX32HQyhsj2ZQ2BA0srm6fFaMURwkcFpFd69MQ44MQpPwFgNdKJ aw7wduL/bZcosD6i+qYLH0Ddlg+HFyax1rw2/r8dxmvDvJMHqSqlkxvMhDPT7bQSZb NQKxaOlyO7GZA== Date: Wed, 15 Nov 2017 22:56:36 +0100 From: Peter =?utf-8?q?M=C3=BCller?= To: "development@lists.ipfire.org" Subject: [PATCH v2] display GeoIP information on ipinfo.cgi Message-ID: <20171115225636.63e93c18.peter.mueller@link38.eu> Organization: Link38 MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Display GeoIP information on ipinfo.cgi and use newly implemented function in /var/ipfire/geoip-functions.pl . Signed-off-by: Peter Müller --- 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 . " $ccode (" . $hostname . ') : '.$whoisname); print "
\n";
 	foreach my $line (@lines) {
 		print &Header::cleanhtml($line,"y");