[wp-hackers] Spam comments on the old posts

Ashwin Bihari abihari at gmail.com
Thu Sep 23 20:05:11 UTC 2004


I think spamming of posts has started to become a hassle for a lot of
people. In a pervious thread about this, in either the forums or the
hackers mailing list, the auto-close plugin was mentioned and that
might be a better alternative than one that requires for moderation of
comments to old posts.

This plugin basically took the number of days as an argument and
closed any posts that were older than the specified day. So you could
be as stringent as 1 week or as lax as 1 month.

Regards


On Thu, 23 Sep 2004 15:21:46 -0400, Peio Popov <peio at peio.org> wrote:
> 
> 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
> 
> _______________________________________________
> hackers mailing list
> hackers at wordpress.org
> http://wordpress.org/mailman/listinfo/hackers_wordpress.org
>



More information about the hackers mailing list