This popped into my head again as I was brushing my teeth this morning
(which for whatever reason is when I tend to do my best thinking), and
there's a much more efficient way to do this.
<cfif !StructKeyExists(application, "ipCheck")>
<cfset application.ipCheck = {} />
</cfif>
<cfif StructKeyExists(application.ipCheck, CGI.REMOTE_ADDR)>
<cfif DateDiff('s', application.ipCheck[CGI.REMOTE_ADDR], Now()) lte
10>
BANNED!
<cfabort />
<cfelse>
<cfset application.ipCheck[CGI.REMOTE_ADDR] = Now() />
You Pass!
</cfif>
<cfelse>
<cfset application.ipCheck[CGI.REMOTE_ADDR] = Now() />
</cfif>
<cfdump var="#application.ipCheck#" />
Basically that uses structs instead of an array, with the IP address
as the key of the struct and the timestamp of the last hit as the
value. That way you don't have to loop over the array to find what
you're looking for.
--
online documentation: http://openbd.org/manual/
google+ hints/tips: https://plus.google.com/115990347459711259462
http://groups.google.com/group/openbd?hl=en
Join us @ http://www.OpenCFsummit.org/ Dallas, Feb 2012