26
Here goes - I hope I can make sense of this for you (and me!)
There are 3 parts to adding captcha to a form:
1. Providing the captcha functionality
2. Adding the captcha element to the form
3. Verification of the captcha entry
To
add the captcha functionality to a form, you need to -
1. have the latest version of Frameworks (1.10) on your site, it includes a captcha folder.
2. add '
include_once XOOPS_ROOT_PATH."/Frameworks/captcha/formcaptcha.php";' to the page that creates the form. An alternative method would be to add this line to class/xoopsformloader.php, making the captcha function available for all forms loaded by Xoops
Next, you need to
add the captcha element to the form. The basic method for doing this in a XOOPS form is to use this structure
$form->addElement(&$element, $required = false);For a captcha element, the syntax looks like this -
$xoopsform->addElement(new XoopsFormCaptcha($caption, $name, $skipmember, $numchar, $minfontsize, $maxfontsize, $backgroundtype, $backgroundnum);Putting this all together results in how phppp modified the register.php form (lines 150 - 153)
Quote:
if(@include_once XOOPS_ROOT_PATH."/Frameworks/captcha/formcaptcha.php") {
$cpatcha = new XoopsFormCaptcha();
echo $cpatcha->getCaption().": ".$cpatcha->render();
}
The final step is to
verify the captcha entry when the form is submitted. The basic syntax is
if(@include_once XOOPS_ROOT_PATH."/Frameworks/captcha/captcha.php") {
$xoopsCaptcha = XoopsCaptcha::instance();
if(! $xoopsCaptcha->verify() ) {
echo $xoopsCaptcha->getMessage();
...
}
}Again, using phppp's register.php, lines 177 - 182,
Quote:
if(@include_once XOOPS_ROOT_PATH."/Frameworks/captcha/captcha.php") {
$xoopsCaptcha = XoopsCaptcha::instance();
if(! $xoopsCaptcha->verify() ) {
$stop .= $xoopsCaptcha->getMessage()."
";
}
}
More about using the XoopsForm Library is in the
dev.xoops.org wikiAll of this comes from reading the comments in formcaptcha.php (Frameworks/captcha/formcaptcha.php) and the documentation about XoopsForms on dev.xoops.org
That's about as far as I can go with this...
Hope it helps!