'', 'body'=>''); // Do nothing
$vars['msg'] = str_replace("\n", '', $vars['msg']); // Cut LFs
$head = '';
$match = array();
if (preg_match('/^(-{1,2})-*\s*(.*)/', $vars['msg'], $match)) {
$head = & $match[1];
$vars['msg'] = & $match[2];
}
if ($vars['msg'] == '') return array('msg'=>'', 'body'=>''); // Do nothing
$commentplus = str_replace('$msg', $vars['msg'], PLUGIN_COMMENTplus_FORMAT_MSG);
if(isset($vars['name']) || ($vars['nodate'] != '1')) {
$_name = (! isset($vars['name']) || $vars['name'] == '') ? $_no_name : $vars['name'];
if ($_name == null){
$_name = 'Anonymous';
}
$_name = ($_name == '') ? '' : str_replace('$name', $_name, PLUGIN_COMMENTplus_FORMAT_NAME);
$_now = ($vars['nodate'] == '1') ? '' :
str_replace('$now', $now, PLUGIN_COMMENTplus_FORMAT_NOW);
$commentplus = str_replace("\x08MSG\x08", $commentplus, PLUGIN_COMMENTplus_FORMAT_STRING);
$commentplus = str_replace("\x08NAME\x08", $_name, $commentplus);
$commentplus = str_replace("\x08NOW\x08", $_now, $commentplus);
}
$commentplus = '-' . $head . ' ' . $commentplus;
$postdata = '';
$commentplus_no = 0;
$above = (isset($vars['above']) && $vars['above'] == '1');
$commentplus_added = FALSE;
foreach (get_source($vars['refer']) as $line) {
if (! $above) $postdata .= $line;
if (preg_match('/^#commentplus/i', $line) && $commentplus_no++ == $vars['commentplus_no']) {
$commentplus_added = TRUE;
if ($above) {
$postdata = rtrim($postdata) . "\n" .
$commentplus . "\n" .
"\n"; // Insert one blank line above #commment, to avoid indentation
} else {
$postdata = rtrim($postdata) . "\n" .
$commentplus . "\n";
}
}
if ($above) $postdata .= $line;
}
$title = $_title_updated;
$body = '';
if ($commentplus_added) {
// new commentplus added
if (md5(get_source($vars['refer'], TRUE, TRUE)) !== $vars['digest']) {
$title = $_title_commentplus_collided;
$body = $_msg_commentplus_collided . make_pagelink($vars['refer']);
}
// require "iplog.php";//IPLOGを入れてる場合のみ可能
// addLog($commentplus,'コメント+');
page_write($vars['refer'], $postdata);
} else {
// failed to add the commentplus
$title = $_title_commentplus_collided;
$body = $_commentplus_plugin_fail_msg . make_pagelink($vars['refer']);
}
$retvars['msg'] = $title;
$retvars['body'] = $body;
$vars['page'] = $vars['refer'];
return $retvars;
}
function plugin_commentplus_convert()
{
global $vars, $digest, $_btn_comment, $_btn_name, $_msg_commentplus;
static $numbers = array();
static $commentplus_cols = PLUGIN_COMMENTplus_SIZE_MSG;
if (PKWK_READONLY) return ''; // Show nothing
$page = $vars['page'];
if (! isset($numbers[$page])) $numbers[$page] = 0;
$commentplus_no = $numbers[$page]++;
$options = func_num_args() ? func_get_args() : array();
if (in_array('noname', $options)) {
$nametags = '';
} else {
$nametags = '' .
'' . "\n";
}
$nodate = in_array('nodate', $options) ? '1' : '0';
$above = in_array('above', $options) ? '1' :
(in_array('below', $options) ? '0' : PLUGIN_COMMENTplus_DIRECTION_DEFAULT);
$script = get_page_uri($page);
$s_page = htmlsc($page);
$string = <<
EOD;
//顔文字↑
return $string;
}