วันศุกร์ที่ 18 กุมภาพันธ์ พ.ศ. 2554

Anti-Bot: Are You Human/Bot?

Anti-Bot: Are You Human/Bot?
ต้นฉบับ  http://custom.simplemachines.org/mods/index.php?mod=999

ม็อดตัวนี้คนเขาทำมานานแล้ว และไม่มีการอัพเดตเวอร์ชันมานาน สนับสนุนแค่นี้
1.1.4, 1.1.7, 1.1.8, 1.1.9, 1.1.10, 2.0 Beta 3 Public, 2.0 RC1, 2.0 RC1-1, 2.0 RC1.2 
ดังนั้น  1.1.12 กับ 2.0 RC4 จึงลงแบบแพ็คเกจไม่ได้ ต้องเมนวลเท่านั้น 
(ยังไงก็ต้องเมนวลอยู่ดี ถ้าใช้ไฟล์ภาษาไทย)

ถึงจะแก่แต่ก็เก๋า กันบอทสมัครสมาชิกได้ชะงัดนัก 


สำหรับ 1.1.12
เวอร์ชัน 2.0 RC3-4 ไม่จำเป็นต้องลงม็อดตัวนี้ 
เพราะมันฟังชันตั้งคำถามก่อนสมัครไว้ให้อยู่แล้ว ที่เมนูสแปม 


Themes/default/Register.template.php
ค้นหา

โค๊ด:
// Are there age restrictions in place?

วางก่อนที่ค้นหา
โค๊ด:
## Start MOD Are You Human?
if (!empty($modSettings['are_you_human_s']))
echo '
<tr valign="top">
<td width="40%" valign="top">
<b>', $context['are_you_human_question'], ':</b>
<div class="smalltext">', $txt['are_you_human_desc'], '</div>
</td>
<td>
<select name="', $_SESSION['are_you_human']['name'], '" tabindex="',  $context['tabindex']++, '" class="select">',
$context['are_you_human_answers'], '
</select>
</td>
</tr>';
## End MOD Are You Human?


ค้นหา

โค๊ด:
<input type="text" name="coppaPhone" id="coppaPhone_input" value="', !empty($modSettings['coppaPhone']) ? $modSettings['coppaPhone'] : '', '" size="22" maxlength="35" />
</td>
</tr>

วางหลัง
โค๊ด:
<tr class="windowbg2">
<td width="100%" colspan="2" align="center">
<hr />
</td>
</tr><tr class="windowbg2">
<th width="50%" align="right">
<label for="are_you_human_s">', $txt['are_you_human_s'], '</label>:
</th>
<td valign="top">
<input type="checkbox" name="are_you_human_s" id="are_you_human_s"', empty($modSettings['are_you_human_s']) ? '' : ' checked="checked"', ' class="check" />
</td>
</tr><tr class="windowbg2">
<th width="50%" align="right">
<label for="are_you_human_q">', $txt['are_you_human_q'], '</label>:
</th>
<td valign="top">
<select name="are_you_human_q" id="are_you_human_q" >
<option value="0" ', ('0' == $modSettings['are_you_human_q'] ? 'selected="selected"' : '') , '>', $txt['are_you_human_q_0'], '</option>
<option value="1" ', ('1' == $modSettings['are_you_human_q'] ? 'selected="selected"' : '') , '>', $txt['are_you_human_q_1'], '</option>
<option value="2" ', ('2' == $modSettings['are_you_human_q'] ? 'selected="selected"' : '') , '>', $txt['are_you_human_q_2'], '</option>
</select>
</td>
</tr><tr class="windowbg2">
<th width="50%" align="right">
<label for="are_you_human_a">', $txt['are_you_human_a'], '</label>:
</th>
<td valign="top">
<input type="checkbox" name="are_you_human_a" id="are_you_human_a"', empty($modSettings['are_you_human_a']) ? '' : ' checked="checked"', ' class="check" />
</td>
</tr>


Sources/Register.php
ค้นหา
โค๊ด:
// Under age restrictions?

วางก่อน
โค๊ด:
## Start MOD Are You Human? - Generating Code
if (!empty($modSettings['are_you_human_s']))
{
// Generate Random field name
$_SESSION['are_you_human']['name'] = chr(mt_rand(97, 122)) . md5(mt_rand());
$_SESSION['are_you_human']['answer'] = chr(mt_rand(97, 122)) . md5(mt_rand());

// Choice the Question
$context['are_you_human_question'] = $modSettings['are_you_human_q'] >> 1
? $txt['are_you_human_q' . mt_rand(1, 2)]
: ($modSettings['are_you_human_q'] ? $txt['are_you_human_q2'] : $txt['are_you_human_q1']);

// Choice the Answer
$answer_correct = $context['are_you_human_question'] == $txt['are_you_human_q1']
? $txt['are_you_human_answers'][0] : $txt['are_you_human_answers'][1];

// Shuffle the Answers?
if ($modSettings['are_you_human_a'])
shuffle($txt['are_you_human_answers']);

// Create the Options
$context['are_you_human_answers'] = '';
foreach ($txt['are_you_human_answers'] as $value)
$context['are_you_human_answers'] .= '
<option value="' . ($value == $answer_correct ? $_SESSION['are_you_human']['answer'] : chr(mt_rand(97, 122)) . md5(mt_rand())) . '">' . $value . '</option>';
unset($answer_correct);

// This page should be reaload always
header('Cache-Control: no-store');
}
## End MOD Are You Human? - Generating Code

ค้นหา
โค๊ด:
// Are they under age, and under age users are banned?

วางก่อน
โค๊ด:
## Start MOD Are You Human? - Capturing Bots

// Backup & Deleting SuperGlobal
$session = isset($_SESSION['are_you_human']) ? $_SESSION['are_you_human'] : false;
unset($_SESSION['are_you_human']);

// Are You Human?
if (!empty($modSettings['are_you_human_s']))
if (empty($session) || empty($_POST[$session['name']]) || $_POST[$session['name']] != $session['answer'])
fatal_lang_error(empty($session) ? 'are_you_human_expired' : 'are_you_human_fail', false);

// Old way - spammers should be the only one trying this
if (isset($_POST['areyouhuman']))
fatal_lang_error('are_you_human_fail', false);

## End MOD Are You Human? - Capturing Bots


Sources/ManageRegistration.php
ค้นหา
โค๊ด:
'coppaPhone' => !empty($_POST['coppaPhone']) ? $_POST['coppaPhone'] : '',

วางหลัง
โค๊ด:
## MOD Are You Human?
'are_you_human_s' => empty($_POST['are_you_human_s']) ? '0' : '1',
'are_you_human_q' => ereg('[0-2]', $_POST['are_you_human_q']) ? $_POST['are_you_human_q'] : '0',
'are_you_human_a' => empty($_POST['are_you_human_a']) ? '0' : '1',


Themes/default/languages/Modifications.english.php

ค้นหา
โค๊ด:
?>

วางก่อน
โค๊ด:
// Are You Human?
$txt['are_you_human_q1'] = 'Are You Human?';
$txt['are_you_human_q2'] = 'Are You Bot?';
$txt['are_you_human_desc'] = 'Another Anti-Bot Measure';
$txt['are_you_human_answers'][0] = 'Yes';
$txt['are_you_human_answers'][1] = 'No';
$txt['are_you_human_answers'][2] = 'I don\'t know';
$txt['are_you_human_answers'][3] = 'Maybe';
$txt['are_you_human_answers'][4] = 'I think...';
$txt['are_you_human_answers'][5] = 'Waits';
$txt['are_you_human_answers'][6] = 'Hmm'; 
// You can add more Answers for confused the bots

$txt['are_you_human_expired'] = 'This page has expired. Please restart the <a href="' . $scripturl . '?action=register;">registration page</a>.';
$txt['are_you_human_fail'] = 'Please confirm that you are human in order to proceed with registration.<br />
Bots are not allowed to register.';

$txt['are_you_human_s'] = 'Enable MOD Are You Human';
$txt['are_you_human_q'] = 'Select the Question';
$txt['are_you_human_a'] = 'Order Rand the Answers';
$txt['are_you_human_q_0'] = 'Are You Human?';
$txt['are_you_human_q_1'] = 'Are You Bot?';
$txt['are_you_human_q_2'] = 'Random Question';


Themes/default/languages/Modifications.thai-utf8.php
เครดิตภาษาไทย  it-dark.org

ค้นหา
โค๊ด:
?>

วางก่อน
โค๊ด:
/Are You Human?it-dark.org
$txt['are_you_human_q1'] = 'กรุณาตอบคำถามของท่าน?';
$txt['are_you_human_q2'] = 'กรุณาตอบคำถามของท่าน';
$txt['are_you_human_desc'] = '<font color=yellow>คุณจะไม่สแปมบอร์ดใช่หรือไม่. </font>';
$txt['are_you_human_answers'][0] = 'ไม่ใช่';
$txt['are_you_human_answers'][1] = 'ใช่';
$txt['are_you_human_answers'][2] = 'ฉันไม่รู้';
$txt['are_you_human_answers'][3] = 'อาจจะใช่';
$txt['are_you_human_answers'][4] = 'คิดว่าน่าจะใช่...';
$txt['are_you_human_answers'][5] = 'รอคิดดูก่อน';
$txt['are_you_human_answers'][6] = 'อืม..';

// You can add more Answers for confused the bots

$txt['are_you_human_expired'] = 'หมดเวลาของการสมัคร. กรุณาเริ่มต้นใหม่ <a href="' . $scripturl . '?
action=register;">สมัครสมาชิก</a>.';
$txt['are_you_human_fail'] = 'กรุณาตรวจสอบคำตอบของคุณ..<br />คุณแอบแฝงเข้ามา ไม่อนุญาติให้ลงทะเบียน.';
$txt['are_you_human_s'] = 'เปิดใช้งาน';
$txt['are_you_human_q'] = 'เลือกคำถาม';
$txt['are_you_human_a'] = 'สุ่มตอบ';
$txt['are_you_human_q_0'] = 'คำถามที่1';
$txt['are_you_human_q_1'] = 'คำถามที่2';
$txt['are_you_human_q_2'] = 'สุมคำถาม';


หลังจากแก้โค๊ดทั้งหมดเสร็จแล้ว ต้องเพิ่มฐานข้อมูล
ดาวน์โหลดไฟล์แนบ install1.php  จากนั้นอัพขึ้นโฮสต์ วางไว้ที่เดียวกับ SSI.php
คลิกเพื่อดาวน์โหลด* install1.php 

จากนั้นเข้าเบราว์เซอร์ แล้วพิมพ์
http://www/.เว็บคุณ.โดเมน/บอร์ด/install1.php

ไม่มีความคิดเห็น:

แสดงความคิดเห็น