From f14254c46b93b19c14b67e7842b07fe949be2a44 Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Sun, 21 Mar 2004 08:31:33 +0000 Subject: [PATCH] New comment moderation code, for trackbacks and comments. git-svn-id: https://develop.svn.wordpress.org/trunk@984 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/options-discussion.php | 2 +- wp-comments-post.php | 17 ++++++----------- wp-comments.php | 10 ---------- wp-includes/functions.php | 14 ++++++++++++++ wp-trackback.php | 8 +++----- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php index e3937559d9..acec53b858 100644 --- a/wp-admin/options-discussion.php +++ b/wp-admin/options-discussion.php @@ -113,7 +113,7 @@ if ($user_level <= 3) { User must fill out name and email -

When a comment contains any of these words in its content, name, URI, or email, hold it in the moderation queue: (Seperate multiple words with new lines.)

+

When a comment contains any of these words in its content, name, URI, email, or IP, hold it in the moderation queue: (Seperate multiple words with new lines.) Common spam words.

diff --git a/wp-comments-post.php b/wp-comments-post.php index 5f0b7885b7..502b00c8ec 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -75,24 +75,19 @@ if (!empty($lasttime)) { if ($ok) { // if there was no comment from this IP in the last 10 seconds - $comment_moderation = get_settings('comment_moderation'); $moderation_notify = get_settings('moderation_notify'); $comments_notify = get_settings('comments_notify'); - // o42: this place could be the hook for further comment spam checking - // $approved should be set according the final approval status - // of the new comment - if ('manual' == $comment_moderation) { - $approved = 0; - } else if ('auto' == $comment_moderation) { - $approved = 0; - } else { // none + if(check_comment($author, $email, $url, $comment, $user_ip)) { $approved = 1; + } else { + $approved = 0; } + $wpdb->query("INSERT INTO $tablecomments - (comment_ID, comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) + (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) VALUES - ('0', '$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '$approved') + ('$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '$approved') "); $comment_ID = $wpdb->get_var('SELECT last_insert_id()'); diff --git a/wp-comments.php b/wp-comments.php index 6856d81b5e..dbc30260e8 100644 --- a/wp-comments.php +++ b/wp-comments.php @@ -71,16 +71,6 @@

- -

- Please note: Comment moderation is currently enabled so there may be a delay between when you post your comment and when it shows up. Patience is a virtue; there’s no need to resubmit your comment. -

- -

diff --git a/wp-includes/functions.php b/wp-includes/functions.php index a5561915cd..31c8b22f89 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1564,4 +1564,18 @@ function get_posts($args) { return $posts; } +function check_comment($author, $email, $url, $comment, $user_ip) { + $words = explode("\n", get_settings('moderation_keys') ); + foreach ($words as $word) { + $word = trim($word); + $pattern = "#$word#i"; + if ( preg_match($pattern, $author) ) return false; + if ( preg_match($pattern, $email) ) return false; + if ( preg_match($pattern, $url) ) return false; + if ( preg_match($pattern, $comment) ) return false; + if ( preg_match($pattern, $user_ip) ) return false; + } +return true; +} + ?> \ No newline at end of file diff --git a/wp-trackback.php b/wp-trackback.php index 4aceac262f..6b298227fd 100644 --- a/wp-trackback.php +++ b/wp-trackback.php @@ -66,12 +66,10 @@ if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$tb_u $comment_moderation = get_settings('comment_moderation'); $moderation_notify = get_settings('moderation_notify'); - if ('manual' == $comment_moderation) { - $approved = 0; - } else if ('auto' == $comment_moderation) { - $approved = 0; - } else { // none + if(check_comment($author, $email, $url, $comment, $user_ip)) { $approved = 1; + } else { + $approved = 0; } $result = $wpdb->query("INSERT INTO $tablecomments