Image-based captcha element

Generates image displaying random word

category Zend
package Zend_Captcha
subpackage Adapter

 Methods

Constructor

__construct(array | \Traversable $options) 

Validator() - one or multiple scalar values f.e. Validator($first, $second, $third) - an array f.e. Validator(array($first => 'first', $second => 'second', $third => 'third')) - an instance of Traversable f.e. Validator($config_instance)

Parameters

$options

array\Traversable

Exceptions

\Zend\Captcha\Exception\ExtensionNotLoadedException

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

inherited_from \Zend\Validator\AbstractValidator::__get()
inherited_from \Zend\Captcha\AbstractAdapter::__get()
inherited_from \Zend\Captcha\AbstractWord::__get()

Parameters

$property

string

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

mixed

Invoke as command

__invoke(mixed $value) : bool
Inherited

inherited_from \Zend\Validator\AbstractValidator::__invoke()
inherited_from \Zend\Captcha\AbstractAdapter::__invoke()
inherited_from \Zend\Captcha\AbstractWord::__invoke()

Parameters

$value

mixed

Returns

bool

Generate captcha

generate() : string

Returns

stringcaptcha ID

Get default translation object for all validate objects

getDefaultTranslator() : \Zend\I18n\Translator\Translator | null
Inherited

inherited_from \Zend\Validator\AbstractValidator::getDefaultTranslator()
inherited_from \Zend\Captcha\AbstractAdapter::getDefaultTranslator()
inherited_from \Zend\Captcha\AbstractWord::getDefaultTranslator()

Returns

Get default translation text domain for all validate objects

getDefaultTranslatorTextDomain() : string
Inherited

inherited_from \Zend\Validator\AbstractValidator::getDefaultTranslatorTextDomain()
inherited_from \Zend\Captcha\AbstractAdapter::getDefaultTranslatorTextDomain()
inherited_from \Zend\Captcha\AbstractWord::getDefaultTranslatorTextDomain()

Returns

string

getDotNoiseLevel()

getDotNoiseLevel() : int

Returns

int

Get captcha expiration

getExpiration() : int

Returns

int

Get font to use when generating captcha

getFont() : string

Returns

string

Get font size

getFontSize() : int

Returns

int

Get garbage collection frequency

getGcFreq() : int

Returns

int

Get captcha image height

getHeight() : int

Returns

int

Get helper name used to render captcha

getHelperName() : string

By default, return empty string, indicating no helper needed.

Returns

string

Retrieve captcha ID

getId() : string
Inherited

inherited_from \Zend\Captcha\AbstractWord::getId()

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() : int

Returns

int

Returns the maximum allowed message length

getMessageLength() : integer
Inherited

inherited_from \Zend\Validator\AbstractValidator::getMessageLength()
inherited_from \Zend\Captcha\AbstractAdapter::getMessageLength()
inherited_from \Zend\Captcha\AbstractWord::getMessageLength()

Returns

integer

Returns the message templates from the validator

getMessageTemplates() : array
Inherited

inherited_from \Zend\Validator\AbstractValidator::getMessageTemplates()
inherited_from \Zend\Captcha\AbstractAdapter::getMessageTemplates()
inherited_from \Zend\Captcha\AbstractWord::getMessageTemplates()

Returns

array

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

getMessageVariables() : array
Inherited

inherited_from \Zend\Validator\AbstractValidator::getMessageVariables()
inherited_from \Zend\Captcha\AbstractAdapter::getMessageVariables()
inherited_from \Zend\Captcha\AbstractWord::getMessageVariables()

Returns

array

Returns array of validation failure messages

getMessages() : array
Inherited

The array keys are validation failure message identifiers, and the array values are the corresponding human-readable message strings.

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

inherited_from \Zend\Validator\AbstractValidator::getMessages()
inherited_from \Zend\Captcha\AbstractAdapter::getMessages()
inherited_from \Zend\Captcha\AbstractWord::getMessages()

Returns

array

Get name

getName() : string
Inherited

inherited_from \Zend\Captcha\AbstractAdapter::getName()
inherited_from \Zend\Captcha\AbstractWord::getName()

Returns

string

Returns an option

getOption(string $option) : mixed
Inherited

inherited_from \Zend\Validator\AbstractValidator::getOption()
inherited_from \Zend\Captcha\AbstractAdapter::getOption()
inherited_from \Zend\Captcha\AbstractWord::getOption()

Parameters

$option

string

Option to be returned

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

mixedReturned option

Retrieve options representing object state

getOptions() : array
Inherited

inherited_from \Zend\Captcha\AbstractAdapter::getOptions()
inherited_from \Zend\Captcha\AbstractWord::getOptions()

Returns

array

Get session object

getSession() : \Zend\Session\Container
Inherited

inherited_from \Zend\Captcha\AbstractWord::getSession()

Exceptions

\Zend\Captcha\Exception\InvalidArgumentException

Returns

Retrieve session class to utilize

getSessionClass() : string
Inherited

inherited_from \Zend\Captcha\AbstractWord::getSessionClass()

Returns

string

getStartImage()

getStartImage() : string

Returns

string

Get captcha image file suffix

getSuffix() : string

Returns

string

Get session token timeout

getTimeout() : int
Inherited

inherited_from \Zend\Captcha\AbstractWord::getTimeout()

Returns

int

Return translation object

getTranslator() : \Zend\I18n\Translator\Translator | null
Inherited

inherited_from \Zend\Validator\AbstractValidator::getTranslator()
inherited_from \Zend\Captcha\AbstractAdapter::getTranslator()
inherited_from \Zend\Captcha\AbstractWord::getTranslator()

Returns

Return the translation text domain

getTranslatorTextDomain() : string
Inherited

inherited_from \Zend\Validator\AbstractValidator::getTranslatorTextDomain()
inherited_from \Zend\Captcha\AbstractAdapter::getTranslatorTextDomain()
inherited_from \Zend\Captcha\AbstractWord::getTranslatorTextDomain()

Returns

string

Numbers should be included in the pattern?

getUseNumbers() : bool
Inherited

inherited_from \Zend\Captcha\AbstractWord::getUseNumbers()

Returns

bool

Get captcha image width

getWidth() : int

Returns

int

Get captcha word

getWord() : string
Inherited

inherited_from \Zend\Captcha\AbstractWord::getWord()

Returns

string

Retrieve word length to use when generating captcha

getWordlen() : integer
Inherited

inherited_from \Zend\Captcha\AbstractWord::getWordlen()

Returns

integer

Is there a default translation object set?

hasDefaultTranslator() : bool
Inherited

inherited_from \Zend\Validator\AbstractValidator::hasDefaultTranslator()
inherited_from \Zend\Captcha\AbstractAdapter::hasDefaultTranslator()
inherited_from \Zend\Captcha\AbstractWord::hasDefaultTranslator()

Returns

bool

Does this validator have its own specific translator?

hasTranslator() : bool
Inherited

inherited_from \Zend\Validator\AbstractValidator::hasTranslator()
inherited_from \Zend\Captcha\AbstractAdapter::hasTranslator()
inherited_from \Zend\Captcha\AbstractWord::hasTranslator()

Returns

bool

Is translation enabled?

isTranslatorEnabled() : bool
Inherited

inherited_from \Zend\Validator\AbstractValidator::isTranslatorEnabled()
inherited_from \Zend\Captcha\AbstractAdapter::isTranslatorEnabled()
inherited_from \Zend\Captcha\AbstractWord::isTranslatorEnabled()

Returns

bool

Validate the word

isValid(mixed $value, mixed $context) : bool
Inherited

If $value fails validation, then this method returns false, and getMessages() will return an array of messages that explain why the validation failed.

see \Zend\Validator\ValidatorInterface::isValid()
inherited_from \Zend\Captcha\AbstractWord::isValid()

Parameters

$value

mixed

$context

mixed

Exceptions

\Zend\Validator\Exception\RuntimeException If validation of $value is impossible

Returns

bool

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

isValueObscured() : bool
Inherited

inherited_from \Zend\Validator\AbstractValidator::isValueObscured()
inherited_from \Zend\Captcha\AbstractAdapter::isValueObscured()
inherited_from \Zend\Captcha\AbstractWord::isValueObscured()

Returns

bool

Set default translation object for all validate objects

setDefaultTranslator(\Zend\I18n\Translator\Translator $translator, string $textDomain) : void
Inherited

inherited_from \Zend\Validator\AbstractValidator::setDefaultTranslator()
inherited_from \Zend\Captcha\AbstractAdapter::setDefaultTranslator()
inherited_from \Zend\Captcha\AbstractWord::setDefaultTranslator()

Parameters

$textDomain

string

(optional)

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Set default translation text domain for all validate objects

setDefaultTranslatorTextDomain(string $textDomain) : void
Inherited

inherited_from \Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain()
inherited_from \Zend\Captcha\AbstractAdapter::setDefaultTranslatorTextDomain()
inherited_from \Zend\Captcha\AbstractWord::setDefaultTranslatorTextDomain()

Parameters

$textDomain

string

setDotNoiseLevel()

setDotNoiseLevel(int $dotNoiseLevel) : \Zend\Captcha\Image

Parameters

$dotNoiseLevel

int

Returns

Set captcha expiration

setExpiration(int $expiration) : \Zend\Captcha\Image

Parameters

$expiration

int

Returns

Set captcha font

setFont(string $font) : \Zend\Captcha\Image

Parameters

$font

string

Returns

Set captcha font size

setFontSize(int $fsize) : \Zend\Captcha\Image

Parameters

$fsize

int

Returns

Set garbage collection frequency

setGcFreq(int $gcFreq) : \Zend\Captcha\Image

Parameters

$gcFreq

int

Returns

Set captcha image height

setHeight(int $height) : \Zend\Captcha\Image

Parameters

$height

int

Returns

setImgAlt()

setImgAlt(string $imgAlt) : \Zend\Captcha\Image

Parameters

$imgAlt

string

Returns

Set captcha image storage directory

setImgDir(string $imgDir) : \Zend\Captcha\Image

Parameters

$imgDir

string

Returns

Set captcha image base URL

setImgUrl(string $imgUrl) : \Zend\Captcha\Image

Parameters

$imgUrl

string

Returns

Sets if session should be preserved on generate()

setKeepSession(bool $keepSession) : \Zend\Captcha\AbstractWord
Inherited

inherited_from \Zend\Captcha\AbstractWord::setKeepSession()

Parameters

$keepSession

bool

Should session be kept on generate()?

Returns

setLineNoiseLevel()

setLineNoiseLevel(int $lineNoiseLevel) : \Zend\Captcha\Image

Parameters

$lineNoiseLevel

int

Returns

Sets the validation failure message template for a particular key

setMessage(string $messageString, string $messageKey) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setMessage()
inherited_from \Zend\Captcha\AbstractAdapter::setMessage()
inherited_from \Zend\Captcha\AbstractWord::setMessage()

Parameters

$messageString

string

$messageKey

string

OPTIONAL

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

\Zend\Validator\AbstractValidatorProvides a fluent interface

Sets the maximum allowed message length

setMessageLength(integer $length) 
Inherited

inherited_from \Zend\Validator\AbstractValidator::setMessageLength()
inherited_from \Zend\Captcha\AbstractAdapter::setMessageLength()
inherited_from \Zend\Captcha\AbstractWord::setMessageLength()

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\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setMessages()
inherited_from \Zend\Captcha\AbstractAdapter::setMessages()
inherited_from \Zend\Captcha\AbstractWord::setMessages()

Parameters

$messages

array

Returns

Set name

setName(string $name) : \Zend\Captcha\AbstractAdapter
Inherited

inherited_from \Zend\Captcha\AbstractAdapter::setName()
inherited_from \Zend\Captcha\AbstractWord::setName()

Parameters

$name

string

Returns

Set single option for the object

setOption(string $key, string $value) : \Zend\Captcha\AbstractAdapter
Inherited

inherited_from \Zend\Captcha\AbstractAdapter::setOption()
inherited_from \Zend\Captcha\AbstractWord::setOption()

Parameters

$key

string

$value

string

Returns

Set object state from options array

setOptions(array | \Traversable $options) : \Zend\Captcha\AbstractAdapter
Inherited

inherited_from \Zend\Captcha\AbstractAdapter::setOptions()
inherited_from \Zend\Captcha\AbstractWord::setOptions()

Parameters

$options

array\Traversable

Exceptions

\Zend\Captcha\Exception\InvalidArgumentException

Returns

Set session namespace object

setSession(\Zend\Session\Container $session) : \Zend\Captcha\AbstractWord
Inherited

inherited_from \Zend\Captcha\AbstractWord::setSession()

Parameters

Returns

Set session class for persistence

setSessionClass(string $sessionClass) : \Zend\Captcha\AbstractWord
Inherited

inherited_from \Zend\Captcha\AbstractWord::setSessionClass()

Parameters

$sessionClass

string

Returns

setStartImage()

setStartImage(string $startImage) : \Zend\Captcha\Image

Parameters

$startImage

string

Returns

Set captcha image filename suffix

setSuffix(string $suffix) : \Zend\Captcha\Image

Parameters

$suffix

string

Returns

Set timeout for session token

setTimeout(int $ttl) : \Zend\Captcha\AbstractWord
Inherited

inherited_from \Zend\Captcha\AbstractWord::setTimeout()

Parameters

$ttl

int

Returns

Set translation object

setTranslator(\Zend\I18n\Translator\Translator $translator, string $textDomain) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setTranslator()
inherited_from \Zend\Captcha\AbstractAdapter::setTranslator()
inherited_from \Zend\Captcha\AbstractWord::setTranslator()

Parameters

$textDomain

string

(optional)

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

Indicate whether or not translation should be enabled

setTranslatorEnabled(bool $flag) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setTranslatorEnabled()
inherited_from \Zend\Captcha\AbstractAdapter::setTranslatorEnabled()
inherited_from \Zend\Captcha\AbstractWord::setTranslatorEnabled()

Parameters

$flag

bool

Returns

Set translation text domain

setTranslatorTextDomain(string $textDomain) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setTranslatorTextDomain()
inherited_from \Zend\Captcha\AbstractAdapter::setTranslatorTextDomain()
inherited_from \Zend\Captcha\AbstractWord::setTranslatorTextDomain()

Parameters

$textDomain

string

Returns

Set if numbers should be included in the pattern

setUseNumbers(bool $useNumbers) : \Zend\Captcha\AbstractWord
Inherited

inherited_from \Zend\Captcha\AbstractWord::setUseNumbers()

Parameters

$useNumbers

bool

numbers should be included in the pattern?

Returns

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

setValueObscured(bool $flag) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setValueObscured()
inherited_from \Zend\Captcha\AbstractAdapter::setValueObscured()
inherited_from \Zend\Captcha\AbstractWord::setValueObscured()

Parameters

$flag

bool

Returns

Set captcha image width

setWidth(int $width) : \Zend\Captcha\Image

Parameters

$width

int

Returns

Set word length of captcha

setWordlen(integer $wordlen) : \Zend\Captcha\AbstractWord
Inherited

inherited_from \Zend\Captcha\AbstractWord::setWordlen()

Parameters

$wordlen

integer

Returns

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

createMessage(string $messageKey, string | array | object $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.

inherited_from \Zend\Validator\AbstractValidator::createMessage()
inherited_from \Zend\Captcha\AbstractAdapter::createMessage()
inherited_from \Zend\Captcha\AbstractWord::createMessage()

Parameters

$messageKey

string

$value

stringarrayobject

Returns

string

error()

error(string $messageKey, string $value) : void
Inherited

inherited_from \Zend\Validator\AbstractValidator::error()
inherited_from \Zend\Captcha\AbstractAdapter::error()
inherited_from \Zend\Captcha\AbstractWord::error()

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\NoFontProvidedException if no font was set
\Zend\Captcha\Exception\ImageNotLoadableException if start image cannot be loaded

Generate a random identifier

generateRandomId() : string
Inherited

inherited_from \Zend\Captcha\AbstractWord::generateRandomId()

Returns

string

Generate new random word

generateWord() : string
Inherited

inherited_from \Zend\Captcha\AbstractWord::generateWord()

Returns

string

Returns the validation value

getValue() : mixed
Inherited

inherited_from \Zend\Validator\AbstractValidator::getValue()
inherited_from \Zend\Captcha\AbstractAdapter::getValue()
inherited_from \Zend\Captcha\AbstractWord::getValue()

Returns

mixedValue to be validated

Generate random frequency

randomFreq() : float

Returns

float

Generate random phase

randomPhase() : float

Returns

float

Generate random character size

randomSize() : int

Returns

int

Set captcha identifier

setId(string $id) : \Zend\Captcha\AbstractWord
Inherited

inherited_from \Zend\Captcha\AbstractWord::setId()

Parameters

$id

string

Returns

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

setValue(mixed $value) : void
Inherited

inherited_from \Zend\Validator\AbstractValidator::setValue()
inherited_from \Zend\Captcha\AbstractAdapter::setValue()
inherited_from \Zend\Captcha\AbstractWord::setValue()

Parameters

$value

mixed

Set captcha word

setWord(string $word) : \Zend\Captcha\AbstractWord
Inherited

inherited_from \Zend\Captcha\AbstractWord::setWord()

Parameters

$word

string

Returns

Translate a validation message

translateMessage(string $messageKey, string $message) : string
Inherited

inherited_from \Zend\Validator\AbstractValidator::translateMessage()
inherited_from \Zend\Captcha\AbstractAdapter::translateMessage()
inherited_from \Zend\Captcha\AbstractWord::translateMessage()

Parameters

$messageKey

string

$message

string

Returns

string

 Properties

 

$C

$C 
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$C
 

$CN

$CN 
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$CN
 

$V

$V 
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$V
 

$VN

$VN 
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$VN
 

$abstractOptions

$abstractOptions 
Inherited

inherited_from \Zend\Validator\AbstractValidator::$$abstractOptions
inherited_from \Zend\Captcha\AbstractAdapter::$$abstractOptions
inherited_from \Zend\Captcha\AbstractWord::$$abstractOptions
 

Default translation object for all validate objects

$defaultTranslator : \Zend\I18n\Translator\Translator
Inherited

inherited_from \Zend\Validator\AbstractValidator::$$defaultTranslator
inherited_from \Zend\Captcha\AbstractAdapter::$$defaultTranslator
inherited_from \Zend\Captcha\AbstractWord::$$defaultTranslator
 

Default text domain to be used with translator

$defaultTranslatorTextDomain : string
Inherited

inherited_from \Zend\Validator\AbstractValidator::$$defaultTranslatorTextDomain
inherited_from \Zend\Captcha\AbstractAdapter::$$defaultTranslatorTextDomain
inherited_from \Zend\Captcha\AbstractWord::$$defaultTranslatorTextDomain
 

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

$dotNoiseLevel : int

 

How long to keep generated images

$expiration : int

 

Image font file

$font : string

 

Font size

$fsize : int

 

How frequently to execute garbage collection

$gcFreq : int

 

Image height

$height : int

 

Random session ID

$id : string
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$id
 

Image's alt tag content

$imgAlt : string

 

Directory for generated images

$imgDir : string

 

URL for accessing images

$imgUrl : string

 

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

$keepSession : bool
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$keepSession
 

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

$lineNoiseLevel : int

 

Limits the maximum returned length of a error message

$messageLength : Integer
Inherited

inherited_from \Zend\Validator\AbstractValidator::$$messageLength
inherited_from \Zend\Captcha\AbstractAdapter::$$messageLength
inherited_from \Zend\Captcha\AbstractWord::$$messageLength
 

Error messages

$messageTemplates : array
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$messageTemplates
 

Captcha name

$name : string
Inherited

Useful to generate/check form fields

inherited_from \Zend\Captcha\AbstractAdapter::$$name
inherited_from \Zend\Captcha\AbstractWord::$$name
 

Captcha options

$options : array
Inherited

inherited_from \Zend\Captcha\AbstractAdapter::$$options
inherited_from \Zend\Captcha\AbstractWord::$$options
 

Session

$session : \Zend\Session\Container
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$session
 

Class name for sessions

$sessionClass : string
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$sessionClass
 

Options to skip when processing options

$skipOptions : array
Inherited

inherited_from \Zend\Captcha\AbstractAdapter::$$skipOptions
inherited_from \Zend\Captcha\AbstractWord::$$skipOptions
 

Image to use as starting point Default is blank image.

$startImage : string

If provided, should be PNG image.

 

Image suffix (including dot)

$suffix : string

 

Session lifetime for the captcha data

$timeout : integer
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$timeout
 

Should the numbers be used or only letters

$useNumbers : bool
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$useNumbers
 

The value to be validated

$value : mixed
Inherited

inherited_from \Zend\Validator\AbstractValidator::$$value
inherited_from \Zend\Captcha\AbstractAdapter::$$value
inherited_from \Zend\Captcha\AbstractWord::$$value
 

Image width

$width : int

 

Generated word

$word : string
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$word
 

Length of the word to generate

$wordlen : integer
Inherited

inherited_from \Zend\Captcha\AbstractWord::$$wordlen

 Constants

 

BAD_CAPTCHA

BAD_CAPTCHA 
Inherited

inherited_from \Zend\Captcha\AbstractWord::BAD_CAPTCHA
 

MISSING_ID

MISSING_ID 
Inherited

inherited_from \Zend\Captcha\AbstractWord::MISSING_ID
 

MISSING_VALUE

MISSING_VALUE 
Inherited

inherited_from \Zend\Captcha\AbstractWord::MISSING_VALUE