adolfintel 7 лет назад
Родитель
Сommit
2267646581
1 измененных файлов с 18 добавлено и 4 удалено
  1. 18 4
      Test backends/getIP.php

+ 18 - 4
Test backends/getIP.php

@@ -91,10 +91,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 {