Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2011
    Thanked 0 Times in 0 Posts

    How to block out a div for a certain IP address

    I have to block out a certain div for a certain IP addresss
    I am using asp here is the code:

        Dim sBlockedIP
        sBlockedIP = Request.ServerVariables("REMOTE_ADDR")
        'check if the IP is the one that is blocked
        If sBlockedIP = "" Then
        'if IP address is banned then redirect to no_access.asp
        Response.Redirect "no_access.asp"
        End If
    this is the html that needs to be blocked to this IP

      <div id="social_media_outer">
          <div id="social_media">
          <div id="fb-root"> <script src="#">
          </script><fb:like href="" send="true" layout="button_count" show_faces="false" action="recommend" border="6" font="">
          <span  class='st_linkedin' >
          <span  class='st_facebook' >
          <span  class='st_sharethis' st_title="#"></span>
          <a href="http://twitter.com/share" data-count="none"><img src="#" style="position:relative;
          bottom:-4px; border:none;" /></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><span class="st_email" ></span>
          <a href="javascript:print(document)"><img src="http://www.gosh.org/facebook/sharethis/print_icon.gif" style="position:relative;
          bottom:-4px; border:none;" /></a>
    Can someone help please.

  2. #2
    Senior Coder
    Join Date
    Dec 2002
    Arlington, Texas USA
    Thanked 11 Times in 11 Posts
    When I do something similar is I create a file with the asp code in it and nothing else.

    Then I use it as an include file

    However, if you only want to block certain content then you do NOT want to do the redirect because then you are blocking the entire page. So instead of having the redirect you can create a boolean value that is checked

        Dim sBlockedIP
        Dim boolBlocked
        sBlockedIP = Request.ServerVariables("REMOTE_ADDR")
        'check if the IP is the one that is blocked
        If sBlockedIP = "" Then
             boolBlocked = True
        End If
    Next you will have in the page the part to block
    <%If Not boolBlocked Then%>
        some html to display
    <%End If%>
    Last edited by miranda; 05-23-2012 at 06:43 PM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts