Jump to content

Comment Spam Filter


ShoeLace1291

Recommended Posts

Ok, so I want to make a comment spam filter for my site.  I know the basic logic, but have yet to figure out how to write the functions.  I have a database table called comments that has a column called "time", which contains a unix timestamp value of when it was posted.  Basically what I want to do is this:

 

When a user tries to post a comment, the script determines with a database query if they have posted a comment in the last 120 seconds.

 

So basically I have to find the current time, and the time it was 120 seconds before the current time.  Then I have to find any comments posted by the user that were made after the 120 second mark.

 

My database query should then look something like this, right?

 

$query = mysql_query("SELECT * FROM comments WHERE author = ".$_SESSION['id']." AND time > '".$120secondsago"'");

 

Please correct me if my logic is wrong, which it very well may be, but how would I find the unix timestamp code from 120 seconds before the current time?  Note that 120 seconds is just an example and also that I have not worked with dates in mysql very often.

 

$query = mysql_query("SELECT * FROM comments WHERE author = ".$_SESSION['id']." AND time

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.