Blesta Source Documentation

Turnstile extends AbstractCaptcha

CloudFlare Turnstile integration

Table of Contents

Properties

$Html
$apiUrl
$options
$verifyUrl

Methods

__construct() Initialize Turnstile
buildHtml() Builds the HTML content to render the Turnstile
errors() Retrieves any errors associated with the captcha
getName() Returns the name of the captcha provider
getOptionFields() Gets a list of the options input fields
setOptions() Sets Turnstile options
verify() Verifies whether or not the captcha is valid
setErrors() Sets the given errors
Properties

$apiUrl

private string $apiUrl = 'https://challenges.cloudflare.com/turnstile/v0/api.js'

The CloudFlare Turnstile JavaScript API URL

$options

private array<string|int, mixed> $options = []

An array of options

$verifyUrl

private string $verifyUrl = 'https://challenges.cloudflare.com/turnstile/v0/siteverify'

The CloudFlare Turnstile Verification API URL

Methods

__construct()

Initialize Turnstile

public __construct() : mixed

buildHtml()

Builds the HTML content to render the Turnstile

public buildHtml() : string
Return values
string

The HTML

errors()

Retrieves any errors associated with the captcha

public errors() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of errors

getName()

Returns the name of the captcha provider

public getName() : string
Return values
string

The name of the captcha provider

getOptionFields()

Gets a list of the options input fields

public getOptionFields([array<string|int, mixed> $vars = [] ]) : InputFields
Parameters
$vars : array<string|int, mixed> = []

An array containing the posted fields

Return values
InputFields

An object representing the list of input fields

setOptions()

Sets Turnstile options

public setOptions(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

An array of options including:

  • turnstile_secret_key The Turnstile site key
  • turnstile_site_key The Turnstile shared key
  • lang The user's language (e.g. "en" for English)
  • ip_address The user's IP address (optional)

verify()

Verifies whether or not the captcha is valid

public verify(array<string|int, mixed> $data) : bool
Parameters
$data : array<string|int, mixed>

An array of data to validate against, including:

  • response The value of 'g-turnstile-response' in the submitted form
Return values
bool

Whether or not the captcha is valid

setErrors()

Sets the given errors

protected setErrors(array<string|int, mixed> $errors) : mixed
Parameters
$errors : array<string|int, mixed>

An array of error messages in the format:

  • ['name' => ['type' => 'Error Message']]
Tags
subpackage

core.Util.Captcha.Captchas

copyright

Copyright (c) 2024, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results