I need some help. I want to knows is there any possible code in php to block certain ip address from access my IP address and my pc from access certain IP address. (for example, I'm using ip address 192.168.1.2 and I want to block ip address from 192.168.1.3 and vice versa). Is there any possible in php code? if possible, I don't want to write in .htaccess file but code in .php file.
HERE IS MY SOME PHP CODE
<?php
$address = "192.168.1.7";
$total=0;
$i=1;
$blockIPstatus="no";
while($blockIPstatus=="no") {
$ping = exec("ping $address");
$pingTime = explode(',',trim($ping));
$time = explode("=",trim($pingTime[2]));
$onlytime = implode("m",trim($time));
$number=chop($time[1],"ms");
$total=$total+$number;
$average=$total/$i;
echo ", Total=".$total;
echo ", average=".round($average, 2);
echo "<br>";
if($average>=500)
$blockIPstatus="yes";
}
// i need some function to block this ip from here
?>