-
☆ A M B ☆
- 24,524 Posts
There are several snippets that use the default MODx captcha mechanism; webLogin and eForm are two that come to mind. If you look at the code in the assets/snippets/eform/eform.inc.php file and do a search for "veriword", you’ll see how it’s done. The captcha form is set up around line 566:
// set vericode
if($vericode) {
$_SESSION['eForm.VeriCode'] = $fields['vericode'] = substr(uniqid(''),-5);
$fields['verimageurl'] = $modx->config['base_url'].'manager/includes/veriword.php?rand='.rand();
}
and the submission is validated around line 172:
# check vericode
if($vericode) {
//add support for captcha code - thanks to Djamoer
$code = $_SESSION['veriword'] ? $_SESSION['veriword'] : $_SESSION['eForm.VeriCode'];
if($fields['vericode']!=$code) {
$vMsg[count($vMsg)]=$_lang['ef_failed_vericode'];
$rClass['vericode']=$invalidClass; //added in 1.4.4
}
}