natas

IP to Location with PHP?

22 posts in this topic

Does anyone know if there are any free sites or services that let you input an IP and it gives you back the location info? I've been checking google and found a bunch of pay software, but its not really what I'm looking for. I'd like to be able to query something with PHP and get back the results instantly.

Thanks!

0

Share this post


Link to post
Share on other sites

I saw that but it isnt free.

Having it be as easy as "$City=$_SERVER["HTTP_GEOBYTESCITY"];" would be nice though.

0

Share this post


Link to post
Share on other sites
Does anyone know if there are any free sites or services that let you input an IP and it gives you back the location info? I've been checking google and found a bunch of pay software, but its not really what I'm looking for. I'd like to be able to query something with PHP and get back the results instantly.

Thanks!

Do you mean like the "City From IP" feature on DNS Suff ? Not sure if that's what you're talking about...

0

Share this post


Link to post
Share on other sites

yo vox. yeah thats what im talking about! they use the ip2location.com database apparently though (which isnt free. damn!). ip2location looks pretty good though.

0

Share this post


Link to post
Share on other sites

There's an XSS vulnerability in IP2Phrase that you can use to potentially steal the city, state, and country information, put it into a cookie, and use it however you want with the $_COOKIE global hash array.

Edited by tokachu
0

Share this post


Link to post
Share on other sites

Here, wrote a basic script for you:

<html>
<body>

<form action="ip2.php" method="POST">
Enter IP: <input type="text" name="ipaddress" />
<input type="submit" />
</form>

</body>
</html>

<?php
$url = "http://www.hostip.info/api/get.html?ip=$ipaddress";
$tempdata = fopen($url, 'r');
$ipinfo = fread($tempdata, 100);
fclose($tempdata);

print ($ipinfo);
?>

Worked for me the first times. Not anymore. Could be some kind of limit of lookups per IP on their end. Drats.

Edited by Seal
0

Share this post


Link to post
Share on other sites

do you mean just like reverse dns lookup? google it...

0

Share this post


Link to post
Share on other sites

I wouldn't really trust that hostip.info place. They claim that Bell's Mind is in Zurich, Switzerland... in a river (Google Earth). :blink:

0

Share this post


Link to post
Share on other sites

yeah unfortunately i dont even want to use that hostip place. ntheory is right, they are not accurate at all. all the other sites i have tried looked up my ip properly, except that one.

0

Share this post


Link to post
Share on other sites

ehhh....thats not really what im looking for. that ip2location database is looking pretty good right about now.... i cant believe there are so many sites that you can query for this kind of information, but not easily automate.

0

Share this post


Link to post
Share on other sites

We used the cheapest IP2Location database at my old job, and it was pretty decent. When you order it, you get a few different formats of database, but they are all pretty much the same. Start IP address, End IP Address, Country name, Country Code, etc as appropariate for the database you'ev got. The bigger the database, the more specific the data is obviously.

One thing I have just found that you could very easily use is the IP2Location Dynamic Phrase thing. It's a javascript that you can include in your site to write stuff out for the end user, but they've made it in such a way that you could easily have a script use it and rip out what you need. It produces a single document.write line with your template in it. Stick the following into your browser and see what you get :)

http://www.ip2phrase.com/ip2phrase.asp?tem...F<ISP>%2F

Reading the result and splitting it on / charactors should be easy enough, and you have your location data free of charge :)

--

Graham

0

Share this post


Link to post
Share on other sites

that one is kind of cool, but argh!!! it doesnt give the state! why give the city if your not gonna associate the state with it!!

0

Share this post


Link to post
Share on other sites
sazzer's link gave ME the state...

Same here:

'/xx.xx.xx.xx/CANADA/CA/ONTARIO/OTTAWA/ROGERS CABLE INC. SLNT/

0

Share this post


Link to post
Share on other sites

I was thinking of something along these lines:

<!-- BEGIN GEOLOCATION -->
<script language="JavaScript"
src="http://www.ip2phrase.com/ip2phrase.asp?template=%27%29%3B_Qc%3D%27<CITY>%27%3B_Qs%3D%27<REGION>%27%3B_Qu%3D%27<COUNTRY>%27%3B_Qi%3D%27<ISP>%27%3B%2F%2F">
</script>
<script language="JavaScript"><!--
 setCookie("CITY", _Qc);
 setCookie("REGION", _Qs);
 setCookie("COUNTRY", _Qu);
 setCookie("ISP", _Qi);
//--></script>
<!-- END GEOLOCATION -->

Another thing: I don't think it's the most accurate database. In fact, it's off by 75 miles in my case, though Google (of course) pinpoints my city exactly. So if you're aiming for using the database for really targeted advertisement, you might as well use Google.

0

Share this post


Link to post
Share on other sites

can you find some one exact location from an ip as in there addres if they live in new york or some city (im useing new york as an example) could you find out that they live on 123 first street just from there ip

0

Share this post


Link to post
Share on other sites
can you find some one exact location from an ip as in there addres if they live in new york or some city (im useing new york as an example) could you find out that they live on 123 first street just from there ip

No.

0

Share this post


Link to post
Share on other sites
can you find some one exact location from an ip as in there addres if they live in new york or some city (im useing new york as an example) could you find out that they live on 123 first street just from there ip

No.

but couldnt this be posible in the future i think so

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now