5.2
+- Added urlalias plugin to replace URL values in URL reports by a text.
- Added geoip plugin to track countries from IP location instead of domain
value.
- Support for postfix mail log.
# Plugin files must be .pm files stored in 'plugins' directory.
# Uncomment LoadPlugin lines to enable a plugin after checking that perl
# modules required by the plugin are installed.
-#
# Plugin: HashFiles
# Perl modules required: Storable
#
#LoadPlugin="geoip"
+# Plugin: UrlAliases
+# Perl modules required: None
+# Show a text in all URL reports instead of URL value.
+# A text files called urlalias.txt, with two fields (first is URL, second is
+# text to show) separated by a tab char. must be created in plugin directory.
+#
+#LoadPlugin="urlalias"
+
# Plugin: Graph3D
# Perl modules required: Graph3D
# Some reported charts are nice 3D graphics.
$MAXDIFFEXTRA=500;
$WIDTHCOLICON=32;
# Plugins variable
-use vars qw/ %PluginsLoaded /;
+use vars qw/ %PluginsLoaded $PluginDir /;
%PluginsLoaded=();
+$PluginDir='';
# Running variables
use vars qw/
$DIR $PROG $Extension
#tie %_host_p, 'Tie::StdHash';
#tie %TmpOS, 'Tie::Cache::LRU';
-# Those addresses are shown with those lib (First column is full exact relative URL, second column is text to show instead of URL)
-use vars qw/ %Aliases /;
-%Aliases = (
- '/', '<b>HOME PAGE</b>',
- '/cgi-bin/awstats.pl', '<b>AWStats stats page</b>',
- '/cgi-bin/awstats/awstats.pl', '<b>AWStats stats page</b>',
- # Following the same example, you can put here HTML text you want to see in links instead of URL text.
-# '/YourRelativeUrl', '<b>Your HTML text</b>'
- );
-
-
# PROTOCOL CODES
# HTTP codes
if ($EnableLockForUpdate !~ /[0-1]/) { $EnableLockForUpdate=0; }
if (! $DNSStaticCacheFile) { $DNSStaticCacheFile="dnscache.txt"; }
if (! $DNSLastUpdateCacheFile) { $DNSLastUpdateCacheFile="dnscachelastupdate.txt"; }
+ if ($DNSStaticCacheFile eq $DNSLastUpdateCacheFile) { error("Error: DNSStaticCacheFile and DNSLastUpdateCacheFile must have different values."); }
if ($AllowAccessFromWebToAuthenticatedUsersOnly !~ /[0-1]/) { $AllowAccessFromWebToAuthenticatedUsersOnly=0; }
if ($CreateDirDataIfNotExists !~ /[0-1]/) { $CreateDirDataIfNotExists=0; }
if ($SaveDatabaseFilesWithPermissionsForEveryone !~ /[0-1]/) { $SaveDatabaseFilesWithPermissionsForEveryone=1; }
if ($searchdir && (!($searchdir =~ /\/$/)) && (!($searchdir =~ /\\$/)) ) { $searchdir .= "/"; }
my $pluginpath="${searchdir}${pluginfile}.pm";
if (-s "$pluginpath") {
+ $PluginDir="${searchdir}"; # Set plugin dir
if ($Debug) { debug(" Try to init plugin '$pluginname' ($pluginpath) with param '$pluginparam'",1); }
my $loadret=require "$pluginpath";
if (! $loadret || $loadret =~ /^error/i) {
#--------------------------------------------------------------------
sub ShowURL() {
my $url=shift;
- my $nompage=$Aliases{$url}?$Aliases{$url}:CleanFromCSSA($url);
+ my $nompage=CleanFromCSSA($url);
+
+ # Call to plugin function ReplaceURL
+ foreach my $pluginname (keys %{$PluginsLoaded{'ReplaceURL'}}) {
+ my $function="ReplaceURL_$pluginname('$url')";
+ eval("$function");
+ }
+
if (length($nompage)>$MaxLengthOfURL) { $nompage=substr($nompage,0,$MaxLengthOfURL)."..."; }
if ($ShowLinksOnUrl) {
my $newkey=CleanFromCSSA($url);
--- /dev/null
+#!/usr/bin/perl
+#-----------------------------------------------------------------------------
+# UrlAlias AWStats plugin
+# This plugin allow you to report all URL links with a text title instead of
+# URL value.
+# You must create a file called urlalias.cnfigvalue.txt and store it in
+# plugin directory that contains 2 columns separated by a tab char.
+# First column is URL value and second column is text title to use instead of.
+#-----------------------------------------------------------------------------
+# Perl Required Modules: None
+#-----------------------------------------------------------------------------
+# $Revision$ - $Author$ - $Date$
+
+
+# <-----
+# 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
+# SHOULD BE AT LEAST 5.1
+my $PluginNeedAWStatsVersion="5.2";
+# ----->
+
+# <-----
+# THIS VARIABLE MUST CONTAINS THE NAME OF ALL FUNCTIONS THAT MANAGE THE PLUGIN
+my $PluginHooksFunctions="ReplaceURL";
+# ----->
+
+# <-----
+# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE
+use vars qw/
+$urlaliasloaded
+%UrlAliases
+/;
+# ----->
+
+
+
+#-----------------------------------------------------------------------------
+# PLUGIN FUNTION Init_pluginname
+#-----------------------------------------------------------------------------
+sub Init_urlalias {
+ my $InitParams=shift;
+ my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
+
+ # <-----
+ # YOU CAN ENTER HERE CODE TO INIT PLUGIN GLOBAL VARIABLES
+ debug("InitParams=$InitParams",1);
+ $urlaliasloaded=0;
+ %UrlAliases=();
+ # ----->
+ return ($checkversion?$checkversion:"$PluginHooksFunctions");
+}
+
+
+
+#-----------------------------------------------------------------------------
+# PLUGIN FUNTION GetCountryCodeByName_pluginname
+# UNIQUE: YES (Only one function GetCountryName can exists for all loaded plugins)
+# GetCountryName is called to translate a host name or ip to a country name.
+#-----------------------------------------------------------------------------
+sub ReplaceURL_urlalias {
+ # <-----
+ if (! $urlaliasloaded) {
+ my $filetoload="$PluginDir/urlalias.txt";
+ # Load urlalias file
+ open(URLALIASFILE,"$filetoload") or error("Error: Couldn't open UrlAlias file \"$filetoload\": $!");
+ # This is the fastest way to load with regexp that I know
+ %UrlAliases = map(/^([^\s]+)\s+([^\s]+)$/o,<URLALIASFILE>);
+ close URLALIASFILE;
+ debug("UrlAlias file loaded: ".(scalar keys %UrlAliases)." aliases found.");
+ $urlaliasloaded=1;
+ }
+ my $urltoreplace="$_[0]";
+ if ($UrlAliases{$urltoreplace}) { print "<font style=\"color: #$color_link; font-weight: bold\">$UrlAliases{$urltoreplace}</font><br>"; }
+ else { print ""; }
+ return 1;
+ # ----->
+}
+
+
+1; # Do not remove this line