PHP code example of brianlmoon / php-safelist-check

1. Go to this page and download the library: Download brianlmoon/php-safelist-check 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/ */

    

brianlmoon / php-safelist-check example snippets




$checker = new Safelist\Check();

try {
	$checker->safelist(array(
		'10.0.3.1',
		'10.0.0.0/16',
		'2001:db8:100:934b::3:1',
		'2001:db8:100:934b::/64',
		'*.example.com',
		'localhost',
		new Safelist\Definition\Domain('vpn.work.com'),
	));
}
catch (InvalidArgumentException $e) {
	// thrown when an invalid definition is encountered
}

$checker->check('10.0.1.1'); // true
$checker->check('10.1.1.1'); // false
$checker->check('2001:db8:100:934b::210:2'); // true
$checker->check('another.example.com'); // true