Improved performance of getIP.php
This commit is contained in:
parent
78c0190618
commit
7e3a1dc50e
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
telemetry/idObfuscation_salt.php
|
||||
getIP_serverLocation.php
|
||||
|
|
2
doc.md
2
doc.md
|
@ -41,6 +41,8 @@ Later we'll see how to use the test without PHP, and how to configure the teleme
|
|||
|
||||
__Important:__ keep all the files together; all paths are relative to the js file
|
||||
|
||||
__Important:__ Make sure PHP is allowed to write to the directory where you're installing the speedtest because getIP.php needs to create a cache file to improve performance.
|
||||
|
||||
## Basic usage
|
||||
You can start using this speedtest on your site without any special knowledge.
|
||||
Start by copying one of the included examples. Here's a description for each of them:
|
||||
|
|
22
getIP.php
22
getIP.php
|
@ -89,10 +89,24 @@ if (isset($_GET["isp"])) {
|
|||
}
|
||||
if (isset($_GET["distance"])) {
|
||||
if ($clientLoc) {
|
||||
$json = file_get_contents("https://ipinfo.io/json");
|
||||
$details = json_decode($json, true);
|
||||
if (array_key_exists("loc", $details)){
|
||||
$serverLoc = $details["loc"];
|
||||
$locFile="getIP_serverLocation.php";
|
||||
$serverLoc=null;
|
||||
if(file_exists($locFile)){
|
||||
require $locFile;
|
||||
}else{
|
||||
$json = file_get_contents("https://ipinfo.io/json");
|
||||
$details = json_decode($json, true);
|
||||
if (array_key_exists("loc", $details)){
|
||||
$serverLoc = $details["loc"];
|
||||
}
|
||||
if($serverLoc){
|
||||
$lf=fopen($locFile,"w");
|
||||
fwrite($lf,chr(60)."?php\n");
|
||||
fwrite($lf,'$serverLoc="'.addslashes($serverLoc).'";');
|
||||
fwrite($lf,"\n");
|
||||
fwrite($lf,"?".chr(62));
|
||||
fclose($lf);
|
||||
}
|
||||
}
|
||||
if ($serverLoc) {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue