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

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.33

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24  
Google Analytics is used in this page; Cookies are used. 忍者AdMax is used in this page; Cookies are used. Privacy policy.