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