* 同一spamを投稿されにくくする工夫 [#i5ea33e9]

- ページ: [[BugTrack2]]
- 投稿者: [[teanan]]
- 優先順位: 普通
- 状態: 提案
- カテゴリー: プラグイン
- 投稿日: 2007-10-06 (土) 11:13:23
- バージョン: 

** メッセージ [#jcf07afd]
同じ内容のコメントspamをたくさんのページに投稿される場合があります。現状のcommentプラグインは無防備です。spam投稿のコスト(投稿者の手間)を少しでも高くするための工夫を施しましょう。

** パッチ [#x0d1fc85]
PukiWiki-1.4.7(comment.inc.php v1.36)からの差分です。

 --- comment.inc.php.orig	Sat Jan 28 23:54:51 2006
 +++ comment.inc.php	Sat Oct 06 10:48:42 2007
 @@ -18,6 +18,8 @@
  define('PLUGIN_COMMENT_FORMAT_NOW',  '&new{$now};');
  define('PLUGIN_COMMENT_FORMAT_STRING', "\x08MSG\x08 -- \x08NAME\x08 \x08NOW\x08");
  
 +define('PLUGIN_COMMENT_MIXTURE', 'comment_mixture');
 +
  function plugin_comment_action()
  {
  	global $script, $vars, $now, $_title_updated, $_no_name;
 @@ -51,9 +53,11 @@
   	$postdata    = '';
  	$comment_no  = 0;
  	$above       = (isset($vars['above']) && $vars['above'] == '1');
 +	$hash        = isset($vars['hash'])? $vars['hash'] : '';
  	foreach (get_source($vars['refer']) as $line) {
 		if (! $above) $postdata .= $line;
 -		if (preg_match('/^#comment/i', $line) && $comment_no++ == $vars['comment_no']) {
 +		$check = plugin_comment_gethash($vars['refer'], $comment_no);
 +		if (preg_match('/^#comment/i', $line) && $comment_no++ == $vars['comment_no'] && $hash == $check) {
 			if ($above) {
 				$postdata = rtrim($postdata) . "\n" .
 					$comment . "\n" .
 @@ -93,6 +97,7 @@
  
  	if (! isset($numbers[$vars['page']])) $numbers[$vars['page']] = 0;
  	$comment_no = $numbers[$vars['page']]++;
 +	$hash = plugin_comment_gethash($vars['page'], $comment_no);
  
  	$options = func_num_args() ? func_get_args() : array();
  	if (in_array('noname', $options)) {
 @@ -118,6 +123,7 @@
    <input type="hidden" name="plugin" value="comment" />
    <input type="hidden" name="refer"  value="$s_page" />
    <input type="hidden" name="comment_no" value="$comment_no" />
 +  <input type="hidden" name="hash"   value="$hash" />
    <input type="hidden" name="nodate" value="$nodate" />
    <input type="hidden" name="above"  value="$above" />
    <input type="hidden" name="digest" value="$digest" />
 @@ -130,4 +136,12 @@
  
  	return $string;
  }
 +
 +function plugin_comment_gethash($page, $comment_no)
 +{
 +	global $page_title;
 +	return md5($page_title . $page . $comment_no . $_SERVER['REMOTE_ADDR'] .
 +			PLUGIN_COMMENT_MIXTURE);
 +}
 +
  ?>

--------

#comment


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Site admin: PukiWiki Development Team

PukiWiki 1.5.4+ © 2001-2022 PukiWiki Development Team. Powered by PHP 5.6.40-0+deb8u12. HTML convert time: 0.063 sec.

OSDN