/**
  * Get the captcha image or sound or validation result.
  */
 public function GetCaptchaResponse()
 {
     if (is_null($this->Captcha)) {
         HttpHelper::BadRequest('captcha');
     }
     $commandString = $this->GetUrlParameter('get');
     if (!\LBD_StringHelper::HasValue($commandString)) {
         \LBD_HttpHelper::BadRequest('command');
     }
     $command = \LBD_CaptchaHttpCommand::FromQuerystring($commandString);
     switch ($command) {
         case \LBD_CaptchaHttpCommand::GetImage:
             $responseBody = $this->GetImage();
             break;
         case \LBD_CaptchaHttpCommand::GetSound:
             $responseBody = $this->GetSound();
             break;
         case \LBD_CaptchaHttpCommand::GetValidationResult:
             $responseBody = $this->GetValidationResult();
             break;
         default:
             \LBD_HttpHelper::BadRequest('command');
             break;
     }
     // disallow audio file search engine indexing
     header('X-Robots-Tag: noindex, nofollow, noarchive, nosnippet');
     echo $responseBody;
     exit;
 }
 /**
  * Get contents of Captcha resources (js, css, gif files).
  *
  * @param string  $p_FileName
  * @return string
  */
 public function GetResource($p_FileName)
 {
     $resourcePath = realpath(Path::GetPublicDirPathInLibrary() . $p_FileName);
     if (!is_readable($resourcePath)) {
         HttpHelper::BadRequest('command');
     }
     // allow caching
     HttpHelper::AllowCache();
     // captcha resource file information
     $fileInfo = pathinfo($resourcePath);
     $fileLength = filesize($resourcePath);
     $fileContents = file_get_contents($resourcePath);
     $mimeType = self::GetMimeType($fileInfo['extension']);
     return (new Response($fileContents, 200))->header('Content-Type', $mimeType)->header('Content-Length', $fileLength);
 }