# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
my $PluginNeedAWStatsVersion="5.4";
-my $PluginHooksFunctions="GetCountryCodeByAddr GetCountryCodeByName";
+my $PluginHooksFunctions="GetCountryCodeByAddr GetCountryCodeByName ShowInfoHost";
# ----->
# <-----
}
+#-----------------------------------------------------------------------------
+# 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 "<TD>This is a new cell for $param</TD>";
+# Parameters: Host name or ip
+#-----------------------------------------------------------------------------
+sub ShowInfoHost_geoip {
+ 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 =~ tr/&/&/s; $NewLinkParams =~ s/^&//; $NewLinkParams =~ s/&$//;
+ if ($NewLinkParams) { $NewLinkParams="${NewLinkParams}&"; }
+
+ print "<th width=\"80\">";
+ print "<a href=\"#countries\">GeoIP<br>Country</a>";
+ print "</th>";
+ }
+ 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 "<td>";
+ if ($key && $ip==4) {
+ my $res=lc($gi->country_code_by_addr($param)) if $gi;
+ if ($Debug) { debug(" Plugin geoip: GetCountryByIp for $param: [$res]",5); }
+ if ($res) { print $DomainsHashIDLib{$res}; }
+ else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
+ }
+ if ($key && $ip==6) {
+ print "<span style=\"color: #$color_other\">$Message[0]</span>";
+ }
+ if (! $key) {
+ my $res=lc($gi->country_code_by_addr($param)) if $gi;
+ if ($Debug) { debug(" Plugin geoip: GetCountryByHostname for $param: [$res]",5); }
+ if ($res) { print $DomainsHashIDLib{$res}; }
+ else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
+ }
+ print "</td>";
+ }
+ else {
+ print "<td> </td>";
+ }
+ return 1;
+ # ----->
+}
+
+
1; # Do not remove this line
%_isp_k
%_isp_l
$MAXNBOFSECTIONGIR
+$MAXLENGTH
/;
# ----->
my $InitParams=shift;
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
$MAXNBOFSECTIONGIR=10;
+ $MAXLENGTH=20;
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
if ($key && $ip==4) {
my $isp=$geoip_isp_maxmind->org_by_addr($param) if $geoip_isp_maxmind;
if ($Debug) { debug(" Plugin geoip_isp_maxmind: GetIspByIp for $param: [$isp]",5); }
- if ($isp) { print "$isp"; }
+ if ($isp) {
+ if (length($isp) <= $MAXLENGTH) {
+ print "$isp";
+ }
+ else {
+ print substr($isp,0,$MAXLENGTH).'...';
+ }
+ }
else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
}
if ($key && $ip==6) {
if (! $key) {
my $isp=$geoip_isp_maxmind->org_by_name($param) if $geoip_isp_maxmind;
if ($Debug) { debug(" Plugin geoip_isp_maxmind: GetIspByHostname for $param: [$isp]",5); }
- if ($isp) { print "$isp"; }
+ if ($isp) {
+ if (length($isp) <= $MAXLENGTH) {
+ print "$isp";
+ }
+ else {
+ print substr($isp,0,$MAXLENGTH).'...';
+ }
+ }
else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
}
print "</td>";
%_org_k
%_org_l
$MAXNBOFSECTIONGIR
+$MAXLENGTH
/;
# ----->
my $InitParams=shift;
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
$MAXNBOFSECTIONGIR=10;
+ $MAXLENGTH=20;
# <-----
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
if ($key && $ip==4) {
my $org=$geoip_org_maxmind->org_by_addr($param) if $geoip_org_maxmind;
if ($Debug) { debug(" Plugin geoip_org_maxmind: GetOrgByIp for $param: [$org]",5); }
- if ($org) { print "$org"; }
+ if ($org) {
+ if (length($org) <= $MAXLENGTH) {
+ print "$org";
+ }
+ else {
+ print substr($org,0,$MAXLENGTH).'...';
+ }
+ }
else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
}
if ($key && $ip==6) {
if (! $key) {
my $org=$geoip_org_maxmind->org_by_name($param) if $geoip_org_maxmind;
if ($Debug) { debug(" Plugin geoip_org_maxmind: GetOrgByHostname for $param: [$org]",5); }
- if ($org) { print "$org"; }
+ if ($org) {
+ if (length($org) <= $MAXLENGTH) {
+ print "$org";
+ }
+ else {
+ print substr($org,0,$MAXLENGTH).'...';
+ }
+ }
else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
}
print "</td>";
my ($res1,$res2,$countryregion)=();
($res1,$res2)=$geoip_region_maxmind->region_by_name($param) if $geoip_region_maxmind;
if ($Debug) { debug(" Plugin geoip_region_maxmind: GetRegionByIp for $param: [${res1}_${res2}]",5); }
- if ($res1 =~ /\w\w/) { print $DomainsHashIDLib{lc($res1)}||uc($res1); }
- else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
- if ($res1 =~ /\w\w/ && $res2 =~ /\w\w/) {
- print " (";
- print $region{lc($res1)}{uc($res2)};
- print ")";
+ if (! $PluginsLoaded{'init'}{'geoip'}) {
+ # Show country
+ if ($res1 =~ /\w\w/) { print $DomainsHashIDLib{lc($res1)}||uc($res1); }
+ else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
+ # Show region
+ if ($res1 =~ /\w\w/ && $res2 =~ /\w\w/) {
+ print " (";
+ print $region{lc($res1)}{uc($res2)};
+ print ")";
+ }
+ }
+ else {
+ if ($res1 =~ /\w\w/ && $res2 =~ /\w\w/) {
+ print $region{lc($res1)}{uc($res2)};
+ }
+ else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
}
}
if ($key && $ip==6) {
my ($res1,$res2,$countryregion)=();
($res1,$res2)=$geoip_region_maxmind->region_by_name($param) if $geoip_region_maxmind;
if ($Debug) { debug(" Plugin geoip_region_maxmind: GetRegionByName for $param: [${res1}_${res2}]",5); }
- if ($res1 =~ /\w\w/) { print $DomainsHashIDLib{lc($res1)}||uc($res1); }
- else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
- if ($res1 =~ /\w\w/ && $res2 =~ /\w\w/) {
- print " (";
- print $region{lc($res1)}{uc($res2)};
- print ")";
+ if (! $PluginsLoaded{'init'}{'geoip'}) {
+ # Show country
+ if ($res1 =~ /\w\w/) { print $DomainsHashIDLib{lc($res1)}||uc($res1); }
+ else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
+ # Show region
+ if ($res1 =~ /\w\w/ && $res2 =~ /\w\w/) {
+ print " (";
+ print $region{lc($res1)}{uc($res2)};
+ print ")";
+ }
+ }
+ else {
+ if ($res1 =~ /\w\w/ && $res2 =~ /\w\w/) {
+ print $region{lc($res1)}{uc($res2)};
+ }
+ else { print "<span style=\"color: #$color_other\">$Message[0]</span>"; }
}
}
print "</td>";
#!/usr/bin/perl
#-----------------------------------------------------------------------------
# HostInfo AWStats plugin
-# This plugin allow you to add information on hosts, like a whois fields.
+# This plugin allow you to add information on hosts, like whois fields.
#-----------------------------------------------------------------------------
# Perl Required Modules: XWhois
#-----------------------------------------------------------------------------
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
push @INC, "${DIR}/plugins";
if (!eval ('require "Net/XWhois.pm";')) { return $@?"Error: $@":"Error: Need Perl module Net::XWhois"; }
+if (!eval ('require "Digest/MD5.pm";')) { return $@?"Error: $@":"Error: Need Perl module Digest::MD5"; }
# ----->
use strict;no strict "refs";
function neww(a,b) {
var wfeatures="directories=0,menubar=1,status=0,resizable=1,scrollbars=1,toolbar=0,width=$WIDTHINFO,height=$HEIGHTINFO,left=" + eval("(screen.width - $WIDTHINFO)/2") + ",top=" + eval("(screen.height - $HEIGHTINFO)/2");
EOF
- print "if (b==1) { fen=window.open('".XMLEncode("$AWScript?$urlparam&host")."='+a,'whois',wfeatures); }\n";
- print "if (b==2) { fen=window.open('".XMLEncode("$AWScript?$urlparam&host")."='+a,'whois',wfeatures); }\n";
+ print "fen=window.open('".XMLEncode("$AWScript?$urlparam&host")."='+a+'&key='+b,'whois',wfeatures);\n";
print <<EOF;
}
</script>
}
elsif ($param) {
my $keyforwhois;
- my $linkforwhois;
if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
$keyforwhois=$param;
- $linkforwhois=2;
}
- elsif ($param =~ /^[0-9A-F]*:/i) { # IPv6 address
+ elsif ($param =~ /^[0-9A-F]*:/i) { # IPv6 address
$keyforwhois=$param;
- $linkforwhois=2;
}
else { # Hostname
$param =~ /([-\w]+\.[-\w]+\.(?:au|uk|jp|nz))$/ or $param =~ /([-\w]+\.[-\w]+)$/;
$keyforwhois=$1;
- $linkforwhois=1;
}
print "<td>";
- if ($keyforwhois && $linkforwhois) { print "<a href=\"javascript:neww('$keyforwhois',$linkforwhois)\">?</a>"; }
+# if ($keyforwhois) { print "<a href=\"javascript:neww('$keyforwhois','".md5_hex("${keyforwhois}XXX")."')\">?</a>"; }
+ if ($keyforwhois) { print "<a href=\"javascript:neww('$keyforwhois','${keyforwhois}XXX')\">?</a>"; }
else { print " " }
print "</td>";
}