Captchas

General
The CAPTCHA plugin system is designed to allow any kind of anti-BOT without having to edit files. The CAPTCHA infrastructure of 3.0.5 was refactored into captcha_abstract.php. As a naming convention, all CAPTCHA plugins have to end with "_plugin.php" and begin with the CAPTCHA's class name. I.e. a CAPTCHA class named "phpbb_captcha_gd" has to be defined in a file named "phpbb_captcha_gd_plugin.php".

Usage
The use of the captcha plugins is closely related to the old system. On the style side, a typical example would be (plus the actual form around it):

In php, the corresponding code would look like this. (the code does not include the parts where the actual form gets processed. It is just the part of an hypothetical page that deals with CAPTCHAs:

//	// Get the captcha instance include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_POST);

// Put any errors messages that occur into the $error array // Of course this is only an example, you do not need to use this method of error handling $error = array; $s_hidden_fields = ''; $submit = request_var('submit', false); // 

if ($submit) {		$visual_confirmation_response = $captcha->validate; if ($visual_confirmation_response) {			$error[] = $visual_confirmation_response; }

//  if (!sizeof($error)) {			// No errors => invalidate the question // IMPORTANT: Only do this when the action was really successful! // -> otherwise the captcha would remain solved and a spammer //     could keep spamming without solving a CAPTCHA $captcha->reset; }		else if ($captcha->is_solved) {			// okay, captcha solved, but something else went wrong. // store the entered code in a hidden field, so that users don't have to enter the captcha twice // assumes that $s_hidden_fields is registered in the template later on			$s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields); }	}

// if the form was not yet submitted or the CAPTCHA was not solved ... if (!$submit || !$captcha->is_solved) {		// ... display the CAPTCHA $template->assign_vars(array( 'S_CONFIRM_CODE'	           => true, 'CAPTCHA_TEMPLATE'             => $captcha->get_template, ));	}

// 

Naming Conventions

 * language files should use the name "captcha_ .php
 * template files should use the name "captcha_ .html
 * acp template files should use the name "captcha_ _acp.html
 * demo template files should use the name "captcha_ _acp_demo.html
 * plugin files have to use the name "phpbb_ _plugin.php