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