1. Go to this page and download the library: Download mantoufan/yzhanip 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/ */
mantoufan / yzhanip example snippets
use YZhanIP\YZhanIP;
(new YZhanIP('127.0.0.1'))->in(new YZhanIP('127.0.0.*')); // true, new YZhanIP can be omitted
(new YZhanIP('127.0.0.1'))->in('127.0.0.1-127.0.0.30'); // true
(new YZhanIP('127.0.0.1'))->in('127.0.0.*'); // true
(new YZhanIP('127.0.0.1'))->in('127.0.0.1/21'); // true
(new YZhanIP('2001:4860:4801::af88'))->in('2001:4860:4801::af88-2001:4860:4801::afff'); // true
(new YZhanIP('2001:4860:4801::af88'))->in('2001:4860:*::af88'); // true
(new YZhanIP('2001:4860:4801::af88'))->in('2001:4860:4801::af88/7'); // true
(new YZhanIP('127.0.0.1-127.0.0.30'))->in('127.0.0.*'); // true
(new YZhanIP('127.0.0.*'))->in('127.0.0.1/21'); // true
(new YZhanIP('2001:4860:4801::af88-2001:4860:4801::afff'))->in('2001:4860:*::af88'); // true
(new YZhanIP('2001:4860:*::af88'))->in('2001:4860:4801::af88/7'); // true
(new YZhanIP(['127.0.0.1', '127.0.0.1-127.0.0.30', '127.0.0.*']))->in('127.0.0.1/21'); // true
(new YZhanIP(['2001:4860:4801::af88', '2001:4860:4801::af88-2001:4860:4801::afff', '2001:4860:*::af88']))->in('2001:4860:4801::af88/7'); // true
(new YZhanIP(['127.0.0.*', '127.0.0.1/21']))->toString(); // 127.0.0.0-127.0.0.255,127.0.0.0-127.0.7.255
(new YZhanIP('2001:4860:4801:0000:0000:0000:0000:af88'))->toString(); // 2001:4860:4801::af88
(new YZhanIP(['2001:4860:*::af88', '2001:4860:4801::af88/7']))->toString(); // 2001:4860::af88-2001:4860:ffff::af88,2000::-21ff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
(new YZhanIP('2001:4860:4801:0000:0000:0000:0000:af88'))->toRaw(); // 2001:4860:4801:0000:0000:0000:0000:af88
(new YZhanIP(['127.0.0.*', '127.0.0.1/21']))->toRaw(); // 127.0.0.*,127.0.0.1/21
(new YZhanIP(['2001:4860:*::af88', '2001:4860:4801::af88/7']))->toRaw(); // 2001:4860:*::af88,2001:4860:4801::af88/7
(new YZhanIP(['127.0.0.1', '65.0.0.1', '2001:4860:4801::af88', '3001::af88', '127.0.0.*', '2001:4860:4801::af88-2001:4860:4801::afff']))->filter(['127.0.0.1/21', '2001:4860:4801::af88/7'])->toRaw(); // 127.0.0.1,2001:4860:4801::af88,127.0.0.*,2001:4860:4801::af88-2001:4860:4801::afff
$url = '{URL with IP and IP range inside}';
$ipCrawler = new IPCrawler($url, array( // The following are Default Config, no Modification no Statement
'cacheDir' => sys_get_temp_dir(),
'cacheKey' => 'yzhanip' . md5($url),
'cacheMaxAge' => 86400, // Unit: s
'timeOut' => 6,
));
// $ipCrawler = new IPCrawler($url); // use Default Config
$ipCrawler->get() // array('{IP}', '{IP Range}' ...)