Class TReCaptcha

Description

Implements interfaces:

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 PrivateKey and 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 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:

  1.  <com:TReCaptcha ID="Captcha"
  2.                  PublicKey="..."
  3.                  PrivateKey="..."
  4.  />
  5.  <com:TReCaptchaValidator ControlToValidate="Captcha"
  6.                           ErrorMessage="You are challenged!" />

  • author: Bérczi Gábor <gabor.berczi@devworx.hu>
  • version: $Id: TWebControl.php 2996 2011-06-20 15:24:57Z ctrlaltca@gmail.com $
  • since: 3.2

Located in /Web/UI/WebControls/TReCaptcha.php (line 54)

TComponent
   |
   --TApplicationComponent
      |
      --TControl
         |
         --TWebControl
            |
            --TReCaptcha
Class Constant Summary
 ChallengeFieldName = 'recaptcha_challenge_field'
 ResponseFieldName = 'recaptcha_response_field'
Method Summary
void addAttributesToRender ( $writer)
bool getIsValid ()
void getLanguage ()
void getPrivateKey ()
void getPublicKey ()
void getTagName ()
void getThemeName ()
void onPreRender (mixed $param)
void regenerateToken ()
void renderContents ( $writer)
void setCustomTranslations ( $value)
void setIsValid (bool $value)
void setLanguage ( $value)
void setPrivateKey ( $value)
void setPublicKey ( $value)
void setThemeName ( $value)
void validate ()
Variables

Inherited Variables

Inherited from TWebControl

TWebControl::$_decorator
Methods
addAttributesToRender (line 199)
  • access: protected
void addAttributesToRender ( $writer)
  • $writer

Redefinition of:
TWebControl::addAttributesToRender()
Adds attribute name-value pairs to renderer.
getChallengeFieldName (line 138)
  • access: protected
void getChallengeFieldName ()
getClientSideOptions (line 148)
  • access: public
void getClientSideOptions ()
getCustomTranslations (line 118)
  • access: public
void getCustomTranslations ()
getIsValid (line 71)

Returns true if this control validated successfully.

Defaults to true.

  • return: wether this control validated successfully.
  • access: public
bool getIsValid ()
getLanguage (line 128)
  • access: public
void getLanguage ()
getPrivateKey (line 98)
  • access: public
void getPrivateKey ()
getPublicKey (line 88)
  • access: public
void getPublicKey ()
getResponseFieldName (line 143)
  • access: public
void getResponseFieldName ()
getTagName (line 61)
  • access: public
void getTagName ()

Redefinition of:
TWebControl::getTagName()
Returns the tag name used for this control.
getThemeName (line 108)
  • access: public
void getThemeName ()
getValidationPropertyValue (line 83)
  • access: public
void getValidationPropertyValue ()
onPreRender (line 184)

Checks for API keys

  • access: public
void onPreRender (mixed $param)
  • mixed $param: event parameter

Redefinition of:
TWebControl::onPreRender()
If your subclass overrides the onPreRender method be sure to call this method through parent::onPreRender($param); so your sub-class can be decorated, among other things.
regenerateToken (line 205)
  • access: public
void regenerateToken ()
renderContents (line 213)
  • access: public
void renderContents ( $writer)
  • $writer

Redefinition of:
TWebControl::renderContents()
Renders the body content enclosed between the control tag.
setCustomTranslations (line 123)
  • access: public
void setCustomTranslations ( $value)
  • $value
setIsValid (line 78)
  • access: public
void setIsValid (bool $value)
  • bool $value: wether this control is valid.
setLanguage (line 133)
  • access: public
void setLanguage ( $value)
  • $value
setPrivateKey (line 103)
  • access: public
void setPrivateKey ( $value)
  • $value
setPublicKey (line 93)
  • access: public
void setPublicKey ( $value)
  • $value
setThemeName (line 113)
  • access: public
void setThemeName ( $value)
  • $value
validate (line 160)
  • access: public
void validate ()

Inherited Methods

Inherited From TWebControl

TWebControl::addAttributesToRender()
TWebControl::clearStyle()
TWebControl::copyBaseAttributes()
TWebControl::createStyle()
TWebControl::getAccessKey()
TWebControl::getBackColor()
TWebControl::getBorderColor()
TWebControl::getBorderStyle()
TWebControl::getBorderWidth()
TWebControl::getCssClass()
TWebControl::getDecorator()
TWebControl::getDisplay()
TWebControl::getEnsureId()
TWebControl::getFont()
TWebControl::getForeColor()
TWebControl::getHasStyle()
TWebControl::getHeight()
TWebControl::getStyle()
TWebControl::getTabIndex()
TWebControl::getTagName()
TWebControl::getToolTip()
TWebControl::getWidth()
TWebControl::onPreRender()
TWebControl::render()
TWebControl::renderBeginTag()
TWebControl::renderContents()
TWebControl::renderEndTag()
TWebControl::setAccessKey()
TWebControl::setBackColor()
TWebControl::setBorderColor()
TWebControl::setBorderStyle()
TWebControl::setBorderWidth()
TWebControl::setCssClass()
TWebControl::setDisplay()
TWebControl::setEnsureId()
TWebControl::setForeColor()
TWebControl::setHeight()
TWebControl::setStyle()
TWebControl::setTabIndex()
TWebControl::setToolTip()
TWebControl::setWidth()

Inherited From TControl

TControl::__construct()
TControl::addedControl()
TControl::addParsedObject()
TControl::addToPostDataLoader()
TControl::applyStyleSheetSkin()
TControl::autoBindProperty()
TControl::autoDataBindProperties()
TControl::bindProperty()
TControl::broadcastEvent()
TControl::bubbleEvent()
TControl::clearChildState()
TControl::clearControlState()
TControl::clearNamingContainer()
TControl::clearViewState()
TControl::convertUniqueIdToClientId()
TControl::createChildControls()
TControl::createControlCollection()
TControl::dataBind()
TControl::dataBindChildren()
TControl::dataBindProperties()
TControl::ensureChildControls()
TControl::findControl()
TControl::findControlsByID()
TControl::findControlsByType()
TControl::focus()
TControl::getAdapter()
TControl::getAllowChildControls()
TControl::getAttribute()
TControl::getAttributes()
TControl::getChildControlsCreated()
TControl::getClientID()
TControl::getControls()
TControl::getControlStage()
TControl::getControlState()
TControl::getCustomData()
TControl::getEnabled()
TControl::getEnableTheming()
TControl::getEnableViewState()
TControl::getHasAdapter()
TControl::getHasAttributes()
TControl::getHasChildInitialized()
TControl::getHasControls()
TControl::getHasInitialized()
TControl::getHasLoaded()
TControl::getHasLoadedPostData()
TControl::getHasPreRendered()
TControl::getID()
TControl::getIsSkinApplied()
TControl::getNamingContainer()
TControl::getPage()
TControl::getParent()
TControl::getRegisteredObject()
TControl::getSkinID()
TControl::getSourceTemplateControl()
TControl::getTemplateControl()
TControl::getUniqueID()
TControl::getViewState()
TControl::getVisible()
TControl::hasAttribute()
TControl::initRecursive()
TControl::isDescendentOf()
TControl::isObjectRegistered()
TControl::loadRecursive()
TControl::loadState()
TControl::loadStateRecursive()
TControl::onDataBinding()
TControl::onInit()
TControl::onLoad()
TControl::onPreRender()
TControl::onUnload()
TControl::preRenderRecursive()
TControl::raiseBubbleEvent()
TControl::registerObject()
TControl::removeAttribute()
TControl::removedControl()
TControl::render()
TControl::renderChildren()
TControl::renderControl()
TControl::saveState()
TControl::saveStateRecursive()
TControl::setAdapter()
TControl::setAttribute()
TControl::setChildControlsCreated()
TControl::setControlStage()
TControl::setControlState()
TControl::setCustomData()
TControl::setEnabled()
TControl::setEnableTheming()
TControl::setEnableViewState()
TControl::setID()
TControl::setPage()
TControl::setSkinID()
TControl::setTemplateControl()
TControl::setViewState()
TControl::setVisible()
TControl::trackViewState()
TControl::traverseChildControls()
TControl::unbindProperty()
TControl::unloadRecursive()
TControl::unregisterObject()
TControl::__get()

Inherited From TApplicationComponent

TApplicationComponent::getApplication()
TApplicationComponent::getRequest()
TApplicationComponent::getResponse()
TApplicationComponent::getService()
TApplicationComponent::getSession()
TApplicationComponent::getUser()
TApplicationComponent::publishAsset()
TApplicationComponent::publishFilePath()

Inherited From TComponent

TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__call()
TComponent::__get()
TComponent::__set()
TComponent::__sleep()
TComponent::__wakeup()
Class Constants

Documentation generated on Mon, 25 Jun 2012 14:39:00 +0200 by phpDocumentor 1.4.3