PHP Class ValidateCode

Mostrar archivo Open project: zblogcn/zblogphp Class Usage Examples

Protected Properties

Property Type Description
$backgroundColor array
$charset
$codelen
$contents resource
$distortion boolean
$fingerprint array
$font 高度
$fontsize 字体
$height 宽度
$ignoreAllEffects boolean Ignore all effects
$interpolation boolean Is the interpolation enabled ?
$maxAngle The maximum angle of char
$maxBehindLines The maximum number of lines to draw behind the image. null - use default algorithm
$maxFrontLines The maximum number of lines to draw in front of the image. null - use default algorithm
$maxOffset The maximum offset of char
$phrase string
$textColor array
$useFingerprint boolean
$width 位数

Public Methods

Method Description
GetCode ( ) : string 获取验证码
GetImg ( $n = null ) 对外生成
__construct ( )
build ( $fingerprint = null ) Generate the image
create ( $phrase = null ) Instantiation
directOutput ( $quality = 90 ) Outputs the image
distort ( $image, $width, $height, $bg ) Distorts the image
get ( $quality = 90 ) Gets the image contents
getContents ( ) The image contents
getFingerprint ( ) : array
getGd ( ) Gets the image GD
getPhrase ( ) Gets the captcha phrase
inline ( $quality = 90 ) Gets the HTML inline base64
output ( ) Outputs the image
setBackgroundColor ( $r, $g, $b ) Sets the background color to use
setBackgroundImages ( array $backgroundImages ) Sets the list of background images to use (one image is randomly selected)
setDistortion ( $distortion ) Enables/disable distortion
setIgnoreAllEffects ( boolean $ignoreAllEffects ) : CaptchaBuilder Sets the ignoreAllEffects value
setInterpolation ( $interpolate = true ) : CaptchaBuilder Enable/Disables the interpolation
setMaxAngle ( $maxAngle )
setMaxBehindLines ( $maxBehindLines )
setMaxFrontLines ( $maxFrontLines )
setMaxOffset ( $maxOffset )
setPhrase ( $phrase ) Setting the phrase
setTextColor ( $r, $g, $b ) Sets the text color to use

Protected Methods

Method Description
createCode ( $n = null ) 生成随机码
drawLine ( $image, $width, $height, $tcol = null ) Draw lines over the image
getCol ( $image, $x, $y, $background ) : integer
getRGB ( $col ) : array
interpolate ( $x, $y, $nw, $ne, $sw, $se ) : integer
postEffect ( $image ) Apply some post effects
rand ( $min, $max ) Returns a random number or the next number in the fingerprint
writePhrase ( $image, $phrase, $font, $width, $height ) Writes the phrase on the image

Method Details

GetCode() public method

获取验证码
public GetCode ( ) : string
return string

GetImg() public method

对外生成
public GetImg ( $n = null )

__construct() public method

public __construct ( )

build() public method

Generate the image
public build ( $fingerprint = null )

create() public static method

Instantiation
public static create ( $phrase = null )

createCode() protected method

生成随机码
protected createCode ( $n = null )

directOutput() public method

Outputs the image
public directOutput ( $quality = 90 )

distort() public method

Distorts the image
public distort ( $image, $width, $height, $bg )

drawLine() protected method

Draw lines over the image
protected drawLine ( $image, $width, $height, $tcol = null )

get() public method

Gets the image contents
public get ( $quality = 90 )

getCol() protected method

protected getCol ( $image, $x, $y, $background ) : integer
$image
$x
$y
return integer

getContents() public method

The image contents
public getContents ( )

getFingerprint() public method

public getFingerprint ( ) : array
return array

getGd() public method

Gets the image GD
public getGd ( )

getPhrase() public method

Gets the captcha phrase
public getPhrase ( )

getRGB() protected method

protected getRGB ( $col ) : array
$col
return array

inline() public method

Gets the HTML inline base64
public inline ( $quality = 90 )

interpolate() protected method

protected interpolate ( $x, $y, $nw, $ne, $sw, $se ) : integer
$x
$y
$nw
$ne
$sw
$se
return integer

output() public method

Outputs the image
public output ( )

postEffect() protected method

Apply some post effects
protected postEffect ( $image )

rand() protected method

Returns a random number or the next number in the fingerprint
protected rand ( $min, $max )

setBackgroundColor() public method

Sets the background color to use
public setBackgroundColor ( $r, $g, $b )

setBackgroundImages() public method

Sets the list of background images to use (one image is randomly selected)
public setBackgroundImages ( array $backgroundImages )
$backgroundImages array

setDistortion() public method

Enables/disable distortion
public setDistortion ( $distortion )

setIgnoreAllEffects() public method

Sets the ignoreAllEffects value
public setIgnoreAllEffects ( boolean $ignoreAllEffects ) : CaptchaBuilder
$ignoreAllEffects boolean
return CaptchaBuilder

setInterpolation() public method

Enable/Disables the interpolation
public setInterpolation ( $interpolate = true ) : CaptchaBuilder
$interpolate bool True to enable, false to disable
return CaptchaBuilder

setMaxAngle() public method

public setMaxAngle ( $maxAngle )

setMaxBehindLines() public method

public setMaxBehindLines ( $maxBehindLines )

setMaxFrontLines() public method

public setMaxFrontLines ( $maxFrontLines )

setMaxOffset() public method

public setMaxOffset ( $maxOffset )

setPhrase() public method

Setting the phrase
public setPhrase ( $phrase )

setTextColor() public method

Sets the text color to use
public setTextColor ( $r, $g, $b )

writePhrase() protected method

Writes the phrase on the image
protected writePhrase ( $image, $phrase, $font, $width, $height )

Property Details

$backgroundColor protected_oe property

protected array $backgroundColor
return array

$charset protected_oe property

protected $charset

$codelen protected_oe property

protected $codelen

$contents protected_oe property

protected resource $contents
return resource

$distortion protected_oe property

protected bool $distortion
return boolean

$fingerprint protected_oe property

protected array $fingerprint
return array

$font protected_oe property

高度
protected $font

$fontsize protected_oe property

字体
protected $fontsize

$height protected_oe property

宽度
protected $height

$ignoreAllEffects protected_oe property

Ignore all effects
protected bool $ignoreAllEffects
return boolean

$interpolation protected_oe property

Is the interpolation enabled ?
protected bool $interpolation
return boolean

$maxAngle protected_oe property

The maximum angle of char
protected $maxAngle

$maxBehindLines protected_oe property

The maximum number of lines to draw behind the image. null - use default algorithm
protected $maxBehindLines

$maxFrontLines protected_oe property

The maximum number of lines to draw in front of the image. null - use default algorithm
protected $maxFrontLines

$maxOffset protected_oe property

The maximum offset of char
protected $maxOffset

$phrase protected_oe property

protected string $phrase
return string

$textColor protected_oe property

protected array $textColor
return array

$useFingerprint protected_oe property

protected bool $useFingerprint
return boolean

$width protected_oe property

位数
protected $width