~ubuntu-branches/ubuntu/lucid/awstats/lucid-updates

« back to all changes in this revision

Viewing changes to wwwroot/cgi-bin/plugins/geoip_city_maxmind.pm

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde
  • Date: 2008-12-10 13:05:43 UTC
  • mfrom: (7.1.10 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081210130543-2sh59pphufllknju
Tags: 6.7.dfsg-5.1
* Non-maintainer upload by the Security Team.
* Strip '"' characters during URL decoding, fixing a cross-site
  scripting attack (CVE-2008-3714; CVE-2008-5080; Closes: #495432).

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
# This plugin allow you to add a city report.
5
5
# Need the licensed city database from Maxmind.
6
6
#-----------------------------------------------------------------------------
7
 
# Perl Required Modules: Geo::IP (Geo::IP::PurePerl is not yet supported)
 
7
# Perl Required Modules: Geo::IP or Geo::IP::PurePerl
8
8
#-----------------------------------------------------------------------------
9
 
# $Revision: 1.13 $ - $Author: eldy $ - $Date: 2005/12/14 23:44:33 $
 
9
# $Revision: 1.20 $ - $Author: eldy $ - $Date: 2006/09/04 06:04:04 $
10
10
 
11
11
 
12
12
# <-----
13
13
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
14
 
if (!eval ('require "Geo/IP.pm";'))     {
15
 
    return $@?"Error: $@":"Error: Need Perl module Geo::IP (Geo::IP::PurePerl is not yet supported)";
 
14
use vars qw/ $type /;
 
15
$type='geoip';
 
16
if (!eval ('require "Geo/IP.pm";')) {
 
17
        $error1=$@;
 
18
        $type='geoippureperl';
 
19
        if (!eval ('require "Geo/IP/PurePerl.pm";')) {
 
20
                $error2=$@;
 
21
                $ret=($error1||$error2)?"Error:\n$error1$error2":"";
 
22
                $ret.="Error: Need Perl module Geo::IP or Geo::IP::PurePerl";
 
23
                return $ret;
 
24
        }
16
25
}
17
26
# ----->
18
27
use strict;no strict "refs";
25
34
# <-----
26
35
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
27
36
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
28
 
my $PluginNeedAWStatsVersion="6.2";
 
37
my $PluginNeedAWStatsVersion="6.5";
29
38
my $PluginHooksFunctions="AddHTMLMenuLink AddHTMLGraph ShowInfoHost SectionInitHashArray SectionProcessIp SectionProcessHostname SectionReadHistory SectionWriteHistory";
30
39
# ----->
31
40
 
32
41
# <-----
33
42
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
34
43
use vars qw/
 
44
%TmpDomainLookup
35
45
$geoip_city_maxmind
36
46
%_city_p
37
47
%_city_h
4252
4262
# ----->
4253
4263
 
4254
4264
 
 
4265
sub RegionName($$)
 
4266
{
 
4267
        my $countrycode = shift || "";
 
4268
        my $regioncode = shift || "";
 
4269
 
 
4270
        if ($countrycode eq "us") { return $regus{uc $regioncode} || ""; }
 
4271
        if ($countrycode eq "ca") { return $regca{uc $regioncode} || ""; }
 
4272
 
 
4273
        return $regall{uc($countrycode."_".$regioncode)} || "";
 
4274
}
 
4275
 
 
4276
 
4255
4277
#-----------------------------------------------------------------------------
4256
4278
# PLUGIN FUNCTION: Init_pluginname
4257
4279
#-----------------------------------------------------------------------------
4263
4285
        # <-----
4264
4286
        # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
4265
4287
        debug(" Plugin geoip_city_maxmind: InitParams=$InitParams",1);
4266
 
#    if ($UpdateStats) {
4267
 
        my ($mode,$datafile)=split(/\s+/,$InitParams,2);
4268
 
        if (! $datafile) { $datafile="GeoIPCity.dat"; }
4269
 
        if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE')  { $mode=Geo::IP::GEOIP_MEMORY_CACHE(); }
4270
 
        else { $mode=Geo::IP::GEOIP_STANDARD(); }
4271
 
        debug(" Plugin geoip_city_maxmind: GeoIP initialized in mode $mode",1);
4272
 
        $geoip_city_maxmind = Geo::IP->open($datafile, $mode);
4273
 
#    }
 
4288
        my ($mode,$datafile)=split(/\s+/,$InitParams,2);
 
4289
        if (! $datafile) { $datafile="GeoIPCity.dat"; }
 
4290
        if ($type eq 'geoippureperl') {
 
4291
                if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE')  { $mode=Geo::IP::PurePerl::GEOIP_MEMORY_CACHE(); }
 
4292
                else { $mode=Geo::IP::PurePerl::GEOIP_STANDARD(); }
 
4293
        } else {
 
4294
                if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE')  { $mode=Geo::IP::GEOIP_MEMORY_CACHE(); }
 
4295
                else { $mode=Geo::IP::GEOIP_STANDARD(); }
 
4296
        }
 
4297
        %TmpDomainLookup=();
 
4298
        debug(" Plugin geoip_city_maxmind: GeoIP initialized type=$type mode=$mode",1);
 
4299
        if ($type eq 'geoippureperl') {
 
4300
                $geoip_city_maxmind = Geo::IP::PurePerl->open($datafile, $mode);
 
4301
        } else {
 
4302
                $geoip_city_maxmind = Geo::IP->open($datafile, $mode);
 
4303
        }
 
4304
# Fails on some GeoIP version
 
4305
#       debug(" Plugin geoip_city_maxmind: GeoIP initialized database_info=".$geoip_city_maxmind->database_info());
4274
4306
        # ----->
4275
4307
 
4276
4308
        return ($checkversion?$checkversion:"$PluginHooksFunctions");
4348
4380
            $city=~s/%20/ /g;
4349
4381
#            if ($countrycode ne $country) { next; }
4350
4382
                        my $p_p; my $p_h;
4351
 
                        if ($TotalPages) { $p_p=int($_city_p{$key}/$TotalPages*1000)/10; }
 
4383
                        if ($TotalPages) { $p_p=int(($_city_p{$key}||0)/$TotalPages*1000)/10; }
4352
4384
                        if ($TotalHits)  { $p_h=int($_city_h{$key}/$TotalHits*1000)/10; }
4353
4385
                    print "<tr>";
4354
4386
                    print "<td class=\"aws\">".$DomainsHashIDLib{$countrycode}."</td>";
4355
 
                    print "<td class=\"aws\">".($regall{uc($countrycode."_".$regioncode)}?$regall{uc($countrycode."_".$regioncode)}:"&nbsp;")."</td>";
 
4387
                    my $regionlib=RegionName($countrycode, $regioncode);
 
4388
                    print "<td class=\"aws\">".($regionlib?$regionlib:'&nbsp;')."</td>";
4356
4389
                    print "<td class=\"aws\">".ucfirst($city)."</td>";
4357
4390
                if ($ShowCities =~ /P/i) { print "<td>".($_city_p{$key}?$_city_p{$key}:"&nbsp;")."</td>"; }
4358
4391
                if ($ShowCities =~ /P/i) { print "<td>".($_city_p{$key}?"$p_p %":'&nbsp;')."</td>"; }
4403
4436
 
4404
4437
 
4405
4438
#-----------------------------------------------------------------------------
 
4439
# PLUGIN FUNCTION: GetCountryCodeByAddr_pluginname
 
4440
# UNIQUE: YES (Only one plugin using this function can be loaded)
 
4441
# GetCountryCodeByAddr is called to translate an ip into a country code in lower case.
 
4442
#-----------------------------------------------------------------------------
 
4443
# Rem: not used
 
4444
sub GetCountryCodeByAddr_geoip_city_maxmind {
 
4445
    my $param="$_[0]";
 
4446
        # <-----
 
4447
        my $res=$TmpDomainLookup{$param}||'';
 
4448
        if ($type eq 'geoippureperl') {
 
4449
                if (! $res) {
 
4450
                        my @record = ();
 
4451
                        @record=$geoip_city_maxmind->get_city_record($param) if $geoip_city_maxmind;
 
4452
                my $country;
 
4453
                $country=$record[0] if @record;
 
4454
                $res=lc($country) || 'unknown';
 
4455
                        $TmpDomainLookup{$param}=$res;
 
4456
                if ($Debug) { debug("  Plugin geoip_region_maxmind: GetCountryCodeByAddr for $param: [$res]",5); }
 
4457
                }
 
4458
                elsif ($Debug) { debug("  Plugin geoip_region_maxmind: GetCountryCodeByAddr for $param: Already resolved to [$res]",5); }
 
4459
        }
 
4460
        else
 
4461
        {
 
4462
                if (! $res) {
 
4463
                my $record=();
 
4464
                $record=$geoip_city_maxmind->record_by_addr($param) if $geoip_city_maxmind;
 
4465
                my $country;
 
4466
                $country=$record->country if $record;
 
4467
                $res=lc($country) || 'unknown';
 
4468
                        $TmpDomainLookup{$param}=$res;
 
4469
                if ($Debug) { debug("  Plugin geoip_region_maxmind: GetCountryCodeByAddr for $param: [$res]",5); }
 
4470
                }
 
4471
                elsif ($Debug) { debug("  Plugin geoip_region_maxmind: GetCountryCodeByAddr for $param: Already resolved to [$res]",5); }
 
4472
        }
 
4473
        # ----->
 
4474
        return $res;
 
4475
}
 
4476
 
 
4477
 
 
4478
#-----------------------------------------------------------------------------
 
4479
# PLUGIN FUNCTION: GetCountryCodeByName_pluginname
 
4480
# UNIQUE: YES (Only one plugin using this function can be loaded)
 
4481
# GetCountryCodeByName is called to translate a host name into a country code in lower case.
 
4482
#-----------------------------------------------------------------------------
 
4483
# Rem: not used
 
4484
sub GetCountryCodeByName_geoip_city_maxmind {
 
4485
    my $param="$_[0]";
 
4486
        # <-----
 
4487
        my $res=$TmpDomainLookup{$param}||'';
 
4488
        if ($type eq 'geoippureperl') {
 
4489
                if (! $res) {
 
4490
                        my @record = ();
 
4491
                        @record=$geoip_city_maxmind->get_city_record($param) if $geoip_city_maxmind;
 
4492
                my $country;
 
4493
                $country=$record[0] if @record;
 
4494
                $res=lc($country) || 'unknown';
 
4495
                        $TmpDomainLookup{$param}=$res;
 
4496
                if ($Debug) { debug("  Plugin geoip_region_maxmind: GetCountryCodeByName for $param: [$res]",5); }
 
4497
                }
 
4498
                elsif ($Debug) { debug("  Plugin geoip_region_maxmind: GetCountryCodeByName for $param: Already resolved to [$res]",5); }
 
4499
        }
 
4500
        else
 
4501
        {
 
4502
                if (! $res) {
 
4503
                my $record=();
 
4504
                $record=$geoip_city_maxmind->record_by_name($param) if $geoip_city_maxmind;
 
4505
                my $country;
 
4506
                $country=$record->country if $record;
 
4507
                $res=lc($country) || 'unknown';
 
4508
                        $TmpDomainLookup{$param}=$res;
 
4509
                if ($Debug) { debug("  Plugin geoip_region_maxmind: GetCountryCodeByName for $param: [$res]",5); }
 
4510
                }
 
4511
                elsif ($Debug) { debug("  Plugin geoip_region_maxmind: GetCountryCodeByName for $param: Already resolved to [$res]",5); }
 
4512
        }
 
4513
        # ----->
 
4514
        return $res;
 
4515
}
 
4516
 
 
4517
 
 
4518
#-----------------------------------------------------------------------------
4406
4519
# PLUGIN FUNCTION: ShowInfoHost_pluginname
4407
4520
# UNIQUE: NO (Several plugins using this function can be loaded)
4408
4521
# Function called to add additionnal columns to the Hosts report.
4414
4527
sub ShowInfoHost_geoip_city_maxmind {
4415
4528
    my $param="$_[0]";
4416
4529
        # <-----
4417
 
        if ($param eq '__title__') {
 
4530
        if ($param eq '__title__')
 
4531
        {
4418
4532
        my $NewLinkParams=${QueryString};
4419
4533
        $NewLinkParams =~ s/(^|&|&amp;)update(=\w*|$)//i;
4420
4534
        $NewLinkParams =~ s/(^|&|&amp;)output(=\w*|$)//i;
4430
4544
        $NewLinkParams =~ s/^&amp;//; $NewLinkParams =~ s/&amp;$//;
4431
4545
        if ($NewLinkParams) { $NewLinkParams="${NewLinkParams}&"; }
4432
4546
 
 
4547
#               print "<th width=\"80\">";
 
4548
#        print "<a href=\"".($ENV{'GATEWAY_INTERFACE'} || !$StaticLinks?XMLEncode("$AWScript?${NewLinkParams}output=plugin_geoip_city_maxmind&amp;suboutput=country"):"$PROG$StaticLinks.plugin_geoip_city_maxmind.country.$StaticExt")."\"$NewLinkTarget>GeoIP<br/>Country</a>";
 
4549
#        print "</th>";
4433
4550
                print "<th width=\"80\">";
4434
4551
        print "<a href=\"".($ENV{'GATEWAY_INTERFACE'} || !$StaticLinks?XMLEncode("$AWScript?${NewLinkParams}output=plugin_geoip_city_maxmind"):"$PROG$StaticLinks.plugin_geoip_city_maxmind.$StaticExt")."\"$NewLinkTarget>GeoIP<br/>City</a>";
4435
4552
        print "</th>";
4436
4553
        }
4437
 
        elsif ($param) {
 
4554
        elsif ($param)
 
4555
        {
4438
4556
        my $ip=0;
4439
4557
                my $key;
4440
4558
                if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
4445
4563
                    $ip=6;
4446
4564
                        $key=$param;
4447
4565
                }
4448
 
                print "<td>";
4449
4566
                if ($key && $ip==4) {
4450
 
                my $record=();
4451
 
                $record=$geoip_city_maxmind->record_by_addr($param) if $geoip_city_maxmind;
4452
 
                if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByIp for $param: [$record]",5); }
4453
 
            my $city;
4454
 
            $city=$record->city if $record;
 
4567
                my $country;
 
4568
                my $city;
 
4569
                        if ($type eq 'geoippureperl')
 
4570
                        {
 
4571
                                my @record = ();
 
4572
                                @record=$geoip_city_maxmind->get_city_record($param) if $geoip_city_maxmind;
 
4573
                        if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByIp for $param: [@record]",5); }
 
4574
                    $country=$record[0] if @record;
 
4575
                    $city=$record[4] if @record;
 
4576
                        }
 
4577
                        else
 
4578
                        {
 
4579
                        my $record=();
 
4580
                        $record=$geoip_city_maxmind->record_by_addr($param) if $geoip_city_maxmind;
 
4581
                        if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByIp for $param: [$record]",5); }
 
4582
                    $country=$record->country_code if $record;
 
4583
                    $city=$record->city if $record;
 
4584
                        }
 
4585
#                       print "<td>";
 
4586
#                   if ($country) { print $DomainsHashIDLib{$country}?$DomainsHashIDLib{$country}:"<span style=\"color: #$color_other\">$Message[0]</span>"; }
 
4587
#                   else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
 
4588
#                   print "</td>";
 
4589
                        print "<td>";
4455
4590
                    if ($city) { print "$city"; }
4456
4591
                    else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
 
4592
                    print "</td>";
4457
4593
                }
4458
4594
                if ($key && $ip==6) {
 
4595
#                       print "<td>";
 
4596
#                   print "<span style=\"color: #$color_other\">$Message[0]</span>";
 
4597
#                       print "</td>";
 
4598
                        print "<td>";
4459
4599
                    print "<span style=\"color: #$color_other\">$Message[0]</span>";
 
4600
                        print "</td>";
4460
4601
                }
4461
4602
                if (! $key) {
4462
 
                my $record=();
4463
 
                $record=$geoip_city_maxmind->record_by_name($param) if $geoip_city_maxmind;
4464
 
                if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByHostname for $param: [$record]",5); }
4465
 
            my $city;
4466
 
            $city=$record->city if $record;
 
4603
                my $country;
 
4604
                my $city;
 
4605
                        if ($type eq 'geoippureperl')
 
4606
                        {
 
4607
                                my @record = ();
 
4608
                                @record=$geoip_city_maxmind->get_city_record($param) if $geoip_city_maxmind;
 
4609
                        if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByHostname for $param: [@record]",5); }
 
4610
                    $country=$record[0] if @record;
 
4611
                    $city=$record[4] if @record;
 
4612
                        }
 
4613
                        else
 
4614
                        {
 
4615
                        my $record=();
 
4616
                        $record=$geoip_city_maxmind->record_by_name($param) if $geoip_city_maxmind;
 
4617
                        if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByHostname for $param: [$record]",5); }
 
4618
                    $country=$record->country_code if $record;
 
4619
                    $city=$record->city if $record;
 
4620
                        }
 
4621
#                       print "<td>";
 
4622
#                   if ($country) { print $DomainsHashIDLib{$country}?$DomainsHashIDLib{$country}:"<span style=\"color: #$color_other\">$Message[0]</span>"; }
 
4623
#                   else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
 
4624
#                   print "</td>";
 
4625
                        print "<td>";
4467
4626
                    if ($city) { print "$city"; }
4468
4627
                    else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
 
4628
                        print "</td>";
4469
4629
                }
4470
 
                print "</td>";
4471
4630
        }
4472
 
        else {
 
4631
        else
 
4632
        {
 
4633
#               print "<td>&nbsp;</td>";
4473
4634
                print "<td>&nbsp;</td>";
4474
4635
        }
4475
4636
        return 1;
4482
4643
# UNIQUE: NO (Several plugins using this function can be loaded)
4483
4644
#-----------------------------------------------------------------------------
4484
4645
sub SectionInitHashArray_geoip_city_maxmind {
4485
 
    my $param="$_[0]";
 
4646
#    my $param="$_[0]";
4486
4647
        # <-----
4487
4648
        if ($Debug) { debug(" Plugin geoip_city_maxmind: Init_HashArray"); }
4488
4649
        %_city_p = %_city_h = %_city_k = %_city_l =();
4498
4659
sub SectionProcessIp_geoip_city_maxmind {
4499
4660
    my $param="$_[0]";      # Param must be an IP
4500
4661
        # <-----
4501
 
        my $record=();
4502
 
        $record=$geoip_city_maxmind->record_by_addr($param) if $geoip_city_maxmind;
4503
 
        if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByIp for $param: [$record]",5); }
4504
 
    if ($record) {
4505
 
        my $city=$record->city;
4506
 
#       if ($PageBool) { $_city_p{$city}++; }
4507
 
        if ($city) {
4508
 
            my $countrycity=($record->country_code).'_'.$city;
4509
 
            $countrycity=~s/ /%20/g;
4510
 
            if ($record->region) { $countrycity.='_'.$record->region; }
4511
 
            $_city_h{lc($countrycity)}++;
4512
 
        } else {
4513
 
            $_city_h{'unknown'}++;
4514
 
        }
4515
 
#       if ($timerecord > $_city_l{$city}) { $_city_l{$city}=$timerecord; }
4516
 
    } else {
4517
 
        $_city_h{'unknown'}++;
4518
 
    }
 
4662
        if ($type eq 'geoippureperl') {
 
4663
                my @record = ();
 
4664
                @record=$geoip_city_maxmind->get_city_record($param) if $geoip_city_maxmind;
 
4665
                if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByName for $param: [@record]",5); }
 
4666
            if (@record) {
 
4667
                        my $city=$record[4];
 
4668
                        if ($city) {
 
4669
                    my $countrycity=$record[0].'_'.$city;
 
4670
                    $countrycity=~s/ /%20/g;
 
4671
                    if ($record[3]) { $countrycity.='_'.$record[3]; }
 
4672
                    $_city_h{lc($countrycity)}++;
 
4673
                } else {
 
4674
                    $_city_h{'unknown'}++;
 
4675
                }
 
4676
            } else {
 
4677
                $_city_h{'unknown'}++;
 
4678
            }
 
4679
        }
 
4680
        else
 
4681
        {
 
4682
                my $record=();
 
4683
                $record=$geoip_city_maxmind->record_by_addr($param) if $geoip_city_maxmind;
 
4684
                if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByIp for $param: [$record]",5); }
 
4685
            if ($record) {
 
4686
                my $city=$record->city;
 
4687
        #       if ($PageBool) { $_city_p{$city}++; }
 
4688
                if ($city) {
 
4689
                    my $countrycity=($record->country_code).'_'.$city;
 
4690
                    $countrycity=~s/ /%20/g;
 
4691
                    if ($record->region) { $countrycity.='_'.$record->region; }
 
4692
                    $_city_h{lc($countrycity)}++;
 
4693
                } else {
 
4694
                    $_city_h{'unknown'}++;
 
4695
                }
 
4696
        #       if ($timerecord > $_city_l{$city}) { $_city_l{$city}=$timerecord; }
 
4697
            } else {
 
4698
                $_city_h{'unknown'}++;
 
4699
            }
 
4700
        }
4519
4701
        # ----->
4520
4702
        return;
4521
4703
}
4528
4710
sub SectionProcessHostname_geoip_city_maxmind {
4529
4711
    my $param="$_[0]";      # Param must be an IP
4530
4712
        # <-----
4531
 
        my $record=();
4532
 
        $record=$geoip_city_maxmind->record_by_name($param) if $geoip_city_maxmind;
4533
 
        if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByName for $param: [$record]",5); }
4534
 
    if ($record) {
4535
 
        my $city=$record->city;
4536
 
#           if ($PageBool) { $_city_p{$city}++; }
4537
 
        if ($city) {
4538
 
            my $countrycity=($record->country_code).'_'.$city;
4539
 
            $countrycity=~s/ /%20/g;
4540
 
            if ($record->region) { $countrycity.='_'.$record->region; }
4541
 
            $_city_h{lc($countrycity)}++;
4542
 
        } else {
4543
 
            $_city_h{'unknown'}++;
4544
 
        }
4545
 
#           if ($timerecord > $_city_l{$city}) { $_city_l{$city}=$timerecord; }
4546
 
    } else {
4547
 
        $_city_h{'unknown'}++;
4548
 
    }
 
4713
        if ($type eq 'geoippureperl') {
 
4714
                my @record = ();
 
4715
                @record=$geoip_city_maxmind->get_city_record($param) if $geoip_city_maxmind;
 
4716
                if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByName for $param: [@record]",5); }
 
4717
            if (@record) {
 
4718
                        my $city=$record[4];
 
4719
                        if ($city) {
 
4720
                    my $countrycity=$record[0].'_'.$city;
 
4721
                    $countrycity=~s/ /%20/g;
 
4722
                    if ($record[3]) { $countrycity.='_'.$record[3]; }
 
4723
                    $_city_h{lc($countrycity)}++;
 
4724
                } else {
 
4725
                    $_city_h{'unknown'}++;
 
4726
                }
 
4727
            } else {
 
4728
                $_city_h{'unknown'}++;
 
4729
            }
 
4730
        }
 
4731
        else
 
4732
        {
 
4733
                my $record=();
 
4734
                $record=$geoip_city_maxmind->record_by_name($param) if $geoip_city_maxmind;
 
4735
                if ($Debug) { debug("  Plugin geoip_city_maxmind: GetCityByName for $param: [$record]",5); }
 
4736
            if ($record) {
 
4737
                my $city=$record->city;
 
4738
        #           if ($PageBool) { $_city_p{$city}++; }
 
4739
                if ($city) {
 
4740
                    my $countrycity=($record->country_code).'_'.$city;
 
4741
                    $countrycity=~s/ /%20/g;
 
4742
                    if ($record->region) { $countrycity.='_'.$record->region; }
 
4743
                    $_city_h{lc($countrycity)}++;
 
4744
                } else {
 
4745
                    $_city_h{'unknown'}++;
 
4746
                }
 
4747
        #           if ($timerecord > $_city_l{$city}) { $_city_l{$city}=$timerecord; }
 
4748
            } else {
 
4749
                $_city_h{'unknown'}++;
 
4750
            }
 
4751
        }
4549
4752
        # ----->
4550
4753
        return;
4551
4754
}