Added ISP info in getIP.php; Fixed a bug that could leave an aborted test running in background

This commit is contained in:
dosse91 2018-02-09 08:41:28 +01:00
parent d51e198522
commit c835d9d0b9
5 changed files with 26 additions and 11 deletions

View file

@ -1,12 +1,21 @@
<?php
$ip="";
header('Content-Type: text/plain; charset=utf-8');
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
echo $_SERVER['HTTP_CLIENT_IP'];
$ip=$_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['X-Real-IP'])) {
echo $_SERVER['X-Real-IP'];
$ip=$_SERVER['X-Real-IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
echo $_SERVER['HTTP_X_FORWARDED_FOR'];
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
echo $_SERVER['REMOTE_ADDR'];
$ip=$_SERVER['REMOTE_ADDR'];
}
$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;
?>