This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtracking.php
69 lines (56 loc) · 1.87 KB
/
tracking.php
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
include "app_settings.php";
$data['lat'] = $_GET['lat'];
$data['lon'] = $_GET['lon'];
$data['timestamp'] = $_GET['timestamp'];
//$data['hdop'] = $_GET['hdop'];
//$data['altitude'] = $_GET['altitude'];
//$data['speed'] = $_GET['speed'];
//$data['leg'] = $_GET['leg'];
$data['key'] = $_GET['key'];
$tasker = $_GET['tasker'];
if ($data['key'] != $tracking_key){
echo "tracking key invalid";
return;
}
if ( !$data['lon'] || !$data['lat'] || !$data['timestamp'] ) {
echo "Faltan parametros";
return;
}
$lat = $data['lat'];
$lon = $data['lon'];
//$loc = $data['leg'];
if ($tasker) {
$lat = strtok($data['lat'],',');
$lon = strtok(',');
$data['lat'] = $lat;
$data['lon'] = $lon;
}
/*if ($loc) {
$file = "./resources/$loc.latest";
$hist = "./resources/$loc.history";
} else {
$file = "./resources/location.latest";
$hist = "./resources/location.history";
}
$f = fopen($file, 'w');
fwrite($f, serialize($data));
fclose($f);*/
/*$body = fopen($hist, 'a');
fwrite($body, "new google.maps.LatLng(${lat}, ${lon}),\n");
fclose($body);*/
$epochFecha = intval($data['timestamp'] / 1000);
$fecha = date('d/m/Y H:i:s', $epochFecha);
/*$body = fopen("./map2/textfile.txt", 'a');
fwrite($body, "${lat}\t${lon}\t${fecha}\tEpoch: ${epochFecha}\thttp://dev.openlayers.org/img/marker.png\t16,16\t-8,-16\n");
fclose($body);*/
//Nuevo sustituo por meses, para liberar carga
$ficherofecha = date('Y_m', $epochFecha);
$nombreficheromensual = "./map3/loc_${ficherofecha}.tsv";
$data = "${lat}\t${lon}\t${fecha}\tEpoch: ${epochFecha}\thttp://dev.openlayers.org/img/marker.png\t16,16\t-8,-16\n";
if (!file_exists($nombreficheromensual)) {
file_put_contents($nombreficheromensual, "lat\tlon\ttitle\tdescription\ticon\ticonSize\ticonOffset\n", FILE_APPEND);
}
file_put_contents($nombreficheromensual, $data, FILE_APPEND);
?>
<b>saving location <?=$lat?>, <?=$lon?> to file</b>