[FX.php List] [OFF] Getting visitor's IP

Kevin Futter kfutter at sbc.melb.catholic.edu.au
Thu Aug 21 19:07:49 MDT 2008


On 22/08/08 1:46 AM, "Bob Patin" <bob at patin.com> wrote:

> Strange... I know that I used this a couple of years ago.
> 
> Could there be a setting on my web server that would change this
> behavior? Would it be a PHP setting or possibly something in the
> server itself (Mac OS X Server/Apache)?
> 
> If anyone knows, I'd appreciate some guidance.
> 

Hi Bob,

The problem is that Mac OS X Server stores this info in a non-standard
variable. You're probably testing for:

$_SERVER['REMOTE_ADDR']

Whereas OS X Server uses:

$_SERVER['HTTP_PC_REMOTE_ADDR']

Been there and done that one.

I now normalise the two of them thusly:

if (isset($_SERVER['HTTP_PC_REMOTE_ADDR']))
{
// OS X Server uses HTTP_PC_REMOTE_ADDR to store user IP

$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_PC_REMOTE_ADDR'];
}

$ip = $_SERVER['REMOTE_ADDR'];

Hope this helps!


-- 
Kevin Futter
Webmaster, St. Bernard's College
http://www.sbc.melb.catholic.edu.au/


#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal
#####################################################################################

This e-mail and any attachments may be confidential. You must not disclose or use the information in this e-mail if you are not the intended recipient. If you have received this e-mail in error, please notify us immediately and delete the e-mail and all copies. The College does not guarantee that this e-mail is virus or error free.  The attached files are provided and may only be used on the basis that the user assumes all responsibility for any loss, damage or consequence resulting directly or indirectly from the use of the attached files, whether caused by the negligence of the sender or not. The content and opinions in this e-mail are not necessarily those of the College.


More information about the FX.php_List mailing list