Magento’s Core HTTP Helper Class – Get Remote IP Address

Have you ever wanted to get the remote IP address of your Magento website’s visitors, the referring website’s address or even validate an IP address?

Magento’s Core HTTP helper class offers a bunch of really useful functions.

<?php
Mage::helper('core/http')->getRemoteAddr($ipToLong = false);
Mage::helper('core/http')->getServerAddr($ipToLong = false);
Mage::helper('core/http')->getHttpHost($clean = true);
Mage::helper('core/http')->getHttpUserAgent($clean = true);
Mage::helper('core/http')->getHttpAcceptLanguage($clean = true);
Mage::helper('core/http')->getHttpAcceptCharset($clean = true);
Mage::helper('core/http')->getHttpReferer($clean = true);
Mage::helper('core/http')->getRequestUri($clean = false);
Mage::helper('core/http')->validateIpAddr($address);
?>