2017-02-26 10:13:26 +00:00
|
|
|
<?php
|
2018-02-09 07:41:28 +00:00
|
|
|
$ip="";
|
2017-12-20 06:28:21 +00:00
|
|
|
header('Content-Type: text/plain; charset=utf-8');
|
|
|
|
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
2018-02-09 07:41:28 +00:00
|
|
|
$ip=$_SERVER['HTTP_CLIENT_IP'];
|
2017-12-20 06:28:21 +00:00
|
|
|
} elseif (!empty($_SERVER['X-Real-IP'])) {
|
2018-02-09 07:41:28 +00:00
|
|
|
$ip=$_SERVER['X-Real-IP'];
|
2017-12-20 06:28:21 +00:00
|
|
|
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
2018-02-09 07:41:28 +00:00
|
|
|
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
|
2017-12-20 06:28:21 +00:00
|
|
|
} else {
|
2018-02-09 07:41:28 +00:00
|
|
|
$ip=$_SERVER['REMOTE_ADDR'];
|
2017-12-20 06:28:21 +00:00
|
|
|
}
|
2018-02-17 12:06:18 +00:00
|
|
|
$ip=preg_replace("/^::ffff:/", "", $ip);
|
2018-02-09 07:41:28 +00:00
|
|
|
$isp="";
|
|
|
|
if(isset($_GET["isp"])){
|
|
|
|
$json = file_get_contents("https://ipinfo.io/".$ip."/json");
|
|
|
|
$details = json_decode($json,true);
|
|
|
|
if(array_key_exists("org",$details)) $isp.=$details["org"]; else $isp.="Unknown ISP";
|
|
|
|
if(array_key_exists("country",$details)) $isp.=" (".$details["country"].")";
|
|
|
|
echo $ip." - ".$isp;
|
|
|
|
} else echo $ip;
|
2017-02-26 10:13:26 +00:00
|
|
|
?>
|