![]() |
How to get clients ip in php
I am having a problem with some server load sharing and getting the clients correct ip.
When I use xforwardedfor it gets the first machines ip (servers ip) and I use remote_addr it gets the 2nd machines ip. I tried using ['HTTP_CLIENT_IP'] but it shows ip blank. Does anyone know what I can use grab the ip from the users browser? |
['REMOTE_ADDR']
|
Quote:
|
Don't mind me... I'm retarded.
|
$_server["remote_addr"]
|
Quote:
|
Quote:
Here is what they told me. Its passed as a variable "x-client-ip" in unix if you want to set the log to read it, you would use this: LogFormat "\"%{X-Client-IP}i\" %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined Well, how would I get that in php? |
If
$_SERVER['REMOTE_ADDR'] doesn't work, superglobals may be broken :( Try: $ip = getenv('REMOTE_ADDR'); echo $ip |
$_server[http_pc_remote_addr]
|
Quote:
|
Quote:
|
Are you using a proxy?
|
Have you tried x-forwarded-client?
|
Quote:
|
Quote:
Returns a 0 |
How about $_GET['x-client-ip']
|
Quote:
|
This is the code I used
<?php $RIGHT_IP = $_GET['x-client-ip']; ?> <? echo "$RIGHT_IP"; ?> |
Here is what they just said also:
If it were in unix it would be LogFormat "\"%{X-Client-IP}i\" %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined Wtf does that mean? |
Have you tried echo phpinfo(); to see what might work?
I grabbed this function from php.net and added the echo.. maybe? PHP Code:
|
Quikdraw - I tried the phpinfo and found the variable that held the ip
You rock :pimp Got it working |
Quote:
<?=$RIGHT_IP?> :thumbsup |
So what was the variable?
|
Quote:
|
All times are GMT -7. The time now is 09:42 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123