Zend Framework  3.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Image Class Reference

Image-based captcha element. More...

Public Member Functions

 __construct ($options=null)
 Constructor.
 
 getImgAlt ()
 
 getStartImage ()
 
 getDotNoiseLevel ()
 
 getLineNoiseLevel ()
 
 getExpiration ()
 Get captcha expiration.
 
 getGcFreq ()
 Get garbage collection frequency.
 
 getFont ()
 Get font to use when generating captcha.
 
 getFontSize ()
 Get font size.
 
 getHeight ()
 Get captcha image height.
 
 getImgDir ()
 Get captcha image directory.
 
 getImgUrl ()
 Get captcha image base URL.
 
 getSuffix ()
 Get captcha image file suffix.
 
 getWidth ()
 Get captcha image width.
 
 setStartImage ($startImage)
 
 setDotNoiseLevel ($dotNoiseLevel)
 
 setLineNoiseLevel ($lineNoiseLevel)
 
 setExpiration ($expiration)
 Set captcha expiration.
 
 setGcFreq ($gcFreq)
 Set garbage collection frequency.
 
 setFont ($font)
 Set captcha font.
 
 setFontSize ($fsize)
 Set captcha font size.
 
 setHeight ($height)
 Set captcha image height.
 
 setImgDir ($imgDir)
 Set captcha image storage directory.
 
 setImgUrl ($imgUrl)
 Set captcha image base URL.
 
 setImgAlt ($imgAlt)
 
 setSuffix ($suffix)
 Set captcha image filename suffix.
 
 setWidth ($width)
 Set captcha image width.
 
 generate ()
 Generate captcha.
 
 getHelperName ()
 Get helper name used to render captcha.
 
- Public Member Functions inherited from AbstractWord
 getSessionClass ()
 Retrieve session class to utilize.
 
 setSessionClass ($sessionClass)
 Set session class for persistence.
 
 getWordlen ()
 Retrieve word length to use when generating captcha.
 
 setWordlen ($wordlen)
 Set word length of captcha.
 
 getId ()
 Retrieve captcha ID.
 
 setTimeout ($ttl)
 Set timeout for session token.
 
 getTimeout ()
 Get session token timeout.
 
 setKeepSession ($keepSession)
 Sets if session should be preserved on generate()
 
 getUseNumbers ()
 Numbers should be included in the pattern?
 
 setUseNumbers ($useNumbers)
 Set if numbers should be included in the pattern.
 
 getSession ()
 Get session object.
 
 setSession (Container $session)
 Set session namespace object.
 
 getWord ()
 Get captcha word.
 
 generate ()
 Generate new session ID and new word.
 
 isValid ($value, $context=null)
 Validate the word.
 
 getHelperName ()
 Get helper name used to render captcha.
 
- Public Member Functions inherited from AbstractAdapter
 getName ()
 Get name.
 
 setName ($name)
 Set name.
 
 setOption ($key, $value)
 Set single option for the object.
 
 setOptions ($options=[])
 Set object state from options array.
 
 getOptions ()
 Retrieve options representing object state.
 
 getHelperName ()
 Get helper name used to render captcha.
 
- Public Member Functions inherited from AbstractValidator
 __construct ($options=null)
 Abstract constructor for all validators A validator should accept following parameters:
 
 getOption ($option)
 Returns an option.
 
 getOptions ()
 Returns all available options.
 
 setOptions ($options=[])
 Sets one or multiple options.
 
 getMessages ()
 Returns array of validation failure messages.
 
 __invoke ($value)
 Invoke as command.
 
 getMessageVariables ()
 Returns an array of the names of variables that are used in constructing validation failure messages.
 
 getMessageTemplates ()
 Returns the message templates from the validator.
 
 setMessage ($messageString, $messageKey=null)
 Sets the validation failure message template for a particular key.
 
 setMessages (array $messages)
 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.
 
 __get ($property)
 Magic function returns the value of the requested property, if and only if it is the value or a message variable.
 
 setValueObscured ($flag)
 Set flag indicating whether or not value should be obfuscated in messages.
 
 isValueObscured ()
 Retrieve flag indicating whether or not value should be obfuscated in messages.
 
 setTranslator (Translator\TranslatorInterface $translator=null, $textDomain=null)
 Set translation object.
 
 getTranslator ()
 Return translation object.
 
 hasTranslator ()
 Does this validator have its own specific translator?
 
 setTranslatorTextDomain ($textDomain= 'default')
 Set translation text domain.
 
 getTranslatorTextDomain ()
 Return the translation text domain.
 
 setTranslatorEnabled ($flag=true)
 Indicate whether or not translation should be enabled.
 
 isTranslatorEnabled ()
 Is translation enabled?
 
- Public Member Functions inherited from TranslatorAwareInterface
 setTranslator (TranslatorInterface $translator=null, $textDomain=null)
 Sets translator to use in helper.
 
- Public Member Functions inherited from ValidatorInterface
 isValid ($value)
 Returns true if and only if $value meets the validation requirements.
 

Protected Member Functions

 randomFreq ()
 Generate random frequency.
 
 randomPhase ()
 Generate random phase.
 
 randomSize ()
 Generate random character size.
 
 generateImage ($id, $word)
 Generate image captcha.
 
 gc ()
 Remove old files from image directory.
 
- Protected Member Functions inherited from AbstractWord
 setId ($id)
 Set captcha identifier.
 
 setWord ($word)
 Set captcha word.
 
 generateWord ()
 Generate new random word.
 
 generateRandomId ()
 Generate a random identifier.
 

Protected Attributes

 $imgDir = "public/images/captcha/"
 
 $imgUrl = "/images/captcha/"
 
 $imgAlt = ""
 
 $suffix = ".png"
 
 $width = 200
 
 $height = 50
 
 $fsize = 24
 
 $font
 
 $startImage
 
 $gcFreq = 10
 
 $expiration = 600
 
 $dotNoiseLevel = 100
 
 $lineNoiseLevel = 5
 
- Protected Attributes inherited from AbstractWord
 $id
 
 $word
 
 $session
 
 $sessionClass = 'Zend\Session\Container'
 
 $useNumbers = true
 
 $timeout = 300
 
 $keepSession = false
 
 $messageTemplates
 
 $wordlen = 8
 
- Protected Attributes inherited from AbstractAdapter
 $name
 
 $options = []
 
 $skipOptions
 
- Protected Attributes inherited from AbstractValidator
 $value
 
 $abstractOptions
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractValidator
static setDefaultTranslator (Translator\TranslatorInterface $translator=null, $textDomain=null)
 Set default translation object for all validate objects.
 
static getDefaultTranslator ()
 Get default translation object for all validate objects.
 
static hasDefaultTranslator ()
 Is there a default translation object set?
 
static setDefaultTranslatorTextDomain ($textDomain= 'default')
 Set default translation text domain for all validate objects.
 
static getDefaultTranslatorTextDomain ()
 Get default translation text domain for all validate objects.
 
static getMessageLength ()
 Returns the maximum allowed message length.
 
static setMessageLength ($length=-1)
 Sets the maximum allowed message length.
 
- Public Attributes inherited from AbstractWord
const MISSING_VALUE = 'missingValue'
 #@+ Error codes
 
const MISSING_ID = 'missingID'
 
const BAD_CAPTCHA = 'badCaptcha'
 
- Static Public Attributes inherited from AbstractWord
static $V = ["a", "e", "i", "o", "u", "y"]
 
static $VN = ["a", "e", "i", "o", "u", "y", "2", "3", "4", "5", "6", "7", "8", "9"]
 
static $C = ["b", "c", "d", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "z"]
 
static $CN = ["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 Protected Attributes inherited from AbstractValidator
static $defaultTranslator
 
static $defaultTranslatorTextDomain = 'default'
 
static $messageLength = -1
 

Detailed Description

Image-based captcha element.

Generates image displaying random word

Constructor & Destructor Documentation

__construct (   $options = null)

Constructor.

Parameters
array | \Traversable$options
Exceptions
Exception\ExtensionNotLoadedException

Member Function Documentation

gc ( )
protected

Remove old files from image directory.

generate ( )

Generate captcha.

Returns
string captcha ID

Implements AdapterInterface.

generateImage (   $id,
  $word 
)
protected

Generate image captcha.

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

Parameters
string$idCaptcha ID
string$wordCaptcha word
Exceptions
Exception\NoFontProvidedExceptionif no font was set
Exception\ImageNotLoadableExceptionif start image cannot be loaded
getDotNoiseLevel ( )
Returns
int
getExpiration ( )

Get captcha expiration.

Returns
int
getFont ( )

Get font to use when generating captcha.

Returns
string
getFontSize ( )

Get font size.

Returns
int
getGcFreq ( )

Get garbage collection frequency.

Returns
int
getHeight ( )

Get captcha image height.

Returns
int
getHelperName ( )

Get helper name used to render captcha.

Returns
string

Implements AdapterInterface.

getImgAlt ( )
Returns
string
getImgDir ( )

Get captcha image directory.

Returns
string
getImgUrl ( )

Get captcha image base URL.

Returns
string
getLineNoiseLevel ( )
Returns
int
getStartImage ( )
Returns
string
getSuffix ( )

Get captcha image file suffix.

Returns
string
getWidth ( )

Get captcha image width.

Returns
int
randomFreq ( )
protected

Generate random frequency.

Returns
float
randomPhase ( )
protected

Generate random phase.

Returns
float
randomSize ( )
protected

Generate random character size.

Returns
int
setDotNoiseLevel (   $dotNoiseLevel)
Parameters
int$dotNoiseLevel
Returns
Image
setExpiration (   $expiration)

Set captcha expiration.

Parameters
int$expiration
Returns
Image
setFont (   $font)

Set captcha font.

Parameters
string$font
Returns
Image
setFontSize (   $fsize)

Set captcha font size.

Parameters
int$fsize
Returns
Image
setGcFreq (   $gcFreq)

Set garbage collection frequency.

Parameters
int$gcFreq
Returns
Image
setHeight (   $height)

Set captcha image height.

Parameters
int$height
Returns
Image
setImgAlt (   $imgAlt)
Parameters
string$imgAlt
Returns
Image
setImgDir (   $imgDir)

Set captcha image storage directory.

Parameters
string$imgDir
Returns
Image
setImgUrl (   $imgUrl)

Set captcha image base URL.

Parameters
string$imgUrl
Returns
Image
setLineNoiseLevel (   $lineNoiseLevel)
Parameters
int$lineNoiseLevel
Returns
Image
setStartImage (   $startImage)
Parameters
string$startImage
Returns
Image
setSuffix (   $suffix)

Set captcha image filename suffix.

Parameters
string$suffix
Returns
Image
setWidth (   $width)

Set captcha image width.

Parameters
int$width
Returns
Image

Member Data Documentation

$dotNoiseLevel = 100
protected
$expiration = 600
protected
$font
protected
$fsize = 24
protected
$gcFreq = 10
protected
$height = 50
protected
$imgAlt = ""
protected
$imgDir = "public/images/captcha/"
protected
$imgUrl = "/images/captcha/"
protected
$lineNoiseLevel = 5
protected
$startImage
protected
$suffix = ".png"
protected
$width = 200
protected