Hello,
I want to share something we have been using for some time to generate a captcha image in the user registration form.
We use the ImageMagick library with the TclMagick interface to create an image, based of a background image, and then we write some random text on it, you can see how this working in (https://oacsrocks.org/register/user-new )
ImageMagick comes pre-installed in many linux distributions and TclMagick is usually not hard to get (out from repositories or compiled from source) or even you can get a really simple build from pragana.net http://www.pragana.net/tclmagick-simple-build.tar.gz
First you will need some images for use as backgrounds and place them in some public directory, for example the first time I did this the backgrounds and generated captchas went to /myserverroot/www/captchas
I made a little zip with some background images and the captchas-proc.tcl file, I usually place this file under the acs-subsite/tcl/ directory.
here is the zip:
Then we edited the file at /acs-subsite/lib/user-new.tcl and added this ad_page_contract
ad_page_contract {
register form with captchas
} {
{captcha_id {[captcha::create]} }
}
Then we extended the register form with this new couple of fields, the captcha_id and the captcha_text:
ad_form -extend -name register -form {
{captcha_id:text(hidden) {value $captcha_id } {after_html "<td> </td><td><img src=[captcha::get_filename $captcha_id] ></td>" } }
{captcha_text:text {label "Enter the text above"} }
}
The database table for the captchas is very simple, we use a definition like this:
create table captchas
(
captcha_id integer default nextval('captcha_seq'),
captcha_file varchar(200),
captcha_text varchar(20),
primary key (captcha_id)
);
with a sequence for the captcha_id
CREATE SEQUENCE captcha_seq;
I hope this helps someone, any doubts, comments, corrections and tips for improvement will be greatly appreciated.