StatCounter User Forum  
StatCounter Free web tracker and counter

Go Back   StatCounter User Forum > StatCounter.com > Help

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2006, 02:56 AM
Dana Dana is offline
Junior Member
 
Join Date: Jan 2006
Posts: 11
Question Block an IP (not MySpace)

HI I tried following instructions from this thread:

http://forum.statcounter.com/vb/show...hlight=myspace

but I am having a problem following. I am new to HTML code and don't know all the rules.

I am trying to block someone from a personal homepage - not myspace. I want them to be redirected elsewhere. I used this code highlighted in blue to show you. I used it EXACTLY like this, spaces and all. Each line exactly the way it appears. Is this correct?

<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>


I attempted to block my own IP first to see if it would work. Nothing. I am using Frontpage and I placed the code up top under the <body> section. Above that I have the head and title sections. There is no template, just what I made with tables and text in the "normal" view. I also have the stat counter (invisible) on the same page. The code is inserted near the bottom and it is working perfectly for me. Any guidance would be very much appreciated.

~Dana~
Reply With Quote
  #2  
Old 01-05-2006, 03:07 AM
webado's Avatar
webado webado is offline
Moderator
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada
Posts: 28,147
Default

That script goes after the <head> tag, and before the </head> tag. Not in the body section.

Make sure you're not using design mode or layout mode. It has to be code view mode, source code mode or html mode - whatever it may be called in Frontpage.

But another problem you'll have is that this script requires that the page where you use it has to be suffixed by .shtml not .html , because it uses a SSI (server side include) directive. The server only interprets that at all if the file is suffixed by .shtml .
__________________
Christina
>>Forum Moderator<<

Please do not PM me for support. The forum is here for that.
Reply With Quote
  #3  
Old 01-05-2006, 01:02 PM
Dana Dana is offline
Junior Member
 
Join Date: Jan 2006
Posts: 11
Default

Thanks so much! I will try that out. I hope I do it right
Reply With Quote
  #4  
Old 01-10-2006, 11:38 PM
Dana Dana is offline
Junior Member
 
Join Date: Jan 2006
Posts: 11
Default

I have tried this out on my IP, and it works as far as blocking goes, but rather than getting redirected to the designated webpage, I get this message:

Directory Listing Denied
This Virtual Directory does not allow contents to be listed.


Is there something I am doing wrong or is there another way to have the blocked user redirected to another website - for example, the online dictionary definition of "stalker"? Thanks for your help!

Another question, will statcounter log whether or not this person continues to try to access my page if they are blocked?

Last edited by Dana; 01-10-2006 at 11:40 PM.
Reply With Quote
  #5  
Old 01-11-2006, 12:12 AM
webado's Avatar
webado webado is offline
Moderator
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada
Posts: 28,147
Default

Quote:
Originally Posted by Dana
I have tried this out on my IP, and it works as far as blocking goes, but rather than getting redirected to the designated webpage, I get this message:

Directory Listing Denied
This Virtual Directory does not allow contents to be listed.


Is there something I am doing wrong or is there another way to have the blocked user redirected to another website - for example, the online dictionary definition of "stalker"? Thanks for your help!

Another question, will statcounter log whether or not this person continues to try to access my page if they are blocked?
Well, where are you redirecting that visitor from the banned ip address? It has to be a proper url somewhere, the way you'd use it in the address bar of the browser (with http:// in front).

That visit won't get logged actually since the script happens before the rest of the page loads. You cannot place that script elsewhere though , as it will give an error, redirection has to happen before anything of the page is output by html.
__________________
Christina
>>Forum Moderator<<

Please do not PM me for support. The forum is here for that.
Reply With Quote
  #6  
Old 01-11-2006, 12:38 AM
Dana Dana is offline
Junior Member
 
Join Date: Jan 2006
Posts: 11
Default

LOL okay I am literally trying to redirect the deranged visitor to this site: http://www.urbandictionary.com/define.php?term=Mental

Can I just paste it in there? Do I need to add a hyperlink to that?

Thanks so much for your help!!!
Reply With Quote
  #7  
Old 01-11-2006, 12:43 AM
webado's Avatar
webado webado is offline
Moderator
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada
Posts: 28,147
Default

It has to simply be used in place of the aol url from the earlier example.

[html]
<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.urbandictionary.com/define.php?term=Mental";
}
// -->
</script>
[/html]

Of course this won't ever work for a visitor with a javascript disabled browser.

And dont' remember you need to save yoru page as .shtml as it is using an SSI construct.
__________________
Christina
>>Forum Moderator<<

Please do not PM me for support. The forum is here for that.

Last edited by webado; 01-11-2006 at 12:47 AM.
Reply With Quote
  #8  
Old 01-11-2006, 12:45 PM
Dana Dana is offline
Junior Member
 
Join Date: Jan 2006
Posts: 11
Default

Chrisoc, thank you so much for your help! I really appreciate it!!!

Okay, when trying it out yesterday afternoon, I saved as a .shtml and blocked my own IP. I was blocked, just not redirected. That is when I wrote back in the forum asking if I was doing something wrong because I was not getting redirected to the designated site. I wondered if I had the spacing messed up. I pasted the new address right over the AOL address from the sample. Can you think of anything crucial that would prevent that redirection from working? From the things you have mentioned, I believe I have gotten them taken care of. BTW, have you ever tried to block & redirect anyone?

According to statcounter, the visitor has Java enabled. I also have Java enabled and pretty much have the same set up as the visitor that I want to block and send elsewhere.

When I blocked myself, I did not get the message in quotes on the code. Is this "You are visiting this site from a blocked IP address " supposed to appear as well? Before I block the actual person, I am hoping to try it out and see exactly what they will see.
Reply With Quote
  #9  
Old 01-11-2006, 02:02 PM
webado's Avatar
webado webado is offline
Moderator
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada
Posts: 28,147
Default

I don't know how you actually did it.
Here's what I'm doing (and make sure the IP address you are testing with is correct at that moment - to be used instead of 255.255.255.255 which is below):

[html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="EN">
<head>
<title>To ban or not to ban</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript" type="text/javascript">
var ip = '<!--#echo var="REMOTE_ADDR"-->';

if (ip =='255.255.255.255') {
alert("You are visiting this site from a blocked IP address " +ip);
window.location="http://www.urbandictionary.com/define.php?term=Mental";
}

</script>

</head>

<body bgcolor="#FFFFFF" text="#000000">


<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center"><b>Page content here.</b></p>

</body>
</html>
[/html]

For the ip address substitute the one you have at the moment you are testing.
Also for the page to redirect to use a url of your own, either on your website or somewhere else (just not mine please ) Here I used the one you wanted to use.

But as I said, if the visitor does not have javascript enabled, the redirection will not happen.
__________________
Christina
>>Forum Moderator<<

Please do not PM me for support. The forum is here for that.

Last edited by webado; 01-11-2006 at 02:07 PM.
Reply With Quote
  #10  
Old 10-18-2006, 07:40 AM
nowhere500 nowhere500 is offline
Junior Member
 
Join Date: Oct 2006
Posts: 1
Default full site

This code worked for me but the only problem is that I'm using blogger, generating a new page every time I post to my blog. I've blocked my stalker from my index page. I'm wondering if there's a way to block my stalker from accessing every page of my website.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:23 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.