From 8a79d5712a1ce1ff123fd92797b06a3c412f0995 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Thu, 25 Mar 2004 10:11:58 +0000 Subject: [PATCH] If more than X links in a comment, moderate that sucker. git-svn-id: http://svn.automattic.com/wordpress/trunk@1011 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/options-discussion.php | 14 +++++++++----- wp-admin/upgrade-functions.php | 5 +++++ wp-includes/functions.php | 5 +++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php index acf8222702..f60ad87e6e 100644 --- a/wp-admin/options-discussion.php +++ b/wp-admin/options-discussion.php @@ -68,8 +68,8 @@ if ($user_level <= 3) {

Discussion Options

- -

Usual settings for an article: (These settings may be overidden for individual articles.)

+ +

Usual settings for an article: (These settings may be overidden for individual articles.)

-

Email me whenever:

+

Email me whenever:

-

Before a comment appears:

+

Before a comment appears:

-

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.

+

Comment Moderation:

+

Hold a comment in the queue if it contains more than + + links. (A common characteristic of comment spam is a large number of hyperlinks.)

+

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-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 1cf2b49824..5a7a71c529 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -794,6 +794,11 @@ function upgrade_110() { $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('active_plugins', 3, '', 8)"); } + // Option for max # of links per comment + if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'comment_max_links'")) { + $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('comment_max_links', 3, '5', 8)"); + } + } ?> \ No newline at end of file diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 0b2587dc88..2e6bd3a408 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1577,6 +1577,11 @@ function check_comment($author, $email, $url, $comment, $user_ip) { if ( preg_match($pattern, $comment) ) return false; if ( preg_match($pattern, $user_ip) ) return false; } + + preg_match_all('|([\n ])([a-z]+?)://([^, <>{}\n\r]+)|i', $comment, $all_links); + $number = count($all_links[0]); + if ($number >= get_settings('comment_max_links')) return false; + return true; }