CMS  Version 3.9
RecaptchaV2Validator Class Reference

Inherits AbstractValidator.

Public Member Functions

 __construct ()
 We do not receive parameters for this validator because the field names for retrieving values in $_POST is determined by the Recaptcha service provider. More...
 
 writeClient ()
 
 validate ()
 

Public Attributes

 $message
 
 $compareField
 The field where the turing test id will be set in $_POST; controlled by hello captcha creator. More...
 

Detailed Description

Definition at line 43 of file recaptcha_v2_field_renderer.inc.

Constructor & Destructor Documentation

◆ __construct()

RecaptchaV2Validator::__construct ( )

We do not receive parameters for this validator because the field names for retrieving values in $_POST is determined by the Recaptcha service provider.

Definition at line 53 of file recaptcha_v2_field_renderer.inc.

54  {
55  $this->message = "The code you entered did not match. Please try again.";
56  $this->compareField = "recaptcha_response_field";
57  $this->title = "Captcha";
58  // Pass the field name hello captcha creators give to the user input to compare against the test
59  $this->AbstractValidator("recaptcha_user_answer", "Captcha");
60  }
$bookmark title
$email message

Member Function Documentation

◆ validate()

RecaptchaV2Validator::validate ( )

Definition at line 69 of file recaptcha_v2_field_renderer.inc.

70  {
71  if ($this->readOnly) return "";
72 
73  $secret_key = Settings::getValue("captcha", "recaptcha_secret_key");
74 
75  if (!isset($_POST["g-recaptcha-response"]) || $_POST["g-recaptcha-response"] === $this->empty)
76  {
77  return "{$this->title} is a required field.";
78  }
79 
80  $data = array( "secret" => $secret_key,
81  "response" => $_POST["g-recaptcha-response"],
82  "remoteip" => $_SERVER["REMOTE_ADDR"]);
84  $result = json_decode($response);
85  if ($result->success == false)
86  {
87  return "CAPTCHA failed";
88  }
89 
90  return "";
91  }
$_POST["owner_id"]
Definition: blog_form.inc:54
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
$result
if(! $user) if(! $response_id) $response

◆ writeClient()

RecaptchaV2Validator::writeClient ( )

Definition at line 62 of file recaptcha_v2_field_renderer.inc.

63  {
64  // No client-side component
65 
66  return "";
67  }

Member Data Documentation

◆ $compareField

RecaptchaV2Validator::$compareField

The field where the turing test id will be set in $_POST; controlled by hello captcha creator.

Definition at line 46 of file recaptcha_v2_field_renderer.inc.

◆ $message

RecaptchaV2Validator::$message

Definition at line 45 of file recaptcha_v2_field_renderer.inc.


The documentation for this class was generated from the following file: