blocking
Posted in
161
7:50 am, June 25, 2025
blocking all ips in a range
block all ips in a range
// The IP prefixes you want to block. Add a dot at the end.
$ip_block = ['47.79.'];
foreach ($ip_block as $ip_block_val) {
// Check if the user's IP address begins with the blocked prefix.
// strpos() will return 0 if it's found at the beginning of the string.
if (strpos($_SERVER['REMOTE_ADDR'], $ip_block_val) === 0) {
echo "Your IP range has been blocked.";
return false;
}
}
PHP
// The IP prefixes you want to block. Add a dot at the end.
$ip_block = ['47.79.'];
foreach ($ip_block as $ip_block_val) {
// Check if the user's IP address begins with the blocked prefix.
// strpos() will return 0 if it's found at the beginning of the string.
if (strpos($_SERVER['REMOTE_ADDR'], $ip_block_val) === 0) {
echo "Your IP range has been blocked.";
return false;
}
}
View Statistics
This Week
1
This Month
1
This Year
250
Add Comment
Other Items in blocking
Related Search Terms
Other Categories in Code
alpine js apps c css factorio font awesome images linux quick modals sqlite site bugs site updates slick slider sliders testing windows apps animation apache api apps asp bat blocking bootstrap bootstrap templates charts cookies core css css filters css grid design elements docker domains emoji fancybox fonts foundation framework gimp git html icons ideas image formatting images javascript javascript functions jquery js linux mac minecraft misc modal modals mysql nginx node php php errors php function php functions php simple html dom pi400 python react regex sections simple_html_dom simplepie php site bugs site documentation slick slick slider sql sqlite ssh sublime svg svg css templates tools video virtual box vscode vue webdev windows windows 11 windows commands wordpress