Heine

  • home
  • drupal
  • about
Home › Drupal

Math captcha for anonymous users

Heine — Sat, 24/02/2007 - 12:58

This morning I broke down and wrote a simple math captcha module (for Drupal) to use with user registration and anonymous commenting on this site.

Because this site uses caching for anonymous users, the module needs to make sure that whenever a captcha is displayed, the page is not added to the cache.

Caching is handled by includes/common.inc:

function drupal_page_footer() {
  if (variable_get('cache', 0)) {
    page_set_cache();
  }
  module_invoke_all('exit');
}

So whenever a captcha is added to a form (hook_form_alter), we simply set the global cache variable to FALSE.

// Add captcha to the form.
// ...
$GLOBALS['conf']['cache'] = FALSE;

This certainly has drawbacks, but those are mitigated when the comment form is displayed on a seperate page.

To bad that math captcha's are easy to bypass or break by simple trial and error or automated calculation.

The module can be downloaded from my public Subversion repository. See also Adding settings to Captcha.

Average: 4.2 (6 votes)
  • Captcha
  • Drupal
  • Login to post comments

Recent posts

  • In doubt? Read the specs!
  • About the Webform SA
  • Psalmen voor Altblokfluit
  • Unserializing user-supplied data, a bad idea
  • Planet Drupal past and current
more

Security reviews

  • Afraid custom code makes your site vulnerable?
  • You don't really trust that module you just downloaded from Drupal.org?

Sleep better after a security review.

Tags

bladmuziek blood donation blood supply CSRF Drupal Input Format modx MSM Performance Planet Drupal Security Varnish
more tags
  • home
  • drupal
  • about

Copyright © 2011 by Heine Deelstra. All rights reserved.