[wp-hackers] Spam comments on the old posts
Peio Popov
peio at peio.org
Thu Sep 23 19:21:46 UTC 2004
Hi Guys,
from what I've seen the comment spammers usually spam on old posts and
the legitimate comments are mostly on the recent posts.
So I've written a small hack to flag for approval comments that are
older than certain period of time (default: 2 weeks).
Here is the idea and please excuse the text formatting:
function my_comment_on_old_post($comments_period = 1209600) {
global $comment_post_ID, $time_newcomment, $tableposts, $wpdb;
$postdate = $wpdb->get_var("SELECT post_date FROM $tableposts WHERE ID
= $comment_post_ID ");
if (!empty($postdate)) {
$time_post = mysql2date('U', $postdate);
if (( $time_newcomment - $time_post ) > $comments_period) {
return false;
}
}
return true;
}
The function is defined in my-hacks.php and is called in
wp-comments-post.php around line 63 where:
if(check_comment($author, $email, $url, $comment, $user_ip) ) {
is replaced with
if(check_comment($author, $email, $url, $comment, $user_ip) &&
my_comment_on_old_post() ) {
It can be easily adapted to work with the posts wich are on the front
page and I might add that code later.
Tested on WP 1.2
Regards
Peio Popov
My blog entry: http://blog.peio.org/index.php?p=154
More information about the hackers
mailing list