function GetValidationResult() { // saved data for the specified Captcha object in the application $captcha = GetCaptchaObject(); if (is_null($captcha)) { LBD_HttpHelper::BadRequest('captcha'); } // identifier of the particular Captcha object instance $instanceId = GetInstanceId(); if (is_null($instanceId)) { LBD_HttpHelper::BadRequest('instance'); } // code to validate $userInput = GetUserInput(); while (ob_get_length()) { ob_end_clean(); } ob_start(); try { // response MIME type & headers header('Content-Type: text/javascript'); header('X-Robots-Tag: noindex, nofollow, noarchive, nosnippet'); // JSON-encoded validation result $result = false; if (isset($userInput) && isset($instanceId)) { $result = $captcha->Validate($userInput, $instanceId, LBD_ValidationAttemptOrigin::Client); $captcha->Save(); } $resultJson = GetJsonValidationResult($result); echo $resultJson; } catch (Exception $e) { header('Content-Type: text/plain'); echo $e->getMessage(); } ob_end_flush(); exit; }
function GetValidationResult() { // saved data for the specified Captcha object in the application $captcha = GetCaptchaObject(); if (is_null($captcha)) { LBD_HttpHelper::BadRequest('captcha'); } // identifier of the particular Captcha object instance $instanceId = GetInstanceId(); if (is_null($instanceId)) { LBD_HttpHelper::BadRequest('instance'); } // code to validate $userInput = GetUserInput(); // response MIME type & headers header('Content-Type: text/javascript'); // JSON-encoded validation result $result = false; if (isset($userInput) && isset($instanceId)) { $result = $captcha->Validate($userInput, $instanceId, LBD_ValidationAttemptOrigin::Client); $captcha->Save(); } session_write_close(); $resultJson = GetJsonValidationResult($result); echo $resultJson; }