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

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24