Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Spam\Time Controal Question

    I have a comment thing in my site, how do I set spamcontrol like thing?
    The comment is IP based, so everyone can post, but someone can post in certain tutorial each 5 minutes.
    Can somebody help me?

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's probably a bad way to go about it because a group of users could have the same IP.

    I'm guessing that you have a database. You can add a field for IP Addresses and Time.
    When a post is made you can check against the table for the IP and Time. If it exists within the last 5 mins then dissalow, if not then add the comment and update the IP table

  • #3
    New Coder
    Join Date
    Feb 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, that was my thought, but the question is how :P

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's pretty impossible to say how. There would be different methods depending on how the script works, if it has a database, what fields are in the database, if it uses sessions or just IP Addresses.

  • #5
    New Coder
    Join Date
    Feb 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by degsy
    It's probably a bad way to go about it because a group of users could have the same IP.
    So I guess it'd be based on sessions...

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,593
    Thanks
    0
    Thanked 645 Times in 635 Posts
    If you save the ip address and time of posting along with each post then you can simply retrieve any entries for the current ip address in descending time order and if that time is less than 5 minutes ago then disallow the post.

    If the ip address is reallocated to a different person then the chances of them trying to post is so close to zero as to not be worth worrying about. I use a 15 minute test in a script where I only expect each person to post one message.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •