PHP code example of arraypress / wp-ip-utils
1. Go to this page and download the library: Download arraypress/wp-ip-utils 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/ */
arraypress / wp-ip-utils example snippets
use ArrayPress\IPUtils\IP;
// Behind Cloudflare or a load balancer, declare it first.
IP::trusted_proxies( [ '173.245.48.0/20', '103.21.244.0/22' ] );
$ip = IP::get();
// Block by CIDR or wildcard, from a setting.
if ( IP::is_match( $ip, $blocked_patterns ) ) {
wp_die( 'Access denied' );
}
// Store it without storing all of it.
$for_logs = IP::anonymize( $ip ); // 203.0.113.0