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:- Override
CController::actions()
and register an action of class CCaptchaAction with ID 'captcha'. - In the form model, declare an attribute to store user-entered verification code, and declare the attribute to be validated by the 'captcha' validator.
- In the controller view, insert a
CCaptcha
widget in the form.
- CComponent
- CAction implements IAction
- CCaptchaAction
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
public
|
|
public
string
|
#
generateValidationHash( string $code )
Generates a hash code that can be used for client side validation. |
public
string
|
|
public
boolean
|
|
protected
string
|
|
protected
string
|
|
protected
|
#
renderImage( string $code )
Renders the CAPTCHA image based on the code using library specified in the
|
protected
|
|
protected
|
#
renderImageImagick( string $code )
Renders the CAPTCHA image based on the code using ImageMagick library. |
__construct(),
getController(),
getId(),
runWithParams(),
runWithParamsInternal()
|
run()
|
string |
REFRESH_GET_VAR
|
'refresh' |
#
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. |
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). |
public
integer
|
$width | 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. |
public
integer
|
$padding | 2 |
#
padding around the text. Defaults to 2. |
public
integer
|
$backColor | 0xFFFFFF |
#
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). |
public
boolean
|
$transparent | false |
#
whether to use transparent background. Defaults to false. |
public
integer
|
$minLength | 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. |
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. |
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. |
public
string
|
$fixedVerifyCode |
|
#
the fixed verification code. When this is property is set, |
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. |
public
string
|
$verifyCode |
#
The verification code. |
$controller,
$id
|