BotDetect PHP CAPTCHA Core API Reference

While the BotDetect Web API members are used for Captcha functionality within a PHP web form context (dealing with markup generation and related tasks), the core BotDetect API contains members related to general Captcha functionality, independent of the context it's used for.

BDC_CaptchaBase

A base Captcha object, representing a generic Captcha instance capable of generating Captcha codes, images and sounds + validating user inputs. The Captcha instances tailored for PHP form use all delegate core Captcha functionality to a contained BDC_CaptchaBase instance.

BDC_CaptchaBase Class Reference
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public function function __construct()
  • $p_CaptchaId
The BDC_CaptchaBase object constructor takes the Captcha identifier (a string) as parameter, and automatically initializes the instance identifier.
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get CaptchaId Unique identifier of the Captcha object within the application (for example, if you placed one Captcha object on the Registration page and another on the Contact Us page, they would have distinct CaptchaId values).
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get InstanceId Globally unique identifier of the current Captcha object instance, used to ensure each page load keeps separate Captcha codes, for example when opening the same form in multiple browser tabs.
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public function GetCode
  • $p_InstanceId
  • $p_Purpose
Generates a random Captcha code for the given CodeUsePurpose, using settings stored in instance data belonging to the specified InstanceId
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public function GetImage
  • $p_InstanceId
Generates a Captcha image, using settings stored in instance data belonging to the specified InstanceId
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public function GetSound
  • $p_InstanceId
Generates a Captcha sound, using settings stored in instance data belonging to the specified InstanceId
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public function Validate
  • $p_UserInput
  • $p_InstanceId
  • $p_Origin
Compares the user input to the Captcha code stored for the given InstanceId, using validation rules specified for the current ValidationAttemptOrigin
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public function Save Goes through the current BDC_CaptchaBase object instance and saves changes to the Captcha persistence medium (PHP Session by default)
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public function Load Updates the current BDC_CaptchaBase object instance to match data stored in the Captcha persistence medium (PHP Session by default)
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get/__set CodeLength Length (number of characters) of the Captcha code rendered; the default value is 5.
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get/__set CodeStyle

Numeric representation of the Captcha CodeStyle, i.e. the algorithm used to generate Captcha codes from default pre-defined locale character sets; the default value is 0.

BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get/__set ImageStyle

Numeric representation of the Captcha ImageStyle, i.e. the algorithm used to render Captcha codes in images; the default image style is 0.

BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get/__set ImageWidth Width of the generate Captcha image, in pixels; the default Captcha image width is 250 px.
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get/__set ImageHeight Height of the generate Captcha image, in pixels; the default Captcha image height is 50 px.
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get/__set ImageFormat

Numeric representation of the ImageFormat in which the Captcha image will be generated; the default format is 0.

BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get/__set CustomDarkColor Optional custom dark color point; modifies the color palette used for Captcha image drawing. Should be a Html color, i.e. specified either by name ("Red") or hex value ("#f00" or "#ff0000")
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get/__set CustomLightColor Optional custom light color point; modifies the color palette used for Captcha image drawing. Should be a Html color, i.e. specified either by name ("Red") or hex value ("#f00" or "#ff0000")
BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get/__set SoundStyle

Captcha sound style - can be a fixed or a randomized value selected from the 10 BotDetect sound generation algorithms.

BotDetect PHP Captcha Library Reference: BDC_CaptchaBase Class public property property __get/__set SoundFormat

Captcha sound output format (WavPcm16bit8KhzMono or WavPcm8bit8KhzMono).

CaptchaRandomization class

CaptchaRandomization is a helper class used for easy randomization of Captcha parameters in configuration files and PHP form code.

CaptchaRandomization Class Reference
BotDetect PHP Captcha Library Reference: CaptchaRandomization Class public function GetRandomCodeLength
  • $p_Min = 0
  • $p_Max = 0
Returns a random Captcha code length, using the specified minimal and maximal values
BotDetect PHP Captcha Library Reference: CaptchaRandomization Class public function GetRandomCodeStyle
  • $p_UsedValues = null
Returns a random Captcha code style. Selects from all available styles if no parameter is specified, or from the given value set if specified
BotDetect PHP Captcha Library Reference: CaptchaRandomization Class public function GetRandomImageStyle
  • $p_UsedValues = null
Returns a random Captcha image style. Selects from all available styles if no parameter is specified, or from the given value set if specified
BotDetect PHP Captcha Library Reference: CaptchaRandomization Class public function GetRandomSoundStyle
  • $p_UsedValues = null
Returns a random Captcha sound style. Selects from all available styles if no parameter is specified, or from the given value set if specified

CaptchaConfiguration class

The CaptchaConfiguration class is a simple helper that can be used to access the global Captcha configuration object.

CaptchaConfiguration Class Reference
BotDetect PHP Captcha Library Reference: CaptchaConfiguration Class public function GetSettings
  • $p_CaptchaId = null
Returns the current global Captcha settings object
BotDetect PHP Captcha Library Reference: CaptchaConfiguration Class public function SaveSettings
  • $p_Settings
Updates the global Captcha settings object with the given instance