captcha problem

Hi @ all !

Today my browsers would not shows me the captcha image.

When I try to HTTP GET manually the image, i get the following message (using Firefox 3.5.6) :


The image [...] cannot be displayed, because it contains errors

IE says me that the image size is unavailable and it was unable to display it.

My GD extension is activated as everyday and i did not updated any PHP or Apache components.

The line that calls the captcha function is the following (at the view) :


$this->widget('CCaptcha',array('buttonType'=>'button'));

Any suggestion please ?

Did you include the captcha action in the access rules in case you use them?

I included all things needed and it worked well for some time.

I included :


    public function actions()

    {

        return array(

            'captcha' => array(

                'class' => 'CCaptchaAction',

                'backColor' => 0xEBF4FB,

                ),

            );

    }

and :


    public function filters()

    {

        return array('accessControl');

    }


    public function accessRules()

    {

        return array(array('allow', 'actions' => array('list', 'show', 'add', 'update', 'captcha'), 'users' => array('*')));

    }

and :




    public function rules()

    {

        return array(

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

            );

    }

have you find a solution?

nothing currently but i’ll try to do a winmerge compare with my old files soon.

Can you call the captcha action directly? I guess there is an php error somewhere but you can see it because the image/png headers are already sent.

When I call the captcha action directly via HTTP GET "localhost/titles/captcha", Firefox says :


The image [...] cannot be displayed, because it contains errors

IE shows me a blank image.

I did a winmerge comparison with a working model file (like the contact form/model/controller) and i tried many copy/pastes and I did not find anything.

I ll stay you informed of what is making a such different behavior if I find something.

Maybe the same problem with BOM in your files like here?

http://www.yiiframework.com/forum/index.php?/topic/6283-localizing-yii/

Thanks but it is not the same problem because I tried many encodings for the main.php file without success.

Also the captcha located @ /site/captcha (contact page) works.

i think you can set the php.ini like:


display_errors = On

error_reporting = E_ALL | E_STRICT

and you may be know what’s wrong~

Finally I found where the problem was from !

It is because my controller file was UTF-8 encoded.

I switched file encoding to ANSI into the "Notepad++" editor and the problem was solved.

Are you sure you really checked for the BOM in your UTF-8 files? Unicode is known for solving problems, not causing them. :)

Here is what I tried when encoding the controller file:

  • UTF-8 with BOM : doesn’t work

  • UTF-8 without BOM : works well

  • ANSI : works well

I had the same problem, but was caused to some "echoes" in /index.php and prtected/config/main.php which overrided the image type header for the captcha widget.

I removed that echoes in /index.php and/or protected/config/main.php and the captcha was generated ok.