[thelist] CFMX: IP Address Ban/Prevent

Russ russ at unrealisticexpectations.com
Sun Feb 22 10:03:54 CST 2004


Thanks, Josh.

You've given me pretty much exactly what I'm looking for.  The client
wants to globally ban the addresses--that is, block them from the site
completely without any opportunity to read or interact with any of the
content, at least initially.  I may persuade them to have this
functionality in place only when a user attempts to submit content,
which would probably be preferred.

This leads me to another question, since the client has a lot of
sites--couldn't they create a "master list" and pull from an XML feed of
the data from one location rather than trying to add the IP addresses to
each of the domain names?

This is running on RedHat, btw.

Thanks again,

Russ

 
> In application.cfm...
> 
> <cfquery name="whatever"...>
>   SELECT 1
>   FROM banned_ips
>   WHERE addr = '#cgi.remote_addr#'
> </query>
> 
> <cfif whatever.recordcount>
>   <cflocation ...>
> </cfif>
> 
> If the list of banned IP's is small, then you may consider creating a
> comma-separated list of banned IP's and then doing something 
> like this:
> 
> --- ips.cfm ---
> 
> <cfset banned_ips = "123.45.67.8,124.56.78.9">
> 
> --- application.cfm ---
> 
> <cfinclude template="ips.cfm">
> 
> <cfif ListFind(banned_ips, cgi.remote_addr)>
>   <cflocation ...>
> </cfif>
> 
> You could also have ips.cfm create a struct of ips (using the 
> ip and the key
> and the empty string as the value) to facilitate faster 
> lookup--though you
> add the overhead of populating the struct with each page request.
> 
> Lastly, you could put the information into the application 
> scope... but
> depending on how you feel about shared global variables, this 
> may not be the
> best solution for you.




More information about the thelist mailing list