• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4608
  • Last Modified:

Get ISP from IP Address using PHP **URGENT 500 POINTS**

I want to get a users ISP, City and State from their IP address. I don't really have $320 for GeoIP what else can I do and GeoLite City is very inaccurrate. Is there anyway I can use dig or something to do it.

Max
0
TheMaximumWeasel
Asked:
TheMaximumWeasel
  • 3
  • 3
  • 2
  • +1
1 Solution
 
ixtiCommented:
If you are using PHP 5.x then you can use PEAR package Net_GeoIP (http://pear.php.net/package/Net_GeoIP)
0
 
Joseph MelnickCommented:
Hello TheMaximumWeasel,

A good place to aquire ip to location data is www.hostip.info. These people provide this data at no cost. Read and follow their terms and agreements and us their data. Very Cool.

It provides data for IP address lookup to City, State, Country.

Joseph Melnick (jmelnick)
0
 
missilesiloCommented:
Try an ARIN Whois.

<?php

$ip_address = $_SERVER["REMOTE_ADDR"];

$content = file_get_contents("http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip_address");

$pos = strpos($content, "<pre") + 4;
$content = substr($content,$pos);

$pos = strpos($content, "OrgName:") + 8;
$content = substr($content,$pos);
$pos = strpos($content, "\n");
$isp_name = trim(substr($content,0,$pos));
$content = substr($content,$pos);

$pos = strpos($content, "City:") + 5;
$content = substr($content,$pos);
$pos = strpos($content, "\n");
$city = trim(substr($content,0,$pos));
$content = substr($content,$pos);

$pos = strpos($content, "StateProv:") + 10;
$content = substr($content,$pos);
$pos = strpos($content, "\n");
$state = trim(substr($content,0,$pos));
$content = substr($content,$pos);

echo "ISP: $isp_name\n";
echo "City: $city\n";
echo "State: $state\n";

?>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Joseph MelnickCommented:
This approach is ok for low volume lookups but I expect that are limit. Joseph
0
 
TheMaximumWeaselAuthor Commented:
I like the idea of the net_geoIP but does that give more than the country and is it accurate. cause just mod_geoip is just the country and if I get the geoLite city from maxmind (opensource geoip) it isn't accurate at all.

Max
0
 
ixtiCommented:
I didn't used this packege before, so I can't say more info about it.
You can get info about what Net_GeoIP packege can do here:

http://pear.php.net/package/Net_GeoIP/docs/latest/Net_GeoIP/Net_GeoIP.html

As I understand, this package can use free and commercial DataBase.
0
 
Joseph MelnickCommented:
Hello TheMaximumWeasel,

net_geoip uses maxmind free or commercial databases so your free option is country only data.

Did you look into hostip.info?

Joseph Melnick
0
 
missilesiloCommented:
The code I posted retrieves the ISP, City and State from an IP address.

Have you tried it?
0
 
missilesiloCommented:
Thanks for the A
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now