How to limit, per user

Discussion in 'PHP' started by brainet, Jul 10, 2007.

  1. #1
    I have pagerank checker site,
    And i want to limit it so that user can only run the pagerank checker for 10 times/user or IP.

    any solution or example or tutorial on this.

    thanks in advance :D
     
    brainet, Jul 10, 2007 IP
  2. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    an easy way, would be to create a session (start_session()) and use that to track on how many times they have used it, once they hit your limit, don't let them use the tool again until the limit frame has run out.



    another way to do it, would be to have a mysql table, that you just put ipaddress,time and browser strings into, insert a row when a search is done, and before it's used, check to see how many rows there are, if the number of rows is over your allowed amount, don't let them use it.
     
    powerspike, Jul 10, 2007 IP
  3. lwbbs

    lwbbs Well-Known Member

    Messages:
    331
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    108
    #3
    You can use cookie, session, database, etc.
    But user can clear cookie, restart browser or change the ip.
    You may require register too.

     
    lwbbs, Jul 10, 2007 IP
  4. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just use a database. Your script that does the pagerank can get the IP using $_SERVER['REMOTE_ADDR']. You don't need sessions or cookies for IP tracking. Per user tracking would require a login and sessions. You do the same thing as an IP but in the database you store the username instead of the ip address.

    Whenever a request is made update or insert the entry into the database to track the number of time that ip has made the request for the current day. Then get the count and if it's greater than X then just exit the script.
     
    KalvinB, Jul 11, 2007 IP
  5. lwbbs

    lwbbs Well-Known Member

    Messages:
    331
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    108
    #5
    If you just use remote IP, you can't block the users who use dynamic IP.
    The better way is to request use to register an account.

     
    lwbbs, Jul 11, 2007 IP