Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfparam name="country" default="US">
- <cfparam name="results" default="">
- <cftry>
- <cfhttp url="http://freegeoip.net/xml/#cgi.remote_addr#" name="results" method="get" delimiter="#chr(10)#" timeout="10" />
- <cfset colname = results.columnlist> <!--- there's only one column and its name isn't something we can reference it by --->
- <cfset x = 0>
- <cfset a = []>
- <cfif IsQuery(results)>
- <cfloop query="#results#">
- <cfset x = x + 1>
- <cfset a[x] = results[colname]>
- <cfif a[x] contains "Latitude">
- <cfset mylat = REReplaceNoCase(a[x], "<[^[:space:]][^>]*>", "", "ALL")>
- </cfif>
- <cfif a[x] contains "Longitude">
- <cfset mylon = REReplaceNoCase(a[x], "<[^[:space:]][^>]*>", "", "ALL")>
- </cfif>
- <cfif a[x] contains "CountryCode">
- <cfset country = REReplaceNoCase(a[x], "<[^[:space:]][^>]*>", "", "ALL")>
- </cfif>
- </cfloop>
- </cfif>
- <cfif country eq "AU">
- <cflocation url="http://www.hearandlearn.com.au" addtoken="no">
- </cfif>
- <cfcatch type="any">
- <!--- <cfdump var="#cfcatch#" abort="true"> --->
- </cfcatch>
- </cftry>
- <!---
- Query
- Execution Time: 0 ms
- Record Count: 13
- Cached: No
- Lazy: No
- <?xml version=1.0 encoding=UTF-8?>
- 1 <Response>
- 2 <Ip>75.164.200.43</Ip>
- 3 <CountryCode>US</CountryCode>
- 4 <CountryName>United States</CountryName>
- 5 <RegionCode>OR</RegionCode>
- 6 <RegionName>Oregon</RegionName>
- 7 <City>Portland</City>
- 8 <ZipCode></ZipCode>
- 9 <Latitude>45.5234</Latitude>
- 10 <Longitude>-122.6762</Longitude>
- 11 <MetroCode>820</MetroCode>
- 12 <AreaCode>503</AreaCode>
- 13 </Response>
- --->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement