PHP code example of maxcrossan / yii_ip_blocker

1. Go to this page and download the library: Download maxcrossan/yii_ip_blocker 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/ */

    

maxcrossan / yii_ip_blocker example snippets


    'preload'=>array('ip-blocker'),
    
    'components'=>array(
        'ip-blocker' => array(
            'class' => Crossan\IPBlocker::class,
            //Expression to validate on (should return true if validation is cified as:
            // 1. Wildcard format:     1.2.3.*
            // 2. CIDR format:         1.2.3/24  OR  1.2.3.4/255.255.255.0
            // 3. Start-End IP format: 1.2.3.0-1.2.3.255
            'whitelistedIPs' => array(
                ':1', '127.0.0.1', //Localhost
                '123.123.123.123', //Office
            ),
            'whitelistArraySupplier' => null, //Use this to grab IPs from a method somewhere in your codebase. Will override whitelistedIPs if set.
        ),
    )
bash
    php composer.phar