Dark Bit Factory & Gravity
ARCHIVE => Archive => Java,JS & Flash => Topic started by: combatking0 on January 14, 2010
-
I've been writing a fault & equipment database at work, and I discovered a PHP function which effectively runs an NSLookup based on the client's IP address.
The returned hostname is then checked in the database to find out which room the user is posting from, allowing the user to report a fault in their room with a single click, rather than looking for their room from a big drop-down box.
I'll put some sample code up on Tuesday when I get back into work.
The PHP command is:
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
No good for internet, but great for intranet scripting.
-
I'll see if I can incorporate it somewhere on the portal :)
-
Work won't let me paste the source code on the internets for security purposes, but there really isn't much else to it than I have already posted - it's what you do with the returned data that counts.