mirror of
https://github.com/librespeed/speedtest.git
synced 2026-10-08 21:43:02 +00:00
Added ISP info in getIP.php; Fixed a bug that could leave an aborted test running in background
This commit is contained in:
parent
d51e198522
commit
c835d9d0b9
5 changed files with 26 additions and 11 deletions
17
getIP.php
17
getIP.php
|
|
@ -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;
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue