Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CCaptcha
  • CCaptchaAction
  • MobileCaptcha
  • Overview
  • Package
  • Class
  • Tree

Class CCaptchaAction

CCaptchaAction renders a CAPTCHA image.

CCaptchaAction is used together with CCaptcha and CCaptchaValidator to provide the CAPTCHA feature.

You must configure properties of CCaptchaAction to customize the appearance of the generated image.

Note, CCaptchaAction requires PHP GD2 extension.

Using CAPTCHA involves the following steps:
  1. Override CController::actions() and register an action of class CCaptchaAction with ID 'captcha'.
  2. In the form model, declare an attribute to store user-entered verification code, and declare the attribute to be validated by the 'captcha' validator.
  3. In the controller view, insert a CCaptcha widget in the form.
CComponent
Extended by CAction implements IAction
Extended by CCaptchaAction
Package: system\web\widgets\captcha
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/web/widgets/captcha/CCaptchaAction.php
Methods summary
public
# run( )

Runs the action.

Runs the action.

public string
# generateValidationHash( string $code )

Generates a hash code that can be used for client side validation.

Generates a hash code that can be used for client side validation.

Parameters

$code
string
$code the CAPTCHA code

Returns

string
a hash code generated from the CAPTCHA code

Since

1.1.7
public string
# getVerifyCode( boolean $regenerate = false )

Gets the verification code.

Gets the verification code.

Parameters

$regenerate
boolean
$regenerate whether the verification code should be regenerated.

Returns

string
the verification code.
public boolean
# validate( string $input, boolean $caseSensitive )

Validates the input to see if it matches the generated code.

Validates the input to see if it matches the generated code.

Parameters

$input
string
$input user input
$caseSensitive
boolean
$caseSensitive whether the comparison should be case-sensitive

Returns

boolean
whether the input is valid
protected string
# generateVerifyCode( )

Generates a new verification code.

Generates a new verification code.

Returns

string
the generated verification code
protected string
# getSessionKey( )

Returns the session variable name used to store verification code.

Returns the session variable name used to store verification code.

Returns

string
the session variable name
protected
# renderImage( string $code )

Renders the CAPTCHA image based on the code using library specified in the CCaptchaAction::$backend property.

Renders the CAPTCHA image based on the code using library specified in the CCaptchaAction::$backend property.

Parameters

$code
string
$code the verification code
protected
# renderImageGD( string $code )

Renders the CAPTCHA image based on the code using GD library.

Renders the CAPTCHA image based on the code using GD library.

Parameters

$code
string
$code the verification code

Since

1.1.13
protected
# renderImageImagick( string $code )

Renders the CAPTCHA image based on the code using ImageMagick library.

Renders the CAPTCHA image based on the code using ImageMagick library.

Parameters

$code
string
$code the verification code

Since

1.1.13
Methods inherited from CAction
__construct(), getController(), getId(), runWithParams(), runWithParamsInternal()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Magic methods inherited from CAction
run()
Constants summary
string REFRESH_GET_VAR 'refresh'
#

The name of the GET parameter indicating whether the CAPTCHA image should be regenerated.

The name of the GET parameter indicating whether the CAPTCHA image should be regenerated.

string SESSION_VAR_PREFIX 'Yii.CCaptchaAction.'
#

Prefix to the session variable name used by the action.

Prefix to the session variable name used by the action.

Properties summary
public integer $testLimit 3
#

how many times should the same CAPTCHA be displayed. Defaults to 3. A value less than or equal to 0 means the test is unlimited (available since version 1.1.2).

how many times should the same CAPTCHA be displayed. Defaults to 3. A value less than or equal to 0 means the test is unlimited (available since version 1.1.2).

public integer $width 120
#

the width of the generated CAPTCHA image. Defaults to 120.

the width of the generated CAPTCHA image. Defaults to 120.

public integer $height 50
#

the height of the generated CAPTCHA image. Defaults to 50.

the height of the generated CAPTCHA image. Defaults to 50.

public integer $padding 2
#

padding around the text. Defaults to 2.

padding around the text. Defaults to 2.

public integer $backColor 0xFFFFFF
#

the background color. For example, 0x55FF00. Defaults to 0xFFFFFF, meaning white color.

the background color. For example, 0x55FF00. Defaults to 0xFFFFFF, meaning white color.

public integer $foreColor 0x2040A0
#

the font color. For example, 0x55FF00. Defaults to 0x2040A0 (blue color).

the font color. For example, 0x55FF00. Defaults to 0x2040A0 (blue color).

public boolean $transparent false
#

whether to use transparent background. Defaults to false.

whether to use transparent background. Defaults to false.

public integer $minLength 6
#

the minimum length for randomly generated word. Defaults to 6.

the minimum length for randomly generated word. Defaults to 6.

public integer $maxLength 7
#

the maximum length for randomly generated word. Defaults to 7.

the maximum length for randomly generated word. Defaults to 7.

public integer $offset -2
#

the offset between characters. Defaults to -2. You can adjust this property in order to decrease or increase the readability of the captcha.

the offset between characters. Defaults to -2. You can adjust this property in order to decrease or increase the readability of the captcha.

Since

1.1.7
public string $fontFile
#

the TrueType font file. Defaults to SpicyRice.ttf which is provided with the Yii release. Note that non-free Duality.ttf has been changed to open/free SpicyRice.ttf since 1.1.14.

the TrueType font file. Defaults to SpicyRice.ttf which is provided with the Yii release. Note that non-free Duality.ttf has been changed to open/free SpicyRice.ttf since 1.1.14.

public string $fixedVerifyCode
#

the fixed verification code. When this is property is set, CCaptchaAction::getVerifyCode() will always return this value. This is mainly used in automated tests where we want to be able to reproduce the same verification code each time we run the tests. Defaults to null, meaning the verification code will be randomly generated.

the fixed verification code. When this is property is set, CCaptchaAction::getVerifyCode() will always return this value. This is mainly used in automated tests where we want to be able to reproduce the same verification code each time we run the tests. Defaults to null, meaning the verification code will be randomly generated.

Since

1.1.4
public string $backend
#

the graphic extension that will be used to draw CAPTCHA image. Possible values are 'gd', 'imagick' and null. Null value means that fallback mode will be used: ImageMagick is preferred over GD. Default value is null.

the graphic extension that will be used to draw CAPTCHA image. Possible values are 'gd', 'imagick' and null. Null value means that fallback mode will be used: ImageMagick is preferred over GD. Default value is null.

Since

1.1.13
Magic properties summary
public string $verifyCode
#

The verification code.

The verification code.

Magic properties inherited from CAction
$controller, $id
API documentation generated by ApiGen 2.8.0