Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
externalError #1
Get country from IP
Dear All,
I need to do the following with CF:
When a user visits my website, I need to get his/her IP address and thus know the country he/she is browsing from.
Is this possible?
Kindly advise
externalError Guest
-
Country of user
Hi, Is that possible to understand which country is the user from his or her GSM operator in smartphones with .NET Compact Framework? Any help... -
Module for Country/Country Codes Lists
Hi! My name is Shlomi Fish and I am a co-developer of the WWW::Form module: http://search.cpan.org/~bschmau/WWW-Form-1.13/ Benjamin Schmaus... -
Country
How can I view visitors country using php/apache? -
getting country stats
My client wants to see stats which tell him the number of hits he's getting from different countries. I'm coding page hit count stats myself in PHP... -
how to get the country ?
from the IP of the request ? -
PaulH #2
Re: Get country from IP
[url]http://www.sustainablegis.com/projects/geoLocator/[/url]
PaulH Guest
-
externalError #3
Re: Get country from IP
geoLocator did not work with me! Thanks anyway. I tried to code it as the
following (I have a database with IP_FROM, IP_TO, and Country fields):
<cfparam name='variables.ipnumber' default='0'> <cfparam name='variables.loc'
default='n/a'> <cfset dsn = 'iplocation'> <cfif isdefined('form.sbmt') and
len(form.ipaddress) gt 10> <cfset a = ListFirst(form.ipaddress,'.')> <cfset
a_rest = ListRest(form.ipaddress, '.')> <cfset b = ListFirst(a_rest, '.')>
<cfset b_rest = ListRest(a_rest, '.')> <cfset c = ListFirst(b_rest, '.')>
<cfset c_rest = ListRest(b_rest,'.')> <cfset d = ListFirst(c_rest, '.')>
<cfset ipnumber = a*(256*256*256) + b*(256*256) + c*256 + d> <cfquery
datasource='#dsn#' name='q' maxrows='1'> SELECT country FROM iplocation
WHERE ip_from <= #variables.ipnumber# AND ip_to >= #variables.ipnumber#
</cfquery> <cfoutput query='q'><cfset variables.loc =
'#q.country#'></cfoutput> </cfif> <cfform action='index.cfm' method='post'>
<table> <tr> <td>IP Address</td> <td><cfinput type='text' name='ipaddress'
size='20' required='yes' value='#cgi.remote_addr#'></td> </tr> <tr> <td>IP
Number</td> <td><input type='text' name='ipnumber' disabled
value='<cfoutput>#variables.ipnumber#</cfoutput>'></td> </tr> <tr>
<td>Location</td> <td><input type='text' name='loc' disabled
value='<cfoutput>#variables.loc#</cfoutput>'></td> </tr> <tr>
<td>&nbsp;</td> <td><input type='submit' name='sbmt' value='Calculate IP
#'></td> </tr> </table> </cfform> but I still have a problem retreiving the IP
using #CGI.remote_addr# if the machine is behind a router. Any solution to
this? Kindly advise
externalError Guest
-
-
externalError #5
Re: Get country from IP
No idea. Could you give some tips on How to use it.
Regards
externalError Guest
-
PaulH #6
Re: Get country from IP
it's outlined in the zip but:
- place the InetAddressLocator.jar file in the cf install
dir\wwwroot\web-inf\lib dir
- to simplify things place the index.cfm (that's a simple testbed) and the
geoLocator.cfc in the same dir & then edit this line in the index.cfm file:
geoLocator=createobject("component","cfc.geoLocato r");
to this:
geoLocator=createobject("component","geoLocator");
that's it.
PaulH Guest
-
eddymilner #7
Re: Get country from IP
Well you can use Web Services, i dont think it's what you want but try it , In
dreamweaver go Application window then press component then choose Web Services
, after when you fined that , add this link
[url]http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl[/url] in proxy genereter choose
ColdFusion . and press ok ..... in cood panel add this code <cfinvoke
webservice='http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl' method='resolveIP'
returnvariable='aIPInformation'> <cfinvokeargument name='IPaddress' value='put
ip here'/> <cfinvokeargument name='licenseKey' value=''/> </cfinvoke>
<cfoutput> #aIPInformation.country# #aIPInformation.stateProvince#
#aIPInformation.organization# #aIPInformation.city# </cfoutput> i hope it
will work
eddymilner Guest



Reply With Quote

