From: eldy <>
Date: Wed, 17 Jul 2002 21:13:22 +0000 (+0000)
Subject: Added plugins
X-Git-Tag: AWSTATS_5_0_BETA~171
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de51d79fbcab2e21e5c23f405d4a1bd2bb37b5aa;p=thirdparty%2FAWStats.git
Added plugins
---
diff --git a/wwwroot/cgi-bin/awstats.model.conf b/wwwroot/cgi-bin/awstats.model.conf
index 0ab9cfd3..009799cc 100644
--- a/wwwroot/cgi-bin/awstats.model.conf
+++ b/wwwroot/cgi-bin/awstats.model.conf
@@ -644,3 +644,16 @@ color_k="2EA495" # Background color for number of bytes (Default = "2EA495")
color_s="8888DD" # Background color for number of search (Default = "8888DD")
color_e="CEC2E8" # Background color for number of entry pages (Default = "CEC2E8")
color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2E2")
+
+
+
+#-----------------------------------------------------------------------------
+# PLUGINS
+#-----------------------------------------------------------------------------
+
+# Add here all plugins file you want to load (Don't forget to uncomment line
+# if it start with '#'). Plugin files must be stored in 'plugins' directory.
+# Example: "timehires.pl"
+#
+#LoadPlugin="timehires.pl" # Time with -showsteps option are in milliseconds
+
diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl
index 7a9f0cef..b4c01952 100644
--- a/wwwroot/cgi-bin/awstats.pl
+++ b/wwwroot/cgi-bin/awstats.pl
@@ -1,14 +1,10 @@
#!/usr/bin/perl
-# With some other Unix Os, first line may be
-#!/usr/local/bin/perl
-# With Apache for Windows and ActiverPerl, first line may be
-#!C:/Program Files/ActiveState/ActivePerl/bin/perl
-#-Description-------------------------------------------
+#-----------------------------------------------------------------------------
# Free realtime web server logfile analyzer to show advanced web statistics.
# Works from command line or as a CGI. You must use this script as often as
# necessary from your scheduler to update your statistics.
# See AWStats documenation (in docs/ directory) for all setup instructions.
-#-------------------------------------------------------
+#-----------------------------------------------------------------------------
# $Revision$ - $Author$ - $Date$
#use warnings; # Must be used in test mode only. This reduce a little process speed
@@ -17,14 +13,6 @@ use strict;no strict "refs";
use Socket;
use Time::Local; # use Time::Local 'timelocal_nocheck' is faster but not supported by all Time::Local modules
-use vars qw/ $UseHiRes $UseCompress /;
-# Next 'use' can be uncommented to get miliseconds time in showsteps option
-use Time::HiRes qw( gettimeofday ); $UseHiRes=1;
-# Next 'use' can be uncommented to allow read/write of gz compressed log or history files (not working yet)
-#use Compress::Zlib; $UseCompress=1;
-
-# TODO If PurgeLogFile is on, only one update process must be allowed
-
#-------------------------------------------------------
# Defines
@@ -41,6 +29,9 @@ $NBOFLINESFORBENCHMARK
/;
$DEBUGFORCED = 0; # Force debug level to log lesser level into debug.log file (Keep this value to 0)
$NBOFLINESFORBENCHMARK=5000; # Benchmark info are printing every NBOFLINESFORBENCHMARK lines
+# Plugins variable
+use vars qw/ $UseHiRes $UseCompress /;
+$UseHiRes=$UseCompress=0;
# Running variables
use vars qw/
$DIR $PROG $Extension
@@ -200,8 +191,9 @@ use vars qw/
@BrowsersSearchIDOrder @OSSearchIDOrder @SearchEnginesSearchIDOrder @WordsToCleanSearchUrl
/;
use vars qw/
-@SessionsRange @Message @HostAliases @AllowAccessFromWebToFollowingAuthenticatedUsers @OnlyFiles
-@SkipDNSLookupFor @SkipFiles @SkipHosts @DOWIndex @RobotsSearchIDOrder
+@SessionsRange @Message @HostAliases @AllowAccessFromWebToFollowingAuthenticatedUsers
+@OnlyFiles @SkipDNSLookupFor @SkipFiles @SkipHosts @PluginsToLoad
+@DOWIndex @RobotsSearchIDOrder
@_msiever_h @_nsver_h @_from_p @_from_h @_time_p @_time_h @_time_k
@keylist
/;
@@ -209,9 +201,8 @@ use vars qw/
@Message=();
@HostAliases=();
@AllowAccessFromWebToFollowingAuthenticatedUsers=();
-@OnlyFiles = @SkipDNSLookupFor = @SkipFiles = @SkipHosts = ();
-@DOWIndex=();
-@RobotsSearchIDOrder = ();
+@OnlyFiles = @SkipDNSLookupFor = @SkipFiles = @SkipHosts = @PluginsToLoad = ();
+@DOWIndex = @RobotsSearchIDOrder = ();
@_msiever_h = @_nsver_h = ();
@_from_p = @_from_h = ();
@_time_p = @_time_h = @_time_k = ();
@@ -526,48 +517,65 @@ sub error {
my $thirdmessage=shift||"";
if ($Debug) { debug("$message $secondmessage $thirdmessage",1); }
if ($message =~ /^Format error$/) {
+ my $tagbold=""; my $tagunbold=""; my $tagbr=""; my $tagfontred=""; my $tagunfont="";
# Files seems to have bad format
- if ($HTMLOutput) { print "
\n"; }
- print "AWStats did not found any valid log lines that match your LogFormat parameter, in the ${NbOfLinesForCorruptedLog}th first non commented lines read of your log.
\n";
- print "Your log file $thirdmessage must have a bad format or LogFormat parameter setup does not match this format.
\n";
- print "Your LogFormat parameter is $LogFormat, this means each line in your log file need to have ";
- if ($LogFormat == 1) {
- print "\"combined log format\" like this:
\n";
- print ($HTMLOutput?"":"");
- print "111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234 \"http://www.fromserver.com/from.htm\" \"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)\"\n";
- print ($HTMLOutput?"
":"");
- }
- if ($LogFormat == 2) {
- print "\"MSIE Extended W3C log format\" like this:
\n";
- print ($HTMLOutput?"":"");
- print "date time c-ip c-username cs-method cs-uri-sterm sc-status sc-bytes cs-version cs(User-Agent) cs(Referer)\n";
- print ($HTMLOutput?"
":"");
- }
- if ($LogFormat == 3) {
- print "\"WebStar native log format\"
\n";
- }
- if ($LogFormat == 4) {
- print "\"common log format\" like this:
\n";
- print ($HTMLOutput?"":"");
- print "111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234\n";
- print ($HTMLOutput?"
":"");
- }
- if ($LogFormat == 5) {
- print "\"ISA native log format\"
\n";
- }
- if ($LogFormat !~ /^[1-5]$/) {
- print "the following personalized log format:
\n";
- print ($HTMLOutput?"":"");
- print "$LogFormat\n";
- print ($HTMLOutput?"
":"");
- }
- print "And this is a sample of what AWStats found in your log (the record number $NbOfLinesForCorruptedLog in your log):\n";
- print ($HTMLOutput?"
":"");
- print "$secondmessage";
- print ($HTMLOutput?"
":"");
- print "\n";
- #print "Note: If your $NbOfLinesForCorruptedLog first lines in your log files are wrong because they are ";
- #print "result of a worm virus attack, you can increase the NbOfLinesForCorruptedLog parameter in config file.\n";
+ if ($HTMLOutput) {
+ $tagbold=""; $tagunbold=""; $tagbr="
"; $tagfontred=""; $tagunfont="";
+ print "
\n";
+ }
+ if ($LogSeparator !~ $message) {
+ # Bad LogSeparator parameter
+ if ($HTMLOutput) { print "${tagfontred}"; }
+ print "AWStats did not found the ${tagbold}LogSeparator${tagunbold} in your log records.${tagbr}\n";
+ if ($HTMLOutput) { print "${tagunfont}"; }
+ }
+ else {
+ # Bad LogFormat parameter
+ print "AWStats did not found any valid log lines that match your ${tagbold}LogFormat${tagunbold} parameter, in the ${NbOfLinesForCorruptedLog}th first non commented lines read of your log.${tagbr}\n";
+ if ($HTMLOutput) { print "${tagfontred}"; }
+ print "Your log file ${tagbold}$thirdmessage${tagunbold} must have a bad format or ${tagbold}LogFormat${tagunbold} parameter setup does not match this format.${tagbr}${tagbr}\n";
+ if ($HTMLOutput) { print "${tagunfont}"; }
+ print "Your AWStats ${tagbold}LogFormat${tagunbold} parameter is:\n";
+ print "${tagbold}$LogFormat${tagunbold}${tagbr}\n";
+ print "This means each line in your web server log file need to have ";
+ if ($LogFormat == 1) {
+ print "${tagbold}\"combined log format\"${tagunbold} like this:${tagbr}\n";
+ print ($HTMLOutput?"":"");
+ print "111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234 \"http://www.fromserver.com/from.htm\" \"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)\"\n";
+ print ($HTMLOutput?"${tagbr}${tagbr}\n":"");
+ }
+ if ($LogFormat == 2) {
+ print "${tagbold}\"MSIE Extended W3C log format\"${tagunbold} like this:${tagbr}\n";
+ print ($HTMLOutput?"":"");
+ print "date time c-ip c-username cs-method cs-uri-sterm sc-status sc-bytes cs-version cs(User-Agent) cs(Referer)\n";
+ print ($HTMLOutput?"${tagbr}${tagbr}\n":"");
+ }
+ if ($LogFormat == 3) {
+ print "${tagbold}\"WebStar native log format\"${tagunbold}${tagbr}\n";
+ }
+ if ($LogFormat == 4) {
+ print "${tagbold}\"common log format\"${tagunbold} like this:${tagbr}\n";
+ print ($HTMLOutput?"":"");
+ print "111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234\n";
+ print ($HTMLOutput?"${tagbr}${tagbr}\n":"");
+ }
+ if ($LogFormat == 5) {
+ print "${tagbold}\"ISA native log format\"${tagunbold}${tagbr}\n";
+ }
+ if ($LogFormat !~ /^[1-5]$/) {
+ print "the following personalized log format:${tagbr}\n";
+ print ($HTMLOutput?"":"");
+ print "$LogFormat\n";
+ print ($HTMLOutput?"${tagbr}${tagbr}\n":"");
+ }
+ print "And this is a sample of records AWStats found in your log file (the record number $NbOfLinesForCorruptedLog in your log):\n";
+ print ($HTMLOutput?"
":"");
+ print "$secondmessage";
+ print ($HTMLOutput?"${tagbr}${tagbr}":"");
+ print "\n";
+ }
+ #print "Note: If your $NbOfLinesForCorruptedLog first lines in your log files are wrong because of ";
+ #print "a worm virus attack, you can increase the NbOfLinesForCorruptedLog parameter in config file.\n";
#print "\n";
}
else {
@@ -912,6 +920,7 @@ sub Read_Config_File {
if ($param =~ /^color_s/) { $color_s=$value; next; }
if ($param =~ /^color_e/) { $color_e=$value; next; }
if ($param =~ /^color_x/) { $color_x=$value; next; }
+ if ($param =~ /^LoadPlugin/) { push @PluginsToLoad, $value; next; }
}
close CONFIG;
# If parameter NotPageList not found, init for backward compatibility
@@ -970,7 +979,6 @@ sub Read_Ref_Data {
}
-
#------------------------------------------------------------------------------
# Function: Get the messages for a specified language
# Parameter: Language id
@@ -1362,6 +1370,37 @@ sub Check_Config {
}
}
+
+#------------------------------------------------------------------------------
+# Function: Load plugins files
+# Parameter: None
+# Return value: None
+# Input: $DIR
+# Output: None
+#------------------------------------------------------------------------------
+sub Read_Plugins {
+ my %FilePath=();
+ if ($Debug) { debug("Call to Read_Plugins @PluginsToLoad"); }
+ foreach my $file (@PluginsToLoad) {
+ foreach my $dir ("${DIR}plugins","./plugins") {
+ my $searchdir=$dir;
+ if ($searchdir && (!($searchdir =~ /\/$/)) && (!($searchdir =~ /\\$/)) ) { $searchdir .= "/"; }
+ if (! $FilePath{$file}) {
+ if (-s "${searchdir}${file}") {
+ $FilePath{$file}="${searchdir}${file}";
+ if ($Debug) { debug("Call to Read_Plugins [FilePath{$file}=\"$FilePath{$file}\"]"); }
+ require "$FilePath{$file}";
+ }
+ }
+ }
+ if (! $FilePath{$file}) {
+ my $filetext=$file; $filetext =~ s/\.pm$//; $filetext =~ s/_/ /g;
+ &warning("Warning: Can't open plugin file \"$file\" for read.\nCheck if file is in ${DIR}plugins directory and is readable.");
+ }
+ }
+}
+
+
#--------------------------------------------------------------------
# Input: year,month,0|1 (0=read only 1st part, 1=read all file)
#--------------------------------------------------------------------
@@ -2904,6 +2943,9 @@ if ($Lang eq "10") { $Lang="kr"; }
# Check and correct bad parameters
&Check_Config;
+# Load plugins
+&Read_Plugins;
+
# Here SiteDomain is always defined
if ($Debug) { &debug("Site domain to analyze: $SiteDomain"); }
@@ -5432,6 +5474,9 @@ else {
0; # Do not remove this line
+# TODO If PurgeLogFile is on, only one update process must be allowed
+
+
#-------------------------------------------------------
# ALGORITHM SUMMARY
# Read config file
diff --git a/wwwroot/cgi-bin/plugins/timehires.pl b/wwwroot/cgi-bin/plugins/timehires.pl
new file mode 100644
index 00000000..c59b5b1b
--- /dev/null
+++ b/wwwroot/cgi-bin/plugins/timehires.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+#-----------------------------------------------------------------------------
+# TimeHires AWStats plugin
+# Change time accuracy in showsteps option from seconds to milliseconds
+#-----------------------------------------------------------------------------
+# Perl Required Modules: Time::HiRes
+#-----------------------------------------------------------------------------
+# $Revision$ - $Author$ - $Date$
+
+use Time::HiRes qw( gettimeofday );
+
+
+$UseHiRes=1;
+
+1; # Do not remove this line