[08/11] ipinfo.cgi: Display network flags of the given addresses.

Message ID 20200922182509.18643-8-stefan.schantl@ipfire.org
State Accepted
Commit e5b1e648f68401dc8e9a144b85ad0dcae2f74c0b
Headers
Series [01/11] location-functions.pl: Refactor get_locations() function to use the Location module. |

Commit Message

Stefan Schantl Sept. 22, 2020, 6:25 p.m. UTC
  Use the libloc data for gathering and displaying the stored network
flags, like "Anonymous Proxy" for the addresses.

The notice of a flag only will be displayed, if a flag is set for the
network which contains the given address.

Currently this notice text is "hardcoded" in englisch language, because
the entire other content of the page is in Englisch (responses from RIR's)
and also the flag names like "Anonymous Proxy" are only availabe in
English.

IMHO there is no need to to translate the string "This address is marked
as" into different languages, because of the reasons abouve.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 html/cgi-bin/ipinfo.cgi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Patch

diff --git a/html/cgi-bin/ipinfo.cgi b/html/cgi-bin/ipinfo.cgi
index 978488cb1..cce6097ff 100644
--- a/html/cgi-bin/ipinfo.cgi
+++ b/html/cgi-bin/ipinfo.cgi
@@ -64,6 +64,7 @@  if (&General::validip($addr)) {
 	# enumerate location information for IP address...
 	my $db_handle = &Location::Functions::init();
 	my $ccode = &Location::Functions::lookup_country_code($db_handle, $addr);
+	my $network_flag = &Location::Functions::address_has_flag($addr);
 
 	# Try to get the continent of the country code.
 	my $continent = &Location::get_continent_code($db_handle, $ccode);
@@ -108,6 +109,17 @@  if (&General::validip($addr)) {
 	}
 
 	&Header::openbox('100%', 'left', $addr . " <a href='country.cgi#$ccode'><img src='$flag_icon' border='0' align='absmiddle' alt='$ccode' title='$ccode' /></a> (" . $hostname . ') : '.$whois_server);
+
+	# Check if the address has a flag.
+	if ($network_flag) {
+		# Get
+		my $network_flag_name = &Location::Functions::get_full_country_name($network_flag);
+
+		# Display notice.
+		print "<h3>This address is marked as $network_flag_name.</h3>\n";
+		print "<br>\n";
+	}
+
 	print "<pre>\n";
 	foreach my $line (@lines) {
 		print &Header::cleanhtml($line,"y");