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

git-svn-id: http://svn.automattic.com/wordpress/trunk@5947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2007-08-27 06:34:18 +00:00
parent c89928a4c8
commit d9793c3e8d
2 changed files with 14 additions and 10 deletions

View File

@ -191,16 +191,7 @@ function wp_allow_comment($commentdata) {
if ( $wpdb->get_var($dupe) )
wp_die( __('Duplicate comment detected; it looks as though you\'ve already said that!') );
// Simple flood-protection
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") ) {
$time_lastcomment = mysql2date('U', $lasttime);
$time_newcomment = mysql2date('U', $comment_date_gmt);
$flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
if ( $flood_die ) {
do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
wp_die( __('You are posting comments too quickly. Slow down.') );
}
}
do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt );
if ( $user_id ) {
$userdata = get_userdata($user_id);
@ -225,6 +216,18 @@ function wp_allow_comment($commentdata) {
return $approved;
}
function check_comment_flood_db( $ip, $email, $date ) {
global $wpdb;
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") ) {
$time_lastcomment = mysql2date('U', $lasttime);
$time_newcomment = mysql2date('U', $date);
$flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
if ( $flood_die ) {
do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
wp_die( __('You are posting comments too quickly. Slow down.') );
}
}
}
function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
global $wpdb;

View File

@ -106,6 +106,7 @@ add_filter('mce_plugins', '_mce_load_rtl_plugin');
add_filter('mce_buttons', '_mce_add_direction_buttons');
add_filter('pre_kses', 'wp_pre_kses_less_than');
add_filter('sanitize_title', 'sanitize_title_with_dashes');
add_action('check_comment_flood', 'check_comment_flood_db', 10, 3);
add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3);
add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
add_filter('comment_email', 'antispambot');