![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
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? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Aug 2003
Location: Someplace Windy
Posts: 4,501
|
['REMOTE_ADDR']
__________________
Perfect Gonzo |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 | |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Aug 2003
Location: Someplace Windy
Posts: 4,501
|
Don't mind me... I'm retarded.
__________________
Perfect Gonzo |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Oct 2002
Location: European Union
Posts: 1,752
|
$_server["remote_addr"]
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | |
jellyfish
![]() ![]() Join Date: Dec 2003
Posts: 71,528
|
Quote:
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 | |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
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? |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Jun 2003
Location: Costa Rica
Posts: 1,953
|
If
$_SERVER['REMOTE_ADDR'] doesn't work, superglobals may be broken ![]() Try: $ip = getenv('REMOTE_ADDR'); echo $ip
__________________
Yii Framework Guru - Seasoned PHP vet - Partner @ XXXCoupon.com |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Join Date: Mar 2004
Location: → → →
Posts: 1,717
|
$_server[http_pc_remote_addr]
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
Quote:
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Confirmed User
Industry Role:
Join Date: Dec 2001
Posts: 7,952
|
Are you using a proxy?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Confirmed User
Join Date: Aug 2003
Location: Someplace Windy
Posts: 4,501
|
Have you tried x-forwarded-client?
__________________
Perfect Gonzo |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 | |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 | |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
Quote:
Returns a 0 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 |
Confirmed User
Join Date: Aug 2003
Location: Someplace Windy
Posts: 4,501
|
How about $_GET['x-client-ip']
__________________
Perfect Gonzo |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 | |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
This is the code I used
<?php $RIGHT_IP = $_GET['x-client-ip']; ?> <? echo "$RIGHT_IP"; ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#19 |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
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? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#20 |
Confirmed User
Join Date: Mar 2004
Location: → → →
Posts: 1,717
|
Have you tried echo phpinfo(); to see what might work?
I grabbed this function from php.net and added the echo.. maybe? PHP Code:
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#21 |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
Quikdraw - I tried the phpinfo and found the variable that held the ip
You rock ![]() Got it working |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#22 | |
Confirmed User
Industry Role:
Join Date: Jun 2003
Location: Costa Rica
Posts: 1,953
|
Quote:
<?=$RIGHT_IP?> ![]()
__________________
Yii Framework Guru - Seasoned PHP vet - Partner @ XXXCoupon.com |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#23 |
Confirmed User
Join Date: Aug 2003
Location: Someplace Windy
Posts: 4,501
|
So what was the variable?
__________________
Perfect Gonzo |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#24 | |
Confirmed User
Join Date: Jul 2005
Posts: 658
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |