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 = "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

  <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.

Recommended Answers

All 2 Replies

Hello,

So my asp is not as strong as asp.net because I switched over to asp.net when I first picked up asp. This is very easy to do using asp.net. Bear with me here on the asp part, but I beleive that you can do this using your If Then statement. Again, my asp is weak so I am not sure this is the best approach. But, this is how I would suggest you resolve this...

Create a variable as a string as assign all of that HTML code you want to hide to the string. In line #6 above, you can redirect the user if the IF returns TRUE, but if it returns FALSE, then just do a Response.Write(myHTML).

So it would look like this....

<%
    Dim sBlockedIP
    Dim myHTML
    myHTML = "<div ...  all of your code ... /div>"
    sBlockedIP = Request.ServerVariables("REMOTE_ADDR")

    If sBlockedIP = "00.000.00.00" Then
         Response.Redirect "no_access.asp"
    Else
         Response.Write(myHTML)
    End If
%> 

Thanks i will give this a go, but my asp skills are not very good at all to be honest.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.