Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Again, IP banning Q
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 02 October 2003 :  10:23:38  Show Profile
I got this code, I think from Nikkol some time ago:
strRemIP = Request.ServerVariables("REMOTE_ADDR")
strBanIP = Mid(strRemIP, 1, InStrRev(strRemIP,"."))

This gives the IP address up to the last period, which is great for banning entire ranges. But now I have a limited range of IP addresses (say xx.xx.xx.53 to xx.xx.xx.71) that I want banned.
What would be the easiest way to check if the visitor's IP address fits in that range?

I was thinking... maybe I should first using the code shown above and then get the last part of the visitor's IP address (let's say I call that strLastIPpart) and check that against the two numbers in the range?
if strBanIP = "xx.xx.xx" then
	if strLastPPpart => 64 or strLastIPpart =< 79 then
		redirect
	end if
end if

Also, how would I get the last part of an IP address? I don't quite grasp how that Mid function works, and w3school.com didn't really help...

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 02 October 2003 :  10:35:11  Show Profile  Visit D3mon's Homepage
strLastPPpart = right(strRemIP,(len(strRemIP)-InStrRev(strRemIP,"."))

Something like that


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"

Edited by - D3mon on 02 October 2003 10:40:37
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 02 October 2003 :  10:48:11  Show Profile
Actually, what I did is this:
strVisitorIPEnd = Mid(strRemIP, Len(strBanIP)+1)
This returns the part of the IP address after the last period.
I then have this:
if (strNewBannedIPs = strBanIP) And ((strVisitorIPEnd >= 53) or (strVisitorIPEnd <= 71)) then
Response.Redirect "page.asp"
end if


I guess I took the long way around
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.23 seconds. Powered By: Snitz Forums 2000 Version 3.4.07