Oct 22
Digg
Stumbleupon
Technorati
Delicious

sfCaptcha fix

I’ve got an email regard to sfCaptcha plugin. I think this can be interesting to everyone who uses this plugin so I decided to publish it here. I’m going also to fix code the way described here but until then this is good advise for everyone who uses my captch solution and sometimes got a problem with captcha code appereance:

Hello,

We are using your sfCaptcha plugin and noticed the following:

In the 1.02 version of the sfCaptcha plugin in Captcha.class.php the
seed starts with 0 (zero):

public function generate() {
$this->iData = ”;
$alphabet = sfConfig::get(‘app_captcha_alphabet’, ‘0123456789’);

Nevertheless in jpgraph 2.2 in jpgraph_antispam.php, there is a
validation that returns false if the char is 0 or o:

function Stroke() {
$n=strlen($this->iData);
if( $n==0 ) {
return false;
}
for($i=0; $i < $n; ++$i ) { if( $this->iData[$i]===’0′ || strtolower($this->iData[$i])===’o’) {
return false;
}
}

This of course, causes random blank images in our application. Our
suggestion fix is to start the default seed from 1 like so:

$alphabet = sfConfig::get(‘app_captcha_alphabet’, ‘123456789’);

It’s working perfectly for us this way.


Author: symfonian

1 Comment(s)

miefony
September 18, 2008

hi,

it’s great but i encounter problem with Internet Explorer 6 & 7, the captcha doesnt want to reset after correct and incorrect value..

any idea.?

Thanks

Comments RSS TrackBack Identifier URI

Leave a comment