VB icon

Detect User's IP address and filter based on it

Email
Submitted on: 1/1/2015 12:46:00 AM
By: Ian Ippolito (PSC)  
Level: Beginner
User Rating: By 5 Users
Compatibility: ASP (Active Server Pages)
Views: 1323
author picture
 
     If you have the need to filter out certain users from your site (hackers, unauthorized personel, etc.) and you know their IP address, you can use this code to do so. It detects the IP address of the current user and based on what that address is, takes action. Of course, you need to replace the IP address and the action in the code with whatever you would like to do...
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Detect User's IP address and filter based on it
' Description:If you have the need to filter out certain users from your site (hackers, unauthorized personel, etc.) and you know their IP address, you can use this code to do so. It detects the IP address of the current user and based on what that address is, takes action. Of course, you need to replace the IP address and the action in the code with whatever you would like to do...
' By: Ian Ippolito (PSC)
'**************************************

<%@ Language=VBScript %>
<%option explicit
'get user's ip address
dim strUserIpAddress
strUserIpAddress = Request.ServerVariables("REMOTE_ADDR")
'check if this 
If strUserIpAddress = "14.10.0.1" then ' put your IP here
	Response.write "You've been banned from this site!"
Else
	Response.write "Welcome to the site!"
End If 
%>


Other 12 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.