forked from acasadoalonso/SWiface-PHP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgettrackerdata.php
More file actions
executable file
·86 lines (81 loc) · 1.94 KB
/
gettrackerdata.php
File metadata and controls
executable file
·86 lines (81 loc) · 1.94 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
//$mysql=true;
$dbhost="casadonfs";
$dbuser="ogn";
$dbpass="ogn";
$dbname="SWIFACE";
$dtzlocal= new DateTimeZone('Europe/madrid');
$dtlocal = new DateTime("now", $dtzlocal);
$tslocal = $dtlocal->format("O");
if (isset($_GET['username']))
$username = $_GET['username'];
if (isset($_GET['cpassord']))
$cpassword = $_GET['cpassword'];
$contestname = $_GET['contestname'];
$querytype = $_GET['querytype'];
$trackerid = $_GET['trackerid'];
$starttime = $_GET['starttime'];
$endtime = $_GET['endtime'];
$compression = $_GET['compression'];
$syear = substr($starttime, 2, 6);
$stime = substr($starttime, 8);
$eyear = substr($endtime, 2, 6);
$etime = substr($endtime, 8);
$ini_array = parse_ini_file("/etc/local/SWSconfig.ini");
$DBpath=$ini_array['DBpath'];
$DB=$DBpath.'SWiface.db';
if ($querytype == "getintfixes")
{
$output= "{datadelay}0{/datadelay}\n";
$output= $tslocal;
$query1="SELECT idflarm, date, time, latitude, longitude, altitude FROM OGNDATA WHERE idflarm = '".$trackerid."'";
$query2=" and date = '".$syear."' and time >= '".$stime."' and time <= '".$etime."'"." order by time";
$query=$query1.$query2;
if ($mysql)
{
$db = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
}
else
{
$db = new SQLite3($DB, SQLITE3_OPEN_READONLY);
}
$results = $db->query($query);
if ($results)
{
if ($mysql)
{
$row = $results->fetch_array() ;
}
else
{
$row = $results->fetchArray() ;
}
while ($row)
{
$idflarm=$row[0];
$date =$row[1];
$time =$row[2];
$lati =$row[3];
$long =$row[4];
$alti =$row[5];
$output .= $idflarm.',20'. $date. $time. ','. $lati. ','. $long. ','. $alti. ",1\n";
if ($mysql)
{
$row = $results->fetch_array() ;
}
else
{
$row = $results->fetchArray() ;
}
}
$db->close();
}
if ($_GET["compression"] == "gzip")
{
print gzencode($output);
}
else {
print $output;
}
}
?>