Plugin Directory

Changeset 707942


Ignore:
Timestamp:
05/04/2013 04:52:25 PM (13 years ago)
Author:
filiw
Message:

version 20130504

Location:
anti-captcha/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anti-captcha/trunk/anti-captcha.php

    r705485 r707942  
    44Plugin URI: http://blog.fili.nl/wordpress-anti-captcha-plugin/
    55Description: Anti-Captcha is a transparent captcha solution which does not require any end-user interaction
    6 Version: 20130429
     6Version: 20130504
    77Author: Filidor Wiese
    88Author URI: http://www.fili.nl/
     
    3838function anti_captcha_process_comment($incoming_comment)
    3939{
    40     if (is_user_logged_in()) return $incoming_comment;
    41    
    42     if (!anti_captcha_verify_token($_POST['anti-captcha-token'])) {
    43         add_filter('pre_comment_approved', create_function('$a', 'return \'spam\';'));
     40    // Default to spam
     41    $commentStatus = 'spam';
     42
     43    // Approve comment if user is logged in or provides a valid anti-capcha-token
     44    if (is_user_logged_in() || anti_captcha_verify_token($_POST['anti-captcha-token'])) {
     45        $commentStatus = '1';
     46
     47        // If a mailaddress is provided, check it for format and MX-records
     48        if (strlen($incoming_comment['comment_author_email'])) {
     49
     50            // If this test fails, hold comment for moderation
     51            if (!anti_captcha_validate_email($incoming_comment['comment_author_email'])) {
     52                $commentStatus = '0';
     53            }
     54        }
    4455    }
    4556   
     57    add_filter('pre_comment_approved', create_function('$a', "return '" . $commentStatus . "';"));
     58
    4659    return $incoming_comment;
    4760}
     
    7285    }
    7386}
     87
     88function anti_captcha_validate_email($email)
     89{
     90    if (!strstr($email,'@')) { return false; }
     91    $email = strtolower($email);
     92   
     93    list($local, $domain) = explode('@', $email);
     94    if (count(dns_get_record($domain, DNS_MX)) < 1) {
     95        return false;
     96    }
     97   
     98    $match_local = preg_match('#^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$#', $local);
     99    $match_domain = preg_match('#^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$#', $domain);
     100   
     101    return ($match_local && $match_domain ? true : false);
     102}
  • anti-captcha/trunk/readme.txt

    r705485 r707942  
    55Requires at least: 2.8.4
    66Tested up to: 3.5.1
    7 Stable tag: 20130429
     7Stable tag: 20130504
    88
    99Anti-Captcha is a transparent captcha solution which does not require any end-user interaction
     
    5454== Changelog ==
    5555
     56= 20130504 =
     57* Fixed a bug in which legitimate comments where always flagged for moderation
     58* Added a check on the format of the supplied mailaddress and it's MX-records (on fail, a comment will be held for moderation instead of being approved)
     59
    5660= 20130429 =
    5761* Updated anti-captcha to version 0.3 which introduces a new DOMReady loading method
Note: See TracChangeset for help on using the changeset viewer.