Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    16
    Thanks
    0
    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:

    Code:
        <%
        Dim sBlockedIP
        sBlockedIP = Request.ServerVariables("REMOTE_ADDR")
        'check if the IP is the one that is blocked
        If sBlockedIP = "00.000.00.00" 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

    Code:
      <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="">
          </fb:like>
          <span  class='st_linkedin' >
          </span></span>
          <span  class='st_facebook' >
          </span>
          <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>
    
     </div>
    </div>
    </div>
    Can someone help please.

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 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

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