自作プラグイン/commentplus.inc.php
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
** commentplus.inc.php [#e468904c]
|RIGHT:100|LEFT:360|c
|~サマリ|機能追加版コメントプラグイン|
|~リビジョン|1.0.2|
|~対応バージョン|1.5.x|
|~投稿者|[[K]]|
|~投稿日|&new{2020-08-05 (水) 22:16:23};|
#contents
**概要 [#o5c7ac0a]
コメントに絵文字などの機能を加えたプラグインです。
//**ダウンロード [#e183570a]
// k0.22web.org/commentplus.inc.php-1.0.dl
**ソース [#r574e65a]
<?php
define('applyNoname', ''); //名前が入力されていない時に...
define('PLUGIN_COMMENTplus_DIRECTION_DEFAULT', '1'); // ...
define('PLUGIN_COMMENTplus_SIZE_MSG', 70);
define('PLUGIN_COMMENTplus_SIZE_NAME', 15);
// ----
define('PLUGIN_COMMENTplus_FORMAT_MSG', '$msg');
define('PLUGIN_COMMENTplus_FORMAT_NAME', '[[$name]]');
define('PLUGIN_COMMENTplus_FORMAT_NOW', '&new{$now};');
define('PLUGIN_COMMENTplus_FORMAT_STRING', "\x08MSG\x08 ...
function plugin_commentplus_action()
{
global $vars, $now, $_title_updated, $_no_name;
global $_msg_commentplus_collided, $_title_commentplus_...
global $_commentplus_plugin_fail_msg;
if (PKWK_READONLY) die_message('PKWK_READONLY prohibits...
if (! isset($vars['msg'])) return array('msg'=>'', 'bod...
$vars['msg'] = str_replace("\n", '', $vars['msg']); // ...
$head = '';
$match = array();
if (preg_match('/^(-{1,2})-*\s*(.*)/', $vars['msg'], $m...
$head = & $match[1];
$vars['msg'] = & $match[2];
}
if ($vars['msg'] == '') return array('msg'=>'', 'body'=...
$commentplus = str_replace('$msg', $vars['msg'], PLUGI...
if(isset($vars['name']) || ($vars['nodate'] != '1')) {
$_name = (! isset($vars['name']) || $vars['name'] == '...
if ($_name == null){
$_name = applyNoname;
}
$_name = ($_name == '') ? '' : str_replace('$name', $_...
$_now = ($vars['nodate'] == '1') ? '' :
str_replace('$now', $now, PLUGIN_COMMENTplus_FORMAT_N...
$commentplus = str_replace("\x08MSG\x08", $commentplu...
$commentplus = str_replace("\x08NAME\x08", $_name, $co...
$commentplus = str_replace("\x08NOW\x08", $_now, $co...
}
$commentplus = '-' . $head . ' ' . $commentplus;
$postdata = '';
$commentplus_no = 0;
$above = (isset($vars['above']) && $vars['above']...
$commentplus_added = FALSE;
foreach (get_source($vars['refer']) as $line) {
if (! $above) $postdata .= $line;
if (preg_match('/^#commentplus/i', $line) && $commentp...
$commentplus_added = TRUE;
if ($above) {
$postdata = rtrim($postdata) . "\n" .
$commentplus . "\n" .
"\n"; // Insert one blank line above #commment, to...
} 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)) !== $v...
$title = $_title_commentplus_collided;
$body = $_msg_commentplus_collided . make_pagelink($...
}
//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...
}
$retvars['msg'] = $title;
$retvars['body'] = $body;
$vars['page'] = $vars['refer'];
return $retvars;
}
function plugin_commentplus_convert()
{
global $vars, $digest, $_btn_comment, $_btn_name, $_msg...
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 = '<label for="_p_commentplus_commentplus_' ...
$_msg_commentplus . '</label>';
} else {
$nametags = '<label for="_p_commentplus_name_' . $comm...
$_btn_name . '</label>' .
'<input type="text" name="name" id="_p_commentplus_na...
$commentplus_no . '" size="' . PLUGIN_COMMENTplus_SI...
'" />' . "\n";
}
$nodate = in_array('nodate', $options) ? '1' : '0';
$above = in_array('above', $options) ? '1' :
(in_array('below', $options) ? '0' : PLUGIN_COMMENTplu...
$script = get_page_uri($page);
$s_page = htmlsc($page);
$string = <<<EOD
<br />
<script src="https://ajax.googleapis.com/ajax/libs/j...
<form action="$script" method="post" class="_p_commentpl...
<div>
<input type="hidden" name="plugin" value="commentplus"...
<input type="hidden" name="refer" value="$s_page" />
<input type="hidden" name="commentplus_no" value="$com...
<input type="hidden" name="nodate" value="$nodate" />
<input type="hidden" name="above" value="$above" />
<input type="hidden" name="digest" value="$digest" />
$nametags
<input type="text" name="msg" id="_p_commentplus_comme...
size="$commentplus_cols" required />
<input type="submit" name="commentplus" value="$_btn_c...
</div>
</form>
<script>
document.activeElement.onInput = function()
{
if (document.activeElement.type == "text"){
dae = document.activeElement;
text_len = dae.value.length;
text_pos = dae.selectionStart;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
}
};
document.activeElement.onclick = function()
{
if (document.activeElement.type == "text"){
dae = document.activeElement;
text_len = dae.value.length;
text_pos = dae.selectionStart;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
}
};
function inputToCommentplusArea(input_text) {
dae.value = text_bf + input_text + text_af;
text_len = dae.value.length;
text_pos = text_pos + input_text.length;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
};
function inputToCommentplusArea2(input_text1,input_text2...
size = window.prompt("サイズ:", "10");
text1 = window.prompt("テキスト:", dae.value.substri...
text_af = dae.value.substr(text_pos + dae.value.subs...
dae.value = text_bf + input_text1 + size + input_tex...
text_len = dae.value.length;
text_pos = text_pos + input_text.length;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
};
function inputToCommentplusAreaURL(input_text1,input_tex...
text1 = window.prompt("テキスト:", "");
url1 = window.prompt("URL:", "http://");
dae.value = text_bf + "[["+text1+">"+url1+"]]" + tex...
text_len = dae.value.length;
text_pos = text_pos + input_text.length;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
};
function inputToCommentplusArea3(input_text) {
text_af = dae.value.substr(text_pos + dae.value.subs...
dae.value = text_bf + input_text + dae.value.substri...
text_se_1 = dae.selectionEnd;
text_len = dae.value.length;
text_pos = text_pos + input_text.length;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
};
</script>
<a href="javascript:inputToCommentplusAreaURL()">[URL]</...
<a href="javascript:inputToCommentplusArea3('\'\'...
<a href="javascript:inputToCommentplusArea3('\'\'...
<a href="javascript:inputToCommentplusArea3('%%%')">[U]<...
<a href="javascript:inputToCommentplusArea3('%%')">[S]</...
<a href="javascript:inputToCommentplusArea2('&size(','){...
<a href="javascript:inputToCommentplusArea('&attachref()...
<a href="javascript:inputToCommentplusArea('&br;')">[改...
<a href="javascript:inputToCommentplusArea('&smile;'...
<a href="javascript:inputToCommentplusArea('&bigsmile...
<a href="javascript:inputToCommentplusArea('&huh;')"...
<a href="javascript:inputToCommentplusArea('&oh;')">...
<a href="javascript:inputToCommentplusArea('&wink;')...
<a href="javascript:inputToCommentplusArea('&sad;')"...
<a href="javascript:inputToCommentplusArea('&heart;'...
EOD;
//顔文字↑
return $string;
}
**使い方 [#j6d6dc69]
"plugin/commentplus.inc.php"で保存してください。
#commentplus
で使うことができます。
**注意 [#sab23c3e]
-%%#commentplusを同じページに複数設置するとボタンのバグが...
**ライセンス [#i1e4a42f]
GPL
終了行:
** commentplus.inc.php [#e468904c]
|RIGHT:100|LEFT:360|c
|~サマリ|機能追加版コメントプラグイン|
|~リビジョン|1.0.2|
|~対応バージョン|1.5.x|
|~投稿者|[[K]]|
|~投稿日|&new{2020-08-05 (水) 22:16:23};|
#contents
**概要 [#o5c7ac0a]
コメントに絵文字などの機能を加えたプラグインです。
//**ダウンロード [#e183570a]
// k0.22web.org/commentplus.inc.php-1.0.dl
**ソース [#r574e65a]
<?php
define('applyNoname', ''); //名前が入力されていない時に...
define('PLUGIN_COMMENTplus_DIRECTION_DEFAULT', '1'); // ...
define('PLUGIN_COMMENTplus_SIZE_MSG', 70);
define('PLUGIN_COMMENTplus_SIZE_NAME', 15);
// ----
define('PLUGIN_COMMENTplus_FORMAT_MSG', '$msg');
define('PLUGIN_COMMENTplus_FORMAT_NAME', '[[$name]]');
define('PLUGIN_COMMENTplus_FORMAT_NOW', '&new{$now};');
define('PLUGIN_COMMENTplus_FORMAT_STRING', "\x08MSG\x08 ...
function plugin_commentplus_action()
{
global $vars, $now, $_title_updated, $_no_name;
global $_msg_commentplus_collided, $_title_commentplus_...
global $_commentplus_plugin_fail_msg;
if (PKWK_READONLY) die_message('PKWK_READONLY prohibits...
if (! isset($vars['msg'])) return array('msg'=>'', 'bod...
$vars['msg'] = str_replace("\n", '', $vars['msg']); // ...
$head = '';
$match = array();
if (preg_match('/^(-{1,2})-*\s*(.*)/', $vars['msg'], $m...
$head = & $match[1];
$vars['msg'] = & $match[2];
}
if ($vars['msg'] == '') return array('msg'=>'', 'body'=...
$commentplus = str_replace('$msg', $vars['msg'], PLUGI...
if(isset($vars['name']) || ($vars['nodate'] != '1')) {
$_name = (! isset($vars['name']) || $vars['name'] == '...
if ($_name == null){
$_name = applyNoname;
}
$_name = ($_name == '') ? '' : str_replace('$name', $_...
$_now = ($vars['nodate'] == '1') ? '' :
str_replace('$now', $now, PLUGIN_COMMENTplus_FORMAT_N...
$commentplus = str_replace("\x08MSG\x08", $commentplu...
$commentplus = str_replace("\x08NAME\x08", $_name, $co...
$commentplus = str_replace("\x08NOW\x08", $_now, $co...
}
$commentplus = '-' . $head . ' ' . $commentplus;
$postdata = '';
$commentplus_no = 0;
$above = (isset($vars['above']) && $vars['above']...
$commentplus_added = FALSE;
foreach (get_source($vars['refer']) as $line) {
if (! $above) $postdata .= $line;
if (preg_match('/^#commentplus/i', $line) && $commentp...
$commentplus_added = TRUE;
if ($above) {
$postdata = rtrim($postdata) . "\n" .
$commentplus . "\n" .
"\n"; // Insert one blank line above #commment, to...
} 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)) !== $v...
$title = $_title_commentplus_collided;
$body = $_msg_commentplus_collided . make_pagelink($...
}
//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...
}
$retvars['msg'] = $title;
$retvars['body'] = $body;
$vars['page'] = $vars['refer'];
return $retvars;
}
function plugin_commentplus_convert()
{
global $vars, $digest, $_btn_comment, $_btn_name, $_msg...
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 = '<label for="_p_commentplus_commentplus_' ...
$_msg_commentplus . '</label>';
} else {
$nametags = '<label for="_p_commentplus_name_' . $comm...
$_btn_name . '</label>' .
'<input type="text" name="name" id="_p_commentplus_na...
$commentplus_no . '" size="' . PLUGIN_COMMENTplus_SI...
'" />' . "\n";
}
$nodate = in_array('nodate', $options) ? '1' : '0';
$above = in_array('above', $options) ? '1' :
(in_array('below', $options) ? '0' : PLUGIN_COMMENTplu...
$script = get_page_uri($page);
$s_page = htmlsc($page);
$string = <<<EOD
<br />
<script src="https://ajax.googleapis.com/ajax/libs/j...
<form action="$script" method="post" class="_p_commentpl...
<div>
<input type="hidden" name="plugin" value="commentplus"...
<input type="hidden" name="refer" value="$s_page" />
<input type="hidden" name="commentplus_no" value="$com...
<input type="hidden" name="nodate" value="$nodate" />
<input type="hidden" name="above" value="$above" />
<input type="hidden" name="digest" value="$digest" />
$nametags
<input type="text" name="msg" id="_p_commentplus_comme...
size="$commentplus_cols" required />
<input type="submit" name="commentplus" value="$_btn_c...
</div>
</form>
<script>
document.activeElement.onInput = function()
{
if (document.activeElement.type == "text"){
dae = document.activeElement;
text_len = dae.value.length;
text_pos = dae.selectionStart;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
}
};
document.activeElement.onclick = function()
{
if (document.activeElement.type == "text"){
dae = document.activeElement;
text_len = dae.value.length;
text_pos = dae.selectionStart;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
}
};
function inputToCommentplusArea(input_text) {
dae.value = text_bf + input_text + text_af;
text_len = dae.value.length;
text_pos = text_pos + input_text.length;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
};
function inputToCommentplusArea2(input_text1,input_text2...
size = window.prompt("サイズ:", "10");
text1 = window.prompt("テキスト:", dae.value.substri...
text_af = dae.value.substr(text_pos + dae.value.subs...
dae.value = text_bf + input_text1 + size + input_tex...
text_len = dae.value.length;
text_pos = text_pos + input_text.length;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
};
function inputToCommentplusAreaURL(input_text1,input_tex...
text1 = window.prompt("テキスト:", "");
url1 = window.prompt("URL:", "http://");
dae.value = text_bf + "[["+text1+">"+url1+"]]" + tex...
text_len = dae.value.length;
text_pos = text_pos + input_text.length;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
};
function inputToCommentplusArea3(input_text) {
text_af = dae.value.substr(text_pos + dae.value.subs...
dae.value = text_bf + input_text + dae.value.substri...
text_se_1 = dae.selectionEnd;
text_len = dae.value.length;
text_pos = text_pos + input_text.length;
text_bf = dae.value.substr(0, text_pos);
text_af = dae.value.substr(text_pos, text_len);
};
</script>
<a href="javascript:inputToCommentplusAreaURL()">[URL]</...
<a href="javascript:inputToCommentplusArea3('\'\'...
<a href="javascript:inputToCommentplusArea3('\'\'...
<a href="javascript:inputToCommentplusArea3('%%%')">[U]<...
<a href="javascript:inputToCommentplusArea3('%%')">[S]</...
<a href="javascript:inputToCommentplusArea2('&size(','){...
<a href="javascript:inputToCommentplusArea('&attachref()...
<a href="javascript:inputToCommentplusArea('&br;')">[改...
<a href="javascript:inputToCommentplusArea('&smile;'...
<a href="javascript:inputToCommentplusArea('&bigsmile...
<a href="javascript:inputToCommentplusArea('&huh;')"...
<a href="javascript:inputToCommentplusArea('&oh;')">...
<a href="javascript:inputToCommentplusArea('&wink;')...
<a href="javascript:inputToCommentplusArea('&sad;')"...
<a href="javascript:inputToCommentplusArea('&heart;'...
EOD;
//顔文字↑
return $string;
}
**使い方 [#j6d6dc69]
"plugin/commentplus.inc.php"で保存してください。
#commentplus
で使うことができます。
**注意 [#sab23c3e]
-%%#commentplusを同じページに複数設置するとボタンのバグが...
**ライセンス [#i1e4a42f]
GPL
ページ名: