Friday, August 28, 2009

How to block users from visiting your blogger

/ On : 7:21 AM/

Sometimes some people visit your blog and put spam comments to market thier sites or blog, these spam comments are a problem for bloggers. Note that most of these spam comments come from a certain IP address. This can be tracked using a tracker placed in your blog.There is a simple trick / hack to block users by thier IP address from visiting your blog by using JavaScript and PHP .

All you need to block users from visiting your blog:

1. Login into your Blogger Dashboard and choose Edit HTML.
2. Search on <head> tag.
3. Then add the following code at the beginning of your blog's <head> tag.

<script type="text/javascript" src=""></script>
<script type="text/javascript">
// Banned ip script 2.0
//(C)2009 Anhvo

var banned_ip = new Array();

banned_ip[0] = '85.142';
banned_ip[1] = '';
banned_ip[2] = '';
banned_ip[3] = '85.78';

var mes_bi = "Your IP is banned so you cannot visit this website!";

for(var i=0;i&lt;banned_ip.length;i++) {
eval('var re = /^' + banned_ip[i] + '/ ;');
if (re.test(mc_user_ip))
document.write('&lt;style type="text/css"&gt;');

Replace the IP ranges from the above code with the IPs of the visitors you want to keep out of your blog. Example: If you want to block all IPs in the range '11.22.XXX.XXX', simply add "11.22" as the IP number in the above code.

Related Posts:


seo greece said...

I was looking for this information through other sites but i found this information really helpful for me.

Post a Comment

Featured Video