Log in

View Full Version : Storing the users current IP address


Nxs
07-08-2009, 09:11 AM
Regarding this thread :

http://www.vbulletin.com/forum/showthread.php?t=312600

Im trying to find a quick easy way to record a users name & ip address when they visit the forums, any ideas and suggestions from the community ?

My own thought was just to put a hook on the forumdisplay page to update the "ipaddress" in the "user" table, but not sure what impact this will have.

Lynne
07-08-2009, 02:26 PM
You are making the assumption that a user will first login to the forums prior to the game server? Is that always true? Personally, I'd do something with the server iptables to block ips that pound the server. Or, I'd talk to the host about different methods available to combat a dos attack.

Nxs
07-08-2009, 02:31 PM
You are making the assumption that a user will first login to the forums prior to the game server? Is that always true? Personally, I'd do something with the server iptables to block ips that pound the server. Or, I'd talk to the host about different methods available to combat a dos attack.

After 3 days of being constantly DDOS'd we've tried those.

Our host will provide DDOS protection.... for $1,000 a month - so thats a non starter

We frequently run a PHP script to scan the apache access_log, find anything that has requested the same "GET" in a short time then add it to the IPTABLES list - this is working and catching about 80-90% of the ddos but its a task we have to run every few hours as and when new zombies power up

All players have been told if they are on DHCP they will need to browse the forums before they can loginto the game to ensure their IP is authorised, and they are happy with this if it will reduce the LAG of the current packet filter :)

Lynne
07-08-2009, 03:00 PM
Well, I can tell you that the IP in the user table is just the registration IP. If I were to try what you are doing, I'd create a new field called something like "current_ip" and put the current ip addy in there and use that instead of replacing the registration ip. As soon as a user logs into the site, I'd grab the ip and put it in the field.

Nxs
07-11-2009, 06:10 PM
Any pointers on how to do this ? I did some plugins a long time ago and cant really remember that much :)

Ive created a custom user field, found it in the vb database structure. Just need to know the best way to update a userfield as a plugin.

I bet its really easy one liner, something simple like $vbulletin->setsomething.....

Lynne
07-11-2009, 06:20 PM
Actually, it isn't just a one-liner. You need to add it to the datamanager array for the user (one of the class_dm_ files contains the array) and then you need to set the variable wherever it is that you grab the ip.

Nxs
07-11-2009, 06:23 PM
So I guess this is really bad, sloppy poor coding then

but for a 1st draft it works, sure it wont detect a proxy but its a start :)



// test
$uid=$vbulletin->userinfo['userid'];

if ($uid > 0) {
$query="UPDATE userfield SET field5='" . $_SERVER['REMOTE_ADDR'] . "' WHERE userid=$uid";
mysql_query($query);
}

Lynne
07-11-2009, 09:59 PM
I suppose you could do it that way. It isn't as clean as using the vbulletin datamanagers, but I suppose it will work.