From b8899402d04af5e592c0853c58aaf7ac44ec7737 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 20 Apr 2005 21:56:28 +0000 Subject: [PATCH] Dupe comment check - http://mosquito.wordpress.org/view.php?id=1265 git-svn-id: http://svn.automattic.com/wordpress/trunk@2561 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions-post.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index 6a82a65593..e66f3ba573 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -485,6 +485,13 @@ function wp_new_comment( $commentdata, $spam = false ) { $post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1"); } + // Simple duplicate check + $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$author' "; + if ( $email ) $dupe .= "OR comment_author_email = '$email' "; + $dupe .= ") AND comment_content = '$comment' LIMIT 1"; + if ( $wpdb->get_var($dupe) ) + 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 = '$user_ip' OR comment_author_email = '$email' ORDER BY comment_date DESC LIMIT 1") ) { $time_lastcomment = mysql2date('U', $lasttime);