Definition:
function check_comment_flood_db( $ip, $email, $date ) {}
Check whether comment flooding is occurring.
Won’t run, if current user can manage options, so to not block administrators.
Parameters
- string $ip: Comment IP.
- string $email: Comment author email address.
- string $date: MySQL time string.
Defined filters
- comment_flood_filter
apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment)
Defined actions
- comment_flood_trigger
do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
Source code
function check_comment_flood_db( $ip, $email, $date ) { global $wpdb; if ( current_user_can( 'manage_options' ) ) return; // don't throttle admins $hour_ago = gmdate( 'Y-m-d H:i:s', time() - 3600 ); if ( $lasttime = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( `comment_author_IP` = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1", $hour_ago, $ip, $email ) ) ) { $time_lastcomment = mysql2date('U', $lasttime, false); $time_newcomment = mysql2date('U', $date, false); $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); if ( $flood_die ) { do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); if ( defined('DOING_AJAX') ) die( __('You are posting comments too quickly. Slow down.') ); wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 403) ); } } }
603
No comments yet... Be the first to leave a reply!