| 1 | Index: wp-includes/functions-post.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/functions-post.php (revision 2551) |
|---|
| 4 | +++ wp-includes/functions-post.php (working copy) |
|---|
| 5 | @@ -480,24 +480,33 @@ |
|---|
| 6 | $now = current_time('mysql'); |
|---|
| 7 | $now_gmt = current_time('mysql', 1); |
|---|
| 8 | |
|---|
| 9 | - // Simple flood-protection |
|---|
| 10 | - if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$user_ip' OR comment_author_email = '$email' ORDER BY comment_date DESC LIMIT 1") ) { |
|---|
| 11 | - $time_lastcomment = mysql2date('U', $lasttime); |
|---|
| 12 | - $time_newcomment = mysql2date('U', $now_gmt); |
|---|
| 13 | - if ( ($time_newcomment - $time_lastcomment) < 15 ) { |
|---|
| 14 | - do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); |
|---|
| 15 | - die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') ); |
|---|
| 16 | + // If user is admin or the post author, never moderate or throttle |
|---|
| 17 | + if ( $user_id ) { |
|---|
| 18 | + $userdata = get_userdata($user_id); |
|---|
| 19 | + $post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1"); |
|---|
| 20 | + } |
|---|
| 21 | + if ( $userdata && ($user_id == $post_author || $userdata['user_level'] >= 9) ) { |
|---|
| 22 | + $approved = 1; |
|---|
| 23 | + } else { |
|---|
| 24 | + // Simple flood-protection |
|---|
| 25 | + if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$user_ip' OR comment_author_email = '$email' ORDER BY comment_date DESC LIMIT 1") ) { |
|---|
| 26 | + $time_lastcomment = mysql2date('U', $lasttime); |
|---|
| 27 | + $time_newcomment = mysql2date('U', $now_gmt); |
|---|
| 28 | + if ( ($time_newcomment - $time_lastcomment) < 15 ) { |
|---|
| 29 | + do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); |
|---|
| 30 | + die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') ); |
|---|
| 31 | + } |
|---|
| 32 | } |
|---|
| 33 | - } |
|---|
| 34 | |
|---|
| 35 | - if ( check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) ) |
|---|
| 36 | - $approved = 1; |
|---|
| 37 | - else |
|---|
| 38 | - $approved = 0; |
|---|
| 39 | - if ( wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) ) |
|---|
| 40 | - $approved = 'spam'; |
|---|
| 41 | + if ( check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) ) |
|---|
| 42 | + $approved = 1; |
|---|
| 43 | + else |
|---|
| 44 | + $approved = 0; |
|---|
| 45 | + if ( wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) ) |
|---|
| 46 | + $approved = 'spam'; |
|---|
| 47 | |
|---|
| 48 | - $approved = apply_filters('pre_comment_approved', $approved); |
|---|
| 49 | + $approved = apply_filters('pre_comment_approved', $approved); |
|---|
| 50 | + } |
|---|
| 51 | |
|---|
| 52 | $result = $wpdb->query("INSERT INTO $wpdb->comments |
|---|
| 53 | (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, user_id) |
|---|