$_SERVER['REMOTE_ADDR']

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Xerpher
New php-forum User
New php-forum User
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada
Contact:

$_SERVER['REMOTE_ADDR']

Postby Xerpher » Fri Oct 04, 2002 10:03 am

Is there another way to get somebody's IP?

Because I made a unique counter which logs IP's and how many visits that IP made, but I found out that my ISP has a seperate IP for all it's users and that IP works fine for accessing the computer, but when I browse the web, it spits out a different IP that different nearly everytime. So a friend of mine with the same ISP saw how many visits I made :? :cry:

Jay

Postby Jay » Fri Oct 04, 2002 1:46 pm

Proxy server?

No, there's no other way. You could try print_r($_SERVER) if you don't believe me, but there you go!

Xerpher
New php-forum User
New php-forum User
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada
Contact:

Postby Xerpher » Fri Oct 04, 2002 1:52 pm

Darn it... Thanks anyway

DoppyNL

Postby DoppyNL » Sat Oct 05, 2002 1:27 am

I found this code somewhere on php.net:

Code: Select all

if(getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
elseif(getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else
$ip = getenv("REMOTE_ADDR");


please note that only remote_addr can be used for authentication, since all the other values can be tempered with quite easily.

Greetz Daan

Jay

Postby Jay » Sat Oct 05, 2002 10:02 am

DoppyNL wrote:I found this code somewhere on php.net:

Code: Select all

if(getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
elseif(getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else
$ip = getenv("REMOTE_ADDR");


please note that only remote_addr can be used for authentication, since all the other values can be tempered with quite easily.

Greetz Daan

Yeah, there was that floating around in the back of my mind, but I wasn't sure if it was real or a figment of my imagination. I suppose I spent too much time dreaming up funky bits of code ;)


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron