コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
ファイル: Captcha_handler.php プロジェクト: Rih/rih.github.io
 public function index()
 {
     $commandString = $this->input->get('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;
     }
     $this->output->cache(0);
     $this->output->set_output($responseBody);
 }
コード例 #3
0
<?php

session_start();
LBD_HttpHelper::FixEscapedQuerystrings();
LBD_HttpHelper::CheckForIgnoredRequests();
// There are several Captcha commands accessible through the Http interface;
// first we detect which of the valid commands is the current Http request for.
if (!array_key_exists('get', $_GET) || !LBD_StringHelper::HasValue($_GET['get'])) {
    LBD_HttpHelper::BadRequest('command');
}
$commandString = LBD_StringHelper::Normalize($_GET['get']);
$command = LBD_CaptchaHttpCommand::FromQuerystring($commandString);
switch ($command) {
    case LBD_CaptchaHttpCommand::GetImage:
        GetImage();
        break;
    case LBD_CaptchaHttpCommand::GetSound:
        GetSound();
        break;
    case LBD_CaptchaHttpCommand::GetValidationResult:
        GetValidationResult();
        break;
    default:
        LBD_HttpHelper::BadRequest('command');
        break;
}
// Returns the Captcha image binary data
function GetImage()
{
    // saved data for the specified Captcha object in the application
    $captcha = GetCaptchaObject();