[wp-cvs] wordpress/wp-includes comment-functions.php, 1.12, 1.13 functions-post.php, 1.25, 1.26

Matthew Mullenweg saxmatt at users.sourceforge.net
Mon Jan 10 20:21:09 GMT 2005


Update of /cvsroot/cafelog/wordpress/wp-includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12293/wp-includes

Modified Files:
	comment-functions.php functions-post.php 
Log Message:
Spam tastes great, we should eat more of it. Add 'spam' approval value, and basic blacklist.

Index: comment-functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/comment-functions.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** comment-functions.php	7 Jan 2005 22:01:58 -0000	1.12
--- comment-functions.php	10 Jan 2005 20:21:05 -0000	1.13
***************
*** 725,729 ****
  	if ( 1 == get_settings('comment_whitelist')) {
  		if( $author != '' && $email != '' ) {
! 		    $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author_email = '$email' and comment_approved = '1' ");
  		    if ( 1 == $ok_to_comment && false === strpos( $email, get_settings('moderation_keys')) )
  			return true;
--- 725,729 ----
  	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;
***************
*** 733,746 ****
  	}
  
- 	// Useless numeric encoding is a pretty good spam indicator:
- 	// Extract entities:
- 	if (preg_match_all('/&#(\d+);/',$comment,$chars)) {
- 		foreach ($chars[1] as $char) {
- 			// If it's an encoded char in the normal ASCII set, reject
- 			if ($char < 128)
- 				return false;
- 		}
- 	}
- 
  	$mod_keys = trim( get_settings('moderation_keys') );
  	if ('' == $mod_keys )
--- 733,736 ----

Index: functions-post.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/functions-post.php,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** functions-post.php	7 Jan 2005 01:21:12 -0000	1.25
--- functions-post.php	10 Jan 2005 20:21:06 -0000	1.26
***************
*** 382,387 ****
  }
  
  
! function wp_new_comment( $commentdata ) {
  	global $wpdb;
  
--- 382,424 ----
  }
  
+ function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
+ 	global $wpdb;
  
! 	if ( preg_match_all('/&#(\d+);/', $comment, $chars) ) {
! 		foreach ($chars[1] as $char) {
! 			// If it's an encoded char in the normal ASCII set, reject
! 			if ($char < 128)
! 				return true;
! 		}
! 	}
! 
! 	$mod_keys = trim( get_settings('blacklist_keys') );
! 	if ('' == $mod_keys )
! 		return false; // If moderation keys are empty
! 	$words = explode("\n", $mod_keys );
! 
! 	foreach ($words as $word) {
! 		$word = trim($word);
! 
! 		// Skip empty lines
! 		if ( empty($word) ) { continue; }
! 
! 		// Do some escaping magic so that '#' chars in the 
! 		// spam words don't break things:
! 		$word = preg_quote($word, '#');
! 		
! 		$pattern = "#$word#i"; 
! 		if ( preg_match($pattern, $author    ) ) return true;
! 		if ( preg_match($pattern, $email     ) ) return true;
! 		if ( preg_match($pattern, $url       ) ) return true;
! 		if ( preg_match($pattern, $comment   ) ) return true;
! 		if ( preg_match($pattern, $user_ip   ) ) return true;
! 		if ( preg_match($pattern, $user_agent) ) return true;
! 	}
! 
! 	return false;
! }
! 
! function wp_new_comment( $commentdata, $spam = false ) {
  	global $wpdb;
  
***************
*** 413,420 ****
  	}
  
! 	if( check_comment($author, $email, $url, $comment, $user_ip, $user_agent) )
  		$approved = 1;
  	else
  		$approved = 0;
  
  	$result = $wpdb->query("INSERT INTO $wpdb->comments 
--- 450,459 ----
  	}
  
! 	if ( check_comment($author, $email, $url, $comment, $user_ip, $user_agent) )
  		$approved = 1;
  	else
  		$approved = 0;
+ 	if ( wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) )
+ 		$approved = 'spam';
  
  	$result = $wpdb->query("INSERT INTO $wpdb->comments 
***************
*** 427,435 ****
  	do_action('comment_post', $comment_id);
  
! 	if ( !$approved )
! 		wp_notify_moderator($comment_id);
! 
! 	if ( get_settings('comments_notify') && $approved )
! 		wp_notify_postauthor($comment_id, 'comment');
  
  	return $result;
--- 466,476 ----
  	do_action('comment_post', $comment_id);
  
! 	if ( 'spam' != $approved ) { // If it's spam save it silently for later crunching
! 		if ( !$approved )
! 			wp_notify_moderator($comment_id);
! 	
! 		if ( get_settings('comments_notify') && $approved )
! 			wp_notify_postauthor($comment_id, 'comment');
! 	}
  
  	return $result;



More information about the cvs mailing list