It is currently April 19th, 2024, 6:47 pm

show your location (city) from ip?

Tips and Tricks from the Rainmeter Community
alphashadow
Posts: 1
Joined: May 17th, 2009, 6:32 pm

show your location (city) from ip?

Post by alphashadow »

i'm new to this. Is there any plugin or code to show a city name from your ip? or simply, is there a simple code to display text? (ex. "NEW YORK)
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: show your location (city) from ip?

Post by jsmorley »

alphashadow wrote:i'm new to this. Is there any plugin or code to show a city name from your ip? or simply, is there a simple code to display text? (ex. "NEW YORK)
Simply dislaying text that you define to show the city is easy.

[MeterCity]
Meter=STRING
X=1
Y=1
FontName=Tahoma
FontColor=255,255,255,255
Text="NEW YORK"

What would be more fun is to automate it by parsing a web site like http://www.ipaddresslocation.org/. So it detects your external IP address and returns the City and other information (country, country flag, language etc.)

Need a regexp guru to come up with the parse for the website... Volunteers?
furyfire
Posts: 4
Joined: May 27th, 2009, 10:47 am

Re: show your location (city) from ip?

Post by furyfire »

I just read the post about a request for location providing.
And I decided to make my own webservice.. The format is VERY basic xml and can be parsed using the following regex.
(?siU)<country>([A-Z]{2})</country>.*<region>([A-Za-z0-9 ]+)</region>.*<city>([A-Za-z]+)</city>
Similar goes for country etc etc.
#1 will be country
#2 region (Only usefull for people in the US)
#3 City

Please notice that the result will never be correct. Some IP's won't be shown and some will be far far off. (My location is reported 2000 miles wrong :-)) But for most this should work fairly allright.

http://geo.furyfire.info/

My webservice allso allows you to find the location of a userdefined IP
http://geo.furyfire.info/?ip=74.125.67.100
Will find the location of google.

And please be kind to my server haha
/regards
FuryFire

Check my website for more goodies!
http://furyfire.info
sgtevmckay

Re: show your location (city) from ip?

Post by sgtevmckay »

Here's a little idea, although I guess a regexp would need to be made.

If you know your IP Address, place it at the end of the following address string (After the = Sign)

This will bring up a web page that will give you location information for the US, unknown if the following address will work outside of country.
http://iplocationtools.com/ip_query.php?ip=

The following address, same instructions as above, is for country.
http://iplocationtools.com/ip_query_country.php?ip=

If you omit your IP after the = sign in the address it will focus on the closest available IP address

Also a neat trick of this site is that it can locate Domains :D
IE:
http://iplocationtools.com/ip_query2.php?ip=ebay.com

You can also track up to 25 IP Addresses at any given time: :D
IE:
http://iplocationtools.com/ip_query2.php?ip=74.125.45.100,206.190.60.37
Yes there is 2 Address in the query above

More information can be found here:
http://iplocationtools.com/ip_location_api.php

These folks are happy to Supply to Rainmeter and any other Parse, XML, API, etc that is needed.
Be careful about your update protocol times, or you will be blocked!

I will see what else I can come up with
sgtevmckay

Re: show your location (city) from ip?

Post by sgtevmckay »

jsmorley wrote: What would be more fun is to automate it by parsing a web site like http://www.ipaddresslocation.org/. So it detects your external IP address and returns the City and other information (country, country flag, language etc.)
Ok, hit a bit of a snag here, and I think a lot of folks may run into this.

Some Internet Service Providers are kind enough(?) to redirect your signals, buffer your IP address calls, and redirect to you.
In my case I use Qwest business for all the ISP needs.
They have given me a secure firewall re-route.
This means that you will never know my exact location.
I will also have a free floating address out of Denver, CO , Las Cruces, NM , or Albuquerque, NM.
If some of you would note, That I apparently had the same IP address during the contract that I recently completed in Albuquerque, NM. Know That I live in Santa Fe, NM.
No Matter where I go, if I have an account listed to my secure business re-direct, it will always appear with the same initial IP address, and is then filtered and redirect by Qwest.

I know; what does all this mean?
Well, quite simply a site that "auto detects" my location will be wrong every time, and may give up any one of 3 or more locations at any given time.
As I have stated I am in Santa Fe, NM, but an auto detect from Mr. Morley's website gives me the following information:

Hello, visitor from: Denver, United States
Your Country Code: US
Your IP State: Colorado
Your IP Address: 97.123.121.***
Your Hostname: 97-123-121-***.albq.qwest.net
Your ISP: Qwest Communications
Powered by IP Address Locator

Uhm.....Ooops :D
That's Qwest for you :roll:

Oh and by the way, that is not my direct IP Address, but the secure redirect from Qwest :twisted:
Omited final 3 digits of IP address, apologies

Update:
If I put my physical Local WAN IP Address, it detects my location just fine ;)
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: show your location (city) from ip?

Post by jsmorley »

Yes, if a user is doing any kind of "spoofing" of his IP address, this won't work.
sgtevmckay

Re: show your location (city) from ip?

Post by sgtevmckay »

In this case, it is the Service provider doing the spoof.
I know that there are a number of providers that do this automatically for their clients, and not on demand.

It is just something to keep in mind as we move forward ;)

I am an information monger, so I will want this skin too :D
sgtevmckay

Re: show your location (city) from ip?

Post by sgtevmckay »

I am also curious as to what readings may be given using a tool such as TOR?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: show your location (city) from ip?

Post by jsmorley »

Clearly this isn't going to be much use if a user's correct IP address isn't visible to the outside world. If you are using a proxie of some kind like TOR so you can download the R5 of Transformers 2 from Mininova.org without running afoul of the MPAA you are not going to WANT this to work... ;-)
sgtevmckay

Re: show your location (city) from ip?

Post by sgtevmckay »

No reason to give up the project :shock:

I say move forward :D