Ticket #3175: vroom_vroom.diff

File vroom_vroom.diff, 1.8 kB (added by markjaquith, 2 years ago)

Pushing the "spammers as a motorcycle gang" metaphor a little too far

  • wp-includes/default-filters.php

    old new  
    3838 
    3939add_filter('comment_email', 'antispambot'); 
    4040 
     41add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3); 
     42 
    4143add_filter('comment_url', 'clean_url'); 
    4244 
    4345add_filter('comment_text', 'convert_chars'); 
  • wp-includes/comment.php

    old new  
    187187        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") ) { 
    188188                $time_lastcomment = mysql2date('U', $lasttime); 
    189189                $time_newcomment  = mysql2date('U', $comment_date_gmt); 
    190                 if ( ($time_newcomment - $time_lastcomment) < 15 ) { 
     190                $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); 
     191                if ( $flood_die ) { 
    191192                        do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); 
    192                         wp_die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') ); 
     193                        wp_die( __('You are posting comments too quickly.  Slow down.') ); 
    193194                } 
    194195        } 
    195196 
     
    355356        return $commentdata; 
    356357} 
    357358 
     359function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) { 
     360        if ( $block ) // a plugin has already blocked... we'll let that decision stand 
     361                return $block; 
     362        if ( ($time_newcomment - $time_lastcomment) < 15 ) 
     363                return true; 
     364        return false; 
     365} 
     366 
    358367function wp_new_comment( $commentdata ) { 
    359368        $commentdata = apply_filters('preprocess_comment', $commentdata); 
    360369