How do I find out the ISP provider of a person viewing a PHP page?
Is it possible to use PHP to track or reveal it?
If I use something like the following:
A quick alternative. (This website allows up to 50 calls per minute.)
$json=file_get_contents("https://extreme-ip-lookup.com/json/$ip");
extract(json_decode($json,true));
echo "ISP: $isp ($city, $region, $country)<br>";
API details at the bottom of the page.
GeoIP will help you with this: http://www.maxmind.com/app/locate_my_ip
There is a php library for accessing geoip data: http://www.maxmind.com/app/php
Attention though, you need to put the geoip db on your machine in order to make it work, all instructions are there :)
If all these answers are not useful then you can try API way.
1.http://extreme-ip-lookup.com/json/[IP ADDRESS HERE]
EXAMPLE: http://extreme-ip-lookup.com/json/106.192.146.13
2.http://ip-api.com/json/[IP ADDRESS HERE]
EXAMPLE: http://ip-api.com/json/113.14.168.85
once it works for you don't forget to convert JSON into PHP.
Why not use ARIN's REST API.
<?php
// get IP Address
$ip=$_SERVER['REMOTE_ADDR'];
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, 'http://whois.arin.net/rest/ip/' . $ip);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
// execute
$returnValue = curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
$result = json_decode($returnValue);
echo <<<END
<pre>
Handle: {$result->net->handle->{'$'}}
Ref: {$result->net->ref->{'$'}}
Name: {$result->net->name->{'$'}}
echo "OrgRef: {$result->net->orgRef->{'@name'}}";
</pre>
END;
// eof
https://www.arin.net/resources/whoisrws/whois_api.html
Sometimes fields change, so this is the improvement of the above post.
<body>
<table align="center">
<?
$ip=$_SERVER['REMOTE_ADDR'];
$url=file_get_contents("http://whatismyipaddress.com/ip/$ip");
preg_match_all('/<th>(.*?)<\/th><td>(.*?)<\/td>/s',$url,$output,PREG_SET_ORDER);
for ($q=0; $q < 25; $q++) {
if ($output[$q][1]) {
if (!stripos($output[$q][2],"Blacklist")) {
echo "<tr><td>".$output[$q][1]."</td><td>".$output[$q][2]."</td></tr>";
}
}
}
?>
</table>
</body>
You can obtain this information from ipinfo.io or similar services.
<?php
/**
* Get ip info from ipinfo.io
*
* There are other services like this, for example
* http://extreme-ip-lookup.com/json/106.192.146.13
* http://ip-api.com/json/113.14.168.85
*
* source: https://stackoverflow.com/a/54721918/3057377
*/
function getIpInfo($ip = '') {
$ipinfo = file_get_contents("https://ipinfo.io/" . $ip);
$ipinfo_json = json_decode($ipinfo, true);
return $ipinfo_json;
}
function displayIpInfo($ipinfo_json) {
var_dump($ipinfo_json);
echo <<<END
<pre>
ip : {$ipinfo_json['ip']}
city : {$ipinfo_json['city']}
region : {$ipinfo_json['region']}
country : {$ipinfo_json['country']}
loc : {$ipinfo_json['loc']}
postal : {$ipinfo_json['postal']}
org : {$ipinfo_json['org']}
</pre>
END;
}
function main() {
echo("<h1>Server IP information</h1>");
$ipinfo_json = getIpInfo();
displayIpInfo($ipinfo_json);
echo("<h1>Visitor IP information</h1>");
$visitor_ip = $_SERVER['REMOTE_ADDR'];
$ipinfo_json = getIpInfo($visitor_ip);
displayIpInfo($ipinfo_json);
}
main();
?>