Missing Captcha Image

Permalink 1 user found helpful
I read all of the posts related to this subject, and still can't get captcha images to display.

LAMP system running 5.5.1 with shared concrete folder using Alias and php_value entries in common area of httpd.conf.

One site displays captcha fine. Other does not. So the problem isn't caused by a missing file or package, etc.

Both have the same user and group on all site specific files. Apache can write to folder, contents, and sub-directories of config, files, and packages.

The sites do have different themes, but I even temporarily renamed the local themes, packages, and blocks folders in effort to identify the cause.

I have cleared the cache both from the dashboard and command line.

It fails on new forms as well as existing ones such as register.

Could there be a setting in the database? Looked but didn't see anything.

It doesn't appear that the captcha image is stored or saved anywhere on the site that works.

I know I could probably get re-captcha to work instead, but I'd really like to know why one site works and the other doesn't.

LenKrause
View Replies: View Best Answer
jero replied on at Permalink Reply
jero
I had a similar problem a while back, and as I recall it was the imagettfbbox() function that wasn't defined, and required an additional PHP module to get it working. Bolting a function_exists() call somewhere in your theme template would rule that out.

I found also that concrete/tools/captcha.php had all error reporting turned off. You might want to turn it all on and see if anything squeaks - it might provide some interesting information. In my case it revealed the 500 error and the imagettfbbox problem. Check error logs after doing this if you don't see anything in the browser.
LenKrause replied on at Permalink Reply
LenKrause
Added function_exists check for imagettfbbox and it does exist. I expected that it would since both sites share the same core and one site works.

Enabled error reporting in captcha.php. No message in browser. Apache access_log shows result code 200 for image even though image does not display. Apache error_log has no entry. /etc/php.ini does not have custom error_log entry.
jero replied on at Permalink Reply
jero
Yes, I thought the function would exist, but always worth checking the obvious.

Try adding this code into one of your templates:
[code]
<?php
$captcha = Loader::helper('validation/captcha');
var_dump($captcha);
$captcha->display();
?>
[code]

You should see a captcha image, and something that looks like this:

===================================================================
object(ValidationCaptchaHelper)#233 (1) { ["securimage:private"]=> object(Securimage)#234 (37) { ["image_width"]=> int(175) ["image_height"]=> int(45) ["image_type"]=> int(2) ["code_length"]=> int(4) ["charset"]=> string(29) "ABCDEFGHKLMNPRSTUVWYZ23456789" ["wordlist_file"]=> string(18) "../words/words.txt" ["use_wordlist"]=> bool(true) ["use_gd_font"]=> bool(false) ["gd_font_file"]=> string(22) "gdfonts/bubblebath.gdf" ["gd_font_size"]=> int(20) ["ttf_file"]=> string(80) "/var/www/concrete2/concrete/config/../libraries/3rdparty/securimage/elephant.ttf" ["font_size"]=> int(24) ["text_angle_minimum"]=> int(-20) ["text_angle_maximum"]=> int(20) ["text_x_start"]=> int(8) ["text_minimum_distance"]=> int(30) ["text_maximum_distance"]=> int(33) ["image_bg_color"]=> string(7) "#e3daed" ["text_color"]=> string(7) "#ff0000" ["use_multi_text"]=> bool(true) ["multi_text_color"]=> string(23) "#0a68dd,#f65c47,#8d32fd" ["use_transparent_text"]=> bool(true) ["text_transparency_percentage"]=> int(15) ["draw_lines"]=> bool(true) ["line_color"]=> string(7) "#80BFFF" ["line_distance"]=> int(5) ["line_thickness"]=> int(1) ["draw_angled_lines"]=> bool(false) ["draw_lines_over_text"]=> bool(false) ["arc_linethrough"]=> bool(true) ["arc_line_colors"]=> string(7) "#8080ff" ["audio_path"]=> string(8) "./audio/" ["im"]=> NULL ["bgimg"]=> NULL ["code"]=> NULL ["code_entered"]=> NULL ["correct_code"]=> NULL } }
===================================================================

Have you tried in another browser? I once managed to instruct firefox/adblock to not show certain images and spent a while figuring out what I'd done.

Also, if you haven't done so already, clear the C5 cache and turn off caching.
LenKrause replied on at Permalink Reply
LenKrause
Thanks for your continued assistance.

Adding code provided does display the variable dump in the browser, but the captcha box shows the broken-link image in a bordered box both in Chrome & IE. Firefox does not show the box, nor the image.

Other site that shares same core files displays captcha in all three browsers, so I don't think it is a server or browser issue.

Have disabled and cleared cache again without luck.
jero replied on at Permalink Reply
jero
OK, it's beginning to sound like a URL path issue. On the sites that work, what is the URL of the captcha image? It should be something like

http://www.example.com/index.php/tools/required/captcha?nocache=1329861073


You should be able to type that URL in and it should produce the captcha image.

If you track down the path of the one that's broken, and compare it, maybe it's a bit different and that might explain what's happening.
LenKrause replied on at Permalink Reply
LenKrause
jero replied on at Permalink Reply
jero
Firefox tells me that the failing image "contains errors". I downloaded the URL with wget, and resulting file is considered "data" by Linux, and not a PNG. However, if I edit the file, it appears to be a valid PNG file, but with a single new line at the start, which if I remove it and save can be viewed as a PNG.

Therefore, something somewhere is inserting a new line character into the image output stream. You want to check what's going on in the output() function in concrete/libraries/3rdparty/securimage/secureimage.php. I'd try pushing the output into a file and seeing what that gives you. It's definitely sending an image/png content type so either imagepng() is not behaving, or something has corrupted the image data before it's output as a png.
adz replied on at Permalink Reply
adz
I'm getting this exact same problem, any ideas on how to fix?
thehawkeye replied on at Permalink Reply
This is where the problem is. There is no /required/ under /tools/ in several of our installations. I wish the core team would jump in this thread...
thehawkeye replied on at Permalink Reply
This is where the problem is. There is no /tools/required/ folder in the installation. The form points to this for the captcha.
Phallanx replied on at Permalink Reply
Phallanx
@LenKrause
Can you post a link to a page on the non working site that has the issue? (registration page or one with comments)
LenKrause replied on at Permalink Reply
LenKrause
adz replied on at Permalink Reply
adz
Hi Guys, I'm getting pretty much the same problem!

I have two sites which are pretty much the same, they both show the image on the local test server, and both live websites run on the same VPS. Yet one will show the image, and the other won't.

Any ideas? I'm getting the same issue that it appears that the image output stream is being corrupted before it is saved and loaded, running the secureimage.php file WILL generate a captcha, but doesn't display it on the registration page.
LenKrause replied on at Permalink Reply
LenKrause
In our case, the image that does not display, had a single new-line character at the beginning of the image. If you save the image file to disc and remove the first character of the file, the image header is correct, and the image displays.

I haven't yet figured out how why one site on the server creates the image properly, and the other does not, when they share a common c5 code base, and there have been no customization to the captcha routines.

I thought it might have been a character set issue in the data base as there were some differences, but I have resolved them, yet the problem remains.
LenKrause replied on at Permalink Best Answer Reply
LenKrause
Solved:

Deleted new line at end of file config/site.php so that the file ends with ?>
jero replied on at Permalink Reply
jero
Awesome - probably best not to close the PHP at all (no ?>) which is how the installer leaves the file.

Just tried deliberately adding a new line on one of my sites, and it broke several other things - so useful to know to check this first. Rather surprised I've not fallen for this one before.
Onslow replied on at Permalink Reply
I have this same problem and deleting the empty line in config/site.php didnt work out neither adding ?> to the end. How is this possible to fix?

EDIT: Missing captcha-image has this URL: /index.php/tools/required/captcha?nocache=1367048368. Still, when i go to /tools with FileZilla there isnt even any /required folder?
Onslow replied on at Permalink Reply
I have this same problem and deleting the empty line in config/site.php didnt work out neither adding ?> to the end. How is this possible to fix?
ncheese replied on at Permalink Reply
BTW I got this working by rebuilding Apache and making sure FreeType and GD Libraries were selected for the re-build.
leesalminen replied on at Permalink Reply
@ncheese Worked for me!

Thanks!
Onslow replied on at Permalink Reply
Please, somebody help me with this? :S
shahroq replied on at Permalink Reply
shahroq
jero replied on at Permalink Reply
jero
Rather than adding "?>" to the end, make sure you remove it.

Removing it ensures that any blank lines are treated as code, and not output as html. The first line in the file should be the one and only occurrence of <?php

Also, try adding this to the end of site.php:

if ( ! function_exists('imagettfbbox'))
        die('imagettfbbox does not exist');


If your site complains that the function imagettfbbox doesn't exist, you need to install the PHP modules that define it. This is a job for your website administrator.
Onslow replied on at Permalink Reply
Many thanks from your help shahroq and jero. :)

I checked the coding of site.php and its UTF-8 (not BOM) so that should be fine.

Also i added the code jero offered to my site.php and the result was that i dont have imagettfbbox on my site so this must be the problem, right?
Nornik replied on at Permalink Reply
Has to do with the index.php part of the url. If you right click the broken image and open in new tab, then take out the index.php/ part the image will now show.

So its a pretty url issue.
Nornik replied on at Permalink Reply
Has to do with the index.php part of the url. If you right click the broken image and open in new tab, then take out the index.php/ part the image will now show.

So its a pretty url issue.