API Documentation

Captcha/Image.php

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

category
Zend  
copyright
Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Captcha  
subpackage
Adapter  
version
$Id: Image.php 24146 2011-06-15 13:15:22Z adamlundrigan $  

\Zend_Captcha_Image

Image-based captcha element

Generates image displaying random word

Extends from
\Zend_Captcha_Word
category
Zend  
copyright
Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Captcha  
subpackage
Adapter  
version
$Id: Word.php 23775 2011-03-01 17:25:24Z ralph $  

Properties

Propertyprotectedint  $_dotNoiseLevel= '100'

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

Default value100Details
Type
int
Propertyprotectedint  $_expiration= '600'

How long to keep generated images

Default value600Details
Type
int
Propertyprotectedstring  $_font= ''

Image font file

Details
Type
string
Propertyprotectedint  $_fsize= '24'

Font size

Default value24Details
Type
int
Propertyprotectedint  $_gcFreq= '10'

How frequently to execute garbage collection

Default value10Details
Type
int
Propertyprotectedint  $_height= '50'

Image height

Default value50Details
Type
int
Propertyprotectedstring  $_imgAlt= ''

Image's alt tag content

Details
Type
string
Propertyprotectedstring  $_imgDir= './images/captcha/'

Directory for generated images

Default value./images/captcha/Details
Type
string
Propertyprotectedstring  $_imgUrl= '/images/captcha/'

URL for accessing images

Default value/images/captcha/Details
Type
string
Propertyprotectedint  $_lineNoiseLevel= '5'

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

Default value5Details
Type
int
Propertyprotectedstring  $_startImage= ''

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

Details
Type
string
Propertyprotectedstring  $_suffix= '.png'

Image suffix (including dot)

Default value.pngDetails
Type
string
Propertyprotectedint  $_width= '200'

Image width

Default value200Details
Type
int

Methods

methodpublic__construct( array|\Zend_Config $options = null ) : void

Constructor

Inherited from: \Zend_Captcha_Base::__construct()
Parameters
Name Type Description
$options array|\Zend_Config
methodpublic__get( string $property ) : mixed

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

Inherited from: \Zend_Validate_Abstract::__get()
Parameters
Name Type Description
$property string
Returns
Type Description
mixed
Throws
Exception Description
\Zend_Validate_Exception
methodprotected_createMessage( string $messageKey, string $value ) : string

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

Inherited from: \Zend_Validate_Abstract::_createMessage()

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
Name Type Description
$messageKey string
$value string
Returns
Type Description
string
methodprotected_error( string $messageKey, string $value = null ) : void
Parameters
Name Type Description
$messageKey string
$value string OPTIONAL
methodprotected_gc( ) : void

Remove old files from image directory

methodprotected_generateImage( string $id, string $word ) : void

Generate image captcha

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

Parameters
Name Type Description
$id string Captcha ID
$word string Captcha word
methodprotected_generateRandomId( ) : void
methodprotected_generateWord( ) : string

Generate new random word

Inherited from: \Zend_Captcha_Word::_generateWord()
Returns
Type Description
string
methodprotected_randomFreq( ) : float

Generate random frequency

Returns
Type Description
float
methodprotected_randomPhase( ) : float

Generate random phase

Returns
Type Description
float
methodprotected_randomSize( ) : int

Generate random character size

Returns
Type Description
int
methodprotected_setId( string $id ) : void

Set captcha identifier

Inherited from: \Zend_Captcha_Word::_setId()
Parameters
Name Type Description
$id string return Zend_Captcha_Word
methodprotected_setValue( mixed $value ) : void

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

Inherited from: \Zend_Validate_Abstract::_setValue()
Parameters
Name Type Description
$value mixed
methodprotected_setWord( string $word ) : \Zend_Captcha_Word

Set captcha word

Inherited from: \Zend_Captcha_Word::_setWord()
Parameters
Name Type Description
$word string
Returns
Type Description
\Zend_Captcha_Word
methodpublicgenerate( ) : string

Generate captcha

Returns
Type Description
string captcha ID
methodpublicgetDecorator( ) : string

Get captcha decorator

Inherited from: \Zend_Captcha_Word::getDecorator()

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

Returns
Type Description
string
methodpublicgetDefaultTranslator( ) : \Zend_Translate_Adapter|null
static

Get default translation object for all validate objects

Inherited from: \Zend_Validate_Abstract::getDefaultTranslator()
Returns
Type Description
\Zend_Translate_Adapternull
methodpublicgetDotNoiseLevel( ) : int

Returns
Type Description
int
methodpublicgetErrors( ) : array

Returns array of validation failure message codes

Inherited from: \Zend_Validate_Abstract::getErrors()
Returns
Type Description
array
Details
deprecated
Since 1.5.0  
methodpublicgetExpiration( ) : int

Get captcha expiration

Returns
Type Description
int
methodpublicgetFont( ) : string

Get font to use when generating captcha

Returns
Type Description
string
methodpublicgetFontSize( ) : int

Get font size

Returns
Type Description
int
methodpublicgetGcFreq( ) : int

Get garbage collection frequency

Returns
Type Description
int
methodpublicgetHeight( ) : int

Get captcha image height

Returns
Type Description
int
methodpublicgetId( ) : string

Retrieve captcha ID

Inherited from: \Zend_Captcha_Word::getId()
Returns
Type Description
string
methodpublicgetImgAlt( ) : string

Returns
Type Description
string
methodpublicgetImgDir( ) : string

Get captcha image directory

Returns
Type Description
string
methodpublicgetImgUrl( ) : string

Get captcha image base URL

Returns
Type Description
string
methodpublicgetLineNoiseLevel( ) : int

Returns
Type Description
int
methodpublicgetMessageLength( ) : integer
static

Returns the maximum allowed message length

Inherited from: \Zend_Validate_Abstract::getMessageLength()
Returns
Type Description
integer
methodpublicgetMessageTemplates( ) : array

Returns the message templates from the validator

Inherited from: \Zend_Validate_Abstract::getMessageTemplates()
Returns
Type Description
array
methodpublicgetMessageVariables( ) : array

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

Inherited from: \Zend_Validate_Abstract::getMessageVariables()
Returns
Type Description
array
methodpublicgetMessages( ) : array

Returns array of validation failure messages

Inherited from: \Zend_Validate_Abstract::getMessages()

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

Returns
Type Description
array
methodpublicgetName( ) : string

Get name

Inherited from: \Zend_Captcha_Base::getName()
Returns
Type Description
string
methodpublicgetObscureValue( ) : bool

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

Inherited from: \Zend_Validate_Abstract::getObscureValue()
Returns
Type Description
bool
methodpublicgetOptions( ) : array

Retrieve options representing object state

Inherited from: \Zend_Captcha_Base::getOptions()
Returns
Type Description
array
methodpublicgetSession( ) : \Zend_Session_Namespace

Get session object

Inherited from: \Zend_Captcha_Word::getSession()
Returns
Type Description
\Zend_Session_Namespace
methodpublicgetSessionClass( ) : string

Retrieve session class to utilize

Inherited from: \Zend_Captcha_Word::getSessionClass()
Returns
Type Description
string
methodpublicgetStartImage( ) : string

Returns
Type Description
string
methodpublicgetSuffix( ) : string

Get captcha image file suffix

Returns
Type Description
string
methodpublicgetTimeout( ) : int

Get session token timeout

Inherited from: \Zend_Captcha_Word::getTimeout()
Returns
Type Description
int
methodpublicgetTranslator( ) : \Zend_Translate_Adapter|null

Return translation object

Inherited from: \Zend_Validate_Abstract::getTranslator()
Returns
Type Description
\Zend_Translate_Adapternull
methodpublicgetUseNumbers( ) : bool

Numbers should be included in the pattern?

Inherited from: \Zend_Captcha_Word::getUseNumbers()
Returns
Type Description
bool
methodpublicgetWidth( ) : int

Get captcha image width

Returns
Type Description
int
methodpublicgetWord( ) : string

Get captcha word

Inherited from: \Zend_Captcha_Word::getWord()
Returns
Type Description
string
methodpublicgetWordlen( ) : integer

Retrieve word length to use when genrating captcha

Inherited from: \Zend_Captcha_Word::getWordlen()
Returns
Type Description
integer
methodpublichasDefaultTranslator( ) : boolean
static

Is there a default translation object set?

Inherited from: \Zend_Validate_Abstract::hasDefaultTranslator()
Returns
Type Description
boolean
methodpublichasTranslator( ) : bool

Does this validator have its own specific translator?

Inherited from: \Zend_Validate_Abstract::hasTranslator()
Returns
Type Description
bool
methodpublicisValid( mixed $value,  $context = null ) : boolean

Validate the word

Inherited from: \Zend_Captcha_Word::isValid()

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

Parameters
Name Type Description
$value mixed
$context
Returns
Type Description
boolean
Throws
Exception Description
\Zend_Validate_Exception If validation of $value is impossible
Details
see
\Zend_Validate_Interface::isValid()  
methodpublicrender( \Zend_View_Interface $view = null, mixed $element = null ) : string

Display the captcha

Parameters
Name Type Description
$view \Zend_View_Interface
$element mixed
Returns
Type Description
string
methodpublicsetConfig( \Zend_Config $config ) : \Zend_Captcha_Base

Set object state from config object

Inherited from: \Zend_Captcha_Base::setConfig()
Parameters
Name Type Description
$config \Zend_Config
Returns
Type Description
\Zend_Captcha_Base
methodpublicsetDefaultTranslator( \Zend_Translate|\Zend_Translate_Adapter|null $translator = null ) : void
static

Set default translation object for all validate objects

Inherited from: \Zend_Validate_Abstract::setDefaultTranslator()
Parameters
Name Type Description
$translator \Zend_Translate|\Zend_Translate_Adapter|null
methodpublicsetDisableTranslator( bool $flag ) : \Zend_Validate_Abstract

Indicate whether or not translation should be disabled

Inherited from: \Zend_Validate_Abstract::setDisableTranslator()
Parameters
Name Type Description
$flag bool
Returns
Type Description
\Zend_Validate_Abstract
methodpublicsetDotNoiseLevel( int $dotNoiseLevel ) : void

Parameters
Name Type Description
$dotNoiseLevel int
methodpublicsetExpiration( int $expiration ) : \Zend_Captcha_Image

Set captcha expiration

Parameters
Name Type Description
$expiration int
Returns
Type Description
\Zend_Captcha_Image
methodpublicsetFont( string $font ) : \Zend_Captcha_Image

Set captcha font

Parameters
Name Type Description
$font string
Returns
Type Description
\Zend_Captcha_Image
methodpublicsetFontSize( int $fsize ) : \Zend_Captcha_Image

Set captcha font size

Parameters
Name Type Description
$fsize int
Returns
Type Description
\Zend_Captcha_Image
methodpublicsetGcFreq( int $gcFreq ) : \Zend_Captcha_Image

Set garbage collection frequency

Parameters
Name Type Description
$gcFreq int
Returns
Type Description
\Zend_Captcha_Image
methodpublicsetHeight( int $height ) : \Zend_Captcha_Image

Set captcha image height

Parameters
Name Type Description
$height int
Returns
Type Description
\Zend_Captcha_Image
methodpublicsetImgAlt( string $imgAlt ) : void

Parameters
Name Type Description
$imgAlt string
methodpublicsetImgDir( string $imgDir ) : \Zend_Captcha_Image

Set captcha image storage directory

Parameters
Name Type Description
$imgDir string
Returns
Type Description
\Zend_Captcha_Image
methodpublicsetImgUrl( string $imgUrl ) : \Zend_Captcha_Image

Set captcha image base URL

Parameters
Name Type Description
$imgUrl string
Returns
Type Description
\Zend_Captcha_Image
methodpublicsetKeepSession( bool $keepSession ) : \Zend_Captcha_Word

Sets if session should be preserved on generate()

Inherited from: \Zend_Captcha_Word::setKeepSession()
Parameters
Name Type Description
$keepSession bool

Should session be kept on generate()?

Returns
Type Description
\Zend_Captcha_Word
methodpublicsetLineNoiseLevel( int $lineNoiseLevel ) : void

Parameters
Name Type Description
$lineNoiseLevel int
methodpublicsetMessage( string $messageString, string $messageKey = null ) : \Zend_Validate_Abstract

Sets the validation failure message template for a particular key

Inherited from: \Zend_Validate_Abstract::setMessage()
Parameters
Name Type Description
$messageString string
$messageKey string OPTIONAL
Returns
Type Description
\Zend_Validate_Abstract Provides a fluent interface
Throws
Exception Description
\Zend_Validate_Exception
methodpublicsetMessageLength( integer $length ) : void
static

Sets the maximum allowed message length

Inherited from: \Zend_Validate_Abstract::setMessageLength()
Parameters
Name Type Description
$length integer
methodpublicsetMessages( array $messages ) : \Zend_Validate_Abstract

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.

Inherited from: \Zend_Validate_Abstract::setMessages()
Parameters
Name Type Description
$messages array
Returns
Type Description
\Zend_Validate_Abstract
methodpublicsetName( string $name ) : \Zend_Captcha_Adapter

Set name

Inherited from: \Zend_Captcha_Base::setName()
Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_Captcha_Adapter
methodpublicsetObscureValue( bool $flag ) : \Zend_Validate_Abstract

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

Inherited from: \Zend_Validate_Abstract::setObscureValue()
Parameters
Name Type Description
$flag bool
Returns
Type Description
\Zend_Validate_Abstract
methodpublicsetOption( string $key, string $value ) : \Zend_Form_Element

Set single option for the object

Inherited from: \Zend_Captcha_Base::setOption()
Parameters
Name Type Description
$key string
$value string
Returns
Type Description
\Zend_Form_Element
methodpublicsetOptions( array $options = null ) : \Zend_Form_Element

Set object state from options array

Inherited from: \Zend_Captcha_Base::setOptions()
Parameters
Name Type Description
$options array
Returns
Type Description
\Zend_Form_Element
methodpublicsetSession( \Zend_Session_Namespace $session ) : \Zend_Captcha_Word

Set session namespace object

Inherited from: \Zend_Captcha_Word::setSession()
Parameters
Name Type Description
$session \Zend_Session_Namespace
Returns
Type Description
\Zend_Captcha_Word
methodpublicsetSessionClass( string $_sessionClass ) : \Zend_Captcha_Word

Set session class for persistence

Inherited from: \Zend_Captcha_Word::setSessionClass()
Parameters
Name Type Description
$_sessionClass string
Returns
Type Description
\Zend_Captcha_Word
methodpublicsetStartImage( string $startImage ) : void

Parameters
Name Type Description
$startImage string
methodpublicsetSuffix( string $suffix ) : \Zend_Captcha_Image

Set captch image filename suffix

Parameters
Name Type Description
$suffix string
Returns
Type Description
\Zend_Captcha_Image
methodpublicsetTimeout( int $ttl ) : \Zend_Captcha_Word

Set timeout for session token

Inherited from: \Zend_Captcha_Word::setTimeout()
Parameters
Name Type Description
$ttl int
Returns
Type Description
\Zend_Captcha_Word
methodpublicsetTranslator( \Zend_Translate|\Zend_Translate_Adapter|null $translator = null ) : \Zend_Validate_Abstract

Set translation object

Inherited from: \Zend_Validate_Abstract::setTranslator()
Parameters
Name Type Description
$translator \Zend_Translate|\Zend_Translate_Adapter|null
Returns
Type Description
\Zend_Validate_Abstract
methodpublicsetUseNumbers( bool $_useNumbers ) : \Zend_Captcha_Word

Set if numbers should be included in the pattern

Inherited from: \Zend_Captcha_Word::setUseNumbers()
Parameters
Name Type Description
$_useNumbers bool

numbers should be included in the pattern?

Returns
Type Description
\Zend_Captcha_Word
methodpublicsetWidth( int $width ) : \Zend_Captcha_Image

Set captcha image width

Parameters
Name Type Description
$width int
Returns
Type Description
\Zend_Captcha_Image
methodpublicsetWordlen( integer $wordlen ) : \Zend_Captcha_Word

Set word length of captcha

Inherited from: \Zend_Captcha_Word::setWordlen()
Parameters
Name Type Description
$wordlen integer
Returns
Type Description
\Zend_Captcha_Word
methodpublictranslatorIsDisabled( ) : bool

Is translation disabled?

Inherited from: \Zend_Validate_Abstract::translatorIsDisabled()
Returns
Type Description
bool
Documentation was generated by DocBlox 0.13.3.