Development Captcha
From Cloudrexx Development Wiki
Contents
Client Integration (Template/Content)
<form>
...
<label>[[TXT_MODULE_CAPTCHA]]</label>
[[MODULE_CAPTCHA_CODE]]
...
</form>
Server Integration (PHP)
$this->objTemplate->setVariable(array(
'TXT_MODULE_CAPTCHA' => $_CORELANG['TXT_CORE_CAPTCHA'],
'MODULE_CAPTCHA_CODE' => \FWCaptcha::getInstance()->getCode(),
));
Validation
if (!\FWCaptcha::getInstance()->check()) {
throw new Exception('Invalid Captcha');
}
Older Contrexx Versions (<3.0)
- Client-Side (Template/Content)
<form>
...
<img src="[[CONTACT_CAPTCHA_URL]]" />
<input type="text" name="modulenameFormCaptcha"/>
...
</form>
- Server-Side (PHP)
include_once ASCMS_LIBRARY_PATH.'/spamprotection/captcha.class.php';
$objCaptcha = new Captcha();
$this->_objTpl->setVariable('CONTACT_CAPTCHA_URL', $objCaptcha->getUrl());
- Validation
if (!$objCaptcha->check($_POST['modulenameFormCaptcha'])) {
throw new Exception($_ARRAYLANG['TXT_CORE_INVALID_CAPTCHA');
}