xplo.re Medusa Core Framework 3.1
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • Authentication
  • Authentication_Token
  • Autoloader
  • Cache
  • Charset
  • ClassDescriptor
  • Closure
  • Controller
  • Converter
  • Date
  • Decoder
  • Delegate
  • Dispatcher
  • Encoder
  • Env
  • Env_Field
  • Env_File
  • Env_FileList
  • Env_Request
  • Env_SERVER
  • Exchange
  • Fault
  • Field
  • Filter
  • Filter_Value
  • Formatter
  • Hash
  • IP
  • Loader
  • Locale
  • Locale_Iterator
  • Locale_Node
  • Log
  • Module
  • Module_Iterator
  • Nothing
  • Object
  • OS
  • Plugin
  • Profiler
  • Query
  • Registry
  • Resource
  • Server
  • Session
  • Session_Token
  • Set
  • Storage
  • Storage_Result
  • Storage_Statement
  • Stream
  • String
  • Translation
  • URI
  • URI_Parameters
  • UUID
  • Value
  • Version
  • View

Interfaces

  • Accessor
  • Chainable
  • Comparable
  • Configurable
  • Equality
  • Identity
  • Inquiry
  • Masquerade
  • Mutator
  • SeekableStream
  • Storable
  • Variator

Exceptions

  • Exception

Constants

  • Copyright
  • ProductName
  • UseVersion
  • Version

Functions

  • ns_expand
  • ns_file_exists
  • ns_get_version
  • ns_resolve

Class IP

Provides parsing and transformation support for IPv4 and IPv6 addresses.

Core\Object implements Core\Chainable
Extended by Core\Set implements Core\Accessor
Extended by Core\IP implements Core\Equality, Serializable, Core\Storable
Namespace: Core
Package: Core
Since: 3.0
Requires: PHP 5.3, Filter
Version: 1.1
Located at IP.inc.php

Methods summary

public
# __construct( mixed $sourceIP )

Initialises a new Core\IP instance from an IP address string, hex address or another Core\IP instance.

Initialises a new Core\IP instance from an IP address string, hex address or another Core\IP instance.

Parameters

$sourceIP
Source IP address to parse.

Throws

Core\Exception\InvalidArgument
Supplied IP address is invalid.

Since

3.0
public static Core\IP
# clientIP( )

Returns new Core\IP instance for the remote client IP address, if any.

Returns new Core\IP instance for the remote client IP address, if any.

This method does not resolve proxy connections. Use the Core\IP::remoteIP() method instead to retrieve the best approximation for the final client IP address.

Returns

Core\IP

Core\IP instance for client IP address. If no such address exists (e.g. when not used within a server environment), null is returned instead.

See

Core\IP::remoteIP()

Since

3.0
public static Core\IP
# remoteIP( )

Returns new IP instance for the final remote client IP address, if any. If a proxy connection is detected, this method tries to resolve the final remote client IP by parsing all appropriate HTTP headers. Otherwise this method behaves equally to the Core\IP::clientIP() method.

Returns new IP instance for the final remote client IP address, if any. If a proxy connection is detected, this method tries to resolve the final remote client IP by parsing all appropriate HTTP headers. Otherwise this method behaves equally to the Core\IP::clientIP() method.

To retrieve the IP address of the client directly connected to the server, use the Core\IP::clientIP() method instead.

Caution: The IP returned by this method might be incorrect. Most proxy servers add additional HTTP headers for their respective clients, but are not required to do so. Additionally, this function might be disabled by a system administrator. Therefore the chain of proxy and client IPs might be incomplete, bogus or completely missing.

Returns

Core\IP

IP instance for the final client IP address. If no such address exists (e.g. when not used within a server environment), null is returned instead.

See

Core\IP::clientIP()

Since

3.0
public static string
# shortenIP( mixed $sourceIP )

Parses a given IP and returns the shortened variant.

Parses a given IP and returns the shortened variant.

The return value equals that of the Core\IP::brief() function for an IP instance.

Parameters

$sourceIP
Source IP address to parse.

Returns

string
Brief notion of IP address or null, if the source IP cannot be parsed.

Since

3.0
public static Core\IP
# unpack( $data )

Returns an IP instance restored from a natural binary 4-byte (IPv4) or 16-byte (IPv6) string.

Returns an IP instance restored from a natural binary 4-byte (IPv4) or 16-byte (IPv6) string.

Parameters

$data

4-byte (IPv4) or 16-byte (IPv6) string storing the native representation of an IP address.

Returns

Core\IP

New IP instance restored from the packed binary representation or null, if packed data is not a valid binary IP string.

Since

3.1

Implementation of

Core\Storable::unpack()
public string
# __toString( )

Returns string of IP address as generated by Core\IP::address().

Returns string of IP address as generated by Core\IP::address().

Returns

string

Since

3.0

Overrides

Core\Object::__toString
public string
# brief( )

Formats the IP address in shortest possible notation. Uses the abbreviated notation for IPv6 addresses if possible to fold the longest chain of zero bytes.

Formats the IP address in shortest possible notation. Uses the abbreviated notation for IPv6 addresses if possible to fold the longest chain of zero bytes.

Returns

string

Since

3.0
public string
# hash( )

Returns the binary 4-byte (IPv4) or 16-byte (IPv6) representation of the current IP.

Returns the binary 4-byte (IPv4) or 16-byte (IPv6) representation of the current IP.

The hash method changed with version 1.1. Until then, a 34-byte hexadecimal string was returned, equal to the value of hexaddr() prefixed with »0x«. Since version 1.1, the hash is identical to the return value of the Core\IP::pack() method.

Returns

string

4-byte (IPv4) or 16-byte (IPv6) binary string storing the IP in standard binary format.

See

Core\IP::pack()
Core\IP::unpack()

Since

3.0

Overrides

Core\Object::hash
public string
# hostname( )

Performs a reverse address lookup.

Performs a reverse address lookup.

Returns

string
Reverse hostname of IP address if lookup succeeded, otherwise null.

Since

3.0
public boolean
# isEqualTo( mixed $ip )

Tests, whether the current object is equal to another value or object.

Tests, whether the current object is equal to another value or object.

Parameters

$ip

$object Value or object to test for equality with the current object.

Returns

boolean

Returns true, if the current object and the value or object are equal, otherwise false.

Since

3.0

Implementation of

Core\Equality::isEqualTo()
public string
# pack( )

Returns the natural binary 4-byte (IPv4) or 16-byte (IPv6) representation of the current IP address.

Returns the natural binary 4-byte (IPv4) or 16-byte (IPv6) representation of the current IP address.

Returns

string

4-byte (IPv4) or 16-byte (IPv6) binary string storing the IP in standard binary format.

Since

3.1

Implementation of

Core\Storable::pack()
public string
# serialize( )

Serialises the IP address.

Serialises the IP address.

Returns

string
Serialised IP address.

Since

3.0

Implementation of

Serializable::serialize()
public
# unserialize( string $stream )

Un-serialises an IP address.

Un-serialises an IP address.

Parameters

$stream
Serialised data stream to un-serialise IP address from.

Since

3.0

Implementation of

Serializable::unserialize()
protected string
# address( )

Formats the IP address in standard notation. Includes each chunk but does not pad components.

Formats the IP address in standard notation. Includes each chunk but does not pad components.

Returns

string
IP address string in standard notation.

Since

3.0
protected string
# hex( )

Formats the IP address as a hexadecimal number.

Formats the IP address as a hexadecimal number.

Returns

string
String with hexadecimal notion of IP address.

Since

3.0
protected string
# ipv4( )

Returns IPv4 version of current IP. If the current IP is an IPv6 address, the IP is checked for IPv4 compatibility, mapping, 6to4 or translation mode and the extracted IPv4 is returned. Otherwise the method returns null.

Returns IPv4 version of current IP. If the current IP is an IPv6 address, the IP is checked for IPv4 compatibility, mapping, 6to4 or translation mode and the extracted IPv4 is returned. Otherwise the method returns null.

Returns

string
IPv4 version of current IP address or null, if extraction failed.

Since

3.0
protected string
# ipv6Compatible( )

IPv6-compatible address conversion. If the IP address of this instance is an IPv4 address, the resulting IPv6 address is the equivalent of the IPv4 address, padded by zeroes. This special address is used by dual-stack devices that both support IPv4 and IPv6.

IPv6-compatible address conversion. If the IP address of this instance is an IPv4 address, the resulting IPv6 address is the equivalent of the IPv4 address, padded by zeroes. This special address is used by dual-stack devices that both support IPv4 and IPv6.

Returns

string
IPv6-compatible address string.

Since

3.0
protected string
# ipv6Embedded( )

IPv6-compatible address conversion in embedded format. Equals the IPv6 address returned by ipv6compatible() but uses a special format for improved readability by using standard IPv4 notion for the last two segments if the represented address is actually an IPv4 address.

IPv6-compatible address conversion in embedded format. Equals the IPv6 address returned by ipv6compatible() but uses a special format for improved readability by using standard IPv4 notion for the last two segments if the represented address is actually an IPv4 address.

The example IP address 10.152.5.8 in an IPv6-compatible embedded format equals 0:0:0:0:0:0:10.152.5.8.

Returns

string
IPv6-compatible address string in embedded format.

Since

3.0
protected string
# ipv6Mapped( )

IPv4-mapped IPv6-address conversion. Used by hybrid dual-stack systems. The IPv4 address is embedded in an IPv6 address with a prefix of 80 bits zeroes and 16 bits ones.

IPv4-mapped IPv6-address conversion. Used by hybrid dual-stack systems. The IPv4 address is embedded in an IPv6 address with a prefix of 80 bits zeroes and 16 bits ones.

Returns

string
IPv4-mapped IPv6-address string.

Since

3.0
protected string
# ipv6To4( )

Network base address for 6to4 transitional networks. The IP address is prefixed by 2002 and followed by the IPv4 address, yielding a /48 network for a single IPv4 address.

Network base address for 6to4 transitional networks. The IP address is prefixed by 2002 and followed by the IPv4 address, yielding a /48 network for a single IPv4 address.

Returns

string
6to4-compatible IPv6 address string.

Link

6to4

Since

3.0
protected string
# ipv6Translated( )

IPv4-translated IPv6 address used by stateless IP/ICMP translation. An IPv4 address is prefixed by ::ffff:0:0:0/96.

IPv4-translated IPv6 address used by stateless IP/ICMP translation. An IPv4 address is prefixed by ::ffff:0:0:0/96.

Returns

string
IPv4-translated IPv6 address string.

Link

Stateless IP/ICMP Translation

Since

3.0

Methods inherited from Core\Set

__get(), __isset()

Methods inherited from Core\Object

__autocreateFactory(), __call(), __processParameters(), attachMethod(), chain(), getValueForKey(), getValueForKeyPath(), getValueForUndefinedKey(), issetValueForKey(), setValueForKey(), setValueForKeyPath(), setValueForUndefinedKey(), uuid()

Constants summary

integer IPv4

Denotes an IPv4 network address.

Denotes an IPv4 network address.

Since

3.0
# 4
integer IPv6

Denotes an IPv6 network address.

Denotes an IPv6 network address.

Since

3.0
# 6

Constants inherited from Core\Object

AnyParameterType, AutochainParameterType, AutocreateParameterType, BooleanParameterType, CharParameterType, EnumParameterType, IntegerParameterType, RealParameterType, StringParameterType, UserParameterType

Properties summary

protected array $_v_chunks

IP address chunks. For an IPv4 address, each chunk represents a single 8 bit address part, for an IPv6 address, each chunk represents a 16 bit address part.

IP address chunks. For an IPv4 address, each chunk represents a single 8 bit address part, for an IPv6 address, each chunk represents a 16 bit address part.

Since

3.0
#
protected integer $_v_type

IP type identifier. Either Core\IP::IPv4 or Core\IP::IPv6.

IP type identifier. Either Core\IP::IPv4 or Core\IP::IPv6.

Since

3.0
#

Magic properties

public read-only string $address

Standard formatted address.

public read-only string $brief

Formatted address in short notion.

public read-only array $chunks

IP address chunks.

public read-only string $hex

Address in hexadecimal notion.

public read-only string $hostname

Reverse hostname of IP address or null, if it cannot be resolved.

public read-only string $ipv4

Formatted IPv4 address or null, if the address cannot be represented by an IPv4 address.

public read-only string $ipv6Compatible

IPv6-compatible address string.

public read-only string $ipv6Embedded

IPv6-compatible address string in embedded format.

public read-only string $ipv6Mapped

IPv4-mapped IPv6-address string.

public read-only string $ipv6To4

6to4-compatible IPv6 address string.

public read-only string $ipv6Translated

IPv4-translated IPv6 address string.

public read-only integer $type

IP type identifier. Either Core\IP::IPv4 or Core\IP::IPv6.

Magic properties inherited from Core\Object

$hash, $uuid

xplo.re Medusa Core Framework 3.1 API documentation generated by ApiGen