UserFrosting API

Captcha

Captcha Class.

Implements the captcha for user registration.

Tags
author

r3wt

author

Alex Weissman (https://alexanderweissman.com)

see
http://www.userfrosting.com/components/#messages

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

Methods

__construct()

Create a new captcha.

public __construct( $session : Session , $key : string ) : mixed
Parameters
$session : Session
$key : string
Return values
mixed

generateRandomCode()

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
mixed

getCaptcha()

Returns the captcha code.

public getCaptcha( ) : string
Return values
string

getImage()

Returns the captcha image.

public getImage( ) : string
Return values
string

verifyCode()

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
bool

generateImage()

Generate the image for the current captcha.

protected generateImage( ) : string

This generates an image as a binary string.

Return values
string

Search results