If
you have been noticing the works of spammers and trolls on your
website, you need to understand that, it is quite difficult to
completely avoid these spammers but that doesn’t mean you don’t have to
fight them back, but allow them keeps disturbing your site. There are so
many ways you can minimize spammers on your blog. Here I will give you
this simple PHP tutorials that will help you block these spammers IP
addresses from accessing your blog.
First of all, you will need to know the IP address of that particular spammer or troll that is disturbing your site. And follow this instructions below.
1. You will have to copy and paste this PHP code below in a notepad.
2. Replace IP Address 1, IP Address 2, and IP Address 3 in the code below, with the spammers IP addresses you want block.
<?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
}
?>
3. Save the file with a .php extension for example (SpamIPblocker.php)
4. Then upload the new created PHP file on any PHP supported web hosting service. You can use any of these 000webhost.com or zymic.com.
5. Finally, you will need to paste the following code in your Blogspot blog using two methods.
<SCRIPT LANGUAGE='javascript'
SRC='BlogspotIPblocker.php' TYPE='text/
javascript'></SCRIPT>
METHOD 1:
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.
METHOD 2:
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 then Save the gadget. That's all
When the spammer or troll tries to visit your blog again, their IP addresses will be blocked.
First of all, you will need to know the IP address of that particular spammer or troll that is disturbing your site. And follow this instructions below.
1. You will have to copy and paste this PHP code below in a notepad.
2. Replace IP Address 1, IP Address 2, and IP Address 3 in the code below, with the spammers IP addresses you want block.
<?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
}
?>
3. Save the file with a .php extension for example (SpamIPblocker.php)
4. Then upload the new created PHP file on any PHP supported web hosting service. You can use any of these 000webhost.com or zymic.com.
5. Finally, you will need to paste the following code in your Blogspot blog using two methods.
<SCRIPT LANGUAGE='javascript'
SRC='BlogspotIPblocker.php' TYPE='text/
javascript'></SCRIPT>
METHOD 1:
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.
METHOD 2:
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 then Save the gadget. That's all
When the spammer or troll tries to visit your blog again, their IP addresses will be blocked.
No comments:
Post a Comment