';
+
+ $y = substr($date_str,0,4)+0;
+ $m = substr($date_str,4,2)+0;
+
+ $prev_date_str = sprintf("%04d%02d",$y,$m-1);
+ if($m-1<1) {
+ $prev_date_str = sprintf("%04d%02d",$y-1,12);
+ }
+ $next_date_str = sprintf("%04d%02d",$y,$m+1);
+ if($m+1>12) {
+ $next_date_str = sprintf("%04d%02d",$y+1,1);
+ }
+
+ if($prefix == "") {
+ $ret .= '
+
+
+
+
+
+ |
+
+
+';
+ }
+ else {
+ $ret .= '
+
+
+
+
+
+ |
+
+
+';
+ }
+
+ foreach($weeklabels as $label)
+ {
+ $ret .= '
+
+ '.$label.'
+ | ';
+ }
+
+ $ret .= " \n\n";
+
+ while(checkdate($m_num,$day,$year))
+ {
+ $dt = sprintf("%4d-%02d-%02d", $year, $m_num, $day);
+ $name = "$prefix$dt";
+ $page = "[[$prefix$dt]]";
+ $page_url = rawurlencode("[[$prefix$dt]]");
+
+ if($cmd == "edit") $refer = "&refer=$page_url";
+ else $refer = "";
+
+ if($cmd == "read" && !is_page($page))
+ $link = "$day";
+ else
+ $link = "$day";
+
+ if($fweek)
+ {
+ for($i=0;$i<$wday;$i++)
+ { // Blank
+ $ret .= " | \n";
+ }
+ $fweek=false;
+ }
+
+ if($wday == 0) $ret .= " \n";
+ if(!$other_month && ($day == $today[mday]) && ($m_num == $today[mon]) && ($year == $today[year]))
+ {
+ // Today
+ $ret .= " $link | \n";
+ }
+ else if($wday == 0)
+ {
+ // Sunday
+ $ret .= " $link | \n";
+ }
+ else if($wday == 6)
+ {
+ // Saturday
+ $ret .= " $link | \n";
+ }
+ else
+ {
+ // Weekday
+ $ret .= " $link | \n";
+ }
+ $day++;
+ $wday++;
+ $wday = $wday % 7;
+ }
+ if($wday > 0)
+ {
+ while($wday < 7)
+ { // Blank
+ $ret .= " | \n";
+ $wday++;
+ }
+ }
+
+ $ret .= " \n \n";
+
+ $page = sprintf("[[%s%4d-%02d-%02d]]", $prefix, $today[year], $today[mon], $today[mday]);
+ $page_url = rawurlencode($page);
+ if(is_page($page)) {
+ $str = convert_html(join("",file(get_filename(encode($page)))));
+ $str .= " [¤³¤ÎÆüµ¤òÊÔ½¸]";
+ }
+ else {
+ $str = make_link(sprintf('[[%s%4d-%02d-%02d]]',$prefix, $today[year], $today[mon], $today[mday])).'¤Ï¶õ¤Ç¤¹¡£';
+ }
+
+ $ret .= "".$str." | ";
+
+ return $ret;
+}
+
+function plugin_calendar2_action()
+{
+ global $command,$vars;
+
+ $command = 'read';
+ $page = strip_bracket($vars['page']);
+ $vars['page'] = '*';
+ if($vars['file']) $vars['page'] = $vars['file'];
+
+ $date = $vars['date'];
+ if($date=='') {
+ $date = date("Ym");
+ }
+
+ $aryargs = array($vars['page'],$date);
+ $ret["msg"] = "calendar ".$vars['page']."/".$vars['date'];
+ $ret["body"] = call_user_func_array("plugin_calendar2_convert",$aryargs);
+
+ $vars['page'] = $page;
+
+ return $ret;
+}
+
+?>
\ No newline at end of file
diff --git a/plugin/calendar_edit.inc.php b/plugin/calendar_edit.inc.php
index 8ede3d0..3b9f545 100644
--- a/plugin/calendar_edit.inc.php
+++ b/plugin/calendar_edit.inc.php
@@ -1,24 +1,24 @@
-
-function plugin_calendar_edit_convert()
-{
- global $command;
-
- $command = edit;
-
- if(func_num_args())
- $aryargs = func_get_args();
- else
- $aryargs = array();
-
-
- if(file_exists(PLUGIN_DIR."calendar.inc.php"))
- {
- require_once PLUGIN_DIR."calendar.inc.php";
- return call_user_func_array("plugin_calendar_convert",$aryargs);
- }
- else
- {
- return FALSE;
- }
-}
-?>
+
+function plugin_calendar_edit_convert()
+{
+ global $command;
+
+ $command = edit;
+
+ if(func_num_args())
+ $aryargs = func_get_args();
+ else
+ $aryargs = array();
+
+
+ if(file_exists(PLUGIN_DIR."calendar.inc.php"))
+ {
+ require_once PLUGIN_DIR."calendar.inc.php";
+ return call_user_func_array("plugin_calendar_convert",$aryargs);
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+?>
diff --git a/plugin/calendar_read.inc.php b/plugin/calendar_read.inc.php
index 8234a85..20ba5ec 100644
--- a/plugin/calendar_read.inc.php
+++ b/plugin/calendar_read.inc.php
@@ -1,23 +1,23 @@
-
-function plugin_calendar_read_convert()
-{
- global $command;
-
- $command = read;
-
- if(func_num_args())
- $aryargs = func_get_args();
- else
- $aryargs = array();
-
- if(file_exists(PLUGIN_DIR."calendar.inc.php"))
- {
- require_once PLUGIN_DIR."calendar.inc.php";
- return call_user_func_array("plugin_calendar_convert",$aryargs);
- }
- else
- {
- return FALSE;
- }
-}
-?>
+
+function plugin_calendar_read_convert()
+{
+ global $command;
+
+ $command = read;
+
+ if(func_num_args())
+ $aryargs = func_get_args();
+ else
+ $aryargs = array();
+
+ if(file_exists(PLUGIN_DIR."calendar.inc.php"))
+ {
+ require_once PLUGIN_DIR."calendar.inc.php";
+ return call_user_func_array("plugin_calendar_convert",$aryargs);
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+?>
diff --git a/plugin/comment.inc.php b/plugin/comment.inc.php
index 8f24955..6eabb58 100644
--- a/plugin/comment.inc.php
+++ b/plugin/comment.inc.php
@@ -1,148 +1,170 @@
-
-global $name_cols,$comment_cols;
-
-/////////////////////////////////////////////////
-// Rg̼OeLXgGAÌJ
-$name_cols = 15;
-/////////////////////////////////////////////////
-// RgÌeLXgGAÌJ
-$comment_cols = 70;
-/////////////////////////////////////////////////
-// RgÌ}ütH[}bg(¼O)
-$name_format = '[[$name]]';
-/////////////////////////////////////////////////
-// RgÌ}ütH[}bg(Rgàe)
-$comment_format = '$now $name $msg';
-/////////////////////////////////////////////////
-// Rgð}ü·éÊu 1:ÌO 0:Ìã
-$comment_ins = 1;
-
-
-// initialize
-$comment_no = 0;
-
-function plugin_comment_action()
-{
- global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup,$update_exec,$now;
- global $name_cols,$comment_cols,$name_format,$comment_format,$comment_ins;
- global $_title_collided,$_msg_collided,$_title_updated;
-
- if($post["msg"])
- {
- $post["msg"] = preg_replace("/\n/","",$post["msg"]);
-
- $postdata = "";
- $postdata_old = file(get_filename(encode($post["refer"])));
- $comment_no = 0;
-
- if($post[name])
- {
- $name = str_replace('$name',$post[name],$name_format);
- }
- if($post[msg])
- {
- if(preg_match("/^(-{1,2})(.*)/",$post[msg],$match))
- {
- $head = $match[1];
- $post[msg] = $match[2];
- }
-
- $comment = str_replace('$msg',$post[msg],$comment_format);
- $comment = str_replace('$name',$name,$comment);
- $comment = str_replace('$now',$now,$comment);
- }
- $comment = $head.$comment;
-
- foreach($postdata_old as $line)
- {
- if(!$comment_ins) $postdata .= $line;
- if(preg_match("/^#comment/",$line))
- {
- if($comment_no == $post["comment_no"] && $post[msg]!="")
- {
- $postdata .= "-$comment\n";
- }
- $comment_no++;
- }
- if($comment_ins) $postdata .= $line;
- }
-
- $postdata_input = "-$comment\n";
- }
-
- if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"])
- {
- $title = $_title_collided;
-
- $body = "$_msg_collided\n";
-
- $body .= "\n";
- }
- else
- {
- $postdata = user_rules_str($postdata);
-
- // ·ªt@CÌì¬
- if(is_page($post["refer"]))
- $oldpostdata = join("",file(get_filename(encode($post["refer"]))));
- else
- $oldpostdata = "\n";
- if($postdata)
- $diffdata = do_diff($oldpostdata,$postdata);
- file_write(DIFF_DIR,$post["refer"],$diffdata);
-
- // obNAbvÌì¬
- if(is_page($post["refer"]))
- $oldposttime = filemtime(get_filename(encode($post["refer"])));
- else
- $oldposttime = time();
-
- // ÒWàeª½à©êĢȢÆobNAbvàí·é?µÈ¢Å·æËB
- if(!$postdata && $del_backup)
- backup_delete(BACKUP_DIR.encode($post["refer"]).".txt");
- else if($do_backup && is_page($post["refer"]))
- make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime);
-
- // t@CÌ«Ý
- file_write(DATA_DIR,$post["refer"],$postdata);
-
- // is_pageÌLbV
ðNA·éB
- is_page($post["refer"],true);
-
- $title = $_title_updated;
- }
- $retvars["msg"] = $title;
- $retvars["body"] = $body;
-
- $post["page"] = $post["refer"];
- $vars["page"] = $post["refer"];
-
- return $retvars;
-}
-function plugin_comment_convert()
-{
- global $script,$comment_no,$vars,$name_cols,$comment_cols,$digest;
- global $_btn_comment,$_btn_name,$vars;
-
- if((arg_check("read")||$vars["cmd"] == ""||arg_check("unfreeze")||arg_check("freeze")||$vars["write"]||$vars["comment"]))
- $button = "\n";
-
- $string = "";
-
- $comment_no++;
-
- return $string;
-}
-?>
+
+global $name_cols, $comment_cols, $msg_format, $name_format;
+global $msg_format, $now_format, $comment_format;
+global $comment_ins, $comment_mail, $comment_no;
+
+
+/////////////////////////////////////////////////
+// ¥³¥á¥ó¥È¤Î̾Á°¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¥«¥é¥à¿ô
+$name_cols = 15;
+/////////////////////////////////////////////////
+// ¥³¥á¥ó¥È¤Î¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¥«¥é¥à¿ô
+$comment_cols = 70;
+/////////////////////////////////////////////////
+// ¥³¥á¥ó¥È¤ÎÁÞÆþ¥Õ¥©¡¼¥Þ¥Ã¥È
+$name_format = '[[$name]]';
+$msg_format = '$msg';
+$now_format = 'SIZE(1):$now';
+/////////////////////////////////////////////////
+// ¥³¥á¥ó¥È¤ÎÁÞÆþ¥Õ¥©¡¼¥Þ¥Ã¥È(¥³¥á¥ó¥ÈÆâÍÆ)
+$comment_format = '$msg -- $name $now';
+/////////////////////////////////////////////////
+// ¥³¥á¥ó¥È¤òÁÞÆþ¤¹¤ë°ÌÃÖ 1:Íó¤ÎÁ° 0:Íó¤Î¸å
+$comment_ins = 1;
+/////////////////////////////////////////////////
+// ¥³¥á¥ó¥È¤¬Åê¹Æ¤µ¤ì¤¿¾ì¹ç¡¢ÆâÍƤò¥á¡¼¥ë¤ÇÁ÷¤ëÀè
+$comment_mail = FALSE;
+
+// initialize
+$comment_no = 0;
+
+function plugin_comment_action()
+{
+ global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup,$update_exec,$now;
+ global $name_cols,$comment_cols,$name_format,$msg_format,$now_format,$comment_format,$comment_ins;
+ global $_title_collided,$_msg_collided,$_title_updated;
+ global $_msg_comment_collided,$_title_comment_collided;
+
+ $_comment_format = $comment_format;
+ if($post["nodate"]=="1") {
+ $_comment_format = str_replace('$now','',$_comment_format);
+ }
+ if($post["msg"]=="") {
+ $retvars["msg"] = $name;
+ $post["page"] = $post["refer"];
+ $vars["page"] = $post["refer"];
+ $retvars["body"] = convert_html(join("",file(get_filename(encode($post["refer"])))));
+ return $retvars;
+ }
+ if($post["msg"])
+ {
+ $post["msg"] = preg_replace("/\n/","",$post["msg"]);
+
+ $postdata = "";
+ $postdata_old = file(get_filename(encode($post["refer"])));
+ $comment_no = 0;
+
+ if($post["name"])
+ {
+ $name = str_replace('$name',$post["name"],$name_format);
+ }
+ if($post["msg"])
+ {
+ if(preg_match("/^(-{1,2})(.*)/",$post["msg"],$match))
+ {
+ $head = $match[1];
+ $post["msg"] = $match[2];
+ }
+
+ $comment = str_replace('$msg',str_replace('$msg',$post["msg"],$msg_format),$_comment_format);
+ $comment = str_replace('$name',$name,$comment);
+ $comment = str_replace('$now',str_replace('$now',$now,$now_format),$comment);
+ $comment = $head.$comment;
+ }
+
+ foreach($postdata_old as $line)
+ {
+ if(!$comment_ins) $postdata .= $line;
+ if(preg_match("/^#comment/",$line))
+ {
+ if($comment_no == $post["comment_no"] && $post[msg]!="")
+ {
+ $postdata .= "-$comment\n";
+ }
+ $comment_no++;
+ }
+ if($comment_ins) $postdata .= $line;
+ }
+
+ $postdata_input = "-$comment\n";
+ }
+
+ $title = $_title_updated;
+ if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"])
+ {
+ $title = $_title_comment_collided;
+ $body = $_msg_comment_collided . make_link($post["refer"]);
+ }
+
+ $postdata = user_rules_str($postdata);
+
+ // º¹Ê¬¥Õ¥¡¥¤¥ë¤ÎºîÀ®
+ if(is_page($post["refer"]))
+ $oldpostdata = join("",file(get_filename(encode($post["refer"]))));
+ else
+ $oldpostdata = "\n";
+ if($postdata)
+ $diffdata = do_diff($oldpostdata,$postdata);
+ file_write(DIFF_DIR,$post["refer"],$diffdata);
+ // ¥Ð¥Ã¥¯¥¢¥Ã¥×¤ÎºîÀ®
+ if(is_page($post["refer"]))
+ $oldposttime = filemtime(get_filename(encode($post["refer"])));
+ else
+ $oldposttime = time();
+
+ // ÊÔ½¸ÆâÍƤ¬²¿¤â½ñ¤«¤ì¤Æ¤¤¤Ê¤¤¤È¥Ð¥Ã¥¯¥¢¥Ã¥×¤âºï½ü¤¹¤ë?¤·¤Ê¤¤¤Ç¤¹¤è¤Í¡£
+ if(!$postdata && $del_backup)
+ backup_delete(BACKUP_DIR.encode($post["refer"]).".txt");
+ else if($do_backup && is_page($post["refer"]))
+ make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime);
+
+ // ¥Õ¥¡¥¤¥ë¤Î½ñ¤¹þ¤ß
+ file_write(DATA_DIR,$post["refer"],$postdata);
+
+ // is_page¤Î¥¥ã¥Ã¥·¥å¤ò¥¯¥ê¥¢¤¹¤ë¡£
+ is_page($post["refer"],true);
+
+ $retvars["msg"] = $title;
+ $retvars["body"] = $body;
+
+ $post["page"] = $post["refer"];
+ $vars["page"] = $post["refer"];
+
+ return $retvars;
+}
+function plugin_comment_convert()
+{
+ global $script,$comment_no,$vars,$name_cols,$comment_cols,$digest;
+ global $_btn_comment,$_btn_name,$_msg_comment,$vars;
+
+ $options = func_get_args();
+
+ $nametags = "$_btn_name\n";
+ if(is_array($options) && in_array("noname",$options)) {
+ $nametags = $_msg_comment;
+ }
+
+ $nodate = '0';
+ if(is_array($options) && in_array("nodate",$options)) {
+ $nodate = '1';
+ }
+
+ if((arg_check("read")||$vars["cmd"] == ""||arg_check("unfreeze")||arg_check("freeze")||$vars["write"]||$vars["comment"]))
+ $button = "\n";
+
+ $string = "";
+
+ $comment_no++;
+
+ return $string;
+}
+?>
diff --git a/plugin/counter.inc.php b/plugin/counter.inc.php
new file mode 100644
index 0000000..d921ed8
--- /dev/null
+++ b/plugin/counter.inc.php
@@ -0,0 +1,52 @@
+
+/*
+ * PukiWiki ¥«¥¦¥ó¥¿¡¼¥×¥é¥°¥¤¥ó
+ *
+ * CopyRight 2002 Y.MASUI GPL2
+ * http://masui.net/pukiwiki/ masui@masui.net
+ */
+
+// counter file
+define(COUNTER_DIR, "./counter/");
+
+function plugin_counter_convert()
+{
+ global $vars;
+
+ $file = COUNTER_DIR.encode($vars["page"]).".count";
+ if(!file_exists($file))
+ {
+ $nf = fopen($file, "w");
+ fputs($nf,"0\n0\n0\n0\n\n");
+ fclose($nf);
+ }
+ $array = file($file);
+ $count = rtrim($array[0]);
+ $today = rtrim($array[1]);
+ $today_count = rtrim($array[2]);
+ $yesterday_count = rtrim($array[3]);
+ $ip = rtrim($array[4]);
+ if($ip != $_SERVER["REMOTE_ADDR"] && !(arg_check("add") || arg_check("edit") || arg_check("preview") || $vars['preview'] != '' || $vars['write'] != '')) {
+ $t = date("Y/m/d");
+ if($t != $today) {
+ $yesterday_count = $today_count;
+ $today_count = 0;
+ $today = $t;
+ }
+ ++$count;
+ ++$today_count;
+ }
+
+ $ip = $_SERVER["REMOTE_ADDR"];
+ $nf = fopen($file, "w");
+ fputs($nf,"$count\n");
+ fputs($nf,"$today\n");
+ fputs($nf,"$today_count\n");
+ fputs($nf,"$yesterday_count\n");
+ fputs($nf,"$ip\n");
+ fclose($nf);
+
+ return "Counter: $count, today: $today_count, yesterday: $yesterday_count";
+
+}
+?>
diff --git a/plugin/img.inc.php b/plugin/img.inc.php
new file mode 100644
index 0000000..b0d9c52
--- /dev/null
+++ b/plugin/img.inc.php
@@ -0,0 +1,20 @@
+
+function plugin_img_convert()
+{
+ if(func_num_args()!=2) {
+ return;
+ }
+ $aryargs = func_get_args();
+ $url = $aryargs[0];
+ $align = strtoupper($aryargs[1]);
+
+ if($align == 'R' || $align == 'RIGHT') {
+ $align = 'right';
+ }
+ else {
+ $align = 'left';
+ }
+
+ return "";
+}
+?>
diff --git a/plugin/insert.inc.php b/plugin/insert.inc.php
new file mode 100644
index 0000000..1d56783
--- /dev/null
+++ b/plugin/insert.inc.php
@@ -0,0 +1,121 @@
+
+/////////////////////////////////////////////////
+// ¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¥«¥é¥à¿ô
+define("INSERT_COLS",70);
+/////////////////////////////////////////////////
+// ¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¹Ô¿ô
+define("INSERT_ROWS",5);
+/////////////////////////////////////////////////
+// ÁÞÆþ¤¹¤ë°ÌÃÖ 1:Íó¤ÎÁ° 0:Íó¤Î¸å
+define("INSERT_INS",1);
+
+function plugin_insert_action()
+{
+ global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup;
+ global $_title_collided,$_msg_collided,$_title_updated;
+
+ if($post["msg"])
+ {
+ $postdata = "";
+ $postdata_old = file(get_filename(encode($post["refer"])));
+ $insert_no = 0;
+
+ if($post[msg])
+ {
+ $insert = $post[msg];
+ }
+
+ foreach($postdata_old as $line)
+ {
+ if(!INSERT_INS) $postdata .= $line;
+ if(preg_match("/^#insert$/",$line))
+ {
+ if($insert_no == $post["insert_no"] && $post[msg]!="")
+ {
+ $postdata .= "$insert\n";
+ }
+ $insert_no++;
+ }
+ if(INSERT_INS) $postdata .= $line;
+ }
+
+ $postdata_input = "$insert\n";
+ }
+ else
+ return;
+
+ if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"])
+ {
+ $title = $_title_collided;
+
+ $body = "$_msg_collided\n";
+
+ $body .= "\n";
+ }
+ else
+ {
+ $postdata = user_rules_str($postdata);
+
+ // º¹Ê¬¥Õ¥¡¥¤¥ë¤ÎºîÀ®
+ if(is_page($post["refer"]))
+ $oldpostdata = join("",file(get_filename(encode($post["refer"]))));
+ else
+ $oldpostdata = "\n";
+ if($postdata)
+ $diffdata = do_diff($oldpostdata,$postdata);
+ file_write(DIFF_DIR,$post["refer"],$diffdata);
+
+ // ¥Ð¥Ã¥¯¥¢¥Ã¥×¤ÎºîÀ®
+ if(is_page($post["refer"]))
+ $oldposttime = filemtime(get_filename(encode($post["refer"])));
+ else
+ $oldposttime = time();
+
+ // ÊÔ½¸ÆâÍƤ¬²¿¤â½ñ¤«¤ì¤Æ¤¤¤Ê¤¤¤È¥Ð¥Ã¥¯¥¢¥Ã¥×¤âºï½ü¤¹¤ë?¤·¤Ê¤¤¤Ç¤¹¤è¤Í¡£
+ if(!$postdata && $del_backup)
+ backup_delete(BACKUP_DIR.encode($post["refer"]).".txt");
+ else if($do_backup && is_page($post["refer"]))
+ make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime);
+
+ // ¥Õ¥¡¥¤¥ë¤Î½ñ¤¹þ¤ß
+ file_write(DATA_DIR,$post["refer"],$postdata);
+
+ // is_page¤Î¥¥ã¥Ã¥·¥å¤ò¥¯¥ê¥¢¤¹¤ë¡£
+ is_page($post["refer"],true);
+
+ $title = $_title_updated;
+ }
+ $retvars["msg"] = $title;
+ $retvars["body"] = $body;
+
+ $post["page"] = $post["refer"];
+ $vars["page"] = $post["refer"];
+
+ return $retvars;
+}
+function plugin_insert_convert()
+{
+ global $script,$insert_no,$vars,$digest;
+ global $_btn_insert,$vars;
+
+ if((arg_check("read")||$vars["cmd"] == ""||arg_check("unfreeze")||arg_check("freeze")||$vars["write"]||$vars["insert"]))
+ $button = "\n";
+
+ $string = "";
+
+ $insert_no++;
+
+ return $string;
+}
+?>
diff --git a/plugin/lookup.inc.php b/plugin/lookup.inc.php
index 58a2ab7..76dd5ec 100644
--- a/plugin/lookup.inc.php
+++ b/plugin/lookup.inc.php
@@ -1,37 +1,37 @@
-
-function plugin_lookup_convert()
-{
- global $script,$vars;
-
- $args = func_get_args();
-
- if(func_num_args() < 2) return FALSE;
-
- $iwn = trim(strip_tags($args[0]));
- $btn = trim(strip_tags($args[1]));
- $default = trim(strip_tags($args[2]));
-
- $ret = "\n";
-
- return $ret;
-}
-function plugin_lookup_action()
-{
- global $vars,$script;
-
- if(!$vars["inter"] || !$vars["page"]) return;
-
- $interwikiname = "[[".$vars["inter"].":".$vars["page"]."]]";
- $interwikiname = rawurlencode($interwikiname);
-
- header("Location: $script?$interwikiname");
- die();
-}
-?>
+
+function plugin_lookup_convert()
+{
+ global $script,$vars;
+
+ $args = func_get_args();
+
+ if(func_num_args() < 2) return FALSE;
+
+ $iwn = trim(strip_tags($args[0]));
+ $btn = trim(strip_tags($args[1]));
+ $default = trim(strip_tags($args[2]));
+
+ $ret = "\n";
+
+ return $ret;
+}
+function plugin_lookup_action()
+{
+ global $vars,$script;
+
+ if(!$vars["inter"] || !$vars["page"]) return;
+
+ $interwikiname = "[[".$vars["inter"].":".$vars["page"]."]]";
+ $interwikiname = rawurlencode($interwikiname);
+
+ header("Location: $script?$interwikiname");
+ die();
+}
+?>
diff --git a/plugin/ls.inc.php b/plugin/ls.inc.php
new file mode 100644
index 0000000..6e149a3
--- /dev/null
+++ b/plugin/ls.inc.php
@@ -0,0 +1,62 @@
+
+/*
+ * PukiWiki ls¥×¥é¥°¥¤¥ó
+ *
+ * CopyRight 2002 Y.MASUI GPL2
+ * http://masui.net/pukiwiki/ masui@masui.net
+ */
+
+function plugin_ls_convert()
+{
+ global $vars, $script;
+
+ if(func_num_args())
+ $aryargs = func_get_args();
+ else
+ $aryargs = array();
+
+ $with_title = FALSE;
+ if(array_search('title',$aryargs)!==FALSE) {
+ $with_title = TRUE;
+ }
+ $ls = $comment = '';
+ $filepattern = encode('[['.strip_bracket($vars["page"]).'/');
+ $filepattern_len = strlen($filepattern);
+ if ($dir = @opendir(DATA_DIR))
+ {
+ while($file = readdir($dir))
+ {
+ if($file == ".." || $file == ".") continue;
+ if(substr($file,0,$filepattern_len)!=$filepattern) continue;
+ $page = decode(trim(preg_replace("/\.txt$/"," ",$file)));
+ if($with_title) {
+ $comment = '';
+ $fd = fopen(DATA_DIR . $file,'r');
+ if(!feof ($fd)) {
+ $comment = ereg_replace("^[-*]+",'',fgets($fd,1024));
+ $comment = ereg_replace("[~\r\n]+$",'',$comment);
+ $comment = trim($comment);
+ }
+ if($comment != '' && substr($comment,0,1) != '#') {
+ $comment = " - " . convert_html($comment);
+ }
+ else {
+ $comment = '';
+ }
+ fclose($fd);
+ }
+ $url = rawurlencode($page);
+ $name = strip_bracket($page);
+ $title = $name ." " .get_pg_passage($page,false);
+ $ls .= "$name$comment\n";
+ }
+ closedir($dir);
+ }
+
+ if($ls=='') {
+ return '';
+ }
+
+ return "";
+}
+?>
diff --git a/plugin/memo.inc.php b/plugin/memo.inc.php
new file mode 100644
index 0000000..88ecbcb
--- /dev/null
+++ b/plugin/memo.inc.php
@@ -0,0 +1,126 @@
+
+/////////////////////////////////////////////////
+// ¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¥«¥é¥à¿ô
+define("MEMO_COLS",80);
+/////////////////////////////////////////////////
+// ¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¹Ô¿ô
+define("MEMO_ROWS",5);
+
+function plugin_memo_action()
+{
+ global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup;
+ global $_title_collided,$_msg_collided,$_title_updated;
+
+ $post["msg"] = preg_replace("/(\x0D\x0A)/","\n",$post["msg"]);
+ $post["msg"] = preg_replace("/(\x0D)/","\n",$post["msg"]);
+ $post["msg"] = preg_replace("/(\x0A)/","\n",$post["msg"]);
+
+ if($post["msg"])
+ {
+ $post["msg"] = str_replace("\n","\\n",$post["msg"]);
+
+ $postdata = "";
+ $postdata_old = file(get_filename(encode($post["refer"])));
+ $memo_no = 0;
+
+ $memo_body = $post["msg"];
+
+ foreach($postdata_old as $line)
+ {
+ if(preg_match("/^#memo\(?.*\)?$/",$line))
+ {
+ if($memo_no == $post["memo_no"] && $post["msg"]!="")
+ {
+ $postdata .= "#memo($memo_body)\n";
+ $line = "";
+ }
+ $memo_no++;
+ }
+ $postdata .= $line;
+ }
+
+ $postdata_input = "$memo_body\n";
+ }
+ else
+ return;
+
+ if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"])
+ {
+ $title = $_title_collided;
+
+ $body = "$_msg_collided\n";
+
+ $body .= "\n";
+ }
+ else
+ {
+ $postdata = user_rules_str($postdata);
+
+ // º¹Ê¬¥Õ¥¡¥¤¥ë¤ÎºîÀ®
+ if(is_page($post["refer"]))
+ $oldpostdata = join("",file(get_filename(encode($post["refer"]))));
+ else
+ $oldpostdata = "\n";
+ if($postdata)
+ $diffdata = do_diff($oldpostdata,$postdata);
+ file_write(DIFF_DIR,$post["refer"],$diffdata);
+
+ // ¥Ð¥Ã¥¯¥¢¥Ã¥×¤ÎºîÀ®
+ if(is_page($post["refer"]))
+ $oldposttime = filemtime(get_filename(encode($post["refer"])));
+ else
+ $oldposttime = time();
+
+ // ÊÔ½¸ÆâÍƤ¬²¿¤â½ñ¤«¤ì¤Æ¤¤¤Ê¤¤¤È¥Ð¥Ã¥¯¥¢¥Ã¥×¤âºï½ü¤¹¤ë?¤·¤Ê¤¤¤Ç¤¹¤è¤Í¡£
+ if(!$postdata && $del_backup)
+ backup_delete(BACKUP_DIR.encode($post["refer"]).".txt");
+ else if($do_backup && is_page($post["refer"]))
+ make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime);
+
+ // ¥Õ¥¡¥¤¥ë¤Î½ñ¤¹þ¤ß
+ file_write(DATA_DIR,$post["refer"],$postdata);
+
+ // is_page¤Î¥¥ã¥Ã¥·¥å¤ò¥¯¥ê¥¢¤¹¤ë¡£
+ is_page($post["refer"],true);
+
+ $title = $_title_updated;
+ }
+ $retvars["msg"] = $title;
+ $retvars["body"] = $body;
+
+ $post["page"] = $post["refer"];
+ $vars["page"] = $post["refer"];
+
+ return $retvars;
+}
+function plugin_memo_convert()
+{
+ global $script,$memo_no,$vars,$digest;
+ global $_btn_memo_update,$vars;
+
+ if(func_num_args())
+ $aryargs = func_get_args();
+
+ $data = str_replace("\\n","\n",$aryargs[0]);
+
+ if((arg_check("read")||$vars["cmd"] == ""||arg_check("unfreeze")||arg_check("freeze")||$vars["write"]||$vars["memo"]))
+ $button = "\n";
+
+ $string = "";
+
+ $memo_no++;
+
+ return $string;
+}
+?>
diff --git a/plugin/newpage.inc.php b/plugin/newpage.inc.php
new file mode 100644
index 0000000..15fc8b5
--- /dev/null
+++ b/plugin/newpage.inc.php
@@ -0,0 +1,52 @@
+
+function plugin_newpage_init()
+{
+ $_plugin_recent_messages = array(
+ '_msg_newpage' => '¥Ú¡¼¥¸¿·µ¬ºîÀ®'
+ );
+ set_plugin_messages($_plugin_recent_messages);
+}
+
+function plugin_newpage_convert()
+{
+ global $script,$vars,$_btn_edit,$_msg_newpage;
+
+ $ret = "\n";
+
+ return $ret;
+}
+
+function plugin_newpage_action()
+{
+ global $vars,$script,$_btn_edit,$_msg_newpage;
+
+ if(!$vars["page"]) {
+ $retvars["msg"] = $_msg_newpage;
+ $retvars["body"] = "\n";
+
+ return $retvars;
+ }
+
+ if(!preg_match("/^($BracketName)|($InterWikiName)$/",$vars["page"]))
+ {
+ $vars["page"] = "[[$vars[page]]]";
+ }
+
+ $wikiname = rawurlencode($vars["page"]);
+
+ header("Location: $script?$wikiname");
+ die();
+}
+?>
diff --git a/plugin/online.inc.php b/plugin/online.inc.php
index 30926c2..4d00b2e 100644
--- a/plugin/online.inc.php
+++ b/plugin/online.inc.php
@@ -1,48 +1,48 @@
-
-
-// user list file
-define(USR_LST, "user.dat");
-// time out sec
-define(TIMEOUT, 300);
-
-function plugin_online_convert()
-{
- global $HTTP_SERVER_VARS;
-
- if(!file_exists(USR_LST))
- {
- $nf = fopen(USR_LST, "w");
- fclose($nf);
- }
- CheckUser($HTTP_SERVER_VARS["REMOTE_ADDR"]);
- return UserCount();
-}
-
-function CheckUser($addr)
-{
- $usr_arr = file(USR_LST);
- $fp = fopen(USR_LST, "w");
- while(!flock($fp,LOCK_EX));
- $now = time();
- for($i = 0; $i < count($usr_arr); $i++)
- {
- list($ip_addr,$tim_stmp) = explode("|", $usr_arr[$i]);
- if(($now-$tim_stmp) < TIMEOUT)
- {
- if($ip_addr != $addr)
- {
- fputs($fp, "$ip_addr|$tim_stmp");
- }
- }
- }
- fputs($fp, "$addr|$now\n");
- flock($fp,LOCK_UN);
- fclose($fp);
-}
-
-function UserCount()
-{
- $usr_arr = file(USR_LST);
- return count($usr_arr);
-}
-?>
+
+
+// user list file
+define(USR_LST, "counter/user.dat");
+// time out sec
+define(TIMEOUT, 300);
+
+function plugin_online_convert()
+{
+ global $HTTP_SERVER_VARS;
+
+ if(!file_exists(USR_LST))
+ {
+ $nf = fopen(USR_LST, "w");
+ fclose($nf);
+ }
+ CheckUser($HTTP_SERVER_VARS["REMOTE_ADDR"]);
+ return UserCount();
+}
+
+function CheckUser($addr)
+{
+ $usr_arr = file(USR_LST);
+ $fp = fopen(USR_LST, "w");
+ while(!flock($fp,LOCK_EX));
+ $now = time();
+ for($i = 0; $i < count($usr_arr); $i++)
+ {
+ list($ip_addr,$tim_stmp) = explode("|", $usr_arr[$i]);
+ if(($now-$tim_stmp) < TIMEOUT)
+ {
+ if($ip_addr != $addr)
+ {
+ fputs($fp, "$ip_addr|$tim_stmp");
+ }
+ }
+ }
+ fputs($fp, "$addr|$now\n");
+ flock($fp,LOCK_UN);
+ fclose($fp);
+}
+
+function UserCount()
+{
+ $usr_arr = file(USR_LST);
+ return count($usr_arr);
+}
+?>
diff --git a/plugin/readme.ja.txt b/plugin/readme.ja.txt
index 1135a76..ab59b40 100644
--- a/plugin/readme.ja.txt
+++ b/plugin/readme.ja.txt
@@ -1,64 +1,81 @@
-
-/////////////////////////////////////////////////
-// vOCfBNgÉ¢Ä
-
- PukiWikiÌy[WÌHTMLÖÌRo[gÆAvOC@\©çÌlðó¯æÁÄ
- ðs¤vOCðÝu·é±ÆªÅ«Ü·B
-
- ±ÌeLXgÍA»ÌvOCÌLqû@É¢ÄÌà¾ðµÜ·B
-
-
-/////////////////////////////////////////////////
-// y[WàÅÌvOCÌÄÑoµ
-
- #vOC¼
- #vOC¼(arg1,arg2...)
-
- sªÉXy[XÍÜßé±ÆÍÅ«È¢B
- øàÉÊ()ðgp·é±ÆªÅ«éB½¾µ ) PÌÍsÂB
- øðwèµÈÄàÄÑo¹é
-
-
-/////////////////////////////////////////////////
-// t@C¼
-
- vOC¼.inc.php
-
-
-/////////////////////////////////////////////////
-// Ö
-
- ¡function plugin_vOC¼_convert()
-
- HTMLÖÌRo[gÉÄÑo³êé
-
- øÍ func_get_args() ÅzñÖi[Å«éB([0]`[n])
- func_num_args() ÉæÁÄAn³ê½øÌðßé±ÆªÅ«éB
-
- ¡function plugin_vOC¼_action()
-
- GETEPOST\bhÅpluginðwè³ê½Æ«ÉÄÑo³êé
-
- ÔlÉ array("msg" => "$1 is page") ÈÇðÔ·Æ $1 ðy[W¼ÆµÄ
- y[W^CgÉu·³êé
-
- die() ðÀs·é±ÆÉæèAy[WÉßçÈ¢æ¤ÉÅ«é
-
-/////////////////////////////////////////////////
-// t@Càe
-
- [UÉÝè³¹éúlÈÇÉ¢ÄÍAdefine Åè`·éB
-
- Ro[gÌGETEPOSTÌoÍàeÉKvÈàÌÍ refer Æ plugin Æ¢¤lÅA
- refer : »Ìy[W̼O($vars["page"])
- plugin : vOC¼
- ƵܷB
-
- ȺÌlð global ÅO[oÏÉ·é±ÆÉæÁÄlðæ¾Å«Ü·B
-
- $script : XNvg¼
- $get : GET\bhÉæéHTTP©çÌø
- $post : POST\bhÉæéHTTP©çÌø
- $vars : GETEPOST¼ûÌ\bhÉæéHTTP©çÌø
-
- $vars["page"] : J¢Ä¢éy[W¼(strip_bracketÖÉæè[[]]ðæè¯é)
+/////////////////////////////////////////////////
+// ¥×¥é¥°¥¤¥ó¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤Ä¤¤¤Æ
+
+ PukiWiki¤Î¥Ú¡¼¥¸¤ÎHTML¤Ø¤Î¥³¥ó¥Ð¡¼¥È»þ¤È¡¢¥×¥é¥°¥¤¥óµ¡Ç½¤«¤é¤ÎÃͤò¼õ¤±¼è¤Ã¤Æ
+ ½èÍý¤ò¹Ô¤¦¥×¥é¥°¥¤¥ó¤òÀßÃÖ¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
+
+ ¤³¤Î¥Æ¥¥¹¥È¤Ï¡¢¤½¤Î¥×¥é¥°¥¤¥ó¤Îµ½ÒÊýË¡¤Ë¤Ä¤¤¤Æ¤ÎÀâÌÀ¤ò¤·¤Þ¤¹¡£
+
+
+/////////////////////////////////////////////////
+// ¥Ú¡¼¥¸Æâ¤Ç¤Î¥×¥é¥°¥¤¥ó¤Î¸Æ¤Ó½Ð¤·
+
+ #¥×¥é¥°¥¤¥ó̾
+ #¥×¥é¥°¥¤¥ó̾(arg1,arg2...)
+
+ ¹ÔƬ¤Ë¥¹¥Ú¡¼¥¹¤Ï´Þ¤á¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
+ °ú¿ôÆâ¤Ë³ç¸Ì()¤ò»ÈÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£¤¿¤À¤· ) ñÂΤÏÉԲġ£
+ °ú¿ô¤ò»ØÄꤷ¤Ê¤¯¤Æ¤â¸Æ¤Ó½Ð¤»¤ë
+
+
+/////////////////////////////////////////////////
+// ¥Õ¥¡¥¤¥ë̾
+
+ ¥×¥é¥°¥¤¥ó̾.inc.php
+
+
+/////////////////////////////////////////////////
+// ´Ø¿ô
+
+ ¢£function plugin_¥×¥é¥°¥¤¥ó̾_convert()
+
+ HTML¤Ø¤Î¥³¥ó¥Ð¡¼¥È»þ¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë
+
+ °ú¿ô¤Ï func_get_args() ¤ÇÇÛÎó¤Ø³ÊǼ¤Ç¤¤ë¡£([0]¡Á[n])
+ func_num_args() ¤Ë¤è¤Ã¤Æ¡¢ÅϤµ¤ì¤¿°ú¿ô¤Î¿ô¤òµá¤á¤ë¤³¤È¤¬¤Ç¤¤ë¡£
+
+ ¢£function plugin_¥×¥é¥°¥¤¥ó̾_action()
+
+ GET¡¦POST¥á¥½¥Ã¥É¤Çplugin¤ò»ØÄꤵ¤ì¤¿¤È¤¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë
+
+ ÊÖÃÍ¤Ë array("msg" => "$1 is page") ¤Ê¤É¤òÊÖ¤¹¤È $1 ¤ò¥Ú¡¼¥¸Ì¾¤È¤·¤Æ
+ ¥Ú¡¼¥¸¥¿¥¤¥È¥ë¤ËÃÖ´¹¤µ¤ì¤ë
+
+ die() ¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢¥Ú¡¼¥¸¤ËÌá¤é¤Ê¤¤¤è¤¦¤Ë¤Ç¤¤ë
+
+ ¢£function plugin_¥×¥é¥°¥¤¥ó̾_init()
+
+ ¥×¥é¥°¥¤¥ó¤¬Æɤ߹þ¤Þ¤ì¤ë»þ¤Ë¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£
+
+ $_plugin_recent_messages = array(
+ '_recent_plugin_li'=>'¡¦',
+ '_recent_plugin_frame '=>'ºÇ¿·¤Î%d·ï%s'
+ );
+ set_plugin_messages($_plugin_recent_messages);
+
+ ¤È¤·¤ÆÃÖ¤¯¤È¡¢*.lng¥Õ¥¡¥¤¥ë¤Ç¥Ü¥¿¥ó¤ä¥á¥Ã¥»¡¼¥¸¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Î¤ß
+ ¥á¥Ã¥»¡¼¥¸¤Ê¤É¤¬¥»¥Ã¥È¤µ¤ì¤Þ¤¹¡£
+ ÊÑ¿ô¤Ê¤É¤Î½é´ü²½¤â¹Ô¤¨¤Þ¤¹¤¬¡¢PukiWiki 1.3.1(MASUI'z Edition)°Ê¹ß¤Î¤ß
+ ͸ú¤Ç¤¹¤Î¤Ç¡¢¸Å¤¤PukiWiki¤«¤é¤Ï¸Æ¤Ð¤ì¤Ê¤¤²ÄǽÀ¤¬¤¢¤ë¤³¤È¤òµ¤¤ò¤Ä¤±¤Æ
+ ¤¯¤À¤µ¤¤¡£
+ set_plugin_messages´Ø¿ô¤âPukiWiki 1.3.1(MASUI'z Edition)°Ê¹ß¤Î¤ß¤Ç¤¹¡£
+
+
+/////////////////////////////////////////////////
+// ¥Õ¥¡¥¤¥ëÆâÍÆ
+
+ ¥æ¡¼¥¶¤ËÀßÄꤵ¤»¤ë½é´üÃͤʤɤˤĤ¤¤Æ¤Ï¡¢define ¤ÇÄêµÁ¤¹¤ë¡£
+
+ ¥³¥ó¥Ð¡¼¥È»þ¤ÎGET¡¦POST¤Î½ÐÎÏÆâÍƤËɬÍפʤâ¤Î¤Ï refer ¤È plugin ¤È¤¤¤¦Ãͤǡ¢
+ refer : ¤½¤Î¥Ú¡¼¥¸¤Î̾Á°($vars["page"])
+ plugin : ¥×¥é¥°¥¤¥ó̾
+ ¤È¤·¤Þ¤¹¡£
+
+ °Ê²¼¤ÎÃͤò global ¤Ç¥°¥í¡¼¥Ð¥ëÊÑ¿ô¤Ë¤¹¤ë¤³¤È¤Ë¤è¤Ã¤ÆÃͤò¼èÆÀ¤Ç¤¤Þ¤¹¡£
+
+ $script : ¥¹¥¯¥ê¥×¥È̾
+ $get : GET¥á¥½¥Ã¥É¤Ë¤è¤ëHTTP¤«¤é¤Î°ú¿ô
+ $post : POST¥á¥½¥Ã¥É¤Ë¤è¤ëHTTP¤«¤é¤Î°ú¿ô
+ $vars : GET¡¦POSTξÊý¤Î¥á¥½¥Ã¥É¤Ë¤è¤ëHTTP¤«¤é¤Î°ú¿ô
+
+ $vars["page"] : ³«¤¤¤Æ¤¤¤ë¥Ú¡¼¥¸Ì¾(strip_bracket´Ø¿ô¤Ë¤è¤ê[[]]¤ò¼è¤ê½ü¤±¤ë)
diff --git a/plugin/recent.inc.php b/plugin/recent.inc.php
new file mode 100644
index 0000000..0b20bd2
--- /dev/null
+++ b/plugin/recent.inc.php
@@ -0,0 +1,66 @@
+
+/*
+ * PukiWiki ºÇ¿·¤Î?·ï¤òɽ¼¨¤¹¤ë¥×¥é¥°¥¤¥ó
+ *
+ * CopyRight 2002 Y.MASUI GPL2
+ * http://masui.net/pukiwiki/ masui@masui.net
+ *
+ * Êѹ¹ÍúÎò:
+ * 2002.04.08: pat¤µ¤ó¡¢¤ß¤Î¤ë¤µ¤ó¤Î»ØŦ¤Ë¤è¤ê¡¢¥ê¥ó¥¯À褬ÆüËܸì¤Î¾ì¹ç¤Ë
+ * ²½¤±¤ë¤Î¤ò½¤Àµ
+ *
+ * 2002.06.17: plugin_recent_init()¤òÀßÄê
+ */
+
+function plugin_recent_init()
+{
+ $_plugin_recent_messages = array(
+ '_recent_plugin_li'=>'¡¦',
+ '_recent_plugin_frame '=>'ºÇ¿·¤Î%d·ï%s');
+ set_plugin_messages($_plugin_recent_messages);
+}
+
+function plugin_recent_convert()
+{
+ global $_recent_plugin_li,$_recent_plugin_frame;
+ global $WikiName,$BracketName,$script,$whatsnew;
+
+ $recent_lines = 10;
+ if(func_num_args()>0) {
+ $array = func_get_args();
+ $recent_lines = $array[0];
+ }
+
+ $lines = file(get_filename(encode($whatsnew)));
+ $date = $items = "";
+ $cnt = 0;
+ foreach($lines as $line)
+ {
+ if($cnt > $recent_lines - 1) break;
+ if(preg_match("/(($WikiName)|($BracketName))/",$line,$match))
+ {
+ $name = $match[1];
+ if($match[2])
+ {
+ $title = $match[1];
+ }
+ else
+ {
+ $title = strip_bracket($match[1]);
+ }
+ if(preg_match("/([0-9]{4}-[0-9]{2}-[0-9]{2})/",$line,$match)) {
+ if($date != $match[0]) {
+ if($date != '') {
+ $items .= " ";
+ }
+ $items .= "".$match[0]." ";
+ $date = $match[0];
+ }
+ }
+ $items .= $_recent_plugin_li."".$title." \n";
+ $cnt++;
+ }
+ }
+ return sprintf($_recent_plugin_frame,$cnt,$items);
+}
+?>
diff --git a/plugin/source.inc.php b/plugin/source.inc.php
new file mode 100644
index 0000000..989c6d0
--- /dev/null
+++ b/plugin/source.inc.php
@@ -0,0 +1,12 @@
+
+function plugin_source_action()
+{
+ global $post,$vars,$script,$InterWikiName,$WikiName,$BracketName,$defaultpage;
+
+ header("Content-type: text/plain");
+ readfile(get_filename(encode($vars["page"])));
+
+ die();
+}
+
+?>
diff --git a/plugin/update.inc.php b/plugin/update.inc.php
new file mode 100644
index 0000000..39a98ea
--- /dev/null
+++ b/plugin/update.inc.php
@@ -0,0 +1,118 @@
+
+///////////////////////
+//
+define(PLUGIN_UPDATE_SECRET,'GReenOrRed');
+
+
+function plugin_update_action()
+{
+ global $vars,$script,$do_backup,$del_backup;
+
+ $page = $vars["page"];
+
+ header("Content-type: text/plain");
+
+ // º¹Ê¬¥Õ¥¡¥¤¥ë¤ÎºîÀ®
+ if(is_page($vars["page"]))
+ $oldpostdata = join("",get_source($page));
+ else
+ $oldpostdata = "";
+
+ list($postdata,$auto) = plugin_update_diff($oldpostdata,$vars['body']);
+ $postdata = user_rules_str($postdata);
+ if($postdata == $oldpostdata) {
+ print "status noupdate\n\n";
+ die;
+ }
+
+ if($postdata)
+ $diffdata = do_diff($oldpostdata,$postdata);
+ file_write(DIFF_DIR,$page,$diffdata);
+
+ // ¥Ð¥Ã¥¯¥¢¥Ã¥×¤ÎºîÀ®
+ if(is_page($page))
+ $oldposttime = filemtime(get_filename(encode($page)));
+ else
+ $oldposttime = time();
+
+ // ÊÔ½¸ÆâÍƤ¬²¿¤â½ñ¤«¤ì¤Æ¤¤¤Ê¤¤¤È¥Ð¥Ã¥¯¥¢¥Ã¥×¤âºï½ü¤¹¤ë?¤·¤Ê¤¤¤Ç¤¹¤è¤Í¡£
+ if(!$postdata && $del_backup)
+ backup_delete(BACKUP_DIR.encode($vars["page"]).".txt");
+ else if($do_backup && is_page($vars["page"]))
+ make_backup(encode($vars["page"]).".txt",$oldpostdata,$oldposttime);
+
+ // ¥Õ¥¡¥¤¥ë¤Î½ñ¤¹þ¤ß
+ file_write(DATA_DIR,$vars["page"],$postdata);
+
+ // is_page¤Î¥¥ã¥Ã¥·¥å¤ò¥¯¥ê¥¢¤¹¤ë¡£
+ is_page($vars["page"],true);
+
+ if($auto) {
+ print "status updated\n";
+ }
+ else {
+ print "status collided\n";
+ }
+ print "\n".$postdata;
+
+ die();
+}
+
+// º¹Ê¬¤ÎºîÀ®
+function plugin_update_diff($oldstr,$newstr)
+{
+ $oldlines = split("\n",ereg_replace("[\r\n\t ]+$",'',$oldstr));
+ $newlines = split("\n",ereg_replace("[\r\n\t ]+$",'',$newstr));
+
+ if(sizeof($oldlines)==1 && $oldlines[0]=='') {
+ $oldlines = array();
+ }
+ if(sizeof($newlines)==1 && $newlines[0]=='') {
+ $newlines = array();
+ }
+
+ $retdiff = $props = array();
+ $auto = true;
+
+ foreach($newlines as $newline) {
+ $flg = false;
+ $cnt = 0;
+ foreach($oldlines as $oldline) {
+ if($oldline == $newline) {
+ if($cnt>0) {
+ for($i=0; $i<$cnt; ++$i) {
+ array_push($retdiff,array_shift($oldlines));
+ array_push($props,'! ');
+ $auto = false;
+ }
+ }
+ array_push($retdiff,array_shift($oldlines));
+ array_push($props,'');
+ $flg = true;
+ break;
+ }
+ $cnt++;
+ }
+ if(!$flg) {
+ array_push($retdiff,$newline);
+# array_push($props,'+ ');
+ array_push($props,'');
+ }
+ }
+ foreach($oldlines as $oldline) {
+ array_push($retdiff,$oldline);
+ array_push($props,'! ');
+ $auto = false;
+ }
+ if($auto) {
+ return array(join("\n",$retdiff),$auto);
+ }
+
+ $ret = '';
+ foreach($retdiff as $line) {
+ $ret .= array_shift($props) . $line . "\n";
+ }
+ return array($ret,$auto);
+}
+
+?>
diff --git a/plugin/version.inc.php b/plugin/version.inc.php
index 6d73b76..65102d1 100644
--- a/plugin/version.inc.php
+++ b/plugin/version.inc.php
@@ -1,6 +1,6 @@
-
-function plugin_version_convert()
-{
- return "".S_VERSION."";
-}
-?>
+
+function plugin_version_convert()
+{
+ return "".S_VERSION."";
+}
+?>
diff --git a/plugin/vote.inc.php b/plugin/vote.inc.php
new file mode 100644
index 0000000..a1fe4a7
--- /dev/null
+++ b/plugin/vote.inc.php
@@ -0,0 +1,150 @@
+
+
+function plugin_vote_action()
+{
+ global $post,$vars,$script,$cols,$rows,$del_backup,$do_backup;
+ global $_title_collided,$_msg_collided,$_title_updated;
+
+ $postdata_old = file(get_filename(encode($post["refer"])));
+ $vote_no = 0;
+
+ foreach($postdata_old as $line)
+ {
+ if(preg_match("/^#vote\((.*)\)$/",$line,$arg))
+ {
+ if($vote_no == $post["vote_no"])
+ {
+ $args = explode(",",$arg[1]);
+
+ foreach($args as $arg)
+ {
+ if(preg_match("/^(.+)\[(\d+)\]$/",$arg,$match))
+ {
+ $arg = $match[1];
+ $cnt = $match[2];
+ }
+ else
+ {
+ $cnt = 0;
+ }
+
+ if($post["vote"][preg_replace("/\]\]$/","",$arg)]) $cnt++;
+
+ $votes[] = $arg.'['.$cnt.']';
+ }
+
+ $vote_str = "#vote(" . @join(",",$votes) . ")\n";
+
+ $postdata_input = $vote_str;
+ $postdata .= $vote_str;
+ $line = "";
+ }
+ $vote_no++;
+ }
+ $postdata .= $line;
+ }
+
+ if(md5(@join("",@file(get_filename(encode($post["refer"]))))) != $post["digest"])
+ {
+ $title = $_title_collided;
+
+ $body = "$_msg_collided\n";
+
+ $body .= "\n";
+ }
+ else
+ {
+ // ?¡¦?a?t?@?C???I?i?¢Ì
+ if(is_page($post["refer"]))
+ $oldpostdata = join("",file(get_filename(encode($post["refer"]))));
+ else
+ $oldpostdata = "\n";
+ if($postdata)
+ $diffdata = do_diff($oldpostdata,$postdata);
+ file_write(DIFF_DIR,$post["refer"],$diffdata);
+
+ // ?o?b?N?A?b?v?I?i?¢Ì
+ if(is_page($post["refer"]))
+ $oldposttime = filemtime(get_filename(encode($post["refer"])));
+ else
+ $oldposttime = time();
+
+ // ?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
+ if(!$postdata && $del_backup)
+ backup_delete(BACKUP_DIR.encode($post["refer"]).".txt");
+ else if($do_backup && is_page($post["refer"]))
+ make_backup(encode($post["refer"]).".txt",$oldpostdata,$oldposttime);
+
+ // ?t?@?C???I?¡Æ?¢ã???Y
+ file_write(DATA_DIR,$post["refer"],$postdata);
+
+ // is_page?I?L???b?V?¡Ä?d?N???A?¡¦?e?B
+ is_page($post["refer"],true);
+
+ $title = $_title_updated;
+ }
+
+ $retvars["msg"] = $title;
+ $retvars["body"] = $body;
+
+ $post["page"] = $post["refer"];
+ $vars["page"] = $post["refer"];
+
+ return $retvars;
+}
+function plugin_vote_convert()
+{
+ global $script,$vars,$vote_no,$digest;
+
+ $args = func_get_args();
+
+ if(!func_num_args()) return FALSE;
+
+ $string = "\n";
+
+ $vote_no++;
+
+ return $string;
+}
+?>
+
diff --git a/pukiwiki.ini.php b/pukiwiki.ini.php
index 3071cd8..3091708 100644
--- a/pukiwiki.ini.php
+++ b/pukiwiki.ini.php
@@ -1,5 +1,9 @@
/////////////////////////////////////////////////
+// PukiWiki - Yet another WikiWikiWeb clone.
+//
+// $Id: pukiwiki.ini.php,v 1.2 2002/06/21 05:21:46 masui Exp $
+//
// PukiWiki setting file
/////////////////////////////////////////////////
@@ -19,7 +23,7 @@ define("PLUGIN_DIR","./plugin/");
/////////////////////////////////////////////////
// ¥¹¥¥ó¥Õ¥¡¥¤¥ë¤Î¾ì½ê¡£
-define("SKIN_FILE","./pukiwiki.skin.ja.php");
+define("SKIN_FILE","./skin/pukiwiki.skin.ja.php");
/////////////////////////////////////////////////
// Language
@@ -154,11 +158,19 @@ $splitter = ">>>>>>>>>>";
/////////////////////////////////////////////////
// °ìÍ÷¡¦¹¹¿·°ìÍ÷¤Ë´Þ¤á¤Ê¤¤¥Ú¡¼¥¸Ì¾(Àµµ¬É½¸½¤Ç)
$non_list = "^(\[\[\:)";
+
/////////////////////////////////////////////////
// ¿÷·Á¤È¤¹¤ë¥Ú¡¼¥¸¤ÎÆɤ߹þ¤ß¤òɽ¼¨¤µ¤»¤ë¤«
$load_template_func = 1;
/////////////////////////////////////////////////
+// ¥Ú¡¼¥¸Ì¾¤Ë½¾¤Ã¤Æ¼«Æ°¤Ç¡¢¿÷·Á¤È¤¹¤ë¥Ú¡¼¥¸¤ÎÆɤ߹þ¤ß
+$auto_template_func = 1;
+$auto_template_rules = array(
+'\[\[((.+)\/([^\/]+))\]\]' => '[[\2/template]]'
+);
+
+/////////////////////////////////////////////////
// ¥æ¡¼¥¶ÄêµÁ¥ë¡¼¥ë
//
// Àµµ¬É½¸½¤Çµ½Ò¤·¤Æ¤¯¤À¤µ¤¤¡£?(){}-*./+\$^|¤Ê¤É
@@ -173,6 +185,7 @@ $str_rules = array(
"date\?" => date($date_format,UTIME),
"time\?" => date($time_format,UTIME),
);
+
/////////////////////////////////////////////////
// ¥æ¡¼¥¶ÄêµÁ¥ë¡¼¥ë(¥³¥ó¥Ð¡¼¥È»þ¤ËÃÖ´¹¡¢Ä¾Àܤ·¤Ê¤¤)
$line_rules = array(
@@ -369,4 +382,4 @@ now?
';
-?>
\ No newline at end of file
+?>
diff --git a/pukiwiki.php b/pukiwiki.php
index aaa6ee8..7d8ad50 100644
--- a/pukiwiki.php
+++ b/pukiwiki.php
@@ -1,2400 +1,732 @@
-
-// pukiwiki.php - Yet another WikiWikiWeb clone.
-//
-// Copyright (C) 2001,2002 by sng.
-//
-// http://factage.com/sng/pukiwiki/
-//
-// Special thanks
-// YukiWiki by Hiroshi Yuki
-//
-// http://www.hyuki.com/yukiwiki/
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-//# $Id: pukiwiki.php,v 1.1 2002/06/20 13:59:31 masui Exp $
-/////////////////////////////////////////////////
-
-/////////////////////////////////////////////////
-// ÀßÄê¥Õ¥¡¥¤¥ë¤Î¾ì½ê
-define("INI_FILE","./pukiwiki.ini.php");
-
-//** ½é´üÀßÄê **
-
-define("S_VERSION","1.3");
-define("UTIME",time());
-define("HTTP_USER_AGENT",$HTTP_SERVER_VARS["HTTP_USER_AGENT"]);
-define("PHP_SELF",$HTTP_SERVER_VARS["PHP_SELF"]);
-define("SERVER_NAME",$HTTP_SERVER_VARS["SERVER_NAME"]);
-
-define("MUTIME",getmicrotime());
-
-$script = basename($PHP_SELF);
-
-$WikiName = '([A-Z][a-z]+([A-Z][a-z]+)+)';
-$BracketName = '\[\[(\[*[^\s\]]+?\]*)\]\]';
-$InterWikiName = '\[\[(\[*[^\s\]]+?\]*):(\[*[^>\]]+?\]*)\]\]';
-
-//** ÆþÎÏÃͤÎÀ°·Á **
-
-$post = $HTTP_POST_VARS;
-$get = $HTTP_GET_VARS;
-
-if($get["page"]) $get["page"] = rawurldecode($get["page"]);
-if($post["word"]) $post["word"] = rawurldecode($post["word"]);
-if($get["word"]) $get["word"] = rawurldecode($get["word"]);
-if(get_magic_quotes_gpc())
-{
- if($get["page"]) $get["page"] = stripslashes($get["page"]);
- if($post["page"]) $post["page"] = stripslashes($post["page"]);
- if($get["word"]) $get["word"] = stripslashes($get["word"]);
- if($post["word"]) $post["word"] = stripslashes($post["word"]);
- if($post["msg"]) $post["msg"] = stripslashes($post["msg"]);
-}
-if($post["msg"])
-{
- $post["msg"] = preg_replace("/<\/(textarea[^>]*)>/i", "</$1>", $post["msg"]);
- $post["msg"] = preg_replace("/(\x0D\x0A)/","\n",$post["msg"]);
- $post["msg"] = preg_replace("/(\x0D)/","\n",$post["msg"]);
- $post["msg"] = preg_replace("/(\x0A)/","\n",$post["msg"]);
-}
-
-$vars = array_merge($post,$get);
-$arg = rawurldecode($HTTP_SERVER_VARS["argv"][0]);
-
-//** ½é´ü½èÍý **
-
-$update_exec = "";
-
-// ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɹþ
-@require(INI_FILE);
-@require(LANG.".lng");
-
-// ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÊÑ¿ô¥Á¥§¥Ã¥¯
-$wrong_ini_file = "";
-if(!isset($rss_max)) $wrong_ini_file .= '$rss_max ';
-if(!isset($page_title)) $wrong_ini_file .= '$page_title ';
-if(!isset($note_hr)) $wrong_ini_file .= '$note_hr ';
-if(!isset($related_link)) $wrong_ini_file .= '$related_link ';
-if(!isset($show_passage)) $wrong_ini_file .= '$show_passage ';
-if(!isset($rule_related_str)) $wrong_ini_file .= '$rule_related_str ';
-if(!isset($load_template_func)) $wrong_ini_file .= '$load_template_func ';
-if(!defined("LANG")) $wrong_ini_file .= 'LANG ';
-if(!defined("PLUGIN_DIR")) $wrong_ini_file .= 'PLUGIN_DIR ';
-
-if(!is_writable(DATA_DIR))
- die_message("DATA_DIR is not found or not writable.");
-if(!is_writable(DIFF_DIR))
- die_message("DIFF_DIR is not found or not writable.");
-if($do_backup && !is_writable(BACKUP_DIR))
- die_message("BACKUP_DIR is not found or not writable.");
-if(!file_exists(INI_FILE))
- die_message("INI_FILE is not found.");
-if($wrong_ini_file)
- die_message("The setting file runs short of information. The version of a setting file may be old.
These option are not found : $wrong_ini_file");
-//if(ini_get("register_globals") !== "0")
-// die_message("Wrong PHP4 setting in 'register_globals',set value 'Off' to httpd.conf or .htaccess.");
-if(!file_exists(SKIN_FILE))
- die_message("SKIN_FILE is not found.");
-if(!file_exists(LANG.".lng"))
- die_message(LANG.".lng(language file) is not found.");
-
-if(!file_exists(get_filename(encode($defaultpage))))
- touch(get_filename(encode($defaultpage)));
-if(!file_exists(get_filename(encode($whatsnew))))
- touch(get_filename(encode($whatsnew)));
-if(!file_exists(get_filename(encode($interwiki))))
- touch(get_filename(encode($interwiki)));
-
-$ins_date = date($date_format,UTIME);
-$ins_time = date($time_format,UTIME);
-$ins_week = "(".$weeklabels[date("w",UTIME)].")";
-
-$now = "$ins_date $ins_week $ins_time";
-
-// ** ¥á¥¤¥ó½èÍý **
-
-// Plug-in hook
-if(isset($vars["plugin"]))
-{
- if(!file_exists(PLUGIN_DIR.$vars["plugin"].".inc.php"))
- {
- $vars["plugin"] = "";
- }
- else
- {
- require_once(PLUGIN_DIR.$vars["plugin"].".inc.php");
- if(!function_exists("plugin_".$vars["plugin"]."_action"))
- {
- $vars["plugin"] = "";
- }
- }
-}
-
-
-// Plug-in action
-if(!empty($vars["plugin"]))
-{
- $retvars = @call_user_func("plugin_".$vars["plugin"]."_action");
-
- $title = strip_bracket($vars["refer"]);
- $page = make_search($vars["refer"]);
-
- if($retvars["msg"])
- {
- $title = str_replace("$1",$title,$retvars["msg"]);
- $page = str_replace("$1",$page,$retvars["msg"]);
- }
-
- if(!empty($retvars["body"]))
- {
- $body = $retvars["body"];
- }
- else
- {
- $cmd = "read";
- $vars["page"] = $vars["refer"];
- $body = @join("",@file(get_filename(encode($vars["refer"]))));
- $body = convert_html($body);
- }
-}
-// °ìÍ÷¤Îɽ¼¨
-else if(arg_check("list"))
-{
- header_lastmod($whatsnew);
-
- $page = $title = $_title_list;
- $body = "\n" . get_list(false) . " \n";
-}
-// ¥Õ¥¡¥¤¥ë̾°ìÍ÷¤Îɽ¼¨
-else if(arg_check("filelist"))
-{
- header_lastmod($whatsnew);
-
- $page = $title = $_title_filelist;
- $body = "\n";
-}
-// ÊÔ½¸ÉÔ²Äǽ¤Ê¥Ú¡¼¥¸¤òÊÔ½¸¤·¤è¤¦¤È¤·¤¿¤È¤
-else if(((arg_check("add") || arg_check("edit") || arg_check("preview")) && (is_freeze($vars["page"]) || !is_editable($vars["page"]) || $vars["page"] == "")))
-{
- $body = $title = str_replace('$1',strip_bracket($vars["page"]),$_title_cannotedit);
- $page = str_replace('$1',make_search($vars["page"]),$_title_cannotedit);
-
- if(is_freeze($vars["page"]))
- $body .= "($_msg_unfreeze)";
-}
-// ÄɲÃ
-else if(arg_check("add"))
-{
- $title = str_replace('$1',strip_bracket($get["page"]),$_title_add);
- $page = str_replace('$1',make_search($get["page"]),$_title_add);
- $body = "\n";
- $body .= "- $_msg_add
\n";
- $body .= " \n";
- $body .= edit_form("",$get["page"],true);
-}
-// ÊÔ½¸
-else if(arg_check("edit"))
-{
- $postdata = @join("",@file(get_filename(encode($get["page"]))));
-
- $title = str_replace('$1',strip_bracket($get["page"]),$_title_edit);
- $page = str_replace('$1',make_search($get["page"]),$_title_edit);
- $body = edit_form($postdata,$get["page"]);
-}
-// ¥×¥ì¥Ó¥å¡¼
-else if(arg_check("preview") || $post["preview"] || $post["template"])
-{
- if($post["template"] && file_exists(get_filename(encode($post["template_page"]))))
- {
- $post["msg"] = @join("",@file(get_filename(encode($post["template_page"]))));
- }
-
- $post["msg"] = preg_replace("/^#freeze\n/","",$post["msg"]);
- $postdata_input = $post["msg"];
-
- if($post["add"])
- {
- if($post["add_top"])
- {
- $postdata = $post["msg"];
- $postdata .= "\n\n";
- $postdata .= @join("",@file(get_filename(encode($post["page"]))));
- }
- else
- {
- $postdata = @join("",@file(get_filename(encode($post["page"]))));
- $postdata .= "\n\n";
- $postdata .= $post["msg"];
- }
- }
- else
- {
- $postdata = $post["msg"];
- }
-
- $title = str_replace('$1',strip_bracket($post["page"]),$_title_preview);
- $page = str_replace('$1',make_search($post["page"]),$_title_preview);
-
- $body = "$_msg_preview \n";
- if($postdata == "") $body .= "$_msg_preview_delete \n";
- else $body .= " \n";
-
- if($postdata != "")
- {
- $postdata = convert_html($postdata);
-
- $body .= "\n"
- ."\n"
- .$postdata
- ."\n | \n"
- ." \n";
- }
-
- if($post["add"])
- {
- if($post["add_top"]) $checked_top = " checked";
- $addtag = '';
- $add_top = '¥Ú¡¼¥¸¤Î¾å¤ËÄɲÃ';
- }
- if($post["notimestamp"]) $checked_time = "checked";
-
- $body .= "\n";
-}
-// ½ñ¤¹þ¤ß¤â¤·¤¯¤ÏÄɲä⤷¤¯¤Ï¥³¥á¥ó¥È¤ÎÁÞÆþ
-else if($post["write"])
-{
- $post["msg"] = preg_replace("/^#freeze\n/","",$post["msg"]);
- $postdata_input = $post["msg"];
-
- if($post["add"])
- {
- if($post["add_top"])
- {
- $postdata = $post["msg"];
- $postdata .= "\n\n";
- $postdata .= @join("",@file(get_filename(encode($post["page"]))));
- }
- else
- {
- $postdata = @join("",@file(get_filename(encode($post["page"]))));
- $postdata .= "\n\n";
- $postdata .= $post["msg"];
- }
- }
- else
- {
- $postdata = $post["msg"];
- }
-
- if(md5(@join("",@file(get_filename(encode($post["page"]))))) != $post["digest"])
- {
- $title = str_replace('$1',strip_bracket($post["page"]),$_title_collided);
- $page = str_replace('$1',make_search($post["page"]),$_title_collided);
-
- $body .= "$_msg_collided\n";
-
- $body .= "\n";
- }
- else
- {
- $postdata = user_rules_str($postdata);
-
- // º¹Ê¬¥Õ¥¡¥¤¥ë¤ÎºîÀ®
- if(is_page($post["page"]))
- $oldpostdata = join("",file(get_filename(encode($post["page"]))));
- else
- $oldpostdata = "\n";
- if($postdata)
- $diffdata = do_diff($oldpostdata,$postdata);
- file_write(DIFF_DIR,$post["page"],$diffdata);
-
- // ¥Ð¥Ã¥¯¥¢¥Ã¥×¤ÎºîÀ®
- if(is_page($post["page"]))
- $oldposttime = filemtime(get_filename(encode($post["page"])));
- else
- $oldposttime = time();
-
- // ÊÔ½¸ÆâÍƤ¬²¿¤â½ñ¤«¤ì¤Æ¤¤¤Ê¤¤¤È¥Ð¥Ã¥¯¥¢¥Ã¥×¤âºï½ü¤¹¤ë?¤·¤Ê¤¤¤Ç¤¹¤è¤Í¡£
- if(!$postdata && $del_backup)
- backup_delete(BACKUP_DIR.encode($post["page"]).".txt");
- else if($do_backup && is_page($post["page"]))
- make_backup(encode($post["page"]).".txt",$oldpostdata,$oldposttime);
-
- // ¥Õ¥¡¥¤¥ë¤Î½ñ¤¹þ¤ß
- file_write(DATA_DIR,$post["page"],$postdata);
-
- // is_page¤Î¥¥ã¥Ã¥·¥å¤ò¥¯¥ê¥¢¤¹¤ë¡£
- is_page($post["page"],true);
-
- if($postdata)
- {
- $title = str_replace('$1',strip_bracket($post["page"]),$_title_updated);
- $page = str_replace('$1',make_search($post["page"]),$_title_updated);
- $body = convert_html($postdata);
- }
- else
- {
- $title = str_replace('$1',strip_bracket($post["page"]),$_title_deleted);
- $page = str_replace('$1',make_search($post["page"]),$_title_deleted);
- $body = str_replace('$1',strip_bracket($post["page"]),$_title_deleted);
- }
- }
-}
-// Åà·ë
-else if(arg_check("freeze") && $vars["page"] && $function_freeze)
-{
- if(is_freeze($vars["page"]))
- {
- $title = str_replace('$1',strip_bracket($vars["page"]),$_title_isfreezed);
- $page = str_replace('$1',make_search($vars["page"]),$_title_isfreezed);
- $body = str_replace('$1',strip_bracket($vars["page"]),$_title_isfreezed);
- }
- else if(md5($post["pass"]) == $adminpass)
- {
- $postdata = file(get_filename(encode($post["page"])));
- $postdata = join("",$postdata);
- $postdata = "#freeze\n".$postdata;
-
- file_write(DATA_DIR,$vars["page"],$postdata);
-
- $title = str_replace('$1',strip_bracket($vars["page"]),$_title_freezed);
- $page = str_replace('$1',make_search($vars["page"]),$_title_freezed);
- $postdata = join("",file(get_filename(encode($vars["page"]))));
- $postdata = convert_html($postdata);
-
- $body = $postdata;
- }
- else
- {
- $title = str_replace('$1',strip_bracket($vars["page"]),$_title_freeze);
- $page = str_replace('$1',make_search($vars["page"]),$_title_freeze);
-
- $body.= " \n";
-
- if($post["pass"])
- $body .= "$_msg_invalidpass \n";
- else
- $body.= "$_msg_freezing \n";
-
- $body.= "\n";
- }
-}
-//Åà·ë¤Î²ò½ü
-else if(arg_check("unfreeze") && $vars["page"] && $function_freeze)
-{
- if(!is_freeze($vars["page"]))
- {
- $title = str_replace('$1',strip_bracket($vars["page"]),$_title_isunfreezed);
- $page = str_replace('$1',make_search($vars["page"]),$_title_isunfreezed);
- $body = str_replace('$1',strip_bracket($vars["page"]),$_title_isunfreezed);
- }
- else if(md5($post["pass"]) == $adminpass)
- {
- $postdata = file(get_filename(encode($post["page"])));
- array_shift($postdata);
- $postdata = join("",$postdata);
-
- file_write(DATA_DIR,$vars["page"],$postdata);
-
- $title = str_replace('$1',strip_bracket($vars["page"]),$_title_unfreezed);
- $page = str_replace('$1',make_search($vars["page"]),$_title_unfreezed);
-
- $postdata = join("",file(get_filename(encode($vars["page"]))));
- $postdata = convert_html($postdata);
-
- $body = $postdata;
- }
- else
- {
- $title = str_replace('$1',strip_bracket($vars["page"]),$_title_unfreeze);
- $page = str_replace('$1',make_search($vars["page"]),$_title_unfreeze);
-
- $body.= " \n";
-
- if($post["pass"])
- $body .= "$_msg_invalidpass \n";
- else
- $body.= "$_msg_unfreezing \n";
-
- $body.= "\n";
- }
-}
-// º¹Ê¬¤Îɽ¼¨
-else if(arg_check("diff"))
-{
- $pagename = strip_bracket($get["page"]);
- if(!is_page($get["page"]))
- {
- $title = $pagename;
- $page = make_search($vars["page"]);
- $body = "»ØÄꤵ¤ì¤¿¥Ú¡¼¥¸¤Ï¸«¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£";
- }
- else
- {
- $link = str_replace('$1',"$pagename",$_msg_goto);
-
- $body = "\n"
- ."- $_msg_addline
\n"
- ."- $_msg_delline
\n"
- ."- $link
\n"
- ." \n"
- ."$hr\n";
- }
-
- if(!file_exists(DIFF_DIR.encode($get["page"]).".txt") && is_page($get["page"]))
- {
- $title = str_replace('$1',strip_bracket($get["page"]),$_title_diff);
- $page = str_replace('$1',make_search($get["page"]),$_title_diff);
-
- $diffdata = file(get_filename(encode($get["page"])));
- $body .= "\n"
- ."\n"
- .join("",$diffdata)
- ."\n"
- ." \n"
- ."\n";
- }
- else if(file_exists(DIFF_DIR.encode($get["page"]).".txt"))
- {
- $title = str_replace('$1',strip_bracket($get["page"]),$_title_diff);
- $page = str_replace('$1',make_search($get["page"]),$_title_diff);
-
- $diffdata = file(DIFF_DIR.encode($get["page"]).".txt");
- $diffdata = preg_replace("/","<",$diffdata);
- $diffdata = preg_replace("/>/",">",$diffdata);
- $diffdata = preg_replace("/^(\-)(.*)/"," $2",$diffdata);
- $diffdata = preg_replace("/^(\+)(.*)/"," $2",$diffdata);
-
- $body .= "\n"
- .join("",$diffdata)
- ."\n"
- ." \n";
- }
-}
-// ¸¡º÷
-else if(arg_check("search"))
-{
- if($vars["word"])
- {
- $title = $page = str_replace('$1',$vars["word"],$_title_result);
- }
- else
- {
- $page = $title = $_title_search;
- }
-
- if($vars["word"])
- $body = do_search($vars["word"],$vars["type"]);
- else
- $body = " \n$_msg_searching";
-
- if($vars["type"]=="AND" || !$vars["type"]) $and_check = "checked";
- else if($vars["type"]=="OR") $or_check = "checked";
-
- $body .= "\n";
-}
-// ¥Ð¥Ã¥¯¥¢¥Ã¥×
-else if($do_backup && arg_check("backup"))
-{
- if($get["page"] && $get["age"] && (file_exists(BACKUP_DIR.encode($get["page"]).".txt") || file_exists(BACKUP_DIR.encode($get["page"]).".gz")))
- {
- $pagename = strip_bracket($get["page"]);
- $body = "\n";
-
- $body .= "- $_msg_backuplist
\n";
-
- if(!arg_check("backup_diff") && is_page($get["page"]))
- {
- $link = str_replace('$1',"$_msg_diff",$_msg_view);
- $body .= "- $link
\n";
- }
- if(!arg_check("backup_nowdiff") && is_page($get["page"]))
- {
- $link = str_replace('$1',"$_msg_nowdiff",$_msg_view);
- $body .= "- $link
\n";
- }
- if(!arg_check("backup_source"))
- {
- $link = str_replace('$1',"$_msg_source",$_msg_view);
- $body .= "- $link
\n";
- }
- if(arg_check("backup_diff") || arg_check("backup_source") || arg_check("backup_nowdiff"))
- {
- $link = str_replace('$1',"$_msg_backup",$_msg_view);
- $body .= "- $link
\n";
- }
-
- if(is_page($get["page"]))
- {
- $link = str_replace('$1',"$pagename",$_msg_goto);
- $body .= "- $link
\n";
- }
- else
- {
- $link = str_replace('$1',$pagename,$_msg_deleleted);
- $body .= "- $link
\n";
- }
-
- $backups = array();
- $backups = get_backup_info(encode($get["page"]).".txt");
- if(count($backups)) $body .= "\n";
- foreach($backups as $key => $val)
- {
- $ins_date = date($date_format,$val);
- $ins_time = date($time_format,$val);
- $ins_week = "(".$weeklabels[date("w",$val)].")";
- $backupdate = "($ins_date $ins_week $ins_time)";
- if($key != $get["age"])
- $body .= "- $key $backupdate
\n";
- else
- $body .= "- $key $backupdate
\n";
- }
- if(count($backups)) $body .= " \n";
-
- if(arg_check("backup_diff"))
- {
- $title = str_replace('$1',$pagename,$_title_backupdiff)."(No.$get[age])";
- $page = str_replace('$1',make_search($get["page"]),$_title_backupdiff)."(No.$get[age])";
-
- $backupdata = @join("",get_backup($get[age]-1,encode($get["page"]).".txt"));
- $postdata = @join("",get_backup($get[age],encode($get["page"]).".txt"));
- $diffdata = split("\n",do_diff($backupdata,$postdata));
- }
- else if(arg_check("backup_nowdiff"))
- {
- $title = str_replace('$1',$pagename,$_title_backupnowdiff)."(No.$get[age])";
- $page = str_replace('$1',make_search($get["page"]),$_title_backupnowdiff)."(No.$get[age])";
-
- $backupdata = @join("",get_backup($get[age],encode($get["page"]).".txt"));
- $postdata = @join("",@file(get_filename(encode($get["page"]))));
- $diffdata = split("\n",do_diff($backupdata,$postdata));
- }
- else if(arg_check("backup_source"))
- {
- $title = str_replace('$1',$pagename,$_title_backupsource)."(No.$get[age])";
- $page = str_replace('$1',make_search($get["page"]),$_title_backupsource)."(No.$get[age])";
- $backupdata = join("",get_backup($get[age],encode($get["page"]).".txt"));
-
- $body.=" \n\n$backupdata \n";
- }
- else
- {
- $pagename = strip_bracket($get["page"]);
- $title = str_replace('$1',$pagename,$_title_backup)."(No.$get[age])";
- $page = str_replace('$1',make_search($get["page"]),$_title_backup)."(No.$get[age])";
- $backupdata = join("",get_backup($get[age],encode($get["page"]).".txt"));
- $backupdata = convert_html($backupdata);
- $body .= "\n"
- ."$hr\n";
- $body .= $backupdata;
- }
-
- if(arg_check("backup_diff") || arg_check("backup_nowdiff"))
- {
- $diffdata = preg_replace("/","<",$diffdata);
- $diffdata = preg_replace("/>/",">",$diffdata);
- $diffdata = preg_replace("/^(\-)(.*)/"," $2",$diffdata);
- $diffdata = preg_replace("/^(\+)(.*)/"," $2",$diffdata);
-
- $body .= " \n"
- ."$_msg_addline\n"
- ."$_msg_delline\n"
- ."\n"
- ."$hr\n"
- ."\n".join("\n",$diffdata)." \n";
- }
- }
- else if($get["page"] && (file_exists(BACKUP_DIR.encode($get["page"]).".txt") || file_exists(BACKUP_DIR.encode($get["page"]).".gz")))
- {
- $title = str_replace('$1',strip_bracket($get["page"]),$_title_pagebackuplist);
- $page = str_replace('$1',make_search($get["page"]),$_title_pagebackuplist);
- $body = get_backup_list($get["page"]);
- }
- else
- {
- $page = $title = $_title_backuplist;
- $body = get_backup_list();
- }
-}
-// ¥Ø¥ë¥×¤Îɽ¼¨
-else if(arg_check("help"))
-{
- $title = $page = "¥Ø¥ë¥×";
- $body = catrule();
-}
-// MD5¥Ñ¥¹¥ï¡¼¥É¤Ø¤ÎÊÑ´¹
-else if($vars["md5"])
-{
- $title = $page = "Make password of MD5";
- $body = "$vars[md5] : ".md5($vars["md5"]);
-}
-else if(arg_check("rss"))
-{
- if(!arg_check("rss10"))
- catrss(1);
- else
- catrss(2);
- die();
-}
-// ¥Ú¡¼¥¸¤Îɽ¼¨¤ÈInterWikiName¤Î²ò¼á
-else if((arg_check("read") && $vars["page"] != "") || (!arg_check("read") && $arg != "" && $vars["page"] == ""))
-{
- // ¥¢¥¯¥·¥ç¥ó¤òÌÀ¼¨Åª¤Ë»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¥Ú¡¼¥¸Ì¾¤È¤·¤Æ²ò¼á
- if($arg != "" && $vars["page"] == "" && $vars["cmd"] == "")
- {
- $post["page"] = $arg;
- $get["page"] = $arg;
- $vars["page"] = $arg;
- }
-
- // ¥Ú¡¼¥¸Ì¾¤¬WikiName¤Ç¤Ê¤¯¡¢BracketName¤Ç¤Ê¤±¤ì¤ÐBracketName¤È¤·¤Æ²ò¼á
- if(!preg_match("/^(($WikiName)|($BracketName)|($InterWikiName))$/",$get["page"]))
- {
- $vars["page"] = "[[$vars[page]]]";
- $get["page"] = $vars["page"];
- }
-
- // WikiName¡¢BracketName¤¬¼¨¤¹¥Ú¡¼¥¸¤òɽ¼¨
- if(is_page($get["page"]))
- {
- $postdata = join("",file(get_filename(encode($get["page"]))));
- $postdata = convert_html($postdata);
-
- $title = strip_bracket($get["page"]);
- $page = make_search($get["page"]);
- $body = $postdata;
-
- header_lastmod($vars["page"]);
- }
- else if(preg_match("/($InterWikiName)/",$get["page"],$match))
- {
- // InterWikiName¤ÎȽÊ̤ȥڡ¼¥¸¤Îɽ¼¨
- $interwikis = open_interwikiname_list();
-
- if(!$interwikis[$match[2]]["url"])
- {
- $title = $page = $_title_invalidiwn;
- $body = str_replace('$1',strip_bracket($get[page]),str_replace('$2',"InterWikiName",$_msg_invalidiwn));
- }
- else
- {
- // ʸ»ú¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
- if($interwikis[$match[2]]["opt"] == "yw")
- {
- // YukiWiki·Ï
- if(!preg_match("/$WikiName/",$match[3]))
- $match[3] = "[[".mb_convert_encoding($match[3],"SJIS","auto")."]]";
- }
- else if($interwikis[$match[2]]["opt"] == "moin")
- {
- // moin·Ï
- if(function_exists("mb_convert_encoding"))
- {
- $match[3] = rawurlencode(mb_convert_encoding($match[3],"EUC-JP","auto"));
- $match[3] = str_replace("%","_",$match[3]);
- }
- else
- $not_mb = 1;
- }
- else if($interwikis[$match[2]]["opt"] == "" || $interwikis[$match[2]]["opt"] == "std")
- {
- // ÆâÉôʸ»ú¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Î¤Þ¤ÞURL¥¨¥ó¥³¡¼¥É
- $match[3] = rawurlencode($match[3]);
- }
- else if($interwikis[$match[2]]["opt"] == "asis" || $interwikis[$match[2]]["opt"] == "raw")
- {
- // URL¥¨¥ó¥³¡¼¥É¤·¤Ê¤¤
- $match[3] = $match[3];
- }
- else if($interwikis[$match[2]]["opt"] != "")
- {
- // ¥¨¥¤¥ê¥¢¥¹¤ÎÊÑ´¹
- if($interwikis[$match[2]]["opt"] == "sjis")
- $interwikis[$match[2]]["opt"] = "SJIS";
- else if($interwikis[$match[2]]["opt"] == "euc")
- $interwikis[$match[2]]["opt"] = "EUC-JP";
- else if($interwikis[$match[2]]["opt"] == "utf8")
- $interwikis[$match[2]]["opt"] = "UTF-8";
-
- // ¤½¤Î¾¡¢»ØÄꤵ¤ì¤¿Ê¸»ú¥³¡¼¥É¤Ø¥¨¥ó¥³¡¼¥É¤·¤ÆURL¥¨¥ó¥³¡¼¥É
- if(function_exists("mb_convert_encoding"))
- $match[3] = rawurlencode(mb_convert_encoding($match[3],$interwikis[$match[2]]["opt"],"auto"));
- else
- $not_mb = 1;
- }
-
- if(strpos($interwikis[$match[2]]["url"],'$1') !== FALSE)
- $url = str_replace('$1',$match[3],$interwikis[$match[2]]["url"]);
- else
- $url = $interwikis[$match[2]]["url"] . $match[3];
-
- if($not_mb)
- {
- $title = $page = "Not support mb_jstring.";
- $body = "This server's PHP does not have \"mb_jstring\" module.Cannot convert encoding.";
- }
- else
- {
- header("Location: $url");
- die();
- }
- }
- }
- // WikiName¡¢BracketName¤¬¸«¤Ä¤«¤é¤º¡¢InterWikiName¤Ç¤â¤Ê¤¤¾ì¹ç
- else
- {
- //$title = strip_bracket($get["page"]);
- //$page = make_search($get["page"]);
- //$body = "»ØÄꤵ¤ì¤¿¥Ú¡¼¥¸¤Ï¸«¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£";
-
- $title = str_replace('$1',strip_bracket($get["page"]),$_title_edit);
- $page = str_replace('$1',make_search($get["page"]),$_title_edit);
- $body = edit_form("",$get["page"]);
- }
-}
-// ²¿¤â»ØÄꤵ¤ì¤Ê¤¤¾ì¹ç¡¢¥È¥Ã¥×¥Ú¡¼¥¸¤òɽ¼¨
-else
-{
- $postdata = join("",file(get_filename(encode($defaultpage))));
-
- $vars["page"] = $defaultpage;
- $title = strip_bracket($defaultpage);
- $page = make_search($vars["page"]);
- $body = convert_html($postdata);
-
- header_lastmod($vars["page"]);
-}
-
-// ** ½ÐÎϽèÍý **
-
-catbody($title,$page,$body);
-
-// ** ³Æ¼ï´Ø¿ô **
-
-// ËÜʸ¤ò¥Ú¡¼¥¸Ì¾¤«¤é½ÐÎÏ
-function catbodyall($page,$title="",$pg="")
-{
- if($title === "") $title = strip_bracket($page);
- if($pg === "") $pg = make_search($page);
-
- $body = join("",file(get_filename(encode($page))));
- $body = convert_html($body);
-
- header_lastmod($vars["page"]);
- catbody($title,$pg,$body);
- die();
-}
-
-// ËÜʸ¤ò½ÐÎÏ
-function catbody($title,$page,$body)
-{
- global $script,$vars,$arg,$do_backup,$modifier,$modifierlink,$defaultpage,$whatsnew,$hr;
- global $date_format,$weeklabels,$time_format,$longtaketime,$related_link;
- global $HTTP_SERVER_VARS,$cantedit;
-
- if($vars["page"] && !arg_check("backup") && $vars["page"] != $whatsnew)
- {
- $is_page = 1;
- }
-
- $link_add = "$script?cmd=add&page=".rawurlencode($vars["page"]);
- $link_edit = "$script?cmd=edit&page=".rawurlencode($vars["page"]);
- $link_diff = "$script?cmd=diff&page=".rawurlencode($vars["page"]);
- $link_top = "$script?$defaultpage";
- $link_list = "$script?cmd=list";
- $link_filelist = "$script?cmd=filelist";
- $link_search = "$script?cmd=search";
- $link_whatsnew = "$script?$whatsnew";
- $link_backup = "$script?cmd=backup&page=".rawurlencode($vars["page"]);
- $link_help = "$script?cmd=help";
-
- if(is_page($vars["page"]) && $is_page)
- {
- $fmt = @filemtime(get_filename(encode($vars["page"])));
- }
-
- if(is_page($vars["page"]) && $related_link && $is_page && !arg_check("edit") && !arg_check("freeze") && !arg_check("unfreeze"))
- {
- $related = make_related($vars["page"],false);
- }
-
- if(is_page($vars["page"]) && !in_array($vars["page"],$cantedit) && !arg_check("backup") && !arg_check("edit") && !$vars["preview"])
- {
- $is_read = TRUE;
- }
-
- //if(!$longtaketime)
- $longtaketime = getmicrotime() - MUTIME;
- $taketime = sprintf("%01.03f",$longtaketime);
-
- require(SKIN_FILE);
-}
-
-// ¥Õ¥¡¥¤¥ë¤Ø¤Î½ÐÎÏ
-function file_write($dir,$page,$str)
-{
- global $post,$update_exec;
-
- if($str == "")
- {
- @unlink($dir.encode($page).".txt");
- }
- else
- {
- if($post["notimestamp"] && is_page($page))
- {
- $timestamp = @filemtime($dir.encode($page).".txt");
- }
- $fp = fopen($dir.encode($page).".txt","w");
- while(!flock($fp,LOCK_EX));
- fputs($fp,$str);
- flock($fp,LOCK_UN);
- fclose($fp);
- if($timestamp)
- touch($dir.encode($page).".txt",$timestamp);
- }
-
- if(!$timestamp)
- put_lastmodified();
-
- if($update_exec)
- {
- system($update_exec." > /dev/null &");
- }
-}
-
-// ¥Ð¥Ã¥¯¥¢¥Ã¥×°ìÍ÷¤Î¼èÆÀ
-function get_backup_list($_page="")
-{
- global $script,$date_format,$time_format,$weeklabels,$cantedit;
- global $_msg_backuplist,$_msg_diff,$_msg_nowdiff,$_msg_source;
-
- $ins_date = date($date_format,$val);
- $ins_time = date($time_format,$val);
- $ins_week = "(".$weeklabels[date("w",$val)].")";
- $ins = "$ins_date $ins_week $ins_time";
-
- if (($dir = @opendir(BACKUP_DIR)) && !$_page)
- {
- while($file = readdir($dir))
- {
- if(function_exists(gzopen))
- $file = str_replace(".txt",".gz",$file);
-
- if($file == ".." || $file == ".") continue;
- $page = decode(trim(preg_replace("/(\.txt)|(\.gz)$/"," ",$file)));
- if(in_array($page,$cantedit)) continue;
- $page_url = rawurlencode($page);
- $name = $page;
- $name = strip_bracket($name);
- if(is_page($page))
- $vals[$name]["link"] = "$name";
- else
- $vals[$name]["link"] = "$name";
- $vals[$name]["name"] = $page;
- }
- closedir($dir);
- $vals = list_sort($vals);
- $retvars[] = "";
- }
- else
- {
- $page_url = rawurlencode($_page);
- $name = strip_bracket($_page);
- $vals[$name]["link"] = "";
- $vals[$name]["name"] = $_page;
- $retvars[] = "";
- $retvars[] .= "- $_msg_backuplist
\n";
- }
-
-
- foreach($vals as $page => $line)
- {
- $arybackups = get_backup_info(encode($line["name"]).".txt");
- $page_url = rawurlencode($line["name"]);
- if(count($arybackups)) $line["link"] .= "\n\n";
- foreach($arybackups as $key => $val)
- {
- $ins_date = date($date_format,$val);
- $ins_time = date($time_format,$val);
- $ins_week = "(".$weeklabels[date("w",$val)].")";
- $backupdate = "($ins_date $ins_week $ins_time)";
- if(!$_page)
- {
- $line["link"] .= "- $key $backupdate
\n";
- }
- else
- {
- $line["link"] .= "- $key $backupdate [ $_msg_diff | $_msg_nowdiff | $_msg_source ]
\n";
- }
- }
- if(count($arybackups)) $line["link"] .= " ";
- $retvars[] = $line["link"];
- }
- $retvars[] = " ";
-
- return join("\n",$retvars);
-}
-
-// ºÇ½ª¹¹¿·¥Ú¡¼¥¸¤Î¹¹¿·
-function put_lastmodified()
-{
- global $script,$maxshow,$whatsnew,$date_format,$time_format,$weeklabels,$post,$non_list;
-
- if($post["notimestamp"]) return;
-
- if ($dir = @opendir(DATA_DIR))
- {
- while($file = readdir($dir))
- {
- $page = decode(trim(preg_replace("/\.txt$/"," ",$file)));
-
- if($page == $whatsnew || $file == "." || $file == "..") continue;
- if(preg_match("/$non_list/",$page)) continue;
-
- if(file_exists(get_filename(encode($page))))
- {
- $page_url = rawurlencode($page);
- $lastmodtime = filemtime(get_filename(encode($page)));
- $lastmod = date($date_format,$lastmodtime)
- . " (" . $weeklabels[date("w",$lastmodtime)] . ") "
- . date($time_format,$lastmodtime);
- $putval[$lastmodtime][] = "-$lastmod - $page";
- }
- }
- closedir($dir);
- }
-
- $cnt = 1;
- krsort($putval);
- $fp = fopen(get_filename(encode($whatsnew)),"w");
- flock($fp,LOCK_EX);
- foreach($putval as $pages)
- {
- foreach($pages as $page)
- {
- fputs($fp,$page."\n");
- $cnt++;
- if($cnt > $maxshow) break;
- }
- if($cnt > $maxshow) break;
- }
- flock($fp,LOCK_EX);
- fclose($fp);
-}
-
-// ¸¡º÷
-function do_search($word,$type="AND",$non_format=0)
-{
- global $script,$whatsnew,$vars;
- global $_msg_andresult,$_msg_orresult,$_msg_notfoundresult;
-
- $database = array();
- $retval = array();
- $cnt = 0;
-
- if ($dir = @opendir(DATA_DIR))
- {
- while($file = readdir($dir))
- {
- if($file == ".." || $file == ".") continue;
- $cnt++;
- $page = decode(trim(preg_replace("/\.txt$/"," ",$file)));
- if($page == $whatsnew) continue;
- if($page == $vars["page"] && $non_format) continue;
- $data[$page] = file(DATA_DIR.$file);
- }
- closedir($dir);
- }
-
- $arywords = explode(" ",$word);
- $result_word = $word;
-
- foreach($data as $name => $lines)
- {
- $line = join("\n",$lines);
-
- $hit = 0;
- if(strpos($result_word," ") !== FALSE)
- {
- foreach($arywords as $word)
- {
- if($type=="AND")
- {
- if(strpos($line,$word) === FALSE)
- {
- $hit = 0;
- break;
- }
- else
- {
- $hit = 1;
- }
- }
- else if($type=="OR")
- {
- if(strpos($line,$word) !== FALSE)
- $hit = 1;
- }
- }
- if($hit==1 || strpos($name,$word)!==FALSE)
- {
- $page_url = rawurlencode($name);
- $word_url = rawurlencode($word);
- $name2 = strip_bracket($name);
- $str = get_pg_passage($name);
- $retval[$name2] = "- $name2$str
";
- }
- }
- else
- {
- if(stristr($line,$word) || stristr($name,$word))
- {
- $page_url = rawurlencode($name);
- $word_url = rawurlencode($word);
- $name2 = strip_bracket($name);
- $link_tag = "$name2";
- $link_tag .= get_pg_passage($name,false);
- if($non_format)
- {
- $tm = @filemtime(get_filename(encode($name)));
- $retval[$tm] = $link_tag;
- }
- else
- {
- $retval[$name2] = "- $link_tag
";
- }
- }
- }
- }
-
- if($non_format)
- return $retval;
-
- $retval = list_sort($retval);
-
- if(count($retval) && !$non_format)
- {
- $retvals = "\n" . join("\n",$retval) . " \n \n";
-
- if($type=="AND")
- $retvals.= str_replace('$1',$result_word,str_replace('$2',count($retval),str_replace('$3',$cnt,$_msg_andresult)));
- else
- $retvals.= str_replace('$1',$result_word,str_replace('$2',count($retval),str_replace('$3',$cnt,$_msg_orresult)));
-
- }
- else
- $retvals .= str_replace('$1',$result_word,$_msg_notfoundresult);
- return $retvals;
-}
-
-// º¹Ê¬¤ÎºîÀ®
-function do_diff($strlines1,$strlines2)
-{
- $lines1 = split("\n",$strlines1);
- $lines2 = split("\n",$strlines2);
-
- $same_lines = $diff_lines = $del_lines = $add_lines = $retdiff = array();
-
- if(count($lines1) > count($lines2)) { $max_line = count($lines1)+2; }
- else { $max_line = count($lines2)+2; }
-
- //$same_lines = array_intersect($lines1,$lines2);
-
- $diff_lines = array_diff($lines1,$lines2);
- $diff_lines = array_merge($diff_lines,array_diff($lines2,$lines1));
-
- foreach($diff_lines as $line)
- {
- $index = array_search($line,$lines1);
- if($index > -1)
- {
- $del_lines[$index] = $line;
- }
-
- //$index = array_search($line,$lines2);
- //if($index > -1)
- //{
- // $add_lines[$index] = $line;
- //}
- }
-
- $cnt=0;
- foreach($lines2 as $line)
- {
- $line = rtrim($line);
-
- while($del_lines[$cnt])
- {
- $retdiff[] = "- ".$del_lines[$cnt];
- $del_lines[$cnt] = "";
- $cnt++;
- }
-
- if(in_array($line,$diff_lines))
- {
- $retdiff[] = "+ $line";
- }
- else
- {
- $retdiff[] = " $line";
- }
-
- $cnt++;
- }
-
- foreach($del_lines as $line)
- {
- if(trim($line))
- $retdiff[] = "- $line";
- }
-
- return join("\n",$retdiff);
-}
-
-// °ìÍ÷¤Î¼èÆÀ
-function get_list($withfilename)
-{
- global $script,$list_index,$top,$non_list,$whatsnew;
- global $_msg_symbol,$_msg_other;
-
- $retval = array();
- if ($dir = @opendir(DATA_DIR))
- {
- while($file = readdir($dir))
- {
- $page = decode(trim(preg_replace("/\.txt$/"," ",$file)));
- if($file == ".." || $file == ".") continue;
- if(preg_match("/$non_list/",$page) && !$withfilename) continue;
- if($page == $whatsnew) continue;
- $page_url = rawurlencode($page);
- $page2 = strip_bracket($page);
- $pg_passage = get_pg_passage($page);
- $retval[$page2] .= "- $page2$pg_passage
\n";
- if($withfilename)
- {
- $retval[$page2] .= "\n";
- }
- }
- closedir($dir);
- }
-
- $retval = list_sort($retval);
-
- if($list_index)
- {
- $head_str = "";
- $etc_sw = 0;
- $symbol_sw = 0;
- $top_link = "";
- foreach($retval as $page => $link)
- {
- $head = substr($page,0,1);
- if($head_str != $head && !$etc_sw)
- {
- $retval2[$page] = "";
-
- if(preg_match("/([A-Z])|([a-z])/",$head,$match))
- {
- if($match[1])
- $head_nm = "High:$head";
- else
- $head_nm = "Low:$head";
-
- if($head_str) $retval2[$page] = " \n";
- $retval2[$page] .= "$head\n\n";
- $head_str = $head;
- if($top_link) $top_link .= "|";
- $top_link .= " ".$head." ";
- }
- else if(preg_match("/[ -~]/",$head))
- {
- if(!$symbol_sw)
- {
- if($head_str) $retval2[$page] = " \n";
- $retval2[$page] .= "$_msg_symbol\n\n";
- $head_str = $head;
- if($top_link) $top_link .= "|";
- $top_link .= "$_msg_symbol";
- $symbol_sw = 1;
- }
- }
- else
- {
- if($head_str) $retval2[$page] = " \n";
- $retval2[$page] .= "$_msg_other\n\n";
- $etc_sw = 1;
- if($top_link) $top_link .= "|";
- $top_link .= "$_msg_other";
- }
- }
- $retval2[$page] .= $link;
- }
- $retval2[] = " \n";
-
- $top_link = " \n";
-
- array_unshift($retval2,$top_link);
- }
- else
- {
- $retval2 = $retval;
- }
-
- return join("",$retval2);
-}
-
-// ÊÔ½¸¥Õ¥©¡¼¥à¤Îɽ¼¨
-function edit_form($postdata,$page,$add=0)
-{
- global $script,$rows,$cols,$hr,$vars,$function_freeze;
- global $_btn_addtop,$_btn_preview,$_btn_update,$_btn_freeze,$_msg_help,$_btn_notchangetimestamp;
- global $whatsnew,$_btn_template,$_btn_load,$non_list,$load_template_func;
-
- $digest = md5(@join("",@file(get_filename(encode($page)))));
-
- if($add)
- {
- $addtag = '';
- $add_top = ''.$_btn_addtop.'';
- }
-
- if($vars["help"] == "true")
- $help = $hr.catrule();
- else
- $help = " \n\n";
-
- if($function_freeze)
- $str_freeze = '';
-
- if($load_template_func)
- {
- $vals = array();
- if ($dir = @opendir(DATA_DIR))
- {
- while($file = readdir($dir))
- {
- $pg_org = decode(trim(preg_replace("/\.txt$/"," ",$file)));
- if($file == ".." || $file == "." || $pg_org == $whatsnew) continue;
- if(preg_match("/$non_list/",$pg_org)) continue;
- $name = strip_bracket($pg_org);
- $vals[$name] = " ";
- }
- closedir($dir);
- }
- @ksort($vals);
-
- $template = " \n"
- ." \n";
-
- if($vars["refer"]) $refer = $vars["refer"]."\n\n";
- }
-
-return '
- |