/[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.3 - (hide annotations) (download)
Wed Feb 18 07:22:11 2004 UTC (21 years, 2 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
FILE REMOVED
WikiDB error reporting bug fixed

1 wakaba 1.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 wakaba 1.2 for (split /\n/, SuikaWiki::Plugin->get_data (content => [qw/Wiki Log UserAgent/])) {
16     if (/^-{(\d+)} (.+)$/) {
17 wakaba 1.1 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 wakaba 1.2 $s .= sprintf qq(-{%d} %s\n), $ua{$_}, $_;
26 wakaba 1.1 }
27 wakaba 1.2 ## TODO:
28     SuikaWiki::Plugin->set_data (content => [qw/Wiki Log UserAgent/] => $s, -touch => 0);
29 wakaba 1.1 }
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  
Google Analytics is used in this page; Cookies are used. 忍者AdMax is used in this page; Cookies are used. Privacy policy.