protected function checkIPVersion($UserIP = false)
	{
		// Test for IPv4
		if (ip2long($UserIP) !== false)
		{
			$this->IP_Version = "IPv4";
			return $this->IP_Version;
		}
		
		// Test for IPv6
		if (substr_count($UserIP, ":") < 2)
		{
			$this->IP_Version = false;
			return false; 
		}
		// ::1 or 2001::0db8
		if (substr_count($UserIP, "::") > 1)
		{
			$this->IP_Version = false;
			return false; // one allowed
		}
		$groups = explode(':', $UserIP);
		$num_groups = count($groups);
		if (($num_groups > 8) || ($num_groups < 3))
		{
			$this->IP_Version = false;
			return false;
		}
		$empty_groups = 0;
		foreach ($groups as $group)
		{
			$group = trim($group);
			if (! empty($group) && ! (is_numeric($group) && ($group == 0)))
			{
				if (! preg_match('#([a-fA-F0-9]{0,4})#', $group))
				{
					$this->IP_Version = false;
					return false;
				}
			}
			else
			{
				++ $empty_groups;
			}
		}
		if ($empty_groups < $num_groups)
		{
			$this->IP_Version = "IPv6";
			return $this->IP_Version;
		}
		$this->IP_Version = false;
		return false; // no (valid) IP Address
	}
protected function checkIPVersion($UserIP = false)
	{
		// Test for IPv4
		if (ip2long($UserIP) !== false)
		{
			$this->IP_Version = "IPv4";
			return $this->IP_Version;
		}
		
		// Test for IPv6
		if (substr_count($UserIP, ":") < 2)
		{
			$this->IP_Version = false;
			return false; 
		}
		// ::1 or 2001::0db8
		if (substr_count($UserIP, "::") > 1)
		{
			$this->IP_Version = false;
			return false; // one allowed
		}
		$groups = explode(':', $UserIP);
		$num_groups = count($groups);
		if (($num_groups > 8) || ($num_groups < 3))
		{
			$this->IP_Version = false;
			return false;
		}
		$empty_groups = 0;
		foreach ($groups as $group)
		{
			$group = trim($group);
			if (! empty($group) && ! (is_numeric($group) && ($group == 0)))
			{
				if (! preg_match('#([a-fA-F0-9]{0,4})#', $group))
				{
					$this->IP_Version = false;
					return false;
				}
			}
			else
			{
				++ $empty_groups;
			}
		}
		if ($empty_groups < $num_groups)
		{
			$this->IP_Version = "IPv6";
			return $this->IP_Version;
		}
		$this->IP_Version = false;
		return false; // no (valid) IP Address
	}
protected function checkIPVersion ( $ UserIP = false ) { // Test for IPv4 if ( ip2long ( $ UserIP ) !== false ) { $ this -> IP_Version = "IPv4" ; return $ this -> IP_Version ; } // Test for IPv6 if ( substr_count ( $ UserIP , ":" ) < 2 ) { $ this -> IP_Version = false ; return false ; } // ::1 or 2001::0db8 if ( substr_count ( $ UserIP , "::" ) > 1 ) { $ this -> IP_Version = false ; return false ; // one allowed } $ groups = explode ( ':' , $ UserIP ) ; $ num_groups = count ( $ groups ) ; if ( ( $ num_groups > 8 ) || ( $ num_groups < 3 ) ) { $ this -> IP_Version = false ; return false ; } $ empty_groups = 0 ; foreach ( $ groups as $ group ) { $ group = trim ( $ group ) ; if ( ! empty ( $ group ) && ! ( is_numeric ( $ group ) && ( $ group == 0 ) ) ) { if ( ! preg_match ( '#([a-fA-F0-9]{0,4})#' , $ group ) ) { $ this -> IP_Version = false ; return false ; } } else { ++ $ empty_groups ; } } if ( $ empty_groups < $ num_groups ) { $ this -> IP_Version = "IPv6" ; return $ this -> IP_Version ; } $ this -> IP_Version = false ; return false ; // no (valid) IP Address }
IP =  IPv4 or IPv6 ?

@param string $ip	IP Address (IPv4 or IPv6)
@return mixed		false: no valid IPv4 and no valid IPv6
"IPv4" : IPv4 Address
"IPv6" : IPv6 Address
@access protected
IP = IPv4 or IPv6 ?