Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Other Web Development Languages (http://www.programmingforums.org/forum40.html)
-   -   Geolocation through IPs (http://www.programmingforums.org/showthread.php?t=12981)

grimpirate Apr 11th, 2007 11:45 PM

Geolocation through IPs
 
Before I start let me say that I have no idea how it is that latitude and longitude are determined from an IP address. I'm unsure if all methods use some sort of database, or if there's an actual way to determine the location based on the constituent numbers of the address. In any case, I found a website which allows you to type in an IP address and it provides the geographic data free of charge. So what I did was I used PHP to parse the content of this page into an array format and then store it in a database. Then another script turns it into a variable and passes the geographical information to a Flash file. Finally, this Flash file translates onto a globe the approximate positions of these regions. I just did this as a nifty little trick for tracking where people are accessing the main page of my software from. Thought someone might like to see it. Limitations: It only tracks the people that access the front page of my site, and it doesn't update dynamically. Sadly, the awardspace server won't allow me to use the PHP function file_get_contents() beyond the scope of the local URL. I'm forced to update the map's database files by hand.

DaWei Apr 12th, 2007 12:18 AM

It's strictly database, as there's no strict relation to lat/long. You can get DBs via a Google search. Nice implementation, though.

PhilBon Apr 12th, 2007 1:26 PM

What was the site that you got the long and lat points from? You might want to think about downloading a PHP Proxy and looking at the code that it uses to retrieve the website and adapt it for your site. If you are still needing to use the php function to access a site and can't do it, install PHP and MySQL onto a machine at home and run all the ip addresses through and have it load into the mysql database or have it be called by your current webserver and then have it return the long and lat points. If that makes any sense.

grimpirate Apr 12th, 2007 2:15 PM

Quote:

What was the site that you got the long and lat points from?
The site is http://www.geoiptool.com/
Quote:

You might want to think about downloading a PHP Proxy and looking at the code that it uses to retrieve the website and adapt it for your site.
No clue what you mean by a PHP Proxy.
Quote:

If you are still needing to use the php function to access a site and can't do it,
Any sort of data retrieval from sites beyond the actual awardspace server is not permissible I tried file/stream/socket anything I could think of and had no luck.
Quote:

install PHP and MySQL onto a machine at home and run all the ip addresses through and have it load into the mysql database or have it be called by your current webserver and then have it return the long and lat points. If that makes any sense.
When I stated that I update the database files by hand that's not exactly (I don't go into notepad and edit the files) what I meant. I'll explain it in a stepwise manner:
  1. My website logs all the ips to a file called visitors.txt
  2. I periodically download visitors.txt onto my home computer
  3. Using my local PHP setup I run a file called grimbbstats.php which takes the file visitors.txt breaks it into individual ips and then runs each ip through the site. Furthermore, it creates a series of database entries (not using MySQL but my own relational flat file database implementation) into a folder.
  4. The created database entries are then uploaded into a folder on my site.
  5. Finally, the map.swf file accesses the database by first accessing a file called locate.php which parses the database into latitude and longitude in a flash understandable way.
  6. You see the map with its little green dots. :)
So the only limitation is the lack of being able to access foreign sites from my server. I could probably do this with javascript, buuuuuuut I don't like javascript. I like all my sites to function without the need for javascript. Reinventing wheels is fun dur dur. Ahh you can only enjoy DaWei's praise for so long before you burn yourself out. You flew too close to the sun Grim! My wax scripts are melting, melting!

PhilBon Apr 12th, 2007 7:20 PM

a PHP Proxy, is a web based proxy: http://www.phproxy.org/ to where it's coded in php. Then again it sounds like you've already done something like it. You could probably automate that whole process that you use:
Quote:

1. My website logs all the ips to a file called visitors.txt
2. I periodically download visitors.txt onto my home computer
3. Using my local PHP setup I run a file called grimbbstats.php which takes the file visitors.txt breaks it into individual ips and then runs each ip through the site. Furthermore, it creates a series of database entries (not using MySQL but my own relational flat file database implementation) into a folder.
4. The created database entries are then uploaded into a folder on my site.
5. Finally, the map.swf file accesses the database by first accessing a file called locate.php which parses the database into latitude and longitude in a flash understandable way.
6. You see the map with its little green dots.
That's only if you don't want to deal with all that uploading and downloading.

physicist Apr 13th, 2007 12:39 AM

well it says im in pennsylvania, LOL im not even close really...

Infinite Recursion Apr 13th, 2007 1:06 AM

I suppose it is where your IP is registered... not necessarily your physical location.

DaWei Apr 13th, 2007 2:17 AM

Yup. Mine shows about 100 miles southeast. My site's server is in Toronto, but its IP shows in Calgary. That's quite a fur piece.


All times are GMT -5. The time now is 2:05 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC