修訂 | 686561d8eb47507e1c895e7f66cc7b58b17416e5 (tree) |
---|---|
時間 | 2002-06-21 14:21:46 |
作者 | masui <masui> |
Commiter | masui |
MASUI'z Edition first beta release
-split program files pukiwiki.php -> *.php
-add new plugins
-update plugins
-fix & update
@@ -0,0 +1,238 @@ | ||
1 | +<? | |
2 | +// PukiWiki - Yet another WikiWikiWeb clone. | |
3 | +// $Id: backup.php,v 1.1 2002/06/21 05:21:46 masui Exp $ | |
4 | +///////////////////////////////////////////////// | |
5 | + | |
6 | +// バックアップデータを作成する | |
7 | +function make_backup($filename,$body,$oldtime) | |
8 | +{ | |
9 | + global $splitter,$cycle,$maxage; | |
10 | + $aryages = array(); | |
11 | + $arystrout = array(); | |
12 | + | |
13 | + if(function_exists(gzfile)) | |
14 | + $filename = str_replace(".txt",".gz",$filename); | |
15 | + | |
16 | + $realfilename = BACKUP_DIR.$filename; | |
17 | + | |
18 | + if(time() - @filemtime($realfilename) > (60 * 60 * $cycle)) | |
19 | + { | |
20 | + $aryages = read_backup($filename); | |
21 | + if(count($aryages) >= $maxage) | |
22 | + { | |
23 | + array_shift($aryages); | |
24 | + } | |
25 | + | |
26 | + foreach($aryages as $lines) | |
27 | + { | |
28 | + foreach($lines as $key => $line) | |
29 | + { | |
30 | + if($key && $key == "timestamp") | |
31 | + { | |
32 | + $arystrout[] = "$splitter " . rtrim($line); | |
33 | + } | |
34 | + else | |
35 | + { | |
36 | + $arystrout[] = rtrim($line); | |
37 | + } | |
38 | + } | |
39 | + } | |
40 | + | |
41 | + $strout = join("\n",$arystrout); | |
42 | + if(!preg_match("/\n$/",$strout) && trim($strout)) $strout .= "\n"; | |
43 | + | |
44 | + $body = "$splitter " . $oldtime . "\n" . $body; | |
45 | + if(!preg_match("/\n$/",$body)) $body .= "\n"; | |
46 | + | |
47 | + $fp = backup_fopen($realfilename,"w"); | |
48 | + backup_fputs($fp,$strout); | |
49 | + backup_fputs($fp,$body); | |
50 | + backup_fclose($fp); | |
51 | + } | |
52 | + | |
53 | + return true; | |
54 | +} | |
55 | + | |
56 | +// 特定の世代のバックアップデータを取得 | |
57 | +function get_backup($age,$filename) | |
58 | +{ | |
59 | + $aryages = read_backup($filename); | |
60 | + | |
61 | + foreach($aryages as $key => $lines) | |
62 | + { | |
63 | + if($key != $age) continue; | |
64 | + foreach($lines as $key => $line) | |
65 | + { | |
66 | + if($key && $key == "timestamp") continue; | |
67 | + $retvars[] = $line; | |
68 | + } | |
69 | + } | |
70 | + | |
71 | + return $retvars; | |
72 | +} | |
73 | + | |
74 | +// バックアップ情報を返す | |
75 | +function get_backup_info($filename) | |
76 | +{ | |
77 | + global $splitter; | |
78 | + $lines = array(); | |
79 | + $retvars = array(); | |
80 | + $lines = backup_file(BACKUP_DIR.$filename); | |
81 | + | |
82 | + if(!is_array($lines)) return array(); | |
83 | + | |
84 | + $age = 0; | |
85 | + foreach($lines as $line) | |
86 | + { | |
87 | + preg_match("/^$splitter\s(\d+)$/",trim($line),$match); | |
88 | + if($match[1]) | |
89 | + { | |
90 | + $age++; | |
91 | + $retvars[$age] = $match[1]; | |
92 | + } | |
93 | + } | |
94 | + | |
95 | + return $retvars; | |
96 | +} | |
97 | + | |
98 | +// バックアップデータ全体を取得 | |
99 | +function read_backup($filename) | |
100 | +{ | |
101 | + global $splitter; | |
102 | + $lines = array(); | |
103 | + $lines = backup_file(BACKUP_DIR.$filename); | |
104 | + | |
105 | + if(!is_array($lines)) return array(); | |
106 | + | |
107 | + $age = 0; | |
108 | + foreach($lines as $line) | |
109 | + { | |
110 | + preg_match("/^$splitter\s(\d+)$/",trim($line),$match); | |
111 | + if($match[1]) | |
112 | + { | |
113 | + $age++; | |
114 | + $retvars[$age]["timestamp"] = $match[1] . "\n"; | |
115 | + } | |
116 | + else | |
117 | + { | |
118 | + $retvars[$age][] = $line; | |
119 | + } | |
120 | + } | |
121 | + | |
122 | + return $retvars; | |
123 | +} | |
124 | + | |
125 | +// バックアップ一覧の取得 | |
126 | +function get_backup_list($_page="") | |
127 | +{ | |
128 | + global $script,$date_format,$time_format,$weeklabels,$cantedit; | |
129 | + global $_msg_backuplist,$_msg_diff,$_msg_nowdiff,$_msg_source; | |
130 | + | |
131 | + $ins_date = date($date_format,$val); | |
132 | + $ins_time = date($time_format,$val); | |
133 | + $ins_week = "(".$weeklabels[date("w",$val)].")"; | |
134 | + $ins = "$ins_date $ins_week $ins_time"; | |
135 | + | |
136 | + if (($dir = @opendir(BACKUP_DIR)) && !$_page) | |
137 | + { | |
138 | + while($file = readdir($dir)) | |
139 | + { | |
140 | + if(function_exists(gzopen)) | |
141 | + $file = str_replace(".txt",".gz",$file); | |
142 | + | |
143 | + if($file == ".." || $file == ".") continue; | |
144 | + $page = decode(trim(preg_replace("/(\.txt)|(\.gz)$/"," ",$file))); | |
145 | + if(in_array($page,$cantedit)) continue; | |
146 | + $page_url = rawurlencode($page); | |
147 | + $name = $page; | |
148 | + $name = strip_bracket($name); | |
149 | + if(is_page($page)) | |
150 | + $vals[$name]["link"] = "<li><a href=\"$script?$page_url\">$name</a></li>"; | |
151 | + else | |
152 | + $vals[$name]["link"] = "<li>$name</li>"; | |
153 | + $vals[$name]["name"] = $page; | |
154 | + } | |
155 | + closedir($dir); | |
156 | + $vals = list_sort($vals); | |
157 | + $retvars[] = "<ul>"; | |
158 | + } | |
159 | + else | |
160 | + { | |
161 | + $page_url = rawurlencode($_page); | |
162 | + $name = strip_bracket($_page); | |
163 | + $vals[$name]["link"] = ""; | |
164 | + $vals[$name]["name"] = $_page; | |
165 | + $retvars[] = "<ul>"; | |
166 | + $retvars[] .= "<li><a href=\"$script?cmd=backup\">$_msg_backuplist</a></li>\n"; | |
167 | + } | |
168 | + | |
169 | + | |
170 | + foreach($vals as $page => $line) | |
171 | + { | |
172 | + $arybackups = get_backup_info(encode($line["name"]).".txt"); | |
173 | + $page_url = rawurlencode($line["name"]); | |
174 | + if(count($arybackups)) $line["link"] .= "\n<ul>\n"; | |
175 | + foreach($arybackups as $key => $val) | |
176 | + { | |
177 | + $ins_date = date($date_format,$val); | |
178 | + $ins_time = date($time_format,$val); | |
179 | + $ins_week = "(".$weeklabels[date("w",$val)].")"; | |
180 | + $backupdate = "($ins_date $ins_week $ins_time)"; | |
181 | + if(!$_page) | |
182 | + { | |
183 | + $line["link"] .= "<li><a href=\"$script?cmd=backup&page=$page_url&age=$key\">$key $backupdate</a></li>\n"; | |
184 | + } | |
185 | + else | |
186 | + { | |
187 | + $line["link"] .= "<li><a href=\"$script?cmd=backup&page=$page_url&age=$key\">$key $backupdate</a> [ <a href=\"$script?cmd=backup_diff&page=$page_url&age=$key\">$_msg_diff</a> | <a href=\"$script?cmd=backup_nowdiff&page=$page_url&age=$key\">$_msg_nowdiff</a> | <a href=\"$script?cmd=backup_source&page=$page_url&age=$key\">$_msg_source</a> ]</li>\n"; | |
188 | + } | |
189 | + } | |
190 | + if(count($arybackups)) $line["link"] .= "</ul>"; | |
191 | + $retvars[] = $line["link"]; | |
192 | + } | |
193 | + $retvars[] = "</ul>"; | |
194 | + | |
195 | + return join("\n",$retvars); | |
196 | +} | |
197 | + | |
198 | +// zlib関数が使用できれば、圧縮して使用するためのファイルシステム関数 | |
199 | +function backup_fopen($filename,$mode) | |
200 | +{ | |
201 | + if(function_exists(gzopen)) | |
202 | + return gzopen(str_replace(".txt",".gz",$filename),$mode); | |
203 | + else | |
204 | + return fopen($filename,$mode); | |
205 | +} | |
206 | + | |
207 | +function backup_fputs($zp,$str) | |
208 | +{ | |
209 | + if(function_exists(gzputs)) | |
210 | + return gzputs($zp,$str); | |
211 | + else | |
212 | + return fputs($zp,$str); | |
213 | +} | |
214 | + | |
215 | +function backup_fclose($zp) | |
216 | +{ | |
217 | + if(function_exists(gzclose)) | |
218 | + return gzclose($zp); | |
219 | + else | |
220 | + return fclose($zp); | |
221 | +} | |
222 | + | |
223 | +function backup_file($filename) | |
224 | +{ | |
225 | + if(function_exists(gzfile)) | |
226 | + return @gzfile(str_replace(".txt",".gz",$filename)); | |
227 | + else | |
228 | + return @file($filename); | |
229 | +} | |
230 | + | |
231 | +function backup_delete($filename) | |
232 | +{ | |
233 | + if(function_exists(gzopen)) | |
234 | + return @unlink(str_replace(".txt",".gz",$filename)); | |
235 | + else | |
236 | + return @unlink($filename); | |
237 | +} | |
238 | +?> |
@@ -0,0 +1,3 @@ | ||
1 | +#!/bin/sh | |
2 | + | |
3 | +grep -B1 "^function" ../*.php | sed -e "s/^\.\.\///" | sed "s/[a-z]*\.php\:function[ \t]*//" |
@@ -79,6 +79,7 @@ $_btn_notchangetimestamp = 'Not change timestamp'; | ||
79 | 79 | $_btn_addtop = 'Add to top of page'; |
80 | 80 | $_btn_template = 'Page for use template'; |
81 | 81 | $_btn_load = 'Load'; |
82 | +$_btn_edit = 'Edit'; | |
82 | 83 | |
83 | 84 | /////////////////////////////////////// |
84 | 85 | // plug-in message |
@@ -87,6 +88,7 @@ $_btn_load = 'Load'; | ||
87 | 88 | // comment |
88 | 89 | $_btn_name = 'Name: '; |
89 | 90 | $_btn_comment = 'Submit'; |
91 | +$_msg_comment = 'Comment: '; | |
90 | 92 | |
91 | 93 | /////////////////////////////////////// |
92 | 94 | // attach file |
@@ -94,6 +96,7 @@ $_title_uploaded = 'Uploaded file to $1'; | ||
94 | 96 | $_title_file_deleted = 'Deleted file in $1'; |
95 | 97 | $_title_notfound = 'Not found the file in $1'; |
96 | 98 | $_title_upload = 'Upload at $1'; |
99 | +$_title_confirm_delete = 'Delete %s'; | |
97 | 100 | |
98 | 101 | $_msg_noparm = 'Cannot upload/delete in $1'; |
99 | 102 | $_msg_already_exists = 'Already exists file in $1'; |
@@ -102,6 +105,16 @@ $_msg_maxsize = 'Maximum file size is $1.'; | ||
102 | 105 | $_msg_delete = 'Delete \'$1\''; |
103 | 106 | $_msg_exceed = 'File size is too big to $1'; |
104 | 107 | $_msg_attachfile = 'Attach file'; |
108 | +$_msg_confirm_delete = '<center>comfirm Delete '%s'<br>%s</center>'; | |
105 | 109 | $_btn_upload = 'Upload'; |
106 | 110 | $_btn_delete = 'Del'; |
111 | + | |
112 | +/////////////////////////////////////// | |
113 | +// newpage | |
114 | +$_msg_newpage = 'new page'; | |
115 | + | |
116 | +/////////////////////////////////////// | |
117 | +// recent | |
118 | +$_recent_plugin_frame = '<span align="center"><h5 class="side_label">recent(%d)</h5></span><small>%s</small>'; | |
119 | +$_recent_plugin_li = '.'; | |
107 | 120 | ?> |
@@ -0,0 +1,223 @@ | ||
1 | +<? | |
2 | +// PukiWiki - Yet another WikiWikiWeb clone. | |
3 | +// $Id: file.php,v 1.1 2002/06/21 05:21:46 masui Exp $ | |
4 | +///////////////////////////////////////////////// | |
5 | + | |
6 | +// ソースを取得 | |
7 | +function get_source($page) | |
8 | +{ | |
9 | + if(page_exists($page)) { | |
10 | + return file(get_filename(encode($page))); | |
11 | + } | |
12 | + | |
13 | + return array(); | |
14 | +} | |
15 | + | |
16 | +// ページが存在するか? | |
17 | +function page_exists($page) | |
18 | +{ | |
19 | + return file_exists(get_filename(encode($page))); | |
20 | +} | |
21 | + | |
22 | +// ファイルへの出力 | |
23 | +function file_write($dir,$page,$str) | |
24 | +{ | |
25 | + global $post,$update_exec; | |
26 | + | |
27 | + if($str == "") | |
28 | + { | |
29 | + @unlink($dir.encode($page).".txt"); | |
30 | + } | |
31 | + else | |
32 | + { | |
33 | + if($post["notimestamp"] && is_page($page)) | |
34 | + { | |
35 | + $timestamp = @filemtime($dir.encode($page).".txt"); | |
36 | + } | |
37 | + $fp = fopen($dir.encode($page).".txt","w"); | |
38 | + while(!flock($fp,LOCK_EX)); | |
39 | + fputs($fp,$str); | |
40 | + flock($fp,LOCK_UN); | |
41 | + fclose($fp); | |
42 | + if($timestamp) | |
43 | + touch($dir.encode($page).".txt",$timestamp); | |
44 | + } | |
45 | + | |
46 | + if(!$timestamp) | |
47 | + put_lastmodified(); | |
48 | + | |
49 | + if($update_exec) | |
50 | + { | |
51 | + system($update_exec." > /dev/null &"); | |
52 | + } | |
53 | +} | |
54 | + | |
55 | +// 最終更新ページの更新 | |
56 | +function put_lastmodified() | |
57 | +{ | |
58 | + global $script,$maxshow,$whatsnew,$date_format,$time_format,$weeklabels,$post,$non_list; | |
59 | + | |
60 | + if($post["notimestamp"]) return; | |
61 | + | |
62 | + $files = get_existpages(); | |
63 | + foreach($files as $page) { | |
64 | + if($page == $whatsnew) continue; | |
65 | + if(preg_match("/$non_list/",$page)) continue; | |
66 | + | |
67 | + if(file_exists(get_filename(encode($page)))) | |
68 | + { | |
69 | + $page_url = rawurlencode($page); | |
70 | + $lastmodtime = filemtime(get_filename(encode($page))); | |
71 | + $lastmod = date($date_format,$lastmodtime) | |
72 | + . " (" . $weeklabels[date("w",$lastmodtime)] . ") " | |
73 | + . date($time_format,$lastmodtime); | |
74 | + $putval[$lastmodtime][] = "-$lastmod - $page"; | |
75 | + } | |
76 | + } | |
77 | + | |
78 | + $cnt = 1; | |
79 | + krsort($putval); | |
80 | + $fp = fopen(get_filename(encode($whatsnew)),"w"); | |
81 | + flock($fp,LOCK_EX); | |
82 | + foreach($putval as $pages) | |
83 | + { | |
84 | + foreach($pages as $page) | |
85 | + { | |
86 | + fputs($fp,$page."\n"); | |
87 | + $cnt++; | |
88 | + if($cnt > $maxshow) break; | |
89 | + } | |
90 | + if($cnt > $maxshow) break; | |
91 | + } | |
92 | + flock($fp,LOCK_EX); | |
93 | + fclose($fp); | |
94 | +} | |
95 | + | |
96 | +// ファイル名を得る(エンコードされている必要有り) | |
97 | +function get_filename($pagename) | |
98 | +{ | |
99 | + return DATA_DIR.$pagename.".txt"; | |
100 | +} | |
101 | + | |
102 | +// ページが存在するかしないか | |
103 | +function is_page($page,$reload=false) | |
104 | +{ | |
105 | + global $InterWikiName,$_ispage; | |
106 | + | |
107 | + if(($_ispage[$page] === true || $_ispage[$page] === false) && !$reload) return $_ispage[$page]; | |
108 | + | |
109 | + if(preg_match("/($InterWikiName)/",$page)) | |
110 | + $_ispage[$page] = false; | |
111 | + else if(!page_exists($page)) | |
112 | + $_ispage[$page] = false; | |
113 | + else | |
114 | + $_ispage[$page] = true; | |
115 | + | |
116 | + return $_ispage[$page]; | |
117 | +} | |
118 | + | |
119 | +// ページが編集可能か | |
120 | +function is_editable($page) | |
121 | +{ | |
122 | + global $BracketName,$WikiName,$InterWikiName,$cantedit,$_editable; | |
123 | + | |
124 | + if($_editable === true || $_editable === false) return $_editable; | |
125 | + | |
126 | + if(preg_match("/^$InterWikiName$/",$page)) | |
127 | + $_editable = false; | |
128 | + elseif(!preg_match("/^$BracketName$/",$page) && !preg_match("/^$WikiName$/",$page)) | |
129 | + $_editable = false; | |
130 | + else if(in_array($page,$cantedit)) | |
131 | + $_editable = false; | |
132 | + else | |
133 | + $_editable = true; | |
134 | + | |
135 | + return $_editable; | |
136 | +} | |
137 | + | |
138 | +// ページが凍結されているか | |
139 | +function is_freeze($page) | |
140 | +{ | |
141 | + global $_freeze; | |
142 | + | |
143 | + if(!is_page($page)) return false; | |
144 | + if($_freeze === true || $_freeze === false) return $_freeze; | |
145 | + | |
146 | + $lines = get_source($page); | |
147 | + | |
148 | + if($lines[0] == "#freeze\n") | |
149 | + $_freeze = true; | |
150 | + else | |
151 | + $_freeze = false; | |
152 | + | |
153 | + return $_freeze; | |
154 | +} | |
155 | + | |
156 | +// 指定されたページの経過時刻 | |
157 | +function get_pg_passage($page,$sw=true) | |
158 | +{ | |
159 | + global $_pg_passage,$show_passage; | |
160 | + | |
161 | + if(!$show_passage) return ""; | |
162 | + | |
163 | + if(isset($_pg_passage[$page])) | |
164 | + { | |
165 | + if($sw) | |
166 | + return $_pg_passage[$page]["str"]; | |
167 | + else | |
168 | + return $_pg_passage[$page]["label"]; | |
169 | + } | |
170 | + if($pgdt = @filemtime(get_filename(encode($page)))) | |
171 | + { | |
172 | + $pgdt = UTIME - $pgdt; | |
173 | + if(ceil($pgdt / 60) < 60) | |
174 | + $_pg_passage[$page]["label"] = "(".ceil($pgdt / 60)."m)"; | |
175 | + else if(ceil($pgdt / 60 / 60) < 24) | |
176 | + $_pg_passage[$page]["label"] = "(".ceil($pgdt / 60 / 60)."h)"; | |
177 | + else | |
178 | + $_pg_passage[$page]["label"] = "(".ceil($pgdt / 60 / 60 / 24)."d)"; | |
179 | + | |
180 | + $_pg_passage[$page]["str"] = "<small>".$_pg_passage[$page]["label"]."</small>"; | |
181 | + } | |
182 | + else | |
183 | + { | |
184 | + $_pg_passage[$page]["label"] = ""; | |
185 | + $_pg_passage[$page]["str"] = ""; | |
186 | + } | |
187 | + | |
188 | + if($sw) | |
189 | + return $_pg_passage[$page]["str"]; | |
190 | + else | |
191 | + return $_pg_passage[$page]["label"]; | |
192 | +} | |
193 | + | |
194 | +// Last-Modified ヘッダ | |
195 | +function header_lastmod($page) | |
196 | +{ | |
197 | + global $lastmod; | |
198 | + | |
199 | + if($lastmod && is_page($page)) | |
200 | + { | |
201 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime(get_filename(encode($page))))." GMT"); | |
202 | + } | |
203 | +} | |
204 | + | |
205 | +// 全ページ名を配列に | |
206 | +function get_existpages() | |
207 | +{ | |
208 | + $aryret = array(); | |
209 | + | |
210 | + if ($dir = @opendir(DATA_DIR)) | |
211 | + { | |
212 | + while($file = readdir($dir)) | |
213 | + { | |
214 | + if($file == ".." || $file == "." || strstr($file,".txt")===FALSE) continue; | |
215 | + $page = decode(trim(preg_replace("/\.txt$/"," ",$file))); | |
216 | + array_push($aryret,$page); | |
217 | + } | |
218 | + closedir($dir); | |
219 | + } | |
220 | + | |
221 | + return $aryret; | |
222 | +} | |
223 | +?> |
@@ -0,0 +1,340 @@ | ||
1 | +<? | |
2 | +// PukiWiki - Yet another WikiWikiWeb clone. | |
3 | +// $Id: func.php,v 1.1 2002/06/21 05:21:46 masui Exp $ | |
4 | +///////////////////////////////////////////////// | |
5 | + | |
6 | +// 検索 | |
7 | +function do_search($word,$type="AND",$non_format=0) | |
8 | +{ | |
9 | + global $script,$whatsnew,$vars; | |
10 | + global $_msg_andresult,$_msg_orresult,$_msg_notfoundresult; | |
11 | + | |
12 | + $database = array(); | |
13 | + $retval = array(); | |
14 | + $cnt = 0; | |
15 | + | |
16 | + $files = get_existpages(); | |
17 | + foreach($files as $page) { | |
18 | + $cnt++; | |
19 | + if($page == $whatsnew) continue; | |
20 | + if($page == $vars["page"] && $non_format) continue; | |
21 | + $data[$page] = get_source($page); | |
22 | + } | |
23 | + | |
24 | + $arywords = explode(" ",$word); | |
25 | + $result_word = $word; | |
26 | + | |
27 | + foreach($data as $name => $lines) | |
28 | + { | |
29 | + $line = join("\n",$lines); | |
30 | + | |
31 | + $hit = 0; | |
32 | + if(strpos($result_word," ") !== FALSE) | |
33 | + { | |
34 | + foreach($arywords as $word) | |
35 | + { | |
36 | + if($type=="AND") | |
37 | + { | |
38 | + if(strpos($line,$word) === FALSE) | |
39 | + { | |
40 | + $hit = 0; | |
41 | + break; | |
42 | + } | |
43 | + else | |
44 | + { | |
45 | + $hit = 1; | |
46 | + } | |
47 | + } | |
48 | + else if($type=="OR") | |
49 | + { | |
50 | + if(strpos($line,$word) !== FALSE) | |
51 | + $hit = 1; | |
52 | + } | |
53 | + } | |
54 | + if($hit==1 || strpos($name,$word)!==FALSE) | |
55 | + { | |
56 | + $page_url = rawurlencode($name); | |
57 | + $word_url = rawurlencode($word); | |
58 | + $name2 = strip_bracket($name); | |
59 | + $str = get_pg_passage($name); | |
60 | + $retval[$name2] = "<li><a href=\"$script?$page_url\">$name2</a>$str</li>"; | |
61 | + } | |
62 | + } | |
63 | + else | |
64 | + { | |
65 | + if(stristr($line,$word) || stristr($name,$word)) | |
66 | + { | |
67 | + $page_url = rawurlencode($name); | |
68 | + $word_url = rawurlencode($word); | |
69 | + $name2 = strip_bracket($name); | |
70 | + $link_tag = "<a href=\"$script?$page_url\">$name2</a>"; | |
71 | + $link_tag .= get_pg_passage($name,false); | |
72 | + if($non_format) | |
73 | + { | |
74 | + $tm = @filemtime(get_filename(encode($name))); | |
75 | + $retval[$tm] = $link_tag; | |
76 | + } | |
77 | + else | |
78 | + { | |
79 | + $retval[$name2] = "<li>$link_tag</li>"; | |
80 | + } | |
81 | + } | |
82 | + } | |
83 | + } | |
84 | + | |
85 | + if($non_format) | |
86 | + return $retval; | |
87 | + | |
88 | + $retval = list_sort($retval); | |
89 | + | |
90 | + if(count($retval) && !$non_format) | |
91 | + { | |
92 | + $retvals = "<ul>\n" . join("\n",$retval) . "</ul>\n<br>\n"; | |
93 | + | |
94 | + if($type=="AND") | |
95 | + $retvals.= str_replace('$1',$result_word,str_replace('$2',count($retval),str_replace('$3',$cnt,$_msg_andresult))); | |
96 | + else | |
97 | + $retvals.= str_replace('$1',$result_word,str_replace('$2',count($retval),str_replace('$3',$cnt,$_msg_orresult))); | |
98 | + | |
99 | + } | |
100 | + else | |
101 | + $retvals .= str_replace('$1',$result_word,$_msg_notfoundresult); | |
102 | + return $retvals; | |
103 | +} | |
104 | + | |
105 | +// プログラムへの引数のチェック | |
106 | +function arg_check($str) | |
107 | +{ | |
108 | + global $arg,$vars; | |
109 | + | |
110 | + return preg_match("/^".$str."/",$vars["cmd"]); | |
111 | +} | |
112 | + | |
113 | +// ページリストのソート | |
114 | +function list_sort($values) | |
115 | +{ | |
116 | + if(!is_array($values)) return array(); | |
117 | + | |
118 | + // ksortのみだと、[[日本語]]、[[英文字]]、英文字のみ、に順に並べ替えられる | |
119 | + ksort($values); | |
120 | + | |
121 | + $vals1 = array(); | |
122 | + $vals2 = array(); | |
123 | + $vals3 = array(); | |
124 | + | |
125 | + // 英文字のみ、[[英文字]]、[[日本語]]、の順に並べ替える | |
126 | + foreach($values as $key => $val) | |
127 | + { | |
128 | + if(preg_match("/\[\[[^\w]+\]\]/",$key)) | |
129 | + $vals3[$key] = $val; | |
130 | + else if(preg_match("/\[\[[\W]+\]\]/",$key)) | |
131 | + $vals2[$key] = $val; | |
132 | + else | |
133 | + $vals1[$key] = $val; | |
134 | + } | |
135 | + return array_merge($vals1,$vals2,$vals3); | |
136 | +} | |
137 | + | |
138 | +// ページ名のエンコード | |
139 | +function encode($key) | |
140 | +{ | |
141 | + $enkey = ''; | |
142 | + $arych = preg_split("//", $key, -1, PREG_SPLIT_NO_EMPTY); | |
143 | + | |
144 | + foreach($arych as $ch) | |
145 | + { | |
146 | + $enkey .= sprintf("%02X", ord($ch)); | |
147 | + } | |
148 | + | |
149 | + return $enkey; | |
150 | +} | |
151 | + | |
152 | +// ファイル名のデコード | |
153 | +function decode($key) | |
154 | +{ | |
155 | + $dekey = ''; | |
156 | + | |
157 | + for($i=0;$i<strlen($key);$i+=2) | |
158 | + { | |
159 | + $ch = substr($key,$i,2); | |
160 | + $dekey .= chr(intval("0x".$ch,16)); | |
161 | + } | |
162 | + return urldecode($dekey); | |
163 | +} | |
164 | + | |
165 | +// InterWikiName List の解釈(返値:2次元配列) | |
166 | +function open_interwikiname_list() | |
167 | +{ | |
168 | + global $interwiki; | |
169 | + | |
170 | + $retval = array(); | |
171 | + $aryinterwikiname = get_source($interwiki); | |
172 | + | |
173 | + $cnt = 0; | |
174 | + foreach($aryinterwikiname as $line) | |
175 | + { | |
176 | + if(preg_match("/\[((https?|ftp|news)(\:\/\/[[:alnum:]\+\$\;\?\.%,!#~\*\/\:@&=_\-]+))\s([^\]]+)\]\s?([^\s]*)/",$line,$match)) | |
177 | + { | |
178 | + $retval[$match[4]]["url"] = $match[1]; | |
179 | + $retval[$match[4]]["opt"] = $match[5]; | |
180 | + } | |
181 | + } | |
182 | + | |
183 | + return $retval; | |
184 | +} | |
185 | + | |
186 | +// [[ ]] を取り除く | |
187 | +function strip_bracket($str) | |
188 | +{ | |
189 | + global $strip_link_wall; | |
190 | + | |
191 | + if($strip_link_wall) | |
192 | + { | |
193 | + preg_match("/^\[\[(.*)\]\]$/",$str,$match); | |
194 | + if($match[1]) | |
195 | + $str = $match[1]; | |
196 | + } | |
197 | + return $str; | |
198 | +} | |
199 | + | |
200 | +// テキスト整形ルールを表示する | |
201 | +function catrule() | |
202 | +{ | |
203 | + global $rule_body; | |
204 | + return $rule_body; | |
205 | +} | |
206 | + | |
207 | +// エラーメッセージを表示する | |
208 | +function die_message($msg) | |
209 | +{ | |
210 | + $title = $page = "Runtime error"; | |
211 | + | |
212 | + $body = "<h3>Runtime error</h3>\n"; | |
213 | + $body .= "<b>Error message : $msg</b>\n"; | |
214 | + | |
215 | + catbody($title,$page,$body); | |
216 | + | |
217 | + die(); | |
218 | +} | |
219 | + | |
220 | +// 現在時刻をマイクロ秒で取得 | |
221 | +function getmicrotime() | |
222 | +{ | |
223 | + list($usec, $sec) = explode(" ",microtime()); | |
224 | + return ((float)$sec + (float)$usec); | |
225 | +} | |
226 | + | |
227 | +// 差分の作成 | |
228 | +function do_diff($strlines1,$strlines2) | |
229 | +{ | |
230 | + $lines1 = split("\n",$strlines1); | |
231 | + $lines2 = split("\n",$strlines2); | |
232 | + | |
233 | + $same_lines = $diff_lines = $del_lines = $add_lines = $retdiff = array(); | |
234 | + | |
235 | + if(count($lines1) > count($lines2)) { $max_line = count($lines1)+2; } | |
236 | + else { $max_line = count($lines2)+2; } | |
237 | + | |
238 | + //$same_lines = array_intersect($lines1,$lines2); | |
239 | + | |
240 | + $diff_lines2 = array_diff($lines2,$lines1); | |
241 | + $diff_lines = array_merge($diff_lines2,array_diff($lines1,$lines2)); | |
242 | + | |
243 | + foreach($diff_lines as $line) | |
244 | + { | |
245 | + $index = array_search($line,$lines1); | |
246 | + if($index > -1) | |
247 | + { | |
248 | + $del_lines[$index] = $line; | |
249 | + } | |
250 | + | |
251 | + //$index = array_search($line,$lines2); | |
252 | + //if($index > -1) | |
253 | + //{ | |
254 | + // $add_lines[$index] = $line; | |
255 | + //} | |
256 | + } | |
257 | + | |
258 | + $cnt=0; | |
259 | + foreach($lines2 as $line) | |
260 | + { | |
261 | + $line = rtrim($line); | |
262 | + | |
263 | + while($del_lines[$cnt]) | |
264 | + { | |
265 | + $retdiff[] = "- ".$del_lines[$cnt]; | |
266 | + $del_lines[$cnt] = ""; | |
267 | + $cnt++; | |
268 | + } | |
269 | + | |
270 | + if(in_array($line,$diff_lines)) | |
271 | + { | |
272 | + $retdiff[] = "+ $line"; | |
273 | + } | |
274 | + else | |
275 | + { | |
276 | + $retdiff[] = " $line"; | |
277 | + } | |
278 | + | |
279 | + $cnt++; | |
280 | + } | |
281 | + | |
282 | + foreach($del_lines as $line) | |
283 | + { | |
284 | + if(trim($line)) | |
285 | + $retdiff[] = "- $line"; | |
286 | + } | |
287 | + | |
288 | + return join("\n",$retdiff); | |
289 | +} | |
290 | + | |
291 | + | |
292 | +// 差分の作成 | |
293 | +function do_update_diff($oldstr,$newstr) | |
294 | +{ | |
295 | + $oldlines = split("\n",$oldstr); | |
296 | + $newlines = split("\n",$newstr); | |
297 | + | |
298 | + $retdiff = $props = array(); | |
299 | + $auto = true; | |
300 | + | |
301 | + foreach($newlines as $newline) { | |
302 | + $flg = false; | |
303 | + $cnt = 0; | |
304 | + foreach($oldlines as $oldline) { | |
305 | + if($oldline == $newline) { | |
306 | + if($cnt>0) { | |
307 | + for($i=0; $i<$cnt; ++$i) { | |
308 | + array_push($retdiff,array_shift($oldlines)); | |
309 | + array_push($props,'! '); | |
310 | + $auto = false; | |
311 | + } | |
312 | + } | |
313 | + array_push($retdiff,array_shift($oldlines)); | |
314 | + array_push($props,''); | |
315 | + $flg = true; | |
316 | + break; | |
317 | + } | |
318 | + $cnt++; | |
319 | + } | |
320 | + if(!$flg) { | |
321 | + array_push($retdiff,$newline); | |
322 | + array_push($props,'+ '); | |
323 | + } | |
324 | + } | |
325 | + foreach($oldlines as $oldline) { | |
326 | + array_push($retdiff,$oldline); | |
327 | + array_push($props,'! '); | |
328 | + $auto = false; | |
329 | + } | |
330 | + if($auto) { | |
331 | + return array(join("\n",$retdiff),$auto); | |
332 | + } | |
333 | + | |
334 | + $ret = ''; | |
335 | + foreach($retdiff as $line) { | |
336 | + $ret .= array_shift($props) . $line . "\n"; | |
337 | + } | |
338 | + return array($ret,$auto); | |
339 | +} | |
340 | +?> |
@@ -0,0 +1,760 @@ | ||
1 | +<? | |
2 | +// PukiWiki - Yet another WikiWikiWeb clone. | |
3 | +// $Id: html.php,v 1.1 2002/06/21 05:21:46 masui Exp $ | |
4 | +///////////////////////////////////////////////// | |
5 | + | |
6 | +// 本文をページ名から出力 | |
7 | +function catbodyall($page,$title="",$pg="") | |
8 | +{ | |
9 | + if($title === "") $title = strip_bracket($page); | |
10 | + if($pg === "") $pg = make_search($page); | |
11 | + | |
12 | + $body = join("",get_source($page)); | |
13 | + $body = convert_html($body); | |
14 | + | |
15 | + header_lastmod($vars["page"]); | |
16 | + catbody($title,$pg,$body); | |
17 | + die(); | |
18 | +} | |
19 | + | |
20 | +// 本文を出力 | |
21 | +function catbody($title,$page,$body) | |
22 | +{ | |
23 | + global $script,$vars,$arg,$do_backup,$modifier,$modifierlink,$defaultpage,$whatsnew,$hr; | |
24 | + global $date_format,$weeklabels,$time_format,$longtaketime,$related_link; | |
25 | + global $HTTP_SERVER_VARS,$cantedit; | |
26 | + | |
27 | + if($vars["page"] && !arg_check("backup") && $vars["page"] != $whatsnew) | |
28 | + { | |
29 | + $is_page = 1; | |
30 | + } | |
31 | + | |
32 | + $link_add = "$script?cmd=add&page=".rawurlencode($vars["page"]); | |
33 | + $link_edit = "$script?cmd=edit&page=".rawurlencode($vars["page"]); | |
34 | + $link_diff = "$script?cmd=diff&page=".rawurlencode($vars["page"]); | |
35 | + $link_top = "$script?$defaultpage"; | |
36 | + $link_list = "$script?cmd=list"; | |
37 | + $link_filelist = "$script?cmd=filelist"; | |
38 | + $link_search = "$script?cmd=search"; | |
39 | + $link_whatsnew = "$script?$whatsnew"; | |
40 | + $link_backup = "$script?cmd=backup&page=".rawurlencode($vars["page"]); | |
41 | + $link_help = "$script?cmd=help"; | |
42 | + | |
43 | + if(is_page($vars["page"]) && $is_page) | |
44 | + { | |
45 | + $fmt = @filemtime(get_filename(encode($vars["page"]))); | |
46 | + } | |
47 | + | |
48 | + if(is_page($vars["page"]) && $related_link && $is_page && !arg_check("edit") && !arg_check("freeze") && !arg_check("unfreeze")) | |
49 | + { | |
50 | + $related = make_related($vars["page"],false); | |
51 | + } | |
52 | + | |
53 | + if(is_page($vars["page"]) && !in_array($vars["page"],$cantedit) && !arg_check("backup") && !arg_check("edit") && !$vars["preview"]) | |
54 | + { | |
55 | + $is_read = TRUE; | |
56 | + } | |
57 | + | |
58 | + //if(!$longtaketime) | |
59 | + $longtaketime = getmicrotime() - MUTIME; | |
60 | + $taketime = sprintf("%01.03f",$longtaketime); | |
61 | + | |
62 | + require(SKIN_FILE); | |
63 | +} | |
64 | + | |
65 | +// テキスト本体をHTMLに変換する | |
66 | +function convert_html($string) | |
67 | +{ | |
68 | + global $result,$saved,$hr,$script,$page,$vars,$top; | |
69 | + global $note_id,$foot_explain,$digest,$note_hr; | |
70 | + global $user_rules,$str_rules,$line_rules,$strip_link_wall; | |
71 | + | |
72 | + global $longtaketime; | |
73 | + | |
74 | + $string = rtrim($string); | |
75 | + $string = preg_replace("/(\x0D\x0A)/","\n",$string); | |
76 | + $string = preg_replace("/(\x0D)/","\n",$string); | |
77 | + $string = preg_replace("/(\x0A)/","\n",$string); | |
78 | + | |
79 | + $start_mtime = getmicrotime(); | |
80 | + | |
81 | + $digest = md5(@join("",get_source($vars["page"]))); | |
82 | + | |
83 | + $content_id = 0; | |
84 | + $user_rules = array_merge($str_rules,$line_rules); | |
85 | + | |
86 | + $result = array(); | |
87 | + $saved = array(); | |
88 | + $arycontents = array(); | |
89 | + | |
90 | + $string = preg_replace("/^#freeze\n/","",$string); | |
91 | + | |
92 | + $lines = split("\n", $string); | |
93 | + $note_id = 1; | |
94 | + $foot_explain = array(); | |
95 | + | |
96 | + $table = 0; | |
97 | + | |
98 | + if(preg_match("/#contents/",$string)) | |
99 | + $top_link = "<a href=\"#contents\">$top</a>"; | |
100 | + | |
101 | + foreach ($lines as $line) | |
102 | + { | |
103 | + if(!preg_match("/^\/\/(.*)/",$line,$comment_out) && $table != 0) | |
104 | + { | |
105 | + if(!preg_match("/^\|(.+)\|$/",$line,$out)) | |
106 | + array_push($result, "</table>"); | |
107 | + if(!$out[1] || $table != count(explode("|",$out[1]))) | |
108 | + $table = 0; | |
109 | + } | |
110 | + | |
111 | + $comment_out = $comment_out[1]; | |
112 | + | |
113 | + if(preg_match("/^(\*{1,3})(.*)/",$line,$out)) | |
114 | + { | |
115 | + $result = array_merge($result,$saved); $saved = array(); | |
116 | + $str = inline($out[2]); | |
117 | + | |
118 | + $level = strlen($out[1]) + 1; | |
119 | + | |
120 | + array_push($result, "<h$level><a name=\"content:$content_id\">$str</a> $top_link</h$level>"); | |
121 | + $arycontents[] = str_repeat("-",$level-1)."<a href=\"#content:$content_id\">".strip_htmltag($str)."</a>\n"; | |
122 | + $content_id++; | |
123 | + } | |
124 | + else if(preg_match("/^(-{1,4})(.*)/",$line,$out)) | |
125 | + { | |
126 | + if(strlen($out[1]) == 4) | |
127 | + { | |
128 | + $result = array_merge($result,$saved); $saved = array(); | |
129 | + array_push($result, $hr); | |
130 | + } | |
131 | + else | |
132 | + { | |
133 | + back_push('ul', strlen($out[1])); | |
134 | + array_push($result, '<li>' . inline($out[2]) . '</li>'); | |
135 | + } | |
136 | + } | |
137 | + else if (preg_match("/^:([^:]+):(.*)/",$line,$out)) | |
138 | + { | |
139 | + back_push('dl', 1); | |
140 | + array_push($result, '<dt>' . inline($out[1]) . '</dt>', '<dd>' . inline($out[2]) . '</dd>'); | |
141 | + } | |
142 | + else if(preg_match("/^(>{1,3})(.*)/",$line,$out)) | |
143 | + { | |
144 | + back_push('blockquote', strlen($out[1])); | |
145 | + array_push($result, ltrim(inline($out[2]))); | |
146 | + } | |
147 | + else if (preg_match("/^\s*$/",$line,$out)) | |
148 | + { | |
149 | + $result = array_merge($result,$saved); $saved = array(); | |
150 | + //array_unshift($saved, "</p>"); | |
151 | + array_push($result, "<p>"); | |
152 | + } | |
153 | + else if(preg_match("/^(\s+.*)/",$line,$out)) | |
154 | + { | |
155 | + back_push('pre', 1); | |
156 | + array_push($result, htmlspecialchars($out[1],ENT_NOQUOTES)); | |
157 | + } | |
158 | + else if(preg_match("/^\|(.+)\|$/",$line,$out)) | |
159 | + { | |
160 | + $arytable = explode("|",$out[1]); | |
161 | + | |
162 | + if(!$table) | |
163 | + { | |
164 | + $result = array_merge($result,$saved); $saved = array(); | |
165 | + array_push($result,"<table class=\"style_table\" cellspacing=\"1\" border=\"0\">"); | |
166 | + $table = count($arytable); | |
167 | + } | |
168 | + | |
169 | + array_push($result,"<tr>"); | |
170 | + foreach($arytable as $td) | |
171 | + { | |
172 | + array_push($result,"<td class=\"style_td\">"); | |
173 | + array_push($result,ltrim(inline($td))); | |
174 | + array_push($result,"</td>"); | |
175 | + } | |
176 | + array_push($result,"</tr>"); | |
177 | + | |
178 | + } | |
179 | + else if(strlen($comment_out) != 0) | |
180 | + { | |
181 | + array_push($result," <!-- ".htmlspecialchars($comment_out)." -->"); | |
182 | + } | |
183 | + else | |
184 | + { | |
185 | + array_push($result, inline($line)); | |
186 | + } | |
187 | + } | |
188 | + if($table) array_push($result, "</table>"); | |
189 | + | |
190 | + $result_last = $result = array_merge($result,$saved); $saved = array(); | |
191 | + | |
192 | + if($content_id != 0) | |
193 | + { | |
194 | + $result = array(); | |
195 | + $saved = array(); | |
196 | + | |
197 | + foreach($arycontents as $line) | |
198 | + { | |
199 | + if(preg_match("/^(-{1,3})(.*)/",$line,$out)) | |
200 | + { | |
201 | + back_push('ul', strlen($out[1])); | |
202 | + array_push($result, '<li>'.$out[2].'</li>'); | |
203 | + } | |
204 | + } | |
205 | + $result = array_merge($result,$saved); $saved = array(); | |
206 | + | |
207 | + $contents = "<a name=\"contents\"></a>\n"; | |
208 | + $contents .= join("\n",$result); | |
209 | + if($strip_link_wall) | |
210 | + { | |
211 | + $contents = preg_replace("/\[\[([^\]]+)\]\]/","$1",$contents); | |
212 | + } | |
213 | + } | |
214 | + | |
215 | + $result_last = inline2($result_last); | |
216 | + | |
217 | + $result_last = preg_replace("/^#contents/",$contents,$result_last); | |
218 | + | |
219 | + $str = join("\n", $result_last); | |
220 | + | |
221 | + if($foot_explain) | |
222 | + { | |
223 | + $str .= "\n"; | |
224 | + $str .= "$note_hr\n"; | |
225 | + //$str .= "<p>\n"; | |
226 | + $str .= join("\n",inline2($foot_explain)); | |
227 | + //$str .= "</p>\n"; | |
228 | + } | |
229 | + | |
230 | + $longtaketime = getmicrotime() - $start_mtime; | |
231 | + | |
232 | + $str = preg_replace("/&((amp)|(quot)|(nbsp)|(lt)|(gt));/","&$1;",$str); | |
233 | + | |
234 | + return $str; | |
235 | +} | |
236 | + | |
237 | +// $tagのタグを$levelレベルまで詰める。 | |
238 | +function back_push($tag, $level) | |
239 | +{ | |
240 | + global $result,$saved; | |
241 | + | |
242 | + while (count($saved) > $level) { | |
243 | + array_push($result, array_shift($saved)); | |
244 | + } | |
245 | + if ($saved[0] != "</$tag>") { | |
246 | + $result = array_merge($result,$saved); $saved = array(); | |
247 | + } | |
248 | + while (count($saved) < $level) { | |
249 | + array_unshift($saved, "</$tag>"); | |
250 | + array_push($result, "<$tag>"); | |
251 | + } | |
252 | +} | |
253 | + | |
254 | +// リンクの付加その他 | |
255 | +function inline($line) | |
256 | +{ | |
257 | + $line = htmlspecialchars($line); | |
258 | + | |
259 | + $line = preg_replace("/( | |
260 | + | |
261 | + (\(\(([^\(\)]+)\)\)) | |
262 | + | | |
263 | + (\(\((.+)\)\)) | |
264 | + | |
265 | + )/ex","make_note(\"$1\")",$line); | |
266 | + | |
267 | + return $line; | |
268 | +} | |
269 | + | |
270 | +// リンクの付加その他2 | |
271 | +function inline2($str) | |
272 | +{ | |
273 | + global $WikiName,$BracketName,$InterWikiName,$vars,$related,$related_link,$script; | |
274 | + $cnts_plain = array(); | |
275 | + $cnts_plugin = array(); | |
276 | + $arykeep = array(); | |
277 | + | |
278 | + for($cnt=0;$cnt<count($str);$cnt++) | |
279 | + { | |
280 | + if(preg_match("/^(\s)/",$str[$cnt])) | |
281 | + { | |
282 | + $arykeep[$cnt] = $str[$cnt]; | |
283 | + $str[$cnt] = ""; | |
284 | + $cnts_plain[] = $cnt; | |
285 | + } | |
286 | + else if(preg_match("/^\#([^\(]+)\(?(.*)\)?$/",$str[$cnt],$match)) | |
287 | + { | |
288 | + if(exist_plugin_convert($match[1])) { | |
289 | + $aryplugins[$cnt] = $str[$cnt]; | |
290 | + $str[$cnt] = ""; | |
291 | + $cnts_plugin[] = $cnt; | |
292 | + } | |
293 | + } | |
294 | + } | |
295 | + | |
296 | + $str = preg_replace("/'''([^']+?)'''/s","<i>$1</i>",$str); // Italic | |
297 | + | |
298 | + $str = preg_replace("/''([^']+?)''/s","<b>$1</b>",$str); // Bold | |
299 | + | |
300 | + $str = preg_replace("/ | |
301 | + ( | |
302 | + (\[\[([^\]]+)\:(https?|ftp|news)(:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)\]\]) | |
303 | + | | |
304 | + (\[(https?|ftp|news)(:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)\s([^\]]+)\]) | |
305 | + | | |
306 | + (https?|ftp|news)(:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+) | |
307 | + | | |
308 | + ([[:alnum:]\-_.]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+) | |
309 | + | | |
310 | + (\[\[([^\]]+)\:([[:alnum:]\-_.]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+)\]\]) | |
311 | + | | |
312 | + ($InterWikiName) | |
313 | + | | |
314 | + ($BracketName) | |
315 | + | | |
316 | + ($WikiName) | |
317 | + )/ex","make_link('$1')",$str); | |
318 | + | |
319 | + $str = preg_replace("/#related/",make_related($vars["page"],true),$str); | |
320 | + | |
321 | + $str = make_user_rules($str); | |
322 | + | |
323 | + $aryplugins = preg_replace("/^\#([^\(]+)$/ex","do_plugin_convert('$1','$2')",$aryplugins); | |
324 | + $aryplugins = preg_replace("/^\#([^\(]+)\((.*)\)$/ex","do_plugin_convert('$1','$2')",$aryplugins); | |
325 | + | |
326 | + $tmp = $str; | |
327 | + $str = preg_replace("/^#norelated$/","",$str); | |
328 | + if($tmp != $str) | |
329 | + $related_link = 0; | |
330 | + | |
331 | + foreach($cnts_plain as $cnt) | |
332 | + $str[$cnt] = $arykeep[$cnt]; | |
333 | + | |
334 | + foreach($cnts_plugin as $cnt) | |
335 | + $str[$cnt] = $aryplugins[$cnt]; | |
336 | + | |
337 | + return $str; | |
338 | +} | |
339 | + | |
340 | +// 一覧の取得 | |
341 | +function get_list($withfilename) | |
342 | +{ | |
343 | + global $script,$list_index,$top,$non_list,$whatsnew; | |
344 | + global $_msg_symbol,$_msg_other; | |
345 | + | |
346 | + $retval = array(); | |
347 | + $files = get_existpages(); | |
348 | + foreach($files as $page) { | |
349 | + if(preg_match("/$non_list/",$page) && !$withfilename) continue; | |
350 | + if($page == $whatsnew) continue; | |
351 | + $page_url = rawurlencode($page); | |
352 | + $page2 = strip_bracket($page); | |
353 | + $pg_passage = get_pg_passage($page); | |
354 | + $retval[$page2] .= "<li><a href=\"$script?$page_url\">$page2</a>$pg_passage</li>\n"; | |
355 | + if($withfilename) | |
356 | + { | |
357 | + $retval[$page2] .= "<ul><li>$file</li></ul>\n"; | |
358 | + } | |
359 | + } | |
360 | + | |
361 | + $retval = list_sort($retval); | |
362 | + | |
363 | + if($list_index) | |
364 | + { | |
365 | + $head_str = ""; | |
366 | + $etc_sw = 0; | |
367 | + $symbol_sw = 0; | |
368 | + $top_link = ""; | |
369 | + foreach($retval as $page => $link) | |
370 | + { | |
371 | + $head = substr($page,0,1); | |
372 | + if($head_str != $head && !$etc_sw) | |
373 | + { | |
374 | + $retval2[$page] = ""; | |
375 | + | |
376 | + if(preg_match("/([A-Z])|([a-z])/",$head,$match)) | |
377 | + { | |
378 | + if($match[1]) | |
379 | + $head_nm = "High:$head"; | |
380 | + else | |
381 | + $head_nm = "Low:$head"; | |
382 | + | |
383 | + if($head_str) $retval2[$page] = "</ul>\n"; | |
384 | + $retval2[$page] .= "<li><a href=\"#top:$head_nm\" name=\"$head_nm\"><b>$head</b></a></li>\n<ul>\n"; | |
385 | + $head_str = $head; | |
386 | + if($top_link) $top_link .= "|"; | |
387 | + $top_link .= "<a href=\"#$head_nm\" name=\"top:$head_nm\"><b> ".$head." </b></a>"; | |
388 | + } | |
389 | + else if(preg_match("/[ -~]/",$head)) | |
390 | + { | |
391 | + if(!$symbol_sw) | |
392 | + { | |
393 | + if($head_str) $retval2[$page] = "</ul>\n"; | |
394 | + $retval2[$page] .= "<li><a href=\"#top:symbol\" name=\"symbol\"><b>$_msg_symbol</b></a></li>\n<ul>\n"; | |
395 | + $head_str = $head; | |
396 | + if($top_link) $top_link .= "|"; | |
397 | + $top_link .= "<a href=\"#symbol\" name=\"top:symbol\"><b>$_msg_symbol</b></a>"; | |
398 | + $symbol_sw = 1; | |
399 | + } | |
400 | + } | |
401 | + else | |
402 | + { | |
403 | + if($head_str) $retval2[$page] = "</ul>\n"; | |
404 | + $retval2[$page] .= "<li><a href=\"#top:etc\" name=\"etc\"><b>$_msg_other</b></a></li>\n<ul>\n"; | |
405 | + $etc_sw = 1; | |
406 | + if($top_link) $top_link .= "|"; | |
407 | + $top_link .= "<a href=\"#etc\" name=\"top:etc\"><b>$_msg_other</b></a>"; | |
408 | + } | |
409 | + } | |
410 | + $retval2[$page] .= $link; | |
411 | + } | |
412 | + $retval2[] = "</ul>\n"; | |
413 | + | |
414 | + $top_link = "<div align=\"center\"><a name=\"top\">$top_link</a></div><br>\n"; | |
415 | + | |
416 | + array_unshift($retval2,$top_link); | |
417 | + } | |
418 | + else | |
419 | + { | |
420 | + $retval2 = $retval; | |
421 | + } | |
422 | + | |
423 | + return join("",$retval2); | |
424 | +} | |
425 | + | |
426 | +// 編集フォームの表示 | |
427 | +function edit_form($postdata,$page,$add=0) | |
428 | +{ | |
429 | + global $script,$rows,$cols,$hr,$vars,$function_freeze; | |
430 | + global $_btn_addtop,$_btn_preview,$_btn_update,$_btn_freeze,$_msg_help,$_btn_notchangetimestamp; | |
431 | + global $whatsnew,$_btn_template,$_btn_load,$non_list,$load_template_func; | |
432 | + | |
433 | + $digest = md5(@join("",get_source($page))); | |
434 | + | |
435 | + if($add) | |
436 | + { | |
437 | + $addtag = '<input type="hidden" name="add" value="true">'; | |
438 | + $add_top = '<input type="checkbox" name="add_top" value="true"><small>'.$_btn_addtop.'</small>'; | |
439 | + } | |
440 | + | |
441 | + if($vars["help"] == "true") | |
442 | + $help = $hr.catrule(); | |
443 | + else | |
444 | + $help = "<br>\n<ul><li><a href=\"$script?cmd=edit&help=true&page=".rawurlencode($page)."\">$_msg_help</a></ul></li>\n"; | |
445 | + | |
446 | + if($function_freeze) | |
447 | + $str_freeze = '<input type="submit" name="freeze" value="'.$_btn_freeze.'" accesskey="f">'; | |
448 | + | |
449 | + if($load_template_func) | |
450 | + { | |
451 | + $vals = array(); | |
452 | + | |
453 | + $files = get_existpages(); | |
454 | + foreach($files as $pg_org) { | |
455 | + if($pg_org == $whatsnew) continue; | |
456 | + if(preg_match("/$non_list/",$pg_org)) continue; | |
457 | + $name = strip_bracket($pg_org); | |
458 | + $vals[$name] = " <option value=\"$pg_org\">$name</option>"; | |
459 | + } | |
460 | + @ksort($vals); | |
461 | + | |
462 | + $template = " <select name=\"template_page\">\n" | |
463 | + ." <option value=\"\">-- $_btn_template --</option>\n" | |
464 | + .join("\n",$vals) | |
465 | + ." </select>\n" | |
466 | + ." <input type=\"submit\" name=\"template\" value=\"$_btn_load\" accesskey=\"r\"><br>\n"; | |
467 | + | |
468 | + if($vars["refer"]) $refer = $vars["refer"]."\n\n"; | |
469 | + } | |
470 | + | |
471 | +return ' | |
472 | +<form action="'.$script.'" method="post"> | |
473 | +<input type="hidden" name="page" value="'.$page.'"> | |
474 | +<input type="hidden" name="digest" value="'.$digest.'"> | |
475 | +'.$addtag.' | |
476 | +<table cellspacing="3" cellpadding="0" border="0"> | |
477 | + <tr> | |
478 | + <td colspan="2" align="right"> | |
479 | +'.$template.' | |
480 | + </td> | |
481 | + </tr> | |
482 | + <tr> | |
483 | + <td colspan="2" align="right"> | |
484 | + <textarea name="msg" rows="'.$rows.'" cols="'.$cols.'" wrap="virtual"> | |
485 | +'.htmlspecialchars($refer.$postdata).'</textarea> | |
486 | + </td> | |
487 | + </tr> | |
488 | + <tr> | |
489 | + <td> | |
490 | + <input type="submit" name="preview" value="'.$_btn_preview.'" accesskey="p"> | |
491 | + <input type="submit" name="write" value="'.$_btn_update.'" accesskey="s"> | |
492 | + '.$add_top.' | |
493 | + <input type="checkbox" name="notimestamp" value="true"><small>'.$_btn_notchangetimestamp.'</small> | |
494 | + </td> | |
495 | + </form> | |
496 | + <form action="'.$script.'?cmd=freeze" method="post"> | |
497 | + <input type="hidden" name="page" value="'.$vars["page"].'"> | |
498 | + <td align="right"> | |
499 | + '.$str_freeze.' | |
500 | + </td> | |
501 | + </form> | |
502 | + </tr> | |
503 | +</table> | |
504 | +' . $help; | |
505 | +} | |
506 | + | |
507 | +// 関連するページ | |
508 | +function make_related($page,$_isrule) | |
509 | +{ | |
510 | + global $related_str,$rule_related_str,$related,$_make_related,$vars; | |
511 | + | |
512 | + $page_name = strip_bracket($vars["page"]); | |
513 | + | |
514 | + if(!is_array($_make_related)) | |
515 | + { | |
516 | + $aryrelated = do_search($page,"OR",1); | |
517 | + | |
518 | + if(is_array($aryrelated)) | |
519 | + { | |
520 | + foreach($aryrelated as $key => $val) | |
521 | + { | |
522 | + $new_arylerated[$key.md5($val)] = $val; | |
523 | + } | |
524 | + } | |
525 | + | |
526 | + if(is_array($related)) | |
527 | + { | |
528 | + foreach($related as $key => $val) | |
529 | + { | |
530 | + $new_arylerated[$key.md5($val)] = $val; | |
531 | + } | |
532 | + } | |
533 | + | |
534 | + @krsort($new_arylerated); | |
535 | + $_make_related = @array_unique($new_arylerated); | |
536 | + } | |
537 | + | |
538 | + if($_isrule) | |
539 | + { | |
540 | + if(is_array($_make_related)) | |
541 | + { | |
542 | + foreach($_make_related as $str) | |
543 | + { | |
544 | + preg_match("/<a\shref=\"([^\"]+)\">([^<]+)<\/a>(.*)/",$str,$out); | |
545 | + | |
546 | + if($out[3]) $title = " title=\"$out[2] $out[3]\""; | |
547 | + | |
548 | + $aryret[$out[2]] = "<a href=\"$out[1]\"$title>$out[2]</a>"; | |
549 | + } | |
550 | + @ksort($aryret); | |
551 | + } | |
552 | + } | |
553 | + else | |
554 | + { | |
555 | + $aryret = $_make_related; | |
556 | + } | |
557 | + | |
558 | + if($_isrule) $str = $rule_related_str; | |
559 | + else $str = $related_str; | |
560 | + | |
561 | + return @join($str,$aryret); | |
562 | +} | |
563 | + | |
564 | +// 注釈処理 | |
565 | +function make_note($str) | |
566 | +{ | |
567 | + global $note_id,$foot_explain; | |
568 | + | |
569 | + $str = preg_replace("/^\(\(/","",$str); | |
570 | + $str = preg_replace("/\)\)$/","",$str); | |
571 | + | |
572 | + $str= str_replace("\\'","'",$str); | |
573 | + | |
574 | + $str = make_user_rules($str); | |
575 | + | |
576 | + $foot_explain[] = "<a name=\"notefoot:$note_id\" href=\"#notetext:$note_id\"><sup><small>*$note_id</small></sup></a> <small>$str</small><br />\n"; | |
577 | + $note = "<a name=\"notetext:$note_id\" href=\"#notefoot:$note_id\"><sup><small>*$note_id</small></sup></a>"; | |
578 | + $note_id++; | |
579 | + | |
580 | + return $note; | |
581 | +} | |
582 | + | |
583 | +// リンクを付加する | |
584 | +function make_link($name) | |
585 | +{ | |
586 | + global $BracketName,$WikiName,$InterWikiName,$script,$link_target,$interwiki_target; | |
587 | + global $related,$show_passage,$vars,$defaultpage; | |
588 | + | |
589 | + $aryconv_htmlspecial = array("&","<",">"); | |
590 | + $aryconv_html = array("&","<",">"); | |
591 | + | |
592 | + $page = $name; | |
593 | + | |
594 | + if(preg_match("/^\[\[([^\]]+)\:((https?|ftp|news)([^\]]+))\]\]$/",$name,$match)) | |
595 | + { | |
596 | + $match[2] = str_replace($aryconv_htmlspecial,$aryconv_html,$match[2]); | |
597 | + return "<a href=\"$match[2]\" target=\"$link_target\">$match[1]</a>"; | |
598 | + } | |
599 | + else if(preg_match("/^\[((https?|ftp|news)([^\]\s]+))\s([^\]]+)\]$/",$name,$match)) | |
600 | + { | |
601 | + $match[1] = str_replace($aryconv_htmlspecial,$aryconv_html,$match[1]); | |
602 | + return "<a href=\"$match[1]\" target=\"$link_target\">$match[4]</a>"; | |
603 | + } | |
604 | + else if(preg_match("/^(https?|ftp|news).*?(\.gif|\.png|\.jpeg|\.jpg)?$/",$name,$match)) | |
605 | + { | |
606 | + $name = str_replace($aryconv_htmlspecial,$aryconv_html,$name); | |
607 | + if($match[2]) | |
608 | + return "<a href=\"$name\" target=\"$link_target\"><img src=\"$name\" border=\"0\"></a>"; | |
609 | + else | |
610 | + return "<a href=\"$name\" target=\"$link_target\">$page</a>"; | |
611 | + } | |
612 | + else if(preg_match("/^\[\[([^\]]+)\:([[:alnum:]\-_.]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+)\]\]/",$name,$match)) | |
613 | + { | |
614 | + $match[1] = str_replace($aryconv_htmlspecial,$aryconv_html,$match[1]); | |
615 | + $match[2] = str_replace($aryconv_htmlspecial,$aryconv_html,$match[2]); | |
616 | + | |
617 | + return "<a href=\"mailto:$match[2]\">$match[1]</a>"; | |
618 | + } | |
619 | + else if(preg_match("/^([[:alnum:]\-_]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+)/",$name)) | |
620 | + { | |
621 | + $name = str_replace($aryconv_htmlspecial,$aryconv_html,$name); | |
622 | + return "<a href=\"mailto:$name\">$page</a>"; | |
623 | + } | |
624 | + else if(preg_match("/^($InterWikiName)$/",str_replace($aryconv_htmlspecial,$aryconv_html,$name))) | |
625 | + { | |
626 | + $page = strip_bracket($page); | |
627 | + $percent_name = str_replace($aryconv_htmlspecial,$aryconv_html,$name); | |
628 | + $percent_name = rawurlencode($percent_name); | |
629 | + | |
630 | + return "<a href=\"$script?$percent_name\" target=\"$interwiki_target\">$page</a>"; | |
631 | + } | |
632 | + else if(preg_match("/^($BracketName)|($WikiName)$/",str_replace($aryconv_htmlspecial,$aryconv_html,$name))) | |
633 | + { | |
634 | + if(preg_match("/^([^>]+)>([^>]+)$/",strip_bracket(str_replace($aryconv_htmlspecial,$aryconv_html,$name)),$match)) | |
635 | + { | |
636 | + $page = $match[1]; | |
637 | + $name = $match[2]; | |
638 | + if(!preg_match("/^($BracketName)|($WikiName)$/",$page)) | |
639 | + $page = "[[$page]]"; | |
640 | + if(!preg_match("/^($BracketName)|($WikiName)$/",$name)) | |
641 | + $name = "[[$name]]"; | |
642 | + } | |
643 | + | |
644 | + if(preg_match("/^\[\[\.\/([^\]]*)\]\]/",str_replace($aryconv_htmlspecial,$aryconv_html,$name),$match)) | |
645 | + { | |
646 | + if(!$match[1]) | |
647 | + $name = $vars["page"]; | |
648 | + else | |
649 | + $name = "[[".strip_bracket($vars[page])."/$match[1]]]"; | |
650 | + } | |
651 | + else if(preg_match("/^\[\[\..\/([^\]]+)\]\]/",str_replace($aryconv_htmlspecial,$aryconv_html,$name),$match)) | |
652 | + { | |
653 | + for($i=0;$i<substr_count($name,"../");$i++) | |
654 | + $name = preg_replace("/(.+)\/([^\/]+)$/","$1",strip_bracket($vars["page"])); | |
655 | + | |
656 | + if(!preg_match("/^($BracketName)|($WikiName)$/",$name)) | |
657 | + $name = "[[$name]]"; | |
658 | + | |
659 | + if($vars["page"]==$name) | |
660 | + $name = "[[$match[1]]]"; | |
661 | + else | |
662 | + $name = "[[".strip_bracket($name)."/$match[1]]]"; | |
663 | + } | |
664 | + else if($name == "[[../]]") | |
665 | + { | |
666 | + $name = preg_replace("/(.+)\/([^\/]+)$/","$1",strip_bracket($vars["page"])); | |
667 | + | |
668 | + if(!preg_match("/^($BracketName)|($WikiName)$/",$name)) | |
669 | + $name = "[[$name]]"; | |
670 | + if($vars["page"]==$name) | |
671 | + $name = $defaultpage; | |
672 | + } | |
673 | + | |
674 | + $page = strip_bracket($page); | |
675 | + $pagename = strip_bracket($name); | |
676 | + $percent_name = str_replace($aryconv_htmlspecial,$aryconv_html,$name); | |
677 | + $percent_name = rawurlencode($percent_name); | |
678 | + | |
679 | + $refer = rawurlencode($vars["page"]); | |
680 | + if(is_page($name)) | |
681 | + { | |
682 | + $str = get_pg_passage($name,false); | |
683 | + $tm = @filemtime(get_filename(encode($name))); | |
684 | + if($vars["page"] != $name) | |
685 | + $related[$tm] = "<a href=\"$script?$percent_name\">$pagename</a>$str"; | |
686 | + if($show_passage) | |
687 | + { | |
688 | + $str_title = "title=\"$pagename $str\""; | |
689 | + } | |
690 | + return "<a href=\"$script?$percent_name\" $str_title>$page</a>"; | |
691 | + } | |
692 | + else | |
693 | + return "<span class=\"noexists\">$page<a href=\"$script?cmd=edit&page=$percent_name&refer=$refer\">?</a></span>"; | |
694 | + } | |
695 | + else | |
696 | + { | |
697 | + return $page; | |
698 | + } | |
699 | +} | |
700 | + | |
701 | +// ユーザ定義ルール(ソースを置換する) | |
702 | +function user_rules_str($str) | |
703 | +{ | |
704 | + global $str_rules; | |
705 | + | |
706 | + $arystr = split("\n",$str); | |
707 | + | |
708 | + // 日付・時刻置換処理 | |
709 | + foreach($arystr as $str) | |
710 | + { | |
711 | + if(substr($str,0,1) != " ") | |
712 | + { | |
713 | + foreach($str_rules as $rule => $replace) | |
714 | + { | |
715 | + $str = preg_replace("/$rule/",$replace,$str); | |
716 | + } | |
717 | + } | |
718 | + $retvars[] = $str; | |
719 | + } | |
720 | + | |
721 | + return join("\n",$retvars); | |
722 | +} | |
723 | + | |
724 | +// ユーザ定義ルール(ソースは置換せずコンバート) | |
725 | +function make_user_rules($str) | |
726 | +{ | |
727 | + global $user_rules; | |
728 | + | |
729 | + foreach($user_rules as $rule => $replace) | |
730 | + { | |
731 | + $str = preg_replace("/$rule/",$replace,$str); | |
732 | + } | |
733 | + | |
734 | + return $str; | |
735 | +} | |
736 | + | |
737 | +// HTMLタグを取り除く | |
738 | +function strip_htmltag($str) | |
739 | +{ | |
740 | + //$str = preg_replace("/<a[^>]+>\?<\/a>/","",$str); | |
741 | + return preg_replace("/<[^>]+>/","",$str); | |
742 | +} | |
743 | + | |
744 | +// ページ名からページ名を検索するリンクを作成 | |
745 | +function make_search($page) | |
746 | +{ | |
747 | + global $script,$WikiName; | |
748 | + | |
749 | + $page = htmlspecialchars($page); | |
750 | + $name = strip_bracket($page); | |
751 | + $url = rawurlencode($page); | |
752 | + | |
753 | + //WikiWikiWeb like... | |
754 | + //if(preg_match("/^$WikiName$/",$page)) | |
755 | + // $name = preg_replace("/([A-Z][a-z]+)/","$1 ",$name); | |
756 | + | |
757 | + return "<a href=\"$script?cmd=search&word=$url\">$name</a> "; | |
758 | +} | |
759 | + | |
760 | +?> |
@@ -0,0 +1,103 @@ | ||
1 | +<? | |
2 | +// PukiWiki - Yet another WikiWikiWeb clone. | |
3 | +// $Id: init.php,v 1.1 2002/06/21 05:21:46 masui Exp $ | |
4 | +///////////////////////////////////////////////// | |
5 | + | |
6 | +// 設定ファイルの場所 | |
7 | +define("INI_FILE","./pukiwiki.ini.php"); | |
8 | + | |
9 | +//** 初期設定 ** | |
10 | + | |
11 | +define("S_VERSION","1.3.1(MASUI'z Edition)"); | |
12 | +define("S_COPYRIGHT","<b>\"PukiWiki\" ".S_VERSION."</b> Copyright © 2001,2002 <a href=\"mailto:sng@factage.com\">sng</a>, <a href=\"http://masui.net/pukiwiki/\">MASUI</a>. License is <a href=\"http://www.gnu.org/\">GNU/GPL</a>."); | |
13 | +define("UTIME",time()); | |
14 | +define("HTTP_USER_AGENT",$HTTP_SERVER_VARS["HTTP_USER_AGENT"]); | |
15 | +define("PHP_SELF",$HTTP_SERVER_VARS["PHP_SELF"]); | |
16 | +define("SERVER_NAME",$HTTP_SERVER_VARS["SERVER_NAME"]); | |
17 | + | |
18 | +define("MUTIME",getmicrotime()); | |
19 | + | |
20 | +$script = getenv('SCRIPT_NAME'); | |
21 | + | |
22 | +$WikiName = '([A-Z][a-z]+([A-Z][a-z]+)+)'; | |
23 | +$BracketName = '\[\[(\[*[^\s\]]+?\]*)\]\]'; | |
24 | +$InterWikiName = '\[\[(\[*[^\s\]]+?\]*):(\[*[^>\]]+?\]*)\]\]'; | |
25 | + | |
26 | +//** 入力値の整形 ** | |
27 | + | |
28 | +$post = $HTTP_POST_VARS; | |
29 | +$get = $HTTP_GET_VARS; | |
30 | + | |
31 | +if($get["page"]) $get["page"] = rawurldecode($get["page"]); | |
32 | +if($post["word"]) $post["word"] = rawurldecode($post["word"]); | |
33 | +if($get["word"]) $get["word"] = rawurldecode($get["word"]); | |
34 | +if(get_magic_quotes_gpc()) | |
35 | +{ | |
36 | + if($get["page"]) $get["page"] = stripslashes($get["page"]); | |
37 | + if($post["page"]) $post["page"] = stripslashes($post["page"]); | |
38 | + if($get["word"]) $get["word"] = stripslashes($get["word"]); | |
39 | + if($post["word"]) $post["word"] = stripslashes($post["word"]); | |
40 | + if($post["msg"]) $post["msg"] = stripslashes($post["msg"]); | |
41 | +} | |
42 | +if($post["msg"]) | |
43 | +{ | |
44 | + $post["msg"] = preg_replace("/<\/(textarea[^>]*)>/i", "</$1>", $post["msg"]); | |
45 | + $post["msg"] = preg_replace("/(\x0D\x0A)/","\n",$post["msg"]); | |
46 | + $post["msg"] = preg_replace("/(\x0D)/","\n",$post["msg"]); | |
47 | + $post["msg"] = preg_replace("/(\x0A)/","\n",$post["msg"]); | |
48 | +} | |
49 | + | |
50 | +$vars = array_merge($post,$get); | |
51 | +$arg = rawurldecode($HTTP_SERVER_VARS["argv"][0]); | |
52 | + | |
53 | +//** 初期処理 ** | |
54 | + | |
55 | +$update_exec = ""; | |
56 | + | |
57 | +// 設定ファイルの読込 | |
58 | +@require(INI_FILE); | |
59 | +@require(LANG.".lng"); | |
60 | + | |
61 | +// 設定ファイルの変数チェック | |
62 | +$wrong_ini_file = ""; | |
63 | +if(!isset($rss_max)) $wrong_ini_file .= '$rss_max '; | |
64 | +if(!isset($page_title)) $wrong_ini_file .= '$page_title '; | |
65 | +if(!isset($note_hr)) $wrong_ini_file .= '$note_hr '; | |
66 | +if(!isset($related_link)) $wrong_ini_file .= '$related_link '; | |
67 | +if(!isset($show_passage)) $wrong_ini_file .= '$show_passage '; | |
68 | +if(!isset($rule_related_str)) $wrong_ini_file .= '$rule_related_str '; | |
69 | +if(!isset($load_template_func)) $wrong_ini_file .= '$load_template_func '; | |
70 | +if(!defined("LANG")) $wrong_ini_file .= 'LANG '; | |
71 | +if(!defined("PLUGIN_DIR")) $wrong_ini_file .= 'PLUGIN_DIR '; | |
72 | + | |
73 | +if(!is_writable(DATA_DIR)) | |
74 | + die_message("DATA_DIR is not found or not writable."); | |
75 | +if(!is_writable(DIFF_DIR)) | |
76 | + die_message("DIFF_DIR is not found or not writable."); | |
77 | +if($do_backup && !is_writable(BACKUP_DIR)) | |
78 | + die_message("BACKUP_DIR is not found or not writable."); | |
79 | +if(!file_exists(INI_FILE)) | |
80 | + die_message("INI_FILE is not found."); | |
81 | +if($wrong_ini_file) | |
82 | + die_message("The setting file runs short of information.<br>The version of a setting file may be old.<br><br>These option are not found : $wrong_ini_file"); | |
83 | +//if(ini_get("register_globals") !== "0") | |
84 | +// die_message("Wrong PHP4 setting in 'register_globals',set value 'Off' to httpd.conf or .htaccess."); | |
85 | +if(!file_exists(SKIN_FILE)) | |
86 | + die_message("SKIN_FILE is not found."); | |
87 | +if(!file_exists(LANG.".lng")) | |
88 | + die_message(LANG.".lng(language file) is not found."); | |
89 | + | |
90 | +if(!file_exists(get_filename(encode($defaultpage)))) | |
91 | + touch(get_filename(encode($defaultpage))); | |
92 | +if(!file_exists(get_filename(encode($whatsnew)))) | |
93 | + touch(get_filename(encode($whatsnew))); | |
94 | +if(!file_exists(get_filename(encode($interwiki)))) | |
95 | + touch(get_filename(encode($interwiki))); | |
96 | + | |
97 | +$ins_date = date($date_format,UTIME); | |
98 | +$ins_time = date($time_format,UTIME); | |
99 | +$ins_week = "(".$weeklabels[date("w",UTIME)].")"; | |
100 | + | |
101 | +$now = "$ins_date $ins_week $ins_time"; | |
102 | + | |
103 | +?> |
@@ -39,8 +39,12 @@ $_msg_add = ' | ||
39 | 39 | $_msg_preview = '以下のプレビューを確認して、よければページ下部のボタンで更新してください。'; |
40 | 40 | $_msg_preview_delete = '(ページの内容は空です。更新するとこのページは削除されます。)'; |
41 | 41 | $_msg_collided = 'あなたがこのページを編集している間に、他の人が同じページを更新してしまったようです。<br> |
42 | -以下にあなたの編集したテキストがありますので、あなたの編集内容が失われないように<br> | |
43 | -エディタにコピー&ペーストしてください。その後で最新の内容から再度編集し直してください。'; | |
42 | +今回追加した行は +で始まっています。<br> | |
43 | +!で始まる行が変更された可能性があります。<br> | |
44 | +!や+で始まる行を修正して再度ページの更新を行ってください。<br>'; | |
45 | +$_msg_collided_auto = 'あなたがこのページを編集している間に、他の人が同じページを更新してしまったようです。<br> | |
46 | +自動で衝突を解消しましたが、問題がある可能性があります。<br> | |
47 | +確認後、[ページの更新]を押してください。<br>'; | |
44 | 48 | $_msg_freezing = '凍結用のパスワードを入力してください。'; |
45 | 49 | $_msg_unfreezing = '凍結解除用のパスワードを入力してください。'; |
46 | 50 | $_msg_invalidpass = 'パスワードが間違っています。'; |
@@ -78,6 +82,7 @@ $_btn_notchangetimestamp = ' | ||
78 | 82 | $_btn_addtop = 'ページの上に追加'; |
79 | 83 | $_btn_template = '雛形とするページ'; |
80 | 84 | $_btn_load = '読込'; |
85 | +$_btn_edit = '編集'; | |
81 | 86 | |
82 | 87 | /////////////////////////////////////// |
83 | 88 | // plug-in message |
@@ -86,6 +91,10 @@ $_btn_load = ' | ||
86 | 91 | // comment |
87 | 92 | $_btn_name = 'お名前: '; |
88 | 93 | $_btn_comment = 'コメントの挿入'; |
94 | +$_msg_comment = 'コメント: '; | |
95 | +$_title_comment_collided = '$1 で【更新の衝突】が起きました'; | |
96 | +$_msg_comment_collided = 'あなたがこのページを編集している間に、他の人が同じページを更新してしまったようです。<br> | |
97 | +コメントを追加しましたが、違う位置に挿入されているかもしれません。<p>'; | |
89 | 98 | |
90 | 99 | /////////////////////////////////////// |
91 | 100 | // attach file |
@@ -93,6 +102,7 @@ $_title_uploaded = '$1 | ||
93 | 102 | $_title_file_deleted = '$1 からファイルを削除しました'; |
94 | 103 | $_title_notfound = '$1 にそのファイルは見つかりません'; |
95 | 104 | $_title_upload = '$1 への添付'; |
105 | +$_title_confirm_delete = '%s を削除します'; | |
96 | 106 | |
97 | 107 | $_msg_noparm = '$1 へはアップロード・削除はできません'; |
98 | 108 | $_msg_already_exists = '$1 に同じファイル名が存在します'; |
@@ -101,7 +111,17 @@ $_msg_maxsize = ' | ||
101 | 111 | $_msg_delete = '\'$1\' を削除します'; |
102 | 112 | $_msg_exceed = '$1 へのファイルサイズが大きすぎます'; |
103 | 113 | $_msg_attachfile = '添付ファイル'; |
114 | +$_msg_confirm_delete = '<center>%s を削除します。<br>%s</center>'; | |
104 | 115 | |
105 | 116 | $_btn_upload = 'アップロード'; |
106 | 117 | $_btn_delete = '削除'; |
118 | + | |
119 | +/////////////////////////////////////// | |
120 | +// newpage | |
121 | +$_msg_newpage = 'ページ新規作成'; | |
122 | + | |
123 | +/////////////////////////////////////// | |
124 | +// recent | |
125 | +$_recent_plugin_frame = '<span align="center"><h5 class="side_label">最新の%d件</h5></span><small>%s</small>'; | |
126 | +$_recent_plugin_li = '・'; | |
107 | 127 | ?> |
@@ -0,0 +1,96 @@ | ||
1 | +<? | |
2 | +// PukiWiki - Yet another WikiWikiWeb clone. | |
3 | +// $Id: plugin.php,v 1.1 2002/06/21 05:21:46 masui Exp $ | |
4 | +///////////////////////////////////////////////// | |
5 | + | |
6 | +// プラグイン用に未定義の変数を設定 | |
7 | +function set_plugin_messages($messages) | |
8 | +{ | |
9 | + foreach ($messages as $name=>$val) { | |
10 | + global $$name; | |
11 | + if(!isset($$name)) { | |
12 | + $$name = $val; | |
13 | + } | |
14 | + } | |
15 | +} | |
16 | + | |
17 | +//プラグイン(action)が存在するか | |
18 | +function exist_plugin_action($name) { | |
19 | + if(!file_exists(PLUGIN_DIR.$name.".inc.php")) | |
20 | + { | |
21 | + return false; | |
22 | + } | |
23 | + else | |
24 | + { | |
25 | + require_once(PLUGIN_DIR.$name.".inc.php"); | |
26 | + if(!function_exists("plugin_".$name."_action")) | |
27 | + { | |
28 | + return false; | |
29 | + } | |
30 | + } | |
31 | + return true; | |
32 | +} | |
33 | + | |
34 | +//プラグイン(convert)が存在するか | |
35 | +function exist_plugin_convert($name) { | |
36 | + if(!file_exists(PLUGIN_DIR.$name.".inc.php")) | |
37 | + { | |
38 | + return false; | |
39 | + } | |
40 | + else | |
41 | + { | |
42 | + require_once(PLUGIN_DIR.$name.".inc.php"); | |
43 | + if(!function_exists("plugin_".$name."_convert")) | |
44 | + { | |
45 | + return false; | |
46 | + } | |
47 | + } | |
48 | + return true; | |
49 | +} | |
50 | + | |
51 | +//プラグインの初期化を実行 | |
52 | +function do_plugin_init($name) { | |
53 | + $funcname = "plugin_".$name."_init"; | |
54 | + if(!function_exists($funcname)) | |
55 | + { | |
56 | + return false; | |
57 | + } | |
58 | + | |
59 | + $func_check = "_funccheck_".$funcname; | |
60 | + global $$func_check; | |
61 | + if($$func_check) | |
62 | + { | |
63 | + return false; | |
64 | + } | |
65 | + $$func_check = true; | |
66 | + return @call_user_func($funcname); | |
67 | +} | |
68 | + | |
69 | +//プラグイン(action)を実行 | |
70 | +function do_plugin_action($name) { | |
71 | + if(!exist_plugin_action($name)) { | |
72 | + return array(); | |
73 | + } | |
74 | + do_plugin_init($name); | |
75 | + return @call_user_func("plugin_".$name."_action"); | |
76 | +} | |
77 | + | |
78 | +//プラグイン(convert)を実行 | |
79 | +function do_plugin_convert($plugin_name,$plugin_args) | |
80 | +{ | |
81 | + $invalid_return = "#${plugin_name}(${plugin_args})"; | |
82 | + | |
83 | + if($plugin_args !== "") | |
84 | + $aryargs = explode(",",$plugin_args); | |
85 | + else | |
86 | + $aryargs = array(); | |
87 | + | |
88 | + do_plugin_init($plugin_name); | |
89 | + $retvar = call_user_func_array("plugin_${plugin_name}_convert",$aryargs); | |
90 | + | |
91 | + if($retvar === FALSE) return $invalid_return; | |
92 | + else return $retvar; | |
93 | +} | |
94 | + | |
95 | + | |
96 | +?> | |
\ No newline at end of file |
@@ -1,11 +1,11 @@ | ||
1 | -<? | |
2 | -function plugin_aname_convert() | |
3 | -{ | |
4 | - if(func_num_args()) | |
5 | - $aryargs = func_get_args(); | |
6 | - else | |
7 | - $aryargs = array(); | |
8 | - | |
9 | - return "<a name=\"$aryargs[0]\"></a>"; | |
10 | -} | |
11 | -?> | |
1 | +<? | |
2 | +function plugin_aname_convert() | |
3 | +{ | |
4 | + if(func_num_args()) | |
5 | + $aryargs = func_get_args(); | |
6 | + else | |
7 | + $aryargs = array(); | |
8 | + | |
9 | + return "<a name=\"$aryargs[0]\"></a>"; | |
10 | +} | |
11 | +?> |
@@ -0,0 +1,29 @@ | ||
1 | +<? | |
2 | +function plugin_anchor_convert() | |
3 | +{ | |
4 | + global $WikiName,$BracketName,$script,$vars; | |
5 | + | |
6 | + if(func_num_args() == 1) | |
7 | + $aryargs = func_get_args(); | |
8 | + else | |
9 | + return FALSE; | |
10 | + | |
11 | + list($wbn,$aname) = explode("#",$aryargs[0]); | |
12 | + | |
13 | + if(!$aname) return FALSE; | |
14 | + | |
15 | + if(!preg_match("/^$WikiName|$BracketName$/",$wbn) && $wbn) | |
16 | + $wbn = "[[$wbn]]"; | |
17 | + | |
18 | + if(!preg_match("/^$WikiName|$BracketName$/",$aryargs[0])) | |
19 | + $page = "[[$aryargs[0]]]"; | |
20 | + else | |
21 | + $page = $aryargs[0]; | |
22 | + | |
23 | + $page = strip_bracket($page); | |
24 | + | |
25 | + if($wbn) $wbn = "$script?".rawurlencode($wbn); | |
26 | + | |
27 | + return "<a href=\"$wbn#$aname\">$page</a>"; | |
28 | +} | |
29 | +?> |
@@ -0,0 +1,228 @@ | ||
1 | +<? | |
2 | + /* | |
3 | + | |
4 | + PukiWiki BBS風プラグイン | |
5 | + | |
6 | + CopyRight 2002 OKAWARA,Satoshi | |
7 | + http://www.dml.co.jp/~kawara/pukiwiki/pukiwiki.php | |
8 | + kawara@dml.co.jp | |
9 | + | |
10 | + LANGUAGEファイルに下記の値を追加してからご使用ください | |
11 | + $_btn_name = 'お名前'; | |
12 | + $_btn_article = '記事の投稿'; | |
13 | + $_btn_subject = '題名: '; | |
14 | + | |
15 | + ※$_btn_nameはcommentプラグインで既に設定されている場合があります | |
16 | + | |
17 | + 投稿内容の自動メール転送機能をご使用になりたい場合は | |
18 | + -投稿内容のメール自動配信 | |
19 | + -投稿内容のメール自動配信先 | |
20 | + を設定の上、ご使用ください。 | |
21 | + | |
22 | + */ | |
23 | + | |
24 | +///////////////////////////////////////////////// | |
25 | +// テキストエリアのカラム数 | |
26 | +define("article_COLS",70); | |
27 | +///////////////////////////////////////////////// | |
28 | +// テキストエリアの行数 | |
29 | +define("article_ROWS",5); | |
30 | +///////////////////////////////////////////////// | |
31 | +// 名前テキストエリアのカラム数 | |
32 | +define("NAME_COLS",24); | |
33 | +///////////////////////////////////////////////// | |
34 | +// 題名テキストエリアのカラム数 | |
35 | +define("SUBJECT_COLS",60); | |
36 | +///////////////////////////////////////////////// | |
37 | +// 名前の挿入フォーマット | |
38 | +$name_format = '[[$name]]'; | |
39 | +///////////////////////////////////////////////// | |
40 | +// 題名の挿入フォーマット | |
41 | +$subject_format = '**$subject'; | |
42 | +///////////////////////////////////////////////// | |
43 | +// 題名が未記入の場合の表記 | |
44 | +$no_subject = '無題'; | |
45 | +///////////////////////////////////////////////// | |
46 | +// 挿入する位置 1:欄の前 0:欄の後 | |
47 | +define("ARTICLE_INS",0); | |
48 | +///////////////////////////////////////////////// | |
49 | +// 書き込みの下に一行コメントを入れる 1:入れる 0:入れない | |
50 | +define("ARTICLE_COMMENT",1); | |
51 | +///////////////////////////////////////////////// | |
52 | +// 改行を自動的変換 1:する 0:しない | |
53 | +define("ARTICLE_AUTO_BR",1); | |
54 | + | |
55 | +///////////////////////////////////////////////// | |
56 | +// 投稿内容のメール自動配信 1:する 0:しない | |
57 | +define("MAIL_AUTO_SEND",0); | |
58 | +///////////////////////////////////////////////// | |
59 | +// 投稿内容のメール送信時の送信者メールアドレス | |
60 | +define("MAIL_FROM",''); | |
61 | +///////////////////////////////////////////////// | |
62 | +// 投稿内容のメール送信時の題名 | |
63 | +define("MAIL_SUBJECT_PREFIX",'[someone\'sPukiWiki]'); | |
64 | +///////////////////////////////////////////////// | |
65 | +// 投稿内容のメール自動配信先 | |
66 | +$_mailto = array ( | |
67 | + '' | |
68 | +); | |
69 | + | |
70 | + | |
71 | +function plugin_article_action() | |
72 | +{ | |
73 | + global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup,$now; | |
74 | + global $name_format, $subject_format, $no_subject; | |
75 | + global $_title_collided,$_msg_collided,$_title_updated; | |
76 | + global $_mailto; | |
77 | + | |
78 | + if($post["msg"]) | |
79 | + { | |
80 | + $postdata = ""; | |
81 | + $postdata_old = file(get_filename(encode($post["refer"]))); | |
82 | + $article_no = 0; | |
83 | + | |
84 | + if($post[name]) | |
85 | + { | |
86 | + $name = str_replace('$name',$post[name],$name_format); | |
87 | + } | |
88 | + if($post[subject]) | |
89 | + { | |
90 | + $subject = str_replace('$subject',$post[subject],$subject_format); | |
91 | + } else { | |
92 | + $subject = str_replace('$subject',$no_subject,$subject_format); | |
93 | + } | |
94 | + | |
95 | + $article = $subject."\n>"; | |
96 | + $article .= $name." (".$now.")\n>~\n"; | |
97 | + | |
98 | + if(ARTICLE_AUTO_BR){ | |
99 | + //改行の取り扱いはけっこう厄介。特にURLが絡んだときは… | |
100 | + $article_body = $post[msg]; | |
101 | + $article_body = str_replace("\n","\n>~\n",$article_body); | |
102 | + $article_body = preg_replace("/\n\n/","\n",$article_body); | |
103 | + $article .= $article_body; | |
104 | + } else { | |
105 | + $article .= ">".$post[msg]; | |
106 | + } | |
107 | + | |
108 | + if(ARTICLE_COMMENT){ | |
109 | + $article .= "\n\n#comment\n"; | |
110 | + } | |
111 | + | |
112 | + foreach($postdata_old as $line) | |
113 | + { | |
114 | + if(!ARTICLE_INS) $postdata .= $line; | |
115 | + if(preg_match("/^#article$/",$line)) | |
116 | + { | |
117 | + if($article_no == $post["article_no"] && $post[msg]!="") | |
118 | + { | |
119 | + $postdata .= "$article\n"; | |
120 | + } | |
121 | + $article_no++; | |
122 | + } | |
123 | + if(ARTICLE_INS) $postdata .= $line; | |
124 | + } | |
125 | + | |
126 | + $postdata_input = "$article\n"; | |
127 | + } | |
128 | + else | |
129 | + return; | |
130 | + | |
131 | + if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"]) | |
132 | + { | |
133 | + $title = $_title_collided; | |
134 | + | |
135 | + $body = "$_msg_collided\n"; | |
136 | + | |
137 | + $body .= "<form action=\"$script?cmd=preview\" method=\"post\">\n" | |
138 | + ."<input type=\"hidden\" name=\"refer\" value=\"".$post["refer"]."\">\n" | |
139 | + ."<input type=\"hidden\" name=\"digest\" value=\"".$post["digest"]."\">\n" | |
140 | + ."<textarea name=\"msg\" rows=\"$rows\" cols=\"$cols\" wrap=\"virtual\" id=\"textarea\">$postdata_input</textarea><br>\n" | |
141 | + ."</form>\n"; | |
142 | + } | |
143 | + else | |
144 | + { | |
145 | + $postdata = user_rules_str($postdata); | |
146 | + | |
147 | + // 差分ファイルの作成 | |
148 | + if(is_page($post["refer"])) | |
149 | + $oldpostdata = join("",file(get_filename(encode($post["refer"])))); | |
150 | + else | |
151 | + $oldpostdata = "\n"; | |
152 | + if($postdata) | |
153 | + $diffdata = do_diff($oldpostdata,$postdata); | |
154 | + file_write(DIFF_DIR,$post["refer"],$diffdata); | |
155 | + | |
156 | + // バックアップの作成 | |
157 | + if(is_page($post["refer"])) | |
158 | + $oldposttime = filemtime(get_filename(encode($post["refer"]))); | |
159 | + else | |
160 | + $oldposttime = time(); | |
161 | + | |
162 | + // 編集内容が何も書かれていないとバックアップも削除する?しないですよね。 | |
163 | + if(!$postdata && $del_backup) | |
164 | + backup_delete(BACKUP_DIR.encode($post["refer"]).".txt"); | |
165 | + else if($do_backup && is_page($post["refer"])) | |
166 | + make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime); | |
167 | + | |
168 | + // ファイルの書き込み | |
169 | + file_write(DATA_DIR,$post["refer"],$postdata); | |
170 | + | |
171 | + // 投稿内容のメール自動送信 | |
172 | + if(MAIL_AUTO_SEND){ | |
173 | + $mailaddress = implode(',' ,$_mailto); | |
174 | + $mailsubject = MAIL_SUBJECT_PREFIX." ".str_replace("**","",$subject); | |
175 | + if($post["name"]){ | |
176 | + $mailsubject .= '/'.$post["name"]; | |
177 | + } | |
178 | + $mailsubject = mb_encode_mimeheader($mailsubject); | |
179 | + | |
180 | + $mailbody = $post["msg"]; | |
181 | + $mailbody .= "\n\n---\n"; | |
182 | + $mailbody .= "投稿者: ".$post["name"]." ($now)\n"; | |
183 | + $mailbody .= "投稿先: ".$post["refer"]."\n"; | |
184 | + $mailbody .= " URL: ".$script.'?'.rawurlencode($post["refer"])."\n"; | |
185 | + $mailbody = mb_convert_encoding( $mailbody, "JIS" ); | |
186 | + | |
187 | + $mailaddheader = "From: ".MAIL_FROM; | |
188 | + | |
189 | + mail($mailaddress, $mailsubject, $mailbody, $mailaddheader); | |
190 | + } | |
191 | + | |
192 | + // is_pageのキャッシュをクリアする。 | |
193 | + is_page($post["refer"],true); | |
194 | + | |
195 | + $title = $_title_updated; | |
196 | + } | |
197 | + $retvars["msg"] = $title; | |
198 | + $retvars["body"] = $body; | |
199 | + | |
200 | + $post["page"] = $post["refer"]; | |
201 | + $vars["page"] = $post["refer"]; | |
202 | + | |
203 | + return $retvars; | |
204 | +} | |
205 | +function plugin_article_convert() | |
206 | +{ | |
207 | + global $script,$article_no,$vars,$digest; | |
208 | + global $_btn_article,$_btn_name,$_btn_subject,$vars; | |
209 | + | |
210 | + if((arg_check("read")||$vars["cmd"] == ""||arg_check("unfreeze")||arg_check("freeze")||$vars["write"]||$vars["article"])) | |
211 | + $button = "<input type=\"submit\" name=\"article\" value=\"$_btn_article\">\n"; | |
212 | + | |
213 | + $string = "<form action=\"$script\" method=\"post\">\n" | |
214 | + ."<input type=\"hidden\" name=\"article_no\" value=\"$article_no\">\n" | |
215 | + ."<input type=\"hidden\" name=\"refer\" value=\"$vars[page]\">\n" | |
216 | + ."<input type=\"hidden\" name=\"plugin\" value=\"article\">\n" | |
217 | + ."<input type=\"hidden\" name=\"digest\" value=\"$digest\">\n" | |
218 | + ."$_btn_name<input type=\"text\" name=\"name\" size=\"".NAME_COLS."\"><br>\n" | |
219 | + ."$_btn_subject<input type=\"text\" name=\"subject\" size=\"".SUBJECT_COLS."\"><br>\n" | |
220 | + ."<textarea name=\"msg\" rows=\"".article_ROWS."\" cols=\"".article_COLS."\">\n</textarea><br>\n" | |
221 | + .$button | |
222 | + ."</form>"; | |
223 | + | |
224 | + $article_no++; | |
225 | + | |
226 | + return $string; | |
227 | +} | |
228 | +?> |
@@ -1,6 +1,8 @@ | ||
1 | 1 | <? |
2 | 2 | // プラグイン attach |
3 | 3 | |
4 | +// changed by Y.MASUI <masui@hisec.co.jp> http://masui.net/pukiwiki/ | |
5 | + | |
4 | 6 | // set PHP value to enable file upload |
5 | 7 | ini_set("file_uploads","1"); |
6 | 8 |
@@ -31,7 +33,7 @@ function plugin_attach_convert() | ||
31 | 33 | while($file = readdir($dir)) |
32 | 34 | { |
33 | 35 | if($file == ".." || $file == ".") continue; |
34 | - if(!preg_match("/^${decoded_pgname}_(.*)$/",$file,$match)) continue; | |
36 | + if(!preg_match("/^${decoded_pgname}_([^.]+)$/",$file,$match)) continue; | |
35 | 37 | |
36 | 38 | $lastmod = date("Y/m/d H:i:s",filemtime(UPLOAD_DIR.$file)); |
37 | 39 |
@@ -44,8 +46,15 @@ function plugin_attach_convert() | ||
44 | 46 | $filename_url = rawurlencode($filename); |
45 | 47 | $refername_url = rawurlencode($vars[page]); |
46 | 48 | |
47 | - $del = "[<a href=\"$script?plugin=attach&delfile=${filename_url}&refer=${refername_url}\" title=\"".str_replace('$1',$filename,$_msg_delete)."\">$_btn_delete</a>]"; | |
48 | - $open = "<a href=\"$script?plugin=attach&openfile=${filename_url}&refer=${refername_url}\" title=\"$lastmod $file_size\">$icon$filename</a>\n"; | |
49 | + $counter = ''; | |
50 | + if(file_exists(UPLOAD_DIR.$file.'.log')) { | |
51 | + $list = file(UPLOAD_DIR.$file.'.log'); | |
52 | + | |
53 | + $counter = ' <small>' . chop($list[0]) . '件</small>'; | |
54 | + } | |
55 | + | |
56 | + $del = "[<a href=\"$script?plugin=attach&mode=confirm&delfile=${filename_url}&refer=${refername_url}\" title=\"".str_replace('$1',$filename,$_msg_delete)."\">$_btn_delete</a>]"; | |
57 | + $open = "<a href=\"$script?plugin=attach&openfile=${filename_url}&refer=${refername_url}\" title=\"$lastmod $file_size\">$icon$filename</a>$counter\n"; | |
49 | 58 | |
50 | 59 | $into = "$open <small>$del</small>"; |
51 | 60 |
@@ -87,11 +96,12 @@ function plugin_attach_action() | ||
87 | 96 | { |
88 | 97 | global $vars,$script,$max_size,$HTTP_POST_FILES; |
89 | 98 | global $_title_uploaded,$_title_file_deleted,$_title_notfound,$_msg_noparm,$_msg_already_exists,$_msg_attach_filelist,$_msg_delete,$_msg_exceed,$_btn_delete; |
90 | - global $_msg_maxsize,$_btn_upload,$_msg_attachfile,$_title_upload; | |
99 | + global $_msg_maxsize,$_btn_upload,$_msg_attachfile,$_title_upload,$_title_confirm_delete,$_msg_confirm_delete; | |
91 | 100 | |
92 | 101 | $postfiles = $HTTP_POST_FILES; |
93 | 102 | $icon = FILE_ICON; |
94 | 103 | |
104 | + $vars["mode"] = rawurldecode($vars["mode"]); | |
95 | 105 | $vars["openfile"] = rawurldecode($vars["openfile"]); |
96 | 106 | $vars["delfile"] = rawurldecode($vars["delfile"]); |
97 | 107 | $vars["refer"] = rawurldecode($vars["refer"]); |
@@ -114,18 +124,32 @@ function plugin_attach_action() | ||
114 | 124 | } |
115 | 125 | else if($vars["delfile"]) |
116 | 126 | { |
117 | - $filename = encode($vars["refer"])."_".encode($vars["delfile"]); | |
118 | - if(is_freeze($vars["refer"]) || !is_editable($vars["refer"])) return array("msg" => $_msg_noparm); | |
127 | + if($vars["mode"] == "confirm") { | |
128 | + $form = "<form action=\"$script\" method=\"post\">\n"; | |
129 | + $form .= "<input type=\"hidden\" name=\"plugin\" value=\"attach\">\n"; | |
130 | + $form .= "<input type=\"hidden\" name=\"refer\" value=\"$vars[refer]\">\n"; | |
131 | + $form .= "<input type=\"hidden\" name=\"delfile\" value=\"$vars[delfile]\">\n"; | |
132 | + $form .= "<input type=\"submit\" value=\"$_btn_delete\">\n"; | |
133 | + $form .= "</form>"; | |
134 | + | |
135 | + $retvars["body"] = sprintf($_msg_confirm_delete,$vars["delfile"],$form); | |
136 | + $retvars["msg"] = sprintf($_title_confirm_delete,$vars["delfile"]); | |
137 | + return $retvars; | |
138 | + } | |
139 | + else { | |
140 | + $filename = encode($vars["refer"])."_".encode($vars["delfile"]); | |
141 | + if(is_freeze($vars["refer"]) || !is_editable($vars["refer"])) return array("msg" => $_msg_noparm); | |
119 | 142 | |
120 | - if(!file_exists(UPLOAD_DIR.$filename)) | |
143 | + if(!file_exists(UPLOAD_DIR.$filename)) | |
121 | 144 | return array("msg" => $_title_notfound); |
122 | 145 | |
123 | - @unlink(UPLOAD_DIR.$filename); | |
146 | + @unlink(UPLOAD_DIR.$filename); | |
124 | 147 | |
125 | - if(file_exists(DATA_DIR.encode($vars["refer"]).".txt")) | |
126 | - @touch(DATA_DIR.encode($vars["refer"]).".txt"); | |
148 | + if(file_exists(DATA_DIR.encode($vars["refer"]).".txt")) | |
149 | + @touch(DATA_DIR.encode($vars["refer"]).".txt"); | |
127 | 150 | |
128 | - return array("msg" => $_title_file_deleted); | |
151 | + return array("msg" => $_title_file_deleted); | |
152 | + } | |
129 | 153 | } |
130 | 154 | else if($vars["openfile"]) |
131 | 155 | { |
@@ -145,9 +169,10 @@ function plugin_attach_action() | ||
145 | 169 | $pgname_keep = ""; |
146 | 170 | $retbody = ""; |
147 | 171 | $aryret = array(); |
172 | + $pagenames = array(); | |
148 | 173 | while($file = readdir($dir)) |
149 | 174 | { |
150 | - if($file == ".." || $file == ".") continue; | |
175 | + if($file == ".." || $file == "." || strstr($file,".log")!=FALSE) continue; | |
151 | 176 | |
152 | 177 | settype($dfile_size,"double"); |
153 | 178 | $dfile_size = round(filesize(UPLOAD_DIR.$file)/1000,1); |
@@ -163,34 +188,22 @@ function plugin_attach_action() | ||
163 | 188 | $passage = get_pg_passage($pagename); |
164 | 189 | |
165 | 190 | $pagename = strip_bracket($pagename); |
166 | - $page = "<a href=\"$script?${pagename_url}\">$pagename</a>$passage\n"; | |
167 | - | |
168 | - $strtmp = ""; | |
169 | - if($pgname_keep != $pagename) | |
170 | - { | |
171 | - if($pgname_keep!="") | |
172 | - $strtmp .= "</ul>\n"; | |
173 | - | |
174 | - $strtmp .= "<li>$page</li>\n"; | |
175 | - $strtmp .= "<ul>\n"; | |
176 | - $aryret[$pagename] = $strtmp; | |
177 | - $pgname_keep = $pagename; | |
178 | - } | |
191 | + $pagenames[$pagename] = "<li><a href=\"$script?${pagename_url}\">$pagename</a>$passage</li>\n"; | |
179 | 192 | |
180 | 193 | $lastmod = date("Y/m/d H:i:s",filemtime(UPLOAD_DIR.$file)); |
181 | 194 | |
182 | - $del = "[<a href=\"$script?plugin=attach&delfile=${filename_url}&refer=${pagename_url}\" title=\"".str_replace('$1',$filename,$_msg_delete)."\">$_btn_delete</a>]"; | |
195 | + $del = "[<a href=\"$script?plugin=attach&mode=confirm&delfile=${filename_url}&refer=${pagename_url}\" title=\"".str_replace('$1',$filename,$_msg_delete)."\">$_btn_delete</a>]"; | |
183 | 196 | |
184 | 197 | $open = "<a href=\"$script?plugin=attach&openfile=${filename_url}&refer=${pagename_url}\" title=\"$lastmod $file_size\">$filename</a>"; |
185 | 198 | |
186 | - | |
187 | - $into = "<li>$open <small>$del</small></li>\n"; | |
188 | - | |
189 | - $aryret[$pagename.$filename] = $into; | |
199 | + $aryret[$pagename] .= "<li>$open <small>$del</small></li>\n"; | |
190 | 200 | } |
191 | 201 | closedir($dir); |
192 | 202 | ksort($aryret); |
193 | - $retbody = join("",$aryret); | |
203 | + $retbody = ''; | |
204 | + foreach($aryret as $pagename => $list) { | |
205 | + $retbody .= $pagenames[$pagename] . "<ul>\n" . $list . "</ul>\n"; | |
206 | + } | |
194 | 207 | } |
195 | 208 | |
196 | 209 | $retvars["msg"] = $_msg_attach_filelist; |
@@ -233,7 +246,18 @@ function attach_filelist() | ||
233 | 246 | function download_file($path_file,$filename) |
234 | 247 | { |
235 | 248 | $content_length = filesize($path_file); |
236 | - | |
249 | + | |
250 | + $list = array(1); | |
251 | + if(file_exists($path_file.'.log')) { | |
252 | + $list = file($path_file.'.log'); | |
253 | + $list[0] = chop($list[0]) + 1; | |
254 | + } | |
255 | + $fp = fopen($path_file.'.log','w'); | |
256 | + foreach ($list as $l) { | |
257 | + fputs($fp,$l); | |
258 | + } | |
259 | + fclose($fp); | |
260 | + | |
237 | 261 | // for japanese |
238 | 262 | if(function_exists("mb_convert_encoding")) |
239 | 263 | $filename = mb_convert_encoding($filename,"SJIS","auto"); |
@@ -1,174 +1,174 @@ | ||
1 | -<? | |
2 | -function plugin_calendar_convert() | |
3 | -{ | |
4 | - global $script,$weeklabels,$vars,$command,$WikiName,$BracketName; | |
5 | - | |
6 | - $args = func_get_args(); | |
7 | - | |
8 | - if(func_num_args() == 0) | |
9 | - { | |
10 | - $date_str = date("Ym"); | |
11 | - $pre = $vars[page]; | |
12 | - $prefix = preg_replace("/^\[\[(.*)\]\]$/","$1",$vars[page])."/"; | |
13 | - } | |
14 | - else if(func_num_args() == 1) | |
15 | - { | |
16 | - if(is_numeric($args[0]) && strlen($args[0]) == 6) | |
17 | - { | |
18 | - $date_str = $args[0]; | |
19 | - $pre = $vars[page]; | |
20 | - $prefix = preg_replace("/^\[\[(.*)\]\]$/","$1",$vars[page])."/"; | |
21 | - } | |
22 | - else | |
23 | - { | |
24 | - $date_str = date("Ym"); | |
25 | - $pre = $args[0]; | |
26 | - $prefix = $args[0]; | |
27 | - } | |
28 | - } | |
29 | - else if(func_num_args() == 2) | |
30 | - { | |
31 | - if(is_numeric($args[0]) && strlen($args[0]) == 6) | |
32 | - { | |
33 | - $date_str = $args[0]; | |
34 | - $pre = $args[1]; | |
35 | - $prefix = $args[1]; | |
36 | - } | |
37 | - else if(is_numeric($args[1]) && strlen($args[1]) == 6) | |
38 | - { | |
39 | - $date_str = $args[1]; | |
40 | - $pre = $args[0]; | |
41 | - $prefix = $args[0]; | |
42 | - } | |
43 | - else | |
44 | - { | |
45 | - $date_str = date("Ym"); | |
46 | - $pre = $vars[page]; | |
47 | - $prefix = preg_replace("/^\[\[(.*)\]\]$/","$1",$vars[page])."/"; | |
48 | - } | |
49 | - } | |
50 | - else | |
51 | - { | |
52 | - return FALSE; | |
53 | - } | |
54 | - | |
55 | - if(!$command) $cmd = "read"; | |
56 | - else $cmd = $command; | |
57 | - | |
58 | - $prefix = strip_tags($prefix); | |
59 | - | |
60 | - $yr = substr($date_str,0,4); | |
61 | - $mon = substr($date_str,4,2); | |
62 | - if($yr != date("Y") || $mon != date("m")) | |
63 | - { | |
64 | - $now_day = 1; | |
65 | - $other_month = 1; | |
66 | - } | |
67 | - else | |
68 | - { | |
69 | - $now_day = date("d"); | |
70 | - $other_month = 0; | |
71 | - } | |
72 | - $today = getdate(mktime(0,0,0,$mon,$now_day,$yr)); | |
73 | - | |
74 | - $m_num = $today[mon]; | |
75 | - $d_num = $today[mday]; | |
76 | - $year = $today[year]; | |
77 | - $f_today = getdate(mktime(0,0,0,$m_num,1,$year)); | |
78 | - $wday = $f_today[wday]; | |
79 | - $day = 1; | |
80 | - $fweek = true; | |
81 | - | |
82 | - $m_name = "$year.$m_num ($cmd)"; | |
83 | - | |
84 | - if(!preg_match("/^(($WikiName)|($BracketName))$/",$pre)) | |
85 | - $prefix_url = "[[".$pre."]]"; | |
86 | - else | |
87 | - $prefix_url = $pre; | |
88 | - | |
89 | - $prefix_url = rawurlencode($prefix_url); | |
90 | - $pre = strip_bracket($pre); | |
91 | - | |
92 | - $ret .= ' | |
93 | -<table class="style_calendar" cellspacing="1" width="150" border="0"> | |
94 | - <tbody> | |
95 | - <tr> | |
96 | - <td align="middle" class="style_td_caltop" colspan="7" height="15"> | |
97 | - <div align="center"><small><b>'.$m_name.'</b><br>[<a href="'.$script.'?'.$prefix_url.'">'.$pre.'</a>]</small></div> | |
98 | - </td> | |
99 | - </tr> | |
100 | - <tr> | |
101 | -'; | |
102 | - | |
103 | - foreach($weeklabels as $label) | |
104 | - { | |
105 | - $ret .= ' | |
106 | - <td align="middle" class="style_td_week" height="15"> | |
107 | - <div align="center"><small><b>'.$label.'</b></small></div> | |
108 | - </td>'; | |
109 | - } | |
110 | - | |
111 | - $ret .= "</tr>\n<tr>\n"; | |
112 | - | |
113 | - while(checkdate($m_num,$day,$year)) | |
114 | - { | |
115 | - $dt = sprintf("%4d%02d%02d", $year, $m_num, $day); | |
116 | - $name = "$prefix$dt"; | |
117 | - $page = "[[$prefix$dt]]"; | |
118 | - $page_url = rawurlencode("[[$prefix$dt]]"); | |
119 | - | |
120 | - if($cmd == "edit") $refer = "&refer=$page_url"; | |
121 | - else $refer = ""; | |
122 | - | |
123 | - if($cmd == "read" && !is_page($page)) | |
124 | - $link = "<b>$day</b>"; | |
125 | - else | |
126 | - $link = "<a href=\"$script?cmd=$cmd&page=$page_url$refer\" title=\"$name\"><b>$day</b></a>"; | |
127 | - | |
128 | - if($fweek) | |
129 | - { | |
130 | - for($i=0;$i<$wday;$i++) | |
131 | - { // Blank | |
132 | - $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_blank\" height=\"19\"> </td>\n"; | |
133 | - } | |
134 | - $fweek=false; | |
135 | - } | |
136 | - | |
137 | - if($wday == 0) $ret .= " </tr><tr>\n"; | |
138 | - if(!$other_month && ($day == $today[mday]) && ($m_num == $today[mon]) && ($year == $today[year])) | |
139 | - { | |
140 | - // Today | |
141 | - $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_today\" height=\"19\"><small>$link</small></td>\n"; | |
142 | - } | |
143 | - else if($wday == 0) | |
144 | - { | |
145 | - // Sunday | |
146 | - $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_sun\" height=\"19\"><small>$link</small></td>\n"; | |
147 | - } | |
148 | - else if($wday == 6) | |
149 | - { | |
150 | - // Saturday | |
151 | - $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_sat\" height=\"19\"><small>$link</small></td>\n"; | |
152 | - } | |
153 | - else | |
154 | - { | |
155 | - // Weekday | |
156 | - $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td\" height=\"19\"><small>$link</small></td>\n"; | |
157 | - } | |
158 | - $day++; | |
159 | - $wday++; | |
160 | - $wday = $wday % 7; | |
161 | - } | |
162 | - if($wday > 0) | |
163 | - { | |
164 | - while($wday < 7) | |
165 | - { // Blank | |
166 | - $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_blank\" height=\"19\"> </td>\n"; | |
167 | - $wday++; | |
168 | - } | |
169 | - } | |
170 | - | |
171 | - $ret .= " </tr>\n</table>\n"; | |
172 | - return $ret; | |
173 | -} | |
1 | +<? | |
2 | +function plugin_calendar_convert() | |
3 | +{ | |
4 | + global $script,$weeklabels,$vars,$command,$WikiName,$BracketName; | |
5 | + | |
6 | + $args = func_get_args(); | |
7 | + | |
8 | + if(func_num_args() == 0) | |
9 | + { | |
10 | + $date_str = date("Ym"); | |
11 | + $pre = $vars[page]; | |
12 | + $prefix = preg_replace("/^\[\[(.*)\]\]$/","$1",$vars[page])."/"; | |
13 | + } | |
14 | + else if(func_num_args() == 1) | |
15 | + { | |
16 | + if(is_numeric($args[0]) && strlen($args[0]) == 6) | |
17 | + { | |
18 | + $date_str = $args[0]; | |
19 | + $pre = $vars[page]; | |
20 | + $prefix = preg_replace("/^\[\[(.*)\]\]$/","$1",$vars[page])."/"; | |
21 | + } | |
22 | + else | |
23 | + { | |
24 | + $date_str = date("Ym"); | |
25 | + $pre = $args[0]; | |
26 | + $prefix = $args[0]; | |
27 | + } | |
28 | + } | |
29 | + else if(func_num_args() == 2) | |
30 | + { | |
31 | + if(is_numeric($args[0]) && strlen($args[0]) == 6) | |
32 | + { | |
33 | + $date_str = $args[0]; | |
34 | + $pre = $args[1]; | |
35 | + $prefix = $args[1]; | |
36 | + } | |
37 | + else if(is_numeric($args[1]) && strlen($args[1]) == 6) | |
38 | + { | |
39 | + $date_str = $args[1]; | |
40 | + $pre = $args[0]; | |
41 | + $prefix = $args[0]; | |
42 | + } | |
43 | + else | |
44 | + { | |
45 | + $date_str = date("Ym"); | |
46 | + $pre = $vars[page]; | |
47 | + $prefix = preg_replace("/^\[\[(.*)\]\]$/","$1",$vars[page])."/"; | |
48 | + } | |
49 | + } | |
50 | + else | |
51 | + { | |
52 | + return FALSE; | |
53 | + } | |
54 | + | |
55 | + if(!$command) $cmd = "read"; | |
56 | + else $cmd = $command; | |
57 | + | |
58 | + $prefix = strip_tags($prefix); | |
59 | + | |
60 | + $yr = substr($date_str,0,4); | |
61 | + $mon = substr($date_str,4,2); | |
62 | + if($yr != date("Y") || $mon != date("m")) | |
63 | + { | |
64 | + $now_day = 1; | |
65 | + $other_month = 1; | |
66 | + } | |
67 | + else | |
68 | + { | |
69 | + $now_day = date("d"); | |
70 | + $other_month = 0; | |
71 | + } | |
72 | + $today = getdate(mktime(0,0,0,$mon,$now_day,$yr)); | |
73 | + | |
74 | + $m_num = $today[mon]; | |
75 | + $d_num = $today[mday]; | |
76 | + $year = $today[year]; | |
77 | + $f_today = getdate(mktime(0,0,0,$m_num,1,$year)); | |
78 | + $wday = $f_today[wday]; | |
79 | + $day = 1; | |
80 | + $fweek = true; | |
81 | + | |
82 | + $m_name = "$year.$m_num ($cmd)"; | |
83 | + | |
84 | + if(!preg_match("/^(($WikiName)|($BracketName))$/",$pre)) | |
85 | + $prefix_url = "[[".$pre."]]"; | |
86 | + else | |
87 | + $prefix_url = $pre; | |
88 | + | |
89 | + $prefix_url = rawurlencode($prefix_url); | |
90 | + $pre = strip_bracket($pre); | |
91 | + | |
92 | + $ret .= ' | |
93 | +<table class="style_calendar" cellspacing="1" width="150" border="0"> | |
94 | + <tbody> | |
95 | + <tr> | |
96 | + <td align="middle" class="style_td_caltop" colspan="7" height="15"> | |
97 | + <div align="center"><small><b>'.$m_name.'</b><br>[<a href="'.$script.'?'.$prefix_url.'">'.$pre.'</a>]</small></div> | |
98 | + </td> | |
99 | + </tr> | |
100 | + <tr> | |
101 | +'; | |
102 | + | |
103 | + foreach($weeklabels as $label) | |
104 | + { | |
105 | + $ret .= ' | |
106 | + <td align="middle" class="style_td_week" height="15"> | |
107 | + <div align="center"><small><b>'.$label.'</b></small></div> | |
108 | + </td>'; | |
109 | + } | |
110 | + | |
111 | + $ret .= "</tr>\n<tr>\n"; | |
112 | + | |
113 | + while(checkdate($m_num,$day,$year)) | |
114 | + { | |
115 | + $dt = sprintf("%4d%02d%02d", $year, $m_num, $day); | |
116 | + $name = "$prefix$dt"; | |
117 | + $page = "[[$prefix$dt]]"; | |
118 | + $page_url = rawurlencode("[[$prefix$dt]]"); | |
119 | + | |
120 | + if($cmd == "edit") $refer = "&refer=$page_url"; | |
121 | + else $refer = ""; | |
122 | + | |
123 | + if($cmd == "read" && !is_page($page)) | |
124 | + $link = "<b>$day</b>"; | |
125 | + else | |
126 | + $link = "<a href=\"$script?cmd=$cmd&page=$page_url$refer\" title=\"$name\"><b>$day</b></a>"; | |
127 | + | |
128 | + if($fweek) | |
129 | + { | |
130 | + for($i=0;$i<$wday;$i++) | |
131 | + { // Blank | |
132 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_blank\" height=\"19\">。。</td>\n"; | |
133 | + } | |
134 | + $fweek=false; | |
135 | + } | |
136 | + | |
137 | + if($wday == 0) $ret .= " </tr><tr>\n"; | |
138 | + if(!$other_month && ($day == $today[mday]) && ($m_num == $today[mon]) && ($year == $today[year])) | |
139 | + { | |
140 | + // Today | |
141 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_today\" height=\"19\"><small>$link</small></td>\n"; | |
142 | + } | |
143 | + else if($wday == 0) | |
144 | + { | |
145 | + // Sunday | |
146 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_sun\" height=\"19\"><small>$link</small></td>\n"; | |
147 | + } | |
148 | + else if($wday == 6) | |
149 | + { | |
150 | + // Saturday | |
151 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_sat\" height=\"19\"><small>$link</small></td>\n"; | |
152 | + } | |
153 | + else | |
154 | + { | |
155 | + // Weekday | |
156 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td\" height=\"19\"><small>$link</small></td>\n"; | |
157 | + } | |
158 | + $day++; | |
159 | + $wday++; | |
160 | + $wday = $wday % 7; | |
161 | + } | |
162 | + if($wday > 0) | |
163 | + { | |
164 | + while($wday < 7) | |
165 | + { // Blank | |
166 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_blank\" height=\"19\">。。</td>\n"; | |
167 | + $wday++; | |
168 | + } | |
169 | + } | |
170 | + | |
171 | + $ret .= " </tr>\n</table>\n"; | |
172 | + return $ret; | |
173 | +} | |
174 | 174 | ?> |
\ No newline at end of file |
@@ -0,0 +1,243 @@ | ||
1 | +<? | |
2 | + | |
3 | +function plugin_calendar2_convert() | |
4 | +{ | |
5 | + global $script,$weeklabels,$vars,$command,$WikiName,$BracketName; | |
6 | + | |
7 | + $args = func_get_args(); | |
8 | + | |
9 | + if(func_num_args() == 0) | |
10 | + { | |
11 | + $date_str = date("Ym"); | |
12 | + $pre = strip_bracket($vars['page']); | |
13 | + $prefix = strip_bracket($vars['page'])."/"; | |
14 | + } | |
15 | + else if(func_num_args() == 1) | |
16 | + { | |
17 | + if(is_numeric($args[0]) && strlen($args[0]) == 6) | |
18 | + { | |
19 | + $date_str = $args[0]; | |
20 | + $pre = strip_bracket($vars['page']); | |
21 | + $prefix = strip_bracket($vars['page'])."/"; | |
22 | + } | |
23 | + else | |
24 | + { | |
25 | + $date_str = date("Ym"); | |
26 | + $pre = strip_bracket($args[0]); | |
27 | + $prefix = strip_bracket($args[0]); | |
28 | + } | |
29 | + } | |
30 | + else if(func_num_args() == 2) | |
31 | + { | |
32 | + if(is_numeric($args[0]) && strlen($args[0]) == 6) | |
33 | + { | |
34 | + $date_str = $args[0]; | |
35 | + $pre = strip_bracket($args[1]); | |
36 | + $prefix = strip_bracket($args[1]); | |
37 | + } | |
38 | + else if(is_numeric($args[1]) && strlen($args[1]) == 6) | |
39 | + { | |
40 | + $date_str = $args[1]; | |
41 | + $pre = strip_bracket($args[0]); | |
42 | + $prefix = strip_bracket($args[0]).'/'; | |
43 | + } | |
44 | + else | |
45 | + { | |
46 | + $date_str = date("Ym"); | |
47 | + $pre = strip_bracket($vars[page]); | |
48 | + $prefix = strip_bracket($vars[page])."/"; | |
49 | + } | |
50 | + } | |
51 | + else | |
52 | + { | |
53 | + return FALSE; | |
54 | + } | |
55 | + if($pre == "*") { | |
56 | + $prefix = ''; | |
57 | + $pre = ''; | |
58 | + } | |
59 | + $prefix_ = rawurlencode($pre); | |
60 | + $prefix = strip_tags($prefix); | |
61 | + | |
62 | + if(!$command) $cmd = "read"; | |
63 | + else $cmd = $command; | |
64 | + | |
65 | + | |
66 | + $yr = substr($date_str,0,4); | |
67 | + $mon = substr($date_str,4,2); | |
68 | + if($yr != date("Y") || $mon != date("m")) { | |
69 | + $now_day = 1; | |
70 | + $other_month = 1; | |
71 | + } | |
72 | + else { | |
73 | + $now_day = date("d"); | |
74 | + $other_month = 0; | |
75 | + } | |
76 | + $today = getdate(mktime(0,0,0,$mon,$now_day,$yr)); | |
77 | + | |
78 | + $m_num = $today[mon]; | |
79 | + $d_num = $today[mday]; | |
80 | + $year = $today[year]; | |
81 | + $f_today = getdate(mktime(0,0,0,$m_num,1,$year)); | |
82 | + $wday = $f_today[wday]; | |
83 | + $day = 1; | |
84 | + $fweek = true; | |
85 | + | |
86 | + $m_name = "$year.$m_num ($cmd)"; | |
87 | + | |
88 | + if(!preg_match("/^(($WikiName)|($BracketName))$/",$pre)) | |
89 | + $prefix_url = "[[".$pre."]]"; | |
90 | + else | |
91 | + $prefix_url = $pre; | |
92 | + | |
93 | + $prefix_url = rawurlencode($prefix_url); | |
94 | + $pre = strip_bracket($pre); | |
95 | + | |
96 | + $ret .= '<table border="0" width="100%"><tr><td valign="top">'; | |
97 | + | |
98 | + $y = substr($date_str,0,4)+0; | |
99 | + $m = substr($date_str,4,2)+0; | |
100 | + | |
101 | + $prev_date_str = sprintf("%04d%02d",$y,$m-1); | |
102 | + if($m-1<1) { | |
103 | + $prev_date_str = sprintf("%04d%02d",$y-1,12); | |
104 | + } | |
105 | + $next_date_str = sprintf("%04d%02d",$y,$m+1); | |
106 | + if($m+1>12) { | |
107 | + $next_date_str = sprintf("%04d%02d",$y+1,1); | |
108 | + } | |
109 | + | |
110 | + if($prefix == "") { | |
111 | + $ret .= ' | |
112 | +<table class="style_calendar" cellspacing="1" width="150" border="0"> | |
113 | + <tbody> | |
114 | + <tr> | |
115 | + <td align="middle" class="style_td_caltop" colspan="7" height="15"> | |
116 | + <div align="center"><small><a href="'.$script.'?plugin=calendar2&file='.$prefix_.'&date='.$prev_date_str.'"><<</a> <b>'.$m_name.'</b> <a href="'.$script.'?plugin=calendar2&file='.$prefix_.'&date='.$next_date_str.'">>></a></small></div> | |
117 | + </td> | |
118 | + </tr> | |
119 | + <tr> | |
120 | +'; | |
121 | + } | |
122 | + else { | |
123 | + $ret .= ' | |
124 | +<table class="style_calendar" cellspacing="1" width="150" border="0"> | |
125 | + <tbody> | |
126 | + <tr> | |
127 | + <td align="middle" class="style_td_caltop" colspan="7" height="15"> | |
128 | + <div align="center"><small><a href="'.$script.'?plugin=calendar2&file='.$prefix_.'&date='.$prev_date_str.'"><<</a> <b>'.$m_name.'</b> <a href="'.$script.'?plugin=calendar2&file='.$prefix_.'&date='.$next_date_str.'">>></a><br>[<a href="'.$script.'?'.$prefix_url.'">'.$pre.'</a>]</small></div> | |
129 | + </td> | |
130 | + </tr> | |
131 | + <tr> | |
132 | +'; | |
133 | + } | |
134 | + | |
135 | + foreach($weeklabels as $label) | |
136 | + { | |
137 | + $ret .= ' | |
138 | + <td align="middle" class="style_td_week" height="15"> | |
139 | + <div align="center"><small><b>'.$label.'</b></small></div> | |
140 | + </td>'; | |
141 | + } | |
142 | + | |
143 | + $ret .= "</tr>\n<tr>\n"; | |
144 | + | |
145 | + while(checkdate($m_num,$day,$year)) | |
146 | + { | |
147 | + $dt = sprintf("%4d-%02d-%02d", $year, $m_num, $day); | |
148 | + $name = "$prefix$dt"; | |
149 | + $page = "[[$prefix$dt]]"; | |
150 | + $page_url = rawurlencode("[[$prefix$dt]]"); | |
151 | + | |
152 | + if($cmd == "edit") $refer = "&refer=$page_url"; | |
153 | + else $refer = ""; | |
154 | + | |
155 | + if($cmd == "read" && !is_page($page)) | |
156 | + $link = "<small><a href=\"$script?cmd=$cmd&page=$page_url$refer\" title=\"$name\">$day</a></small>"; | |
157 | + else | |
158 | + $link = "<a href=\"$script?cmd=$cmd&page=$page_url$refer\" title=\"$name\"><b>$day</b></a>"; | |
159 | + | |
160 | + if($fweek) | |
161 | + { | |
162 | + for($i=0;$i<$wday;$i++) | |
163 | + { // Blank | |
164 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_blank\" height=\"19\"> </td>\n"; | |
165 | + } | |
166 | + $fweek=false; | |
167 | + } | |
168 | + | |
169 | + if($wday == 0) $ret .= " </tr><tr>\n"; | |
170 | + if(!$other_month && ($day == $today[mday]) && ($m_num == $today[mon]) && ($year == $today[year])) | |
171 | + { | |
172 | + // Today | |
173 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_today\" height=\"19\">$link</td>\n"; | |
174 | + } | |
175 | + else if($wday == 0) | |
176 | + { | |
177 | + // Sunday | |
178 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_sun\" height=\"19\">$link</td>\n"; | |
179 | + } | |
180 | + else if($wday == 6) | |
181 | + { | |
182 | + // Saturday | |
183 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_sat\" height=\"19\">$link</td>\n"; | |
184 | + } | |
185 | + else | |
186 | + { | |
187 | + // Weekday | |
188 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td\" height=\"19\">$link</td>\n"; | |
189 | + } | |
190 | + $day++; | |
191 | + $wday++; | |
192 | + $wday = $wday % 7; | |
193 | + } | |
194 | + if($wday > 0) | |
195 | + { | |
196 | + while($wday < 7) | |
197 | + { // Blank | |
198 | + $ret .= " <td width=\"14%\" align=\"center\" class=\"style_td_blank\" height=\"19\"> </td>\n"; | |
199 | + $wday++; | |
200 | + } | |
201 | + } | |
202 | + | |
203 | + $ret .= " </tr>\n</table>\n"; | |
204 | + | |
205 | + $page = sprintf("[[%s%4d-%02d-%02d]]", $prefix, $today[year], $today[mon], $today[mday]); | |
206 | + $page_url = rawurlencode($page); | |
207 | + if(is_page($page)) { | |
208 | + $str = convert_html(join("",file(get_filename(encode($page))))); | |
209 | + $str .= "<hr><small><a href=\"$script?cmd=edit&page=$page\">[この日記を編集]</a></small>"; | |
210 | + } | |
211 | + else { | |
212 | + $str = make_link(sprintf('[[%s%4d-%02d-%02d]]',$prefix, $today[year], $today[mon], $today[mday])).'は空です。'; | |
213 | + } | |
214 | + | |
215 | + $ret .= "</td><td valign=\"top\">".$str."</td></tr></table>"; | |
216 | + | |
217 | + return $ret; | |
218 | +} | |
219 | + | |
220 | +function plugin_calendar2_action() | |
221 | +{ | |
222 | + global $command,$vars; | |
223 | + | |
224 | + $command = 'read'; | |
225 | + $page = strip_bracket($vars['page']); | |
226 | + $vars['page'] = '*'; | |
227 | + if($vars['file']) $vars['page'] = $vars['file']; | |
228 | + | |
229 | + $date = $vars['date']; | |
230 | + if($date=='') { | |
231 | + $date = date("Ym"); | |
232 | + } | |
233 | + | |
234 | + $aryargs = array($vars['page'],$date); | |
235 | + $ret["msg"] = "calendar ".$vars['page']."/".$vars['date']; | |
236 | + $ret["body"] = call_user_func_array("plugin_calendar2_convert",$aryargs); | |
237 | + | |
238 | + $vars['page'] = $page; | |
239 | + | |
240 | + return $ret; | |
241 | +} | |
242 | + | |
243 | +?> | |
\ No newline at end of file |
@@ -1,24 +1,24 @@ | ||
1 | -<? | |
2 | -function plugin_calendar_edit_convert() | |
3 | -{ | |
4 | - global $command; | |
5 | - | |
6 | - $command = edit; | |
7 | - | |
8 | - if(func_num_args()) | |
9 | - $aryargs = func_get_args(); | |
10 | - else | |
11 | - $aryargs = array(); | |
12 | - | |
13 | - | |
14 | - if(file_exists(PLUGIN_DIR."calendar.inc.php")) | |
15 | - { | |
16 | - require_once PLUGIN_DIR."calendar.inc.php"; | |
17 | - return call_user_func_array("plugin_calendar_convert",$aryargs); | |
18 | - } | |
19 | - else | |
20 | - { | |
21 | - return FALSE; | |
22 | - } | |
23 | -} | |
24 | -?> | |
1 | +<? | |
2 | +function plugin_calendar_edit_convert() | |
3 | +{ | |
4 | + global $command; | |
5 | + | |
6 | + $command = edit; | |
7 | + | |
8 | + if(func_num_args()) | |
9 | + $aryargs = func_get_args(); | |
10 | + else | |
11 | + $aryargs = array(); | |
12 | + | |
13 | + | |
14 | + if(file_exists(PLUGIN_DIR."calendar.inc.php")) | |
15 | + { | |
16 | + require_once PLUGIN_DIR."calendar.inc.php"; | |
17 | + return call_user_func_array("plugin_calendar_convert",$aryargs); | |
18 | + } | |
19 | + else | |
20 | + { | |
21 | + return FALSE; | |
22 | + } | |
23 | +} | |
24 | +?> |
@@ -1,23 +1,23 @@ | ||
1 | -<? | |
2 | -function plugin_calendar_read_convert() | |
3 | -{ | |
4 | - global $command; | |
5 | - | |
6 | - $command = read; | |
7 | - | |
8 | - if(func_num_args()) | |
9 | - $aryargs = func_get_args(); | |
10 | - else | |
11 | - $aryargs = array(); | |
12 | - | |
13 | - if(file_exists(PLUGIN_DIR."calendar.inc.php")) | |
14 | - { | |
15 | - require_once PLUGIN_DIR."calendar.inc.php"; | |
16 | - return call_user_func_array("plugin_calendar_convert",$aryargs); | |
17 | - } | |
18 | - else | |
19 | - { | |
20 | - return FALSE; | |
21 | - } | |
22 | -} | |
23 | -?> | |
1 | +<? | |
2 | +function plugin_calendar_read_convert() | |
3 | +{ | |
4 | + global $command; | |
5 | + | |
6 | + $command = read; | |
7 | + | |
8 | + if(func_num_args()) | |
9 | + $aryargs = func_get_args(); | |
10 | + else | |
11 | + $aryargs = array(); | |
12 | + | |
13 | + if(file_exists(PLUGIN_DIR."calendar.inc.php")) | |
14 | + { | |
15 | + require_once PLUGIN_DIR."calendar.inc.php"; | |
16 | + return call_user_func_array("plugin_calendar_convert",$aryargs); | |
17 | + } | |
18 | + else | |
19 | + { | |
20 | + return FALSE; | |
21 | + } | |
22 | +} | |
23 | +?> |
@@ -1,148 +1,170 @@ | ||
1 | -<? | |
2 | -global $name_cols,$comment_cols; | |
3 | - | |
4 | -///////////////////////////////////////////////// | |
5 | -// コメントの名前テキストエリアのカラム数 | |
6 | -$name_cols = 15; | |
7 | -///////////////////////////////////////////////// | |
8 | -// コメントのテキストエリアのカラム数 | |
9 | -$comment_cols = 70; | |
10 | -///////////////////////////////////////////////// | |
11 | -// コメントの挿入フォーマット(名前) | |
12 | -$name_format = '[[$name]]'; | |
13 | -///////////////////////////////////////////////// | |
14 | -// コメントの挿入フォーマット(コメント内容) | |
15 | -$comment_format = '$now $name $msg'; | |
16 | -///////////////////////////////////////////////// | |
17 | -// コメントを挿入する位置 1:欄の前 0:欄の後 | |
18 | -$comment_ins = 1; | |
19 | - | |
20 | - | |
21 | -// initialize | |
22 | -$comment_no = 0; | |
23 | - | |
24 | -function plugin_comment_action() | |
25 | -{ | |
26 | - global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup,$update_exec,$now; | |
27 | - global $name_cols,$comment_cols,$name_format,$comment_format,$comment_ins; | |
28 | - global $_title_collided,$_msg_collided,$_title_updated; | |
29 | - | |
30 | - if($post["msg"]) | |
31 | - { | |
32 | - $post["msg"] = preg_replace("/\n/","",$post["msg"]); | |
33 | - | |
34 | - $postdata = ""; | |
35 | - $postdata_old = file(get_filename(encode($post["refer"]))); | |
36 | - $comment_no = 0; | |
37 | - | |
38 | - if($post[name]) | |
39 | - { | |
40 | - $name = str_replace('$name',$post[name],$name_format); | |
41 | - } | |
42 | - if($post[msg]) | |
43 | - { | |
44 | - if(preg_match("/^(-{1,2})(.*)/",$post[msg],$match)) | |
45 | - { | |
46 | - $head = $match[1]; | |
47 | - $post[msg] = $match[2]; | |
48 | - } | |
49 | - | |
50 | - $comment = str_replace('$msg',$post[msg],$comment_format); | |
51 | - $comment = str_replace('$name',$name,$comment); | |
52 | - $comment = str_replace('$now',$now,$comment); | |
53 | - } | |
54 | - $comment = $head.$comment; | |
55 | - | |
56 | - foreach($postdata_old as $line) | |
57 | - { | |
58 | - if(!$comment_ins) $postdata .= $line; | |
59 | - if(preg_match("/^#comment/",$line)) | |
60 | - { | |
61 | - if($comment_no == $post["comment_no"] && $post[msg]!="") | |
62 | - { | |
63 | - $postdata .= "-$comment\n"; | |
64 | - } | |
65 | - $comment_no++; | |
66 | - } | |
67 | - if($comment_ins) $postdata .= $line; | |
68 | - } | |
69 | - | |
70 | - $postdata_input = "-$comment\n"; | |
71 | - } | |
72 | - | |
73 | - if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"]) | |
74 | - { | |
75 | - $title = $_title_collided; | |
76 | - | |
77 | - $body = "$_msg_collided\n"; | |
78 | - | |
79 | - $body .= "<form action=\"$script?cmd=preview\" method=\"post\">\n" | |
80 | - ."<input type=\"hidden\" name=\"refer\" value=\"".$post["refer"]."\">\n" | |
81 | - ."<input type=\"hidden\" name=\"digest\" value=\"".$post["digest"]."\">\n" | |
82 | - ."<textarea name=\"msg\" rows=\"$rows\" cols=\"$cols\" wrap=\"virtual\" id=\"textarea\">$postdata_input</textarea><br>\n" | |
83 | - ."</form>\n"; | |
84 | - } | |
85 | - else | |
86 | - { | |
87 | - $postdata = user_rules_str($postdata); | |
88 | - | |
89 | - // 差分ファイルの作成 | |
90 | - if(is_page($post["refer"])) | |
91 | - $oldpostdata = join("",file(get_filename(encode($post["refer"])))); | |
92 | - else | |
93 | - $oldpostdata = "\n"; | |
94 | - if($postdata) | |
95 | - $diffdata = do_diff($oldpostdata,$postdata); | |
96 | - file_write(DIFF_DIR,$post["refer"],$diffdata); | |
97 | - | |
98 | - // バックアップの作成 | |
99 | - if(is_page($post["refer"])) | |
100 | - $oldposttime = filemtime(get_filename(encode($post["refer"]))); | |
101 | - else | |
102 | - $oldposttime = time(); | |
103 | - | |
104 | - // 編集内容が何も書かれていないとバックアップも削除する?しないですよね。 | |
105 | - if(!$postdata && $del_backup) | |
106 | - backup_delete(BACKUP_DIR.encode($post["refer"]).".txt"); | |
107 | - else if($do_backup && is_page($post["refer"])) | |
108 | - make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime); | |
109 | - | |
110 | - // ファイルの書き込み | |
111 | - file_write(DATA_DIR,$post["refer"],$postdata); | |
112 | - | |
113 | - // is_pageのキャッシュをクリアする。 | |
114 | - is_page($post["refer"],true); | |
115 | - | |
116 | - $title = $_title_updated; | |
117 | - } | |
118 | - $retvars["msg"] = $title; | |
119 | - $retvars["body"] = $body; | |
120 | - | |
121 | - $post["page"] = $post["refer"]; | |
122 | - $vars["page"] = $post["refer"]; | |
123 | - | |
124 | - return $retvars; | |
125 | -} | |
126 | -function plugin_comment_convert() | |
127 | -{ | |
128 | - global $script,$comment_no,$vars,$name_cols,$comment_cols,$digest; | |
129 | - global $_btn_comment,$_btn_name,$vars; | |
130 | - | |
131 | - if((arg_check("read")||$vars["cmd"] == ""||arg_check("unfreeze")||arg_check("freeze")||$vars["write"]||$vars["comment"])) | |
132 | - $button = "<input type=\"submit\" name=\"comment\" value=\"$_btn_comment\">\n"; | |
133 | - | |
134 | - $string = "<form action=\"$script\" method=\"post\">\n" | |
135 | - ."<input type=\"hidden\" name=\"comment_no\" value=\"$comment_no\">\n" | |
136 | - ."<input type=\"hidden\" name=\"refer\" value=\"$vars[page]\">\n" | |
137 | - ."<input type=\"hidden\" name=\"plugin\" value=\"comment\">\n" | |
138 | - ."<input type=\"hidden\" name=\"digest\" value=\"$digest\">\n" | |
139 | - ."$_btn_name<input type=\"text\" name=\"name\" size=\"$name_cols\">\n" | |
140 | - ."<input type=\"text\" name=\"msg\" size=\"$comment_cols\">\n" | |
141 | - .$button | |
142 | - ."</form>"; | |
143 | - | |
144 | - $comment_no++; | |
145 | - | |
146 | - return $string; | |
147 | -} | |
148 | -?> | |
1 | +<? | |
2 | +global $name_cols, $comment_cols, $msg_format, $name_format; | |
3 | +global $msg_format, $now_format, $comment_format; | |
4 | +global $comment_ins, $comment_mail, $comment_no; | |
5 | + | |
6 | + | |
7 | +///////////////////////////////////////////////// | |
8 | +// ・ウ・皈?ネ、ホフセチー・ニ・ュ・ケ・ネ・ィ・?「、ホ・ォ・鬣狒 | |
9 | +$name_cols = 15; | |
10 | +///////////////////////////////////////////////// | |
11 | +// ・ウ・皈?ネ、ホ・ニ・ュ・ケ・ネ・ィ・?「、ホ・ォ・鬣狒 | |
12 | +$comment_cols = 70; | |
13 | +///////////////////////////////////////////////// | |
14 | +// ・ウ・皈?ネ、ホヂニ?・ユ・ゥ。シ・゙・テ・ネ | |
15 | +$name_format = '[[$name]]'; | |
16 | +$msg_format = '$msg'; | |
17 | +$now_format = 'SIZE(1):$now'; | |
18 | +///////////////////////////////////////////////// | |
19 | +// ・ウ・皈?ネ、ホヂニ?・ユ・ゥ。シ・゙・テ・ネ(・ウ・皈?ネニ簣ニ) | |
20 | +$comment_format = '$msg -- $name $now'; | |
21 | +///////////////////////////////////////////////// | |
22 | +// ・ウ・皈?ネ、?゙ニ?、ケ、?フテヨ 1:ヘ?ホチー 0:ヘ?ホク | |
23 | +$comment_ins = 1; | |
24 | +///////////////////////////////////////////////// | |
25 | +// ・ウ・皈?ネ、ャナ?ニ、オ、?ソセ?遑「ニ簣ニ、?癸シ・?ヌチ?? | |
26 | +$comment_mail = FALSE; | |
27 | + | |
28 | +// initialize | |
29 | +$comment_no = 0; | |
30 | + | |
31 | +function plugin_comment_action() | |
32 | +{ | |
33 | + global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup,$update_exec,$now; | |
34 | + global $name_cols,$comment_cols,$name_format,$msg_format,$now_format,$comment_format,$comment_ins; | |
35 | + global $_title_collided,$_msg_collided,$_title_updated; | |
36 | + global $_msg_comment_collided,$_title_comment_collided; | |
37 | + | |
38 | + $_comment_format = $comment_format; | |
39 | + if($post["nodate"]=="1") { | |
40 | + $_comment_format = str_replace('$now','',$_comment_format); | |
41 | + } | |
42 | + if($post["msg"]=="") { | |
43 | + $retvars["msg"] = $name; | |
44 | + $post["page"] = $post["refer"]; | |
45 | + $vars["page"] = $post["refer"]; | |
46 | + $retvars["body"] = convert_html(join("",file(get_filename(encode($post["refer"]))))); | |
47 | + return $retvars; | |
48 | + } | |
49 | + if($post["msg"]) | |
50 | + { | |
51 | + $post["msg"] = preg_replace("/\n/","",$post["msg"]); | |
52 | + | |
53 | + $postdata = ""; | |
54 | + $postdata_old = file(get_filename(encode($post["refer"]))); | |
55 | + $comment_no = 0; | |
56 | + | |
57 | + if($post["name"]) | |
58 | + { | |
59 | + $name = str_replace('$name',$post["name"],$name_format); | |
60 | + } | |
61 | + if($post["msg"]) | |
62 | + { | |
63 | + if(preg_match("/^(-{1,2})(.*)/",$post["msg"],$match)) | |
64 | + { | |
65 | + $head = $match[1]; | |
66 | + $post["msg"] = $match[2]; | |
67 | + } | |
68 | + | |
69 | + $comment = str_replace('$msg',str_replace('$msg',$post["msg"],$msg_format),$_comment_format); | |
70 | + $comment = str_replace('$name',$name,$comment); | |
71 | + $comment = str_replace('$now',str_replace('$now',$now,$now_format),$comment); | |
72 | + $comment = $head.$comment; | |
73 | + } | |
74 | + | |
75 | + foreach($postdata_old as $line) | |
76 | + { | |
77 | + if(!$comment_ins) $postdata .= $line; | |
78 | + if(preg_match("/^#comment/",$line)) | |
79 | + { | |
80 | + if($comment_no == $post["comment_no"] && $post[msg]!="") | |
81 | + { | |
82 | + $postdata .= "-$comment\n"; | |
83 | + } | |
84 | + $comment_no++; | |
85 | + } | |
86 | + if($comment_ins) $postdata .= $line; | |
87 | + } | |
88 | + | |
89 | + $postdata_input = "-$comment\n"; | |
90 | + } | |
91 | + | |
92 | + $title = $_title_updated; | |
93 | + if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"]) | |
94 | + { | |
95 | + $title = $_title_comment_collided; | |
96 | + $body = $_msg_comment_collided . make_link($post["refer"]); | |
97 | + } | |
98 | + | |
99 | + $postdata = user_rules_str($postdata); | |
100 | + | |
101 | + // コケハャ・ユ・。・、・?ホコ?ョ | |
102 | + if(is_page($post["refer"])) | |
103 | + $oldpostdata = join("",file(get_filename(encode($post["refer"])))); | |
104 | + else | |
105 | + $oldpostdata = "\n"; | |
106 | + if($postdata) | |
107 | + $diffdata = do_diff($oldpostdata,$postdata); | |
108 | + file_write(DIFF_DIR,$post["refer"],$diffdata); | |
109 | + // ・ミ・テ・ッ・「・テ・ラ、ホコ?ョ | |
110 | + if(is_page($post["refer"])) | |
111 | + $oldposttime = filemtime(get_filename(encode($post["refer"]))); | |
112 | + else | |
113 | + $oldposttime = time(); | |
114 | + | |
115 | + // ハヤスクニ簣ニ、ャイソ、篆?ォ、?ニ、、、ハ、、、ネ・ミ・テ・ッ・「・テ・ラ、篌??ケ、?、キ、ハ、、、ヌ、ケ、隍ヘ。」 | |
116 | + if(!$postdata && $del_backup) | |
117 | + backup_delete(BACKUP_DIR.encode($post["refer"]).".txt"); | |
118 | + else if($do_backup && is_page($post["refer"])) | |
119 | + make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime); | |
120 | + | |
121 | + // ・ユ・。・、・?ホス?ュケ?、゚ | |
122 | + file_write(DATA_DIR,$post["refer"],$postdata); | |
123 | + | |
124 | + // is_page、ホ・ュ・罕テ・キ・螟?ッ・?「、ケ、?」 | |
125 | + is_page($post["refer"],true); | |
126 | + | |
127 | + $retvars["msg"] = $title; | |
128 | + $retvars["body"] = $body; | |
129 | + | |
130 | + $post["page"] = $post["refer"]; | |
131 | + $vars["page"] = $post["refer"]; | |
132 | + | |
133 | + return $retvars; | |
134 | +} | |
135 | +function plugin_comment_convert() | |
136 | +{ | |
137 | + global $script,$comment_no,$vars,$name_cols,$comment_cols,$digest; | |
138 | + global $_btn_comment,$_btn_name,$_msg_comment,$vars; | |
139 | + | |
140 | + $options = func_get_args(); | |
141 | + | |
142 | + $nametags = "$_btn_name<input type=\"text\" name=\"name\" size=\"$name_cols\">\n"; | |
143 | + if(is_array($options) && in_array("noname",$options)) { | |
144 | + $nametags = $_msg_comment; | |
145 | + } | |
146 | + | |
147 | + $nodate = '0'; | |
148 | + if(is_array($options) && in_array("nodate",$options)) { | |
149 | + $nodate = '1'; | |
150 | + } | |
151 | + | |
152 | + if((arg_check("read")||$vars["cmd"] == ""||arg_check("unfreeze")||arg_check("freeze")||$vars["write"]||$vars["comment"])) | |
153 | + $button = "<input type=\"submit\" name=\"comment\" value=\"$_btn_comment\">\n"; | |
154 | + | |
155 | + $string = "<p><form action=\"$script\" method=\"post\">\n" | |
156 | + ."<input type=\"hidden\" name=\"comment_no\" value=\"$comment_no\">\n" | |
157 | + ."<input type=\"hidden\" name=\"refer\" value=\"$vars[page]\">\n" | |
158 | + ."<input type=\"hidden\" name=\"plugin\" value=\"comment\">\n" | |
159 | + ."<input type=\"hidden\" name=\"nodate\" value=\"$nodate\">\n" | |
160 | + ."<input type=\"hidden\" name=\"digest\" value=\"$digest\">\n" | |
161 | + ."$nametags" | |
162 | + ."<input type=\"text\" name=\"msg\" size=\"$comment_cols\">\n" | |
163 | + .$button | |
164 | + ."</form>"; | |
165 | + | |
166 | + $comment_no++; | |
167 | + | |
168 | + return $string; | |
169 | +} | |
170 | +?> |
@@ -0,0 +1,52 @@ | ||
1 | +<? | |
2 | +/* | |
3 | + * PukiWiki カウンタープラグイン | |
4 | + * | |
5 | + * CopyRight 2002 Y.MASUI GPL2 | |
6 | + * http://masui.net/pukiwiki/ masui@masui.net | |
7 | + */ | |
8 | + | |
9 | +// counter file | |
10 | +define(COUNTER_DIR, "./counter/"); | |
11 | + | |
12 | +function plugin_counter_convert() | |
13 | +{ | |
14 | + global $vars; | |
15 | + | |
16 | + $file = COUNTER_DIR.encode($vars["page"]).".count"; | |
17 | + if(!file_exists($file)) | |
18 | + { | |
19 | + $nf = fopen($file, "w"); | |
20 | + fputs($nf,"0\n0\n0\n0\n\n"); | |
21 | + fclose($nf); | |
22 | + } | |
23 | + $array = file($file); | |
24 | + $count = rtrim($array[0]); | |
25 | + $today = rtrim($array[1]); | |
26 | + $today_count = rtrim($array[2]); | |
27 | + $yesterday_count = rtrim($array[3]); | |
28 | + $ip = rtrim($array[4]); | |
29 | + if($ip != $_SERVER["REMOTE_ADDR"] && !(arg_check("add") || arg_check("edit") || arg_check("preview") || $vars['preview'] != '' || $vars['write'] != '')) { | |
30 | + $t = date("Y/m/d"); | |
31 | + if($t != $today) { | |
32 | + $yesterday_count = $today_count; | |
33 | + $today_count = 0; | |
34 | + $today = $t; | |
35 | + } | |
36 | + ++$count; | |
37 | + ++$today_count; | |
38 | + } | |
39 | + | |
40 | + $ip = $_SERVER["REMOTE_ADDR"]; | |
41 | + $nf = fopen($file, "w"); | |
42 | + fputs($nf,"$count\n"); | |
43 | + fputs($nf,"$today\n"); | |
44 | + fputs($nf,"$today_count\n"); | |
45 | + fputs($nf,"$yesterday_count\n"); | |
46 | + fputs($nf,"$ip\n"); | |
47 | + fclose($nf); | |
48 | + | |
49 | + return "<font size='1'>Counter: $count, today: $today_count, yesterday: $yesterday_count</font>"; | |
50 | + | |
51 | +} | |
52 | +?> |
@@ -0,0 +1,20 @@ | ||
1 | +<? | |
2 | +function plugin_img_convert() | |
3 | +{ | |
4 | + if(func_num_args()!=2) { | |
5 | + return; | |
6 | + } | |
7 | + $aryargs = func_get_args(); | |
8 | + $url = $aryargs[0]; | |
9 | + $align = strtoupper($aryargs[1]); | |
10 | + | |
11 | + if($align == 'R' || $align == 'RIGHT') { | |
12 | + $align = 'right'; | |
13 | + } | |
14 | + else { | |
15 | + $align = 'left'; | |
16 | + } | |
17 | + | |
18 | + return "<div style=\"float:$align\"><img src=\"$url\"></div>"; | |
19 | +} | |
20 | +?> |
@@ -0,0 +1,121 @@ | ||
1 | +<? | |
2 | +///////////////////////////////////////////////// | |
3 | +// テキストエリアのカラム数 | |
4 | +define("INSERT_COLS",70); | |
5 | +///////////////////////////////////////////////// | |
6 | +// テキストエリアの行数 | |
7 | +define("INSERT_ROWS",5); | |
8 | +///////////////////////////////////////////////// | |
9 | +// 挿入する位置 1:欄の前 0:欄の後 | |
10 | +define("INSERT_INS",1); | |
11 | + | |
12 | +function plugin_insert_action() | |
13 | +{ | |
14 | + global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup; | |
15 | + global $_title_collided,$_msg_collided,$_title_updated; | |
16 | + | |
17 | + if($post["msg"]) | |
18 | + { | |
19 | + $postdata = ""; | |
20 | + $postdata_old = file(get_filename(encode($post["refer"]))); | |
21 | + $insert_no = 0; | |
22 | + | |
23 | + if($post[msg]) | |
24 | + { | |
25 | + $insert = $post[msg]; | |
26 | + } | |
27 | + | |
28 | + foreach($postdata_old as $line) | |
29 | + { | |
30 | + if(!INSERT_INS) $postdata .= $line; | |
31 | + if(preg_match("/^#insert$/",$line)) | |
32 | + { | |
33 | + if($insert_no == $post["insert_no"] && $post[msg]!="") | |
34 | + { | |
35 | + $postdata .= "$insert\n"; | |
36 | + } | |
37 | + $insert_no++; | |
38 | + } | |
39 | + if(INSERT_INS) $postdata .= $line; | |
40 | + } | |
41 | + | |
42 | + $postdata_input = "$insert\n"; | |
43 | + } | |
44 | + else | |
45 | + return; | |
46 | + | |
47 | + if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"]) | |
48 | + { | |
49 | + $title = $_title_collided; | |
50 | + | |
51 | + $body = "$_msg_collided\n"; | |
52 | + | |
53 | + $body .= "<form action=\"$script?cmd=preview\" method=\"post\">\n" | |
54 | + ."<input type=\"hidden\" name=\"refer\" value=\"".$post["refer"]."\">\n" | |
55 | + ."<input type=\"hidden\" name=\"digest\" value=\"".$post["digest"]."\">\n" | |
56 | + ."<textarea name=\"msg\" rows=\"$rows\" cols=\"$cols\" wrap=\"virtual\" id=\"textarea\">$postdata_input</textarea><br>\n" | |
57 | + ."</form>\n"; | |
58 | + } | |
59 | + else | |
60 | + { | |
61 | + $postdata = user_rules_str($postdata); | |
62 | + | |
63 | + // 差分ファイルの作成 | |
64 | + if(is_page($post["refer"])) | |
65 | + $oldpostdata = join("",file(get_filename(encode($post["refer"])))); | |
66 | + else | |
67 | + $oldpostdata = "\n"; | |
68 | + if($postdata) | |
69 | + $diffdata = do_diff($oldpostdata,$postdata); | |
70 | + file_write(DIFF_DIR,$post["refer"],$diffdata); | |
71 | + | |
72 | + // バックアップの作成 | |
73 | + if(is_page($post["refer"])) | |
74 | + $oldposttime = filemtime(get_filename(encode($post["refer"]))); | |
75 | + else | |
76 | + $oldposttime = time(); | |
77 | + | |
78 | + // 編集内容が何も書かれていないとバックアップも削除する?しないですよね。 | |
79 | + if(!$postdata && $del_backup) | |
80 | + backup_delete(BACKUP_DIR.encode($post["refer"]).".txt"); | |
81 | + else if($do_backup && is_page($post["refer"])) | |
82 | + make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime); | |
83 | + | |
84 | + // ファイルの書き込み | |
85 | + file_write(DATA_DIR,$post["refer"],$postdata); | |
86 | + | |
87 | + // is_pageのキャッシュをクリアする。 | |
88 | + is_page($post["refer"],true); | |
89 | + | |
90 | + $title = $_title_updated; | |
91 | + } | |
92 | + $retvars["msg"] = $title; | |
93 | + $retvars["body"] = $body; | |
94 | + | |
95 | + $post["page"] = $post["refer"]; | |
96 | + $vars["page"] = $post["refer"]; | |
97 | + | |
98 | + return $retvars; | |
99 | +} | |
100 | +function plugin_insert_convert() | |
101 | +{ | |
102 | + global $script,$insert_no,$vars,$digest; | |
103 | + global $_btn_insert,$vars; | |
104 | + | |
105 | + if((arg_check("read")||$vars["cmd"] == ""||arg_check("unfreeze")||arg_check("freeze")||$vars["write"]||$vars["insert"])) | |
106 | + $button = "<input type=\"submit\" name=\"insert\" value=\"$_btn_insert\">\n"; | |
107 | + | |
108 | + $string = "<form action=\"$script\" method=\"post\">\n" | |
109 | + ."<input type=\"hidden\" name=\"insert_no\" value=\"$insert_no\">\n" | |
110 | + ."<input type=\"hidden\" name=\"refer\" value=\"$vars[page]\">\n" | |
111 | + ."<input type=\"hidden\" name=\"plugin\" value=\"insert\">\n" | |
112 | + ."<input type=\"hidden\" name=\"digest\" value=\"$digest\">\n" | |
113 | + ."<textarea name=\"msg\" rows=\"".INSERT_ROWS."\" cols=\"".INSERT_COLS."\">\n</textarea><br>\n" | |
114 | + .$button | |
115 | + ."</form>"; | |
116 | + | |
117 | + $insert_no++; | |
118 | + | |
119 | + return $string; | |
120 | +} | |
121 | +?> |
@@ -1,37 +1,37 @@ | ||
1 | -<? | |
2 | -function plugin_lookup_convert() | |
3 | -{ | |
4 | - global $script,$vars; | |
5 | - | |
6 | - $args = func_get_args(); | |
7 | - | |
8 | - if(func_num_args() < 2) return FALSE; | |
9 | - | |
10 | - $iwn = trim(strip_tags($args[0])); | |
11 | - $btn = trim(strip_tags($args[1])); | |
12 | - $default = trim(strip_tags($args[2])); | |
13 | - | |
14 | - $ret = "<form action=\"$script\" method=\"post\">\n"; | |
15 | - $ret.= "<input type=\"hidden\" name=\"plugin\" value=\"lookup\">\n"; | |
16 | - $ret.= "<input type=\"hidden\" name=\"refer\" value=\"$vars[page]\">\n"; | |
17 | - $ret.= "<input type=\"hidden\" name=\"inter\" value=\"$iwn\">\n"; | |
18 | - $ret.= "$iwn:\n"; | |
19 | - $ret.= "<input type=\"text\" name=\"page\" size=\"30\" value=\"$default\">\n"; | |
20 | - $ret.= "<input type=\"submit\" value=\"$btn\">\n"; | |
21 | - $ret.= "</form>\n"; | |
22 | - | |
23 | - return $ret; | |
24 | -} | |
25 | -function plugin_lookup_action() | |
26 | -{ | |
27 | - global $vars,$script; | |
28 | - | |
29 | - if(!$vars["inter"] || !$vars["page"]) return; | |
30 | - | |
31 | - $interwikiname = "[[".$vars["inter"].":".$vars["page"]."]]"; | |
32 | - $interwikiname = rawurlencode($interwikiname); | |
33 | - | |
34 | - header("Location: $script?$interwikiname"); | |
35 | - die(); | |
36 | -} | |
37 | -?> | |
1 | +<? | |
2 | +function plugin_lookup_convert() | |
3 | +{ | |
4 | + global $script,$vars; | |
5 | + | |
6 | + $args = func_get_args(); | |
7 | + | |
8 | + if(func_num_args() < 2) return FALSE; | |
9 | + | |
10 | + $iwn = trim(strip_tags($args[0])); | |
11 | + $btn = trim(strip_tags($args[1])); | |
12 | + $default = trim(strip_tags($args[2])); | |
13 | + | |
14 | + $ret = "<form action=\"$script\" method=\"post\">\n"; | |
15 | + $ret.= "<input type=\"hidden\" name=\"plugin\" value=\"lookup\">\n"; | |
16 | + $ret.= "<input type=\"hidden\" name=\"refer\" value=\"$vars[page]\">\n"; | |
17 | + $ret.= "<input type=\"hidden\" name=\"inter\" value=\"$iwn\">\n"; | |
18 | + $ret.= "$iwn:\n"; | |
19 | + $ret.= "<input type=\"text\" name=\"page\" size=\"30\" value=\"$default\">\n"; | |
20 | + $ret.= "<input type=\"submit\" value=\"$btn\">\n"; | |
21 | + $ret.= "</form>\n"; | |
22 | + | |
23 | + return $ret; | |
24 | +} | |
25 | +function plugin_lookup_action() | |
26 | +{ | |
27 | + global $vars,$script; | |
28 | + | |
29 | + if(!$vars["inter"] || !$vars["page"]) return; | |
30 | + | |
31 | + $interwikiname = "[[".$vars["inter"].":".$vars["page"]."]]"; | |
32 | + $interwikiname = rawurlencode($interwikiname); | |
33 | + | |
34 | + header("Location: $script?$interwikiname"); | |
35 | + die(); | |
36 | +} | |
37 | +?> |
@@ -0,0 +1,62 @@ | ||
1 | +<? | |
2 | +/* | |
3 | + * PukiWiki lsプラグイン | |
4 | + * | |
5 | + * CopyRight 2002 Y.MASUI GPL2 | |
6 | + * http://masui.net/pukiwiki/ masui@masui.net | |
7 | + */ | |
8 | + | |
9 | +function plugin_ls_convert() | |
10 | +{ | |
11 | + global $vars, $script; | |
12 | + | |
13 | + if(func_num_args()) | |
14 | + $aryargs = func_get_args(); | |
15 | + else | |
16 | + $aryargs = array(); | |
17 | + | |
18 | + $with_title = FALSE; | |
19 | + if(array_search('title',$aryargs)!==FALSE) { | |
20 | + $with_title = TRUE; | |
21 | + } | |
22 | + $ls = $comment = ''; | |
23 | + $filepattern = encode('[['.strip_bracket($vars["page"]).'/'); | |
24 | + $filepattern_len = strlen($filepattern); | |
25 | + if ($dir = @opendir(DATA_DIR)) | |
26 | + { | |
27 | + while($file = readdir($dir)) | |
28 | + { | |
29 | + if($file == ".." || $file == ".") continue; | |
30 | + if(substr($file,0,$filepattern_len)!=$filepattern) continue; | |
31 | + $page = decode(trim(preg_replace("/\.txt$/"," ",$file))); | |
32 | + if($with_title) { | |
33 | + $comment = ''; | |
34 | + $fd = fopen(DATA_DIR . $file,'r'); | |
35 | + if(!feof ($fd)) { | |
36 | + $comment = ereg_replace("^[-*]+",'',fgets($fd,1024)); | |
37 | + $comment = ereg_replace("[~\r\n]+$",'',$comment); | |
38 | + $comment = trim($comment); | |
39 | + } | |
40 | + if($comment != '' && substr($comment,0,1) != '#') { | |
41 | + $comment = " - " . convert_html($comment); | |
42 | + } | |
43 | + else { | |
44 | + $comment = ''; | |
45 | + } | |
46 | + fclose($fd); | |
47 | + } | |
48 | + $url = rawurlencode($page); | |
49 | + $name = strip_bracket($page); | |
50 | + $title = $name ." " .get_pg_passage($page,false); | |
51 | + $ls .= "<li><a href=\"$script?cmd=read&page=$url\" title=\"$title\">$name</a>$comment\n"; | |
52 | + } | |
53 | + closedir($dir); | |
54 | + } | |
55 | + | |
56 | + if($ls=='') { | |
57 | + return ''; | |
58 | + } | |
59 | + | |
60 | + return "<ul>$ls</ul>"; | |
61 | +} | |
62 | +?> |
@@ -0,0 +1,126 @@ | ||
1 | +<? | |
2 | +///////////////////////////////////////////////// | |
3 | +// テキストエリアのカラム数 | |
4 | +define("MEMO_COLS",80); | |
5 | +///////////////////////////////////////////////// | |
6 | +// テキストエリアの行数 | |
7 | +define("MEMO_ROWS",5); | |
8 | + | |
9 | +function plugin_memo_action() | |
10 | +{ | |
11 | + global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup; | |
12 | + global $_title_collided,$_msg_collided,$_title_updated; | |
13 | + | |
14 | + $post["msg"] = preg_replace("/(\x0D\x0A)/","\n",$post["msg"]); | |
15 | + $post["msg"] = preg_replace("/(\x0D)/","\n",$post["msg"]); | |
16 | + $post["msg"] = preg_replace("/(\x0A)/","\n",$post["msg"]); | |
17 | + | |
18 | + if($post["msg"]) | |
19 | + { | |
20 | + $post["msg"] = str_replace("\n","\\n",$post["msg"]); | |
21 | + | |
22 | + $postdata = ""; | |
23 | + $postdata_old = file(get_filename(encode($post["refer"]))); | |
24 | + $memo_no = 0; | |
25 | + | |
26 | + $memo_body = $post["msg"]; | |
27 | + | |
28 | + foreach($postdata_old as $line) | |
29 | + { | |
30 | + if(preg_match("/^#memo\(?.*\)?$/",$line)) | |
31 | + { | |
32 | + if($memo_no == $post["memo_no"] && $post["msg"]!="") | |
33 | + { | |
34 | + $postdata .= "#memo($memo_body)\n"; | |
35 | + $line = ""; | |
36 | + } | |
37 | + $memo_no++; | |
38 | + } | |
39 | + $postdata .= $line; | |
40 | + } | |
41 | + | |
42 | + $postdata_input = "$memo_body\n"; | |
43 | + } | |
44 | + else | |
45 | + return; | |
46 | + | |
47 | + if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"]) | |
48 | + { | |
49 | + $title = $_title_collided; | |
50 | + | |
51 | + $body = "$_msg_collided\n"; | |
52 | + | |
53 | + $body .= "<form action=\"$script?cmd=preview\" method=\"post\">\n" | |
54 | + ."<input type=\"hidden\" name=\"refer\" value=\"".$post["refer"]."\">\n" | |
55 | + ."<input type=\"hidden\" name=\"digest\" value=\"".$post["digest"]."\">\n" | |
56 | + ."<textarea name=\"msg\" rows=\"$rows\" cols=\"$cols\" wrap=\"virtual\" id=\"textarea\">$postdata_input</textarea><br>\n" | |
57 | + ."</form>\n"; | |
58 | + } | |
59 | + else | |
60 | + { | |
61 | + $postdata = user_rules_str($postdata); | |
62 | + | |
63 | + // 差分ファイルの作成 | |
64 | + if(is_page($post["refer"])) | |
65 | + $oldpostdata = join("",file(get_filename(encode($post["refer"])))); | |
66 | + else | |
67 | + $oldpostdata = "\n"; | |
68 | + if($postdata) | |
69 | + $diffdata = do_diff($oldpostdata,$postdata); | |
70 | + file_write(DIFF_DIR,$post["refer"],$diffdata); | |
71 | + | |
72 | + // バックアップの作成 | |
73 | + if(is_page($post["refer"])) | |
74 | + $oldposttime = filemtime(get_filename(encode($post["refer"]))); | |
75 | + else | |
76 | + $oldposttime = time(); | |
77 | + | |
78 | + // 編集内容が何も書かれていないとバックアップも削除する?しないですよね。 | |
79 | + if(!$postdata && $del_backup) | |
80 | + backup_delete(BACKUP_DIR.encode($post["refer"]).".txt"); | |
81 | + else if($do_backup && is_page($post["refer"])) | |
82 | + make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime); | |
83 | + | |
84 | + // ファイルの書き込み | |
85 | + file_write(DATA_DIR,$post["refer"],$postdata); | |
86 | + | |
87 | + // is_pageのキャッシュをクリアする。 | |
88 | + is_page($post["refer"],true); | |
89 | + | |
90 | + $title = $_title_updated; | |
91 | + } | |
92 | + $retvars["msg"] = $title; | |
93 | + $retvars["body"] = $body; | |
94 | + | |
95 | + $post["page"] = $post["refer"]; | |
96 | + $vars["page"] = $post["refer"]; | |
97 | + | |
98 | + return $retvars; | |
99 | +} | |
100 | +function plugin_memo_convert() | |
101 | +{ | |
102 | + global $script,$memo_no,$vars,$digest; | |
103 | + global $_btn_memo_update,$vars; | |
104 | + | |
105 | + if(func_num_args()) | |
106 | + $aryargs = func_get_args(); | |
107 | + | |
108 | + $data = str_replace("\\n","\n",$aryargs[0]); | |
109 | + | |
110 | + if((arg_check("read")||$vars["cmd"] == ""||arg_check("unfreeze")||arg_check("freeze")||$vars["write"]||$vars["memo"])) | |
111 | + $button = "<input type=\"submit\" name=\"memo\" value=\"$_btn_memo_update\">\n"; | |
112 | + | |
113 | + $string = "<form action=\"$script\" method=\"post\" class=\"memo\">\n" | |
114 | + ."<input type=\"hidden\" name=\"memo_no\" value=\"$memo_no\">\n" | |
115 | + ."<input type=\"hidden\" name=\"refer\" value=\"$vars[page]\">\n" | |
116 | + ."<input type=\"hidden\" name=\"plugin\" value=\"memo\">\n" | |
117 | + ."<input type=\"hidden\" name=\"digest\" value=\"$digest\">\n" | |
118 | + ."<textarea name=\"msg\" rows=\"".MEMO_ROWS."\" cols=\"".MEMO_COLS."\">\n$data</textarea><br>\n" | |
119 | + .$button | |
120 | + ."</form>"; | |
121 | + | |
122 | + $memo_no++; | |
123 | + | |
124 | + return $string; | |
125 | +} | |
126 | +?> |
@@ -0,0 +1,52 @@ | ||
1 | +<? | |
2 | +function plugin_newpage_init() | |
3 | +{ | |
4 | + $_plugin_recent_messages = array( | |
5 | + '_msg_newpage' => 'ページ新規作成' | |
6 | + ); | |
7 | + set_plugin_messages($_plugin_recent_messages); | |
8 | +} | |
9 | + | |
10 | +function plugin_newpage_convert() | |
11 | +{ | |
12 | + global $script,$vars,$_btn_edit,$_msg_newpage; | |
13 | + | |
14 | + $ret = "<form action=\"$script\" method=\"post\">\n"; | |
15 | + $ret.= "<input type=\"hidden\" name=\"plugin\" value=\"newpage\">\n"; | |
16 | + $ret.= "<input type=\"hidden\" name=\"refer\" value=\"$vars[page]\">\n"; | |
17 | + $ret.= "$_msg_newpage: "; | |
18 | + $ret.= "<input type=\"text\" name=\"page\" size=\"30\" value=\"\">\n"; | |
19 | + $ret.= "<input type=\"submit\" value=\"$_btn_edit\">\n"; | |
20 | + $ret.= "</form>\n"; | |
21 | + | |
22 | + return $ret; | |
23 | +} | |
24 | + | |
25 | +function plugin_newpage_action() | |
26 | +{ | |
27 | + global $vars,$script,$_btn_edit,$_msg_newpage; | |
28 | + | |
29 | + if(!$vars["page"]) { | |
30 | + $retvars["msg"] = $_msg_newpage; | |
31 | + $retvars["body"] = "<form action=\"$script\" method=\"post\">\n"; | |
32 | + $retvars["body"].= "<input type=\"hidden\" name=\"plugin\" value=\"newpage\">\n"; | |
33 | + $retvars["body"].= "<input type=\"hidden\" name=\"refer\" value=\"$vars[page]\">\n"; | |
34 | + $retvars["body"].= "$_msg_newpage: "; | |
35 | + $retvars["body"].= "<input type=\"text\" name=\"page\" size=\"30\" value=\"\">\n"; | |
36 | + $retvars["body"].= "<input type=\"submit\" value=\"$_btn_edit\">\n"; | |
37 | + $retvars["body"].= "</form>\n"; | |
38 | + | |
39 | + return $retvars; | |
40 | + } | |
41 | + | |
42 | + if(!preg_match("/^($BracketName)|($InterWikiName)$/",$vars["page"])) | |
43 | + { | |
44 | + $vars["page"] = "[[$vars[page]]]"; | |
45 | + } | |
46 | + | |
47 | + $wikiname = rawurlencode($vars["page"]); | |
48 | + | |
49 | + header("Location: $script?$wikiname"); | |
50 | + die(); | |
51 | +} | |
52 | +?> |
@@ -1,48 +1,48 @@ | ||
1 | -<? | |
2 | - | |
3 | -// user list file | |
4 | -define(USR_LST, "user.dat"); | |
5 | -// time out sec | |
6 | -define(TIMEOUT, 300); | |
7 | - | |
8 | -function plugin_online_convert() | |
9 | -{ | |
10 | - global $HTTP_SERVER_VARS; | |
11 | - | |
12 | - if(!file_exists(USR_LST)) | |
13 | - { | |
14 | - $nf = fopen(USR_LST, "w"); | |
15 | - fclose($nf); | |
16 | - } | |
17 | - CheckUser($HTTP_SERVER_VARS["REMOTE_ADDR"]); | |
18 | - return UserCount(); | |
19 | -} | |
20 | - | |
21 | -function CheckUser($addr) | |
22 | -{ | |
23 | - $usr_arr = file(USR_LST); | |
24 | - $fp = fopen(USR_LST, "w"); | |
25 | - while(!flock($fp,LOCK_EX)); | |
26 | - $now = time(); | |
27 | - for($i = 0; $i < count($usr_arr); $i++) | |
28 | - { | |
29 | - list($ip_addr,$tim_stmp) = explode("|", $usr_arr[$i]); | |
30 | - if(($now-$tim_stmp) < TIMEOUT) | |
31 | - { | |
32 | - if($ip_addr != $addr) | |
33 | - { | |
34 | - fputs($fp, "$ip_addr|$tim_stmp"); | |
35 | - } | |
36 | - } | |
37 | - } | |
38 | - fputs($fp, "$addr|$now\n"); | |
39 | - flock($fp,LOCK_UN); | |
40 | - fclose($fp); | |
41 | -} | |
42 | - | |
43 | -function UserCount() | |
44 | -{ | |
45 | - $usr_arr = file(USR_LST); | |
46 | - return count($usr_arr); | |
47 | -} | |
48 | -?> | |
1 | +<? | |
2 | + | |
3 | +// user list file | |
4 | +define(USR_LST, "counter/user.dat"); | |
5 | +// time out sec | |
6 | +define(TIMEOUT, 300); | |
7 | + | |
8 | +function plugin_online_convert() | |
9 | +{ | |
10 | + global $HTTP_SERVER_VARS; | |
11 | + | |
12 | + if(!file_exists(USR_LST)) | |
13 | + { | |
14 | + $nf = fopen(USR_LST, "w"); | |
15 | + fclose($nf); | |
16 | + } | |
17 | + CheckUser($HTTP_SERVER_VARS["REMOTE_ADDR"]); | |
18 | + return UserCount(); | |
19 | +} | |
20 | + | |
21 | +function CheckUser($addr) | |
22 | +{ | |
23 | + $usr_arr = file(USR_LST); | |
24 | + $fp = fopen(USR_LST, "w"); | |
25 | + while(!flock($fp,LOCK_EX)); | |
26 | + $now = time(); | |
27 | + for($i = 0; $i < count($usr_arr); $i++) | |
28 | + { | |
29 | + list($ip_addr,$tim_stmp) = explode("|", $usr_arr[$i]); | |
30 | + if(($now-$tim_stmp) < TIMEOUT) | |
31 | + { | |
32 | + if($ip_addr != $addr) | |
33 | + { | |
34 | + fputs($fp, "$ip_addr|$tim_stmp"); | |
35 | + } | |
36 | + } | |
37 | + } | |
38 | + fputs($fp, "$addr|$now\n"); | |
39 | + flock($fp,LOCK_UN); | |
40 | + fclose($fp); | |
41 | +} | |
42 | + | |
43 | +function UserCount() | |
44 | +{ | |
45 | + $usr_arr = file(USR_LST); | |
46 | + return count($usr_arr); | |
47 | +} | |
48 | +?> |
@@ -1,64 +1,81 @@ | ||
1 | - | |
2 | -///////////////////////////////////////////////// | |
3 | -// プラグインディレクトリについて | |
4 | - | |
5 | - PukiWikiのページのHTMLへのコンバート時と、プラグイン機能からの値を受け取って | |
6 | - 処理を行うプラグインを設置することができます。 | |
7 | - | |
8 | - このテキストは、そのプラグインの記述方法についての説明をします。 | |
9 | - | |
10 | - | |
11 | -///////////////////////////////////////////////// | |
12 | -// ページ内でのプラグインの呼び出し | |
13 | - | |
14 | - #プラグイン名 | |
15 | - #プラグイン名(arg1,arg2...) | |
16 | - | |
17 | - 行頭にスペースは含めることはできない。 | |
18 | - 引数内に括弧()を使用することができる。ただし ) 単体は不可。 | |
19 | - 引数を指定しなくても呼び出せる | |
20 | - | |
21 | - | |
22 | -///////////////////////////////////////////////// | |
23 | -// ファイル名 | |
24 | - | |
25 | - プラグイン名.inc.php | |
26 | - | |
27 | - | |
28 | -///////////////////////////////////////////////// | |
29 | -// 関数 | |
30 | - | |
31 | - ■function plugin_プラグイン名_convert() | |
32 | - | |
33 | - HTMLへのコンバート時に呼び出される | |
34 | - | |
35 | - 引数は func_get_args() で配列へ格納できる。([0]〜[n]) | |
36 | - func_num_args() によって、渡された引数の数を求めることができる。 | |
37 | - | |
38 | - ■function plugin_プラグイン名_action() | |
39 | - | |
40 | - GET・POSTメソッドでpluginを指定されたときに呼び出される | |
41 | - | |
42 | - 返値に array("msg" => "$1 is page") などを返すと $1 をページ名として | |
43 | - ページタイトルに置換される | |
44 | - | |
45 | - die() を実行することにより、ページに戻らないようにできる | |
46 | - | |
47 | -///////////////////////////////////////////////// | |
48 | -// ファイル内容 | |
49 | - | |
50 | - ユーザに設定させる初期値などについては、define で定義する。 | |
51 | - | |
52 | - コンバート時のGET・POSTの出力内容に必要なものは refer と plugin という値で、 | |
53 | - refer : そのページの名前($vars["page"]) | |
54 | - plugin : プラグイン名 | |
55 | - とします。 | |
56 | - | |
57 | - 以下の値を global でグローバル変数にすることによって値を取得できます。 | |
58 | - | |
59 | - $script : スクリプト名 | |
60 | - $get : GETメソッドによるHTTPからの引数 | |
61 | - $post : POSTメソッドによるHTTPからの引数 | |
62 | - $vars : GET・POST両方のメソッドによるHTTPからの引数 | |
63 | - | |
64 | - $vars["page"] : 開いているページ名(strip_bracket関数により[[]]を取り除ける) | |
1 | +///////////////////////////////////////////////// | |
2 | +// ・ラ・鬣ー・、・?ヌ・」・?ッ・ネ・熙ヒ、ト、、、ニ | |
3 | + | |
4 | + PukiWiki、ホ・レ。シ・ク、ホHTML、リ、ホ・ウ・?ミ。シ・ネサ?、ネ。「・ラ・鬣ー・、・?。ヌス、ォ、鬢ホテヘ、??アシ隍テ、ニ | |
5 | + ス靉?、?ヤ、ヲ・ラ・鬣ー・、・??゚テヨ、ケ、?ウ、ネ、ャ、ヌ、ュ、゙、ケ。」 | |
6 | + | |
7 | + 、ウ、ホ・ニ・ュ・ケ・ネ、マ。「、ス、ホ・ラ・鬣ー・、・?ホオュスメハ?ヒ。、ヒ、ト、、、ニ、ホタ篶タ、?キ、゙、ケ。」 | |
8 | + | |
9 | + | |
10 | +///////////////////////////////////////////////// | |
11 | +// ・レ。シ・クニ筅ヌ、ホ・ラ・鬣ー・、・?ホクニ、モスミ、キ | |
12 | + | |
13 | + #・ラ・鬣ー・、・?セ | |
14 | + #・ラ・鬣ー・、・?セ(arg1,arg2...) | |
15 | + | |
16 | + ケヤニャ、ヒ・ケ・レ。シ・ケ、マエ゙、皃?ウ、ネ、マ、ヌ、ュ、ハ、、。」 | |
17 | + ー??筅ヒウ邵フ()、?ネヘム、ケ、?ウ、ネ、ャ、ヌ、ュ、?」、ソ、タ、キ ) テアツホ、マノヤイト。」 | |
18 | + ー???リト熙キ、ハ、ッ、ニ、篋ニ、モスミ、サ、 | |
19 | + | |
20 | + | |
21 | +///////////////////////////////////////////////// | |
22 | +// ・ユ・。・、・?セ | |
23 | + | |
24 | + ・ラ・鬣ー・、・?セ.inc.php | |
25 | + | |
26 | + | |
27 | +///////////////////////////////////////////////// | |
28 | +// エリソ | |
29 | + | |
30 | + 「」function plugin_・ラ・鬣ー・、・?セ_convert() | |
31 | + | |
32 | + HTML、リ、ホ・ウ・?ミ。シ・ネサ?、ヒクニ、モスミ、オ、? | |
33 | + | |
34 | + ー??マ func_get_args() 、ヌヌロホ?リウハヌシ、ヌ、ュ、?」([0]。チ[n]) | |
35 | + func_num_args() 、ヒ、隍テ、ニ。「ナマ、オ、?ソー??ホソ??皃皃?ウ、ネ、ャ、ヌ、ュ、?」 | |
36 | + | |
37 | + 「」function plugin_・ラ・鬣ー・、・?セ_action() | |
38 | + | |
39 | + GET。ヲPOST・皈ス・テ・ノ、ヌplugin、?リト熙オ、?ソ、ネ、ュ、ヒクニ、モスミ、オ、? | |
40 | + | |
41 | + ハヨテヘ、ヒ array("msg" => "$1 is page") 、ハ、ノ、?ヨ、ケ、ネ $1 、?レ。シ・クフセ、ネ、キ、ニ | |
42 | + ・レ。シ・ク・ソ・、・ネ・?ヒテヨエケ、オ、? | |
43 | + | |
44 | + die() 、?ツケヤ、ケ、?ウ、ネ、ヒ、隍遙「・レ。シ・ク、ヒフ皃鬢ハ、、、隍ヲ、ヒ、ヌ、ュ、 | |
45 | + | |
46 | + 「」function plugin_・ラ・鬣ー・、・?セ_init() | |
47 | + | |
48 | + ・ラ・鬣ー・、・?ャニノ、゚ケ?、゙、???、ヒクニ、モスミ、オ、?゙、ケ。」 | |
49 | + | |
50 | + $_plugin_recent_messages = array( | |
51 | + '_recent_plugin_li'=>'。ヲ', | |
52 | + '_recent_plugin_frame '=>'<span align="center"><h5 class="side_label">コヌソキ、ホ%dキ?/h5></span><small>%s</small>' | |
53 | + ); | |
54 | + set_plugin_messages($_plugin_recent_messages); | |
55 | + | |
56 | + 、ネ、キ、ニテヨ、ッ、ネ。「*.lng・ユ・。・、・?ヌ・ワ・ソ・?茹皈テ・サ。シ・ク、?リト熙キ、ニ、、、ハ、、セ?遉ヒ、ホ、゚ | |
57 | + ・皈テ・サ。シ・ク、ハ、ノ、ャ・サ・テ・ネ、オ、?゙、ケ。」 | |
58 | + ハムソ?ハ、ノ、ホス魘?ス、篁ヤ、ィ、゙、ケ、ャ。「PukiWiki 1.3.1(MASUI'z Edition)ーハケ゚、ホ、゚ | |
59 | + ヘュク?ヌ、ケ、ホ、ヌ。「クナ、、PukiWiki、ォ、鬢マクニ、ミ、?ハ、、イトヌスタュ、ャ、「、?ウ、ネ、?、、?ト、ア、ニ | |
60 | + 、ッ、タ、オ、、。」 | |
61 | + set_plugin_messagesエリソ?祓ukiWiki 1.3.1(MASUI'z Edition)ーハケ゚、ホ、゚、ヌ、ケ。」 | |
62 | + | |
63 | + | |
64 | +///////////////////////////////////////////////// | |
65 | +// ・ユ・。・、・?簣ニ | |
66 | + | |
67 | + ・譯シ・カ、ヒタ゚ト熙オ、サ、?魘?ヘ、ハ、ノ、ヒ、ト、、、ニ、マ。「define 、ヌト?チ、ケ、?」 | |
68 | + | |
69 | + ・ウ・?ミ。シ・ネサ?、ホGET。ヲPOST、ホスミホマニ簣ニ、ヒノャヘラ、ハ、筅ホ、マ refer 、ネ plugin 、ネ、、、ヲテヘ、ヌ。「 | |
70 | + refer : 、ス、ホ・レ。シ・ク、ホフセチー($vars["page"]) | |
71 | + plugin : ・ラ・鬣ー・、・?セ | |
72 | + 、ネ、キ、゙、ケ。」 | |
73 | + | |
74 | + ーハイシ、ホテヘ、 global 、ヌ・ー・?シ・ミ・?ムソ?ヒ、ケ、?ウ、ネ、ヒ、隍テ、ニテヘ、?霹タ、ヌ、ュ、゙、ケ。」 | |
75 | + | |
76 | + $script : ・ケ・ッ・?ラ・ネフセ | |
77 | + $get : GET・皈ス・テ・ノ、ヒ、隍?TTP、ォ、鬢ホー? | |
78 | + $post : POST・皈ス・テ・ノ、ヒ、隍?TTP、ォ、鬢ホー? | |
79 | + $vars : GET。ヲPOSTホセハ?、ホ・皈ス・テ・ノ、ヒ、隍?TTP、ォ、鬢ホー? | |
80 | + | |
81 | + $vars["page"] : ウォ、、、ニ、、、?レ。シ・クフセ(strip_bracketエリソ?ヒ、隍鷦[]]、?隍??ア、? |
@@ -0,0 +1,66 @@ | ||
1 | +<? | |
2 | +/* | |
3 | + * PukiWiki 最新の?件を表示するプラグイン | |
4 | + * | |
5 | + * CopyRight 2002 Y.MASUI GPL2 | |
6 | + * http://masui.net/pukiwiki/ masui@masui.net | |
7 | + * | |
8 | + * 変更履歴: | |
9 | + * 2002.04.08: patさん、みのるさんの指摘により、リンク先が日本語の場合に | |
10 | + * 化けるのを修正 | |
11 | + * | |
12 | + * 2002.06.17: plugin_recent_init()を設定 | |
13 | + */ | |
14 | + | |
15 | +function plugin_recent_init() | |
16 | +{ | |
17 | + $_plugin_recent_messages = array( | |
18 | + '_recent_plugin_li'=>'・', | |
19 | + '_recent_plugin_frame '=>'<span align="center"><h5 class="side_label">最新の%d件</h5></span><small>%s</small>'); | |
20 | + set_plugin_messages($_plugin_recent_messages); | |
21 | +} | |
22 | + | |
23 | +function plugin_recent_convert() | |
24 | +{ | |
25 | + global $_recent_plugin_li,$_recent_plugin_frame; | |
26 | + global $WikiName,$BracketName,$script,$whatsnew; | |
27 | + | |
28 | + $recent_lines = 10; | |
29 | + if(func_num_args()>0) { | |
30 | + $array = func_get_args(); | |
31 | + $recent_lines = $array[0]; | |
32 | + } | |
33 | + | |
34 | + $lines = file(get_filename(encode($whatsnew))); | |
35 | + $date = $items = ""; | |
36 | + $cnt = 0; | |
37 | + foreach($lines as $line) | |
38 | + { | |
39 | + if($cnt > $recent_lines - 1) break; | |
40 | + if(preg_match("/(($WikiName)|($BracketName))/",$line,$match)) | |
41 | + { | |
42 | + $name = $match[1]; | |
43 | + if($match[2]) | |
44 | + { | |
45 | + $title = $match[1]; | |
46 | + } | |
47 | + else | |
48 | + { | |
49 | + $title = strip_bracket($match[1]); | |
50 | + } | |
51 | + if(preg_match("/([0-9]{4}-[0-9]{2}-[0-9]{2})/",$line,$match)) { | |
52 | + if($date != $match[0]) { | |
53 | + if($date != '') { | |
54 | + $items .= "<br>"; | |
55 | + } | |
56 | + $items .= "<b>".$match[0]."</b><br>"; | |
57 | + $date = $match[0]; | |
58 | + } | |
59 | + } | |
60 | + $items .= $_recent_plugin_li."<a href=\"".$script."?".rawurlencode($name)."\" title=\"$title ".get_pg_passage($name,false)."\">".$title."</a><BR>\n"; | |
61 | + $cnt++; | |
62 | + } | |
63 | + } | |
64 | + return sprintf($_recent_plugin_frame,$cnt,$items); | |
65 | +} | |
66 | +?> |
@@ -0,0 +1,12 @@ | ||
1 | +<? | |
2 | +function plugin_source_action() | |
3 | +{ | |
4 | + global $post,$vars,$script,$InterWikiName,$WikiName,$BracketName,$defaultpage; | |
5 | + | |
6 | + header("Content-type: text/plain"); | |
7 | + readfile(get_filename(encode($vars["page"]))); | |
8 | + | |
9 | + die(); | |
10 | +} | |
11 | + | |
12 | +?> |
@@ -0,0 +1,118 @@ | ||
1 | +<? | |
2 | +/////////////////////// | |
3 | +// | |
4 | +define(PLUGIN_UPDATE_SECRET,'GReenOrRed'); | |
5 | + | |
6 | + | |
7 | +function plugin_update_action() | |
8 | +{ | |
9 | + global $vars,$script,$do_backup,$del_backup; | |
10 | + | |
11 | + $page = $vars["page"]; | |
12 | + | |
13 | + header("Content-type: text/plain"); | |
14 | + | |
15 | + // 差分ファイルの作成 | |
16 | + if(is_page($vars["page"])) | |
17 | + $oldpostdata = join("",get_source($page)); | |
18 | + else | |
19 | + $oldpostdata = ""; | |
20 | + | |
21 | + list($postdata,$auto) = plugin_update_diff($oldpostdata,$vars['body']); | |
22 | + $postdata = user_rules_str($postdata); | |
23 | + if($postdata == $oldpostdata) { | |
24 | + print "status noupdate\n\n"; | |
25 | + die; | |
26 | + } | |
27 | + | |
28 | + if($postdata) | |
29 | + $diffdata = do_diff($oldpostdata,$postdata); | |
30 | + file_write(DIFF_DIR,$page,$diffdata); | |
31 | + | |
32 | + // バックアップの作成 | |
33 | + if(is_page($page)) | |
34 | + $oldposttime = filemtime(get_filename(encode($page))); | |
35 | + else | |
36 | + $oldposttime = time(); | |
37 | + | |
38 | + // 編集内容が何も書かれていないとバックアップも削除する?しないですよね。 | |
39 | + if(!$postdata && $del_backup) | |
40 | + backup_delete(BACKUP_DIR.encode($vars["page"]).".txt"); | |
41 | + else if($do_backup && is_page($vars["page"])) | |
42 | + make_backup(encode($vars["page"]).".txt",$oldpostdata,$oldposttime); | |
43 | + | |
44 | + // ファイルの書き込み | |
45 | + file_write(DATA_DIR,$vars["page"],$postdata); | |
46 | + | |
47 | + // is_pageのキャッシュをクリアする。 | |
48 | + is_page($vars["page"],true); | |
49 | + | |
50 | + if($auto) { | |
51 | + print "status updated\n"; | |
52 | + } | |
53 | + else { | |
54 | + print "status collided\n"; | |
55 | + } | |
56 | + print "\n".$postdata; | |
57 | + | |
58 | + die(); | |
59 | +} | |
60 | + | |
61 | +// 差分の作成 | |
62 | +function plugin_update_diff($oldstr,$newstr) | |
63 | +{ | |
64 | + $oldlines = split("\n",ereg_replace("[\r\n\t ]+$",'',$oldstr)); | |
65 | + $newlines = split("\n",ereg_replace("[\r\n\t ]+$",'',$newstr)); | |
66 | + | |
67 | + if(sizeof($oldlines)==1 && $oldlines[0]=='') { | |
68 | + $oldlines = array(); | |
69 | + } | |
70 | + if(sizeof($newlines)==1 && $newlines[0]=='') { | |
71 | + $newlines = array(); | |
72 | + } | |
73 | + | |
74 | + $retdiff = $props = array(); | |
75 | + $auto = true; | |
76 | + | |
77 | + foreach($newlines as $newline) { | |
78 | + $flg = false; | |
79 | + $cnt = 0; | |
80 | + foreach($oldlines as $oldline) { | |
81 | + if($oldline == $newline) { | |
82 | + if($cnt>0) { | |
83 | + for($i=0; $i<$cnt; ++$i) { | |
84 | + array_push($retdiff,array_shift($oldlines)); | |
85 | + array_push($props,'! '); | |
86 | + $auto = false; | |
87 | + } | |
88 | + } | |
89 | + array_push($retdiff,array_shift($oldlines)); | |
90 | + array_push($props,''); | |
91 | + $flg = true; | |
92 | + break; | |
93 | + } | |
94 | + $cnt++; | |
95 | + } | |
96 | + if(!$flg) { | |
97 | + array_push($retdiff,$newline); | |
98 | +# array_push($props,'+ '); | |
99 | + array_push($props,''); | |
100 | + } | |
101 | + } | |
102 | + foreach($oldlines as $oldline) { | |
103 | + array_push($retdiff,$oldline); | |
104 | + array_push($props,'! '); | |
105 | + $auto = false; | |
106 | + } | |
107 | + if($auto) { | |
108 | + return array(join("\n",$retdiff),$auto); | |
109 | + } | |
110 | + | |
111 | + $ret = ''; | |
112 | + foreach($retdiff as $line) { | |
113 | + $ret .= array_shift($props) . $line . "\n"; | |
114 | + } | |
115 | + return array($ret,$auto); | |
116 | +} | |
117 | + | |
118 | +?> |
@@ -1,6 +1,6 @@ | ||
1 | -<? | |
2 | -function plugin_version_convert() | |
3 | -{ | |
4 | - return "<b>".S_VERSION."</b>"; | |
5 | -} | |
6 | -?> | |
1 | +<? | |
2 | +function plugin_version_convert() | |
3 | +{ | |
4 | + return "<b>".S_VERSION."</b>"; | |
5 | +} | |
6 | +?> |
@@ -0,0 +1,150 @@ | ||
1 | +<? | |
2 | + | |
3 | +function plugin_vote_action() | |
4 | +{ | |
5 | + global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup; | |
6 | + global $_title_collided,$_msg_collided,$_title_updated; | |
7 | + | |
8 | + $postdata_old = file(get_filename(encode($post["refer"]))); | |
9 | + $vote_no = 0; | |
10 | + | |
11 | + foreach($postdata_old as $line) | |
12 | + { | |
13 | + if(preg_match("/^#vote\((.*)\)$/",$line,$arg)) | |
14 | + { | |
15 | + if($vote_no == $post["vote_no"]) | |
16 | + { | |
17 | + $args = explode(",",$arg[1]); | |
18 | + | |
19 | + foreach($args as $arg) | |
20 | + { | |
21 | + if(preg_match("/^(.+)\[(\d+)\]$/",$arg,$match)) | |
22 | + { | |
23 | + $arg = $match[1]; | |
24 | + $cnt = $match[2]; | |
25 | + } | |
26 | + else | |
27 | + { | |
28 | + $cnt = 0; | |
29 | + } | |
30 | + | |
31 | + if($post["vote"][preg_replace("/\]\]$/","",$arg)]) $cnt++; | |
32 | + | |
33 | + $votes[] = $arg.'['.$cnt.']'; | |
34 | + } | |
35 | + | |
36 | + $vote_str = "#vote(" . @join(",",$votes) . ")\n"; | |
37 | + | |
38 | + $postdata_input = $vote_str; | |
39 | + $postdata .= $vote_str; | |
40 | + $line = ""; | |
41 | + } | |
42 | + $vote_no++; | |
43 | + } | |
44 | + $postdata .= $line; | |
45 | + } | |
46 | + | |
47 | + if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"]) | |
48 | + { | |
49 | + $title = $_title_collided; | |
50 | + | |
51 | + $body = "$_msg_collided\n"; | |
52 | + | |
53 | + $body .= "<form action=\"$script?cmd=preview\" method=\"post\">\n" | |
54 | + ."<input type=\"hidden\" name=\"refer\" value=\"".$post["refer"]."\">\n" | |
55 | + ."<input type=\"hidden\" name=\"digest\" value=\"".$post["digest"]."\">\n" | |
56 | + ."<textarea name=\"msg\" rows=\"$rows\" cols=\"$cols\" wrap=\"virtual\" id=\"textarea\">$postdata_input</textarea><br>\n" | |
57 | + ."</form>\n"; | |
58 | + } | |
59 | + else | |
60 | + { | |
61 | + // ?・?a?t?@?C???I?i?¬ | |
62 | + if(is_page($post["refer"])) | |
63 | + $oldpostdata = join("",file(get_filename(encode($post["refer"])))); | |
64 | + else | |
65 | + $oldpostdata = "\n"; | |
66 | + if($postdata) | |
67 | + $diffdata = do_diff($oldpostdata,$postdata); | |
68 | + file_write(DIFF_DIR,$post["refer"],$diffdata); | |
69 | + | |
70 | + // ?o?b?N?A?b?v?I?i?¬ | |
71 | + if(is_page($post["refer"])) | |
72 | + $oldposttime = filemtime(get_filename(encode($post["refer"]))); | |
73 | + else | |
74 | + $oldposttime = time(); | |
75 | + | |
76 | + // ?O?W“a?e?a‰??a?‘?c?e?A?¢?E?¢?A?o?b?N?A?b?v?a?i???・?e??μ?E?¢?A?・?a?E?B | |
77 | + if(!$postdata && $del_backup) | |
78 | + backup_delete(BACKUP_DIR.encode($post["refer"]).".txt"); | |
79 | + else if($do_backup && is_page($post["refer"])) | |
80 | + make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime); | |
81 | + | |
82 | + // ?t?@?C???I?‘?≪???Y | |
83 | + file_write(DATA_DIR,$post["refer"],$postdata); | |
84 | + | |
85 | + // is_page?I?L???b?V?…?d?N???A?・?e?B | |
86 | + is_page($post["refer"],true); | |
87 | + | |
88 | + $title = $_title_updated; | |
89 | + } | |
90 | + | |
91 | + $retvars["msg"] = $title; | |
92 | + $retvars["body"] = $body; | |
93 | + | |
94 | + $post["page"] = $post["refer"]; | |
95 | + $vars["page"] = $post["refer"]; | |
96 | + | |
97 | + return $retvars; | |
98 | +} | |
99 | +function plugin_vote_convert() | |
100 | +{ | |
101 | + global $script,$vars,$vote_no,$digest; | |
102 | + | |
103 | + $args = func_get_args(); | |
104 | + | |
105 | + if(!func_num_args()) return FALSE; | |
106 | + | |
107 | + $string = "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\">\n" | |
108 | + | |
109 | + . "<form action=\"$script\" method=\"post\">\n" | |
110 | + . "<input type=\"hidden\" name=\"plugin\" value=\"vote\">\n" | |
111 | + . "<input type=\"hidden\" name=\"refer\" value=\"$vars[page]\">\n" | |
112 | + . "<input type=\"hidden\" name=\"vote_no\" value=\"$vote_no\">\n" | |
113 | + . "<input type=\"hidden\" name=\"digest\" value=\"$digest\">\n" | |
114 | + | |
115 | + . "<tr>\n" | |
116 | + . "<td align=\"left\" class=\"vote_label\"><b>The choices</b></td>\n" | |
117 | + . "<td align=\"center\" class=\"vote_label\"><b>Votes</b></td>\n" | |
118 | + . "</tr>\n"; | |
119 | + | |
120 | + $tdcnt = 0; | |
121 | + foreach($args as $arg) | |
122 | + { | |
123 | + $cnt = 0; | |
124 | + | |
125 | + if(preg_match("/^(.+)\[(\d+)\]$/",$arg,$match)) | |
126 | + { | |
127 | + $arg = $match[1]; | |
128 | + $cnt = $match[2]; | |
129 | + } | |
130 | + | |
131 | + $link = make_link($arg); | |
132 | + | |
133 | + if($tdcnt++ % 2) $cls = "vote_td1"; | |
134 | + else $cls = "vote_td2"; | |
135 | + | |
136 | + $string .= "<tr>" | |
137 | + . "<td width=\"80%\" class=\"$cls\" nowrap>$link</td>" | |
138 | + . "<td class=\"$cls\" nowrap>$cnt <input type=\"submit\" name=\"vote[$arg]\" value=\"Vote\"></td>" | |
139 | + . "</tr>\n"; | |
140 | + } | |
141 | + | |
142 | + $string .= "</form>\n" | |
143 | + . "</table>\n"; | |
144 | + | |
145 | + $vote_no++; | |
146 | + | |
147 | + return $string; | |
148 | +} | |
149 | +?> | |
150 | + |
@@ -1,5 +1,9 @@ | ||
1 | 1 | <? |
2 | 2 | ///////////////////////////////////////////////// |
3 | +// PukiWiki - Yet another WikiWikiWeb clone. | |
4 | +// | |
5 | +// $Id: pukiwiki.ini.php,v 1.2 2002/06/21 05:21:46 masui Exp $ | |
6 | +// | |
3 | 7 | // PukiWiki setting file |
4 | 8 | |
5 | 9 | ///////////////////////////////////////////////// |
@@ -19,7 +23,7 @@ define("PLUGIN_DIR","./plugin/"); | ||
19 | 23 | |
20 | 24 | ///////////////////////////////////////////////// |
21 | 25 | // スキンファイルの場所。 |
22 | -define("SKIN_FILE","./pukiwiki.skin.ja.php"); | |
26 | +define("SKIN_FILE","./skin/pukiwiki.skin.ja.php"); | |
23 | 27 | |
24 | 28 | ///////////////////////////////////////////////// |
25 | 29 | // Language |
@@ -154,11 +158,19 @@ $splitter = ">>>>>>>>>>"; | ||
154 | 158 | ///////////////////////////////////////////////// |
155 | 159 | // 一覧・更新一覧に含めないページ名(正規表現で) |
156 | 160 | $non_list = "^(\[\[\:)"; |
161 | + | |
157 | 162 | ///////////////////////////////////////////////// |
158 | 163 | // 雛形とするページの読み込みを表示させるか |
159 | 164 | $load_template_func = 1; |
160 | 165 | |
161 | 166 | ///////////////////////////////////////////////// |
167 | +// ページ名に従って自動で、雛形とするページの読み込み | |
168 | +$auto_template_func = 1; | |
169 | +$auto_template_rules = array( | |
170 | +'\[\[((.+)\/([^\/]+))\]\]' => '[[\2/template]]' | |
171 | +); | |
172 | + | |
173 | +///////////////////////////////////////////////// | |
162 | 174 | // ユーザ定義ルール |
163 | 175 | // |
164 | 176 | // 正規表現で記述してください。?(){}-*./+\$^|など |
@@ -173,6 +185,7 @@ $str_rules = array( | ||
173 | 185 | "date\?" => date($date_format,UTIME), |
174 | 186 | "time\?" => date($time_format,UTIME), |
175 | 187 | ); |
188 | + | |
176 | 189 | ///////////////////////////////////////////////// |
177 | 190 | // ユーザ定義ルール(コンバート時に置換、直接しない) |
178 | 191 | $line_rules = array( |
@@ -369,4 +382,4 @@ now? | ||
369 | 382 | </ul> |
370 | 383 | '; |
371 | 384 | |
372 | -?> | |
\ No newline at end of file | ||
385 | +?> |
@@ -1,2400 +1,732 @@ | ||
1 | -<? | |
2 | -// pukiwiki.php - Yet another WikiWikiWeb clone. | |
3 | -// | |
4 | -// Copyright (C) 2001,2002 by sng. | |
5 | -// <sng@factage.com> | |
6 | -// http://factage.com/sng/pukiwiki/ | |
7 | -// | |
8 | -// Special thanks | |
9 | -// YukiWiki by Hiroshi Yuki | |
10 | -// <hyuki@hyuki.com> | |
11 | -// http://www.hyuki.com/yukiwiki/ | |
12 | -// | |
13 | -// This program is free software; you can redistribute it and/or modify | |
14 | -// it under the terms of the GNU General Public License as published by | |
15 | -// the Free Software Foundation; either version 2 of the License, or | |
16 | -// (at your option) any later version. | |
17 | -// | |
18 | -// This program is distributed in the hope that it will be useful, | |
19 | -// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | -// GNU General Public License for more details. | |
22 | -// | |
23 | -//# $Id: pukiwiki.php,v 1.1 2002/06/20 13:59:31 masui Exp $ | |
24 | -///////////////////////////////////////////////// | |
25 | - | |
26 | -///////////////////////////////////////////////// | |
27 | -// 設定ファイルの場所 | |
28 | -define("INI_FILE","./pukiwiki.ini.php"); | |
29 | - | |
30 | -//** 初期設定 ** | |
31 | - | |
32 | -define("S_VERSION","1.3"); | |
33 | -define("UTIME",time()); | |
34 | -define("HTTP_USER_AGENT",$HTTP_SERVER_VARS["HTTP_USER_AGENT"]); | |
35 | -define("PHP_SELF",$HTTP_SERVER_VARS["PHP_SELF"]); | |
36 | -define("SERVER_NAME",$HTTP_SERVER_VARS["SERVER_NAME"]); | |
37 | - | |
38 | -define("MUTIME",getmicrotime()); | |
39 | - | |
40 | -$script = basename($PHP_SELF); | |
41 | - | |
42 | -$WikiName = '([A-Z][a-z]+([A-Z][a-z]+)+)'; | |
43 | -$BracketName = '\[\[(\[*[^\s\]]+?\]*)\]\]'; | |
44 | -$InterWikiName = '\[\[(\[*[^\s\]]+?\]*):(\[*[^>\]]+?\]*)\]\]'; | |
45 | - | |
46 | -//** 入力値の整形 ** | |
47 | - | |
48 | -$post = $HTTP_POST_VARS; | |
49 | -$get = $HTTP_GET_VARS; | |
50 | - | |
51 | -if($get["page"]) $get["page"] = rawurldecode($get["page"]); | |
52 | -if($post["word"]) $post["word"] = rawurldecode($post["word"]); | |
53 | -if($get["word"]) $get["word"] = rawurldecode($get["word"]); | |
54 | -if(get_magic_quotes_gpc()) | |
55 | -{ | |
56 | - if($get["page"]) $get["page"] = stripslashes($get["page"]); | |
57 | - if($post["page"]) $post["page"] = stripslashes($post["page"]); | |
58 | - if($get["word"]) $get["word"] = stripslashes($get["word"]); | |
59 | - if($post["word"]) $post["word"] = stripslashes($post["word"]); | |
60 | - if($post["msg"]) $post["msg"] = stripslashes($post["msg"]); | |
61 | -} | |
62 | -if($post["msg"]) | |
63 | -{ | |
64 | - $post["msg"] = preg_replace("/<\/(textarea[^>]*)>/i", "</$1>", $post["msg"]); | |
65 | - $post["msg"] = preg_replace("/(\x0D\x0A)/","\n",$post["msg"]); | |
66 | - $post["msg"] = preg_replace("/(\x0D)/","\n",$post["msg"]); | |
67 | - $post["msg"] = preg_replace("/(\x0A)/","\n",$post["msg"]); | |
68 | -} | |
69 | - | |
70 | -$vars = array_merge($post,$get); | |
71 | -$arg = rawurldecode($HTTP_SERVER_VARS["argv"][0]); | |
72 | - | |
73 | -//** 初期処理 ** | |
74 | - | |
75 | -$update_exec = ""; | |
76 | - | |
77 | -// 設定ファイルの読込 | |
78 | -@require(INI_FILE); | |
79 | -@require(LANG.".lng"); | |
80 | - | |
81 | -// 設定ファイルの変数チェック | |
82 | -$wrong_ini_file = ""; | |
83 | -if(!isset($rss_max)) $wrong_ini_file .= '$rss_max '; | |
84 | -if(!isset($page_title)) $wrong_ini_file .= '$page_title '; | |
85 | -if(!isset($note_hr)) $wrong_ini_file .= '$note_hr '; | |
86 | -if(!isset($related_link)) $wrong_ini_file .= '$related_link '; | |
87 | -if(!isset($show_passage)) $wrong_ini_file .= '$show_passage '; | |
88 | -if(!isset($rule_related_str)) $wrong_ini_file .= '$rule_related_str '; | |
89 | -if(!isset($load_template_func)) $wrong_ini_file .= '$load_template_func '; | |
90 | -if(!defined("LANG")) $wrong_ini_file .= 'LANG '; | |
91 | -if(!defined("PLUGIN_DIR")) $wrong_ini_file .= 'PLUGIN_DIR '; | |
92 | - | |
93 | -if(!is_writable(DATA_DIR)) | |
94 | - die_message("DATA_DIR is not found or not writable."); | |
95 | -if(!is_writable(DIFF_DIR)) | |
96 | - die_message("DIFF_DIR is not found or not writable."); | |
97 | -if($do_backup && !is_writable(BACKUP_DIR)) | |
98 | - die_message("BACKUP_DIR is not found or not writable."); | |
99 | -if(!file_exists(INI_FILE)) | |
100 | - die_message("INI_FILE is not found."); | |
101 | -if($wrong_ini_file) | |
102 | - die_message("The setting file runs short of information.<br>The version of a setting file may be old.<br><br>These option are not found : $wrong_ini_file"); | |
103 | -//if(ini_get("register_globals") !== "0") | |
104 | -// die_message("Wrong PHP4 setting in 'register_globals',set value 'Off' to httpd.conf or .htaccess."); | |
105 | -if(!file_exists(SKIN_FILE)) | |
106 | - die_message("SKIN_FILE is not found."); | |
107 | -if(!file_exists(LANG.".lng")) | |
108 | - die_message(LANG.".lng(language file) is not found."); | |
109 | - | |
110 | -if(!file_exists(get_filename(encode($defaultpage)))) | |
111 | - touch(get_filename(encode($defaultpage))); | |
112 | -if(!file_exists(get_filename(encode($whatsnew)))) | |
113 | - touch(get_filename(encode($whatsnew))); | |
114 | -if(!file_exists(get_filename(encode($interwiki)))) | |
115 | - touch(get_filename(encode($interwiki))); | |
116 | - | |
117 | -$ins_date = date($date_format,UTIME); | |
118 | -$ins_time = date($time_format,UTIME); | |
119 | -$ins_week = "(".$weeklabels[date("w",UTIME)].")"; | |
120 | - | |
121 | -$now = "$ins_date $ins_week $ins_time"; | |
122 | - | |
123 | -// ** メイン処理 ** | |
124 | - | |
125 | -// Plug-in hook | |
126 | -if(isset($vars["plugin"])) | |
127 | -{ | |
128 | - if(!file_exists(PLUGIN_DIR.$vars["plugin"].".inc.php")) | |
129 | - { | |
130 | - $vars["plugin"] = ""; | |
131 | - } | |
132 | - else | |
133 | - { | |
134 | - require_once(PLUGIN_DIR.$vars["plugin"].".inc.php"); | |
135 | - if(!function_exists("plugin_".$vars["plugin"]."_action")) | |
136 | - { | |
137 | - $vars["plugin"] = ""; | |
138 | - } | |
139 | - } | |
140 | -} | |
141 | - | |
142 | - | |
143 | -// Plug-in action | |
144 | -if(!empty($vars["plugin"])) | |
145 | -{ | |
146 | - $retvars = @call_user_func("plugin_".$vars["plugin"]."_action"); | |
147 | - | |
148 | - $title = strip_bracket($vars["refer"]); | |
149 | - $page = make_search($vars["refer"]); | |
150 | - | |
151 | - if($retvars["msg"]) | |
152 | - { | |
153 | - $title = str_replace("$1",$title,$retvars["msg"]); | |
154 | - $page = str_replace("$1",$page,$retvars["msg"]); | |
155 | - } | |
156 | - | |
157 | - if(!empty($retvars["body"])) | |
158 | - { | |
159 | - $body = $retvars["body"]; | |
160 | - } | |
161 | - else | |
162 | - { | |
163 | - $cmd = "read"; | |
164 | - $vars["page"] = $vars["refer"]; | |
165 | - $body = @join("",@file(get_filename(encode($vars["refer"])))); | |
166 | - $body = convert_html($body); | |
167 | - } | |
168 | -} | |
169 | -// 一覧の表示 | |
170 | -else if(arg_check("list")) | |
171 | -{ | |
172 | - header_lastmod($whatsnew); | |
173 | - | |
174 | - $page = $title = $_title_list; | |
175 | - $body = "<ul>\n" . get_list(false) . "</ul>\n"; | |
176 | -} | |
177 | -// ファイル名一覧の表示 | |
178 | -else if(arg_check("filelist")) | |
179 | -{ | |
180 | - header_lastmod($whatsnew); | |
181 | - | |
182 | - $page = $title = $_title_filelist; | |
183 | - $body = "<ul>\n" . get_list(true) . "</ul>\n"; | |
184 | -} | |
185 | -// 編集不可能なページを編集しようとしたとき | |
186 | -else if(((arg_check("add") || arg_check("edit") || arg_check("preview")) && (is_freeze($vars["page"]) || !is_editable($vars["page"]) || $vars["page"] == ""))) | |
187 | -{ | |
188 | - $body = $title = str_replace('$1',strip_bracket($vars["page"]),$_title_cannotedit); | |
189 | - $page = str_replace('$1',make_search($vars["page"]),$_title_cannotedit); | |
190 | - | |
191 | - if(is_freeze($vars["page"])) | |
192 | - $body .= "(<a href=\"$script?cmd=unfreeze&page=".rawurlencode($vars["page"])."\">$_msg_unfreeze</a>)"; | |
193 | -} | |
194 | -// 追加 | |
195 | -else if(arg_check("add")) | |
196 | -{ | |
197 | - $title = str_replace('$1',strip_bracket($get["page"]),$_title_add); | |
198 | - $page = str_replace('$1',make_search($get["page"]),$_title_add); | |
199 | - $body = "<ul>\n"; | |
200 | - $body .= "<li>$_msg_add</li>\n"; | |
201 | - $body .= "</ul>\n"; | |
202 | - $body .= edit_form("",$get["page"],true); | |
203 | -} | |
204 | -// 編集 | |
205 | -else if(arg_check("edit")) | |
206 | -{ | |
207 | - $postdata = @join("",@file(get_filename(encode($get["page"])))); | |
208 | - | |
209 | - $title = str_replace('$1',strip_bracket($get["page"]),$_title_edit); | |
210 | - $page = str_replace('$1',make_search($get["page"]),$_title_edit); | |
211 | - $body = edit_form($postdata,$get["page"]); | |
212 | -} | |
213 | -// プレビュー | |
214 | -else if(arg_check("preview") || $post["preview"] || $post["template"]) | |
215 | -{ | |
216 | - if($post["template"] && file_exists(get_filename(encode($post["template_page"])))) | |
217 | - { | |
218 | - $post["msg"] = @join("",@file(get_filename(encode($post["template_page"])))); | |
219 | - } | |
220 | - | |
221 | - $post["msg"] = preg_replace("/^#freeze\n/","",$post["msg"]); | |
222 | - $postdata_input = $post["msg"]; | |
223 | - | |
224 | - if($post["add"]) | |
225 | - { | |
226 | - if($post["add_top"]) | |
227 | - { | |
228 | - $postdata = $post["msg"]; | |
229 | - $postdata .= "\n\n"; | |
230 | - $postdata .= @join("",@file(get_filename(encode($post["page"])))); | |
231 | - } | |
232 | - else | |
233 | - { | |
234 | - $postdata = @join("",@file(get_filename(encode($post["page"])))); | |
235 | - $postdata .= "\n\n"; | |
236 | - $postdata .= $post["msg"]; | |
237 | - } | |
238 | - } | |
239 | - else | |
240 | - { | |
241 | - $postdata = $post["msg"]; | |
242 | - } | |
243 | - | |
244 | - $title = str_replace('$1',strip_bracket($post["page"]),$_title_preview); | |
245 | - $page = str_replace('$1',make_search($post["page"]),$_title_preview); | |
246 | - | |
247 | - $body = "$_msg_preview<br>\n"; | |
248 | - if($postdata == "") $body .= "<b>$_msg_preview_delete</b><br>\n"; | |
249 | - else $body .= "<br>\n"; | |
250 | - | |
251 | - if($postdata != "") | |
252 | - { | |
253 | - $postdata = convert_html($postdata); | |
254 | - | |
255 | - $body .= "<table width=\"100%\" bgcolor=\"$preview_color\">\n" | |
256 | - ."<tr><td>\n" | |
257 | - .$postdata | |
258 | - ."\n</td></tr>\n" | |
259 | - ."</table>\n"; | |
260 | - } | |
261 | - | |
262 | - if($post["add"]) | |
263 | - { | |
264 | - if($post["add_top"]) $checked_top = " checked"; | |
265 | - $addtag = '<input type="hidden" name="add" value="true">'; | |
266 | - $add_top = '<input type="checkbox" name="add_top" value="true"'.$checked_top.'><small>ページの上に追加</small>'; | |
267 | - } | |
268 | - if($post["notimestamp"]) $checked_time = "checked"; | |
269 | - | |
270 | - $body .= "<form action=\"$script\" method=\"post\">\n" | |
271 | - ."<input type=\"hidden\" name=\"help\" value=\"$post[add]\">\n" | |
272 | - ."<input type=\"hidden\" name=\"page\" value=\"".$post["page"]."\">\n" | |
273 | - ."<input type=\"hidden\" name=\"digest\" value=\"".$post["digest"]."\">\n" | |
274 | - ."$addtag\n" | |
275 | - ."<textarea name=\"msg\" rows=\"$rows\" cols=\"$cols\" wrap=\"virtual\">\n$postdata_input</textarea><br>\n" | |
276 | - ."<input type=\"submit\" name=\"preview\" value=\"$_btn_repreview\" accesskey=\"p\">\n" | |
277 | - ."<input type=\"submit\" name=\"write\" value=\"$_btn_update\" accesskey=\"s\">\n" | |
278 | - ."$add_top\n" | |
279 | - ."<input type=\"checkbox\" name=\"notimestamp\" value=\"true\" $checked_time><small>$_btn_notchangetimestamp</small>\n" | |
280 | - ."</form>\n"; | |
281 | -} | |
282 | -// 書き込みもしくは追加もしくはコメントの挿入 | |
283 | -else if($post["write"]) | |
284 | -{ | |
285 | - $post["msg"] = preg_replace("/^#freeze\n/","",$post["msg"]); | |
286 | - $postdata_input = $post["msg"]; | |
287 | - | |
288 | - if($post["add"]) | |
289 | - { | |
290 | - if($post["add_top"]) | |
291 | - { | |
292 | - $postdata = $post["msg"]; | |
293 | - $postdata .= "\n\n"; | |
294 | - $postdata .= @join("",@file(get_filename(encode($post["page"])))); | |
295 | - } | |
296 | - else | |
297 | - { | |
298 | - $postdata = @join("",@file(get_filename(encode($post["page"])))); | |
299 | - $postdata .= "\n\n"; | |
300 | - $postdata .= $post["msg"]; | |
301 | - } | |
302 | - } | |
303 | - else | |
304 | - { | |
305 | - $postdata = $post["msg"]; | |
306 | - } | |
307 | - | |
308 | - if(md5(@join("",@file(get_filename(encode($post["page"]))))) != $post["digest"]) | |
309 | - { | |
310 | - $title = str_replace('$1',strip_bracket($post["page"]),$_title_collided); | |
311 | - $page = str_replace('$1',make_search($post["page"]),$_title_collided); | |
312 | - | |
313 | - $body .= "$_msg_collided\n"; | |
314 | - | |
315 | - $body .= "<form action=\"$script?cmd=preview\" method=\"post\">\n" | |
316 | - ."<input type=\"hidden\" name=\"page\" value=\"".$post["page"]."\">\n" | |
317 | - ."<input type=\"hidden\" name=\"digest\" value=\"".$post["digest"]."\">\n" | |
318 | - ."<textarea name=\"msg\" rows=\"$rows\" cols=\"$cols\" wrap=\"virtual\" id=\"textarea\">$postdata_input</textarea><br>\n" | |
319 | - ."</form>\n"; | |
320 | - } | |
321 | - else | |
322 | - { | |
323 | - $postdata = user_rules_str($postdata); | |
324 | - | |
325 | - // 差分ファイルの作成 | |
326 | - if(is_page($post["page"])) | |
327 | - $oldpostdata = join("",file(get_filename(encode($post["page"])))); | |
328 | - else | |
329 | - $oldpostdata = "\n"; | |
330 | - if($postdata) | |
331 | - $diffdata = do_diff($oldpostdata,$postdata); | |
332 | - file_write(DIFF_DIR,$post["page"],$diffdata); | |
333 | - | |
334 | - // バックアップの作成 | |
335 | - if(is_page($post["page"])) | |
336 | - $oldposttime = filemtime(get_filename(encode($post["page"]))); | |
337 | - else | |
338 | - $oldposttime = time(); | |
339 | - | |
340 | - // 編集内容が何も書かれていないとバックアップも削除する?しないですよね。 | |
341 | - if(!$postdata && $del_backup) | |
342 | - backup_delete(BACKUP_DIR.encode($post["page"]).".txt"); | |
343 | - else if($do_backup && is_page($post["page"])) | |
344 | - make_backup(encode($post["page"]).".txt",$oldpostdata,$oldposttime); | |
345 | - | |
346 | - // ファイルの書き込み | |
347 | - file_write(DATA_DIR,$post["page"],$postdata); | |
348 | - | |
349 | - // is_pageのキャッシュをクリアする。 | |
350 | - is_page($post["page"],true); | |
351 | - | |
352 | - if($postdata) | |
353 | - { | |
354 | - $title = str_replace('$1',strip_bracket($post["page"]),$_title_updated); | |
355 | - $page = str_replace('$1',make_search($post["page"]),$_title_updated); | |
356 | - $body = convert_html($postdata); | |
357 | - } | |
358 | - else | |
359 | - { | |
360 | - $title = str_replace('$1',strip_bracket($post["page"]),$_title_deleted); | |
361 | - $page = str_replace('$1',make_search($post["page"]),$_title_deleted); | |
362 | - $body = str_replace('$1',strip_bracket($post["page"]),$_title_deleted); | |
363 | - } | |
364 | - } | |
365 | -} | |
366 | -// 凍結 | |
367 | -else if(arg_check("freeze") && $vars["page"] && $function_freeze) | |
368 | -{ | |
369 | - if(is_freeze($vars["page"])) | |
370 | - { | |
371 | - $title = str_replace('$1',strip_bracket($vars["page"]),$_title_isfreezed); | |
372 | - $page = str_replace('$1',make_search($vars["page"]),$_title_isfreezed); | |
373 | - $body = str_replace('$1',strip_bracket($vars["page"]),$_title_isfreezed); | |
374 | - } | |
375 | - else if(md5($post["pass"]) == $adminpass) | |
376 | - { | |
377 | - $postdata = file(get_filename(encode($post["page"]))); | |
378 | - $postdata = join("",$postdata); | |
379 | - $postdata = "#freeze\n".$postdata; | |
380 | - | |
381 | - file_write(DATA_DIR,$vars["page"],$postdata); | |
382 | - | |
383 | - $title = str_replace('$1',strip_bracket($vars["page"]),$_title_freezed); | |
384 | - $page = str_replace('$1',make_search($vars["page"]),$_title_freezed); | |
385 | - $postdata = join("",file(get_filename(encode($vars["page"])))); | |
386 | - $postdata = convert_html($postdata); | |
387 | - | |
388 | - $body = $postdata; | |
389 | - } | |
390 | - else | |
391 | - { | |
392 | - $title = str_replace('$1',strip_bracket($vars["page"]),$_title_freeze); | |
393 | - $page = str_replace('$1',make_search($vars["page"]),$_title_freeze); | |
394 | - | |
395 | - $body.= "<br>\n"; | |
396 | - | |
397 | - if($post["pass"]) | |
398 | - $body .= "<b>$_msg_invalidpass</b><br>\n"; | |
399 | - else | |
400 | - $body.= "$_msg_freezing<br>\n"; | |
401 | - | |
402 | - $body.= "<form action=\"$script?cmd=freeze\" method=\"post\">\n"; | |
403 | - $body.= "<input type=\"hidden\" name=\"page\" value=\"$vars[page]\">\n"; | |
404 | - $body.= "<input type=\"password\" name=\"pass\" size=\"12\">\n"; | |
405 | - $body.= "<input type=\"submit\" name=\"ok\" value=\"$_btn_freeze\">\n"; | |
406 | - $body.= "</form>\n"; | |
407 | - } | |
408 | -} | |
409 | -//凍結の解除 | |
410 | -else if(arg_check("unfreeze") && $vars["page"] && $function_freeze) | |
411 | -{ | |
412 | - if(!is_freeze($vars["page"])) | |
413 | - { | |
414 | - $title = str_replace('$1',strip_bracket($vars["page"]),$_title_isunfreezed); | |
415 | - $page = str_replace('$1',make_search($vars["page"]),$_title_isunfreezed); | |
416 | - $body = str_replace('$1',strip_bracket($vars["page"]),$_title_isunfreezed); | |
417 | - } | |
418 | - else if(md5($post["pass"]) == $adminpass) | |
419 | - { | |
420 | - $postdata = file(get_filename(encode($post["page"]))); | |
421 | - array_shift($postdata); | |
422 | - $postdata = join("",$postdata); | |
423 | - | |
424 | - file_write(DATA_DIR,$vars["page"],$postdata); | |
425 | - | |
426 | - $title = str_replace('$1',strip_bracket($vars["page"]),$_title_unfreezed); | |
427 | - $page = str_replace('$1',make_search($vars["page"]),$_title_unfreezed); | |
428 | - | |
429 | - $postdata = join("",file(get_filename(encode($vars["page"])))); | |
430 | - $postdata = convert_html($postdata); | |
431 | - | |
432 | - $body = $postdata; | |
433 | - } | |
434 | - else | |
435 | - { | |
436 | - $title = str_replace('$1',strip_bracket($vars["page"]),$_title_unfreeze); | |
437 | - $page = str_replace('$1',make_search($vars["page"]),$_title_unfreeze); | |
438 | - | |
439 | - $body.= "<br>\n"; | |
440 | - | |
441 | - if($post["pass"]) | |
442 | - $body .= "<b>$_msg_invalidpass</b><br>\n"; | |
443 | - else | |
444 | - $body.= "$_msg_unfreezing<br>\n"; | |
445 | - | |
446 | - $body.= "<form action=\"$script?cmd=unfreeze\" method=\"post\">\n"; | |
447 | - $body.= "<input type=\"hidden\" name=\"page\" value=\"$vars[page]\">\n"; | |
448 | - $body.= "<input type=\"password\" name=\"pass\" size=\"12\">\n"; | |
449 | - $body.= "<input type=\"submit\" name=\"ok\" value=\"$_btn_unfreeze\">\n"; | |
450 | - $body.= "</form>\n"; | |
451 | - } | |
452 | -} | |
453 | -// 差分の表示 | |
454 | -else if(arg_check("diff")) | |
455 | -{ | |
456 | - $pagename = strip_bracket($get["page"]); | |
457 | - if(!is_page($get["page"])) | |
458 | - { | |
459 | - $title = $pagename; | |
460 | - $page = make_search($vars["page"]); | |
461 | - $body = "指定されたページは見つかりませんでした。"; | |
462 | - } | |
463 | - else | |
464 | - { | |
465 | - $link = str_replace('$1',"<a href=\"$script?".rawurlencode($get["page"])."\">$pagename</a>",$_msg_goto); | |
466 | - | |
467 | - $body = "<ul>\n" | |
468 | - ."<li>$_msg_addline</li>\n" | |
469 | - ."<li>$_msg_delline</li>\n" | |
470 | - ."<li>$link</li>\n" | |
471 | - ."</ul>\n" | |
472 | - ."$hr\n"; | |
473 | - } | |
474 | - | |
475 | - if(!file_exists(DIFF_DIR.encode($get["page"]).".txt") && is_page($get["page"])) | |
476 | - { | |
477 | - $title = str_replace('$1',strip_bracket($get["page"]),$_title_diff); | |
478 | - $page = str_replace('$1',make_search($get["page"]),$_title_diff); | |
479 | - | |
480 | - $diffdata = file(get_filename(encode($get["page"]))); | |
481 | - $body .= "<font color=\"blue\">\n" | |
482 | - ."<pre>\n" | |
483 | - .join("",$diffdata) | |
484 | - ."\n" | |
485 | - ."</pre>\n" | |
486 | - ."</font>\n"; | |
487 | - } | |
488 | - else if(file_exists(DIFF_DIR.encode($get["page"]).".txt")) | |
489 | - { | |
490 | - $title = str_replace('$1',strip_bracket($get["page"]),$_title_diff); | |
491 | - $page = str_replace('$1',make_search($get["page"]),$_title_diff); | |
492 | - | |
493 | - $diffdata = file(DIFF_DIR.encode($get["page"]).".txt"); | |
494 | - $diffdata = preg_replace("/</","<",$diffdata); | |
495 | - $diffdata = preg_replace("/>/",">",$diffdata); | |
496 | - $diffdata = preg_replace("/^(\-)(.*)/","<font color=\"red\"> $2</font>",$diffdata); | |
497 | - $diffdata = preg_replace("/^(\+)(.*)/","<font color=\"blue\"> $2</font>",$diffdata); | |
498 | - | |
499 | - $body .= "<pre>\n" | |
500 | - .join("",$diffdata) | |
501 | - ."\n" | |
502 | - ."</pre>\n"; | |
503 | - } | |
504 | -} | |
505 | -// 検索 | |
506 | -else if(arg_check("search")) | |
507 | -{ | |
508 | - if($vars["word"]) | |
509 | - { | |
510 | - $title = $page = str_replace('$1',$vars["word"],$_title_result); | |
511 | - } | |
512 | - else | |
513 | - { | |
514 | - $page = $title = $_title_search; | |
515 | - } | |
516 | - | |
517 | - if($vars["word"]) | |
518 | - $body = do_search($vars["word"],$vars["type"]); | |
519 | - else | |
520 | - $body = "<br>\n$_msg_searching"; | |
521 | - | |
522 | - if($vars["type"]=="AND" || !$vars["type"]) $and_check = "checked"; | |
523 | - else if($vars["type"]=="OR") $or_check = "checked"; | |
524 | - | |
525 | - $body .= "<form action=\"$script?cmd=search\" method=\"post\">\n" | |
526 | - ."<input type=\"text\" name=\"word\" size=\"20\" value=\"".$vars["word"]."\">\n" | |
527 | - ."<input type=\"radio\" name=\"type\" value=\"AND\" $and_check>$_btn_and\n" | |
528 | - ."<input type=\"radio\" name=\"type\" value=\"OR\" $or_check>$_btn_or\n" | |
529 | - ." <input type=\"submit\" value=\"$_btn_search\">\n" | |
530 | - ."</form>\n"; | |
531 | -} | |
532 | -// バックアップ | |
533 | -else if($do_backup && arg_check("backup")) | |
534 | -{ | |
535 | - if($get["page"] && $get["age"] && (file_exists(BACKUP_DIR.encode($get["page"]).".txt") || file_exists(BACKUP_DIR.encode($get["page"]).".gz"))) | |
536 | - { | |
537 | - $pagename = strip_bracket($get["page"]); | |
538 | - $body = "<ul>\n"; | |
539 | - | |
540 | - $body .= "<li><a href=\"$script?cmd=backup\">$_msg_backuplist</a></li>\n"; | |
541 | - | |
542 | - if(!arg_check("backup_diff") && is_page($get["page"])) | |
543 | - { | |
544 | - $link = str_replace('$1',"<a href=\"$script?cmd=backup_diff&page=".rawurlencode($get["page"])."&age=$get[age]\">$_msg_diff</a>",$_msg_view); | |
545 | - $body .= "<li>$link</li>\n"; | |
546 | - } | |
547 | - if(!arg_check("backup_nowdiff") && is_page($get["page"])) | |
548 | - { | |
549 | - $link = str_replace('$1',"<a href=\"$script?cmd=backup_nowdiff&page=".rawurlencode($get["page"])."&age=$get[age]\">$_msg_nowdiff</a>",$_msg_view); | |
550 | - $body .= "<li>$link</li>\n"; | |
551 | - } | |
552 | - if(!arg_check("backup_source")) | |
553 | - { | |
554 | - $link = str_replace('$1',"<a href=\"$script?cmd=backup_source&page=".rawurlencode($get["page"])."&age=$get[age]\">$_msg_source</a>",$_msg_view); | |
555 | - $body .= "<li>$link</li>\n"; | |
556 | - } | |
557 | - if(arg_check("backup_diff") || arg_check("backup_source") || arg_check("backup_nowdiff")) | |
558 | - { | |
559 | - $link = str_replace('$1',"<a href=\"$script?cmd=backup&page=".rawurlencode($get["page"])."&age=$get[age]\">$_msg_backup</a>",$_msg_view); | |
560 | - $body .= "<li>$link</li>\n"; | |
561 | - } | |
562 | - | |
563 | - if(is_page($get["page"])) | |
564 | - { | |
565 | - $link = str_replace('$1',"<a href=\"$script?".rawurlencode($get["page"])."\">$pagename</a>",$_msg_goto); | |
566 | - $body .= "<li>$link</li>\n"; | |
567 | - } | |
568 | - else | |
569 | - { | |
570 | - $link = str_replace('$1',$pagename,$_msg_deleleted); | |
571 | - $body .= "<li>$link</li>\n"; | |
572 | - } | |
573 | - | |
574 | - $backups = array(); | |
575 | - $backups = get_backup_info(encode($get["page"]).".txt"); | |
576 | - if(count($backups)) $body .= "<ul>\n"; | |
577 | - foreach($backups as $key => $val) | |
578 | - { | |
579 | - $ins_date = date($date_format,$val); | |
580 | - $ins_time = date($time_format,$val); | |
581 | - $ins_week = "(".$weeklabels[date("w",$val)].")"; | |
582 | - $backupdate = "($ins_date $ins_week $ins_time)"; | |
583 | - if($key != $get["age"]) | |
584 | - $body .= "<li><a href=\"$script?cmd=$get[cmd]&page=".rawurlencode($get["page"])."&age=$key\">$key $backupdate</a></li>\n"; | |
585 | - else | |
586 | - $body .= "<li><i>$key $backupdate</i></li>\n"; | |
587 | - } | |
588 | - if(count($backups)) $body .= "</ul>\n"; | |
589 | - | |
590 | - if(arg_check("backup_diff")) | |
591 | - { | |
592 | - $title = str_replace('$1',$pagename,$_title_backupdiff)."(No.$get[age])"; | |
593 | - $page = str_replace('$1',make_search($get["page"]),$_title_backupdiff)."(No.$get[age])"; | |
594 | - | |
595 | - $backupdata = @join("",get_backup($get[age]-1,encode($get["page"]).".txt")); | |
596 | - $postdata = @join("",get_backup($get[age],encode($get["page"]).".txt")); | |
597 | - $diffdata = split("\n",do_diff($backupdata,$postdata)); | |
598 | - } | |
599 | - else if(arg_check("backup_nowdiff")) | |
600 | - { | |
601 | - $title = str_replace('$1',$pagename,$_title_backupnowdiff)."(No.$get[age])"; | |
602 | - $page = str_replace('$1',make_search($get["page"]),$_title_backupnowdiff)."(No.$get[age])"; | |
603 | - | |
604 | - $backupdata = @join("",get_backup($get[age],encode($get["page"]).".txt")); | |
605 | - $postdata = @join("",@file(get_filename(encode($get["page"])))); | |
606 | - $diffdata = split("\n",do_diff($backupdata,$postdata)); | |
607 | - } | |
608 | - else if(arg_check("backup_source")) | |
609 | - { | |
610 | - $title = str_replace('$1',$pagename,$_title_backupsource)."(No.$get[age])"; | |
611 | - $page = str_replace('$1',make_search($get["page"]),$_title_backupsource)."(No.$get[age])"; | |
612 | - $backupdata = join("",get_backup($get[age],encode($get["page"]).".txt")); | |
613 | - | |
614 | - $body.="</ul>\n<pre>\n$backupdata</pre>\n"; | |
615 | - } | |
616 | - else | |
617 | - { | |
618 | - $pagename = strip_bracket($get["page"]); | |
619 | - $title = str_replace('$1',$pagename,$_title_backup)."(No.$get[age])"; | |
620 | - $page = str_replace('$1',make_search($get["page"]),$_title_backup)."(No.$get[age])"; | |
621 | - $backupdata = join("",get_backup($get[age],encode($get["page"]).".txt")); | |
622 | - $backupdata = convert_html($backupdata); | |
623 | - $body .= "</ul>\n" | |
624 | - ."$hr\n"; | |
625 | - $body .= $backupdata; | |
626 | - } | |
627 | - | |
628 | - if(arg_check("backup_diff") || arg_check("backup_nowdiff")) | |
629 | - { | |
630 | - $diffdata = preg_replace("/</","<",$diffdata); | |
631 | - $diffdata = preg_replace("/>/",">",$diffdata); | |
632 | - $diffdata = preg_replace("/^(\-)(.*)/","<font color=\"red\"> $2</font>",$diffdata); | |
633 | - $diffdata = preg_replace("/^(\+)(.*)/","<font color=\"blue\"> $2</font>",$diffdata); | |
634 | - | |
635 | - $body .= "<br>\n" | |
636 | - ."<li>$_msg_addline</li>\n" | |
637 | - ."<li>$_msg_delline</li>\n" | |
638 | - ."</ul>\n" | |
639 | - ."$hr\n" | |
640 | - ."<pre>\n".join("\n",$diffdata)."</pre>\n"; | |
641 | - } | |
642 | - } | |
643 | - else if($get["page"] && (file_exists(BACKUP_DIR.encode($get["page"]).".txt") || file_exists(BACKUP_DIR.encode($get["page"]).".gz"))) | |
644 | - { | |
645 | - $title = str_replace('$1',strip_bracket($get["page"]),$_title_pagebackuplist); | |
646 | - $page = str_replace('$1',make_search($get["page"]),$_title_pagebackuplist); | |
647 | - $body = get_backup_list($get["page"]); | |
648 | - } | |
649 | - else | |
650 | - { | |
651 | - $page = $title = $_title_backuplist; | |
652 | - $body = get_backup_list(); | |
653 | - } | |
654 | -} | |
655 | -// ヘルプの表示 | |
656 | -else if(arg_check("help")) | |
657 | -{ | |
658 | - $title = $page = "ヘルプ"; | |
659 | - $body = catrule(); | |
660 | -} | |
661 | -// MD5パスワードへの変換 | |
662 | -else if($vars["md5"]) | |
663 | -{ | |
664 | - $title = $page = "Make password of MD5"; | |
665 | - $body = "$vars[md5] : ".md5($vars["md5"]); | |
666 | -} | |
667 | -else if(arg_check("rss")) | |
668 | -{ | |
669 | - if(!arg_check("rss10")) | |
670 | - catrss(1); | |
671 | - else | |
672 | - catrss(2); | |
673 | - die(); | |
674 | -} | |
675 | -// ページの表示とInterWikiNameの解釈 | |
676 | -else if((arg_check("read") && $vars["page"] != "") || (!arg_check("read") && $arg != "" && $vars["page"] == "")) | |
677 | -{ | |
678 | - // アクションを明示的に指定していない場合ページ名として解釈 | |
679 | - if($arg != "" && $vars["page"] == "" && $vars["cmd"] == "") | |
680 | - { | |
681 | - $post["page"] = $arg; | |
682 | - $get["page"] = $arg; | |
683 | - $vars["page"] = $arg; | |
684 | - } | |
685 | - | |
686 | - // ページ名がWikiNameでなく、BracketNameでなければBracketNameとして解釈 | |
687 | - if(!preg_match("/^(($WikiName)|($BracketName)|($InterWikiName))$/",$get["page"])) | |
688 | - { | |
689 | - $vars["page"] = "[[$vars[page]]]"; | |
690 | - $get["page"] = $vars["page"]; | |
691 | - } | |
692 | - | |
693 | - // WikiName、BracketNameが示すページを表示 | |
694 | - if(is_page($get["page"])) | |
695 | - { | |
696 | - $postdata = join("",file(get_filename(encode($get["page"])))); | |
697 | - $postdata = convert_html($postdata); | |
698 | - | |
699 | - $title = strip_bracket($get["page"]); | |
700 | - $page = make_search($get["page"]); | |
701 | - $body = $postdata; | |
702 | - | |
703 | - header_lastmod($vars["page"]); | |
704 | - } | |
705 | - else if(preg_match("/($InterWikiName)/",$get["page"],$match)) | |
706 | - { | |
707 | - // InterWikiNameの判別とページの表示 | |
708 | - $interwikis = open_interwikiname_list(); | |
709 | - | |
710 | - if(!$interwikis[$match[2]]["url"]) | |
711 | - { | |
712 | - $title = $page = $_title_invalidiwn; | |
713 | - $body = str_replace('$1',strip_bracket($get[page]),str_replace('$2',"<a href=\"$script?InterWikiName\">InterWikiName</a>",$_msg_invalidiwn)); | |
714 | - } | |
715 | - else | |
716 | - { | |
717 | - // 文字エンコーディング | |
718 | - if($interwikis[$match[2]]["opt"] == "yw") | |
719 | - { | |
720 | - // YukiWiki系 | |
721 | - if(!preg_match("/$WikiName/",$match[3])) | |
722 | - $match[3] = "[[".mb_convert_encoding($match[3],"SJIS","auto")."]]"; | |
723 | - } | |
724 | - else if($interwikis[$match[2]]["opt"] == "moin") | |
725 | - { | |
726 | - // moin系 | |
727 | - if(function_exists("mb_convert_encoding")) | |
728 | - { | |
729 | - $match[3] = rawurlencode(mb_convert_encoding($match[3],"EUC-JP","auto")); | |
730 | - $match[3] = str_replace("%","_",$match[3]); | |
731 | - } | |
732 | - else | |
733 | - $not_mb = 1; | |
734 | - } | |
735 | - else if($interwikis[$match[2]]["opt"] == "" || $interwikis[$match[2]]["opt"] == "std") | |
736 | - { | |
737 | - // 内部文字エンコーディングのままURLエンコード | |
738 | - $match[3] = rawurlencode($match[3]); | |
739 | - } | |
740 | - else if($interwikis[$match[2]]["opt"] == "asis" || $interwikis[$match[2]]["opt"] == "raw") | |
741 | - { | |
742 | - // URLエンコードしない | |
743 | - $match[3] = $match[3]; | |
744 | - } | |
745 | - else if($interwikis[$match[2]]["opt"] != "") | |
746 | - { | |
747 | - // エイリアスの変換 | |
748 | - if($interwikis[$match[2]]["opt"] == "sjis") | |
749 | - $interwikis[$match[2]]["opt"] = "SJIS"; | |
750 | - else if($interwikis[$match[2]]["opt"] == "euc") | |
751 | - $interwikis[$match[2]]["opt"] = "EUC-JP"; | |
752 | - else if($interwikis[$match[2]]["opt"] == "utf8") | |
753 | - $interwikis[$match[2]]["opt"] = "UTF-8"; | |
754 | - | |
755 | - // その他、指定された文字コードへエンコードしてURLエンコード | |
756 | - if(function_exists("mb_convert_encoding")) | |
757 | - $match[3] = rawurlencode(mb_convert_encoding($match[3],$interwikis[$match[2]]["opt"],"auto")); | |
758 | - else | |
759 | - $not_mb = 1; | |
760 | - } | |
761 | - | |
762 | - if(strpos($interwikis[$match[2]]["url"],'$1') !== FALSE) | |
763 | - $url = str_replace('$1',$match[3],$interwikis[$match[2]]["url"]); | |
764 | - else | |
765 | - $url = $interwikis[$match[2]]["url"] . $match[3]; | |
766 | - | |
767 | - if($not_mb) | |
768 | - { | |
769 | - $title = $page = "Not support mb_jstring."; | |
770 | - $body = "This server's PHP does not have \"mb_jstring\" module.Cannot convert encoding."; | |
771 | - } | |
772 | - else | |
773 | - { | |
774 | - header("Location: $url"); | |
775 | - die(); | |
776 | - } | |
777 | - } | |
778 | - } | |
779 | - // WikiName、BracketNameが見つからず、InterWikiNameでもない場合 | |
780 | - else | |
781 | - { | |
782 | - //$title = strip_bracket($get["page"]); | |
783 | - //$page = make_search($get["page"]); | |
784 | - //$body = "指定されたページは見つかりませんでした。"; | |
785 | - | |
786 | - $title = str_replace('$1',strip_bracket($get["page"]),$_title_edit); | |
787 | - $page = str_replace('$1',make_search($get["page"]),$_title_edit); | |
788 | - $body = edit_form("",$get["page"]); | |
789 | - } | |
790 | -} | |
791 | -// 何も指定されない場合、トップページを表示 | |
792 | -else | |
793 | -{ | |
794 | - $postdata = join("",file(get_filename(encode($defaultpage)))); | |
795 | - | |
796 | - $vars["page"] = $defaultpage; | |
797 | - $title = strip_bracket($defaultpage); | |
798 | - $page = make_search($vars["page"]); | |
799 | - $body = convert_html($postdata); | |
800 | - | |
801 | - header_lastmod($vars["page"]); | |
802 | -} | |
803 | - | |
804 | -// ** 出力処理 ** | |
805 | - | |
806 | -catbody($title,$page,$body); | |
807 | - | |
808 | -// ** 各種関数 ** | |
809 | - | |
810 | -// 本文をページ名から出力 | |
811 | -function catbodyall($page,$title="",$pg="") | |
812 | -{ | |
813 | - if($title === "") $title = strip_bracket($page); | |
814 | - if($pg === "") $pg = make_search($page); | |
815 | - | |
816 | - $body = join("",file(get_filename(encode($page)))); | |
817 | - $body = convert_html($body); | |
818 | - | |
819 | - header_lastmod($vars["page"]); | |
820 | - catbody($title,$pg,$body); | |
821 | - die(); | |
822 | -} | |
823 | - | |
824 | -// 本文を出力 | |
825 | -function catbody($title,$page,$body) | |
826 | -{ | |
827 | - global $script,$vars,$arg,$do_backup,$modifier,$modifierlink,$defaultpage,$whatsnew,$hr; | |
828 | - global $date_format,$weeklabels,$time_format,$longtaketime,$related_link; | |
829 | - global $HTTP_SERVER_VARS,$cantedit; | |
830 | - | |
831 | - if($vars["page"] && !arg_check("backup") && $vars["page"] != $whatsnew) | |
832 | - { | |
833 | - $is_page = 1; | |
834 | - } | |
835 | - | |
836 | - $link_add = "$script?cmd=add&page=".rawurlencode($vars["page"]); | |
837 | - $link_edit = "$script?cmd=edit&page=".rawurlencode($vars["page"]); | |
838 | - $link_diff = "$script?cmd=diff&page=".rawurlencode($vars["page"]); | |
839 | - $link_top = "$script?$defaultpage"; | |
840 | - $link_list = "$script?cmd=list"; | |
841 | - $link_filelist = "$script?cmd=filelist"; | |
842 | - $link_search = "$script?cmd=search"; | |
843 | - $link_whatsnew = "$script?$whatsnew"; | |
844 | - $link_backup = "$script?cmd=backup&page=".rawurlencode($vars["page"]); | |
845 | - $link_help = "$script?cmd=help"; | |
846 | - | |
847 | - if(is_page($vars["page"]) && $is_page) | |
848 | - { | |
849 | - $fmt = @filemtime(get_filename(encode($vars["page"]))); | |
850 | - } | |
851 | - | |
852 | - if(is_page($vars["page"]) && $related_link && $is_page && !arg_check("edit") && !arg_check("freeze") && !arg_check("unfreeze")) | |
853 | - { | |
854 | - $related = make_related($vars["page"],false); | |
855 | - } | |
856 | - | |
857 | - if(is_page($vars["page"]) && !in_array($vars["page"],$cantedit) && !arg_check("backup") && !arg_check("edit") && !$vars["preview"]) | |
858 | - { | |
859 | - $is_read = TRUE; | |
860 | - } | |
861 | - | |
862 | - //if(!$longtaketime) | |
863 | - $longtaketime = getmicrotime() - MUTIME; | |
864 | - $taketime = sprintf("%01.03f",$longtaketime); | |
865 | - | |
866 | - require(SKIN_FILE); | |
867 | -} | |
868 | - | |
869 | -// ファイルへの出力 | |
870 | -function file_write($dir,$page,$str) | |
871 | -{ | |
872 | - global $post,$update_exec; | |
873 | - | |
874 | - if($str == "") | |
875 | - { | |
876 | - @unlink($dir.encode($page).".txt"); | |
877 | - } | |
878 | - else | |
879 | - { | |
880 | - if($post["notimestamp"] && is_page($page)) | |
881 | - { | |
882 | - $timestamp = @filemtime($dir.encode($page).".txt"); | |
883 | - } | |
884 | - $fp = fopen($dir.encode($page).".txt","w"); | |
885 | - while(!flock($fp,LOCK_EX)); | |
886 | - fputs($fp,$str); | |
887 | - flock($fp,LOCK_UN); | |
888 | - fclose($fp); | |
889 | - if($timestamp) | |
890 | - touch($dir.encode($page).".txt",$timestamp); | |
891 | - } | |
892 | - | |
893 | - if(!$timestamp) | |
894 | - put_lastmodified(); | |
895 | - | |
896 | - if($update_exec) | |
897 | - { | |
898 | - system($update_exec." > /dev/null &"); | |
899 | - } | |
900 | -} | |
901 | - | |
902 | -// バックアップ一覧の取得 | |
903 | -function get_backup_list($_page="") | |
904 | -{ | |
905 | - global $script,$date_format,$time_format,$weeklabels,$cantedit; | |
906 | - global $_msg_backuplist,$_msg_diff,$_msg_nowdiff,$_msg_source; | |
907 | - | |
908 | - $ins_date = date($date_format,$val); | |
909 | - $ins_time = date($time_format,$val); | |
910 | - $ins_week = "(".$weeklabels[date("w",$val)].")"; | |
911 | - $ins = "$ins_date $ins_week $ins_time"; | |
912 | - | |
913 | - if (($dir = @opendir(BACKUP_DIR)) && !$_page) | |
914 | - { | |
915 | - while($file = readdir($dir)) | |
916 | - { | |
917 | - if(function_exists(gzopen)) | |
918 | - $file = str_replace(".txt",".gz",$file); | |
919 | - | |
920 | - if($file == ".." || $file == ".") continue; | |
921 | - $page = decode(trim(preg_replace("/(\.txt)|(\.gz)$/"," ",$file))); | |
922 | - if(in_array($page,$cantedit)) continue; | |
923 | - $page_url = rawurlencode($page); | |
924 | - $name = $page; | |
925 | - $name = strip_bracket($name); | |
926 | - if(is_page($page)) | |
927 | - $vals[$name]["link"] = "<li><a href=\"$script?$page_url\">$name</a></li>"; | |
928 | - else | |
929 | - $vals[$name]["link"] = "<li>$name</li>"; | |
930 | - $vals[$name]["name"] = $page; | |
931 | - } | |
932 | - closedir($dir); | |
933 | - $vals = list_sort($vals); | |
934 | - $retvars[] = "<ul>"; | |
935 | - } | |
936 | - else | |
937 | - { | |
938 | - $page_url = rawurlencode($_page); | |
939 | - $name = strip_bracket($_page); | |
940 | - $vals[$name]["link"] = ""; | |
941 | - $vals[$name]["name"] = $_page; | |
942 | - $retvars[] = "<ul>"; | |
943 | - $retvars[] .= "<li><a href=\"$script?cmd=backup\">$_msg_backuplist</a></li>\n"; | |
944 | - } | |
945 | - | |
946 | - | |
947 | - foreach($vals as $page => $line) | |
948 | - { | |
949 | - $arybackups = get_backup_info(encode($line["name"]).".txt"); | |
950 | - $page_url = rawurlencode($line["name"]); | |
951 | - if(count($arybackups)) $line["link"] .= "\n<ul>\n"; | |
952 | - foreach($arybackups as $key => $val) | |
953 | - { | |
954 | - $ins_date = date($date_format,$val); | |
955 | - $ins_time = date($time_format,$val); | |
956 | - $ins_week = "(".$weeklabels[date("w",$val)].")"; | |
957 | - $backupdate = "($ins_date $ins_week $ins_time)"; | |
958 | - if(!$_page) | |
959 | - { | |
960 | - $line["link"] .= "<li><a href=\"$script?cmd=backup&page=$page_url&age=$key\">$key $backupdate</a></li>\n"; | |
961 | - } | |
962 | - else | |
963 | - { | |
964 | - $line["link"] .= "<li><a href=\"$script?cmd=backup&page=$page_url&age=$key\">$key $backupdate</a> [ <a href=\"$script?cmd=backup_diff&page=$page_url&age=$key\">$_msg_diff</a> | <a href=\"$script?cmd=backup_nowdiff&page=$page_url&age=$key\">$_msg_nowdiff</a> | <a href=\"$script?cmd=backup_source&page=$page_url&age=$key\">$_msg_source</a> ]</li>\n"; | |
965 | - } | |
966 | - } | |
967 | - if(count($arybackups)) $line["link"] .= "</ul>"; | |
968 | - $retvars[] = $line["link"]; | |
969 | - } | |
970 | - $retvars[] = "</ul>"; | |
971 | - | |
972 | - return join("\n",$retvars); | |
973 | -} | |
974 | - | |
975 | -// 最終更新ページの更新 | |
976 | -function put_lastmodified() | |
977 | -{ | |
978 | - global $script,$maxshow,$whatsnew,$date_format,$time_format,$weeklabels,$post,$non_list; | |
979 | - | |
980 | - if($post["notimestamp"]) return; | |
981 | - | |
982 | - if ($dir = @opendir(DATA_DIR)) | |
983 | - { | |
984 | - while($file = readdir($dir)) | |
985 | - { | |
986 | - $page = decode(trim(preg_replace("/\.txt$/"," ",$file))); | |
987 | - | |
988 | - if($page == $whatsnew || $file == "." || $file == "..") continue; | |
989 | - if(preg_match("/$non_list/",$page)) continue; | |
990 | - | |
991 | - if(file_exists(get_filename(encode($page)))) | |
992 | - { | |
993 | - $page_url = rawurlencode($page); | |
994 | - $lastmodtime = filemtime(get_filename(encode($page))); | |
995 | - $lastmod = date($date_format,$lastmodtime) | |
996 | - . " (" . $weeklabels[date("w",$lastmodtime)] . ") " | |
997 | - . date($time_format,$lastmodtime); | |
998 | - $putval[$lastmodtime][] = "-$lastmod - $page"; | |
999 | - } | |
1000 | - } | |
1001 | - closedir($dir); | |
1002 | - } | |
1003 | - | |
1004 | - $cnt = 1; | |
1005 | - krsort($putval); | |
1006 | - $fp = fopen(get_filename(encode($whatsnew)),"w"); | |
1007 | - flock($fp,LOCK_EX); | |
1008 | - foreach($putval as $pages) | |
1009 | - { | |
1010 | - foreach($pages as $page) | |
1011 | - { | |
1012 | - fputs($fp,$page."\n"); | |
1013 | - $cnt++; | |
1014 | - if($cnt > $maxshow) break; | |
1015 | - } | |
1016 | - if($cnt > $maxshow) break; | |
1017 | - } | |
1018 | - flock($fp,LOCK_EX); | |
1019 | - fclose($fp); | |
1020 | -} | |
1021 | - | |
1022 | -// 検索 | |
1023 | -function do_search($word,$type="AND",$non_format=0) | |
1024 | -{ | |
1025 | - global $script,$whatsnew,$vars; | |
1026 | - global $_msg_andresult,$_msg_orresult,$_msg_notfoundresult; | |
1027 | - | |
1028 | - $database = array(); | |
1029 | - $retval = array(); | |
1030 | - $cnt = 0; | |
1031 | - | |
1032 | - if ($dir = @opendir(DATA_DIR)) | |
1033 | - { | |
1034 | - while($file = readdir($dir)) | |
1035 | - { | |
1036 | - if($file == ".." || $file == ".") continue; | |
1037 | - $cnt++; | |
1038 | - $page = decode(trim(preg_replace("/\.txt$/"," ",$file))); | |
1039 | - if($page == $whatsnew) continue; | |
1040 | - if($page == $vars["page"] && $non_format) continue; | |
1041 | - $data[$page] = file(DATA_DIR.$file); | |
1042 | - } | |
1043 | - closedir($dir); | |
1044 | - } | |
1045 | - | |
1046 | - $arywords = explode(" ",$word); | |
1047 | - $result_word = $word; | |
1048 | - | |
1049 | - foreach($data as $name => $lines) | |
1050 | - { | |
1051 | - $line = join("\n",$lines); | |
1052 | - | |
1053 | - $hit = 0; | |
1054 | - if(strpos($result_word," ") !== FALSE) | |
1055 | - { | |
1056 | - foreach($arywords as $word) | |
1057 | - { | |
1058 | - if($type=="AND") | |
1059 | - { | |
1060 | - if(strpos($line,$word) === FALSE) | |
1061 | - { | |
1062 | - $hit = 0; | |
1063 | - break; | |
1064 | - } | |
1065 | - else | |
1066 | - { | |
1067 | - $hit = 1; | |
1068 | - } | |
1069 | - } | |
1070 | - else if($type=="OR") | |
1071 | - { | |
1072 | - if(strpos($line,$word) !== FALSE) | |
1073 | - $hit = 1; | |
1074 | - } | |
1075 | - } | |
1076 | - if($hit==1 || strpos($name,$word)!==FALSE) | |
1077 | - { | |
1078 | - $page_url = rawurlencode($name); | |
1079 | - $word_url = rawurlencode($word); | |
1080 | - $name2 = strip_bracket($name); | |
1081 | - $str = get_pg_passage($name); | |
1082 | - $retval[$name2] = "<li><a href=\"$script?$page_url\">$name2</a>$str</li>"; | |
1083 | - } | |
1084 | - } | |
1085 | - else | |
1086 | - { | |
1087 | - if(stristr($line,$word) || stristr($name,$word)) | |
1088 | - { | |
1089 | - $page_url = rawurlencode($name); | |
1090 | - $word_url = rawurlencode($word); | |
1091 | - $name2 = strip_bracket($name); | |
1092 | - $link_tag = "<a href=\"$script?$page_url\">$name2</a>"; | |
1093 | - $link_tag .= get_pg_passage($name,false); | |
1094 | - if($non_format) | |
1095 | - { | |
1096 | - $tm = @filemtime(get_filename(encode($name))); | |
1097 | - $retval[$tm] = $link_tag; | |
1098 | - } | |
1099 | - else | |
1100 | - { | |
1101 | - $retval[$name2] = "<li>$link_tag</li>"; | |
1102 | - } | |
1103 | - } | |
1104 | - } | |
1105 | - } | |
1106 | - | |
1107 | - if($non_format) | |
1108 | - return $retval; | |
1109 | - | |
1110 | - $retval = list_sort($retval); | |
1111 | - | |
1112 | - if(count($retval) && !$non_format) | |
1113 | - { | |
1114 | - $retvals = "<ul>\n" . join("\n",$retval) . "</ul>\n<br>\n"; | |
1115 | - | |
1116 | - if($type=="AND") | |
1117 | - $retvals.= str_replace('$1',$result_word,str_replace('$2',count($retval),str_replace('$3',$cnt,$_msg_andresult))); | |
1118 | - else | |
1119 | - $retvals.= str_replace('$1',$result_word,str_replace('$2',count($retval),str_replace('$3',$cnt,$_msg_orresult))); | |
1120 | - | |
1121 | - } | |
1122 | - else | |
1123 | - $retvals .= str_replace('$1',$result_word,$_msg_notfoundresult); | |
1124 | - return $retvals; | |
1125 | -} | |
1126 | - | |
1127 | -// 差分の作成 | |
1128 | -function do_diff($strlines1,$strlines2) | |
1129 | -{ | |
1130 | - $lines1 = split("\n",$strlines1); | |
1131 | - $lines2 = split("\n",$strlines2); | |
1132 | - | |
1133 | - $same_lines = $diff_lines = $del_lines = $add_lines = $retdiff = array(); | |
1134 | - | |
1135 | - if(count($lines1) > count($lines2)) { $max_line = count($lines1)+2; } | |
1136 | - else { $max_line = count($lines2)+2; } | |
1137 | - | |
1138 | - //$same_lines = array_intersect($lines1,$lines2); | |
1139 | - | |
1140 | - $diff_lines = array_diff($lines1,$lines2); | |
1141 | - $diff_lines = array_merge($diff_lines,array_diff($lines2,$lines1)); | |
1142 | - | |
1143 | - foreach($diff_lines as $line) | |
1144 | - { | |
1145 | - $index = array_search($line,$lines1); | |
1146 | - if($index > -1) | |
1147 | - { | |
1148 | - $del_lines[$index] = $line; | |
1149 | - } | |
1150 | - | |
1151 | - //$index = array_search($line,$lines2); | |
1152 | - //if($index > -1) | |
1153 | - //{ | |
1154 | - // $add_lines[$index] = $line; | |
1155 | - //} | |
1156 | - } | |
1157 | - | |
1158 | - $cnt=0; | |
1159 | - foreach($lines2 as $line) | |
1160 | - { | |
1161 | - $line = rtrim($line); | |
1162 | - | |
1163 | - while($del_lines[$cnt]) | |
1164 | - { | |
1165 | - $retdiff[] = "- ".$del_lines[$cnt]; | |
1166 | - $del_lines[$cnt] = ""; | |
1167 | - $cnt++; | |
1168 | - } | |
1169 | - | |
1170 | - if(in_array($line,$diff_lines)) | |
1171 | - { | |
1172 | - $retdiff[] = "+ $line"; | |
1173 | - } | |
1174 | - else | |
1175 | - { | |
1176 | - $retdiff[] = " $line"; | |
1177 | - } | |
1178 | - | |
1179 | - $cnt++; | |
1180 | - } | |
1181 | - | |
1182 | - foreach($del_lines as $line) | |
1183 | - { | |
1184 | - if(trim($line)) | |
1185 | - $retdiff[] = "- $line"; | |
1186 | - } | |
1187 | - | |
1188 | - return join("\n",$retdiff); | |
1189 | -} | |
1190 | - | |
1191 | -// 一覧の取得 | |
1192 | -function get_list($withfilename) | |
1193 | -{ | |
1194 | - global $script,$list_index,$top,$non_list,$whatsnew; | |
1195 | - global $_msg_symbol,$_msg_other; | |
1196 | - | |
1197 | - $retval = array(); | |
1198 | - if ($dir = @opendir(DATA_DIR)) | |
1199 | - { | |
1200 | - while($file = readdir($dir)) | |
1201 | - { | |
1202 | - $page = decode(trim(preg_replace("/\.txt$/"," ",$file))); | |
1203 | - if($file == ".." || $file == ".") continue; | |
1204 | - if(preg_match("/$non_list/",$page) && !$withfilename) continue; | |
1205 | - if($page == $whatsnew) continue; | |
1206 | - $page_url = rawurlencode($page); | |
1207 | - $page2 = strip_bracket($page); | |
1208 | - $pg_passage = get_pg_passage($page); | |
1209 | - $retval[$page2] .= "<li><a href=\"$script?$page_url\">$page2</a>$pg_passage</li>\n"; | |
1210 | - if($withfilename) | |
1211 | - { | |
1212 | - $retval[$page2] .= "<ul><li>$file</li></ul>\n"; | |
1213 | - } | |
1214 | - } | |
1215 | - closedir($dir); | |
1216 | - } | |
1217 | - | |
1218 | - $retval = list_sort($retval); | |
1219 | - | |
1220 | - if($list_index) | |
1221 | - { | |
1222 | - $head_str = ""; | |
1223 | - $etc_sw = 0; | |
1224 | - $symbol_sw = 0; | |
1225 | - $top_link = ""; | |
1226 | - foreach($retval as $page => $link) | |
1227 | - { | |
1228 | - $head = substr($page,0,1); | |
1229 | - if($head_str != $head && !$etc_sw) | |
1230 | - { | |
1231 | - $retval2[$page] = ""; | |
1232 | - | |
1233 | - if(preg_match("/([A-Z])|([a-z])/",$head,$match)) | |
1234 | - { | |
1235 | - if($match[1]) | |
1236 | - $head_nm = "High:$head"; | |
1237 | - else | |
1238 | - $head_nm = "Low:$head"; | |
1239 | - | |
1240 | - if($head_str) $retval2[$page] = "</ul>\n"; | |
1241 | - $retval2[$page] .= "<li><a href=\"#top:$head_nm\" name=\"$head_nm\"><b>$head</b></a></li>\n<ul>\n"; | |
1242 | - $head_str = $head; | |
1243 | - if($top_link) $top_link .= "|"; | |
1244 | - $top_link .= "<a href=\"#$head_nm\" name=\"top:$head_nm\"><b> ".$head." </b></a>"; | |
1245 | - } | |
1246 | - else if(preg_match("/[ -~]/",$head)) | |
1247 | - { | |
1248 | - if(!$symbol_sw) | |
1249 | - { | |
1250 | - if($head_str) $retval2[$page] = "</ul>\n"; | |
1251 | - $retval2[$page] .= "<li><a href=\"#top:symbol\" name=\"symbol\"><b>$_msg_symbol</b></a></li>\n<ul>\n"; | |
1252 | - $head_str = $head; | |
1253 | - if($top_link) $top_link .= "|"; | |
1254 | - $top_link .= "<a href=\"#symbol\" name=\"top:symbol\"><b>$_msg_symbol</b></a>"; | |
1255 | - $symbol_sw = 1; | |
1256 | - } | |
1257 | - } | |
1258 | - else | |
1259 | - { | |
1260 | - if($head_str) $retval2[$page] = "</ul>\n"; | |
1261 | - $retval2[$page] .= "<li><a href=\"#top:etc\" name=\"etc\"><b>$_msg_other</b></a></li>\n<ul>\n"; | |
1262 | - $etc_sw = 1; | |
1263 | - if($top_link) $top_link .= "|"; | |
1264 | - $top_link .= "<a href=\"#etc\" name=\"top:etc\"><b>$_msg_other</b></a>"; | |
1265 | - } | |
1266 | - } | |
1267 | - $retval2[$page] .= $link; | |
1268 | - } | |
1269 | - $retval2[] = "</ul>\n"; | |
1270 | - | |
1271 | - $top_link = "<div align=\"center\"><a name=\"top\">$top_link</a></div><br>\n"; | |
1272 | - | |
1273 | - array_unshift($retval2,$top_link); | |
1274 | - } | |
1275 | - else | |
1276 | - { | |
1277 | - $retval2 = $retval; | |
1278 | - } | |
1279 | - | |
1280 | - return join("",$retval2); | |
1281 | -} | |
1282 | - | |
1283 | -// 編集フォームの表示 | |
1284 | -function edit_form($postdata,$page,$add=0) | |
1285 | -{ | |
1286 | - global $script,$rows,$cols,$hr,$vars,$function_freeze; | |
1287 | - global $_btn_addtop,$_btn_preview,$_btn_update,$_btn_freeze,$_msg_help,$_btn_notchangetimestamp; | |
1288 | - global $whatsnew,$_btn_template,$_btn_load,$non_list,$load_template_func; | |
1289 | - | |
1290 | - $digest = md5(@join("",@file(get_filename(encode($page))))); | |
1291 | - | |
1292 | - if($add) | |
1293 | - { | |
1294 | - $addtag = '<input type="hidden" name="add" value="true">'; | |
1295 | - $add_top = '<input type="checkbox" name="add_top" value="true"><small>'.$_btn_addtop.'</small>'; | |
1296 | - } | |
1297 | - | |
1298 | - if($vars["help"] == "true") | |
1299 | - $help = $hr.catrule(); | |
1300 | - else | |
1301 | - $help = "<br>\n<ul><li><a href=\"$script?cmd=edit&help=true&page=".rawurlencode($page)."\">$_msg_help</a></ul></li>\n"; | |
1302 | - | |
1303 | - if($function_freeze) | |
1304 | - $str_freeze = '<input type="submit" name="freeze" value="'.$_btn_freeze.'" accesskey="f">'; | |
1305 | - | |
1306 | - if($load_template_func) | |
1307 | - { | |
1308 | - $vals = array(); | |
1309 | - if ($dir = @opendir(DATA_DIR)) | |
1310 | - { | |
1311 | - while($file = readdir($dir)) | |
1312 | - { | |
1313 | - $pg_org = decode(trim(preg_replace("/\.txt$/"," ",$file))); | |
1314 | - if($file == ".." || $file == "." || $pg_org == $whatsnew) continue; | |
1315 | - if(preg_match("/$non_list/",$pg_org)) continue; | |
1316 | - $name = strip_bracket($pg_org); | |
1317 | - $vals[$name] = " <option value=\"$pg_org\">$name</option>"; | |
1318 | - } | |
1319 | - closedir($dir); | |
1320 | - } | |
1321 | - @ksort($vals); | |
1322 | - | |
1323 | - $template = " <select name=\"template_page\">\n" | |
1324 | - ." <option value=\"\">-- $_btn_template --</option>\n" | |
1325 | - .join("\n",$vals) | |
1326 | - ." </select>\n" | |
1327 | - ." <input type=\"submit\" name=\"template\" value=\"$_btn_load\" accesskey=\"r\"><br>\n"; | |
1328 | - | |
1329 | - if($vars["refer"]) $refer = $vars["refer"]."\n\n"; | |
1330 | - } | |
1331 | - | |
1332 | -return ' | |
1333 | -<form action="'.$script.'" method="post"> | |
1334 | -<input type="hidden" name="page" value="'.$page.'"> | |
1335 | -<input type="hidden" name="digest" value="'.$digest.'"> | |
1336 | -'.$addtag.' | |
1337 | -<table cellspacing="3" cellpadding="0" border="0"> | |
1338 | - <tr> | |
1339 | - <td colspan="2" align="right"> | |
1340 | -'.$template.' | |
1341 | - </td> | |
1342 | - </tr> | |
1343 | - <tr> | |
1344 | - <td colspan="2" align="right"> | |
1345 | - <textarea name="msg" rows="'.$rows.'" cols="'.$cols.'" wrap="virtual"> | |
1346 | -'.$refer.$postdata.'</textarea> | |
1347 | - </td> | |
1348 | - </tr> | |
1349 | - <tr> | |
1350 | - <td> | |
1351 | - <input type="submit" name="preview" value="'.$_btn_preview.'" accesskey="p"> | |
1352 | - <input type="submit" name="write" value="'.$_btn_update.'" accesskey="s"> | |
1353 | - '.$add_top.' | |
1354 | - <input type="checkbox" name="notimestamp" value="true"><small>'.$_btn_notchangetimestamp.'</small> | |
1355 | - </td> | |
1356 | - </form> | |
1357 | - <form action="'.$script.'?cmd=freeze" method="post"> | |
1358 | - <input type="hidden" name="page" value="'.$vars["page"].'"> | |
1359 | - <td align="right"> | |
1360 | - '.$str_freeze.' | |
1361 | - </td> | |
1362 | - </form> | |
1363 | - </tr> | |
1364 | -</table> | |
1365 | -' . $help; | |
1366 | -} | |
1367 | - | |
1368 | -// ファイル名を得る(エンコードされている必要有り) | |
1369 | -function get_filename($pagename) | |
1370 | -{ | |
1371 | - return DATA_DIR.$pagename.".txt"; | |
1372 | -} | |
1373 | - | |
1374 | -// ページが存在するかしないか | |
1375 | -function is_page($page,$reload=false) | |
1376 | -{ | |
1377 | - global $InterWikiName,$_ispage; | |
1378 | - | |
1379 | - if(($_ispage[$page] === true || $_ispage[$page] === false) && !$reload) return $_ispage[$page]; | |
1380 | - | |
1381 | - if(preg_match("/($InterWikiName)/",$page)) | |
1382 | - $_ispage[$page] = false; | |
1383 | - else if(!file_exists(get_filename(encode($page)))) | |
1384 | - $_ispage[$page] = false; | |
1385 | - else | |
1386 | - $_ispage[$page] = true; | |
1387 | - | |
1388 | - return $_ispage[$page]; | |
1389 | -} | |
1390 | - | |
1391 | -// ページが編集可能か | |
1392 | -function is_editable($page) | |
1393 | -{ | |
1394 | - global $BracketName,$WikiName,$InterWikiName,$cantedit,$_editable; | |
1395 | - | |
1396 | - if($_editable === true || $_editable === false) return $_editable; | |
1397 | - | |
1398 | - if(preg_match("/^$InterWikiName$/",$page)) | |
1399 | - $_editable = false; | |
1400 | - elseif(!preg_match("/^$BracketName$/",$page) && !preg_match("/^$WikiName$/",$page)) | |
1401 | - $_editable = false; | |
1402 | - else if(in_array($page,$cantedit)) | |
1403 | - $_editable = false; | |
1404 | - else | |
1405 | - $_editable = true; | |
1406 | - | |
1407 | - return $_editable; | |
1408 | -} | |
1409 | - | |
1410 | -// ページが凍結されているか | |
1411 | -function is_freeze($page) | |
1412 | -{ | |
1413 | - global $_freeze; | |
1414 | - | |
1415 | - if(!is_page($page)) return false; | |
1416 | - if($_freeze === true || $_freeze === false) return $_freeze; | |
1417 | - | |
1418 | - $lines = file(get_filename(encode($page))); | |
1419 | - | |
1420 | - if($lines[0] == "#freeze\n") | |
1421 | - $_freeze = true; | |
1422 | - else | |
1423 | - $_freeze = false; | |
1424 | - | |
1425 | - return $_freeze; | |
1426 | -} | |
1427 | - | |
1428 | -// プログラムへの引数のチェック | |
1429 | -function arg_check($str) | |
1430 | -{ | |
1431 | - global $arg,$vars; | |
1432 | - | |
1433 | - return preg_match("/^".$str."/",$vars["cmd"]); | |
1434 | -} | |
1435 | - | |
1436 | -// ページリストのソート | |
1437 | -function list_sort($values) | |
1438 | -{ | |
1439 | - if(!is_array($values)) return array(); | |
1440 | - | |
1441 | - // ksortのみだと、[[日本語]]、[[英文字]]、英文字のみ、に順に並べ替えられる | |
1442 | - ksort($values); | |
1443 | - | |
1444 | - $vals1 = array(); | |
1445 | - $vals2 = array(); | |
1446 | - $vals3 = array(); | |
1447 | - | |
1448 | - // 英文字のみ、[[英文字]]、[[日本語]]、の順に並べ替える | |
1449 | - foreach($values as $key => $val) | |
1450 | - { | |
1451 | - if(preg_match("/\[\[[^\w]+\]\]/",$key)) | |
1452 | - $vals3[$key] = $val; | |
1453 | - else if(preg_match("/\[\[[\W]+\]\]/",$key)) | |
1454 | - $vals2[$key] = $val; | |
1455 | - else | |
1456 | - $vals1[$key] = $val; | |
1457 | - } | |
1458 | - return array_merge($vals1,$vals2,$vals3); | |
1459 | -} | |
1460 | - | |
1461 | -// ページ名のエンコード | |
1462 | -function encode($key) | |
1463 | -{ | |
1464 | - $enkey = ''; | |
1465 | - $arych = preg_split("//", $key, -1, PREG_SPLIT_NO_EMPTY); | |
1466 | - | |
1467 | - foreach($arych as $ch) | |
1468 | - { | |
1469 | - $enkey .= sprintf("%02X", ord($ch)); | |
1470 | - } | |
1471 | - | |
1472 | - return $enkey; | |
1473 | -} | |
1474 | - | |
1475 | -// ファイル名のデコード | |
1476 | -function decode($key) | |
1477 | -{ | |
1478 | - $dekey = ''; | |
1479 | - | |
1480 | - for($i=0;$i<strlen($key);$i+=2) | |
1481 | - { | |
1482 | - $ch = substr($key,$i,2); | |
1483 | - $dekey .= chr(intval("0x".$ch,16)); | |
1484 | - } | |
1485 | - return urldecode($dekey); | |
1486 | -} | |
1487 | - | |
1488 | -// テキスト本体をHTMLに変換する | |
1489 | -function convert_html($string) | |
1490 | -{ | |
1491 | - global $result,$saved,$hr,$script,$page,$vars,$top; | |
1492 | - global $note_id,$foot_explain,$digest,$note_hr; | |
1493 | - global $user_rules,$str_rules,$line_rules,$strip_link_wall; | |
1494 | - | |
1495 | - global $longtaketime; | |
1496 | - | |
1497 | - $string = rtrim($string); | |
1498 | - $string = preg_replace("/(\x0D\x0A)/","\n",$string); | |
1499 | - $string = preg_replace("/(\x0D)/","\n",$string); | |
1500 | - $string = preg_replace("/(\x0A)/","\n",$string); | |
1501 | - | |
1502 | - $start_mtime = getmicrotime(); | |
1503 | - | |
1504 | - $digest = md5(@join("",@file(get_filename(encode($vars["page"]))))); | |
1505 | - | |
1506 | - $content_id = 0; | |
1507 | - $user_rules = array_merge($str_rules,$line_rules); | |
1508 | - | |
1509 | - $result = array(); | |
1510 | - $saved = array(); | |
1511 | - $arycontents = array(); | |
1512 | - | |
1513 | - $string = preg_replace("/^#freeze\n/","",$string); | |
1514 | - | |
1515 | - $lines = split("\n", $string); | |
1516 | - $note_id = 1; | |
1517 | - $foot_explain = array(); | |
1518 | - | |
1519 | - $table = 0; | |
1520 | - | |
1521 | - if(preg_match("/#contents/",$string)) | |
1522 | - $top_link = "<a href=\"#contents\">$top</a>"; | |
1523 | - | |
1524 | - foreach ($lines as $line) | |
1525 | - { | |
1526 | - if(!preg_match("/^\/\/(.*)/",$line,$comment_out) && $table != 0) | |
1527 | - { | |
1528 | - if(!preg_match("/^\|(.+)\|$/",$line,$out)) | |
1529 | - array_push($result, "</table>"); | |
1530 | - if(!$out[1] || $table != count(explode("|",$out[1]))) | |
1531 | - $table = 0; | |
1532 | - } | |
1533 | - | |
1534 | - $comment_out = $comment_out[1]; | |
1535 | - | |
1536 | - if(preg_match("/^(\*{1,3})(.*)/",$line,$out)) | |
1537 | - { | |
1538 | - $result = array_merge($result,$saved); $saved = array(); | |
1539 | - $str = inline($out[2]); | |
1540 | - | |
1541 | - $level = strlen($out[1]) + 1; | |
1542 | - | |
1543 | - array_push($result, "<h$level><a name=\"content:$content_id\">$str</a> $top_link</h$level>"); | |
1544 | - $arycontents[] = str_repeat("-",$level-1)."<a href=\"#content:$content_id\">".strip_htmltag($str)."</a>\n"; | |
1545 | - $content_id++; | |
1546 | - } | |
1547 | - else if(preg_match("/^(-{1,4})(.*)/",$line,$out)) | |
1548 | - { | |
1549 | - if(strlen($out[1]) == 4) | |
1550 | - { | |
1551 | - $result = array_merge($result,$saved); $saved = array(); | |
1552 | - array_push($result, $hr); | |
1553 | - } | |
1554 | - else | |
1555 | - { | |
1556 | - back_push('ul', strlen($out[1])); | |
1557 | - array_push($result, '<li>' . inline($out[2]) . '</li>'); | |
1558 | - } | |
1559 | - } | |
1560 | - else if (preg_match("/^:([^:]+):(.*)/",$line,$out)) | |
1561 | - { | |
1562 | - back_push('dl', 1); | |
1563 | - array_push($result, '<dt>' . inline($out[1]) . '</dt>', '<dd>' . inline($out[2]) . '</dd>'); | |
1564 | - } | |
1565 | - else if(preg_match("/^(>{1,3})(.*)/",$line,$out)) | |
1566 | - { | |
1567 | - back_push('blockquote', strlen($out[1])); | |
1568 | - array_push($result, ltrim(inline($out[2]))); | |
1569 | - } | |
1570 | - else if (preg_match("/^\s*$/",$line,$out)) | |
1571 | - { | |
1572 | - $result = array_merge($result,$saved); $saved = array(); | |
1573 | - //array_unshift($saved, "</p>"); | |
1574 | - array_push($result, "<p>"); | |
1575 | - } | |
1576 | - else if(preg_match("/^(\s+.*)/",$line,$out)) | |
1577 | - { | |
1578 | - back_push('pre', 1); | |
1579 | - array_push($result, htmlspecialchars($out[1],ENT_NOQUOTES)); | |
1580 | - } | |
1581 | - else if(preg_match("/^\|(.+)\|$/",$line,$out)) | |
1582 | - { | |
1583 | - $arytable = explode("|",$out[1]); | |
1584 | - | |
1585 | - if(!$table) | |
1586 | - { | |
1587 | - $result = array_merge($result,$saved); $saved = array(); | |
1588 | - array_push($result,"<table class=\"style_table\" cellspacing=\"1\" border=\"0\">"); | |
1589 | - $table = count($arytable); | |
1590 | - } | |
1591 | - | |
1592 | - array_push($result,"<tr>"); | |
1593 | - foreach($arytable as $td) | |
1594 | - { | |
1595 | - array_push($result,"<td class=\"style_td\">"); | |
1596 | - array_push($result,ltrim(inline($td))); | |
1597 | - array_push($result,"</td>"); | |
1598 | - } | |
1599 | - array_push($result,"</tr>"); | |
1600 | - | |
1601 | - } | |
1602 | - else if(strlen($comment_out) != 0) | |
1603 | - { | |
1604 | - array_push($result," <!-- ".htmlspecialchars($comment_out)." -->"); | |
1605 | - } | |
1606 | - else | |
1607 | - { | |
1608 | - array_push($result, inline($line)); | |
1609 | - } | |
1610 | - } | |
1611 | - if($table) array_push($result, "</table>"); | |
1612 | - | |
1613 | - $result_last = $result = array_merge($result,$saved); $saved = array(); | |
1614 | - | |
1615 | - if($content_id != 0) | |
1616 | - { | |
1617 | - $result = array(); | |
1618 | - $saved = array(); | |
1619 | - | |
1620 | - foreach($arycontents as $line) | |
1621 | - { | |
1622 | - if(preg_match("/^(-{1,3})(.*)/",$line,$out)) | |
1623 | - { | |
1624 | - back_push('ul', strlen($out[1])); | |
1625 | - array_push($result, '<li>'.$out[2].'</li>'); | |
1626 | - } | |
1627 | - } | |
1628 | - $result = array_merge($result,$saved); $saved = array(); | |
1629 | - | |
1630 | - $contents = "<a name=\"contents\"></a>\n"; | |
1631 | - $contents .= join("\n",$result); | |
1632 | - if($strip_link_wall) | |
1633 | - { | |
1634 | - $contents = preg_replace("/\[\[([^\]]+)\]\]/","$1",$contents); | |
1635 | - } | |
1636 | - } | |
1637 | - | |
1638 | - $result_last = inline2($result_last); | |
1639 | - | |
1640 | - $result_last = preg_replace("/^#contents/",$contents,$result_last); | |
1641 | - | |
1642 | - $str = join("\n", $result_last); | |
1643 | - | |
1644 | - if($foot_explain) | |
1645 | - { | |
1646 | - $str .= "\n"; | |
1647 | - $str .= "$note_hr\n"; | |
1648 | - //$str .= "<p>\n"; | |
1649 | - $str .= join("\n",inline2($foot_explain)); | |
1650 | - //$str .= "</p>\n"; | |
1651 | - } | |
1652 | - | |
1653 | - $longtaketime = getmicrotime() - $start_mtime; | |
1654 | - | |
1655 | - $str = preg_replace("/&((lt;)|(gt;))/","&$1",$str); | |
1656 | - | |
1657 | - return $str; | |
1658 | -} | |
1659 | - | |
1660 | -// $tagのタグを$levelレベルまで詰める。 | |
1661 | -function back_push($tag, $level) | |
1662 | -{ | |
1663 | - global $result,$saved; | |
1664 | - | |
1665 | - while (count($saved) > $level) { | |
1666 | - array_push($result, array_shift($saved)); | |
1667 | - } | |
1668 | - if ($saved[0] != "</$tag>") { | |
1669 | - $result = array_merge($result,$saved); $saved = array(); | |
1670 | - } | |
1671 | - while (count($saved) < $level) { | |
1672 | - array_unshift($saved, "</$tag>"); | |
1673 | - array_push($result, "<$tag>"); | |
1674 | - } | |
1675 | -} | |
1676 | - | |
1677 | -// リンクの付加その他 | |
1678 | -function inline($line) | |
1679 | -{ | |
1680 | - $line = htmlspecialchars($line); | |
1681 | - | |
1682 | - $line = preg_replace("/( | |
1683 | - | |
1684 | - (\(\(([^\(\)]+)\)\)) | |
1685 | - | | |
1686 | - (\(\((.+)\)\)) | |
1687 | - | |
1688 | - )/ex","make_note(\"$1\")",$line); | |
1689 | - | |
1690 | - return $line; | |
1691 | -} | |
1692 | - | |
1693 | -// リンクの付加その他2 | |
1694 | -function inline2($str) | |
1695 | -{ | |
1696 | - global $WikiName,$BracketName,$InterWikiName,$vars,$related,$related_link,$script; | |
1697 | - $cnts_plain = array(); | |
1698 | - $cnts_plugin = array(); | |
1699 | - $arykeep = array(); | |
1700 | - | |
1701 | - for($cnt=0;$cnt<count($str);$cnt++) | |
1702 | - { | |
1703 | - if(preg_match("/^(\s)/",$str[$cnt])) | |
1704 | - { | |
1705 | - $arykeep[$cnt] = $str[$cnt]; | |
1706 | - $str[$cnt] = ""; | |
1707 | - $cnts_plain[] = $cnt; | |
1708 | - } | |
1709 | - else if(preg_match("/^\#([^\(]+)\(?(.*)\)?$/",$str[$cnt],$match)) | |
1710 | - { | |
1711 | - if(file_exists(PLUGIN_DIR.$match[1].".inc.php")) | |
1712 | - { | |
1713 | - require_once(PLUGIN_DIR.$match[1].".inc.php"); | |
1714 | - if(function_exists("plugin_".$match[1]."_convert")) | |
1715 | - { | |
1716 | - $aryplugins[$cnt] = $str[$cnt]; | |
1717 | - $str[$cnt] = ""; | |
1718 | - $cnts_plugin[] = $cnt; | |
1719 | - } | |
1720 | - } | |
1721 | - } | |
1722 | - } | |
1723 | - | |
1724 | - $str = preg_replace("/'''([^']+?)'''/s","<i>$1</i>",$str); // Italic | |
1725 | - | |
1726 | - $str = preg_replace("/''([^']+?)''/s","<b>$1</b>",$str); // Bold | |
1727 | - | |
1728 | - $str = preg_replace("/ | |
1729 | - ( | |
1730 | - (\[\[([^\]]+)\:(https?|ftp|news)(:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)\]\]) | |
1731 | - | | |
1732 | - (\[(https?|ftp|news)(:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)\s([^\]]+)\]) | |
1733 | - | | |
1734 | - (https?|ftp|news)(:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+) | |
1735 | - | | |
1736 | - ([[:alnum:]\-_.]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+) | |
1737 | - | | |
1738 | - (\[\[([^\]]+)\:([[:alnum:]\-_.]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+)\]\]) | |
1739 | - | | |
1740 | - ($InterWikiName) | |
1741 | - | | |
1742 | - ($BracketName) | |
1743 | - | | |
1744 | - ($WikiName) | |
1745 | - )/ex","make_link('$1')",$str); | |
1746 | - | |
1747 | - $str = preg_replace("/#related/",make_related($vars["page"],true),$str); | |
1748 | - | |
1749 | - $str = make_user_rules($str); | |
1750 | - | |
1751 | - $aryplugins = preg_replace("/^\#([^\(]+)$/ex","plugin_convert('$1','$2')",$aryplugins); | |
1752 | - $aryplugins = preg_replace("/^\#([^\(]+)\((.*)\)$/ex","plugin_convert('$1','$2')",$aryplugins); | |
1753 | - | |
1754 | - $tmp = $str; | |
1755 | - $str = preg_replace("/^#norelated$/","",$str); | |
1756 | - if($tmp != $str) | |
1757 | - $related_link = 0; | |
1758 | - | |
1759 | - foreach($cnts_plain as $cnt) | |
1760 | - $str[$cnt] = $arykeep[$cnt]; | |
1761 | - | |
1762 | - foreach($cnts_plugin as $cnt) | |
1763 | - $str[$cnt] = $aryplugins[$cnt]; | |
1764 | - | |
1765 | - return $str; | |
1766 | -} | |
1767 | - | |
1768 | -// Plug-in | |
1769 | -function plugin_convert($plugin_name,$plugin_args) | |
1770 | -{ | |
1771 | - $invalid_return = "#${plugin_name}(${plugin_args})"; | |
1772 | - | |
1773 | - if($plugin_args !== "") | |
1774 | - $aryargs = explode(",",$plugin_args); | |
1775 | - else | |
1776 | - $aryargs = array(); | |
1777 | - $retvar = call_user_func_array("plugin_${plugin_name}_convert",$aryargs); | |
1778 | - | |
1779 | - if($retvar === FALSE) return $invalid_return; | |
1780 | - else return $retvar; | |
1781 | -} | |
1782 | - | |
1783 | -// 関連するページ | |
1784 | -function make_related($page,$_isrule) | |
1785 | -{ | |
1786 | - global $related_str,$rule_related_str,$related,$_make_related,$vars; | |
1787 | - | |
1788 | - $page_name = strip_bracket($vars["page"]); | |
1789 | - | |
1790 | - if(!is_array($_make_related)) | |
1791 | - { | |
1792 | - $aryrelated = do_search($page,"OR",1); | |
1793 | - | |
1794 | - if(is_array($aryrelated)) | |
1795 | - { | |
1796 | - foreach($aryrelated as $key => $val) | |
1797 | - { | |
1798 | - $new_arylerated[$key.md5($val)] = $val; | |
1799 | - } | |
1800 | - } | |
1801 | - | |
1802 | - if(is_array($related)) | |
1803 | - { | |
1804 | - foreach($related as $key => $val) | |
1805 | - { | |
1806 | - $new_arylerated[$key.md5($val)] = $val; | |
1807 | - } | |
1808 | - } | |
1809 | - | |
1810 | - @krsort($new_arylerated); | |
1811 | - $_make_related = @array_unique($new_arylerated); | |
1812 | - } | |
1813 | - | |
1814 | - if($_isrule) | |
1815 | - { | |
1816 | - if(is_array($_make_related)) | |
1817 | - { | |
1818 | - foreach($_make_related as $str) | |
1819 | - { | |
1820 | - preg_match("/<a\shref=\"([^\"]+)\">([^<]+)<\/a>(.*)/",$str,$out); | |
1821 | - | |
1822 | - if($out[3]) $title = " title=\"$out[2] $out[3]\""; | |
1823 | - | |
1824 | - $aryret[$out[2]] = "<a href=\"$out[1]\"$title>$out[2]</a>"; | |
1825 | - } | |
1826 | - @ksort($aryret); | |
1827 | - } | |
1828 | - } | |
1829 | - else | |
1830 | - { | |
1831 | - $aryret = $_make_related; | |
1832 | - } | |
1833 | - | |
1834 | - if($_isrule) $str = $rule_related_str; | |
1835 | - else $str = $related_str; | |
1836 | - | |
1837 | - return @join($str,$aryret); | |
1838 | -} | |
1839 | - | |
1840 | -// 注釈処理 | |
1841 | -function make_note($str) | |
1842 | -{ | |
1843 | - global $note_id,$foot_explain; | |
1844 | - | |
1845 | - $str = preg_replace("/^\(\(/","",$str); | |
1846 | - $str = preg_replace("/\)\)$/","",$str); | |
1847 | - | |
1848 | - $str= str_replace("\\'","'",$str); | |
1849 | - | |
1850 | - $str = make_user_rules($str); | |
1851 | - | |
1852 | - $foot_explain[] = "<a name=\"notefoot:$note_id\" href=\"#notetext:$note_id\"><sup><small>*$note_id</small></sup></a> <small>$str</small><br />\n"; | |
1853 | - $note = "<a name=\"notetext:$note_id\" href=\"#notefoot:$note_id\"><sup><small>*$note_id</small></sup></a>"; | |
1854 | - $note_id++; | |
1855 | - | |
1856 | - return $note; | |
1857 | -} | |
1858 | - | |
1859 | -// リンクを付加する | |
1860 | -function make_link($name) | |
1861 | -{ | |
1862 | - global $BracketName,$WikiName,$InterWikiName,$script,$link_target,$interwiki_target; | |
1863 | - global $related,$show_passage,$vars,$defaultpage; | |
1864 | - | |
1865 | - $aryconv_htmlspecial = array("&","<",">"); | |
1866 | - $aryconv_html = array("&","<",">"); | |
1867 | - | |
1868 | - $page = $name; | |
1869 | - | |
1870 | - if(preg_match("/^\[\[([^\]]+)\:((https?|ftp|news)([^\]]+))\]\]$/",$name,$match)) | |
1871 | - { | |
1872 | - $match[2] = str_replace($aryconv_htmlspecial,$aryconv_html,$match[2]); | |
1873 | - return "<a href=\"$match[2]\" target=\"$link_target\">$match[1]</a>"; | |
1874 | - } | |
1875 | - else if(preg_match("/^\[((https?|ftp|news)([^\]\s]+))\s([^\]]+)\]$/",$name,$match)) | |
1876 | - { | |
1877 | - $match[1] = str_replace($aryconv_htmlspecial,$aryconv_html,$match[1]); | |
1878 | - return "<a href=\"$match[1]\" target=\"$link_target\">$match[4]</a>"; | |
1879 | - } | |
1880 | - else if(preg_match("/^(https?|ftp|news).*?(\.gif|\.png|\.jpeg|\.jpg)?$/",$name,$match)) | |
1881 | - { | |
1882 | - $name = str_replace($aryconv_htmlspecial,$aryconv_html,$name); | |
1883 | - if($match[2]) | |
1884 | - return "<a href=\"$name\" target=\"$link_target\"><img src=\"$name\" border=\"0\"></a>"; | |
1885 | - else | |
1886 | - return "<a href=\"$name\" target=\"$link_target\">$page</a>"; | |
1887 | - } | |
1888 | - else if(preg_match("/^\[\[([^\]]+)\:([[:alnum:]\-_.]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+)\]\]/",$name,$match)) | |
1889 | - { | |
1890 | - $match[1] = str_replace($aryconv_htmlspecial,$aryconv_html,$match[1]); | |
1891 | - $match[2] = str_replace($aryconv_htmlspecial,$aryconv_html,$match[2]); | |
1892 | - | |
1893 | - return "<a href=\"mailto:$match[2]\">$match[1]</a>"; | |
1894 | - } | |
1895 | - else if(preg_match("/^([[:alnum:]\-_]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+)/",$name)) | |
1896 | - { | |
1897 | - $name = str_replace($aryconv_htmlspecial,$aryconv_html,$name); | |
1898 | - return "<a href=\"mailto:$name\">$page</a>"; | |
1899 | - } | |
1900 | - else if(preg_match("/^($InterWikiName)$/",str_replace($aryconv_htmlspecial,$aryconv_html,$name))) | |
1901 | - { | |
1902 | - $page = strip_bracket($page); | |
1903 | - $percent_name = str_replace($aryconv_htmlspecial,$aryconv_html,$name); | |
1904 | - $percent_name = rawurlencode($percent_name); | |
1905 | - | |
1906 | - return "<a href=\"$script?$percent_name\" target=\"$interwiki_target\">$page</a>"; | |
1907 | - } | |
1908 | - else if(preg_match("/^($BracketName)|($WikiName)$/",str_replace($aryconv_htmlspecial,$aryconv_html,$name))) | |
1909 | - { | |
1910 | - if(preg_match("/^([^>]+)>([^>]+)$/",strip_bracket(str_replace($aryconv_htmlspecial,$aryconv_html,$name)),$match)) | |
1911 | - { | |
1912 | - $page = $match[1]; | |
1913 | - $name = $match[2]; | |
1914 | - if(!preg_match("/^($BracketName)|($WikiName)$/",$page)) | |
1915 | - $page = "[[$page]]"; | |
1916 | - if(!preg_match("/^($BracketName)|($WikiName)$/",$name)) | |
1917 | - $name = "[[$name]]"; | |
1918 | - } | |
1919 | - | |
1920 | - if(preg_match("/^\[\[\.\/([^\]]*)\]\]/",str_replace($aryconv_htmlspecial,$aryconv_html,$name),$match)) | |
1921 | - { | |
1922 | - if(!$match[1]) | |
1923 | - $name = $vars["page"]; | |
1924 | - else | |
1925 | - $name = "[[".strip_bracket($vars[page])."/$match[1]]]"; | |
1926 | - } | |
1927 | - else if(preg_match("/^\[\[\..\/([^\]]+)\]\]/",str_replace($aryconv_htmlspecial,$aryconv_html,$name),$match)) | |
1928 | - { | |
1929 | - for($i=0;$i<substr_count($name,"../");$i++) | |
1930 | - $name = preg_replace("/(.+)\/([^\/]+)$/","$1",strip_bracket($vars["page"])); | |
1931 | - | |
1932 | - if(!preg_match("/^($BracketName)|($WikiName)$/",$name)) | |
1933 | - $name = "[[$name]]"; | |
1934 | - | |
1935 | - if($vars["page"]==$name) | |
1936 | - $name = "[[$match[1]]]"; | |
1937 | - else | |
1938 | - $name = "[[".strip_bracket($name)."/$match[1]]]"; | |
1939 | - } | |
1940 | - else if($name == "[[../]]") | |
1941 | - { | |
1942 | - $name = preg_replace("/(.+)\/([^\/]+)$/","$1",strip_bracket($vars["page"])); | |
1943 | - | |
1944 | - if(!preg_match("/^($BracketName)|($WikiName)$/",$name)) | |
1945 | - $name = "[[$name]]"; | |
1946 | - if($vars["page"]==$name) | |
1947 | - $name = $defaultpage; | |
1948 | - } | |
1949 | - | |
1950 | - $page = strip_bracket($page); | |
1951 | - $pagename = strip_bracket($name); | |
1952 | - $percent_name = str_replace($aryconv_htmlspecial,$aryconv_html,$name); | |
1953 | - $percent_name = rawurlencode($percent_name); | |
1954 | - | |
1955 | - $refer = rawurlencode($vars["page"]); | |
1956 | - if(is_page($name)) | |
1957 | - { | |
1958 | - $str = get_pg_passage($name,false); | |
1959 | - $tm = @filemtime(get_filename(encode($name))); | |
1960 | - if($vars["page"] != $name) | |
1961 | - $related[$tm] = "<a href=\"$script?$percent_name\">$pagename</a>$str"; | |
1962 | - if($show_passage) | |
1963 | - { | |
1964 | - $str_title = "title=\"$pagename $str\""; | |
1965 | - } | |
1966 | - return "<a href=\"$script?$percent_name\" $str_title>$page</a>"; | |
1967 | - } | |
1968 | - else | |
1969 | - return "<span class=\"noexists\">$page<a href=\"$script?cmd=edit&page=$percent_name&refer=$refer\">?</a></span>"; | |
1970 | - } | |
1971 | - else | |
1972 | - { | |
1973 | - return $page; | |
1974 | - } | |
1975 | -} | |
1976 | - | |
1977 | -// ユーザ定義ルール(ソースを置換する) | |
1978 | -function user_rules_str($str) | |
1979 | -{ | |
1980 | - global $str_rules; | |
1981 | - | |
1982 | - $arystr = split("\n",$str); | |
1983 | - | |
1984 | - // 日付・時刻置換処理 | |
1985 | - foreach($arystr as $str) | |
1986 | - { | |
1987 | - if(substr($str,0,1) != " ") | |
1988 | - { | |
1989 | - foreach($str_rules as $rule => $replace) | |
1990 | - { | |
1991 | - $str = preg_replace("/$rule/",$replace,$str); | |
1992 | - } | |
1993 | - } | |
1994 | - $retvars[] = $str; | |
1995 | - } | |
1996 | - | |
1997 | - return join("\n",$retvars); | |
1998 | -} | |
1999 | - | |
2000 | -// ユーザ定義ルール(ソースは置換せずコンバート) | |
2001 | -function make_user_rules($str) | |
2002 | -{ | |
2003 | - global $user_rules; | |
2004 | - | |
2005 | - foreach($user_rules as $rule => $replace) | |
2006 | - { | |
2007 | - $str = preg_replace("/$rule/",$replace,$str); | |
2008 | - } | |
2009 | - | |
2010 | - return $str; | |
2011 | -} | |
2012 | - | |
2013 | -// InterWikiName List の解釈(返値:2次元配列) | |
2014 | -function open_interwikiname_list() | |
2015 | -{ | |
2016 | - global $interwiki; | |
2017 | - | |
2018 | - $retval = array(); | |
2019 | - $aryinterwikiname = file(get_filename(encode($interwiki))); | |
2020 | - | |
2021 | - $cnt = 0; | |
2022 | - foreach($aryinterwikiname as $line) | |
2023 | - { | |
2024 | - if(preg_match("/\[((https?|ftp|news)(\:\/\/[[:alnum:]\+\$\;\?\.%,!#~\*\/\:@&=_\-]+))\s([^\]]+)\]\s?([^\s]*)/",$line,$match)) | |
2025 | - { | |
2026 | - $retval[$match[4]]["url"] = $match[1]; | |
2027 | - $retval[$match[4]]["opt"] = $match[5]; | |
2028 | - } | |
2029 | - } | |
2030 | - | |
2031 | - return $retval; | |
2032 | -} | |
2033 | - | |
2034 | -// zlib関数が使用できれば、圧縮して使用するためのファイルシステム関数 | |
2035 | -function backup_fopen($filename,$mode) | |
2036 | -{ | |
2037 | - if(function_exists(gzopen)) | |
2038 | - return gzopen(str_replace(".txt",".gz",$filename),$mode); | |
2039 | - else | |
2040 | - return fopen($filename,$mode); | |
2041 | -} | |
2042 | -function backup_fputs($zp,$str) | |
2043 | -{ | |
2044 | - if(function_exists(gzputs)) | |
2045 | - return gzputs($zp,$str); | |
2046 | - else | |
2047 | - return fputs($zp,$str); | |
2048 | -} | |
2049 | -function backup_fclose($zp) | |
2050 | -{ | |
2051 | - if(function_exists(gzclose)) | |
2052 | - return gzclose($zp); | |
2053 | - else | |
2054 | - return fclose($zp); | |
2055 | -} | |
2056 | -function backup_file($filename) | |
2057 | -{ | |
2058 | - if(function_exists(gzfile)) | |
2059 | - return @gzfile(str_replace(".txt",".gz",$filename)); | |
2060 | - else | |
2061 | - return @file($filename); | |
2062 | -} | |
2063 | -function backup_delete($filename) | |
2064 | -{ | |
2065 | - if(function_exists(gzopen)) | |
2066 | - return @unlink(str_replace(".txt",".gz",$filename)); | |
2067 | - else | |
2068 | - return @unlink($filename); | |
2069 | -} | |
2070 | - | |
2071 | -// バックアップデータを作成する | |
2072 | -function make_backup($filename,$body,$oldtime) | |
2073 | -{ | |
2074 | - global $splitter,$cycle,$maxage; | |
2075 | - $aryages = array(); | |
2076 | - $arystrout = array(); | |
2077 | - | |
2078 | - if(function_exists(gzfile)) | |
2079 | - $filename = str_replace(".txt",".gz",$filename); | |
2080 | - | |
2081 | - $realfilename = BACKUP_DIR.$filename; | |
2082 | - | |
2083 | - if(time() - @filemtime($realfilename) > (60 * 60 * $cycle)) | |
2084 | - { | |
2085 | - $aryages = read_backup($filename); | |
2086 | - if(count($aryages) >= $maxage) | |
2087 | - { | |
2088 | - array_shift($aryages); | |
2089 | - } | |
2090 | - | |
2091 | - foreach($aryages as $lines) | |
2092 | - { | |
2093 | - foreach($lines as $key => $line) | |
2094 | - { | |
2095 | - if($key && $key == "timestamp") | |
2096 | - { | |
2097 | - $arystrout[] = "$splitter " . rtrim($line); | |
2098 | - } | |
2099 | - else | |
2100 | - { | |
2101 | - $arystrout[] = rtrim($line); | |
2102 | - } | |
2103 | - } | |
2104 | - } | |
2105 | - | |
2106 | - $strout = join("\n",$arystrout); | |
2107 | - if(!preg_match("/\n$/",$strout) && trim($strout)) $strout .= "\n"; | |
2108 | - | |
2109 | - $body = "$splitter " . $oldtime . "\n" . $body; | |
2110 | - if(!preg_match("/\n$/",$body)) $body .= "\n"; | |
2111 | - | |
2112 | - $fp = backup_fopen($realfilename,"w"); | |
2113 | - backup_fputs($fp,$strout); | |
2114 | - backup_fputs($fp,$body); | |
2115 | - backup_fclose($fp); | |
2116 | - } | |
2117 | - | |
2118 | - return true; | |
2119 | -} | |
2120 | - | |
2121 | -// 特定の世代のバックアップデータを取得 | |
2122 | -function get_backup($age,$filename) | |
2123 | -{ | |
2124 | - $aryages = read_backup($filename); | |
2125 | - | |
2126 | - foreach($aryages as $key => $lines) | |
2127 | - { | |
2128 | - if($key != $age) continue; | |
2129 | - foreach($lines as $key => $line) | |
2130 | - { | |
2131 | - if($key && $key == "timestamp") continue; | |
2132 | - $retvars[] = $line; | |
2133 | - } | |
2134 | - } | |
2135 | - | |
2136 | - return $retvars; | |
2137 | -} | |
2138 | - | |
2139 | -// バックアップ情報を返す | |
2140 | -function get_backup_info($filename) | |
2141 | -{ | |
2142 | - global $splitter; | |
2143 | - $lines = array(); | |
2144 | - $retvars = array(); | |
2145 | - $lines = backup_file(BACKUP_DIR.$filename); | |
2146 | - | |
2147 | - if(!is_array($lines)) return array(); | |
2148 | - | |
2149 | - $age = 0; | |
2150 | - foreach($lines as $line) | |
2151 | - { | |
2152 | - preg_match("/^$splitter\s(\d+)$/",trim($line),$match); | |
2153 | - if($match[1]) | |
2154 | - { | |
2155 | - $age++; | |
2156 | - $retvars[$age] = $match[1]; | |
2157 | - } | |
2158 | - } | |
2159 | - | |
2160 | - return $retvars; | |
2161 | -} | |
2162 | - | |
2163 | -// バックアップデータ全体を取得 | |
2164 | -function read_backup($filename) | |
2165 | -{ | |
2166 | - global $splitter; | |
2167 | - $lines = array(); | |
2168 | - $lines = backup_file(BACKUP_DIR.$filename); | |
2169 | - | |
2170 | - if(!is_array($lines)) return array(); | |
2171 | - | |
2172 | - $age = 0; | |
2173 | - foreach($lines as $line) | |
2174 | - { | |
2175 | - preg_match("/^$splitter\s(\d+)$/",trim($line),$match); | |
2176 | - if($match[1]) | |
2177 | - { | |
2178 | - $age++; | |
2179 | - $retvars[$age]["timestamp"] = $match[1] . "\n"; | |
2180 | - } | |
2181 | - else | |
2182 | - { | |
2183 | - $retvars[$age][] = $line; | |
2184 | - } | |
2185 | - } | |
2186 | - | |
2187 | - return $retvars; | |
2188 | -} | |
2189 | - | |
2190 | -// [[ ]] を取り除く | |
2191 | -function strip_bracket($str) | |
2192 | -{ | |
2193 | - global $strip_link_wall; | |
2194 | - | |
2195 | - if($strip_link_wall) | |
2196 | - { | |
2197 | - preg_match("/^\[\[(.*)\]\]$/",$str,$match); | |
2198 | - if($match[1]) | |
2199 | - $str = $match[1]; | |
2200 | - } | |
2201 | - return $str; | |
2202 | -} | |
2203 | - | |
2204 | -// HTMLタグを取り除く | |
2205 | -function strip_htmltag($str) | |
2206 | -{ | |
2207 | - //$str = preg_replace("/<a[^>]+>\?<\/a>/","",$str); | |
2208 | - return preg_replace("/<[^>]+>/","",$str); | |
2209 | -} | |
2210 | - | |
2211 | -// テキスト整形ルールを表示する | |
2212 | -function catrule() | |
2213 | -{ | |
2214 | - global $rule_body; | |
2215 | - return $rule_body; | |
2216 | -} | |
2217 | - | |
2218 | -// エラーメッセージを表示する | |
2219 | -function die_message($msg) | |
2220 | -{ | |
2221 | - $title = $page = "Runtime error"; | |
2222 | - | |
2223 | - $body = "<h3>Runtime error</h3>\n"; | |
2224 | - $body .= "<b>Error message : $msg</b>\n"; | |
2225 | - | |
2226 | - catbody($title,$page,$body); | |
2227 | - | |
2228 | - die(); | |
2229 | -} | |
2230 | - | |
2231 | -// 指定されたページの経過時刻 | |
2232 | -function get_pg_passage($page,$sw=true) | |
2233 | -{ | |
2234 | - global $_pg_passage,$show_passage; | |
2235 | - | |
2236 | - if(!$show_passage) return ""; | |
2237 | - | |
2238 | - if(isset($_pg_passage[$page])) | |
2239 | - { | |
2240 | - if($sw) | |
2241 | - return $_pg_passage[$page]["str"]; | |
2242 | - else | |
2243 | - return $_pg_passage[$page]["label"]; | |
2244 | - } | |
2245 | - if($pgdt = @filemtime(get_filename(encode($page)))) | |
2246 | - { | |
2247 | - $pgdt = UTIME - $pgdt; | |
2248 | - if(ceil($pgdt / 60) < 60) | |
2249 | - $_pg_passage[$page]["label"] = "(".ceil($pgdt / 60)."m)"; | |
2250 | - else if(ceil($pgdt / 60 / 60) < 24) | |
2251 | - $_pg_passage[$page]["label"] = "(".ceil($pgdt / 60 / 60)."h)"; | |
2252 | - else | |
2253 | - $_pg_passage[$page]["label"] = "(".ceil($pgdt / 60 / 60 / 24)."d)"; | |
2254 | - | |
2255 | - $_pg_passage[$page]["str"] = "<small>".$_pg_passage[$page]["label"]."</small>"; | |
2256 | - } | |
2257 | - else | |
2258 | - { | |
2259 | - $_pg_passage[$page]["label"] = ""; | |
2260 | - $_pg_passage[$page]["str"] = ""; | |
2261 | - } | |
2262 | - | |
2263 | - if($sw) | |
2264 | - return $_pg_passage[$page]["str"]; | |
2265 | - else | |
2266 | - return $_pg_passage[$page]["label"]; | |
2267 | -} | |
2268 | - | |
2269 | -// 現在時刻をマイクロ秒で取得 | |
2270 | -function getmicrotime() | |
2271 | -{ | |
2272 | - list($usec, $sec) = explode(" ",microtime()); | |
2273 | - return ((float)$sec + (float)$usec); | |
2274 | -} | |
2275 | - | |
2276 | -// ページ名からページ名を検索するリンクを作成 | |
2277 | -function make_search($page) | |
2278 | -{ | |
2279 | - global $script,$WikiName; | |
2280 | - | |
2281 | - $page = htmlspecialchars($page); | |
2282 | - $name = strip_bracket($page); | |
2283 | - $url = rawurlencode($page); | |
2284 | - | |
2285 | - //WikiWikiWeb like... | |
2286 | - //if(preg_match("/^$WikiName$/",$page)) | |
2287 | - // $name = preg_replace("/([A-Z][a-z]+)/","$1 ",$name); | |
2288 | - | |
2289 | - return "<a href=\"$script?cmd=search&word=$url\">$name</a> "; | |
2290 | -} | |
2291 | - | |
2292 | -// Last-Modified ヘッダ | |
2293 | -function header_lastmod($page) | |
2294 | -{ | |
2295 | - global $lastmod; | |
2296 | - | |
2297 | - if($lastmod && is_page($page)) | |
2298 | - { | |
2299 | - header("Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime(get_filename(encode($page))))." GMT"); | |
2300 | - } | |
2301 | -} | |
2302 | - | |
2303 | -// RecentChanges の RSS を出力 | |
2304 | -function catrss($rss) | |
2305 | -{ | |
2306 | - global $rss_max,$page_title,$WikiName,$BracketName,$script,$whatsnew; | |
2307 | - | |
2308 | - $lines = file(get_filename(encode($whatsnew))); | |
2309 | - header("Content-type: application/xml"); | |
2310 | - | |
2311 | - $item = ""; | |
2312 | - $rdf_li = ""; | |
2313 | - $cnt = 0; | |
2314 | - foreach($lines as $line) | |
2315 | - { | |
2316 | - if($cnt > $rss_max - 1) break; | |
2317 | - | |
2318 | - if(preg_match("/(($WikiName)|($BracketName))/",$line,$match)) | |
2319 | - { | |
2320 | - if($match[2]) | |
2321 | - { | |
2322 | - $title = $url = $match[1]; | |
2323 | - } | |
2324 | - else | |
2325 | - { | |
2326 | - if(function_exists("mb_convert_encoding")) | |
2327 | - $title = mb_convert_encoding(strip_bracket($match[1]),"UTF-8","auto"); | |
2328 | - else | |
2329 | - $title = strip_bracket($match[1]); | |
2330 | - | |
2331 | - $url = $match[1]; | |
2332 | - } | |
2333 | - | |
2334 | - $desc = date("D, d M Y H:i:s T",filemtime(get_filename(encode($match[1])))); | |
2335 | - | |
2336 | - if($rss==2) | |
2337 | - $items.= "<item rdf:about=\"http://".SERVER_NAME.PHP_SELF."?".rawurlencode($url)."\">\n"; | |
2338 | - else | |
2339 | - $items.= "<item>\n"; | |
2340 | - $items.= " <title>$title</title>\n"; | |
2341 | - $items.= " <link>http://".SERVER_NAME.PHP_SELF."?".rawurlencode($url)."</link>\n"; | |
2342 | - $items.= " <description>$desc</description>\n"; | |
2343 | - $items.= "</item>\n\n"; | |
2344 | - $rdf_li.= " <rdf:li rdf:resource=\"http://".SERVER_NAME.PHP_SELF."?".rawurlencode($url)."\"/>\n"; | |
2345 | - | |
2346 | - } | |
2347 | - | |
2348 | - $cnt++; | |
2349 | - } | |
2350 | - | |
2351 | - if($rss==1) | |
2352 | - { | |
2353 | -?> | |
2354 | -<?='<?xml version="1.0" encoding="UTF-8"?>'?> | |
2355 | - | |
2356 | - | |
2357 | -<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" | |
2358 | - "http://my.netscape.com/publish/formats/rss-0.91.dtd"> | |
2359 | - | |
2360 | -<rss version="0.91"> | |
2361 | - | |
2362 | -<channel> | |
2363 | -<title><?=$page_title?></title> | |
2364 | -<link><?="http://".SERVER_NAME.PHP_SELF."?$whatsnew"?></link> | |
2365 | -<description>PukiWiki RecentChanges</description> | |
2366 | -<language>ja</language> | |
2367 | - | |
2368 | -<?=$items?> | |
2369 | -</channel> | |
2370 | -</rss> | |
2371 | -<? | |
2372 | - } | |
2373 | - else if($rss==2) | |
2374 | - { | |
2375 | -?> | |
2376 | -<?='<?xml version="1.0" encoding="utf-8"?>'?> | |
2377 | - | |
2378 | - | |
2379 | -<rdf:RDF | |
2380 | - xmlns="http://purl.org/rss/1.0/" | |
2381 | - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |
2382 | - xml:lang="ja"> | |
2383 | - | |
2384 | - <channel rdf:about="<?="http://".SERVER_NAME.PHP_SELF."?rss"?>"> | |
2385 | - <title><?=$page_title?></title> | |
2386 | - <link><?="http://".SERVER_NAME.PHP_SELF."?$whatsnew"?></link> | |
2387 | - <description>PukiWiki RecentChanges</description> | |
2388 | - <items> | |
2389 | - <rdf:Seq> | |
2390 | -<?=$rdf_li?> | |
2391 | - </rdf:Seq> | |
2392 | - </items> | |
2393 | - </channel> | |
2394 | - | |
2395 | -<?=$items?> | |
2396 | -</rdf:RDF> | |
2397 | -<? | |
2398 | - } | |
2399 | -} | |
2400 | -?> | |
1 | +<? | |
2 | +// pukiwiki.php - Yet another WikiWikiWeb clone. | |
3 | +// | |
4 | +// PukiWiki 1.3.* MASUI'z Edition | |
5 | +// Copyright (C) 2002 by sng, MASUI. | |
6 | +// Yuichiro MASUI <masui@masui.net> | |
7 | +// http://masui.net/pukiwiki/ | |
8 | +// | |
9 | +// PukiWiki 1.3 (Base) | |
10 | +// Copyright (C) 2001,2002 by sng. | |
11 | +// <sng@factage.com> | |
12 | +// http://factage.com/sng/pukiwiki/ | |
13 | +// | |
14 | +// Special thanks | |
15 | +// YukiWiki by Hiroshi Yuki | |
16 | +// <hyuki@hyuki.com> | |
17 | +// http://www.hyuki.com/yukiwiki/ | |
18 | +// | |
19 | +// This program is free software; you can redistribute it and/or modify | |
20 | +// it under the terms of the GNU General Public License as published by | |
21 | +// the Free Software Foundation; either version 2 of the License, or | |
22 | +// (at your option) any later version. | |
23 | +// | |
24 | +// This program is distributed in the hope that it will be useful, | |
25 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 | +// GNU General Public License for more details. | |
28 | +// | |
29 | +// $Id: pukiwiki.php,v 1.2 2002/06/21 05:21:46 masui Exp $ | |
30 | +///////////////////////////////////////////////// | |
31 | + | |
32 | + | |
33 | +///////////////////////////////////////////////// | |
34 | +// プログラムファイル読み込み | |
35 | +require("func.php"); | |
36 | +require("file.php"); | |
37 | +require("plugin.php"); | |
38 | +require("template.php"); | |
39 | +require("html.php"); | |
40 | +require("backup.php"); | |
41 | +require("rss.php"); | |
42 | + | |
43 | + | |
44 | +///////////////////////////////////////////////// | |
45 | +// プログラムファイル読み込み | |
46 | +require("init.php"); | |
47 | + | |
48 | + | |
49 | +///////////////////////////////////////////////// | |
50 | +// メイン処理 | |
51 | + | |
52 | +// Plug-in action | |
53 | +if(!empty($vars["plugin"]) && exist_plugin_action($vars["plugin"])) | |
54 | +{ | |
55 | + $retvars = do_plugin_action($vars["plugin"]); | |
56 | + | |
57 | + $title = strip_bracket($vars["refer"]); | |
58 | + $page = make_search($vars["refer"]); | |
59 | + | |
60 | + if($retvars["msg"]) | |
61 | + { | |
62 | + $title = str_replace("$1",$title,$retvars["msg"]); | |
63 | + $page = str_replace("$1",$page,$retvars["msg"]); | |
64 | + } | |
65 | + | |
66 | + if(!empty($retvars["body"])) | |
67 | + { | |
68 | + $body = $retvars["body"]; | |
69 | + } | |
70 | + else | |
71 | + { | |
72 | + $cmd = "read"; | |
73 | + $vars["page"] = $vars["refer"]; | |
74 | + $body = @join("",get_source($vars["refer"])); | |
75 | + $body = convert_html($body); | |
76 | + } | |
77 | +} | |
78 | +// 一覧の表示 | |
79 | +else if(arg_check("list")) | |
80 | +{ | |
81 | + header_lastmod($whatsnew); | |
82 | + | |
83 | + $page = $title = $_title_list; | |
84 | + $body = "<ul>\n" . get_list(false) . "</ul>\n"; | |
85 | +} | |
86 | +// ファイル名一覧の表示 | |
87 | +else if(arg_check("filelist")) | |
88 | +{ | |
89 | + header_lastmod($whatsnew); | |
90 | + | |
91 | + $page = $title = $_title_filelist; | |
92 | + $body = "<ul>\n" . get_list(true) . "</ul>\n"; | |
93 | +} | |
94 | +// 編集不可能なページを編集しようとしたとき | |
95 | +else if(((arg_check("add") || arg_check("edit") || arg_check("preview")) && (is_freeze($vars["page"]) || !is_editable($vars["page"]) || $vars["page"] == ""))) | |
96 | +{ | |
97 | + $body = $title = str_replace('$1',strip_bracket($vars["page"]),$_title_cannotedit); | |
98 | + $page = str_replace('$1',make_search($vars["page"]),$_title_cannotedit); | |
99 | + | |
100 | + if(is_freeze($vars["page"])) | |
101 | + $body .= "(<a href=\"$script?cmd=unfreeze&page=".rawurlencode($vars["page"])."\">$_msg_unfreeze</a>)"; | |
102 | +} | |
103 | +// 追加 | |
104 | +else if(arg_check("add")) | |
105 | +{ | |
106 | + $title = str_replace('$1',strip_bracket($get["page"]),$_title_add); | |
107 | + $page = str_replace('$1',make_search($get["page"]),$_title_add); | |
108 | + $body = "<ul>\n"; | |
109 | + $body .= "<li>$_msg_add</li>\n"; | |
110 | + $body .= "</ul>\n"; | |
111 | + $body .= edit_form("",$get["page"],true); | |
112 | +} | |
113 | +// 編集 | |
114 | +else if(arg_check("edit")) | |
115 | +{ | |
116 | + $postdata = @join("",get_source($get["page"])); | |
117 | + if($postdata == '') { | |
118 | + $postdata = auto_template($get["page"]); | |
119 | + } | |
120 | + $title = str_replace('$1',strip_bracket($get["page"]),$_title_edit); | |
121 | + $page = str_replace('$1',make_search($get["page"]),$_title_edit); | |
122 | + $body = edit_form($postdata,$get["page"]); | |
123 | +} | |
124 | +// プレビュー | |
125 | +else if(arg_check("preview") || $post["preview"] || $post["template"]) | |
126 | +{ | |
127 | + if($post["template"] && page_exists($post["template_page"])) | |
128 | + { | |
129 | + $post["msg"] = @join("",get_source($post["template_page"])); | |
130 | + } | |
131 | + | |
132 | + $post["msg"] = preg_replace("/^#freeze\n/","",$post["msg"]); | |
133 | + $postdata_input = $post["msg"]; | |
134 | + | |
135 | + if($post["add"]) | |
136 | + { | |
137 | + if($post["add_top"]) | |
138 | + { | |
139 | + $postdata = $post["msg"]; | |
140 | + $postdata .= "\n\n"; | |
141 | + $postdata .= @join("",get_source($post["page"])); | |
142 | + } | |
143 | + else | |
144 | + { | |
145 | + $postdata = @join("",get_source($post["page"])); | |
146 | + $postdata .= "\n\n"; | |
147 | + $postdata .= $post["msg"]; | |
148 | + } | |
149 | + } | |
150 | + else | |
151 | + { | |
152 | + $postdata = $post["msg"]; | |
153 | + } | |
154 | + | |
155 | + $title = str_replace('$1',strip_bracket($post["page"]),$_title_preview); | |
156 | + $page = str_replace('$1',make_search($post["page"]),$_title_preview); | |
157 | + | |
158 | + $body = "$_msg_preview<br>\n"; | |
159 | + if($postdata == "") $body .= "<b>$_msg_preview_delete</b><br>\n"; | |
160 | + else $body .= "<br>\n"; | |
161 | + | |
162 | + if($postdata != "") | |
163 | + { | |
164 | + $postdata = convert_html($postdata); | |
165 | + | |
166 | + $body .= "<table width=\"100%\" bgcolor=\"$preview_color\">\n" | |
167 | + ."<tr><td>\n" | |
168 | + .$postdata | |
169 | + ."\n</td></tr>\n" | |
170 | + ."</table>\n"; | |
171 | + } | |
172 | + | |
173 | + if($post["add"]) | |
174 | + { | |
175 | + if($post["add_top"]) $checked_top = " checked"; | |
176 | + $addtag = '<input type="hidden" name="add" value="true">'; | |
177 | + $add_top = '<input type="checkbox" name="add_top" value="true"'.$checked_top.'><small>ページの上に追加</small>'; | |
178 | + } | |
179 | + if($post["notimestamp"]) $checked_time = "checked"; | |
180 | + | |
181 | + $body .= "<form action=\"$script\" method=\"post\">\n" | |
182 | + ."<input type=\"hidden\" name=\"help\" value=\"$post[add]\">\n" | |
183 | + ."<input type=\"hidden\" name=\"page\" value=\"".$post["page"]."\">\n" | |
184 | + ."<input type=\"hidden\" name=\"digest\" value=\"".$post["digest"]."\">\n" | |
185 | + ."$addtag\n" | |
186 | + ."<textarea name=\"msg\" rows=\"$rows\" cols=\"$cols\" wrap=\"virtual\">\n".htmlspecialchars($postdata_input)."</textarea><br>\n" | |
187 | + ."<input type=\"submit\" name=\"preview\" value=\"$_btn_repreview\" accesskey=\"p\">\n" | |
188 | + ."<input type=\"submit\" name=\"write\" value=\"$_btn_update\" accesskey=\"s\">\n" | |
189 | + ."$add_top\n" | |
190 | + ."<input type=\"checkbox\" name=\"notimestamp\" value=\"true\" $checked_time><small>$_btn_notchangetimestamp</small>\n" | |
191 | + ."</form>\n"; | |
192 | +} | |
193 | +// 書き込みもしくは追加もしくはコメントの挿入 | |
194 | +else if($post["write"]) | |
195 | +{ | |
196 | + $post["msg"] = preg_replace("/^#freeze\n/","",$post["msg"]); | |
197 | + $postdata_input = $post["msg"]; | |
198 | + | |
199 | + if($post["add"]) | |
200 | + { | |
201 | + if($post["add_top"]) | |
202 | + { | |
203 | + $postdata = $post["msg"]; | |
204 | + $postdata .= "\n\n"; | |
205 | + $postdata .= @join("",get_source($post["page"])); | |
206 | + } | |
207 | + else | |
208 | + { | |
209 | + $postdata = @join("",get_source($post["page"])); | |
210 | + $postdata .= "\n\n"; | |
211 | + $postdata .= $post["msg"]; | |
212 | + } | |
213 | + } | |
214 | + else | |
215 | + { | |
216 | + $postdata = $post["msg"]; | |
217 | + } | |
218 | + | |
219 | + $oldpagesrc = get_source($post["page"]); | |
220 | + if(md5(join("",$oldpagesrc)) != $post["digest"]) | |
221 | + { | |
222 | + $title = str_replace('$1',strip_bracket($post["page"]),$_title_collided); | |
223 | + $page = str_replace('$1',make_search($post["page"]),$_title_collided); | |
224 | + $post["digest"] = md5(join("",($oldpagesrc))); | |
225 | + list($postdata_input,$auto) = do_update_diff(join("",$oldpagesrc),$postdata_input); | |
226 | + | |
227 | + if($auto) { | |
228 | + $body = $_msg_collided_auto."\n"; | |
229 | + } | |
230 | + else { | |
231 | + $body = $_msg_collided."\n"; | |
232 | + } | |
233 | + $body .= "<form action=\"$script\" method=\"post\">\n" | |
234 | + ."<input type=\"hidden\" name=\"page\" value=\"".$post["page"]."\">\n" | |
235 | + ."<input type=\"hidden\" name=\"digest\" value=\"".$post["digest"]."\">\n" | |
236 | + ."<textarea name=\"msg\" rows=\"$rows\" cols=\"$cols\" wrap=\"virtual\" id=\"textarea\">$postdata_input</textarea><br>\n" | |
237 | + ."<input type=\"submit\" name=\"preview\" value=\"$_btn_repreview\" accesskey=\"p\">\n" | |
238 | + ."<input type=\"submit\" name=\"write\" value=\"$_btn_update\" accesskey=\"s\">\n" | |
239 | + ."$add_top\n" | |
240 | + ."<input type=\"checkbox\" name=\"notimestamp\" value=\"true\" $checked_time><small>$_btn_notchangetimestamp</small>\n" | |
241 | + ."</form>\n"; | |
242 | + } | |
243 | + else | |
244 | + { | |
245 | + $postdata = user_rules_str($postdata); | |
246 | + | |
247 | + // 差分ファイルの作成 | |
248 | + if(is_page($post["page"])) | |
249 | + $oldpostdata = join("",get_source($post["page"])); | |
250 | + else | |
251 | + $oldpostdata = "\n"; | |
252 | + if($postdata) | |
253 | + $diffdata = do_diff($oldpostdata,$postdata); | |
254 | + file_write(DIFF_DIR,$post["page"],$diffdata); | |
255 | + | |
256 | + // バックアップの作成 | |
257 | + if(is_page($post["page"])) | |
258 | + $oldposttime = filemtime(get_filename(encode($post["page"]))); | |
259 | + else | |
260 | + $oldposttime = time(); | |
261 | + | |
262 | + // 編集内容が何も書かれていないとバックアップも削除する?しないですよね。 | |
263 | + if(!$postdata && $del_backup) | |
264 | + backup_delete(BACKUP_DIR.encode($post["page"]).".txt"); | |
265 | + else if($do_backup && is_page($post["page"])) | |
266 | + make_backup(encode($post["page"]).".txt",$oldpostdata,$oldposttime); | |
267 | + | |
268 | + // ファイルの書き込み | |
269 | + file_write(DATA_DIR,$post["page"],$postdata); | |
270 | + | |
271 | + // is_pageのキャッシュをクリアする。 | |
272 | + is_page($post["page"],true); | |
273 | + | |
274 | + if($postdata) | |
275 | + { | |
276 | + $title = str_replace('$1',strip_bracket($post["page"]),$_title_updated); | |
277 | + $page = str_replace('$1',make_search($post["page"]),$_title_updated); | |
278 | + $body = convert_html($postdata); | |
279 | + header("Location: $script?".rawurlencode($post["page"])); | |
280 | + } | |
281 | + else | |
282 | + { | |
283 | + $title = str_replace('$1',strip_bracket($post["page"]),$_title_deleted); | |
284 | + $page = str_replace('$1',make_search($post["page"]),$_title_deleted); | |
285 | + $body = str_replace('$1',strip_bracket($post["page"]),$_title_deleted); | |
286 | + } | |
287 | + } | |
288 | +} | |
289 | +// 凍結 | |
290 | +else if(arg_check("freeze") && $vars["page"] && $function_freeze) | |
291 | +{ | |
292 | + if(is_freeze($vars["page"])) | |
293 | + { | |
294 | + $title = str_replace('$1',strip_bracket($vars["page"]),$_title_isfreezed); | |
295 | + $page = str_replace('$1',make_search($vars["page"]),$_title_isfreezed); | |
296 | + $body = str_replace('$1',strip_bracket($vars["page"]),$_title_isfreezed); | |
297 | + } | |
298 | + else if(md5($post["pass"]) == $adminpass) | |
299 | + { | |
300 | + $postdata = get_source($post["page"]); | |
301 | + $postdata = join("",$postdata); | |
302 | + $postdata = "#freeze\n".$postdata; | |
303 | + | |
304 | + file_write(DATA_DIR,$vars["page"],$postdata); | |
305 | + | |
306 | + $title = str_replace('$1',strip_bracket($vars["page"]),$_title_freezed); | |
307 | + $page = str_replace('$1',make_search($vars["page"]),$_title_freezed); | |
308 | + $postdata = join("",get_source($vars["page"])); | |
309 | + $postdata = convert_html($postdata); | |
310 | + | |
311 | + $body = $postdata; | |
312 | + } | |
313 | + else | |
314 | + { | |
315 | + $title = str_replace('$1',strip_bracket($vars["page"]),$_title_freeze); | |
316 | + $page = str_replace('$1',make_search($vars["page"]),$_title_freeze); | |
317 | + | |
318 | + $body.= "<br>\n"; | |
319 | + | |
320 | + if($post["pass"]) | |
321 | + $body .= "<b>$_msg_invalidpass</b><br>\n"; | |
322 | + else | |
323 | + $body.= "$_msg_freezing<br>\n"; | |
324 | + | |
325 | + $body.= "<form action=\"$script?cmd=freeze\" method=\"post\">\n"; | |
326 | + $body.= "<input type=\"hidden\" name=\"page\" value=\"$vars[page]\">\n"; | |
327 | + $body.= "<input type=\"password\" name=\"pass\" size=\"12\">\n"; | |
328 | + $body.= "<input type=\"submit\" name=\"ok\" value=\"$_btn_freeze\">\n"; | |
329 | + $body.= "</form>\n"; | |
330 | + } | |
331 | +} | |
332 | +//凍結の解除 | |
333 | +else if(arg_check("unfreeze") && $vars["page"] && $function_freeze) | |
334 | +{ | |
335 | + if(!is_freeze($vars["page"])) | |
336 | + { | |
337 | + $title = str_replace('$1',strip_bracket($vars["page"]),$_title_isunfreezed); | |
338 | + $page = str_replace('$1',make_search($vars["page"]),$_title_isunfreezed); | |
339 | + $body = str_replace('$1',strip_bracket($vars["page"]),$_title_isunfreezed); | |
340 | + } | |
341 | + else if(md5($post["pass"]) == $adminpass) | |
342 | + { | |
343 | + $postdata = get_source($post["page"]); | |
344 | + array_shift($postdata); | |
345 | + $postdata = join("",$postdata); | |
346 | + | |
347 | + file_write(DATA_DIR,$vars["page"],$postdata); | |
348 | + | |
349 | + $title = str_replace('$1',strip_bracket($vars["page"]),$_title_unfreezed); | |
350 | + $page = str_replace('$1',make_search($vars["page"]),$_title_unfreezed); | |
351 | + | |
352 | + $postdata = join("",get_source($vars["page"])); | |
353 | + $postdata = convert_html($postdata); | |
354 | + | |
355 | + $body = $postdata; | |
356 | + } | |
357 | + else | |
358 | + { | |
359 | + $title = str_replace('$1',strip_bracket($vars["page"]),$_title_unfreeze); | |
360 | + $page = str_replace('$1',make_search($vars["page"]),$_title_unfreeze); | |
361 | + | |
362 | + $body.= "<br>\n"; | |
363 | + | |
364 | + if($post["pass"]) | |
365 | + $body .= "<b>$_msg_invalidpass</b><br>\n"; | |
366 | + else | |
367 | + $body.= "$_msg_unfreezing<br>\n"; | |
368 | + | |
369 | + $body.= "<form action=\"$script?cmd=unfreeze\" method=\"post\">\n"; | |
370 | + $body.= "<input type=\"hidden\" name=\"page\" value=\"$vars[page]\">\n"; | |
371 | + $body.= "<input type=\"password\" name=\"pass\" size=\"12\">\n"; | |
372 | + $body.= "<input type=\"submit\" name=\"ok\" value=\"$_btn_unfreeze\">\n"; | |
373 | + $body.= "</form>\n"; | |
374 | + } | |
375 | +} | |
376 | +// 差分の表示 | |
377 | +else if(arg_check("diff")) | |
378 | +{ | |
379 | + $pagename = strip_bracket($get["page"]); | |
380 | + if(!is_page($get["page"])) | |
381 | + { | |
382 | + $title = $pagename; | |
383 | + $page = make_search($vars["page"]); | |
384 | + $body = "指定されたページは見つかりませんでした。"; | |
385 | + } | |
386 | + else | |
387 | + { | |
388 | + $link = str_replace('$1',"<a href=\"$script?".rawurlencode($get["page"])."\">$pagename</a>",$_msg_goto); | |
389 | + | |
390 | + $body = "<ul>\n" | |
391 | + ."<li>$_msg_addline</li>\n" | |
392 | + ."<li>$_msg_delline</li>\n" | |
393 | + ."<li>$link</li>\n" | |
394 | + ."</ul>\n" | |
395 | + ."$hr\n"; | |
396 | + } | |
397 | + | |
398 | + if(!file_exists(DIFF_DIR.encode($get["page"]).".txt") && is_page($get["page"])) | |
399 | + { | |
400 | + $title = str_replace('$1',strip_bracket($get["page"]),$_title_diff); | |
401 | + $page = str_replace('$1',make_search($get["page"]),$_title_diff); | |
402 | + | |
403 | + $diffdata = get_source($get["page"]); | |
404 | + $body .= "<font color=\"blue\">\n" | |
405 | + ."<pre>\n" | |
406 | + .join("",$diffdata) | |
407 | + ."\n" | |
408 | + ."</pre>\n" | |
409 | + ."</font>\n"; | |
410 | + } | |
411 | + else if(file_exists(DIFF_DIR.encode($get["page"]).".txt")) | |
412 | + { | |
413 | + $title = str_replace('$1',strip_bracket($get["page"]),$_title_diff); | |
414 | + $page = str_replace('$1',make_search($get["page"]),$_title_diff); | |
415 | + | |
416 | + $diffdata = file(DIFF_DIR.encode($get["page"]).".txt"); | |
417 | + $diffdata = preg_replace("/</","<",$diffdata); | |
418 | + $diffdata = preg_replace("/>/",">",$diffdata); | |
419 | + $diffdata = preg_replace("/^(\-)(.*)/","<font color=\"red\"> $2</font>",$diffdata); | |
420 | + $diffdata = preg_replace("/^(\+)(.*)/","<font color=\"blue\"> $2</font>",$diffdata); | |
421 | + | |
422 | + $body .= "<pre>\n" | |
423 | + .join("",$diffdata) | |
424 | + ."\n" | |
425 | + ."</pre>\n"; | |
426 | + } | |
427 | +} | |
428 | +// 検索 | |
429 | +else if(arg_check("search")) | |
430 | +{ | |
431 | + if($vars["word"]) | |
432 | + { | |
433 | + $title = $page = str_replace('$1',$vars["word"],$_title_result); | |
434 | + } | |
435 | + else | |
436 | + { | |
437 | + $page = $title = $_title_search; | |
438 | + } | |
439 | + | |
440 | + if($vars["word"]) | |
441 | + $body = do_search($vars["word"],$vars["type"]); | |
442 | + else | |
443 | + $body = "<br>\n$_msg_searching"; | |
444 | + | |
445 | + if($vars["type"]=="AND" || !$vars["type"]) $and_check = "checked"; | |
446 | + else if($vars["type"]=="OR") $or_check = "checked"; | |
447 | + | |
448 | + $body .= "<form action=\"$script?cmd=search\" method=\"post\">\n" | |
449 | + ."<input type=\"text\" name=\"word\" size=\"20\" value=\"".$vars["word"]."\">\n" | |
450 | + ."<input type=\"radio\" name=\"type\" value=\"AND\" $and_check>$_btn_and\n" | |
451 | + ."<input type=\"radio\" name=\"type\" value=\"OR\" $or_check>$_btn_or\n" | |
452 | + ." <input type=\"submit\" value=\"$_btn_search\">\n" | |
453 | + ."</form>\n"; | |
454 | +} | |
455 | +// バックアップ | |
456 | +else if($do_backup && arg_check("backup")) | |
457 | +{ | |
458 | + if($get["page"] && $get["age"] && (file_exists(BACKUP_DIR.encode($get["page"]).".txt") || file_exists(BACKUP_DIR.encode($get["page"]).".gz"))) | |
459 | + { | |
460 | + $pagename = strip_bracket($get["page"]); | |
461 | + $body = "<ul>\n"; | |
462 | + | |
463 | + $body .= "<li><a href=\"$script?cmd=backup\">$_msg_backuplist</a></li>\n"; | |
464 | + | |
465 | + if(!arg_check("backup_diff") && is_page($get["page"])) | |
466 | + { | |
467 | + $link = str_replace('$1',"<a href=\"$script?cmd=backup_diff&page=".rawurlencode($get["page"])."&age=$get[age]\">$_msg_diff</a>",$_msg_view); | |
468 | + $body .= "<li>$link</li>\n"; | |
469 | + } | |
470 | + if(!arg_check("backup_nowdiff") && is_page($get["page"])) | |
471 | + { | |
472 | + $link = str_replace('$1',"<a href=\"$script?cmd=backup_nowdiff&page=".rawurlencode($get["page"])."&age=$get[age]\">$_msg_nowdiff</a>",$_msg_view); | |
473 | + $body .= "<li>$link</li>\n"; | |
474 | + } | |
475 | + if(!arg_check("backup_source")) | |
476 | + { | |
477 | + $link = str_replace('$1',"<a href=\"$script?cmd=backup_source&page=".rawurlencode($get["page"])."&age=$get[age]\">$_msg_source</a>",$_msg_view); | |
478 | + $body .= "<li>$link</li>\n"; | |
479 | + } | |
480 | + if(arg_check("backup_diff") || arg_check("backup_source") || arg_check("backup_nowdiff")) | |
481 | + { | |
482 | + $link = str_replace('$1',"<a href=\"$script?cmd=backup&page=".rawurlencode($get["page"])."&age=$get[age]\">$_msg_backup</a>",$_msg_view); | |
483 | + $body .= "<li>$link</li>\n"; | |
484 | + } | |
485 | + | |
486 | + if(is_page($get["page"])) | |
487 | + { | |
488 | + $link = str_replace('$1',"<a href=\"$script?".rawurlencode($get["page"])."\">$pagename</a>",$_msg_goto); | |
489 | + $body .= "<li>$link</li>\n"; | |
490 | + } | |
491 | + else | |
492 | + { | |
493 | + $link = str_replace('$1',$pagename,$_msg_deleleted); | |
494 | + $body .= "<li>$link</li>\n"; | |
495 | + } | |
496 | + | |
497 | + $backups = array(); | |
498 | + $backups = get_backup_info(encode($get["page"]).".txt"); | |
499 | + if(count($backups)) $body .= "<ul>\n"; | |
500 | + foreach($backups as $key => $val) | |
501 | + { | |
502 | + $ins_date = date($date_format,$val); | |
503 | + $ins_time = date($time_format,$val); | |
504 | + $ins_week = "(".$weeklabels[date("w",$val)].")"; | |
505 | + $backupdate = "($ins_date $ins_week $ins_time)"; | |
506 | + if($key != $get["age"]) | |
507 | + $body .= "<li><a href=\"$script?cmd=$get[cmd]&page=".rawurlencode($get["page"])."&age=$key\">$key $backupdate</a></li>\n"; | |
508 | + else | |
509 | + $body .= "<li><i>$key $backupdate</i></li>\n"; | |
510 | + } | |
511 | + if(count($backups)) $body .= "</ul>\n"; | |
512 | + | |
513 | + if(arg_check("backup_diff")) | |
514 | + { | |
515 | + $title = str_replace('$1',$pagename,$_title_backupdiff)."(No.$get[age])"; | |
516 | + $page = str_replace('$1',make_search($get["page"]),$_title_backupdiff)."(No.$get[age])"; | |
517 | + | |
518 | + $backupdata = @join("",get_backup($get[age]-1,encode($get["page"]).".txt")); | |
519 | + $postdata = @join("",get_backup($get[age],encode($get["page"]).".txt")); | |
520 | + $diffdata = split("\n",do_diff($backupdata,$postdata)); | |
521 | + } | |
522 | + else if(arg_check("backup_nowdiff")) | |
523 | + { | |
524 | + $title = str_replace('$1',$pagename,$_title_backupnowdiff)."(No.$get[age])"; | |
525 | + $page = str_replace('$1',make_search($get["page"]),$_title_backupnowdiff)."(No.$get[age])"; | |
526 | + | |
527 | + $backupdata = @join("",get_backup($get[age],encode($get["page"]).".txt")); | |
528 | + $postdata = @join("",get_source($get["page"])); | |
529 | + $diffdata = split("\n",do_diff($backupdata,$postdata)); | |
530 | + } | |
531 | + else if(arg_check("backup_source")) | |
532 | + { | |
533 | + $title = str_replace('$1',$pagename,$_title_backupsource)."(No.$get[age])"; | |
534 | + $page = str_replace('$1',make_search($get["page"]),$_title_backupsource)."(No.$get[age])"; | |
535 | + $backupdata = join("",get_backup($get[age],encode($get["page"]).".txt")); | |
536 | + | |
537 | + $body.="</ul>\n<pre>\n$backupdata</pre>\n"; | |
538 | + } | |
539 | + else | |
540 | + { | |
541 | + $pagename = strip_bracket($get["page"]); | |
542 | + $title = str_replace('$1',$pagename,$_title_backup)."(No.$get[age])"; | |
543 | + $page = str_replace('$1',make_search($get["page"]),$_title_backup)."(No.$get[age])"; | |
544 | + $backupdata = join("",get_backup($get[age],encode($get["page"]).".txt")); | |
545 | + $backupdata = convert_html($backupdata); | |
546 | + $body .= "</ul>\n" | |
547 | + ."$hr\n"; | |
548 | + $body .= $backupdata; | |
549 | + } | |
550 | + | |
551 | + if(arg_check("backup_diff") || arg_check("backup_nowdiff")) | |
552 | + { | |
553 | + $diffdata = preg_replace("/</","<",$diffdata); | |
554 | + $diffdata = preg_replace("/>/",">",$diffdata); | |
555 | + $diffdata = preg_replace("/^(\-)(.*)/","<font color=\"red\"> $2</font>",$diffdata); | |
556 | + $diffdata = preg_replace("/^(\+)(.*)/","<font color=\"blue\"> $2</font>",$diffdata); | |
557 | + | |
558 | + $body .= "<br>\n" | |
559 | + ."<li>$_msg_addline</li>\n" | |
560 | + ."<li>$_msg_delline</li>\n" | |
561 | + ."</ul>\n" | |
562 | + ."$hr\n" | |
563 | + ."<pre>\n".join("\n",$diffdata)."</pre>\n"; | |
564 | + } | |
565 | + } | |
566 | + else if($get["page"] && (file_exists(BACKUP_DIR.encode($get["page"]).".txt") || file_exists(BACKUP_DIR.encode($get["page"]).".gz"))) | |
567 | + { | |
568 | + $title = str_replace('$1',strip_bracket($get["page"]),$_title_pagebackuplist); | |
569 | + $page = str_replace('$1',make_search($get["page"]),$_title_pagebackuplist); | |
570 | + $body = get_backup_list($get["page"]); | |
571 | + } | |
572 | + else | |
573 | + { | |
574 | + $page = $title = $_title_backuplist; | |
575 | + $body = get_backup_list(); | |
576 | + } | |
577 | +} | |
578 | +// ヘルプの表示 | |
579 | +else if(arg_check("help")) | |
580 | +{ | |
581 | + $title = $page = "ヘルプ"; | |
582 | + $body = catrule(); | |
583 | +} | |
584 | +// MD5パスワードへの変換 | |
585 | +else if($vars["md5"]) | |
586 | +{ | |
587 | + $title = $page = "Make password of MD5"; | |
588 | + $body = "$vars[md5] : ".md5($vars["md5"]); | |
589 | +} | |
590 | +else if(arg_check("rss")) | |
591 | +{ | |
592 | + if(!arg_check("rss10")) | |
593 | + catrss(1); | |
594 | + else | |
595 | + catrss(2); | |
596 | + die(); | |
597 | +} | |
598 | +// ページの表示とInterWikiNameの解釈 | |
599 | +else if((arg_check("read") && $vars["page"] != "") || (!arg_check("read") && $arg != "" && $vars["page"] == "")) | |
600 | +{ | |
601 | + // アクションを明示的に指定していない場合ページ名として解釈 | |
602 | + if($arg != "" && $vars["page"] == "" && $vars["cmd"] == "") | |
603 | + { | |
604 | + $post["page"] = $arg; | |
605 | + $get["page"] = $arg; | |
606 | + $vars["page"] = $arg; | |
607 | + } | |
608 | + | |
609 | + // ページ名がWikiNameでなく、BracketNameでなければBracketNameとして解釈 | |
610 | + if(!preg_match("/^(($WikiName)|($BracketName)|($InterWikiName))$/",$get["page"])) | |
611 | + { | |
612 | + $vars["page"] = "[[$vars[page]]]"; | |
613 | + $get["page"] = $vars["page"]; | |
614 | + } | |
615 | + | |
616 | + // WikiName、BracketNameが示すページを表示 | |
617 | + if(is_page($get["page"])) | |
618 | + { | |
619 | + $postdata = join("",get_source($get["page"])); | |
620 | + $postdata = convert_html($postdata); | |
621 | + | |
622 | + $title = strip_bracket($get["page"]); | |
623 | + $page = make_search($get["page"]); | |
624 | + $body = $postdata; | |
625 | + | |
626 | + header_lastmod($vars["page"]); | |
627 | + } | |
628 | + else if(preg_match("/($InterWikiName)/",$get["page"],$match)) | |
629 | + { | |
630 | + // InterWikiNameの判別とページの表示 | |
631 | + $interwikis = open_interwikiname_list(); | |
632 | + | |
633 | + if(!$interwikis[$match[2]]["url"]) | |
634 | + { | |
635 | + $title = $page = $_title_invalidiwn; | |
636 | + $body = str_replace('$1',strip_bracket($get[page]),str_replace('$2',"<a href=\"$script?InterWikiName\">InterWikiName</a>",$_msg_invalidiwn)); | |
637 | + } | |
638 | + else | |
639 | + { | |
640 | + // 文字エンコーディング | |
641 | + if($interwikis[$match[2]]["opt"] == "yw") | |
642 | + { | |
643 | + // YukiWiki系 | |
644 | + if(!preg_match("/$WikiName/",$match[3])) | |
645 | + $match[3] = "[[".mb_convert_encoding($match[3],"SJIS","auto")."]]"; | |
646 | + } | |
647 | + else if($interwikis[$match[2]]["opt"] == "moin") | |
648 | + { | |
649 | + // moin系 | |
650 | + if(function_exists("mb_convert_encoding")) | |
651 | + { | |
652 | + $match[3] = rawurlencode(mb_convert_encoding($match[3],"EUC-JP","auto")); | |
653 | + $match[3] = str_replace("%","_",$match[3]); | |
654 | + } | |
655 | + else | |
656 | + $not_mb = 1; | |
657 | + } | |
658 | + else if($interwikis[$match[2]]["opt"] == "" || $interwikis[$match[2]]["opt"] == "std") | |
659 | + { | |
660 | + // 内部文字エンコーディングのままURLエンコード | |
661 | + $match[3] = rawurlencode($match[3]); | |
662 | + } | |
663 | + else if($interwikis[$match[2]]["opt"] == "asis" || $interwikis[$match[2]]["opt"] == "raw") | |
664 | + { | |
665 | + // URLエンコードしない | |
666 | + $match[3] = $match[3]; | |
667 | + } | |
668 | + else if($interwikis[$match[2]]["opt"] != "") | |
669 | + { | |
670 | + // エイリアスの変換 | |
671 | + if($interwikis[$match[2]]["opt"] == "sjis") | |
672 | + $interwikis[$match[2]]["opt"] = "SJIS"; | |
673 | + else if($interwikis[$match[2]]["opt"] == "euc") | |
674 | + $interwikis[$match[2]]["opt"] = "EUC-JP"; | |
675 | + else if($interwikis[$match[2]]["opt"] == "utf8") | |
676 | + $interwikis[$match[2]]["opt"] = "UTF-8"; | |
677 | + | |
678 | + // その他、指定された文字コードへエンコードしてURLエンコード | |
679 | + if(function_exists("mb_convert_encoding")) | |
680 | + $match[3] = rawurlencode(mb_convert_encoding($match[3],$interwikis[$match[2]]["opt"],"auto")); | |
681 | + else | |
682 | + $not_mb = 1; | |
683 | + } | |
684 | + | |
685 | + if(strpos($interwikis[$match[2]]["url"],'$1') !== FALSE) | |
686 | + $url = str_replace('$1',$match[3],$interwikis[$match[2]]["url"]); | |
687 | + else | |
688 | + $url = $interwikis[$match[2]]["url"] . $match[3]; | |
689 | + | |
690 | + if($not_mb) | |
691 | + { | |
692 | + $title = $page = "Not support mb_jstring."; | |
693 | + $body = "This server's PHP does not have \"mb_jstring\" module.Cannot convert encoding."; | |
694 | + } | |
695 | + else | |
696 | + { | |
697 | + header("Location: $url"); | |
698 | + die(); | |
699 | + } | |
700 | + } | |
701 | + } | |
702 | + // WikiName、BracketNameが見つからず、InterWikiNameでもない場合 | |
703 | + else | |
704 | + { | |
705 | + //$title = strip_bracket($get["page"]); | |
706 | + //$page = make_search($get["page"]); | |
707 | + //$body = "指定されたページは見つかりませんでした。"; | |
708 | + | |
709 | + $title = str_replace('$1',strip_bracket($get["page"]),$_title_edit); | |
710 | + $page = str_replace('$1',make_search($get["page"]),$_title_edit); | |
711 | + $template = auto_template($get["page"]); | |
712 | + $body = edit_form($template,$get["page"]); | |
713 | + } | |
714 | +} | |
715 | +// 何も指定されない場合、トップページを表示 | |
716 | +else | |
717 | +{ | |
718 | + $postdata = join("",get_source($defaultpage)); | |
719 | + | |
720 | + $vars["page"] = $defaultpage; | |
721 | + $title = strip_bracket($defaultpage); | |
722 | + $page = make_search($vars["page"]); | |
723 | + $body = convert_html($postdata); | |
724 | + | |
725 | + header_lastmod($vars["page"]); | |
726 | +} | |
727 | + | |
728 | +// ** 出力処理 ** | |
729 | +catbody($title,$page,$body); | |
730 | + | |
731 | +// ** 終了 ** | |
732 | +?> |
@@ -1,12 +1,18 @@ | ||
1 | 1 | NAME |
2 | 2 | PukiWiki - 自由にページを追加・削除・編集できるWebページ構築PHPスクリプト |
3 | 3 | |
4 | + PukiWiki 1.3.1beta MASUI'z Edition | |
5 | + Copyright (C) 2001,2002 by sng, MASUI. | |
6 | + Yuichiro MASUI <masui@masui.net> | |
7 | + http://masui.net/pukiwiki/ | |
8 | + | |
9 | + PukiWiki 1.3 (based) | |
4 | 10 | Copyright (C) 2001,2002 by sng. |
5 | 11 | sng <sng@factage.com> |
6 | 12 | http://factage.com/sng/ |
7 | 13 | |
8 | 14 | SYNOPSIS |
9 | - http://factage.com/sng/pukiwiki/pukiwiki.php | |
15 | + http://masui.net/pukiwiki/ | |
10 | 16 | |
11 | 17 | DESCRIPTION |
12 | 18 | PukiWikiは参加者が自由にページを追加・削除・編集できる |
@@ -16,6 +22,8 @@ DESCRIPTION | ||
16 | 22 | PukiWikiは、Webページ全体を自由に変更することができます。 |
17 | 23 | |
18 | 24 | PukiWikiは、結城浩さんのYukiWikiの仕様を参考にして独自に作られました。 |
25 | + PukiWiki(MASUI'z Edition)は、sngさんのPukiWiki 1.3を元にプラグインなどを | |
26 | + まとめたものです。 | |
19 | 27 | |
20 | 28 | PukiWikiはPHPで書かれたPHPスクリプトとして実現されていますので、 |
21 | 29 | PHPが動作するWebサーバならば比較的容易に設置できます。 |
@@ -25,7 +33,7 @@ DESCRIPTION | ||
25 | 33 | 設置方法 |
26 | 34 | 入手 |
27 | 35 | |
28 | - PukiWikiの最新版は、 http://factage.com/sng/php/ から入手できます。 | |
36 | + PukiWiki(MASUI'z Edition)の最新版は、 http://masui.net/pukiwiki/ から入手できます。 | |
29 | 37 | |
30 | 38 | ファイル一覧 |
31 | 39 |
@@ -42,21 +50,28 @@ DESCRIPTION | ||
42 | 50 | 2. 必要に応じてpukiwiki.ini.phpの設定を確認します。 |
43 | 51 | 1.11 から設定ファイルが別ファイルのpukiwiki.ini.phpになりました。 |
44 | 52 | |
45 | - 3. pukiwiki.phpとpukiwiki.gifを同じところに設置します。 | |
53 | + 3. *.phpとpukiwiki.gifを同じところに設置します。 | |
46 | 54 | |
47 | - 4. さらにpukiwiki.phpと同じところにpukiwiki.ini.phpとpukiwiki.skin.ja.php、 もしくはpukiwiki.skin.en.phpを同じところに設置します。 | |
55 | + 4. さらに*.phpと同じところにpukiwiki.ini.phpとpukiwiki.skin.ja.php、 | |
56 | + もしくはpukiwiki.skin.en.phpを同じところに設置します。 | |
48 | 57 | |
49 | - 5. pukiwiki.php内で指定したデータファイルディレクトリを | |
58 | + 5. pukiwiki.ini.php内で指定したデータファイルディレクトリを | |
50 | 59 | 属性 777 で作成する。(ディフォルトは wiki ) |
51 | 60 | |
52 | - 6. pukiwiki.php内で指定した差分ファイルディレクトリを | |
61 | + 6. pukiwiki.ini.php内で指定した差分ファイルディレクトリを | |
53 | 62 | 属性 777 で作成する。(ディフォルトは diff ) |
54 | 63 | |
55 | 64 | 7. 自動バックアップ機能(ディフォルトでは off)を使う場合、 |
56 | - pukiwiki.php内で指定した差分ファイルディレクトリを | |
57 | - 属性 777 で作成する。(ディフォルトは diff ) | |
65 | + pukiwiki.ini.php内で指定した差分ファイルディレクトリを | |
66 | + 属性 777 で作成する。(ディフォルトは backup ) | |
67 | + | |
68 | + 8. attach.inc.php内で指定した添付ファイルディレクトリを | |
69 | + 属性 777 で作成する。(ディフォルトは attach ) | |
58 | 70 | |
59 | - 8. pukiwiki.phpにブラウザからアクセスします。 | |
71 | + 9. counter.inc.php内で指定したカウンターファイルディレクトリを | |
72 | + 属性 777 で作成する。(ディフォルトは counter ) | |
73 | + | |
74 | + 10. pukiwiki.phpにブラウザからアクセスします。 | |
60 | 75 | |
61 | 76 | パーミッション |
62 | 77 |
@@ -67,13 +82,24 @@ DESCRIPTION | ||
67 | 82 | pukiwiki.skin.ja.php 644 ASCII |
68 | 83 | en.lng 644 ASCII |
69 | 84 | ja.lng 644 ASCII |
85 | + func.php 644 ASCII | |
86 | + file.php 644 ASCII | |
87 | + html.php 644 ASCII | |
88 | + init.php 644 ASCII | |
89 | + plugin.php 644 ASCII | |
90 | + template.php 644 ASCII | |
91 | + rss.php 644 ASCII | |
92 | + backup.php 644 ASCII | |
70 | 93 | pukiwiki.gif 644 BINARY |
71 | 94 | |
72 | 95 | ディレクトリ パーミッション |
73 | 96 | wiki 777 |
74 | 97 | diff 777 |
75 | 98 | backup 777 |
76 | - plug-in 777 | |
99 | + attach 777 | |
100 | + counter 777 | |
101 | + skin 755 | |
102 | + plug-in 755 | |
77 | 103 | |
78 | 104 | データのバックアップ方法 |
79 | 105 |
@@ -157,14 +183,14 @@ DESCRIPTION | ||
157 | 183 | 大かっこの中にはスペースを含めてはいけません。 |
158 | 184 | 日本語も使えます。 |
159 | 185 | |
160 | - * また、[[factage:http://factage.com/]] のようにすると factage の文字に | |
161 | - http://factage.com/ へのリンクが貼れます。 | |
186 | + * また、[[pukiwiki:http://masui.net/pukiwiki/]] のようにすると factage の文字に | |
187 | + http://masui.net/pukiwiki/ へのリンクが貼れます。 | |
162 | 188 | |
163 | 189 | * [[サーバ名:WikiName]] のようにすると InterWikiName になります。 |
164 | 190 | |
165 | - * http://factage.com/sng/ のようなURLは自動的にリンクになります。 | |
191 | + * http://masui.net/pukiwiki/ のようなURLは自動的にリンクになります。 | |
166 | 192 | |
167 | - * sng@factage.com のようなメールアドレスも自動的にリンクになります。 | |
193 | + * team@pukiwiki.jp のようなメールアドレスも自動的にリンクになります。 | |
168 | 194 | |
169 | 195 | * 行頭がスペースやタブで始まっていると、 |
170 | 196 | それは整形済みの段落`<pre>'として扱われます。 |
@@ -204,27 +230,27 @@ InterWiki | ||
204 | 230 | InterWikiName のページに以下のようにサーバの定義をする。 |
205 | 231 | |
206 | 232 | * [URL サーバ名] タイプ |
207 | - * [http://factage.com/sng/pukiwiki/pukiwiki.php?read&page= sng] pw | |
233 | + * [http://masui.net/pukiwiki/pukiwiki.php?read&page= pukiwiki] pw | |
208 | 234 | |
209 | 235 | |
210 | 236 | InterWikiNameの追加 |
211 | 237 | サーバ名:WikiNameをBracketNameで作ればInterWikiNameの完成 |
212 | 238 | |
213 | 239 | * [[サーバ名:WikiName]] |
214 | - * [[sng:FrontPage]] | |
240 | + * [[pukiwiki:FrontPage]] | |
215 | 241 | |
216 | 242 | WikiNameの挿入位置 |
217 | 243 | 要求しようとするURLへのWikiNameの挿入位置を $1 で指定することができます。 |
218 | 244 | 省略するとお尻にくっつきます。 |
219 | 245 | |
220 | - * [http://factage.com/sng/pukiwiki/pukiwiki.php?backup&page=$1&age=1 sng] pw | |
246 | + * [http://masui.net/pukiwiki/pukiwiki.php?backup&page=$1&age=1 pukiwiki] pw | |
221 | 247 | |
222 | 248 | |
223 | 249 | 文字コード変換タイプ |
224 | 250 | PukiWikiページ以外にも飛ばせます。日本語をURLに含む可能性もあるのでその場合の |
225 | 251 | エンコーディングの指定をタイプとして指定できます。 |
226 | 252 | |
227 | - * [http://factage.com/sng/pukiwiki/pukiwiki.php?read&page=$1 sng] pw | |
253 | + * [http://masui.net/pukiwiki/pukiwiki.php?read&page=$1 pukiwiki] pw | |
228 | 254 | |
229 | 255 | |
230 | 256 | * std 省略時 |
@@ -264,14 +290,26 @@ RDF/RSS | ||
264 | 290 | |
265 | 291 | RSS 0.91 の出力方法の例 |
266 | 292 | |
267 | - * http://factage.com/sng/pukiwiki/pukiwiki.php?rss | |
293 | + * http://masui.net/pukiwiki/pukiwiki.php?rss | |
268 | 294 | |
269 | 295 | RSS 1.0 の出力方法の例 |
270 | 296 | |
271 | - * http://factage.com/sng/pukiwiki/pukiwiki.php?rss10 | |
297 | + * http://masui.net/pukiwiki/pukiwiki.php?rss10 | |
272 | 298 | |
273 | 299 | 更新履歴 |
274 | - * 2002-03-18 1.3 | |
300 | + * 2002-06-10 1.3.1beta MASUI'z Edition | |
301 | + | |
302 | + PukiWiki 1.3をベースに、MASUIが勝手にプラグインとかまとめてみました。 | |
303 | + ソースファイルを分割。 | |
304 | + calendar2, include, article, memo, aname, anchor, counter, vote, ls, yetlist, recent, source, imgプラグインを添付。 | |
305 | + attach, commentプラグインバージョンアップ。 | |
306 | + 本文に、タグが入っていた場合、編集がうまくできなかった不具合を修正。 | |
307 | + 更新衝突時にdiffアルゴリズムで差分をとり、マージを行う様に変更。 | |
308 | + & <などを含んだ文章を編集すると、それが消えてしまう場合がある不具合を修正。 | |
309 | + 自動テンプレート機能を追加。[[SandBox/template]] | |
310 | + ソースファイルを分割。 | |
311 | + | |
312 | + * 2002-03-18 1.3 by sng. | |
275 | 313 | |
276 | 314 | ある文字列へWikiName/BracketNameへのリンクを貼る。(エイリアス機能) |
277 | 315 | 疑似ディレクトリ構想。./ や ../ などをBracketNameとして使用することで実現。 |
@@ -282,7 +320,7 @@ RDF/RSS | ||
282 | 320 | 一部の整形ルールをプラグイン化する。 |
283 | 321 | Win32でも正常に動作するように修正 |
284 | 322 | |
285 | - * 2002-02-15 1.2.12 | |
323 | + * 2002-02-15 1.2.12 by sng. | |
286 | 324 | |
287 | 325 | バックアップの挙動の変更 |
288 | 326 | 現在表示しているページのみのバックアップ一覧を表示する |
@@ -298,46 +336,51 @@ RDF/RSS | ||
298 | 336 | #norelated を行頭に書くと関連ページを表示しないルールを追加 |
299 | 337 | 関連ページの区切り文字を整形ルール用と分けた |
300 | 338 | |
301 | - * 2002-02-09 1.2.11 関連リンク常時表示機能、経過時間表示機能、セキュリティ対策、コマンドを cmd= に修正。その他バグ修正。 | |
339 | + * 2002-02-09 1.2.11 by sng. 関連リンク常時表示機能、経過時間表示機能、セキュリティ対策、コマンドを cmd= に修正。その他バグ修正。 | |
302 | 340 | |
303 | - * 2002-02-09 1.2.1 バグ修正、高速化、RDF/RSS(1.0,0.91)の実装。 | |
341 | + * 2002-02-09 1.2.1 by sng. バグ修正、高速化、RDF/RSS(1.0,0.91)の実装。 | |
304 | 342 | |
305 | - * 2002-02-07 1.2.0 設定ファイルを外部へ、InterWiki搭載、関連ページルール、注釈ルール、httpリンクルール、バグ修正。 | |
343 | + * 2002-02-07 1.2.0 by sng. 設定ファイルを外部へ、InterWiki搭載、関連ページルール、注釈ルール、httpリンクルール、バグ修正。 | |
306 | 344 | |
307 | - * 2002-02-05 1.10 スキン機能、コメント挿入、見出し目次作成、その他バグ修正。 | |
345 | + * 2002-02-05 1.10 by sng. スキン機能、コメント挿入、見出し目次作成、その他バグ修正。 | |
308 | 346 | |
309 | - * 2002-02-01 1.07 追加機能、ユーザ定義ルール、単語AND/OR検索の実装。 | |
347 | + * 2002-02-01 1.07 by sng. 追加機能、ユーザ定義ルール、単語AND/OR検索の実装。 | |
310 | 348 | |
311 | - * 2001-01-22 1.06 ページ編集時エラーの修正。ページタイトルの[[]]も取り除くように。 | |
349 | + * 2001-01-22 1.06 by sng. ページ編集時エラーの修正。ページタイトルの[[]]も取り除くように。 | |
312 | 350 | |
313 | - * 2001-12-12 1.05 差分アルゴリズムの修正、自動バックアップ機能追加。 | |
351 | + * 2001-12-12 1.05 by sng. 差分アルゴリズムの修正、自動バックアップ機能追加。 | |
314 | 352 | |
315 | - * 2001-12-10 1.01 メールアドレスリンクの不備の修正(thanks to s.sawada) | |
353 | + * 2001-12-10 1.01 by sng. メールアドレスリンクの不備の修正(thanks to s.sawada) | |
316 | 354 | |
317 | - * 2001-12-05 1.00 正式公開。検索結果からのハイライト表示機能の削除。 | |
355 | + * 2001-12-05 1.00 by sng. 正式公開。検索結果からのハイライト表示機能の削除。 | |
318 | 356 | |
319 | - * 2001-11-29 0.96 またまたいくつかのバグの修正。差分の追加。まだまだ未完、とりあえず。 | |
357 | + * 2001-11-29 0.96 by sng. またまたいくつかのバグの修正。差分の追加。まだまだ未完、とりあえず。 | |
320 | 358 | |
321 | - * 2001-11-28 0.94 いくつかのバグの修正。日付・時刻挿入ルールの追加。 | |
359 | + * 2001-11-28 0.94 by sng. いくつかのバグの修正。日付・時刻挿入ルールの追加。 | |
322 | 360 | |
323 | - * 2001-11-27 0.93 コードの清書。検索結果からのページ表示時ハイライト表示。 | |
361 | + * 2001-11-27 0.93 by sng. コードの清書。検索結果からのページ表示時ハイライト表示。 | |
324 | 362 | |
325 | - * 2001-11-26 0.92 データファイル名を YukiWiki と共通の変換方法にした。 | |
363 | + * 2001-11-26 0.92 by sng. データファイル名を YukiWiki と共通の変換方法にした。 | |
326 | 364 | |
327 | - * 2001-11-25 0.91 即日にして単語検索機能が追加。差分は結構かかりそう。 | |
365 | + * 2001-11-25 0.91 by sng. 即日にして単語検索機能が追加。差分は結構かかりそう。 | |
328 | 366 | |
329 | - * 2001-11-25 0.90 一応公開。YukiWiki の検索と差分はまだ。 | |
367 | + * 2001-11-25 0.90 by sng. 一応公開。YukiWiki の検索と差分はまだ。 | |
330 | 368 | |
331 | 369 | TODO |
332 | - - 予定なし、これから実装される YukiWiki の機能を移植 | |
370 | + - 予定なし、これから実装される YukiWiki の機能を移植 by sng. | |
333 | 371 | |
334 | 372 | 作者 |
335 | - Copyright (C) 2001,2002 by sng. | |
336 | - sng <sng@factage.com> | |
337 | - http://factage.com/sng/ | |
338 | - http://factage.com/sng/pukiwiki/ | |
373 | + PukiWiki 1.3.1 MASUI'z Edition by | |
374 | + Copyright (C) 2002 by sng & MASUI. | |
375 | + Yuichiro MASUI <masui@masui.net> | |
376 | + http://masui.net/pukiwiki/ | |
339 | 377 | |
340 | - 質問、意見、バグ報告は sng@factage.com にメールしてください。 | |
378 | + PukiWiki 1.3 by | |
379 | + Copyright (C) 2001,2002 by sng. | |
380 | + sng <sng@factage.com> | |
381 | + http://factage.com/sng/ | |
382 | + | |
383 | + 質問、意見、バグ報告は masui@masui.net にメールしてください。 | |
341 | 384 | |
342 | 385 | 配布条件 |
343 | 386 | PukiWikiは、 GNU General Public Licenseにて公開します。 |
@@ -345,6 +388,8 @@ TODO | ||
345 | 388 | PukiWikiはフリーソフトです。 ご自由にお使いください。 |
346 | 389 | |
347 | 390 | 謝辞 |
391 | + PukiWiki を開発した、sngさんに感謝します。 | |
392 | + | |
348 | 393 | YukiWiki のクローン化を許可していただいた結城浩さんに感謝します。 |
349 | 394 | |
350 | 395 | 本家のWikiWikiを作ったCunningham & Cunningham, Inc.に 感謝します。 |
@@ -0,0 +1,103 @@ | ||
1 | +<? | |
2 | +// PukiWiki - Yet another WikiWikiWeb clone. | |
3 | +// $Id: rss.php,v 1.1 2002/06/21 05:21:46 masui Exp $ | |
4 | +///////////////////////////////////////////////// | |
5 | + | |
6 | +// RecentChanges の RSS を出力 | |
7 | +function catrss($rss) | |
8 | +{ | |
9 | + global $rss_max,$page_title,$WikiName,$BracketName,$script,$whatsnew; | |
10 | + | |
11 | + $lines = get_source($whatsnew); | |
12 | + header("Content-type: application/xml"); | |
13 | + | |
14 | + $item = ""; | |
15 | + $rdf_li = ""; | |
16 | + $cnt = 0; | |
17 | + foreach($lines as $line) | |
18 | + { | |
19 | + if($cnt > $rss_max - 1) break; | |
20 | + | |
21 | + if(preg_match("/(($WikiName)|($BracketName))/",$line,$match)) | |
22 | + { | |
23 | + if($match[2]) | |
24 | + { | |
25 | + $title = $url = $match[1]; | |
26 | + } | |
27 | + else | |
28 | + { | |
29 | + if(function_exists("mb_convert_encoding")) | |
30 | + $title = mb_convert_encoding(strip_bracket($match[1]),"UTF-8","auto"); | |
31 | + else | |
32 | + $title = strip_bracket($match[1]); | |
33 | + | |
34 | + $url = $match[1]; | |
35 | + } | |
36 | + | |
37 | + $desc = date("D, d M Y H:i:s T",filemtime(get_filename(encode($match[1])))); | |
38 | + | |
39 | + if($rss==2) | |
40 | + $items.= "<item rdf:about=\"http://".SERVER_NAME.PHP_SELF."?".rawurlencode($url)."\">\n"; | |
41 | + else | |
42 | + $items.= "<item>\n"; | |
43 | + $items.= " <title>$title</title>\n"; | |
44 | + $items.= " <link>http://".SERVER_NAME.PHP_SELF."?".rawurlencode($url)."</link>\n"; | |
45 | + $items.= " <description>$desc</description>\n"; | |
46 | + $items.= "</item>\n\n"; | |
47 | + $rdf_li.= " <rdf:li rdf:resource=\"http://".SERVER_NAME.PHP_SELF."?".rawurlencode($url)."\"/>\n"; | |
48 | + | |
49 | + } | |
50 | + | |
51 | + $cnt++; | |
52 | + } | |
53 | + | |
54 | + if($rss==1) | |
55 | + { | |
56 | +?> | |
57 | +<?='<?xml version="1.0" encoding="UTF-8"?>'?> | |
58 | + | |
59 | + | |
60 | +<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" | |
61 | + "http://my.netscape.com/publish/formats/rss-0.91.dtd"> | |
62 | + | |
63 | +<rss version="0.91"> | |
64 | + | |
65 | +<channel> | |
66 | +<title><?=$page_title?></title> | |
67 | +<link><?="http://".SERVER_NAME.PHP_SELF."?$whatsnew"?></link> | |
68 | +<description>PukiWiki RecentChanges</description> | |
69 | +<language>ja</language> | |
70 | + | |
71 | +<?=$items?> | |
72 | +</channel> | |
73 | +</rss> | |
74 | +<? | |
75 | + } | |
76 | + else if($rss==2) | |
77 | + { | |
78 | +?> | |
79 | +<?='<?xml version="1.0" encoding="utf-8"?>'?> | |
80 | + | |
81 | + | |
82 | +<rdf:RDF | |
83 | + xmlns="http://purl.org/rss/1.0/" | |
84 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |
85 | + xml:lang="ja"> | |
86 | + | |
87 | + <channel rdf:about="<?="http://".SERVER_NAME.PHP_SELF."?rss"?>"> | |
88 | + <title><?=$page_title?></title> | |
89 | + <link><?="http://".SERVER_NAME.PHP_SELF."?$whatsnew"?></link> | |
90 | + <description>PukiWiki RecentChanges</description> | |
91 | + <items> | |
92 | + <rdf:Seq> | |
93 | +<?=$rdf_li?> | |
94 | + </rdf:Seq> | |
95 | + </items> | |
96 | + </channel> | |
97 | + | |
98 | +<?=$items?> | |
99 | +</rdf:RDF> | |
100 | +<? | |
101 | + } | |
102 | +} | |
103 | +?> |
@@ -1,7 +1,9 @@ | ||
1 | +<? header("Content-Type: text/html; charset=EUC_JP") ?> | |
1 | 2 | <!-- default skin by sng --> |
3 | +<!-- little changed by masui --> | |
2 | 4 | <html> |
3 | 5 | <head> |
4 | -<meta http-equiv="content-type" content="text/html; charset=euc-jp"> | |
6 | +<meta http-equiv="content-type" content="text/html; charset=EUC_JP"> | |
5 | 7 | <title>sng's PukiWiki - <?=$title?></title> |
6 | 8 | <style> |
7 | 9 | <!-- |
@@ -187,7 +189,8 @@ ul { | ||
187 | 189 | <? if($is_page) { ?> |
188 | 190 | [ <a href="<?=$script?>?<?=rawurlencode($vars[page])?>">リロード</a> ] |
189 | 191 | |
190 | -[ <a href="<?=$link_add?>">追加</a> | |
192 | +[ <a href="<?=$script?>?plugin=newpage">新規</a> | |
193 | +<!--| <a href="<?=$link_add?>">追加</a--> | |
191 | 194 | | <a href="<?=$link_edit?>">編集</a> |
192 | 195 | | <a href="<?=$link_diff?>">差分</a> |
193 | 196 | | <a href="<?=$script?>?plugin=attach&pcmd=upload&page=<?=rawurlencode($vars[page])?>">添付</a> |
@@ -209,9 +212,22 @@ ul { | ||
209 | 212 | ]<br> |
210 | 213 | |
211 | 214 | <?=$hr?> |
212 | - | |
213 | -<?=$body?> | |
214 | - | |
215 | +<?if($is_page){ ?> | |
216 | +<table cellspacing="1" cellpadding="0" border="0" width="100%"> | |
217 | + <tr> | |
218 | + <td width="120" valign="top" style="word-break:break-all;"> | |
219 | + <? echo convert_html(@join("",@file(get_filename(encode("MenuBar"))))); ?> | |
220 | + </td> | |
221 | + <td width="10"> | |
222 | + </td> | |
223 | + <td valign="top"> | |
224 | +<? } ?> | |
225 | + <?=$body?> | |
226 | +<?if($is_page){ ?> | |
227 | + </td> | |
228 | + </tr> | |
229 | +</table> | |
230 | +<? } ?> | |
215 | 231 | <?=$hr?> |
216 | 232 | |
217 | 233 | <? |
@@ -234,7 +250,8 @@ if(file_exists(PLUGIN_DIR."attach.inc.php") && $is_read) | ||
234 | 250 | |
235 | 251 | |
236 | 252 | |
237 | -<a href="<?=$link_add?>"><img src="./image/add.gif" width="20" height="20" border="0" alt="追加"></a> | |
253 | +<a href="<?=$script?>?plugin=newpage"><img src="./image/new.gif" width="20" height="20" border="0" alt="新規"></a> | |
254 | +<!--a href="<?=$link_add?>"><img src="./image/add.gif" width="20" height="20" border="0" alt="追加"></a--> | |
238 | 255 | <a href="<?=$link_edit?>"><img src="./image/edit.gif" width="20" height="20" border="0" alt="編集"></a> |
239 | 256 | <a href="<?=$link_diff?>"><img src="./image/diff.gif" width="20" height="20" border="0" alt="差分"></a> |
240 | 257 | |
@@ -268,8 +285,7 @@ if(file_exists(PLUGIN_DIR."attach.inc.php") && $is_read) | ||
268 | 285 | <font face="Verdana" size="1"> |
269 | 286 | Modified by <a href="<?=$modifierlink?>"><?=$modifier?></a><br> |
270 | 287 | <br> |
271 | -<b>"PukiWiki" <?=S_VERSION?></b> Copyright © 2001,2002 <a href="mailto:sng@factage.com">sng</a>.<br> | |
272 | -This is Free Software released under the <a href="http://www.gnu.org/">GNU/GPL license</a>.<br> | |
288 | +<?=S_COPYRIGHT?><br> | |
273 | 289 | Powered by PHP <?=PHP_VERSION?><br> |
274 | 290 | <br> |
275 | 291 | HTML convert time to <?=$taketime?> sec. |
@@ -1,4 +1,5 @@ | ||
1 | 1 | <!-- default skin by sng --> |
2 | +<!-- little changed by masui --> | |
2 | 3 | <html> |
3 | 4 | <head> |
4 | 5 | <meta http-equiv="content-type" content="text/html; charset=euc-jp"> |
@@ -243,8 +244,7 @@ ul { | ||
243 | 244 | <font face="Verdana" size="1"> |
244 | 245 | Modified by <a href="<?=$modifierlink?>"><?=$modifier?></a><br> |
245 | 246 | <br> |
246 | -<b>"PukiWiki" <?=S_VERSION?></b> Copyright © 2001,2002 <a href="mailto:sng@factage.com">sng</a>.<br> | |
247 | -This is Free Software released under the <a href="http://www.gnu.org/">GNU/GPL license</a>.<br> | |
247 | +<?=S_COPYRIGHT?><br> | |
248 | 248 | Powered by PHP <?=PHP_VERSION?><br> |
249 | 249 | <br> |
250 | 250 | HTML convert time to <?=$taketime?> sec. |
@@ -0,0 +1,25 @@ | ||
1 | +<? | |
2 | +// PukiWiki - Yet another WikiWikiWeb clone. | |
3 | +// $Id: template.php,v 1.1 2002/06/21 05:21:46 masui Exp $ | |
4 | +///////////////////////////////////////////////// | |
5 | + | |
6 | +function auto_template($page) | |
7 | +{ | |
8 | + global $auto_template_rules,$auto_template_func; | |
9 | + if(!$auto_template_func) return ''; | |
10 | + | |
11 | + $body = ''; | |
12 | + foreach($auto_template_rules as $rule => $template) | |
13 | + { | |
14 | + if(preg_match("/$rule/",$page,$matches)) { | |
15 | + $template_page = preg_replace("/$rule/",$template,$page); | |
16 | + $body = join('',get_source($template_page)); | |
17 | + for($i=0; $i<count($matches); ++$i) { | |
18 | + $body = str_replace("\$$i",$matches[$i],$body); | |
19 | + } | |
20 | + break; | |
21 | + } | |
22 | + } | |
23 | + return $body; | |
24 | +} | |
25 | +?> | |
\ No newline at end of file |