1 |
wakaba |
1.1 |
# -*- perl -*- |
2 |
|
|
use strict; |
3 |
|
|
|
4 |
|
|
package main; |
5 |
w |
1.9 |
our $VERSION = '2.'.do{my @r=(q$Revision: 1.8 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
6 |
wakaba |
1.1 |
binmode STDOUT; binmode STDIN; |
7 |
wakaba |
1.3 |
use Fcntl; |
8 |
wakaba |
1.1 |
require SuikaWiki::Plugin; |
9 |
|
|
our %embed_command = ( |
10 |
|
|
form => qr/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, |
11 |
|
|
); |
12 |
w |
1.9 |
our ($modifier_dbtype,%uri,%PathTo,%PageName,$kanjicode); |
13 |
wakaba |
1.1 |
|
14 |
wakaba |
1.6 |
our %form; |
15 |
wakaba |
1.1 |
our %database; |
16 |
|
|
our $database = bless {}, 'wiki::dummy'; |
17 |
|
|
my %command_do = ( |
18 |
|
|
default => \&do_view, |
19 |
|
|
adminchangepassword => \&do_adminchangepassword, |
20 |
|
|
write => \&do_write, |
21 |
|
|
comment => \&do_comment, |
22 |
w |
1.9 |
RandomJump => sub { |
23 |
|
|
my @list = keys %main::database; |
24 |
|
|
&main::_http_see_other (page => $list[rand @list]); |
25 |
|
|
}, |
26 |
wakaba |
1.1 |
wikiform => \&do_wikiform, |
27 |
|
|
); |
28 |
|
|
our $UA = ''; ## User agent name |
29 |
|
|
$| = 1; |
30 |
w |
1.9 |
require SuikaWiki::Name::Space; |
31 |
wakaba |
1.5 |
my $NS_XHTML1 = 'http://www.w3.org/1999/xhtml'; |
32 |
wakaba |
1.1 |
|
33 |
w |
1.9 |
sub _wiki_exit () { |
34 |
wakaba |
1.1 |
&close_db; |
35 |
w |
1.9 |
exit; |
36 |
wakaba |
1.1 |
} |
37 |
|
|
|
38 |
|
|
sub do_view { |
39 |
w |
1.9 |
require SuikaWiki::View; |
40 |
wakaba |
1.8 |
my $content = $main::database{$main::form{mypage}}; |
41 |
|
|
my $lm = SuikaWiki::Plugin->_database->mtime ($main::form{mypage}); |
42 |
w |
1.9 |
## Determine mode |
43 |
wakaba |
1.1 |
my $view = $form{mycmd}; |
44 |
w |
1.9 |
if (!$view || $view eq 'default' || $view =~ /[^0-9A-Za-z_]/) { |
45 |
wakaba |
1.1 |
## BUG: this code is not strict |
46 |
w |
1.9 |
if ($main::ENV{HTTP_COOKIE} =~ /SelectedMode=([0-9A-Za-z_-]+)/) { |
47 |
|
|
$view = $1; $view =~ tr/-/_/; |
48 |
wakaba |
1.1 |
} else { |
49 |
|
|
$view = 'read'; |
50 |
|
|
} |
51 |
|
|
} |
52 |
w |
1.9 |
## Get content and its meta info |
53 |
wakaba |
1.8 |
my ($magic, $content) = SuikaWiki::Plugin->magic_and_content ($content); |
54 |
wakaba |
1.1 |
$magic ||= '#?SuikaWiki/0.9'; |
55 |
wakaba |
1.8 |
my $o = bless {param => \%main::form, page => $main::form{mypage}, toc => [], |
56 |
wakaba |
1.1 |
magic => $magic, content => $content, |
57 |
w |
1.9 |
&main::_compatible_options ()}, 'SuikaWiki::Plugin'; |
58 |
wakaba |
1.3 |
my $view_def = SuikaWiki::View->definition ($view); |
59 |
|
|
if (!$view_def->check ($o)) { |
60 |
wakaba |
1.1 |
print "Status: 406 Unsupported Media Type\n"; |
61 |
|
|
$view = '-UnsupportedMediaType'; |
62 |
wakaba |
1.3 |
$view_def = SuikaWiki::View->definition ($view); |
63 |
wakaba |
1.1 |
} |
64 |
w |
1.9 |
my $prop = $view_def->properties; |
65 |
|
|
my $media = $prop->{media}; |
66 |
|
|
if ($prop->{xmedia} && $main::UA =~ /Gecko/) { ## TODO: conneg |
67 |
|
|
$media = $prop->{xmedia}; |
68 |
wakaba |
1.1 |
$o->{media} = $media; |
69 |
wakaba |
1.8 |
} elsif ($main::UA =~ m#Mozilla/0\..+Windows#) { |
70 |
|
|
$main::kanjicode = 'shift_jis'; |
71 |
wakaba |
1.1 |
} |
72 |
w |
1.9 |
|
73 |
|
|
if ($prop->{preprocess}) { |
74 |
|
|
_wiki_exit () unless &{$prop->{preprocess}} (o => $o); |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
## Output CGI/HTTP headers |
78 |
wakaba |
1.1 |
if ($magic =~ m!^\#\?SuikaWiki/0.9!) { |
79 |
w |
1.9 |
&main::print_header ($main::form{mypage}, |
80 |
|
|
-last_modified => ($magic =~ /interactive="yes"/ ? time : $lm), |
81 |
wakaba |
1.1 |
-expires => ($magic =~ /interactive="yes"/ ? 1 : undef), o => $o, |
82 |
w |
1.9 |
-media => $media, -view => $view_def, -magic => $magic, content => $content); |
83 |
wakaba |
1.1 |
} else { |
84 |
w |
1.9 |
&main::print_header($main::form{mypage}, -media => $media, -view => $view_def, |
85 |
wakaba |
1.1 |
-magic => $magic, -last_modified => $lm, o => $o); |
86 |
|
|
} |
87 |
w |
1.9 |
## Output HTTP message body |
88 |
wakaba |
1.8 |
my $fmt = SuikaWiki::Plugin->formatter ('view'); |
89 |
w |
1.9 |
my $s = $fmt->replace ($view_def->as_string => $o, {formatter => $fmt}); |
90 |
|
|
if ($main::kanjicode eq 'euc') { |
91 |
|
|
#require Compress::Zlib; |
92 |
|
|
#print scalar Compress::Zlib::memGzip (''.$s); |
93 |
|
|
print $s; |
94 |
|
|
} else { |
95 |
|
|
$s .= ''; |
96 |
wakaba |
1.8 |
print &main::code_convert (\$s => $main::kanjicode); |
97 |
wakaba |
1.1 |
} |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
sub _do_view_msg (%) { |
101 |
w |
1.9 |
require SuikaWiki::View; |
102 |
wakaba |
1.1 |
my %option = @_; |
103 |
w |
1.9 |
my $o = $option{-o} || bless {param => \%form, page => $option{-page}, |
104 |
|
|
&_compatible_options ()}, 'SuikaWiki::Plugin'; |
105 |
|
|
$o->{toc} = []; |
106 |
|
|
$o->{condition} = \%option; ## This parameter really used?? |
107 |
wakaba |
1.3 |
my $view_def = SuikaWiki::View->definition ($option{-view}); |
108 |
|
|
unless ($view_def->check ($o)) { |
109 |
wakaba |
1.1 |
print "Status: 406 Unsupported Media Type\n"; |
110 |
|
|
$option{-view} = '-UnsupportedMediaType'; |
111 |
wakaba |
1.3 |
$view_def = SuikaWiki::View->definition ($option{-view}); |
112 |
wakaba |
1.1 |
} |
113 |
w |
1.9 |
my $prop = $view_def->properties; |
114 |
|
|
my $media = $prop->{media}; |
115 |
|
|
if ($prop->{xmedia} && $UA =~ /Gecko/) { |
116 |
|
|
$media = $prop->{xmedia}; |
117 |
wakaba |
1.1 |
$o->{media} = $media; |
118 |
|
|
} |
119 |
w |
1.9 |
&print_header($option{-page}, -media => $media, -view => $view_def, o => $o, -goto => $option{-goto}); |
120 |
|
|
## Output HTTP message body |
121 |
|
|
my $fmt = SuikaWiki::Plugin->formatter ('view'); |
122 |
|
|
my $s = $fmt->replace ($view_def->as_string => $o, {formatter => $fmt}); |
123 |
|
|
if ($main::kanjicode eq 'euc') { |
124 |
|
|
print $s; |
125 |
|
|
} else { |
126 |
|
|
print &main::code_convert (\$s => $main::kanjicode); |
127 |
|
|
} |
128 |
wakaba |
1.1 |
} |
129 |
|
|
|
130 |
w |
1.9 |
# [move to SuikaWiki::Plugin::WikiAdmin] |
131 |
wakaba |
1.1 |
sub do_adminchangepassword { |
132 |
|
|
if ($form{mynewpassword} ne $form{mynewpassword2}) { |
133 |
|
|
&_do_view_msg (-view => '-error', -page => $form{mypage}, |
134 |
|
|
error_message => &Resource ('Error:PasswordMismatch')); |
135 |
|
|
return; |
136 |
|
|
} |
137 |
|
|
my ($validpassword_crypt) = $database->meta (AdminPassword => $PageName{AdminSpecialPage}); |
138 |
|
|
if ($validpassword_crypt) { |
139 |
|
|
if (not &valid_password($form{myoldpassword})) { |
140 |
|
|
&_do_view_msg (-view => '-error', -page => $form{mypage}, |
141 |
|
|
error_message => &Resource ('Error:PasswordIsIncorrect')); |
142 |
|
|
return; |
143 |
|
|
} |
144 |
|
|
} |
145 |
|
|
my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time); |
146 |
|
|
my (@token) = ('0'..'9', 'A'..'Z', 'a'..'z'); |
147 |
|
|
my $salt1 = $token[(time | $$) % scalar(@token)]; |
148 |
|
|
my $salt2 = $token[($sec + $min*60 + $hour*60*60) % scalar(@token)]; |
149 |
|
|
my $crypted = crypt($form{mynewpassword}, "$salt1$salt2"); |
150 |
|
|
$database->meta (AdminPassword => $PageName{AdminSpecialPage} => $crypted); |
151 |
|
|
|
152 |
|
|
&_do_view_msg (-view => '-wrote', -page => $form{mypage}); |
153 |
|
|
} |
154 |
|
|
|
155 |
w |
1.9 |
# [move to SuikaWiki::WikiDB] |
156 |
wakaba |
1.1 |
sub valid_password ($) { |
157 |
|
|
my ($validpassword_crypt) = $database->meta (AdminPassword => $PageName{AdminSpecialPage}); |
158 |
|
|
return crypt (shift, $validpassword_crypt) eq $validpassword_crypt ? 1 : 0; |
159 |
|
|
} |
160 |
|
|
|
161 |
w |
1.9 |
# [move to SuikaWiki::Plugin::WikiEdit] |
162 |
wakaba |
1.1 |
sub do_write { |
163 |
|
|
if (&frozen_reject()) { |
164 |
|
|
return; |
165 |
|
|
} |
166 |
|
|
|
167 |
|
|
if (not &is_editable($form{mypage})) { |
168 |
|
|
&_do_view_msg (-view => '-error', -page => $form{mypage}, |
169 |
|
|
error_message => &Resource ('Error:ThisPageIsUneditable')); |
170 |
|
|
return; |
171 |
|
|
} |
172 |
|
|
|
173 |
|
|
## Check confliction |
174 |
|
|
if ($form{myLastModified} ne $database->mtime ($form{mypage})) { |
175 |
|
|
&_do_view_msg (-view => '-conflict', -page => $form{mypage}); |
176 |
|
|
return; |
177 |
|
|
} |
178 |
|
|
|
179 |
|
|
if ($form{mymsg}) { |
180 |
|
|
if ($form{mytouch} || !ref $database) { |
181 |
|
|
$database{$form{mypage}} = $form{mymsg}; |
182 |
|
|
} else { |
183 |
|
|
$database->STORE ($form{mypage} => $form{mymsg}, -touch => 0); |
184 |
|
|
} |
185 |
|
|
$database->meta (IsFrozen => $form{mypage} => 0 + $form{myfrozen}); |
186 |
w |
1.9 |
my $uri = SuikaWiki::Plugin->_uri_wiki_page ($form{mypage}, mode => ($form{after_edit_cmd}||'default'), with_lm => 1); |
187 |
|
|
$uri .= qq(;after_edit_cmd=@{[SuikaWiki::Plugin->encode($form{after_edit_cmd})]}) if $form{after_edit_cmd}; |
188 |
wakaba |
1.1 |
if ($form{__comment_anchor_index}) { |
189 |
w |
1.9 |
$uri .= qq(#anchor-$form{__comment_anchor_index}); |
190 |
wakaba |
1.1 |
} elsif ($form{__wikiform_anchor_index}) { |
191 |
w |
1.9 |
$uri .= qq(#wikiform-$form{__wikiform_anchor_index}); |
192 |
wakaba |
1.1 |
} |
193 |
w |
1.9 |
&_http_see_other (uri => $uri, page => $form{mypage}, alternate_view => '-wrote'); |
194 |
wakaba |
1.1 |
} else { |
195 |
|
|
delete $database{$form{mypage}}; |
196 |
|
|
&_do_view_msg (-view => '-deleted', -page => $form{mypage}); |
197 |
|
|
} |
198 |
|
|
} |
199 |
|
|
|
200 |
w |
1.9 |
sub _http_see_other (%) { |
201 |
|
|
my %o = @_; |
202 |
|
|
$o{uri} ||= SuikaWiki::Plugin->_uri_wiki_page ($o{page}); |
203 |
|
|
if ($o{alternate_view} && ($main::ENV{SERVER_PROTOCOL} eq 'HTTP/0.9' |
204 |
|
|
|| $main::ENV{SERVER_PROTOCOL} eq 'HTTP/1.0')) { |
205 |
|
|
&_do_view_msg (-view => $o{alternate_view}, -page => $o{page}, -goto => $o{uri}, -o => $o{o}); |
206 |
|
|
} else { |
207 |
|
|
my $euri = SuikaWiki::Plugin->escape ($o{uri}); |
208 |
|
|
print qq(Status: 303 See Other |
209 |
|
|
Location: $o{uri} |
210 |
|
|
Content-Type: text/html |
211 |
|
|
Content-Language: en |
212 |
|
|
|
213 |
|
|
<!DOCTYPE p SYSTEM> |
214 |
|
|
<p>See <<a href="$euri">$euri</a>></p>); |
215 |
|
|
} |
216 |
|
|
_wiki_exit (); |
217 |
|
|
} |
218 |
|
|
|
219 |
wakaba |
1.1 |
sub _compatible_options () { |
220 |
w |
1.9 |
(use_anchor_name => ($main::UA =~ m#Mozilla/[12]\.|Microsoft Internet Explorer# ? 1 : 0)); |
221 |
wakaba |
1.1 |
} |
222 |
|
|
|
223 |
w |
1.9 |
|
224 |
wakaba |
1.1 |
|
225 |
|
|
sub print_header ($;%) { |
226 |
|
|
my ($page, %option) = @_; |
227 |
w |
1.9 |
if ($main::ENV{HTTP_IF_MODIFIED_SINCE} && $option{-last_modified}) { |
228 |
|
|
## TODO: use Message::Field::Date |
229 |
|
|
if ($option{-view}->properties->{if}->{modified_since} |
230 |
|
|
&& $main::ENV{HTTP_IF_MODIFIED_SINCE} =~ /([0-9]{1,2})\s*([A-Za-z]{3})\s*([0-9]{2,4})\s*([0-9]{2}):([0-9]{2}):([0-9]{2})\s*[Gg][Mm][Tt]/) { |
231 |
|
|
require Time::Local; |
232 |
|
|
my ($d, $M, $y, $h, $m, $s) = ($1, $2, $3, $4, $5, $6); |
233 |
|
|
$M = {jan=>0,feb=>1,mar=>2,apr=>3,may=>4,jun=>5,jul=>6,aug=>7,sep=>8,oct=>9,nov=>10,dec=>11}->{lc $M}; |
234 |
|
|
#$y += 1900 if $y < 100; ## BUG: don't conform HTTP spec |
235 |
|
|
my $t = Time::Local::timegm_nocheck ($s, $m, $h, $d, $M, $y); |
236 |
|
|
if ($option{-last_modified} <= $t) { |
237 |
|
|
print "Status: 304 Not Modified\n\n"; |
238 |
|
|
_wiki_exit (); |
239 |
|
|
} |
240 |
|
|
} |
241 |
|
|
} |
242 |
wakaba |
1.8 |
my $UA = SuikaWiki::Plugin->user_agent_names; |
243 |
|
|
$option{o}->{-header}->{class}->{frozen} = 1 if &main::is_frozen ($page); |
244 |
w |
1.9 |
$option{o}->{-header}->{class}->{'wiki-page-obsoleted'} = 1 if $option{-magic} =~ /obsoleted="yes"/; |
245 |
wakaba |
1.8 |
$option{o}->{-header}->{additional_html_element} ||= SuikaWiki::Markup::XML->new (type => '#fragment'); |
246 |
w |
1.9 |
print "Vary: Negotiate,User-Agent,Accept-Language,Accept\n"; |
247 |
wakaba |
1.1 |
if ($option{-goto}) { |
248 |
|
|
if ($UA =~ m#Opera|MSIE 2\.#) { |
249 |
wakaba |
1.8 |
## WARNING: This code may output unsafe HTML document if $option{-goto} is unclean. |
250 |
|
|
$option{-goto} =~ tr/;/&/ if $UA =~ m#Opera#; |
251 |
|
|
print qq{Refresh: 0; url=$option{-goto}\n}; |
252 |
|
|
for ($option{o}->{-header}->{additional_html_element}->append_new_node |
253 |
|
|
(namespace_uri => $NS_XHTML1, local_name => 'meta')) { |
254 |
|
|
$_->set_attribute ('http-equiv' => 'refresh'); |
255 |
|
|
$_->set_attribute (content => "0; url=$option{-goto}"); |
256 |
|
|
} |
257 |
wakaba |
1.1 |
} else { |
258 |
wakaba |
1.8 |
$option{-goto} =~ tr/;/&/ if $UA =~ m#Mozilla/[1-4]\.#; |
259 |
|
|
print qq{Refresh: 0; url="$option{-goto}"\n}; |
260 |
|
|
for ($option{o}->{-header}->{additional_html_element}->append_new_node |
261 |
|
|
(namespace_uri => $NS_XHTML1, local_name => 'meta')) { |
262 |
|
|
$_->set_attribute ('http-equiv' => 'refresh'); |
263 |
|
|
$_->set_attribute (content => qq(0; url="$option{-goto}")); |
264 |
|
|
} |
265 |
wakaba |
1.1 |
} |
266 |
|
|
} |
267 |
wakaba |
1.8 |
print qq{Last-Modified: @{[scalar gmtime $option{-last_modified}]}\n} |
268 |
|
|
if $option{-last_modified}; |
269 |
wakaba |
1.1 |
if ($option{-expires} != -1) { |
270 |
|
|
if (defined $option{-expires}) { ## TODO: Don't use asctime |
271 |
|
|
print qq{Expires: @{[scalar gmtime (time + $option{-expires})]}\n}; |
272 |
|
|
} elsif ($option{-media}->{expires} != -1) { |
273 |
|
|
print qq{Expires: @{[scalar gmtime (time + $option{-media}->{expires})]}\n}; |
274 |
|
|
} |
275 |
|
|
} |
276 |
|
|
if ($option{-media}->{charset} && $UA =~ m#Mozilla/[12]\.#) { |
277 |
wakaba |
1.8 |
## UAs don't support official charset names but do non-official names |
278 |
|
|
my $ct = qq{$option{-media}->{type}; charset=@{[ &main::get_charset_name ($main::kanjicode, compatible => 1) ]}}; |
279 |
|
|
print qq{Content-Type: $ct\n}; |
280 |
|
|
for ($option{o}->{-header}->{additional_html_element}->append_new_node |
281 |
|
|
(namespace_uri => $NS_XHTML1, local_name => 'meta')) { |
282 |
|
|
$_->set_attribute ('http-equiv' => 'content-type'); |
283 |
|
|
$_->set_attribute (content => $ct); |
284 |
|
|
} |
285 |
wakaba |
1.1 |
} elsif (!$option{-media}->{charset} || $UA =~ m#Infomosaic|Mozilla/0\.#) { |
286 |
wakaba |
1.8 |
## Media types or UAs don't support charset parameter in HTTP header |
287 |
|
|
print qq{Content-Type: $option{-media}->{type}\n}; |
288 |
|
|
if ($option{-media}->{charset}) { |
289 |
|
|
for ($option{o}->{-header}->{additional_html_element}->append_new_node |
290 |
|
|
(namespace_uri => $NS_XHTML1, local_name => 'meta')) { |
291 |
|
|
$_->set_attribute ('http-equiv' => 'content-type'); |
292 |
|
|
$_->set_attribute (content => qq($option{-media}->{type}; charset=).main::get_charset_name ($main::kanjicode, compatible => 1)); |
293 |
|
|
} |
294 |
|
|
} |
295 |
wakaba |
1.1 |
} else { |
296 |
wakaba |
1.8 |
## Modern UAs and Media types with charset parameter |
297 |
|
|
my $type = $option{-media}->{type}; |
298 |
w |
1.9 |
$type = 'application/xml' if ($type =~ m!^application/r(?:df|ss)\+xml$!) && ($UA =~ m#Gecko#); |
299 |
wakaba |
1.8 |
print qq{Content-Type: $type; charset=@{[&main::get_charset_name ($main::kanjicode)]}\n}; |
300 |
|
|
## meta element is not needed |
301 |
wakaba |
1.1 |
} |
302 |
wakaba |
1.5 |
|
303 |
wakaba |
1.4 |
print <<"EOD"; |
304 |
wakaba |
1.1 |
Content-Style-Type: text/css |
305 |
|
|
|
306 |
|
|
EOD |
307 |
|
|
} |
308 |
|
|
|
309 |
|
|
sub get_charset_name ($;%) { |
310 |
|
|
my ($charset, %option) = (lc shift, @_); |
311 |
|
|
if ($charset =~ 'euc') { |
312 |
|
|
$charset = $option{compatible} ? 'x-euc-jp' : 'euc-jp'; |
313 |
|
|
} elsif ($charset =~ 'sjis' || $charset =~ 'shift') { |
314 |
|
|
$charset = $option{compatible} ? 'x-sjis' : 'shift_jis'; |
315 |
|
|
} elsif ($charset =~ 'jis') { |
316 |
|
|
$charset = 'iso-2022-jp'; |
317 |
|
|
} |
318 |
|
|
$charset; |
319 |
|
|
} |
320 |
|
|
|
321 |
w |
1.9 |
=pod |
322 |
wakaba |
1.1 |
|
323 |
w |
1.9 |
sub _decode_argv () { |
324 |
|
|
my $QS = $main::ENV{QUERY_STRING}; |
325 |
|
|
if ($main::ENV{PATH_INFO}) { |
326 |
|
|
die; |
327 |
|
|
# new format: not implemented yet |
328 |
|
|
} else { |
329 |
|
|
my %argv; |
330 |
|
|
if ($QS =~ /[&;=]/) { ## ?FOO=foo;BAR=bar;BAZ=baz |
331 |
|
|
for (split /[;&]/, $QS) { |
332 |
|
|
if (my ($n, $v) = split /=/, $_, 2) { |
333 |
|
|
for ($n, $v) {tr/+/ /; s/%([0-9A-Fa-f][0-9A-Fa-f])/pack 'HH', $1/ge}; |
334 |
|
|
$argv{$n} = $v; |
335 |
|
|
} |
336 |
|
|
} |
337 |
|
|
} else { ## ?FOO-BAR |
338 |
|
|
$argv{page} = $QS; |
339 |
|
|
$argv{page} =~ tr/+/ /; |
340 |
|
|
$argv{page} =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/pack 'HH', $1/ge; |
341 |
|
|
} |
342 |
|
|
my $ie = $argv{ie}; ## Input coding system |
343 |
|
|
for ([qw/mypage page/], [qw/mycmd mode/]) { |
344 |
|
|
$argv{$_->[1]} ||= $argv{$_->[0]}; |
345 |
|
|
delete $argv{$_->[0]}; |
346 |
|
|
} |
347 |
|
|
for (keys %argv) { |
348 |
|
|
$argv{$_} = main::code_convert ($argv{$_}, $main::kanjicode, $ie); |
349 |
|
|
} |
350 |
|
|
for ([qw/mypage page/], [qw/mycmd mode/]) { |
351 |
|
|
$argv{$_->[0]} = $argv{$_->[1]}; |
352 |
wakaba |
1.8 |
} |
353 |
wakaba |
1.1 |
} |
354 |
|
|
} |
355 |
|
|
|
356 |
w |
1.9 |
=cut |
357 |
wakaba |
1.1 |
|
358 |
|
|
sub init_form { |
359 |
|
|
## TODO: Support multipart/form-data |
360 |
|
|
my $query = ''; |
361 |
|
|
if (uc $main::ENV{REQUEST_METHOD} eq 'POST') { |
362 |
wakaba |
1.5 |
if (lc ($main::ENV{CONTENT_TYPE}) eq 'application/x-www-form-urlencoded' |
363 |
|
|
|| lc ($main::ENV{CONTENT_TYPE}) eq 'application/sgml-form-urlencoded') { |
364 |
|
|
read STDIN, $query, $main::ENV{CONTENT_LENGTH}; |
365 |
|
|
} else { |
366 |
w |
1.9 |
$main::form{mycmd} = '___unsupported_media_type___'; |
367 |
|
|
$main::form{mypage} = $main::PageName{FrontPage}; |
368 |
wakaba |
1.5 |
return; |
369 |
|
|
} |
370 |
wakaba |
1.1 |
} |
371 |
|
|
$query .= ($query ? ';' : '') . $main::ENV{QUERY_STRING}; |
372 |
|
|
if ($main::ENV{REQUEST_METHOD} ne 'POST' && $main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;=]/) { |
373 |
w |
1.9 |
my $query = SuikaWiki::Plugin->decode ($main::ENV{QUERY_STRING}); |
374 |
|
|
$query = &main::code_convert (\$query, $main::kanjicode); |
375 |
|
|
$main::form{mypage} = $query; |
376 |
|
|
$main::form{mycmd} = 'default'; |
377 |
wakaba |
1.1 |
} else { |
378 |
|
|
for (split /[;&]/, $query) { |
379 |
|
|
if (my ($n, $v) = split /=/, $_, 2) { |
380 |
|
|
for ($n, $v) {tr/+/ /; s/%([0-9A-Fa-f][0-9A-Fa-f])/pack 'C', hex $1/ge}; |
381 |
w |
1.9 |
$main::form{$n} = $v; |
382 |
wakaba |
1.1 |
} |
383 |
|
|
} |
384 |
|
|
unless (defined $form{mypage}) { |
385 |
|
|
$form{mypage} = $form{epage}; |
386 |
|
|
$form{mypage} =~ s/([0-9A-F]{2})/ord hex $1/g; |
387 |
|
|
} |
388 |
w |
1.9 |
$form{mypage} = &main::code_convert (\$form{mypage}, $kanjicode); |
389 |
wakaba |
1.1 |
} |
390 |
w |
1.9 |
$form{mypage} =~ tr/\x00-\x20\x7F//d; |
391 |
|
|
$form{mypage} = SuikaWiki::Name::Space::normalize_name ($form{mypage}) || $PageName{FrontPage}; |
392 |
|
|
$form{mycmd} ||= $form{mode} || 'default'; |
393 |
wakaba |
1.4 |
$form{mycmd} =~ tr/-/_/; |
394 |
wakaba |
1.1 |
|
395 |
w |
1.9 |
for ('mymsg', 'myname', grep /^(?:wikiform__|pi_)/, keys %form) { |
396 |
|
|
$form{$_} = &main::code_convert (\$form{$_}, $kanjicode); |
397 |
wakaba |
1.1 |
} |
398 |
|
|
} |
399 |
|
|
|
400 |
w |
1.9 |
# [move to SuikaWiki::WikiDB] |
401 |
wakaba |
1.1 |
sub open_db { |
402 |
w |
1.9 |
if ($main::modifier_dbtype eq 'dbmopen') { |
403 |
|
|
dbmopen(%main::database, $PathTo{WikiDataBase}, 0666) or die "(dbmopen) $main::PathTo{WikiDataBase}"; |
404 |
|
|
} elsif ($main::modifier_dbtype eq 'AnyDBM_File') { |
405 |
wakaba |
1.1 |
eval q{use AnyDBM_File}; |
406 |
w |
1.9 |
tie(%main::database, "AnyDBM_File", $main::PathTo{WikiDataBase}, O_RDWR|O_CREAT, 0666) or die ("(tie AnyDBM_File) $main::PathTo{WikiDataBase}"); |
407 |
|
|
} elsif ($main::modifier_dbtype eq 'Yuki::YukiWikiDB') { |
408 |
wakaba |
1.1 |
eval q{use Yuki::YukiWikiDB}; |
409 |
w |
1.9 |
tie(%main::database, "Yuki::YukiWikiDB", $main::PathTo{WikiDataBase}) or die ("(tie Yuki::YukiWikiDB) $main::PathTo{WikiDataBase}"); |
410 |
wakaba |
1.1 |
} else { ## Yuki::YukiWikiDB || Yuki::YukiWikiDBMeta |
411 |
|
|
eval qq{use $modifier_dbtype}; |
412 |
w |
1.9 |
$database = tie (%database, $modifier_dbtype => $PathTo{WikiDataBase}, |
413 |
|
|
-lock => 2, -backup => $wiki::diff::UseDiff, ## TODO: new diff i/f |
414 |
|
|
-logfile => $main::PathTo{WikiDatabaseErrorLog}) |
415 |
|
|
or die ("(tie $modifier_dbtype) $PathTo{WikiDataBase}"); |
416 |
wakaba |
1.1 |
} |
417 |
|
|
} |
418 |
|
|
|
419 |
w |
1.9 |
# [move to SuikaWiki::WikiDB] |
420 |
wakaba |
1.1 |
sub close_db { |
421 |
|
|
if ($modifier_dbtype eq 'dbmopen') { |
422 |
|
|
dbmclose(%database); |
423 |
|
|
} else { |
424 |
|
|
untie(%database); |
425 |
|
|
} |
426 |
|
|
} |
427 |
|
|
|
428 |
w |
1.9 |
# [move to SuikaWiki::Plugin::WikiEdit] |
429 |
wakaba |
1.1 |
sub editform (@) { |
430 |
|
|
my %option = @_; |
431 |
|
|
my $frozen = &is_frozen ($option{page}); |
432 |
|
|
$option{content} = $database{$option{page}} unless defined $option{content}; |
433 |
|
|
$option{content} = $database{NewPageTemplate} unless length $option{content}; |
434 |
|
|
$option{last_modified} = $database->mtime ($option{page}) unless defined $option{last_modified}; |
435 |
|
|
my $magic = ''; |
436 |
|
|
$magic = $1 if $option{content} =~ m/^([^\x0A\x0D]+)/s; |
437 |
|
|
|
438 |
|
|
my $selected = 'default'; |
439 |
|
|
if ($form{after_edit_cmd}) { |
440 |
|
|
$selected = $form{after_edit_cmd}; |
441 |
|
|
} elsif ($magic =~ /Const|Config|CSS/) { |
442 |
|
|
$selected = 'edit'; |
443 |
|
|
} |
444 |
|
|
my $afteredit = <<EOH; |
445 |
|
|
<select name="after_edit_cmd"> |
446 |
|
|
<option value="default" label="@{[&Resource('Edit:SaveAndDefault',escape=>1)]}"@{[$selected eq 'default' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndDefault',escape=>1)]}</option> |
447 |
|
|
<option value="read" label="@{[&Resource('Edit:SaveAndView',escape=>1)]}"@{[$selected eq 'read' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndView',escape=>1)]}</option> |
448 |
|
|
<option value="edit" label="@{[&Resource('Edit:SaveAndEdit',escape=>1)]}"@{[$selected eq 'edit' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndEdit',escape=>1)]}</option> |
449 |
|
|
</select> |
450 |
|
|
EOH |
451 |
wakaba |
1.8 |
|
452 |
|
|
=pod |
453 |
|
|
|
454 |
|
|
my $f = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'form'); |
455 |
|
|
$f->set_attribute (action => SuikaWiki::Plugin->uri ('wiki'); |
456 |
|
|
$f->set_attribute (method => 'post'); |
457 |
w |
1.9 |
if (!$option{conflict}) { |
458 |
wakaba |
1.8 |
for ($f->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'label')) { |
459 |
|
|
for ($_->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'input')) { |
460 |
|
|
$f->set_attribute (type => 'submit'); |
461 |
|
|
$f->set_attribute (value => SuikaWiki::Plugin->resource ('Edit:Save')); |
462 |
|
|
} |
463 |
w |
1.9 |
#<input type=hidden name=mycmd value=write/> |
464 |
wakaba |
1.8 |
$_->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'kbd', value => 'S'); |
465 |
|
|
} |
466 |
|
|
} |
467 |
|
|
|
468 |
|
|
=cut |
469 |
|
|
|
470 |
|
|
my $f = <<"EOD"; |
471 |
wakaba |
1.1 |
<form action="$uri{wiki}" method="post"> |
472 |
w |
1.9 |
@{[ $option{conflict} ? '' : qq(<label><input type="submit" value="@{[SuikaWiki::Plugin->resource('Edit:Save',escape=>1)]}" /><kbd>S</kbd></label>) ]} |
473 |
|
|
@{[ $option{admin} ? qq(<label>@{[SuikaWiki::Plugin->resource('Edit:Password=',escape=>1)]}<input type="password" name="mypassword" value="" size="10" /></label>) : "" ]} [@{[&get_new_anchor_index($option{content})]}]<br /> |
474 |
wakaba |
1.1 |
<input type="hidden" name="myLastModified" value="$option{last_modified}" /> |
475 |
w |
1.9 |
<input type="hidden" name="mycmd" value="write" /> |
476 |
|
|
<input type="hidden" name="mypage" value="@{[SuikaWiki::Plugin->escape($form{mypage})]}" /> |
477 |
|
|
<textarea cols="@{[SuikaWiki::Plugin->resource('Edit:Form:Cols')+0||80]}" rows="@{[SuikaWiki::Plugin->resource('Edit:Form:Rows')+0||20]}" name="mymsg" tabindex="1">@{[SuikaWiki::Plugin->escape($option{content})]}</textarea><br /> |
478 |
wakaba |
1.1 |
@{[ |
479 |
|
|
$option{admin} ? |
480 |
|
|
qq( |
481 |
w |
1.9 |
<label><input type="radio" name="myfrozen" value="1" @{[$frozen ? qq(checked="checked") : ""]} />@{[SuikaWiki::Plugin->resource('Edit:Freeze',escape=>1)]}</label> |
482 |
|
|
<label><input type="radio" name="myfrozen" value="0" @{[$frozen ? "" : qq(checked="checked")]} />@{[SuikaWiki::Plugin->resource('Edit:DontFreeze',escape=>1)]}</label><br />) |
483 |
wakaba |
1.1 |
: "" |
484 |
|
|
]} |
485 |
|
|
@{[ |
486 |
|
|
$option{conflict} ? "" : |
487 |
|
|
qq( |
488 |
w |
1.9 |
<label><input type="checkbox" name="mytouch" value="on" checked="checked" />@{[SuikaWiki::Plugin->resource('Edit:UpdateTimeStamp',escape=>1)]}</label><br /> |
489 |
|
|
<label><input type="submit" value="@{[SuikaWiki::Plugin->resource('Edit:Save',escape=>1)]}" accesskey="S" /><kbd>S</kbd></label> |
490 |
wakaba |
1.1 |
$afteredit |
491 |
|
|
) |
492 |
|
|
]} |
493 |
|
|
</form> |
494 |
|
|
EOD |
495 |
|
|
$f; |
496 |
|
|
} |
497 |
|
|
|
498 |
w |
1.9 |
# [move to SuikaWiki::WikiDB] |
499 |
wakaba |
1.1 |
sub is_editable { |
500 |
|
|
my ($page) = @_; |
501 |
wakaba |
1.4 |
return 0 unless SuikaWiki::Name::Space::validate_name ($page); |
502 |
|
|
return 0 if $page =~ /[\x00-\x20\[\]\x7F]/; |
503 |
wakaba |
1.2 |
1; |
504 |
wakaba |
1.1 |
} |
505 |
|
|
|
506 |
w |
1.9 |
# [move to SuikaWiki::WikiDB] |
507 |
wakaba |
1.1 |
sub frozen_reject { |
508 |
|
|
my ($isfrozen) = $database->meta (IsFrozen => $form{mypage}); |
509 |
|
|
my ($willbefrozen) = $form{myfrozen}; |
510 |
|
|
if (not $isfrozen and not $willbefrozen) { |
511 |
|
|
# You need no check. |
512 |
|
|
return 0; |
513 |
|
|
} elsif (valid_password($form{mypassword})) { |
514 |
|
|
# You are admin. |
515 |
|
|
return 0; |
516 |
|
|
} else { |
517 |
|
|
&_do_view_msg (-view => '-error', -page => $form{mypage}, |
518 |
wakaba |
1.8 |
error_message => SuikaWiki::Plugin->resource ('Error:PasswordIsIncorrect')); |
519 |
wakaba |
1.1 |
exit; |
520 |
|
|
} |
521 |
|
|
} |
522 |
|
|
|
523 |
w |
1.9 |
# [move to SuikaWiki::WikiDB] |
524 |
wakaba |
1.8 |
sub is_frozen ($) { SuikaWiki::Plugin->_database->meta (IsFrozen => $_[0]) ? 1 : 0 } |
525 |
wakaba |
1.1 |
|
526 |
w |
1.9 |
# [to be obsolete] |
527 |
wakaba |
1.1 |
sub do_comment { |
528 |
|
|
my ($content) = $database{$form{mypage}}; |
529 |
|
|
my $default_name; ## this code is not strict. |
530 |
|
|
$default_name = $1 if $content =~ /default-name="([^"]+)"/; |
531 |
w |
1.9 |
my @time = gmtime (time); |
532 |
|
|
my $datestr = sprintf '[WEAK[%04d-%02d-%02d %02d:%02d:%02d +00:00]]', $time[5]+1900,$time[4]+1,@time[3,2,1,0]; |
533 |
wakaba |
1.1 |
my $namestr = $form{myname} || $default_name || &Resource('WikiForm:WikiComment:DefaultName'); |
534 |
|
|
($namestr = '', $datestr = '') if $form{myname} eq 'nodate'; |
535 |
|
|
if ($namestr =~ /^(?:>>)?[0-9]/) { |
536 |
|
|
$namestr = qq( ''$namestr'': ); |
537 |
|
|
} elsif (length $namestr) { |
538 |
|
|
$namestr = qq( ''[[$namestr]]'': ); |
539 |
|
|
} |
540 |
|
|
my $anchor = &get_new_anchor_index ($content); |
541 |
|
|
my $i = 1; my $o = 0; |
542 |
|
|
$content =~ s{(\[\[\#r?comment\]\])}{ |
543 |
|
|
my $embed = $1; |
544 |
|
|
if ($i == $form{comment_index}) { |
545 |
|
|
if ($embed ne '[[#rcomment]]') { |
546 |
|
|
$embed = "- [$anchor] $datestr$namestr$form{mymsg}\n$embed"; $o = 1; |
547 |
|
|
} else { |
548 |
|
|
$embed .= "\n- [$anchor] $datestr$namestr$form{mymsg}"; $o = 1; |
549 |
|
|
} |
550 |
|
|
} |
551 |
|
|
$i++; $embed; |
552 |
|
|
}ge; |
553 |
|
|
unless ($o) { |
554 |
|
|
$content = "#?SuikaWiki/0.9\n\n" unless $content; |
555 |
|
|
$content .= "\n" unless $content =~ /\n$/s; |
556 |
|
|
$content .= "- [$anchor] $datestr$namestr$form{mymsg}\n"; |
557 |
|
|
} |
558 |
|
|
$form{__comment_anchor_index} = $anchor; |
559 |
|
|
if ($form{mymsg} || $form{myname}) { |
560 |
|
|
$form{mymsg} = $content; |
561 |
|
|
$form{mytouch} = 'on'; |
562 |
|
|
&do_write; |
563 |
|
|
} else { ## Don't write |
564 |
|
|
$form{mycmd} = 'default'; |
565 |
|
|
&do_view; |
566 |
|
|
} |
567 |
|
|
} |
568 |
|
|
|
569 |
w |
1.9 |
# [move to SuikaWiki::Plugin::WikiForm] |
570 |
wakaba |
1.1 |
sub get_new_anchor_index ($) { |
571 |
|
|
my $content = shift; |
572 |
|
|
my $anchor = 0; |
573 |
|
|
$content =~ s/^(?:[-=]+\s*)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge; |
574 |
|
|
$anchor + 1; |
575 |
|
|
} |
576 |
|
|
|
577 |
w |
1.9 |
# [move to SuikaWiki::Plugin::WikiForm] |
578 |
wakaba |
1.1 |
sub do_wikiform { |
579 |
|
|
my $content = $database{$form{mypage}}; |
580 |
|
|
my $anchor = &get_new_anchor_index ($content); |
581 |
|
|
my $write = 0; |
582 |
|
|
my $i = 1; |
583 |
|
|
$content =~ s{$embed_command{form}}{ |
584 |
|
|
my ($embed, $wfname, $template, $option) = ($&, $1, $3, $4); |
585 |
|
|
if (($wfname && $wfname eq $form{wikiform_targetform}) |
586 |
|
|
|| $i == $form{wikiform_index}) { |
587 |
|
|
$template =~ s/\\([\\'])/$1/g; |
588 |
|
|
$option =~ s/\\([\\'])/$1/g; |
589 |
|
|
my $param = bless {depth=>10}, 'SuikaWiki::Plugin'; |
590 |
|
|
$param->{page} = $form{mypage}; |
591 |
|
|
$param->{form_index} = $i; |
592 |
|
|
$param->{form_name} = $wfname; |
593 |
|
|
$param->{anchor_index} = $anchor; |
594 |
|
|
$param->{argv} = \%form; |
595 |
|
|
$param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/; |
596 |
|
|
$param->{default_name} ||= &Resource('WikiForm:WikiComment:DefaultName'); |
597 |
w |
1.9 |
SuikaWiki::Plugin->formatter ('form_option')->replace ($option, $param); |
598 |
wakaba |
1.1 |
my $t = 1; |
599 |
|
|
for (keys %{$param->{require}||{}}) { |
600 |
|
|
(undef $t, last) unless length $param->{argv}->{'wikiform__'.$_}; |
601 |
|
|
} |
602 |
w |
1.9 |
$t = SuikaWiki::Plugin->formatter ('form_template')->replace ($template, $param) if $t; |
603 |
wakaba |
1.1 |
if (length $t) { |
604 |
|
|
if ($param->{output}->{reverse}) { |
605 |
|
|
$embed .= "\n" . $t; |
606 |
|
|
} else { |
607 |
|
|
$embed = $t . "\n" . $embed; |
608 |
|
|
} |
609 |
|
|
$write = 1; |
610 |
|
|
$form{__comment_anchor_index} = $anchor |
611 |
|
|
if $param->{anchor_index_}; ## $anchor is used! |
612 |
|
|
} |
613 |
|
|
$form{__wikiform_anchor_index} = $i; |
614 |
|
|
undef $form{wikiform_targetform}; ## Make sure never to match |
615 |
|
|
undef $form{wikiform_index}; ## with WikiForm in rest of page! |
616 |
|
|
} |
617 |
|
|
$i++; $embed; |
618 |
|
|
}ge; |
619 |
|
|
unless ($write) { |
620 |
|
|
#$content = "#?SuikaWiki/0.9\n\n" unless $content; |
621 |
|
|
#$content .= "\n" unless $content =~ /\n$/s; |
622 |
|
|
# |
623 |
|
|
} |
624 |
|
|
if ($write) { |
625 |
|
|
$form{mymsg} = $content; |
626 |
|
|
$form{mytouch} = 'on'; |
627 |
|
|
&do_write; |
628 |
|
|
} else { ## Don't write! |
629 |
|
|
$form{mycmd} = 'default'; |
630 |
|
|
&do_view; |
631 |
|
|
} |
632 |
|
|
} |
633 |
|
|
|
634 |
w |
1.9 |
# [to be obsolete] ->Message::MIME::Charset |
635 |
wakaba |
1.1 |
sub code_convert { |
636 |
|
|
require Jcode; |
637 |
w |
1.9 |
my ($contentref, $code, $srccode) = (shift, shift || $kanjicode, shift || undef); |
638 |
wakaba |
1.1 |
if ($code =~ /euc/) { $code = 'euc' } |
639 |
|
|
elsif ($code =~ /iso/) { $code = 'jis' } |
640 |
|
|
elsif ($code =~ /shi/) { $code = 'sjis' } |
641 |
|
|
elsif ($code =~ /utf/) { $code = 'utf8' } |
642 |
w |
1.9 |
$$contentref = Jcode->new ($contentref, $srccode)->tr ("\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&,.:;?!`^_/|()[]{}+$%#*@='"~-><\ ))->$code; |
643 |
wakaba |
1.1 |
return $$contentref; |
644 |
|
|
} |
645 |
|
|
|
646 |
w |
1.9 |
# [to be obsolete] ->Message::Field::Date |
647 |
wakaba |
1.1 |
sub _rfc3339_date ($) { |
648 |
|
|
my @time = gmtime (shift); |
649 |
|
|
sprintf '%04d-%02d-%02dT%02d:%02d:%02d+00:00', $time[5]+1900,$time[4]+1,@time[3,2,1,0]; |
650 |
|
|
} |
651 |
|
|
|
652 |
w |
1.9 |
# [obsolete] ->SuikaWiki::SrcFormat |
653 |
|
|
sub convert_format ($$$;%) { |
654 |
|
|
my ($content, $d => $t, %option) = @_; |
655 |
|
|
my $f = SuikaWiki::Plugin->format_converter ($d => $t); |
656 |
|
|
if (ref $f) { |
657 |
|
|
$option{content} = $content; |
658 |
|
|
$option{from} = $d; |
659 |
|
|
$option{to} = $t; |
660 |
|
|
&$f ({}, bless (\%option, 'SuikaWiki::Plugin')); |
661 |
|
|
} elsif ($option{-error_no_return}) { |
662 |
|
|
return undef; |
663 |
|
|
} elsif ($t =~ /HTML|xml/) { |
664 |
|
|
if (length $content) { |
665 |
|
|
my $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'pre'); |
666 |
|
|
$r->append_text ($content); |
667 |
|
|
return $r; |
668 |
|
|
} else { |
669 |
|
|
return ''; |
670 |
|
|
} |
671 |
|
|
} else { |
672 |
|
|
$content; |
673 |
|
|
} |
674 |
|
|
} |
675 |
|
|
|
676 |
|
|
|
677 |
wakaba |
1.1 |
|
678 |
w |
1.9 |
# [obsolete] SuikaWiki::WikiDB |
679 |
wakaba |
1.1 |
package wiki::dummy; |
680 |
|
|
sub mtime (@) {undef} |
681 |
|
|
sub meta (@) {undef} |
682 |
|
|
sub Yuki::YukiWikiDB2::meta (@) {undef} |
683 |
|
|
|
684 |
|
|
package main; |
685 |
w |
1.9 |
SuikaWiki::Plugin->import_plugins (); |
686 |
|
|
$main::UA = $main::ENV{HTTP_USER_AGENT}; |
687 |
|
|
&open_db; |
688 |
|
|
&init_form; |
689 |
|
|
for (@{$SuikaWiki::Plugin::On{WikiDatabaseLoaded}||[]}) { &{$_} } |
690 |
|
|
if ($command_do{$form{mycmd}}) { |
691 |
|
|
&{$command_do{$form{mycmd}}}; # [to be obsolete] |
692 |
|
|
} else { |
693 |
|
|
&{$command_do{default}}; |
694 |
|
|
} |
695 |
|
|
_wiki_exit (); |
696 |
wakaba |
1.1 |
|
697 |
|
|
=head1 NAME |
698 |
|
|
|
699 |
wakaba |
1.4 |
lib/suikawiki.pl --- SuikaWiki transitional library |
700 |
wakaba |
1.1 |
|
701 |
|
|
=head1 AUTHOR |
702 |
|
|
|
703 |
wakaba |
1.4 |
Hiroshi Yuki <hyuki@hyuki.com> <http://www.hyuki.com/yukiwiki/> (YukiWiki) |
704 |
wakaba |
1.1 |
|
705 |
wakaba |
1.4 |
Makio Tsukamoto <http://digit.que.ne.jp/> (WalWiki) |
706 |
wakaba |
1.1 |
|
707 |
|
|
Wakaba <w@suika.fam.cx> |
708 |
|
|
|
709 |
|
|
=head1 LICENSE |
710 |
|
|
|
711 |
wakaba |
1.4 |
Copyright AUTHORS 2000-2003 |
712 |
wakaba |
1.1 |
|
713 |
|
|
This program is free software; you can redistribute it and/or |
714 |
|
|
modify it under the same terms as Perl itself. |
715 |
|
|
|
716 |
|
|
=cut |
717 |
|
|
|
718 |
w |
1.9 |
1; # $Date: 2003/05/31 07:01:46 $ |