2
#-----------------------------------------------------------------------------
3
# Rawlog AWStats plugin
4
# This plugin adds a form in AWStats main page to allow users to see raw
5
# content of current log files. A filter is also available.
6
#-----------------------------------------------------------------------------
7
# Perl Required Modules: None
8
#-----------------------------------------------------------------------------
9
# $Revision: 1.12 $ - $Author: eldy $ - $Date: 2003/12/12 19:25:08 $
13
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES.
15
use strict;no strict "refs";
19
#-----------------------------------------------------------------------------
21
#-----------------------------------------------------------------------------
23
# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
24
# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
25
my $PluginNeedAWStatsVersion="5.7";
26
my $PluginHooksFunctions="AddHTMLBodyHeader BuildFullHTMLOutput";
30
# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
38
#-----------------------------------------------------------------------------
39
# PLUGIN FUNCTION: Init_pluginname
40
#-----------------------------------------------------------------------------
43
my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
46
# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
47
debug(" InitParams=$InitParams",1);
51
return ($checkversion?$checkversion:"$PluginHooksFunctions");
56
#-----------------------------------------------------------------------------
57
# PLUGIN FUNTION: AddHTMLBodyHeader_pluginname
58
# UNIQUE: NO (Several plugins using this function can be loaded)
59
# Function called to Add HTML code at beginning of BODY section.
60
#-----------------------------------------------------------------------------
61
sub AddHTMLBodyHeader_rawlog {
63
# Show form only if option -staticlinks not used
64
if (! $StaticLinks) { &_ShowForm(''); }
70
#-----------------------------------------------------------------------------
71
# PLUGIN FUNTION: BuildFullHTMLOutput_pluginname
72
# UNIQUE: NO (Several plugins using this function can be loaded)
73
# Function called to output an HTML page completely built by plugin instead
75
#-----------------------------------------------------------------------------
76
sub BuildFullHTMLOutput_rawlog {
79
if ($QueryString =~ /filterrawlog=([^&]+)/i) { $Filter=&DecodeEncodedString("$1"); }
84
# Precompiled regex Filter to speed up scan
85
if ($Filter) { $Filter=qr/$Filter/i; }
90
open(LOG,"$LogFile") || error("Couldn't open server log file \"$LogFile\" : $!");
91
binmode LOG; # Avoid premature EOF due to log files corrupted with \cZ or bin chars
94
chomp $_; $_ =~ s/\r//;
95
if ($Filter && $_ !~ /$Filter/o) { next; }
97
if (++$i > $MAXLINE) { last; }
99
print "<br>\n<b>$i lines.</b><br />";
105
my $Filter=shift||'';
107
print "<form action=\"$AWScript\" style=\"padding: 0px 0px 0px 0px; margin-top: 0\">\n";
108
print "<table class=\"aws_border\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">\n";
110
print "<table class=\"aws_data\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\">\n";
111
print "<tr><td><span dir=\"ltr\"><b>Show content of file '$LogFile' ($MAXLINE first lines):</b></span></td></tr>\n";
112
print "<tr><td>$Message[79]: <input type=\"text\" name=\"filterrawlog\" value=\"$Filter\" /><input type=\"submit\" value=\"List\" class=\"aws_button\" />\n";
113
print "<input type=\"hidden\" name=\"config\" value=\"$SiteConfig\" /><input type=\"hidden\" name=\"framename\" value=\"$FrameName\" /><input type=\"hidden\" name=\"pluginmode\" value=\"rawlog\" />";
114
print "</td></tr>\n";
116
print "</td></tr></table>\n";
120
1; # Do not remove this line