[thelist] CFMX: IP Address Ban/Prevent

Joshua Olson joshua at waetech.com
Sun Feb 22 07:36:28 CST 2004


> -----Original Message-----
> From: Russ
> Sent: Sunday, February 22, 2004 8:26 AM
>
> I would think that, since they collect IP addresses already, it should
> be fairly simple to add another table to the DB for IP addresses.
> However, I've not ever checked for an IP address on a page load
> (assuming it should be done in the Application.cfm) and then forced a
> redirect to a page that lets the user know what's happening.
>
> Has anyone ever worked with this sort of thing or does anyone have an
> example of how best to achieve this?

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.

Good luck,

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com/service_areas/
706.210.0168




More information about the thelist mailing list