I want to block some hostnames and ips from accessing my website, I use this codde to =block only one hostname or ip:
<?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$ipz = $_SERVER['REMOTE_ADDR'];
if ($hostname === "blocked hostname" || $ipz == "blokced ip" ){
echo "redirect to some url";
}
else {
echo "show site content";
}
?>
But I have a long list hof hostnames and IPs to be blocked, I want to add all those bad IPs and hostnames I have in a separated file, and then check if the visitors hostname or IP is on that list or not. how can I do that and keep to site loading fast ?
Thanks