libraries/drivers/Captcha – Kohana API 2.3 Documentation

system/libraries/drivers/Captcha.php

Class: Captcha_Driver

abstract class Captcha_Driver

Captcha driver class.


Methods

Captcha_Driver -> __construct

public function __construct

Constructs a new challenge.

Return: void


Captcha_Driver -> generate_challenge

abstract public function generate_challenge

Generate a new Captcha challenge.

Return: string the challenge answer


Captcha_Driver -> render

abstract public function render

Output the Captcha challenge.

Parameters:

boolean html
html output

Return: mixed the rendered Captcha (e.g. an image, riddle, etc.)


Captcha_Driver -> update_response_session

public function update_response_session

Stores the response for the current Captcha challenge in a session so it is available on the next page load for Captcha::valid(). This method is called after controller execution (in the system.post_controller event) in order not to overwrite itself too soon.

Return: void


Captcha_Driver -> valid

public function valid

Validates a Captcha response from a user.

Parameters:

string response
captcha response

Return: boolean


Captcha_Driver -> image_type

public function image_type

Returns the image type.

Parameters:

string filename
filename

Return: string or FALSE image type ("png", "gif" or "jpeg")


Captcha_Driver -> image_create

public function image_create

Creates an image resource with the dimensions specified in config. If a background image is supplied, the image dimensions are used.

Parameters:

string background
(NULL) path to the background image file

Throws: Kohana_Exception if no GD2 support

Return: void


Captcha_Driver -> image_gradient

public function image_gradient

Fills the background with a gradient.

Parameters:

resource color1
gd image color identifier for start color
resource color2
gd image color identifier for end color
string direction
(NULL) direction: 'horizontal' or 'vertical', 'random' by default

Return: void


Captcha_Driver -> image_render

public function image_render

Returns the img html element or outputs the image to the browser.

Parameters:

boolean html
html output

Return: mixed html string or void