CAPTCHA image not displaying depite having GD 2

Hello,

I’ve just installed Yii 1.1.4 on my development environment running OS X 10.6.4, Apache 2.2.14, mod_fastcgi/2.4.2, PHP 5.3.2 (I am not using MAMP, these are the latest default Apache/PHP versions bundled with OS X).

After a lot of issues around permissions and file ownerships which I think I have sorted out, I now have the default demo site up and running.

My problem is that the CAPTCHA image is not displaying. I have GD 2 installed and it works fine on other sites. My PHPInfo file gives:




GD Support 	enabled

GD Version 	bundled (2.0.34 compatible)

GIF Read Support 	enabled

GIF Create Support 	enabled

JPEG Support 	enabled

libJPEG Version 	8b

PNG Support 	enabled

libPNG Version 	1.4.3

WBMP Support 	enabled

XBM Support 	enabled 



Examining the source for the contacts page, I see the HTML is there to place the image, but the image itself is not displayed.




<label for="ContactForm_verifyCode">Verification Code</label>		

<div>

  <img id="yw1" src="/~developer/yiidemo/index.php?r=site/captcha&amp;v=4ca05ac56d4d5" alt="" />

  <input name="ContactForm[verifyCode]" id="ContactForm_verifyCode" type="text" value="" />

</div>



Is there anything that springs to mind?

Edit: corrected a typo

You should examine the action that generates your image. So check all available logs, when you call this URL:

[color=#444444][font=Arial, Helvetica, sans-serif][size=2][color=#008800]/~developer/yiidemo/index.php?r=site/captcha&amp;v=4ca05ac56d4d5[/color][/size][/font][/color]

You are quite right, that should have been the first thing I did (am now slightly embarassed!)

I set up the site as a virtual host to give myself a dedicated log file and here is what that page gives:

A quick search of the Web confirms that the version of the GD library being bundled with OS X 10.6 is lacking some the FreeType functionality.

Looks like OS X users may need to go down the recompiling PHP with Freetype route, or install MAMP.

I’m going with the former. I found a link detailing the steps here:

http://www.gen-x-design.com/archives/recompiling-php-5-3-on-snow-leopard-with-freetype-support/

Wish me luck! (before anyone says it, yes, I’m kicking off a TimeMachine backup first!)

You should also do some research in the forum here. I think this problem was already discussed, maybe there’s another solution…

I did do a quick search and didn’t find anything. I’ll look again though, if it saves me the pain of recompiling.

Incidentally, looking at the Contact Form code, I notice that the way Yii is checking whether or not to use Captcha is by doing:




	public function rules()

	{

		return array(

			// name, email, subject and body are required

			array('name, email, subject, body', 'required'),

			// email has to be a valid email address

			array('email', 'email'),

			// verifyCode needs to be entered correctly

			array('verifyCode', 'captcha', 'allowEmpty'=>!extension_loaded('gd')),

		);

	}



I think it may be better to amend the captcha line to also check for [font=“Courier New”]imagettfbbox()[/font] in the array returned by [font=“Courier New”]get_extension_funcs(‘gd’)[/font]. Is that something that might be worth filing as a change request, do you think?

Thanks for your continued help

You can always file an issue at Yii’s google code page if you found something to improve. Worst that can happen, is that it gets rejected by the devs. But usually you get a note why that happens.

OK, done. And already addressed by the devs and in the current dev build. That was really very quick.