Image-based captcha element

Generates image displaying random word

category Zend
package Zend_Captcha
subpackage Adapter
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Captcha_Word

 Methods

Constructor

__construct(array|\Zend_Config $options = null
Inherited

Parameters

$options

array\Zend_Config

Magic function returns the value of the requested property, if and only if it is the value or a message variable.

__get(string $property) : mixed
Inherited

Parameters

$property

string

Exceptions

\Zend_Validate_Exception

Returns

mixed

Generate captcha

generate() : string
inherited_from \Zend_Captcha_Word::generate()

Returns

stringcaptcha ID

Generate new session ID and new word

generate() : string
Inherited

Returns

stringsession ID

Get optional decorator

getDecorator() : null
Inherited

By default, return null, indicating no extra decorator needed.

inherited_from \Zend_Captcha_Adapter::getDecorator()

Returns

null

Get default translation object for all validate objects

getDefaultTranslator() : \Zend_Translate_Adapter | null
InheritedStatic

Returns

\Zend_Translate_Adapternull

getDotNoiseLevel()

getDotNoiseLevel() : integer

Returns

integer

Returns array of validation failure message codes

getErrors() : array
Inherited
deprecated Since 1.5.0

Returns

array

Get captcha expiration

getExpiration() : integer

Returns

integer

Get font to use when generating captcha

getFont() : string

Returns

string

Get font size

getFontSize() : integer

Returns

integer

Get garbage collection frequency

getGcFreq() : integer

Returns

integer

Get captcha image height

getHeight() : integer

Returns

integer

Retrieve captcha ID

getId() : string
Inherited

Returns

string

getImgAlt()

getImgAlt() : string

Returns

string

Get captcha image directory

getImgDir() : string

Returns

string

Get captcha image base URL

getImgUrl() : string

Returns

string

getLineNoiseLevel()

getLineNoiseLevel() : integer

Returns

integer

Returns the maximum allowed message length

getMessageLength() : integer
InheritedStatic

Returns

integer

Returns the message templates from the validator

getMessageTemplates() : array
Inherited

Returns

array

Returns an array of the names of variables that are used in constructing validation failure messages

getMessageVariables() : array
Inherited

Returns

array

Returns array of validation failure messages

getMessages() : array
Inherited

If isValid() was never called or if the most recent isValid() call returned true, then this method returns an empty array.

inherited_from \Zend_Validate_Interface::getMessages()

Returns

array

Get name

getName() : string
Inherited
inherited_from \Zend_Captcha_Adapter::getName()

Returns

string

Retrieve flag indicating whether or not value should be obfuscated in messages

getObscureValue() : boolean
Inherited

Returns

boolean

Retrieve options representing object state

getOptions() : array
Inherited

Returns

array

Get session object

getSession() : \Zend_Session_Namespace
Inherited

Returns

\Zend_Session_Namespace

Retrieve session class to utilize

getSessionClass() : string
Inherited

Returns

string

getStartImage()

getStartImage() : string

Returns

string

Get captcha image file suffix

getSuffix() : string

Returns

string

Get session token timeout

getTimeout() : integer
Inherited

Returns

integer

Return translation object

getTranslator() : \Zend_Translate_Adapter | null
Inherited

Returns

\Zend_Translate_Adapternull

Numbers should be included in the pattern?

getUseNumbers() : boolean
Inherited

Returns

boolean

Get captcha image width

getWidth() : integer

Returns

integer

Get captcha word

getWord() : string
Inherited

Returns

string

Retrieve word length to use when genrating captcha

getWordlen() : integer
Inherited

Returns

integer

Is there a default translation object set?

hasDefaultTranslator() : boolean
InheritedStatic

Returns

boolean

Does this validator have its own specific translator?

hasTranslator() : boolean
Inherited

Returns

boolean

Validate the word

isValid(mixed $value, array|null $context = null) : boolean
Inherited
see

Parameters

$value

mixed

$context

arraynull

Returns

boolean

Display the captcha

render(\Zend_View_Interface $view = null, mixed $element = null) : string

Parameters

$view

\Zend_View_Interface

$element

mixed

Returns

string

Set object state from config object

setConfig(\Zend_Config $config) : \Zend_Captcha_Base
Inherited

Parameters

$config

\Zend_Config

Returns

\Zend_Captcha_Base

Set default translation object for all validate objects

setDefaultTranslator(\Zend_Translate|\Zend_Translate_Adapter|null $translator = null
InheritedStatic

Parameters

$translator

\Zend_Translate\Zend_Translate_Adapternull

Exceptions

\Zend_Validate_Exception

Indicate whether or not translation should be disabled

setDisableTranslator(boolean $flag) : \Zend_Validate_Abstract
Inherited

Parameters

$flag

boolean

Returns

\Zend_Validate_Abstract

Set dot noise level

setDotNoiseLevel(integer $dotNoiseLevel) : \Zend_Captcha_Image

Parameters

$dotNoiseLevel

integer

Returns

\Zend_Captcha_Image

Set captcha expiration

setExpiration(integer $expiration) : \Zend_Captcha_Image

Parameters

$expiration

integer

Returns

\Zend_Captcha_Image

Set captcha font

setFont(string $font) : \Zend_Captcha_Image

Parameters

$font

string

Returns

\Zend_Captcha_Image

Set captcha font size

setFontSize(integer $fsize) : \Zend_Captcha_Image

Parameters

$fsize

integer

Returns

\Zend_Captcha_Image

Set garbage collection frequency

setGcFreq(integer $gcFreq) : \Zend_Captcha_Image

Parameters

$gcFreq

integer

Returns

\Zend_Captcha_Image

Set captcha image height

setHeight(integer $height) : \Zend_Captcha_Image

Parameters

$height

integer

Returns

\Zend_Captcha_Image

Set image alternative text

setImgAlt(string $imgAlt) : \Zend_Captcha_Image

Parameters

$imgAlt

string

Returns

\Zend_Captcha_Image

Set captcha image storage directory

setImgDir(string $imgDir) : \Zend_Captcha_Image

Parameters

$imgDir

string

Returns

\Zend_Captcha_Image

Set captcha image base URL

setImgUrl(string $imgUrl) : \Zend_Captcha_Image

Parameters

$imgUrl

string

Returns

\Zend_Captcha_Image

Sets if session should be preserved on generate()

setKeepSession(boolean $keepSession) : \Zend_Captcha_Word
Inherited

Parameters

$keepSession

boolean

Should session be kept on generate()?

Returns

\Zend_Captcha_Word

Set line noise level

setLineNoiseLevel(integer $lineNoiseLevel) : \Zend_Captcha_Image

Parameters

$lineNoiseLevel

integer

Returns

\Zend_Captcha_Image

Sets the validation failure message template for a particular key

setMessage(string $messageString, string $messageKey = null) : \Zend_Validate_Abstract
Inherited

Parameters

$messageString

string

$messageKey

string

OPTIONAL

Exceptions

\Zend_Validate_Exception

Returns

\Zend_Validate_AbstractProvides a fluent interface

Sets the maximum allowed message length

setMessageLength(integer $length = -1
InheritedStatic

Parameters

$length

integer

Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.

setMessages(array $messages) : \Zend_Validate_Abstract
Inherited

Parameters

$messages

array

Returns

\Zend_Validate_Abstract

Set name

setName(string $name) : \Zend_Captcha_Adapter
Inherited
inherited_from \Zend_Captcha_Adapter::setName()

Parameters

$name

string

Returns

\Zend_Captcha_Adapter

Set flag indicating whether or not value should be obfuscated in messages

setObscureValue(boolean $flag) : \Zend_Validate_Abstract
Inherited

Parameters

$flag

boolean

Returns

\Zend_Validate_Abstract

Set single option for the object

setOption(string $key, string $value) : \Zend_Form_Element
Inherited

Parameters

$key

string

$value

string

Returns

\Zend_Form_Element

Set object state from options array

setOptions(array $options = null) : \Zend_Form_Element
Inherited

Parameters

$options

array

Returns

\Zend_Form_Element

Set session namespace object

setSession(\Zend_Session_Namespace $session) : \Zend_Captcha_Word
Inherited

Parameters

$session

\Zend_Session_Namespace

Returns

\Zend_Captcha_Word

Set session class for persistence

setSessionClass(string $_sessionClass) : \Zend_Captcha_Word
Inherited

Parameters

$_sessionClass

string

Returns

\Zend_Captcha_Word

Set start image

setStartImage(string $startImage) : \Zend_Captcha_Image

Parameters

$startImage

string

Returns

\Zend_Captcha_Image

Set captch image filename suffix

setSuffix(string $suffix) : \Zend_Captcha_Image

Parameters

$suffix

string

Returns

\Zend_Captcha_Image

Set timeout for session token

setTimeout(integer $ttl) : \Zend_Captcha_Word
Inherited

Parameters

$ttl

integer

Returns

\Zend_Captcha_Word

Set translation object

setTranslator(\Zend_Translate|\Zend_Translate_Adapter|null $translator = null) : \Zend_Validate_Abstract
Inherited

Parameters

$translator

\Zend_Translate\Zend_Translate_Adapternull

Exceptions

\Zend_Validate_Exception

Returns

\Zend_Validate_Abstract

Set if numbers should be included in the pattern

setUseNumbers(boolean $_useNumbers) : \Zend_Captcha_Word
Inherited

Parameters

$_useNumbers

boolean

numbers should be included in the pattern?

Returns

\Zend_Captcha_Word

Set captcha image width

setWidth(integer $width) : \Zend_Captcha_Image

Parameters

$width

integer

Returns

\Zend_Captcha_Image

Set word length of captcha

setWordlen(integer $wordlen) : \Zend_Captcha_Word
Inherited

Parameters

$wordlen

integer

Returns

\Zend_Captcha_Word

Is translation disabled?

translatorIsDisabled() : boolean
Inherited

Returns

boolean

Constructs and returns a validation failure message with the given message key and value.

_createMessage(string $messageKey, string $value) : string
Inherited

Returns null if and only if $messageKey does not correspond to an existing template.

If a translator is available and a translation exists for $messageKey, the translation will be used.

Parameters

$messageKey

string

$value

string

Returns

string

_error()

_error(string $messageKey, string $value = null) : void
Inherited

Parameters

$messageKey

string

$value

string

OPTIONAL

Remove old files from image directory

_gc() 

Generate image captcha

_generateImage(string $id, string $word) 

Override this function if you want different image generator Wave transform from http://www.captcha.ru/captchas/multiwave/

Parameters

$id

string

Captcha ID

$word

string

Captcha word

Exceptions

\Zend_Captcha_Exception

_generateRandomId()

_generateRandomId() 
Inherited

Generate new random word

_generateWord() : string
Inherited

Returns

string

Joins elements of a multidimensional array

_implodeRecursive(array $pieces) : string
Inherited

Parameters

$pieces

array

Returns

string

Generate random frequency

_randomFreq() : float

Returns

float

Generate random phase

_randomPhase() : float

Returns

float

Generate random character size

_randomSize() : integer

Returns

integer

Set captcha identifier

_setId(string $id) : \Zend_Captcha_Word
Inherited

Parameters

$id

string

Returns

\Zend_Captcha_Word

Sets the value to be validated and clears the messages and errors arrays

_setValue(mixed $value) : void
Inherited

Parameters

$value

mixed

Set captcha word

_setWord(string $word) : \Zend_Captcha_Word
Inherited

Parameters

$word

string

Returns

\Zend_Captcha_Word

 Properties

 

$C

$C 

Default

array("b", "c", "d", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "z")
Static
 

$CN

$CN 

Default

array("b", "c", "d", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "z", "2", "3", "4", "5", "6", "7", "8", "9")
Static
 

$V

$V 

Default

array("a", "e", "i", "o", "u", "y")
Static
 

$VN

$VN 

Default

array("a", "e", "i", "o", "u", "y", "2", "3", "4", "5", "6", "7", "8", "9")
Static
 

Default translation object for all validate objects

$_defaultTranslator : \Zend_Translate

Default

Static
 

Number of noise dots on image Used twice - before and after transform

$_dotNoiseLevel : integer

Default

100
 

Array of validation failure message codes

$_errors : array

Default

array()
deprecated Since 1.5.0
 

How long to keep generated images

$_expiration : integer

Default

600
 

Image font file

$_font : string

Default

 

Font size

$_fsize : integer

Default

24
 

How frequently to execute garbage collection

$_gcFreq : integer

Default

10
 

Image height

$_height : integer

Default

50
 

Random session ID

$_id : string

Default

 

Image's alt tag content

$_imgAlt : string

Default

""
 

Directory for generated images

$_imgDir : string

Default

"./images/captcha/"
 

URL for accessing images

$_imgUrl : string

Default

"/images/captcha/"
 

Should generate() keep session or create a new one?

$_keepSession : boolean

Default

false
 

Number of noise lines on image Used twice - before and after transform

$_lineNoiseLevel : integer

Default

5
 

Limits the maximum returned length of a error message

$_messageLength : Integer

Default

-1
Static
 

Validation failure message template definitions

$_messageTemplates : array

Default

array()
 

Additional variables available for validation failure messages

$_messageVariables : array

Default

array()
 

Array of validation failure messages

$_messages : array

Default

array()
 

Element name

$_name : string

Default

Useful to generate/check form fields

 

Flag indidcating whether or not value should be obfuscated in error messages

$_obscureValue : boolean

Default

false
 

Captcha options

$_options : array

Default

array()
 

Session

$_session : \Zend_Session_Namespace

Default

 

Class name for sessions

$_sessionClass : string

Default

'Zend_Session_Namespace'
 

Options to skip when processing options

$_skipOptions : array

Default

array('options', 'config')
 

Image to use as starting point Default is blank image. If provided, should be PNG image.

$_startImage : string

Default

 

Image suffix (including dot)

$_suffix : string

Default

".png"
 

Session lifetime for the captcha data

$_timeout : integer

Default

300
 

Translation object

$_translator : \Zend_Translate

Default

 

Is translation disabled?

$_translatorDisabled : Boolean

Default

false
 

Should the numbers be used or only letters

$_useNumbers : boolean

Default

true
 

The value to be validated

$_value : mixed

Default

 

Image width

$_width : integer

Default

200
 

Generated word

$_word : string

Default

 

Length of the word to generate

$_wordlen : integer

Default

8

 Constants

 

BAD_CAPTCHA

BAD_CAPTCHA = 'badCaptcha' 
 

MISSING_ID

MISSING_ID = 'missingID' 
 

MISSING_VALUE

MISSING_VALUE = 'missingValue'