PHP code example of kigkonsult / iptools

1. Go to this page and download the library: Download kigkonsult/iptools library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kigkonsult / iptools example snippets



$validityRange = [
    '192.168.0.1',                // specific match 
    '192.168.0.10-192.168.0.20'   // within a range
    '192.168.1.*                  // with wildcard
    '192.168.2.0/25               // cidr
    '192.168.3.0/255.255.255.128' // or netmask
];

~~~~~~~~
For filters in detail, examine _IpTool::isIpNumInRange_, below. 

**2a** 'ad hoc' check
~~~~~~~~

use Kigkonsult\IpTools\IpTool;

if( ! Iptool::factory( $validityRange )->checkIPnumInRange( $IpNumToTest )) {
    echo 'error message';

use Kigkonsult\IpTools\IpTool;

$ipValidator = new Iptool( $baseFilterArr );
...
$adHocFilter = '192.168.4.*';
...
if( ! $ipValidator->addFilter( $adHocFilter )
    ->checkIPnumInRange( $IpNumToTest )) {
    echo 'error message';