This is a very simple programme that demonstrate how to block specified IP addresses from accessing the website or webpages. In this code I used array to store the IP adresses but database can also be used to store the IP adresses. You can redirect the user to a specified page of restrict it to specified pages or no access pages.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | '******************************************************* '* MYCPLUS Sample Code - https://www.mycplus.com * '* * '* This code is made available as a service to our * '* visitors and is provided strictly for the * '* purpose of illustration. * '* * '* Please direct all inquiries to saqib at mycplus.com * '******************************************************* '******************************** ' Block the IP addresses that do the SPAM '******************************** Function IsBlockedIP() 'declare variables Dim sIP Dim sIParray(2) 'assign our blocked IP addresses to our array sIParray(0) = "127.0.0.1" sIParray(1) = "127.0.0.2" 'retrieve the visitors IP address sIP = Request.ServerVariables("REMOTE_ADDR") 'loop through the banned IPs using the UBound function For i = 0 to UBound(sIParray) 'check if IP address matches any of the blocked IPs if sIP = sIParray(i) Then Response.Redirect "index.asp" End if Next End Function |