Forum Moderators: coopster

Message Too Old, No Replies

ip tracking with $_SERVER variables

ip tracking with $_SERVER variables

         

maxi million

7:23 am on Aug 19, 2005 (gmt 0)

10+ Year Member



back after a long time...

am in a rather confused state of mind;

i track the IPs of evry visits to my sites and have always used 'REMOTE_ADDR' and also 'HTTP_X_FORWARDED_FOR'. the later comes handy if there are any internal/machine ips can be tracked.

but just had a revelation: HTTP_X_FORWARDED_FOR is actually returned as an array. and it gets entered as comma separated in my db. so far i did not notice such activities so alwys was under the impression that it returns only one distinct machine ip.
what am i supposed to infer when i have a comma separated list (saw 2 values so far)?

again another confusion is-
if i am on lan (which i am) my machine has private network ip, which connects to the local server in turn connecting to the net why doesnt that ip also shows?

and finally-
what is "HTTP_CLIENT_IP"? used it to test get back empty inserts in the db

thanks

jatar_k

8:55 pm on Aug 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> HTTP_CLIENT_IP

doesn't seem to exist in the standard $_SERVER [ca.php.net] array so I am not sure

>> HTTP_X_FORWARDED_FOR

it is possible that multiple proxies might provide this, not sure. I haven't seen that one happen before.

>> lan ... why doesnt that ip also show

it shouldn't, the external ip for everyone on the same connection should be the same. Mine and the folk sitting around me will always be the same. This could be a configuration choice but that goes beyond my realms of expertise.

maxi million

4:30 pm on Aug 20, 2005 (gmt 0)

10+ Year Member



thanks jatar_k

HTTP_CLIENT_IP is apparently not part of $_SERVER but is an environment variable [php.net]...but still wondering about what it returns

i may need to rephrase my 3rd question from the first post here:
on lan a machine belongs to a private network, each machine connects to the local server and has an internal ip. using HTTP_X_FORWARDED_FOR from outside the network also returns the private IP. but if HTTP_X_FORWARDED_FOR actually returns an array, it should also return the ip of the local server.
so when i am tracking ip of my site visitors using both REMOTE_ADDR and HTTP_X_FORWARDED_FOR, it should return something like this:
external ip: 141.152.53.16
machine ip: 172.16.0.1, 172.16.0.68
what i get, however for machine ip is only 172.16.0.68. is the first value by default stripped as it would invariably end with 1?

any ideas?