SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    HTML 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. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could use the same approach of applying an IF statement by putting the HTML inside the conditional part or you could also encapsulate the HTML inside an Include file and use that as part of the IF statement


    <%
    Dim sBlockedIP
    sBlockedIP = Request.ServerVariables("REMOTE_ADDR")
    'check if the IP is the one that is blocked
    If sBlockedIP <> "00.000.00.00" Then
    %>
    [HTML or INCLUDE STATEMENT GOES HERE]
    <%
    End
    %>

  3. #3
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    359
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Keep in mind REMOTE_ADDR isn't fail-safe. You may show the blocked content when you shouldn't if the remote_addr value is blocked or incorrect because of some proxy / firewall setting in the client computer.
    Doug G
    =====
    "If you ain't the lead dog, the view is always the same - Anon

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks i will give this a go, but my asp skills are not very good at all to be honest.


Bookmarks

Posting Permissions

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