public function getRemoteAddr($ipToLong = false)
    {
        if (is_null($this->_remoteAddr)) {
            $headers = $this->getRemoteAddrHeaders();
            foreach ($headers as $var) {
                if ($this->_getRequest()->getServer($var, false)) {
                        $ip_array=explode(',',$this->_getRequest()->getServer($var, false));

                        foreach( $ip_array as $ipAddress )
                        {
                                //Some routers are inserting characters after the IP, trim it. -RK
                                preg_match_all('/\d{1,3}/',$ipAddress,$r);
                                $this->_remoteAddr = $r[0][0].'.'.$r[0][1].'.'.$r[0][2].'.'.$r[0][3];

                                if( $this->_remoteAddr )
                                {
                                        if( !$this->ip_is_private($this->_remoteAddr))
                                        {
                                                break;
                                        } else {
                                                $this->_remoteAddr = '';
                                        }
                                }
                        }
                }

                if( $this->_remoteAddr )
                {
                        break;
                }
            }

            if (!$this->_remoteAddr) {
                $this->_remoteAddr = $this->_getRequest()->getServer('REMOTE_ADDR');
            }
        }

        if (!$this->_remoteAddr) {
            return false;
        }

        return $ipToLong ? inet_pton($this->_remoteAddr) : $this->_remoteAddr;
    }