Jul 062010
 

I install xHelp module in my XOOPS site and allow anonymous users ticket submission, in order to avoid spam, I add the XOOPS User Register Form captcha function to xHelp module.

My System Overview:
XOOPS 2.4.5 RC3
xHelp 0.78b
php Version 5.2.13

Step 1, Edit the template file, the template for anonymous users add ticket page is xhelp_ anon_addTicket.html. You can find it here, XOOPS Control Panel Home -> Template Set Manager -> xHelp[list].

Edit this template file, add the below lines to after ‘<{* End custom field code *}>’ and before ‘<tr id=”addButtons”>’

<tr>
<td>
<{$xhelp_captcha_caption}>
</td>
<td>
<{$xhelp_captcha_render}>
</td>
</tr>

Step 2, Edit the anon_addTicket.php file, you can find it here, ‘xoops\modules\xhelp\’, add the below lines to after ‘$xoopsTpl->assign(‘xhelp_mimetypes’, $mimes);’, about lines 82 of source file,

xoops_load('XoopsFormCaptcha');
$xhelpCaptcha = new XoopsFormCaptcha();
$xhelpCaptchaCaption = $xhelpCaptcha->getCaption();
$xhelpCaptchaRender = $xhelpCaptcha->render();
$xoopsTpl->assign('xhelp_captcha_caption', $xhelpCaptchaCaption);
$xoopsTpl->assign('xhelp_captcha_render', $xhelpCaptchaRender);

add the below lines to before ‘if(!empty($errors)){‘, about lines 283 of source file,

xoops_load('XoopsCaptcha');
$xoopsCaptcha = XoopsCaptcha::getInstance();
if (!$xoopsCaptcha->verify()) {
$xhelpCaptchaErrorMessage = $xoopsCaptcha->getMessage();
}
if(!empty($xhelpCaptchaErrorMessage)){
$message = $xhelpCaptchaErrorMessage;
header("Location: ".XHELP_BASE_URL."/anon_addTicket.php");
exit();
}

Unresolved: Show the confirmation code validate error message.