use strict; package SuikaWiki::Plugin::Registry; our %Info; $Info{q#RequestLog#}->{Name} = q#RequestLog#; $Info{q#RequestLog#}->{q#Version#} = q#2004.0831.0328#; $Info{q#RequestLog#}->{q#InterfaceVersion#} = q#2.9.1#; $Info{q#RequestLog#}->{q#mkpluginVersion#} = q#2.1.19#; $Info{q#RequestLog#}->{q#module_name#} = q#SuikaWiki::Plugin::plugin::RequestLog1040731032807O9uE#; $Info{q#RequestLog#}->{q#Date.RCS#} = q#$Date: 2010/05/16 23:05:49 $#; $Info{q#RequestLog#}->{RequiredPlugin} = [q#WikiLinking#]; $Info{q#RequestLog#}->{Description} = [[q#HTTP Request Logging#, q#en#, q##]]; $Info{q#RequestLog#}->{License} = [[q#%%Perl%%#, q##, q##]]; $Info{q#RequestLog#}->{Author} = [[[[q#Wakaba#, q#ja#, q#Latn#]], [[q#w@suika.fam.cx#]], [q##]]]; package SuikaWiki::Plugin::plugin::RequestLog1040731032807O9uE; #line 1 "(WikiPlugin module source request-log.wp2, block Plugin/Use)" use Message::Util::Error; #line 1 "(WikiPlugin module RequestLog, chunk 1)" {my $def = {q#Parameter#, {q#name#, {q#Type#, q#name#, q#Default#, q#\#REQUIRED#, q#Description#, [[q##, q##, q##]]}}, q#Description#, [], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; #line 1 "(WikiPlugin module source request-log.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/rl__log']/Formatting)" $p->{q#name#} = do { my $r = $f->parse_attr ($p=>q#name#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r}; my $rlist; my $sub = []; try { my $page = $p->{name}; $page ||= $o->{wiki}->{input}->parameter ('rl--for') if $o->{wiki}->{input}; $page = $o->{wiki}->name ($page); unshift @$page, @{$o->{wiki}->{config}->{page}->{q#http://suika.fam.cx/~wakaba/-temp/2004/05/01/reqlog\#root#}||[]}; $rlist = $o->{wiki}->{db}->get ('log__http_request', $page); $sub->[0] = [$o->{wiki}->{db}->keys ('log__http_request', -ns => $page)]; $sub->[1] = [$o->{wiki}->{db}->keys ('log__http_request', -ns => $page, -type => 'ns')]; } catch SuikaWiki::DB::Util::Error with { my $err = shift; $err->throw if $err->{-type} eq 'ERROR_REPORTED'; }; if ($rlist and keys %$rlist) { my $list = $p->{-parent}->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'ol'); for (sort {$rlist->{$b} <=> $rlist->{$a} or $a cmp $b} keys %$rlist) { $list->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'li') ->append_text (sprintf '{%d} %s', $rlist->{$_}, $_); } } for my $i (0, 1) { if (@{$sub->[$i]}) { my $list = $p->{-parent}->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'ul'); my $template = $o->{wiki}->{plugin}->module_package ('WikiResource') ->get_text (name => 'RequestLog:List:'.[qw/Leaf Node/]->[$i], o => $o, wiki => $o->{wiki}); for (sort {$a->[$#$a] cmp $b->[$#$b]} @{$sub->[$i]}) { $o->{wiki}->{plugin}->module_package ('WikiLinking') ->to_wikipage_in_html ({ label => $template, } => { page_name => $o->{wiki}->{var}->{page}, param => { 'rl--for' => $o->{wiki}->name ($_)->stringify (wiki => $o->{wiki}), }, }, { parent => $list->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'li'), o => $o, }); } }}}} #line 1 "(WikiPlugin module RequestLog, chunk 2)" ; $SuikaWiki::Plugin::Rule{view}->{rl__log} = $def; $SuikaWiki::Plugin::Rule{view_resource}->{rl__log} = $def; $SuikaWiki::Plugin::Rule{form_input}->{rl__log} = $def; }; sub http_request_log { #line 1 "(WikiPlugin module source request-log.wp2, block Function[Name='http_request_log']/Main)" my (undef, %opt) = @_; return if not $opt{wiki}->{db} or not $opt{wiki}->{input}; $opt{prop} ||= 'log__http_request'; $opt{ns} ||= [@{$opt{wiki}->{config}->{page}->{q#http://suika.fam.cx/~wakaba/-temp/2004/05/01/reqlog\#root#}||[]}, (gmtime)[5] + 1900]; for (qw/ Accept Accept-Charset Accept-Encoding Accept-Language Accept-Geo Accept-Features AcceptLanguage X-Awg-Client-Protocol-Version X-Awg-Client-Version Blonde-Hunter Cache-Control X-Cache-ID Cache-Info Connection Xonnection Cneonction Proxy-Connection Xroxy-Connection Content-Disposition Content-Language Content-Transfer-Encoding Content-Encoding Content-Feature Date Extension X-EGZ From X-Filtergate-Request X-IBM-RCA-Request If-Modified-Since Unless-Modified-Since If-Match If-None-Match If-Range Keep-Alive X-Locking MAX-Forwards MIME-Version Novinet Npfrefr Npfvoid Pragma ProbixpbContext ProbixpbSignature ProbixpbVersion Proxy----------- User-Agent Proxy-Agent Wser-Agent X-ICAP-Version X-HTX-Agent Dweb-Client Range Request-Range Referrer Weferer Server-Lover X-Sister TE Transfer-Encoding UA-Color UA-CPU UA-OS UA-Pixels X-UP-Subno XXXXX XXXXXXX XXXXXXXXXX XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX ------- ---------- --------------- /) { (my $mv = uc $_) =~ tr/-/_/; SuikaWiki::Plugin::plugin::RequestLog1040731032807O9uE->_log_add (%opt, value => scalar $opt{wiki}->{input}->meta_variable ('HTTP_'.$mv), key => [@{$opt{ns}}, $_]); } SuikaWiki::Plugin::plugin::RequestLog1040731032807O9uE->_log_add (%opt, value => scalar $opt{wiki}->{input}->meta_variable ('CONTENT_TYPE'), key => [@{$opt{ns}}, 'Content-Type']); SuikaWiki::Plugin::plugin::RequestLog1040731032807O9uE->_log_add (%opt, value => scalar $opt{wiki}->{input}->meta_variable ('REQUEST_METHOD'), key => [@{$opt{ns}}, ':request-method']); my $key = [@{$opt{ns}}, ':header-field']; my $list = $opt{wiki}->{db}->get ($opt{prop}, $key); for (grep s/^HTTP_//, $opt{wiki}->{input}->meta_variable_list) { (my $v = ucfirst lc $_) =~ tr/_/-/; $v =~ s/(?<=-)([a-z])/uc $1/ge; $list->{$v}++; } $opt{wiki}->{db}->set ($opt{prop}, $key => $list); my $list = $opt{wiki}->{db}->get ($opt{prop}, $key); } #line 1 "(WikiPlugin module RequestLog, chunk 4)" sub _log_add { #line 1 "(WikiPlugin module source request-log.wp2, block Function[Name='_log_add']/Main)" my (undef, %opt) = @_; return unless length $opt{value}; for ($opt{value}) { s/([^\x20-\x24\x26-\x5A\x5C-\x7E])/sprintf '%%%02X', unpack 'C', $1/ge; s/(bypass-client=\d+\.\d+\.)(\d+)\.(\d+)/$1.'[VAR['.('*' x length $2).']].[VAR['.('*' x length $3).']]'/ge; s/[0-5]\d:[0-5]\d:[0-5]\d GMT/[VAR[**]]:[VAR[**]]:[VAR[**]] GMT/g; s/, (?:[012]\d|3[01])(?=[ -][JFMASOND])/, [VAR[**]]/g; s/; length=([0-9]+)/'; length=[VAR['.('*' x length $1).']]'/ge; } my $list = $opt{wiki}->{db}->get ($opt{prop}, $opt{key}); $list->{$opt{value}}++; $opt{wiki}->{db}->set ($opt{prop}, $opt{key} => $list); } #line 1 "(WikiPlugin module RequestLog, chunk 5)" $SuikaWiki::Plugin::Rule{page_link}->{rl__for_param} = {q#Parameter#, {}, q#Description#, [], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; #line 1 "(WikiPlugin module source request-log.wp2, block FormattingRule[name()='[q#page-link#]/rl__for_param']/Formatting)" $p->{-parent}->append_text ($o->{link}->{dest}->{param}->{'rl--for'});}} #line 1 "(WikiPlugin module RequestLog, chunk 6)" ; package SuikaWiki::Plugin::Resource; our $BaseResource; $BaseResource->{q#und#}->{q##}->{q#RequestLog:List:Leaf#} = q#%link-to-it ( label => {%rl--for-param;}p, );#; $BaseResource->{q#und#}->{q##}->{q#RequestLog:List:Node#} = q#%link-to-it ( label => {%rl--for-param;}p, );#; package SuikaWiki::Plugin::Registry; $Info{q#RequestLog#}->{provide} = {q#rule#, {q#form_input#, [q#rl__log#], q#view#, [q#rl__log#], q#view_resource#, [q#rl__log#], q#page_link#, [q#rl__for_param#]}}; 1;