Re: Client's IP address retrival



Dave wrote:
varungupta (developer.varun@xxxxxxxxx) decided we needed to hear...

Hi Group members !

I want to know about a method for detecting client's IP which is
running behind a proxy server.
I have tried functions available with PHP core but they are returning
the address of proxy server not of the client's machinel.
Is there any way to get the desired results.


You can't do it with PHP. You could use Javascript and pass it as a
form variable.

Depends why you want to do this, since its easy to get around it -
JS could be turned off, or the form var could be overidden.
If say you wanted to ban users from a particular IP then I wouldn't
trust this method, but if you just want the IP for cosmetic reasons
then I'm sure you can live with the pitfalls.

could you can do it with php.... this may not work with annonymous proxies... but most ISP's should forward this header.

if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
	$userip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
	$userip = $_SERVER['REMOTE_ADDR'];
}

*Rob
.



Relevant Pages

  • PHP and Proxy Servers
    ... I am within an organisation which accesses the web through a proxy server. ... >From an earlier post in parsing in PHP I have had that problem solved but ... I was wondering does anyone know of a way for PHP to go ...
    (alt.php)
  • Re: Whats the best Linux group to ask this in
    ... > ability to throw up into a specific area of the page the ip address of the ... Something like "You are connecting from IP ... PHP docs for predefined variables or something like that). ... Note that, if the client is connecting through a proxy server, ...
    (comp.os.linux.security)
  • PHP-Sessions and squid-proxy
    ... I'm experiencing problems using sessions in php. ... But when I activate my own or my providers proxy server a ... I'm running Squid 2.4.6 on Debian linux ...
    (comp.lang.php)
  • Re: Shouldnt a file I create default to being owned by me?
    ... Dave M G wrote: ... So, I was suprised when I created a little PHP script to test something, and when I viewed it through FireFox, it said there was a "permissions error". ... Files by default are created with the permissions 666 MINUS your umask. ...
    (Ubuntu)
  • Re: Auto submitting a form that contains a file field
    ... Client end is NOT php. ...  Thanks, - Dave ... post-file in wget or the equivalent in CURL to do the thing. ...
    (comp.lang.php)