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:


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() {
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.

One reply on “sfCaptcha fix”

Leave a Reply

Your email address will not be published. Required fields are marked *