there are several plugins that require CAPTCHAS. The current situation:
- each of those plugins has to include it's own CAPTCHA, and the developer has to write the necessary code or must find and use a CAPTCHA library
- the user can't change the CAPTCHA according to his wishes, and has different looking CAPTCHAS for each plugin
- each of those plugins could include a totally free (MIT license?) minimal CAPTCHA solution, and provide a hook for CAPTCHA plugins
- the user could decide to stick with the minimal CAPTCHA, or could use one (or several) CAPTCHA plugin for the other plugins according to his wishes
Captcha plugins (and the minimal CAPTCHA solution) should provide two functions:
Code: Select all
/**
* Returns the (X)HTML of the CAPTCHA as inline element,
* e.g. <img src="xxx.png" alt="CAPTCHA">
*
* Sets a cookie or a session variable with the CAPTCHA value.
*
* @return string
*/
function captcha_captcha_display() {
...
}
/**
* Returns if the given $value is correct
* compared to the cookie or session variable already set.
*
* @param string The value the user entered.
* @return bool
*/
function captcha_captcha_check($value) {
...
}
- provide a config option $cf[PLUGIN]['captcha_plugin'], where the user can enter the CAPTCHA plugin he wants to use
- copy the minimal CAPTCH solution to the plugin's root folder as captcha.php
- initialize the CAPTCHA plugin:
Code: Select all
if (!file_exists($pth['folder']['plugins'].$plugin_cf[PLUGIN]['captcha_plugin'].'/captcha.php')) {
// fall back to build in functions:
$plugin_cf[PLUGIN]['captcha_plugin'] = PLUGIN;
}
include_once $pth['folder']['plugins'].$plugin_cf[PLUGIN]['captcha_plugin'].'/captcha.php';
Code: Select all
<?php echo call_user_func($plugin_cf[PLUGIN]['captcha_plugin'].'_captcha_display'); ?>
Code: Select all
if (call_user_func($plugin_cf[PLUGIN]['captcha_plugin'].'_captcha_check', $_POST['captcha'])) {
// error: CAPTCHA not recognized
}
IMO that could spare quite some time for developers needing a CAPTCHA for their plugin, and will users give great freedom choosing the CAPTCHA they like. I can even image very special CAPTCHA solutions, e.g. billard balls for a pool club.
I'm gladly willing to provide at least the mentioned minimal CAPTCHA, probably as simple text based solution comparable to the standard CMSimple_XH mailform's CAPTCHA.
Any comments appreciated.
Christoph