<?xml version="1.0" encoding="iso-8859-1"?>

<rdf:RDF 
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns="http://purl.org/rss/1.0/"
>
		
	<channel rdf:about="http://www.bpurcell.org/index.cfm">
	<title>Brandon Purcell's Blog</title>
	<description>A blog for ColdFusion, Java, and other topics.</description>
	<link>http://www.bpurcell.org/blog/index.cfm</link>
	
	<items>
		<rdf:Seq>
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1131" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1126" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1109" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1104" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1100" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1099" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1098" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1097" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1094" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1092" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1086" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1084" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1080" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1079" />
			
			<rdf:li rdf:resource="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1078" />
			
		</rdf:Seq>
	</items>
	
	</channel>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1131">
	<title>Keeping a session alive on ColdFusion using Jquery</title>
	<description>&lt;p&gt;There is nothing more frustrating than taking 30 minutes filling out some text in a long form only to submit and have your session reset and lose all of your data. Here is a simple solution to keep a session open on forms where users may need an extended period of time for data entry. I included this code on any page where I need the session extended. You can remove the javascript include if JQuery is included on everyone of your pages already.&lt;/p&gt;


&lt;DIV STYLE=&quot;padding-left : 10px;&quot;&gt;&lt;PRE&gt;&lt;FONT COLOR=GRAY&gt;&lt;I&gt;&amp;lt;!--- Include this file on any page where users may take a 
long time filling in text and you want to keep the session open ---&gt;&lt;/I&gt;&lt;/FONT&gt;
&lt;FONT COLOR=MAROON&gt;&amp;lt;cfparam name=&lt;FONT COLOR=BLUE&gt;&quot;variables.refreshrate&quot;&lt;/FONT&gt; default=&lt;FONT COLOR=BLUE&gt;&quot;60000&quot;&lt;/FONT&gt;&gt;&lt;/FONT&gt;

&lt;FONT COLOR=MAROON&gt;&amp;lt;cfoutput&gt;&lt;/FONT&gt;
&lt;FONT COLOR=NAVY&gt;&lt;FONT COLOR=MAROON&gt;&amp;lt;script type=&lt;FONT COLOR=BLUE&gt;&quot;text/javascript&quot;&lt;/FONT&gt; src=&lt;FONT COLOR=BLUE&gt;&quot;/js/jquery-1.3.2.min.js&quot;&lt;/FONT&gt;&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT COLOR=NAVY&gt;&lt;FONT COLOR=MAROON&gt;&amp;lt;/script&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT COLOR=NAVY&gt;&lt;FONT COLOR=MAROON&gt;&amp;lt;script language=&lt;FONT COLOR=BLUE&gt;&quot;JavaScript&quot;&lt;/FONT&gt; type=&lt;FONT COLOR=BLUE&gt;&quot;text/javascript&quot;&lt;/FONT&gt;&gt;&lt;/FONT&gt;&lt;/FONT&gt;
	$(document).ready(function(){
 					setTimeout(&lt;FONT COLOR=BLUE&gt;&quot;callserver()&quot;&lt;/FONT&gt;,#variables.refreshrate#); 
 				});
 	
 	function callserver()
 	{
 		var remoteURL = &apos;/emptypage.cfm	&apos;;
			    $.get(remoteURL,  function(data){
			     &lt;FONT COLOR=GRAY&gt;&lt;I&gt; //alert(data);&lt;/I&gt;&lt;/FONT&gt;
			      setTimeout(&lt;FONT COLOR=BLUE&gt;&quot;callserver()&quot;&lt;/FONT&gt;,#variables.refreshrate#);
			    });
 	}
&lt;FONT COLOR=NAVY&gt;&lt;FONT COLOR=MAROON&gt;&amp;lt;/script&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT COLOR=MAROON&gt;&amp;lt;/cfoutput&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1131</link>
	<dc:date>2009-08-04T06:36:45-07:00</dc:date>
	<dc:subject>ColdFusionMX,Jquery</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1126">
	<title>CFDUMP for PHP and Javascript</title>
	<description>&lt;p&gt;In recent months I have been using PHP to extend functionality inside of WordPress for the SpatialKey site and working with JQuery as well. After working with ColdFusion for so long I have gotten spoiled by the CFDUMP tag . Here are a few options similar to CFDUMP for both PHP and Javascript.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://dbug.ospinto.com/&quot;&gt;CFDUMP for PHP - dBug&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.netgrow.com.au/files/javascript_dump.cfm&quot;&gt;CFDUMP for Javascript&lt;/a&gt;&lt;/p&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1126</link>
	<dc:date>2009-05-14T11:34:24-07:00</dc:date>
	<dc:subject>ColdFusionMX</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1109">
	<title>Suggestions for Preso at Max 2008 Architecting ColdFusion For Scalability And High Availability</title>
	<description>&lt;p&gt;I will be presenting again at Max this year in San
                                      Franscico on the topic of &quot;Architecting ColdFusion For Scalability And
                                      High Availability&quot;. I want to take a new approach this year and solicit
                                      input on specific areas to cover during the presentation. In some cases
                                      you come to Max year after year and hear the same thing and since I
                                      have only 60 minutes and a lot of content in my head I would like to
                                      gather input on what areas the community would find interesting. There
                                      are two main areas where I can focus, coding practices for scalability
                                      and clustering architectures for high availability. I think for the
                                      most part developers attending Max understand best practices for coding
                                      (although it doesn&apos;t mean they always follow them). The clustering
                                      architectures and options have not changed much over the years since
                                      CFMX 6 so many of my old articles still apply. I would be interested to
                                      hear general thoughts on this topic and areas where I could focus the
                                      presentation. My outline is due on the 14th but I think I will probably
                                      tweak things all the way through August.&lt;/p&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1109</link>
	<dc:date>2008-09-01T19:52:32-07:00</dc:date>
	<dc:subject>ColdFusionMX</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1104">
	<title>Open Source Flex Development Frameworks</title>
	<description>&lt;p&gt;&lt;a href=&quot;http://www.infoq.com/news/2008/01/flex-mvc&quot;&gt;This article highlights&lt;/a&gt; the many different Flex development frameworks available as the Flex community has grown by leaps in bounds in recent years. &lt;/p&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1104</link>
	<dc:date>2008-09-01T19:51:29-07:00</dc:date>
	<dc:subject>ColdFusionMX</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1100">
	<title>Obtaining a users geographical location based on their IP with GeoIP and ColdFusion Example</title>
	<description>&lt;p&gt;In my &lt;a href=&quot;http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1099&quot;&gt;last blog posting&lt;/a&gt; I discussed the advantages of using MaxMind GeoIP to obtain a site
                                      visitors geographical location based on their IP. In this posting I
                                      will show you how to integrate GeoIP into your site using ColdFusion.
                                      If you are a ColdFusion developer the most challenging part is getting
                                      the java source compiled and into a jar file so that you can leverage
                                      the GeoIP Java API in ColdFusion. I have made it easier by taking care
                                      of this process&lt;/p&gt;
                                    &lt;p&gt;The first thing you will need to do is &lt;a href=&quot;http://www.bpurcell.org/go.cfm?go=http://www.bpurcell.org/downloads/geoIP_ColdFusion_example.zip&quot;&gt;download the example and jar file&lt;/a&gt;.
                                      Since this example was written using the Lite version of GeoIP you will
                                      need to download the Binary version of the Lite database. After you get
                                      it up and running you can download and just replace the .dat file with
                                      the full binary version. Go to &lt;a href=&quot;http://www.maxmind.com/app/geolitecity&quot;&gt;http://www.maxmind.com/app/geolitecity&lt;/a&gt; and look under the section that says &quot;Binary Format&quot;, click on the
                                      &quot;Download the latest GeoLite&#xa0;City Binary Format&quot; link. After that
                                      go ahead and extract the .dat file from the zip.&lt;/p&gt;
                                    &lt;p&gt;The zip file that you downloaded above will contain a jar file and
                                      two ColdFusion files. Follow along with the steps below and you will be
                                      up and running quickly. &lt;/p&gt;
                                    &lt;p&gt;Steps:&lt;/p&gt;
                                    &lt;ol&gt;
                                      &lt;li&gt;Copy geoIP.jar to Jrun4/servers/lib or
                                        ColdFusion/runtime/servers/lib (I think that is right for standalone CF
                                        it has been a while since I used the standalone version) &lt;/li&gt;
                                      &lt;li&gt;Restart ColdFusion or the JRun instance &lt;/li&gt;
                                      &lt;li&gt;Create a directory for testing in your webroot and copy index.cfm and application.cfc from the zip file above &lt;/li&gt;
                                      &lt;li&gt;Open Application.cfc and modify the entry for
                                        REQUEST.GeoIPCityDB to point to the location where you extracted the
                                        GeoLiteCity.dat file from above. Make sure you use forward slashes and
                                        not backslashes. &lt;br&gt;
                                        REQUEST.GeoIPCityDB=&quot;C:/geoIP/GeoLiteCity.dat&quot;; &lt;/li&gt;
                                      &lt;li&gt;You should then be able to invoke index.cfm from the example and start resolving IP&apos;s to Geographic locations. &lt;/li&gt;
                                    &lt;/ol&gt;
                                    &lt;!-- &lt;p&gt;I have included an &lt;a href=&quot;http://www.bpurcell.org/geoip/index.cfm&quot;&gt;example usage on my site using both the free version and the paid version&lt;/a&gt; so you can get a sense of the differences between the two.&lt;/p&gt; --&gt;
                                    &lt;p&gt;You should be able to take this example code and quickly integrate
                                      it into your own site. Overall it is pretty simple, if you are not
                                      using an Application.cfc file you will just need to add it to your
                                      Application.cfm file. Make sure you add logic so that it only is
                                      initialized once. The initial load is a bit expensive but it loads the
                                      entire database into memory. It is only about 25MB but it is worth the
                                      performance gain you get since you can support hundred-thousands of
                                      queries a second. The UDF in the index.cfm file is a little bit bloated
                                      but there is some reasoning behind it. When I started using this
                                      approach I had already been using IP2Location and had a predefined
                                      query structure that I had to adapt to. You can probably simplify the
                                      approach for the UDF if you choose to. If there are any other questions
                                      feel free to post them or email me. &lt;br&gt;
                                    &lt;/p&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1100</link>
	<dc:date>2008-09-01T19:50:45-07:00</dc:date>
	<dc:subject>ColdFusionMX,JRun</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1099">
	<title>Obtaining a users geographical location based on their IP with GeoIP and ColdFusion</title>
	<description>&lt;p&gt;Early this year I wrote a blog article about using
                                      IP2Location to identify a users location and ISP based upon their IP.
                                      You can find the previous articles here:&lt;/p&gt;
                                    &lt;p&gt;&lt;a href=&quot;http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;amp;entry=1078&quot;&gt;http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;amp;entry=1078&lt;/a&gt;&lt;br&gt;
                                      &lt;a href=&quot;http://www.bpurcell.org/viewcontent.cfm?contentID=147&quot;&gt;http://www.bpurcell.org/viewcontent.cfm?contentID=147&lt;/a&gt;&lt;/p&gt;
                                    &lt;p&gt;The flaw with this approach is that the data was stored into a
                                      database of 4 million rows and it was very expensive to do the lookups
                                      even with the performance optimizations of splitting the data up across
                                      multiple tables. Recent research has turned up a more optimal approach
                                      using &lt;a href=&quot;http://www.maxmind.com/app/ip-location&quot; target=&quot;_blank&quot;&gt;GeoIP&lt;/a&gt; with a binary based solution that will support several hundred requests
                                      per second. Yes that is right, several hundred requests per second. The
                                      initial setup and configuration takes a bit of time to get going but it
                                      is very simple to update and maintain. &lt;/p&gt;
                                    &lt;p&gt;GeoIP is a technology from MaxMind that provides developers with a
                                      non-invasive way to determine geographical and other information about
                                      their Internet visitors in real-time. When a person visits your
                                      website, GeoIP can determine which country, region, city, postal code,
                                      area code the visitor is coming from. Furthermore, GeoIP can provide
                                      information such as longitude/latitude, connection speed, ISP, company
                                      name, domain name, and whether the IP address is an anonymous proxy or
                                      satellite provider. In my findings and experimentation I have found
                                      that GeoIP is also more accurate than IP2Location. &lt;/p&gt;
                                    &lt;p&gt;GeoIP features multiple binary files with different features
                                      available based on the price that you pay. A listing of the different
                                      versions can be &lt;a href=&quot;http://www.maxmind.com/app/geoip_features&quot; target=&quot;_blank&quot;&gt;found here&lt;/a&gt;. For my practical purposes I used both the City and ISP versions. Another great thing that MaxMind offers is a &lt;a href=&quot;http://www.maxmind.com/app/geolitecity&quot; target=&quot;_blank&quot;&gt;GeoLite City version&lt;/a&gt; that is free that you can use to test integration with your system. All
                                      of the API&apos;s are exactly the same but it is less accurate than the
                                      version you purchase. &lt;/p&gt;
                                    &lt;p&gt;The final selling point for me with GeoIP is the different API&apos;s
                                      that they support. You can integrate it with almost any system using
                                      (Java, C, Perl, PHP, VB.net, MS Com....&lt;a href=&quot;http://www.maxmind.com/app/api&quot;&gt;and many others&lt;/a&gt;).
                                      Since I was using ColdFusion I chose to go the Java route. If you are
                                      not experienced with Java you may stumble a bit here but I plan on
                                      posting the Jar that I built for integration along with sample code to
                                      make it very easy to first try the Lite version then use the full
                                      version if it works well for you. You can find the &lt;a href=&quot;http://www.maxmind.com/app/java&quot;&gt;Java source here along with the GeoLite version&lt;/a&gt;. &lt;/p&gt;
                                    &lt;p&gt;If you are experienced with Java and ColdFusion it is pretty
                                      straightforward to get up and running. You will just need to compile
                                      the java source and build a jar, then place it in the classpath of
                                      ColdFusion. It is as easy as instantiating the Java object from CF then
                                      making calls to retrieve the information. I recommend encapsulating
                                      this into a function and loading the reference to the Java object in an
                                      application scope variable that is loaded when the application starts.
                                      I did have to work around a few issues in the Java source to get it
                                      working properly with CF but there were not too many changes needed. &lt;/p&gt;
                                    &lt;p&gt;I have posted&amp;nbsp;a very easy to follow step by step set of instructions on this posting &lt;a href=&quot;http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;amp;entry=1100&quot;&gt;http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;amp;entry=1100&lt;/a&gt;&amp;nbsp;so that you can use to get GeoIP up and running on your site. &lt;/p&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1099</link>
	<dc:date>2008-09-01T19:50:34-07:00</dc:date>
	<dc:subject>ColdFusionMX,JRun</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1098">
	<title>ColdFusion 8 shows error IP license restriction is in effect although you enter a valid key</title>
	<description>&lt;p&gt;I ran into a confusing issue with ColdFusion 8
that could affect users that install the enterprise version with the
evaluation option and are using multiple instances.&lt;/p&gt;
&lt;p&gt;Here is what led up to this issue occuring for me&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Installed ColdFusion 8 as a multi server install with the evaluation option 
&lt;/li&gt;&lt;li&gt;Created an additional instance of ColdFusion 
&lt;/li&gt;&lt;li&gt;Entered in a valid serial number into the new instance that I had just created. 
&lt;/li&gt;&lt;li&gt;After the evaluation period expired the server responded with
a blank page for requests although some of the requests completed
successfully. &lt;/li&gt;&lt;li&gt;Looking in the error log for the new server I found the following error.&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;11/12 17:49:21 error IP license restriction is in effect.&amp;nbsp; Can
only accept connection from either localhost or five IP addresses,
attempted from 192.168.2.9.&amp;nbsp; Previous accesses were from [
{192.150.x.x}&amp;nbsp; {192.168.x.x}&amp;nbsp; {192.168.x.x}&amp;nbsp;
{192.168.x.x}&amp;nbsp; {192.168.x.x} ].&lt;/p&gt;
&lt;p&gt;Of course I had seen this error many times before but in the CF
admin (of the new instance I had created) I saw that CF was running
with an enterprise license so it should not have the IP restriction. It
occured to me that the main CFusion administrative server did not have
the license key. After entering the license key in the CFusion admin
and restarting both instances everything cleared up. This will probably
rarely happen but it could be really confusing if it occurs so I hope
this helps someone.&lt;/p&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1098</link>
	<dc:date>2008-09-01T19:50:24-07:00</dc:date>
	<dc:subject>ColdFusionMX</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1097">
	<title>ColdFusion 8 shows error IP license restriction is in effect although you enter a valid key</title>
	<description>&lt;p&gt;I ran into a confusing issue with ColdFusion 8 that could affect users that install the enterprise version with the evaluation option and are using multiple instances.&lt;/p&gt;
&lt;p&gt;Here is what led up to this issue occuring for me&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Installed ColdFusion 8 as a multi server install with the evaluation option 
&lt;/li&gt;&lt;li&gt;Created an additional instance of ColdFusion 
&lt;/li&gt;&lt;li&gt;Entered in a valid serial number into the new instance that I had just created. 
&lt;/li&gt;&lt;li&gt;After the evaluation period expired the server responded with a blank page for requests although some of the requests completed successfully. 
&lt;/li&gt;&lt;li&gt;Looking in the error log for the new server I found the following error.&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;11/12 17:49:21 error IP license restriction is in effect.&amp;nbsp; Can only accept connection from either localhost or five IP addresses, attempted from 192.168.2.9.&amp;nbsp; Previous accesses were from [ {192.150.x.x}&amp;nbsp; {192.168.x.x}&amp;nbsp; {192.168.x.x}&amp;nbsp; {192.168.x.x}&amp;nbsp; {192.168.x.x} ].&lt;/p&gt;

&lt;p&gt;Of course I had seen this error many times before but in the CF admin (of the new instance I had created) I saw that CF was running with an enterprise license so it should not have the IP restriction. It occured to me that the main CFusion administrative server did not have the license key. After entering the license key in the CFusion admin and restarting both instances everything cleared up. This will probably rarely happen but it could be really confusing if it occurs so I hope this helps someone.&lt;/p&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1097</link>
	<dc:date>2008-09-01T19:50:13-07:00</dc:date>
	<dc:subject>ColdFusionMX</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1094">
	<title>ColdFusion enabled MySQL driver available</title>
	<description>&lt;p&gt;A new version of the MySQL driver has been
                                      released that detects ColdFusion when it is running with Coldfusion MX
                                      7 (and 8). This should result in much better performance for CF/MySQL
                                      users.&lt;br&gt;
                                      &lt;br&gt;
                                      Setting &quot;useDynamicCharsetInfo&quot; to &quot;false&quot; now causes
                                      driver to use static lookups for collations as well (makes
                                      ResultSetMetadata.isCaseSensitive() much more efficient, which leads to
                                      performance increase for ColdFusion, which calls this method for every
                                      column on every table it sees, it appears). &lt;/p&gt;
                                    &lt;p&gt;The driver automatially detects when it is running in a ColdFusion
                                      MX server (tested with version 7), and uses the configuration bundle
                                      coldFusion, which sets &quot;useDynamicCharsetInfo&quot; to &quot;false&quot; (see previous
                                      entry), and sets useLocalSessionState and autoReconnect to true.&lt;br&gt;
                                      &lt;br&gt;
                                      The
                                      update for this driver should should help with performance. I have
                                      personally not tested this driver but wanted to pass this information
                                      along.&lt;/p&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1094</link>
	<dc:date>2008-09-01T19:48:47-07:00</dc:date>
	<dc:subject>ColdFusionMX</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1092">
	<title>Multi-tiered clustering with ISAPI Rewrite and CGI variable issues</title>
	<description>&lt;p&gt;This was something that I meant to write about a
                                      while ago but never got around to it. I recieved a question recently by
                                      email and wanted to provide some tips and tricks when using ISAPI
                                      Rewrite in a multi-tiered load balanced environment. I wrote an article
                                      with Frank DeRienzo several years ago about using a&lt;a href=&quot;http://www.adobe.com/devnet/coldfusion/j2ee/articles/balancing_j2ee.html&quot;&gt; multi-tiered load balanced enviroment&lt;/a&gt;. I followed this up later with a blog entry on my site for &lt;a href=&quot;http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;amp;entry=1070&quot;&gt;Using ISAPI Rewrite with ColdFusion&lt;/a&gt;. &lt;/p&gt;
                                    &lt;p&gt;If you are using ISAPI Rewrite to proxy requests from your webserver
                                      (IIS) to you ColdFusion server or through a load balancer you will run
                                      into issues when accessing various CGI variables. When proxying the
                                      ColdFusion server sees the web server as the end client and therefore
                                      variables like CGI.HTTP_HOST are set to the IP or hostname of the
                                      webserver. To get around this I inject custom headers with ISAPI
                                      rewrite, parse them in CF and then stored them in the request scope. &lt;/p&gt;
                                    &lt;p&gt;First I start by adding the headers to the main httpd.ini
                                      Start-&amp;gt;All Programs-&amp;gt;Helicon-&amp;gt;ISAPI_Rewrite-&amp;gt;httpd.ini (you
                                      may need to change the read only flag in order to save the file)&lt;/p&gt;
                                    &lt;p&gt;#Due to the proxy we add these headers to use in cf through&lt;br&gt;
                                      #GetHttpRequestData().headers.HEADERNAME&lt;br&gt;
                                      RewriteCond %REMOTE_ADDR (.*)&lt;br&gt;
                                      RewriteHeader CLIENT_REMOTE_ADDR: ^$ $1&lt;/p&gt;
                                    &lt;p&gt;RewriteCond %SCRIPT_NAME (.*)&lt;br&gt;
                                      RewriteHeader CLIENT_SCRIPT_NAME: ^$ $1&lt;/p&gt;
                                    &lt;p&gt;RewriteCond %SERVER_NAME (.*)&lt;br&gt;
                                      RewriteHeader CLIENT_SERVER_NAME: ^$ $1&lt;/p&gt;
                                    &lt;p&gt;RewriteCond %SERVER_PORT (.*)&lt;br&gt;
                                      RewriteHeader CLIENT_SERVER_PORT: ^$ $1&lt;/p&gt;
                                    &lt;p&gt;RewriteCond %HTTP_HOST (.*)&lt;br&gt;
                                      RewriteHeader CLIENT_HTTP_HOST: ^$ $1&lt;/p&gt;
                                    &lt;p&gt;RewriteCond %SERVER_PROTOCOL (.*)&lt;br&gt;
                                      RewriteHeader CLIENT_SERVER_PROTOCOL: ^$ $1&lt;/p&gt;
                                    &lt;p&gt;#stores the original URL before any rewriting in a custom header &lt;br&gt;
                                      RewriteCond URL (.*)&lt;br&gt;
                                      RewriteHeader x_rewrite_url_original: ^$ $1&lt;/p&gt;
                                    &lt;p&gt;RewriteCond X-Rewrite-Proxy (.*)&lt;br&gt;
                                      RewriteHeader x_rewrite_proxy: ^$ $1&lt;/p&gt;
                                    &lt;p&gt;I then create a page in CF called httpheaders.cfm and include it
                                      early on in my CF code within Appplication.cfm or within onRequest of
                                      Application.cfc &lt;/p&gt;
                                    &lt;div style=&quot;padding-left: 10px;&quot;&gt;
                                      &lt;pre&gt;&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfsilent&amp;gt;&lt;/font&gt;
&lt;font color=&quot;gray&quot;&gt;&lt;i&gt;&amp;lt;!--- this page is added to handle the custom headers we write with 
ISAPI Rewrite due to the issues we see with proxying requests.
 ---&amp;gt;&lt;/i&gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset httpheaders=GetHttpRequestData().headers&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders=structNew()&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfif isdefined(&lt;font color=&quot;blue&quot;&gt;&quot;httpheaders.CLIENT_REMOTE_ADDR&quot;&lt;/font&gt;)&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.REMOTE_ADDR=httpheaders.CLIENT_REMOTE_ADDR&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfelse&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.REMOTE_ADDR=CGI.REMOTE_ADDR&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;/cfif&amp;gt;&lt;/font&gt;
&lt;font color=&quot;gray&quot;&gt;&lt;i&gt;&amp;lt;!--- I need to find a way to handle SCRIPT_NAME better, with ISAPI 
Rewrite and JRun ones are different ---&amp;gt;&lt;/i&gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfif isdefined(&lt;font color=&quot;blue&quot;&gt;&quot;httpheaders.CLIENT_SCRIPT_NAME&quot;&lt;/font&gt;)&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;gray&quot;&gt;&lt;i&gt;&amp;lt;!--- &amp;lt;cfset 
REQUEST.proxyheaders.SCRIPT_NAME=httpheaders.CLIENT_SCRIPT_NAME&amp;gt; ---&amp;gt;&lt;/i&gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.SCRIPT_NAME=CGI.SCRIPT_NAME&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfelse&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.SCRIPT_NAME=CGI.SCRIPT_NAME&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;/cfif&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfif isdefined(&lt;font color=&quot;blue&quot;&gt;&quot;httpheaders.CLIENT_SERVER_NAME&quot;&lt;/font&gt;)&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.SERVER_NAME=httpheaders.CLIENT_SERVER_NAME&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfelse&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.SERVER_NAME=CGI.SERVER_NAME&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;/cfif&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfif isdefined(&lt;font color=&quot;blue&quot;&gt;&quot;httpheaders.CLIENT_SERVER_PORT&quot;&lt;/font&gt;)&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.SERVER_PORT=httpheaders.CLIENT_SERVER_PORT&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfelse&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.SERVER_PORT=CGI.SERVER_PORT&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;/cfif&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfif isdefined(&lt;font color=&quot;blue&quot;&gt;&quot;httpheaders.CLIENT_SERVER_PROTOCOL&quot;&lt;/font&gt;)&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset 
REQUEST.proxyheaders.SERVER_PROTOCOL=httpheaders.CLIENT_SERVER_PROTOCOL&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfelse&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.SERVER_PROTOCOL=CGI.SERVER_PROTOCOL&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;/cfif&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfif isdefined(&lt;font color=&quot;blue&quot;&gt;&quot;httpheaders.CLIENT_HTTP_HOST&quot;&lt;/font&gt;)&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.HTTP_HOST=httpheaders.CLIENT_HTTP_HOST&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfelse&amp;gt;&lt;/font&gt;
    &lt;font color=&quot;maroon&quot;&gt;&amp;lt;cfset REQUEST.proxyheaders.HTTP_HOST=CGI.HTTP_HOST&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;/cfif&amp;gt;&lt;/font&gt;
&lt;font color=&quot;maroon&quot;&gt;&amp;lt;/cfsilent&amp;gt;&lt;/font&gt;&lt;/pre&gt;
                                    &lt;/div&gt;
                                    &lt;p&gt;After including this code you can access the client&apos;s IP with &quot;&lt;font color=&quot;maroon&quot;&gt;REQUEST.proxyheaders.REMOTE_ADDR&lt;/font&gt;&quot;. &lt;/p&gt;
                                    &lt;p&gt;One other challenge is detecting if a user is using HTTPS if you
                                      have front ended your site with a load balancer and use the SSL
                                      accelerator of BIG-IP or Cisco CSS. To the app it looks exactlyt he
                                      same. I will save that discussion for another blog posting. Let me know
                                      if you have any questions. &lt;/p&gt;
                                    &lt;p&gt;There should be a similar solution with mod_proxy in apache by
                                      adding headers I just have not researched it. If you have the
                                      information post your findings and I will add it to the blog.&lt;/p&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1092</link>
	<dc:date>2008-09-01T19:46:41-07:00</dc:date>
	<dc:subject>ColdFusionMX</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1086">
	<title>Capturing and emailing errors</title>
	<description>&lt;P&gt;Most developers do not spend&amp;nbsp;a lot of time reviewing logs so a lot of errors occur without ever knowing about them. If every error ends up in your inbox then you are forced to address them. I use a template similar to the one below for every site I have developed.&lt;/P&gt;
&lt;DIV style=&quot;PADDING-LEFT: 10px&quot;&gt;&lt;PRE&gt;&lt;FONT color=gray&gt;&lt;I&gt;&amp;lt;!--- Send an email with information about the error ---&amp;gt;&lt;/I&gt;&lt;/FONT&gt;
&lt;FONT color=maroon&gt;&amp;lt;CFMAIL TO=&lt;FONT color=blue&gt;&quot;&lt;A href=&quot;mailto:youremail@host.com&quot;&gt;youremail@host.com&lt;/A&gt;&quot;&lt;/FONT&gt; FROM=&lt;FONT color=blue&gt;&quot;&lt;A href=&quot;mailto:error@site.com&quot;&gt;error@site.com&lt;/A&gt;&quot;&lt;/FONT&gt; 
 SUBJECT=&lt;FONT color=blue&gt;&quot;Error on http://#CGI.HTTP_HOST##CGI.SCRIPT_NAME#&quot;&lt;/FONT&gt; TYPE=&lt;FONT color=blue&gt;&quot;HTML&quot;&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;
A user experienced an error on #ERROR.template#. 
&lt;FONT color=navy&gt;&amp;lt;P&amp;gt;&lt;/FONT&gt;The error information is as follows:&lt;FONT color=navy&gt;&amp;lt;BR&amp;gt;&lt;/FONT&gt;
Diagnostics: #ERROR.Diagnostics#&lt;FONT color=navy&gt;&amp;lt;BR&amp;gt;&lt;/FONT&gt;
Template: #ERROR.template#&lt;FONT color=navy&gt;&amp;lt;BR&amp;gt;&lt;/FONT&gt;
Query String: #ERROR.QueryString#&lt;FONT color=navy&gt;&amp;lt;BR&amp;gt;&lt;/FONT&gt;
Path Info: #CGI.PATH_INFO#&lt;FONT color=navy&gt;&amp;lt;BR&amp;gt;&lt;/FONT&gt;
Referer: #CGI.HTTP_REFERER#&lt;FONT color=navy&gt;&amp;lt;BR&amp;gt;&lt;/FONT&gt;
IP: #CGI.REMOTE_ADDR#&lt;FONT color=navy&gt;&amp;lt;BR&amp;gt;&lt;/FONT&gt;
Date/time: #ERROR.DateTime#&lt;FONT color=navy&gt;&amp;lt;BR&amp;gt;&lt;/FONT&gt;
Browser: #ERROR.Browser#&lt;FONT color=navy&gt;&amp;lt;BR&amp;gt;&lt;/FONT&gt;
URL: &lt;FONT color=green&gt;&amp;lt;a href=&lt;FONT color=blue&gt;&quot;http://#CGI.HTTP_HOST##CGI.SCRIPT_NAME##CGI.PATH_INFO#&quot;&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;
http://#CGI.HTTP_HOST##CGI.SCRIPT_NAME##CGI.PATH_INFO#&lt;FONT color=green&gt;&amp;lt;/a&amp;gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&amp;lt;BR&amp;gt;&lt;/FONT&gt;
Request Method: #cgi.REQUEST_METHOD#
&lt;FONT color=navy&gt;&amp;lt;ul&amp;gt;&lt;/FONT&gt;
&lt;FONT color=navy&gt;&amp;lt;li&amp;gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&amp;lt;b&amp;gt;&lt;/FONT&gt;Users Location:&lt;FONT color=navy&gt;&amp;lt;/b&amp;gt;&lt;/FONT&gt; #error.remoteAddress#
  &lt;FONT color=navy&gt;&amp;lt;li&amp;gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&amp;lt;b&amp;gt;&lt;/FONT&gt;Users Browser:&lt;FONT color=navy&gt;&amp;lt;/b&amp;gt;&lt;/FONT&gt; #error.browser#
  &lt;FONT color=navy&gt;&amp;lt;li&amp;gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&amp;lt;b&amp;gt;&lt;/FONT&gt;Page Refered:&lt;FONT color=navy&gt;&amp;lt;/b&amp;gt;&lt;/FONT&gt; #error.HTTPReferer#
&lt;FONT color=navy&gt;&amp;lt;/ul&amp;gt;&lt;/FONT&gt;
#error.diagnostics#
&lt;FONT color=navy&gt;&amp;lt;br&amp;gt;&lt;/FONT&gt;
&lt;FONT color=maroon&gt;&amp;lt;cfif cgi.REQUEST_METHOD IS &lt;FONT color=blue&gt;&quot;POST&quot;&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;
Form Scope:
&lt;FONT color=maroon&gt;&amp;lt;cfdump var=&lt;FONT color=blue&gt;&quot;#form#&quot;&lt;/FONT&gt; label=&lt;FONT color=blue&gt;&quot;form&quot;&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&amp;lt;br&amp;gt;&lt;/FONT&gt;
&lt;FONT color=maroon&gt;&amp;lt;/cfif&amp;gt;&lt;/FONT&gt;
URL Scope:
&lt;FONT color=maroon&gt;&amp;lt;cfdump var=&lt;FONT color=blue&gt;&quot;#URL#&quot;&lt;/FONT&gt; label=&lt;FONT color=blue&gt;&quot;URL&quot;&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&amp;lt;br&amp;gt;&lt;/FONT&gt;
Session Scope:
&lt;FONT color=maroon&gt;&amp;lt;cfdump var=&lt;FONT color=blue&gt;&quot;#session#&quot;&lt;/FONT&gt; label=&lt;FONT color=blue&gt;&quot;session&quot;&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&amp;lt;br&amp;gt;&lt;/FONT&gt;
CGI Scope:
&lt;FONT color=maroon&gt;&amp;lt;cfdump var=&lt;FONT color=blue&gt;&quot;#CGI#&quot;&lt;/FONT&gt; label=&lt;FONT color=blue&gt;&quot;CGI&quot;&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&amp;lt;br&amp;gt;&lt;/FONT&gt;
Request:
&lt;FONT color=maroon&gt;&amp;lt;cfdump var=&lt;FONT color=blue&gt;&quot;#Request#&quot;&lt;/FONT&gt; label=&lt;FONT color=blue&gt;&quot;Request&quot;&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&amp;lt;br&amp;gt;&lt;/FONT&gt;
CFERROR:
&lt;FONT color=maroon&gt;&amp;lt;cfdump var=&lt;FONT color=blue&gt;&quot;#cferror#&quot;&lt;/FONT&gt; label=&lt;FONT color=blue&gt;&quot;CFERROR Variables.&quot;&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&amp;lt;br&amp;gt;&lt;/FONT&gt;
&lt;FONT color=maroon&gt;&amp;lt;/CFMAIL&amp;gt;&lt;/FONT&gt;
&lt;FONT color=gray&gt;&lt;I&gt;&amp;lt;!--- end of error email ---&amp;gt;&lt;/I&gt;&lt;/FONT&gt;
Place static content in here that you want users to see when there is an error. 
I usually put a saved HTML version of the main website with a notice that an error has occured...etc
&lt;FONT color=maroon&gt;&amp;lt;CFABORT&amp;gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1086</link>
	<dc:date>2006-09-26T08:42:29-07:00</dc:date>
	<dc:subject>ColdFusionMX</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1084">
	<title>Next Version of Adobe JRun : Beta Available</title>
	<description>&lt;P&gt;Although it has been quite a while since JRun 4.0 was released the next release is right around the corner. The JRun team has asked me to post the following message to find developers that are interested in test driving the next release of JRun.&lt;/P&gt;
&lt;HR&gt;

&lt;P&gt;The beta release of next version of JRun appserver,&amp;nbsp; code named Cheetah, is available. Adobe JRun Team is inviting serious evaluators to give feedback on this beta release. Contact vrreddy@adobe.com to be included in the Beta program.&lt;/P&gt;
&lt;P&gt;We believe Beta of JRun Cheetah is reasonably stable and reliable. And we plan to reward those who prove otherwise. We intend to give away fully functional JRun licenses to the users who report highest quality issues during the Beta.&lt;/P&gt;
&lt;P&gt;What More ! We are throwing open a JRun Sample Apps Challenge. We invite the beta users to develop sample applications exploiting the new JRun Cheetah feature sets. The best apps developed by you will be rewarded, and on qualification, will be featured as part JRun releases in samples section.&lt;/P&gt;
&lt;P&gt;Write Code, find Bugs ! Help us serve you better.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Regards,&lt;BR&gt;Vijayan Reddy,&lt;BR&gt;Adobe JRun Team.&lt;/P&gt;
&lt;HR&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1084</link>
	<dc:date>2006-05-01T06:10:19-07:00</dc:date>
	<dc:subject>ColdFusionMX,JRun</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1080">
	<title>Extensive list of ColdFusion MX and JRun debugging and performance tuning</title>
	<description>&lt;P&gt;Steven Erat pointed this link out to me regarding ColdFusion MX and JVM Tuning Links.&lt;BR&gt;&lt;A href=&quot;http://www.pixl8.co.uk/index.cfm/pcms/site.resources.cfmxtuning/&quot;&gt;http://www.pixl8.co.uk/index.cfm/pcms/site.resources.cfmxtuning/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Here are a few others:&lt;BR&gt;&lt;A href=&quot;http://devnulled.com/content/2005/09/coldfusion-mx-tuning-and-clustering-roundup/&quot;&gt;http://devnulled.com/content/2005/09/coldfusion-mx-tuning-and-clustering-roundup/&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Free stack trace utility&lt;BR&gt;&lt;A href=&quot;http://www.seefusion.com/seestack/seestack.cfm&quot;&gt;http://www.seefusion.com/seestack/seestack.cfm&lt;/A&gt; &lt;BR&gt;&lt;/P&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1080</link>
	<dc:date>2006-03-24T11:58:43-07:00</dc:date>
	<dc:subject>ColdFusionMX,JRun</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1079">
	<title>Obtaining a users geographical location based on their IP with IP2Location and ColdFusion - Part 2</title>
	<description>&lt;P&gt;In a &lt;A class=&quot;&quot; href=&quot;http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;amp;entry=1078&quot; target=&quot;&quot;&gt;previous blog posting&lt;/A&gt; I discussed how to obtain a users geographical location based on their IP with IP2Location and ColdFusion. &lt;A class=&quot;&quot; href=&quot;http://www.bpurcell.org/viewcontent.cfm?contentID=147&quot; target=&quot;&quot;&gt;In this article &lt;/A&gt;I explain how to import the data, break the data into multiple tables for optimization, then create the UDF to perform the lookup. I have had several requests for the stored procedures used to break up the IP2Location data. I have posted them along with the CF code.&lt;/P&gt;
&lt;P&gt;&lt;A class=&quot;&quot; href=&quot;http://www.bpurcell.org/viewcontent.cfm?contentID=147&quot; target=&quot;&quot;&gt;You can find the full article here&lt;/A&gt;&lt;/P&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1079</link>
	<dc:date>2006-02-20T10:13:23-07:00</dc:date>
	<dc:subject>ColdFusionMX,General Web Dev</dc:subject>
	</item>
		
  	<item rdf:about="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1078">
	<title>Obtaining a users geographical location based on their IP with IP2Location and ColdFusion</title>
	<description>&lt;P&gt;I recently was encountered with a problem where I needed to find what location a user was logging in from based on their IP. There were several reasons why such a system was needed that I highlight below.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Benefits of building such a system&lt;/STRONG&gt;&lt;/P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;
&lt;OL&gt;
&lt;LI&gt;Targeting fraudulent users that share their accounts 
&lt;LI&gt;Reducing credit card fraud 
&lt;LI&gt;Display native language and currency 
&lt;LI&gt;Redirect web pages based on geographical region 
&lt;LI&gt;Filter access from countries you do not do business with 
&lt;LI&gt;Geographical targeting for in house ad serving&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;I first started looking for third party solutions that could be accessed through a webservice but quickly arrived at &lt;A class=&quot;&quot; href=&quot;http://www.ip2location.com/&quot; target=&quot;&quot;&gt;IP2Location.com&lt;/A&gt;. &lt;A class=&quot;&quot; href=&quot;http://www.ip2location.com/&quot; target=&quot;&quot;&gt;IP2Location&lt;/A&gt; offers a downloadable CSV database that you can run on your own system. The cost is not significant depending on the amount of data you need. They offer IP-Country-Region-City-Latitude-Longitude-ZIPCode-ISP-Domain Database if you need that level of information.&amp;nbsp;&amp;nbsp; Anyways&amp;amp;on to the technical part. &lt;/P&gt;
&lt;P&gt;The CSV format that is provided is simple to import into any database, I was using MS SQL server and imported the data using DTS. There are over 4 million rows in the table so it does not make sense to query directly against the data that was imported for performance reasons. Instead to make the queries very quick that return location data I split the main table out into 20 tables, this left 200,000 rows in each table and proved to scale much better. Since IP2Location offers regular updates I wanted to be able to handle the update process and splitting of the data with very little work on my part. To do that I created two stored procedures. &lt;/P&gt;
&lt;P&gt;1.&amp;nbsp;IP2RangeTable The first stored procedure looks at the main table containing 4 million records and divides it into 20 different ranges. Those ranges are then stored in a range table containing the start, end and table name that will store the data. &lt;BR&gt;2.&amp;nbsp;The second stored procedure uses the IP2RangeTable created previously and bulk inserts the range of data from the main table into the range tables. They were simply called range1&amp;nbsp;- range20. &lt;/P&gt;
&lt;P&gt;Both of the stored procedures were written in such a way that the data could be broken out into X number of tables. It just takes the number of tables as a parameter. In this case I used 20. The further you break it out the better it will perform. &lt;/P&gt;
&lt;P&gt;Next, I created a UDF in ColdFusion (could be done in a stored proc as well) that takes an IP as an argument. The IP is converted to an IP Number. IP Numbers are used in the database to store the IP2Location content. An example for conversion follows.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;IP Number = 16777216*w + 65536*x + 256*y + z&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (1)&lt;BR&gt;where&lt;BR&gt;IP Address = w.x.y.z&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;For example, if IP address is &quot;202.186.13.4&quot;, then its IP Number &quot;3401190660&quot; is based on the formula (1).&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;IP Address = 202.186.13.4&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;So, w = 202, x = 186, y = 13 and z = 4&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;IP Number = 16777216*202 + 65536*186 + 256*13 + 4&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 3388997632 + 12189696 + 3328 + 4&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 3401190660 looks at the IP2Range&lt;/EM&gt; &lt;/P&gt;
&lt;P&gt;Once we have the IP number we need to find what table the record is stored in within the range1-rangeX tables. A query retrieves the values stored in IPRangeTable, from that data we can find the correct range table. Next a query is used against the range table to retrieve the location data. &lt;/P&gt;
&lt;P&gt;This may sound complicated but it is really simple. Unlimately you could just query the original table that you imported from the CSV but I found the queries to take way to long and caused a lot of stress on the db server under load. Even with the right indexes in place. By breaking the data out into range tables you increase the scalablity exponentially. &lt;/P&gt;
&lt;P&gt;Let me know if you have any other questions about this process and the benefits that the data provides.&lt;/P&gt;
&lt;P&gt;Later I will explain how the event gateway was used to log this information for every user that logged into the site as a background process.&lt;/P&gt;</description>
	<link>http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=1078</link>
	<dc:date>2006-02-07T12:08:05-07:00</dc:date>
	<dc:subject>ColdFusionMX,General Web Dev,JRun</dc:subject>
	</item>
		</rdf:RDF> 