View Full Version : need help w/blocking IP addresses
Erika
04-30-2005, 03:19 PM
Hi,
I use Blogger to run my weblog; I have to sign in to their site and all, directly. Anyway, it appears to be CSS coding in my template and I was wondering if there is any coding that I can add in to said template, that will block some IP addresses. I really don't now squat about this and my Google searches were incredibly confusing... It seems like a lot of people add the code to a directory, which I don't have as a Blogger user... Just my template. IS there another option that I could use?
Thanks, ahead of time! :)
jonra01
04-30-2005, 04:06 PM
Here's something that may work if they have javascript enabled, which they probably do. I don't know whether it will work on blogger, because it requires interaction with the server.
Copy and paste the script into the head of the page then change 'xxx.xxx.xxx.xxx' to their ip address. This script is only good for blocking one ip address. It would have to be modified if you wanted to block more than one. If you can't edit the head section of the page it can also be placed just after the opening body tag <body>
<script language="javascript" type="text/javascript">
<!--
var ip = '<!--#echo var="REMOTE_ADDR"-->';
if (ip == "xxx.xxx.xxx.xxx") {
alert("You are visiting this site from a blocked IP address " +ip);
window.location="http://www.aol.com"
}
// -->
</script>
John
Erika
04-30-2005, 04:33 PM
Thank you!! :D
What about the aol.com line at the end? Why is that there? Does that need modification on my behalf?
I should also mentioned that I just signed up for the free version of Movable Type/Type Pad. Hopefully they'll let me have more entensive IP blocking capabilities... :?
jonra01
04-30-2005, 04:53 PM
The aol reference is where the visitor is sent after the script checks their ip address. You can change this to anything you want as long as it is a valid web address.
John
webado
05-01-2005, 01:09 AM
The aol reference is where the visitor is sent after the script checks their ip address. You can change this to anything you want as long as it is a valid web address.
John
hmmmm... maybe even better if it's not a valid web adddresss .... gives them something to really cuss about :wink:
jonra01
05-01-2005, 02:11 AM
hmmmm... maybe even better if it's not a valid web adddresss .... gives them something to really cuss about
I thought about that, but since there is no error checking in this script I'm not sure they wouldn't just end up on a 404 page. If you really disliked them you could redirect them to a site like that one I posted the message about yesterday. :)
If you want to include more than one ip address you would change this in the script if (ip == "xxx.xxx.xxx.xxx" || ip == "xxx.xxx.xxx.xxx")
For those not familiar with JavaScript, the vertical bars ( || ) are called pipes. Two of them together like this stands for the OR operand in JavaScript. You could include a few ip addresses this way.
John
motorwatchercounter
05-01-2005, 05:29 PM
Send them to a site that you know contains trojans if you really don't like them.
Erika
05-26-2005, 10:57 PM
Thanks; now I know how to ban multiple addresses. :D
motorwatchercounter
07-07-2005, 08:51 AM
Do you have access to a control panel with IP deny or access to allow a .htaccess file?
webado
07-07-2005, 09:27 AM
Are you able to see that script exactly as entered in the body of your blog when you view the source?
You should post a link to your blog so we can take a look.
It's of course also possible that the visitor you are trying to ban has a different Ip address from what you are trying to block.
awaddington
07-07-2005, 02:47 PM
Did you place your redirect code before or after your statcounter code?
if your statcounter code comes first then they will probably register as a hit even if your redirect works.
Just a thought.
Cheers
jonra01
07-07-2005, 05:46 PM
Test the script by entering your IP address in the script.
colemic
12-16-2005, 10:14 PM
Hi, I inserted this code, and used my IP address, but it is still not working for me.
If anyone can view it, and tell me what I am doing wrong, please help me out. (It's blogger also, so no htaccess, just a template.)
http://www.thebatchelorchronicles.blogspot.com
Also, can someone please tell me why my profile, links, and archives are beneath the blog entries? It just moved there, all by it's own, I didn't mess with any part of that.
Thanks for your help guys and gals.
webado
12-16-2005, 11:05 PM
Well the right side moved because of whatever you did to the template to shift elements which were placed there precisely.
You can fix that right away by taking the Statcounter code and putting ti right at the bottom just before the </body> tag.
If you want it to show up in that particular footer you'll have to be more careful where exactly you insert it into the html.
Edit your template and select all the contents to your clipboard. Open Notepad and paste it all in. The save the file with some name like blog-template.html , in a folder where you will find it again.
Using Windows Explorere go to that folder, find your file and double click it. It will open up pretty much the way the blog would, without the actual content, but you'll see markers of where each module goes. You can now play with it on your pc until it looks OK. Never lose the original one though, make a copy.
Once you like how the templaet looks, go abck to the blog, edit the template and repalce all the contents of the template with the contents of your file you have just created and fixed : blog-template.html .
You can always preview the blog, no need to publish it. If you're happy, then publish.
jonra01
12-16-2005, 11:53 PM
Where and how did you insert the script? It doesn't show when I do a view source of the page.
webado
12-17-2005, 03:19 AM
It's in the footer div.
But then the entire right side shifted out from it spot and dropped below, in good css fashin, as something must have overflowed its bounds :-D
jonra01
12-17-2005, 07:16 AM
I'm talking about the ip blocking script not the statcounter script. I still don't see it.
webado
12-17-2005, 07:27 AM
Hmm.... I guess the thread kind of unravelled over the months. At least I lost its head .... or mine?
LOL!
Anyway, it's there but I think in the wrong place or not the best place, before the title:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script language="javascript" type="text/javascript">
<!--
var ip = '<!--#echo var="REMOTE_ADDR"-->';
if (ip == "81.34.105.35") {
alert("You are visiting this site from a blocked IP address " +ip);
window.location="http://www.aol.com"
}
// -->
</script>
<title>P2Q</title>
...
Oh, it was not even correct. You have to first get the IP address and then compare with the one you want to block. The red portion was missing. I think it got lost in the forum conversion may?
jonra01
12-17-2005, 05:25 PM
That explains why it wasn't working. Good eye, Christina. :)
webado
12-17-2005, 05:32 PM
Yeah, this forum conversion has made a hash of lots of posts. Phpbb has a [ code ] bbcode but I personally didn't like it since it didn't allow using colors for emphasis, plus it stretched the page horizontally. So anything not in [ code ] got reinterpreted, and that particular construct dropped as probbaly it wouldn't be allowed to be entered other than in an [html ] bbcode construct. This together with url's that got parsed automatically in text... Grrr... :lol:
jonra01
12-17-2005, 05:56 PM
Yeah, this forum conversion has made a hash of lots of posts.
Oh, that's not good. :( I wonder how many code samples have been ruined by the conversion?
webado
12-17-2005, 11:02 PM
Oh, that's not good. :( I wonder how many code samples have been ruined by the conversion?
At a guess? All of them to some extent. Any url for sure, so all snippets including Statcounter code will not be easily readable, if at all.
However we still have access to the old forum so in a real bind we can get the information from there somehow.
jonra01
12-17-2005, 11:19 PM
that doesn't help anyone who is visiting the forum who tries to use one of those old code snippets.
webado
12-18-2005, 12:09 AM
Well, if they really need it and can't figure it out otherwise, they'll post asking why this doesn't work.
I have now fixed that one (yours) and the one (mine) in the thread on MySpace that fell victim to the same thing.
Nethervue
02-02-2006, 02:46 PM
Hi,
I was wondering if this got resolved or not. I also have a blogger site (http://themorencys.com) and there is one guy coming from an IP that accesses the site multiple times a day. I have no idea who this guy is and I want to block him. This is a family type site with pics and such, I don't want some wacko accessing it.
Can someone help? I tries that snippet of code, its inserted directly under the opening body tag. I have tried it in other spots as well, no luck.
Hope you can help!
Thanks
webado
02-02-2006, 04:22 PM
In Blogspot I think you cannot do it, as it doesn't create pages that support SSI. Or else you didn't insert the code in the template at the proper place.
jonra01
02-02-2006, 04:34 PM
The script should go in the head not in the body. Try that and let me know how it works.
Brisguy52
02-02-2006, 05:04 PM
<script language="javascript" type="text/javascript">
<!--
var ip = '<!--#echo var="REMOTE_ADDR"-->';
if (ip == "xxx.xxx.xxx.xxx") {
alert("You are visiting this site from a blocked IP address " +ip);
window.location="http://www.aol.com"
}
// -->
</script>
John
If you wanna block stealthed IP addy's you can replace this -
if (ip == "xxx.xxx.xxx.xxx")
with this -
if (!ip)
was thinking about something else while posting this
Nethervue
02-02-2006, 05:10 PM
Hi,
Didn't seem to work, tested with my IP. Here is the code I used, maybe I missed something:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script language="javascript" type="text/javascript">
<!--
var ip = '<!--#echo var="REMOTE_ADDR"-->';
if (ip == "64.5.232.11") {alert("You are visiting this site from a blocked IP address " +ip);
window.location="http://www.aol.com"
}
// -->
</script>
Brisguy52
02-02-2006, 05:26 PM
Just tried it myself, worked fine in a .shtml page
jonra01
02-02-2006, 05:48 PM
Have you got javascript disabled?
I'm just about to leave the house so I won't be able to test it for 6-7 hours. If you want to wait that long go ahead and set it to my ip address - 69.246.77.246 - and I'll give it a try when I get home.
webado
02-02-2006, 05:56 PM
The Blogspot page is http://morencyj.blogspot.com/index.html - for it to work it would have to be http://morencyj.blogspot.com/index.shtml in order to support SSI.
Nethervue
02-02-2006, 06:00 PM
Hi,
Its a Blogger site, I'm not able to change much within the template. If you go to http://themorencys.com you will see what it looks like.
Brisguy52
02-02-2006, 06:02 PM
If the referer is always the same perhaps you could use something like -
<script language="javascript" type="text/javascript">
var goaway = document.referrer
if (goaway=="their referer") window.location = "http://www.buggeroff.com";
</script>
Nethervue
02-02-2006, 06:04 PM
So I guess there's no way of blocking this guy? Oh well. He..or she..has been accessing this page at least 4/5 times a day for the last few months. Really weird. The IP is coming from someone in the same city that I am in. If you go to Remote Desktop Connection in Win XP and paste in 70.25.33.179, it will bring up the guys PC.
I have a stalker....
Nethervue
02-02-2006, 06:08 PM
If the referer is always the same perhaps you could use something like -
<script language="javascript" type="text/javascript">
var goaway = document.referrer
if (goaway=="their referer") window.location = "http://www.buggeroff.com";
</script>
In that code, where do I specify his IP? Sorry, not to familar with Java!!
webado
02-02-2006, 06:11 PM
No IP is specified there. That cannot be used.
Brisguy52
02-02-2006, 06:19 PM
........................... If you go to Remote Desktop Connection in Win XP and paste in 70.25.33.179, it will bring up the guys PC.
OOOOHHHHHHHHHHHHHH the temptation :evil:
With that referer script, if you can only block this person by their IP, then as Chis said it's no use to you. I was just clutching at straws for an alternative.
Nethervue
02-02-2006, 06:24 PM
OOOOHHHHHHHHHHHHHH the temptation :evil:
With that referer script, if you can only block this person by their IP, then as Chis said it's no use to you. I was just clutching at straws for an alternative.
Tempting indeed!! I did try to login as local admin, no luck. If the guy was in another part of the world, I wouldn't care...but where he is in the same city and the fact that he is on my site more than I am, it freaks me out. I have a lot of pics of my family, etc.
Nethervue
02-02-2006, 06:33 PM
Well, I just put a post on my site asking 70.25.33.179 to please send me an e-mail. See if he does or not.
I appreciate everyones help in trying to block this guy!!
jonra01
02-03-2006, 01:15 AM
I guess the instructions for this script aren't very good. I did mention in the first post that it had to interact with the server, but didn't explain what this meant. As Christina said, the script must be on an SSI page. In most cases this would be a .shtml page. The only way to do this with a blogspot blog is if you put the pages on a server with another isp. This would allow you to rename the index file to index.shtml. There isn't really any alternative method to block ip addresses. If you are on your own hosting you can do the same with a .htaccess file, which would be a better solution than using a script.
christymarie
08-15-2006, 03:43 PM
there is a person who is not very nice who accesses my blog and a friend of mine's blog too ... i would like to block her but based on this thread, i'm guessing that is not possible
am i correct in assuming that?
webado
08-15-2006, 03:44 PM
Correct, not in a blog hosted on Blogspot, as you have no control.
You dont' have to open yoru blog to comments, you know. Not if you're worried about bad comments. Otherwise just keep on cleaning them up.
Once you put a page up on the net it is publicly viewable so you have to expect good and bad people will view it and that shouldn't bother you. if you allow people to post comments then you open your blog to anything including possible hacking. Your choice.
wingkun
08-17-2006, 07:54 AM
FWIW, the next revision of Blogger will allow its users some access control: not by blocking IPs but by allowing you to take your blog private/invitation only. Details here (http://buzz.blogger.com/2006/08/blogger-in-beta.html)
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.