Make the entire comment flood check pluggable as it can cause load problems on large sites.
git-svn-id: https://develop.svn.wordpress.org/trunk@5947 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f1fde3ac2e
commit
7d95821088
@ -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;
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user