SMF – การติดตั้ง reCAPTCHA สำหรับ SMF (ก่อนที่จะกดปุ่ม Post)
การติดตั้ง reCAPTCHA สำหรับ SMF
กรณีใช้ reCAPTCHA ในหน้าสมัครสมาชิกสามารถดาวน์โหลด mod ได้ที่
//custom.simplemachines.org/mods/index.php?mod=1044
แต่ผมจะแนะนำก็คือ การนำ reCAPTCHA มาใช้งานขณะผู้เยี่ยมชมตั้งกระทู้หรือตอบกระทู้
1. สมัครสมาชิกได้ที่ reCAPTCHA Register
หลังจากสมัครเสร็จคุณจะได้รับ Public Key และ Private Key (ใช้ติดต่อสื่อสารระหว่างเซิร์ฟเวอร์และเซิร์ฟเวอร์ของเรา ทำให้ลับยิ่งขึ้น)
2. ดาวน์โหลด reCAPTCHA PHP library ไฟล์สำหรับ PHP
3. แตกไฟล์ library แล้วอับโหลดไฟล์ recaptchalib.php (ใช้ไฟล์เดียว)
– สร้างไดร์เรอทอรี ชื่อ captcha ที่รูท forum
– อับโหลดไฟล์ recaptchalib.php ไปยัง ไดร์เรอทอรี captcha
4. ดาวน์โหลดไฟล์ Post.template.php
/Themes/default/Post.template.php
ค้นหา
[php]
// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
if (!empty($modSettings[‘attachmentCheckExtensions’]))
echo ‘
‘, $txt[‘smf120’], ‘: ‘, $context[‘allowed_extensions’], ‘
‘;
echo ‘
‘, $txt[‘smf121’], ‘: ‘, $modSettings[‘attachmentSizeLimit’], ‘ ‘ . $txt[‘smf211’], !empty($modSettings[‘attachmentNumPerPostLimit’]) ? ‘, ‘ . $txt[‘maxAttachPerPost’] . ‘: ‘ . $modSettings[‘attachmentNumPerPostLimit’] : ”, ”;
}
[/php]
พิมพ์ต่อท้าย
[php]
// Start; Recaptcha on Guest Posts
echo ‘
‘;
if ($context[‘user’][‘is_guest’]) {
require_once(‘captcha/recaptchalib.php’);
$publickey = "your public key"; // you got this from the signup page
echo recaptcha_get_html($publickey);
}
// End; Recaptcha on Guest Posts
[/php]
บรรทัด $publickey = “your public key”; // ให้ระบุ Public Key คุณ
5. ดาวน์โหลดไฟล์ Post.php
/Sources/Post.php
ค้นหา
[php]
"function Post2()"
[/php]
แล้วเพิ่ม
[php]
//reCAPTCHA
require_once(‘captcha/recaptchalib.php’);
$privatekey = "your_private_key";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER[‘REMOTE_ADDR’],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn’t entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
}
[/php]
บรรทัด $privatekey = “your_private_key”; // ให้ระบุ Private Key คุณ
Link of Reference – Using reCAPTCHA with PHP
บทความอื่นๆ ที่เกี่ยวกับการหยุด Spam
2 thoughts on “SMF – การติดตั้ง reCAPTCHA สำหรับ SMF (ก่อนที่จะกดปุ่ม Post)”
หมายความว่าผู้เข้าเยี่ยมชม (guest) สามารถตั้งหระทู้หรือตอบกระทู้ได้โดยที่ไม่ต้อง registation หรือป่าวครับ? ผมกำลังสนใจประเด็นนี้อยู่
น่าจะเข้าใจคงล่ะอย่างกันนะครับ แบบที่คุณเข้าใจ SMF มีฟีเจอร์ทำได้อยู่แล้ว ส่วนเรื่อง reCAPTCHA เป็นตัวเสริมป้องกันพวกสคริปต์ spambot มาโพสต์มั่วๆ ครับ
e.g //www.susethailand.com/suseforum/