Skip to content

Commit 4ca5cee

Browse files
committed
Merge branch 'lambacck-develop' into develop
2 parents d51a21e + 3357f7d commit 4ca5cee

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

wwwroot/cgi-bin/awstats.model.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2
14691469
# the now expired Legacy schema.
14701470
# Replace spaces in the path of geoip data file with string "%20".
14711471
#
1472-
#LoadPlugin="geoip2 /pathto/GeoLite2-Country.mmdb"
1472+
#LoadPlugin="geoip2_country /pathto/GeoLite2-Country.mmdb"
14731473

14741474
# PLUGIN: GeoIP6
14751475
# REQUIRED MODULES: Geo::IP or Geo::IP::PurePerl (from Maxmind, version >= 1.40)

wwwroot/cgi-bin/awstats.pl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,7 +3135,7 @@ sub Read_Plugins {
31353135
'geoipfree' => 'u',
31363136
'geoip' => 'ou',
31373137
'geoip6' => 'ou',
3138-
'geoip2' => 'ou',
3138+
'geoip2_country' => 'ou',
31393139
'geoip_region_maxmind' => 'mou',
31403140
'geoip_city_maxmind' => 'mou',
31413141
'geoip2_city' => 'mou',
@@ -3314,7 +3314,7 @@ sub Read_Plugins {
33143314
if ( $PluginsLoaded{'init'}{'geoip'}
33153315
|| $PluginsLoaded{'init'}{'geoip6'}
33163316
|| $PluginsLoaded{'init'}{'geoipfree'}
3317-
|| $PluginsLoaded{'init'}{'geoip2'})
3317+
|| $PluginsLoaded{'init'}{'geoip2_country'})
33183318
{
33193319
$Message[17] = $Message[25] = $Message[148];
33203320
}
@@ -19435,8 +19435,8 @@ sub HTMLMainExtra{
1943519435
elsif ( $PluginsLoaded{'GetCountryCodeByAddr'}{'geoipfree'} ) {
1943619436
$Domain = GetCountryCodeByAddr_geoipfree($HostResolved);
1943719437
}
19438-
elsif ( $PluginsLoaded{'GetCountryCodeByAddr'}{'geoip2'} ) {
19439-
$Domain = GetCountryCodeByAddr_geoip2($HostResolved);
19438+
elsif ( $PluginsLoaded{'GetCountryCodeByAddr'}{'geoip2_country'} ) {
19439+
$Domain = GetCountryCodeByAddr_geoip2_country($HostResolved);
1944019440
}
1944119441
if ($AtLeastOneSectionPlugin) {
1944219442
foreach my $pluginname (
@@ -19473,9 +19473,9 @@ sub HTMLMainExtra{
1947319473
$Domain = GetCountryCodeByAddr_geoipfree($Host);
1947419474
}
1947519475
elsif (
19476-
$PluginsLoaded{'GetCountryCodeByAddr'}{'geoip2'} )
19476+
$PluginsLoaded{'GetCountryCodeByAddr'}{'geoip2_country'} )
1947719477
{
19478-
$Domain = GetCountryCodeByAddr_geoip2($Host);
19478+
$Domain = GetCountryCodeByAddr_geoip2_country($Host);
1947919479
}
1948019480
elsif ( $HostResolved =~ /\.(\w+)$/ ) { $Domain = $1; }
1948119481
if ($AtLeastOneSectionPlugin) {
@@ -19507,9 +19507,9 @@ sub HTMLMainExtra{
1950719507
$Domain = GetCountryCodeByName_geoipfree($HostResolved);
1950819508
}
1950919509
elsif (
19510-
$PluginsLoaded{'GetCountryCodeByName'}{'geoip2'} )
19510+
$PluginsLoaded{'GetCountryCodeByName'}{'geoip2_country'} )
1951119511
{
19512-
$Domain = GetCountryCodeByName_geoip2($HostResolved);
19512+
$Domain = GetCountryCodeByName_geoip2_country($HostResolved);
1951319513
}
1951419514
elsif ( $HostResolved =~ /\.(\w+)$/ ) { $Domain = $1; }
1951519515
if ($AtLeastOneSectionPlugin) {
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# <-----
1414
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
1515
use vars qw/ $type /;
16-
$type='geoip2';
16+
$type='geoip2_country';
1717
if (!eval ('require "GeoIP2/Database/Reader.pm";')) {
1818
$error=$@;
1919
$ret=($error)?"Error:\n$error":"";
@@ -41,7 +41,7 @@ no strict "refs";
4141
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
4242
my $PluginNeedAWStatsVersion="5.4";
4343
my $PluginHooksFunctions="GetCountryCodeByAddr GetCountryCodeByName ShowInfoHost";
44-
my $PluginName = "geoip2";
44+
my $PluginName = "geoip2_country";
4545
my $LoadedOverride=0;
4646
my $OverrideFile="";
4747
my %TmpDomainLookup;
@@ -59,7 +59,7 @@ use Data::Validate::IP 0.25 qw( is_public_ip );
5959
#-----------------------------------------------------------------------------
6060
# PLUGIN FUNCTION: Init_pluginname
6161
#-----------------------------------------------------------------------------
62-
sub Init_geoip2 {
62+
sub Init_geoip2_country {
6363
my $InitParams=shift;
6464
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
6565

@@ -92,10 +92,10 @@ sub Init_geoip2 {
9292
# UNIQUE: YES (Only one plugin using this function can be loaded)
9393
# GetCountryCodeByAddr is called to translate an ip into a country code in lower case.
9494
#-----------------------------------------------------------------------------
95-
sub GetCountryCodeByAddr_geoip2 {
95+
sub GetCountryCodeByAddr_geoip2_country {
9696
my $param = shift;
9797
if (! $param) { return ''; }
98-
my $res = Lookup_geoip2($param);
98+
my $res = Lookup_geoip2_country($param);
9999
return ($res) ? lc($res) : 'unknown';
100100
}
101101

@@ -105,8 +105,8 @@ sub GetCountryCodeByAddr_geoip2 {
105105
# UNIQUE: YES (Only one plugin using this function can be loaded)
106106
# GetCountryCodeByName is called to translate a host name into a country code in lower case.
107107
#-----------------------------------------------------------------------------
108-
sub GetCountryCodeByName_geoip2 {
109-
return GetCountryCodeByAddr_geoip2(@_);
108+
sub GetCountryCodeByName_geoip2_country {
109+
return GetCountryCodeByAddr_geoip2_country(@_);
110110
}
111111

112112

@@ -119,7 +119,7 @@ sub GetCountryCodeByName_geoip2 {
119119
# print "<TD>This is a new cell for $param</TD>";
120120
# Parameters: Host name or ip
121121
#-----------------------------------------------------------------------------
122-
sub ShowInfoHost_geoip2 {
122+
sub ShowInfoHost_geoip2_country {
123123
my $param="$_[0]";
124124
# <-----
125125
if ($param eq '__title__') {
@@ -142,8 +142,7 @@ sub ShowInfoHost_geoip2 {
142142
print "</th>";
143143
}
144144
elsif ($param) {
145-
print "<td>";
146-
my $res = Lookup_geoip2($param);
145+
my $res = Lookup_geoip2_country($param);
147146
if ($res) {
148147
$res = lc($res);
149148
print $DomainsHashIDLib{$res}?$DomainsHashIDLib{$res}:"<span style=\"color: #$color_other\">$Message[0]</span>";
@@ -164,7 +163,7 @@ sub ShowInfoHost_geoip2 {
164163
# Useful for Intranet records
165164
# CSV format: IP,2-char Country code
166165
#-----------------------------------------------------------------------------
167-
sub LoadOverrideFile_geoip2{
166+
sub LoadOverrideFile_geoip2_country{
168167
my $filetoload="";
169168
if ($OverrideFile){
170169
if (!open(GEOIPFILE, $OverrideFile)){
@@ -203,10 +202,10 @@ sub LoadOverrideFile_geoip2{
203202
# associated country code; or undefined if not available.
204203
# GEOIP entry
205204
#-----------------------------------------------------------------------------
206-
sub Lookup_geoip2 {
205+
sub Lookup_geoip2_country {
207206
$param = shift;
208-
if (!$LoadedOverride) { &LoadOverrideFile_geoip2(); }
209-
if ($Debug) { debug(" Plugin $PluginName: Lookup_geoip2 for $param",5); }
207+
if (!$LoadedOverride) { &LoadOverrideFile_geoip2_country(); }
208+
if ($Debug) { debug(" Plugin $PluginName: Lookup_geoip2_country for $param",5); }
210209
if ($reader && !exists($TmpDomainLookup{$param})) {
211210
$TmpDomainLookup{$param} = undef; # negative entry to avoid repeated lookups
212211
# Resolve the parameter (either a name or an ip address) to a list of network addresses
@@ -216,7 +215,7 @@ sub Lookup_geoip2 {
216215
my ($err, $address, $servicename) = Socket::getnameinfo($_->{addr}, Socket::NI_NUMERICHOST, Socket::NIx_NOSERV);
217216
next if ($err || !is_public_ip($address));
218217

219-
if ($Debug && $param ne $address) { debug(" Plugin $PluginName: Lookup_geoip2 $param resolved to $address",5); }
218+
if ($Debug && $param ne $address) { debug(" Plugin $PluginName: Lookup_geoip2_country $param resolved to $address",5); }
220219
eval {
221220
my $record = $reader->country(ip => $address);
222221
$TmpDomainLookup{$param} = $record->country()->iso_code();
@@ -225,7 +224,7 @@ sub Lookup_geoip2 {
225224
}
226225
}
227226
my $res = $TmpDomainLookup{$param};
228-
if ($Debug) { debug(" Plugin $PluginName: Lookup_geoip2 for $param: [$res]",5); }
227+
if ($Debug) { debug(" Plugin $PluginName: Lookup_geoip2_country for $param: [$res]",5); }
229228
return $res;
230229
}
231230

0 commit comments

Comments
 (0)