[
'ja' => [
'err_blackip' => 'あなたの利用しているIPアドレスは、CtrlCmtプラグインのブラックリストに入っています。',
'err_ngword' => 'コメントに以下のNGワードが含まれています。',
'msg_logout' => 'ログアウトしました。',
'err_login' => 'ログインに失敗しました。',
'name' => '名前',
'comment' => 'コメント',
'date' => '日付',
'page' => 'ページ',
'ip_address' => 'IPアドレス',
"err_iplog" => 'ログは存在しません。
この機能を利用したい場合は「コメント/IPアドレスの保存」を有効にして下さい。',
"controlpanel" => 'コントロールパネル',
"settings" => '設定',
"comment_log" => 'コメントログ',
"logout" => 'ログアウト',
],
'en' => [
'err_blackip' => 'The IP address you are using is on the CtrlCmt plugin\'s blacklist.',
'err_ngword' => 'The comment contains the following NG words.',
'msg_logout' => 'Logged out.',
'err_login' => 'Login failed.',
'name' => 'Name',
'comment' => 'Comment',
'date' => 'Date',
'page' => 'Page',
'ip_address' => 'IP Address',
'err_iplog' => 'Log does not exist.
If you want to use this feature, please enable "Save comments/IP address".',
"controlpanel" => 'Control Panel',
"settings" => 'Settings',
"comment_log" => 'Comment Log',
"logout" => 'Logout',
],
]
);
set_plugin_messages($messages);
}
function plugin_ctrlcmt_convert()
{
return plugin_ctrlcmt_inline(func_get_args());
}
function plugin_ctrlcmt_action() {
global $vars;
global $_ctrlcmt_messages;
$lang = in_array(LANG, $_ctrlcmt_messages) ? $_ctrlcmt_messages[LANG] : $_ctrlcmt_messages['ja'];
if ($vars['do'] == "comment") {
global $now, $_title_updated, $_no_name;
global $_msg_comment_collided, $_title_comment_collided;
global $_comment_plugin_fail_msg;
if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
if (PLUGIN_CTRLCMT_MULTILINE)
$vars['msg'] = preg_replace("/(\n|\r|\r\n)/", "\n&br;", $vars['msg']);
$PLUGIN_CTRLCMT_BLACKIPLIST = PLUGIN_CTRLCMT_BLACKIPLIST;
if (!$PLUGIN_CTRLCMT_BLACKIPLIST == '') {
$blockiparray = explode(",", $PLUGIN_CTRLCMT_BLACKIPLIST);
foreach ($blockiparray as $value){
if ($value == $_SERVER["REMOTE_ADDR"]) {
die_message($lang['err_blackip']);
}
}
}
$PLUGIN_CTRLCMT_NGWORD = PLUGIN_CTRLCMT_NGWORD;
if ((!PLUGIN_CTRLCMT_NGWORD_MODE == 'false') || (isset($PLUGIN_CTRLCMT_NGWORD) && !empty($PLUGIN_CTRLCMT_NGWORD))) {
$PLUGIN_CTRLCMT_NGWORD = "(" . str_replace(",", "|", $PLUGIN_CTRLCMT_NGWORD) . ")";
if (PLUGIN_CTRLCMT_NGWORD_MODE == 'stop') {
if (preg_match_all('/' . $PLUGIN_CTRLCMT_NGWORD . '/u', $vars['msg'], $match, PREG_SET_ORDER))
{
$ngwords = array();
foreach ($match as $value)
{
$ngwords[] = $value[0];
}
die_message($lang['err_ngword'] . '
' . implode(" , ", $ngwords) . '');
}
}
if (PLUGIN_CTRLCMT_NGWORD_MODE == 'hide') {
$vars['msg'] = preg_replace('/' . $PLUGIN_CTRLCMT_NGWORD . '/u', PLUGIN_CTRLCMT_NGWORD_MASK, $vars['msg']);
}
}
if (!isset($vars['msg'])) return array(
'msg' => '',
'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
$comment = str_replace('$msg', $vars['msg'], PLUGIN_CTRLCMT_FORMAT_MSG);
if (isset($vars['name']) || ($vars['nodate'] != '1')) {
$_name = (!isset($vars['name']) || $vars['name'] == '') ? $_no_name : $vars['name'];
$_name2 = $_name;
if (PLUGIN_CTRLCMT_NONAME == "") {
$PLUGIN_CTRLCMT_NONAME = "";
} else {
$PLUGIN_CTRLCMT_NONAME = "[[" . PLUGIN_CTRLCMT_NONAME . "]]";
}
$_name = ($_name == '') ? $PLUGIN_CTRLCMT_NONAME : str_replace('$name', $_name, PLUGIN_CTRLCMT_FORMAT_NAME);
if (PLUGIN_CTRLCMT_IPCRY) {
$_cryedip = substr(base64_encode(hash_hmac("sha1", date("Ymd") . $_SERVER["REMOTE_ADDR"], PLUGIN_CTRLCMT_IPCRYPASS)) , 0, 8);
$_ipcry = " &size(10){[" . $_cryedip . "]};";
} else {
$_ipcry = "";
}
$_now = ($vars['nodate'] == '1') ? '' : str_replace('$now', $now, PLUGIN_CTRLCMT_FORMAT_NOW);
if (PLUGIN_CTRLCMT_SAVEIP) {
$iplog_json = array();
$iplog_loadjson = array();
$iplogIsExist = false;
if (file_exists(PLUGIN_CTRLCMT_DIR . '/cmt/.htaccess') == false) {
mkdir(PLUGIN_CTRLCMT_DIR);
mkdir(PLUGIN_CTRLCMT_DIR . "/cmt");
$open_ht = fopen(PLUGIN_CTRLCMT_DIR . "/cmt/.htaccess", 'a');
@fwrite($open_ht, "Require all denied");
fclose($open_ht);
}
if (file_exists(PLUGIN_CTRLCMT_DIR . '/cmt/log.json')) {
$iplog_loadjson = json_decode(file_get_contents(PLUGIN_CTRLCMT_DIR . "/cmt/log.json") , true);
$iplogIsExist = true;
}
$iplog_json[] = array(
'name' => $_name2,
'comment' => $comment,
'ipcry' => $_cryedip,
'date' => $now,
'page' => $vars['refer'],
'ip_address' => $_SERVER["REMOTE_ADDR"],
);
if ($iplogIsExist == true) {
$iplog_json = array_merge($iplog_json, $iplog_loadjson);
}
file_put_contents(PLUGIN_CTRLCMT_DIR . "/cmt/log.json", json_encode($iplog_json, JSON_PRETTY_PRINT));
}
$comment = str_replace("\$MSG\$", $comment, PLUGIN_CTRLCMT_FORMAT_STRING);
$comment = str_replace("\$NAME\$", $_name, $comment);
$comment = str_replace("\$IPCRY\$", $_ipcry, $comment);
$comment = str_replace("\$NOW\$", $_now, $comment);
}
$comment = '-' . $head . ' ' . $comment;
$postdata = '';
$comment_no = 0;
$above = (isset($vars['above']) && $vars['above'] == '1');
$comment_added = false;
foreach (get_source($vars['refer']) as $line)
{
if (!$above) $postdata .= $line;
if (preg_match('/^#ctrlcmt/i', $line) && $comment_no++ == $vars['ctrlcmt_no'])
{
$comment_added = true;
if ($above)
{
$postdata = rtrim($postdata) . "\n" . $comment . "\n" . "\n"; // Insert one blank line above #commment, to avoid indentation
}
else
{
$postdata = rtrim($postdata) . "\n" . $comment . "\n";
}
}
if ($above) $postdata .= $line;
}
$title = $_title_updated;
$body = '';
if ($comment_added)
{
// new comment added
if (md5(get_source($vars['refer'], true, true)) !== $vars['digest'])
{
$title = $_title_comment_collided;
$body = $_msg_comment_collided . make_pagelink($vars['refer']);
}
page_write($vars['refer'], $postdata);
}
else
{
// failed to add the comment
$title = $_title_comment_collided;
$body = $_comment_plugin_fail_msg . make_pagelink($vars['refer']);
}
$retvars['msg'] = $title;
$retvars['body'] = $body;
$vars['page'] = $vars['refer'];
return $retvars;
}
elseif (!isset($vars['do']))
{
$msg = "CtrlCmt";
$addons_form = '';
$addons_tab = '';
session_start();
if ($vars['logout'] == "true"){
unset($_SESSION['ctrlcmt_loginpass']);
$msg = $lang['msg_logout'];
}
if (pkwk_login($vars['ctrlcmt_loginpass'])){
$_SESSION['ctrlcmt_loginpass'] = $vars['ctrlcmt_loginpass'];
}elseif (isset($vars['ctrlcmt_loginpass'])){
$msg = $lang['err_login'];
}
if (pkwk_login($_SESSION['ctrlcmt_loginpass'])){
if (isset($vars['setting_save'])){
$filedata = file_get_contents(PLUGIN_DIR.basename(__FILE__));
if (isset($vars['PLUGIN_CTRLCMT_FORMAT_STRING'])){
$vars['PLUGIN_CTRLCMT_FORMAT_STRING'] = str_replace('$','\\\$',$vars['PLUGIN_CTRLCMT_FORMAT_STRING']);
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_FORMAT_STRING\'\s*?,\s*?"(.*?)"\s*?\);/u', "define('PLUGIN_CTRLCMT_FORMAT_STRING', \"" . $vars['PLUGIN_CTRLCMT_FORMAT_STRING'] . "\");", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_NONAME'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_NONAME\'\s*?,\s*?"(.*?)"\s*?\);/u', "define('PLUGIN_CTRLCMT_NONAME', \"" . $vars['PLUGIN_CTRLCMT_NONAME'] . "\");", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_MULTILINE'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_MULTILINE\'\s*?,\s*?(true|false)\s*?\);/u', "define('PLUGIN_CTRLCMT_MULTILINE', " . $vars['PLUGIN_CTRLCMT_MULTILINE'] . ");", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_ROWS'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_ROWS\'\s*?,\s*?\'(.*?)\'\s*?\);/u', "define('PLUGIN_CTRLCMT_ROWS', '" . $vars['PLUGIN_CTRLCMT_ROWS'] . "');", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_NGWORD'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_NGWORD\'\s*?,\s*?"(.*?)"\s*?\);/u', "define('PLUGIN_CTRLCMT_NGWORD', \"" . $vars['PLUGIN_CTRLCMT_NGWORD'] . "\");", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_NGWORD_MODE'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_NGWORD_MODE\'\s*?,\s*?\'(.*?)\'\s*?\);/u', "define('PLUGIN_CTRLCMT_NGWORD_MODE', '" . $vars['PLUGIN_CTRLCMT_NGWORD_MODE'] . "');", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_NGWORD_MASK'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_NGWORD_MASK\'\s*?,\s*?\'(.*?)\'\s*?\);/u', "define('PLUGIN_CTRLCMT_NGWORD_MASK', '" . $vars['PLUGIN_CTRLCMT_NGWORD_MASK'] . "');", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_IPCRY'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_IPCRY\'\s*?,\s*?(true|false)\s*?\);/u', "define('PLUGIN_CTRLCMT_IPCRY', " . $vars['PLUGIN_CTRLCMT_IPCRY'] . ");", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_SAVEIP'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_SAVEIP\'\s*?,\s*?(true|false)\s*?\);/u', "define('PLUGIN_CTRLCMT_SAVEIP', " . $vars['PLUGIN_CTRLCMT_SAVEIP'] . ");", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_DIR'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_DIR\'\s*?,\s*?\'(.*?)\'\s*?\);/u', "define('PLUGIN_CTRLCMT_DIR', '" . $vars['PLUGIN_CTRLCMT_DIR'] . "');", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_DIRECTION_DEFAULT'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_DIRECTION_DEFAULT\'\s*?,\s*?\'(.*?)\'\s*?\);/u', "define('PLUGIN_CTRLCMT_DIRECTION_DEFAULT', '" . $vars['PLUGIN_CTRLCMT_DIRECTION_DEFAULT'] . "');", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_SIZE_MSG'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_SIZE_MSG\'\s*?,\s*?(.*?)\s*?\);/u', "define('PLUGIN_CTRLCMT_SIZE_MSG', " . $vars['PLUGIN_CTRLCMT_SIZE_MSG'] . ");", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_SIZE_NAME'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_SIZE_NAME\'\s*?,\s*?(.*?)\s*?\);/u', "define('PLUGIN_CTRLCMT_SIZE_NAME', " . $vars['PLUGIN_CTRLCMT_SIZE_NAME'] . ");", $filedata, 1);
}
if (isset($vars['PLUGIN_CTRLCMT_BLACKIPLIST'])){
$filedata = preg_replace('/define\(\s*?\'PLUGIN_CTRLCMT_BLACKIPLIST\'\s*?,\s*?\'(.*?)\'\s*?\);/u', "define('PLUGIN_CTRLCMT_BLACKIPLIST', '" . $vars['PLUGIN_CTRLCMT_BLACKIPLIST'] . "');", $filedata, 1);
}
file_put_contents(PLUGIN_DIR.basename(__FILE__), $filedata);
echo "saved";
exit;
}
if (exist_plugin("manageform")){
$addons_tab .= "| コメントログ |
|---|