Wednesday, January 5, 2011

CakePHP Captcha component with Securimage

I had made some changes so the component could work with cakePhp 1.3,
or at least it works in my application. The original article is
here, download the latest and the code i have modified.
Make sure you have:

1. Copied the component file into your app/controllers/components.
2. Copied the view file into your app/views/element/
3. To use "captcha_code" field form input.

You could "diff" to see what changes i had made in the code,
specially the component file. Hope it helps.

Happy baking.

5 comments:

Anonymous said...

thank you for this

webmaster said...

Hello. Thanks a lot for the rewrite. I was looking exactly for this after several failed attempts at modifying the code on the Bakery.

One slight problem though. It keeps telling me in my view that "Notice (8): Undefined variable: captcha_data [APP\views\elements\securimage.ctp, line 1]"

I'm using Cake 1.3.8. The securimage.ctp is an element with a single line of code: and from my view, I'm calling it as: echo $this->element('securimage');

Funny thing is that when I access the captcha url directly, i.e. /controller/securimage/0, the image gets displayed properly.

I've got Debug_Kit installed and even that shows that no variable named $captcha_data has been set.

Any ideas why this is happening and how do I go about fixing this?

Phil said...

While the securimage package looks pretty it has known security vulnerabilities.

http://www.idontplaydarts.com/2011/05/exploit-phpcaptcha-securimage/

adesst said...

@phil, Wow! thanks so much for the update.

adesst said...

@webmaster, are you the one who invited me at bitbucket?

I'd pulled the code, and yes looks
like that your code has errors.
Had fixed them, will push soon.