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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sun Oct 5 11:24:52 2003 UTC (22 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +5 -4 lines
New

1 Name:
2 UserAgent
3 FullName:
4 User-agent specified behaviors and user-agent name logging
5 URI:
6 IW:SuikaWiki:"Wiki//UserAgentList"
7
8 MODULE:
9 our $LoggingName;
10 sub add ($) {
11 my $s = shift;
12 return unless length $s;
13 $s =~ s/([^\x20-\x24\x26-\x7E])/sprintf '%%%02X', unpack 'C', $1/ge;
14 my %ua;
15 for (split /\n/, SuikaWiki::Plugin->get_data (content => [qw/Wiki Log UserAgent/])) {
16 if (/^-{(\d+)} (.+)$/) {
17 my ($t, $n) = ($1, $2);
18 $n =~ tr/\x0A\x0D//d;
19 $ua{$n} = $t;
20 }
21 }
22 $ua{$s}++;
23 my $s = qq(#?SuikaWiki/0.9\n);
24 for (sort {$ua{$a} <=> $ua{$b}} keys %ua) {
25 $s .= sprintf qq(-{%d} %s\n), $ua{$_}, $_;
26 }
27 ## TODO:
28 SuikaWiki::Plugin->set_data (content => [qw/Wiki Log UserAgent/] => $s, -touch => 0);
29 }
30
31 if ($LoggingName) {
32 push @{$SuikaWiki::Plugin::On{WikiDatabaseLoaded}}, sub {
33 add ($main::ENV{HTTP_USER_AGENT})
34 if ($main::form{mycmd} eq 'read' || $main::form{mycmd} eq 'default');
35 };
36 };
37
38 POD:TO DO:
39 - better storing format
40
41 - Logging method should be more customizable (what mode? what's except?...)
42 POD:LICENSE:
43 Copyright 2003 Wakaba <w@suika.fam.cx>
44
45 %%GNUGPL2%%

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24