PHP Класс Prado\Web\UI\WebControls\TReCaptcha

TReCaptcha displays a reCAPTCHA (a token displayed as an image) that can be used to determine if the input is entered by a real user instead of some program. It can also prevent multiple submits of the same form either by accident, or on purpose (ie. spamming). The reCAPTCHA to solve (a string consisting of two separate words) displayed is automatically generated by the reCAPTCHA system at recaptcha.net. However, in order to use the services of the site you will need to register and get a public and a private API key pair, and supply those to the reCAPTCHA control through setting the {@link setPrivateKey PrivateKey} and {@link setPublicKey PublicKey} properties. Currently the reCAPTCHA API supports only one reCAPTCHA field per page, so you MUST make sure that all your input is protected and validated by a single reCAPTCHA control. Placing more than one reCAPTCHA control on the page will lead to unpredictable results, and the user will most likely unable to solve any of them successfully. Upon postback, user input can be validated by calling {@link validate()}. The {@link TReCaptchaValidator} control can also be used to do validation, which provides server-side validation. Calling (@link validate()) will invalidate the token supplied, so all consecutive calls to the method - without solving a new captcha - will return false. Therefore if implementing a multi-stage input process, you must make sure that you call validate() only once, either at the end of the input process, or you store the result till the end of the processing. The following template shows a typical use of TReCaptcha control:
С версии: 3.2
Автор: Bérczi Gábor ([email protected])
Наследование: extends TWebControl, implements Prado\Web\UI\IValidatable
Показать файл Открыть проект

Открытые методы

Метод Описание
getCallbackScript ( )
getClientSideOptions ( )
getCustomTranslations ( )
getIsValid ( ) : boolean Returns true if this control validated successfully.
getLanguage ( )
getPrivateKey ( )
getPublicKey ( )
getResponseFieldName ( )
getTagName ( )
getThemeName ( )
getValidationPropertyValue ( )
onPreRender ( $param ) Checks for API keys
regenerateToken ( )
renderContents ( $writer )
setCallbackScript ( $value )
setCustomTranslations ( $value )
setIsValid ( $value )
setLanguage ( $value )
setPrivateKey ( $value )
setPublicKey ( $value )
setThemeName ( $value )
validate ( )

Защищенные методы

Метод Описание
addAttributesToRender ( $writer )
getChallengeFieldName ( )

Приватные методы

Метод Описание
recaptcha_check_answer ( string $privkey, string $remoteip, string $challenge, string $response, array $extra_params = [] ) : boolean Calls an HTTP POST function to verify if the user's guess was correct
recaptcha_get_html ( string $pubkey, string $error = null, boolean $use_ssl = false ) : string Gets the challenge HTML (javascript and non-javascript version).
recaptcha_http_post ( string $host, string $path, array $data, $port = 80 ) : array Submits an HTTP POST to a reCAPTCHA server
recaptcha_qsencode ( $data ) : string Encodes the given data into a query string format

Описание методов

addAttributesToRender() защищенный Метод

protected addAttributesToRender ( $writer )

getCallbackScript() публичный Метод

public getCallbackScript ( )

getChallengeFieldName() защищенный Метод

protected getChallengeFieldName ( )

getClientSideOptions() публичный Метод

getCustomTranslations() публичный Метод

getIsValid() публичный Метод

Defaults to true.
public getIsValid ( ) : boolean
Результат boolean wether this control validated successfully.

getLanguage() публичный Метод

public getLanguage ( )

getPrivateKey() публичный Метод

public getPrivateKey ( )

getPublicKey() публичный Метод

public getPublicKey ( )

getResponseFieldName() публичный Метод

getTagName() публичный Метод

public getTagName ( )

getThemeName() публичный Метод

public getThemeName ( )

getValidationPropertyValue() публичный Метод

onPreRender() публичный Метод

Checks for API keys
public onPreRender ( $param )

regenerateToken() публичный Метод

public regenerateToken ( )

renderContents() публичный Метод

public renderContents ( $writer )

setCallbackScript() публичный Метод

public setCallbackScript ( $value )

setCustomTranslations() публичный Метод

public setCustomTranslations ( $value )

setIsValid() публичный Метод

public setIsValid ( $value )

setLanguage() публичный Метод

public setLanguage ( $value )

setPrivateKey() публичный Метод

public setPrivateKey ( $value )

setPublicKey() публичный Метод

public setPublicKey ( $value )

setThemeName() публичный Метод

public setThemeName ( $value )

validate() публичный Метод

public validate ( )