CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Trouble with Captcha in CiviCRM
Pages: [1]

Author Topic: Trouble with Captcha in CiviCRM  (Read 3684 times)

AlanF

  • Guest
Trouble with Captcha in CiviCRM
July 20, 2008, 07:14:06 pm
I am having trouble getting Captcha to work correctly with CiviCRM. I see "Submit Query" followed by an empty textfield, followed by "Please enter the phrase as displayed in the image", but I don't see the Captcha image. The font path is correct. It points to a TrueType font called Typewrtr.ttf, which I assume is fine. I've also tried to point to arial.ttf, which I found in a Windows directory, but that didn't work either.

By the way, the site is currently running 1.9.12432. I see a message telling me that a newer version of CiviCRM is available: 2.0.5. Not sure whether an upgrade would help.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Trouble with Captcha in CiviCRM
July 20, 2008, 07:34:32 pm

most likely you are missing some image libraries that PHP needs to be compiled with for CAPTCHA (gd, png etc). I'm not sure of the exact things you need compiled into you php5.so, but you should check the PEAR documentation and requirements for Text_CAPTCHA (and Image_Text) at http://pear.php.net. from a quick web search: To run the CAPTCHA classes, your PHP must be compiled --with-freetype-dir (FreeType support), --with-gd, and with gd's png support (compile PHP with libpng).

In 2.1 we've switched to using ReCAPTCHA (http://www.recaptcha.net/) and get around this issue

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

AlanF

  • Guest
Re: Trouble with Captcha in CiviCRM
July 21, 2008, 08:50:13 am
Thanks for your quick reply.

I'm surprised that the Drupal CAPTCHA module would not look for these libraries if they're not standard, and I'm surprised that the Drupal documentation wouldn't say anything about them. Nor do I see them mentioned in the CiviCRM documentation.

AlanF

  • Guest
Re: Trouble with Captcha in CiviCRM
July 21, 2008, 12:08:47 pm
Is it possible to use reCAPTCHA with CiviCRM 1.9.12432? I see that there is a version of the Drupal reCAPTCHA module that works with Drupal 5, which, as you know, works with CiviCRM 1.9. If we could use reCAPTCHA with CiviCRM 1.9, we might be all set.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Trouble with Captcha in CiviCRM
July 21, 2008, 01:09:36 pm

It is possible, but u'll need to do the backporting of the recaptcha code from 2.1 -> 1.9 (which is not trivial, but not too complicated either)

Note that CiviCRM exists outside of drupal also (joomla and standalone modes) so our reliance on other drupal modules is minimal/non-existent

I've seen the "Submit Query" issue before on the pear captcha, so you might want to recheck your file / url permissions etc and see if u can fix that. this might be the quickest short term fix

any specific reason u r using 1.9? note that it is not really supported. 2.0 is a significant improvement and we'd recommend you use that :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

AlanF

  • Guest
Re: Trouble with Captcha in CiviCRM
July 21, 2008, 02:19:32 pm
Could you point me to the recaptcha code in 2.1, and to the files I would need to change in 2.0 or 1.9?

Would there be risks in upgrading from 1.9 to 2.0? What would be the best way to mitigate those risks?

Thanks.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Trouble with Captcha in CiviCRM
July 21, 2008, 02:25:56 pm

the issues and commits related to it are here:

http://issues.civicrm.org/jira/browse/CRM-3104?page=com.atlassian.jira.ext.fisheye:fisheye-issuepanel

I assume u r pretty good with PHP / CiviCRM coding structure  to do the backport.

We've had quite a few sites do the upgrade, so at this point, i think the process is quite good and documented on the wiki

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

AlanF

  • Guest
Re: Trouble with Captcha in CiviCRM
July 21, 2008, 02:42:43 pm
With respect to permissions:

I originally was seeing a nastier error. Then I looked at the path to the file mentioned in the error message and created a directory there (which didn't exist before that). After that, I stopped seeing an error message, but I didn't see the image, even though the captcha image file was written to the directory. The directory, by the way, is the one mentioned in Global Settings as "Images". I tried making that directory writable to groups and the public. (Previously, it had only been writable to the owner.) But that didn't make the problem go away. The image files that are being produced are writable only by the owner but readable by everyone. I was able to download the image files and download them to my machine, where I could look at them. They seem like ordinary captcha image files. Anything I'm missing here?

AlanF

  • Guest
Re: Trouble with Captcha in CiviCRM
July 22, 2008, 08:50:43 am
Yesterday, I was able to get closer to getting captcha to work in Drupal + CiviCRM, but I'm still seeing a problem. I changed the global settings for the Temporary Files, Images, Custom Files, and Image Upload URL so they'd all end in "files/civicrm". This enabled me to see the captcha image, which I hadn't seen before. However, the image that was displayed was always the same, even after I closed the browser. Meanwhile, the actual captcha phrase kept changing, so I'd always be told there was a mismatch. When I downloaded the file that was in files/civicrm and looked at it on my machine, it had new text. But for some reason, the web page displayed to the user always shows the same (old) captcha image.

I'm able to write debug messages now. Any place where you think I should insert one? Is all the captcha processing being done in the one captcha.php file?

Thanks again for your help.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Trouble with Captcha in CiviCRM
July 22, 2008, 11:34:06 am

you might want to check your web server cache rules. most likely the browser is using an old cached image and does not referesh on every page load from the server

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

AlanF

  • Guest
Re: Trouble with Captcha in CiviCRM
July 23, 2008, 10:22:41 am
Unfortunately, I couldn't figure out how to do that. I looked at php.ini, index.php, and other files and didn't see a way to control it. Another option would be to hack the Drupal code, but that's frowned upon (and I'm not sure yet how I'd do it anyway -- maybe using jQuery/JavaScript?). I've asked around a bit as to how to do this, but haven't gotten an answer yet. Could you give me any clues?

Thanks,
Alan

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Trouble with Captcha in CiviCRM
July 23, 2008, 03:41:33 pm

This is part of your web server config. I dont know anything about your hosting situation so cant be of too much help :(

if using apache, check: http://httpd.apache.org/docs/2.0/mod/mod_expires.html

alternatively, you might want to hack CRM/Utils/CAPTCHA.php and generate a new file name for every request. that will bypass the web server caching issue

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

AlanF

  • Guest
Re: Trouble with Captcha in CiviCRM
July 28, 2008, 02:34:05 pm
Good suggestion! I hacked the code to append a random string (generated via rand()) to the filename (which is generated via a hash of the session ID), and now I get a new image each time.

I'll see what people have to say about this at Drupal.org. But it's good to know that the code works with the hack.

ymmatt

  • I’m new here
  • *
  • Posts: 29
  • Karma: 0
Re: Trouble with Captcha in CiviCRM
November 25, 2008, 05:25:26 pm
For future reference I had the same issue regarding drupal-captcha-civicrm. What it turned out to be for me was the fact that the url my.domain/files was not re-written to my.domain/sites/my.domain/files which is where my files (and captcha images) were. This resulted in the image file not being found when the profile pages were loaded.

The resolution for me was to add a rewrite rule for the /drupal/files folder in my /etc/httpd/conf/httpd.conf file
<Directory /path_to_drupal/drupal/files>
   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ /sites/%{HTTP_HOST}/files/$1 [L]
</Directory>

The same type of rule could be added to your .htaccess file in the /drupal/files folder if you use those instead.

I'm not sure if this is a drupal issue, or CiviCrm but it directly affects the use of Captcha with CiviCRM on multi-site installations.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Trouble with Captcha in CiviCRM

This forum was archived on 2017-11-26.