An IP address is really only a 4-byte int seperated into four bytes. So if
you want to find a range, just convert it back to a 4-byte int and compare:
Example:
<cfset LowIP = "192.168.32.0">
<cfset HighIP = "192.168.63.255">
<cfset LowIPRange = BitSHRN(ListGetAt(LowIP, 1, "."), 24) +
BitSHRN(ListGetAt(LowIP, 2, "."), 16 +
BitSHRN(ListGetAt(LowIP, 3, "."), 8) +
BitSHRN(ListGetAt(LowIP, 4, ".")>
<cfset HighIPRange = BitSHRN(ListGetAt(HighIP, 1, "."), 24) +
BitSHRN(ListGetAt(HighIP, 2, "."), 16 +
BitSHRN(ListGetAt(HighIP, 3, "."), 8) +
BitSHRN(ListGetAt(HighIP, 4, ".")>
<cfset CurrentIP = BitSHRN(ListGetAt(cgi.remote_addr, 1, "."), 24) +
BitSHRN(ListGetAt(cgi.remote_addr, 2, "."), 16 +
BitSHRN(ListGetAt(cgi.remote_addr, 3, "."), 8) +
BitSHRN(ListGetAt(cgi.remote_addr, 4, ".")>
<cfif CurrentIP gt LowIP and CurrentIP lt HighIP>
... do stuff...
</cfif>
Honestly, I haven't tried this. E-mail me back if it doesn't work. :) You
might have to do a BitOR with each. Also, you could probably make that into
a UDF. Or something. It's a bit lengthly like this.
Ben Johnson
Hostworks, Inc.
-----Original Message-----
From: Mark M. Kecko [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 14, 2002 1:00 PM
To: CF-Talk
Subject: FW: Reg Expression for IPs
Does anybody have a regular expression for finiding out if a clients IP
address falls within a certain range. I want to know if anybody with an IP
address in the range of 192.168.32.0 - 192.168.63.255 hits a page. Thanks
in advance.
Mark Kecko
The Computer Guy
MediaPost Communications
[EMAIL PROTECTED]
http://www.mediapost.com
(203)222-0330 ext309
"Imagination is the one weapon in the war against reality."
Jules de Gaultier
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists