Riddlecaptcha.plugin

From FUDforum Wiki
Jump to: navigation, search

Riddleaptcha.plugin is a plugin that presents users with simple questions (like a riddle to solve or a registration code) instead of FUDforum's default CAPTCHA challenge.

Contents

Prerequisites

None, this plugin can be uploaded and activated as-is on any forum (FUDforum 3.0.0 or higher).

Usage

If enabled, users will see a riddlecaptcha when trying to register or when posting anonymously.

Code (FUDforum 3.0.9 or higher)

File riddlecaptcha.plugin:

<?php
// Initialize plugin.
plugin_add_hook('CAPTCHA', 'plugin_riddlecaptcha');

// Implement a simple riddle CAPTCHA.
function plugin_riddlecaptcha() {
	$riddles = array(
		array('Are you a spammer? (yes or no)', 'NO'),
		array('Are you human? (yes or no)', 'YES'),
		array('Do you hate spam? (yes or no)', 'YES'),
		array('Do you solve captchas for money? (yes or no)', 'NO'),
		array('Fire is... (hot or cold)', 'HOT'),
		array('Ice is... (hot or cold)', 'COLD'),
		array('Enter the value of ten plus six', '16'),
		array('Enter the value of 5 plus seven', '12'),
		array('Please type the second word in this sentence.', 'TYPE'),
		array('What word is fourth in this sentence?', 'FOURTH')
	);

	$riddle = $riddles[ array_rand($riddles) ];

	$text = $riddle[0] .'<br />';
	$text .= '<input type="text" name="turing_test" id="turing_test" size="25"  required="required" />';
	$text .= '<input type="hidden" name="turing_res" value="'. md5($riddle[1]) .'" />';

	return $text;
}

Old code (before FUDforum 3.0.9)

File riddlecaptcha.plugin:

<?php
// Initialize plugin.
plugin_add_hook('CAPTCHA', 'plugin_riddlecaptcha');

// Implement a simple riddle CAPTCHA.
function plugin_riddlecaptcha() {
	$riddles = array(
		array('Are you a spammer? (yes or no)', 'NO'),
		array('Are you human? (yes or no)', 'YES'),
		array('Do you hate spam? (yes or no)', 'YES'),
		array('Do you solve captchas for money? (yes or no)', 'NO'),
		array('Fire is... (hot or cold)', 'HOT'),
		array('Ice is... (hot or cold)', 'COLD'),
		array('Enter the value of ten plus six', '16'),
		array('Enter the value of 5 plus seven', '12'),
		array('Please type the second word in this sentence.', 'TYPE'),
		array('What word is fourth in this sentence?', 'FOURTH')
	);

	return $riddles[ array_rand($riddles) ];
}

Also see

Languages
Personal tools