views:

84

answers:

2

Hi,

i have strange problem when using Zend_Captcha_Image. Sometimes it generate empty captcha, only with lines and dots, but with no text :(

EDIT: It happens for every 4-10 pageview/image refresh.

Look here for registration form here

This only happens on one server. At another with same OS it is without any problem.

Anybody with same problem ?

Thanks

A: 

Compare output of phpinfo(); and compare all extensions and settings there.

Btw I can see image there: https://forum.esfcr.cz/registration.htm

Update: Any relevant info in error log? Do you log errors?

dwich
It happens for every 4-10 view.
Michal Drozd
@Michal Odd, if it's only happening every now and again. Perhaps you have a corrupt font file? If some of the font definitions are corrupt, maybe it's only breaking when certain characters appear in the CAPTCHA...
Matt Gibson
Thanks for answers, i found bug in Zend code (below).
Michal Drozd
A: 

I just found bug in PHP5 GD or in Zend, or in php-gd compiled for debian lenny8

Here is code in Zend/Captcha/Image.php

$textbox = imageftbbox($fsize, 0, $font, $word);
$x = ($w - ($textbox[2] - $textbox[0])) / 2;
$y = ($h - ($textbox[7] - $textbox[1])) / 2;
imagefttext($img, $fsize, 0, $x, $y, $text_color, $font, $word);

When image is blank there is call something like:

imagefttext(Resource, 30, 0, 1073741903.5, 45.5, 0, "/fonts/arial.ttf", "z9h8")

And this is bad, becouse X has crazy value 1073741903.5. This is out of image, so no text is written. So what I need to do is, fix Zend code, and check and fix X and Y value before calling function.

I hope that will help others with this strange bug.

Michal Drozd