Plugin Directory

Changeset 2392339


Ignore:
Timestamp:
10/02/2020 12:54:45 PM (6 years ago)
Author:
CompleteWebResources
Message:

Add new version 1.2 (spam status and GF)

Location:
exact-match-disallowed-comment-contact-forms/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • exact-match-disallowed-comment-contact-forms/trunk/blocklist-manager.php

    r2384723 r2392339  
    66Author: Complete SEO
    77Author URI: https://www.completewebresources.com/
    8 Version: 1.1
     8Version: 1.2
    99*/
    1010
     
    6161    // CF7 handler
    6262    add_filter( 'wpcf7_submission_is_blacklisted', array( $this, 'cf7_blocklist_check'), 10, 2 );
     63       
     64    // Gravity Forms handler
     65    add_filter( 'gform_entry_is_spam', array( $this, 'gf_blocklist_check' ), 10, 3 );
    6366  }
    6467 
     
    178181        || preg_match( $pattern, $commentdata['comment_author_IP'] )
    179182      ) {
    180         return 0;
     183        return 'spam';
    181184      }
    182185    }
     
    188191    $commentdata['comment_content'] = FrmEntriesHelper::entry_array_to_string( $values );
    189192    $commentdata['comment_author_IP'] = FrmAppHelper::get_ip_address();
    190     $commentdata['comment_author_url'] = '-';
    191     if ( ! $this->default_blocklist_check( false, $commentdata  ) ) {
     193    $commentdata['comment_author_url'] = '';
     194    if ( $this->default_blocklist_check( false, $commentdata  ) == 'spam' ) {
    192195      $errors['spam'] = __( 'Your entry appears to be blocked spam!', 'formidable' );
    193       $this->save_spam_entry( 'Formidable Forms', $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_author_url'] );
     196      $this->save_spam_entry( 'Formidable Forms', $commentdata['comment_content'], $commentdata['comment_author_IP'], '-' );
    194197    }
    195198    return $errors;
     
    198201  // CF7 check
    199202  public function cf7_blocklist_check( $approved, $obj ) {
    200     $target = $obj->get_posted_data();
    201     $ip = $obj->get_meta( 'remote_ip' );
    202     $target = implode( "\n", $target );
    203    
    204     $mod_keys = self::get_disallowed_words();
    205     if ( '' == $mod_keys ) {
    206       return false; // If moderation keys are empty.
    207     }
    208  
    209     // Ensure HTML tags are not being used to bypass the blocklist.
    210     $target_without_html = wp_strip_all_tags( $target );
    211  
    212     $words = explode( "\n", $mod_keys );
    213  
    214     foreach ( (array) $words as $word ) {
    215       $word = trim( $word );
    216    
    217       // Skip empty lines.
    218       if ( empty( $word ) ) {
    219         continue; }
    220    
    221       // Do some escaping magic so that '#' chars
    222       // in the spam words don't break things:
    223       $word = preg_quote( $word, '~' );
    224    
    225       $pattern = "~\b$word\b~i";
    226       if ( preg_match( $pattern, $target )
    227         || preg_match( $pattern, $target_without_html )
    228         || preg_match( $pattern, $ip )
    229       ) {
    230         $this->save_spam_entry( 'Contact Form 7', $target, $ip, '-' );
    231         return true;
     203    $content = $obj->get_posted_data();
     204    $content = implode( "\n", $content );
     205    $commentdata['comment_content'] = $content;
     206    $commentdata['comment_author_IP'] = $obj->get_meta( 'remote_ip' );
     207    $commentdata['comment_author_url'] = '';
     208    if ( $this->default_blocklist_check( false, $commentdata  ) == 'spam' ) {
     209      $this->save_spam_entry( 'Contact Form 7', $commentdata['comment_content'], $commentdata['comment_author_IP'], '-' );
     210      return true;
     211    }
     212    return false;
     213  }
     214   
     215    // Gravity Forms check
     216  public function gf_blocklist_check( $is_spam, $form, $entry ) {
     217    $content = '';
     218    foreach ( $entry as $k => $v ) {
     219      if ( preg_match('/[1-9]+/', $k ) ) {
     220        $content .= "\n" . $v;
    232221      }
    233222    }
    234     return false;
     223    $commentdata['comment_content'] = $content;
     224    $commentdata['comment_author_IP'] = empty( $entry['ip'] ) ? GFFormsModel::get_ip() : $entry['ip'];
     225    $commentdata['comment_author_url'] = '';
     226    if ( $this->default_blocklist_check( false, $commentdata  ) == 'spam' ) {
     227      $this->save_spam_entry( 'Gravity Forms', $commentdata['comment_content'], $commentdata['comment_author_IP'], '-' );
     228      $is_spam = true;
     229    }
     230    return $is_spam;
    235231  }
    236232 
  • exact-match-disallowed-comment-contact-forms/trunk/readme.txt

    r2384723 r2392339  
    22
    33Plugin URI:        https://www.completewebresources.com/exact-match-disallowed-comment-contact-forms-wordpress-plugin/
    4 Tags:              anti spam, formidable, contact form 7, blacklist, blocklist, comment spam, contact form spam
     4Tags:              anti spam, formidable, contact form 7, gravity forms, blacklist, blocklist, comment spam, contact form spam
    55Author URI:        https://www.completewebresources.com/exact-match-disallowed-comment-contact-forms-wordpress-plugin/
    66Author:            Complete SEO
     
    88Requires PHP:      7.0
    99Tested up to:      5.5.1
    10 Stable tag:        1.1
    11 Version:           1.1
     10Stable tag:        1.2
     11Version:           1.2
    1212License:           GPLv3
    1313License URI:       https://www.gnu.org/licenses/gpl-3.0.html
     
    2121If you try to use the WordPress comment blocklist for contact form entries, this can be hugely problematic. The first major issue is falsely identifying comments as spam so you risk blocking valid contact form entries.
    2222
    23 Additionally, there's no moderation queue built into Formidable or Contact Form 7 for entries marked as spam. This plugin fixes those issues.
     23Additionally, there’s no moderation queue built into Formidable Forms, Contact Form 7, or Gravity Forms for entries marked as spam. This plugin fixes those issues.
    2424
    2525= Changing the default WordPress comment blocklist functionality =
     
    3333= Important Notes / FAQ =
    3434
    35 - For default comments in a post after submitting, if blocklisted, the comment will go to Pending status, awaiting moderation whereas the default functionality would be to send that comment to the trash.
    36 - We're currently configured to work with Contact Form 7 and Formidable.
     35- For default comments in a post after submitting, if blocklisted, the comment will go to Spam status, whereas the default functionality would be to send that comment to the trash.
     36- We’re currently configured to work with Contact Form 7, Formidable Forms and Gravity Forms.
    3737- Add keywords you want to block to the WordPress admin area under **Settings > Discussion > Disallowed Comment Keys**
    3838- Upon activation, the plugin will automatically populate three keywords by default in the "Disallowed Comment Keys" field in the WP Admin area. This is so you know things are working. We leave it to the user to control their specific blocklist keywords. If you want a list of we'll known spam words as a starting point, check your preferred search engine for "ultimate comment blocklist" or "WordPress comment blocklist."
     
    5858== Changelog ==
    5959
     60= 1.2 =
     61
     62* Now comments that include blocklist keywords become "Spam" instead of "Pending"
     63* Gravity Forms is integrated
     64
    6065= 1.1 =
    6166
Note: See TracChangeset for help on using the changeset viewer.