EOF
return 1;
# ----->
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: ShowInfoHost_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
# Function called to add additionnal columns to the Hosts report.
# This function is called when building rows of the report (One call for each
# row). So it allows you to add a column in report, for example with code :
# print "This is a new cell for $param | ";
# Parameters: Host name or ip
#-----------------------------------------------------------------------------
sub ShowInfoHost_hostinfo {
my $param="$_[0]";
# <-----
if ($param eq '__title__') {
print "$Message[114] | ";
}
elsif ($param) {
my $keyforwhois;
if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
$keyforwhois=$param;
}
elsif ($param =~ /^[0-9A-F]*:/i) { # IPv6 address
$keyforwhois=$param;
}
else { # Hostname
$param =~ /([-\w]+\.[-\w]+\.(?:au|uk|jp|nz))$/ or $param =~ /([-\w]+\.[-\w]+)$/;
$keyforwhois=$1;
}
print "";
# if ($keyforwhois) { print "?"; }
if ($keyforwhois) { print "?"; }
else { print " " }
print " | ";
}
else {
print " | ";
}
return 1;
# ----->
}
#-----------------------------------------------------------------------------
# PLUGIN FUNTION: BuildFullHTMLOutput_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
# Function called to output an HTML page completely built by plugin instead
# of AWStats output
#-----------------------------------------------------------------------------
sub BuildFullHTMLOutput_hostinfo {
# <-----
my $Host='';
if ($QueryString =~ /host=([^&]+)/i) {
$Host=lc(&DecodeEncodedString("$1"));
}
my $ip='';
my $HostResolved='';
# my $regipv4=qr/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
# my $regipv6=qr/^[0-9A-F]*:/i;
# if ($Host =~ /$regipv4/o) { $ip=4; }
# elsif ($Host =~ /$regipv6/o) { $ip=6; }
# if ($ip == 4) {
# my $lookupresult=lc(gethostbyaddr(pack("C4",split(/\./,$Host)),AF_INET)); # This is very slow, may spend 20 seconds
# if (! $lookupresult || $lookupresult =~ /$regipv4/o || ! IsAscii($lookupresult)) {
# $HostResolved='*';
# }
# else {
# $HostResolved=$lookupresult;
# }
# if ($Debug) { debug(" Reverse DNS lookup for $Host done: $HostResolved",4); }
# }
if (! $ip) { $HostResolved=$Host; }
if ($Debug) { debug(" Plugin hostinfo: DirData=$DirData Host=$Host HostResolved=$HostResolved ",4); }
my $w = new Net::XWhois Verbose=>$Debug, Cache=>$DirData, NoCache=>0, Timeout=>10, Domain=>$HostResolved;
print "
\n";
if ($w && $w->response()) {
&tab_head("Common Whois Fields",0,0,'whois');
print "Common field info | Value |
\n";
print "Name | ".($w->name())." |
";
print "Status | ".($w->status())." |
";
print "NameServers | ".($w->nameservers())." |
";
print "Registrant | ".($w->registrant())." |
";
print "Contact Admin | ".($w->contact_admin())." |
";
print "Contact Tech | ".($w->contact_tech())." |
";
print "Contact Billing | ".($w->contact_billing())." |
";
print "Contact Zone | ".($w->contact_zone())." |
";
print "Contact Emails | ".($w->contact_emails())." |
";
print "Contact Handles | ".($w->contact_handles())." |
";
print "Domain Handles | ".($w->domain_handles())." |
";
&tab_end;
}
&tab_head("Full Whois Field",0,0,'whois');
if ($w && $w->response()) {
print "".($w->response())." |
\n";
}
else {
print " The Whois command failed. Did the server running AWStats is allowed to send WhoIs queries (If a firewall is running, port 43 should be opened from inside to outside) ?
|
\n";
}
&tab_end;
return 1;
# ----->
}
1; # Do not remove this line
awstats-7.2/wwwroot/cgi-bin/plugins/hashfiles.pm 0000600 0001750 0001750 00000012126 10322227006 017675 0 ustar sk sk #!/usr/bin/perl
#-----------------------------------------------------------------------------
# HashFiles AWStats plugin
# Allows AWStats to read/save its data file as native hash files.
# This increase read andwrite files operations.
#-----------------------------------------------------------------------------
# Perl Required Modules: Storable
#-----------------------------------------------------------------------------
# $Revision: 1.12 $ - $Author: eldy $ - $Date: 2005/10/09 14:49:42 $
# <-----
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
if (!eval ('require "Storable.pm";')) { return $@?"Error: $@":"Error: Need Perl module Storable"; }
# ----->
use strict;no strict "refs";
#-----------------------------------------------------------------------------
# PLUGIN VARIABLES
#-----------------------------------------------------------------------------
# <-----
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion="5.1";
my $PluginHooksFunctions="SearchFile LoadCache SaveHash";
# ----->
# <-----
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
use vars qw/
$PluginHashfilesUpToDate
/;
# ----->
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: Init_pluginname
#-----------------------------------------------------------------------------
sub Init_hashfiles {
my $InitParams=shift;
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
$PluginHashfilesUpToDate=1;
# ----->
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
return ($checkversion?$checkversion:"$PluginHooksFunctions");
}
#-----------------------------------------------------------------------------
# PLUGIN FUNTION: SearchFile_pluginname
# UNIQUE: YES (Only one plugin using this function can be loaded)
#-----------------------------------------------------------------------------
sub SearchFile_hashfiles {
my ($searchdir,$dnscachefile,$filesuffix,$dnscacheext,$filetoload)=@_; # Get params sent by ref
if (-f "${searchdir}$dnscachefile$filesuffix.hash") {
my ($tmp1a,$tmp2a,$tmp3a,$tmp4a,$tmp5a,$tmp6a,$tmp7a,$tmp8a,$tmp9a,$datesource,$tmp10a,$tmp11a,$tmp12a) = stat("${searchdir}$dnscachefile$filesuffix$dnscacheext");
my ($tmp1b,$tmp2b,$tmp3b,$tmp4b,$tmp5b,$tmp6b,$tmp7b,$tmp8b,$tmp9b,$datehash,$tmp10b,$tmp11b,$tmp12b) = stat("${searchdir}$dnscachefile$filesuffix.hash");
if ($datesource && $datehash < $datesource) {
$PluginHashfilesUpToDate=0;
debug(" Plugin hashfiles: Hash file not up to date. Will use source file $filetoload instead.");
}
else {
# There is no source file or there is and hash file is up to date. We can just load hash file
$filetoload="${searchdir}$dnscachefile$filesuffix.hash";
}
}
elsif ($filetoload) {
$PluginHashfilesUpToDate=0;
debug(" Plugin hashfiles: Hash file not found. Will use source file $filetoload instead.");
}
# Change calling params
$_[4]=$filetoload;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: LoadCache_pluginname
# UNIQUE: YES (Only one plugin using this function can be loaded)
#-----------------------------------------------------------------------------
sub LoadCache_hashfiles {
my ($filetoload,$hashtoload)=@_;
if ($filetoload =~ /\.hash$/) {
# There is no source file or there is and hash file is up to date. We can just load hash file
eval('%$hashtoload = %{ Storable::retrieve("$filetoload") };') || warning("Warning: Error while retrieving hashfile: $@");
}
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SaveHash_pluginname
# UNIQUE: YES (Only one plugin using this function can be loaded)
#-----------------------------------------------------------------------------
sub SaveHash_hashfiles {
my ($filetosave,$hashtosave,$testifuptodate,$nbmaxofelemtosave,$nbofelemsaved)=@_;
if (! $testifuptodate || ! $PluginHashfilesUpToDate) {
$filetosave =~ s/(\.\w+)$//; $filetosave.=".hash";
debug(" Plugin hashfiles: Save data ".($nbmaxofelemtosave?"($nbmaxofelemtosave records max)":"(all records)")." into hash file $filetosave");
if (! $nbmaxofelemtosave || (scalar keys %$hashtosave <= $nbmaxofelemtosave)) {
# Save all hash array
unless ( eval('Storable::store(\%$hashtosave, "$filetosave");') ) {
$_[4] = 0;
warning("Warning: Error while storing hashfile: $@");
return;
}
$_[4]=scalar keys %$hashtosave;
}
else {
debug(" Plugin hashfiles: We need to resize hash to save from ".(scalar keys %$hashtosave)." to $nbmaxofelemtosave");
# Save part of hash array
my $counter=0;
my %newhashtosave=();
foreach my $key (keys %$hashtosave) {
$newhashtosave{$key}=$hashtosave->{$key};
if (++$counter >= $nbmaxofelemtosave) { last; }
}
unless ( eval('Storable::store(\%newhashtosave, "$filetosave");') ) {
$_[4] = 0;
warning("Warning: Error while storing hashfile: $@");
return;
}
$_[4]=scalar keys %newhashtosave;
}
$_[0]=$filetosave;
}
else {
$_[4]=0;
}
}
1; # Do not remove this line
awstats-7.2/wwwroot/cgi-bin/plugins/rawlog.pm 0000600 0001750 0001750 00000011123 11107571336 017230 0 ustar sk sk #!/usr/bin/perl
#-----------------------------------------------------------------------------
# Rawlog AWStats plugin
# This plugin adds a form in AWStats main page to allow users to see raw
# content of current log files. A filter is also available.
#-----------------------------------------------------------------------------
# Perl Required Modules: None
#-----------------------------------------------------------------------------
# $Revision: 1.17 $ - $Author: eldy $ - $Date: 2008/11/15 16:03:42 $
# <-----
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES.
# ----->
#use strict;
no strict "refs";
#-----------------------------------------------------------------------------
# PLUGIN VARIABLES
#-----------------------------------------------------------------------------
# <-----
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion="5.7";
my $PluginHooksFunctions="AddHTMLBodyHeader BuildFullHTMLOutput";
# ----->
# <-----
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
use vars qw/
$MAXLINE
/;
# ----->
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: Init_pluginname
#-----------------------------------------------------------------------------
sub Init_rawlog {
my $InitParams=shift;
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
debug(" Plugin rawlog: InitParams=$InitParams",1);
if ($QueryString =~ /rawlog_maxlines=(\d+)/i) { $MAXLINE=&DecodeEncodedString("$1"); }
else { $MAXLINE=5000; }
# ----->
return ($checkversion?$checkversion:"$PluginHooksFunctions");
}
#-----------------------------------------------------------------------------
# PLUGIN FUNTION: AddHTMLBodyHeader_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
# Function called to Add HTML code at beginning of BODY section.
#-----------------------------------------------------------------------------
sub AddHTMLBodyHeader_rawlog {
# <-----
# Show form only if option -staticlinks not used
if (! $StaticLinks) { &_ShowForm(''); }
return 1;
# ----->
}
#-----------------------------------------------------------------------------
# PLUGIN FUNTION: BuildFullHTMLOutput_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
# Function called to output an HTML page completely built by plugin instead
# of AWStats output
#-----------------------------------------------------------------------------
sub BuildFullHTMLOutput_rawlog {
# <-----
my $Filter='';
if ($QueryString =~ /filterrawlog=([^&]+)/i) { $Filter=&DecodeEncodedString("$1"); }
# A security check
if ($QueryString =~ /logfile=/i) {
print "
Option logfile is not allowed while building rawlog output.
";
return 0;
}
# Show form
&_ShowForm($Filter);
# Precompiled regex Filter to speed up scan
if ($Filter) { $Filter=qr/$Filter/i; }
print "
\n";
# Show raws
my $xml=($BuildReportFormat eq 'xhtml');
open(LOG,"$LogFile") || error("Couldn't open server log file \"$LogFile\" : $!");
binmode LOG; # Avoid premature EOF due to log files corrupted with \cZ or bin chars
my $i=0;
print "";
while () {
chomp $_; $_ =~ s/\r//;
if ($Filter && $_ !~ /$Filter/o) { next; }
print ($xml?XMLEncode("$_"):"$_");
print "\n";
if (++$i >= $MAXLINE) { last; }
}
print "
\n$i lines.
";
return 1;
# ----->
}
sub _ShowForm {
my $Filter=shift||'';
print "
\n";
print "\n";
}
1; # Do not remove this line
awstats-7.2/wwwroot/cgi-bin/plugins/geoip_org_maxmind.pm 0000600 0001750 0001750 00000046235 12037051034 021427 0 ustar sk sk #!/usr/bin/perl
#-----------------------------------------------------------------------------
# GeoIp_Org_Maxmind AWStats plugin
# This plugin allow you to add a city report.
# Need the licensed ISP database from Maxmind.
#-----------------------------------------------------------------------------
# Perl Required Modules: Geo::IP or Geo::IP::PurePerl
#-----------------------------------------------------------------------------
# $Revision: 1.19 $ - $Author: eldy $ - $Date: 2012/10/15 18:12:44 $
# <-----
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
use vars qw/ $type /;
$type='geoip';
if (!eval ('require "Geo/IP.pm";')) {
$error1=$@;
$type='geoippureperl';
if (!eval ('require "Geo/IP/PurePerl.pm";')) {
$error2=$@;
$ret=($error1||$error2)?"Error:\n$error1$error2":"";
$ret.="Error: Need Perl module Geo::IP or Geo::IP::PurePerl";
return $ret;
}
}
# ----->
#use strict;
no strict "refs";
#-----------------------------------------------------------------------------
# PLUGIN VARIABLES
#-----------------------------------------------------------------------------
# <-----
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion="6.2";
my $PluginHooksFunctions="AddHTMLMenuLink AddHTMLGraph ShowInfoHost SectionInitHashArray SectionProcessIp SectionProcessHostname SectionReadHistory SectionWriteHistory";
my $PluginName="geoip_org_maxmind";
my $LoadedOverride=0;
my $OverrideFile="";
my %TmpDomainLookup;
# ----->
# <-----
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
use vars qw/
$geoip_org_maxmind
%_org_p
%_org_h
%_org_k
%_org_l
$MAXNBOFSECTIONGIR
$MAXLENGTH
/;
# ----->
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: Init_pluginname
#-----------------------------------------------------------------------------
sub Init_geoip_org_maxmind {
my $InitParams=shift;
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
$MAXNBOFSECTIONGIR=10;
$MAXLENGTH=50;
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
debug(" Plugin $PluginName: InitParams=$InitParams",1);
my ($mode,$tmpdatafile)=split(/\s+/,$InitParams,2);
my ($datafile,$override)=split(/\+/,$tmpdatafile,2);
if (! $datafile) { $datafile="GeoIPOrg.dat"; }
else { $datafile =~ s/%20/ /g; }
if ($type eq 'geoippureperl') {
# With pureperl with always use GEOIP_STANDARD.
# GEOIP_MEMORY_CACHE seems to fail with ActiveState
if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE') { $mode=Geo::IP::PurePerl::GEOIP_STANDARD(); }
else { $mode=Geo::IP::PurePerl::GEOIP_STANDARD(); }
} else {
if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE') { $mode=Geo::IP::GEOIP_MEMORY_CACHE(); }
else { $mode=Geo::IP::GEOIP_STANDARD(); }
}
if ($override){ $override =~ s/%20/ /g; $OverrideFile=$override; }
%TmpDomainLookup=();
debug(" Plugin $PluginName: GeoIP initialized type=$type mode=$mode",1);
if ($type eq 'geoippureperl') {
$geoip_org_maxmind = Geo::IP::PurePerl->open($datafile, $mode);
} else {
$geoip_org_maxmind = Geo::IP->open($datafile, $mode);
}
$LoadedOverride=0;
# Fails on some GeoIP version
# debug(" Plugin geoip_org_maxmind: GeoIP initialized database_info=".$geoip_org_maxmind->database_info());
# ----->
return ($checkversion?$checkversion:"$PluginHooksFunctions");
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: AddHTMLMenuLink_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub AddHTMLMenuLink_geoip_org_maxmind {
my $categ=$_[0];
my $menu=$_[1];
my $menulink=$_[2];
my $menutext=$_[3];
# <-----
if ($Debug) { debug(" Plugin $PluginName: AddHTMLMenuLink"); }
if ($categ eq 'who') {
$menu->{"plugin_$PluginName"}=0.5; # Pos
$menulink->{"plugin_$PluginName"}=2; # Type of link
$menutext->{"plugin_$PluginName"}="Organizations"; # Text
}
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: AddHTMLGraph_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub AddHTMLGraph_geoip_org_maxmind {
my $categ=$_[0];
my $menu=$_[1];
my $menulink=$_[2];
my $menutext=$_[3];
# <-----
my $ShowISP='H';
$MinHit{'Org'}=1;
my $total_p; my $total_h; my $total_k;
my $rest_p; my $rest_h; my $rest_k;
if ($Debug) { debug(" Plugin $PluginName: AddHTMLGraph $categ $menu $menulink $menutext"); }
my $title='Organizations';
&tab_head("$title",19,0,'org');
print "Organizations : ".((scalar keys %_org_h)-($_org_h{'unknown'}?1:0))." | ";
if ($ShowISP =~ /P/i) { print "$Message[56] | "; }
if ($ShowISP =~ /P/i) { print "$Message[15] | "; }
if ($ShowISP =~ /H/i) { print "$Message[57] | "; }
if ($ShowISP =~ /H/i) { print "$Message[15] | "; }
if ($ShowISP =~ /B/i) { print "$Message[75] | "; }
if ($ShowISP =~ /L/i) { print "$Message[9] | "; }
print "
\n";
$total_p=$total_h=$total_k=0;
my $count=0;
&BuildKeyList($MaxRowsInHTMLOutput,$MinHit{'Org'},\%_org_h,\%_org_h);
foreach my $key (@keylist) {
if ($key eq 'unknown') { next; }
my $p_p; my $p_h;
if ($TotalPages) { $p_p=int($_org_p{$key}/$TotalPages*1000)/10; }
if ($TotalHits) { $p_h=int($_org_h{$key}/$TotalHits*1000)/10; }
print "";
my $org=$key; $org =~ s/_/ /g;
print "".ucfirst($org)." | ";
if ($ShowISP =~ /P/i) { print "".($_org_p{$key}?Format_Number($_org_p{$key}):" ")." | "; }
if ($ShowISP =~ /P/i) { print "".($_org_p{$key}?"$p_p %":' ')." | "; }
if ($ShowISP =~ /H/i) { print "".($_org_h{$key}?Format_Number($_org_h{$key}):" ")." | "; }
if ($ShowISP =~ /H/i) { print "".($_org_h{$key}?"$p_h %":' ')." | "; }
if ($ShowISP =~ /B/i) { print "".Format_Bytes($_org_k{$key})." | "; }
if ($ShowISP =~ /L/i) { print "".($_org_p{$key}?Format_Date($_org_l{$key},1):'-')." | "; }
print "
\n";
$total_p += $_org_p{$key}||0;
$total_h += $_org_h{$key};
$total_k += $_org_k{$key}||0;
$count++;
}
if ($Debug) { debug("Total real / shown : $TotalPages / $total_p - $TotalHits / $total_h - $TotalBytes / $total_h",2); }
$rest_p=0;
$rest_h=$TotalHits-$total_h;
$rest_k=0;
if ($rest_p > 0 || $rest_h > 0 || $rest_k > 0) { # All other cities
# print "";
# print " | ";
# if ($ShowISP =~ /P/i) { print " | "; }
# if ($ShowISP =~ /P/i) { print " | "; }
# if ($ShowISP =~ /H/i) { print " | "; }
# if ($ShowISP =~ /H/i) { print " | "; }
# if ($ShowISP =~ /B/i) { print " | "; }
# if ($ShowISP =~ /L/i) { print " | "; }
# print "
\n";
my $p_p; my $p_h;
if ($TotalPages) { $p_p=int($rest_p/$TotalPages*1000)/10; }
if ($TotalHits) { $p_h=int($rest_h/$TotalHits*1000)/10; }
print "";
print "$Message[2]/$Message[0] | ";
if ($ShowISP =~ /P/i) { print "".($rest_p?Format_Number($rest_p):" ")." | "; }
if ($ShowISP =~ /P/i) { print "".($rest_p?"$p_p %":' ')." | "; }
if ($ShowISP =~ /H/i) { print "".($rest_h?Format_Number($rest_h):" ")." | "; }
if ($ShowISP =~ /H/i) { print "".($rest_h?"$p_h %":' ')." | "; }
if ($ShowISP =~ /B/i) { print "".Format_Bytes($rest_k)." | "; }
if ($ShowISP =~ /L/i) { print " | "; }
print "
\n";
}
&tab_end();
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: ShowInfoHost_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
# Function called to add additionnal columns to the Hosts report.
# This function is called when building rows of the report (One call for each
# row). So it allows you to add a column in report, for example with code :
# print "This is a new cell for $param | ";
# Parameters: Host name or ip
#-----------------------------------------------------------------------------
sub ShowInfoHost_geoip_org_maxmind {
my $param="$_[0]";
# <-----
if ($param eq '__title__') {
my $NewLinkParams=${QueryString};
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)output(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
my $NewLinkTarget='';
if ($DetailedReportsOnNewWindows) { $NewLinkTarget=" target=\"awstatsbis\""; }
if (($FrameName eq 'mainleft' || $FrameName eq 'mainright') && $DetailedReportsOnNewWindows < 2) {
$NewLinkParams.="&framename=mainright";
$NewLinkTarget=" target=\"mainright\"";
}
$NewLinkParams =~ s/(&|&)+/&/i;
$NewLinkParams =~ s/^&//; $NewLinkParams =~ s/&$//;
if ($NewLinkParams) { $NewLinkParams="${NewLinkParams}&"; }
print "";
print "GeoIP Org";
print " | ";
}
elsif ($param) {
my $ip=0;
my $key;
if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
$ip=4;
$key=$param;
}
elsif ($param =~ /^[0-9A-F]*:/i) { # IPv6 address
$ip=6;
$key=$param;
}
print "";
if ($key && $ip==4) {
my $org = TmpLookup_geoip_org_maxmind($param);
if (!$org && $type eq 'geoippureperl')
{
# Function org_by_addr does not exists in PurePerl but org_by_name do same
$org=$geoip_org_maxmind->org_by_name($param) if $geoip_org_maxmind;
}
elsif(!$org)
{
$org=$geoip_org_maxmind->org_by_addr($param) if $geoip_org_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetOrgByIp for $param: [$org]",5); }
if ($org) {
if (length($org) <= $MAXLENGTH) {
print "$org";
}
else {
print substr($org,0,$MAXLENGTH).'...';
}
}
else { print "$Message[0]"; }
}
if ($key && $ip==6) {
print "$Message[0]";
}
if (! $key) {
my $org = TmpLookup_geoip_org_maxmind($param);
if (!$org && $type eq 'geoippureperl')
{
$org=$geoip_org_maxmind->org_by_name($param) if $geoip_org_maxmind;
}
elsif(!$org)
{
$org=$geoip_org_maxmind->org_by_name($param) if $geoip_org_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetOrgByHostname for $param: [$org]",5); }
if ($org) {
if (length($org) <= $MAXLENGTH) {
print "$org";
}
else {
print substr($org,0,$MAXLENGTH).'...';
}
}
else { print "$Message[0]"; }
}
print " | ";
}
else {
print " | ";
}
return 1;
# ----->
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionInitHashArray_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionInitHashArray_geoip_org_maxmind {
# my $param="$_[0]";
# <-----
if ($Debug) { debug(" Plugin $PluginName: Init_HashArray"); }
%_org_p = %_org_h = %_org_k = %_org_l =();
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionProcessIP_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionProcessIp_geoip_org_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
my $org = TmpLookup_geoip_org_maxmind($param);
if (!$org && $type eq 'geoippureperl')
{
# Function org_by_addr does not exists in PurePerl but org_by_name do same
$org=$geoip_org_maxmind->org_by_name($param) if $geoip_org_maxmind;
}
elsif(!$org)
{
$org=$geoip_org_maxmind->org_by_addr($param) if $geoip_org_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetOrgByIp for $param: [$org]",5); }
if ($org) {
$org =~ s/\s/_/g;
$_org_h{$org}++;
} else {
$_org_h{'unknown'}++;
}
# if ($timerecord > $_org_l{$city}) { $_org_l{$city}=$timerecord; }
# ----->
return;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionProcessHostname_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionProcessHostname_geoip_org_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
my $org = TmpLookup_geoip_org_maxmind($param);
if (!$org && $type eq 'geoippureperl')
{
$org=$geoip_org_maxmind->org_by_name($param) if $geoip_org_maxmind;
}
elsif(!$org)
{
$org=$geoip_org_maxmind->org_by_name($param) if $geoip_org_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetOrgByHostname for $param: [$org]",5); }
if ($org) {
$org =~ s/\s/_/g;
$_org_h{$org}++;
} else {
$_org_h{'unknown'}++;
}
# if ($timerecord > $_org_l{$city}) { $_org_l{$city}=$timerecord; }
# ----->
return;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionReadHistory_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionReadHistory_geoip_org_maxmind {
my $issectiontoload=shift;
my $xmlold=shift;
my $xmleb=shift;
my $countlines=shift;
# <-----
if ($Debug) { debug(" Plugin $PluginName: Begin of PLUGIN_$PluginName section"); }
my @field=();
my $count=0;my $countloaded=0;
do {
if ($field[0]) {
$count++;
if ($issectiontoload) {
$countloaded++;
if ($field[2]) { $_org_h{$field[0]}+=$field[2]; }
}
}
$_=;
chomp $_; s/\r//;
@field=split(/\s+/,($xmlold?XMLDecodeFromHisto($_):$_));
$countlines++;
}
until ($field[0] eq "END_PLUGIN_$PluginName" || $field[0] eq "${xmleb}END_PLUGIN_$PluginName" || ! $_);
if ($field[0] ne "END_PLUGIN_$PluginName" && $field[0] ne "${xmleb}END_PLUGIN_$PluginName") { error("History file is corrupted (End of section PLUGIN not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).","","",1); }
if ($Debug) { debug(" Plugin $PluginName: End of PLUGIN_$PluginName section ($count entries, $countloaded loaded)"); }
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionWriteHistory_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionWriteHistory_geoip_org_maxmind {
my ($xml,$xmlbb,$xmlbs,$xmlbe,$xmlrb,$xmlrs,$xmlre,$xmleb,$xmlee)=(shift,shift,shift,shift,shift,shift,shift,shift,shift);
if ($Debug) { debug(" Plugin $PluginName: SectionWriteHistory_$PluginName start - ".(scalar keys %_org_h)); }
# <-----
print HISTORYTMP "\n";
if ($xml) { print HISTORYTMP "$MAXNBOFSECTIONGIR\n"; }
print HISTORYTMP "# Plugin key - Pages - Hits - Bandwidth - Last access\n";
#print HISTORYTMP "# The $MaxNbOfExtra[$extranum] first number of hits are first\n";
$ValueInFile{'plugin_geoip_org_maxmind'}=tell HISTORYTMP;
print HISTORYTMP "${xmlbb}BEGIN_PLUGIN_$PluginName${xmlbs}".(scalar keys %_org_h)."${xmlbe}\n";
&BuildKeyList($MAXNBOFSECTIONGIR,1,\%_org_h,\%_org_h);
my %keysinkeylist=();
foreach (@keylist) {
$keysinkeylist{$_}=1;
#my $page=$_org_p{$_}||0;
#my $bytes=$_org_k{$_}||0;
#my $lastaccess=$_org_l{$_}||'';
print HISTORYTMP "${xmlrb}$_${xmlrs}0${xmlrs}", $_org_h{$_}, "${xmlrs}0${xmlrs}0${xmlre}\n"; next;
}
foreach (keys %_org_h) {
if ($keysinkeylist{$_}) { next; }
#my $page=$_org_p{$_}||0;
#my $bytes=$_org_k{$_}||0;
#my $lastaccess=$_org_l{$_}||'';
print HISTORYTMP "${xmlrb}$_${xmlrs}0${xmlrs}", $_org_h{$_}, "${xmlrs}0${xmlrs}0${xmlre}\n"; next;
}
print HISTORYTMP "${xmleb}END_PLUGIN_$PluginName${xmlee}\n";
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: LoadOverrideFile
# Attempts to load a comma delimited file that will override the GeoIP database
# Useful for Intranet records
# CSV format: IP,"organization"
#-----------------------------------------------------------------------------
sub LoadOverrideFile_geoip_org_maxmind{
my $filetoload="";
if ($OverrideFile){
if (!open(GEOIPFILE, $OverrideFile)){
debug("Plugin $PluginName: Unable to open override file: $OverrideFile");
$LoadedOverride = 1;
return;
}
}else{
my $conf = (exists(&Get_Config_Name) ? Get_Config_Name() : $SiteConfig);
if ($conf && open(GEOIPFILE,"$DirData/$PluginName.$conf.txt")) { $filetoload="$DirData/$PluginName.$conf.txt"; }
elsif (open(GEOIPFILE,"$DirData/$PluginName.txt")) { $filetoload="$DirData/$PluginName.txt"; }
else { debug("No override file \"$DirData/$PluginName.txt\": $!"); }
}
if ($filetoload)
{
# This is the fastest way to load with regexp that I know
while (){
chomp $_;
s/\r//;
my @record = split(",", $_);
# replace quotes if they were used in the file
foreach (@record){ $_ =~ s/"//g; }
# store in hash
$TmpDomainLookup{$record[0]} = $record[1];
}
close GEOIPFILE;
debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
}
$LoadedOverride = 1;
return;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: TmpLookup
# Searches the temporary hash for the parameter value and returns the corresponding
# GEOIP entry
#-----------------------------------------------------------------------------
sub TmpLookup_geoip_org_maxmind(){
$param = shift;
if (!$LoadedOverride){&LoadOverrideFile_geoip_org_maxmind();}
#my $val;
#if ($geoip_org_maxmind &&
#(($type eq 'geoip' && $geoip_org_maxmind->VERSION >= 1.30) ||
# $type eq 'geoippureperl' && $geoip_org_maxmind->VERSION >= 1.17)){
# $val = $TmpDomainLookup{$geoip_org_maxmind->get_ip_address($param)};
#}
#else {$val = $TmpDomainLookup{$param};}
#return $val || '';
return $TmpDomainLookup{$param}||'';
}
1; # Do not remove this line
awstats-7.2/wwwroot/cgi-bin/plugins/timezone.pm 0000600 0001750 0001750 00000016125 11316507572 017601 0 ustar sk sk #!/usr/bin/perl
#-----------------------------------------------------------------------------
# TimeZone AWStats reloaded plugin
#
# Allow AWStats to convert GMT time stamps to local time zone
# taking into account daylight saving time.
# If the POSIX module is available, a target time zone name
# can be provided, otherwise the default system local time is used.
# For compatibility with the original version of this plugin, "-/+hours"
# is interpreted as a fixed difference to GMT.
#
# 2009 jacob@internet24.de
#-----------------------------------------------------------------------------
# Perl Required Modules: POSIX
#-----------------------------------------------------------------------------
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !!!!! This plugin reduces AWStats speed by about 10% !!!!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# <-----
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
# ----->
use strict;no strict "refs";
#-----------------------------------------------------------------------------
# PLUGIN VARIABLES
#-----------------------------------------------------------------------------
# <-----
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion="5.1";
my $PluginHooksFunctions="ChangeTime GetTimeZoneTitle";
# ----->
# <-----
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
use vars qw/
$PluginTimeZoneZone
$PluginTimeZoneCache
/;
# ----->
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: Init_pluginname
#-----------------------------------------------------------------------------
sub Init_timezone {
my $InitParams=shift;
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
if ($InitParams)
{
if (!eval ('require "POSIX.pm"'))
{
return $@?"Error: $@":"Error: Need Perl module POSIX";
}
}
$PluginTimeZoneZone = "$InitParams";
$PluginTimeZoneCache = {};
# ----->
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
return ($checkversion?$checkversion:"$PluginHooksFunctions");
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: ChangeTime_pluginname
# UNIQUE: YES (Only one plugin using this function can be loaded)
#-----------------------------------------------------------------------------
sub ChangeTime_timezone {
my @d = @{$_[0]};
my $e = $PluginTimeZoneCache->{$d[2]};
my ($i);
unless ($e) {
$e = $PluginTimeZoneCache->{$d[2]} = [
tz_find_zone_diff($PluginTimeZoneZone, $d[2]),
tz_find_month_length($PluginTimeZoneZone, $d[2])
]
}
INTERVAL: foreach $i (@{@$e[0]}) {
foreach (1,0,3,4,5) {
next INTERVAL if $d[$_]>@$i[$_];
last if $d[$_]<@$i[$_];
}
$d[5] += @$i[8];
if ( $d[5]<0 ) {
$d[5] += 60, $d[4]--;
} elsif ( $d[5]>59 ) {
$d[5] -= 60, $d[4]++;
}
$d[4] += @$i[7];
if ( $d[4]<0 ) {
$d[4] += 60, $d[3]--;
} elsif ( $d[4]>59 ) {
$d[4] -= 60, $d[3]++;
}
$d[3] += @$i[6];
if ( $d[3]<0 ) {
$d[3] += 24, $d[0]--;
} elsif ( $d[3]>23 ) {
$d[3] -= 24, $d[0]++;
} else {
return @d;
}
if ($d[0]<1) {
$d[1]--;
if ( $d[1]<1 ) {
$d[2]--, $d[1] = 12, $d[0] = 31;
} else {
$d[0] = $e->[1][$d[1]];
}
} elsif ($d[0]>$e->[1][$d[1]]) {
$d[1]++, $d[0]=1;
if ( $d[1]>12 ) {
$d[2]++, $d[1] = 1;
}
}
return @d;
}
# This should never be reached
return @d;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: GetTimeZoneTitle_pluginname
# UNIQUE: YES (Only one plugin using this function can be loaded)
#-----------------------------------------------------------------------------
sub GetTimeZoneTitle_timezone {
return $PluginTimeZoneZone;
}
#-----------------------------------------------------------------------------
# Tools
#-----------------------------------------------------------------------------
# convenience wrappers
sub tz_mktime
{
return timegm($_[0], $_[1], $_[2],
$_[3], $_[4]-1, $_[5]-1900, 0, 0, -1);
}
sub tz_interval
{
my ($time, $shift) = @_;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
gmtime($time);
return [
$mday,
$mon+1,
2147483647, # max(int32)
$hour,
$min,
$sec,
int($shift/3600),
int(($shift%3600)/60),
int(($shift%60)),
]
}
# return largest $value between $left and $right
# whose tz_shift is equal to that of $left
sub tz_find_break
{
my ($left, $right) = @_;
return undef if $left>$right;
return $left if ($right-$left)<=1;
my $middle = int(($right+$left)/2);
my ($leftshift, $rightshift, $middleshift) =
(tz_shift($left), tz_shift($right), tz_shift($middle));
if ($leftshift == $middleshift) {
return undef if $rightshift == $middleshift;
return tz_find_break($middle, $right);
}
elsif ($rightshift == $middleshift) {
return tz_find_break($left, $middle);
}
}
# compute difference beetween localtime and gmtime in seconds
# for unix time stamp $time
sub tz_shift
{
my ($time) = @_;
my ($lsec,$lmin,$lhour,$lmday,$lmon,$lyear,$lwday,$lyday,$lisdst) =
localtime($time);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
gmtime($time);
my $day_change = $lyear-$year;
$day_change = $lmon-$mon unless $day_change;
$day_change = $lmday-$mday unless $day_change;
my $hour_diff = $lhour-$hour;
my $min_diff = $lmin-$min;
my $sec_diff = $lsec-$sec;
if ($day_change>0) {
$hour_diff +=24;
}
elsif($day_change<0) {
$hour_diff -=24;
}
return (($hour_diff*60)+$min_diff)*60+$sec_diff;
}
# Compute time zone shift intervals for $year
# and time zone $zone
sub tz_find_zone_diff
{
my ($zone, $year) = @_;
my $othertz = $PluginTimeZoneZone &&
$PluginTimeZoneZone !~ m/^[+-]?\d+$/;
my ($left, $middle, $right);
my ($leftshift, $middleshift, $rightshift);
{
local $ENV{TZ} = $zone
if $othertz;
$left = tz_mktime(0,0,0,1,1,$year);
$middle = tz_mktime(0,0,0,1,7,$year);
$right = tz_mktime(59,59,23,31,12,$year);
if (!$PluginTimeZoneZone || $PluginTimeZoneZone !~ m/^[+-]?\d+$/)
{
$leftshift = tz_shift($left);
$middleshift = tz_shift($middle);
$rightshift = tz_shift($right)
}
else
{
$leftshift = $middleshift = $rightshift =
int($PluginTimeZoneZone)*3600;
}
if ($leftshift != $rightshift || $rightshift != $middleshift) {
return
[
tz_interval(tz_find_break($left, $middle), $leftshift),
tz_interval(tz_find_break($middle, $right), $middleshift),
tz_interval($right, $rightshift)
]
}
POSIX::tzset() if $othertz;
}
POSIX::tzset() if $othertz;
return [ tz_interval($right, $rightshift) ]
}
# Compute number of days in all months for $year
sub tz_find_month_length
{
my ($zone, $year) = @_;
my $othertz = $PluginTimeZoneZone &&
$PluginTimeZoneZone !~ m/^[+-]?\d+$/;
my $months = [ undef, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31 ];
{
local $ENV{TZ} = $zone
if $othertz;
# leap year?
$months->[2] = 29 if
(localtime(tz_mktime(0, 0, 12, 28, 2, $year)+86400))[4]
== 1;
POSIX::tzset() if $othertz;
}
POSIX::tzset() if $othertz;
return $months;
}
1; # Do not remove this line
awstats-7.2/wwwroot/cgi-bin/plugins/ipv6.pm 0000600 0001750 0001750 00000004607 10053471024 016622 0 ustar sk sk #!/usr/bin/perl
#-----------------------------------------------------------------------------
# IPv6 AWStats plugin
# This plugin allow AWStats to make reverse DNS Lookup on IPv6 addresses.
#-----------------------------------------------------------------------------
# Perl Required Modules: Net::IP and Net::DNS
#-----------------------------------------------------------------------------
# $Revision: 1.4 $ - $Author: eldy $ - $Date: 2004/05/21 21:18:11 $
# <-----
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
if (!eval ('require "Net/IP.pm";')) { return $@?"Error: $@":"Error: Need Perl module Net::IP"; }
if (!eval ('require "Net/DNS.pm";')) { return $@?"Error: $@":"Error: Need Perl module Net::DNS"; }
# ----->
use strict;no strict "refs";
#-----------------------------------------------------------------------------
# PLUGIN VARIABLES
#-----------------------------------------------------------------------------
# <-----
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion="5.5";
my $PluginHooksFunctions="GetResolvedIP";
# ----->
# <-----
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
use vars qw/
$resolver
/;
# ----->
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: Init_pluginname
#-----------------------------------------------------------------------------
sub Init_ipv6 {
my $InitParams=shift;
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
debug(" Plugin ipv6: InitParams=$InitParams",1);
$resolver = Net::DNS::Resolver->new;
# ----->
return ($checkversion?$checkversion:"$PluginHooksFunctions");
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: GetResolvedIP_pluginname
# UNIQUE: YES (Only one plugin using this function can be loaded)
# GetResolvedIP is called to resolve an IPv6 address into a host name
#-----------------------------------------------------------------------------
sub GetResolvedIP_ipv6 {
# <-----
my $ip = new Net::IP($_[0]);
my $reverseip= $ip->reverse_ip();
my $query = $resolver->query($reverseip, "PTR");
if (! defined($query)) { return; }
my @result=split(/\s/, ($query->answer)[0]->string);
return $result[4];
# ----->
}
1; # Do not remove this line
awstats-7.2/wwwroot/cgi-bin/plugins/graphgooglechartapi.pm 0000600 0001750 0001750 00000045616 11514200772 021760 0 ustar sk sk #!/usr/bin/perl
#-----------------------------------------------------------------------------
# GraphGoogleChartApi AWStats plugin
# Allow AWStats to replace bar graphs with a Google Graph image
#-----------------------------------------------------------------------------
# Perl Required Modules: None
#-----------------------------------------------------------------------------
# $Revision: 1.6 $ - $Author: eldy $ - $Date: 2011/01/14 11:05:31 $
#
# Changelog
#
# 1.0 - Initial release by george@dynapres.nl
# 1.1 - Changed scaling: making it independent of chart series
# 1.2 - Added pie charts, visualization hook, map and axis labels by Chris Larsen
# <-----
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
# ----->
#use strict;
no strict "refs";
#-----------------------------------------------------------------------------
# PLUGIN VARIABLES
#-----------------------------------------------------------------------------
# <-----
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion = "7.0";
my $PluginHooksFunctions = "Init ShowGraph AddHTMLHeader";
my $PluginName = "graphgooglechartapi";
my $ChartProtocol = "http://";
my $ChartURI = "chart.apis.google.com/chart?"; # Don't put the HTTP part here!
my $ChartIndex = 0;
my $title;
my $type;
my $imagewidth = 640; # maximum image width.
my $imageratio = .25; # Height is defaulted to 25% of width
my $pieratio = .20; # Height for pie charts should be different
my $mapratio = .62; # Height for maps is different
my $labellength;
my @blocklabel = ();
my @vallabel = ();
my @valcolor = ();
my @valmax = ();
my @valtotal = ();
my @valaverage = ();
my @valdata = ();
# ----->
# <-----
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
use vars qw/
$DirClasses
$URLIndex
/;
# ----->
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: Init_pluginname
#-----------------------------------------------------------------------------
sub Init_graphgooglechartapi {
my $InitParams = shift;
my $checkversion = &Check_Plugin_Version($PluginNeedAWStatsVersion);
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
$DirClasses = $InitParams;
# ----->
$title = "";
$type = "";
$labellength=2;
$ChartIndex = -1;
return ($checkversion?$checkversion:"$PluginHooksFunctions");
}
#-------------------------------------------------------
# PLUGIN FUNCTION: ShowGraph_pluginname
# UNIQUE: YES (Only one plugin using this function can be loaded)
# Prints the proper chart depending on the $type provided
# Parameters: $title $type $imagewidth \@blocklabel,\@vallabel,\@valcolor,\@valmax,\@valtotal
# Input: None
# Output: HTML code for awgraphapplet insertion
# Return: 0 OK, 1 Error
#-------------------------------------------------------
sub ShowGraph_graphgooglechartapi() {
$title = shift;
$type = shift;
$imagewidth = shift || 640;
$blocklabel = shift;
$vallabel = shift;
$valcolor = shift;
$valmax = shift;
$valtotal = shift;
$valaverage = shift;
$valdata = shift;
# check width
if ($imagewidth < 1){$imagewidth=640;}
if ($type eq 'month') {
$labellength=3;
print Get_Img_Tag(Graph_Monthly(), $title);
}
elsif ($type eq 'daysofmonth') {
$labellength=2;
print Get_Img_Tag(Graph_Daily(), $title);
}
elsif ($type eq 'daysofweek') {
$labellength=3;
print Get_Img_Tag(Graph_Weekly(), $title);
}
elsif ($type eq 'hours') {
$labellength=2;
print Get_Img_Tag(Graph_Hourly(), $title);
}
elsif ($type eq 'cluster'){
$labellength=32;
print Get_Img_Tag(Graph_Pie(), $title);
}
elsif ($type eq 'filetypes'){
$labellength=4;
print Get_Img_Tag(Graph_Pie(), $title);
}
elsif ($type eq 'httpstatus'){
$labellength=4;
print Get_Img_Tag(Graph_Pie(), $title);
}
elsif ($type eq 'browsers'){
$labellength=32;
print Get_Img_Tag(Graph_Pie(), $title);
}
elsif ($type eq 'downloads'){
$labellength=32;
print Get_Img_Tag(Graph_Pie(), $title);
}
elsif ($type eq 'pages'){
$labellength=32;
print Get_Img_Tag(Graph_Pie(), $title);
}
elsif ($type eq 'oss'){
$labellength=32;
print Get_Img_Tag(Graph_Pie(), $title);
}
elsif ($type eq 'hosts'){
$labellength=32;
print Get_Img_Tag(Graph_Pie(), $title);
}
elsif ($type eq 'countries_map'){
print Chart_Map();
}
else {
debug("Unknown type parameter in ShowGraph_graphgooglechartapi function: $title",1);
#error("Unknown type parameter in ShowGraph_graphgooglechartapi function");
}
return 0;
}
#-------------------------------------------------------
# PLUGIN FUNCTION: AddHTMLHeader_pluginname
# UNIQUE: NO
# Prints javascript includes for Google Visualizations
# Parameters: None
# Input: None
# Output: HTML code for Google Visualizations
# Return: 0 OK, 1 Error
#-------------------------------------------------------
sub AddHTMLHeader_graphgooglechartapi(){
print "\n";
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Graph_Monthly
# Prints the image code to display a column chart of monthly usage
# Parameters: None
# Input: None
# Output: HTML code to print a chart
# Return: 0 OK, 1 Error
#-------------------------------------------------------
sub Graph_Monthly(){
my $chxt = "chxt=";
my $chxl = "chxl=";
my $chxs = "chxs=";
my $chco = "chco=";
my $chg = "chg=";
my $chs = "chs=";
my $cht = "cht=bvg";
my $chd = "chd=t:";
my $cba = "chbh=a"; # shows the whole month
my $graphwidth = $imagewidth;
my $graphheight = int ($imagewidth * $imageratio);
# round max values
foreach my $i(0..(scalar @$valmax)){
@$valmax[$i] = Round_Up(@$valmax[$i]);
}
# setup axis
$chxt .= "x,y,y,r"; # add an x for years
# get the month labels
$chxl .= "0:|";
$chxl .= Get_Labels();
# get the hits/pages max
$chxl .= "1:|0|".Get_Suffixed((@$valmax[0]/2),0)."|".Get_Suffixed(@$valmax[0],0)."|";
# get the visitors/pages max
$chxl .= "2:|0|".Get_Suffixed((@$valmax[2]/2),0)."|".Get_Suffixed(@$valmax[2],0)."|";
# get bytes
$chxl .= "3:|0|".Get_Suffixed((@$valmax[4]/2),1)."|".Get_Suffixed(@$valmax[4],1);
# TODO add the year at the start and end
# set the axis colors
$chxs .= "1,".@$valcolor[0]."|2,".@$valcolor[2]."|3,".@$valcolor[4];
# dump colors
foreach my $i(0..(scalar @$valcolor)){
$chco .= @$valcolor[$i];
if ($i < (scalar @$valcolor)-1){ $chco .= ",";}
}
# grid lines
$chg .= "0,50";
# size
$chs .= $graphwidth."x".$graphheight;
# finally get the data
$chd .= Get_Column_Data();
# string and dump
return "$cht&$chxl&$chxt&$chxs&$chco&$chg&$chs&$chd&$cba";
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Graph_Daily
# Prints the image code to display a column chart of daily usage
# Parameters: None
# Input: None
# Output: HTML code to print a chart
# Return: 0 OK, 1 Error
#-------------------------------------------------------
sub Graph_Daily(){
my $chxt = "chxt=";
my $chxl = "chxl=";
my $chxs = "chxs=";
my $chco = "chco=";
my $chg = "chg=";
my $chs = "chs=";
my $cht = "cht=bvg";
my $chd = "chd=t:";
my $cba = "chbh=a"; # shows the whole month
my $graphwidth = $imagewidth;
my $graphheight = int ($imagewidth * $imageratio);
# round max values
foreach my $i(0..(scalar @$valmax)){
@$valmax[$i] = Round_Up(@$valmax[$i]);
}
# setup axis
$chxt .= "x,y,y,r"; # add an x for years
# setup axis labels
# get day labels
$chxl .= "0:|";
$chxl .= Get_Labels();
# get the hits/pages max
$chxl .= "1:|0|".Get_Suffixed((@$valmax[0]/2),0)."|".Get_Suffixed(@$valmax[0],0)."|";
# get the visitors/pages max
$chxl .= "2:|0|".Get_Suffixed((@$valmax[1]/2),0)."|".Get_Suffixed(@$valmax[1],0)."|";
# get bytes
$chxl .= "3:|0|".Get_Suffixed((@$valmax[3]/2),1)."|".Get_Suffixed(@$valmax[3],1);
# TODO month name
# set the axis colors
$chxs .= "1,".@$valcolor[0]."|2,".@$valcolor[1]."|3,".@$valcolor[3];
# dump colors
foreach my $i(0..(scalar @$valcolor)){
$chco .= @$valcolor[$i];
if ($i < (scalar @$valcolor)-1){ $chco .= ",";}
}
# grid lines
$chg .= "0,50";
# size
$chs .= $graphwidth."x".$graphheight;
# finally get the data
$chd .= Get_Column_Data();
# string and dump
return "$cht&$chxl&$chxt&$chxs&$chco&$chg&$chs&$chd&$cba";
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Graph_Weekly
# Prints the image code to display a column chart of weekly usage
# Parameters: None
# Input: None
# Output: HTML code to print a chart
# Return: 0 OK, 1 Error
#-------------------------------------------------------
sub Graph_Weekly(){
my $chxt = "chxt=";
my $chxl = "chxl=";
my $chxs = "chxs=";
my $chco = "chco=";
my $chg = "chg=";
my $chs = "chs=";
my $cht = "cht=bvg";
my $chd = "chd=t:";
my $cba = "chbh=a"; # shows the whole month
my $graphwidth = int ($imagewidth * .75); # to maintain old look/ratio, reduce width of the weekly
my $graphheight = int ($imagewidth * $imageratio);
# round max values
foreach my $i(0..(scalar @$valmax)){
@$valmax[$i] = Round_Up(@$valmax[$i]);
}
# setup axis
$chxt .= "x,y,y,r"; # add an x for years
# setup axis labels
# get the day labels
$chxl .= "0:|";
$chxl .= Get_Labels();
# get the hits/pages max
$chxl .= "1:|0|".Get_Suffixed((@$valmax[0]/2),0)."|".Get_Suffixed(@$valmax[0],0)."|";
# get the visitors/pages max
$chxl .= "2:|0|".Get_Suffixed((@$valmax[1]/2),0)."|".Get_Suffixed(@$valmax[1],0)."|";
# get bytes
$chxl .= "3:|0|".Get_Suffixed((@$valmax[2]/2),1)."|".Get_Suffixed(@$valmax[2],1);
# set the axis colors
$chxs .= "1,".@$valcolor[0]."|2,".@$valcolor[1]."|3,".@$valcolor[2];
# dump colors
foreach my $i(0..(scalar @$valcolor)){
$chco .= @$valcolor[$i];
if ($i < (scalar @$valcolor)-1){ $chco .= ",";}
}
# grid lines
$chg .= "0,50";
# size
$chs .= $graphwidth."x".$graphheight;
# finally get the data
$chd .= Get_Column_Data();
# string and dump
return "$cht&$chxl&$chxt&$chxs&$chco&$chg&$chs&$chd&$cba";
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Graph_Hourly
# Prints the image code to display a column chart of hourly usage
# Parameters: None
# Input: None
# Output: HTML code to print a chart
# Return: 0 OK, 1 Error
#-------------------------------------------------------
sub Graph_Hourly(){
my $chxt = "chxt=";
my $chxl = "chxl=";
my $chxs = "chxs=";
my $chco = "chco=";
my $chg = "chg=";
my $chs = "chs=";
my $cht = "cht=bvg";
my $chd = "chd=t:";
my $cba = "chbh=a"; # shows the whole month
my $graphwidth = $imagewidth;
my $graphheight = int ($imagewidth * $imageratio);
# round max values
foreach my $i(0..(scalar @$valmax - 1)){
@$valmax[$i] = Round_Up(@$valmax[$i]);
}
# setup axis
$chxt .= "x,y,y,r"; # add an x for years
# setup axis labels
$chxl .= "0:|";
$chxl .= Get_Labels();
# get the hits/pages max
$chxl .= "1:|0|".Get_Suffixed((@$valmax[0]/2),0)."|".Get_Suffixed(@$valmax[0],0)."|";
# get the visitors/pages max
$chxl .= "2:|0|".Get_Suffixed((@$valmax[1]/2),0)."|".Get_Suffixed(@$valmax[1],0)."|";
# get bytes
$chxl .= "3:|0|".Get_Suffixed((@$valmax[2]/2),1)."|".Get_Suffixed(@$valmax[2],1);
# TODO years
# set the axis colors
$chxs .= "1,".@$valcolor[0]."|2,".@$valcolor[1]."|3,".@$valcolor[2];
# dump colors
foreach my $i(0..(scalar @$valcolor)){
$chco .= @$valcolor[$i];
if ($i < (scalar @$valcolor)-1){ $chco .= ",";}
}
# grid lines
$chg .= "0,50";
# size
$chs .= $graphwidth."x".$graphheight;
# finally get the data
$chd .= Get_Column_Data();
# string and dump
return "$cht&$chxl&$chxt&$chxs&$chco&$chg&$chs&$chd&$cba";
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Graph_Pie
# Prints the image code to display a pie chart of the provided data
# Parameters: None
# Input: None
# Output: HTML code to print a chart
# Return: 0 OK, 1 Error
#-------------------------------------------------------
sub Graph_Pie(){
my $chl = "chl=";
my $chs = "chs=";
my $chco = "chco=";
my $cht = "cht=p3";
my $chd = "chd=t:";
my $graphwidth = $imagewidth;
my $graphheight = int ($imagewidth * $pieratio);
# get labels
$chl .= Get_Labels();
# get data, just read off the array for however many labels we have
foreach my $i (0..((scalar @$blocklabel)-1)) {
$chd .= int(@$valdata[$i]);
$chd .= ($i < ((scalar @$blocklabel)-1) ? "," : "");
}
# get color, just the first color passed
$chco .= @$valcolor[0];
# set size
$chs .= $graphwidth."x".$graphheight;
return "$cht&$chs&$chco&$chl&$chd";
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Chart_Map
# Prints a Javascript and DIV tag to display a Google Visualization GeoMap
# that uses the Flash plugin to display a map of the world shaded to reflect
# the provided data
# Parameters: None
# Input: None
# Output: Javascript and DIV tag
# Return: 0 OK, 1 Error
#-------------------------------------------------------
sub Chart_Map(){
my $graphwidth = $imagewidth;
my $graphheight = int ($imagewidth * $mapratio);
# Assume we've already included the proper headers so just call our script inline
print "\n\n";
# print the div tag that will contain the map
print "\n";
return;
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Get_Column_Data
# Loops through the data array and prints a CHD string to send to a Google
# chart via the API
# Parameters: None
# Input: @valcolor, @blocklabel, @valdata, @valmax
# Output: None
# Return: A pipe delimited string of data. REQUIRES the "chd=t:" prepended
#-------------------------------------------------------
# Returns a string with the CHD data
sub Get_Column_Data(){
my $chd = "";
# use the # of colors to determine how many values we have
$x= scalar @$valcolor;
for ($serie = 0; $serie <= $x; $serie++) {
foreach my $j (1.. (scalar @$blocklabel)) {
if ($j > 1) { $chd .= ","; }
$val = @$valdata[($j-1)*$x+$serie];
# convert our values to a percent of max
$chd .= (@$valmax[$serie] > 0 ? int(($val / Round_Up(@$valmax[$serie])) * 100) : 0);
}
if ($serie < $x) {
$chd .= "|";
}
}
# return
return $chd;
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Get_Labels
# Returns a CHXL string with labels to send to the Google chart API. Long labels
# are shortened to $labellength
# TODO - better shortening method instead of just lopping off the end of strings
# Parameters: None
# Input: @blocklabel, $labellength
# Output: None
# Return: A pipe delimited string of labels. REQUIRES the "chxl=" prepended
#-------------------------------------------------------
sub Get_Labels(){
my $chxl = "";
foreach my $i (1..(scalar @$blocklabel)) {
$temp = @$blocklabel[$i-1];
if (length($temp) > $labellength){
$temp = (substr($temp,0,$labellength));
}
$chxl .= "$temp|";
}
$chxl =~ s/&//;
return $chxl;
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Round_Up
# Rounds a number up to the next most significant digit, i.e. 1234 becomes 2000
# Useful for getting the max values of our graph
# Parameters: $num
# Input: None
# Output: None
# Return: The rounded number
#-------------------------------------------------------
sub Round_Up(){
my $num = shift;
$num = int($num);
if ($num < 1){ return $num; }
# under 100, just increment and dump
if ($num < 100){return $num++; }
$i = int(substr($num,0,2))+1;
# pad with 0s
$l = length($i);
while ($l<(length($num))){
$i .= "0";
$l++;
}
return $i;
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Get_Suffixed
# Converts a number for axis labels and appends the scientific notation suffix
# or proper size in bytes
# Parameters: $num
# Input: @Message array from AWStats
# Output: None
# Return: A number with suffix, i.e. 400 MB or 200 K
#-------------------------------------------------------
sub Get_Suffixed(){
my $num = shift || 0;
my $isbytes = shift || 0;
my $float = 0;
if ( $num >= ( 1 << 30 ) ) {
$float = (split(/\./, $num / 1000000000))[1];
if ($float){
return sprintf( "%.1f", $num / 1000000000 ) . ($isbytes ? " $Message[110]" : " B");
}else{
return sprintf( "%.0f", $num / 1000000000 ) . ($isbytes ? " $Message[110]" : " B");
}
}
if ( $num >= ( 1 << 20 ) ) {
$float = (split(/\./, $num / 1000000))[1];
if ($float){
return sprintf( "%.1f", $num / 1000000 ) . ($isbytes ? " $Message[109]" : " M");
}else{
return sprintf( "%.0f", $num / 1000000 ) . ($isbytes ? " $Message[109]" : " M");
}
}
if ( $num >= ( 1 << 10 ) ) {
$float = (split(/\./, $num / 1000))[1];
if ($float){
return sprintf( "%.1f", $num / 1000 ) . ($isbytes ? " $Message[108]" : " K");
}else{
return sprintf( "%.0f", $num / 1000 ) . ($isbytes ? " $Message[108]" : " K");
}
}
return int($num);
}
#-------------------------------------------------------
# PLUGIN FUNCTION: Get_Img_Tag
# Builds the full IMG tag to place in HTML that will call the Google Charts API
# Parameters: $params, $title
# Input: $ChartProtocol, $ChartURI, $ChartIndex
# Output: None
# Return: An HTML IMG tag
#-------------------------------------------------------
sub Get_Img_Tag(){
my $params = shift || "";
my $title = shift || "";
my $tag = "
= 9 ? 0 : $ChartIndex + 1);
$tag .= $params;
$tag .= "\" alt=\"$title\"/>";
}
1; # Do not remove this line
awstats-7.2/wwwroot/cgi-bin/plugins/decodeutfkeys.pm 0000600 0001750 0001750 00000005620 10107423146 020572 0 ustar sk sk #!/usr/bin/perl
#-----------------------------------------------------------------------------
# decodeUTFKeys AWStats plugin
# Allow AWStats to convert keywords strings coded by some search engines in
# UTF8 coding to a common string in a local charset.
#-----------------------------------------------------------------------------
# Perl Required Modules: Encode and URI::Escape
#-----------------------------------------------------------------------------
# $Revision: 1.4 $ - $Author: eldy $ - $Date: 2004/08/14 14:49:09 $
# <-----
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
if (!eval ('require "Encode.pm"')) { return $@?"Error: $@":"Error: Need Perl module Encode"; }
if (!eval ('require "URI/Escape.pm"')) { return $@?"Error: $@":"Error: Need Perl module URI::Escape"; }
#if (!eval ('require "HTML/Entities.pm"')) { return $@?"Error: $@":"Error: Need Perl module HTML::Entities"; }
# ----->
use strict;no strict "refs";
#-----------------------------------------------------------------------------
# PLUGIN VARIABLES
#-----------------------------------------------------------------------------
# <-----
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion="6.0";
my $PluginHooksFunctions="DecodeKey";
# ----->
# <-----
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
use vars qw/
/;
# ----->
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: Init_pluginname
#-----------------------------------------------------------------------------
sub Init_decodeutfkeys {
my $InitParams=shift;
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
# ----->
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
return ($checkversion?$checkversion:"$PluginHooksFunctions");
}
#------------------------------------------------------------------------------
# Function: Converts an UTF8 string to specified Charset
# Parameters: utfstringtodecode charsettoencode
# Return: newencodedstring
#------------------------------------------------------------------------------
sub DecodeKey_decodeutfkeys {
my $string = shift;
my $encoding = shift;
if (! $encoding) { error("Function DecodeKey from plugin decodeutfkeys was called but AWStats don't know language code required to output new value."); }
$string =~ s/\\x(\w\w)/%$1/gi; # Change "\xc4\xbe\xd7\xd3\xc3\xc0" into "%c4%be%d7%d3%c3%c0"
$string=URI::Escape::uri_unescape($string);
if ( $string =~ m/^(?:[\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf])*$/ )
{
$string=Encode::encode($encoding, Encode::decode("utf-8", $string));
}
#$string=HTML::Entities::encode_entities($string);
$string =~ s/[;+]/ /g;
return $string;
}
1; # Do not remove this line
awstats-7.2/wwwroot/cgi-bin/plugins/geoip_region_maxmind.pm 0000600 0001750 0001750 00000062160 11434567126 022134 0 ustar sk sk #!/usr/bin/perl
#-----------------------------------------------------------------------------
# GeoIp_Region_Maxmind AWStats plugin
# This plugin allow you to add a region report with regions detected
# from a Geographical database (US and Canada).
# Need the licensed region database from Maxmind.
#-----------------------------------------------------------------------------
# Perl Required Modules: Geo::IP or Geo::IP::PurePerl
#-----------------------------------------------------------------------------
# $Revision: 1.21 $ - $Author: eldy $ - $Date: 2010/08/23 21:55:34 $
# <-----
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
use vars qw/ $type /;
$type='geoip';
if (!eval ('require "Geo/IP.pm";')) {
$error1=$@;
$type='geoippureperl';
if (!eval ('require "Geo/IP/PurePerl.pm";')) {
$error2=$@;
$ret=($error1||$error2)?"Error:\n$error1$error2":"";
$ret.="Error: Need Perl module Geo::IP or Geo::IP::PurePerl";
return $ret;
}
}
# ----->
#use strict;
no strict "refs";
#-----------------------------------------------------------------------------
# PLUGIN VARIABLES
#-----------------------------------------------------------------------------
# <-----
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion="6.5";
my $PluginHooksFunctions="AddHTMLMenuLink AddHTMLGraph ShowInfoHost SectionInitHashArray SectionProcessIp SectionProcessHostname SectionReadHistory SectionWriteHistory";
my $PluginName="geoip_region_maxmind";
my $LoadedOverride=0;
my $OverrideFile="";
# ----->
# <-----
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
use vars qw/
%TmpDomainLookup
$geoip_region_maxmind
%_region_p
%_region_h
%_region_k
%_region_l
$MAXNBOFSECTIONGIR
%region
/;
my %countrylib=('ca'=>'Canada','us'=>'USA');
my %countryregionlib=('ca'=>'Canadian Regions','us'=>'US regions');
my %regca=(
'AB',"Alberta",
'BC',"British Columbia",
'MB',"Manitoba",
'NB',"New Brunswick",
'NF',"Newfoundland",
'NS',"Nova Scotia",
'NU',"Nunavut",
'ON',"Ontario",
'PE',"Prince Edward Island",
'QC',"Quebec",
'SK',"Saskatchewan",
'NT',"Northwest Territories",
'YT',"Yukon Territory"
);
my %regus=(
'AA',"Armed Forces Americas",
'AE',"Armed Forces Europe, Middle East, & Canada",
'AK',"Alaska",
'AL',"Alabama",
'AP',"Armed Forces Pacific",
'AR',"Arkansas",
'AS',"American Samoa",
'AZ',"Arizona",
'CA',"California",
'CO',"Colorado",
'CT',"Connecticut",
'DC',"District of Columbia",
'DE',"Delaware",
'FL',"Florida",
'FM',"Federated States of Micronesia",
'GA',"Georgia",
'GU',"Guam",
'HI',"Hawaii",
'IA',"Iowa",
'ID',"Idaho",
'IL',"Illinois",
'IN',"Indiana",
'KS',"Kansas",
'KY',"Kentucky",
'LA',"Louisiana",
'MA',"Massachusetts",
'MD',"Maryland",
'ME',"Maine",
'MH',"Marshall Islands",
'MI',"Michigan",
'MN',"Minnesota",
'MO',"Missouri",
'MP',"Northern Mariana Islands",
'MS',"Mississippi",
'MT',"Montana",
'NC',"North Carolina",
'ND',"North Dakota",
'NE',"Nebraska",
'NH',"New Hampshire",
'NJ',"New Jersey",
'NM',"New Mexico",
'NV',"Nevada",
'NY',"New York",
'OH',"Ohio",
'OK',"Oklahoma",
'OR',"Oregon",
'PA',"Pennsylvania",
'PR',"Puerto Rico",
'PW',"Palau",
'RI',"Rhode Island",
'SC',"South Carolina",
'SD',"South Dakota",
'TN',"Tennessee",
'TX',"Texas",
'UT',"Utah",
'VA',"Virginia",
'VI',"Virgin Islands",
'VT',"Vermont",
'WA',"Washington",
'WV',"West Virginia",
'WI',"Wisconsin",
'WY',"Wyoming"
);
my %region=(
'ca'=>\%regca,
'us'=>\%regus
);
# ----->
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: Init_pluginname
#-----------------------------------------------------------------------------
sub Init_geoip_region_maxmind {
my $InitParams=shift;
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
$MAXNBOFSECTIONGIR=10;
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
debug(" Plugin $PluginName: InitParams=$InitParams",1);
my ($mode,$tmpdatafile)=split(/\s+/,$InitParams,2);
my ($datafile,$override)=split(/\+/,$tmpdatafile,2);
if (! $datafile) { $datafile="GeoIPRegion.dat"; }
else { $datafile =~ s/%20/ /g; }
if ($type eq 'geoippureperl') {
# With pureperl we always use GEOIP_STANDARD.
# GEOIP_MEMORY_CACHE seems to fail with ActiveState
if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE') { $mode=Geo::IP::PurePerl::GEOIP_STANDARD(); }
else { $mode=Geo::IP::PurePerl::GEOIP_STANDARD(); }
} else {
if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE') { $mode=Geo::IP::GEOIP_MEMORY_CACHE(); }
else { $mode=Geo::IP::GEOIP_STANDARD(); }
}
if ($override){ $override =~ s/%20/ /g; $OverrideFile=$override; }
%TmpDomainLookup=();
debug(" Plugin $PluginName: GeoIP initialized type=$type mode=$mode",1);
if ($type eq 'geoippureperl') {
$geoip_region_maxmind = Geo::IP::PurePerl->open($datafile, $mode);
} else {
$geoip_region_maxmind = Geo::IP->open($datafile, $mode);
}
$LoadedOverride=0;
# Fails with some geoip versions
# debug(" Plugin geoip_region_maxmind: GeoIP initialized database_info=".$geoip_region_maxmind->database_info());
# ----->
return ($checkversion?$checkversion:"$PluginHooksFunctions");
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: AddHTMLMenuLink_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub AddHTMLMenuLink_geoip_region_maxmind {
my $categ=$_[0];
my $menu=$_[1];
my $menulink=$_[2];
my $menutext=$_[3];
# <-----
if ($Debug) { debug(" Plugin $PluginName: AddHTMLMenuLink"); }
if ($categ eq 'who') {
$menu->{"plugin_$PluginName"}=2.1; # Pos
$menulink->{"plugin_$PluginName"}=2; # Type of link
$menutext->{"plugin_$PluginName"}="Regions"; # Text
}
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: AddHTMLGraph_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub AddHTMLGraph_geoip_region_maxmind {
my $categ=$_[0];
my $menu=$_[1];
my $menulink=$_[2];
my $menutext=$_[3];
# <-----
my $ShowRegions='H';
$MinHit{'Regions'}=1;
my $total_p; my $total_h; my $total_k;
my $rest_p; my $rest_h; my $rest_k;
if ($Debug) { debug(" Plugin $PluginName: AddHTMLGraph"); }
my $title='Regions';
&tab_head("$title",19,0,'regions');
print "US and CA Regions : ".((scalar keys %_region_h)-($_region_h{'unknown'}?1:0))." | ";
if ($ShowRegions =~ /P/i) { print "$Message[56] | "; }
if ($ShowRegions =~ /P/i) { print "$Message[15] | "; }
if ($ShowRegions =~ /H/i) { print "$Message[57] | "; }
if ($ShowRegions =~ /H/i) { print "$Message[15] | "; }
if ($ShowRegions =~ /B/i) { print "$Message[75] | "; }
if ($ShowRegions =~ /L/i) { print "$Message[9] | "; }
print "
\n";
$total_p=$total_h=$total_k=0;
my $count=0;
&BuildKeyList($MaxRowsInHTMLOutput,$MinHit{'Regions'},\%_region_h,\%_region_h);
# Group by country
my @countrylist=('ca','us');
foreach my $country (@countrylist) {
print "".$countryregionlib{$country}." | ";
if ($ShowRegions =~ /P/i) { print " | "; }
if ($ShowRegions =~ /P/i) { print " | "; }
if ($ShowRegions =~ /H/i) { print " | "; }
if ($ShowRegions =~ /H/i) { print " | "; }
if ($ShowRegions =~ /B/i) { print " | "; }
if ($ShowRegions =~ /L/i) { print " | "; }
print "
\n";
foreach my $key (@keylist) {
if ($key eq 'unknown') { next; }
my ($countrycode,$regioncode)=split('_',$key);
if ($countrycode ne $country) { next; }
my $p_p; my $p_h;
if ($TotalPages) { $p_p=int($_region_p{$key}/$TotalPages*1000)/10; }
if ($TotalHits) { $p_h=int($_region_h{$key}/$TotalHits*1000)/10; }
print "".$region{$countrycode}{uc($regioncode)}." ($regioncode) | ";
if ($ShowRegions =~ /P/i) { print "".($_region_p{$key}?Format_Number($_region_p{$key}):" ")." | "; }
if ($ShowRegions =~ /P/i) { print "".($_region_p{$key}?"$p_p %":' ')." | "; }
if ($ShowRegions =~ /H/i) { print "".($_region_h{$key}?Format_Number($_region_h{$key}):" ")." | "; }
if ($ShowRegions =~ /H/i) { print "".($_region_h{$key}?"$p_h %":' ')." | "; }
if ($ShowRegions =~ /B/i) { print "".Format_Bytes($_region_k{$key})." | "; }
if ($ShowRegions =~ /L/i) { print "".($_region_p{$key}?Format_Date($_region_l{$key},1):'-')." | "; }
print "
\n";
$total_p += $_region_p{$key}||0;
$total_h += $_region_h{$key};
$total_k += $_region_k{$key}||0;
$count++;
}
}
if ($Debug) { debug("Total real / shown : $TotalPages / $total_p - $TotalHits / $total_h - $TotalBytes / $total_h",2); }
$rest_p=0;
$rest_h=$TotalHits-$total_h;
$rest_k=0;
if ($rest_p > 0 || $rest_h > 0 || $rest_k > 0) { # All other regions
print " | ";
if ($ShowRegions =~ /P/i) { print " | "; }
if ($ShowRegions =~ /P/i) { print " | "; }
if ($ShowRegions =~ /H/i) { print " | "; }
if ($ShowRegions =~ /H/i) { print " | "; }
if ($ShowRegions =~ /B/i) { print " | "; }
if ($ShowRegions =~ /L/i) { print " | "; }
print "
\n";
my $p_p; my $p_h;
if ($TotalPages) { $p_p=int($rest_p/$TotalPages*1000)/10; }
if ($TotalHits) { $p_h=int($rest_h/$TotalHits*1000)/10; }
print "$Message[2]/$Message[0] | ";
if ($ShowRegions =~ /P/i) { print "".($rest_p?Format_Number($rest_p):" ")." | "; }
if ($ShowRegions =~ /P/i) { print "".($rest_p?"$p_p %":' ')." | "; }
if ($ShowRegions =~ /H/i) { print "".($rest_h?Format_Number($rest_h):" ")." | "; }
if ($ShowRegions =~ /H/i) { print "".($rest_h?"$p_h %":' ')." | "; }
if ($ShowRegions =~ /B/i) { print "".Format_Bytes($rest_k)." | "; }
if ($ShowRegions =~ /L/i) { print " | "; }
print "
\n";
}
&tab_end();
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: GetCountryCodeByAddr_pluginname
# UNIQUE: YES (Only one plugin using this function can be loaded)
# GetCountryCodeByAddr is called to translate an ip into a country code in lower case.
#-----------------------------------------------------------------------------
# Rem: Not used
sub GetCountryCodeByAddr_geoip_region_maxmind {
my $param="$_[0]";
# <-----
if (!$LoadedOverride){&LoadOverrideFile_geoip_region_maxmind();}
my $res=$TmpDomainLookup{$param}||'';
if (! $res) {
my ($res1,$res2,$countryregion)=();
($res1,$res2)=$geoip_region_maxmind->region_by_name($param) if $geoip_region_maxmind;
$res=lc($res1) || 'unknown';
$TmpDomainLookup{$param}=$res;
if ($Debug) { debug(" Plugin $PluginName: GetCountryCodeByAddr for $param: [$res]",5); }
}
elsif ($Debug) { debug(" Plugin $PluginName: GetCountryCodeByAddr for $param: Already resolved to [$res]",5); }
# ----->
return $res;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: GetCountryCodeByName_pluginname
# UNIQUE: YES (Only one plugin using this function can be loaded)
# GetCountryCodeByName is called to translate a host name into a country code in lower case.
#-----------------------------------------------------------------------------
# Rem: Not used
sub GetCountryCodeByName_geoip_region_maxmind {
my $param="$_[0]";
# <-----
if (!$LoadedOverride){&LoadOverrideFile_geoip_region_maxmind();}
my $res=$TmpDomainLookup{$param}||'';
if (! $res) {
my ($res1,$res2,$countryregion)=();
($res1,$res2)=$geoip_region_maxmind->region_by_name($param) if $geoip_region_maxmind;
$res=lc($res1) || 'unknown';
$TmpDomainLookup{$param}=$res;
if ($Debug) { debug(" Plugin $PluginName: GetCountryCodeByName for $param: [$res]",5); }
}
elsif ($Debug) { debug(" Plugin $PluginName: GetCountryCodeByName for $param: Already resolved to [$res]",5); }
# ----->
return $res;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: ShowInfoHost_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
# Function called to add additionnal columns to the Hosts report.
# This function is called when building rows of the report (One call for each
# row). So it allows you to add a column in report, for example with code :
# print "This is a new cell for $param | ";
# Parameters: Host name or ip
#-----------------------------------------------------------------------------
sub ShowInfoHost_geoip_region_maxmind {
my $param="$_[0]";
# <-----
if ($param eq '__title__') {
my $NewLinkParams=${QueryString};
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)output(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
my $NewLinkTarget='';
if ($DetailedReportsOnNewWindows) { $NewLinkTarget=" target=\"awstatsbis\""; }
if (($FrameName eq 'mainleft' || $FrameName eq 'mainright') && $DetailedReportsOnNewWindows < 2) {
$NewLinkParams.="&framename=mainright";
$NewLinkTarget=" target=\"mainright\"";
}
$NewLinkParams =~ s/(&|&)+/&/i;
$NewLinkParams =~ s/^&//; $NewLinkParams =~ s/&$//;
if ($NewLinkParams) { $NewLinkParams="${NewLinkParams}&"; }
print "";
print "GeoIP Region";
print " | ";
}
elsif ($param) {
# try loading our override file if we haven't yet
if (!$LoadedOverride){&LoadOverrideFile_geoip_region_maxmind();}
my $ip=0;
my $key;
if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
$ip=4;
$key=$param;
}
elsif ($param =~ /^[0-9A-F]*:/i) { # IPv6 address
$ip=6;
$key=$param;
}
print "";
if ($key && $ip==4) {
my ($res1,$res2,$countryregion)=();
my @res = TmpLookup_geoip_region_maxmind($param);
if (@res){
$res1 = $res[0];
$res2 = $res[1];
}else{
($res1,$res2)=$geoip_region_maxmind->region_by_name($param) if $geoip_region_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetRegionByIp for $param: [${res1}_${res2}]",5); }
if (! $PluginsLoaded{'init'}{'geoip'}) {
# Show country
if ($res1 =~ /\w\w/) { print $DomainsHashIDLib{lc($res1)}||uc($res1); }
else { print "$Message[0]"; }
# Show region
if ($res1 =~ /\w\w/ && $res2 =~ /\w\w/) {
print " (";
print $region{lc($res1)}{uc($res2)};
print ")";
}
}
else {
# Show region
if ($res1 =~ /\w\w/ && $res2 =~ /\w\w/) {
print $region{lc($res1)}{uc($res2)};
}
else { print "$Message[0]"; }
}
}
if ($key && $ip==6) {
print "$Message[0]";
}
if (! $key) {
my ($res1,$res2,$countryregion)=();
my @res = TmpLookup_geoip_region_maxmind($param);
if (@res){
$res1 = $res[0];
$res2 = $res[1];
}else{
($res1,$res2)=$geoip_region_maxmind->region_by_name($param) if $geoip_region_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetRegionByName for $param: [${res1}_${res2}]",5); }
if (! $PluginsLoaded{'init'}{'geoip'}) {
# Show country
if ($res1 =~ /\w\w/) { print $DomainsHashIDLib{lc($res1)}||uc($res1); }
else { print "$Message[0]"; }
# Show region
if ($res1 =~ /\w\w/ && $res2 =~ /\w\w/) {
print " (";
print $region{lc($res1)}{uc($res2)};
print ")";
}
}
else {
# Show region
if ($res1 =~ /\w\w/ && $res2 =~ /\w\w/) {
print $region{lc($res1)}{uc($res2)};
}
else { print "$Message[0]"; }
}
}
print " | ";
}
else {
print " | ";
}
return 1;
# ----->
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionInitHashArray_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionInitHashArray_geoip_region_maxmind {
# my $param="$_[0]";
# <-----
if ($Debug) { debug(" Plugin $PluginName: Init_HashArray"); }
%_region_p = %_region_h = %_region_k = %_region_l =();
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionProcessHostname_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionProcessIp_geoip_region_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
my ($res1,$res2,$countryregion)=();
my @res = TmpLookup_geoip_region_maxmind($param);
if (@res){
$res1 = $res[0];
$res2 = $res[1];
}else{
($res1,$res2)=$geoip_region_maxmind->region_by_name($param) if $geoip_region_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetRegionByIp for $param: [${res1}_${res2}]",5); }
if ($res2 =~ /\w\w/) { $countryregion=lc("${res1}_${res2}"); }
else { $countryregion='unknown'; }
# if ($PageBool) { $_region_p{$countryregion}++; }
$_region_h{$countryregion}++;
# if ($timerecord > $_region_l{$countryregion}) { $_region_l{$countryregion}=$timerecord; }
# ----->
return;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionProcessHostname_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionProcessHostname_geoip_region_maxmind {
my $param="$_[0]"; # Param must be a hostname
# <-----
my ($res1,$res2,$countryregion)=();
my @res = TmpLookup_geoip_region_maxmind($param);
if (@res){
$res1 = $res[0];
$res2 = $res[1];
}else{
($res1,$res2)=$geoip_region_maxmind->region_by_name($param) if $geoip_region_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetRegionByName for $param: [${res1}_${res2}]",5); }
if ($res2 =~ /\w\w/) { $countryregion=lc("${res1}_${res2}"); }
else { $countryregion='unknown'; }
# if ($PageBool) { $_region_p{$countryregion}++; }
$_region_h{$countryregion}++;
# if ($timerecord > $_region_l{$countryregion}) { $_region_l{$countryregion}=$timerecord; }
# ----->
return;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionReadHistory_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionReadHistory_geoip_region_maxmind {
my $issectiontoload=shift;
my $xmlold=shift;
my $xmleb=shift;
my $countlines=shift;
# <-----
if ($Debug) { debug(" Plugin $PluginName: Begin of PLUGIN_$PluginName"); }
my @field=();
my $count=0;my $countloaded=0;
do {
if ($field[0]) {
$count++;
if ($issectiontoload) {
$countloaded++;
if ($field[2]) { $_region_h{$field[0]}+=$field[2]; }
}
}
$_=;
chomp $_; s/\r//;
@field=split(/\s+/,($xmlold?XMLDecodeFromHisto($_):$_));
$countlines++;
}
until ($field[0] eq "END_PLUGIN_$PluginName" || $field[0] eq "${xmleb}END_PLUGIN_$PluginName" || ! $_);
if ($field[0] ne "END_PLUGIN_$PluginName" && $field[0] ne "${xmleb}END_PLUGIN_$PluginName") { error("History file is corrupted (End of section PLUGIN not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).","","",1); }
if ($Debug) { debug(" Plugin $PluginName: End of PLUGIN_$PluginName section ($count entries, $countloaded loaded)"); }
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionWriteHistory_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionWriteHistory_geoip_region_maxmind {
my ($xml,$xmlbb,$xmlbs,$xmlbe,$xmlrb,$xmlrs,$xmlre,$xmleb,$xmlee)=(shift,shift,shift,shift,shift,shift,shift,shift,shift);
if ($Debug) { debug(" Plugin $PluginName: SectionWriteHistory_$PluginName start - ".(scalar keys %_region_h)); }
# <-----
print HISTORYTMP "\n";
if ($xml) { print HISTORYTMP "$MAXNBOFSECTIONGIR\n"; }
print HISTORYTMP "# Plugin key - Pages - Hits - Bandwidth - Last access\n";
#print HISTORYTMP "# The $MaxNbOfExtra[$extranum] first number of hits are first\n";
$ValueInFile{"plugin_$PluginName"}=tell HISTORYTMP;
print HISTORYTMP "${xmlbb}BEGIN_PLUGIN_$PluginName${xmlbs}".(scalar keys %_region_h)."${xmlbe}\n";
&BuildKeyList($MAXNBOFSECTIONGIR,1,\%_region_h,\%_region_h);
my %keysinkeylist=();
foreach (@keylist) {
$keysinkeylist{$_}=1;
#my $page=$_region_p{$_}||0;
#my $bytes=$_region_k{$_}||0;
#my $lastaccess=$_region_l{$_}||'';
print HISTORYTMP "${xmlrb}$_${xmlrs}0${xmlrs}", $_region_h{$_}, "${xmlrs}0${xmlrs}0${xmlre}\n"; next;
}
foreach (keys %_region_h) {
if ($keysinkeylist{$_}) { next; }
#my $page=$_region_p{$_}||0;
#my $bytes=$_region_k{$_}||0;
#my $lastaccess=$_region_l{$_}||'';
print HISTORYTMP "${xmlrb}$_${xmlrs}0${xmlrs}", $_region_h{$_}, "${xmlrs}0${xmlrs}0${xmlre}\n"; next;
}
print HISTORYTMP "${xmleb}END_PLUGIN_$PluginName${xmlee}\n";
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: LoadOverrideFile
# Attempts to load a comma delimited file that will override the GeoIP database
# Useful for Intranet records
# CSV format: IP,2-char Country code, region
#-----------------------------------------------------------------------------
sub LoadOverrideFile_geoip_region_maxmind{
my $filetoload="";
if ($OverrideFile){
if (!open(GEOIPFILE, $OverrideFile)){
debug("Plugin $PluginName: Unable to open override file: $OverrideFile");
$LoadedOverride = 1;
return;
}
}else{
my $conf = (exists(&Get_Config_Name) ? Get_Config_Name() : $SiteConfig);
if ($conf && open(GEOIPFILE,"$DirData/$PluginName.$conf.txt")) { $filetoload="$DirData/$PluginName.$conf.txt"; }
elsif (open(GEOIPFILE,"$DirData/$PluginName.txt")) { $filetoload="$DirData/$PluginName.txt"; }
else { debug("No override file \"$DirData/$PluginName.txt\": $!"); }
}
if ($filetoload)
{
# This is the fastest way to load with regexp that I know
while (){
chomp $_;
s/\r//;
my @record = split(",", $_);
# replace quotes if they were used in the file
foreach (@record){ $_ =~ s/"//g; }
# now we need to copy our file values in the order to mimic the lookup values
my @res = ();
$res[0] = $record[1]; # country code
$res[1] = $record[2]; # region code
# store in hash
$TmpDomainLookup{$record[0]} = [@res];
}
close GEOIPFILE;
debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
}
$LoadedOverride = 1;
return;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: TmpLookup
# Searches the temporary hash for the parameter value and returns the corresponding
# GEOIP entry
#-----------------------------------------------------------------------------
sub TmpLookup_geoip_region_maxmind(){
$param = shift;
if (!$LoadedOverride){&LoadOverrideFile_geoip_region_maxmind();}
#my @val = ();
#if ($geoip_region_maxmind &&
#(($type eq 'geoip' && $geoip_region_maxmind->VERSION >= 1.30) ||
# $type eq 'geoippureperl' && $geoip_region_maxmind->VERSION >= 1.17)){
# @val = @{$TmpDomainLookup{$geoip_region_maxmind->get_ip_address($param)}};
#}
#else {@val = @{$TmpDomainLookup{$param};}}
#return @val;
if ($TmpDomainLookup{$param}) { return @{$TmpDomainLookup{$param};} }
else { return; }
}
1; # Do not remove this line
awstats-7.2/wwwroot/cgi-bin/plugins/geoip_isp_maxmind.pm 0000600 0001750 0001750 00000046365 11426257452 021454 0 ustar sk sk #!/usr/bin/perl
#-----------------------------------------------------------------------------
# GeoIp_Isp_Maxmind AWStats plugin
# This plugin allow you to add a city report.
# Need the licensed ISP database from Maxmind.
#-----------------------------------------------------------------------------
# Perl Required Modules: Geo::IP or Geo::IP::PurePerl
#-----------------------------------------------------------------------------
# $Revision: 1.18 $ - $Author: eldy $ - $Date: 2010/08/04 12:38:02 $
# <-----
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
use vars qw/ $type /;
$type='geoip';
if (!eval ('require "Geo/IP.pm";')) {
$error1=$@;
$type='geoippureperl';
if (!eval ('require "Geo/IP/PurePerl.pm";')) {
$error2=$@;
$ret=($error1||$error2)?"Error:\n$error1$error2":"";
$ret.="Error: Need Perl module Geo::IP or Geo::IP::PurePerl";
return $ret;
}
}
# ----->
#use strict;
no strict "refs";
#-----------------------------------------------------------------------------
# PLUGIN VARIABLES
#-----------------------------------------------------------------------------
# <-----
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion="6.2";
my $PluginHooksFunctions="AddHTMLMenuLink AddHTMLGraph ShowInfoHost SectionInitHashArray SectionProcessIp SectionProcessHostname SectionReadHistory SectionWriteHistory";
my $PluginName="geoip_isp_maxmind";
my $LoadedOverride=0;
my $OverrideFile="";
my %TmpDomainLookup;
# ----->
# <-----
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
use vars qw/
$geoip_isp_maxmind
%_isp_p
%_isp_h
%_isp_k
%_isp_l
$MAXNBOFSECTIONGIR
$MAXLENGTH
/;
# ----->
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: Init_pluginname
#-----------------------------------------------------------------------------
sub Init_geoip_isp_maxmind {
my $InitParams=shift;
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
$MAXNBOFSECTIONGIR=10;
$MAXLENGTH=20;
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
debug(" Plugin $PluginName: InitParams=$InitParams",1);
my ($mode,$tmpdatafile)=split(/\s+/,$InitParams,2);
my ($datafile,$override)=split(/\+/,$tmpdatafile,2);
if (! $datafile) { $datafile="GeoIPIsp.dat"; }
else { $datafile =~ s/%20/ /g; }
if ($type eq 'geoippureperl') {
# With pureperl with always use GEOIP_STANDARD.
# GEOIP_MEMORY_CACHE seems to fail with ActiveState
if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE') { $mode=Geo::IP::PurePerl::GEOIP_STANDARD(); }
else { $mode=Geo::IP::PurePerl::GEOIP_STANDARD(); }
} else {
if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE') { $mode=Geo::IP::GEOIP_MEMORY_CACHE(); }
else { $mode=Geo::IP::GEOIP_STANDARD(); }
}
if ($override){ $override =~ s/%20/ /g; $OverrideFile=$override; }
%TmpDomainLookup=();
debug(" Plugin $PluginName: GeoIP initialized type=$type mode=$mode",1);
if ($type eq 'geoippureperl') {
$geoip_isp_maxmind = Geo::IP::PurePerl->open($datafile, $mode);
} else {
$geoip_isp_maxmind = Geo::IP->open($datafile, $mode);
}
$LoadedOverride=0;
# Fails on some GeoIP version
# debug(" Plugin geoip_isp_maxmind: GeoIP initialized database_info=".$geoip_isp_maxmind->database_info());
# ----->
return ($checkversion?$checkversion:"$PluginHooksFunctions");
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: AddHTMLMenuLink_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub AddHTMLMenuLink_geoip_isp_maxmind {
my $categ=$_[0];
my $menu=$_[1];
my $menulink=$_[2];
my $menutext=$_[3];
# <-----
if ($Debug) { debug(" Plugin $PluginName: AddHTMLMenuLink"); }
if ($categ eq 'who') {
$menu->{"plugin_$PluginName"}=0.6; # Pos
$menulink->{"plugin_$PluginName"}=2; # Type of link
$menutext->{"plugin_$PluginName"}="ISP"; # Text
}
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: AddHTMLGraph_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub AddHTMLGraph_geoip_isp_maxmind {
my $categ=$_[0];
my $menu=$_[1];
my $menulink=$_[2];
my $menutext=$_[3];
# <-----
my $ShowISP='H';
$MinHit{'Isp'}=1;
my $total_p; my $total_h; my $total_k;
my $rest_p; my $rest_h; my $rest_k;
if ($Debug) { debug(" Plugin $PluginName: AddHTMLGraph $categ $menu $menulink $menutext"); }
my $title='ISP';
&tab_head("$title",19,0,'isp');
print "ISP : ".((scalar keys %_isp_h)-($_isp_h{'unknown'}?1:0))." | ";
if ($ShowISP =~ /P/i) { print "$Message[56] | "; }
if ($ShowISP =~ /P/i) { print "$Message[15] | "; }
if ($ShowISP =~ /H/i) { print "$Message[57] | "; }
if ($ShowISP =~ /H/i) { print "$Message[15] | "; }
if ($ShowISP =~ /B/i) { print "$Message[75] | "; }
if ($ShowISP =~ /L/i) { print "$Message[9] | "; }
print "
\n";
$total_p=$total_h=$total_k=0;
my $count=0;
&BuildKeyList($MaxRowsInHTMLOutput,$MinHit{'Isp'},\%_isp_h,\%_isp_h);
foreach my $key (@keylist) {
if ($key eq 'unknown') { next; }
my $p_p; my $p_h;
if ($TotalPages) { $p_p=int($_isp_p{$key}/$TotalPages*1000)/10; }
if ($TotalHits) { $p_h=int($_isp_h{$key}/$TotalHits*1000)/10; }
print "";
my $isp=$key; $isp =~ s/_/ /g;
print "".ucfirst($isp)." | ";
if ($ShowISP =~ /P/i) { print "".($_isp_p{$key}?Format_Number($_isp_p{$key}):" ")." | "; }
if ($ShowISP =~ /P/i) { print "".($_isp_p{$key}?"$p_p %":' ')." | "; }
if ($ShowISP =~ /H/i) { print "".($_isp_h{$key}?Format_Number($_isp_h{$key}):" ")." | "; }
if ($ShowISP =~ /H/i) { print "".($_isp_h{$key}?"$p_h %":' ')." | "; }
if ($ShowISP =~ /B/i) { print "".Format_Bytes($_isp_k{$key})." | "; }
if ($ShowISP =~ /L/i) { print "".($_isp_p{$key}?Format_Date($_isp_l{$key},1):'-')." | "; }
print "
\n";
$total_p += $_isp_p{$key}||0;
$total_h += $_isp_h{$key};
$total_k += $_isp_k{$key}||0;
$count++;
}
if ($Debug) { debug("Total real / shown : $TotalPages / $total_p - $TotalHits / $total_h - $TotalBytes / $total_h",2); }
$rest_p=0;
$rest_h=$TotalHits-$total_h;
$rest_k=0;
if ($rest_p > 0 || $rest_h > 0 || $rest_k > 0) { # All other cities
# print "";
# print " | ";
# if ($ShowISP =~ /P/i) { print " | "; }
# if ($ShowISP =~ /P/i) { print " | "; }
# if ($ShowISP =~ /H/i) { print " | "; }
# if ($ShowISP =~ /H/i) { print " | "; }
# if ($ShowISP =~ /B/i) { print " | "; }
# if ($ShowISP =~ /L/i) { print " | "; }
# print "
\n";
my $p_p; my $p_h;
if ($TotalPages) { $p_p=int($rest_p/$TotalPages*1000)/10; }
if ($TotalHits) { $p_h=int($rest_h/$TotalHits*1000)/10; }
print "";
print "$Message[2]/$Message[0] | ";
if ($ShowISP =~ /P/i) { print "".($rest_p?Format_Number($rest_p):" ")." | "; }
if ($ShowISP =~ /P/i) { print "".($rest_p?"$p_p %":' ')." | "; }
if ($ShowISP =~ /H/i) { print "".($rest_h?Format_Number($rest_h):" ")." | "; }
if ($ShowISP =~ /H/i) { print "".($rest_h?"$p_h %":' ')." | "; }
if ($ShowISP =~ /B/i) { print "".Format_Bytes($rest_k)." | "; }
if ($ShowISP =~ /L/i) { print " | "; }
print "
\n";
}
&tab_end();
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: ShowInfoHost_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
# Function called to add additionnal columns to the Hosts report.
# This function is called when building rows of the report (One call for each
# row). So it allows you to add a column in report, for example with code :
# print "This is a new cell for $param | ";
# Parameters: Host name or ip
#-----------------------------------------------------------------------------
sub ShowInfoHost_geoip_isp_maxmind {
my $param="$_[0]";
# <-----
if ($param eq '__title__') {
my $NewLinkParams=${QueryString};
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)output(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
my $NewLinkTarget='';
if ($DetailedReportsOnNewWindows) { $NewLinkTarget=" target=\"awstatsbis\""; }
if (($FrameName eq 'mainleft' || $FrameName eq 'mainright') && $DetailedReportsOnNewWindows < 2) {
$NewLinkParams.="&framename=mainright";
$NewLinkTarget=" target=\"mainright\"";
}
$NewLinkParams =~ s/(&|&)+/&/i;
$NewLinkParams =~ s/^&//; $NewLinkParams =~ s/&$//;
if ($NewLinkParams) { $NewLinkParams="${NewLinkParams}&"; }
print "";
print "GeoIP ISP";
print " | ";
}
elsif ($param) {
my $ip=0;
my $key;
if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
$ip=4;
$key=$param;
}
elsif ($param =~ /^[0-9A-F]*:/i) { # IPv6 address
$ip=6;
$key=$param;
}
print "";
if ($key && $ip==4) {
my $isp = TmpLookup_geoip_isp_maxmind($param);
if (!$isp && $type eq 'geoippureperl')
{
# Function isp_by_addr does not exists in PurePerl but isp_by_name do same
$isp=$geoip_isp_maxmind->isp_by_name($param) if $geoip_isp_maxmind;
}
elsif (!$isp)
{
# Function isp_by_addr does not exits, so we use org_by_addr
$isp=$geoip_isp_maxmind->org_by_addr($param) if $geoip_isp_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetIspByIp for $param: [$isp]",5); }
if ($isp) {
if (length($isp) <= $MAXLENGTH) {
print "$isp";
}
else {
print substr($isp,0,$MAXLENGTH).'...';
}
}
else { print "$Message[0]"; }
}
if ($key && $ip==6) {
print "$Message[0]";
}
if (! $key) {
my $isp = TmpLookup_geoip_isp_maxmind($param);
if (!$isp && $type eq 'geoippureperl')
{
$isp=$geoip_isp_maxmind->isp_by_name($param) if $geoip_isp_maxmind;
}
elsif (!$isp)
{
$isp=$geoip_isp_maxmind->isp_by_name($param) if $geoip_isp_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetIspByHostname for $param: [$isp]",5); }
if ($isp) {
if (length($isp) <= $MAXLENGTH) {
print "$isp";
}
else {
print substr($isp,0,$MAXLENGTH).'...';
}
}
else { print "$Message[0]"; }
}
print " | ";
}
else {
print " | ";
}
return 1;
# ----->
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionInitHashArray_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionInitHashArray_geoip_isp_maxmind {
# my $param="$_[0]";
# <-----
if ($Debug) { debug(" Plugin $PluginName: Init_HashArray"); }
%_isp_p = %_isp_h = %_isp_k = %_isp_l =();
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionProcessIP_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionProcessIp_geoip_isp_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
my $isp = TmpLookup_geoip_isp_maxmind($param);
if (!$isp && $type eq 'geoippureperl')
{
# Function isp_by_addr does not exists in PurePerl but isp_by_name do same
$isp=$geoip_isp_maxmind->isp_by_name($param) if $geoip_isp_maxmind;
}
elsif(!$isp)
{
# Function isp_by_addr does not exits, so we use org_by_addr
$isp=$geoip_isp_maxmind->org_by_addr($param) if $geoip_isp_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetIspByIp for $param: [$isp]",5); }
if ($isp) {
$isp =~ s/\s/_/g;
$_isp_h{$isp}++;
} else {
$_isp_h{'unknown'}++;
}
# if ($timerecord > $_isp_l{$city}) { $_isp_l{$city}=$timerecord; }
# ----->
return;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionProcessHostname_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionProcessHostname_geoip_isp_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
my $isp = TmpLookup_geoip_isp_maxmind($param);
if (!$isp && $type eq 'geoippureperl')
{
$isp=$geoip_isp_maxmind->isp_by_name($param) if $geoip_isp_maxmind;
}
elsif(!$isp)
{
$isp=$geoip_isp_maxmind->isp_by_name($param) if $geoip_isp_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetIspByHostname for $param: [$isp]",5); }
if ($isp) {
$isp =~ s/\s/_/g;
$_isp_h{$isp}++;
} else {
$_isp_h{'unknown'}++;
}
# if ($timerecord > $_isp_l{$city}) { $_isp_l{$city}=$timerecord; }
# ----->
return;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionReadHistory_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionReadHistory_geoip_isp_maxmind {
my $issectiontoload=shift;
my $xmlold=shift;
my $xmleb=shift;
my $countlines=shift;
# <-----
if ($Debug) { debug(" Plugin $PluginName: Begin of PLUGIN_$PluginName section"); }
my @field=();
my $count=0;my $countloaded=0;
do {
if ($field[0]) {
$count++;
if ($issectiontoload) {
$countloaded++;
if ($field[2]) { $_isp_h{$field[0]}+=$field[2]; }
}
}
$_=;
chomp $_; s/\r//;
@field=split(/\s+/,($xmlold?XMLDecodeFromHisto($_):$_));
$countlines++;
}
until ($field[0] eq "END_PLUGIN_$PluginName" || $field[0] eq "${xmleb}END_PLUGIN_$PluginName" || ! $_);
if ($field[0] ne "END_PLUGIN_$PluginName" && $field[0] ne "${xmleb}END_PLUGIN_$PluginName") { error("History file is corrupted (End of section PLUGIN not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).","","",1); }
if ($Debug) { debug(" Plugin $PluginName: End of PLUGIN_$PluginName ($count entries, $countloaded loaded)"); }
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: SectionWriteHistory_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
#-----------------------------------------------------------------------------
sub SectionWriteHistory_geoip_isp_maxmind {
my ($xml,$xmlbb,$xmlbs,$xmlbe,$xmlrb,$xmlrs,$xmlre,$xmleb,$xmlee)=(shift,shift,shift,shift,shift,shift,shift,shift,shift);
if ($Debug) { debug(" Plugin $PluginName: SectionWriteHistory_$PluginName start - ".(scalar keys %_isp_h)); }
# <-----
print HISTORYTMP "\n";
if ($xml) { print HISTORYTMP "$MAXNBOFSECTIONGIR\n"; }
print HISTORYTMP "# Plugin key - Pages - Hits - Bandwidth - Last access\n";
#print HISTORYTMP "# The $MaxNbOfExtra[$extranum] first number of hits are first\n";
$ValueInFile{"plugin_$PluginName"}=tell HISTORYTMP;
print HISTORYTMP "${xmlbb}BEGIN_PLUGIN_$PluginName${xmlbs}".(scalar keys %_isp_h)."${xmlbe}\n";
&BuildKeyList($MAXNBOFSECTIONGIR,1,\%_isp_h,\%_isp_h);
my %keysinkeylist=();
foreach (@keylist) {
$keysinkeylist{$_}=1;
#my $page=$_isp_p{$_}||0;
#my $bytes=$_isp_k{$_}||0;
#my $lastaccess=$_isp_l{$_}||'';
print HISTORYTMP "${xmlrb}$_${xmlrs}0${xmlrs}", $_isp_h{$_}, "${xmlrs}0${xmlrs}0${xmlre}\n"; next;
}
foreach (keys %_isp_h) {
if ($keysinkeylist{$_}) { next; }
#my $page=$_isp_p{$_}||0;
#my $bytes=$_isp_k{$_}||0;
#my $lastaccess=$_isp_l{$_}||'';
print HISTORYTMP "${xmlrb}$_${xmlrs}0${xmlrs}", $_isp_h{$_}, "${xmlrs}0${xmlrs}0${xmlre}\n"; next;
}
print HISTORYTMP "${xmleb}END_PLUGIN_$PluginName${xmlee}\n";
# ----->
return 0;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: LoadOverrideFile
# Attempts to load a comma delimited file that will override the GeoIP database
# Useful for Intranet records
# CSV format: IP,"isp"
#-----------------------------------------------------------------------------
sub LoadOverrideFile_geoip_isp_maxmind{
my $filetoload="";
if ($OverrideFile){
if (!open(GEOIPFILE, $OverrideFile)){
debug("Plugin $PluginName: Unable to open override file: $OverrideFile");
$LoadedOverride = 1;
return;
}
}else{
my $conf = (exists(&Get_Config_Name) ? Get_Config_Name() : $SiteConfig);
if ($conf && open(GEOIPFILE,"$DirData/$PluginName.$conf.txt")) { $filetoload="$DirData/$PluginName.$conf.txt"; }
elsif (open(GEOIPFILE,"$DirData/$PluginName.txt")) { $filetoload="$DirData/$PluginName.txt"; }
else { debug("No override file \"$DirData/$PluginName.txt\": $!"); }
}
if ($filetoload)
{
# This is the fastest way to load with regexp that I know
while (){
chomp $_;
s/\r//;
my @record = split(",", $_);
# replace quotes if they were used in the file
foreach (@record){ $_ =~ s/"//g; }
# store in hash
$TmpDomainLookup{$record[0]} = $record[1];
}
close GEOIPFILE;
debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
}
$LoadedOverride = 1;
return;
}
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: TmpLookup
# Searches the temporary hash for the parameter value and returns the corresponding
# GEOIP entry
#-----------------------------------------------------------------------------
sub TmpLookup_geoip_isp_maxmind(){
$param = shift;
if (!$LoadedOverride){&LoadOverrideFile_geoip_isp_maxmind();}
#my $val;
#if ($geoip_isp_maxmind &&
#(($type eq 'geoip' && $geoip_isp_maxmind->VERSION >= 1.30) ||
# $type eq 'geoippureperl' && $geoip_isp_maxmind->VERSION >= 1.17)){
# $val = $TmpDomainLookup{$geoip_isp_maxmind->get_ip_address($param)};
#}
#else {$val = $TmpDomainLookup{$param};}
#return $val || '';
return $TmpDomainLookup{$param}||'';
}
1; # Do not remove this line
awstats-7.2/wwwroot/cgi-bin/plugins/graphapplet.pm 0000600 0001750 0001750 00000011761 11377011131 020243 0 ustar sk sk #!/usr/bin/perl
#-----------------------------------------------------------------------------
# GraphApplet AWStats plugin
# Allow AWStats to replace bar graphs with an Applet (awgraphapplet) that draw
# 3D graphs instead.
#-----------------------------------------------------------------------------
# Perl Required Modules: None
#-----------------------------------------------------------------------------
# $Revision: 1.10 $ - $Author: manolamancha $ - $Date: 2010/05/11 12:33:48 $
# <-----
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
# ----->
#use strict;
no strict "refs";
#-----------------------------------------------------------------------------
# PLUGIN VARIABLES
#-----------------------------------------------------------------------------
# <-----
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion="6.0";
my $PluginHooksFunctions="ShowGraph";
# ----->
# <-----
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
use vars qw/
$DirClasses
/;
# ----->
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: Init_pluginname
#-----------------------------------------------------------------------------
sub Init_graphapplet {
my $InitParams=shift;
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
$DirClasses=$InitParams;
# ----->
return ($checkversion?$checkversion:"$PluginHooksFunctions");
}
#-------------------------------------------------------
# PLUGIN FUNCTION: ShowGraph_pluginname
# UNIQUE: YES (Only one plugin using this function can be loaded)
# Add the code for call to applet awgraphapplet
# Parameters: $title $type $showmonthstats \@blocklabel,\@vallabel,\@valcolor,\@valmax,\@valtotal
# Input: None
# Output: HTML code for awgraphapplet insertion
# Return: 0 OK, 1 Error
#-------------------------------------------------------
sub ShowGraph_graphapplet() {
my $title=shift;
my $type=shift;
my $showmonthstats=shift;
my $blocklabel=shift;
my $vallabel=shift;
my $valcolor=shift;
my $valmax=shift;
my $valtotal=shift;
my $valaverage=shift;
my $valdata=shift;
my $graphwidth=780;
my $graphheight=400;
my $blockspacing=5;
my $valspacing=1;
my $valwidth=5;
my $barsize=0;
my $blockfontsize=11;
if ($type eq 'month') { $graphwidth=540; $graphheight=160; $blockspacing=8; $valspacing=0; $valwidth=6; $barsize=$BarHeight; $blockfontsize=11; }
elsif ($type eq 'daysofmonth') { $graphwidth=640; $graphheight=160; $blockspacing=3; $valspacing=0; $valwidth=4; $barsize=$BarHeight; $blockfontsize=9; }
elsif ($type eq 'daysofweek') { $graphwidth=300; $graphheight=160; $blockspacing=10; $valspacing=0; $valwidth=6; $barsize=$BarHeight; $blockfontsize=10; }
elsif ($type eq 'hours') { $graphwidth=600; $graphheight=160; $blockspacing=4; $valspacing=0; $valwidth=6; $barsize=$BarHeight; $blockfontsize=11; }
else { debug("Unknown type parameter in ShowGraph_graphapplet function: $type", 1); return 0; }
# print "