Blocking Ip address using php?

franc

New member
Hi Everyone,

You know i want to know ho w do i block IP addresses using php. In my case i wanna block all IP addresses starting with 202.

I have tried using the following code but to no success

<?php


// blocking users whose IP Addresses start with 202.
$block = array("202.*.*.*");
if (in_array($_SERVER['REMOTE_ADDR'], $block)) {
echo "You cannot access this site";
exit();
}
?>

anyone has any better ideas than this?!
 
Back
Top