Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-01-2012, 04:47 PM   PM User | #1
jelly46
New Coder

 
Join Date: Aug 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
jelly46 is an unknown quantity at this point
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.
jelly46 is offline   Reply With Quote
Old 05-23-2012, 05:40 PM   PM User | #2
miranda
Senior Coder

 
Join Date: Dec 2002
Location: Arlington, Texas USA
Posts: 1,062
Thanks: 4
Thanked 8 Times in 8 Posts
miranda is an unknown quantity at this point
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..
miranda is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 01:53 AM.


Advertisement
Log in to turn off these ads.