-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathload.php
More file actions
45 lines (40 loc) · 1.89 KB
/
Copy pathload.php
File metadata and controls
45 lines (40 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?
function getUserIP() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED']))
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
header("Access-Control-Allow-Origin: *");
error_reporting(E_ALL);
$id = $_GET["id"];
$definition = file_get_contents("gs://aircraft-bucket/" . $id . (isset($_GET["cockpit"]) ? "/cockpit.json" : "/aircraft.json"));
$definition = str_replace("http://", "https://",$definition);
$descriptor = explode(PHP_EOL, file_get_contents("gs://aircraft-bucket/" . $id . "/descriptor.txt"));
$descriptor[2] = str_replace("http://", "https://",$descriptor[2]);
$encoded = base64_encode($definition);
$result = new stdClass();
$result->id = intval($id);
$result->name = preg_replace('/[\x00-\x1F\x7F\xA0]/u', '', $descriptor[0]);
$result->altId = intval(preg_replace('/[\x00-\x1F\x7F\xA0]/u', '', $descriptor[1]));
$result->fullPath = preg_replace('/[\x00-\x1F\x7F\xA0]/u', '', $descriptor[2]);
$result->isPremium = 0;
$result->isCommunity = 0;
$result->definition = $encoded;
$json_result = json_encode($result);
echo $json_result;
file_put_contents("gs://aircraft-bucket/stats.csv", file_get_contents("gs://aircraft-bucket/stats.csv") . "\n" . getUserIP() . ", " . date(DATE_RFC2822));