Jump to content


Photo

IP records


  • Please log in to reply
5 replies to this topic

#1 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 29 September 2006 - 11:36 AM

I'm developing a site and I want to implement a feature during the login phase that will allow me to keep track of the users IP address (for security and limiting users in certain ways around the site).

I have created the table 'userIPs' with 3 fields:

Userid - This will store the userid of the user who just logged in
IP - This stored the IP of the users computer
Date - The time the user logged in

Now what I would like to do is record this information each time a user logs in, however, to stop the list getting too large I want to do the following:

1. User logs in, all the details are recorded above.
2a. Unon another login, if it is the same user/IP simply just update the date field.
2b. Upon another login, if the user has different IP, record a new row with all the detail below.

So basically I'll end up with a list of users and all the Ips they have used and when it was last used.

Anyone know how this can be done or a better suggestion on how I could achieve this?

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 29 September 2006 - 12:03 PM

I agree with logging the details, that's a good idea, however, using the info to restrict areas/features of the site is not a good idea.  As you've correctly identified (and it would appear made provision for) is that users IP's will probably change quite regularly.

As for how you'd do it, just take a look at the Predefined $_SERVER Variables area of the PHP manual.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 29 September 2006 - 12:17 PM

I had thought about that so was going to use a cron to delete records that are older than X.

My primary use for it would be to simply spot multiple accounts. Then monitor them to see if they break any terms and conditions of the site.

I know that users can simply use proxies, but a small monitoring system is better than none at all.

Anyone point me in the right direction?

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 29 September 2006 - 12:22 PM

Anyone point me in the right direction?


Did you look at the section I pointed you at?  That will give you the information you need for getting the IP Address, I assumed you already had the code to insert into the database as you've got the database setup already.

If you need info on entering data into the database then check out the manual section relating to your database (more than likely MySQL).

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 29 September 2006 - 12:31 PM

Sorry - completely missed that last line, but thankfully i already know how to get the users IP.

I have not started the script yet, still perfecting the login authentication. But I'll have a go later and post if I have problems.

#6 acdx

acdx
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 29 September 2006 - 12:44 PM

I'd suggest you simply add a "last login time" (datetime?) and a "last login ip" (varchar) column to your user table, defaulting to NULL. When someone logs in, "update users set logintime = xx, loginip = xx where id = xx". It's not like the users are gonna "go back to their old ip" anyway.

.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users