From: Neil Gierman Date: Fri, 20 Apr 2018 00:08:33 +0000 (-0500) Subject: Make city plugin more functional X-Git-Tag: AWSTATS_7_8~22^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a53eaa6aee677d45bfac7f00367089924c85a1c7;p=thirdparty%2FAWStats.git Make city plugin more functional --- diff --git a/wwwroot/cgi-bin/plugins/geoip2_city.pm b/wwwroot/cgi-bin/plugins/geoip2_city.pm index 076f2aa5..92d0bbcf 100644 --- a/wwwroot/cgi-bin/plugins/geoip2_city.pm +++ b/wwwroot/cgi-bin/plugins/geoip2_city.pm @@ -4378,16 +4378,16 @@ sub AddHTMLGraph_geoip2_city { # print "\n"; foreach my $key (@keylist) { if ($key eq 'unknown') { next; } - my ($countrycode,$city,$regioncode)=split('_',$key,3); + my ($countrycode,$city,$regionname)=split('_',$key,3); $city=~s/%20/ /g; + $regionname=~s/%20/ /g; # if ($countrycode ne $country) { next; } my $p_p; my $p_h; if ($TotalPages) { $p_p=int(($_city_p{$key}||0)/$TotalPages*1000)/10; } if ($TotalHits) { $p_h=int($_city_h{$key}/$TotalHits*1000)/10; } print ""; print "".$DomainsHashIDLib{$countrycode}.""; - my $regionlib=RegionName($countrycode, $regioncode); - print "".($regionlib?$regionlib:' ').""; + print "".ucfirst(EncodeToPageCode($regionname)).""; print "".ucfirst(EncodeToPageCode($city)).""; if ($ShowCities =~ /P/i) { print "".($_city_p{$key}?Format_Number($_city_p{$key}):" ").""; } if ($ShowCities =~ /P/i) { print "".($_city_p{$key}?"$p_p %":' ').""; } @@ -4587,10 +4587,10 @@ sub ShowInfoHost_geoip2_city { else { my $record=(); - $record=$geoip2_city->record_by_name($param) if $geoip2_city; + $record=$geoip2_city->city(ip=>$param) if $geoip2_city; if ($Debug) { debug(" Plugin $PluginName: GetCityByHostname for $param: [$record]",5); } - $country=$record->country_code if $record; - $city=$record->city if $record; + $country=$record->country()->iso_code() if $record; + $city=$record->city()->name() if $record; } # print ""; # if ($country) { print $DomainsHashIDLib{$country}?$DomainsHashIDLib{$country}:"$Message[0]"; }