Show local ip of visitor

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tOKmaZ
Forum Newbie
Posts: 2
Joined: Tue Jan 03, 2006 8:32 am

Show local ip of visitor

Post by tOKmaZ »

Hi,
I wonder if there is any method to use that will show a visitor's local ip-address?

Thomas
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You can view the external IP address they used to access your site but it may be a proxy server at the end of the day.

Code: Select all

echo $_SERVER['REMOTE_ADDR'];
As for getting their internal IP on an intranet you can't do it for security reasons... that information isn;t sent over HTTP :)
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

that and to top it off if you start echoing peolpe's IP address on your webpage you might freak someone out.heh..though..that could be a good reason to do it....
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

I'm not sure if echoing out peoples IP addresses will really freak anyone out. I think anyone who knows what an IP address is will also know that servers can see your IP address.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

true,but not every joe smo knows things about IP addresses :-D It depends on who his auideince is..
tOKmaZ
Forum Newbie
Posts: 2
Joined: Tue Jan 03, 2006 8:32 am

Post by tOKmaZ »

As for getting their internal IP on an intranet you can't do it for security reasons... that information isn;t sent over HTTP Smile
This is what I thought.. anyways, I wasn't going to echo it, but using it for detecting if my webpage were accessed by me (from my home computer, which also is my webserver) or someone else.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Seems reasonable - your IP may even be the normal localhost (127.0.0.1) so its easily detected if that's the case. Just keep in mind (for any other possible future reasons) that IP is not a unique identifier as commonly believed. It should work for local access from your home PC to a webserver on that same PC. If you are redirecting through your ISP (not http://localhost/) keep in mind you may not have a fixed IP yourself...
TS_Death_Angel
Forum Commoner
Posts: 31
Joined: Sat Dec 31, 2005 8:49 am

Post by TS_Death_Angel »

Isn't JavaScript able to show your local IP adress?
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

For the user using the browser maybe - not a clue to be honest. But for a server to know every visitors IP it needs the REMOTE_ADDR $_SERVER variable...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Javascript does not have access to IP information.
Post Reply