Comment scropt confusion!

Discussion in 'Programming' started by TheRagingStock, Apr 7, 2008.

  1. #1
    OK the website I have is that users can rate organizations at schools. However, I had the programmer make it so that users can leave 1 comment per IP address. However, I just realized...what if 20 people live in a house and are using wifi..then they are all using the same IP right? So if one person comments all the rest will get denied right?

    So how do you think I should go about this, is there some other way so that instead of 1 comment per IP, its 1 comment per computer?

    Thanks for all your help...
     
    TheRagingStock, Apr 7, 2008 IP
  2. Louis11

    Louis11 Active Member

    Messages:
    783
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    70
    #2
    By the nature of what you just described, every computer on the network will show one IP. They will have internal IP addresses to identify each computer, however this will not suffice as you do not (and cannot) access these IPs.

    You may consider using a cookie or session (preferably the latter).

    So, when a user posts set a variable like this:
    
    $_SESSION['commented'] = true;
    
    PHP:
    Make sure to have:
    session_start();
    PHP:
    at the VERY top of every page you will be accessing the session (aka. checking if the user has posted already).

    Then when they are trying to post do a:
    
    $already_posted = $_SESSION['commented'];
    
    if($already_posted){
         print "You already posted!";
         // do appropriate exiting
    }
    
    else{
      // continue as normal
    }
    
    PHP:
    Only problem with this is that a user could clear his sessions/cookies and be able to post again. But it will let you identify individual computers that reside behind a network router or hub.

    But anyway, I hope that helps!

    Cheers,
    Louis
     
    Louis11, Apr 9, 2008 IP
  3. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #3
    There is ultimately no way to reliably do what you want. As the suggestion above cookies or session variables are one method but easily overcome, unique email addresses being required is another option but it is easy for a single person to own many email addresses etc.

    It is a case of trying to balance restricting 1 person from having many posts and stopping others having any. Even with IPs, most peoples IP is dynamic and so simple for them to change it if they are so inclined.
     
    AstarothSolutions, Apr 10, 2008 IP
  4. c4st

    c4st Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You should throttle ips. Limit how often the user can comment X minutes per comment.
     
    c4st, Apr 10, 2008 IP