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 | ||
---|---|---|
function __construct()
|
The BDC_CaptchaBase object constructor takes the Captcha identifier (a string) as parameter, and automatically initializes the instance identifier. |
|
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). | |
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. | |
GetCode
|
Generates a random Captcha code for the given CodeUsePurpose , using settings stored in instance data belonging to the specified InstanceId |
|
GetImage
|
Generates a Captcha image, using settings stored in instance data belonging to the specified InstanceId |
|
GetSound
|
Generates a Captcha sound, using settings stored in instance data belonging to the specified InstanceId |
|
Validate
|
Compares the user input to the Captcha code stored for the given InstanceId , using validation rules specified for the current ValidationAttemptOrigin |
|
Save | Goes through the current BDC_CaptchaBase object instance and saves changes to the Captcha persistence medium (PHP Session by default) |
|
Load | Updates the current BDC_CaptchaBase object instance to match data stored in the Captcha persistence medium (PHP Session by default) |
|
property __get/__set CodeLength | Length (number of characters) of the Captcha code rendered; the default value is 5. | |
property __get/__set CodeStyle | Numeric representation of the Captcha |
|
property __get/__set ImageStyle | Numeric representation of the Captcha |
|
property __get/__set ImageWidth | Width of the generate Captcha image, in pixels; the default Captcha image width is 250 px. | |
property __get/__set ImageHeight | Height of the generate Captcha image, in pixels; the default Captcha image height is 50 px. | |
property __get/__set ImageFormat | Numeric representation of the |
|
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" ) |
|
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" ) |
|
property __get/__set SoundStyle | Captcha sound style - can be a fixed or a randomized value selected from the 10 BotDetect sound generation algorithms. |
|
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 | ||
---|---|---|
GetRandomCodeLength
|
Returns a random Captcha code length, using the specified minimal and maximal values | |
GetRandomCodeStyle
|
Returns a random Captcha code style. Selects from all available styles if no parameter is specified, or from the given value set if specified | |
GetRandomImageStyle
|
Returns a random Captcha image style. Selects from all available styles if no parameter is specified, or from the given value set if specified | |
GetRandomSoundStyle
|
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 | ||
---|---|---|
GetSettings
|
Returns the current global Captcha settings object | |
SaveSettings
|
Updates the global Captcha settings object with the given instance |
Current BotDetect Versions
-
BotDetect ASP.NET CAPTCHA
2019-07-22v4.4.2 -
BotDetect Java CAPTCHA
2019-07-22v4.0.Beta3.7 -
BotDetect PHP CAPTCHA
2019-07-22v4.2.5