|
Class TReCaptcha
TReCaptcha class.
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 setPrivateKey PrivateKey and 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 TReCaptcha::validate() . The
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:
<com:TReCaptcha ID="Captcha"
PublicKey="..."
PrivateKey="..."
/>
<com:TReCaptchaValidator ControlToValidate="Captcha"
ErrorMessage="You are challenged!" />
-
TComponent
-
TApplicationComponent
-
TControl
implements
IRenderable,
IBindable
-
TWebControl
implements
IStyleable
-
TReCaptcha
implements
IValidatable
Methods summary
public
string
|
#
getTagName( )
Returns the tag name used for this control. By default, the tag name is
'span'. You can override this method to provide customized tag names.
Returns the tag name used for this control. By default, the tag name is
'span'. You can override this method to provide customized tag names.
Returns
string tag name of the control to be rendered
Overrides
|
public
boolean
|
#
getIsValid( )
Returns true if this control validated successfully. Defaults to true.
Returns true if this control validated successfully. Defaults to true.
Returns
boolean wether this control validated successfully.
Implementation of
|
public
boolean
|
#
setIsValid( boolean $value )
Parameters
- $value
boolean wether this control is valid.
Returns
boolean wether this control's validators validated successfully
Implementation of
|
public
mixed
|
#
getValidationPropertyValue( )
Returns
mixed the value of the property to be validated.
Implementation of
|
public
|
|
public
|
#
setPublicKey( mixed $value )
|
public
|
|
public
|
#
setPrivateKey( mixed $value )
|
public
|
|
public
|
#
setThemeName( mixed $value )
|
public
|
#
getCustomTranslations( )
|
public
|
#
setCustomTranslations( mixed $value )
|
public
|
|
public
|
#
setLanguage( mixed $value )
|
public
|
|
public
|
#
setCallbackScript( mixed $value )
|
protected
|
#
getChallengeFieldName( )
|
public
|
#
getResponseFieldName( )
|
public
|
#
getClientSideOptions( )
|
public
|
|
public
|
#
onPreRender( mixed $param )
Checks for API keys
Parameters
- $param
mixed event parameter
Overrides
|
protected
|
#
addAttributesToRender( THtmlWriter $writer )
Adds attribute name-value pairs to renderer. By default, the method will
render 'id', 'accesskey', 'disabled', 'tabindex', 'title' and all custom
attributes. The method can be overriden to provide customized attribute
rendering.
Adds attribute name-value pairs to renderer. By default, the method will
render 'id', 'accesskey', 'disabled', 'tabindex', 'title' and all custom
attributes. The method can be overriden to provide customized attribute
rendering.
Parameters
- $writer
THtmlWriter
the writer used for the rendering purpose
Overrides
|
public
|
|
public
|
#
renderContents( THtmlWriter $writer )
Renders the body content enclosed between the control tag. By default, child
controls and text strings will be rendered. You can override this method to
provide customized content rendering.
Renders the body content enclosed between the control tag. By default, child
controls and text strings will be rendered. You can override this method to
provide customized content rendering.
Parameters
- $writer
THtmlWriter
the writer used for the rendering purpose
Overrides
|
Methods inherited from TWebControl
clearStyle(),
copyBaseAttributes(),
createStyle(),
getAccessKey(),
getBackColor(),
getBorderColor(),
getBorderStyle(),
getBorderWidth(),
getCssClass(),
getDecorator(),
getDisplay(),
getEnsureId(),
getFont(),
getForeColor(),
getHasStyle(),
getHeight(),
getStyle(),
getTabIndex(),
getToolTip(),
getWidth(),
render(),
renderBeginTag(),
renderEndTag(),
setAccessKey(),
setBackColor(),
setBorderColor(),
setBorderStyle(),
setBorderWidth(),
setCssClass(),
setDisplay(),
setEnsureId(),
setForeColor(),
setHeight(),
setStyle(),
setTabIndex(),
setToolTip(),
setWidth()
|
Methods inherited from TControl
__construct(),
__get(),
addParsedObject(),
addToPostDataLoader(),
addedControl(),
applyStyleSheetSkin(),
autoBindProperty(),
autoDataBindProperties(),
bindProperty(),
broadcastEvent(),
bubbleEvent(),
clearChildState(),
clearControlState(),
clearNamingContainer(),
clearViewState(),
convertUniqueIdToClientId(),
createChildControls(),
createControlCollection(),
dataBind(),
dataBindChildren(),
dataBindProperties(),
ensureChildControls(),
findControl(),
findControlsByID(),
findControlsByType(),
focus(),
getAdapter(),
getAllowChildControls(),
getAttribute(),
getAttributes(),
getChildControlsCreated(),
getClientID(),
getControlStage(),
getControlState(),
getControls(),
getCustomData(),
getEnableTheming(),
getEnableViewState(),
getEnabled(),
getHasAdapter(),
getHasAttributes(),
getHasChildInitialized(),
getHasControls(),
getHasInitialized(),
getHasLoaded(),
getHasLoadedPostData(),
getHasPreRendered(),
getID(),
getIsSkinApplied(),
getNamingContainer(),
getPage(),
getParent(),
getRegisteredObject(),
getSkinID(),
getSourceTemplateControl(),
getTemplateControl(),
getUniqueID(),
getViewState(),
getVisible(),
hasAttribute(),
initRecursive(),
isDescendentOf(),
isObjectRegistered(),
loadRecursive(),
loadState(),
loadStateRecursive(),
onDataBinding(),
onInit(),
onLoad(),
onUnload(),
preRenderRecursive(),
raiseBubbleEvent(),
registerObject(),
removeAttribute(),
removedControl(),
renderChildren(),
renderControl(),
saveState(),
saveStateRecursive(),
setAdapter(),
setAttribute(),
setChildControlsCreated(),
setControlStage(),
setControlState(),
setCustomData(),
setEnableTheming(),
setEnableViewState(),
setEnabled(),
setID(),
setPage(),
setSkinID(),
setTemplateControl(),
setViewState(),
setVisible(),
trackViewState(),
traverseChildControls(),
unbindProperty(),
unloadRecursive(),
unregisterObject()
|
Methods inherited from TComponent
__call(),
__destruct(),
__isset(),
__set(),
__sleep(),
__unset(),
__wakeup(),
asa(),
attachBehavior(),
attachBehaviors(),
attachClassBehavior(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
clearBehaviors(),
createdOnTemplate(),
detachBehavior(),
detachBehaviors(),
detachClassBehavior(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
evaluateStatements(),
fxAttachClassBehavior(),
fxDetachClassBehavior(),
getAutoGlobalListen(),
getBehaviorsEnabled(),
getClassHierarchy(),
getEventHandlers(),
getListeningToGlobalEvents(),
getSubProperty(),
hasEvent(),
hasEventHandler(),
hasProperty(),
isa(),
listen(),
raiseEvent(),
setSubProperty(),
unlisten()
|
Constants summary
string |
ChallengeFieldName |
'recaptcha_challenge_field' |
|
string |
ResponseFieldName |
'recaptcha_response_field' |
|
Constants inherited from TControl
AUTOMATIC_ID_PREFIX,
CLIENT_ID_SEPARATOR,
CS_CHILD_INITIALIZED,
CS_CONSTRUCTED,
CS_INITIALIZED,
CS_LOADED,
CS_PRERENDERED,
CS_STATE_LOADED,
ID_FORMAT,
ID_SEPARATOR,
IS_CHILD_CREATED,
IS_CREATING_CHILD,
IS_DISABLE_THEMING,
IS_DISABLE_VIEWSTATE,
IS_ID_SET,
IS_SKIN_APPLIED,
IS_STYLESHEET_APPLIED,
RF_ADAPTER,
RF_AUTO_BINDINGS,
RF_CHILD_STATE,
RF_CONTROLS,
RF_CONTROLSTATE,
RF_DATA_BINDINGS,
RF_EVENTS,
RF_NAMED_CONTROLS,
RF_NAMED_CONTROLS_ID,
RF_NAMED_OBJECTS,
RF_SKIN_ID
|
|