Changeset View
Changeset View
Standalone View
Standalone View
core/units/helpers/captcha_helper.php
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Line(s) | |||||
function validateCode($event, $check_request = true) | function validateCode($event, $check_request = true) | ||||
{ | { | ||||
if ($this->Application->isAdmin) { | if ($this->Application->isAdmin) { | ||||
// no captcha codes in admin | // no captcha codes in admin | ||||
return true; | return true; | ||||
} | } | ||||
if ($check_request) { | if ($check_request) { | ||||
// perform validation only when field is found on form | // perform validation only when field is found on form | ||||
Lint: CodingStandard.Commenting.InlineComment.NotCapital: Inline comments must start with a capital letter | |||||
Inline comments must end in full-stops, exclamation marks, or question marks Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
list ($id, $field_values) = each($this->Application->GetVar($event->getPrefixSpecial())); | $field_values = current($this->Application->GetVar($event->getPrefixSpecial())); | ||||
if (!array_key_exists('Captcha', $field_values)) { | if (!array_key_exists('Captcha', $field_values)) { | ||||
Expected 1 spaces before "if" closing bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace: Expected 1 spaces before "if" closing bracket; 0 found | |||||
Expected 1 spaces after "if" opening bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace: Expected 1 spaces after "if" opening bracket; 0 found | |||||
No blank line found before "if" control structure Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.NoLineBeforeOpen: No blank line found before "if" control structure | |||||
// when captcha code not submitted | // when captcha code not submitted | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
/** @var kDBItem $object */ | /** @var kDBItem $object */ | ||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
$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 |
Inline comments must start with a capital letter