From 743313fa50f1788c79a59051313ef300df80903a Mon Sep 17 00:00:00 2001 From: saxmatt Date: Mon, 10 Jan 2005 23:21:42 +0000 Subject: [PATCH] Whitelist trackbacks and pingbacks from domains in blogroll. git-svn-id: http://svn.automattic.com/wordpress/trunk@2077 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment-functions.php | 17 +++++++++++------ wp-includes/functions-post.php | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/wp-includes/comment-functions.php b/wp-includes/comment-functions.php index a08d500bf1..ace6ecaa7a 100644 --- a/wp-includes/comment-functions.php +++ b/wp-includes/comment-functions.php @@ -713,7 +713,7 @@ function wp_notify_moderator($comment_id) { return true; } -function check_comment($author, $email, $url, $comment, $user_ip, $user_agent) { +function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) { global $wpdb; if (1 == get_settings('comment_moderation')) return false; // If moderation is set to manual @@ -724,11 +724,16 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent) { // Comment whitelisting: if ( 1 == get_settings('comment_whitelist')) { if( $author != '' && $email != '' ) { - $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' "); - if ( 1 == $ok_to_comment && false === strpos( $email, get_settings('moderation_keys')) ) - return true; - } else { - return false; + $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' "); + if ( 1 == $ok_to_comment && false === strpos( $email, get_settings('moderation_keys')) ) + return true; + } + if ( 'trackback' == $comment_type || 'pingback' == $comment_type ) { // check if domain is in blogroll + $uri = parse_url($url); + $domain = $uri['host']; + $in_blogroll = $wpdb->get_var("SELECT link_id FROM $wpdb->links WHERE link_url LIKE ('%$domain%') LIMIT 1"); + if ( $in_blogroll ) + return true; } } diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index 0626f5dee4..e891f13648 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -452,7 +452,7 @@ function wp_new_comment( $commentdata, $spam = false ) { die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') ); } - if ( check_comment($author, $email, $url, $comment, $user_ip, $user_agent) ) + if ( check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) ) $approved = 1; else $approved = 0;