I know this has been reported before, and various solutions have been suggested, including turning off the cache - but this is happening for me on two sites (multi-sites with shared 4.7.6 codebase) which have never used cacheing.

I'm trying to use this on the user registration page, but on both the maths questions and the textimages, there are no right answers - it fails every time, reporting an "incorrect" answer.

Please note this is on the latest 4.7 version - it looks like there have been some big changes in the 5.x module and maybe that works fine, but the 4.7 is definitely broken at the moment. For various reasons I don't want to upgrade to 5.x just yet, but without a working captcha my sites are wide open to spambots.

Comments

Boinng’s picture

I should add - I'm seeing this in Firefox, so it's not an IE7 issue.

mcurry’s picture

I've got a very simple captcha module extension which seems to work well on my sites, even though I've experienced similar problems with captcha math problems failing to validate. You can try this variant and see if things are still broken. Note that you need to change the default word in _ed_captcha_get_required_response() and then enable this module, and set the captcha module options to use this captcha provider. Even thought the same word is used for every visitor, it'll block most if not all bots for a period of time - security through obscurity to be sure, but considering the fact that for some of us, the math captchas seem to have problems, I'll take this option for now at leas.

I know this is 'weak' and incomplete: I am considering adding some features to this module and making it a contributed module under the captcha project, so stay tuned.

Paste the following into a file named 'ed_captcha.module', install it on your site, and enable it - let me know if it gets you past your current issue with the captcha module, or, if you continue to have problems.


  /**
   * $Id: ed_captcha.module 279 2007-05-06 08:37:20Z mcurry $
   */

define('CAPTCHA_FORM_ELEM_NAME', 'captcha_response');

function _ed_captcha_get_required_response() {
  return variable_get('ed_captcha_word', 'your-site-secret-word-here');
}


/*
 * implementation of the captcha challenge & validation
 */
function ed_captcha_captchachallenge(&$form, &$captcha) {
  $captcha = _ed_captcha_get_required_response(); // this sets $_SESSION['captcha'] since that's what is passed in by ref
  $form_elem_name=CAPTCHA_FORM_ELEM_NAME; 
  $form[$form_elem_name] = array (
    '#type' => 'textfield',
    '#title' => t('Please enter "<em>%word</em>" below.', array('%word' => $captcha)),
    '#defaultvalue' => '',
    '#size' => 10,
    '#description' => t('This is used to help us know that you a <strong>real person</strong>, and not just some visiting bot.'),
    '#weight' => variable_get('ed_captcha_weight', -1),
    '#required' => TRUE,
    '#validate' => array('_captcha_validate' => array()),
    '#prefix' => '<div class="ed_captcha-question">',
    '#suffix' => '</div>',
  );

}

function ed_captcha_captchavalidate(&$captcha_response, &$correct) {
  if (isset($_SESSION['captcha'])) {
    $expected = $_SESSION['captcha'];
  } 
  else {
    $correct = FALSE; 
    return; // first time thru, don't need to nag user with an 
  }
  $captcha_response= drupal_strtolower($captcha_response);
  if (($_SESSION['captcha'] != '') && ($captcha_response == $_SESSION['captcha'])) {
    $correct = TRUE;
  }
  else {
    $correct = FALSE;
    form_set_error(CAPCTHA_FORM_ELEM_NAME, t('The <strong>Spam Avoidance</strong> answer you gave is incorrect.  Please enter "<strong>%answer</strong>" in the space provided.', array('%answer' => $_SESSION['captcha'])));
  }
}

Boinng’s picture

Inactivist - thanks very much for your help, I've tried that and it worked fine up to a point (ie, it presented me with the question) - but, unfortunately, still wouldn't accept the correct answer - I just got "The Spam Avoidance answer you gave is incorrect. Please enter "Farmers" in the space provided." (Farmers being my chosen "secret" word).

Since you have it working at your site(s), it must be something peculiar to mine, but I've no idea what that could be!

mcurry’s picture

Hm... thanks for the feedback.

I suppose it could be something fundamentally broken in the captcha module, but I don't really know. Is this problem peculiar to your browser environment or is it happening to all visitors?

Sorry to hear you are having trouble... I've been plagued by odd problems with the captcha module too, which is why I made this variant..

soxofaan’s picture

Status: Active » Closed (fixed)

Closing this issue:
Maintenance and support for the CAPTCHA module for drupal 4.7 are already a long time inexistent. Considering that the Drupal 4.7 branch is now officially unmaintained due to the recent Drupal 6.0 release, it is very unlikely this will change.