Edit report at https://bugs.php.net/bug.php?id=42094&edit=1
ID: 42094 Comment by: aladdin18 at hotmail dot com Reported by: fushimi at rep dot fielding dot nec dot co dot jp Summary: getenv("REMOTE_ADDR") returns no IP address Status: Not a bug Type: Bug Package: Apache2 related Operating System: Windows 2000 PHP Version: 5.2.3 Block user comment: N Private report: N New Comment: Hi every one my name is AlAa My problem with $_SERVER['remote_addr'] I'm not sure if I'm having a problem with the installation of PHP on the server or if there's something that I'm not doing right in the code, but I am trying to capture the IP address of anyone that is trying to log into a secure part of a site. Regardless of my IP address, when I do: Code: echo $_SERVER['remote_addr']; It returns '192.168.1.1'. This is the first time I've written code that is being used on a Windows Server, so I don't know if that has anything to do with it. I've run phpinfo(), and in the PHP Variables section, it shows "_SERVER["REMOTE_ADDR"]" : 192.168.1.1. Does this mean that the php.ini file is setup wrong, or am I missing something? i am running my own server on windows 7 iis7.5 with php as fastcgi and i am behind a router with a dynamic ip not static and i am using http://www.no-ip.com/ that give me a link to my router and i am opening 80 port in my router forwarding it to my id address 192.168.1.5 and i have tested a php file that contains <?php echo $_SERVER['REMOTE_ADDR']; ?> tested it using tor network that give me ip out of my network to test that file always give me the same result 192.168.1.1 i am trying to get IP address of the visitor and i asked someone of my friends to use this form it sends the same ip i hope someone tells me what i am doing wrong and the solution for this problem Thanks in advance Previous Comments: ------------------------------------------------------------------------ [2007-07-27 04:59:52] fushimi at rep dot fielding dot nec dot co dot jp Thank you again for your help. Could you give me any idea about how can I enable this option in Apache2? ------------------------------------------------------------------------ [2007-07-26 09:50:13] j...@php.net It's apache that isn't setting it. PHP only sets the variables to whatever the server says they are. No bug in PHP. ------------------------------------------------------------------------ [2007-07-26 00:48:12] fushimi at rep dot fielding dot nec dot co dot jp Thank you, to reply me so quickly. Yes, $_SERVER['REMOTE_ADDR'] return the right IP address. One more thing that I forgot to mention, my Http server is Apache version 2.2.4. To help you, below is the results of PHP variable using phpinfo(): PHP5.2.3 and Apache2.2.4 ======================== _SERVER["SERVER_ADDR"] 192.168.1.3 _SERVER["SERVER_PORT"] 80 _SERVER["REMOTE_ADDR"] 0.0.0.0 _SERVER["REMOTE_PORT"] 0 PHP5.1.2 and Apache2.0.59 ========================= _SERVER["SERVER_ADDR"] 192.168.1.2 _SERVER["SERVER_PORT"] 80 _SERVER["REMOTE_ADDR"] 192.168.1.1 _SERVER["REMOTE_PORT"] 2476 ------------------------------------------------------------------------ [2007-07-25 11:58:27] j...@php.net Does it show up in $_SERVER['REMOTE_ADDR'] ?? ------------------------------------------------------------------------ [2007-07-25 07:53:25] fushimi at rep dot fielding dot nec dot co dot jp Description: ------------ I am evaluating the newest PHP 5.2.3, in relation with my current PHP 5.1.2. So, when I tried to get the remote IP using getenv(“REMOTE_ADDR”), I obtained the following results: PHP 5.2.3 => return 0.0.0.0 PHP 5.1.2 => return 192.168.1.1 PHP in ISAPI mode. Reproduce code: --------------- $ip = getenv("REMOTE_ADDR"); echo "IP Address ....: ".$ip; Expected result: ---------------- IP Address ....: 192.168.1.1 Actual result: -------------- IP Address ....: 0.0.0.0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=42094&edit=1