えせキャプチャシステム

著者: momokuri Eメール

大垣さんとおしゃべりしたときに、えせキャプチャシステムについてのアイディアをいただいたので、早速(といっても、あれから一ヶ月くらいたっていますが)実装しました。

実装イメージは、本記事にコメントをするリンクを押してみてください。

...

変更点は以下の通りです。

skins/_feedback.phpの151行めに


// get values for the ese-capture hack
$comment_test_question = $Settings->get('comment_test_query');
$comment_test_answer = $Settings->get('comment_test_value');
$comment_test_wrong = $Settings->get('comment_test_reject');

追加。

185行めのform_text( 'url', $comment_author_url, 40, T_('Site/Url'), T_('Your URL will be displayed.'), 100, 'bComment' );
の下に、


// this is for the ese-capture hack
if (is_logged_in())
{
echo '<input type="hidden" name="is_human" value="'.$comment_test_answer.'" />';
} else {
echo '<img src="/img/'.$comment_test_question.'" height="80" class="bCapture" />';
form_text( 'is_human', '', 10, T_('Simple Caputure Test'), T_('Please enter above number'), 50, 'bCapture' );
}

を追加。

つづいて、admin/_set_general.form.phpの71行めに

// this is for the ese-capture hack
form_text( 'comment_test_query', $Settings->get('comment_test_query'), 80, T_('Ese-capture Test filename'), '
'.T_('This is what visitors will see when they try to comment.'), 255 );
form_text( 'comment_test_value', $Settings->get('comment_test_value'), 80, T_('Turing Test Answer'), '
'.T_('This is EXACTLY what you expect them to put in the form field.'), 255 );
form_text( 'comment_test_reject', $Settings->get('comment_test_reject'), 80, T_('Failed Test Statement'), '
'.T_('This is what they see when they don\'t enter your answer correctly.'), 255 );

を追加。おなじくadmin/b2options.phpの85行め $Settings->set( 'user_minpwdlen', $user_minpwdlen );の直後に


// this is for the ese-capture hack
param( 'comment_test_query', 'string', true );
$Settings->set( 'comment_test_query', $comment_test_query );
param( 'comment_test_value', 'string', true );
$Settings->set( 'comment_test_value', $comment_test_value );
param( 'comment_test_reject', 'string', true );
$Settings->set( 'comment_test_reject', $comment_test_reject );

を追加する。

最後に、利用しているskinのcssファイルに


input.bCapture,
textarea.bCapture
{
background-color: #eee;
border: 1px solid #ccc;
width: 47%;
padding: 2px;
margin: 0ex;
}
img.bCapture
{
border: 0px;
margin-top: 0px;
margin-right: 0px;
margin-left: 15ex;
}

を追加する。

データベースでは、


INSERT INTO `evo_settings` ( `set_name` , `set_value` )
VALUES (
'comment_test_query', 'filename for ese-capture'
);
INSERT INTO `evo_settings` ( `set_name` , `set_value` )
VALUES (
'comment_test_value', 'valus of image'
);
INSERT INTO `evo_settings` ( `set_name` , `set_value` )
VALUES (
'comment_test_reject', 'message for abuse'
);

のようにして設定を増やす。

使いかたですが、まず管理者になって、設定でファイル名、正解のキーワードや数字、エラーになったときの言葉を入力します。
ファイルは、記事のイメージアップロード機能を使って、img/配下にいれてください。

ファイル名には、img/配下のファイル名のみ指定します。

これは、まだまだ、かなり汚いハックです

この記事へのトラックバック アドレス

トラックバック URL (右をクリックし、ショートカット/リンクをコピーして下さい)

2 コメント

コメント from: momokuri [メンバー] Eメール
momokuri本ハックは、Simple Turing Testというハックをもとに、最小限の労力で実現しています。
とりあえずは、コンセプト証明という意味合いにとらえてください。

たとえば、設定で複数の画像・解答ペアを登録できるようにするとか、画像ファイル名がimgタグのsrc属性に見えないようにして、自動解析できなくするなどの方法を、本来とるべきです。

というわけで、TODOですが、
1) imgタグのsrc属性が一定になるハックをする。
はやります。複数登録ですが、ときどき管理者が画像を置き換えて、設定を手動で変える、ことにしてサボります。
2006/07/02 @ 23:44
コメント from: momokuri [メンバー] Eメール
momokuriskins/_feedback.phpの
echo '<img src="/img/'.$comment_test_question.'"
のところをecho '<img src="/htsrv/esecapture.php"
のように置き換えて、htsrv/esecapture.phpというファイルを

<?php
require_once( dirname(__FILE__) . '/../b2evocore/_main.php' );

$capture_filename = $Settings->get('comment_test_query');
$capture_fnlen = strlen($capture_filename);
if ($capture_fnlen < 4 ){ exit;};
$capture_filetype = substr($capture_filename, $capture_fnlen-3, 3);
header("Content-type: image/png");
switch($capture_filetype){
case "png":
$im = imagecreatefrompng("../img/".$capture_filename);
break;
case "gif":
$im = imagecreatefromgif("../img/".$capture_filename);
break;
default:
$im = imagecreatefrompng("../img/defaultcapture.png");
}
imagepng($im);
imagedestroy($im);
?>

と新規に作成すれば、ファイル名がクライアントに送られなくなります。
2006/07/03 @ 16:51

この投稿にはモデレーション待ちのフィードバックが 1 件あります....

コメントを残す


頂いたEメールアドレスはこのサイト上には表示されません

頂いたURLは表示されます。
(改行が自動で <br /> になります)
(名前、Eメールとウエブサイト)
(ユーザに、メッセージ・フォームを通じた連絡を許可します (あなたのEメール・アドレスは表示されません))