| 26 |
use Yuki::YukiWikiDB; |
use Yuki::YukiWikiDB; |
| 27 |
use AnyDBM_File; |
use AnyDBM_File; |
| 28 |
require 'jcode.pl'; |
require 'jcode.pl'; |
| 29 |
# use Jcode; |
require Jcode; |
| 30 |
use Fcntl; |
use Fcntl; |
| 31 |
my $version = '2.0.beta1.2002-05-29'; |
my $version = '2.0.beta1.2002-05-29'; |
| 32 |
my $walversion; |
my $walversion; |
| 116 |
$AdminChangePassword => 1, |
$AdminChangePassword => 1, |
| 117 |
$CompletedSuccessfully => 1, |
$CompletedSuccessfully => 1, |
| 118 |
#$FrontPage => 1, |
#$FrontPage => 1, |
| 119 |
|
WikiUserAgentList => 1, |
| 120 |
); |
); |
| 121 |
my %form; |
my %form; |
| 122 |
my %database; |
my %database; |
| 159 |
my $walversion = '2.0.beta1.wal.1'; # Walrus add (1) |
my $walversion = '2.0.beta1.wal.1'; # Walrus add (1) |
| 160 |
############################## |
############################## |
| 161 |
# &test_convert; |
# &test_convert; |
| 162 |
|
my $UA = ''; |
| 163 |
&main; |
&main; |
| 164 |
exit(0); |
exit(0); |
| 165 |
############################## |
############################## |
| 166 |
|
|
| 167 |
sub main { |
sub main { |
| 168 |
|
$UA = $main::ENV{HTTP_USER_AGENT}; |
| 169 |
&init_resource; |
&init_resource; |
| 170 |
&open_db; |
&open_db; |
| 171 |
&init_form; |
&init_form; |
| 182 |
my $content = $database{$form{mypage}}; |
my $content = $database{$form{mypage}}; |
| 183 |
my $lm = &get_info($form{mypage}, $info_LastModified); |
my $lm = &get_info($form{mypage}, $info_LastModified); |
| 184 |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
| 185 |
|
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
| 186 |
my ($r, $c) = get_search_result ($form{mypage}); |
my ($r, $c) = get_search_result ($form{mypage}); |
| 187 |
my $rl = wiki::referer::list_html ($form{mypage}); |
my $rl = wiki::referer::list_html ($form{mypage}); |
| 188 |
my @toc; |
my @toc; |
| 193 |
## - 'SuikaWiki/0.9' CRLF |
## - 'SuikaWiki/0.9' CRLF |
| 194 |
## - 'H2H/' ("0.9" / "1.0" / "1.1") CRLF |
## - 'H2H/' ("0.9" / "1.0" / "1.1") CRLF |
| 195 |
## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF |
## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF |
| 196 |
$cf = $1 if $content =~ s#^(?:/\*\s*|[\#<]\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.][^\x0D\x0A]*)?)[\x0D\x0A]+##s; |
$cf = $1 if $content =~ s#^(?:/\*\s*|[\#<]\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+##s; |
| 197 |
if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) { |
if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) { |
| 198 |
&print_header ($form{mypage}, -last_modified => $lm, |
&print_header ($form{mypage}, -last_modified => $lm, |
| 199 |
-content_format => $cf, -noindex => $cf =~ /obsoleted="yes"/); |
-content_format => $cf, -noindex => $cf =~ /obsoleted="yes"/); |
| 200 |
&print_content ($content, content_format => $cf, last_modified => $lm, |
&print_content ($content, content_format => $cf, last_modified => $lm, |
| 201 |
-toc => \@toc); |
-toc => \@toc); |
| 202 |
print &text_to_html (q([[#comment]])) unless $cf =~ /obsoleted="yes"/; |
print &text_to_html (q([[#comment]])) if $cf !~ /obsoleted="yes"/ && !$fixedpage{$form{mypage}}; |
| 203 |
} else { |
} else { |
| 204 |
&print_header($form{mypage}, -last_modified => $lm); |
&print_header($form{mypage}, -last_modified => $lm); |
| 205 |
print "<pre>@{[&escape($content)]}</pre>"; |
print "<pre>@{[&escape($content)]}</pre>"; |
| 206 |
} |
} |
| 207 |
if ($c) { |
if ($c) { |
| 208 |
print q{<h2 id="wikipage-see-also">See also</h2>}; |
print qq{<h2 @{[&id_and_name('wikipage-see-also')]}>See also</h2>}; |
| 209 |
print $r; |
print $r; |
| 210 |
} |
} |
| 211 |
if ($rl) { |
if ($rl) { |
| 212 |
print qq(<div id="wikipage-referer"><h2>参照元</h2>\n$rl</div>\n); |
print qq(<div @{[&id_and_name('wikipage-referer')]}><h2>参照元</h2>\n$rl</div>\n); |
| 213 |
} |
} |
| 214 |
&print_footer($form{mypage}, $lm); |
&print_footer($form{mypage}, $lm); |
| 215 |
} |
} |
| 230 |
} |
} |
| 231 |
} |
} |
| 232 |
|
|
| 233 |
|
sub id_and_name ($) { |
| 234 |
|
my $name = shift; |
| 235 |
|
if ($UA =~ m#Mozilla/2#) { |
| 236 |
|
qq{id="$name"><a name="$name"></a}; |
| 237 |
|
} else { |
| 238 |
|
qq{id="$name"}; |
| 239 |
|
} |
| 240 |
|
} |
| 241 |
|
|
| 242 |
sub do_edit { |
sub do_edit { |
| 243 |
my ($page) = &unarmor_name(&armor_name($form{mypage})); |
my ($page) = &unarmor_name(&armor_name($form{mypage})); |
| 244 |
&print_header($page, -noindex => 1); |
&print_header($page, -noindex => 1); |
| 250 |
&print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0); |
&print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0); |
| 251 |
} |
} |
| 252 |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
| 253 |
|
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
| 254 |
my ($r, $c) = get_search_result ($form{mypage}); |
my ($r, $c) = get_search_result ($form{mypage}); |
| 255 |
my $rl = wiki::referer::list_html ($form{mypage}); |
my $rl = wiki::referer::list_html ($form{mypage}); |
| 256 |
if ($c) { |
if ($c) { |
| 355 |
&update_recent_changes; |
&update_recent_changes; |
| 356 |
} |
} |
| 357 |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
| 358 |
&print_header($CompletedSuccessfully, -noindex => 1, -goto => $url_cgi.'?'.&encode($form{mypage}).($form{__comment_anchor_index}?"#anchor-$form{__comment_anchor_index}":'')); |
&print_header($CompletedSuccessfully, -noindex => 1, -goto => $url_cgi.'?mycmd=read;mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}).($form{__comment_anchor_index}?"#anchor-$form{__comment_anchor_index}":'')); |
| 359 |
&print_message($resource{saved}); |
&print_message($resource{saved}); |
| 360 |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
| 361 |
&print_footer($CompletedSuccessfully); |
&print_footer($CompletedSuccessfully); |
| 387 |
} |
} |
| 388 |
|
|
| 389 |
sub get_search_result ($;%) { |
sub get_search_result ($;%) { |
| 390 |
my $word = shift; |
my $word = lc shift; |
| 391 |
my %option = @_; |
my %option = @_; |
| 392 |
my @r; |
my @r; |
| 393 |
foreach my $page (keys %database) { |
foreach my $page (keys %database) { |
| 396 |
my $cf = 'SuikaWiki/0.9'; |
my $cf = 'SuikaWiki/0.9'; |
| 397 |
$cf = $1 if $content =~ s/^\#\?([^\x0A\x0D]+)//s; |
$cf = $1 if $content =~ s/^\#\?([^\x0A\x0D]+)//s; |
| 398 |
next if $cf =~ /obsoleted="yes"/; |
next if $cf =~ /obsoleted="yes"/; |
| 399 |
if (index ($page, $word) > -1) { |
if (index (lc $page, $word) > -1) { |
| 400 |
my $c = $content =~ s/\Q$word\E/$word/g; |
my $c = $content =~ s/\Q$word\E//gi; |
| 401 |
push @r, [$page, $c+20]; |
push @r, [$page, $c+20]; |
| 402 |
} elsif (index ($word, $page) > -1) { |
} elsif (index ($word, lc $page) > -1) { |
| 403 |
my $c = $content =~ s/\Q$word\E/$word/g; |
my $c = $content =~ s/\Q$word\E//gi; |
| 404 |
push @r, [$page, $c+10]; |
push @r, [$page, $c+10]; |
| 405 |
} elsif (my $c = $content =~ s/\Q$word\E/$word/g) { |
} elsif (my $c = $content =~ s/\Q$word\E//gi) { |
| 406 |
push @r, [$page, $c]; |
push @r, [$page, $c]; |
| 407 |
} |
} |
| 408 |
} |
} |
| 409 |
my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#g; $s }; |
my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#gi; $s }; |
| 410 |
my $r = join "\n", map {qq(<li>[$_->[1]] <a href ="$url_cgi?@{[&encode($_->[0])]}" class="wiki">@{[&$em(&escape($_->[0]))]}</a> <span class="wikipage-summary">@{[&$em(&escape(&get_subjectline($_->[0])))]}</span></li>)} sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r; |
my $r = join "\n", map {qq(<li>[$_->[1]] <a href ="$url_cgi?@{[&encode($_->[0])]}" class="wiki">@{[&$em(&escape($_->[0]))]}</a> <span class="wikipage-summary">@{[&$em(&escape(&get_subjectline($_->[0])))]}</span></li>)} sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r; |
| 411 |
$r = qq|<ul class="search-result">$r</ul>| if $r; |
$r = qq|<ul class="search-result">$r</ul>| if $r; |
| 412 |
get_message ($resource{notfound}) if @r == 0 && $option{-output_not_found}; |
get_message ($resource{notfound}) if @r == 0 && $option{-output_not_found}; |
| 460 |
$bodyclass = "frozen"; |
$bodyclass = "frozen"; |
| 461 |
} |
} |
| 462 |
$bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/; |
$bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/; |
| 463 |
print qq{Refresh: 0; url="$option{-goto}"\n} if $option{-goto}; |
if ($option{-goto}) { |
| 464 |
|
if ($UA =~ m#Mozilla/2|Opera#) { |
| 465 |
|
$option{-goto} =~ tr/;/&/; |
| 466 |
|
print qq{Refresh: 0; url=$option{-goto}\n}; |
| 467 |
|
} else { |
| 468 |
|
print qq{Refresh: 0; url="$option{-goto}"\n}; |
| 469 |
|
} |
| 470 |
|
} |
| 471 |
print qq{Last-Modified: $option{-last_modified}\n} if $option{-last_modified}; |
print qq{Last-Modified: $option{-last_modified}\n} if $option{-last_modified}; |
| 472 |
|
my $meta_ct = ''; |
| 473 |
|
if ($UA =~ m#Mozilla/2#) { |
| 474 |
|
$meta_ct = qq{text/html; charset=@{[&x_charset($charset)]}}; |
| 475 |
|
print qq{Content-Type: $meta_ct\n}; |
| 476 |
|
$meta_ct = qq{<meta http-equiv="content-type" content="$meta_ct">}; |
| 477 |
|
} else { |
| 478 |
|
print qq{Content-Type: text/html; charset=$charset\n}; |
| 479 |
|
} |
| 480 |
my $cookedpage = &encode($page); |
my $cookedpage = &encode($page); |
| 481 |
my $escapedpage = &escape($page); |
my $escapedpage = &escape($page); |
| 482 |
print <<"EOD"; |
print <<"EOD"; |
|
Content-type: text/html; charset=$charset |
|
| 483 |
Content-Language: $lang |
Content-Language: $lang |
| 484 |
Content-Style-Type: text/css |
Content-Style-Type: text/css |
| 485 |
|
|
| 489 |
"http://www.w3.org/TR/html4/loose.dtd"> + RUBY --> |
"http://www.w3.org/TR/html4/loose.dtd"> + RUBY --> |
| 490 |
<html lang="$lang"> |
<html lang="$lang"> |
| 491 |
<head> |
<head> |
| 492 |
|
$meta_ct |
| 493 |
<title>$escapedpage</title> |
<title>$escapedpage</title> |
| 494 |
<link rel="index" href="$url_cgi?$IndexPage"> |
<link rel="index" href="$url_cgi?$IndexPage"> |
| 495 |
<link rel="help" href="$url_cgi?WikiHelp"> |
<link rel="help" href="$url_cgi?WikiHelp"> |
| 505 |
EOD |
EOD |
| 506 |
} |
} |
| 507 |
|
|
| 508 |
|
sub x_charset ($) { |
| 509 |
|
my $charset = lc shift; |
| 510 |
|
if ($charset eq 'euc-jp') { |
| 511 |
|
$charset = 'x-euc-jp'; |
| 512 |
|
} elsif ($charset eq 'shift_jis') { |
| 513 |
|
$charset = 'x-sjis'; |
| 514 |
|
} |
| 515 |
|
$charset; |
| 516 |
|
} |
| 517 |
|
|
| 518 |
sub print_navigate_links (@) { |
sub print_navigate_links (@) { |
| 519 |
my ($page) = @_; |
my ($page) = @_; |
| 520 |
my $editable = 0; |
my $editable = 0; |
| 540 |
qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">編集</a> | ) |
qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">編集</a> | ) |
| 541 |
: qq() |
: qq() |
| 542 |
]} |
]} |
| 543 |
|
<a href="$url_cgi?mycmd=read;mypage=$cookedpage;x-param=@{[time.[0..9]->[rand 10]]}">表示</a> | |
| 544 |
@{[ $admineditable |
@{[ $admineditable |
| 545 |
? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | ) |
? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | ) |
| 546 |
: qq() |
: qq() |
| 767 |
sub inline { |
sub inline { |
| 768 |
my ($line) = @_; |
my ($line) = @_; |
| 769 |
$line = &escape($line); |
$line = &escape($line); |
| 770 |
$line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3</@{[lc $1]}>}g; |
$line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD|SAMP|DFN)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3</@{[lc $1]}>}g; |
| 771 |
$line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g; |
$line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g; |
| 772 |
$line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g; |
$line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g; |
| 773 |
$line =~ s:\[RUBYB\[([^]]+)\] \[([^]]+)\] \[([^]]+)\]\]:<span class="ruby"><ruby class="rb"><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby><span class="rp"> (</span><span class="rt-below">$3</span><span class="rp">) </span></span>:g; |
$line =~ s:\[RUBYB\[([^]]+)\] \[([^]]+)\] \[([^]]+)\]\]:<span class="ruby"><ruby class="rb"><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby><span class="rp"> (</span><span class="rt-below">$3</span><span class="rp">) </span></span>:g; |
| 824 |
if ($interwiki{$site}) { |
if ($interwiki{$site}) { |
| 825 |
my $uri = &escape ($fmt{interwiki}->replace ($interwiki{$site} => {site => $site, name => $name})); |
my $uri = &escape ($fmt{interwiki}->replace ($interwiki{$site} => {site => $site, name => $name})); |
| 826 |
$site = &escape ($site); $name = &escape ($name); |
$site = &escape ($site); $name = &escape ($name); |
| 827 |
qq(<<a href="$uri" class="out-of-wiki interwiki" title="$name ($site); URI: <$uri>">$name</a>>); |
qq(<<a href="$uri" class="out-of-wiki interwiki" title="$name ($site); URI: <$uri>"><span class="interwiki-site">$site:</span><span class="interwiki-name">$name</span></a>>); |
| 828 |
} else { |
} else { |
| 829 |
qq(<未登録の <a href="$url_cgi?InterWikiName" class="wiki">InterWikiName</a>: @{[&escape ($site)]}>); |
qq(<未登録の <a href="$url_cgi?InterWikiName" class="wiki">InterWikiName</a>: @{[&escape ($site)]}>); |
| 830 |
} |
} |
| 891 |
$form{$var} = param($var); |
$form{$var} = param($var); |
| 892 |
} |
} |
| 893 |
} |
} |
| 894 |
if ($main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;]/) { |
$form{mypage} = &code_convert(\$form{mypage}, $kanjicode); |
| 895 |
|
if ($main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;=]/) { |
| 896 |
my $query = &decode($main::ENV{QUERY_STRING}); |
my $query = &decode($main::ENV{QUERY_STRING}); |
| 897 |
|
$query = &code_convert(\$query, $kanjicode); |
| 898 |
if ($page_command{$query}) { |
if ($page_command{$query}) { |
| 899 |
$form{mycmd} = $page_command{$query}; |
$form{mycmd} = $page_command{$query}; |
| 900 |
$form{mypage} = $query; |
$form{mypage} = $query; |
| 904 |
} |
} |
| 905 |
} |
} |
| 906 |
$form{mypage} ||= 'HomePage'; |
$form{mypage} ||= 'HomePage'; |
| 907 |
|
$form{mycmd} ||= 'read'; |
| 908 |
|
|
| 909 |
# mypreview_edit -> do_edit, with preview. |
# mypreview_edit -> do_edit, with preview. |
| 910 |
# mypreview_adminedit -> do_adminedit, with preview. |
# mypreview_adminedit -> do_adminedit, with preview. |
| 939 |
unshift @updates, $update; |
unshift @updates, $update; |
| 940 |
} |
} |
| 941 |
splice(@updates, $maxrecent + 1); |
splice(@updates, $maxrecent + 1); |
| 942 |
$database{$RecentChanges} = join("\n", @updates); |
$database{$RecentChanges} = "#?SuikaWiki/0.9\n" . join("\n", @updates); |
| 943 |
if ($file_touch) { |
if ($file_touch) { |
| 944 |
open(FILE, "> $file_touch"); |
open(FILE, "> $file_touch"); |
| 945 |
print FILE localtime() . "\n"; |
print FILE localtime() . "\n"; |
| 1227 |
$fmt{interwiki}->{encoded} = sub { |
$fmt{interwiki}->{encoded} = sub { |
| 1228 |
my ($o, $p) = @_; |
my ($o, $p) = @_; |
| 1229 |
if ($o->{except}) { |
if ($o->{except}) { |
| 1230 |
$o->{except} =~ tr/\x00-\x20<>\x23%\x22{|}\x5C^[]`\x7F-\xFF//d; |
$o->{except} =~ tr/\x00-\x20\x22\x23%\x2D<>^[\x5C]`{|}\x7F-\xFF//d; |
| 1231 |
} |
} |
| 1232 |
my $s = &code_convert (\$p->{name}, $o->{charset} || 'iso-2022-7bit'); |
my $s = &code_convert (\$p->{name}, $o->{charset} || 'iso-2022-7bit'); |
| 1233 |
$s =~ s/([^$o->{except}A-Za-z0-9_-])/sprintf '%02X', unpack 'C', $1/ge; |
$s =~ s/([^$o->{except}A-Za-z0-9_-])/sprintf '%%%02X', unpack 'C', $1/ge; |
| 1234 |
$s; |
$s; |
| 1235 |
}; |
}; |
| 1236 |
$fmt{interwiki}->{ykwk} = sub { ## YukiWiki1 |
$fmt{interwiki}->{ykwk} = sub { ## YukiWiki1 |
| 1440 |
$code = 'euc' if $code =~ /euc/; |
$code = 'euc' if $code =~ /euc/; |
| 1441 |
$code = 'sjis' if $code =~ /shift/; |
$code = 'sjis' if $code =~ /shift/; |
| 1442 |
$code = 'utf8' if $code =~ /utf/; |
$code = 'utf8' if $code =~ /utf/; |
| 1443 |
# &Jcode::convert($contentref, $code); # for Jcode.pm |
&Jcode::convert($contentref, $code); # for Jcode.pm |
| 1444 |
&jcode::convert($contentref, $code); # for jcode.pl |
# &jcode::convert($contentref, $code); # for jcode.pl |
| 1445 |
|
&jcode::tr ($contentref, "\xA3\xB0-\xA3\xB9\xA3\xC1-\xA3\xDA\xA3\xE1-\xA3\xFA\xA1\xF5\xA1\xA4\xA1\xA5\xA1\xA7\xA1\xA8\xA1\xA9\xA1\xAA\xA1\xAE\xA1\xB0\xA1\xB2\xA1\xBF\xA1\xC3\xA1\xCA\xA1\xCB\xA1\xCE\xA1\xCF\xA1\xD0\xA1\xD1\xA1\xDC\xA1\xF0\xA1\xF3\xA1\xF4\xA1\xF6\xA1\xF7\xA1\xE1\xA2\xAF\xA2\xB0\xA2\xB2\xA2\xB1\xA1\xE4\xA1\xE3\xA1\xC0\xA1\xA1" => q(0-9A-Za-z&,.:;?!`^_/|()[]{}+$%#*@='"~-><\ )) if $code eq 'euc'; |
| 1446 |
return $$contentref; |
return $$contentref; |
| 1447 |
} |
} |
| 1448 |
|
|
| 1582 |
} |
} |
| 1583 |
|
|
| 1584 |
sub __get_database ($) { $database{ $_[0] } } |
sub __get_database ($) { $database{ $_[0] } } |
| 1585 |
|
sub __set_database ($$) { $database{ $_[0] } = $_[1] } |
| 1586 |
|
|
| 1587 |
package wiki::referer; |
package wiki::referer; |
| 1588 |
sub add ($$) { |
sub add ($$) { |
| 1664 |
main::code_convert (\$s); |
main::code_convert (\$s); |
| 1665 |
} |
} |
| 1666 |
|
|
| 1667 |
|
package wiki::useragent; |
| 1668 |
|
|
| 1669 |
|
sub add ($) { |
| 1670 |
|
my $s = shift; |
| 1671 |
|
return unless length $s; |
| 1672 |
|
$s =~ s/([\x00-\x08\x0A-\x1F\x25\x7F-\xFF])/sprintf '%%%02X', unpack 'C', $1/g; |
| 1673 |
|
my %ua; |
| 1674 |
|
for (split /\n/, &main::__get_database('WikiUserAgentList')) { |
| 1675 |
|
if (/^-\[(\d+)\] (.+)$/) { |
| 1676 |
|
my ($t, $n) = ($1, $2); |
| 1677 |
|
$n =~ tr/\x0A\x0D//d; |
| 1678 |
|
$ua{$n} = $t; |
| 1679 |
|
} |
| 1680 |
|
} |
| 1681 |
|
$ua{$s}++; |
| 1682 |
|
my $s = qq(#?SuikaWiki/0.9\n); |
| 1683 |
|
for (sort {$ua{$a} <=> $ua{$b}} keys %ua) { |
| 1684 |
|
$s .= sprintf qq(-[%d] %s\n), $ua{$_}, $_; |
| 1685 |
|
} |
| 1686 |
|
&main::__set_database ('WikiUserAgentList' => $s); |
| 1687 |
|
} |
| 1688 |
|
|
| 1689 |
1; |
1; |
| 1690 |
__END__ |
__END__ |
| 1691 |
=head1 NAME |
=head1 NAME |