2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
5 // $Id: comment.inc.php,v 1.23 2004/07/31 03:09:20 henoheno 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','&new{$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, $now;
32 global $_title_updated, $_no_name;
33 global $_msg_comment_collided, $_title_comment_collided;
35 if (! isset($vars['msg']) || $vars['msg'] == '') {
36 return array('msg'=>'', 'body'=>'');
38 $vars['msg'] = preg_replace("/\n/", '', $vars['msg']);
43 if (preg_match('/^(-{1,2})(.*)/', $vars['msg'], $match))
46 $vars['msg'] = $match[2];
50 $_msg = str_replace('$msg', $vars['msg'], COMMENT_MSG_FORMAT);
52 $_name = (! isset($vars['name']) || $vars['name'] == '') ? $_no_name : $vars['name'];
53 $_name = ($_name == '') ? '' : str_replace('$name', $_name, COMMENT_NAME_FORMAT);
55 $_now = ($vars['nodate'] == '1') ? '' : str_replace('$now', $now, COMMENT_NOW_FORMAT);
57 $comment = str_replace("\x08MSG\x08", $_msg, COMMENT_FORMAT);
58 $comment = str_replace("\x08NAME\x08",$_name,$comment);
59 $comment = str_replace("\x08NOW\x08", $_now, $comment);
60 $comment = $head . $comment;
63 $postdata_old = get_source($vars['refer']);
65 $comment_ins = ($vars['above'] == '1');
67 foreach ($postdata_old as $line)
73 if (preg_match('/^#comment/', $line) and $comment_no++ == $vars['comment_no'])
75 $postdata = rtrim($postdata)."\n-$comment\n";
87 $title = $_title_updated;
89 if (md5(@join('',get_source($vars['refer']))) != $vars['digest'])
91 $title = $_title_comment_collided;
92 $body = $_msg_comment_collided . make_pagelink($vars['refer']);
95 page_write($vars['refer'], $postdata);
97 $retvars['msg'] = $title;
98 $retvars['body'] = $body;
100 $vars['page'] = $vars['refer'];
105 function plugin_comment_convert()
107 global $script, $vars, $digest;
108 global $_btn_comment, $_btn_name, $_msg_comment;
109 static $numbers = array();
111 if (! isset($numbers[$vars['page']])) {
112 $numbers[$vars['page']] = 0;
114 $comment_no = $numbers[$vars['page']]++;
116 $options = func_num_args() ? func_get_args() : array();
118 if (in_array('noname',$options)) {
119 $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" />