cURL Remote Address

Monday 1st June, 2009

While trying to stop my Google Analytics code showing up on this site when I access the page I went for the obvious solution - simply to check if the visitor's IP address ($_SERVER['REMOTE_ADDR']) matched the IP addresses I normally access the site from.

However, I found that PHP was reporting the 'REMOTE _ADDR' to be the server's IP address. It didn't take long to realise this was a side effect of the way I've used the cURL technique within my CMS - it is the server itself which is accessing the page with the Google javascript in it - which of course makes perfect sense when you think about it.

Simple solution? I just send the user's IP address to that page as a URL variable.

I'm still getting to grips with this cURL business - not entirely convinced I'm using it for what it was originally intended, but as far as I can tell it's doing the job perfectly.

Comments

Please login to comment on this page

back