Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 269
- Log:
Overdue upgrade to AWStats v6.9, the most recent version
available at the time of writing.
- Author:
- rool
- Date:
- Wed May 27 23:57:15 +0100 2009
- Size:
- 4691 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/perl |
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.17 $ - $Author: eldy $ - $Date: 2008/11/15 16:03:42 $ |
10 | |
11 | |
12 | # <----- |
13 | # ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES. |
14 | # -----> |
15 | #use strict; |
16 | no strict "refs"; |
17 | |
18 | |
19 | |
20 | #----------------------------------------------------------------------------- |
21 | # PLUGIN VARIABLES |
22 | #----------------------------------------------------------------------------- |
23 | # <----- |
24 | # ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN |
25 | # AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE. |
26 | my $PluginNeedAWStatsVersion="5.7"; |
27 | my $PluginHooksFunctions="AddHTMLBodyHeader BuildFullHTMLOutput"; |
28 | # -----> |
29 | |
30 | # <----- |
31 | # IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE. |
32 | use vars qw/ |
33 | $MAXLINE |
34 | /; |
35 | # -----> |
36 | |
37 | |
38 | |
39 | #----------------------------------------------------------------------------- |
40 | # PLUGIN FUNCTION: Init_pluginname |
41 | #----------------------------------------------------------------------------- |
42 | sub Init_rawlog { |
43 | my $InitParams=shift; |
44 | my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion); |
45 | |
46 | # <----- |
47 | # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS |
48 | debug(" Plugin rawlog: InitParams=$InitParams",1); |
49 | |
50 | if ($QueryString =~ /rawlog_maxlines=(\d+)/i) { $MAXLINE=&DecodeEncodedString("$1"); } |
51 | else { $MAXLINE=5000; } |
52 | |
53 | # -----> |
54 | |
55 | return ($checkversion?$checkversion:"$PluginHooksFunctions"); |
56 | } |
57 | |
58 | |
59 | |
60 | #----------------------------------------------------------------------------- |
61 | # PLUGIN FUNTION: AddHTMLBodyHeader_pluginname |
62 | # UNIQUE: NO (Several plugins using this function can be loaded) |
63 | # Function called to Add HTML code at beginning of BODY section. |
64 | #----------------------------------------------------------------------------- |
65 | sub AddHTMLBodyHeader_rawlog { |
66 | # <----- |
67 | # Show form only if option -staticlinks not used |
68 | if (! $StaticLinks) { &_ShowForm(''); } |
69 | return 1; |
70 | # -----> |
71 | } |
72 | |
73 | |
74 | #----------------------------------------------------------------------------- |
75 | # PLUGIN FUNTION: BuildFullHTMLOutput_pluginname |
76 | # UNIQUE: NO (Several plugins using this function can be loaded) |
77 | # Function called to output an HTML page completely built by plugin instead |
78 | # of AWStats output |
79 | #----------------------------------------------------------------------------- |
80 | sub BuildFullHTMLOutput_rawlog { |
81 | # <----- |
82 | my $Filter=''; |
83 | if ($QueryString =~ /filterrawlog=([^&]+)/i) { $Filter=&DecodeEncodedString("$1"); } |
84 | |
85 | # A security check |
86 | if ($QueryString =~ /logfile=/i) { |
87 | print "<br />Option logfile is not allowed while building rawlog output.<br />"; |
88 | return 0; |
89 | } |
90 | |
91 | # Show form |
92 | &_ShowForm($Filter); |
93 | |
94 | # Precompiled regex Filter to speed up scan |
95 | if ($Filter) { $Filter=qr/$Filter/i; } |
96 | |
97 | print "<hr />\n"; |
98 | |
99 | # Show raws |
100 | my $xml=($BuildReportFormat eq 'xhtml'); |
101 | open(LOG,"$LogFile") || error("Couldn't open server log file \"$LogFile\" : $!"); |
102 | binmode LOG; # Avoid premature EOF due to log files corrupted with \cZ or bin chars |
103 | my $i=0; |
104 | print "<pre>"; |
105 | while (<LOG>) { |
106 | chomp $_; $_ =~ s/\r//; |
107 | if ($Filter && $_ !~ /$Filter/o) { next; } |
108 | print ($xml?XMLEncode("$_"):"$_"); |
109 | print "\n"; |
110 | if (++$i >= $MAXLINE) { last; } |
111 | } |
112 | print "</pre><br />\n<b>$i lines.</b><br />"; |
113 | return 1; |
114 | # -----> |
115 | } |
116 | |
117 | sub _ShowForm { |
118 | my $Filter=shift||''; |
119 | print "<br />\n"; |
120 | print "<form action=\"$AWScript\" style=\"padding: 0px 0px 0px 0px; margin-top: 0\">\n"; |
121 | print "<table class=\"aws_border\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">\n"; |
122 | print "<tr><td>"; |
123 | print "<table class=\"aws_data\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\">\n"; |
124 | print "<tr><td><span dir=\"ltr\"><b>Show content of file '$LogFile' ($MAXLINE first lines):</b></span></td></tr>\n"; |
125 | print "<tr><td>$Message[79]: <input type=\"text\" name=\"filterrawlog\" value=\"$Filter\" /> Max Number of Lines: <input type=\"text\" name=\"rawlog_maxlines\" size=\"5\" value=\"$MAXLINE\" /> <input type=\"submit\" value=\"List\" class=\"aws_button\" />\n"; |
126 | print "<input type=\"hidden\" name=\"config\" value=\"$SiteConfig\" /><input type=\"hidden\" name=\"framename\" value=\"$FrameName\" /><input type=\"hidden\" name=\"pluginmode\" value=\"rawlog\" />"; |
127 | print "</td></tr>\n"; |
128 | print "</table>\n"; |
129 | print "</td></tr></table>\n"; |
130 | print "</form>\n"; |
131 | } |
132 | |
133 | 1; # Do not remove this line |