I installed CAPTCHA module.
The image CAPTCHA works fine on my localhost...
When i upload the same module to the server, Instead of the CAPTCHA image it's displaying "image CAPTCHA" which is the alternative text in the img tag...
Text CAPTCHA and Math CAPTCHA are working well..
Having this pending for a long time.
Pls help..
thank u

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ainigma32’s picture

Project: Drupal core » CAPTCHA
Version: 6.8 » 6.x-2.x-dev
Component: other » Image Captcha (image_captcha)
Assigned: Sandymaguire » Unassigned

Reassigning to the proper queue (guessing the version)

- Arie

soxofaan’s picture

Version: 6.x-2.x-dev » 6.x-1.0-rc2
Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

I guess that the version is 6.x-1.0-rc2 (not 6.x-2.x)

it works on your localhost setup, but it doesn't work on your hosting server: what are the differences between the two?

Sandymaguire’s picture

i installed captcha module on the site on localhost, captcha image displays..
When i did the same on the site hosted online.The captcha image is not displaying.Instead displays text "image CAPTCHA"

soxofaan’s picture

#3 does not add extra information compared to the original post. Please provide more information, otherwise I can't help.

Provide version numbers (PHP, Drupal, CAPTCHA module, etc), other installed modules, hosting setup information, on which kind of forms do you enable CAPTCHAs, etc ...

Sandymaguire’s picture

Hi
PHP5
Drupal 6.9
Captcha module CAPTCHA 6.x-1.0-rc2

Other installed modules are..
abuse
CCK
Contact Forms
ddblock
email
feedapi
feedapi_mapper
flickr
image
jquery_update
link
profile_category_weight
terms_of_use
Views
webform

I have enabled image captcha in user_register ie the registration form.

soxofaan’s picture

what happens if you request the image URL directly (right click on the
alt text and choose something like "open image" or "view image",
depending on your browser)?

what browser are you using (firefox, opera, safari, internet explorer)?

oneiropolos’s picture

have you tried running cron and checking if the image shows afterwards?

Sandymaguire’s picture

Hi
#6 when i right click and do view image a black scree opens up... the url is like

http://www.example.com/myproject/image_captcha/624106399

actually the module renders the

the image doesnt come instead the alternative text is coming..

#7
yes i did cron still the same prob persists..

ty

stanb’s picture

I'm having exactly the same issue with Captcha (6.x-1.0-rc2) on Drupal 6.9. I just upgraded to Drupal 6.9 from 6.8. Image CAPTCHA was working fine on Drupal 6.8. My contact form Image CAPTCHA image and the Image CAPTCHA examples produce the same behavior, i.e., the image is replaced with the allternate text "Image CAPTCHA". Also ran cron manually which had no effect on this Image CAPTCHA behavior.

stanb’s picture

ok...should have tried this first but it seems one always overlooks the obvious. I re-uploaded my font for Image CAPTCHA to /sites/all/modules/captcha/image_captcha/fonts and everything is working fine....doh!

Sandymaguire’s picture

Hi can stanb be more specific about the contents of /sites/all/modules/captcha/image_captcha/fonts .
I have nothing but a readme.txt file and it says install ttf files.
I tried putting some fonts like Grantham Bold.ttf
Still the same prob persists...
Pls help.

Sandymaguire’s picture

For ppl who get the alt text displayed instead of the captcha image.

This may sound as a rubbish solution.... But for not it worked great for me.

replace

$result['form']['captcha_image'] = array(
'#type' => 'markup',
'#value' => 'Only local images are allowed.',
'#weight' => -2,
);

on line 139 on image_captcha.module with the following

$result['form']['captcha_image'] = array(
'#type' => 'markup',
'#value' => '

Only local images are allowed.

',
'#weight' => -2,
);

1.U are setting the alternative text alt= "'.t('image CAPTCHA') with alt="'. t($code).
2.Strike through the text.
3.Also display a background image behind the code.

miruoss’s picture

@Sandymaguire: After putting the ttf file into the font directory, you should select it in the image captcha settings. Otherwise the font won't be used.

francois22’s picture

I have exactly the same issue, since 6.9 Captcha's images are broken.

After several investigations, it appears that drupal, since 6.9 (and still in 6.10) adds 3 headers lines to any page, including the jpeg image of Captcha, so corruping the jpeq response content ...

A work-arround, is to empty the response buffer in the hook_init of mymodule (or any module you could change), as follow:

<<
function mymodule_init() {

// CAPTCHA FIX: empty output buffer for captcha image generation.
if (substr($_GET['q'],0,14) == 'image_captcha/') ob_clean();
}
>>

May i suggest to include a call to ob_clean() in the function image_captcha_image($seed=NULL) ?

On the drupal side, who knows which mymodule's code could be call before mymodule_init() ?

soxofaan’s picture

at #14: I can't reproduce your findings on my Drupal 6.10 setup, so I don't think those three header lines are from Drupal core.
I assume the problem lies in one of the contrib modules you installed.
can you check this?

francois22’s picture

Ooups ! I finaly find : some of include files of my module have the ?> tag plus an empty line at the end. That's the way empty lines came into the page before the call to mymodule_init() ! The empty line was copied to the output ...

I saw that Drupal's code have not end tag at all and that many people accept it as a good practice ... That's just a problem if you use a XMLEditor.

soxofaan’s picture

I saw that Drupal's code have not end tag at all and that many people accept it as a good practice

Indeed. For those interested: in PHP the closing ?> is optional and not using it is recommended/best practice in Drupal code.

(Edit: better wording of what I wanted to say)

drasgardian’s picture

I ran into this same problem using Drupal 6.10 and image captcha 6.x-2.0-beta3. After reading this page I went back and checked my custom modules, sure enough I'd left a closing ?> followed by blank lines at the bottom of one of my (unrelated) modules and after removing that the image captcha image came back.

jannalexx’s picture

true,
solved here also, maybe more than one empty line at the end could lead to this, even if closing ?> does not exist

gram.steve’s picture

I spend a fair amount of time chasing this bug in one of my sites. My problem was originally not getting the image captcha, then when I switched to math captcha for testing I was getting a captcha token invalid message.

I had deleted user 0 during a cleanup of users from extensive testing for code that automatically creates new users. I deleted all but admin (user 1). Restoring user 0 solved my problem. The weird thing is that all non auth users were getting sessions, but never seemed to get captcha data in those sessions.

Found the answer in another thread related to the invalid token, but wanted to pass it on. This solved my problem without any code modifications.

Drupal 6.12
Captcha 6.x-1.0-rc2

All browsers.

Alex72RM’s picture

Hi everyone,

I have same problem (it works great into a WAMP framework, but it doesn't run into a Linux environment), without inconsistency in user table.

So, are there other causes for non-working image captcha?

Drupal 6.13
6.x-2.0-rc2

soxofaan’s picture

So, are there other causes for non-working image captcha?

this thread discusses several other causes too: see #6, #14-#17

Alex72RM’s picture

@#6:
with IE (clicking on broken image link --> view link/open page http:///image_captcha/82/1247476990): the web page cannot be rendered.
with Firefox (clicking on alt text --> view link/open page): blank page.

@#14 & @#17:
I have no custom module. How (and where) should I apply that solutions? How can you be confident that different php code (closing tag and/or a patch) can solve this issue in a Linux environment, whereas in a WAMP env. all is working great?

soxofaan’s picture

@Alex72RM: what do you get when you download the image url with "wget" under linux/osx?
Or if you are not familiar with wget and the site is publicly accessible: send me the link through my contact form

soxofaan’s picture

@Alex72RM: I got your message and tried the link, but the request for the image returns nothing

$ wget http://example.com/image_captcha/89/12474
--12:11:10--  http://example.com/image_captcha/89/12474
           => `12474'
Resolving [snip]
Connecting to [snip] ... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

so it's not the problem of #14-#17

Another possible reason is that your linux PHP setup has no support for the imagejpeg function. Did you build the site on one setup (with imagejpeg support) and then moved it to that linux setup (possibly without imagejpeg support)? For more info see #205525: Images cannot be generated, because your PHP installation's GD library has no JPEG support. you can also get more information about your setup at example.com/admin/logs/status/php (there should be something like "--with-gd", GD is the PHP image handling library)

Alex72RM’s picture

Hi again,

phpinfo() tell me that gd is all ok.

Freetype support: enabled
Freetype linkage: with freetype
JPG Support: enabled

cakka’s picture

Getting same problem ....

soxofaan’s picture

Please provide more info than "getting the same problem". If that's all you give me, I can't help you.

e.g.:
which version of drupal, captcha module?
what's your webserver setup (linux? php version?)
does the image work on the image CAPTCHA admin page? does it work for authenticated users?
are there related error messages in the drupal log, webserver log or php log?
do you have a uid=0 in your users table? (which is common source for problems in CAPTCHA 5.x-3.x and 6.x-1.x, see http://drupal.org/project/issues/search/captcha?issue_tags=captchauid0)

Alex72RM’s picture

Hi again,

I hope my response could be useful.

which version of drupal, captcha module?
6.13, 6.x-2.0-rc2

what's your webserver setup (linux? php version?)
Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7| DAV/2 PHP/5.2.6 Phusion_Passenger/2.0.5

does the image work on the image CAPTCHA admin page? does it work for authenticated users?
It doesn't work at all, for authenticated users (from examples pages into captcha admin section, the behavior is the same) nor anonymous ones.

are there related error messages in the drupal log, webserver log or php log?
No errors in drupal log (it's written that image_captcha.js has been processed). I cannot investigate further into webserver/php log...

do you have a uid=0 in your users table? (which is common source for problems in CAPTCHA 5.x-3.x and 6.x-1.x, see http://drupal.org/project/issues/search/captcha?issue_tags=captchauid0)
Yes, uid 0 is there.

adzio’s picture

Subscribing

vijayitsoft’s picture

I have Two sites running with almost same modules installed but image captcha is working fine with one (image is displaying) but not with other.

What might be the reason ,I am not having any possible reason to explain my client (no version compatibility excuses) because it is running with one perfectly.

Plz help, very urgent !!!!!!!!!!

soxofaan’s picture

at vijayitsoft: does CAPTCHA 6.x-2.x work? does the simple math challenge work on both sites?
your problem is probably cookies: are the cookie domains correct for both sites?

jannalexx’s picture

it can be fuzzy but now works, latest actions:

clear all caches
http://pshahmumbai.wordpress.com/2009/08/09/clear-drupal-caches/

make and run from root a php file using this code

<?php
  include_once './includes/bootstrap.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  drupal_flush_all_caches();

install latest captcha-6.x-2.0-rc3 but remove the additional space at the end of captcha.inc file
try that in other modules too if you still cannot get the images...
if this is the issue, someone could write a global core patch or a module to check those (*.module, *.inc) files for spaces and prevent this bug in general...

timurek’s picture

Version: 6.x-1.0-rc2 » 6.x-2.0-rc3

I am experiencing the same problem and none of solutions above worked for me.

I have uid=0 in users table, I switched page compression off, flushed cache, and still no progress.

Math captcha works, but there is no captcha image for anonymous users. Strange thing, on administration page I have a perfectly looking image captcha example.

Please, let me know which informations are needed to solve this problem?

Thanks a lot

soxofaan’s picture

at jennalexx in #33: why do you suggest to remove additional space at the end of captcha.inc and other files? What would this be good for? One thing that can break image captcha is a closing ?> delimiter followed by whitespace at the end of a module or include file. But captcha.inc does not have a closing ?> delimiter, as most drupal module and include files, so there is no problem here.

at timurek in #34: when you say math captcha works, does this just mean that it shows a challenge, or does it mean that it also correctly blocks wrong answers and accepts right answers? Other interesting info: look at the markup code and report how an captcha image url looks like, try to load a captcha image url directly and report what you get (nothing, error message, an unreadable file, ...) also try different browsers for this.

timurek’s picture

#35: Match CAPTCHA shows challenge, but also blocks when wrong answer is entered. I use it as well as other types of captchas from captcha pack :)
Image captcha: As anonymous user, when I try to access image captcha file directly, i got nothing:
http://www.vypocetni.technika.cz/image_captcha/%252F1252081547
But (working) image in administration module has another type of URL:
http://www.vypocetni.technika.cz/image_captcha/784/1252081520
Is it not strange? Especially the %252F part?

Issue appears in any browser I tried - IE, Opera, Firefox.

Thanks for taking care of it.

soxofaan’s picture

At #36: see #431672: Image does not show in image_captcha when using random_captcha_type, the problem is in CAPTCHA pack, you should update to a version after 19 august, like 6.x-1.x-dev or 6.x-1.0-beta3

timurek’s picture

Works, thanks a lot!

zbricoleur’s picture

I was having a very similar problem. I had the latest official release of CAPTCHA installed (6.x-2.0) in sites/all/modules of a multi-site installation. And Image CAPTCHA was working fine on every site but one. I tried every solution above, with no luck. So I downloaded the 6.x-2.0-dev version, thinking it was worth a try. I opened up the install file just to see if it was going to require a database update, and that prompted me to check the schema version for CAPTCHA in the systems table of the recalcitrant site. Ah hah. Turns out that, while I had the latest official release installed on that site, I hadn't run the updates on that site (as I had on all the others). I ran the updates, and bingo, it worked.

I did end up installing the dev version of the module as a result of the update (I had put it in sites/recalcitrant.site/modules/captcha_2, but apparently Drupal looks at the info file not the folder name). However, I am pretty sure that it was the database update and not the new code that fixed it, since that had been the ONLY difference between this site and the other sites that were functioning properly.

benkyma’s picture

I had exactly this issue. Image Captcha worked perfectly under MAMP localhost but broke on my production server. I fixed it by installing the GD image library and restarting the server. Instructions here:
http://www.cyberciti.biz/faq/ubuntu-linux-install-or-add-php-gd-support-...

doimuagio’s picture

I have godaddy account and had this problem as well.
- Server: linux, php 5.2.8
- Drupal: 6.16
- Captcha : 2.1 (latest)
- Freetype support: enabled
- Freetype linkage: with freetype
- Image didn't work on admin page, no preview images for available fonts, examples also didn't work
- Math captcha works (block wrong answers, accept correct answers)
- No other contributed modules installed
- No errors in log file

JThan’s picture

Have the same problem. On one site with the hoster it works, same hoster other account it does not work. Cannot find any differences between the accounts.

mimohodom’s picture

Version: 6.x-2.0-rc3 » 6.x-2.x-dev
Assigned: Unassigned » mimohodom
Status: Postponed (maintainer needs more info) » Active

Hi,

I've got the same problem and I am dead stuck. The math_captcha works nice, but once I switch to images there is nothing but alt text.
I could not even manage images on admin page, and there was no preview for available fonts, examples as mentioned in #41

Software configuration is as follows:

Server: Windows 2003
Web server: WAMP 2.0 (Apache 2.2.11, php 5.3.0, mysql 5.1.36)
Drupal: 6.16
Captcha : tried 2.x-dev, 2.1, 2.0-rc3
Browsers: Chrome, FF 3.6.8, IE6, IE8

I played a little bit with the module and made it to display (embedded) images - data-uri, base64 - by ($captcha_sid - 1).
Unfortunately, this functionality is not supported in IE6 (pardon me) which is a must for me ...

There is one thing to notice about this obviously wrong idea. I had to update captcha_sessions table with the $code value so to say "by hand" to implement it. And image renewal didn't follow a page refresh. But this ($captcha_sid - 1) emerged from the fact that I was constantly getting a captcha image `UNDEFINED' -- which was a rendering of the db_query result with $captcha_sid as a parameter.

soxofaan’s picture

at mimohodom in #43: have you already tried/checked for the stuff discussed in #6, #14-#17, #25 ?

Also, if it's on a public site, providing a link to it can help debugging the problem (if you don't want to disclose it publicly here in this thread, use my contact form)

soxofaan’s picture

Hi mimohodom,
I received your message with the link.

The CAPTCHA images do not show up because they are corrupt.
There are an extra 12 bytes before the PNG data for some reason.

E.g. This is a dump of the first bytes of your corrupted CAPTCHA image:

0000000 357 273 277 357 273 277 357 273 277 357 273 277 211   P   N   G
0000020  \r  \n 032  \n  \0  \0  \0  \r   I   H   D   R  \0  \0  \0 330
0000040  \0  \0  \0   H  \b 002  \0  \0  \0 033   $ 254 371  \0  \0  \0

A normal PNG looks like this

0000000 211   P   N   G  \r  \n 032  \n  \0  \0  \0  \r   I   H   D   R
0000020  \0  \0  \0 200  \0  \0  \0   F  \b 006  \0  \0  \0 004 217 234
0000040   b  \0  \0  \0 004   g   A   M   A  \0  \0 257 310   7 005 212

The usual cause of this is discussed in #14-#17 and #271883: no CAPTCHA image because of corrupted images: when a modules on your site uses a closing ?>-tag with trailing whitespace, you get this whitespace before the stuff Drupal outputs, the image data in this case.
However, the strange thing is that the prefixing bytes in your case (357 273 277 357 273 277 357 273 277 357 273 277 or in hexidecimal: bbef efbf bfbb bbef efbf bfbb) do not seem related to whitespace.
Also note that you have these bytes at the start of your html pages too (careful: the "view source" tool of your browser may hide these, so use some sort of more advanced editor or hexdump tool to see this).

Anyway: the problem is not in the CAPTCHA module,
maybe some other module on your site generates these erroneous bytes or there is a problem with your setup. You could try disabling some modules and see what happens for example.

mimohodom’s picture

Status: Active » Fixed

Hi saxofaan,

thanks (again) for your support. The problem turned out to be with my own modules: all the .info, .module and .inc files were encoded in UTF-8. Converting them to ANSI solved the issue.

Hope, this note will save somebody's time.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sdjewani’s picture

i am using d6, on my site some time captcha image become invisible. although i didn't worked on this module. as i am working on numbers of custom module. so if there is any mistake in code i do. the captcha image become invisible. so it is difficult to find issue.
can any one tell how this can be resolved.
i am also wonder why this is effected by working on other custom module.

olecarme’s picture

Version: 6.x-2.x-dev » 7.x-1.0
Issue summary: View changes
Status: Closed (fixed) » Active

I'm encountering a problem which was discussed there some time ago, with Drupal 6. But now it occurs with Drupal 7.

I have two Drupal 7 websites. The first one, http://sunsethill.ubud/ is almost finished and used math captcha. The second one, http://thewoolenbarn.com/ is only a skeleton with empty pages. I used math captcha on the first website, and begun using image captcha on the second one. Since it seems to be much safer than math captcha, I changed to image captcha on the first website. But the image does not appear: I see a pseudo-image when using Chrome, and the contents of the alt=field when using Firefox.

I read the full discussion here, and made several attempts. For example, I uninstalled the captcha module and then installed it again. At the moment, image captcha is used only on the register page http://sunsethill-ubud.com/user/register

The src= field of the img tag mentions the directory image_captcha which does exist on the website. When comparing the html code of the two sites, I cannot see any significant difference. The two websites use very similar modules, including Commerce, but the website where image captcha does not work also uses the Rooms module.

ScratchyCat’s picture

Hi,

I have the same issue with D7 and Captcha module 7.x-1.0.

When I developed site on my local computer image captcha worked perfectly, but since I have uploaded site on webserver I noticed that captcha images are not displayed. Now I'm triing to check all reasons listed above.

samjosein’s picture

Make sure you all have the enabled both 'CAPTCHA' and 'Image CAPTCHA' modules to work with '#captcha_type' => 'image_captcha/Image',

Don't forget to use:
'#captcha_type' => 'image_captcha/Image',

and not:
'#captcha_type' => 'image_captcha/image',

[see the capital 'I' in Image]

eurotyke’s picture

Installed the latest development version 7.x-1.3-dev and this solved the problem.

JulesM’s picture

Hi. I installed the Captcha module and enabled it along with the image component intending it for use with the contact form. After logging out from admin to test it, I am now completely locked out of the site because, on the login page, there is no image displayed. I am a novice user of Drupal and have searched for a fix but can't find anything which doesn't involve logging in as admin (which I can't do). Can you help, please?

Addendum: I am using the latest v7 of Drupal and the latest version of the module. I ran the cron before logging out and everything was green. I have tried the login page on all my browsers, which are also up to date, without any filters activated. I'm really up a gum-tree, here. :-(

Resolution: I have been able to login to my site after deleting the respective module folders through the webhost control panel but that didn't shed any light on the original problem. There's nothing like brute force and ignorance when you are on your own and desperate, eh?

fchandler’s picture

Had a similar issue with D7.39, and CAPTCHA7.x-1.3 on a fresh install. But I was not getting an image on the configuration page, let alone on the forms. Worked fine on my local environment. Used a script to install Drupal on the live server through my hosting service. It did not automatically turn on clean URLs. After turning on clean URLs, the Images appear. Not sure how those are related, but fixed the lack of an image. For what it is worth.

Live Server:
Web server Apache/2
PHP 5.3.29
Database system MySQL, MariaDB, or equivalent
Database system version 5.5.44-0ubuntu0.12.04.1-log

Dev Server:
Web server Apache/2.4.7 (Ubuntu)
PHP 5.5.9-1ubuntu4.11
Database system MySQL, MariaDB, or equivalent
Database system version 5.5.44-0ubuntu0.14.04.1

ChrisValentine’s picture

I concur with fchandler above - having Clean URLs off stops the images appearing (at least with D 7.39).

Chris.

mikhailkrainiuk’s picture

Assigned: mimohodom » Unassigned
Status: Active » Needs review
FileSize
676 bytes

Hello!
I have some problem: on my local server Apache image works fine. But on by other server Nginx image doesn't work.
Reason of this bug is double check_plain in function image_captcha_captcha():
$img_src = check_url(url("image_captcha", $options));
Tag image builds like
"<img src="/image_captcha?sid=7&amp;ts=1450935487" ..." ("&amp;" instead "&").

This bug is fixed on 7.x-dev version. For 7.x-1.3 this bug is actual yet.
You can drop "check_url" near "$img_src" from 247 string. Or use attached patch.

Status: Needs review » Needs work

The last submitted patch, 56: captcha-image_check_url-383346-56.patch, failed testing.

ExPdx’s picture

I discovered that one of my Drupal 7 sites with Image Captcha installed (and previously working) had indeed quit working when I updated from 7.x-1.2 to 7.x-1.3.

I traced the problem down to the changes in the image_captcha_captcha function. The changes to take care of the TODO in version 7.x-1.2 regarding "using a theming funtion" seem to now require that CLEAN URLs are enabled (as fchandler pointed out).

In my case, I found I could bypass this simply by using the image.captcha.module from 7.x-1.2 (at least for now).

The README.txt with the tar.gz says:
Dependencies:
The basic CAPTCHA module has no dependencies, nothing special is required.

IMHO, it would be good to at least mention that CLEAN URLs need to be enabled for image captcha to work.

Short of sorting out exactly why CLEAN URLs needs to be enable for the new code to work, perhaps a check for CLEAN URLs in the image.captcha.module and then use the old code or the new code depending on the result might be a short term workaround.

Thanks to fchandler and ChrisValentine for your observations. It was helpful to me.

nandansahoo’s picture

today i am try to create a backlink with my site cintain url
http://sdub.org/rapidgator-premium-link-generator/ but bi am did not sucess . please help me

DevElCuy’s picture

Patch at #56 works fixes the issue with nginx.

STILL, make sure you have php-gd (GD extension) installed, there is no alternative AFAIK.

Chris Matthews’s picture

Version: 7.x-1.0 » 7.x-1.x-dev

Version change only

golubovicm’s picture

In my case, I had image captcha working just fine on staging, but I was getting WhiteScreenOfDeath with code 200 on live. No error logged, all libs were there. At end it was some DNS security stuff, only some specific paths were allowed and other stripped somehow. So if you run out of ideas check with server admin if there's some restriction on his side.

Captain_Canuck’s picture

If running CAPTCHA module and Image CAPTCHA with any module such as https://www.drupal.org/project/require_login

The image for the captcha will be replaced by alt text.

I am trying to determine which paths need to be added to the exclude list within the require_login module to fix this.

So far I have tried:

/image-captcha-generate
/image-captcha-refresh

With no luck.

I will let you know what I find.