21 |
our (%PageName,$kanjicode,$lang,%FixedPage); |
our (%PageName,$kanjicode,$lang,%FixedPage); |
22 |
|
|
23 |
############################## |
############################## |
|
my $info_LastModified = 'LastModified'; |
|
|
my $info_IsFrozen = 'IsFrozen'; |
|
|
############################## |
|
24 |
my %form; |
my %form; |
25 |
our %database; |
our %database; |
26 |
our $database; |
our $database = bless {}, 'wiki::dummy'; |
|
my %infobase; |
|
27 |
my %interwiki; |
my %interwiki; |
28 |
############################## |
############################## |
29 |
my %page_command = ( |
my %page_command = ( |
62 |
|
|
63 |
sub do_read { |
sub do_read { |
64 |
my $content = $database{$form{mypage}}; |
my $content = $database{$form{mypage}}; |
65 |
#print "content-type:text/plain;charset=euc-jp\n\n".gmtime."Get Lastmodified\n"; |
my $lm = $database->mtime ($form{mypage}); |
|
my $lm = &get_info($form{mypage}, $info_LastModified); |
|
66 |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
67 |
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
|
#print gmtime."Search...\n"; |
|
68 |
my ($r, $c) = get_search_result ($form{mypage}); |
my ($r, $c) = get_search_result ($form{mypage}); |
69 |
my $rl = wiki::referer::list_html ($form{mypage}); |
my $rl = wiki::referer::list_html ($form{mypage}); |
70 |
my @toc; |
my @toc; |
77 |
## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF |
## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF |
78 |
$cf = $1 if $content =~ s#^(?:/\*\s*|[\#<]\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\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; |
79 |
if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) { |
if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) { |
80 |
#print gmtime."Header...\n"; |
my $expires = time; |
81 |
&print_header ($form{mypage}, -last_modified => $lm, -expires => time + 120, |
if ($cf =~ /interactive="yes"/) { |
82 |
|
$lm = $expires; |
83 |
|
} else { |
84 |
|
$expires += 120; |
85 |
|
} |
86 |
|
&print_header ($form{mypage}, -last_modified => $lm, -expires => $expires, |
87 |
-content_format => $cf, -noindex => ($cf =~ /obsoleted="yes"/ ? 1 : 0)); |
-content_format => $cf, -noindex => ($cf =~ /obsoleted="yes"/ ? 1 : 0)); |
|
#print "\n". gmtime."Body...\n"; |
|
88 |
&print_content ($content, content_format => $cf, last_modified => $lm, |
&print_content ($content, content_format => $cf, last_modified => $lm, |
89 |
-toc => \@toc); |
-toc => \@toc); |
90 |
print &text_to_html (q([[#comment]])) if $cf !~ /obsoleted="yes"/ && !$FixedPage{$form{mypage}}; |
print &text_to_html (q([[#comment]])) if $cf !~ /obsoleted="yes"/ && !$FixedPage{$form{mypage}}; |
109 |
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
110 |
my $content = $database{$form{mypage}}; |
my $content = $database{$form{mypage}}; |
111 |
if ($content =~ m#^\s*/\*\s*W3C-CSS#) { |
if ($content =~ m#^\s*/\*\s*W3C-CSS#) { |
112 |
my $lm = gmtime &get_info($form{mypage}, $info_LastModified); |
my $lm = gmtime $database->mtime ($form{mypage}); |
113 |
print "Content-Type: text/css; charset=@{[&get_charset_name($kanjicode)]}\n"; |
print "Content-Type: text/css; charset=@{[&get_charset_name($kanjicode)]}\n"; |
114 |
print "Last-Modified: $lm\n"; |
print "Last-Modified: $lm\n"; |
115 |
print "Expires: @{[scalar gmtime time+3600]}\n"; ## TODO: don't use asctime |
print "Expires: @{[scalar gmtime time+3600]}\n"; ## TODO: don't use asctime |
142 |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
143 |
} else { |
} else { |
144 |
&print_header($page, -noindex => 1, -expires => time+60); |
&print_header($page, -noindex => 1, -expires => time+60); |
145 |
&print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0); |
&print_editform($database{$page}, $database->mtime ($page), admin=>0); |
146 |
} |
} |
147 |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
148 |
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
165 |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
166 |
} else { |
} else { |
167 |
&print_message(&Resource('Error:PasswordIsNotSpecified')); |
&print_message(&Resource('Error:PasswordIsNotSpecified')); |
168 |
&print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>1); |
&print_editform($database{$page}, $database->mtime ($page), admin=>1); |
169 |
} |
} |
170 |
&print_footer($page); |
&print_footer($page); |
171 |
} |
} |
174 |
if ($form{mynewpassword} ne $form{mynewpassword2}) { |
if ($form{mynewpassword} ne $form{mynewpassword2}) { |
175 |
&print_error(&Resource('Error:PasswordMismatch')); |
&print_error(&Resource('Error:PasswordMismatch')); |
176 |
} |
} |
177 |
my ($validpassword_crypt) = &get_info($PageName{AdminSpecialPage}, 'AdminPassword'); |
my ($validpassword_crypt) = $database->meta (AdminPassword => $PageName{AdminSpecialPage}); |
178 |
if ($validpassword_crypt) { |
if ($validpassword_crypt) { |
179 |
if (not &valid_password($form{myoldpassword})) { |
if (not &valid_password($form{myoldpassword})) { |
180 |
&print_error(&Resource('Error:PasswordIsIncorrect')); |
&print_error(&Resource('Error:PasswordIsIncorrect')); |
185 |
my $salt1 = $token[(time | $$) % scalar(@token)]; |
my $salt1 = $token[(time | $$) % scalar(@token)]; |
186 |
my $salt2 = $token[($sec + $min*60 + $hour*60*60) % scalar(@token)]; |
my $salt2 = $token[($sec + $min*60 + $hour*60*60) % scalar(@token)]; |
187 |
my $crypted = crypt($form{mynewpassword}, "$salt1$salt2"); |
my $crypted = crypt($form{mynewpassword}, "$salt1$salt2"); |
188 |
&set_info($PageName{AdminSpecialPage}, 'AdminPassword', $crypted); |
$database->meta (AdminPassword => $PageName{AdminSpecialPage} => $crypted); |
189 |
|
|
190 |
&print_header('CompletedSuccessfully', -noindex => 1); |
&print_header('CompletedSuccessfully', -noindex => 1); |
191 |
&print_message(&Resource('Error:PasswordIsChanged')); |
&print_message(&Resource('Error:PasswordIsChanged')); |
193 |
} |
} |
194 |
|
|
195 |
sub valid_password ($) { |
sub valid_password ($) { |
196 |
my ($validpassword_crypt) = &get_info($PageName{AdminSpecialPage}, 'AdminPassword'); |
my ($validpassword_crypt) = $database->meta (AdminPassword => $PageName{AdminSpecialPage}); |
197 |
return crypt (shift, $validpassword_crypt) eq $validpassword_crypt ? 1 : 0; |
return crypt (shift, $validpassword_crypt) eq $validpassword_crypt ? 1 : 0; |
198 |
} |
} |
199 |
|
|
219 |
} else { |
} else { |
220 |
$database->STORE ($form{mypage} => $form{mymsg}, -touch => 0); |
$database->STORE ($form{mypage} => $form{mymsg}, -touch => 0); |
221 |
} |
} |
222 |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
$database->meta (IsFrozen => $form{mypage} => 0 + $form{myfrozen}); |
223 |
my $fragment = ''; |
my $fragment = ''; |
224 |
$fragment .= qq(;after_edit_cmd=@{[&encode($form{after_edit_cmd})]}) if $form{after_edit_cmd}; |
$fragment .= qq(;after_edit_cmd=@{[&encode($form{after_edit_cmd})]}) if $form{after_edit_cmd}; |
225 |
if ($form{__comment_anchor_index}) { |
if ($form{__comment_anchor_index}) { |
233 |
&print_footer('CompletedSuccessfully'); |
&print_footer('CompletedSuccessfully'); |
234 |
} else { |
} else { |
235 |
delete $database{$form{mypage}}; |
delete $database{$form{mypage}}; |
|
delete $infobase{$form{mypage}}; |
|
236 |
&print_header($form{mypage}, -noindex => 1); |
&print_header($form{mypage}, -noindex => 1); |
237 |
&print_message(&Resource('Error:PageIsDeletedSuccessfully')); |
&print_message(&Resource('Error:PageIsDeletedSuccessfully')); |
238 |
&print_footer($form{mypage}); |
&print_footer($form{mypage}); |
312 |
} |
} |
313 |
push @head, qq(<title>@{[&escape($page)]}</title>); |
push @head, qq(<title>@{[&escape($page)]}</title>); |
314 |
if ($UA !~ m#Mozilla/[1-4]\.# || $UA =~ m#MSIE (?:[4-9]\.|\d\d)#) { |
if ($UA !~ m#Mozilla/[1-4]\.# || $UA =~ m#MSIE (?:[4-9]\.|\d\d)#) { |
315 |
push @head, qq(<link rel="stylesheet" type="text/css" href="@{[&escape($uri{wiki}.'?mycmd=TEXT_CSS;mypage='.&encode($PageName{DefaultStyleForHTML}).';x-lm='.&get_info($PageName{DefaultStyleForHTML}, $info_LastModified))]}"); |
push @head, qq(<link rel="stylesheet" type="text/css"). |
316 |
|
qq( href="@{[&escape($uri{wiki}.'?mycmd=TEXT_CSS;mypage='.&encode($PageName{DefaultStyleForHTML}).';x-lm='.$database->mtime ($PageName{DefaultStyleForHTML}))]}"); |
317 |
} |
} |
318 |
push @head, q(<meta name="ROBOTS" content="NOINDEX">) if $option{-noindex}; |
push @head, q(<meta name="ROBOTS" content="NOINDEX">) if $option{-noindex}; |
319 |
my ($Links, $links) = &make_navigate_links ($page); |
my ($Links, $links) = &make_navigate_links ($page); |
691 |
$FormIndex++; |
$FormIndex++; |
692 |
if (length $definition) { |
if (length $definition) { |
693 |
my $param = bless {}, 'SuikaWiki::Plugin'; |
my $param = bless {}, 'SuikaWiki::Plugin'; |
694 |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
my $lastmodified = $database->mtime ($form{mypage}); |
695 |
&load_formatter (qw/form_input form_option/); |
&load_formatter (qw/form_input form_option/); |
696 |
$definition = &unescape ($definition); |
$definition = &unescape ($definition); |
697 |
$definition =~ s/\\(.)/$1/g; |
$definition =~ s/\\(.)/$1/g; |
809 |
sub open_db { |
sub open_db { |
810 |
if ($modifier_dbtype eq 'dbmopen') { |
if ($modifier_dbtype eq 'dbmopen') { |
811 |
dbmopen(%database, $PathTo{WikiDataBase}, 0666) or &print_error("(dbmopen) $PathTo{WikiDataBase}"); |
dbmopen(%database, $PathTo{WikiDataBase}, 0666) or &print_error("(dbmopen) $PathTo{WikiDataBase}"); |
|
dbmopen(%infobase, $PathTo{WikiInfoBase}, 0666) or &print_error("(dbmopen) $PathTo{WikiInfoBase}"); |
|
812 |
} elsif ($modifier_dbtype eq 'AnyDBM_File') { |
} elsif ($modifier_dbtype eq 'AnyDBM_File') { |
813 |
eval q{use AnyDBM_File}; |
eval q{use AnyDBM_File}; |
814 |
tie(%database, "AnyDBM_File", $PathTo{WikiDataBase}, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $PathTo{WikiDataBase}"); |
tie(%database, "AnyDBM_File", $PathTo{WikiDataBase}, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $PathTo{WikiDataBase}"); |
815 |
tie(%infobase, "AnyDBM_File", $PathTo{WikiInfoBase}, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $PathTo{WikiInfoBase}"); |
} elsif ($modifier_dbtype eq 'Yuki::YukiWikiDB') { |
|
} elsif ($modifier_dbtype eq 'YukiWikiDB') { |
|
816 |
eval q{use Yuki::YukiWikiDB}; |
eval q{use Yuki::YukiWikiDB}; |
817 |
tie(%database, "Yuki::YukiWikiDB", $PathTo{WikiDataBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiDataBase}"); |
tie(%database, "Yuki::YukiWikiDB", $PathTo{WikiDataBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiDataBase}"); |
818 |
tie(%infobase, "Yuki::YukiWikiDB", $PathTo{WikiInfoBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiInfoBase}"); |
} else { ## Yuki::YukiWikiDB || Yuki::YukiWikiDBMeta |
|
} else { |
|
819 |
eval qq{use $modifier_dbtype}; |
eval qq{use $modifier_dbtype}; |
820 |
$database = tie(%database, $modifier_dbtype => $PathTo{WikiDataBase}, -lock => 2, -backup => $wiki::diff::UseDiff) or &print_error("(tie $modifier_dbtype) $PathTo{WikiDataBase}"); |
$database = tie(%database, $modifier_dbtype => $PathTo{WikiDataBase}, -lock => 2, -backup => $wiki::diff::UseDiff) or &print_error("(tie $modifier_dbtype) $PathTo{WikiDataBase}"); |
|
tie(%infobase, $modifier_dbtype => $PathTo{WikiInfoBase}, -lock => 2) or &print_error("(tie $modifier_dbtype) $PathTo{WikiInfoBase}"); |
|
821 |
} |
} |
822 |
} |
} |
823 |
|
|
824 |
sub close_db { |
sub close_db { |
825 |
if ($modifier_dbtype eq 'dbmopen') { |
if ($modifier_dbtype eq 'dbmopen') { |
826 |
dbmclose(%database); |
dbmclose(%database); |
|
dbmclose(%infobase); |
|
827 |
} else { |
} else { |
828 |
untie(%database); |
untie(%database); |
|
untie(%infobase); |
|
829 |
} |
} |
830 |
} |
} |
831 |
|
|
950 |
|
|
951 |
sub conflict { |
sub conflict { |
952 |
my ($page, $rawmsg) = @_; |
my ($page, $rawmsg) = @_; |
953 |
if ($form{myLastModified} eq &get_info($page, $info_LastModified)) { |
if ($form{myLastModified} eq $database->mtime ($page)) { |
954 |
return 0; |
return 0; |
955 |
} |
} |
956 |
&print_header($page, -noindex => 1); |
&print_header($page, -noindex => 1); |
982 |
$interwiki{'[[]]'} = 1; ## dummy |
$interwiki{'[[]]'} = 1; ## dummy |
983 |
} |
} |
984 |
|
|
|
|
|
|
sub get_info { |
|
|
my ($page, $key) = @_; |
|
|
my %info = map { split(/=/, $_, 2) } split(/\n/, $infobase{$page}); |
|
|
return $info{$key}; |
|
|
} |
|
|
|
|
|
sub set_info { |
|
|
my ($page, $key, $value) = @_; |
|
|
my %info = map { split(/=/, $_, 2) } split(/\n/, $infobase{$page}); |
|
|
$info{$key} = $value; |
|
|
my $s = ''; |
|
|
for (keys %info) { |
|
|
$s .= "$_=$info{$_}\n"; |
|
|
} |
|
|
$infobase{$page} = $s; |
|
|
} |
|
|
|
|
985 |
sub frozen_reject { |
sub frozen_reject { |
986 |
my ($isfrozen) = &get_info($form{mypage}, $info_IsFrozen); |
my ($isfrozen) = $database->meta (IsFrozen => $form{mypage}); |
987 |
my ($willbefrozen) = $form{myfrozen}; |
my ($willbefrozen) = $form{myfrozen}; |
988 |
if (not $isfrozen and not $willbefrozen) { |
if (not $isfrozen and not $willbefrozen) { |
989 |
# You need no check. |
# You need no check. |
997 |
} |
} |
998 |
} |
} |
999 |
|
|
1000 |
sub is_frozen { |
sub is_frozen ($) { $database->meta (IsFrozen => $_[0]) ? 1 : 0 } |
|
my ($page) = @_; |
|
|
if (&get_info($page, $info_IsFrozen)) { |
|
|
return 1; |
|
|
} else { |
|
|
return 0; |
|
|
} |
|
|
} |
|
1001 |
|
|
1002 |
sub do_comment { |
sub do_comment { |
1003 |
my ($content) = $database{$form{mypage}}; |
my ($content) = $database{$form{mypage}}; |
1052 |
my ($embedded) = @_; |
my ($embedded) = @_; |
1053 |
if ($embedded eq '[[#comment]]' or $embedded eq '[[#rcomment]]') { |
if ($embedded eq '[[#comment]]' or $embedded eq '[[#rcomment]]') { |
1054 |
unless ($main::_EMBEDED) { |
unless ($main::_EMBEDED) { |
1055 |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
my $lastmodified = $database->mtime ($form{mypage}); |
1056 |
return <<"EOD"; |
return <<"EOD"; |
1057 |
<form action="$url_cgi" method="post" id="x-comment-@{[++$CommentIndex]}" class="comment"><p> |
<form action="$url_cgi" method="post" id="x-comment-@{[++$CommentIndex]}" class="comment"><p> |
1058 |
<input type="hidden" name="mycmd" value="comment"> |
<input type="hidden" name="mycmd" value="comment"> |
1234 |
title => &escape($title), |
title => &escape($title), |
1235 |
link => $myuri . '?' . &encode($title), |
link => $myuri . '?' . &encode($title), |
1236 |
description => &escape(&get_subjectline($title,delimiter=>'')), |
description => &escape(&get_subjectline($title,delimiter=>'')), |
1237 |
'dc:date' => &get_info ($title, $info_LastModified), |
'dc:date' => $database->mtime ($title), |
1238 |
); |
); |
1239 |
$count++; |
$count++; |
1240 |
} |
} |
1262 |
} |
} |
1263 |
|
|
1264 |
sub __get_database ($) { $database{ $_[0] } } |
sub __get_database ($) { $database{ $_[0] } } |
|
sub __set_database ($$) { $database{ $_[0] } = $_[1] } |
|
1265 |
|
|
1266 |
sub do_map { |
sub do_map { |
1267 |
my $page = $form{mypage}; |
my $page = $form{mypage}; |
1315 |
$list{ $uri }++; |
$list{ $uri }++; |
1316 |
set ($page, \%list); |
set ($page, \%list); |
1317 |
} |
} |
1318 |
sub get ($) { |
sub get ($) { split /"/, $main::database->meta (Referer => $_[0]) } |
|
my $page = shift; |
|
|
split /"/, main::get_info ($page, 'Referer'); |
|
|
} |
|
1319 |
sub set ($%) { |
sub set ($%) { |
1320 |
my $page = shift; |
my $page = shift; |
1321 |
my $list = shift; |
my $list = shift; |
1322 |
main::set_info ($page, Referer => join '"', %$list); |
$main::database->meta (Referer => $page => join '"', %$list); |
1323 |
} |
} |
1324 |
|
|
1325 |
sub get_dont_record () { |
sub get_dont_record () { |
1413 |
$h; |
$h; |
1414 |
} |
} |
1415 |
|
|
1416 |
|
package wiki::dummy; |
1417 |
|
sub mtime (@) {undef} |
1418 |
|
sub meta (@) {undef} |
1419 |
|
sub Yuki::YukiWikiDB2::meta (@) {undef} |
1420 |
|
|
1421 |
package SuikaWiki::Plugin; |
package SuikaWiki::Plugin; |
1422 |
our $plugin_directory; # defined in top of this file. |
our $plugin_directory; # defined in top of this file. |
1423 |
our %List; |
our %List; |