Development Captcha

From Cloudrexx Development Wiki
Jump to: navigation, search

Client Integration (Template/Content)

<highlightsyntax><form> ... <label>TXT_MODULE_CAPTCHA</label> MODULE_CAPTCHA_CODE ... </form> </highlightsyntax>

Server Integration (PHP)

<highlightsyntax>$this->objTemplate->setVariable(array(

   'TXT_MODULE_CAPTCHA'   => $_CORELANG['TXT_CORE_CAPTCHA'],
   'MODULE_CAPTCHA_CODE'  => \FWCaptcha::getInstance()->getCode(),

)); </highlightsyntax>

Validation

<highlightsyntax>if (!\FWCaptcha::getInstance()->check()) {

   throw new Exception('Invalid Captcha');

} </highlightsyntax>


Older Contrexx Versions (<3.0)

Client-Side (Template/Content)

<highlightsyntax><form> ... <img src="CONTACT_CAPTCHA_URL" /> <input type="text" name="modulenameFormCaptcha"/> ... </form> </highlightsyntax>

Server-Side (PHP)

<highlightsyntax>include_once ASCMS_LIBRARY_PATH.'/spamprotection/captcha.class.php'; $objCaptcha = new Captcha(); $this->_objTpl->setVariable('CONTACT_CAPTCHA_URL', $objCaptcha->getUrl()); </highlightsyntax>

Validation

<highlightsyntax>if (!$objCaptcha->check($_POST['modulenameFormCaptcha'])) {

   throw new Exception($_ARRAYLANG['TXT_CORE_INVALID_CAPTCHA');

} </highlightsyntax>