/[pub]/suikawiki/script/misc/plugins/RequestLog.wps
Suika

Contents of /suikawiki/script/misc/plugins/RequestLog.wps

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.2.2 - (hide annotations) (download)
Tue Feb 3 07:59:16 2004 UTC (22 years, 5 months ago) by wakaba
Branch: branch-suikawiki-1
Changes since 1.1.2.1: +13 -3 lines
Logging provided header field names

1 wakaba 1.1 Name:
2     RequestLog
3     FullName:
4 wakaba 1.1.2.1 Logging HTTP Header Field Body Value in the Request
5 wakaba 1.1 URI:
6 wakaba 1.1.2.1 IW:SuikaWiki:"Wiki//Log"
7 wakaba 1.1
8     Description:
9     Implementation of this module is temporary.
10     Reimplementation is needed!
11    
12     MODULE:
13     our $LoggingName;
14     sub add ($$) {
15     my ($name, $s) = @_;
16     return unless length $s;
17 wakaba 1.1.2.1 $s =~ s/([^\x20-\x24\x26-\x5A\x5C-\x7E])/sprintf '%%%02X', unpack 'C', $1/ge;
18     $s =~ s/(bypass-client=\d+\.\d+\.)(\d+)\.(\d+)/$1.'[VAR['.('*' x length $2).']].[VAR['.('*' x length $3).']]'/ge;
19     $s =~ s/[0-5]\d:[0-5]\d:[0-5]\d GMT/[VAR[**]]:[VAR[**]]:[VAR[**]] GMT/g;
20 wakaba 1.1.2.2 $s =~ s/, (?:[012]\d|3[01])(?=[ -][JFMASOND])/, [VAR[**]]/g;
21 wakaba 1.1.2.1 $s =~ s/; length=([0-9]+)/'; length=[VAR['.('*' x length $1).']]'/ge;
22 wakaba 1.1 my %ua;
23     for (split /\n/, $main::database{$main::PageName{'Log_'.$name}}) {
24     if (/^-\{(\d+)\} (.+)$/) {
25     my ($t, $n) = ($1, $2);
26     $n =~ tr/\x0A\x0D//d;
27     $ua{$n} = $t;
28     }
29     }
30     $ua{$s}++;
31     my $s = qq(#?SuikaWiki/0.9 interactive="yes"\n);
32     for (sort {$ua{$a} <=> $ua{$b}} keys %ua) {
33     $s .= sprintf qq(-{%d} %s\n), $ua{$_}, $_;
34     }
35     SuikaWiki::Plugin->_database->STORE ($main::PageName{'Log_'.$name} => $s, -touch => 0);
36     }
37    
38     my $year = (gmtime)[5] + 1900;
39     my @fields = (
40     [qw/ACCEPT AcceptType/],
41     [qw/ACCEPT_CHARSET AcceptCharset/],
42     [qw/ACCEPT_ENCODING AcceptEncoding/],
43     [qw/ACCEPT_LANGUAGE AcceptLanguage/],
44     [qw/TE AcceptTransferEncoding/],
45     [qw/CONNECTION Connection/],
46     [qw/ACCEPT_GEO AcceptGeo/],
47     [qw/KEEP_ALIVE KeepAlive/],
48     [qw/MIME_VERSION MIMEVersion/],
49     [qw/UA_COLOR UserAgentDisplayColor/],
50     [qw/UA_CPU UserAgentCPU/],
51     [qw/UA_OS UserAgentOS/],
52     [qw/UA_PIXELS UserAgentDisplaySize/],
53     [qw/CACHE_CONTROL CacheControl/],
54