From: Stefan Schantl Date: Sat, 7 Nov 2020 18:47:24 +0000 (+0100) Subject: Adjust CGI files to work with latest location-function.pl changes. X-Git-Tag: v2.25-core155~384^2~74 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07e42be9783ddfe2c6e49d98676fcdb7f2dfecd7;hp=427190d5789b02331cb91d72f0fb7f97374a0aa0;p=ipfire-2.x.git Adjust CGI files to work with latest location-function.pl changes. Fixes #12515. Signed-off-by: Stefan Schantl Signed-off-by: Michael Tremer --- diff --git a/html/cgi-bin/connections.cgi b/html/cgi-bin/connections.cgi index 6c55bd7a06..8613b9d9b0 100644 --- a/html/cgi-bin/connections.cgi +++ b/html/cgi-bin/connections.cgi @@ -86,9 +86,6 @@ if ( $debug ){ my @dummy = ( ${Header::table1colour} ); undef (@dummy); -# Init libloc database connection. -my $libloc_db_handle = &Location::Functions::init(); - # check sorting arguments if ( $cgiin{'sort_field'} ~~ [ '1','2','3','4','5','6','7','8','9' ] ) { $SORT_FIELD = $cgiin{'sort_field'}; @@ -554,9 +551,9 @@ foreach my $line (@conntrack) { my $bytes_out = format_bytes($bytes[1]); # enumerate location information - my $srcccode = &Location::Functions::lookup_country_code($libloc_db_handle, $sip_ret); + my $srcccode = &Location::Functions::lookup_country_code($sip_ret); my $src_flag_icon = &Location::Functions::get_flag_icon($srcccode); - my $dstccode = &Location::Functions::lookup_country_code($libloc_db_handle, $dip_ret); + my $dstccode = &Location::Functions::lookup_country_code($dip_ret); my $dst_flag_icon = &Location::Functions::get_flag_icon($dstccode); # Format TTL diff --git a/html/cgi-bin/country.cgi b/html/cgi-bin/country.cgi index b519d89b3c..b1c72bb223 100644 --- a/html/cgi-bin/country.cgi +++ b/html/cgi-bin/country.cgi @@ -52,11 +52,8 @@ print< END -# Init libloc database connection. -my $db_handle = &Location::Functions::init(); - # Get a list of all supported country codes. -my @countries = &Location::database_countries($db_handle); +my @countries = &Location::database_countries(); # Loop through whole country list. foreach my $country (@countries) { diff --git a/html/cgi-bin/dns.cgi b/html/cgi-bin/dns.cgi index 13dd9d6a09..762e77ff1d 100755 --- a/html/cgi-bin/dns.cgi +++ b/html/cgi-bin/dns.cgi @@ -269,9 +269,6 @@ my %dns_servers = (); # Read-in config file. &General::readhasharray("$servers_file", \%dns_servers); -# Libloc database handle -my $libloc_db_handle = &Location::Functions::init(); - &Header::openpage($Lang::tr{'dns title'}, 1, ''); &Header::openbigbox('100%', 'left', '', $errormessage); @@ -598,7 +595,7 @@ END } # collect more information about name server (rDNS, country code) - my $ccode = &Location::Functions::lookup_country_code($libloc_db_handle, $nameserver); + my $ccode = &Location::Functions::lookup_country_code($nameserver); my $flag_icon = &Location::Functions::get_flag_icon($ccode); my $rdns; diff --git a/html/cgi-bin/ipinfo.cgi b/html/cgi-bin/ipinfo.cgi index d8cb6c6b76..ecc7c436cf 100644 --- a/html/cgi-bin/ipinfo.cgi +++ b/html/cgi-bin/ipinfo.cgi @@ -62,12 +62,11 @@ if (&General::validip($addr)) { if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; } # enumerate location information for IP address... - my $db_handle = &Location::Functions::init(); - my $ccode = &Location::Functions::lookup_country_code($db_handle, $addr); + my $ccode = &Location::Functions::lookup_country_code($addr); my @network_flags = &Location::Functions::address_has_flags($addr); # Try to get the continent of the country code. - my $continent = &Location::get_continent_code($db_handle, $ccode); + my $continent = &Location::Functions::get_continent_code($ccode); # Check if a whois server for the continent is known. if($whois_servers_by_continent{$continent}) { diff --git a/html/cgi-bin/logs.cgi/firewalllog.dat b/html/cgi-bin/logs.cgi/firewalllog.dat index 2b690e35b7..361bf04327 100644 --- a/html/cgi-bin/logs.cgi/firewalllog.dat +++ b/html/cgi-bin/logs.cgi/firewalllog.dat @@ -24,9 +24,6 @@ require "${General::swroot}/location-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; -# Libloc database handle. -my $libloc_db_handle = &Location::Functions::init(); - my %color = (); my %mainsettings = (); &General::readhash("${General::swroot}/main/settings", \%mainsettings); @@ -354,7 +351,8 @@ foreach $_ (@log) $srcport=$1 if $packet =~ /SPT=(\d+)/; $dstport=$1 if $packet =~ /DPT=(\d+)/; - my $ccode = &Location::Functions::lookup_country_code($libloc_db_handle, $srcaddr); + # Get the country code. + my $ccode = &Location::Functions::lookup_country_code($srcaddr); my $servi = uc(getservbyport($srcport, lc($proto))); if ($servi ne '' && $srcport < 1024) { diff --git a/html/cgi-bin/logs.cgi/firewalllogcountry.dat b/html/cgi-bin/logs.cgi/firewalllogcountry.dat index 701abab2c8..e3901b945d 100644 --- a/html/cgi-bin/logs.cgi/firewalllogcountry.dat +++ b/html/cgi-bin/logs.cgi/firewalllogcountry.dat @@ -22,9 +22,6 @@ require "${General::swroot}/location-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; -# Libloc database handle. -my $libloc_db_handle = &Location::Functions::init(); - use POSIX(); my %cgiparams=(); @@ -311,7 +308,7 @@ foreach $_ (@log) # Traffic from red if($srcaddr ne '') { # srcaddr is set - my $ccode = &Location::Functions::lookup_country_code($libloc_db_handle, $srcaddr); + my $ccode = &Location::Functions::lookup_country_code($srcaddr); if ($ccode eq '') { $ccode = 'unknown'; } diff --git a/html/cgi-bin/logs.cgi/firewalllogip.dat b/html/cgi-bin/logs.cgi/firewalllogip.dat index 670d72a526..6de4081afb 100644 --- a/html/cgi-bin/logs.cgi/firewalllogip.dat +++ b/html/cgi-bin/logs.cgi/firewalllogip.dat @@ -22,9 +22,6 @@ require "${General::swroot}/location-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; -# Libloc database handle. -my $libloc_db_handle = &Location::Functions::init(); - use POSIX(); my %cgiparams=(); @@ -438,7 +435,8 @@ for($s=0;$s<$lines;$s++) $col="bgcolor='$color{\"color$colorIndex\"}'"; print ""; - my $ccode = &Location::Functions::lookup_country_code($libloc_db_handle, $key[$s]); + # Get country code. + my $ccode = &Location::Functions::lookup_country_code($key[$s]); $color++; print "
"; diff --git a/html/cgi-bin/logs.cgi/showrequestfromcountry.dat b/html/cgi-bin/logs.cgi/showrequestfromcountry.dat index 4d80e77a4d..2a246ec60e 100644 --- a/html/cgi-bin/logs.cgi/showrequestfromcountry.dat +++ b/html/cgi-bin/logs.cgi/showrequestfromcountry.dat @@ -19,9 +19,6 @@ require "${General::swroot}/location-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; -# Libloc database handle. -my $libloc_db_handle = &Location::Functions::init(); - use POSIX(); #workaround to suppress a warning when a variable is used only once @@ -181,7 +178,7 @@ if (!$skip) } elsif($srcaddr ne '') { # or srcaddr matches country code - my $ccode = &Location::Functions::lookup_country_code($libloc_db_handle, $srcaddr); + my $ccode = &Location::Functions::lookup_country_code($srcaddr); if($ccode eq uc($country)){ $log[$lines] = $_; $lines++; @@ -352,7 +349,7 @@ foreach $_ (@slice) if($iface eq $country || $srcaddr ne '') { my $ccode=''; if($iface ne $country) { - $ccode = &Location::Functions::lookup_country_code($libloc_db_handle, $srcaddr); + $ccode = &Location::Functions::lookup_country_code($srcaddr); } if($iface eq $country || $ccode eq uc($country)) { my $chain = ''; diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index e7bc505e74..8626a94cad 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -3002,9 +3002,6 @@ END &Header::openbigbox('100%', 'LEFT', '', ''); &Header::openbox('100%', 'LEFT', $Lang::tr{'ovpn con stat'}); - # Libloc database handle. - my $libloc_db_handle = &Location::Functions::init(); - # # $Lang::tr{'protocol'} # protocol temp removed @@ -3055,7 +3052,7 @@ END $users[$uid]{'Proto'} = $proto; # get country code for "RealAddress"... - my $ccode = &Location::Functions::lookup_country_code($libloc_db_handle, (split ':', $users[$uid]{'RealAddress'})[0]); + my $ccode = &Location::Functions::lookup_country_code((split ':', $users[$uid]{'RealAddress'})[0]); my $flag_icon = &Location::Functions::get_flag_icon($ccode); $users[$uid]{'Country'} = "$ccode"; $uid++; diff --git a/html/cgi-bin/remote.cgi b/html/cgi-bin/remote.cgi index 9c742669bc..a27e10de95 100644 --- a/html/cgi-bin/remote.cgi +++ b/html/cgi-bin/remote.cgi @@ -277,10 +277,6 @@ sub printactivelogins() print "$Lang::tr{'ssh no active logins'}\n"; } else { # list active logins... - - # Libloc database handle. - my $libloc_db_handle = &Location::Functions::init(); - foreach my $line (@output) { my @arry = split(/\ +/, $line); @@ -291,7 +287,7 @@ sub printactivelogins() $remoteip =~ s/[()]//g; # display more information about that IP adress... - my $ccode = &Location::Functions::lookup_country_code($libloc_db_handle, $remoteip); + my $ccode = &Location::Functions::lookup_country_code($remoteip); my $flag_icon = &Location::Functions::get_flag_icon($ccode); # get rDNS... diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi index 14bfcfe900..983bb30c9a 100644 --- a/html/cgi-bin/tor.cgi +++ b/html/cgi-bin/tor.cgi @@ -30,9 +30,6 @@ require "${General::swroot}/location-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; -# Init libloc database connection. -my $db_handle = &Location::Functions::init(); - #workaround to suppress a warning when a variable is used only once my @dummy = ( ${Header::colouryellow} ); undef (@dummy); @@ -322,7 +319,7 @@ END