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
LVL 4
TheMaximumWeaselAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ixtiCommented:
If you are using PHP 5.x then you can use PEAR package Net_GeoIP (http://pear.php.net/package/Net_GeoIP)
Joseph MelnickSenior Software Developer - Pharmacy ApplicationsCommented:
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)
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";

?>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Joseph MelnickSenior Software Developer - Pharmacy ApplicationsCommented:
This approach is ok for low volume lookups but I expect that are limit. Joseph
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
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.
Joseph MelnickSenior Software Developer - Pharmacy ApplicationsCommented:
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
missilesiloCommented:
The code I posted retrieves the ISP, City and State from an IP address.

Have you tried it?
missilesiloCommented:
Thanks for the A
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.