From: eldy <> Date: Sat, 26 Apr 2003 19:26:38 +0000 (+0000) Subject: Added 'userinfo' plugin to add information from a text file (like lastname, office... X-Git-Tag: AWSTATS_5_5_BETA~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9c20c96a15bb746d607f97bd885bf84a60ef424;p=thirdparty%2FAWStats.git Added 'userinfo' plugin to add information from a text file (like lastname, office department,...) in authenticated user chart. --- diff --git a/docs/awstats_changelog.txt b/docs/awstats_changelog.txt index fd09f0bf..c98c2f00 100644 --- a/docs/awstats_changelog.txt +++ b/docs/awstats_changelog.txt @@ -15,31 +15,33 @@ Fixes: New features/improvments: - Added a 'Screen Size' report. - Group OS by families. Added a detailed OS version chart. -- Better 404 errors management. URLs are always cleaned from their - parameter to build '404 not found' URLs list (because parameters are not - interesting as they can't have effect as page is not found). Referrer - URLs list for '404 not found' URLs are kept with parameters only if - URLReferrerWithQuery is set to 1. This make this report more useful. +- Better 404 errors management. URLs are always cleaned from their parameter + to build '404 not found' URLs list (because parameters are not interesting + as they can't have effect as page is not found). Referrer URLs list for '404 + not found' URLs are kept with parameters only if URLReferrerWithQuery is set + to 1. This make this report more useful. - Added 'geoipfree' plugin (same than 'geoip' plugin but using the free Perl module Geo::IPfree). -- 'geoip' plugin can works with Perl module Geo::IP but also with Perl - module Geo::IP::PurePerl). +- 'geoip' plugin can works with Perl module Geo::IP but also with Perl module + Geo::IP::PurePerl). +- Added 'userinfo' plugin to add information from a text file (like lastname, + office department,...) in authenticated user chart. - month parameter can accept format -month=D, not only -month=DD - Optimized code size. - Optimized HTML output report size. - Added plugin ipv6 to fully support IPv6 (included reverse DNS lookup). -- Split month summary chart and days of month chart in two different - charts in main page. This also means that ShowDaysOfMonthStats and +- Split month summary chart and days of month chart in two different charts in + main page. This also means that ShowDaysOfMonthStats and AddDataArrayShowDaysOfMonthStats parameters were added. - Added -staticlinksext to build static pages with another extension than default .html Other/Documentation: - Added Isle of Man, Monserat, and Palestinian flag icon. -- Added "local network host" and "Satellite access host" in label of - possible countries and icons (They appears when using geoip plugins). -- Better management of parsed lines counting. The last line number is - also stored in history file, for a future use. +- Added "local network host" and "Satellite access host" in label of possible + countries and icons (They appears when using geoip plugins). +- Better management of parsed lines counting. The last line number is also + stored in history file, for a future use. - Removed LogFormat=5 option for ISA log file because I am fed up of supporting bugged and non standard MS products. Sorry but this takes me too many times. To use AWStats with an ISA server, just use now a preprocessor diff --git a/wwwroot/cgi-bin/awstats.model.conf b/wwwroot/cgi-bin/awstats.model.conf index 0124e063..b5769d6a 100644 --- a/wwwroot/cgi-bin/awstats.model.conf +++ b/wwwroot/cgi-bin/awstats.model.conf @@ -1043,27 +1043,14 @@ color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2 # #LoadPlugin="tooltips" -# Plugin: HashFiles -# Perl modules required: Storable -# AWStats DNS cache files are read/saved as native hash files. This increase -# DNS cache files loading speed, above all for very large web sites. -# -#LoadPlugin="hashfiles" - -# Plugin: TimeHiRes -# Perl modules required: Time::HiRes -# Time reported by -showsteps option is in millisecond. For debug purpose. -# -#LoadPlugin="timehires" - -# Plugin: TimeZone -# Perl modules required: Time::Local -# Allow AWStats to correct a bad timezone for user of some IIS that use -# GMT date in its log instead of local server time. -# This module is useless for Apache and most IIS version. -# This plugin reduces AWStats speed of 40% !!!!!!! +# Plugin: IPv6 +# Perl modules required: Net::IP and Net::DNS +# This plugin gives AWStats capability to make reverse DNS lookup on IPv6 +# addresses. +# Note: If you are interesting in having country report, you should use the +# geoipfree (or geoip) plugin instead of enabled reverse DNS lookup. # -#LoadPlugin="timezone +2" +#LoadPlugin="ipv6" # Plugin: GeoIPfree # Perl modules required: Geo::IPfree version 0.2+ (from Graciliano M.P.) @@ -1094,6 +1081,38 @@ color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2 # #LoadPlugin="urlalias" +# Plugin: UserInfo +# Perl modules required: None +# Add a text (Firtname, Lastname, Office Department, ...) in authenticated user +# reports for each login value. +# A text file called userinfo.myconfig.txt, with two fields (first is login, +# second is text to show) separated by a tab char. must be created in plugins +# directory. +# +LoadPlugin="userinfo" + +# Plugin: HashFiles +# Perl modules required: Storable +# AWStats DNS cache files are read/saved as native hash files. This increase +# DNS cache files loading speed, above all for very large web sites. +# +#LoadPlugin="hashfiles" + +# Plugin: TimeHiRes +# Perl modules required: Time::HiRes +# Time reported by -showsteps option is in millisecond. For debug purpose. +# +#LoadPlugin="timehires" + +# Plugin: TimeZone +# Perl modules required: Time::Local +# Allow AWStats to correct a bad timezone for user of some IIS that use +# GMT date in its log instead of local server time. +# This module is useless for Apache and most IIS version. +# This plugin reduces AWStats speed of 40% !!!!!!! +# +#LoadPlugin="timezone +2" + # Plugin: Graph3D # Perl modules required: None # Supported charts are built by a nice 3D graphic applet. diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 33367c0f..158bc27a 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -3523,8 +3523,7 @@ sub Save_History { # Output: None # Return: 1 Ok, 0 at least one error (tmp files are removed) #-------------------------------------------------------------------- -sub Rename_All_Tmp_History() -{ +sub Rename_All_Tmp_History { my $pid=$$; my $renameok=1; @@ -3746,8 +3745,7 @@ sub ChangeWordSeparatorsIntoSpace { #------------------------------------------------------------------------------ # Function: Converts an UTF8 binary string #------------------------------------------------------------------------------ -sub Utf8_To_Ascii -{ +sub Utf8_To_Ascii { my $string = shift; my $format = $ENV{"UCFORMAT"}||('%lx'); $string =~ s/([\xC0-\xDF])([\x80-\xBF])/sprintf ("%c", hex(sprintf($format,unpack("c",$1)<<6&0x07C0|unpack("c",$2)&0x003F)))/ge; @@ -3759,8 +3757,7 @@ sub Utf8_To_Ascii #-------------------------------------------------------------------- # Function: Encode a binary string into a non binary string #-------------------------------------------------------------------- -sub EncodeString -{ +sub EncodeString { my $string = shift; # use bytes; $string =~ s/([\x2B\x80-\xFF])/sprintf ("%%%2x", ord($1))/eg; @@ -3905,36 +3902,6 @@ sub Format_Date { return "$dateformat"; } -#-------------------------------------------------------------------- -# Function: Write a HTML cell with a WhoIs link to parameter -# Parameters: Key to used as WhoIs target -# Input: $LinksToWhoIs $LinksToIPWhoIs -# Output: None -# Return: None -#-------------------------------------------------------------------- -sub ShowWhoIsCell { - my $keyurl=shift; - my $keyforwhois; - my $linkforwhois; - if ($keyurl =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address - $keyforwhois=$keyurl; - $linkforwhois=2; - } - elsif ($keyurl =~ /^[0-9A-F]*:/i) { # IPv6 address - $keyforwhois=$keyurl; - $linkforwhois=2; - } - else { # Hostname - $keyurl =~ /([-\w]+\.[-\w]+\.(au|uk|jp|nz))$/ or $keyurl =~ /([-\w]+\.[-\w]+)$/; - $keyforwhois=$1; - $linkforwhois=1; - } - print ""; - if ($keyforwhois && $linkforwhois) { print "?"; } - else { print " " } - print ""; -} - #-------------------------------------------------------------------- # Function: Return 1 if string contains only ascii chars # Parameters: string @@ -4140,7 +4107,7 @@ sub SigHandler { # Output: None # Return: Int #-------------------------------------------------------------------- -sub Convert_IP_To_Decimal() { +sub Convert_IP_To_Decimal { my ($IPAddress) = @_; my @ip_seg_arr = split(/\./,$IPAddress); my $decimal_ip_address = 256 * 256 *256 * $ip_seg_arr[0] + 256 * 256 * $ip_seg_arr[1] + 256 * $ip_seg_arr[2] + $ip_seg_arr[3]; @@ -4154,7 +4121,7 @@ sub Convert_IP_To_Decimal() { # Output: None # Return: 1 There is at least one not null value, 0 else #-------------------------------------------------------------------- -sub AtLeastOneNotNull() { +sub AtLeastOneNotNull { debug(" Call to AtLeastOneNotNull (".join('-',@_).")",3); foreach my $val (@_) { if ($val) { return 1; } } return 0; @@ -4167,7 +4134,7 @@ sub AtLeastOneNotNull() { # Output: HTML Form # Return: None #-------------------------------------------------------------------- -sub ShowFormFilter() { +sub ShowFormFilter { my $fieldfiltername=shift; my $fieldfiltervalue=shift; if (! $StaticLinks) { @@ -4196,19 +4163,51 @@ sub ShowFormFilter() { } #-------------------------------------------------------------------- -# Function: Write URL with HTML link or not +# Function: Write Host info +# Parameters: Key to used as WhoIs target +# Input: $ShowLinksToWhoIs +# Output: None +# Return: None +#-------------------------------------------------------------------- +sub ShowHostInfo { + if ($ShowLinksToWhoIs) { + my $keyurl=shift; + my $keyforwhois; + my $linkforwhois; + if ($keyurl =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address + $keyforwhois=$keyurl; + $linkforwhois=2; + } + elsif ($keyurl =~ /^[0-9A-F]*:/i) { # IPv6 address + $keyforwhois=$keyurl; + $linkforwhois=2; + } + else { # Hostname + $keyurl =~ /([-\w]+\.[-\w]+\.(au|uk|jp|nz))$/ or $keyurl =~ /([-\w]+\.[-\w]+)$/; + $keyforwhois=$1; + $linkforwhois=1; + } + print ""; + if ($keyforwhois && $linkforwhois) { print "?"; } + else { print " " } + print ""; + } +} + +#-------------------------------------------------------------------- +# Function: Write URL info (with plugins info) # Parameters: $url # Input: %Aliases $MaxLengthOfURL $ShowLinksOnUrl $SiteDomain $UseHTTPSLinkForUrl # Output: URL link # Return: None #-------------------------------------------------------------------- -sub ShowURL() { +sub ShowURLInfo { my $url=shift; my $nompage=CleanFromCSSA($url); - # Call to plugins' function ReplaceURL - foreach my $pluginname (keys %{$PluginsLoaded{'ReplaceURL'}}) { - my $function="ReplaceURL_$pluginname('$url')"; + # Call to plugins' function ShowInfoURL + foreach my $pluginname (keys %{$PluginsLoaded{'ShowInfoURL'}}) { + my $function="ShowInfoURL_$pluginname('$url')"; eval("$function"); } @@ -4234,6 +4233,22 @@ sub ShowURL() { } } +#-------------------------------------------------------------------- +# Function: Write other user info +# Parameters: $user +# Input: %Aliases $MaxLengthOfURL $ShowLinksOnUrl $SiteDomain $UseHTTPSLinkForUrl +# Output: URL link +# Return: None +#-------------------------------------------------------------------- +sub ShowUserInfo { + my $user=shift; + # Call to plugins' function ShowInfoUser + foreach my $pluginname (keys %{$PluginsLoaded{'ShowInfoUser'}}) { + my $function="ShowInfoUser_$pluginname('$user')"; + eval("$function"); + } +} + #-------------------------------------------------------------------- # Function: Define value for PerlParsingFormat (used for regex log record parsing) # Parameters: - @@ -4241,7 +4256,7 @@ sub ShowURL() { # Output: @fieldlib # Return: - #-------------------------------------------------------------------- -sub DefinePerlParsingFormat() { +sub DefinePerlParsingFormat { # Log records examples: # Apache combined: 62.161.78.73 user - [dd/mmm/yyyy:hh:mm:ss +0000] "GET / HTTP/1.1" 200 1234 "http://www.from.com/from.htm" "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" # Apache combined (408 error): my.domain.com - user [09/Jan/2001:11:38:51 -0600] "OPTIONS /mime-tmp/xxx file.doc HTTP/1.1" 408 - "-" "-" @@ -6687,7 +6702,7 @@ if (scalar keys %HTMLOutput) { foreach my $key (@keylist) { my $host=CleanFromCSSA($key); print "".($_robot_l{$key}?'':'')."$host".($_robot_l{$key}?'':'').""; - if ($ShowLinksToWhoIs && $LinksToWhoIs) { ShowWhoIsCell($key); } + ShowHostInfo($key); if ($ShowHostsStats =~ /P/i) { print "".($_host_p{$key}?$_host_p{$key}:" ").""; } if ($ShowHostsStats =~ /H/i) { print "$_host_h{$key}"; } if ($ShowHostsStats =~ /B/i) { print "".Format_Bytes($_host_k{$key}).""; } @@ -6703,7 +6718,7 @@ if (scalar keys %HTMLOutput) { $rest_k=$TotalBytes-$total_k; if ($rest_p > 0 || $rest_h > 0 || $rest_k > 0) { # All other visitors (known or not) print "$Message[2]"; - if ($ShowLinksToWhoIs && $LinksToWhoIs) { ShowWhoIsCell(''); } + ShowHostInfo(''); if ($ShowHostsStats =~ /P/i) { print "".($rest_p?$rest_p:" ").""; } if ($ShowHostsStats =~ /H/i) { print "$rest_h"; } if ($ShowHostsStats =~ /B/i) { print "".Format_Bytes($rest_k).""; } @@ -6729,7 +6744,7 @@ if (scalar keys %HTMLOutput) { foreach my $key (@keylist) { my $host=CleanFromCSSA($key); print "$host"; - if ($ShowLinksToWhoIs && $LinksToWhoIs) { ShowWhoIsCell($key); } + ShowHostInfo($key); if ($ShowHostsStats =~ /P/i) { print "".($_host_p{$key}?$_host_p{$key}:" ").""; } if ($ShowHostsStats =~ /H/i) { print "$_host_h{$key}"; } if ($ShowHostsStats =~ /B/i) { print "".Format_Bytes($_host_k{$key}).""; } @@ -6746,7 +6761,7 @@ if (scalar keys %HTMLOutput) { $rest_k=$TotalBytes-$total_k; if ($rest_p > 0 || $rest_h > 0 || $rest_k > 0) { # All other visitors (known or not) print "$Message[82]"; - if ($ShowLinksToWhoIs && $LinksToWhoIs) { ShowWhoIsCell(''); } + ShowHostInfo(''); if ($ShowHostsStats =~ /P/i) { print "".($rest_p?$rest_p:" ").""; } if ($ShowHostsStats =~ /H/i) { print "$rest_h"; } if ($ShowHostsStats =~ /B/i) { print "".Format_Bytes($rest_k).""; } @@ -6859,6 +6874,7 @@ if (scalar keys %HTMLOutput) { if ($HTMLOutput{'lastlogins'}) { $title.="$Message[9]"; } &tab_head("$title",19); print "$Message[94] : ".(scalar keys %_login_h).""; + ShowUserInfo(''); if ($ShowAuthenticatedUsers =~ /P/i) { print "$Message[56]"; } if ($ShowAuthenticatedUsers =~ /H/i) { print "$Message[57]"; } if ($ShowAuthenticatedUsers =~ /B/i) { print "$Message[75]"; } @@ -6870,6 +6886,7 @@ if (scalar keys %HTMLOutput) { if ($HTMLOutput{'lastlogins'}) { &BuildKeyList($MaxRowsInHTMLOutput,$MinHit{'Host'},\%_login_h,\%_login_l); } foreach my $key (@keylist) { print "$key"; + ShowUserInfo($key); if ($ShowAuthenticatedUsers =~ /P/i) { print "".($_login_p{$key}?$_login_p{$key}:" ").""; } if ($ShowAuthenticatedUsers =~ /H/i) { print "$_login_h{$key}"; } if ($ShowAuthenticatedUsers =~ /B/i) { print "".Format_Bytes($_login_k{$key}).""; } @@ -6886,6 +6903,7 @@ if (scalar keys %HTMLOutput) { $rest_k=$TotalBytes-$total_k; if ($rest_p > 0 || $rest_h > 0 || $rest_k > 0) { # All other logins and/or anonymous print "$Message[125]"; + ShowUserInfo(''); if ($ShowAuthenticatedUsers =~ /P/i) { print "".($rest_p?$rest_p:" ").""; } if ($ShowAuthenticatedUsers =~ /H/i) { print "$rest_h"; } if ($ShowAuthenticatedUsers =~ /B/i) { print "".Format_Bytes($rest_k).""; } @@ -6985,7 +7003,7 @@ if (scalar keys %HTMLOutput) { } foreach my $key (@keylist) { print ""; - &ShowURL($key); + &ShowURLInfo($key); print ""; my $bredde_p=0; my $bredde_e=0; my $bredde_x=0; my $bredde_k=0; if ($max_p > 0) { $bredde_p=int($BarWidth*($_url_p{$key}||0)/$max_p)+1; } @@ -7308,7 +7326,7 @@ if (scalar keys %HTMLOutput) { if ($TotalRefererPages) { $p_p=int($_pagesrefs_p{$key}/$TotalRefererPages*1000)/10; } if ($TotalRefererHits) { $p_h=int($_pagesrefs_h{$key}/$TotalRefererHits*1000)/10; } print ""; - &ShowURL($key); + &ShowURLInfo($key); print ""; print "".($_pagesrefs_p{$key}?$_pagesrefs_p{$key}:' ')."".($_pagesrefs_p{$key}?"$p_p %":' ').""; print "".($_pagesrefs_h{$key}?$_pagesrefs_h{$key}:' ')."".($_pagesrefs_h{$key}?"$p_h %":' ').""; @@ -8000,7 +8018,7 @@ if (scalar keys %HTMLOutput) { foreach my $key (@keylist) { print ""; print "$key"; - if ($ShowLinksToWhoIs && $LinksToWhoIs) { ShowWhoIsCell($key); } + ShowHostInfo($key); if ($ShowHostsStats =~ /P/i) { print "".($_host_p{$key}||" ").""; } if ($ShowHostsStats =~ /H/i) { print "$_host_h{$key}"; } if ($ShowHostsStats =~ /B/i) { print "".Format_Bytes($_host_k{$key}).""; } @@ -8132,6 +8150,7 @@ if (scalar keys %HTMLOutput) { if ($ShowAuthenticatedUsers =~ /L/i) { $title.="   -   $Message[9]"; } &tab_head("$title",19); print "$Message[94] : ".(scalar keys %_login_h).""; + ShowUserInfo(''); if ($ShowAuthenticatedUsers =~ /P/i) { print "$Message[56]"; } if ($ShowAuthenticatedUsers =~ /H/i) { print "$Message[57]"; } if ($ShowAuthenticatedUsers =~ /B/i) { print "$Message[75]"; } @@ -8148,6 +8167,7 @@ if (scalar keys %HTMLOutput) { if ($max_h > 0) { $bredde_h=int($BarWidth*$_login_h{$key}/$max_h)+1; } if ($max_k > 0) { $bredde_k=int($BarWidth*$_login_k{$key}/$max_k)+1; } print "$key"; + ShowUserInfo($key); if ($ShowAuthenticatedUsers =~ /P/i) { print "".($_login_p{$key}?$_login_p{$key}:" ").""; } if ($ShowAuthenticatedUsers =~ /H/i) { print "$_login_h{$key}"; } if ($ShowAuthenticatedUsers =~ /B/i) { print "".Format_Bytes($_login_k{$key}).""; } @@ -8168,6 +8188,7 @@ if (scalar keys %HTMLOutput) { $rest_k=$TotalBytes-$total_k; if ($rest_p > 0 || $rest_h > 0 || $rest_k > 0) { # All other logins print "$Message[125]"; + ShowUserInfo(''); if ($ShowAuthenticatedUsers =~ /P/i) { print "".($rest_p?$rest_p:" ").""; } if ($ShowAuthenticatedUsers =~ /H/i) { print "$rest_h"; } if ($ShowAuthenticatedUsers =~ /B/i) { print "".Format_Bytes($rest_k).""; } @@ -8339,7 +8360,7 @@ if (scalar keys %HTMLOutput) { } foreach my $key (@keylist) { print ""; - &ShowURL($key); + &ShowURLInfo($key); print ""; my $bredde_p=0; my $bredde_e=0; my $bredde_x=0; my $bredde_k=0; if ($max_p > 0) { $bredde_p=int($BarWidth*($_url_p{$key}||0)/$max_p)+1; } @@ -8586,7 +8607,7 @@ if (scalar keys %HTMLOutput) { &BuildKeyList($MaxNbOf{'RefererShown'},$MinHit{'Refer'},\%_pagesrefs_h,\%_pagesrefs_p); foreach my $key (@keylist) { print "- "; - &ShowURL($key); + &ShowURLInfo($key); print ""; print "".($_pagesrefs_p{$key}?$_pagesrefs_p{$key}:'0').""; print "$_pagesrefs_h{$key}"; diff --git a/wwwroot/cgi-bin/plugins/urlalias.pm b/wwwroot/cgi-bin/plugins/urlalias.pm index d9c210ff..bf3aa166 100644 --- a/wwwroot/cgi-bin/plugins/urlalias.pm +++ b/wwwroot/cgi-bin/plugins/urlalias.pm @@ -25,15 +25,15 @@ use strict;no strict "refs"; # <----- # ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN # AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE. -my $PluginNeedAWStatsVersion="5.2"; -my $PluginHooksFunctions="ReplaceURL"; +my $PluginNeedAWStatsVersion="5.5"; +my $PluginHooksFunctions="ShowInfoURL"; # -----> # <----- # IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE. use vars qw/ -$urlaliasloaded -%UrlAliases +$urlinfoloaded +%UrlInfo /; # -----> @@ -49,8 +49,8 @@ sub Init_urlalias { # <----- # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS debug(" InitParams=$InitParams",1); - $urlaliasloaded=0; - %UrlAliases=(); + $urlinfoloaded=0; + %UrlInfo=(); # -----> return ($checkversion?$checkversion:"$PluginHooksFunctions"); @@ -64,22 +64,22 @@ sub Init_urlalias { # Function called to add additionnal information for URLs in URLs' report. # Parameters: URL #----------------------------------------------------------------------------- -sub ReplaceURL_urlalias { +sub ShowInfoURL_urlalias { # <----- - if (! $urlaliasloaded) { + if (! $urlinfoloaded) { # Load urlalias file my $filetoload=''; - if ($SiteConfig && open(URLALIASFILE,"$PluginDir/urlalias.$SiteConfig.txt")) { $filetoload="$PluginDir/urlalias.$SiteConfig.txt"; } - elsif (open(URLALIASFILE,"$PluginDir/urlalias.txt")) { $filetoload="$PluginDir/urlalias.txt"; } + if ($SiteConfig && open(URLINFOFILE,"$PluginDir/urlalias.$SiteConfig.txt")) { $filetoload="$PluginDir/urlalias.$SiteConfig.txt"; } + elsif (open(URLINFOFILE,"$PluginDir/urlalias.txt")) { $filetoload="$PluginDir/urlalias.txt"; } else { error("Couldn't open UrlAlias file \"$PluginDir/urlalias.txt\": $!"); } # This is the fastest way to load with regexp that I know - %UrlAliases = map(/^([^\t]+)\t+([^\t]+)/o,); - close URLALIASFILE; - debug("UrlAlias file loaded: ".(scalar keys %UrlAliases)." aliases found."); - $urlaliasloaded=1; + %UrlInfo = map(/^([^\t]+)\t+([^\t]+)/o,); + close URLINFOFILE; + debug("UrlAlias file loaded: ".(scalar keys %UrlInfo)." entries found."); + $urlinfoloaded=1; } my $urltoreplace="$_[0]"; - if ($UrlAliases{$urltoreplace}) { print "$UrlAliases{$urltoreplace}
"; } + if ($UrlInfo{$urltoreplace}) { print "$UrlInfo{$urltoreplace}
"; } else { print ""; } return 1; # -----> diff --git a/wwwroot/cgi-bin/plugins/userinfo.pm b/wwwroot/cgi-bin/plugins/userinfo.pm new file mode 100644 index 00000000..386e0036 --- /dev/null +++ b/wwwroot/cgi-bin/plugins/userinfo.pm @@ -0,0 +1,90 @@ +#!/usr/bin/perl +#----------------------------------------------------------------------------- +# UserInfo AWStats plugin +# This plugin allow you to add information on authenticated users chart from +# a text file. Like full user name and lastname. +# You must create a file called userinfo.configvalue.txt and store it in +# plugin directory that contains 2 columns separated by a tab char. +# First column is authenticated user login and second column is text +# you want add. +#----------------------------------------------------------------------------- +# 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 +# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE. +my $PluginNeedAWStatsVersion="5.5"; +my $PluginHooksFunctions="ShowInfoUser"; +# -----> + +# <----- +# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE. +use vars qw/ +$userinfoloaded +%UserInfo +/; +# -----> + + + +#----------------------------------------------------------------------------- +# PLUGIN FUNCTION: Init_pluginname +#----------------------------------------------------------------------------- +sub Init_userinfo { + my $InitParams=shift; + my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion); + + # <----- + # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS + debug(" InitParams=$InitParams",1); + $userinfoloaded=0; + %UserInfo=(); + # -----> + + return ($checkversion?$checkversion:"$PluginHooksFunctions"); +} + + + +#----------------------------------------------------------------------------- +# PLUGIN FUNCTION: ShowInfoUser_pluginname +# UNIQUE: NO (Several plugins using this function can be loaded) +# Function called to add additionnal information for Users in users' report. +# Parameters: URL +#----------------------------------------------------------------------------- +sub ShowInfoUser_userinfo { + # <----- + if (! $userinfoloaded) { + # Load userinfo file + my $filetoload=''; + if ($SiteConfig && open(USERINFOFILE,"$PluginDir/userinfo.$SiteConfig.txt")) { $filetoload="$PluginDir/userinfo.$SiteConfig.txt"; } + elsif (open(USERINFOFILE,"$PluginDir/userinfo.txt")) { $filetoload="$PluginDir/userinfo.txt"; } + else { error("Couldn't open UserInfo file \"$PluginDir/userinfo.txt\": $!"); } + # This is the fastest way to load with regexp that I know + %UserInfo = map(/^([^\t]+)\t+([^\t]+)/o,); + close USERINFOFILE; + debug("UserInfo file loaded: ".(scalar keys %UserInfo)." entries found."); + $userinfoloaded=1; + } + my $userinfotoreplace="$_[0]"; + if ($UserInfo{$userinfotoreplace}) { print "$UserInfo{$userinfotoreplace}"; } + else { print " "; } + return 1; + # -----> +} + + +1; # Do not remove this line