How to block IP address in a guestbook?

Discussion in 'ASP General' started by pcchong, May 19, 2004.

  1. pcchong

    pcchong Guest

    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
    pcchong, May 19, 2004
    #1
    1. Advertising

  2. pcchong

    PW Guest

    "pcchong" <> wrote in message
    news:...
    > 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
    %>
    PW, May 19, 2004
    #2
    1. Advertising

  3. pcchong

    Roland Hall Guest

    "pcchong" wrote in message news:...
    : 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
    Roland Hall, May 19, 2004
    #3
  4. pcchong

    Jeff Cochran Guest

    On Wed, 19 May 2004 19:29:20 +0800, "PW" <>
    wrote:

    >
    >"pcchong" <> wrote in message
    >news:...
    >> 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
    Jeff Cochran, May 19, 2004
    #4
  5. pcchong

    pcchong Guest

    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" <> wrote in message
    news:...
    >
    > "pcchong" <> wrote in message
    > news:...
    > > 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
    > %>
    >
    >
    pcchong, May 19, 2004
    #5
  6. 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" <> wrote in message
    > news:...
    >>
    >> "pcchong" <> wrote in message
    >> news:...
    >>> 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.
    Bob Barrows [MVP], May 19, 2004
    #6
  7. pcchong

    pcchong Guest

    Thanks. This is a better way.


    pcchong

    "Bob Barrows [MVP]" <> wrote in message
    news:...
    > 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" <> wrote in message
    > > news:...
    > >>
    > >> "pcchong" <> wrote in message
    > >> news:...
    > >>> 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.
    >
    >
    pcchong, May 20, 2004
    #7
  8. pcchong

    pcchong Guest

    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]" <> wrote in message
    news:...
    > 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" <> wrote in message
    > > news:...
    > >>
    > >> "pcchong" <> wrote in message
    > >> news:...
    > >>> 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.
    >
    >
    pcchong, May 21, 2004
    #8
  9. pcchong

    Jeff Cochran Guest

    On Fri, 21 May 2004 21:53:32 +0800, "pcchong" <>
    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]" <> wrote in message
    >news:...
    >> 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" <> wrote in message
    >> > news:...
    >> >>
    >> >> "pcchong" <> wrote in message
    >> >> news:...
    >> >>> 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.
    >>
    >>

    >
    Jeff Cochran, May 21, 2004
    #9
  10. pcchong

    pcchong Guest

    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" <> wrote in message
    news:...
    > On Fri, 21 May 2004 21:53:32 +0800, "pcchong" <>
    > 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]" <> wrote in message
    > >news:...
    > >> 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" <> wrote in message
    > >> > news:...
    > >> >>
    > >> >> "pcchong" <> wrote in message
    > >> >> news:...
    > >> >>> 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.
    > >>
    > >>

    > >

    >
    pcchong, May 22, 2004
    #10
  11. Are you sure the offender has an ip that should be blocked by this
    statement? How are you verifying this?

    Are you sure Request.ServerVariables("REMOTE_ADDR") contains that ip
    address? How are you verifying this?

    Bob Barrows
    pcchong wrote:
    > 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" <> wrote in message
    > news:...
    >> On Fri, 21 May 2004 21:53:32 +0800, "pcchong"
    >> <> 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.

    >>

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], May 22, 2004
    #11
  12. pcchong

    pcchong Guest

    I can see his IP from the guestbook. I tested this filter using my IP
    address and it worked, that is why I am so puzzled. I would appreciate it if
    you could suggest how I can verify the IP. Many thanks again.

    pcchong

    "Bob Barrows [MVP]" <> wrote in message
    news:eZsbRP$...
    > Are you sure the offender has an ip that should be blocked by this
    > statement? How are you verifying this?
    >
    > Are you sure Request.ServerVariables("REMOTE_ADDR") contains that ip
    > address? How are you verifying this?
    >
    > Bob Barrows
    > pcchong wrote:
    > > 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" <> wrote in message
    > > news:...
    > >> On Fri, 21 May 2004 21:53:32 +0800, "pcchong"
    > >> <> 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.
    > >>

    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
    pcchong, May 23, 2004
    #12
  13. pcchong

    PW Guest

    "pcchong" <> wrote in message
    news:%...
    > I can see his IP from the guestbook. I tested this filter using my IP
    > address and it worked, that is why I am so puzzled. I would appreciate it

    if
    > you could suggest how I can verify the IP. Many thanks again.



    Perhaps you enemy is bypassing the initial (menu?) ASP and going straight to
    the guestbook ASP. Move the new code from your initial (menu) ASP over to
    the page where you insert the guestbook information into your database.
    That way, you enemy will be able to type in a post, but it won't get written
    to your database, and therefore no one will ever see it.

    HTH,
    PW
    PW, May 23, 2004
    #13
  14. pcchong

    Evertjan. Guest

    PW wrote on 23 mei 2004 in microsoft.public.inetserver.asp.general:

    > "pcchong" <> wrote in message
    > news:%...
    >> I can see his IP from the guestbook. I tested this filter using my IP
    >> address and it worked, that is why I am so puzzled. I would
    >> appreciate it

    > if
    >> you could suggest how I can verify the IP. Many thanks again.

    >
    >
    > Perhaps you enemy is bypassing the initial (menu?) ASP and going
    > straight to the guestbook ASP. Move the new code from your initial
    > (menu) ASP over to the page where you insert the guestbook information
    > into your database. That way, you enemy will be able to type in a
    > post, but it won't get written to your database, and therefore no one
    > will ever see it.
    >


    why not block both pages?

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., May 23, 2004
    #14
  15. pcchong

    pcchong Guest

    Yes, you are right. Instead of just put the filter in the index(first) file,
    I should put it also in the other input files. Problem solved. Many many
    thanks to everyone.

    pcchong

    "Evertjan." <> wrote in message
    news:Xns94F2545D081F3eejj99@194.109.133.29...
    > PW wrote on 23 mei 2004 in microsoft.public.inetserver.asp.general:
    >
    > > "pcchong" <> wrote in message
    > > news:%...
    > >> I can see his IP from the guestbook. I tested this filter using my IP
    > >> address and it worked, that is why I am so puzzled. I would
    > >> appreciate it

    > > if
    > >> you could suggest how I can verify the IP. Many thanks again.

    > >
    > >
    > > Perhaps you enemy is bypassing the initial (menu?) ASP and going
    > > straight to the guestbook ASP. Move the new code from your initial
    > > (menu) ASP over to the page where you insert the guestbook information
    > > into your database. That way, you enemy will be able to type in a
    > > post, but it won't get written to your database, and therefore no one
    > > will ever see it.
    > >

    >
    > why not block both pages?
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
    pcchong, May 23, 2004
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John ©
    Replies:
    5
    Views:
    4,540
    Skeleton Man
    Jun 24, 2004
  2. Oded Dror

    Guestbook Problems

    Oded Dror, Jan 31, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,524
    Juan T. Llibre
    Jan 31, 2006
  3. Johan

    guestbook

    Johan, Jul 22, 2003, in forum: HTML
    Replies:
    3
    Views:
    12,641
    Davmagic com
    Jul 22, 2003
  4. NK

    guestbook results

    NK, Aug 31, 2003, in forum: HTML
    Replies:
    3
    Views:
    1,274
    David Dorward
    Sep 1, 2003
  5. morrell
    Replies:
    1
    Views:
    933
    roy axenov
    Oct 10, 2006
Loading...

Share This Page