SilverStripe\Recaptcha\RecaptchaField
Provides an {@link FormField} which allows form to validate for non-bot submissions by giving them a challenge to decrypt an image.
Generation and validation of captchas is handled on external server.
This field doesn't save anything back to the form,
and only submits recaptcha-related form-data to an external server.
Synopsis
class RecaptchaField
extends FormField
{
- // members
- public array $options = ;
- public RecaptchaFieldHttpClient $client;
- private static string $public_api_key = '';
- private static string $private_api_key = '';
- private static string $proxy_server = '';
- private static string $proxy_auth = '';
- private static string $api_verify_server = 'https://www.google.com/recaptcha/api/siteverify';
- private static string $recaptcha_js_url = 'https://www.google.com/recaptcha/api.js';
- private static string $recaptcha_noscript_url = 'https://www.google.com/recaptcha/api/fallback?k=%s';
- private static bool $noscript_enabled = false;
- private static string $httpclient_class = RecaptchaFieldHttpClient::class;
- // methods
- public void __construct()
- public void Field()
- public boolean validate()
- protected string recaptchaHttpPost()
- public $this setHttpClient()
- public RecaptchaFieldHttpClient getHttpClient()
Hierarchy
Extends
- SilverStripe\Forms\FormField
Tasks
Line | Task |
---|---|
169+ | implement socket timeout handling (or switch to curl?) |
Members
private
- $api_verify_server
—
string
Verify API server address (relative) - $httpclient_class — string
- $noscript_enabled
—
SilverStripe\Recaptcha\bool
Default the noscript option to false - $private_api_key
—
string
Your private API key for a specific domain (get one at https://www.google.com/recaptcha/admin) - $proxy_auth
—
string
Your proxy server authentication - $proxy_server
—
string
Your proxy server details including the port - $public_api_key
—
string
Your public API key for a specific domain (get one at https://www.google.com/recaptcha/admin) - $recaptcha_js_url
—
string
Javascript-address which includes necessary logic from the recaptcha-server. - $recaptcha_noscript_url — string
public
- $client — SilverStripe\Recaptcha\RecaptchaFieldHttpClient
- $options
—
array
Javasript-object formatted as a string, which can contain options about the used theme/language etc.
Methods
protected
- recaptchaHttpPost() — Fires off a HTTP-POST request
public
- __construct()
- Field()
- getHttpClient()
- setHttpClient()
- validate() — Validate by submitting to external service