Heine

  • home
  • drupal
  • drupal core commits
  • 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

Post new comment

I reserve the right to edit any comment submitted to the site. If your comment contains flaming, advertisements, or simply too many spelling errors (leet speak), it may never appear.
The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <as>, <as3>, <csharp>, <diff>, <drupal5>, <drupal6>, <html>, <js>, <mysql>, <php>, <phpbrief>, <python>, <sql>, <plain>, <xml>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

Recent posts

  • Planet Drupal past and current
  • Help! - Cannot access a global variable.
  • Why is my module's update hook not listed on update.php's selection form?
  • How do I add a class to a link generated with l()
  • ZeroDayScan - Full path disclosure bug in Drupal 6.16 (0day)
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

Captcha CSRF Drupal embed Input Format modx OpenID Performance Planet Drupal rants Security Varnish
more tags
  • home
  • drupal
  • drupal core commits
  • about

Copyright © 2010 by Heine Deelstra. All rights reserved.