Limit access to PHP site to 1 hour

Discussion in 'PHP' started by bluesky422, Jun 16, 2008.

  1. #1
    Hello, is it possible to log and track an IP address for time on a site and then limit the time they can stay to 1 hour?

    I am trying to prohibit people from staying on the site for more than 1 hour at a time and then eliminate this restriction after 24 hours.

    Any help would be appreciated.

    Thanks!
     
    bluesky422, Jun 16, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    yes you create a member area and in member area count the time per IP exit-enter

    Run a cron every hour to allow access to accounts where 24 hours passed

    Regards

    Alex
     
    kmap, Jun 16, 2008 IP
  3. projectshifter

    projectshifter Peon

    Messages:
    394
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Gross, using crons for this is overkill :(

    Best way to do it is to store the list of IPs into the database, as well as the time they first accessed the site. Do a SELECT <timecolumn> FROM <table> WHERE ip="'.$_SERVER['DOCUMENT_ROOT'].'" WHERE time>".(time()-60*60*24)." LIMIT 1" If that returns a result, they've been on the site in the last 24 hours, and you'll just want to check and see if the time it gives is less than time() minus one hour (60*60). If you want it so they can do it 1 hour per 24 hour window, that's the best way to do it, if you want it to be they have to wait 24 hours since the last time, on every page view have it set lasttime=time() type of system. Hope that helps.
     
    projectshifter, Jun 16, 2008 IP