Block a specific IP Address to execute, run rest code and View the Website or Web page

Sometimes we need to stop some specified IP Addresses to block the execute the code or stop to view our website or code so that I wrote that PHP code its help to doing that.

By this code, you can also stop the spamming from any hacker IP Address, if you find the IP Address of the Spammer or hacker they can not make spam on your website or contact form. I also wrote this code when someone create spamming on my contact us page form after validation he successfully create spamming and I got 1000 spamming emails. With this code, I block that IP address and stop the code execution

<!doctype html>

<html>
<head>
<title>Page Title</title>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0">
</head>

<body>

<?php 

$ip = $_SERVER['REMOTE_ADDR'];

$data = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));

$ClientState = $data['geoplugin_city'];
$ClientIPAddress = $data['geoplugin_request'];;

echo $ClientIPAddress; 

if($ClientIPAddress == '156.96.46.226'){

exit(); 

}else{
echo 'Sorry We Offline know.';
}

?>

<h1>This PHP Code help to stop excuited code when Speicifed IP Address is dedected. MyFreeOnlineTools</h1>
<h2>This PHP Code help to stop excuited code when Speicifed IP Address is dedected. MyFreeOnlineTools </h2>
<h3>This PHP Code help to stop excuited code when Speicifed IP Address is dedected. MyFreeOnlineTools</h3>
<h4>This PHP Code help to stop excuited code when Speicifed IP Address is dedected. MyFreeOnlineTools</h4>
<h5>This PHP Code help to stop excuited code when Speicifed IP Address is dedected. MyFreeOnlineTools</h5>
<h6>This PHP Code help to stop excuited code when Speicifed IP Address is dedected. MyFreeOnlineTools</h6>

</body>
</html>

Above I used GeoPlugin to find IP Location and IP Address Details it’s free to use. Link below

https://www.geoplugin.com/