From: eldy <> Date: Sun, 3 Aug 2003 15:27:27 +0000 (+0000) Subject: Added rawlog plugin to add a form to show raw log content with filter capabilities. X-Git-Tag: AWSTATS_5_7_BETA~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5343ee358b6ea64dfa497092290e274cd2e82c72;p=thirdparty%2FAWStats.git Added rawlog plugin to add a form to show raw log content with filter capabilities. --- diff --git a/wwwroot/cgi-bin/awstats.model.conf b/wwwroot/cgi-bin/awstats.model.conf index 726ddb4a..d83c3ad7 100644 --- a/wwwroot/cgi-bin/awstats.model.conf +++ b/wwwroot/cgi-bin/awstats.model.conf @@ -1137,6 +1137,13 @@ color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2 # #LoadPlugin="timezone +2" +# Plugin: Rawlog +# Perl modules required: None +# 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. +# +#LoadPlugin="rawlog" + # Plugin: Graph3D # Perl modules required: None # Supported charts are built by a nice 3D graphic applet. diff --git a/wwwroot/cgi-bin/plugins/rawlog.pm b/wwwroot/cgi-bin/plugins/rawlog.pm new file mode 100644 index 00000000..2e288f99 --- /dev/null +++ b/wwwroot/cgi-bin/plugins/rawlog.pm @@ -0,0 +1,121 @@ +#!/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$ - $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.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(" InitParams=$InitParams",1); + $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 + &_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"); } + + # Show form + &_ShowForm($Filter); + + print "
\n"; + + # Show raws + 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; + while () { + chomp $_; $_ =~ s/\r//; + + if ($Filter) { + if ($_ !~ m/$Filter/i) { next; } + } + print "$_
"; + $i++; + if ($i > $MAXLINE) { last; } + } + print "$i lines.
"; + return 1; + # -----> +} + +sub _ShowForm { + my $Filter=shift||''; + print "
\n"; + print "
\n"; + print "\n"; + print "
"; + print "\n"; + print "\n"; + print "\n"; + print "
Show content of file '$LogFile' ($MAXLINE first lines):
$Message[79]: \n"; + print ""; + print "
\n"; + print "
\n"; + print "
\n"; +} + +1; # Do not remove this line