/[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.8 by wakaba, Sun Mar 24 00:51:52 2002 UTC revision 1.26 by wakaba, Sat Sep 28 10:54:27 2002 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl
2  use lib "../lib";  #!perl
3  use CGI::Carp 'fatalsToBrowser';  #
4  use Algorithm::Diff qw(traverse_sequences);  # wiki.cgi - This is YukiWiki, yet another Wiki clone.
5  # use strict;  #
6  #  # Copyright (C) 2000-2002 by Hiroshi Yuki.
7  # yukiwiki.cgi - Yet another WikiWikiWeb clone.  # <[email protected]>
8  #  # http://www.hyuki.com/yukiwiki/
9  # Copyright (C) 2000,2001 by Hiroshi Yuki.  #
10  # <[email protected]>  # This program is free software; you can redistribute it and/or
11  # http://www.hyuki.com/yukiwiki/  # modify it under the same terms as Perl itself.
12  #  #
13  # This program is free software; you can redistribute it and/or modify  ##############################
14  # it under the terms of the GNU General Public License as published by  #
15  # the Free Software Foundation; either version 2 of the License, or  # walwiki.cgi based on yukiwiki.cgi - Yet another WikiWikiWeb clone.
16  # (at your option) any later version.  #
17  #  # WalWiki�θ��С������ϡ�YukiWiki 2.0.beta1��١����ˤ��Ƥ��ޤ���
18  # This program is distributed in the hope that it will be useful,  #
19  # but WITHOUT ANY WARRANTY; without even the implied warranty of  # * ��������
20  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  #
21  # GNU General Public License for more details.  # 2.0.beta1.wal.1 on 2002/05/19,22:32:19
22  #  # (1) Footer���ѹ�
23  # $Id$  # (2) WikiName�γ�ĥ : PerlCE����ޡ�PPMInstall�ϴޤޤʤ�
24  ##############################  # (3) ��̾��󥯡�[��̾ URL]�ˤ��б���
25  my $version = "1.6.6";  # (4) ISBN�򥢥ޥ���.jp��Asociate�ץ�������󥯤��Ѵ���
26  ##############################  # (5) [[#box:InterWikiName]]��InterWiki�ʥƥ����ȥܥå�������
27  # ñ�ȥƥ��ȤΤȤ��ˤ� 1 �ˤ��롣  # (6) HTML�⡼���б���
28  my $testing = 0;  #
29  ##############################  # ��2.0.alpha0.wal.3�ǤޤǤν������⡢�ʲ����ѹ�������ޤ���
30  # �����饤�֥��  # ���ʲ���YukiWiki2�˼������줿���ᡢ�ȼ������ɤϤʤ��ʤ�ޤ�����
31  my $jcodelib = 'jcode.pl';  #   - ����饤��β����Ѵ�
32  ##############################  #   - YukiWikiDB�б�
33  # ��¸��ɽ���δ���������  #   - �ơ��֥�
34  my $kanjicode = 'euc';     # 'sjis' 'euc'  #   - DB��Ϣ�⥸�塼��use��eval��
35  my $charset = 'euc-jisx0213';  # 'Shift_JIS' 'EUC-JP'  #   - BracketName�ˤ�륭������֥饱�åȤ��ӽ�
36  ##############################  # ��ISBN�ֹ�ؤ��б���WalWiki2.0��ꡢInterWiki�ؤ�Add-On�ˤʤ�ޤ�����
37  # dbmopen���Ȥ���ʤ�1���Ȥ��ʤ��ʤ�0  #   [[ISBN http://www.amazon.co.jp/exec/obidos/ASIN/isbn($1)/walrdigi-22]]�Τ褦����Ͽ��
38  my $dbmopen = 0;  #
39  ##############################  #=======================================
40  # �ǡ����١���̾��.pag, .dir, .db�ʤɤ����ס�  
41  # $dbmopen = 1�ΤȤ��ϥǡ����١���̾��  # Walrus add (debug) start
42  # $dbmopen = 0�ΤȤ��ϥǥ��쥯�ȥ�̾�ˤʤ롣  my $walrus_log;
43  my $dbname = './wikidata';  my $walrus_debugging = 0;
44  my $diffdbname = './wikidiff';  # Walrus add (debug) end
45  ##############################  
46  # �����Ԥλ�̾�ʼ�ͳ���ѹ����Ƥ���������  # Libraries.
47  my $modifier = 'suika';  use strict;
48  ##############################  use lib qw(./WalWiki/lib);
49  # �����Ԥ�Web�ڡ����ʼ�ͳ���ѹ����Ƥ���������  use CGI qw(:standard);
50  my $modifierlink = 'http://suika.fam.cx/';  use CGI::Carp qw(fatalsToBrowser);
51  ##############################  use Yuki::RSS;
52  # ���Υڡ�����URL  use Yuki::DiffText qw(difftext);
53  my $thisurl = 'wiki';  use Yuki::YukiWikiDB;
54  ##############################  use AnyDBM_File;
55  # ���ϥڡ���̾  require 'jcode.pl';
56  my $toppage = 'HomePage';  # use Jcode;
57  ##############################  use Fcntl;
58  # �ǽ������ڡ���̾  my $version = '2.0.beta1.2002-05-29';
59  my $whatsnew = 'RecentChanges';  my $walversion;
60  ##############################  ##############################
61  # �ǽ������˷Ǻܤ���ڡ�����  #
62  my $maxnew = 50;  # You MUST modify following '$modifier_...' variables.
63  ##############################  #
64  # ��������ե�����̾�ʥ��顼�ǡ�  my $modifier_mail = '[email protected]';   # Your mail address, like '[email protected]'.
65  my $iconfile = '';  my $modifier_url  = 'http://suika.fam.cx/~wakaba/';     # Your web page, like 'http://digit.que.ne.jp/work/'.
66  ##############################  my $modifier_name = '��';       # Your name, like 'Makio Tsukamoto'.
67  # ��������ե�����̾�ʥ�Υ����ǡ�  # my $modifier_dbtype = 'AnyDBM_File';  # Fast, not available on some server, page size limited.
68  # my $iconfile = '';  # my $modifier_dbtype = 'dbmopen';      # Fast, not available on some server, page size limited.
69  ##############################  my $modifier_dbtype = 'YukiWikiDB';     # Slow, available on all environment.
70  # �ڡ������ѹ������Ȥ���touch����ե������''�ʤ鲿�⤷�ʤ���  # my $modifier_sendmail = '/usr/sbin/sendmail -t -n'; # Your sendmail.
71  my $touchfile = 'touch.txt';  my $modifier_sendmail = ''; # If you don't need mail notification.
72  ##############################  my $modifier_dir_data = './wikidata'; # Your data directory.
73  # �ץ�ӥ塼�Ѥ��طʿ�  my $modifier_rss_title = "WalWiki $walversion";
74  my $preview_color = '#FFCCCC';  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  my $style = <<'EOD';  #
78  pre, dl, ul, ol, p, blockquote { line-height:120%; }  # You MAY modify following variables.
79  a { text-decoration: none; }  #
80  a:link { color: #0000FF; background-color: #FFFFFF; }  my $file_touch = "$modifier_dir_data/touched.txt";
81  a:visited { color: #9900CC; background-color: #FFFFFF; }  my $file_resource = "$modifier_dir_data/resource.txt";
82  a:hover { text-decoration: underline; }  my $file_FrontPage = "$modifier_dir_data/frontpage.txt";
83  EOD  my $file_conflict = "$modifier_dir_data/conflict.txt";
84  ##############################  my $file_format = "$modifier_dir_data/format.txt";
85  # �ƥ�����������ʬ���礭��  my $url_cgi = 'wiki';
86  my $cols = 80;  my $url_stylesheet = $url_cgi.'?mycmd=TEXT_CSS;mypage=WikiHTMLStyle';
87  my $rows = 20;  my $icontag = '<img src="/icons/folder" alt="*" width="40" height="40" />';
88  ##############################  my $maxrecent = 50;
89  my %form = ();  my $cols = 80;
90  my %database = ();  my $rows = 20;
91  my %diffbase = ();  ##############################
92  my $diff_text = '';  #
93  my @diff_added = ();  # You MAY, but do NOT NEED modify following variables.
94  my @diff_deleted = ();  #
95  my $msgrefA;  my $dataname = "$modifier_dir_data/wiki";
96  my $msgrefB;  my $infoname = "$modifier_dir_data/info";
97  ##############################  my $diffname = "$modifier_dir_data/diff";
98  # �Խ��Բĥڡ���̾����  my $editchar = '?';
99  my @uneditable = ( $whatsnew );  my $subject_delimiter = ' - ';
100  ##############################  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  # YukiWiki�Υ�󥯤�2���ढ�롣  ##############################
103  #  my $InterWikiName = 'InterWikiName';
104  # (1) WikiName (RecentChanges�Ȥ�FrontPage�Τ褦�ʤ��)  my $RecentChanges = 'RecentChanges';
105  # (2) BracketName ([[����]]�Ȥ�[[�ȥ�֥륷�塼��]]�Τ褦�ʤ��)  my $AdminChangePassword = 'AdminChangePassword';
106  #  my $CompletedSuccessfully = 'CompletedSuccessfully';
107  # �����ե�JIS��2�Х����ܤˤ� ']' ���褦��Τǡ�  my $FrontPage = 'HomePage';
108  # ʸ��']'��1��¿���Ȥ�褦�ˤ��Ƥ��롣  my $IndexPage = 'IndexPage';
109  #  my $SearchPage = 'SearchPage';
110  my $WikiName = '([A-Z][a-z]+([A-Z][a-z]+)+)';  my $CreatePage = 'CreatePage';
111  my $BracketName = '\[\[([^>\x09]+?\]?)\]\]';  my $ErrorPage = 'ErrorPage';
112    my $RssPage = 'RssPage';
113  # ����������ʬ�Υ���  my $NAME_OF_WikiPageLicense = 'WikiPageLicense';
114  my $IconTag = ''; #<<"EOD";  my $AdminSpecialPage = 'Admin Special Page'; # must include spaces.
115  #<a href="http://www.hyuki.com/yukiwiki/"><img src="$iconfile"  ##############################
116  # border="0" width="80" height="80" alt="[YukiWiki]" /></a>  # my $wiki_name = '\b([A-Z][a-z]+([A-Z][a-z]+)+)\b';        # Walrus del (2)
117  #EOD  my $wiki_name   = '\b([A-Z][a-z]+([A-Z][a-z]*)+)\b';        # Walrus add (2)
118    my $bracket_name = '\[\[(\S+?)\]\]';
119  require "$jcodelib";  my $embedded_name = '\[\[(#\S+?)\]\]';
120    my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]';
121  &init_form($kanjicode);  my $interwiki_name = 'i:([^:]+):([^:].*)';
122    ##############################
123  if ($testing) {  my $embed_comment = '[[#comment]]';
124      %form = (  my $embed_rcomment = '[[#rcomment]]';
125          # 'mycmd' => 'write',  my $embed_comment_Name_Prompt = '̾��:';
126          'mycmd' => 'read',  my $DEFAULT_embed_comment_name = '̵̾������';
127          #'mycmd' => 'search',  my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$';    # Walrus add (5)
128          #'mycmd' => 'edit',  my %embed_command = (
129          'mymsg' => <<"EOD",          searched        => '^\[\[#searched:([^\]]+)\]\]$',
130  �Ϥ���ޤ��ơ�  );
131  ���줫�餤�������񤭹��ߤޤ��͡�  ##############################
132  LinkPage�⸫�Ƥ���������  my $info_LastModified = 'LastModified';
133  TestPage�Ϥɤ��Ǥ��礦����  my $info_IsFrozen = 'IsFrozen';
134  �ɤ������������  my $info_AdminPassword = 'AdminPassword';
135  http://www.hyuki.com/  ##############################
136  [[����]]  my $kanjicode = 'euc';
137  EOD  my $charset = 'EUC-JP';
138          'mypage' => '<����>',  my $lang = 'ja';
139          'myword' => '��',  my %fixedpage = (
140          # '3C8C8B8FE98D5F3E' => '',      $IndexPage => 1,
141          # 'TestPage' => '',      $CreatePage => 1,
142      );      $ErrorPage => 1,
143  }      $RssPage => 1,
144  &main;      $RecentChanges => 1,
145  exit(0);      $SearchPage => 1,
146        $AdminChangePassword => 1,
147  # �ᥤ��      $CompletedSuccessfully => 1,
148  sub main {      #$FrontPage => 1,
149      &normalize_form;  );
150      if ($dbmopen) {  my %form;
151          if (!dbmopen(%database, $dbname, 0666)) {  my %database;
152              &print_error("(dbmopen) $dbname �����ޤ���");  my %infobase;
153          }  my %diffbase;
154      } else {  my %resource;
155          if (!tie(%database, "YukiWikiDB", $dbname)) {  my %interwiki;
156              &print_error("(tie error)");  ##############################
157          }  my %page_command = (
158      }      $IndexPage => 'index',
159        $SearchPage => 'searchform',
160      # myspecial�б�      $CreatePage => 'create',
161      foreach (keys %form) {      $RssPage => 'rss',
162          if (/^myspecial_(.*)/) {      $AdminChangePassword => 'adminchangepasswordform',
163              $form{mycmd} = $1;      #$FrontPage => 'FrontPage',
164              last;  );
165          }  my %command_do = (
166      }      read => \&do_read,
167        TEXT_CSS => \&do_output_css,
168      if ($form{mycmd} eq 'read') {      edit => \&do_edit,
169          &do_read;      adminedit => \&do_adminedit,
170      } elsif ($form{mycmd} eq 'preview') {      adminchangepasswordform => \&do_adminchangepasswordform,
171          &do_preview;      adminchangepassword => \&do_adminchangepassword,
172      } elsif ($form{mycmd} eq 'write') {      write => \&do_write,
173          &do_write;      index => \&do_index,
174      } elsif ($form{mycmd} eq 'edit') {      searchform => \&do_searchform,
175          &do_edit;      search => \&do_search,
176      } elsif ($form{mycmd} eq 'reedit') {      create => \&do_create,
177          &do_reedit;      createresult => \&do_createresult,
178      } elsif ($form{mycmd} eq 'search') {      FrontPage => \&do_FrontPage,
179          &do_search;      comment => \&do_comment,
180      } elsif ($form{mycmd} eq 'list') {      rss => \&do_rss,
181          &do_list;      diff => \&do_diff,
182      } elsif ($form{mycmd} eq 'diff') {      interwikibox => \&do_interwiki_box, # Walrus add (5)
183          &do_diff;  );
184      } else {  ##############################
185          $form{mypage} = $toppage;  my @ignore_html_page = ('FrontPage');        # Walrus add (6)
186          &do_read;  my @ignore_html_tags = ('a', 'br', 'img');   # Walrus add (6)
187      }  my $walversion = '2.0.beta1.wal.1';          # Walrus add (1)
188      if ($dbmopen) {  ##############################
189          dbmclose(%database);  # &test_convert;
190      } else {  &main;
191          untie(%database);  exit(0);
192      }  ##############################
193  }  
194    sub main {
195  # �ڡ�����ɽ��      &init_resource;
196  sub do_read {      &open_db;
197      my $page_name = $form{mypage};      &init_form;
198      my $percent_name = &encode_percent($page_name);      &init_InterWikiName;
199      &print_header($page_name);      if ($command_do{$form{mycmd}}) {
200      print qq|<h1>$IconTag<a href="$thisurl?mycmd=search;myword=$percent_name">$page_name</a></h1>\n|;          &{$command_do{$form{mycmd}}};
201      &print_toolbar($page_name);      } else {
202      print &convert_html(&get_page($page_name));          &do_FrontPage;
203      &print_footer;      }
204  }      &close_db;
205    }
206  # �ڡ������Խ�  
207  sub do_edit {  sub do_read {
208      if (not &is_editable($form{mypage})) {    &print_header($form{mypage});
209          # �Խ��Բĥڡ�����ɽ���Τ�    my $content = $database{$form{mypage}};
210          &do_read;      my $cf = 'SuikaWiki/0.9';
211          return;      $cf = $1 if $content =~ s#^(?:/\*\s*|\#\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:\s[^\x0D\x0A]+)?)[\x0D\x0A]+##s;
212      }      if ($cf =~ m#^SuikaWiki/0.9(?:$|\s)#) {
213      &editpage(&get_page($form{mypage}));        &print_content($content, $cf);
214  }        print &text_to_html (q([[#comment]]));
215        } else {
216  # �ڡ����κ��Խ�        print "<pre>@{[&escape($content)]}</pre>";
217  sub do_reedit {      }
218      if (not &is_editable($form{mypage})) {    my ($r, $c) = get_search_result ($form{mypage});
219          # �Խ��Բĥڡ�����ɽ���Τ�      if ($c) {
220          &do_read;        print q{<h2 id="SEE-ALSO">See also</h2>};
221      } else {        print $r;
222          &editpage($form{mymsg});      }
223      }    &print_footer($form{mypage});
224  }  }
225    
226  sub editpage {  sub do_output_css {
227      my $page_msg = shift;    my $content = $database{$form{mypage}};
228      my $page_name = $form{mypage};    if ($content =~ m#^\s*/\*\s*W3C-CSS#) {
229      my $digest = &calc_message_digest($page_msg);      print "Content-Type: text/css; charset=$charset\n";
230      &print_header($page_name);      print "\n";
231      print qq|<h1>$IconTag${page_name}���Խ�</h1>\n|;      print $content;
232      &print_toolbar($page_name);    } else {
233      $page_msg = &escape($page_msg);      print "Status: 406 Unsupported Media Type\n";
234      print <<"EOD";      &print_header('WikiPageIsNotCSS');
235  <form action="$thisurl" method="post">      &print_content($database{WikiPageIsNotCSS});
236  <!--<input type="hidden" name="mycmd" value="preview">-->      &print_footer('WikiPageIsNotCSS');
237  <input type="hidden" name="mypage" value="$page_name">    }
238  <input type="hidden" name="mydigest" value="$digest">  }
239  <textarea cols="$cols" rows="$rows" name="mymsg" wrap="virtual">$page_msg</textarea><br>  
240  <input type="submit" name="myspecial_preview" value="��ǧ">  sub do_edit {
241  <input type="submit" name="myspecial_write" value="��ǧ�����ѹ�">      my ($page) = &unarmor_name(&armor_name($form{mypage}));
242  </form>      &print_header($page);
243  <hr>      if (not &is_editable($page)) {
244  <h3>�ƥ����������Υ롼��</h3>          &print_message($resource{cantchange});
245        } elsif (&is_frozen($page)) {
246  <p>�̾�����Ϥ���ʸ�������Τޤ޽��Ϥ���ޤ�����          &print_message($resource{cantchange});
247  �ʲ��Υ롼��˽��äƥƥ�����������Ԥ����Ȥ��Ǥ��ޤ���</p>      } else {
248            &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0);
249  <ul>      }
250  <li>      &print_footer($page);
251  ���Ԥ�����ζ��ڤ�Ȥʤ�ޤ���  }
252    
253  <li>  sub do_adminedit {
254  HTML�Υ����Ͻ񤱤ޤ���      my ($page) = &unarmor_name(&armor_name($form{mypage}));
255        &print_header($page);
256  <li>      if (not &is_editable($page)) {
257  ''��Ĵ''�Τ褦�˥��󥰥륯��������ĤǤϤ���ȡ���Ĵ�ˤʤ�ޤ���          &print_message($resource{cantchange});
258        } else {
259  <li>          &print_message($resource{passwordneeded});
260  '''���˶�Ĵ'''�Τ褦�˥��󥰥륯�����Ȼ��ĤǤϤ���ȡ����˶�Ĵ�ˤʤ�ޤ���          &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>1);
261        }
262  <li>      &print_footer($page);
263  ----�Τ褦�˥ޥ��ʥ�4�Ĥ�����ȡ���ʿ���ˤʤ�ޤ���  }
264    
265  <li>  sub do_adminchangepasswordform {
266  *���Ƭ�˽񤯤��縫�Ф��ˤʤ�ޤ���      &print_header($AdminChangePassword);
267        &print_passwordform;
268  <li>      &print_footer($AdminChangePassword);
269  **���Ƭ�˽񤯤Ⱦ����Ф��ˤʤ�ޤ���  }
270    
271  <li>  sub do_adminchangepassword {
272  -���Ƭ�˽񤯤Ȳվ�񤭤ˤʤ�ޤ���- -- --- ��3��٥뤬����ޤ���      if ($form{mynewpassword} ne $form{mynewpassword2}) {
273            &print_error($resource{passwordmismatcherror});
274  <li>      }
275  :���Ƭ�˽񤯤��Ѹ�Ȳ���ʸ�����ޤ���      my ($validpassword_crypt) = &get_info($AdminSpecialPage, $info_AdminPassword);
276        if ($validpassword_crypt) {
277  <pre>          if (not &valid_password($form{myoldpassword})) {
278      :�Ѹ�1:���������񤤤�����ʸ1              &send_mail_to_admin(<<"EOD", "AdminChangePassword");
279      :�Ѹ�2:���������񤤤�����ʸ2  myoldpassword=$form{myoldpassword}
280      :�Ѹ�3:���������񤤤�����ʸ3  mynewpassword=$form{mynewpassword}
281  </pre>  mynewpassword2=$form{mynewpassword2}
282    EOD
283  <li>              &print_error($resource{passworderror});
284  http://www.hyuki.com/ �Τ褦��URL�ϼ�ưŪ�˥�󥯤ˤʤ�ޤ���          }
285        }
286  <li>      my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time);
287  YukiWiki�Τ褦����ʸ����ʸ���򺮤�����ʸ�����񤯤ȡ�      my (@token) = ('0'..'9', 'A'..'Z', 'a'..'z');
288  YukiWiki�Υڡ���̾�ˤʤ�ޤ���      my $salt1 = $token[(time | $$) % scalar(@token)];
289        my $salt2 = $token[($sec + $min*60 + $hour*60*60) % scalar(@token)];
290  <li>      my $crypted = crypt($form{mynewpassword}, "$salt1$salt2");
291  [[����]]�Τ褦����Ť��礫�ä�[[ ]]�Ǥ����ä�ʸ�����񤯤ȡ�      &set_info($AdminSpecialPage, $info_AdminPassword, $crypted);
292  YukiWiki�Υڡ���̾�ˤʤ�ޤ���  
293  �礫�ä�����ˤϥ��ڡ�����ޤ�ƤϤ����ޤ���      &print_header($CompletedSuccessfully);
294  ���ܸ��Ȥ��ޤ���      &print_message($resource{passwordchanged});
295        &print_footer($CompletedSuccessfully);
296  <li>  }
297  ��Ƭ�����ڡ����ǻϤޤäƤ���ȡ�  
298  ��������������Ѥ߰����ޤ���  sub do_index {
299  �ץ�������񤭹���Ȥ��˻Ȥ��������Ǥ���      &print_header($IndexPage);
300        print qq(<ul>);
301  <li>      foreach my $page (sort keys %database) {
302  &gt; ���Ƭ�˽񤯤ȡ�          if (&is_editable($page)) {
303  ����ʸ���񤱤ޤ���              print qq(<li><a href="$url_cgi?@{[&encode($page)]}">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</li>);
304  &gt; �ο���¿���ȥ���ǥ�Ȥ������ʤ�ޤ���3��٥�ޤǡˡ�              # print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>);
305                # print qq(<li>@{[0 + &is_frozen($page)]}</li>);
306  </ul>          }
307  EOD      }
308      &print_footer;      print qq(</ul>);
309  }      &print_footer($IndexPage);
310    }
311  # �ڡ����θ���  
312  sub do_search {  sub do_write {
313      if ($form{myword}) {      if (&frozen_reject()) {
314          &print_header('�������');          return;
315          print qq|<h1>$IconTag$form{myword}�θ������</h1>\n|;      }
316          &print_toolbar();  
317          print qq|<ul>\n|;      if (not &is_editable($form{mypage})) {
318          my $count = 0;          &print_header($form{mypage});
319          foreach my $page_name (sort keys %database) {    # sort����Τ�̵�Ť���          &print_message($resource{cantchange});
320              if ($database{$page_name} =~ /\Q$form{'myword'}\E/) {          &print_footer($form{mypage});
321                  my $encoded = &encode_percent($page_name);          return;
322                  print qq|<li><a href="$thisurl?mycmd=read;mypage=$encoded">$page_name</a>\n|;      }
323                  $count++;  
324              }      if (&conflict($form{mypage}, $form{mymsg})) {
325          }          return;
326          print qq|</ul>\n|;      }
327          if ($count > 0) {  
328              print qq|<p><strong>$form{myword}</strong>��ޤ�ڡ����ϡ���˼���<strong>$count</strong> �ڡ����Ǥ���</p>\n|;      # Making diff
329          } else {      {
330              print qq|<p><strong>$form{myword}</strong>��ޤ�ڡ����ϸ��Ĥ���ޤ���</p>\n|;          &open_diff;
331          }          my @msg1 = split(/\n/, $database{$form{mypage}});
332      } else {          my @msg2 = split(/\n/, $form{mymsg});
333          &print_header('ñ�측��');          $diffbase{$form{mypage}} = &difftext(\@msg1, \@msg2);
334          print qq|<h1>$IconTagñ�측��</h1>\n|;          &close_diff;
335          &print_toolbar();      }
336      }  
337      print <<"EOD";      if ($form{mymsg}) {
338  <p>          $database{$form{mypage}} = $form{mymsg};
339  <form action="$thisurl" method="post">          &send_mail_to_admin($form{mypage}, "Modify");
340  <input type="hidden" name="mycmd" value="search">          if ($form{mytouch}) {
341  <input type="text" name="myword" size="20" value="$form{myword}">              &set_info($form{mypage}, $info_LastModified, '' . localtime);
342  <input type="submit" value="ñ�측��">              &update_recent_changes;
343  </form>          }
344  </p>          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});
345  EOD          &print_header($CompletedSuccessfully, -goto => $url_cgi.'?'.&encode($form{mypage}));
346      &print_footer;          &print_message($resource{saved});
347  }          &print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}");
348            &print_footer($CompletedSuccessfully);
349  # �ڡ����ΰ���      } else {
350  sub do_list {          &send_mail_to_admin($form{mypage}, "Delete");
351      &print_header('�ڡ�������');          delete $database{$form{mypage}};
352      print qq|<h1>$IconTag �ڡ�������</h1>\n|;          delete $infobase{$form{mypage}};
353      &print_toolbar();          if ($form{mytouch}) {
354      print qq|<ul>\n|;              &update_recent_changes;
355      foreach my $page_name (sort keys %database) {    # sort����Τ�̵�Ť���          }
356          my $encoded = &encode_percent($page_name);          &print_header($form{mypage});
357          print qq|<li><a href="$thisurl?mycmd=read;mypage=$encoded">$page_name</a>\n|          &print_message($resource{deleted});
358      }          &print_footer($form{mypage});
359      print qq|</ul>\n|;      }
360      &print_footer;  }
361  }  
362    sub do_searchform {
363  # �ץ�ӥ塼      &print_header($SearchPage);
364  sub do_preview {      &print_searchform("");
365      my $page_name = $form{mypage};      &print_footer($SearchPage);
366      my $escapedmsg = &escape($form{mymsg});  }
367      &print_header($page_name);  
368      print qq|<h1>$IconTag${page_name}�Υץ�ӥ塼</h1>\n|;  sub do_search {
369      &print_toolbar($page_name);      my $word = $form{mymsg};
370      # local $percent_name = &encode_percent($page_name);      &print_header($SearchPage);
371      print qq|<p>�ʲ��Υץ�ӥ塼���ǧ���ơ��褱��Хڡ��������Υܥ���ǹ������Ƥ���������</p>\n|;      &print_searchform(&escape($word));
372      if ($form{mymsg}) {      print scalar get_search_result ($word, -output_not_found => 1);
373          print qq|<table width="100%" bgcolor="$preview_color" ><tr><td>\n|;      &print_footer($SearchPage);
374          # print &convert_html($escapedmsg);  }
375          print &convert_html($form{mymsg});  
376          print qq|</td></tr></table>\n|;  sub get_search_result ($;%) {
377      } else {    my $word = shift;
378          print qq|<p>�ʥڡ��������Ƥ϶��Ǥ�����������Ȥ��Υڡ�����<strong>���</strong>����ޤ�����</p>\n|;    my %option = @_;
379      }    my $counter = 0;
380      &print_preview_buttons($page_name, $escapedmsg, $form{mydigest});    my $r = '';
381      &print_footer;    foreach my $page (sort keys %database) {
382  }      next if $page eq $RecentChanges;
383        if (   index ($database{$page}, $word) > 0
384  sub print_preview_buttons {          || index ($page, $word) > 0
385      my ($page_name, $escapedmsg, $digest) = @_;          || index ($word, $page) > 0
386      print <<"EOD";         ) {
387      <form action="$thisurl" method="post">        $r .= qq(<li><a href ="$url_cgi?@{[&encode($page)]}" class="wiki">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</li>);
388      <textarea cols="$cols" rows="$rows" name="mymsg" wrap="virtual">$escapedmsg</textarea>        $counter++;
389      <br />      }
390      <input type="hidden" name="mypage" value="$page_name">    }
391      <input type="hidden" name="mydigest" value="$digest">    $r = qq|<ul>$r</ul>| if $r;
392      <input type="submit" name="myspecial_preview" value="���٥ץ�ӥ塼">    get_message ($resource{notfound})
393      <input type="submit" name="myspecial_write" value="�ڡ����ι���">      if $counter == 0 && $option{-output_not_found};
394      </form>    wantarray? ($r, $counter): $r;
395  EOD  }
396  }  
397    sub do_create {
398  # �񤭹���      &print_header($CreatePage);
399  sub do_write {      print <<"EOD";
400      if (not &is_editable($form{mypage})) {  <form action="$url_cgi" method="post">
401          # �Խ��Բĥڡ�����ɽ���Τ�      <input type="hidden" name="mycmd" value="edit">
402          &do_read;      <strong>$resource{newpagename}</strong><br>
403          return;      <input type="text" name="mypage" value="" size="20">
404      }      <input type="submit" value="$resource{createbutton}"><br>
405    </form>
406      my $page_name = $form{mypage};  EOD
407        &print_footer($CreatePage);
408      # digest��Ȥäơ������ξ��ͥ����å�  }
409      my $original_digest = &calc_message_digest(&get_page($page_name));  
410      if ($form{mydigest} ne $original_digest) {  sub do_FrontPage {
411          &print_header($page_name);      open(FILE, $file_FrontPage) or &print_error("($file_FrontPage)");
412          print qq|<h1>$IconTag${page_name}�ǡڹ����ξ��ۤ͡������ޤ���</h1>\n|;      my $content = join('', <FILE>);
413          print <<"EOD";      &code_convert(\$content, $kanjicode);
414  <p>���ʤ������Υڡ������Խ����Ƥ���֤ˡ�      close(FILE);
415  ¾�οͤ�Ʊ���ڡ����򹹿����Ƥ��ޤä��褦�Ǥ���      &print_header($FrontPage);
416  </p><p>      &print_content($content);
417  �ʲ��ˡ����ʤ����Խ������ƥ����Ȥ�����ޤ��Τǡ�      &print_footer($FrontPage);
418  ���ʤ����Խ����Ƥ������ʤ��褦�ˡ�  }
419  ���ޤ��������Ģ�ʤɤ˥��ԡ����ڡ����Ȥ��Ƥ���������  
420  </p><p>  sub print_error {
421  ���ԡ����ڡ����Ȥ��Ѥ�Ǥ��顢      my ($msg) = @_;
422  �ǿ������Ƥ򸫤ƺ����Խ���ľ���Ƥ���������      &print_header($ErrorPage);
423  �ǿ������Ƥ�      print qq(<p><strong class="error">$msg</strong></p>);
424  <a target="_blank" href="$thisurl?mycmd=read;mypage=$form{mypage}">$form{mypage}</a>      &print_footer($ErrorPage);
425  �Ǹ��뤳�Ȥ��Ǥ��ޤ���      exit(0);
426  </p>  }
427  EOD  
428          # &print_toolbar($page_name);  sub print_header {
429          &print_preview_buttons($page_name, &escape($form{mymsg}), $form{mydigest});      my ($page,%option) = @_;
430          &print_footer;      my $bodyclass = "normal";
431          return;      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {
432      }          $bodyclass = "frozen";
433        }
434      # diff����      if ($option{-goto}) {
435      {        print qq{Refresh: 0; url="$option{-goto}"\n};
436          &opendiff;      }
437          my @msg1 = split(/\n/, &get_page($page_name));      my $cookedpage = &encode($page);
438          my @msg2 = split(/\n/, $form{mymsg});      my $escapedpage = &escape($page);
439          $msgrefA = \@msg1;      print <<"EOD";
440          $msgrefB = \@msg2;  Content-type: text/html; charset=$charset
441          &diff_check;  Content-Language: $lang
442          $diffbase{$form{mypage}} = $diff_text;  Content-Style-Type: text/css
443          $diff_text = '';  
444          &closediff;  <!DOCTYPE html
445      }      PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
446        "http://www.w3.org/TR/html4/loose.dtd">
447      &print_header($page_name);  <html lang="$lang">
448      &set_page($page_name, $form{mymsg});  <head>
449      if ($form{mymsg}) {      <title>$escapedpage @{[&escape(&get_subjectline($page))]}</title>
450          print qq|<h1>$IconTag${page_name}�򹹿����ޤ���</h1>\n|;      <link rel="index" href="$url_cgi?$IndexPage">
451          &print_toolbar($page_name);      <link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense">
452          print &convert_html(&get_page($page_name));      <link rev="made" href="mailto:@{[&escape($modifier_mail)]}">
453      } else {      <link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}">
454          print qq|<h1>$IconTag${page_name}�������ޤ���</h1>\n|;  </head>
455          &print_toolbar($page_name);  <body class="$bodyclass">
456          print qq|<p>${page_name}�������ޤ�����</p>\n|;  EOD
457      }    &print_navigate_links ($page);
458      &print_footer;    print <<EOD;
459      # �������줿�Τǥ��å����Ƥ�����  <h1 class="header"><a
460      if ($touchfile) {      title="$resource{searchthispage}"
461          open(FILE, "> $touchfile");      href="$url_cgi?mycmd=search;mymsg=$cookedpage">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</h1>
462          print FILE "\n";  EOD
463          close(FILE);  }
464      }  
465  }  sub print_navigate_links (@) {
466      my ($page) = @_;
467  # �ڡ������ѹ���      my $editable = 0;
468  sub do_diff {      my $admineditable = 0;
469      if (not &is_editable($form{mypage})) {      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {
470          # �Խ��Բĥڡ�����ɽ���Τ�          $editable = 0;
471          &do_read;          $admineditable = 1;
472          return;      } elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) {
473      }          $admineditable = 1;
474      &opendiff;          $editable = 1;
475      &print_header($form{mypage} . '���ѹ���');      } else {
476      print qq|<h1>$IconTag <a href="$thisurl?mycmd=read&mypage=$form{mypage}">$form{mypage}</a>���ѹ���</h1>\n|;          $editable = 0;
477      &print_toolbar();      }
478      $_ = &escape($diffbase{$form{mypage}});      my $cookedpage = &encode($page);
479      print <<"EOD";    print <<EOH;
480  <ul>  <div class="tools">
481  <li>�ɲä��줿�Ԥ�<ins>�Ŀ�</ins>�Ǥ���      @{[ $admineditable
482  <li>������줿�Ԥ�<del>�ֿ�</del>�Ǥ���          ? qq(<a title="$resource{admineditthispage}" href="$url_cgi?mycmd=adminedit;mypage=$cookedpage">$resource{admineditbutton}</a> | )
483  <li><a href="$thisurl?mycmd=read;mypage=$form{mypage}">$form{mypage}</a>�عԤ���          : qq()
484  </ul>      ]}
485  <hr />      @{[ $editable
486  EOD          ? qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">$resource{editbutton} <kbd>E</kbd></a> | )
487      print qq|<pre>\n|;          : qq()
488      foreach (split(/\n/, $_)) {      ]}
489          if (/^\+(.*)/) {      @{[ $admineditable
490              print qq|<ins>$1</ins>\n|;          ? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | )
491          } elsif (/^\-(.*)/) {          : qq()
492              print qq|<del>$1</del>\n|;      ]}
493          } elsif (/^\=(.*)/) {      <a href="$url_cgi?$CreatePage">$resource{createbutton}</a> |
494              print qq|$1\n|;      <a href="$url_cgi?$IndexPage">$resource{indexbutton}</a> |
495          } else {      <a href="$url_cgi?$RssPage">$resource{rssbutton}</a> |
496              print qq|??? $_\n|;      <a href="$url_cgi?$FrontPage">$FrontPage</a> |
497          }      <a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> |
498      }      <a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a>
499      print qq|</pre>\n|;  </div>
500      &print_footer;  EOH
501      &closediff;  }
502  }  
503    sub print_footer {
504  sub opendiff {      my ($page) = @_;
505      if ($dbmopen) {      $walrus_log = ($walrus_debugging) ? &text_to_html("----\n$walrus_log") : '';    # Walrus add (debug)
506          if (!dbmopen(%diffbase, $diffdbname, 0666)) {      # Walrus mod (1) start
507              &print_error("(dbmopen) $diffdbname �����ޤ���");    my $cvslog = '$Revision$ $Date$';
508          }    print_navigate_links ($page);
509      } else {    print <<"EOD";
510          if (!tie(%diffbase, "YukiWikiDB", $diffdbname)) {  <div class="footer">
511              &print_error("(tie error)");  <p>
512          }  <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 />
513      }  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 />
514  }  <a href="/gate/cvs/wakaba/wiki/" title="CVS Repository">
515    $cvslog
516  sub closediff {  </a>
517      if ($dbmopen) {  </p>
518          dbmclose(%diffbase);  <div class="navigation">
519      } else {  [<a href="/" title="���Υ����С��μ���">/</a>
520          untie(%diffbase);  <a href="/map" title="���Υ����С��ΰ���">�Ͽ�</a>
521      }  <a href="/search/" title="���Υ����С��θ���">����</a>]
522  }  </div>
523    </div>
524  # �ե����फ��ξ����Ϣ������ %form �������  $walrus_log
525  # &init_form('euc');  </body>
526  sub init_form {  </html>
527      my ($charcode) = @_;  EOD
528      my $query;  #       print <<"EOD";
529      if ($ENV{REQUEST_METHOD} =~ /^post$/i) {  #   <hr>
530          read(STDIN, $query, $ENV{CONTENT_LENGTH});  #   <address class="footer">
531      } else {  #       <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version
532          $query = $ENV{QUERY_STRING};  #       &copy; 2000-2002 by <a href="http://www.hyuki.com/">Hiroshi Yuki</a>.<br />
533      }  #       Modified by <a href="$modifier_url">$modifier_name</a>.
534      my @assocarray = split(/[&;]/, $query);  #   </address>
535      foreach my $assoc (@assocarray) {  #   <p class="footer">
536          my ($property, $value) = split(/=/, $assoc);  #       <a href="http://www.hyuki.com/yukiwiki/">$icontag</a>
537          $value =~ tr/+/ /;  #   </p>
538          $value =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("C", hex($1))/eg;  #   </body>
539          &jcode::convert(\$value, $charcode);  #   </html>
540          $form{$property} = $value;  #   EOD
541      }      # Walrus mod (1) end
542  }  }
543    
544  # ���顼�ڡ�������Ϥ���  sub escape {
545  sub print_error {      my $s = shift;
546      my ($msg) = @_;      $s =~ s|\r\n|\n|g;
547      &print_header('Error');      $s =~ s|&|&amp;|g;
548      print "<h1>$IconTag$msg</h1></body></html>";      $s =~ s|<|&lt;|g;
549      exit(0);      $s =~ s|>|&gt;|g;
550  }      $s =~ s|"|&quot;|g;
551        return $s;
552  sub escape {  }
553      my ($line) = shift;  
554      $line =~ s|<|&lt;|g;  sub unescape {
555      $line =~ s|>|&gt;|g;      my $s = shift;
556      $line =~ s|"|&quot;|g;      # $s =~ s|\n|\r\n|g;
557      # $line =~ s|\&|&amp;|g;      $s =~ s|&lt;|<|g;
558      return $line;      $s =~ s|&gt;|>|g;
559  }      $s =~ s|&quot;|"|g;
560        $s =~ s|&amp;|&|g;
561  sub inline {      return $s;
562      my ($line) = shift;  }
563      $line = &escape($line);  
564      $line =~ s|'''([^']+?)'''|<strong>$1</strong>|g;  sub print_content ($;$) {
565      $line =~ s|''([^']+?)''|<em>$1</em>|g;                my ($rawcontent, $format) = @_;
566      $line =~ s!      print &text_to_html($rawcontent, toc=>1);
567         (  }
568           (?:&lt;(?:mailto|http|https|ftp|urn):[\x21-\x7E]*)&gt;  
569         #| (?:$WikiName)                         # LocalLinkLikeThis  sub text_to_html {
570         | (?:$BracketName)                      # [[���ܸ���]]      my ($txt, %option) = @_;
571         )      my (@txt) = split(/\n/, $txt);
572              !      my (@toc);
573                  &make_link($1)      my $tocnum = 0;
574              !gex;      my (@saved, @result);
575      return $line;      unshift(@saved, "</p>");
576  }      push(@result, "<p>");
577        foreach (@txt) {
578  # �ڡ����Υ����ȥ뤫��ڡ��������Ƥ�����          chomp;
579  sub get_page {          if (/^\*\*\*\*\*([^\x0D\x0A]*)/) {
580      my $page_name = shift;              push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
581      return $database{$page_name};              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');
582  }              $tocnum++;
583            } elsif (/^\*\*\*\*([^\x0D\x0A]*)/) {
584  # �ڡ��������Ƥ�Ϳ����              push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
585  # &set_page($title, $txt)              push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>');
586  sub set_page {              $tocnum++;
587      # �ڡ����򹹿�����          } elsif (/^\*\*\*([^\x0D\x0A]*)/) {
588      my $title = $_[0];              push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
589      $database{$title} = $_[1];              push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>');
590      # ���ڡ����ʤ�������              $tocnum++;
591      unless ($database{$title}) {          } elsif (/^\*\*([^\x0D\x0A]*)/) {
592          delete $database{$title};          # if (/^\*\*(.*)/) {
593      }          # Walrus mod (6) end
594      # RecentChanges�򹹿�����              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
595      my $delim = ' - ';              push(@result, splice(@saved), qq(<h3><a name="i$tocnum"> </a>) . &inline($1) . '</h3>');
596      my @pages = split(/\n/, $database{$whatsnew});              $tocnum++;
597      my $datestr = &get_current_datestr;          } elsif (/^\*([^\x0D\x0A]*)/) {
598      unshift(@pages, qq|-$datestr$delim$title|);              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
599      # Ʊ��ڡ����ι����Ϻǿ��Τ�ΤΤߤˤ���              push(@result, splice(@saved), qq(<h2><a name="i$tocnum"> </a>) . &inline($1) . '</h2>');
600      # ¸�ߤ��ʤ��ڡ����ϥ����åפ��롣              $tocnum++;
601      my %count;          } elsif (/^(={1,6})(.*)/) {
602      my @newpages;              &back_push('ol', length($1), \@saved, \@result);
603      foreach my $line (@pages) {              push(@result, '<li>' . &inline($2) . '</li>');
604          my ($prefix, $title) = split(/$delim/, $line);          } elsif (/^(-{1,6})(.*)/) {
605          $count{$title}++;              &back_push('ul', length($1), \@saved, \@result);
606          if ($count{$title} == 1 and exists($database{$title})) {              push(@result, '<li>' . &inline($2) . '</li>');
607              push(@newpages, qq|$prefix - $title|);          } elsif (/^:([^:]+):(.*)/) {
608          }              &back_push('dl', 1, \@saved, \@result);
609      }              push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>');
610      # �����������˹���          } elsif (/^(>{1,5})(.*)/) {
611      $database{$whatsnew} = join("\n", splice(@newpages, 0, $maxnew));              &back_push('blockquote', length($1), \@saved, \@result);
612  }              push(@result, &inline($2));
613            } elsif (/^\s*$/) {
614  # �ڡ����Υإå������              push(@result, splice(@saved));
615  sub print_header {              unshift(@saved, "</p>");
616      my $title = shift;              push(@result, "<p>");
617      print <<"EOD";          } elsif (/^(\s+.*)$/) {
618  Content-type: text/html              &back_push('pre', 1, \@saved, \@result);
619                #push(@result, &escape($1)); # Not &inline, but &escape
620  <html><head>              push(@result, &inline($1));
621  <title>$title</title>  #       } elsif (/^\,(.*)$/) {             # Walrus del (BF)
622  <style type="text/css">          } elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF)
623  $style              &back_push('table', 1, \@saved, \@result, ' border="1"');
624  </style>              #######
625  </head>              # This part is taken from Mr. Ohzaki's Perl Memo and Makio Tsukamoto's WalWiki.
626  <body>              # XXXXX
627  EOD              my $tmp = "$1,";
628  }              my @value = map {/^"(.*)"$/ ? scalar($_ = $1, s/""/"/g, $_) : $_} ($tmp =~ /("[^"]*(?:""[^"]*)*"|[^,]*),/g);
629                my @align = map {(s/^\s+//) ? ((s/\s+$//) ? ' align="center"' : ' align="right"') : ''} @value;
630  # �ġ���С������              my @colspan = map {($_ eq '==') ? 0 : 1} @value;
631  sub print_toolbar {              for (my $i = 0; $i < @value; $i++) {
632      my $page_name = shift;                  if ($colspan[$i]) {
633      my $percent_name = &encode_percent($page_name);                      while ($i + $colspan[$i] < @value and $value[$i + $colspan[$i]] eq '==') {
634      my $editlink = '';                          $colspan[$i]++;
635      if ($page_name ne '' and &is_editable($page_name)) {                      }
636          $editlink = <<"EOD";                      $colspan[$i] = ($colspan[$i] > 1) ? sprintf(' colspan="%d"', $colspan[$i]) : '';
637  <a href="$thisurl?mycmd=edit;mypage=$percent_name">�Խ�</a> |                      $value[$i] = sprintf('<td%s%s>%s</td>', $align[$i], $colspan[$i], &inline($value[$i]));
638  <a href="$thisurl?mycmd=diff;mypage=$percent_name">��ʬ</a> |                  } else {
639  EOD                      $value[$i] = '';
640      }                  }
641      print <<"EOD";              }
642  <p>              push(@result, join('', '<tr>', @value, '</tr>'));
643   [              # XXXXX
644  <a href="$thisurl?mycmd=read;mypage=$toppage">�ȥå�</a> |              #######
645  <a href="$thisurl?mycmd=list">����</a> |          } elsif (/^\[INS\[/) {
646  $editlink              push(@result, "<ins>");
647  <a href="$thisurl?mycmd=search">ñ�측��</a> |          } elsif (/^\]INS\]/) {
648  <a href="$thisurl?mycmd=read;mypage=$whatsnew">�ǽ�����</a>              push(@result, "</ins>");
649   ]          } elsif (/^\[DEL\[/) {
650  </p>              push(@result, "<del>");
651  EOD          } elsif (/^\]DEL\]/) {
652  }              push(@result, "</del>");
653            } elsif (/^\[PRE\[/) {
654  # �ڡ����Υեå������              push(@result, "<pre>");
655  sub print_footer {          } elsif (/^\]PRE\]/) {
656      print <<"EOD";              push(@result, "</pre>");
657  <address>          } else {
658  <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> 1.6.6 Copyright (C) 2000,2001 by <a href="http://www.hyuki.com/">Hiroshi Yuki.</a>              push(@result, &inline($_));
659  + <a href="$modifierlink">$modifier</a> ${version}.          }
660  [<a href="/" title="���Υ����С��μ���">/</a>      }
661  <a href="/map" title="���Υ����С��ΰ���">�Ͽ�</a>      push(@result, splice(@saved));
662  <a href="/search/" title="���Υ����С��θ���">����</a>]  
663  </address>      if ($option{toc}) {
664  </body></html>          # Convert @toc (table of contents) to HTML.
665  EOD          # This part is taken from Makio Tsukamoto's WalWiki.
666  }          my (@tocsaved, @tocresult);
667            foreach (@toc) {
668  # URL��ڡ�����̾�������󥯤���              if (/^(-{1,6})(.*)$/) {
669  sub make_link {                  &back_push('ul', length($1), \@tocsaved, \@tocresult);
670      my $name = shift;                  push(@tocresult, '<li>' . $2 . '</li>');
671      $name =~ s/^&lt;(.*)&gt;$/$1/;              }
672      $name =~ s/^\[\[(.*)\]\]$/$1/;          }
673      if ($name =~ /^(http|https|ftp).*?(\.png|\.jpeg|\.jpg)?$/) {          push(@tocresult, splice(@tocsaved));
674          if ($2) {          return join("\n", @tocresult, @result);
675              return qq|<a href="$name"><img border="0" src="$name" /></a>|;      } else {
676          } else {          return join("\n", @result);
677              return qq|&lt;<a href="$name">$name</a>&gt;|;      }
678          }  }
679      } elsif ($name =~ /^mailto:(.*)/) {  
680          my $address = $1;  sub back_push {
681          return qq|&lt;<a href="$name">$address</a>&gt;|;      my ($tag, $level, $savedref, $resultref, $attr) = @_;
682      } elsif ($name =~ /^urn:[0-9A-Za-z_:-]+/) {      while (@$savedref > $level) {
683          return qq|&lt;<a href="/uri-res/N2L?${name}">$name</a>&gt;|;          push(@$resultref, shift(@$savedref));
684      } else {      }
685        my $name2 = $name; $name2 =~ tr/\x20/-/;      if ($savedref->[0] ne "</$tag>") {
686        if ($database{$name2}) {          push(@$resultref, splice(@$savedref));
687          my $percent_name = &encode_percent($name2);      }
688          return qq|<a href="$thisurl?mycmd=read;mypage=$percent_name" class="wiki">$name</a>|;      while (@$savedref < $level) {
689        } elsif ($database{'[['.$name2.']]'}) {          unshift(@$savedref, "</$tag>");
690          my $percent_name = &encode_percent('[['.$name2.']]');          push(@$resultref, "<$tag$attr>");
691          return qq|<a href="$thisurl?mycmd=read;mypage=$percent_name" class="wiki">$name</a>|;      }
692        } else {  }
693          my $percent_name = &encode_percent($name2);  
694          return qq|<a href="$thisurl?mycmd=edit;mypage=$percent_name" class="wiki newpage">$name?</a>|;  sub inline {
695        }      my ($line) = @_;
696      }      $line = &escape($line);
697  }      $line =~ s|'''([^']+?)'''|<strong>$1</strong>|g;
698        $line =~ s|''([^']+?)''|<em>$1</em>|g;
699  # %xx �η����˥��󥳡��ɤ���      $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
700  # ����ϡ�      $line =~ s!
701  # http://www.hyuki.com/yukiwiki/yukiwiki.cgi?mycmd=read&mypage=%3C%8C%8B%8F%E9%8D_%3E        (
702  # �Ȥ��������Τ���˻Ȥ��롣          (?:&lt;(?:mailto|http|https|ftp|urn|news):[\x21-\x7E]*)&gt;
703  # '<����>' �� '%3C%8C%8B%8F%E9%8D_%3E'        |
704  sub encode_percent {          ($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]]
705      my $name = shift;        |
706      my $encoded = '';          ($interwiki_definition) # [[Friend http://somewhere/?q=sjis($1)]]
707      foreach my $ch (split(//, $name)) {        #|
708          if ($ch =~ /[A-Za-z0-9_]/) {        #  ($wiki_name)
709              $encoded .= $ch;        )
710          } else {              !
711              $encoded .= '%' . sprintf("%02X", ord($ch));                  &make_link($1)
712          }              !gex;
713      }      return $line;
714      return $encoded;  }
715  }  
716    sub make_link {
717  # �ƥ��������Τ�HTML���Ѵ�����      my $chunk = shift;
718  sub convert_html {      # Walrus add (3) start
719      my ($txt) = shift;      $chunk =~ s/^&lt;(.*)&gt;$/$1/;
720      my (@txt) = split(/\n/, $txt);      my $name  = $chunk;
721      foreach (@txt) {      if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) {
722          chomp;          ($name, $chunk) = ($1, $2);
723          if (/^\*\*(.*)/) {      } elsif ($chunk =~ /^mailto:(.*)$/) {
724              push(@result, splice(@saved), '<h3>' . &inline($1) . '</h3>');          $name = $1;
725          } elsif (/^\*(.*)/) {      }
726              push(@result, splice(@saved), '<h2>' . &inline($1) . '</h2>');      if ($use_autoimg and $name =~ /^(http|https|ftp):.+\.(png|gif|jpe?g)/) {
727          } elsif (/^----/) {          $name = qq(<img src="$name">) ;
728              push(@result, splice(@saved), '<hr>');      }
729          } elsif (/^(-{1,3})(.*)/) {      $name = &unarmor_name($name);
730              &back_push('ul', length($1));      # Walrus add (3) end
731              push(@result, '<li>' . &inline($2) . '</li>');      if ($chunk =~ /^(http|https|ftp|news):/) {
732          } elsif (/^:([^:]+):(.*)/) {          # Walrus mod (3) start
733              &back_push('dl', 1);  #       if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) {
734              push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>');  #           return qq(<a href="$chunk"><img src="$chunk"></a>);
735          } elsif (/^(>{1,3})(.*)/) {  #       } else {
736              &back_push('blockquote', length($1));  #           return qq(<a href="$chunk">$chunk</a>);
737              push(@result, &inline($2));  #       }
738          } elsif (/^\s*$/) {          return qq(&lt;<a href="$chunk">$name</a>&gt;);
739              push(@result, splice(@saved));          # Walrus mod (3) end
740              unshift(@saved, "</p>");      } elsif ($chunk =~ m#^urn:[0-9A-Za-z_:;/.-]+#) {
741              push(@result, "<p>");          return qq|&lt;<a href="/uri-res/N2L?${name}">$name</a>&gt;|;
742          } elsif (/^(\s+.*)$/) {      } elsif ($chunk =~ /^mailto:(.*)/) {
743              &back_push('pre', 1);  #       return qq(<a href="$chunk">$2</a>);                 # Walrus del (3)
744              push(@result, &escape($1)); # Not &inline, but &escape          return qq(&lt;<a href="$chunk">$name</a>&gt;);              # Walrus add (3)
745          } else {      } elsif ($chunk =~ /^$interwiki_definition$/) {
746              push(@result, &inline($_));  #       return qq(<span class="InterWiki">$chunk</span>);   # Walrus del (3)
747          }          return qq(<span class="InterWiki">$name</span>);    # Walrus add (3)
748      }      } elsif ($chunk =~ /^$embedded_name$/) {
749      push(@result, splice(@saved));          return &embedded_to_html($chunk);
750      return join("\n", @result);      } else {
751  }          $chunk = &unarmor_name($chunk);
752            $chunk = &unescape($chunk); # To treat '&' or '>' or '<' correctly.
753  # &back_push($tag, $count)          my $cookedchunk = &encode($chunk);
754  # $tag�Υ�����$level��٥�ޤǵͤ�롣          if ($chunk =~ /^$interwiki_name$/) {
755  sub back_push {              my ($intername, $localname) = ($1, $2);
756      my ($tag, $level) = @_;              my $remoteurl = $interwiki{$intername};
757      while (@saved > $level) {              if ($remoteurl) {
758          push(@result, shift(@saved));  #               $remoteurl =~ s/\b(euc|sjis|ykwk|asis)\(\$1\)/&interwiki_convert($1, $localname)/e;      # Walrus del (4)
759      }                  $remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $localname)/e; # Walrus add (4)
760      if ($saved[0] ne "</$tag>") {  #               return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3)
761          push(@result, splice(@saved));                  return qq(<a href="$remoteurl">@{[&escape($name)]}</a>);  # Walrus add (3)
762      }              } else {
763      while (@saved < $level) {  #               return $chunk;                              # Walrus del (3)
764          unshift(@saved, "</$tag>");                  return &escape($name);                               # Walrus add (3)
765          push(@result, "<$tag>");              }
766      }          } elsif ($database{$chunk}) {
767  }              my $subject = &escape(&get_subjectline($chunk, delimiter => ''));
768    #           return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$chunk</a>);  # Walrus del (3)
769  # �Խ���ǽ�ڡ�������              return qq(<a title="$subject" href="$url_cgi?$cookedchunk" class="wiki">@{[&escape($name)]}</a>);   # Walrus add (3)
770  sub is_editable {          } elsif ($page_command{$chunk}) {
771      my ($pagename) = @_;  #           return qq(<a title="$chunk" href="$url_cgi?$cookedchunk">$chunk</a>);    # Walrus del (3)
772      foreach (@uneditable) {              return qq(<a title="$chunk" href="$url_cgi?$cookedchunk" class="wiki">@{[&escape($name)]}</a>);     # Walrus add (3)
773          if ($pagename eq $_) {          } else {
774              return 0;              return qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedchunk" class="wiki">@{[&escape($name)]}<span class="mark">$editchar</span></a>);
775          }          }
776      }      }
777      if (&is_valid_name($pagename)) {  }
778          return 1;  
779      }  sub print_message {
780      return 0;      my ($msg) = @_;
781  }      print qq(<p><strong>$msg</strong></p>);
782    }
783  # Valid��̾������  
784  sub is_valid_name {  sub get_message {
785      my ($pagename) = @_;      my ($msg) = @_;
786      if ($pagename =~ /^$WikiName$/) {      qq(<p><strong>$msg</strong></p>);
787          return 1;  }
788      } elsif ($pagename =~ /^$BracketName$/) {  
789          return 1;  sub init_form {
790      } else {      if (param()) {
791          return 0;          foreach my $var (param()) {
792      }              $form{$var} = param($var);
793  }          }
794        } else {
795  # ���߻����ʸ���������          $ENV{QUERY_STRING} = $FrontPage;
796  sub get_current_datestr {      }
797      my (@wdays) = ( "��", "��", "��", "��", "��", "��", "��" );  
798      my ($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime(time);      my $query = &decode($ENV{QUERY_STRING});
799      return sprintf("%4d-%02d-%02d (%s) %02d:%02d:%02d",      if ($page_command{$query}) {
800          $year + 1900, $mon + 1, $mday, $wdays[$wday], $hour, $min, $sec);          $form{mycmd} = $page_command{$query};
801  }          $form{mypage} = $query;
802        } elsif ($query =~ /^($wiki_name)$/) {
803  # URL?SomePage�䡢          $form{mycmd} = 'read';
804  # URL?[[����]]�η������ä���硢(not yet)          $form{mypage} = $1;
805  # ����Ū��mycmd��read�ˤ���$form�����Ƥ����ꤹ�롣      } elsif ($database{$query}) {
806  sub normalize_form {          $form{mycmd} = 'read';
807      foreach my $key (keys %form) {          $form{mypage} = $query;
808          if ($key =~ /^$WikiName$/) {      }
809              $form{mycmd} = 'read';  
810              $form{mypage} = $1;      # mypreview_edit        -> do_edit, with preview.
811              last;      # mypreview_adminedit   -> do_adminedit, with preview.
812          } elsif ($key =~ /^$BracketName$/) {      # mypreview_write       -> do_write, without preview.
813              $form{mycmd} = 'read';      foreach (keys %form) {
814              $form{mypage} = $1;          if (/^mypreview_(.*)$/) {
815              last;              $form{mycmd} = $1;
816          }              $form{mypreview} = 1;
817      }          }
818  }      }
819    
820  # �Ѵ��ƥ��Ȥ�Ԥʤ��Ȥ��Υ���ץ�      #
821  sub print_sample {      # $form{mycmd} is frozen here.
822      my $txt = &convert_html(<<"EOD");      #
823  *�縫�Ф�1  
824  **�����Ф�1-1      $form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode);
825  -����1      $form{myname} = &code_convert(\$form{myname}, $kanjicode);
826  -����2  }
827  -����3  
828  ����1����1����1����1����1����1����1����1����1����1����1����1  sub update_recent_changes {
829  ����1����1����1����1����1����''��Ĵ''1����1����1����1����1����1      my $update = "- @{[&get_now]} @{[&armor_name($form{mypage})]} @{[&get_subjectline($form{mypage})]}";
830  ����1����1����1����1����1����1����1����1����1����1����1����1      my @oldupdates = split(/\r?\n/, $database{$RecentChanges});
831        my @updates;
832  ����2����2����2����2����2����2����2����2����2����2����2����2      foreach (@oldupdates) {
833  ����2����2����2����2����2����2����2����2����2����2����2����2          /^\- \d\d\d\d\-\d\d\-\d\d \(...\) \d\d:\d\d:\d\d (\S+)/;    # date format.
834  ����2����2����2����2����2����2����2����2����2����2����2����2          my $name = &unarmor_name($1);
835  **�����Ф�1-2          if (&is_exist_page($name) and ($name ne $form{mypage})) {
836  :�Ѹ�1:���������񤤤�����ʸ1��''��Ĵñ��''              push(@updates, $_);
837  ����1����1����1����1����1����1����1����1����1����1����1����1          }
838  ����1����1����1����1����1����1����1����1����1����1����1����1      }
839  ����1����1����1����1����1����1����1����1����1����1����1����1      if (&is_exist_page($form{mypage})) {
840  :�Ѹ�2:���������񤤤�����ʸ2          unshift(@updates, $update);
841  :�Ѹ�3:���������񤤤�����ʸ3      }
842  ----      splice(@updates, $maxrecent + 1);
843  *�縫�Ф�2      $database{$RecentChanges} = join("\n", @updates);
844  **�����Ф�2-1      if ($file_touch) {
845  &lt;http://suika.fam.cx/&gt;          open(FILE, "> $file_touch");
846  **�����Ф�2-2          print FILE localtime() . "\n";
847            close(FILE);
848  [[����]]      }
849    }
850  ����1����1����1����1����1����1����1����1����1����1����1����1  
851  ����1����1����1����'''��Ĵ'''1����1����1����1����1����1����1����1  sub get_subjectline {
852  ����1����1����1����'''''������Ĵ'''''1����1����1����1����1����1����1����1����1      my ($page, %option) = @_;
853  >����2����2����2����2����2����2����2����2����2����2����2����2      if (not &is_editable($page)) {
854  >����2����2����2����2����2����2����2����2����2����2����2����2          return "";
855  >����2����2����2����2����2����2����2����2����2����2����2����2      } else {
856            # Delimiter check.
857  ��٥�0��٥�0��٥�0��٥�0��٥�0��٥�0          my $delim = $subject_delimiter;
858            if (defined($option{delimiter})) {
859  >��٥�1              $delim = $option{delimiter};
860  >��٥�1          }
861  >��٥�1  
862  >>��٥�2          # Get the subject of the page.
863  >>��٥�2          my $subject = $database{$page};
864  >>��٥�2          $subject =~ s#^SuikaWiki/0.9[^\x0D\x0A]*[\x0D\x0A]+##s;
865  >>>��٥�3          $subject =~ s/\r?\n.*//s;
866  -�Ϥ�1          return "$delim$subject";
867  --�Ϥ�2      }
868  ��������2  }
869  ---�Ϥ�3  
870  --�Ϥ�2  sub send_mail_to_admin {
871  ---�Ϥ�3      my ($page, $mode) = @_;
872  --�Ϥ�2      return unless $modifier_sendmail;
873  ---�Ϥ�3      my $message = <<"EOD";
874  >>>��٥�3  To: $modifier_mail
875  >>>��٥�3  From: $modifier_mail
876  >>>��٥�3  Subject: [Wiki]
877  EOD  MIME-Version: 1.0
878      print $txt;  Content-Type: text/plain; charset=ISO-2022-JP
879      exit;  Content-Transfer-Encoding: 7bit
880  }  
881    --------
882  sub diff_check {  MODE = $mode
883      traverse_sequences(  REMOTE_ADDR = $ENV{REMOTE_ADDR}
884              $msgrefA, $msgrefB,  REMOTE_HOST = $ENV{REMOTE_HOST}
885              {  --------
886                  MATCH => \&df_match,  $page
887                  DISCARD_A => \&df_delete,  --------
888                  DISCARD_B => \&df_add,  $database{$page}
889              }  --------
890      );  EOD
891      &diff_flush;      &code_convert(\$message, 'jis');
892  }      open(MAIL, "| $modifier_sendmail");
893        print MAIL $message;
894  sub diff_flush {      close(MAIL);
895      $diff_text .= join('', map { "-$_\n" } splice(@diff_deleted));  }
896      $diff_text .= join('', map { "+$_\n" } splice(@diff_added));  
897  }  sub open_db {
898        if ($modifier_dbtype eq 'dbmopen') {
899  sub df_match {          dbmopen(%database, $dataname, 0666) or &print_error("(dbmopen) $dataname");
900      my ($a, $b) = @_;          dbmopen(%infobase, $infoname, 0666) or &print_error("(dbmopen) $infoname");
901      &diff_flush;      } elsif ($modifier_dbtype eq 'AnyDBM_File') {
902      $diff_text .= "=$msgrefA->[$a]\n";          tie(%database, "AnyDBM_File", $dataname, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $dataname");
903  }          tie(%infobase, "AnyDBM_File", $infoname, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $infoname");
904        } else {
905  sub df_delete {          tie(%database, "Yuki::YukiWikiDB", $dataname) or &print_error("(tie Yuki::YukiWikiDB) $dataname");
906      my ($a, $b) = @_;          tie(%infobase, "Yuki::YukiWikiDB", $infoname) or &print_error("(tie Yuki::YukiWikiDB) $infoname");
907      push(@diff_deleted, $msgrefA->[$a]);      }
908  }  }
909    
910  sub df_add {  sub close_db {
911      my ($a, $b) = @_;      if ($modifier_dbtype eq 'dbmopen') {
912      push(@diff_added, $msgrefB->[$b]);          dbmclose(%database);
913  }          dbmclose(%infobase);
914        } elsif ($modifier_dbtype eq 'AnyDBM_File') {
915  sub calc_message_digest {   # You have to use MD5...          untie(%database);
916      my $text = shift;          untie(%infobase);
917      my @text = split(//, $text);      } else {
918      my $len = length($text);          untie(%database);
919      my $checksum = 0;          untie(%infobase);
920      foreach (@text) {      }
921          $checksum += ord($_);  }
922          $checksum = ($checksum * 2) % 65536 + (($checksum & 32768) ? 1 : 0); # 16bit rotate  
923      }  sub open_diff {
924      return "$len:$checksum";      if ($modifier_dbtype eq 'dbmopen') {
925  }          dbmopen(%diffbase, $diffname, 0666) or &print_error("(dbmopen) $diffname");
926        } elsif ($modifier_dbtype eq 'AnyDBM_File') {
927  # Definition of YukiWikiDB          tie(%diffbase, "AnyDBM_File", $diffname, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $diffname");
928  package YukiWikiDB;      } else {
929            tie(%diffbase, "Yuki::YukiWikiDB", $diffname) or &print_error("(tie Yuki::YukiWikiDB) $diffname");
930  my $debug = 1;      }
931    }
932  # Constructor  
933  sub new {  sub close_diff {
934      return shift->TIEHASH(@_);      if ($modifier_dbtype eq 'dbmopen') {
935  }          dbmclose(%diffbase);
936        } elsif ($modifier_dbtype eq 'AnyDBM_File') {
937  # tying          untie(%diffbase);
938  sub TIEHASH {      } else {
939      my ($class, $dbname) = @_;          untie(%diffbase);
940      my $self = {      }
941          dir => $dbname,  }
942          keys => [],  
943      };  sub print_searchform {
944      if (not -d $self->{dir}) {      my ($word) = @_;
945          if (!mkdir($self->{dir}, 0777)) {      print <<"EOD";
946              print "mkdir(" . $self->{dir} . ") fail\n" if ($debug);  <form action="$url_cgi" method="get">
947              return undef;      <input type="hidden" name="mycmd" value="search">
948          }      <input type="text" name="mymsg" value="$word" size="20">
949      }      <input type="submit" value="$resource{searchbutton}">
950      return bless($self, $class);  </form>
951  }  EOD
952    }
953  # Store  
954  sub STORE {  sub print_editform {
955      my ($self, $key, $val) = @_;      my ($mymsg, $lastmodified, %mode) = @_;
956      my $file = &make_filename($self, $key);      my $frozen = &is_frozen($form{mypage});
957      if (open(FILE,"> $file")) {  
958          binmode(FILE);      if ($form{mypreview}) {
959          print FILE $val;          if ($form{mymsg}) {
960          close(FILE);              unless ($mode{conflict}) {
961          return $self->{$key} = $val;                  print qq(<h3>$resource{previewtitle}</h3>\n);
962      } else {                  print qq($resource{previewnotice}\n);
963          print "$file create error.";                  print qq(<div class="preview">\n);
964      }                  &print_content($form{mymsg});
965  }                  print qq(</div>\n);
966                }
967  # Fetch          } else {
968  sub FETCH {              print qq($resource{previewempty});
969      my ($self, $key) = @_;          }
970      my $file = &make_filename($self, $key);          $mymsg = &escape($form{mymsg});
971      if (open(FILE, $file)) {      } else {
972          local $/;          $mymsg = &escape($mymsg || $database{NewPageTemplate});
973          $self->{$key} = <FILE>;      }
974          close(FILE);  
975      }      my $edit = $mode{admin} ? 'adminedit' : 'edit';
976      return $self->{$key};      my $escapedmypage = &escape($form{mypage});
977  }      my $escapedmypassword = &escape($form{mypassword});
978    
979  # Exists      print <<"EOD";
980  sub EXISTS {  <form action="$url_cgi" method="post">
981      my ($self, $key) = @_;      @{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10"><br>) : "" ]}
982      my $file = &make_filename($self, $key);      <input type="hidden" name="myLastModified" value="$lastmodified">
983      return -e($file);      <input type="hidden" name="mypage" value="$escapedmypage">
984  }      <textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br>
985    @{[
986  # Delete      $mode{admin} ?
987  sub DELETE {      qq(
988      my ($self, $key) = @_;      <input type="radio" name="myfrozen" value="1" @{[$frozen ? qq(checked="checked") : ""]}>$resource{frozenbutton}
989      my $file = &make_filename($self, $key);      <input type="radio" name="myfrozen" value="0" @{[$frozen ? "" : qq(checked="checked")]}>$resource{notfrozenbutton}<br>)
990      unlink $file;      : ""
991      return delete $self->{$key};  ]}
992  }  @{[
993        $mode{conflict} ? "" :
994  sub FIRSTKEY {      qq(
995      my ($self) = @_;          <input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br>
996      opendir(DIR, $self->{dir}) or die $self->{dir};          <input type="submit" name="mypreview_$edit" value="$resource{previewbutton}">
997      @{$self->{keys}} = grep /\.txt$/, readdir(DIR);          <input type="submit" name="mypreview_write" value="$resource{savebutton}" accesskey="S"><kbd>S</kbd><br>
998      foreach my $name (@{$self->{keys}}) {      )
999          $name =~ s/\.txt$//;  ]}
1000          $name =~ s/[0-9A-F][0-9A-F]/pack("C", hex($&))/eg;  </form>
1001      }  EOD
1002      return shift @{$self->{keys}};      unless ($mode{conflict}) {
1003  }          # Show the format rule.
1004            open(FILE, $file_format) or &print_error("($file_format)");
1005  sub NEXTKEY {          my $content = join('', <FILE>);
1006      my ($self) = @_;          &code_convert(\$content, $kanjicode);
1007      return shift @{$self->{keys}};          close(FILE);
1008  }          print &text_to_html($content, toc=>0);
1009        }
1010  sub make_filename {  }
1011      my ($self, $key) = @_;  
1012      my $enkey = '';  sub print_passwordform {
1013      foreach my $ch (split(//, $key)) {          print <<"EOD";
1014          $enkey .= sprintf("%02X", ord($ch));  <form action="$url_cgi" method="post">
1015      }      <input type="hidden" name="mycmd" value="adminchangepassword">
1016      return $self->{dir} . "/$enkey.txt";      $resource{oldpassword} <input type="password" name="myoldpassword" size="10"><br>
1017  }      $resource{newpassword} <input type="password" name="mynewpassword" size="10"><br>
1018  __END__      $resource{newpassword2} <input type="password" name="mynewpassword2" size="10"><br>
1019        <input type="submit" value="$resource{changepasswordbutton}"><br>
1020  =head1 NAME  </form>
1021    EOD
1022  YukiWiki - ��ͳ�˥ڡ������ɲá�������Խ��Ǥ���Web�ڡ�������CGI  }
1023    
1024      Copyright (C) 2000,2001 by Hiroshi Yuki.  sub is_editable {
1025      ���� <[email protected]>      my ($page) = @_;
1026      http://www.hyuki.com/      if (&is_bracket_name($page)) {
1027      http://www.hyuki.com/yukiwiki/          return 0;
1028        } elsif ($fixedpage{$page}) {
1029  =head1 SYNOPSIS          return 0;
1030        } elsif ($page =~ /\s/) {
1031      http://www.hyuki.com/yukiwiki/yukiwiki.cgi          return 0;
1032        } elsif ($page =~ /^\#/) {
1033  =head1 DESCRIPTION          return 0;
1034        } elsif ($page =~ /^$interwiki_name$/) {
1035  YukiWiki�ʷ�륦�������ˤϻ��üԤ���ͳ�˥ڡ������ɲá�������Խ��Ǥ���          return 0;
1036  �Ի׵Ĥ�Web�ڡ���������CGI�Ǥ���      } else {
1037  Web��ư���Ǽ��ĤȤ���äȻ��Ƥ��ޤ�����          return 1;
1038  Web�Ǽ��Ĥ�ñ�˥�å��������ɲä�������ʤΤ��Ф��ơ�      }
1039  YukiWiki�ϡ�Web�ڡ������Τ�ͳ���ѹ����뤳�Ȥ��Ǥ��ޤ���  }
1040    
1041  YukiWiki�ϡ�Cunningham & Cunningham��WikiWikiWeb��  # armor_name:
1042  ���ͤ򻲹ͤˤ����ȼ��˺���ޤ�����  #   WikiName -> WikiName
1043    #   not_wiki_name -> [[not_wiki_name]]
1044  YukiWiki��Perl�ǽ񤫤줿CGI������ץȤȤ��Ƽ¸�����Ƥ��ޤ��Τǡ�  sub armor_name {
1045  Perl��ư���Web�����Фʤ�����Ū�ưפ����֤Ǥ��ޤ���      my ($name) = @_;
1046        #if ($name =~ /^$wiki_name$/) {
1047  ���Ȥ�dbmopen���Ȥ���Ķ��ʤ�����֤Ǥ��ޤ�(Version 1.5.0�ʹߤʤ�dbmopen���Ȥ��ʤ��Ƥ����֤Ǥ��ޤ�)��      #    return $name;
1048        #} else {
1049            return "[[$name]]";
1050  YukiWiki�ϥե꡼���եȤǤ���      #}
1051  ����ͳ�ˤ��Ȥ�����������  }
1052    
1053  =head1 ������ˡ  # unarmor_name:
1054    #   [[bracket_name]] -> bracket_name
1055  =head2 ����  #   WikiName -> WikiName
1056    sub unarmor_name {
1057  YukiWiki�κǿ��Ǥϡ�      my ($name) = @_;
1058  http://www.hyuki.com/yukiwiki/      if ($name =~ /^$bracket_name$/) {
1059  ��������Ǥ��ޤ���          return $1;
1060        } else {
1061  =head2 �ե��������          return $name;
1062        }
1063      readme.txt      �ɥ������  }
1064      yukiwiki.cgi    YukiWiki����  
1065      yukiwiki.gif    �����ʥ��顼�ǡ�  sub is_bracket_name {
1066      yukimono.gif    �����ʥ�Υ����ǡ�      my ($name) = @_;
1067      jcode.pl        ���������ɥ饤�֥��      if ($name =~ /^$bracket_name$/) {
1068            return 1;
1069  =head2 ���󥹥ȡ���      } else {
1070            return 0;
1071  =over 4      }
1072    }
1073  =item 1.  
1074    sub decode {
1075  ���������֤�򤯡�      my ($s) = @_;
1076        $s =~ tr/+/ /;
1077  =item 2.      $s =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("C", hex($1))/eg;
1078        return $s;
1079  yukiwiki.cgi�ΤϤ�������ˤ���������ǧ���ޤ���  }
1080  �̾�ϲ��⤷�ʤ��Ƥ褤����  
1081  �Ϥ����$touchfile��''�ˤ��������褤�Ǥ��礦��  sub encode {
1082        my ($s) = @_;
1083  =item 3.      my $encoded = '';
1084        foreach my $ch (split(//, $s)) {
1085  yukiwiki.cgi��jcode.pl��Ʊ���Ȥ��������֤��ޤ���          if ($ch =~ /[A-Za-z0-9_]/) {
1086                $encoded .= $ch;
1087  =item 4.          } else {
1088                $encoded .= '%' . sprintf("%02X", ord($ch));
1089  ������0��yukiwiki.db�Ȥ����ե���������֤��ޤ���          }
1090  ��Perl�����ƥ�ˤ�äƤ�yukiwiki.pag, yukiwiki.dir��      }
1091        return $encoded;
1092  =item 5.  }
1093    
1094  yukiwiki.cgi�˥֥饦�����饢���������ޤ���  sub init_resource {
1095        open(FILE, $file_resource) or &print_error("(resource)");
1096  =back      while (<FILE>) {
1097            chomp;
1098  =head2 �ѡ��ߥå����          next if /^#/;
1099            my ($key, $value) = split(/=/, $_, 2);
1100          �ե�����        �ѡ��ߥå����      ž���⡼��          $resource{$key} = &code_convert(\$value, $kanjicode);
1101          yukiwiki.cgi    755                 ASCII      }
1102          yukiwiki.gif    644                 BINARY      close(FILE);
1103          yukimono.gif    644                 BINARY  }
1104          jcode.pl        644                 ASCII  
1105    sub conflict {
1106      $dbmopen = 1; �ˤ������:      my ($page, $rawmsg) = @_;
1107          yukiwiki.db     666                 BINARY      if ($form{myLastModified} eq &get_info($page, $info_LastModified)) {
1108          (yukiwiki.pag, yukiwiki.dir�ξ��⤢���          return 0;
1109        }
1110      $dbmopen = 0; �ˤ������: (�����ȥǥ��쥯�ȥ��777�ˤ��Ƥ���)      open(FILE, $file_conflict) or &print_error("(conflict)");
1111          .               777                 (ž�����ʤ�)      my $content = join('', <FILE>);
1112        &code_convert(\$content, $kanjicode);
1113  =head1 �ǡ����ΥХå����å���ˡ      close(FILE);
1114        &print_header($page);
1115  $dbmopen = 1;�ξ��ϡ�      &print_content($content);
1116  �ǡ����Ϥ��٤�yukiwiki.db(.dir, .pag)�����롣      &print_editform($rawmsg, $form{myLastModified}, frozen=>0, conflict=>1);
1117  �����Хå����åפ���Ф褤��      &print_footer($page);
1118        return 1;
1119  $dbmopen = 0;�ξ��ϡ�  }
1120  yukiwiki�Ȥ����ǥ��쥯�ȥ꤬�Ǥ���Τǡ�  
1121  ����ʲ���Хå����åפ���Ф褤��  sub get_now {
1122        my (@week) = qw(Sun Mon Tue Wed Thu Fri Sat);
1123  =head1 �������ڡ����κ����      my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time);
1124        $year += 1900;
1125  =over 4      $mon++;
1126        $mon = "0$mon" if $mon < 10;
1127  =item 1.      $day = "0$day" if $day < 10;
1128        $hour = "0$hour" if $hour < 10;
1129  �ޤ���Ŭ���ʥڡ������㤨��FrontPage�ˤ����ӡ�      $min = "0$min" if $min < 10;
1130  �ڡ����β��ˤ�����Խ��ץ�󥯤򤿤ɤ�ޤ���      $sec = "0$sec" if $sec < 10;
1131        $weekday = $week[$weekday];
1132  =item 2.      return "$year-$mon-$day ($weekday) $hour:$min:$sec";
1133    }
1134  ����ȥƥ��������Ϥ��Ǥ�����֤ˤʤ�Τǡ�  
1135  ������NewPage�Τ褦��ñ��  # [[YukiWiki http://www.hyuki.com/yukiwiki/wiki.cgi?euc($1)]]
1136  ����ʸ����ʸ�����ߤ��Ƥ����ʸ�����  sub init_InterWikiName {
1137  ��񤤤ơ���¸�פ��ޤ���      my $content = $database{$InterWikiName};
1138        while ($content =~ /\[\[(\S+) +(\S+)\]\]/g) {
1139  =item 3.          my ($name, $url) = ($1, $2);
1140            $interwiki{$name} = $url;
1141  ��¸����ȡ�FrontPage�Υڡ������񤭴���ꡢ      }
1142  ���ʤ����񤤤�NewPage�Ȥ���ʸ����θ���� ? �Ȥ�����󥯤�ɽ������ޤ���  }
1143  ���� ? �Ϥ��Υڡ������ޤ�¸�ߤ��ʤ����Ȥ򼨤����Ǥ���  
1144    sub interwiki_convert {
1145  =item 4.      my ($type, $localname) = @_;
1146        if ($type eq 'sjis' or $type eq 'euc') {
1147  ���� ? �򥯥�å�����ȿ������ڡ���NewPage���Ǥ��ޤ��Τǡ�          &code_convert(\$localname, $type);
1148  ���ʤ��ι�����ʸ�Ϥ򤽤ο������ڡ����˽񤤤���¸���ޤ���          return &encode($localname);
1149        } elsif ($type eq 'ykwk') {
1150  =item 5.          # for YukiWiki1
1151            if ($localname =~ /^$wiki_name$/) {
1152  NewPage�ڡ������Ǥ����FrontPage�� ? �Ͼä��ơ���󥯤Ȥʤ�ޤ���              return $localname;
1153            } else {
1154  =back              &code_convert(\$localname, 'sjis');
1155                return &encode("[[" . $localname . "]]");
1156  =head1 �ƥ����������Υ롼��          }
1157        } elsif ($type eq 'asis') {
1158  =over 4          return $localname;
1159        # Walrus add (4) start
1160  =item *      } elsif ($type eq 'isbn') {
1161            $localname = join('', ($localname =~ /[0-9x]/g)) if ($localname =~ /^(\d-?){9}[\dx]$/);
1162  Ϣ³����ʣ���Ԥϥե��뤵���ɽ������ޤ���          return $localname;
1163        # Walrus add (4) end
1164  =item *      } else {
1165            return $localname;
1166  ���Ԥ�����C<< <p> >>�ζ��ڤ�Ȥʤ�ޤ���      }
1167    }
1168  =item *  
1169    sub get_info {
1170  HTML�Υ����Ͻ񤱤ޤ���      my ($page, $key) = @_;
1171        my %info = map { split(/=/, $_, 2) } split(/\n/, $infobase{$page});
1172  =item *      return $info{$key};
1173    }
1174  B<''�ܡ����''>�Τ褦�˥��󥰥륯��������ĤǤϤ���ȡ�  
1175  �ܡ����C<< <b> >>�ˤʤ�ޤ���  sub set_info {
1176        my ($page, $key, $value) = @_;
1177  =item *      my %info = map { split(/=/, $_, 2) } split(/\n/, $infobase{$page});
1178        $info{$key} = $value;
1179  B<'''������å�'''>�Τ褦�˥��󥰥륯�����Ȼ��ĤǤϤ���ȡ�      my $s = '';
1180  ������å�C<< <i> >>�ˤʤ�ޤ���      for (keys %info) {
1181            $s .= "$_=$info{$_}\n";
1182  =item *      }
1183        $infobase{$page} = $s;
1184  B<---->�Τ褦�˥ޥ��ʥ�4�Ĥ�����ȡ�  }
1185  ��ʿ��C<< <hr> >>�ˤʤ�ޤ���  
1186    sub frozen_reject {
1187  =item *      my ($isfrozen) = &get_info($form{mypage}, $info_IsFrozen);
1188        my ($willbefrozen) = $form{myfrozen};
1189  �Ԥ�B<*>�ǤϤ����ȡ�      if (not $isfrozen and not $willbefrozen) {
1190  �縫�Ф�C<< <h2> >>�ˤʤ�ޤ���          # You need no check.
1191            return 0;
1192  =item *      } elsif (valid_password($form{mypassword})) {
1193            # You are admin.
1194  �Ԥ�B<**>�ǤϤ����ȡ�          return 0;
1195  �����Ф�C<< <h3> >>�ˤʤ�ޤ���      } else {
1196            &print_error($resource{passworderror});
1197  =item *          return 1;
1198        }
1199  �Ԥ�ޥ��ʥ�-�ǤϤ����ȡ�  }
1200  �վ��C<< <ul> >>�ˤʤ�ޤ���  
1201  �ޥ��ʥ��ο���������ȥ�٥뤬������ޤ���3��٥�ޤǡ�  sub valid_password {
1202        my ($givenpassword) = @_;
1203      -����1      my ($validpassword_crypt) = &get_info($AdminSpecialPage, $info_AdminPassword);
1204      --����1-1      if (crypt($givenpassword, $validpassword_crypt) eq $validpassword_crypt) {
1205      --����1-2          return 1;
1206      -����2      } else {
1207      -����3          return 0;
1208      --����3-1      }
1209      ---����3-1-1  }
1210      ---����3-1-2  
1211      --����3-2  sub is_frozen {
1212        my ($page) = @_;
1213  =item *      if (&get_info($page, $info_IsFrozen)) {
1214            return 1;
1215  �������Ȥ��ȡ�      } else {
1216  �Ѹ�Ȳ���ʸ�Υꥹ��C<< <dl> >>���񤱤ޤ���          return 0;
1217        }
1218      :�Ѹ�1:���������񤤤�����ʸ1  }
1219      :�Ѹ�2:���������񤤤�����ʸ2  
1220      :�Ѹ�3:���������񤤤�����ʸ3  sub do_comment {
1221        my ($content) = $database{$form{mypage}};
1222  =item *      my $datestr = &get_now;
1223        my $namestr = " ''[[@{[$form{myname}||$DEFAULT_embed_comment_name]}]]'' : ";
1224  ���      #if ($content =~ s/(\Q$embed_comment\E)/- $datestr$namestr$form{mymsg}\n$1/) {
1225        #  ;
1226  =over 4      #} else {
1227        #  $content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/;
1228  =item *      #}
1229        my $i = 0;  my $o = 0;
1230  LinkToSomePage��FrontPage�Τ褦�ˡ�      $content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{
1231  ��ñ��κǽ�ΰ�ʸ������ʸ���ˤ�����Τ�        my $embed = $1;
1232  ��İʾ�Ϣ³������Τ�YukiWiki�Υڡ���̾�Ȥʤꡢ        if ($i == $form{comment_index}) {
1233  ���줬ʸ����˴ޤޤ��ȥ�󥯤ˤʤ�ޤ���          if ($embed eq $embed_comment) {
1234              $embed = "- $datestr$namestr$form{mymsg}\n$embed";  $o = 1;
1235  =item *          } else {
1236              $embed .= "\n- $datestr$namestr$form{mymsg}";  $o = 1;
1237  http://www.hyuki.com/ �Τ褦��URL�ϼ�ưŪ�˥�󥯤ˤʤ�ޤ���          }
1238          }
1239  =item *        $i++; $embed;
1240        }ge;
1241  ��Ť��礫�ä�[[ ]]�Ǥ����ä�ʸ����⡢      unless ($o) {
1242  YukiWiki�Υڡ���̾�ˤʤ�ޤ���        $content .= "- $datestr$namestr$form{mymsg}\n";
1243  �礫�ä�����ˤϥ��ڡ�����ޤ�ƤϤ����ޤ���      }
1244  ���ܸ��Ȥ��ޤ���      if ($form{mymsg}) {
1245            $form{mymsg} = $content;
1246  =back          $form{mytouch} = 'on';
1247            &do_write;
1248  =item *      } else {
1249            $form{mycmd} = 'read';
1250  ��Ƭ�����ڡ����䥿�֤ǻϤޤäƤ���ȡ�          &do_read;
1251  ����������Ѥߤ�����C<< <pre> >>�Ȥ��ư����ޤ���      }
1252  �ץ�������ɽ���ʤɤ˻Ȥ��������Ǥ���  }
1253    
1254    my $_O_COMMENT_INDEX = 0;
1255  =item *  sub embedded_to_html {
1256        my ($embedded) = @_;
1257  �Ԥ� > �ǤϤ����ȡ�      if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) {
1258  ����ʸC<< <blockquote> >>���񤱤ޤ���          my $lastmodified = &get_info($form{mypage}, $info_LastModified);
1259  >�ο���¿���ȥ���ǥ�Ȥ������ʤ�ޤ���3��٥�ޤǡˡ�          return <<"EOD";
1260    <form action="$url_cgi" method="post">
1261      >ʸ��      <input type="hidden" name="mycmd" value="comment">
1262      >ʸ��      <input type="hidden" name="mypage" value="$form{mypage}">
1263      >>����ʤ����      <input type="hidden" name="myLastModified" value="$lastmodified">
1264      >ʸ��      <input type="hidden" name="mytouch" value="on">
1265        <input type="hidden" name="comment_index" value="@{[$_O_COMMENT_INDEX++]}">
1266  =back      $embed_comment_Name_Prompt
1267        <input type="text" name="myname" value="" size="10">
1268  =head1 ��������      <input type="text" name="mymsg" value="" size="60">
1269        <input type="submit" value="$resource{commentbutton}">
1270  =over 4  </form>
1271    EOD
1272  =item *    } elsif ($embedded =~ /$embed_command{searched}/) {
1273        return get_search_result ($1);
1274  2001ǯ10��20����Version 1.6.6��      # Walrus add (5) start
1275        } elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) {
1276  �����ξ����к���          $_ = &make_interwiki_box($1, $2);
1277  ���ڡ����δ�ñ�ʥ����å�������äƤ�����          return ($_) ? $_ : $embedded;
1278  �������˥����å��������Ӥ��롣      # Walrus add (5) end
1279  �����Ľ��digest�Ȥ���ʸ����򸡺������ʬ���롣      } else {
1280  �����MD5�ʤɤǤ����Ȥ�ä����������Τ�����ɡ�          return $embedded;
1281        }
1282  ���ͻ���ɽ��������å������ʤɤϡֶ˰��פ���Υڡ����򻲹ͤˤ�����  }
1283    
1284  =item *  # Walrus add (5) start
1285    sub do_interwiki_box {
1286  2001ǯ10��17����Version 1.6.5��      my $remoteurl = $interwiki{$form{'myintername'}};
1287        if ($remoteurl) {
1288  �ץ�ӥ塼���̤ǡ������ܥ���򲡤����Ȥ������������          $remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $form{'mylocalname'})/e;
1289  ��å����������Ƥ�input���Ǥ�type="hidden"��Ȥä�������Τ���롣          print "Location: $remoteurl\n\n";
1290  ����ˡ�textarea���Ǥ�Ȥ���          exit(1);
1291  �ƥץ�ӥ塼�Ѥ�myspecial_��Ƴ�����Ǥ⤭�줤���к��ǤϤʤ���      } else {
1292            &do_read;
1293  =item *      }
1294    }
1295  2001ǯ8��30����Version 1.6.4��  # Walrus add (5) end
1296    
1297  URL�ǥ����쥯�Ȥ˥ڡ���̾����ꤷ�Ƥ⡢  # Walrus add (5) start
1298  $WikiName��$BracketName�ʳ��Υڡ�������ʤ��褦�ˤ�����  sub make_interwiki_box {
1299  (is_valid_name��is_editable����)��      my ($localname, $intername) = @_;
1300        my %ignoretype = (
1301  =item *          'box'      => 'text',
1302            'text'     => 'text',
1303  2001ǯ8��30����Version 1.6.3��          'pass'     => 'password',
1304            'password' => 'password'
1305  RecentChanges���Խ������Խ��ԲĤȤ�����      );
1306  �Խ��Բĥڡ�����@uneditable�˥ڡ���̾������롣      my $converted = ($ignoretype{$localname}) ? <<EOD : undef;
1307    <form action="$url_cgi" method="post">
1308  =item *      <input type="hidden" name="mycmd" value="interwikibox">
1309        <input type="hidden" name="mypage" value="$form{mypage}">
1310  2001ǯ2��25����Version 1.6.1, 1.6.2��      <input type="hidden" name="myintername" value="$intername">
1311        $intername:
1312  ��ʬ��ǽ�ΥХ�������      <input type="$ignoretype{$localname}" name="mylocalname" value="" size="10">
1313  do_preview��'>'�������ʤ��Х�����      <input type="submit" value="Submit">
1314  �ʥ桼������λ�Ŧ�ˡ�  </form>
1315    EOD
1316  =item *  }
1317    # Walrus add (5) end
1318  2001ǯ2��22����Version 1.6.0��  
1319  ��ʬ��ǽ�����������  sub code_convert {
1320        my ($contentref, $kanjicode) = @_;
1321  =item *  #   &Jcode::convert($contentref, $kanjicode);       # for Jcode.pm
1322        &jcode::convert($contentref, $kanjicode);       # for jcode.pl
1323  2001ǯ2��19����Version 1.5.4��      return $$contentref;
1324  �����ե�����ؤΥ�󥯤ϲ����ˤ��Ƥߤ���  }
1325    
1326  =item *  sub test_convert {
1327        my $txt = &text_to_html(<<"EOD", toc=>1);
1328  2001ǯ2��19����Version 1.5.3��  *HEADER1
1329  RecentChanges����˺�������ڡ���������Τ��᤿��  **HEADER1-1
1330  use strict;�ǰ��ä�������ʬ�򾯤�����(�����ǤϤʤ�)��  -ITEM1
1331    -ITEM2
1332  =item *  -ITEM3
1333    PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1
1334  2001ǯ2��16����Version 1.5.2��  PAR1PAR1PAR1PAR1PAR1PAR1''BOLD''PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1
1335  textarea��ɽ������ӥץ�ӥ塼�������� < �� > �� &lt; �� &gt; ���Ѵ�����  PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1
1336  (do_preview, editpage, print_preview_buttons)��  
1337    PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2
1338  =item *  PAR2PAR2PAR2PAR2PAR2PAR2'''ITALIC'''PAR2PAR2PAR2PAR2PAR2PAR2PAR2
1339    PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2
1340  2000ǯ12��27����Version 1.5.1��  **HEADER1-2
1341  �ץ�ӥ塼���̤�����������  :TERM1:DESCRIPTION1 AND ''BOLD''
1342    PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1
1343  =item *  PAR1PAR1PAR1PAR1PAR1PAR1''BOLD''PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1
1344    PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1
1345  2000ǯ12��22����Version 1.5.0��  :TERM2:DESCRIPTION2
1346  ����Ū�ˤ����֤��ľ������  :TERM3:DESCRIPTION3
1347  ���������Ӻ�������褦�ˤ���(do_list)��  ----
1348  �񤭹������˳�ǧ���̤�Ф��褦�ˤ���(do_preview)��  *HEADER2
1349  �ƥ����Ȥν������Խ����̤����줿(do_edit, do_reedit)��  **HEADER2-1
1350  WhatsNew��RecentChanges��TopPage��FrontPage���ѹ�������  http://www.hyuki.com/
1351    **HEADER2-2
1352  =item *  
1353    [[YukiWiki2]]
1354  2000ǯ12��20����Version 1.1.0��  
1355  tie�����Ѥ��ơ�dbmopen���Ȥ��ʤ����Ǥ�ư���褦�˽�����  PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1
1356  ���ѼԤ�1�ͤǤ���ֶ˰��פ��󤫤�  PAR1PAR1PAR1PAR1PAR1PAR1'''''BOLD ITALIC'''''PAR1PAR1PAR1PAR1PAR1
1357  ���äƤ��������������ɤ򸵤ˤ��Ƥ��ޤ���  PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1
1358    >PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2
1359  =item *  >PAR2PAR2PAR2PAR2PAR2PAR2'''ITALIC'''PAR2PAR2PAR2PAR2PAR2PAR2PAR2
1360    >PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2
1361  2000ǯ9��5����Version 1.0.2��  
1362   <body color=...> �� <body bgcolor=...>  LEVEL0LEVEL0LEVEL0LEVEL0LEVEL0LEVEL0LEVEL0
1363  ���ѼԤ���λ�Ŧ�ˤ�롣���ա�  
1364    >LEVEL1
1365  =item *  >LEVEL1
1366    >LEVEL1
1367  2000ǯ8��6����Version 1.0.1�������  >>LEVEL2
1368  C MAGAZINE�ʥ��եȥХ󥯥ѥ֥�å��󥰡�  >>LEVEL2
1369  2000ǯ10���Ϣ�ܵ������������ǡ�  >>LEVEL2
1370  [[ ]] �κǸ夬��˾�פΤ褦�˥��ե�JIS��  >>>LEVEL3
1371  0x5D�ˤʤ���β����Ԥʤä���  -HELLO-1
1372    --HELLO-2
1373  =item *  (HELLO-2, HELLO-2, HELLO-2)
1374    ---HELLO-3
1375  2000ǯ8��5����Version 1.0.0�������  (HELLO-3, HELLO-3, HELLO-3)
1376    --HELLO-2
1377  =item *  ---HELLO-3
1378    --HELLO-2
1379  2000ǯ7��23����Version 0.82�������  ---HELLO-3
1380  �Խ����Υ�󥯥ߥ���  >>>LEVEL3
1381  <textarea>��°���ѹ���  >>>LEVEL3
1382    >>>LEVEL3
1383  =item *  >>>LEVEL3
1384    EOD
1385  2000ǯ7��22����Version 0.81�������      print $txt;
1386  �������Ȥ߹��ࡣ      exit;
1387    }
1388  =item *  
1389    sub do_diff {
1390  2000ǯ7��21����Version 0.80�������      if (not &is_editable($form{mypage})) {
1391  POD��CGI��˽񤭹��ࡣ          &do_read;
1392            return;
1393  =item *      }
1394        &open_diff;
1395  2000ǯ7��19����Version 0.70�������      my $title = $form{mypage};
1396  '''������å�'''�䡢--��---��>>��>>>�ʤɤ������      &print_header($title);
1397        $_ = &escape($diffbase{$form{mypage}});
1398  =item *      &close_diff;
1399        print qq(<h3>$resource{difftitle}</h3>);
1400  2000ǯ7��18����Version 0.60�������      print qq($resource{diffnotice});
1401  *����*��''����''���ѹ�      print qq(<pre class="diff">);
1402        foreach (split(/\n/, $_)) {
1403  =item *          if (/^\+(.*)/) {
1404                print qq(<b class="added">$1</b>\n);
1405  2000ǯ7��17����Version 0.50�������          } elsif (/^\-(.*)/) {
1406                print qq(<s class="deleted">$1</s>\n);
1407  =item *          } elsif (/^\=(.*)/) {
1408                print qq(<span class="same">$1</span>\n);
1409  2000ǯ7��17��������ˤ��������ɲä��롣          } else {
1410                print qq|??? $_\n|;
1411  =item *          }
1412        }
1413  2000ǯ7��16�������������ɲá�      print qq(</pre>);
1414        print qq(<hr>);
1415  =item *      &print_footer($title);
1416    }
1417  2000ǯ7��15����������  
1418    sub do_rss {
1419  =back      my $rss = new Yuki::RSS(
1420            version => '1.0',
1421  =head1 TODO          encoding => $charset,
1422        );
1423      - �ƥ�����ɽ���⡼��      $rss->channel(
1424      - Charset��������          title => $modifier_rss_title,
1425      - textarea����Ĥ������б�          link  => $modifier_rss_link,
1426      - ��˥塼�αѸ�ɽ���յ�          description => $modifier_rss_description,
1427      - �ץ�ӥ塼�Υܥ���ǡ�mymsg��input��value������Ƥ��뤬�����Ԥ򤽤Τޤ�value�ˤ���ƤϤ����ʤ��ΤǤϤʤ�����      );
1428      - �ֺ��Խ��פε�ǽ�ϥ֥饦���� back �ǽ�ʬ�ǤϤʤ������ץ�ӥ塼�Ϥ�äȥ���ץ�ˡ�      my $recentchanges = $database{$RecentChanges};
1429      - �ڡ��������ȥ��Wikiname�ˤ������ˤ�����褦�ˤ��롣      my $count = 0;
1430      - InterWiki���ε�ǽ��URL�򱣤��Ĥġ���󥯤�ĥ���      foreach (split(/\n/, $recentchanges)) {
1431            last if ($count >= 15);
1432  =head1 ���          /^\- \d\d\d\d\-\d\d\-\d\d \(...\) \d\d:\d\d:\d\d (\S+)/;    # date format.
1433            my $title = &unarmor_name($1);
1434      Copyright (C) 2000 by Hiroshi Yuki.          my $escaped_title = &escape($title);
1435      ���� <[email protected]>          my $link = $modifier_rss_link . '?' . &encode($title);
1436      http://www.hyuki.com/          my $description = $escaped_title . &escape(&get_subjectline($title));
1437      http://www.hyuki.com/yukiwiki/          $rss->add_item(
1438                title => $escaped_title,
1439  ���䡢�ո����Х����� [email protected] �˥᡼�뤷�Ƥ���������              link  => $link,
1440                description => $description,
1441  =head1 ���۾��          );
1442            $count++;
1443  YukiWiki�ϡ�      }
1444  GNU General Public License�ˤƸ������ޤ���      # print RSS information (as XML).
1445        print <<"EOD"
1446  YukiWiki�ϥե꡼���եȤǤ���  Content-type: text/xml
1447  ����ͳ�ˤ��Ȥ�����������  
1448  ��ʬ���ߤ�YukiWiki������褦�˥���ץ�ˤ��Ƥ���ޤ���  @{[$rss->as_string]}
1449    EOD
1450  =head1 �ռ�  }
1451    
1452  �ܲȤ�WikiWiki���ä�Cunningham & Cunningham, Inc.��  sub is_exist_page {
1453  ���դ��ޤ���      my ($name) = @_;
1454        if ($use_exists) {
1455  YukiWiki��ڤ���ǻȤäƤ�������          return exists($database{$name});
1456  �ͥåȾ�������˴��դ��ޤ���      } else {
1457            return $database{$name};
1458  YukiWiki�Υ�����ǥ����󤷤Ƥ������ä��������व��      }
1459  http://city.hokkai.or.jp/~reina/  }
1460  �˴��դ��ޤ���  
1461    1;
1462  tie��Ȥä��Ǥθ��ˤʤ륳���ɤ����äƤ������ä�  __END__
1463  �ֶ˰��פ���˴��դ��ޤ���  =head1 NAME
1464    
1465  =head1 ���ȥ��  wiki.cgi - This is YukiWiki, yet another Wiki clone.
1466    
1467  =over 4  =head1 DESCRIPTION
1468    
1469  =item *  YukiWiki is yet another Wiki clone.
1470    
1471  YukiWiki�ۡ���ڡ���  YukiWiki can treat Japanese WikiNames (enclosed with [[ and ]]).
1472  http://www.hyuki.com/yukiwiki/  YukiWiki provides 'InterWiki' feature, RDF Site Summary (RSS),
1473    and some embedded commands (such as [[#comment]] to add comments).
1474  =item *  
1475    Read F<readme_en.txt> (English) or F<readme_ja.txt> (Japanese) in more detail.
1476  �ܲȤ�WikiWiki  
1477  http://c2.com/cgi/wiki?WikiWikiWeb  =head1 AUTHOR
1478    
1479  =item *  Hiroshi Yuki <[email protected]> http://www.hyuki.com/yukiwiki/
1480    
1481  �ܲȤ�WikiWiki�κ��(Cunningham & Cunningham, Inc.)  =head1 LICENSE
1482  http://c2.com/  
1483    Copyright (C) 2000-2002 by Hiroshi Yuki.
1484  =item *  
1485    This program is free software; you can redistribute it and/or
1486  YukiWiki�Υ����ǥ�����򤷤Ƥ������ä��������व��Υڡ���  modify it under the same terms as Perl itself.
1487  http://city.hokkai.or.jp/~reina/  
1488    =cut
 =back  
   
 =cut  

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.26

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24