[ '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 .= "
  • PukiWikiManageForm
  • "; $addons_form .= "
    "; } //- $PLUGIN_CTRLCMT_FORMAT_STRING = PLUGIN_CTRLCMT_FORMAT_STRING; $PLUGIN_CTRLCMT_NONAME = PLUGIN_CTRLCMT_NONAME; $PLUGIN_CTRLCMT_ROWS = PLUGIN_CTRLCMT_ROWS; $PLUGIN_CTRLCMT_NGWORD = PLUGIN_CTRLCMT_NGWORD; $PLUGIN_CTRLCMT_NGWORD_MASK = PLUGIN_CTRLCMT_NGWORD_MASK; $PLUGIN_CTRLCMT_BLACKIPLIST = PLUGIN_CTRLCMT_BLACKIPLIST; $PLUGIN_CTRLCMT_SIZE_MSG = PLUGIN_CTRLCMT_SIZE_MSG; $PLUGIN_CTRLCMT_SIZE_NAME = PLUGIN_CTRLCMT_SIZE_NAME; if(PLUGIN_CTRLCMT_SAVEIP == true){ $PLUGIN_CTRLCMT_SAVEIP_TRUE = "selected"; }else if(PLUGIN_CTRLCMT_SAVEIP == false){ $PLUGIN_CTRLCMT_SAVEIP_FALSE = "selected"; } if(PLUGIN_CTRLCMT_IPCRY == true){ $PLUGIN_CTRLCMT_IPCRY_TRUE = "selected"; }else if(PLUGIN_CTRLCMT_IPCRY == false){ $PLUGIN_CTRLCMT_IPCRY_FALSE = "selected"; } if(PLUGIN_CTRLCMT_MULTILINE == true){ $PLUGIN_CTRLCMT_MULTILINE_TRUE = "selected"; }else if(PLUGIN_CTRLCMT_MULTILINE == false){ $PLUGIN_CTRLCMT_MULTILINE_FALSE = "selected"; } if(PLUGIN_CTRLCMT_NGWORD_MODE == "stop"){ $PLUGIN_CTRLCMT_NGWORD_MODE_STOP = "selected"; }else if(PLUGIN_CTRLCMT_NGWORD_MODE == "hide"){ $PLUGIN_CTRLCMT_NGWORD_MODE_HIDE = "selected"; }else if(PLUGIN_CTRLCMT_NGWORD_MODE == "false"){ $PLUGIN_CTRLCMT_NGWORD_MODE_FALSE = "selected"; } if (file_exists(PLUGIN_CTRLCMT_DIR . '/cmt/log.json')) { $commentlogs = ''; $log_json = json_decode(file_get_contents(PLUGIN_CTRLCMT_DIR . "/cmt/log.json") , true); foreach($log_json as $value){ $commentlogs .= << {$lang['name']} {$value['name']} {$lang['comment']} {$value['comment']} ID {$value['ipcry']} {$lang['date']} {$value['date']} {$lang['page']} {$value['page']} {$lang['ip_address']} {$value['ip_address']}
    EOD; } }else{ $commentlogs = << {$lang['err_iplog']} EOD; } //- $body = <<

    {$lang['controlpanel']}

    • {$lang['settings']}
    • {$lang['comment_log']}
    • {$addons_tab}
    • {$lang['logout']}
    標準設定
    出力コメントフォーマット
    名前未入力時の自動割り当てネーム
    メッセージの入力フォームのサイズ
    名前の入力フォームのサイズ
    複数行コメント
    複数行数
    スパム対策設定
    IPアドレス/コメントの保存
    保存されたログはコメントログで確認できます。
    ブラックIPリスト
    ブラックIPリストに入れられたIPアドレスの使用者はエラーメッセージが表示され、CtrlCmtでコメントができなくなります。
    「,」で複数指定が可能。
    自作自演防止ID生成機能
    禁止ワード設定
    NGワード対策モード
    マスク...NGワードが存在する場合は、NGワードを「NGワードのマスク」で設定した文字列に置き換えられる。
    エラー...NGワードが存在する場合は、投稿を拒否し、エラー画面を表示する。
    NGワード
    正規表現の利用が可能。「,」で複数指定が可能。
    NGワードのマスク
    NGワード対策モードがマスクの場合のみ、使われる。
    ※入力フォームでは「'」や「"」の特殊文字が使えない場合がございます。
     どうしても利用したい場合は文字コードを利用するか、直接ctrlcmt.inc.phpを編集してください。
    {$commentlogs}
    コメントログ
    {$addons_form}
    EOD; return array('msg' => $msg, 'body' => $body); } $body = <<コントロールパネルへログイン
    管理者パスワード:
    EOD; return array('msg' => $msg, 'body' => $body); } } function plugin_ctrlcmt_inline() { global $vars, $digest, $_btn_comment, $_btn_name, $_msg_comment; static $numbers = array(); static $comment_cols = PLUGIN_CTRLCMT_SIZE_MSG; static $comment_rows = PLUGIN_CTRLCMT_ROWS; if (PKWK_READONLY) return ''; // Show nothing $page = $vars['page']; if (! isset($numbers[$page])) $numbers[$page] = 0; $comment_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_CTRLCMT_DIRECTION_DEFAULT); $script = get_page_uri($page); $s_page = htmlsc($page); if (PLUGIN_CTRLCMT_MULTILINE == true){ $msg_input_element = "
    \n\n
    \n"; } else { $msg_input_element = ''; } $string = <<
    $nametags {$msg_input_element}
    EOD; return $string . (exist_plugin("inputtoolbar") ? "\n" . plugin_inputtoolbar_convert() : ''); }