Excellent spam moderation patch from CarLBanks - http://mosquito.wordpress.org/view.php?id=835

git-svn-id: https://develop.svn.wordpress.org/trunk@2258 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg
2005-02-11 01:52:19 +00:00
parent be4d5e36f2
commit d0c7d85ee5
2 changed files with 45 additions and 43 deletions

View File

@@ -568,17 +568,6 @@ function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
}
/* wp_set_comment_status:
part of otaku42's comment moderation hack
changes the status of a comment according to $comment_status.
allowed values:
hold : set comment_approve field to 0
approve: set comment_approve field to 1
delete : remove comment out of database
returns true if change could be applied
returns false on database error or invalid value for $comment_status
*/
function wp_set_comment_status($comment_id, $comment_status) {
global $wpdb;
@@ -589,6 +578,9 @@ function wp_set_comment_status($comment_id, $comment_status) {
case 'approve':
$query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
break;
case 'spam':
$query = "UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID='$comment_id' LIMIT 1";
break;
case 'delete':
$query = "DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1";
break;
@@ -605,30 +597,21 @@ function wp_set_comment_status($comment_id, $comment_status) {
}
/* wp_get_comment_status
part of otaku42's comment moderation hack
gets the current status of a comment
returned values:
"approved" : comment has been approved
"unapproved": comment has not been approved
"deleted ": comment not found in database
a (boolean) false signals an error
*/
function wp_get_comment_status($comment_id) {
global $wpdb;
$result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
if ($result == NULL) {
return "deleted";
} else if ($result == "1") {
return "approved";
} else if ($result == "0") {
return "unapproved";
} else {
return false;
}
global $wpdb;
$result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
if ($result == NULL) {
return 'deleted';
} else if ($result == '1') {
return 'approved';
} else if ($result == '0') {
return 'unapproved';
} else if ($result == 'spam') {
return 'spam';
} else {
return false;
}
}
if ( ! function_exists('wp_notify_postauthor') ) {