Captcha
Captcha Class.
Implements the captcha for user registration.
Tags
Table of Contents
$code | string | |
---|---|---|
$image | string | |
$session | Session | |
$key | string | |
__construct() | Create a new captcha. | mixed |
generateRandomCode() | Generates a new captcha for the user registration form. | mixed |
getCaptcha() | Returns the captcha code. | string |
getImage() | Returns the captcha image. | string |
verifyCode() | Check that the specified code, when hashed, matches the code in the session. | bool |
generateImage() | Generate the image for the current captcha. | string |
Properties
$code
protected
string
$code
$image
protected
string
$image
$session
protected
Session
$session
$key
protected
string
$key
Methods
__construct()
Create a new captcha.
public
__construct(
$session :
Session
, $key :
string
)
: mixed
Parameters
- $session : Session
- $key : string
Return values
mixedgenerateRandomCode()
Generates a new captcha for the user registration form.
public
generateRandomCode(
)
: mixed
This generates a random 5-character captcha and stores it in the session with an md5 hash. Also, generates the corresponding captcha image.
Return values
mixedgetCaptcha()
Returns the captcha code.
public
getCaptcha(
)
: string
Return values
stringgetImage()
Returns the captcha image.
public
getImage(
)
: string
Return values
stringverifyCode()
Check that the specified code, when hashed, matches the code in the session.
public
verifyCode(
$code :
string
)
: bool
Also, stores the specified code in the session with an md5 hash.
Parameters
- $code : string
Return values
boolgenerateImage()
Generate the image for the current captcha.
protected
generateImage(
)
: string
This generates an image as a binary string.