WordPress.org

Make WordPress Core

Changeset 5947


Ignore:
Timestamp:
08/27/2007 06:34:18 AM (12 years ago)
Author:
matt
Message:

Make the entire comment flood check pluggable as it can cause load problems on large sites.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r5885 r5947  
    192192        wp_die( __('Duplicate comment detected; it looks as though you\'ve already said that!') );
    193193
    194     // Simple flood-protection
    195     if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$comment_author_IP' OR comment_author_email = '$comment_author_email' ORDER BY comment_date DESC LIMIT 1") ) {
    196         $time_lastcomment = mysql2date('U', $lasttime);
    197         $time_newcomment  = mysql2date('U', $comment_date_gmt);
    198         $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
    199         if ( $flood_die ) {
    200             do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
    201             wp_die( __('You are posting comments too quickly.  Slow down.') );
    202         }
    203     }
     194    do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt );
    204195
    205196    if ( $user_id ) {
     
    226217}
    227218
     219function check_comment_flood_db( $ip, $email, $date ) {
     220    global $wpdb;
     221    if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$ip' OR comment_author_email = '$email' ORDER BY comment_date DESC LIMIT 1") ) {
     222        $time_lastcomment = mysql2date('U', $lasttime);
     223        $time_newcomment  = mysql2date('U', $date);
     224        $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
     225        if ( $flood_die ) {
     226            do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
     227            wp_die( __('You are posting comments too quickly.  Slow down.') );
     228        }
     229    }
     230}
    228231
    229232function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
  • trunk/wp-includes/default-filters.php

    r5937 r5947  
    107107add_filter('pre_kses', 'wp_pre_kses_less_than');
    108108add_filter('sanitize_title', 'sanitize_title_with_dashes');
     109add_action('check_comment_flood', 'check_comment_flood_db', 10, 3);
    109110add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3);
    110111add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
Note: See TracChangeset for help on using the changeset viewer.