Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > How to block IP address in a guestbook?

Reply
Thread Tools

How to block IP address in a guestbook?

 
 
pcchong
Guest
Posts: n/a
 
      05-19-2004
I use a free database-driven ASP guestbook. I want to add a IP address
blocking filter to it( just to block one particular guest). What is the
easiest way to do so? Thanks.

pcchong


 
Reply With Quote
 
 
 
 
PW
Guest
Posts: n/a
 
      05-19-2004

"pcchong" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I use a free database-driven ASP guestbook. I want to add a IP address
> blocking filter to it( just to block one particular guest). What is the
> easiest way to do so? Thanks.



Put this at the beginning of the first ASP (change "111.222.333" to your
enemys IP address) ...

<%
if Request.ServerVariables("REMOTE_ADDR") = "111.222.333" then
Response.End
end if
%>


 
Reply With Quote
 
 
 
 
Roland Hall
Guest
Posts: n/a
 
      05-19-2004
"pcchong" wrote in message news:(E-Mail Removed)...
: I use a free database-driven ASP guestbook. I want to add a IP address
: blocking filter to it( just to block one particular guest). What is the
: easiest way to do so? Thanks.

I don't know where you're coming from [IP address] so you would have to
modify this but directions are included. I'm redirecting everyone as an
example. Modify the appropriate lines and then put this at the top of your
page where you want to block someone. However, if their IP is dynamic, then
you'd need to modify it to block IP ranges.

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
dim outtahair, visitor, strURL
strURL = "http://www.fbi.gov/mostwant.htm" ' modify this line for target
redirect host
outtahair = Request.ServerVariables("REMOTE_HOST")
' Delete the line above and uncomment the one below replacing x.x.x.x with
IP to redirect
' outtahair = "x.x.x.x"
visitor = Request.ServerVariables("REMOTE_HOST")
if visitor = outtahair then
Response.Clear()
Response.Redirect(strURL)
end if
%>

http://kiddanger.com/lab/remotehostredirect.asp

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


 
Reply With Quote
 
Jeff Cochran
Guest
Posts: n/a
 
      05-19-2004
On Wed, 19 May 2004 19:29:20 +0800, "PW" <(E-Mail Removed)>
wrote:

>
>"pcchong" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> I use a free database-driven ASP guestbook. I want to add a IP address
>> blocking filter to it( just to block one particular guest). What is the
>> easiest way to do so? Thanks.

>
>
>Put this at the beginning of the first ASP (change "111.222.333" to your
>enemys IP address) ...
>
><%
>if Request.ServerVariables("REMOTE_ADDR") = "111.222.333" then
> Response.End
>end if
>%>


Better would be to check the address and if it's not allowed, simply
not update the guestbook. Let them go through the process, thank them
for their entry, just don't record it.

Jeff
 
Reply With Quote
 
pcchong
Guest
Posts: n/a
 
      05-19-2004
Thanks. It works for specific IP, but what if it is a IP range, say
210.187.176.# to 210.187.176.### . How do I change the line? Thanks.


pcchong

"PW" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "pcchong" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I use a free database-driven ASP guestbook. I want to add a IP address
> > blocking filter to it( just to block one particular guest). What is the
> > easiest way to do so? Thanks.

>
>
> Put this at the beginning of the first ASP (change "111.222.333" to your
> enemys IP address) ...
>
> <%
> if Request.ServerVariables("REMOTE_ADDR") = "111.222.333" then
> Response.End
> end if
> %>
>
>



 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      05-19-2004
Use Instr(), or a Regular Expression.

Instr():

dim sIP
sIP = Request.ServerVariables("REMOTE_ADDR")

if Instr(sIP, "111.222.333") > 0 then

For more complicated patterns, you should use a Regular Expression.

Bob Barrows

pcchong wrote:
> Thanks. It works for specific IP, but what if it is a IP range, say
> 210.187.176.# to 210.187.176.### . How do I change the line? Thanks.
>
>
> pcchong
>
> "PW" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>
>> "pcchong" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> I use a free database-driven ASP guestbook. I want to add a IP
>>> address blocking filter to it( just to block one particular guest).
>>> What is the easiest way to do so? Thanks.

>>
>>
>> Put this at the beginning of the first ASP (change "111.222.333" to
>> your enemys IP address) ...
>>
>> <%
>> if Request.ServerVariables("REMOTE_ADDR") = "111.222.333" then
>> Response.End
>> end if
>> %>


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
pcchong
Guest
Posts: n/a
 
      05-20-2004
Thanks. This is a better way.


pcchong

"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Use Instr(), or a Regular Expression.
>
> Instr():
>
> dim sIP
> sIP = Request.ServerVariables("REMOTE_ADDR")
>
> if Instr(sIP, "111.222.333") > 0 then
>
> For more complicated patterns, you should use a Regular Expression.
>
> Bob Barrows
>
> pcchong wrote:
> > Thanks. It works for specific IP, but what if it is a IP range, say
> > 210.187.176.# to 210.187.176.### . How do I change the line? Thanks.
> >
> >
> > pcchong
> >
> > "PW" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >>
> >> "pcchong" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >>> I use a free database-driven ASP guestbook. I want to add a IP
> >>> address blocking filter to it( just to block one particular guest).
> >>> What is the easiest way to do so? Thanks.
> >>
> >>
> >> Put this at the beginning of the first ASP (change "111.222.333" to
> >> your enemys IP address) ...
> >>
> >> <%
> >> if Request.ServerVariables("REMOTE_ADDR") = "111.222.333" then
> >> Response.End
> >> end if
> >> %>

>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>



 
Reply With Quote
 
pcchong
Guest
Posts: n/a
 
      05-21-2004
My joy is shortlived. This guest still managed to enter with the same IP
(within the IP range that the IP blocking filter set). How can he get
through? Thanks.

pcchong

"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Use Instr(), or a Regular Expression.
>
> Instr():
>
> dim sIP
> sIP = Request.ServerVariables("REMOTE_ADDR")
>
> if Instr(sIP, "111.222.333") > 0 then
>
> For more complicated patterns, you should use a Regular Expression.
>
> Bob Barrows
>
> pcchong wrote:
> > Thanks. It works for specific IP, but what if it is a IP range, say
> > 210.187.176.# to 210.187.176.### . How do I change the line? Thanks.
> >
> >
> > pcchong
> >
> > "PW" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >>
> >> "pcchong" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >>> I use a free database-driven ASP guestbook. I want to add a IP
> >>> address blocking filter to it( just to block one particular guest).
> >>> What is the easiest way to do so? Thanks.
> >>
> >>
> >> Put this at the beginning of the first ASP (change "111.222.333" to
> >> your enemys IP address) ...
> >>
> >> <%
> >> if Request.ServerVariables("REMOTE_ADDR") = "111.222.333" then
> >> Response.End
> >> end if
> >> %>

>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>



 
Reply With Quote
 
Jeff Cochran
Guest
Posts: n/a
 
      05-21-2004
On Fri, 21 May 2004 21:53:32 +0800, "pcchong" <(E-Mail Removed)>
wrote:

>My joy is shortlived. This guest still managed to enter with the same IP
>(within the IP range that the IP blocking filter set). How can he get
>through? Thanks.


Good question. But what did you do with Bob's code? Are you sure
you're blocking that IP and not just checking to see what it is?

Jeff

>"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> Use Instr(), or a Regular Expression.
>>
>> Instr():
>>
>> dim sIP
>> sIP = Request.ServerVariables("REMOTE_ADDR")
>>
>> if Instr(sIP, "111.222.333") > 0 then
>>
>> For more complicated patterns, you should use a Regular Expression.
>>
>> Bob Barrows
>>
>> pcchong wrote:
>> > Thanks. It works for specific IP, but what if it is a IP range, say
>> > 210.187.176.# to 210.187.176.### . How do I change the line? Thanks.
>> >
>> >
>> > pcchong
>> >
>> > "PW" <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> >>
>> >> "pcchong" <(E-Mail Removed)> wrote in message
>> >> news:(E-Mail Removed)...
>> >>> I use a free database-driven ASP guestbook. I want to add a IP
>> >>> address blocking filter to it( just to block one particular guest).
>> >>> What is the easiest way to do so? Thanks.
>> >>
>> >>
>> >> Put this at the beginning of the first ASP (change "111.222.333" to
>> >> your enemys IP address) ...
>> >>
>> >> <%
>> >> if Request.ServerVariables("REMOTE_ADDR") = "111.222.333" then
>> >> Response.End
>> >> end if
>> >> %>

>>
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get a
>> quicker response by posting to the newsgroup.
>>
>>

>


 
Reply With Quote
 
pcchong
Guest
Posts: n/a
 
      05-22-2004
I place this in the beginning of the first asp:

<%
dim sIP
sIP = Request.ServerVariables("REMOTE_ADDR")
if Instr(sIP, "###.###.###") > 0 then
Response.End
end if
%>

Anything wrong? Please advise. Thanks.

pcchong

"Jeff Cochran" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Fri, 21 May 2004 21:53:32 +0800, "pcchong" <(E-Mail Removed)>
> wrote:
>
> >My joy is shortlived. This guest still managed to enter with the same IP
> >(within the IP range that the IP blocking filter set). How can he get
> >through? Thanks.

>
> Good question. But what did you do with Bob's code? Are you sure
> you're blocking that IP and not just checking to see what it is?
>
> Jeff
>
> >"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
> >news:(E-Mail Removed)...
> >> Use Instr(), or a Regular Expression.
> >>
> >> Instr():
> >>
> >> dim sIP
> >> sIP = Request.ServerVariables("REMOTE_ADDR")
> >>
> >> if Instr(sIP, "111.222.333") > 0 then
> >>
> >> For more complicated patterns, you should use a Regular Expression.
> >>
> >> Bob Barrows
> >>
> >> pcchong wrote:
> >> > Thanks. It works for specific IP, but what if it is a IP range, say
> >> > 210.187.176.# to 210.187.176.### . How do I change the line? Thanks.
> >> >
> >> >
> >> > pcchong
> >> >
> >> > "PW" <(E-Mail Removed)> wrote in message
> >> > news:(E-Mail Removed)...
> >> >>
> >> >> "pcchong" <(E-Mail Removed)> wrote in message
> >> >> news:(E-Mail Removed)...
> >> >>> I use a free database-driven ASP guestbook. I want to add a IP
> >> >>> address blocking filter to it( just to block one particular guest).
> >> >>> What is the easiest way to do so? Thanks.
> >> >>
> >> >>
> >> >> Put this at the beginning of the first ASP (change "111.222.333" to
> >> >> your enemys IP address) ...
> >> >>
> >> >> <%
> >> >> if Request.ServerVariables("REMOTE_ADDR") = "111.222.333" then
> >> >> Response.End
> >> >> end if
> >> >> %>
> >>
> >> --
> >> Microsoft MVP -- ASP/ASP.NET
> >> Please reply to the newsgroup. The email account listed in my From
> >> header is my spam trap, so I don't check it very often. You will get a
> >> quicker response by posting to the newsgroup.
> >>
> >>

> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Fo:Block can you check to see if a block contains any text by using the block id? morrell XML 1 10-10-2006 07:18 PM
Problem with enterprise application block - data block Showjumper ASP .Net 1 03-19-2005 03:48 PM
Block DIV within a block DIV? Noozer HTML 3 01-06-2005 10:24 PM



Advertisments