PHP Class Pop\Image\Captcha

Author: Nick Sagona, III ([email protected])
Show file Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$border mixed CAPTCHA border width
$colors integer CAPTCHA colors
$expire integer CAPTCHA token expiration in seconds
$font string CAPTCHA font
$grid integer CAPTCHA grid spacing
$image mixed CAPTCHA image resource
$length integer CAPTCHA string length
$rotate integer CAPTCHA rotate
$size integer CAPTCHA font size (if using system fonts, it will be capped at 5)
$swirl integer CAPTCHA swirl
$token array CAPTCHA token object
$x integer CAPTCHA x
$y integer CAPTCHA y

Public Methods

Method Description
__construct ( array $options, boolean $forceGd = false ) : Captcha Constructor
factory ( array $options, boolean $forceGd = false ) : Captcha Static method to instantiate the CAPTCHA image object and return itself to facilitate chaining methods together.
generateToken ( ) : void Method to generate the token object
getBackgroundColor ( ) : array Method to get the background color
getBorderColor ( ) : array Method to get the border color
getBorderWidth ( ) : mixed Method to get the border width
getExpire ( ) : integer Method to get the expiration length in seconds
getFont ( ) : string Method to get the font
getGridColor ( ) : array Method to get the grid color
getGridWidth ( ) : integer Method to get the grid spacing
getLength ( ) : integer Method to get the string length
getRotate ( ) : integer Method to get the rotation
getSize ( ) : integer Method to get the font size
getSwirl ( ) : integer Method to get the swirl
getTextColor ( ) : array Method to get the text color
getToken ( ) : array Method to get the token object, generating a new one if necessary
getX ( ) : integer Method to get the X position
getY ( ) : integer Method to get the Y position
image ( ) : mixed Method to get the image object
output ( ) : void Method to output the image object
setBackgroundColor ( integer $r, integer $g, integer $b ) : Captcha Method to set the background color
setBorderColor ( integer $r = null, integer $g = null, integer $b = null ) : Captcha Method to set the border color
setBorderWidth ( mixed $border = 0.55 ) : Captcha Method to set the border width
setExpire ( integer $expire = 300 ) : Captcha Method to set the expiration length in seconds
setFont ( string $font = null ) : Captcha Method to set the font
setGridColor ( integer $r = null, integer $g = null, integer $b = null ) : Captcha Method to set the grid color
setGridWidth ( integer $grid = 5 ) : Captcha Method to set the grid spacing
setLength ( integer $length = 4 ) : Captcha Method to set the string length
setRotate ( integer $rotate = null ) : Captcha Method to set the rotation
setSize ( integer $size = 20 ) : Captcha Method to set the font size
setSwirl ( integer $swirl = null ) : Captcha Method to set the swirl
setTextColor ( integer $r, integer $g, integer $b ) : Captcha Method to set the text color
setX ( integer $x = null ) : Captcha Method to set the X position
setXY ( integer $x = null, integer $y = null ) : Captcha Method to set the X, Y position
setY ( integer $y = null ) : Captcha Method to set the Y position

Method Details

__construct() public method

Instantiate a CAPTCHA image object. Valid options are: $options = array( 'width' => 75, 'height' => 25, 'background' => array(200, 200, 200) // R, G, B values for the background color ); $options = array( 'image' => 'some-image-background,gif' ); This $forceGd flag forces the object to use the Gd extension. If both are installed, it will default to Imagick unless this flag is set to true.
public __construct ( array $options, boolean $forceGd = false ) : Captcha
$options array
$forceGd boolean
return Captcha

factory() public static method

Static method to instantiate the CAPTCHA image object and return itself to facilitate chaining methods together.
public static factory ( array $options, boolean $forceGd = false ) : Captcha
$options array
$forceGd boolean
return Captcha

generateToken() public method

Method to generate the token object
public generateToken ( ) : void
return void

getBackgroundColor() public method

Method to get the background color
public getBackgroundColor ( ) : array
return array

getBorderColor() public method

Method to get the border color
public getBorderColor ( ) : array
return array

getBorderWidth() public method

Method to get the border width
public getBorderWidth ( ) : mixed
return mixed

getExpire() public method

Method to get the expiration length in seconds
public getExpire ( ) : integer
return integer

getFont() public method

Method to get the font
public getFont ( ) : string
return string

getGridColor() public method

Method to get the grid color
public getGridColor ( ) : array
return array

getGridWidth() public method

Method to get the grid spacing
public getGridWidth ( ) : integer
return integer

getLength() public method

Method to get the string length
public getLength ( ) : integer
return integer

getRotate() public method

Method to get the rotation
public getRotate ( ) : integer
return integer

getSize() public method

Method to get the font size
public getSize ( ) : integer
return integer

getSwirl() public method

Method to get the swirl
public getSwirl ( ) : integer
return integer

getTextColor() public method

Method to get the text color
public getTextColor ( ) : array
return array

getToken() public method

Method to get the token object, generating a new one if necessary
public getToken ( ) : array
return array

getX() public method

Method to get the X position
public getX ( ) : integer
return integer

getY() public method

Method to get the Y position
public getY ( ) : integer
return integer

image() public method

Method to get the image object
public image ( ) : mixed
return mixed

output() public method

Method to output the image object
public output ( ) : void
return void

setBackgroundColor() public method

Method to set the background color
public setBackgroundColor ( integer $r, integer $g, integer $b ) : Captcha
$r integer
$g integer
$b integer
return Captcha

setBorderColor() public method

Method to set the border color
public setBorderColor ( integer $r = null, integer $g = null, integer $b = null ) : Captcha
$r integer
$g integer
$b integer
return Captcha

setBorderWidth() public method

Method to set the border width
public setBorderWidth ( mixed $border = 0.55 ) : Captcha
$border mixed
return Captcha

setExpire() public method

Method to set the expiration length in seconds
public setExpire ( integer $expire = 300 ) : Captcha
$expire integer
return Captcha

setFont() public method

Method to set the font
public setFont ( string $font = null ) : Captcha
$font string
return Captcha

setGridColor() public method

Method to set the grid color
public setGridColor ( integer $r = null, integer $g = null, integer $b = null ) : Captcha
$r integer
$g integer
$b integer
return Captcha

setGridWidth() public method

Method to set the grid spacing
public setGridWidth ( integer $grid = 5 ) : Captcha
$grid integer
return Captcha

setLength() public method

Method to set the string length
public setLength ( integer $length = 4 ) : Captcha
$length integer
return Captcha

setRotate() public method

Method to set the rotation
public setRotate ( integer $rotate = null ) : Captcha
$rotate integer
return Captcha

setSize() public method

Method to set the font size
public setSize ( integer $size = 20 ) : Captcha
$size integer
return Captcha

setSwirl() public method

Method to set the swirl
public setSwirl ( integer $swirl = null ) : Captcha
$swirl integer
return Captcha

setTextColor() public method

Method to set the text color
public setTextColor ( integer $r, integer $g, integer $b ) : Captcha
$r integer
$g integer
$b integer
return Captcha

setX() public method

Method to set the X position
public setX ( integer $x = null ) : Captcha
$x integer
return Captcha

setXY() public method

Method to set the X, Y position
public setXY ( integer $x = null, integer $y = null ) : Captcha
$x integer
$y integer
return Captcha

setY() public method

Method to set the Y position
public setY ( integer $y = null ) : Captcha
$y integer
return Captcha

Property Details

$border protected property

CAPTCHA border width
protected mixed $border
return mixed

$colors protected property

CAPTCHA colors
protected int $colors
return integer

$expire protected property

CAPTCHA token expiration in seconds
protected int $expire
return integer

$font protected property

CAPTCHA font
protected string $font
return string

$grid protected property

CAPTCHA grid spacing
protected int $grid
return integer

$image protected property

CAPTCHA image resource
protected mixed $image
return mixed

$length protected property

CAPTCHA string length
protected int $length
return integer

$rotate protected property

CAPTCHA rotate
protected int $rotate
return integer

$size protected property

CAPTCHA font size (if using system fonts, it will be capped at 5)
protected int $size
return integer

$swirl protected property

CAPTCHA swirl
protected int $swirl
return integer

$token protected property

CAPTCHA token object
protected array $token
return array

$x protected property

CAPTCHA x
protected int $x
return integer

$y protected property

CAPTCHA y
protected int $y
return integer