concrete/src/Utility/IPAddress.php
public function setIp($ipAddress, $isHex = false)
    {
        if ($isHex) {
            $this->ipHex = $ipAddress;
        } else {
            //discard any IPv6 port
            $ipAddress = preg_replace('/\[(.*?)\].*/', '$1', $ipAddress);
            //discard any IPv4 port
            if (strpos($ipAddress, '.') !== false) {
                $ipAddress = preg_replace('/(.*?(?:\d{1,3}\.?){4}).*/', "$1", $ipAddress);
            }
            $this->ipHex = bin2hex(inet_pton($ipAddress));
        }

        return $this;
    }
public function setIp($ipAddress, $isHex = false)
    {
        if ($isHex) {
            $this->ipHex = $ipAddress;
        } else {
            //discard any IPv6 port
            $ipAddress = preg_replace('/\[(.*?)\].*/', '$1', $ipAddress);
            //discard any IPv4 port
            if (strpos($ipAddress, '.') !== false) {
                $ipAddress = preg_replace('/(.*?(?:\d{1,3}\.?){4}).*/', "$1", $ipAddress);
            }
            $this->ipHex = bin2hex(inet_pton($ipAddress));
        }

        return $this;
    }
public function setIp ( $ ipAddress , $ isHex = false ) { if ( $ isHex ) { $ this -> ipHex = $ ipAddress ; } else { //discard any IPv6 port $ ipAddress = preg_replace ( '/\[(.*?)\].*/' , '$1' , $ ipAddress ) ; //discard any IPv4 port if ( strpos ( $ ipAddress , '.' ) !== false ) { $ ipAddress = preg_replace ( '/(.*?(?:\d{1,3}\.?){4}).*/' , "$1" , $ ipAddress ) ; } $ this -> ipHex = bin2hex ( inet_pton ( $ ipAddress ) ) ; } return $ this ; }
Sets the current IP Address.

@param string $ipAddress
@param bool $isHex

@return $this
Sets the current IP Address .