Fortunately, there are various measures to minimize spammers and trolls on your blog, and this simple PHP tutorial is one of them. All you need to know is the IP address of the particular spammer or troll.
The instructions are as follows:
- Copy/paste the PHP code below in a notepad
- Replace IP Address 1, IP Address 2, and IP Address 3 with the actual IP addresses you want blocked
- Save the file as a .php file (ex. ipblocker.php)
<?php
/*
Blogspot IP address blocker.
*/
$iplist = array(“IP Address 1?,”IP Address 2?,”IP Address 3?); // the list of banned IPs
$ip = getenv(“REMOTE_ADDR”); // get the visitors IP address
// echo “$ip”;
$found = false;
foreach ($iplist as $value) { // scan the list
if (strpos($ip, $value) === 0){
$found = true;
}
}
if ($found == true) {
echo “top.location = “error.html”;n”; // page to divert to
}
?>
4. Upload your newly created PHP file on any PHP supported web hosting service like 000webhost.com and zymic.com5. Lastly, paste the following code in your Blogger or Blogspot blog
<SCRIPT LANGUAGE=’javascript’ SRC=’BlogspotIPblocker.php’ TYPE=’text/javascript’></SCRIPT>
There are 2 methods by which you can do this:
METHOD A:
- Go to the ‘Design’ section of your Blogger dashboard
- Under ‘Template’, click on ‘Edit HTML’
- Look for the </head> tag and paste the code before it
- Go to the ‘Design’ section of your Blogger dashboard
- Under ‘Layout’, click on ‘Add a Gadget’
- Scroll down and select ‘HTML/JavaScript’ and paste the code inside the ‘Content’ box
- Save the gadget
0 comments:
Post a Comment