18 |
form => qr/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, |
form => qr/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, |
19 |
); |
); |
20 |
our ($modifier_dbtype,$url_cgi,%uri,%PathTo,$use_exists); |
our ($modifier_dbtype,$url_cgi,%uri,%PathTo,$use_exists); |
21 |
our (%PageName,$kanjicode,$lang,%fixedpage); |
our (%PageName,$kanjicode,$lang,%FixedPage); |
22 |
|
|
23 |
############################## |
############################## |
24 |
my $info_LastModified = 'LastModified'; |
my $info_LastModified = 'LastModified'; |
33 |
my %page_command = ( |
my %page_command = ( |
34 |
$PageName{IndexPage} => 'index', |
$PageName{IndexPage} => 'index', |
35 |
$PageName{RssPage} => 'rss', |
$PageName{RssPage} => 'rss', |
|
AdminChangePassword => 'adminchangepasswordform', |
|
36 |
); |
); |
37 |
my %command_do = ( |
my %command_do = ( |
38 |
read => \&do_read, |
read => \&do_read, |
39 |
TEXT_CSS => \&do_output_css, |
TEXT_CSS => \&do_output_css, |
40 |
edit => \&do_edit, |
edit => \&do_edit, |
41 |
adminedit => \&do_adminedit, |
adminedit => \&do_adminedit, |
|
adminchangepasswordform => \&do_adminchangepasswordform, |
|
42 |
adminchangepassword => \&do_adminchangepassword, |
adminchangepassword => \&do_adminchangepassword, |
43 |
write => \&do_write, |
write => \&do_write, |
44 |
index => \&do_index, |
index => \&do_index, |
91 |
#print "\n". gmtime."Body...\n"; |
#print "\n". gmtime."Body...\n"; |
92 |
&print_content ($content, content_format => $cf, last_modified => $lm, |
&print_content ($content, content_format => $cf, last_modified => $lm, |
93 |
-toc => \@toc); |
-toc => \@toc); |
94 |
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}}; |
95 |
} else { |
} else { |
96 |
&print_header($form{mypage}, -expires => time + 120, -last_modified => $lm); |
&print_header($form{mypage}, -expires => time + 120, -last_modified => $lm); |
97 |
print "<pre>@{[&escape($content)]}</pre>"; |
print "<pre>@{[&escape($content)]}</pre>"; |
139 |
sub do_edit { |
sub do_edit { |
140 |
my ($page) = &unarmor_name(&armor_name($form{mypage})); |
my ($page) = &unarmor_name(&armor_name($form{mypage})); |
141 |
if (not &is_editable($page)) { |
if (not &is_editable($page)) { |
142 |
&print_header($page, -noindex => 1); |
&print_header($page, -noindex => 1, -expires => time+60); |
143 |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
144 |
} elsif (&is_frozen($page)) { |
} elsif (&is_frozen($page)) { |
145 |
&print_header($page, -noindex => 1); |
&print_header($page, -noindex => 1, -expires => time+60); |
146 |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
147 |
} else { |
} else { |
148 |
&print_header($page, -noindex => 1, -expires => time+60); |
&print_header($page, -noindex => 1, -expires => time+60); |
164 |
|
|
165 |
sub do_adminedit { |
sub do_adminedit { |
166 |
my ($page) = &unarmor_name(&armor_name($form{mypage})); |
my ($page) = &unarmor_name(&armor_name($form{mypage})); |
167 |
&print_header($page, -noindex => 1); |
&print_header($page, -noindex => 1, -expires => time+60); |
168 |
if (not &is_editable($page)) { |
if (not &is_editable($page)) { |
169 |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
170 |
} else { |
} else { |
174 |
&print_footer($page); |
&print_footer($page); |
175 |
} |
} |
176 |
|
|
|
sub do_adminchangepasswordform { |
|
|
&print_header('AdminChangePassword', -noindex => 1); |
|
|
&print_passwordform; |
|
|
&print_footer('AdminChangePassword'); |
|
|
} |
|
|
|
|
177 |
sub do_adminchangepassword { |
sub do_adminchangepassword { |
178 |
if ($form{mynewpassword} ne $form{mynewpassword2}) { |
if ($form{mynewpassword} ne $form{mynewpassword2}) { |
179 |
&print_error(&Resource('Error:PasswordMismatch')); |
&print_error(&Resource('Error:PasswordMismatch')); |
181 |
my ($validpassword_crypt) = &get_info($PageName{AdminSpecialPage}, 'AdminPassword'); |
my ($validpassword_crypt) = &get_info($PageName{AdminSpecialPage}, 'AdminPassword'); |
182 |
if ($validpassword_crypt) { |
if ($validpassword_crypt) { |
183 |
if (not &valid_password($form{myoldpassword})) { |
if (not &valid_password($form{myoldpassword})) { |
|
# &send_mail_to_admin(<<"EOD", "AdminChangePassword"); |
|
|
#myoldpassword=$form{myoldpassword} |
|
|
#mynewpassword=$form{mynewpassword} |
|
|
#mynewpassword2=$form{mynewpassword2} |
|
|
#EOD |
|
184 |
&print_error(&Resource('Error:PasswordIsIncorrect')); |
&print_error(&Resource('Error:PasswordIsIncorrect')); |
185 |
} |
} |
186 |
} |
} |
196 |
&print_footer('CompletedSuccessfully'); |
&print_footer('CompletedSuccessfully'); |
197 |
} |
} |
198 |
|
|
199 |
|
sub valid_password ($) { |
200 |
|
my ($validpassword_crypt) = &get_info($PageName{AdminSpecialPage}, 'AdminPassword'); |
201 |
|
return crypt (shift, $validpassword_crypt) eq $validpassword_crypt ? 1 : 0; |
202 |
|
} |
203 |
|
|
204 |
sub do_index { |
sub do_index { |
205 |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
206 |
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
251 |
|
|
252 |
if ($form{mymsg}) { |
if ($form{mymsg}) { |
253 |
$database{$form{mypage}} = $form{mymsg}; |
$database{$form{mypage}} = $form{mymsg}; |
|
#&send_mail_to_admin($form{mypage}, "Modify"); |
|
254 |
if ($form{mytouch}) { |
if ($form{mytouch}) { |
255 |
&set_info($form{mypage}, $info_LastModified, time); |
&set_info($form{mypage}, $info_LastModified, time); |
256 |
&update_recent_changes; |
&update_recent_changes; |
268 |
&print_content(&Resource('Error:ContinueReading')." @{[&armor_name($form{mypage})]}"); |
&print_content(&Resource('Error:ContinueReading')." @{[&armor_name($form{mypage})]}"); |
269 |
&print_footer('CompletedSuccessfully'); |
&print_footer('CompletedSuccessfully'); |
270 |
} else { |
} else { |
|
#&send_mail_to_admin($form{mypage}, "Delete"); |
|
271 |
delete $database{$form{mypage}}; |
delete $database{$form{mypage}}; |
272 |
delete $infobase{$form{mypage}}; |
delete $infobase{$form{mypage}}; |
273 |
if ($form{mytouch}) { |
if ($form{mytouch}) { |
741 |
$param->{output}->{form} = 1 unless defined $param->{output}->{form}; |
$param->{output}->{form} = 1 unless defined $param->{output}->{form}; |
742 |
$definition .= ' %submit;' if $definition !~ /%submit/ && !$param->{output}->{nosubmit} && $param->{output}->{form}; |
$definition .= ' %submit;' if $definition !~ /%submit/ && !$param->{output}->{nosubmit} && $param->{output}->{form}; |
743 |
my $target_page = $param->{output}->{page} || $form{mypage}; |
my $target_page = $param->{output}->{page} || $form{mypage}; |
744 |
$param->{form_disabled} = 1 if $fixedpage{$target_page}; |
$param->{form_disabled} = 1 if $FixedPage{$target_page}; |
745 |
my $target_form = $param->{output}->{id}; |
my $target_form = $param->{output}->{id}; |
746 |
my $r = ''; |
my $r = ''; |
747 |
$r = <<EOH if $param->{output}->{form}; |
$r = <<EOH if $param->{output}->{form}; |
942 |
$magic = $1 if $mymsg =~ m/^([^\x0A\x0D]+)/s; |
$magic = $1 if $mymsg =~ m/^([^\x0A\x0D]+)/s; |
943 |
|
|
944 |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
|
my $escapedmypage = &escape($form{mypage}); |
|
|
my $escapedmypassword = &escape($form{mypassword}); |
|
945 |
my $selected = 'read'; |
my $selected = 'read'; |
946 |
if ($form{after_edit_cmd}) { |
if ($form{after_edit_cmd}) { |
947 |
$selected = $form{after_edit_cmd}; |
$selected = $form{after_edit_cmd}; |
959 |
<form action="$url_cgi" method="post"> |
<form action="$url_cgi" method="post"> |
960 |
<h2>@{[&Resource('Edit:Title',escape=>1)]}</h2> |
<h2>@{[&Resource('Edit:Title',escape=>1)]}</h2> |
961 |
@{[ $mode{conflict} ? '' : qq(<input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}"><kbd>S</kbd>) ]} |
@{[ $mode{conflict} ? '' : qq(<input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}"><kbd>S</kbd>) ]} |
962 |
@{[ $mode{admin} ? qq(<label>@{[&Resource('Edit:Password=',escape=>1)]}<input type="password" name="mypassword" value="$escapedmypassword" size="10"></label>) : "" ]} [@{[do {my $n = 0; |
@{[ $mode{admin} ? qq(<label>@{[&Resource('Edit:Password=',escape=>1)]}<input type="password" name="mypassword" value="" size="10"></label>) : "" ]} [@{[do {my $n = 0; |
963 |
$mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge; |
$mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge; |
964 |
++$n}]}]<br> |
++$n}]}]<br> |
965 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
966 |
<input type="hidden" name="mypage" value="$escapedmypage"> |
<input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}"> |
967 |
<textarea cols="@{[&Resource('Edit:Form:Cols')+0||80]}" rows="@{[&Resource('Edit:Form:Rows')+0||20]}" name="mymsg" tabindex="1">$mymsg</textarea><br> |
<textarea cols="@{[&Resource('Edit:Form:Cols')+0||80]}" rows="@{[&Resource('Edit:Form:Rows')+0||20]}" name="mymsg" tabindex="1">$mymsg</textarea><br> |
968 |
@{[ |
@{[ |
969 |
$mode{admin} ? |
$mode{admin} ? |
975 |
@{[ |
@{[ |
976 |
$mode{conflict} ? "" : |
$mode{conflict} ? "" : |
977 |
qq( |
qq( |
978 |
<input type="checkbox" name="mytouch" value="on" checked="checked">@{[&Resource('Edit:UpdateTimeStamp',escape=>1)]}<br> |
<label><input type="checkbox" name="mytouch" value="on" checked="checked">@{[&Resource('Edit:UpdateTimeStamp',escape=>1)]}</label><br> |
979 |
<input type="submit" name="mypreview_$edit" value="@{[&Resource('Edit:Preview',escape=>1)]}"> |
<input type="submit" name="mypreview_$edit" value="@{[&Resource('Edit:Preview',escape=>1)]}"> |
980 |
<input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}" accesskey="S"><kbd>S</kbd> |
<label><input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}" accesskey="S"><kbd>S</kbd></label> |
981 |
$afteredit |
$afteredit |
|
<br> |
|
982 |
) |
) |
983 |
]} |
]} |
984 |
</form> |
</form> |
991 |
} |
} |
992 |
} |
} |
993 |
|
|
|
sub print_passwordform { |
|
|
print <<"EOD"; |
|
|
<form action="$url_cgi" method="post"> |
|
|
<input type="hidden" name="mycmd" value="adminchangepassword"> |
|
|
<label>@{[&Resource('Password:Old=',escape=>1)]}<input type="password" name="myoldpassword" size="10"></label><br> |
|
|
<label>@{[&Resource('Password:New1=',escape=>1)]}<input type="password" name="mynewpassword" size="10"></label><br> |
|
|
<label>@{[&Resource('Password:New2=',escape=>1)]}<input type="password" name="mynewpassword2" size="10"></label><br> |
|
|
<input type="submit" value="@{[&Resource('WikiForm:Change',escape=>1)]}"><br> |
|
|
</form> |
|
|
EOD |
|
|
} |
|
|
|
|
994 |
sub is_editable { |
sub is_editable { |
995 |
my ($page) = @_; |
my ($page) = @_; |
996 |
if ($fixedpage{$page} || $page =~ /\s/ || $page =~ /^\#/) { |
if ($FixedPage{$page} || $page =~ /\s/ || $page =~ /^\#/) { |
997 |
return 0; |
return 0; |
998 |
} else { |
} else { |
999 |
return 1; |
return 1; |
1104 |
} |
} |
1105 |
} |
} |
1106 |
|
|
|
sub valid_password { |
|
|
my ($givenpassword) = @_; |
|
|
my ($validpassword_crypt) = &get_info($PageName{AdminSpecialPage}, 'AdminPassword'); |
|
|
if (crypt($givenpassword, $validpassword_crypt) eq $validpassword_crypt) { |
|
|
return 1; |
|
|
} else { |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
1107 |
sub is_frozen { |
sub is_frozen { |
1108 |
my ($page) = @_; |
my ($page) = @_; |
1109 |
if (&get_info($page, $info_IsFrozen)) { |
if (&get_info($page, $info_IsFrozen)) { |
1501 |
} |
} |
1502 |
|
|
1503 |
package wiki::useragent; |
package wiki::useragent; |
1504 |
|
our $UseLog; |
1505 |
|
|
1506 |
sub add ($) { |
sub add ($) { |
1507 |
my $s = shift; |
my $s = shift; |
1508 |
return unless length $s; |
return unless length $s; |
1509 |
|
return unless $UseLog; |
1510 |
$s =~ s/([\x00-\x08\x0A-\x1F\x25\x7F-\xFF])/sprintf '%%%02X', unpack 'C', $1/ge; |
$s =~ s/([\x00-\x08\x0A-\x1F\x25\x7F-\xFF])/sprintf '%%%02X', unpack 'C', $1/ge; |
1511 |
my %ua; |
my %ua; |
1512 |
for (split /\n/, &main::__get_database('WikiUserAgentList')) { |
for (split /\n/, &main::__get_database($main::PageName{UserAgentList})) { |
1513 |
if (/^-\[(\d+)\] (.+)$/) { |
if (/^-\[(\d+)\] (.+)$/) { |
1514 |
my ($t, $n) = ($1, $2); |
my ($t, $n) = ($1, $2); |
1515 |
$n =~ tr/\x0A\x0D//d; |
$n =~ tr/\x0A\x0D//d; |
1521 |
for (sort {$ua{$a} <=> $ua{$b}} keys %ua) { |
for (sort {$ua{$a} <=> $ua{$b}} keys %ua) { |
1522 |
$s .= sprintf qq(-[%d] %s\n), $ua{$_}, $_; |
$s .= sprintf qq(-[%d] %s\n), $ua{$_}, $_; |
1523 |
} |
} |
1524 |
&main::__set_database ('WikiUserAgentList' => $s); |
&main::__set_database ($main::PageName{UserAgentList} => $s); |
1525 |
} |
} |
1526 |
|
|
1527 |
package wiki::suikawikiconst; |
package wiki::suikawikiconst; |