473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Unknown IP address?


I'm using

$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
$_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

to get a visitor's IP address, but every once in a while I get
"unknown, unknown" instead of an address. Is there something I'm
leaving out?
Aug 21 '06 #1
2 3340
Steven Paul wrote:
I'm using

$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
$_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

to get a visitor's IP address, but every once in a while I get
"unknown, unknown" instead of an address. Is there something I'm
leaving out?
It's probable that your server environment uses another variable
(HTTP_CLIENT_IP for instance).

Examin the printout of the phpinfo() function to find the correct key.
JW
Aug 21 '06 #2
*** Steven Paul escribió/wrote (Mon, 21 Aug 2006 14:40:34 -0600):
$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
$_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

to get a visitor's IP address, but every once in a while I get
"unknown, unknown" instead of an address. Is there something I'm
leaving out?
I'm afraid that obtaining client IP address is not rocket science. In
particular, HTTP_X_FORWARDED_FOR is generated by (some/most?) proxies and
it isn't 100% reliable. However, it's your best guess.

BTW, HTTP_X_FORWARDED_FOR can be a comma separated list of address so your
function needs some extending:

function estimated_client_ip(){
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
list($ip)=explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
return $ip;
}else{
return $_SERVER['REMOTE_ADDR'];
}
}
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: lothar.sch | last post by:
Hi, My python scripts are running as cgi scripts on an IIS on Windows XP. I have to distribute it to IIS on Windows 2003 Server. I tried to set python as cgi scripts in IIS on this machine in...
2
by: James | last post by:
Can anyone please shed some light on the following... I have a framework that uses dynamically created tables, named using an incremental "attribute set ID", as follows: attrdata_1 attrdata_2...
0
by: Jerry Camel | last post by:
Let's try this again... I think I sent half a message before. Things were working just fine and I'm not sure what changed. The code is pretty simple. But now I can't send a message anymore. I...
9
by: Christian Christmann | last post by:
Hi, I was just going through this exercise http://www.cas.mcmaster.ca/~franek/books/membook-answers/ch4/answers-ch4-3.html and I'am confused about the answer. It says: "... the compiler...
1
by: bjlemaire | last post by:
Hello, I am writing an app that is retrieving data via an ODBC connection to an Access database. I am returning many columns, and it seems that for certain columns that I try to read, I get the...
1
by: tactech | last post by:
Hello Can somebody help me and tell me why I can’t change the background color of the second PN2 panel. I get this error about unknown source Exception in thread "AWT-EventQueue-1"...
3
by: abcd | last post by:
I have a linux machine (ip = 10.10.10.8), which can ping other machines on the same subnet...such as 10.10.10.1 10.10.10.2 10.10.10.5 10.10.10.6 10.10.10.254 If I use...
0
by: imtired | last post by:
Hi all, Im trying to setup a DNS server at home for a possible business using Windows XP Pro and BIND9 Got most of it working now (ie able to bowse using the IP for the DNS server -yay) but when i...
4
by: omono84 | last post by:
I know that this should be rather simple but i seem to be missing a step to get it to work. and have been unable to find a solution on the net. The aim is that I click on the open button to find...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.