/[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.3 - (hide annotations) (download)
Sat Mar 13 03:39:35 2004 UTC (21 years, 1 month ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
FILE REMOVED
Typo fixed

1 wakaba 1.1 Name:
2     RequestLog
3     FullName:
4     HTTP Request Header Field Body logging
5     URI:
6     IW:SuikaWiki:"Wiki//UserAgentList"
7    
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     $s =~ s/([^\x20-\x24\x26-\x7E])/sprintf '%%%02X', unpack 'C', $1/ge;
18     my %ua;
19     for (split /\n/, $main::database{$main::PageName{'Log_'.$name}}) {
20     if (/^-\{(\d+)\} (.+)$/) {
21     my ($t, $n) = ($1, $2);
22     $n =~ tr/\x0A\x0D//d;
23     $ua{$n} = $t;
24     }
25     }
26     $ua{$s}++;
27     my $s = qq(#?SuikaWiki/0.9 interactive="yes"\n);
28     for (sort {$ua{$a} <=> $ua{$b}} keys %ua) {
29     $s .= sprintf qq(-{%d} %s\n), $ua{$_}, $_;
30     }
31     SuikaWiki::Plugin->_database->STORE ($main::PageName{'Log_'.$name} => $s, -touch => 0);
32     }
33    
34     my $year = (gmtime)[5] + 1900;
35     my @fields = (
36     [qw/ACCEPT AcceptType/],
37     [qw/ACCEPT_CHARSET AcceptCharset/],
38     [qw/ACCEPT_ENCODING AcceptEncoding/],
39     [qw/ACCEPT_LANGUAGE AcceptLanguage/],
40     [qw/TE AcceptTransferEncoding/],
41     [qw/CONNECTION Connection/],
42     [qw/ACCEPT_GEO AcceptGeo/],
43     [qw/KEEP_ALIVE KeepAlive/],
44     [qw/MIME_VERSION MIMEVersion/],
45     [qw/UA_COLOR UserAgentDisplayColor/],
46     [qw/UA_CPU UserAgentCPU/],
47     [qw/UA_OS UserAgentOS/],
48     [qw/UA_PIXELS UserAgentDisplaySize/],
49     [qw/CACHE_CONTROL CacheControl/],
50     [qw/PRAGMA Pragma/],
51     [qw/IF_MODIFIED_SINCE IMS/],
52     [qw/XONNECTION Xonnection:/],
53     [qw/XROXY_CONNECTION Xroxy-Connection:/],
54     [qw/UNLESS_MODIFIED_SINCE Unless-Modified-Since:/],
55     [qw/XXXXXXXXXXXXXXX XXXXXXXXXXXXXXX:/],
56     [qw/XXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX:/],
57     [qw/RANGE Range:/],
58     [qw/REQUEST_RANGE Request-Range:/],
59     [qw/FROM From:/],
60     [qw/DATE Date:/],
61     [qw/CONTENT_TRANSFER_ENCODING CTE/],
62     [qw/CONTENT_LANGUAGE Content-Language:/],
63     [qw/CONTENT_DISPOSITION Content-Disposition:/],
64     [qw/REFERRER Referrer:/],
65     # [qw/ /],
66     # [qw/ /],
67     # [qw/ /],
68     # [qw/ /],
69     # [qw/ /],
70     );
71     for (@fields) {
72     $main::PageName{'Log_'.$_->[0]} = 'Wiki//Log//'.$_->[1].'//'.$year;
73     }
74     $main::PageName{Log_CONTENT_TYPE} = 'Wiki//Log//ContentType//'.$year;
75     $main::PageName{Log_REQUEST_METHOD} = 'Wiki//Log//RequestMethod//'.$year;
76     push @{$SuikaWiki::Plugin::On{WikiDatabaseLoaded}}, sub {
77     for (map {$_->[0]} @fields) {
78 wakaba 1.2 my $s = $main::ENV{'HTTP_'.$_};
79     if ({qw/IF_MODIFIED_SINCE 1 DATE 1 UNLESS_MODIFIED_SINCE 1/}->{$_}) {
80     $s =~ s/(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/[VAR[**]]:[VAR[**]]:[VAR[**]]/;
81     $s =~ s/, (?:[012][0-9]|3[01])(?=[ -])/, [VAR[**]]/;
82     $s =~ s/length=[0-9]+/length=[VAR[*]]/;
83     }
84     add ($_ => $s);
85 wakaba 1.1 }
86     add ('CONTENT_TYPE' => $main::ENV{CONTENT_TYPE});
87     add ('REQUEST_METHOD' => $main::ENV{REQUEST_METHOD});
88     };
89    
90    
91    
92     POD:TO DO:
93     - better storing format
94    
95     - Logging method should be more customizable (what mode? what's except?...)
96     POD:LICENSE:
97     Copyright 2003 Wakaba <w@suika.fam.cx>
98    
99     %%GNUGPL2%%

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24