17/02/2023
For download errors or dead links,please contact the Support
Team,please copy the post link and paste it into the error form

Download PHP script to block vpn networks

PHP script to block vpn networks

 

<?php

// List of VPN IP addresses to block
$vpn_ips = array(
'10.0.0.0/8',
'172.16.0.0/12',
'192.168.0.0/16',
'103.243.24.0/24',
// Add more IP addresses here as needed
);

// Get the user’s IP address
$user_ip = $_SERVER['REMOTE_ADDR'];

// Check if the user’s IP address is within any of the VPN networks
foreach ($vpn_ips as $vpn_ip) {
if (ip_in_range($user_ip, $vpn_ip)) {
// User is using a VPN, block access
header('HTTP/1.1 403 Forbidden');
echo 'Access denied. Please disable your VPN to access this site.';
exit;
}
}

// User is not using a VPN, allow access
echo 'Welcome to the site!';

// Function to check if an IP address is within a network range
function ip_in_range($ip, $range) {
list($subnet, $mask) = explode('/', $range);
$subnet = ip2long($subnet);
$mask = ~((1 << (32 - $mask)) - 1);
$ip = ip2long($ip);
return ($ip & $mask) == $subnet;
}