2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
5 // $Id: comment.inc.php,v 1.20 2003/07/10 03:21:12 arino Exp $
8 /////////////////////////////////////////////////
9 // ¥³¥á¥ó¥È¤Î̾Á°¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¥«¥é¥à¿ô
10 define('COMMENT_NAME_COLS',15);
11 /////////////////////////////////////////////////
12 // ¥³¥á¥ó¥È¤Î¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¥«¥é¥à¿ô
13 define('COMMENT_COLS',70);
14 /////////////////////////////////////////////////
15 // ¥³¥á¥ó¥È¤ÎÁÞÆþ¥Õ¥©¡¼¥Þ¥Ã¥È
16 define('COMMENT_NAME_FORMAT','[[$name]]');
17 define('COMMENT_MSG_FORMAT','$msg');
18 define('COMMENT_NOW_FORMAT','SIZE(10){$now}');
19 /////////////////////////////////////////////////
20 // ¥³¥á¥ó¥È¤ÎÁÞÆþ¥Õ¥©¡¼¥Þ¥Ã¥È(¥³¥á¥ó¥ÈÆâÍÆ)
21 define('COMMENT_FORMAT',"\x08MSG\x08 -- \x08NAME\x08 \x08NOW\x08");
22 /////////////////////////////////////////////////
23 // ¥³¥á¥ó¥È¤òÁÞÆþ¤¹¤ë°ÌÃÖ 1:Íó¤ÎÁ° 0:Íó¤Î¸å
24 define('COMMENT_INS','1');
25 /////////////////////////////////////////////////
26 // ¥³¥á¥ó¥È¤¬Åê¹Æ¤µ¤ì¤¿¾ì¹ç¡¢ÆâÍƤò¥á¡¼¥ë¤ÇÁ÷¤ëÀè
27 //define('COMMENT_MAIL',FALSE);
29 function plugin_comment_action()
31 global $script,$vars,$post,$now;
32 global $_title_updated,$_no_name;
33 global $_msg_comment_collided,$_title_comment_collided;
35 $post['msg'] = preg_replace("/\n/",'',$post['msg']);
37 if ($post['msg'] == '')
39 return array('msg'=>'','body'=>'');
43 if (preg_match('/^(-{1,2})(.*)/',$post['msg'],$match))
46 $post['msg'] = $match[2];
49 $_msg = str_replace('$msg',$post['msg'],COMMENT_MSG_FORMAT);
50 $_name = $post['name'] == '' ? $_no_name : $post['name'];
51 $_name = ($_name == '') ? '' : str_replace('$name',$_name,COMMENT_NAME_FORMAT);
52 $_now = ($post['nodate'] == '1') ? '' : str_replace('$now',$now,COMMENT_NOW_FORMAT);
54 $comment = str_replace("\x08MSG\x08", $_msg, COMMENT_FORMAT);
55 $comment = str_replace("\x08NAME\x08",$_name,$comment);
56 $comment = str_replace("\x08NOW\x08", $_now, $comment);
57 $comment = $head.$comment;
60 $postdata_old = get_source($post['refer']);
62 $comment_ins = ($post['above'] == '1');
64 foreach ($postdata_old as $line)
70 if (preg_match('/^#comment/',$line) and $comment_no++ == $post['comment_no'])
72 $postdata = rtrim($postdata)."\n-$comment\n";
84 $title = $_title_updated;
86 if (md5(@join('',get_source($post['refer']))) != $post['digest'])
88 $title = $_title_comment_collided;
89 $body = $_msg_comment_collided . make_pagelink($post['refer']);
92 page_write($post['refer'],$postdata);
94 $retvars['msg'] = $title;
95 $retvars['body'] = $body;
97 $post['page'] = $vars['page'] = $post['refer'];
101 function plugin_comment_convert()
103 global $script,$vars,$digest;
104 global $_btn_comment,$_btn_name,$_msg_comment;
105 static $numbers = array();
107 if (!array_key_exists($vars['page'],$numbers))
109 $numbers[$vars['page']] = 0;
111 $comment_no = $numbers[$vars['page']]++;
113 $options = func_num_args() ? func_get_args() : array();
115 if (in_array('noname',$options))
117 $nametags = $_msg_comment;
121 $nametags = $_btn_name.'<input type="text" name="name" size="'.COMMENT_NAME_COLS."\" />\n";
124 $nodate = in_array('nodate',$options) ? '1' : '0';
125 $above = in_array('above',$options) ? '1' : (in_array('below',$options) ? '0' : COMMENT_INS);
127 $s_page = htmlspecialchars($vars['page']);
128 $comment_cols = COMMENT_COLS;
131 <form action="$script" method="post">
133 <input type="hidden" name="comment_no" value="$comment_no" />
134 <input type="hidden" name="refer" value="$s_page" />
135 <input type="hidden" name="plugin" value="comment" />
136 <input type="hidden" name="nodate" value="$nodate" />
137 <input type="hidden" name="above" value="$above" />
138 <input type="hidden" name="digest" value="$digest" />
140 <input type="text" name="msg" size="$comment_cols" />
141 <input type="submit" name="comment" value="$_btn_comment" />