2017 © Pedro Peláez
 

library network

image

piwik/network

  • Sunday, September 10, 2017
  • by piwik
  • Repository
  • 13 Watchers
  • 13 Stars
  • 274,322 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

Matomo/Network

Component providing Network tools., (*1)

Build Status, (*2)

Installation

With Composer:, (*3)

{
    "require": {
        "matomo/network": "*"
    }
}

Usage

IP

To manipulate an IP address, you can use the Matomo\Network\IP class:, (*4)

$ip = IP::fromStringIP('127.0.0.1');
// IPv6
$ip = IP::fromStringIP('::1');
// In binary format:
$ip = IP::fromBinaryIP("\x7F\x00\x00\x01");

echo $ip->toString(); // 127.0.0.1
echo $ip->toBinary();

// IPv4 & IPv6
if ($ip instanceof IPv4) {}
if ($ip instanceof IPv6) {}

// Hostname reverse lookup
echo $ip->getHostname();

if ($ip->isInRange('192.168.1.1/32')) {}
if ($ip->isInRange('192.168.*.*')) {}

// Anonymize an IP by setting X bytes to null bytes
$ip->anonymize(2);

The Matomo\Network\IPUtils class provides utility methods:, (*5)

echo IPUtils::binaryToStringIP("\x7F\x00\x00\x01");
echo IPUtils::stringToBinaryIP('127.0.0.1');

// Sanitization methods
$sanitizedIp = IPUtils::sanitizeIp($_GET['ip']);
$sanitizedIpRange = IPUtils::sanitizeIpRange($_GET['ipRange']);

// IP range
$bounds = IPUtils::getIPRangeBounds('192.168.1.*');
echo $bounds[0]; // 192.168.1.0
echo $bounds[1]; // 192.168.1.255

License

The Network component is released under the LGPL v3.0., (*6)

The Versions

10/09 2017

dev-master

9999999-dev

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.3.2

 

The Development Requires

18/07 2016

0.2.0

0.2.0.0

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.3.2

 

The Development Requires

23/10 2014

0.1.0

0.1.0.0

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.3.2

 

The Development Requires