That's a really good idea. Probably a good approach to take as this is likely 
not the only time this kind of approach could come in handy for you.

So the MaxMind API: is that making calls to their site or using their 
downloadable file? If it's using their downloadable file, you should consider 
your work here to have 2 parts: downloading and processing the file and then 
working with the data as needed.

In regards to downloading the file, this blog post of Ben Nadel's may be useful 
for you: 
http://www.bennadel.com/blog/1903-Parsing-CSV-Data-With-ColdFusion-s-CFHTTP-Tag.htm.
 Because of the fact that you're working with data that changes infrequently 
and that is going to be needed on every request, you're best off to keep it in 
the Application scope. I'd put code in the OnApplicationStart() method of 
Application.cfc that calls out to get the CSV file and puts in a query in the 
Application scope.

Once you've done that, all you have to do on every request (if this is 
happening for every page in the site then I would do it in the OnRequestStart() 
method of Application.cfc; if it's just the home page, I would do it directly 
for that page, whatever that may means for the framework you're working with) 
is query the data. I don't know how the data is structured; if it literally has 
every single IP address in the world then actually my point above about keeping 
it in memory might be incorrect because that might just be too much data to 
keep in memory! But if it's more general ranges then I'd think you should be 
fine. In any event, the user's IP address is in CGI.REMOTE_ADDR so you just 
provide that in the where clause (if the data only contains ranges you might 
have to do a string operation to remove the last octet or whatever from 
CGI.REMOTE_ADDR). After you've done the query, you'll have back the data you 
need to do the redirect with <cflocation> or whatever you want to do for the 
redirection.

Josh

From: Dawn Hoagland <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Date: Tuesday, September 4, 2012 6:52 PM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: Re: [ACFUG Discuss] Need a way to redirect users based on country

FWIW - ColdFusion is written in Java.  You can put their library in your class 
path (or use a java loader) and call it directly.  It sounds harder than it 
actually is to do.

On Tue, Sep 4, 2012 at 6:28 PM, Michael Brown 
<[email protected]<mailto:[email protected]>> wrote:
Thanks Josh,

The challenge is to redirect users when the hit the sites home page based on 
the country ID.   This seems to require a two step approach.  First I need the 
ip address from the user, then require a look-up based on such to determine the 
country of the IP address.  All transparent to the site visitor MaxMind 
supplies an API to get real-time data on IP addresses worldwide.  They provide 
a CSV file that is updated monthly that can be downloaded.

I thought there may be a CF script that could simply(easy for me to say) do the 
look-up and than provide the redirect.  As far as the GEO Coding is concerns, 
I'm not set on MaxMind as the data source.  Maxmind seems to have scripts for 
everything but CF, see: http://dev.maxmind.com/geoip/downloadable

I hope this makes more sense. :)

Big Thanks for the reply and input!

On Tue, Sep 4, 2012 at 5:10 PM, Josh Adams 
<[email protected]<mailto:[email protected]>> wrote:
Is there a challenge that you're facing or is it just that you would love it if 
you didn't have to do the coding? I don't fault you if you don't want to do the 
coding—why reinvent the wheel if you don't have to? But if that's your 
situation, I think Charlie is right that it looks like you're not going to find 
the code you need via this list at least. On the bright side, I don't know the 
ins and outs of the MaxMind Data (had never heard of it until this post) but 
off the cuff this doesn't seem to me it would be a difficult thing to 
accomplish. And if I'm missing something, well then we're back to my question 
about a challenge you're facing.

Josh

From: Charlie Arehart <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Date: Monday, September 3, 2012 8:12 PM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: RE: [ACFUG Discuss] Need a way to redirect users based on country

That’s a REALLY specific need, Michael. I’m afraid the silence is just because 
there are no folks on this list who’ve used that specific dataset.

Maybe if you propose a more generic problem, or what you do and do not know how 
to do with the specific aspect of what you may be trying to do with the lookup, 
someone may be able to offer a suggestion.

/charlie

From:[email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf 
Of Michael Brown
Sent: Saturday, September 01, 2012 8:26 PM
To: Michael Brown
Cc: [email protected]<mailto:[email protected]>
Subject: [ACFUG Discuss] Need a way to redirect users based on country

Any takers?


Any known CF scripts that can incorporate MaxMind Data for redirects based on 
Country?  Looking for small foot print script.  Seen a few out there but NON 
written for CF.  Any help would be great.

Sent from my iPad

On Aug 29, 2012, at 5:53 PM, Michael Brown 
<[email protected]<mailto:[email protected]>> wrote:
Good Evening Group Members,

Any known CF scripts that can incorporate MaxMind Data for redirects based on 
Country?  Looking for small foot print script.  Seen a few out there but 
written for CF.  Any help would be great.

--
Michael Brown
770-605-5240<tel:770-605-5240>
Marketing Solutions with vision!
http://www.singleconcepts.com



-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink<http://www.fusionlink.com>
-------------------------------------------------------------

-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink<http://www.fusionlink.com>
-------------------------------------------------------------



--
Michael Brown
770-605-5240<tel:770-605-5240>

Marketing Solutions with vision!
http://www.singleconcepts.com





--
Dawn




-------------------------------------------------------------

To unsubscribe from this list, manage your profile @ 

http://www.acfug.org?fa=login.edituserform



For more info, see http://www.acfug.org/mailinglists

Archive @ http://www.mail-archive.com/discussion%40acfug.org/

List hosted by http://www.fusionlink.com

-------------------------------------------------------------


Reply via email to