Changeset View
Changeset View
Standalone View
Standalone View
core/units/helpers/captcha_helper.php
Show First 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | |||||
// perform validation only when field is found on form | // perform validation only when field is found on form | ||||
list ($id, $field_values) = each($this->Application->GetVar($event->getPrefixSpecial())); | list ($id, $field_values) = each($this->Application->GetVar($event->getPrefixSpecial())); | ||||
if (!array_key_exists('Captcha', $field_values)) { | if (!array_key_exists('Captcha', $field_values)) { | ||||
// when captcha code not submitted | // when captcha code not submitted | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$valid_code = $this->Application->RecallVar($event->getPrefixSpecial() . '_captcha_code'); | $valid_code = $this->Application->RecallVar($event->getPrefixSpecial() . '_captcha_code'); | ||||
if (!$object->GetDBField('Captcha') || ($object->GetDBField('Captcha') != $valid_code)) { | if (!$object->GetDBField('Captcha') || ($object->GetDBField('Captcha') != $valid_code)) { | ||||
// empty code OR codes doesn't match | // empty code OR codes doesn't match | ||||
$object->SetError('Captcha', 'captcha_error', 'lu_captcha_error'); | $object->SetError('Captcha', 'captcha_error', 'lu_captcha_error'); | ||||
$this->Application->StoreVar($event->getPrefixSpecial() . '_captcha_code', $this->GenerateCaptchaCode()); | $this->Application->StoreVar($event->getPrefixSpecial() . '_captcha_code', $this->GenerateCaptchaCode()); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
No newline at end of file | No newline at end of file |