MyBB Community Forums

Full Version: Creating a Captcha
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to add a captcha verification to my plugin, but even copying direct code from the MyBB default files (newreply.php, member.php, showthread.php, etc.) doesn't seem to work.

Can somebody guide me here? I need this for a plugin.
personally I just use reCAPTCHA's lib in my own sites, but I'm not sure how you'd do it for a plugin. If all else fails just download the reCAPTCHA lib and include it with your plugin? But even then people will need their own pub & private keys for the reCAPTCHA.
Maybe you could implement something like this.

I haven't tried it myself, it's a simple image verification. Should be able to implement it.

Let me know if you can't and I'll try think up something else Smile
The thing is that I want to use MyBB class to generate my captcha, no extra libs. Those two you guys mentioned would be my last resource Undecided
Try this PHP code;
if($mybb->settings['captchaimage'] == 1 && function_exists('imagepng'))
{
	$randomstr = random_str(5);
	$imagehash = md5(random_str(12));
	$imagearray= array(
		'imagehash' => $imagehash,
		'imagestring' => $randomstr,
		'dateline' => TIME_NOW
	);
	$db->insert_query('captcha', $imagearray);
	eval("\$captcha = \"" . $templates->get('post_captcha') . "\";");
}
And then add {$captcha} in the HTML where you want this to appear. Make sure you add $templates, $captcha; as global object.
^^ That way will not support reCAPTCHA.

I documented how I used the CAPTCHA class for a contact form page here: http://www.mybbstyles.com/thread-new-pag...33#pid1533
Thanks, I was using the right code, but was trying while logged in (when the captcha was intended for guests only Toungue).