Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 269
- Log:
Overdue upgrade to AWStats v6.9, the most recent version
available at the time of writing.
- Author:
- rool
- Date:
- Wed May 27 23:57:15 +0100 2009
- Size:
- 3738 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/perl |
2 | #----------------------------------------------------------------------------- |
3 | # GeoIpFree AWStats plugin |
4 | # This plugin allow you to get AWStats country report with countries detected |
5 | # from a Geographical database (GeoIP internal database) instead of domain |
6 | # hostname suffix. |
7 | #----------------------------------------------------------------------------- |
8 | # Perl Required Modules: Geo::IPfree (version 0.2+) |
9 | #----------------------------------------------------------------------------- |
10 | # $Revision: 1.12 $ - $Author: eldy $ - $Date: 2008/11/15 16:03:42 $ |
11 | |
12 | |
13 | # <----- |
14 | # ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES |
15 | push @INC, "${DIR}/plugins"; |
16 | if (!eval ('require "Geo/IPfree.pm";')) { return $@?"Error: $@":"Error: Need Perl module Geo::IPfree"; } |
17 | # -----> |
18 | #use strict; |
19 | no strict "refs"; |
20 | |
21 | |
22 | |
23 | #----------------------------------------------------------------------------- |
24 | # PLUGIN VARIABLES |
25 | #----------------------------------------------------------------------------- |
26 | # <----- |
27 | # ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN |
28 | # AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE. |
29 | my $PluginNeedAWStatsVersion="5.5"; |
30 | my $PluginHooksFunctions="GetCountryCodeByAddr GetCountryCodeByName"; |
31 | # -----> |
32 | |
33 | # <----- |
34 | # IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE. |
35 | use vars qw/ |
36 | %TmpDomainLookup |
37 | $gi |
38 | /; |
39 | # -----> |
40 | |
41 | |
42 | |
43 | #----------------------------------------------------------------------------- |
44 | # PLUGIN FUNCTION: Init_pluginname |
45 | #----------------------------------------------------------------------------- |
46 | sub Init_geoipfree { |
47 | my $InitParams=shift; |
48 | my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion); |
49 | |
50 | # <----- |
51 | # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS |
52 | debug(" Plugin geoipfree: InitParams=$InitParams",1); |
53 | %TmpDomainLookup=(); |
54 | $gi = Geo::IPfree::new(); |
55 | # $gi->Faster; # Do not enable Faster as the Memoize module is rarely available |
56 | # -----> |
57 | |
58 | return ($checkversion?$checkversion:"$PluginHooksFunctions"); |
59 | } |
60 | |
61 | |
62 | #----------------------------------------------------------------------------- |
63 | # PLUGIN FUNCTION: GetCountryCodeByName_pluginname |
64 | # UNIQUE: YES (Only one plugin using this function can be loaded) |
65 | # GetCountryCodeByName is called to translate a host name into a country name. |
66 | #----------------------------------------------------------------------------- |
67 | sub GetCountryCodeByName_geoipfree { |
68 | my $param="$_[0]"; |
69 | # <----- |
70 | my $res=$TmpDomainLookup{$param}||''; |
71 | if (! $res) { |
72 | ($res,undef)=$gi->LookUp($param); |
73 | if ($res !~ /\w\w/) { $res='ip'; } |
74 | else { $res=lc($res); } |
75 | $TmpDomainLookup{$param}=$res; |
76 | if ($Debug) { debug(" Plugin geoipfree: GetCountryCodeByName for $param: $res",5); } |
77 | } |
78 | elsif ($Debug) { debug(" Plugin geoipfree: GetCountryCodeByName for $param: Already resolved to $res",5); } |
79 | # -----> |
80 | return $res; |
81 | } |
82 | |
83 | #----------------------------------------------------------------------------- |
84 | # PLUGIN FUNCTION: GetCountryCodeByAddr_pluginname |
85 | # UNIQUE: YES (Only one plugin using this function can be loaded) |
86 | # GetCountryCodeByAddr is called to translate an ip into a country name. |
87 | #----------------------------------------------------------------------------- |
88 | sub GetCountryCodeByAddr_geoipfree { |
89 | my $param="$_[0]"; |
90 | # <----- |
91 | my $res=$TmpDomainLookup{$param}||''; |
92 | if (! $res) { |
93 | ($res,undef)=$gi->LookUp($param); |
94 | if ($res !~ /\w\w/) { $res='ip'; } |
95 | else { $res=lc($res); } |
96 | $TmpDomainLookup{$param}=$res; |
97 | if ($Debug) { debug(" Plugin geoipfree: GetCountryCodeByAddr for $param: $res",5); } |
98 | } |
99 | elsif ($Debug) { debug(" Plugin geoipfree: GetCountryCodeByAddr for $param: Already resolved to $res",5); } |
100 | # -----> |
101 | return $res; |
102 | } |
103 | |
104 | 1; # Do not remove this line |
105 | |
106 | |
107 | # Internal IP address: |
108 | # 10.x.x.x |
109 | # 192.168.x.x |
110 |