Joined: 25 Jun 2004 Posts: 126 Location: Liverpool(home) or Derby(uni), UK votes: 3
Posted: Thu Jun 01, 2006 2:31 pm Post subject: IP info & Google maps locator
I am really offering two seperate services that should be used in conjunction, but could be used seperately if desired.
Before I begin, I would first like to say that this is running on a home server, so I cannot guarantee its stability. If anyone would be so kind as to offer some of their own, more stable server space for this, then it would be much apreciated. The files to run this service are attatched.
Not all IPs can be located. The website used to retrieve the information seems to cover most of america, but not many other countries. Also since another site is used to locate the IPs, I cannot guarantee their accuracy, however most of the examples I tried (not posted) seem to be pretty good.
(example of an un-locatable [or in this case, impossible] IP)
[Teario] says (14:50):
!ipinfo 209.59.555.555
[Crybot] says (14:50):
Unable to locate the given IP
(locating my own IP [which i have removed from the quote] it could not find my city, so no co-ordinates were given)
[Teario]says (14:53):
!ipinfo myip.myip.myip.myip
[Crybot] says (14:53):
City: (Unknown city)
Country: UNITED KINGDOM
Country abbrev: UK
(example of *** as IP (aparently a private address))
[Teario] says (14:53):
!ipinfo ***.***.***.***
[Crybot] says (14:53):
City: (Private Address)
Country: (Private Address)
Country abbrev: XX
(example of no ip address provided)
[Teario] says (14:54):
!ipinfo
[Crybot] says (14:54):
City: (Unknown City?)
Country: (Unknown Country?)
Country abbrev: XX
Well that is pretty much it. I hope you enjoy using the service and put it to good use
remember: the files are attatched if you would like to offer to run this service, or also if youre just interested in seeing how I put it together (and maybe improving my code? )
Joined: 25 Jun 2004 Posts: 126 Location: Liverpool(home) or Derby(uni), UK votes: 3
Posted: Thu Mar 08, 2007 11:59 am Post subject:
There is a way you can do it. In PHP you can get the ip address of the visitor to the site by using $_SERVER['REMOTE_ADDR']
Then you can use other services to locate the ip address for you, and give you the latitude and longitude. After that you just have to show a map. If you use the google maps api, then you can create a new marker at the co-ordinates you got from locating the ip.
Im pretty sure the above script gets the ip from the pages html code. There are probably services out there that will format them in a way much easier to use so search around first.