2 // $Id: comment.inc.php,v 1.14 2003/04/01 07:17:40 panda Exp $
4 /////////////////////////////////////////////////
5 // ¥³¥á¥ó¥È¤Î̾Á°¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¥«¥é¥à¿ô
6 define('COMMENT_NAME_COLS',15);
7 /////////////////////////////////////////////////
8 // ¥³¥á¥ó¥È¤Î¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¥«¥é¥à¿ô
9 define('COMMENT_COLS',70);
10 /////////////////////////////////////////////////
11 // ¥³¥á¥ó¥È¤ÎÁÞÆþ¥Õ¥©¡¼¥Þ¥Ã¥È
12 define('COMMENT_NAME_FORMAT','[[$name]]');
13 define('COMMENT_MSG_FORMAT','$msg');
14 define('COMMENT_NOW_FORMAT','SIZE(10){$now}');
15 /////////////////////////////////////////////////
16 // ¥³¥á¥ó¥È¤ÎÁÞÆþ¥Õ¥©¡¼¥Þ¥Ã¥È(¥³¥á¥ó¥ÈÆâÍÆ)
17 define('COMMENT_FORMAT',"\x08MSG\x08 -- \x08NAME\x08 \x08NOW\x08");
18 /////////////////////////////////////////////////
19 // ¥³¥á¥ó¥È¤òÁÞÆþ¤¹¤ë°ÌÃÖ 1:Íó¤ÎÁ° 0:Íó¤Î¸å
20 define('COMMENT_INS',1);
21 /////////////////////////////////////////////////
22 // ¥³¥á¥ó¥È¤¬Åê¹Æ¤µ¤ì¤¿¾ì¹ç¡¢ÆâÍƤò¥á¡¼¥ë¤ÇÁ÷¤ëÀè
23 //define('COMMENT_MAIL',FALSE);
25 function plugin_comment_action()
27 global $script,$vars,$post,$now;
28 global $_title_updated;
29 global $_msg_comment_collided,$_title_comment_collided;
31 $post['msg'] = preg_replace("/\n/",'',$post['msg']);
33 if ($post['msg'] == '') {
34 return array('msg'=>'','body'=>'');
37 $comment_format = COMMENT_FORMAT;
38 if ($post['nodate']=='1') {
39 $comment_format = str_replace('$now','',$comment_format);
43 $postdata_old = get_source($post['refer']);
47 if ($post['name'] != '') {
48 $name = str_replace('$name',$post['name'],COMMENT_NAME_FORMAT);
52 if (preg_match('/^(-{1,2})(.*)/',$post['msg'],$match)) {
54 $post['msg'] = $match[2];
57 $comment = str_replace("\x08MSG\x08",str_replace('$msg',$post['msg'],COMMENT_MSG_FORMAT),$comment_format);
58 $comment = str_replace("\x08NAME\x08",$name,$comment);
59 $comment = str_replace("\x08NOW\x08",str_replace('$now',$now,COMMENT_NOW_FORMAT),$comment);
60 $comment = $head.$comment;
62 foreach($postdata_old as $line) {
66 if (preg_match('/^#comment/',$line)) {
67 if ($comment_no == $post['comment_no'] and $post['msg'] != '') {
68 $postdata = rtrim($postdata)."\n-$comment\n";
80 $title = $_title_updated;
82 if (md5(@join('',get_source($post['refer']))) != $post['digest']) {
83 $title = $_title_comment_collided;
84 $body = $_msg_comment_collided . make_link($post['refer']);
87 page_write($post['refer'],$postdata);
89 $retvars['msg'] = $title;
90 $retvars['body'] = $body;
92 $post['page'] = $vars['page'] = $post['refer'];
96 function plugin_comment_convert()
98 global $script,$vars,$digest;
99 global $_btn_comment,$_btn_name,$_msg_comment;
100 static $comment_no = 0;
102 $options = func_num_args() ? func_get_args() : array();
104 if (in_array('noname',$options)) {
105 $nametags = $_msg_comment;
108 $nametags = $_btn_name.'<input type="text" name="name" size="'.COMMENT_NAME_COLS."\" />\n";
111 $nodate = in_array('nodate',$options) ? '1' : '0';
113 $s_page = htmlspecialchars($vars['page']);
114 $comment_cols = COMMENT_COLS;
117 <form action="$script" method="post">
119 <input type="hidden" name="comment_no" value="$comment_no" />
120 <input type="hidden" name="refer" value="$s_page" />
121 <input type="hidden" name="plugin" value="comment" />
122 <input type="hidden" name="nodate" value="$nodate" />
123 <input type="hidden" name="digest" value="$digest" />
125 <input type="text" name="msg" size="$comment_cols" />
126 <input type="submit" name="comment" value="$_btn_comment" />