The attached patch provides the Captcha module with a two-part interface to other modules.
First, it defines two functions that other modules can call to present a captcha challenge. (For example, I have written an input filter module that encodes email addresses to protect them from spam harvesters; using this interface, it can present a captcha challenge before revealing the email address.) This interface consists of two functions: captcha_form()
, which generates form items for the challenge, and captcha_test()
, which tests the user's response.
Second, it defines a hook interface so that other modules can implement different captcha tests. (At present, the administrator selects which available test to use; in the future, this could be extended to, for example, permit visually impaired users to choose an alternative to the default image recognition challenge.) As an example, I have converted the arithmetic test from an earlier version of captcha.module into a captcha plug-in.
Comment | File | Size | Author |
---|---|---|---|
#2 | captcharith.module | 3.04 KB | kps |
#1 | safemail.module | 4.75 KB | kps |
captcha-api.patch | 8.78 KB | kps | |
Comments
Comment #1
kps CreditAttribution: kps commentedAttached to this comment is an example of a module that uses the captcha interface defined in the above patch. This module encodes email addresses to protect them from spam harvesting. [Note: this example module is a work in progress.]
Comment #2
kps CreditAttribution: kps commentedAttached to this comment is a sample module that uses the hook interface defined in the patch above. This module is a plug-in captcha test that asks a simple arithmetic question; this makes the captcha module usable on systems without the GD image library. (This code is derived from an earlier version of captcha.module.)
Comment #3
arnabdotorg CreditAttribution: arnabdotorg commentedWill be working on this for 4.7 onwards.
Comment #4
arnabdotorg CreditAttribution: arnabdotorg commentedI've added this functionality to the cvs version, pl. test and confirm.
Comment #5
(not verified) CreditAttribution: commented