/[pub]/suikawiki/script/wiki.cgi
Suika

Diff of /suikawiki/script/wiki.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by wakaba, Sun Jun 2 04:26:22 2002 UTC revision 1.48 by w, Fri Jan 3 08:25:31 2003 UTC
# Line 1  Line 1 
1  #!/usr/local/bin/perl  #!/usr/bin/perl
2  #!perl  # wiki.cgi - This is YukiWiki, yet another Wiki clone.
3  #  #
4  # wiki.cgi - This is YukiWiki, yet another Wiki clone.  # This program is free software; you can redistribute it and/or
5  #  # modify it under the same terms as Perl itself.
6  # Copyright (C) 2000-2002 by Hiroshi Yuki.  
7  # <hyuki@hyuki.com>  use strict;
8  # http://www.hyuki.com/yukiwiki/  use lib qw(./lib);
9  #  use CGI::Carp qw(fatalsToBrowser);
10  # This program is free software; you can redistribute it and/or  our $VERSION = do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
11  # modify it under the same terms as Perl itself.  
12  #  require 'wikidata/suikawiki-config.ph';
13  ##############################  use Fcntl;
14  #  ##############################
15  # walwiki.cgi based on yukiwiki.cgi - Yet another WikiWikiWeb clone.  my %fmt;        ## formatter objects
16  #  my %embed_command = (
17  # WalWikiの現バージョンは、YukiWiki 2.0.beta1をベースにしています。          searched        => '^\[\[#searched:([^\]]+)\]\]$',
18  #          form    => qr/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/,
19  # * 更新内容  );
20  #  our ($modifier_dbtype,$url_cgi,%uri,%PathTo,$use_exists);
21  # 2.0.beta1.wal.1 on 2002/05/19,22:32:19  our (%PageName,$kanjicode,$lang,%ViewDefinition);
22  # (1) Footerの変更  
23  # (2) WikiNameの拡張 : PerlCEも包含、PPMInstallは含まない  ##############################
24  # (3) 別名リンク([別名 URL])に対応。  my %form;
25  # (4) ISBNをアマゾン.jpのAsociateプログラムリンクに変換。  our %database;
26  # (5) [[#box:InterWikiName]]でInterWikiなテキストボックス生成  our $database = bless {}, 'wiki::dummy';
27  # (6) HTMLモード対応。  my %interwiki;
28  #  ##############################
29  # 旧2.0.alpha0.wal.3版までの修正の内、以下に変更があります。  my %page_command = (
30  # ・以下はYukiWiki2に実装されたため、独自コードはなくなりました。      $PageName{RssPage} => 'rss',
31  #   - インラインの画像変換  );
32  #   - YukiWikiDB対応  my %command_do = (
33  #   - テーブル      read => \&do_read,
34  #   - DB関連モジュールuseのeval化      TEXT_CSS => \&do_output_css,
35  #   - BracketNameによるキーからブラケットを排除      edit => \&do_view,
36  # ・ISBN番号への対応はWalWiki2.0より、InterWikiへのAdd-Onになりました。      adminchangepassword => \&do_adminchangepassword,
37  #   [[ISBN http://www.amazon.co.jp/exec/obidos/ASIN/isbn($1)/walrdigi-22]]のように登録。      write => \&do_write,
38  #      searchform => \&do_searchform,
39  #=======================================      comment => \&do_comment,
40        RandomJump  => \&do_random_jump,
41  # Walrus add (debug) start      rss => \&do_rss,
42  my $walrus_log;      diff => \&do_diff,
43  my $walrus_debugging = 0;      wikiform    => \&do_wikiform,
44  # Walrus add (debug) end      map => \&do_view,
45    );
46  # Libraries.  my $UA = '';  ## User agent name
47  use strict;  $| = 1;
48  use lib qw(./WalWiki/lib);  ##############################
49  use CGI qw(:standard);  
50  use CGI::Carp qw(fatalsToBrowser);  sub main {
51  use Yuki::RSS;      $UA = $main::ENV{HTTP_USER_AGENT};
52  use Yuki::DiffText qw(difftext);      &open_db;
53  use Yuki::YukiWikiDB;      &init_form;
54  use AnyDBM_File;      if ($command_do{$form{mycmd}}) {
55  require 'jcode.pl';          &{$command_do{$form{mycmd}}};
56  # use Jcode;      } else {
57  use Fcntl;          &{$command_do{read}};
58  my $version = '2.0.beta1.2002-05-29';      }
59  ##############################      &close_db;
60  #  }
61  # You MUST modify following '$modifier_...' variables.  
62  #  sub do_read {
63  my $modifier_mail = ''; # Your mail address, like 'walrus@digit.que.ne.jp'.    my $content = $database{$form{mypage}};
64  my $modifier_url  = ''; # Your web page, like 'http://digit.que.ne.jp/work/'.    my $lm = $database->mtime ($form{mypage});
65  my $modifier_name = ''; # Your name, like 'Makio Tsukamoto'.    wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
66  # my $modifier_dbtype = 'AnyDBM_File';  # Fast, not available on some server, page size limited.    wiki::useragent::add ($ENV{HTTP_USER_AGENT});
67  # my $modifier_dbtype = 'dbmopen';      # Fast, not available on some server, page size limited.    my @toc;
68  my $modifier_dbtype = 'YukiWikiDB';     # Slow, available on all environment.      my $cf = 'SuikaWiki/0.9';
69  # my $modifier_sendmail = '/usr/sbin/sendmail -t -n'; # Your sendmail.      ## Should be support at least:
70  my $modifier_sendmail = ''; # If you don't need mail notification.      ## - 'SuikaWiki/0.9' CRLF
71  my $modifier_dir_data = './WalWiki'; # Your data directory.      ## - 'H2H/' ("0.9" / "1.0" / "1.1") CRLF
72  my $modifier_rss_title = "WalWiki $walversion";      ## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF
73  my $modifier_rss_link = 'http://yourhost/wiki.cgi'; # Blank is not allowed.      $cf = $1 if $content =~ s#^(?:/\*\s*|[\#<]\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+##s;
74  my $modifier_rss_description = 'This is WalWiki, yet another Wiki clone based on YukiWiki';      if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) {
75  ##############################        my $expires = time;
76  #        if ($cf =~ /interactive="yes"/) {
77  # You MAY modify following variables.          $lm = $expires;
78  #        } else {
79  my $file_touch = "$modifier_dir_data/touched.txt";          $expires += 120;
80  my $file_resource = "$modifier_dir_data/resource.txt";        }
81  my $file_FrontPage = "$modifier_dir_data/frontpage.txt";        &print_header ($form{mypage}, -last_modified => $lm, -expires => $expires,
82  my $file_conflict = "$modifier_dir_data/conflict.txt";          -content_format => $cf, -noindex => ($cf =~ /obsoleted="yes"/ ? 1 : 0));
83  my $file_format = "$modifier_dir_data/format.txt";        &print_content ($content, content_format => $cf, last_modified => $lm,
84  my $url_cgi = 'wiki.cgi';          -toc => \@toc);
85  my $url_stylesheet = './WalWiki/Theme/wiki.css';        print &text_to_html (q([[#comment]])) if $cf !~ /obsoleted="yes"/ && !$database->meta (IsFrozen => $form{mypage});
86  my $icontag = '<img src="./WalWiki/Theme/icon.gif" alt="*" width="40" height="40" />';      } else {
87  my $maxrecent = 50;        &print_header($form{mypage}, -expires => time + 120, -last_modified => $lm);
88  my $cols = 80;        print "<pre>@{[&escape($content)]}</pre>";
89  my $rows = 20;      }
90  ##############################      &load_formatter ('view');
91  #      print $fmt{view}->replace ($ViewDefinition{read} => bless {param => \%form, page => $form{mypage}, toc => \@toc, formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin');
92  # You MAY, but do NOT NEED modify following variables.      &print_footer ($form{mypage}, $lm);
93  #  }
94  my $dataname = "$modifier_dir_data/wiki";  
95  my $infoname = "$modifier_dir_data/info";  sub do_output_css {
96  my $diffname = "$modifier_dir_data/diff";    wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
97  my $editchar = '?';    wiki::useragent::add ($ENV{HTTP_USER_AGENT});
98  my $subject_delimiter = ' - ';    my $content = $database{$form{mypage}};
99  my $use_autoimg = 1; # automatically convert image URL into <img> tag.    if ($content =~ m#^\s*/\*\s*W3C-CSS#) {
100  my $use_exists = 0; # If you can use 'exists' method for your DB.      my $lm = gmtime $database->mtime ($form{mypage});
101  ##############################      print "Content-Type: text/css; charset=@{[&get_charset_name($kanjicode)]}\n";
102  my $InterWikiName = 'InterWikiName';      print "Last-Modified: $lm\n";
103  my $RecentChanges = 'RecentChanges';      print "Expires: @{[scalar gmtime time+3600]}\n";    ## TODO: don't use asctime
104  my $AdminChangePassword = 'AdminChangePassword';      print "\n";
105  my $CompletedSuccessfully = 'CompletedSuccessfully';      print $content;
106  my $FrontPage = 'FrontPage';    } else {
107  my $IndexPage = 'IndexPage';      print "Status: 406 Unsupported Media Type\n";
108  my $SearchPage = 'SearchPage';      &print_header('WikiPageIsNotCSS', -noindex => 1);
109  my $CreatePage = 'CreatePage';      &print_content($database{WikiPageIsNotCSS});
110  my $ErrorPage = 'ErrorPage';      &print_footer('WikiPageIsNotCSS');
111  my $RssPage = 'RssPage';    }
112  my $AdminSpecialPage = 'Admin Special Page'; # must include spaces.  }
113  ##############################  
114  # my $wiki_name = '\b([A-Z][a-z]+([A-Z][a-z]+)+)\b';        # Walrus del (2)  sub id_and_name ($) {
115  my $wiki_name   = '\b([A-Z][a-z]+([A-Z][a-z]*)+)\b';        # Walrus add (2)      my $name = shift;
116  my $bracket_name = '\[\[(\S+?)\]\]';      if ($UA =~ m#Mozilla/[12]\.|Microsoft Internet Explorer#) {
117  my $embedded_name = '\[\[(#\S+?)\]\]';        qq{id="$name"><a name="$name"></a};
118  my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]';      } else {
119  my $interwiki_name = '([^:]+):([^:].*)';          qq{id="$name"};
120  ##############################      }
121  my $embed_comment = '[[#comment]]';  }
122  my $embed_rcomment = '[[#rcomment]]';  
123  my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$';    # Walrus add (5)  sub do_view {
124  ##############################      wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
125  my $info_LastModified = 'LastModified';      wiki::useragent::add ($ENV{HTTP_USER_AGENT});
126  my $info_IsFrozen = 'IsFrozen';      &print_header($form{mypage}, -noindex => 1, -expires => time+60);
127  my $info_AdminPassword = 'AdminPassword';      &load_formatter ('view');
128  ##############################      my $view = $form{mycmd};
129  my $kanjicode = 'euc';      if ($view eq 'edit') {
130  my $charset = 'EUC-JP';        $view = 'adminedit' if $form{admin};
131  my $lang = 'ja';      } elsif ($view =~ /[^0-9A-Za-z]/) {
132  my %fixedpage = (        $view = 'view'
133      $IndexPage => 1,      }
134      $CreatePage => 1,      print $fmt{view}->replace ($ViewDefinition{$view} => bless {param => \%form, page => $form{mypage}, toc => [], formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin');
135      $ErrorPage => 1,      &print_footer($form{mypage});
136      $RssPage => 1,  }
137      $RecentChanges => 1,  
138      $SearchPage => 1,  sub do_adminchangepassword {
139      $AdminChangePassword => 1,      if ($form{mynewpassword} ne $form{mynewpassword2}) {
140      $CompletedSuccessfully => 1,          &print_error(&Resource('Error:PasswordMismatch'));
141      $FrontPage => 1,      }
142  );      my ($validpassword_crypt) = $database->meta (AdminPassword => $PageName{AdminSpecialPage});
143  my %form;      if ($validpassword_crypt) {
144  my %database;          if (not &valid_password($form{myoldpassword})) {
145  my %infobase;              &print_error(&Resource('Error:PasswordIsIncorrect'));
146  my %diffbase;          }
147  my %resource;      }
148  my %interwiki;      my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time);
149  ##############################      my (@token) = ('0'..'9', 'A'..'Z', 'a'..'z');
150  my %page_command = (      my $salt1 = $token[(time | $$) % scalar(@token)];
151      $IndexPage => 'index',      my $salt2 = $token[($sec + $min*60 + $hour*60*60) % scalar(@token)];
152      $SearchPage => 'searchform',      my $crypted = crypt($form{mynewpassword}, "$salt1$salt2");
153      $CreatePage => 'create',      $database->meta (AdminPassword => $PageName{AdminSpecialPage} => $crypted);
154      $RssPage => 'rss',  
155      $AdminChangePassword => 'adminchangepasswordform',      &print_header('CompletedSuccessfully', -noindex => 1);
156      $FrontPage => 'FrontPage',      &print_message(&Resource('Error:PasswordIsChanged'));
157  );      &print_footer('CompletedSuccessfully');
158  my %command_do = (  }
159      read => \&do_read,  
160      edit => \&do_edit,  sub valid_password ($) {
161      adminedit => \&do_adminedit,      my ($validpassword_crypt) = $database->meta (AdminPassword => $PageName{AdminSpecialPage});
162      adminchangepasswordform => \&do_adminchangepasswordform,      return crypt (shift, $validpassword_crypt) eq $validpassword_crypt ? 1 : 0;
163      adminchangepassword => \&do_adminchangepassword,  }
164      write => \&do_write,  
165      index => \&do_index,  sub do_write {
166      searchform => \&do_searchform,      if (&frozen_reject()) {
167      search => \&do_search,          return;
168      create => \&do_create,      }
169      createresult => \&do_createresult,  
170      FrontPage => \&do_FrontPage,      if (not &is_editable($form{mypage})) {
171      comment => \&do_comment,          &print_header($form{mypage}, -noindex => 1);
172      rss => \&do_rss,          &print_message(&Resource('Error:ThisPageIsUneditable'));
173      diff => \&do_diff,          &print_footer($form{mypage});
174      interwikibox => \&do_interwiki_box, # Walrus add (5)          return;
175  );      }
176  ##############################  
177  my @ignore_html_page = ('FrontPage');        # Walrus add (6)      ## Check confliction
178  my @ignore_html_tags = ('a', 'br', 'img');   # Walrus add (6)      if ($form{myLastModified} ne $database->mtime ($page)) {
179  my $walversion = '2.0.beta1.wal.1';          # Walrus add (1)        &print_header($page, -noindex => 1);
180  ##############################        &load_formatter ('view');
181  # &test_convert;        print $fmt{view}->replace ($ViewDefinition{-conflict} => bless {param => \%form, page => $form{mypage}, toc => [], formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin');
182  &main;        &print_footer($page);
183  exit(0);        return;
184  ##############################      }
185    
186  sub main {      if ($form{mymsg}) {
187      &init_resource;          if ($form{mytouch} || !ref $database) {
188      &open_db;            $database{$form{mypage}} = $form{mymsg};
189      &init_form;          } else {
190      &init_InterWikiName;            $database->STORE ($form{mypage} => $form{mymsg}, -touch => 0);
191      if ($command_do{$form{mycmd}}) {          }
192          &{$command_do{$form{mycmd}}};          $database->meta (IsFrozen => $form{mypage} => 0 + $form{myfrozen});
193      } else {          my $fragment = '';
194          &do_FrontPage;          $fragment .= qq(;after_edit_cmd=@{[&encode($form{after_edit_cmd})]}) if $form{after_edit_cmd};
195      }          if ($form{__comment_anchor_index}) {
196      &close_db;              $fragment .= qq(#anchor-$form{__comment_anchor_index});
197  }          } elsif ($form{__wikiform_anchor_index}) {
198                $fragment .= qq(#wikiform-$form{__wikiform_anchor_index});
199  sub do_read {          }
200      &print_header($form{mypage});          &print_header('CompletedSuccessfully', -noindex => 1, -goto => $url_cgi.'?mycmd='.&encode($form{after_edit_cmd}||'read').';mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}$fragment));
201      &print_content($database{$form{mypage}});          &print_message(&Resource('Error:SavedSuccessfully'));
202      &print_footer($form{mypage});          &print_content(&Resource('Error:ContinueReading')." @{[&armor_name($form{mypage})]}");
203  }          &print_footer('CompletedSuccessfully');
204        } else {
205  sub do_edit {          delete $database{$form{mypage}};
206      my ($page) = &unarmor_name(&armor_name($form{mypage}));          &print_header($form{mypage}, -noindex => 1);
207      &print_header($page);          &print_message(&Resource('Error:PageIsDeletedSuccessfully'));
208      if (not &is_editable($page)) {          &print_footer($form{mypage});
209          &print_message($resource{cantchange});      }
210      } elsif (&is_frozen($page)) {  }
211          &print_message($resource{cantchange});  
212      } else {  sub _compatible_options () {
213          &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0);    (use_anchor_name => ($UA =~ m#Mozilla/[12]\.|Microsoft Internet Explorer# ? 1 : 0));
214      }  }
215      &print_footer($page);  
216  }  sub get_search_result ($;%) {
217      my $word = lc shift;
218  sub do_adminedit {    my %option = @_;
219      my ($page) = &unarmor_name(&armor_name($form{mypage}));    my @r;
220      &print_header($page);    foreach my $page (keys %database) {
221      if (not &is_editable($page)) {      next if !$option{-match_myself} && ($page eq $word);
222          &print_message($resource{cantchange});      my $content = lc $database{$page};
223      } else {      if (index (lc $page, $word) > -1) {
224          &print_message($resource{passwordneeded});        my $c = $content =~ s/\Q$word\E//g;
225          &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>1);        push @r, [$page, $c+20];
226      }      } elsif (index ($word, lc $page) > -1) {
227      &print_footer($page);        my $c = $content =~ s/\Q$word\E//g;
228  }        push @r, [$page, $c+10];
229        } elsif (my $c = $content =~ s/\Q$word\E//g) {
230  sub do_adminchangepasswordform {        push @r, [$page, $c];
231      &print_header($AdminChangePassword);      }
232      &print_passwordform;    }
233      &print_footer($AdminChangePassword);    #my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#gi; $s };
234  }    my $r = join "\n", map {qq(<li>[$_->[1]] <a href ="$url_cgi?@{[&encode($_->[0])]}" class="wiki">@{[&escape($_->[0])]}</a> <span class="wikipage-summary">@{[&escape(&get_subjectline($_->[0]))]}</span></li>)} sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r;
235      $r = qq|<ul class="search-result">$r</ul>| if $r;
236  sub do_adminchangepassword {    wantarray? ($r, scalar @r): $r;
237      if ($form{mynewpassword} ne $form{mynewpassword2}) {  }
238          &print_error($resource{passwordmismatcherror});  
239      }  sub do_random_jump {
240      my ($validpassword_crypt) = &get_info($AdminSpecialPage, $info_AdminPassword);    my @list = keys %database;
241      if ($validpassword_crypt) {    my $name = &encode ($list[rand @list]);
242          if (not &valid_password($form{myoldpassword})) {    my $scheme = 'http';
243              &send_mail_to_admin(<<"EOD", "AdminChangePassword");    $scheme = lc $1 if $main::ENV{SERVER_PROTOCOL} =~ m#([A-Za-z0-9+.%-]+)#;
244  myoldpassword=$form{myoldpassword}    print "Location: $scheme://$main::ENV{SERVER_NAME}:$main::ENV{SERVER_PORT}$url_cgi?$name\n";
245  mynewpassword=$form{mynewpassword}    print "\n";
246  mynewpassword2=$form{mynewpassword2}  }
247  EOD  
248              &print_error($resource{passworderror});  sub print_error {
249          }      my ($msg) = @_;
250      }      &print_header($PageName{ErrorPage}, -noindex => 1);
251      my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time);      print qq(<p><strong class="error">$msg</strong></p>);
252      my (@token) = ('0'..'9', 'A'..'Z', 'a'..'z');      &print_footer($PageName{ErrorPage});
253      my $salt1 = $token[(time | $$) % scalar(@token)];      exit(0);
254      my $salt2 = $token[($sec + $min*60 + $hour*60*60) % scalar(@token)];  }
255      my $crypted = crypt($form{mynewpassword}, "$salt1$salt2");  
256      &set_info($AdminSpecialPage, $info_AdminPassword, $crypted);  sub print_header ($;%) {
257        my ($page, %option) = @_;
258      &print_header($CompletedSuccessfully);      my @head;
259      &print_message($resource{passwordchanged});      $option{body_class} = &is_frozen($page) ? 'frozen' : 'normal';
260      &print_footer($CompletedSuccessfully);      $option{body_class} .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/;
261  }      if ($option{-goto}) {
262          if ($UA =~ m#Opera|MSIE 2\.#) {
263  sub do_index {            ## WARNING: This code may output unsafe HTML document if
264      &print_header($IndexPage);            ##          $option{-goto} is not clean.
265      print qq(<ul>);            $option{-goto} =~ tr/;/&/ if $UA =~ m#Opera#;
266      foreach my $page (sort keys %database) {            print qq{Refresh: 0; url=$option{-goto}\n};
267          if (&is_editable($page)) {            push @head, qq(<meta http-equiv="refresh" content="0; url=$option{-goto}">);
268              print qq(<li><a href="$url_cgi?@{[&encode($page)]}">$page</a>@{[&escape(&get_subjectline($page))]}</li>);        } else {
269              # print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>);            $option{-goto} =~ tr/;/&/ if $UA =~ m#Mozilla/[1-4]\.#;
270              # print qq(<li>@{[0 + &is_frozen($page)]}</li>);            print qq{Refresh: 0; url="$option{-goto}"\n};
271          }            push @head, qq(<meta http-equiv="refresh" content="0; url=&quot;@{[&escape($option{-goto})]}&quot;">);
272      }        }
273      print qq(</ul>);      }
274      &print_footer($IndexPage);      print qq{Last-Modified: @{[scalar gmtime $option{-last_modified}]}\n} if $option{-last_modified};
275  }      if ($option{-expires}) {
276          print qq{Expires: @{[scalar gmtime $option{-expires}]}\n};
277  sub do_write {      }
278      if (&frozen_reject()) {      if ($UA =~ m#Mozilla/2#) {
279          return;          my $ct = qq{text/html; charset=@{[&get_charset_name($kanjicode,compatible=>1)]}};
280      }          print qq{Content-Type: $ct\n};
281            push @head, qq{<meta http-equiv="content-type" content="$ct">};
282      if (not &is_editable($form{mypage})) {      } elsif ($UA =~ m#Infomosaic#) {
283          &print_header($form{mypage});          print qq{Content-Type: text/html\n};
284          &print_message($resource{cantchange});      } else {
285          &print_footer($form{mypage});          print qq{Content-Type: text/html; charset=@{[&get_charset_name($kanjicode)]}\n};
286          return;      }
287      }      push @head, qq(<title>@{[&escape($page)]}</title>);
288        if ($UA !~ m#Mozilla/[1-4]\.# || $UA =~ m#MSIE (?:[4-9]\.|\d\d)#) {
289      if (&conflict($form{mypage}, $form{mymsg})) {        push @head, qq(<link rel="stylesheet" type="text/css").
290          return;                    qq( href="@{[&escape($uri{wiki}.'?mycmd=TEXT_CSS;mypage='.&encode($PageName{DefaultStyleForHTML}).';x-lm='.$database->mtime ($PageName{DefaultStyleForHTML}))]}");
291      }      }
292        push @head, q(<meta name="ROBOTS" content="NOINDEX">) if $option{-noindex};
293      # Making diff      my ($Links, $links) = &make_navigate_links ($page);
294      {      #print $Links;      ## Link: fields
295          &open_diff;      $links = join "\n", (@head, $links);
296          my @msg1 = split(/\n/, $database{$form{mypage}});      print <<"EOD";
297          my @msg2 = split(/\n/, $form{mymsg});  Content-Language: $lang
298          $diffbase{$form{mypage}} = &difftext(\@msg1, \@msg2);  Content-Style-Type: text/css
299          &close_diff;  
300      }  <!-- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
301    "http://www.w3.org/TR/html4/loose.dtd"> + RUBY -->
302      if ($form{mymsg}) {  <html lang="$lang" class="$option{body_class}">
303          $database{$form{mypage}} = $form{mymsg};  <head profile="http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiHTMLMetaProfile">
304          &send_mail_to_admin($form{mypage}, "Modify");  $links
305          if ($form{mytouch}) {  </head>
306              &set_info($form{mypage}, $info_LastModified, '' . localtime);  <body class="$option{body_class}">
307              &update_recent_changes;  EOD
308          }      &print_navigate_links ($page);
309          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});      print <<EOD;
310          &print_header($CompletedSuccessfully);  <h1 class="header">@{[&escape($page)]}</h1>
311          &print_message($resource{saved});  EOD
312          &print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}");  }
313          &print_footer($CompletedSuccessfully);  
314      } else {  sub get_charset_name ($;%) {
315          &send_mail_to_admin($form{mypage}, "Delete");      my ($charset, %option) = (lc shift, @_);
316          delete $database{$form{mypage}};      if ($charset =~ 'euc') {
317          delete $infobase{$form{mypage}};          $charset = $option{compatible} ? 'x-euc-jp' : 'euc-jp';
318          if ($form{mytouch}) {      } elsif ($charset =~ 'sjis' || $charset =~ 'shift') {
319              &update_recent_changes;          $charset = $option{compatible} ? 'x-sjis' : 'shift_jis';
320          }      } elsif ($charset =~ 'jis') {
321          &print_header($form{mypage});          $charset = 'iso-2022-jp';
322          &print_message($resource{deleted});      }
323          &print_footer($form{mypage});      $charset;
324      }  }
325  }  
326    sub print_navigate_links (@) {
327  sub do_searchform {    my ($page) = @_;
328      &print_header($SearchPage);    my $editable = (&is_editable($page) && !&is_frozen($page)) ? 1 : 0;
329      &print_searchform("");    my $cookedpage = &encode($page);
330      &print_footer($SearchPage);    print <<EOH;
331  }  <div class="tools">
332        @{[ $editable
333  sub do_search {          ? qq(<a title="@{[&Resource('EditThisPageLong',escape=>1)]}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E" class="wiki-cmd">@{[&Resource('EditThisPage',escape=>1)]}</a> | )
334      my $word = &escape($form{mymsg});          : qq()
335      &print_header($SearchPage);      ]}
336      &print_searchform($word);      <a href="$url_cgi?mycmd=read;mypage=$cookedpage;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki-cmd" title="@{[&Resource('ViewThisPageLong',escape=>1)]}">@{[&Resource('ViewThisPage',escape=>1)]}</a> |
337      my $counter = 0;      <a href="$url_cgi?mycmd=map;mypage=$cookedpage" class="wiki-cmd" title="@{[&Resource('ShowMapOfThisPageLong',escape=>1)]}">@{[&Resource('ShowMapOfThisPage',escape=>1)]}</a> |
338      foreach my $page (sort keys %database) {      <a href="$url_cgi?$PageName{CreatePage}" class="wiki" title="@{[&Resource('GoToCreatePageLong',escape=>1)]}">@{[&Resource('GoToCreatePage',escape=>1)]}</a> |
339          next if $page =~ /^$RecentChanges$/;      <a href="$url_cgi?$PageName{IndexPage}" class="wiki" title="@{[&Resource('GoToIndexPageLong',escape=>1)]}">@{[&Resource('GoToIndexPage',escape=>1)]}</a> |
340          if ($database{$page} =~ /\Q$form{mymsg}\E/ or $page =~ /\Q$form{mymsg}\E/) {      <a href="$url_cgi?$PageName{FrontPage}" class="wiki" title="@{[&Resource('GoToHomePageLong',escape=>1)]}">@{[&Resource('GoToHomePage',escape=>1)]}</a> |
341              if ($counter == 0) {      <a href="$url_cgi?$PageName{SearchPage}" class="wiki" title="@{[&Resource('GoToSearchPageLong',escape=>1)]}">@{[&Resource('GoToSearchPage',escape=>1)]}</a> |
342                  print qq|<ul>|;      <a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink" title="@{[&Resource('GoSomewhereLong',escape=>1)]}">@{[&Resource('GoSomewhere',escape=>1)]}</a> |
343              }      <a href="$url_cgi?$PageName{RecentChanges}" class="wiki" title="@{[&Resource('GoToRecentChangesLong',escape=>1)]}">@{[&Resource('GoToRecentChanges',escape=>1)]}</a>
344              print qq(<li><a href ="$url_cgi?@{[&encode($page)]}">$page</a>@{[&escape(&get_subjectline($page))]}</li>);  </div>
345              $counter++;  EOH
346          }  }
347      }  
348      if ($counter == 0) {  sub make_navigate_links ($) {
349          &print_message($resource{notfound});      my $page = shift;
350      } else {      my @link;
351          print qq|</ul>|;      push @link, {rel=>'edit', href=>"$url_cgi?mycmd=edit;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>&Resource('EditThisPageLink')} if &is_editable ($page) && !&is_frozen ($page);
352      }      push @link, {rel=>'edit', href=>"$url_cgi?mycmd=edit;admin=1;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>&Resource('AdminEditThisPageLink')} if &is_editable ($page) || &is_frozen ($page);
353      &print_footer($SearchPage);      push @link, {rel=>'view', href=>"$url_cgi?mycmd=read;mypage=@{[&encode($page)]};x-p=@{[time.[0..9]->[rand 10]]}", class=>'wiki-command', title=>&Resource('ViewThisPageLink')};
354  }      push @link, {rel=>'myself', href=>"$url_cgi?@{[&encode($page)]}", class=>'wiki', title=>&Resource('GoToMyselfLink')};
355        push @link, {rel=>'index', href=>"$url_cgi?$PageName{IndexPage}", class=>'wiki', title=>&Resource('GoToIndexPageLink')};
356  sub do_create {      push @link, {rel=>'home', href=>"$url_cgi?$PageName{FrontPage}", class=>'wiki', title=>&Resource('GoToHomePageLink')};
357      &print_header($CreatePage);      push @link, {rel=>'News', href=>"$url_cgi?WikiNews", class=>'wiki', title=>&Resource('GoToWikiNewsLink')};
358      print <<"EOD";      push @link, {rel=>'News', href=>"$url_cgi?$PageName{RecentChanges}", class=>"wiki", title=>&Resource('GoToRecentChangesLink')};
359  <form action="$url_cgi" method="post">      push @link, {rel=>'News', href=>"$url_cgi?$PageName{RssPage}", class=>"wiki", title=>&Resource('GoToRssPageLink'), type=>'application/xml'};
360      <input type="hidden" name="mycmd" value="edit">      push @link, {rel=>'search', href=>"$url_cgi?$PageName{SearchPage}", class=>'wiki', title=>&Resource('GoToSearchPageLink')};
361      <strong>$resource{newpagename}</strong><br>      push @link, {rel=>'help', href=>"$url_cgi?WikiHelp", class=>'wiki', title=>&Resource('GoToWikiHelpLink')};
362      <input type="text" name="mypage" value="" size="20">      push @link, {rel=>'copyright', href=>"$url_cgi?WikiPageLicense", class=>'wiki', title=>&Resource('GoToWikiPageLicenseLink')};
363      <input type="submit" value="$resource{createbutton}"><br>      push @link, {rel=>'jump', href=>qq(javascript:var%20WikiName=prompt('Please%20input%20the%20WikiName:','','Jump%20to%20SuikaWiki');if(WikiName)%7B_content.location.href='$url_cgi%3F'+encodeURIComponent(WikiName)%7D), class=>'wiki-cmd', title=>&Resource('JumpToLink')};
364  </form>      push @link, {rel=>'jump', href=>qq(javascript:var%20WikiName=prompt('Please%20input%20the%20WikiName:','','Jump%20to%20SuikaWiki');if(WikiName)%7B_content.location.href='$url_cgi%3Fmycmd=edit;mypage='+encodeURIComponent(WikiName)%7D), class=>'wiki-cmd', title=>&Resource('JumpToEditLink')};
365  EOD      push @link, {rel=>'lucky', href=>"$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}", class=>'wiki randomlink', title=>&Resource('GoSomewhereLink')};
366      &print_footer($CreatePage);      push @link, {rel=>'history', href=>$uri{cvs_wikipage}.do{my $s=$page;$s=~s/(.)/sprintf '%02X', ord $1/ges;$s}.'.txt', title=>&Resource('ViewHistoryOfThisPageLink'),hreflang=>'en'} if $uri{cvs_wikipage};
367  }      push @link, {rel=>'history', href=>"$url_cgi?mycmd=diff;mypage=@{[&encode($page)]}", title=>&Resource('ViewDiffOfThisPageLink'), class=>'wiki-command'} if $wiki::diff::UseDiff;
368        push @link, {rel=>'contents', href=>"$url_cgi?mycmd=map;mypage=@{[&encode($page)]}", title=>&Resource('ShowMapOfThisPageLink'), class=>'wiki-command'};
369  sub do_FrontPage {      my ($Links, $links) = ('', '');
370      open(FILE, $file_FrontPage) or &print_error("($file_FrontPage)");      for my $e (@link) {
371      my $content = join('', <FILE>);          $links .= qq(<link);
372      &code_convert(\$content, $kanjicode);          $Links .= qq(Link: <$e->{href}>);
373      close(FILE);          for my $attr (qw/rel rev href title class type hreflang charset/) {
374      &print_header($FrontPage);              $links .= qq( $attr="@{[&escape($e->{$attr})]}") if $e->{$attr};
375      &print_content($content);          }
376      &print_footer($FrontPage);          for my $attr (qw/rel rev title/) {
377  }              $Links .= qq(; $attr="@{[do{$e->{$attr} =~ s/([\\\"])/\\$1/g; $e->{$attr}}]}") if $e->{$attr};
378            }
379  sub print_error {          $links .= qq(>\n);
380      my ($msg) = @_;          $Links .= qq(\n);
381      &print_header($ErrorPage);      }
382      print qq(<p><strong class="error">$msg</strong></p>);      wantarray ? ($Links, $links) : $Links;
383      &print_footer($ErrorPage);  }
384      exit(0);  
385  }  sub print_footer {
386        my ($page, $lm) = @_;
387  sub print_header {      my $epage = &encode ($page);
388      my ($page) = @_;    my $cvslog1 = q$Revision$;
389      my $bodyclass = "normal";    my $cvslog2 = q$Date$;
390      my $editable = 0;    print_navigate_links ($page);
391      my $admineditable = 0;    print <<"EOD";
392      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {  @{[ $lm ? qq(<div id="wikipage-last-modified">@{[&Resource('LastModified=',escape=>1)]}@{[&_rfc3339_date ($lm)]}</div>) : '' ]}
393          $editable = 0;  <div class="footer">
394          $admineditable = 1;  <a href="http://www.hyuki.com/yukiwiki/" title="YukiWiki 2.0.beta1.2002-05-29 &copy; 2000-2002 by Hiroshi Yuki">@{[&Resource('About:Name:YukiWiki',escape=>1)]}</a> <a href="http://digit.que.ne.jp/work/" title="WalWiki 2.0.beta1.wal.1 &copy; 2000-2002 by Makio Tsukamoto">@{[&Resource('About:Name:WalWiki',escape=>1)]}</a>
395          $bodyclass = "frozen";  <a href="/gate/cvs/wakaba/wiki/" title="@{[&Resource('About:SuikaWiki:JumpToCVS',escape=>1)]} ($cvslog2)">@{[&Resource('About:Name:SuikaWiki',escape=>1)]} $cvslog1</a>
396      } elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) {  </div>
397          $admineditable = 1;  </body>
398          $editable = 1;  </html>
399      } else {  EOD
400          $editable = 0;  }
401      }  
402      my $cookedpage = &encode($page);  sub escape {
403      print <<"EOD";      my $s = shift;
404  Content-type: text/html; charset=$charset      $s =~ s|\x0D\x0A|\x0A|g;
405        $s =~ s|&|&amp;|g;
406  <!DOCTYPE html      $s =~ s|<|&lt;|g;
407      PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"      $s =~ s|>|&gt;|g;
408      "http://www.w3.org/TR/html4/loose.dtd">      $s =~ s|"|&quot;|g;
409  <html lang="$lang">      return $s;
410  <head>  }
411      <meta http-equiv="Content-Language" content="$lang">  
412      <meta http-equiv="Content-Type" content="text/html; charset=$charset">  sub unescape {
413      <title>$page @{[&escape(&get_subjectline($page))]}</title>      my $s = shift;
414      <link rel="index" href="$url_cgi?$IndexPage">      # $s =~ s|\n|\r\n|g;
415      <link rev="made" href="mailto:$modifier_mail">      $s =~ s|&lt;|<|g;
416      <link rel="stylesheet" type="text/css" href="$url_stylesheet">      $s =~ s|&gt;|>|g;
417  </head>      $s =~ s|&quot;|"|g;
418  <body class="$bodyclass">      $s =~ s|&amp;|&|g;
419  <div class="tools">      return $s;
420      @{[ $admineditable  }
421          ? qq(<a title="$resource{admineditthispage}" href="$url_cgi?mycmd=adminedit&amp;mypage=$cookedpage">$resource{admineditbutton}</a> | )  
422          : qq()  sub print_content ($;$) {
423      ]}      my ($rawcontent, %option) = @_;
424      @{[ $editable      print &text_to_html($rawcontent, toc=>1, %option);
425          ? qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit&amp;mypage=$cookedpage">$resource{editbutton}</a> | )  }
426          : qq()  
427      ]}  sub text_to_html {
428      @{[ $admineditable      my ($txt, %option) = @_;
429          ? qq(<a href="$url_cgi?mycmd=diff&amp;mypage=$cookedpage">$resource{diffbutton}</a> | )      my $toc = $option{-toc} || [];
430          : qq()      my $tocnum = 0;
431      ]}      
432      <a href="$url_cgi?$CreatePage">$resource{createbutton}</a> |      ## Load constants
433      <a href="$url_cgi?$IndexPage">$resource{indexbutton}</a> |      my %const;
434      <a href="$url_cgi?$RssPage">$resource{rssbutton}</a> |      if ($option{content_format} =~ /import="([^"]+)"/) {
435      <a href="$url_cgi?$FrontPage">$FrontPage</a> |        for (split /\s*,\s*/, $1) {
436      <a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> |          my $wp = $database{$_};
437      <a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a>          if ($wp =~ m!^\#\?SuikaWikiConst/1.0!) {
438  </div>            wiki::suikawikiconst::to_hash ($wp => \%const);
439  <h1 class="header"><a          }
440      title="$resource{searchthispage}"        }
441      href="$url_cgi?mycmd=search&amp;mymsg=$cookedpage">$page</a>@{[&escape(&get_subjectline($page))]}</h1>      }
442  EOD      
443  }      $txt =~ s{__&&([^&]+)&&__}{defined $const{$1}?$const{$1}:qq(__&&$1&&__)}ge;
444        my (@txt) = split(/\n/, $txt);
445  sub print_footer {      my (@saved, @result);
446      my ($page) = @_;      unshift(@saved, "</p>");
447      $walrus_log = ($walrus_debugging) ? &text_to_html("----\n$walrus_log") : '';    # Walrus add (debug)      push(@result, "<p>");
448      # Walrus mod (1) start      foreach (@txt) {
449      my $mod_info = $modifier_name ? qq(Modified by <a href="$modifier_url">$modifier_name</a>.) : '';          chomp;
450      print <<"EOD";          if (/^\*\*\*\*\*([^\x0D\x0A]*)/) {
451  <div class="footer">              push @$toc, [5, "i$tocnum" => ($1 || $tocnum)];
452  <hr />              push(@result, splice(@saved), qq(<h6 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h6>');
453  <p>              $tocnum++;
454  <a href="http://digit.que.ne.jp/work/">WalWiki</a> $walversion &copy; 2000-2002 by <a href="http://digit.que.ne.jp/">Makio Tsukamoto</a>.<br />          } elsif (/^\*\*\*\*([^\x0D\x0A]*)/) {
455  based on <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version &copy; 2000-2002 by <a href="http://www.hyuki.com/">Hiroshi Yuki</a>.<br />              push @$toc, [4, "i$tocnum" => ($1 || $tocnum)];
456  $mod_info              push(@result, splice(@saved), qq(<h5 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h5>');
457  </p><p>              $tocnum++;
458  <a href="http://digit.que.ne.jp/work/">$icontag</a>          } elsif (/^\*\*\*([^\x0D\x0A]*)/) {
459  </p>              push @$toc, [3, "i$tocnum" => ($1 || $tocnum)];
460  </div>              push(@result, splice(@saved), qq(<h4 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h4>');
461  $walrus_log <!-- Walrus add (debug) -->              $tocnum++;
462  </body>          } elsif (/^\*\*([^\x0D\x0A]*)/) {
463  </html>          # if (/^\*\*(.*)/) {
464  EOD          # Walrus mod (6) end
465  #       print <<"EOD";              push @$toc, [2, "i$tocnum" => ($1 || $tocnum)];
466  #   <hr>              push(@result, splice(@saved), qq(<h3 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h3>');
467  #   <address class="footer">              $tocnum++;
468  #       <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version          } elsif (/^\*([^\x0D\x0A]*)/) {
469  #       &copy; 2000-2002 by <a href="http://www.hyuki.com/">Hiroshi Yuki</a>.<br />              push @$toc, [1, "i$tocnum" => ($1 || $tocnum)];
470  #       Modified by <a href="$modifier_url">$modifier_name</a>.              push(@result, splice(@saved), qq(<h2 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h2>');
471  #   </address>              $tocnum++;
472  #   <p class="footer">          } elsif (/^(={1,6})(.*)/) {
473  #       <a href="http://www.hyuki.com/yukiwiki/">$icontag</a>              &back_push('ol', length($1), \@saved, \@result);
474  #   </p>              push(@result, '<li>' . &inline($2, const => \%const) . '</li>');
475  #   </body>          } elsif (/^(-{1,6})(.*)/) {
476  #   </html>            &back_push('ul', length($1), \@saved, \@result);
477  #   EOD            my ($pf, $l) = ('', $2);
478      # Walrus mod (1) end            if (!$main::_EMBEDED && $l =~ s/^\s*\[([0-9]+)\]//) {
479  }              my $num = 0+$1;
480                $pf = qq(<a name="anchor-$num" id="anchor-$num" class="anchor">[$num]</a>);
481  sub escape {            }
482      my $s = shift;            push(@result, '<li>' . $pf . &inline ($l, const => \%const) . '</li>');
483      $s =~ s|\r\n|\n|g;          } elsif (/^:([^:]+):(.*)/) {
484      $s =~ s|\&|&amp;|g;              &back_push('dl', 1, \@saved, \@result);
485      $s =~ s|<|&lt;|g;              push(@result, '<dt>' . &inline($1, const => \%const) . '</dt>', '<dd>' . &inline($2, const => \%const) . '</dd>');
486      $s =~ s|>|&gt;|g;          } elsif (/^(?!>>\d)(>{1,5})(.*)/) {
487      $s =~ s|"|&quot;|g;              &back_push('blockquote', length($1), \@saved, \@result);
488      return $s;              push @result, "<p>";
489  }              push(@result, &inline($2, const => \%const));
490                unshift @saved, "</p>";
491  sub unescape {          } elsif (/^\s*$/) {
492      my $s = shift;              push(@result, splice(@saved));
493      # $s =~ s|\n|\r\n|g;              push(@result, "<p>");
494      $s =~ s|\&amp;|\&|g;              unshift(@saved, "</p>");
495      $s =~ s|\&lt;|\<|g;          } elsif (/^(\s+.*)$/) {
496      $s =~ s|\&gt;|\>|g;              &back_push('pre', 1, \@saved, \@result);
497      $s =~ s|\&quot;|\"|g;              push(@result, &inline($1, const => \%const));
498      return $s;          } elsif (/^\,(.*?)[\x0D\x0A]*$/) {
499  }              &back_push('table', 1, \@saved, \@result);
500                #######
501  sub print_content {              # This part is taken from Mr. Ohzaki's Perl Memo and Makio Tsukamoto's WalWiki.
502      my ($rawcontent) = @_;              # XXXXX
503      print &text_to_html($rawcontent, toc=>1);              my $tmp = "$1,";
504  }              my @value = map {/^"(.*)"$/ ? scalar($_ = $1, s/""/"/g, $_) : $_} ($tmp =~ /("[^"]*(?:""[^"]*)*"|[^,]*),/g);
505                my @align = map {(s/^\s+//) ? ((s/\s+$//) ? ' align="center"' : ' align="right"') : ''} @value;
506  sub text_to_html {              my @colspan = map {($_ eq '==') ? 0 : 1} @value;
507      my ($txt, %option) = @_;              for (my $i = 0; $i < @value; $i++) {
508      my (@txt) = split(/\n/, $txt);                  if ($colspan[$i]) {
509      my (@toc);                      while ($i + $colspan[$i] < @value and $value[$i + $colspan[$i]] eq '==') {
510      my $tocnum = 0;                          $colspan[$i]++;
511      my (@saved, @result);                      }
512      unshift(@saved, "</p>");                      $colspan[$i] = ($colspan[$i] > 1) ? sprintf(' colspan="%d"', $colspan[$i]) : '';
513      push(@result, "<p>");                      $value[$i] = sprintf('<td%s%s>%s</td>', $align[$i], $colspan[$i], &inline($value[$i], const => \%const));
514      foreach (@txt) {                  } else {
515          chomp;                      $value[$i] = '';
516          # Walrus mod (6) start                  }
517          if ($saved[0] eq '</html>') {              }
518              if (/<\/html>/i) { splice(@saved); }              push(@result, join('', '<tr>', @value, '</tr>'));
519              else { push (@result, &html_to_ignored_html($_)); }              # XXXXX
520          } elsif (/^<html>/i and &is_ignore_html($form{mypage})) {              #######
521              push(@result, splice(@saved));          } elsif (/^\[(INS|DEL|PRE)\[\s*$/) {
522              push(@saved, '</html>');              push @result, splice (@saved), '<'.lc($1).'>';
523          } elsif (/^\*\*(.*)/) {              unshift @saved, "</p>";
524          # if (/^\*\*(.*)/) {              push @result, "<p>";
525          # Walrus mod (6) end          } elsif (/^\](INS|DEL|PRE)\]\s*$/) {
526              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push @result, splice (@saved), '</'.lc($1).'>';
527              push(@result, splice(@saved), qq(<h3><a name="i$tocnum"> </a>) . &inline($1) . '</h3>');          } elsif (/^\[([0-9]+)\](.*)$/ && !$main::_EMBEDED) {
528              $tocnum++;            my $num = 0+$1;
529          } elsif (/^\*(.*)/) {            push @result, qq(<a name="anchor-$num" id="anchor-$num" class="anchor">[$num]</a>);
530              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));            push @result, &inline ($2, const => \%const);
531              push(@result, splice(@saved), qq(<h2><a name="i$tocnum"> </a>) . &inline($1) . '</h2>');          } else {
532              $tocnum++;              push(@result, &inline($_, const => \%const));
533          } elsif (/^----/) {          }
534              push(@result, splice(@saved), '<hr>');      }
535          } elsif (/^(-{1,3})(.*)/) {      push(@result, splice(@saved));
536              &back_push('ul', length($1), \@saved, \@result);      
537              push(@result, '<li>' . &inline($2) . '</li>');      my $r = join("\n", @result);
538          } elsif (/^:([^:]+):(.*)/) {      $r =~ s#<p>\x0D?\x0A</p>##g;
539              &back_push('dl', 1, \@saved, \@result);      $r =~ s#[\x0D\x0A]+</#</#g;
540              push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>');      $r =~ s#<pre>\x0D?\x0A#<pre>#g;
541          } elsif (/^(>{1,3})(.*)/) {      $r;
542              &back_push('blockquote', length($1), \@saved, \@result);  }
543              push(@result, &inline($2));  
544          } elsif (/^\s*$/) {  sub back_push {
545              push(@result, splice(@saved));      my ($tag, $level, $savedref, $resultref, $attr) = @_;
546              unshift(@saved, "</p>");      while (@$savedref > $level) {
547              push(@result, "<p>");          push(@$resultref, shift(@$savedref));
548          } elsif (/^(\s+.*)$/) {      }
549              &back_push('pre', 1, \@saved, \@result);      if ($savedref->[0] ne "</$tag>") {
550              push(@result, &escape($1)); # Not &inline, but &escape          push(@$resultref, splice(@$savedref));
551  #       } elsif (/^\,(.*)$/) {             # Walrus del (BF)      }
552          } elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF)      while (@$savedref < $level) {
553              &back_push('table', 1, \@saved, \@result, ' border="1"');          unshift(@$savedref, "</$tag>");
554              #######          push(@$resultref, "<$tag$attr>");
555              # This part is taken from Mr. Ohzaki's Perl Memo and Makio Tsukamoto's WalWiki.      }
556              # XXXXX  }
557              my $tmp = "$1,";  
558              my @value = map {/^"(.*)"$/ ? scalar($_ = $1, s/""/"/g, $_) : $_} ($tmp =~ /("[^"]*(?:""[^"]*)*"|[^,]*),/g);  sub inline ($;%) {
559              my @align = map {(s/^\s+//) ? ((s/\s+$//) ? ' align="center"' : ' align="right"') : ''} @value;      my ($line, %option) = @_;
560              my @colspan = map {($_ eq '==') ? 0 : 1} @value;      $line = &escape($line);
561              for (my $i = 0; $i < @value; $i++) {      $line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3, $4)}ge;
562                  if ($colspan[$i]) {      $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;
563                      while ($i + $colspan[$i] < @value and $value[$i + $colspan[$i]] eq '==') {      $line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g;
564                          $colspan[$i]++;      $line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g;
565                      }      $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;
566                      $colspan[$i] = ($colspan[$i] > 1) ? sprintf(' colspan="%d"', $colspan[$i]) : '';      $line =~ s:\[RUBY\[([^]]+)\] \[([^]]+)\]\]:<ruby><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby>:g;
567                      $value[$i] = sprintf('<td%s%s>%s</td>', $align[$i], $colspan[$i], &inline($value[$i]));      $line =~ s:\[RUBYB\[([^]]+)\] \[([^]]+)\]\]:<span class="ruby"><span class="rb">$1</span><span class="rp"> (</span><span class="rt-below">$2</span><span class="rp">) </span></span>:g;
568                  } else {      $line =~ s|'''([^']+)'''|<strong>$1</strong>|g;
569                      $value[$i] = '';      $line =~ s|''([^']+)''|<em>$1</em>|g;
570                  }      $line =~ s{
571              }        (\[\[(\#\S+?)\]\])
572              push(@result, join('', '<tr>', @value, '</tr>'));        |\[\[([^[]+?)](?:&gt;&gt;([0-9]+))?]
573              # XXXXX        |&gt;&gt;([0-9]+)
574              #######        |&lt;([A-Za-z0-9%]+:(?:(?!&gt;).)+)&gt;
575          } else {      }{
576              push(@result, &inline($_));        my ($l, $page,$anchor, $anum, $uri) = ($1, $3,$4, 0+$5, $6);
577          }        if ($l) {
578      }          &embedded_to_html($1);
579      push(@result, splice(@saved));        } elsif (defined $page) {
580            &make_wikilink ($page, anchor => 0+$anchor);
581      if ($option{toc}) {        } elsif ($anum) {
582          # Convert @toc (table of contents) to HTML.          qq(<a href="#anchor-$anum" class="wiki-anchor">&gt;&gt;$anum</a>);
583          # This part is taken from Makio Tsukamoto's WalWiki.        } elsif ($uri) {
584          my (@tocsaved, @tocresult);          &make_urilink ($uri);
585          foreach (@toc) {        }
586              if (/^(-{1,3})(.*)/) {      }gex;
587                  &back_push('ul', length($1), \@tocsaved, \@tocresult);      return $line;
588                  push(@tocresult, '<li>' . $2 . '</li>');  }
589              }  
590          }  sub make_wikilink ($%) {
591          push(@tocresult, splice(@tocsaved));    my ($ename, %option) = @_;
592          return join("\n", @tocresult, @result);    my $name = &unescape ($ename);
593      } else {    if ($database{$name}) {
594          return join("\n", @result);      my $subject = &escape (&get_subjectline ($name, delimiter => ''));
595      }      if ($option{anchor}) {
596  }        return qq(<a title="$subject" href="$url_cgi?@{[&encode($name)]}#anchor-$option{anchor}" class="wiki">$ename&gt;&gt;$option{anchor}</a>);
597        } else {
598  sub back_push {        return qq(<a title="$subject" href="$url_cgi?@{[&encode($name)]}" class="wiki">$ename</a>);
599      my ($tag, $level, $savedref, $resultref, $attr) = @_;      }
600      while (@$savedref > $level) {    } else {
601          push(@$resultref, shift(@$savedref));      return qq(<a title="@{[&Resource('JumpAndEditWikiPage',escape=>1)]}" href="$url_cgi?@{[&escape($name)]}" class="wiki not-exist">$ename<span class="mark">@{[&Resource('JumpAndEditWikiPageMark',escape=>1)]}</span></a>);
602      }    }
603      if ($savedref->[0] ne "</$tag>") {  }
604          push(@$resultref, splice(@$savedref));  
605      }  sub make_urilink ($;%) {
606      while (@$savedref < $level) {    require URI;
607          unshift(@$savedref, "</$tag>");    my $uri = shift;
608          push(@$resultref, "<$tag$attr>");    if ($uri =~ s/^IW://) {       ## InterWiki (not URI)
609      }      $uri = &unescape ($uri);
610  }      if ($uri =~ /^([^\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+|"(?:\\.|[^"\\])+"):([^\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+|"(?:\\.|[^"\\])+")$/) {
611          my ($site, $name) = ($1, $2);
612  sub inline {        for ($site, $name) {
613      my ($line) = @_;          if (s/^"//) { s/"$//; s/\\(.)/$1/g }
614      $line = &escape($line);        }
615      $line =~ s|'''([^']+?)'''|<i>$1</i>|g;  # Italic        &init_InterWikiName () unless $interwiki{'[[]]'};
616      $line =~ s|''([^']+?)''|<b>$1</b>|g;    # Bold        if ($interwiki{$site}) {
617      $line =~ s|(\d\d\d\d-\d\d-\d\d \(\w\w\w\) \d\d:\d\d:\d\d)|<span class="date">$1</span>|g;   # Date          &load_formatter ('interwiki');
618      $line =~ s!          my $uri = &escape ($fmt{interwiki}->replace ($interwiki{$site} => {site => $site, name => $name}));
619                  (          $site = &escape ($site); $name = &escape ($name);
620                      ((mailto|http|https|ftp):([^\x00-\x20()<>\x7F-\xFF])*)  # Direct http://...          qq(&lt;<a href="$uri" class="out-of-wiki interwiki" title="$name ($site); URI: &lt;$uri&gt;"><span class="interwiki-site">$site:</span><span class="interwiki-name">$name</span></a>&gt;);
621                          |        } else {
622                      ($bracket_name)             # [[likethis]], [[#comment]], [[Friend:remotelink]]          qq(&lt;@{[&Resource('Error:UnknownInterWikiName=',escape=>1)]}@{[&escape ($site)]}&gt;);
623                          |        }
624                      ($interwiki_definition)     # [[Friend http://somewhere/?q=sjis($1)]]      } else {
625                          |        qq(&lt;@{[&Resource('Error:InvalidInterWiki=',escape=>1)]}@{[&escape($uri)]}&gt;);
626                      ($wiki_name)                # LocalLinkLikeThis      }
627                  )    } elsif ($uri =~ /^urn:/) {   ## URN
628              !      my $uri2 = &escape (URI->new ('/uri-res/N2L?'.&unescape ($uri), 'http')->canonical);
629                  &make_link($1)      qq(&lt;<a href="$uri2" title="URI: &lt;$uri&gt; (via &lt;$uri2&gt;)" class="out-of-wiki urn">$uri</a>&gt;);
630              !gex;    } elsif ($uri =~ s/^MAIL://) {        ## mail address (not URI)
631      return $line;      my $uri2 = &escape (URI->new ('mailto:'.&unescape ($uri))->canonical);
632  }      qq(&lt;<a href="$uri2" class="out-of-wiki mail">$uri</a>&gt;);
633      } elsif ($uri =~ s/^IMG(?:\([^)]+\))?://) {   ## image (not URI itself)
634  sub make_link {      my $uri2 = &escape (URI->new (&unescape ($uri))->canonical);
635      my $chunk = shift;      qq(<img src="$uri2" alt="" title="URI: &lt;$uri2&gt;" class="out-of-wiki">);
636      # Walrus add (3) start    } else {      ## misc. URI
637      my $name  = $chunk;      CGI::Carp::warningsToBrowser (0);
638      if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) {      my $uri2 = &escape (URI->new (&unescape ($uri))->canonical);
639          ($name, $chunk) = ($1, $2);      CGI::Carp::warningsToBrowser (1);
640      } elsif ($chunk =~ /^mailto:(.*)$/) {      qq(&lt;<a href="$uri2" title="URI: &lt;$uri2&gt;" class="out-of-wiki">$uri</a>&gt;);
641          $name = $1;    }
642      }  }
643      if ($use_autoimg and $name =~ /^(http|https|ftp|):.+\.(png|gif|jpe?g)/) {  
644          $name = qq(<img src="$name">) ;  {my $FormIndex = 0;
645      }  sub make_custom_form ($$$$) {
646      $name = &unarmor_name($name);      my ($wfname, $definition, $template, $option) = @_;
647      # Walrus add (3) end      ## $template and $option is currently not used in this procedure.
648      if ($chunk =~ /^(http|https|ftp):/) {      unless ($main::_EMBEDED) {
649          # Walrus mod (3) start          $FormIndex++;
650  #       if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) {          if (length $definition) {
651  #           return qq(<a href="$chunk"><img src="$chunk"></a>);              my $param = bless {}, 'SuikaWiki::Plugin';
652  #       } else {              my $lastmodified = $database->mtime ($form{mypage});
653  #           return qq(<a href="$chunk">$chunk</a>);              &load_formatter (qw/form_input form_option/);
654  #       }              $definition = &unescape ($definition);
655          return qq(<a href="$chunk">$name</a>);              $definition =~ s/\\(.)/$1/g;
656          # Walrus mod (3) end              $option = &unescape ($option);
657      } elsif ($chunk =~ /^(mailto):(.*)/) {              $option =~ s/\\(.)/$1/g;
658  #       return qq(<a href="$chunk">$2</a>);                 # Walrus del (3)              $fmt{form_option}->replace ($option, $param);
659          return qq(<a href="$chunk">$name</a>);              # Walrus add (3)              $param->{output}->{form} = 1 unless defined $param->{output}->{form};
660      } elsif ($chunk =~ /^$interwiki_definition$/) {              $definition .= ' %submit;' if $definition !~ /%submit/ && !$param->{output}->{nosubmit} && $param->{output}->{form};
661  #       return qq(<span class="InterWiki">$chunk</span>);   # Walrus del (3)              my $target_page = $param->{output}->{page} || $form{mypage};
662          return qq(<span class="InterWiki">$name</span>);    # Walrus add (3)              $param->{form_disabled} = 1 if $database->meta (IsFrozen => $form{mypage});
663      } elsif ($chunk =~ /^$embedded_name$/) {              my $target_form = $param->{output}->{id};
664          return &embedded_to_html($chunk);              my $r = '';
665      } else {              $r = <<EOH if $param->{output}->{form};
666          $chunk = &unarmor_name($chunk);  <form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform">
667          $chunk = &unescape($chunk); # To treat '&' or '>' or '<' correctly.    <input type="hidden" name="mycmd" value="@{[$param->{form_disabled}?'read':'wikiform']}">
668          my $cookedchunk = &encode($chunk);    <input type="hidden" name="mypage" value="@{[&escape($target_page)]}">
669          if ($chunk =~ /^$interwiki_name$/) {    <input type="hidden" name="myLastModified" value="$lastmodified">
670              my ($intername, $localname) = ($1, $2);    <input type="hidden" name="mytouch" value="on">
671              my $remoteurl = $interwiki{$intername};    <input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}">
672              if ($remoteurl) {  EOH
673  #               $remoteurl =~ s/\b(euc|sjis|ykwk|asis)\(\$1\)/&interwiki_convert($1, $localname)/e;      # Walrus del (4)              $r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#;
674                  $remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $localname)/e; # Walrus add (4)              $r .= $fmt{form_input}->replace ($definition, $param);
675  #               return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3)              $r .= "</form>\n" if $param->{output}->{form};
676                  return qq(<a href="$remoteurl">$name</a>);  # Walrus add (3)              $r;
677              } else {         } else {  ## No input-interface WikiForm
678  #               return $chunk;                              # Walrus del (3)             qq(<a id="wikiform-$FormIndex" name="wikiform-$FormIndex"><!-- #form --></a>);
679                  return $name;                               # Walrus add (3)         }
680              }      } else {
681          } elsif ($database{$chunk}) {          qq(<ins class="wiki-error">@{[&Resource('Error:WikiForm:EmbedIsNotSupported',escape=>1)]}</ins>);
682              my $subject = &escape(&get_subjectline($chunk, delimiter => ''));      }
683  #           return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$chunk</a>);  # Walrus del (3)  }}
684              return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$name</a>);   # Walrus add (3)  
685          } elsif ($page_command{$chunk}) {  sub print_message {
686  #           return qq(<a title="$chunk" href="$url_cgi?$cookedchunk">$chunk</a>);    # Walrus del (3)      my ($msg) = @_;
687              return qq(<a title="$chunk" href="$url_cgi?$cookedchunk">$name</a>);     # Walrus add (3)      print qq(<p><strong>@{[&escape($msg)]}</strong></p>);
688          } else {  }
689  #           return qq($chunk<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit&amp;mypage=$cookedchunk">$editchar</a>); # Walrus del (3)  
690              return qq($name<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit&amp;mypage=$cookedchunk">$editchar</a>);  # Walrus add (3)  sub init_form {
691          }      ## TODO: Support multipart/form-data
692      }      my $query = '';
693  }      if (uc $main::ENV{REQUEST_METHOD} eq 'POST') {
694          read STDIN, $query, $main::ENV{CONTENT_LENGTH};
695  # Walrus add (6) start      }
696  sub is_ignore_html {      $query .= ($query ? ';' : '') . $main::ENV{QUERY_STRING};
697      my ($pagename) = @_;      if ($main::ENV{REQUEST_METHOD} ne 'POST' && $main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;=]/) {
698      foreach (@ignore_html_page) {        my $query = &decode($main::ENV{QUERY_STRING});
699          return 1 if ($pagename eq $_);        $query = &code_convert(\$query, $kanjicode);
700      }        if ($page_command{$query}) {
701      return 0;          $form{mycmd} = $page_command{$query};
702  }          $form{mypage} = $query;
703  # Walrus add (6) end        } else {
704            $form{mypage} = $query;
705  # Walrus add (6) start          $form{mycmd} = $database{$form{mypage}} ? 'read' : 'edit';
706  sub html_to_ignored_html {        }
707      my $str = shift(@_);      } else {
708      my $text_regex        = q{[^<]*};        for (split /[;&]/, $query) {
709      my $tag_regex_        = q{[^"'<>]*(?:"[^"]*"[^"'<>]*|'[^']*'[^"'<>]*)*(?:>|(?=<)|$(?!\n))}; #'}}}}          if (my ($n, $v) = split /=/, $_, 2) {
710      my $comment_tag_regex = '<!(?:--[^-]*-(?:[^-]+-)*?-(?:[^>-]*(?:-[^>-]+)*?)??)*(?:>|$(?!\n)|--.*$)';            for ($n, $v) {tr/+/ /; s/%([0-9A-Fa-f][0-9A-Fa-f])/pack 'C', hex $1/ge};
711      my $tag_regex         = qq{$comment_tag_regex|<$tag_regex_};            $form{$n} = $v;
712      my $ignored           = join('|', @ignore_html_tags);          }
713      my $result = '';        }
714      while ($str =~ /($text_regex)($tag_regex)?/gso) {        unless (defined $form{mypage}) {
715        last if $1 eq '' and $2 eq '';          $form{mypage} = $form{epage};
716        $result .= $1;          $form{mypage} =~ s/([0-9A-F]{2})/ord hex $1/g;
717        my $tag_tmp = $2;        }
718        $result .= ($tag_tmp =~ /^<\/?($ignored)(?![0-9A-Za-z])/i) ? $tag_tmp : &escape($tag_tmp);        if ($page_command{$form{mypage}} && $form{mycmd} eq 'read') {
719        if ($tag_tmp =~ /^<(XMP|PLAINTEXT|SCRIPT)(?![0-9A-Za-z])/i) {          $form{mypage} = &code_convert(\$form{mypage}, $kanjicode);
720          $str =~ /(.*?)(?:<\/$1(?![0-9A-Za-z])$tag_regex_|$)/gsi;          $form{mycmd} = $page_command{$form{mypage}};
721          $result .= &escape($1);        }
722        }      }
723      }      $form{mypage} ||= 'HomePage';
724      return $result;      $form{mypage} =~ tr/\x00-\x1F\x7F//d;
725  }      $form{mycmd} ||= 'read';
726  # Walrus add (6) end  
727        # mypreview_edit        -> do_edit, with preview.
728  sub print_message {      # mypreview_adminedit   -> do_adminedit, with preview.
729      my ($msg) = @_;      # mypreview_write       -> do_write, without preview.
730      print qq(<p><strong>$msg</strong></p>);      foreach (keys %form) {
731  }          if (/^mypreview_(.*)$/) {
732                $form{mycmd} = $1;
733  sub init_form {              $form{mypreview} = 1;
734      if (param()) {          }
735          foreach my $var (param()) {      }
736              $form{$var} = param($var);  
737          }      #
738      } else {      # $form{mycmd} is frozen here.
739          $ENV{QUERY_STRING} = $FrontPage;      #
740      }  
741        for (grep /^wikiform__/, keys %form) {
742      my $query = &decode($ENV{QUERY_STRING});          $form{$_} = &code_convert (\$form{$_}, $kanjicode);
743      if ($page_command{$query}) {      }
744          $form{mycmd} = $page_command{$query};      $form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode);
745          $form{mypage} = $query;      $form{myname} = &code_convert(\$form{myname}, $kanjicode);
746      } elsif ($query =~ /^($wiki_name)$/) {  }
747          $form{mycmd} = 'read';  
748          $form{mypage} = $1;  {my %SubjectLine;
749      } elsif ($database{$query}) {  sub get_subjectline {
750          $form{mycmd} = 'read';      my ($page, %option) = @_;
751          $form{mypage} = $query;      unless (defined $SubjectLine{$page}) {
752      }        if (not &is_editable($page)) {
753            $SubjectLine{$page} = "";
754      # mypreview_edit        -> do_edit, with preview.        } else {
755      # mypreview_adminedit   -> do_adminedit, with preview.          $SubjectLine{$page} = $database{$page};
756      # mypreview_write       -> do_write, without preview.          $SubjectLine{$page} =~ s!^\#\?[^\x0A\x0D]+[\x0A\x0D]*!!s;
757      foreach (keys %form) {          $SubjectLine{$page} =~ s/\x0D?\x0A.*//s;
758          if (/^mypreview_(.*)$/) {        }
759              $form{mycmd} = $1;      }
760              $form{mypreview} = 1;      if (length $SubjectLine{$page}) {
761          }        $option{delimiter} = defined $option{delimiter} ? $option{delimiter} : &Resource('Title-Summary Delimiter');
762      }        $option{delimiter}.$SubjectLine{$page}.$option{tail};
763        } else {
764      #        '';
765      # $form{mycmd} is frozen here.      }
766      #  }}
767    
768      $form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode);  sub open_db {
769      $form{myname} = &code_convert(\$form{myname}, $kanjicode);      if ($modifier_dbtype eq 'dbmopen') {
770  }          dbmopen(%database, $PathTo{WikiDataBase}, 0666) or &print_error("(dbmopen) $PathTo{WikiDataBase}");
771        } elsif ($modifier_dbtype eq 'AnyDBM_File') {
772  sub update_recent_changes {          eval q{use AnyDBM_File};
773      my $update = "- @{[&get_now]} @{[&armor_name($form{mypage})]} @{[&get_subjectline($form{mypage})]}";          tie(%database, "AnyDBM_File", $PathTo{WikiDataBase}, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $PathTo{WikiDataBase}");
774      my @oldupdates = split(/\r?\n/, $database{$RecentChanges});      } elsif ($modifier_dbtype eq 'Yuki::YukiWikiDB') {
775      my @updates;          eval q{use Yuki::YukiWikiDB};
776      foreach (@oldupdates) {          tie(%database, "Yuki::YukiWikiDB", $PathTo{WikiDataBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiDataBase}");
777          /^\- \d\d\d\d\-\d\d\-\d\d \(...\) \d\d:\d\d:\d\d (\S+)/;    # date format.      } else {    ## Yuki::YukiWikiDB || Yuki::YukiWikiDBMeta
778          my $name = &unarmor_name($1);          eval qq{use $modifier_dbtype};
779          if (&is_exist_page($name) and ($name ne $form{mypage})) {          $database = tie(%database, $modifier_dbtype => $PathTo{WikiDataBase}, -lock => 2, -backup => $wiki::diff::UseDiff) or &print_error("(tie $modifier_dbtype) $PathTo{WikiDataBase}");
780              push(@updates, $_);      }
781          }  }
782      }  
783      if (&is_exist_page($form{mypage})) {  sub close_db {
784          unshift(@updates, $update);      if ($modifier_dbtype eq 'dbmopen') {
785      }          dbmclose(%database);
786      splice(@updates, $maxrecent + 1);      } else {
787      $database{$RecentChanges} = join("\n", @updates);          untie(%database);
788      if ($file_touch) {      }
789          open(FILE, "> $file_touch");  }
790          print FILE localtime() . "\n";  
791          close(FILE);  sub editform (@) {
792      }    my %option = @_;
793  }    my $frozen = &is_frozen ($option{page});
794      $option{content} = $database{$option{page}} unless defined $option{content};
795  sub get_subjectline {    $option{content} = $database{NewPageTemplate} unless length $option{content};
796      my ($page, %option) = @_;    $option{last_modified} = $database->mtime ($option{page}) unless defined $option{last_modified};
797      if (not &is_editable($page)) {    my $f = '';
798          return "";    my $magic = '';
799      } else {    $magic = $1 if $option{content} =~ m/^([^\x0A\x0D]+)/s;
800          # Delimiter check.    
801          my $delim = $subject_delimiter;    my $selected = 'read';
802          if (defined($option{delimiter})) {    if ($form{after_edit_cmd}) {
803              $delim = $option{delimiter};      $selected = $form{after_edit_cmd};
804          }    } elsif ($magic =~ /Const|Config|CSS/) {
805        $selected = 'edit';
806          # Get the subject of the page.    }
807          my $subject = $database{$page};    my $afteredit = <<EOH;
808          $subject =~ s/\r?\n.*//s;  <select name="after_edit_cmd">
809          return "$delim$subject";  <option value="read" label="@{[&Resource('Edit:SaveAndView',escape=>1)]}"@{[$selected eq 'read' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndView',escape=>1)]}</option>
810      }  <option value="edit" label="@{[&Resource('Edit:SaveAndEdit',escape=>1)]}"@{[$selected eq 'edit' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndEdit',escape=>1)]}</option>
811  }  </select>
812    EOH
813  sub send_mail_to_admin {    $f .= <<"EOD";
814      my ($page, $mode) = @_;  <form action="$uri{wiki}" method="post">
815      return unless $modifier_sendmail;      @{[ $option{conflict} ? '' : qq(<label><input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}"><kbd>S</kbd></label>) ]}
816      my $message = <<"EOD";      @{[ $option{admin} ? qq(<label>@{[&Resource('Edit:Password=',escape=>1)]}<input type="password" name="mypassword" value="" size="10"></label>) : "" ]} [@{[&get_new_anchor_index($option{content})]}]<br>
817  To: $modifier_mail      <input type="hidden" name="myLastModified" value="$option{last_modified}">
818  From: $modifier_mail      <input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}">
819  Subject: [Wiki]      <textarea cols="@{[&Resource('Edit:Form:Cols')+0||80]}" rows="@{[&Resource('Edit:Form:Rows')+0||20]}" name="mymsg" tabindex="1">@{[&escape($option{content})]}</textarea><br>
820  MIME-Version: 1.0  @{[
821  Content-Type: text/plain; charset=ISO-2022-JP      $option{admin} ?
822  Content-Transfer-Encoding: 7bit      qq(
823        <label><input type="radio" name="myfrozen" value="1" @{[$frozen ? qq(checked="checked") : ""]}>@{[&Resource('Edit:Freeze',escape=>1)]}</label>
824  --------      <label><input type="radio" name="myfrozen" value="0" @{[$frozen ? "" : qq(checked="checked")]}>@{[&Resource('Edit:DontFreeze',escape=>1)]}</label><br>)
825  MODE = $mode      : ""
826  REMOTE_ADDR = $ENV{REMOTE_ADDR}  ]}
827  REMOTE_HOST = $ENV{REMOTE_HOST}  @{[
828  --------      $option{conflict} ? "" :
829  $page      qq(
830  --------          <label><input type="checkbox" name="mytouch" value="on" checked="checked">@{[&Resource('Edit:UpdateTimeStamp',escape=>1)]}</label><br>
831  $database{$page}          <label><input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}" accesskey="S"><kbd>S</kbd></label>
832  --------         $afteredit
833  EOD      )
834      &code_convert(\$message, 'jis');  ]}
835      open(MAIL, "| $modifier_sendmail");  </form>
836      print MAIL $message;  EOD
837      close(MAIL);      unless ($option{conflict}) {
838  }          ## Show help text
839            my $help = $database{WikiEditHelp};
840  sub open_db {          $help =~ s!^\#\?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+!!s;
841      if ($modifier_dbtype eq 'dbmopen') {          $f .= &text_to_html ($help, toc => 0);
842          dbmopen(%database, $dataname, 0666) or &print_error("(dbmopen) $dataname");      }
843          dbmopen(%infobase, $infoname, 0666) or &print_error("(dbmopen) $infoname");      $f;
844      } elsif ($modifier_dbtype eq 'AnyDBM_File') {  }
845          tie(%database, "AnyDBM_File", $dataname, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $dataname");  
846          tie(%infobase, "AnyDBM_File", $infoname, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $infoname");  sub is_editable {
847      } else {      my ($page) = @_;
848          tie(%database, "Yuki::YukiWikiDB", $dataname) or &print_error("(tie Yuki::YukiWikiDB) $dataname");      $page =~ /[\x00-\x1F\x7F]/ ? 0 : 1;
849          tie(%infobase, "Yuki::YukiWikiDB", $infoname) or &print_error("(tie Yuki::YukiWikiDB) $infoname");  }
850      }  
851  }  # armor_name:
852    #   WikiName -> WikiName
853  sub close_db {  #   not_wiki_name -> [[not_wiki_name]]
854      if ($modifier_dbtype eq 'dbmopen') {  sub armor_name { qq([[$_[0]]]) }
855          dbmclose(%database);  
856          dbmclose(%infobase);  # unarmor_name:
857      } elsif ($modifier_dbtype eq 'AnyDBM_File') {  #   [[bracket_name]] -> bracket_name
858          untie(%database);  #   WikiName -> WikiName
859          untie(%infobase);  sub unarmor_name {
860      } else {      my ($name) = @_;
861          untie(%database);      if ($name =~ /^\[\[(\S+?)\]\]$/) {
862          untie(%infobase);          return $1;
863      }      } else {
864  }          return $name;
865        }
866  sub open_diff {  }
867      if ($modifier_dbtype eq 'dbmopen') {  
868          dbmopen(%diffbase, $diffname, 0666) or &print_error("(dbmopen) $diffname");  sub decode {
869      } elsif ($modifier_dbtype eq 'AnyDBM_File') {      my ($s) = @_;
870          tie(%diffbase, "AnyDBM_File", $diffname, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $diffname");      $s =~ tr/+/ /;
871      } else {      $s =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("C", hex($1))/eg;
872          tie(%diffbase, "Yuki::YukiWikiDB", $diffname) or &print_error("(tie Yuki::YukiWikiDB) $diffname");      return $s;
873      }  }
874  }  
875    sub encode {
876  sub close_diff {      my ($s) = @_;
877      if ($modifier_dbtype eq 'dbmopen') {      my $encoded = '';
878          dbmclose(%diffbase);      foreach my $ch (split(//, $s)) {
879      } elsif ($modifier_dbtype eq 'AnyDBM_File') {          if ($ch =~ /[A-Za-z0-9_]/) {
880          untie(%diffbase);              $encoded .= $ch;
881      } else {          } else {
882          untie(%diffbase);              $encoded .= '%' . sprintf("%02X", ord($ch));
883      }          }
884  }      }
885        return $encoded;
886  sub print_searchform {  }
887      my ($word) = @_;  
888      print <<"EOD";  sub get_now {
889  <form action="$url_cgi" method="get">      my ($sec, $min, $hour, $day, $mon, $year) = localtime(time);
890      <input type="hidden" name="mycmd" value="search">      $year += 1900;
891      <input type="text" name="mymsg" value="$word" size="20">      $mon++;
892      <input type="submit" value="$resource{searchbutton}">      $mon = "0$mon" if $mon < 10;
893  </form>      $day = "0$day" if $day < 10;
894  EOD      $hour = "0$hour" if $hour < 10;
895  }      $min = "0$min" if $min < 10;
896        #$sec = "0$sec" if $sec < 10;
897  sub print_editform {      return "$year-$mon-$day $hour:$min";
898      my ($mymsg, $lastmodified, %mode) = @_;  }
899      my $frozen = &is_frozen($form{mypage});  
900    sub init_InterWikiName {
901      if ($form{mypreview}) {    my @content = split /\n/, $database{InterWikiName};
902          if ($form{mymsg}) {    for (@content) {
903              unless ($mode{conflict}) {      if (/^([^#]\S*)\s+(\S[^\x0A\x0D]+)/) {
904                  print qq(<h3>$resource{previewtitle}</h3>\n);        $interwiki{$1} = $2;
905                  print qq($resource{previewnotice}\n);      }
906                  print qq(<div class="preview">\n);    }
907                  &print_content($form{mymsg});    $interwiki{'[[]]'} = 1;       ## dummy
908                  print qq(</div>\n);  }
909              }  
910          } else {  sub frozen_reject {
911              print qq($resource{previewempty});      my ($isfrozen) = $database->meta (IsFrozen => $form{mypage});
912          }      my ($willbefrozen) = $form{myfrozen};
913          $mymsg = &escape($form{mymsg});      if (not $isfrozen and not $willbefrozen) {
914      } else {          # You need no check.
915          $mymsg = &escape($mymsg);          return 0;
916      }      } elsif (valid_password($form{mypassword})) {
917            # You are admin.
918      my $edit = $mode{admin} ? 'adminedit' : 'edit';          return 0;
919        } else {
920      print <<"EOD";          &print_error(&Resource('Error:PasswordIsIncorrect'));
921  <form action="$url_cgi" method="post">          return 1;
922      @{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$form{mypassword}" size="10"><br>) : "" ]}      }
923      <input type="hidden" name="myLastModified" value="$lastmodified">  }
924      <input type="hidden" name="mypage" value="$form{mypage}">  
925      <textarea cols="$cols" rows="$rows" name="mymsg" wrap="off">$mymsg</textarea><br>  sub is_frozen ($) { $database->meta (IsFrozen => $_[0]) ? 1 : 0 }
926  @{[  
927      $mode{admin} ?  sub do_comment {
928      qq(      my ($content) = $database{$form{mypage}};
929      <input type="radio" name="myfrozen" value="1" @{[$frozen ? qq(checked="checked") : ""]}>$resource{frozenbutton}      my $default_name;   ## this code does not strict.
930      <input type="radio" name="myfrozen" value="0" @{[$frozen ? "" : qq(checked="checked")]}>$resource{notfrozenbutton}<br>)      $default_name = $1 if $content =~ /default-name="([^"]+)"/;
931      : ""      my $datestr = '[WEAK['.&get_now.']]';
932  ]}      my $namestr = $form{myname} || $default_name || &Resource('WikiForm:WikiComment:DefaultName');
933  @{[      ($namestr = '', $datestr = '') if $form{myname} eq 'nodate';
934      $mode{conflict} ? "" :      if ($namestr =~ /^(?:>>)?[0-9]/) {
935      qq(        $namestr = qq( ''$namestr'': );
936          <input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br>      } elsif (length $namestr) {
937          <input type="submit" name="mypreview_$edit" value="$resource{previewbutton}">        $namestr = qq( ''[[$namestr]]'': );
938          <input type="submit" name="mypreview_write" value="$resource{savebutton}"><br>      }
939      )      my $anchor = &get_new_anchor_index ($content);
940  ]}      my $i = 1;  my $o = 0;
941  </form>      $content =~ s{(\[\[\#r?comment\]\])}{
942  EOD        my $embed = $1;
943      unless ($mode{conflict}) {        if ($i == $form{comment_index}) {
944          # Show the format rule.          if ($embed ne '[[#rcomment]]') {
945          open(FILE, $file_format) or &print_error("($file_format)");            $embed = "- [$anchor] $datestr$namestr$form{mymsg}\n$embed";  $o = 1;
946          my $content = join('', <FILE>);          } else {
947          &code_convert(\$content, $kanjicode);            $embed .= "\n- [$anchor] $datestr$namestr$form{mymsg}";  $o = 1;
948          close(FILE);          }
949          print &text_to_html($content, toc=>0);        }
950      }        $i++; $embed;
951  }      }ge;
952        unless ($o) {
953  sub print_passwordform {        $content = "#?SuikaWiki/0.9\n\n" unless $content;
954          print <<"EOD";        $content .= "\n" unless $content =~ /\n$/s;
955  <form action="$url_cgi" method="post">        $content .= "- [$anchor] $datestr$namestr$form{mymsg}\n";
956      <input type="hidden" name="mycmd" value="adminchangepassword">      }
957      $resource{oldpassword} <input type="password" name="myoldpassword" size="10"><br>      $form{__comment_anchor_index} = $anchor;
958      $resource{newpassword} <input type="password" name="mynewpassword" size="10"><br>      if ($form{mymsg} || $form{myname}) {
959      $resource{newpassword2} <input type="password" name="mynewpassword2" size="10"><br>          $form{mymsg} = $content;
960      <input type="submit" value="$resource{changepasswordbutton}"><br>          $form{mytouch} = 'on';
961  </form>          &do_write;
962  EOD      } else {
963  }          $form{mycmd} = 'read';
964            &do_read;
965  sub is_editable {      }
966      my ($page) = @_;  }
967      if (&is_bracket_name($page)) {  
968          return 0;  sub get_new_anchor_index ($) {
969      } elsif ($fixedpage{$page}) {      my $content = shift;
970          return 0;      my $anchor = 0;
971      } elsif ($page =~ /\s/) {      $content =~ s/^(?:[-=]+\s*)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge;
972          return 0;      $anchor + 1;
973      } elsif ($page =~ /^\#/) {  }
974          return 0;  
975      } elsif ($page =~ /^$interwiki_name$/) {  my $CommentIndex = 0;
976          return 0;  sub embedded_to_html {
977      } else {      my ($embedded) = @_;
978          return 1;      if ($embedded eq '[[#comment]]' or $embedded eq '[[#rcomment]]') {
979      }        unless ($main::_EMBEDED) {
980  }          my $lastmodified = $database->mtime ($form{mypage});
981            return <<"EOD";
982  # armor_name:  <form action="$url_cgi" method="post" id="x-comment-@{[++$CommentIndex]}" class="comment"><p>
983  #   WikiName -> WikiName      <input type="hidden" name="mycmd" value="comment">
984  #   not_wiki_name -> [[not_wiki_name]]      <input type="hidden" name="mypage" value="$form{mypage}">
985  sub armor_name {      <input type="hidden" name="myLastModified" value="$lastmodified">
986      my ($name) = @_;      <input type="hidden" name="mytouch" value="on">
987      if ($name =~ /^$wiki_name$/) {      <input type="hidden" name="comment_index" value="$CommentIndex">
988          return $name;      @{[&Resource('WikiForm:WikiComment:Name=',escape=>1)]}
989      } else {      <input type="text" name="myname" value="" size="10" class="comment-name">
990          return "[[$name]]";      <input type="text" name="mymsg" value="" size="60" class="comment-msg">
991      }      <input type="submit" value="@{[&Resource('WikiForm:Add',escape=>1)]}" title="@{[&Resource('WikiForm:AddLong',escape=>1)]}" class="comment-submit">
992  }  </p></form>
993    EOD
994  # unarmor_name:       } else {
995  #   [[bracket_name]] -> bracket_name          return <<"EOD";
996  #   WikiName -> WikiName  <del><form action="$url_cgi" method="get">
997  sub unarmor_name {      <input type="hidden" name="mycmd" value="read">
998      my ($name) = @_;      <input type="hidden" name="mypage" value="$form{mypage}">
999      if ($name =~ /^$bracket_name$/) {      @{[&Resource('WikiForm:WikiComment:Name=',escape=>1)]}
1000          return $1;      <input type="text" name="myname" value="" size="10" disabled="disabled">
1001      } else {      <input type="text" name="mymsg" value="" size="60" disabled="disabled">
1002          return $name;  </form></del>
1003      }  EOD
1004  }      }
1005      } elsif ($embedded =~ /$embed_command{searched}/) {
1006  sub is_bracket_name {      return get_search_result ($1, -match_myself => 1);
1007      my ($name) = @_;    } elsif ($embedded =~ /^\[\[\#embed:(.+)\]\]$/) {
1008      if ($name =~ /^$bracket_name$/) {      my ($name, $r) = ($1, '');
1009          return 1;      if ($main::_EMBEDED != 1) {
1010      } else {        my ($content, $cf) = ($database{$name}, 'SuikaWiki/0.9');
1011          return 0;        $cf = $1 if $content =~ s!^(?:[\#<]\?|/\*\s*)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.][^\x0D\x0A]*)?)[\x0D\x0A]+!!s;
1012      }        if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) {
1013  }          $main::_EMBEDED = 1;
1014            $r = &text_to_html ($content, content_format => $cf);
1015  sub decode {          $main::_EMBEDED = 0;
1016      my ($s) = @_;        } elsif (length $content) {
1017      $s =~ tr/+/ /;          $r = "<pre>@{[&escape ($content)]}</pre>";
1018      $s =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("C", hex($1))/eg;        } else {
1019      return $s;          $r = &text_to_html ("[INS[\n[[$name]]: @{[&Resource('Embed:PageNotFound')]}\n]INS]\n", content_format => 'SuikaWiki/0.9');
1020  }        }
1021        } else {    ## nested #EMBED
1022  sub encode {        $r = &text_to_html ("[INS[\n[[$name]]: @{[&Resource('Embed:Nested',escape=>1)]}\n]INS]\n", content_format => 'SuikaWiki/0.9');
1023      my ($s) = @_;      }
1024      my $encoded = '';      return qq(<blockquote title="@{[&escape($name)]}" class="wiki-embed">$r<div class="cite-note">。リ<cite><a href="$url_cgi?@{[&encode($name)]}" class="wiki">@{[&escape($name)]}</a></cite>。ル</div></blockquote>);
1025      foreach my $ch (split(//, $s)) {    } elsif ($embedded =~ /^\[\[\#randomlink:(.+)\]\]$/) {
1026          if ($ch =~ /[A-Za-z0-9_]/) {      return qq(<a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">$1</a>);
1027              $encoded .= $ch;    } else {
1028          } else {      return $embedded;
1029              $encoded .= '%' . sprintf("%02X", ord($ch));    }
1030          }  }
1031      }  
1032      return $encoded;  sub load_formatter (@) {
1033  }      for my $t (@_) {
1034            unless ($fmt{$t}) {
1035  sub init_resource {              require Message::Util::Formatter;
1036      open(FILE, $file_resource) or &print_error("(resource)");              $fmt{$t} = Message::Util::Formatter->new;
1037      while (<FILE>) {              for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) {
1038          chomp;                  $_->load_formatter ($fmt{$t}, type => 'wiki'.$t);
1039          next if /^#/;              }
1040          my ($key, $value) = split(/=/, $_, 2);          }
1041          $resource{$key} = &code_convert(\$value, $kanjicode);      }
1042      }  }
1043      close(FILE);  
1044  }  sub do_wikiform {
1045        my $content = $database{$form{mypage}};
1046  sub conflict {      my $anchor = &get_new_anchor_index ($content);
1047      my ($page, $rawmsg) = @_;      &load_formatter (qw/form_template form_option/);
1048      if ($form{myLastModified} eq &get_info($page, $info_LastModified)) {      my $write = 0;
1049          return 0;      my $i = 1;
1050      }      $content =~ s{$embed_command{form}}{
1051      open(FILE, $file_conflict) or &print_error("(conflict)");          my ($embed, $wfname, $template, $option) = ($&, $1, $3, $4);
1052      my $content = join('', <FILE>);          if (($wfname && $wfname eq $form{wikiform_targetform})
1053      &code_convert(\$content, $kanjicode);              || $i == $form{wikiform_index}) {
1054      close(FILE);              $template =~ s/\\(.)/$1/g;
1055      &print_header($page);              $option =~ s/\\(.)/$1/g;
1056      &print_content($content);              my $param = bless {}, 'SuikaWiki::Plugin';
1057      &print_editform($rawmsg, $form{myLastModified}, frozen=>0, conflict=>1);              $param->{page} = $form{mypage};
1058      &print_footer($page);              $param->{form_index} = $i;
1059      return 1;              $param->{form_name} = $wfname;
1060  }              $param->{anchor_index} = $anchor;
1061                $param->{argv} = \%form;
1062  sub get_now {              $param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/;
1063      my (@week) = qw(Sun Mon Tue Wed Thu Fri Sat);              $param->{default_name} ||= &Resource('WikiForm:WikiComment:DefaultName');
1064      my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time);              $fmt{form_option}->replace ($option, $param);
1065      $year += 1900;              my $t = 1;
1066      $mon++;              for (@{$param->{require}||[]}) {
1067      $mon = "0$mon" if $mon < 10;                  (undef $t, last) unless length $param->{argv}->{'wikiform__'.$_};
1068      $day = "0$day" if $day < 10;              }
1069      $hour = "0$hour" if $hour < 10;              $t = $fmt{form_template}->replace ($template, $param) if $t;
1070      $min = "0$min" if $min < 10;              if (length $t) {
1071      $sec = "0$sec" if $sec < 10;                  if ($param->{output}->{reverse}) {
1072      $weekday = $week[$weekday];                      $embed .= "\n" . $t;
1073      return "$year-$mon-$day ($weekday) $hour:$min:$sec";                  } else {
1074  }                      $embed = $t . "\n" . $embed;
1075                    }
1076  # [[YukiWiki http://www.hyuki.com/yukiwiki/wiki.cgi?euc($1)]]                  $write = 1;
1077  sub init_InterWikiName {                  $form{__comment_anchor_index} = $anchor
1078      my $content = $database{$InterWikiName};                    if $param->{anchor_index_};  ## $anchor is used!
1079      while ($content =~ /\[\[(\S+) +(\S+)\]\]/g) {              }
1080          my ($name, $url) = ($1, $2);              $form{__wikiform_anchor_index} = $i;
1081          $interwiki{$name} = $url;              undef $form{wikiform_targetform};  ## make sure never to match
1082      }              undef $form{wikiform_index};       ## with WikiForm in rest of page
1083  }          }
1084            $i++; $embed;
1085  sub interwiki_convert {      }ge;
1086      my ($type, $localname) = @_;      unless ($write) {
1087      if ($type eq 'sjis' or $type eq 'euc') {        #$content = "#?SuikaWiki/0.9\n\n" unless $content;
1088          &code_convert(\$localname, $type);        #$content .= "\n" unless $content =~ /\n$/s;
1089          return &encode($localname);        #
1090      } elsif ($type eq 'ykwk') {      }
1091          # for YukiWiki1      if ($write) {
1092          if ($localname =~ /^$wiki_name$/) {          $form{mymsg} = $content;
1093              return $localname;          $form{mytouch} = 'on';
1094          } else {          &do_write;
1095              &code_convert(\$localname, 'sjis');      } else {
1096              return &encode("[[" . $localname . "]]");          $form{mycmd} = 'read';
1097          }          &do_read;
1098      } elsif ($type eq 'asis') {      }
1099          return $localname;  }
1100      # Walrus add (4) start  
1101      } elsif ($type eq 'isbn') {  sub code_convert {
1102          $localname = join('', ($localname =~ /[0-9x]/g)) if ($localname =~ /^(\d-?){9}[\dx]$/);    require Jcode;
1103          return $localname;      my ($contentref, $code) = (shift, shift || $kanjicode);
1104      # Walrus add (4) end      $code = 'jis' if $code =~ /iso/;
1105      } else {      $code = 'euc' if $code =~ /euc/;
1106          return $localname;      $code = 'sjis' if $code =~ /shift/;
1107      }      $code = 'utf8' if $code =~ /utf/;
1108  }      $$contentref = Jcode->new ($contentref)->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;
1109        return $$contentref;
1110  sub get_info {  }
1111      my ($page, $key) = @_;  
1112      my %info = map { split(/=/, $_, 2) } split(/\n/, $infobase{$page});  sub do_diff {
1113      return $info{$key};      my $title = $form{mypage};
1114  }      &print_header($title, -noindex => 1);
1115        print qq(<h2>@{[&Resource('Diff:Title',escape=>1)]}</h2>);
1116  sub set_info {      print qq(<p>@{[&Resource('Diff:Notice',escape=>1)]}</p>);
1117      my ($page, $key, $value) = @_;      print qq(<pre class="diff">);
1118      my %info = map { split(/=/, $_, 2) } split(/\n/, $infobase{$page});      for (split(/\n/, &escape ($database->traverse_diff ($form{mypage})))) {
1119      $info{$key} = $value;          if (/^\+(.*)/) {
1120      my $s = '';              print qq(<ins class="added">$1</ins>\n);
1121      for (keys %info) {          } elsif (/^\-(.*)/) {
1122          $s .= "$_=$info{$_}\n";              print qq(<del class="deleted">$1</del>\n);
1123      }          } elsif (/^\=(.*)/) {
1124      $infobase{$page} = $s;              print qq(<span class="same">$1</span>\n);
1125  }          } else {
1126                print qq|??? $_\n|;
1127  sub frozen_reject {          }
1128      my ($isfrozen) = &get_info($form{mypage}, $info_IsFrozen);      }
1129      my ($willbefrozen) = $form{myfrozen};      print qq(</pre>);
1130      if (not $isfrozen and not $willbefrozen) {      &print_footer($title);
1131          # You need no check.  }
1132          return 0;  
1133      } elsif (valid_password($form{mypassword})) {  sub do_rss {
1134          # You are admin.      eval q{use Yuki::RSS};
1135          return 0;      my $rss = new Yuki::RSS(
1136      } else {          version => '1.0',
1137          &print_error($resource{passworderror});          encoding => &get_charset_name ($kanjicode),
1138          return 1;      );
1139      }      my $scheme = 'http';
1140  }      $scheme = lc $1 if $main::ENV{SERVER_PROTOCOL} =~ m#([A-Za-z0-9+.%-]+)#;
1141        my $myuri = "$scheme://$main::ENV{SERVER_NAME}:$main::ENV{SERVER_PORT}$url_cgi";
1142  sub valid_password {      $rss->stylesheet (
1143      my ($givenpassword) = @_;        href      => $myuri . "?mycmd=TEXT_CSS;mypage=WikiStyle:RSS",
1144      my ($validpassword_crypt) = &get_info($AdminSpecialPage, $info_AdminPassword);        type      => 'text/css',
1145      if (crypt($givenpassword, $validpassword_crypt) eq $validpassword_crypt) {      );
1146          return 1;      $rss->channel(
1147      } else {          title   => &Resource ('RSS:WikiTitle'),
1148          return 0;          link    => $myuri,
1149      }          description     => &Resource ('RSS:WikiDescription'),
1150  }          'dc:language'   => $lang,
1151        );
1152  sub is_frozen {      my $recentchanges = $database{RecentChanges};
1153      my ($page) = @_;      my $count = 0;
1154      if (&get_info($page, $info_IsFrozen)) {      foreach (split(/\n/, $recentchanges)) {
1155          return 1;          last if ($count >= 15);
1156      } else {          if (/\[\[([^]]+)\]\]/) {
1157          return 0;            my $title = $1;
1158      }            $rss->add_item (
1159  }              title       => &escape($title),
1160                link        => $myuri . '?' . &encode($title),
1161  sub do_comment {              description => &escape(&get_subjectline($title,delimiter=>'')),
1162      my ($content) = $database{$form{mypage}};              'dc:date'   => $database->mtime ($title),
1163      my $datestr = &get_now;            );
1164      my $namestr = $form{myname} ? " ''[[$form{myname}]]'' : " : " ";            $count++;
1165      if ($content =~ s/(\Q$embed_comment\E)/- $datestr$namestr$form{mymsg}\n$1/) {          }
1166          ;      }
1167      } else {      # print RSS information (as XML).
1168          $content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/;      print <<"EOD"
1169      }  Content-type: application/xml; charset=@{[&get_charset_name ($kanjicode)]}
1170      if ($form{mymsg}) {  
1171          $form{mymsg} = $content;  @{[$rss->as_string]}
1172          $form{mytouch} = 'on';  EOD
1173          &do_write;  }
1174      } else {  
1175          $form{mycmd} = 'read';  sub _rfc3339_date ($) {
1176          &do_read;    my @time = gmtime (shift);
1177      }    sprintf '%04d-%02d-%02dT%02d:%02d:%02d+00:00', $time[5]+1900,$time[4]+1,@time[3,2,1,0];
1178  }  }
1179    
1180  sub embedded_to_html {  sub is_exist_page {
1181      my ($embedded) = @_;      my ($name) = @_;
1182      if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) {      if ($use_exists) {
1183          my $lastmodified = &get_info($form{mypage}, $info_LastModified);          return exists($database{$name});
1184          return <<"EOD";      } else {
1185  <form action="$url_cgi" method="post">          return $database{$name};
1186      <input type="hidden" name="mycmd" value="comment">      }
1187      <input type="hidden" name="mypage" value="$form{mypage}">  }
1188      <input type="hidden" name="myLastModified" value="$lastmodified">  
1189      <input type="hidden" name="mytouch" value="on">  sub __get_database ($) { $database{ $_[0] } }
1190      $resource{yourname}  
1191      <input type="text" name="myname" value="" size="10">  my %_Resource;
1192      <input type="text" name="mymsg" value="" size="40">  sub Resource ($;%) {
1193      <input type="submit" value="$resource{commentbutton}">    my ($s, %o) = @_;
1194  </form>    unless (defined $_Resource{$s}) {
1195  EOD      $_Resource{$_[0]} = &wiki::resource::get ($s, $_Resource{__option});
1196      # Walrus add (5) start    }
1197      } elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) {    $o{escape} ? &escape ($_Resource{$s}) : $_Resource{$s};
1198          $_ = &make_interwiki_box($1, $2);  }
1199          return ($_) ? $_ : $embedded;  
1200      # Walrus add (5) end  package wiki::referer;
1201      } else {  sub add ($$) {
1202          return $embedded;    my $page = shift;
1203      }    my $uri = shift;
1204  }    unless (ref $uri) {
1205        require URI;
1206  # Walrus add (5) start      $uri = URI->new ($uri);
1207  sub do_interwiki_box {      ## Some schemes do not have query part.
1208      my $remoteurl = $interwiki{$form{'myintername'}};      eval q{ $uri->query (undef) if $uri->query =~ /^[0-9]{6,8}$/ };
1209      if ($remoteurl) {      $uri->fragment (undef);
1210          $remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $form{'mylocalname'})/e;    }
1211          print "Location: $remoteurl\n\n";    $uri = $uri->canonical;
1212          exit(1);    return unless $uri;
1213      } else {    for my $regex (&get_dont_record) {
1214          &do_read;      return if $uri =~ /$regex/;
1215      }    }
1216  }    my %list = get ($page);
1217  # Walrus add (5) end    $list{ $uri }++;
1218      set ($page, \%list);
1219  # Walrus add (5) start  }
1220  sub make_interwiki_box {  sub get ($) { split /"/, $main::database->meta (Referer => $_[0]) }
1221      my ($localname, $intername) = @_;  sub set ($%) {
1222      my %ignoretype = (    my $page = shift;
1223          'box'      => 'text',    my $list = shift;
1224          'text'     => 'text',    $main::database->meta (Referer => $page => join '"', %$list);
1225          'pass'     => 'password',  }
1226          'password' => 'password'  
1227      );  sub get_dont_record () {
1228      my $converted = ($ignoretype{$localname}) ? <<EOD : undef;    map {s/\$/\\\$/g; s/\@/\\\@/g; $_}
1229  <form action="$url_cgi" method="post">    grep !/^#/,
1230      <input type="hidden" name="mycmd" value="interwikibox">    split /[\x0D\x0A]+/, &main::__get_database ('RefererDontRecord');
1231      <input type="hidden" name="mypage" value="$form{mypage}">  }
1232      <input type="hidden" name="myintername" value="$intername">  sub get_site_name () {
1233      $intername:    my @lines = grep /[^#]/, split /[\x0D\x0A]+/, &main::__get_database('RefererSiteName');
1234      <input type="$ignoretype{$localname}" name="mylocalname" value="" size="10">    my @item;
1235      <input type="submit" value="Submit">    for (@lines) {
1236  </form>      next if /^#/;
1237  EOD      my ($uri, $name) = split /\s+/, $_, 2;
1238  }      $uri =~ s/\$/\\\$/g;  $uri =~ s/\@/\\\@/g;  $uri =~ s/\//\\\//g;
1239  # Walrus add (5) end      $name =~ s!([()/\\])!\\$1!g;  $name =~ s/\$([0-9]+)/).__decode (\${$1}).q(/g;
1240        push @item, [$uri, qq(q($name))];
1241  sub code_convert {    }
1242      my ($contentref, $kanjicode) = @_;    @item;
1243  #   &Jcode::convert($contentref, $kanjicode);       # for Jcode.pm  }
1244      &jcode::convert($contentref, $kanjicode);       # for jcode.pl  
1245      return $$contentref;  sub list_html ($) {
1246  }    my $page = shift;
1247      my %list = get ($page);
1248  sub test_convert {    my $r = '';
1249      my $txt = &text_to_html(<<"EOD", toc=>1);    my @name = get_site_name;
1250  *HEADER1    for my $uri (sort keys %list) {
1251  **HEADER1-1      my $title;
1252  -ITEM1      for my $item (@name) {
1253  -ITEM2        if ($uri =~ /$item->[0]/) {
1254  -ITEM3          $title = $uri;
1255  PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1          eval qq{\$title =~ s/^.*$item->[0].*\$/$item->[1]/e}
1256  PAR1PAR1PAR1PAR1PAR1PAR1''BOLD''PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1            or die $@ ;#. qq{\$title =~ s/^.*$item->[0].*\$/$item->[1]/e};
1257  PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1          last;
1258          }
1259  PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2      }
1260  PAR2PAR2PAR2PAR2PAR2PAR2'''ITALIC'''PAR2PAR2PAR2PAR2PAR2PAR2PAR2      my $euri = main::escape ($uri);
1261  PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2      if ($title) {
1262  **HEADER1-2        $r .= qq(<li>[$list{$uri}] <a href="$euri" title="URI: &lt;$euri&gt;">@{[main::escape ($title)]}</a></li>\n);
1263  :TERM1:DESCRIPTION1 AND ''BOLD''      } else {
1264  PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1        $r .= qq(<li>[$list{$uri}] &lt;<a href="$euri">$euri</a>&gt;</li>\n);
1265  PAR1PAR1PAR1PAR1PAR1PAR1''BOLD''PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1      }
1266  PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1    }
1267  :TERM2:DESCRIPTION2    $r ? qq(<ul>$r</ul>\n) : '';
1268  :TERM3:DESCRIPTION3  }
1269  ----  
1270  *HEADER2  sub __decode ($) {
1271  **HEADER2-1    my $s = shift;
1272  http://www.hyuki.com/    $s =~ tr/+/ /;
1273  **HEADER2-2    $s =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/chr hex $1/ge;
1274      main::code_convert (\$s);
1275  [[YukiWiki2]]  }
1276    
1277  PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1  package wiki::useragent;
1278  PAR1PAR1PAR1PAR1PAR1PAR1'''''BOLD ITALIC'''''PAR1PAR1PAR1PAR1PAR1  our $UseLog;
1279  PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1  
1280  >PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2  sub add ($) {
1281  >PAR2PAR2PAR2PAR2PAR2PAR2'''ITALIC'''PAR2PAR2PAR2PAR2PAR2PAR2PAR2    my $s = shift;
1282  >PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2    return unless length $s;
1283      return unless $UseLog;
1284  LEVEL0LEVEL0LEVEL0LEVEL0LEVEL0LEVEL0LEVEL0    $s =~ s/([\x00-\x08\x0A-\x1F\x25\x7F-\xFF])/sprintf '%%%02X', unpack 'C', $1/ge;
1285      my %ua;
1286  >LEVEL1    for (split /\n/, &main::__get_database($main::PageName{UserAgentList})) {
1287  >LEVEL1      if (/^-\[(\d+)\] (.+)$/) {
1288  >LEVEL1        my ($t, $n) = ($1, $2);
1289  >>LEVEL2        $n =~ tr/\x0A\x0D//d;
1290  >>LEVEL2        $ua{$n} = $t;
1291  >>LEVEL2      }
1292  >>>LEVEL3    }
1293  -HELLO-1    $ua{$s}++;
1294  --HELLO-2    my $s = qq(#?SuikaWiki/0.9\n);
1295  (HELLO-2, HELLO-2, HELLO-2)    for (sort {$ua{$a} <=> $ua{$b}} keys %ua) {
1296  ---HELLO-3      $s .= sprintf qq(-[%d] %s\n), $ua{$_}, $_;
1297  (HELLO-3, HELLO-3, HELLO-3)    }
1298  --HELLO-2    $main::database->STORE ($main::PageName{UserAgentList} => $s, -touch => 0);
1299  ---HELLO-3  }
1300  --HELLO-2  
1301  ---HELLO-3  package wiki::suikawikiconst;
1302  >>>LEVEL3  
1303  >>>LEVEL3  sub to_hash ($;$) {
1304  >>>LEVEL3    my $page = shift;
1305  >>>LEVEL3    my $h = shift || {};
1306  EOD    my $val;
1307      print $txt;    for my $line (split /\n/, $page) {
1308      exit;      $line =~ tr/\x0A\x0D//d;
1309  }      if ($val && $line =~ s/^\s+//) {
1310          $h->{$val} .= length $h->{$val} ? "\n" . $line : $line;
1311  sub do_diff {      } elsif ($line =~ /^(.+):/) {
1312      if (not &is_editable($form{mypage})) {        $val = $1; $h->{$val} = '';
1313          &do_read;      }
1314          return;    }
1315      }    $h;
1316      &open_diff;  }
1317      my $title = $form{mypage};  
1318      &print_header($title);  package wiki::dummy;
1319      $_ = &escape($diffbase{$form{mypage}});  sub mtime (@) {undef}
1320      &close_diff;  sub meta (@) {undef}
1321      print qq(<h3>$resource{difftitle}</h3>);  sub Yuki::YukiWikiDB2::meta (@) {undef}
1322      print qq($resource{diffnotice});  
1323      print qq(<pre class="diff">);  package SuikaWiki::Plugin;
1324      foreach (split(/\n/, $_)) {    our $plugin_directory;  # defined in top of this file.
1325          if (/^\+(.*)/) {    our %List;
1326              print qq(<b class="added">$1</b>\n);    our %Index;
1327          } elsif (/^\-(.*)/) {  
1328              print qq(<s class="deleted">$1</s>\n);  sub escape ($$) { main::escape ($_[1]) }
1329          } elsif (/^\=(.*)/) {  sub unescape ($$) { main::unescape ($_[1]) }
1330              print qq(<span class="same">$1</span>\n);  sub encode ($$) { main::encode ($_[1]) }
1331          } else {  sub decode ($$) { main::decode ($_[1]) }
1332              print qq|??? $_\n|;  sub __get_datetime ($) { main::get_now () }
1333          }  sub resource ($$;%) { shift; &main::Resource (@_) }
1334      }  sub uri ($$) { $main::uri{$_[1]} }
1335      print qq(</pre>);  sub new_index ($$) { ++$Index{$_[1]} }
1336      print qq(<hr>);  
1337      &print_footer($title);  sub regist ($@) {
1338  }      my $pack = shift;
1339        for (@_) {
1340  sub do_rss {          push @{$List{$_}}, $pack;
1341      my $rss = new Yuki::RSS(      }
1342          version => '1.0',  }
1343          encoding => $charset,  
1344      );  sub import_plugins () {
1345      $rss->channel(      opendir PDIR, $plugin_directory;
1346          title => $modifier_rss_title,      my @plugin = grep {s/\.pm$//} readdir (PDIR);
1347          link  => $modifier_rss_link,      closedir PDIR;
1348          description => $modifier_rss_description,      for (@plugin) {
1349      );          eval qq{ use SuikaWiki::Plugin::$_ } unless /[^A-Za-z0-9_]/;
1350      my $recentchanges = $database{$RecentChanges};          push @{$List{_all}}, qq(SuikaWiki::Plugin::$_);
1351      my $count = 0;      }
1352      foreach (split(/\n/, $recentchanges)) {  }
1353          last if ($count >= 15);  
1354          /^\- \d\d\d\d\-\d\d\-\d\d \(...\) \d\d:\d\d:\d\d (\S+)/;    # date format.  &import_plugins ();
1355          my $title = &unarmor_name($1);  
1356          my $escaped_title = &escape($title);  package wiki::conneg;
1357          my $link = $modifier_rss_link . '?' . &encode($title);  
1358          my $description = $escaped_title . &escape(&get_subjectline($title));  ## BUG: this parser isn't strict.
1359          $rss->add_item(  sub get_accept_lang (;$) {
1360              title => $escaped_title,    my $alang = shift || $main::ENV{HTTP_ACCEPT_LANGUAGE};
1361              link  => $link,    my %alang = (ja => 0.0002, en => 0.0001);
1362              description => $description,    my $i = 0.1;
1363          );    for (split /\s*,\s*/, $alang) {
1364          $count++;      tr/\x09\x0A\x0D\x20//d;
1365      }      if (/((?:(?!;q=).)+)(?:;q="?([0-9.]+)"?)?/) {
1366      # print RSS information (as XML).        my $l = lc $1; $l =~ tr/\x22\x5C//d;
1367      print <<"EOD"        $alang{$l} = (defined $2 ? $2 : 1.000)*1000;
1368  Content-type: text/xml        $alang{$l} += $i unless $alang{$l} == 0;
1369          $i -= 0.001;
1370  @{[$rss->as_string]}      }
1371  EOD    }
1372  }    \%alang;
1373    }
1374  sub is_exist_page {  
1375      my ($name) = @_;  package wiki::resource;
1376      if ($use_exists) {  
1377          return exists($database{$name});  sub get ($;\%) {
1378      } else {    my ($resname, $option) = @_;
1379          return $database{$name};    $option->{accept_language} ||= &wiki::conneg::get_accept_lang ();
1380      }    $option->{resource} ||= {};
1381  }    my $v;
1382      for my $lang (sort {$option->{accept_language}->{$b} <=> $option->{accept_language}->{$a}} grep {$option->{accept_language}->{$_}!=0} keys %{$option->{accept_language}}) {
1383  1;      while (length $lang) {
1384  __END__        unless ($option->{accept_language}->{defined $option->{accept_language}->{$lang} ? $lang : '*'} == 0) {
1385  =head1 NAME          $option->{resource}->{$lang} ||= &wiki::suikawikiconst::to_hash (&main::__get_database('WikiResource:'.$lang));
1386            $v = $option->{resource}->{$lang}->{$resname};
1387  wiki.cgi - This is YukiWiki, yet another Wiki clone.          last if defined $v;
1388          }
1389  =head1 DESCRIPTION        $lang =~ s/[^+-]*$//; $lang =~ s/[+-]$//;
1390        }
1391  YukiWiki is yet another Wiki clone.      last if defined $v;
1392      }
1393  YukiWiki can treat Japanese WikiNames (enclosed with [[ and ]]).    defined $v ? $v : $resname;
1394  YukiWiki provides 'InterWiki' feature, RDF Site Summary (RSS),  }
1395  and some embedded commands (such as [[#comment]] to add comments).  
1396    package main;
1397  Read F<readme_en.txt> (English) or F<readme_ja.txt> (Japanese) in more detail.  &main;
1398    exit 0;
1399  =head1 AUTHOR  
1400    1;
1401  Hiroshi Yuki <hyuki@hyuki.com> http://www.hyuki.com/yukiwiki/  __END__
1402    =head1 NAME
1403  =head1 LICENSE  
1404    wiki.cgi --- SuikaWiki: Yet yet another Wiki engine
1405  Copyright (C) 2000-2002 by Hiroshi Yuki.  
1406    =head1 AUTHORS
1407  This program is free software; you can redistribute it and/or  
1408  modify it under the same terms as Perl itself.  Hiroshi Yuki <hyuki@hyuki.com> <http://www.hyuki.com/yukiwiki/>
1409    
1410  =cut  Makio Tsukamoto <http://digit.que.ne.jp/>
1411    
1412    Wakaba <w@suika.fam.cx>
1413    
1414    =head1 LICENSE
1415    
1416    Copyright (C) 2000-2003 AUTHORS
1417    
1418    This program is free software; you can redistribute it and/or
1419    modify it under the same terms as Perl itself.
1420    
1421    =cut

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.48

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24