On our D6 installation we have CAPTCHA 6.x-2.4 plus Captcha Riddler 6.x-1.1 and Image CAPTCH 6.X-2.4 (all from the same package I believe). All three are installed and enabled.

Although we have used this module before with success on other sites, it is not working on this site which is a subdomain on our staging server.

The configuration page (/admin/user/captcha/image_captcha) does not show the CAPTCHA in the preview example. Further the font previews are not shown in that section. The font files are there and should be readable by inspecting the permissions of the individual files and the directories which contain them. (I wonder if the standard D6 .htaccess protection causes a problem here). However, instead of a preview of the font, the text path to the font's .ttf file is shown.

Looking at other tickets related to this, I saw the suggestion that one display the output of settings for the GD library. I have done this and it looks OK:

array (
  'GD Version' => 'bundled (2.0.34 compatible)',
  'FreeType Support' => true,
  'FreeType Linkage' => 'with freetype',
  'T1Lib Support' => false,
  'GIF Read Support' => true,
  'GIF Create Support' => true,
  'JPG Support' => true,
  'PNG Support' => true,
  'WBMP Support' => true,
  'XPM Support' => false,
  'XBM Support' => true,
  'JIS-mapped Japanese Font Support' => false,
)imagejpeg: true
imagecreatetruecolor: true
imagedestroy: true
imagecolorallocate: true
imagefilledrectangle: true
imagecolorat: true
imagesetpixel: true
imageline: true
imagefontwidth: true
imagettfbbox: true
imagestring: true
imagettftext: true

It certainly is not missing any of the features which seem to be required for this function.

Looking at another ticket I saw reference to a user with uid=0. We have such a user but the name and mail fields are empty. Is this an issue?

Switching the contact form's CAPTCHA to math seems to work.

When I try to view the sample image from the admin page, Firefox gives me this message:

The image “.../image_captcha/5414/1310082595” cannot be displayed because it contains errors.

I saved the image and attached it to this ticket in case it helps any.

As near as I can tell, the module (and PHP) can't see the fonts so the CAPTCHA images are not being created. I would appreciate any suggestions of how to resolve this.

James

CommentFileSizeAuthor
#2 1310991057.png6.47 KBscjv
1310082595.jpg5.26 KBkeeline
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

soxofaan’s picture

Category: bug » support

thanks for providing the image, really useful.
The image is indeed corrupt, because of extra bytes before the JPEG header:

357 273 277 377 330 377 340  \0 020   J   F   I   F  \0 001 001

a normal JPEG starts with:

377 330 377 340  \0 020   J   F   I   F  \0 001 001 001 001   ,

These extra bytes are probably caused by another module on your site.

Have you already tried CAPTCHA 6.x-2.x-dev ? In #976436: CAPTCHA image does not appear for anonymous users (again), we added a feature to try to flush these erroneous bytes before generating the image.

scjv’s picture

FileSize
6.47 KB

I have the same problem.
That's my PNG image with additional byte 0x0A before the PNG header.
JPG image also has additional byte 0x0A before standard header.

wundo’s picture

scjv, this is usually caused by an line break at the before < ?php or because you're closing the php tag (i.e. there is a ?>) followed by an \n in one of your files.

scjv’s picture

I have additional [Enter] before <?php in the simplenews_template.module found.
All is now working.

Thank you, wundo!!!

bgprior’s picture

I was having this problem. It seems to have been a clash with the duplicate_role module (at least, it started working again when I disabled the duplicate_role module).

texasgopher’s picture

I'm completely frustrated with this issue. I have tried turning off EVERY installed module to see if one of them is conflicting with CAPTCHA Image. But nothing makes a difference. The fonts are still not displaying on the admin page.

I'm running:
Drupal 6.22
Captcha 6.x-2.4

Any other suggestions? Let me know if I need to provide you any additional information. I also get an error message when I look at the CAPTCHA module settings:

warning: imagettftext(): Could not find/open font in [my root]\sites\all\modules\captcha\image_captcha\image_captcha.admin.inc on line 456.

Thanks.

soxofaan’s picture

Let me know if I need to provide you any additional information

@texasgopher: From your description, I understand that only the font previews on the admin page don't work, is that correct?
Do the captcha images work (partially)? Is there a canvas with background color? noise? With or without rendered characters?
Does the built-in font work (the crappy small size bitmap font)?

texasgopher’s picture

In the section where you select (check) the fonts, the only one that shows up is the built-in crappy small size font. And no matter how large I make it, it is still very small in the image preview section. No other TTF fonts that I have installed either show up in the list (the check box does) or in the preview.

I talked to my ISP today and apparently it may have something to do with their PHP version and true type fonts. Here was their explanation:

"...it's a PHP configuration issue. I can make changes to the main PHP configuration, but the command line switches are handled by the Control Panel. And that ttf option happens to be a command line switch. So unless we can get the Control Panel to change that in their next update I don't think I'll be able to turn it on."

Then he asked me if the CAPTCHA module can be configured to NOT use True Type fonts. I said I didn't think so, but I'd try to find out.

Does that explanation make sense? And can it be configured to not use TTF?

Thanks!

soxofaan’s picture

Hi, (sorry for the delay),

I can't make much from the explanation of your ISP.

But to answer their/your question: yes, the CAPTCHA module can use something else than TTF fonts: the built-in crappy one. Unfortunately, the scale option does not work for it, as you noted. The used size is already the largest one of the built-in fonts.

pvaling’s picture

In my case there was a bug with .module file in one custom module. One developer was using unknown text editor on Windows and broke file encoding (resave it in UTF with BOM encoding).

There was a real problem to find this corrupted file.

To check if you have the same case:
1. Download corrupted image (wget http://10.0.2.XX/image_captcha/3/1328256666)
2. Check first bytes of file (xxd -p 1328256666)

My output:

efbbbf89504e470d0a1a0a0000000d49484452000000b40000003c080200
0000404c07d0000012ff49444154789ccd5d7f5454d5be9f5c6fddd2c575
66a1336fe00a0f4da334342d5896a1d6504ed1757ca05e1e9af910f50992...

If output begins from "efbbbf" it mean that you got problems with UTF encoding in your project (one of files is saved in UTF with BOM mode).

Next step is to find corrupted files and fix them.

3. Execute command (find -type f|while read file;do [ "`head -c3 -- "$file"`" == $'\xef\xbb\xbf' ] && echo "found BOM in: $file";done) in modules folder.

My out:
found BOM in: ./z3950/z3950.module

4. To fix this file run: sudo sed -i '1 s/\xEF\xBB\xBF//' z3950.module

All shell commands are provided for Ubintu Server 10.04.

Good luck!

cancerian7’s picture

Thank you very much Petr Valing.

I upgraded my site from D6 to D7. I was getting this issue with Image Styles. In my case I found Bom in these two following files.

found BOM in: ./sites/default/settings.php
found BOM in: ./sites/default/files/.htaccess

You solved my problem.

Thanks.

wundo’s picture

wundo’s picture

Status: Active » Closed (outdated)