Pluggable comment throttling from Mark Jaquith. fixes #3175
git-svn-id: http://svn.automattic.com/wordpress/trunk@4265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f129cef6b9
commit
8a4b655453
|
@ -187,9 +187,10 @@ function wp_allow_comment($commentdata) {
|
||||||
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") ) {
|
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_lastcomment = mysql2date('U', $lasttime);
|
||||||
$time_newcomment = mysql2date('U', $comment_date_gmt);
|
$time_newcomment = mysql2date('U', $comment_date_gmt);
|
||||||
if ( ($time_newcomment - $time_lastcomment) < 15 ) {
|
$flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
|
||||||
|
if ( $flood_die ) {
|
||||||
do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
|
do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
|
||||||
wp_die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') );
|
wp_die( __('You are posting comments too quickly. Slow down.') );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,6 +356,14 @@ function wp_filter_comment($commentdata) {
|
||||||
return $commentdata;
|
return $commentdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) {
|
||||||
|
if ( $block ) // a plugin has already blocked... we'll let that decision stand
|
||||||
|
return $block;
|
||||||
|
if ( ($time_newcomment - $time_lastcomment) < 15 )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function wp_new_comment( $commentdata ) {
|
function wp_new_comment( $commentdata ) {
|
||||||
$commentdata = apply_filters('preprocess_comment', $commentdata);
|
$commentdata = apply_filters('preprocess_comment', $commentdata);
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ add_filter('comment_author', 'wp_specialchars');
|
||||||
|
|
||||||
add_filter('comment_email', 'antispambot');
|
add_filter('comment_email', 'antispambot');
|
||||||
|
|
||||||
|
add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3);
|
||||||
|
|
||||||
add_filter('comment_url', 'clean_url');
|
add_filter('comment_url', 'clean_url');
|
||||||
|
|
||||||
add_filter('comment_text', 'convert_chars');
|
add_filter('comment_text', 'convert_chars');
|
||||||
|
|
Loading…
Reference in New Issue