|
@@ -13,33 +13,33 @@ discard block |
|
|
block discarded – undo |
|
13
|
13
|
* @param Array $filter the filter |
|
14
|
14
|
* @return Array the SQL part |
|
15
|
15
|
*/ |
|
16
|
|
- public function getFilter($filter = array(),$where = false,$and = false) { |
|
|
16
|
+ public function getFilter($filter = array(), $where = false, $and = false) { |
|
17
|
17
|
global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
|
18
|
18
|
$filters = array(); |
|
19
|
19
|
if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
|
20
|
20
|
if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
21
|
21
|
$filters = $globalStatsFilters[$globalFilterName]; |
|
22
|
22
|
} else { |
|
23
|
|
- $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
|
23
|
+ $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
24
|
24
|
} |
|
25
|
25
|
} |
|
26
|
26
|
if (isset($filter[0]['source'])) { |
|
27
|
|
- $filters = array_merge($filters,$filter); |
|
|
27
|
+ $filters = array_merge($filters, $filter); |
|
28
|
28
|
} |
|
29
|
|
- if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
|
29
|
+ if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
30
|
30
|
$filter_query_join = ''; |
|
31
|
31
|
$filter_query_where = ''; |
|
32
|
|
- foreach($filters as $flt) { |
|
|
32
|
+ foreach ($filters as $flt) { |
|
33
|
33
|
if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
34
|
34
|
if (isset($flt['source'])) { |
|
35
|
|
- $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
|
35
|
+ $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
36
|
36
|
} else { |
|
37
|
|
- $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
|
37
|
+ $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
38
|
38
|
} |
|
39
|
39
|
} |
|
40
|
40
|
} |
|
41
|
41
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
42
|
|
- $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
|
42
|
+ $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
43
|
43
|
} |
|
44
|
44
|
if (isset($filter['ident']) && !empty($filter['ident'])) { |
|
45
|
45
|
$filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
@@ -67,22 +67,22 @@ discard block |
|
|
block discarded – undo |
|
67
|
67
|
$filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
|
68
|
68
|
} |
|
69
|
69
|
} |
|
70
|
|
- $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
|
70
|
+ $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
71
|
71
|
} |
|
72
|
72
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
73
|
|
- $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
73
|
+ $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
74
|
74
|
} |
|
75
|
75
|
if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
76
|
76
|
elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
77
|
77
|
if ($filter_query_where != '') { |
|
78
|
|
- $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
|
78
|
+ $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
79
|
79
|
} |
|
80
|
80
|
$filter_query = $filter_query_join.$filter_query_where; |
|
81
|
81
|
return $filter_query; |
|
82
|
82
|
} |
|
83
|
83
|
|
|
84
|
84
|
// marine_archive |
|
85
|
|
- public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
|
85
|
+ public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
86
|
86
|
/* |
|
87
|
87
|
require_once(dirname(__FILE__).'/class.Marine.php'); |
|
88
|
88
|
if ($over_country == '') { |
|
@@ -94,16 +94,16 @@ discard block |
|
|
block discarded – undo |
|
94
|
94
|
*/ |
|
95
|
95
|
$country = $over_country; |
|
96
|
96
|
// Route is not added in marine_archive |
|
97
|
|
- $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
|
97
|
+ $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
98
|
98
|
VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
|
99
|
99
|
|
|
100
|
|
- $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
|
100
|
+ $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
101
|
101
|
|
|
102
|
102
|
try { |
|
103
|
103
|
$sth = $this->db->prepare($query); |
|
104
|
104
|
$sth->execute($query_values); |
|
105
|
105
|
$sth->closeCursor(); |
|
106
|
|
- } catch(PDOException $e) { |
|
|
106
|
+ } catch (PDOException $e) { |
|
107
|
107
|
return "error : ".$e->getMessage(); |
|
108
|
108
|
} |
|
109
|
109
|
return "success"; |
|
@@ -123,9 +123,9 @@ discard block |
|
|
block discarded – undo |
|
123
|
123
|
|
|
124
|
124
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125
|
125
|
//$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126
|
|
- $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
|
126
|
+ $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
127
|
127
|
|
|
128
|
|
- $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
|
128
|
+ $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
129
|
129
|
|
|
130
|
130
|
return $spotter_array; |
|
131
|
131
|
} |
|
@@ -144,7 +144,7 @@ discard block |
|
|
block discarded – undo |
|
144
|
144
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145
|
145
|
//$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146
|
146
|
//$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147
|
|
- $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
|
147
|
+ $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
148
|
148
|
|
|
149
|
149
|
// $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
|
150
|
150
|
/* |
|
@@ -157,7 +157,7 @@ discard block |
|
|
block discarded – undo |
|
157
|
157
|
} |
|
158
|
158
|
$spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
|
159
|
159
|
*/ |
|
160
|
|
- $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
|
160
|
+ $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
161
|
161
|
|
|
162
|
162
|
return $spotter_array; |
|
163
|
163
|
} |
|
@@ -172,14 +172,14 @@ discard block |
|
|
block discarded – undo |
|
172
|
172
|
{ |
|
173
|
173
|
date_default_timezone_set('UTC'); |
|
174
|
174
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175
|
|
- $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
|
175
|
+ $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
176
|
176
|
|
|
177
|
177
|
// $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
|
178
|
178
|
|
|
179
|
179
|
try { |
|
180
|
180
|
$sth = $this->db->prepare($query); |
|
181
|
181
|
$sth->execute(array(':id' => $id)); |
|
182
|
|
- } catch(PDOException $e) { |
|
|
182
|
+ } catch (PDOException $e) { |
|
183
|
183
|
echo $e->getMessage(); |
|
184
|
184
|
die; |
|
185
|
185
|
} |
|
@@ -198,14 +198,14 @@ discard block |
|
|
block discarded – undo |
|
198
|
198
|
{ |
|
199
|
199
|
date_default_timezone_set('UTC'); |
|
200
|
200
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201
|
|
- $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
|
201
|
+ $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
202
|
202
|
|
|
203
|
203
|
// $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
|
204
|
204
|
|
|
205
|
205
|
try { |
|
206
|
206
|
$sth = $this->db->prepare($query); |
|
207
|
207
|
$sth->execute(array(':id' => $id)); |
|
208
|
|
- } catch(PDOException $e) { |
|
|
208
|
+ } catch (PDOException $e) { |
|
209
|
209
|
echo $e->getMessage(); |
|
210
|
210
|
die; |
|
211
|
211
|
} |
|
@@ -227,12 +227,12 @@ discard block |
|
|
block discarded – undo |
|
227
|
227
|
date_default_timezone_set('UTC'); |
|
228
|
228
|
|
|
229
|
229
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230
|
|
- $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
|
230
|
+ $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
231
|
231
|
|
|
232
|
232
|
try { |
|
233
|
233
|
$sth = $this->db->prepare($query); |
|
234
|
234
|
$sth->execute(array(':ident' => $ident)); |
|
235
|
|
- } catch(PDOException $e) { |
|
|
235
|
+ } catch (PDOException $e) { |
|
236
|
236
|
echo $e->getMessage(); |
|
237
|
237
|
die; |
|
238
|
238
|
} |
|
@@ -253,12 +253,12 @@ discard block |
|
|
block discarded – undo |
|
253
|
253
|
date_default_timezone_set('UTC'); |
|
254
|
254
|
|
|
255
|
255
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256
|
|
- $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
|
256
|
+ $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
257
|
257
|
|
|
258
|
258
|
try { |
|
259
|
259
|
$sth = $this->db->prepare($query); |
|
260
|
260
|
$sth->execute(array(':id' => $id)); |
|
261
|
|
- } catch(PDOException $e) { |
|
|
261
|
+ } catch (PDOException $e) { |
|
262
|
262
|
echo $e->getMessage(); |
|
263
|
263
|
die; |
|
264
|
264
|
} |
|
@@ -279,12 +279,12 @@ discard block |
|
|
block discarded – undo |
|
279
|
279
|
date_default_timezone_set('UTC'); |
|
280
|
280
|
|
|
281
|
281
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282
|
|
- $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
|
282
|
+ $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
283
|
283
|
|
|
284
|
284
|
try { |
|
285
|
285
|
$sth = $this->db->prepare($query); |
|
286
|
286
|
$sth->execute(array(':id' => $id)); |
|
287
|
|
- } catch(PDOException $e) { |
|
|
287
|
+ } catch (PDOException $e) { |
|
288
|
288
|
echo $e->getMessage(); |
|
289
|
289
|
die; |
|
290
|
290
|
} |
|
@@ -306,13 +306,13 @@ discard block |
|
|
block discarded – undo |
|
306
|
306
|
date_default_timezone_set('UTC'); |
|
307
|
307
|
|
|
308
|
308
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309
|
|
- $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
|
309
|
+ $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
310
|
310
|
// $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
|
311
|
311
|
|
|
312
|
312
|
try { |
|
313
|
313
|
$sth = $this->db->prepare($query); |
|
314
|
314
|
$sth->execute(array(':ident' => $ident)); |
|
315
|
|
- } catch(PDOException $e) { |
|
|
315
|
+ } catch (PDOException $e) { |
|
316
|
316
|
echo $e->getMessage(); |
|
317
|
317
|
die; |
|
318
|
318
|
} |
|
@@ -329,13 +329,13 @@ discard block |
|
|
block discarded – undo |
|
329
|
329
|
* @return Array the spotter information |
|
330
|
330
|
* |
|
331
|
331
|
*/ |
|
332
|
|
- public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
|
332
|
+ public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
333
|
333
|
{ |
|
334
|
334
|
$Marine = new Marine($this->db); |
|
335
|
335
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
336
|
|
- $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
|
336
|
+ $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
337
|
337
|
|
|
338
|
|
- $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
|
338
|
+ $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
339
|
339
|
|
|
340
|
340
|
return $spotter_array; |
|
341
|
341
|
} |
|
@@ -348,7 +348,7 @@ discard block |
|
|
block discarded – undo |
|
348
|
348
|
try { |
|
349
|
349
|
$sth = $this->db->prepare($query); |
|
350
|
350
|
$sth->execute(); |
|
351
|
|
- } catch(PDOException $e) { |
|
|
351
|
+ } catch (PDOException $e) { |
|
352
|
352
|
echo $e->getMessage(); |
|
353
|
353
|
die; |
|
354
|
354
|
} |
|
@@ -360,24 +360,24 @@ discard block |
|
|
block discarded – undo |
|
360
|
360
|
* @return Array the spotter information |
|
361
|
361
|
* |
|
362
|
362
|
*/ |
|
363
|
|
- public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
|
363
|
+ public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
364
|
364
|
{ |
|
365
|
365
|
global $globalDBdriver, $globalLiveInterval; |
|
366
|
366
|
date_default_timezone_set('UTC'); |
|
367
|
367
|
|
|
368
|
368
|
$filter_query = ''; |
|
369
|
369
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
370
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
370
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
371
|
371
|
} |
|
372
|
372
|
// Use spotter_output also ? |
|
373
|
373
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
374
|
|
- $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
|
374
|
+ $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
375
|
375
|
} |
|
376
|
376
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
377
|
377
|
$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
378
|
378
|
} |
|
379
|
379
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
380
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
380
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
381
|
381
|
} |
|
382
|
382
|
|
|
383
|
383
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -396,14 +396,14 @@ discard block |
|
|
block discarded – undo |
|
396
|
396
|
GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
|
397
|
397
|
AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
|
398
|
398
|
*/ |
|
399
|
|
- $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
|
399
|
+ $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
400
|
400
|
FROM marine_archive |
|
401
|
401
|
INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
|
402
|
402
|
WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
|
403
|
403
|
'.$filter_query.' ORDER BY fammarine_id'; |
|
404
|
404
|
} else { |
|
405
|
405
|
//$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
406
|
|
- $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
|
406
|
+ $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
407
|
407
|
FROM marine_archive |
|
408
|
408
|
INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
|
409
|
409
|
WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
|
@@ -413,7 +413,7 @@ discard block |
|
|
block discarded – undo |
|
413
|
413
|
try { |
|
414
|
414
|
$sth = $this->db->prepare($query); |
|
415
|
415
|
$sth->execute(); |
|
416
|
|
- } catch(PDOException $e) { |
|
|
416
|
+ } catch (PDOException $e) { |
|
417
|
417
|
echo $e->getMessage(); |
|
418
|
418
|
die; |
|
419
|
419
|
} |
|
@@ -428,24 +428,24 @@ discard block |
|
|
block discarded – undo |
|
428
|
428
|
* @return Array the spotter information |
|
429
|
429
|
* |
|
430
|
430
|
*/ |
|
431
|
|
- public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
|
431
|
+ public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
432
|
432
|
{ |
|
433
|
433
|
global $globalDBdriver, $globalLiveInterval; |
|
434
|
434
|
date_default_timezone_set('UTC'); |
|
435
|
435
|
|
|
436
|
436
|
$filter_query = ''; |
|
437
|
437
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
438
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
438
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
439
|
439
|
} |
|
440
|
440
|
// Should use spotter_output also ? |
|
441
|
441
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
442
|
|
- $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
|
442
|
+ $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
443
|
443
|
} |
|
444
|
444
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
445
|
445
|
$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
446
|
446
|
} |
|
447
|
447
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
448
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
448
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
449
|
449
|
} |
|
450
|
450
|
|
|
451
|
451
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -455,7 +455,7 @@ discard block |
|
|
block discarded – undo |
|
455
|
455
|
FROM marine_archive |
|
456
|
456
|
INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
|
457
|
457
|
*/ |
|
458
|
|
- $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
|
458
|
+ $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
459
|
459
|
FROM marine_archive_output |
|
460
|
460
|
LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
|
461
|
461
|
WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
|
@@ -470,7 +470,7 @@ discard block |
|
|
block discarded – undo |
|
470
|
470
|
WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
|
471
|
471
|
'.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
|
472
|
472
|
*/ |
|
473
|
|
- $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
|
473
|
+ $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
474
|
474
|
FROM marine_archive_output |
|
475
|
475
|
INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
|
476
|
476
|
WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
|
@@ -482,7 +482,7 @@ discard block |
|
|
block discarded – undo |
|
482
|
482
|
try { |
|
483
|
483
|
$sth = $this->db->prepare($query); |
|
484
|
484
|
$sth->execute(); |
|
485
|
|
- } catch(PDOException $e) { |
|
|
485
|
+ } catch (PDOException $e) { |
|
486
|
486
|
echo $e->getMessage(); |
|
487
|
487
|
die; |
|
488
|
488
|
} |
|
@@ -497,23 +497,23 @@ discard block |
|
|
block discarded – undo |
|
497
|
497
|
* @return Array the spotter information |
|
498
|
498
|
* |
|
499
|
499
|
*/ |
|
500
|
|
- public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
|
500
|
+ public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
501
|
501
|
{ |
|
502
|
502
|
global $globalDBdriver, $globalLiveInterval; |
|
503
|
503
|
date_default_timezone_set('UTC'); |
|
504
|
504
|
|
|
505
|
505
|
$filter_query = ''; |
|
506
|
506
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
507
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
507
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
508
|
508
|
} |
|
509
|
509
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
510
|
|
- $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
|
510
|
+ $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
511
|
511
|
} |
|
512
|
512
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
513
|
513
|
$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
514
|
514
|
} |
|
515
|
515
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
516
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
516
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
517
|
517
|
} |
|
518
|
518
|
|
|
519
|
519
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -528,7 +528,7 @@ discard block |
|
|
block discarded – undo |
|
528
|
528
|
try { |
|
529
|
529
|
$sth = $this->db->prepare($query); |
|
530
|
530
|
$sth->execute(); |
|
531
|
|
- } catch(PDOException $e) { |
|
|
531
|
+ } catch (PDOException $e) { |
|
532
|
532
|
echo $e->getMessage(); |
|
533
|
533
|
die; |
|
534
|
534
|
} |
|
@@ -548,7 +548,7 @@ discard block |
|
|
block discarded – undo |
|
548
|
548
|
* @return Array the spotter information |
|
549
|
549
|
* |
|
550
|
550
|
*/ |
|
551
|
|
- public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
|
551
|
+ public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
552
|
552
|
{ |
|
553
|
553
|
global $globalTimezone, $globalDBdriver; |
|
554
|
554
|
require_once(dirname(__FILE__).'/class.Translation.php'); |
|
@@ -570,7 +570,7 @@ discard block |
|
|
block discarded – undo |
|
570
|
570
|
|
|
571
|
571
|
$q_array = explode(" ", $q); |
|
572
|
572
|
|
|
573
|
|
- foreach ($q_array as $q_item){ |
|
|
573
|
+ foreach ($q_array as $q_item) { |
|
574
|
574
|
$additional_query .= " AND ("; |
|
575
|
575
|
$additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
576
|
576
|
$additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
@@ -602,7 +602,7 @@ discard block |
|
|
block discarded – undo |
|
602
|
602
|
|
|
603
|
603
|
if ($registration != "") |
|
604
|
604
|
{ |
|
605
|
|
- $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
|
605
|
+ $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
606
|
606
|
if (!is_string($registration)) |
|
607
|
607
|
{ |
|
608
|
608
|
return false; |
|
@@ -613,7 +613,7 @@ discard block |
|
|
block discarded – undo |
|
613
|
613
|
|
|
614
|
614
|
if ($aircraft_icao != "") |
|
615
|
615
|
{ |
|
616
|
|
- $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
|
616
|
+ $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
617
|
617
|
if (!is_string($aircraft_icao)) |
|
618
|
618
|
{ |
|
619
|
619
|
return false; |
|
@@ -624,7 +624,7 @@ discard block |
|
|
block discarded – undo |
|
624
|
624
|
|
|
625
|
625
|
if ($aircraft_manufacturer != "") |
|
626
|
626
|
{ |
|
627
|
|
- $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
|
627
|
+ $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
628
|
628
|
if (!is_string($aircraft_manufacturer)) |
|
629
|
629
|
{ |
|
630
|
630
|
return false; |
|
@@ -645,7 +645,7 @@ discard block |
|
|
block discarded – undo |
|
645
|
645
|
|
|
646
|
646
|
if ($airline_icao != "") |
|
647
|
647
|
{ |
|
648
|
|
- $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
|
648
|
+ $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
649
|
649
|
if (!is_string($airline_icao)) |
|
650
|
650
|
{ |
|
651
|
651
|
return false; |
|
@@ -656,7 +656,7 @@ discard block |
|
|
block discarded – undo |
|
656
|
656
|
|
|
657
|
657
|
if ($airline_country != "") |
|
658
|
658
|
{ |
|
659
|
|
- $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
|
659
|
+ $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
660
|
660
|
if (!is_string($airline_country)) |
|
661
|
661
|
{ |
|
662
|
662
|
return false; |
|
@@ -667,7 +667,7 @@ discard block |
|
|
block discarded – undo |
|
667
|
667
|
|
|
668
|
668
|
if ($airline_type != "") |
|
669
|
669
|
{ |
|
670
|
|
- $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
|
670
|
+ $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
671
|
671
|
if (!is_string($airline_type)) |
|
672
|
672
|
{ |
|
673
|
673
|
return false; |
|
@@ -689,7 +689,7 @@ discard block |
|
|
block discarded – undo |
|
689
|
689
|
|
|
690
|
690
|
if ($airport != "") |
|
691
|
691
|
{ |
|
692
|
|
- $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
|
692
|
+ $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
693
|
693
|
if (!is_string($airport)) |
|
694
|
694
|
{ |
|
695
|
695
|
return false; |
|
@@ -700,7 +700,7 @@ discard block |
|
|
block discarded – undo |
|
700
|
700
|
|
|
701
|
701
|
if ($airport_country != "") |
|
702
|
702
|
{ |
|
703
|
|
- $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
|
703
|
+ $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
704
|
704
|
if (!is_string($airport_country)) |
|
705
|
705
|
{ |
|
706
|
706
|
return false; |
|
@@ -711,7 +711,7 @@ discard block |
|
|
block discarded – undo |
|
711
|
711
|
|
|
712
|
712
|
if ($callsign != "") |
|
713
|
713
|
{ |
|
714
|
|
- $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
|
714
|
+ $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
715
|
715
|
if (!is_string($callsign)) |
|
716
|
716
|
{ |
|
717
|
717
|
return false; |
|
@@ -719,7 +719,7 @@ discard block |
|
|
block discarded – undo |
|
719
|
719
|
$translate = $Translation->ident2icao($callsign); |
|
720
|
720
|
if ($translate != $callsign) { |
|
721
|
721
|
$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
|
722
|
|
- $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
|
722
|
+ $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
723
|
723
|
} else { |
|
724
|
724
|
$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
|
725
|
725
|
} |
|
@@ -728,7 +728,7 @@ discard block |
|
|
block discarded – undo |
|
728
|
728
|
|
|
729
|
729
|
if ($owner != "") |
|
730
|
730
|
{ |
|
731
|
|
- $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
|
731
|
+ $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
732
|
732
|
if (!is_string($owner)) |
|
733
|
733
|
{ |
|
734
|
734
|
return false; |
|
@@ -739,7 +739,7 @@ discard block |
|
|
block discarded – undo |
|
739
|
739
|
|
|
740
|
740
|
if ($pilot_name != "") |
|
741
|
741
|
{ |
|
742
|
|
- $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
|
742
|
+ $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
743
|
743
|
if (!is_string($pilot_name)) |
|
744
|
744
|
{ |
|
745
|
745
|
return false; |
|
@@ -750,7 +750,7 @@ discard block |
|
|
block discarded – undo |
|
750
|
750
|
|
|
751
|
751
|
if ($pilot_id != "") |
|
752
|
752
|
{ |
|
753
|
|
- $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
|
753
|
+ $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
754
|
754
|
if (!is_string($pilot_id)) |
|
755
|
755
|
{ |
|
756
|
756
|
return false; |
|
@@ -761,7 +761,7 @@ discard block |
|
|
block discarded – undo |
|
761
|
761
|
|
|
762
|
762
|
if ($departure_airport_route != "") |
|
763
|
763
|
{ |
|
764
|
|
- $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
|
764
|
+ $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
765
|
765
|
if (!is_string($departure_airport_route)) |
|
766
|
766
|
{ |
|
767
|
767
|
return false; |
|
@@ -772,7 +772,7 @@ discard block |
|
|
block discarded – undo |
|
772
|
772
|
|
|
773
|
773
|
if ($arrival_airport_route != "") |
|
774
|
774
|
{ |
|
775
|
|
- $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
|
775
|
+ $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
776
|
776
|
if (!is_string($arrival_airport_route)) |
|
777
|
777
|
{ |
|
778
|
778
|
return false; |
|
@@ -785,8 +785,8 @@ discard block |
|
|
block discarded – undo |
|
785
|
785
|
{ |
|
786
|
786
|
$altitude_array = explode(",", $altitude); |
|
787
|
787
|
|
|
788
|
|
- $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789
|
|
- $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
|
788
|
+ $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
|
789
|
+ $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
790
|
790
|
|
|
791
|
791
|
|
|
792
|
792
|
if ($altitude_array[1] != "") |
|
@@ -804,8 +804,8 @@ discard block |
|
|
block discarded – undo |
|
804
|
804
|
{ |
|
805
|
805
|
$date_array = explode(",", $date_posted); |
|
806
|
806
|
|
|
807
|
|
- $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
808
|
|
- $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
|
807
|
+ $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
|
808
|
+ $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
809
|
809
|
|
|
810
|
810
|
if ($globalTimezone != '') { |
|
811
|
811
|
date_default_timezone_set($globalTimezone); |
|
@@ -837,8 +837,8 @@ discard block |
|
|
block discarded – undo |
|
837
|
837
|
{ |
|
838
|
838
|
$limit_array = explode(",", $limit); |
|
839
|
839
|
|
|
840
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
841
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
840
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
841
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
842
|
842
|
|
|
843
|
843
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
844
|
844
|
{ |
|
@@ -849,8 +849,8 @@ discard block |
|
|
block discarded – undo |
|
849
|
849
|
|
|
850
|
850
|
|
|
851
|
851
|
if ($origLat != "" && $origLon != "" && $dist != "") { |
|
852
|
|
- $dist = number_format($dist*0.621371,2,'.',''); |
|
853
|
|
- $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
|
852
|
+ $dist = number_format($dist*0.621371, 2, '.', ''); |
|
|
853
|
+ $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
854
|
854
|
FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
|
855
|
855
|
AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
|
856
|
856
|
} else { |
|
@@ -867,12 +867,12 @@ discard block |
|
|
block discarded – undo |
|
867
|
867
|
$additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
|
868
|
868
|
} |
|
869
|
869
|
|
|
870
|
|
- $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
|
870
|
+ $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
871
|
871
|
WHERE marine_archive_output.ident <> '' |
|
872
|
872
|
".$additional_query." |
|
873
|
873
|
".$filter_query.$orderby_query; |
|
874
|
874
|
} |
|
875
|
|
- $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
|
875
|
+ $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
876
|
876
|
|
|
877
|
877
|
return $spotter_array; |
|
878
|
878
|
} |
|
@@ -889,7 +889,7 @@ discard block |
|
|
block discarded – undo |
|
889
|
889
|
try { |
|
890
|
890
|
$sth = $this->db->prepare($query); |
|
891
|
891
|
$sth->execute(); |
|
892
|
|
- } catch(PDOException $e) { |
|
|
892
|
+ } catch (PDOException $e) { |
|
893
|
893
|
return "error"; |
|
894
|
894
|
} |
|
895
|
895
|
} |
|
@@ -926,8 +926,8 @@ discard block |
|
|
block discarded – undo |
|
926
|
926
|
{ |
|
927
|
927
|
$limit_array = explode(",", $limit); |
|
928
|
928
|
|
|
929
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
930
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
929
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
930
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
931
|
931
|
|
|
932
|
932
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
933
|
933
|
{ |
|
@@ -968,7 +968,7 @@ discard block |
|
|
block discarded – undo |
|
968
|
968
|
$query_values = array(); |
|
969
|
969
|
$limit_query = ''; |
|
970
|
970
|
$additional_query = ''; |
|
971
|
|
- $filter_query = $this->getFilter($filter,true,true); |
|
|
971
|
+ $filter_query = $this->getFilter($filter, true, true); |
|
972
|
972
|
|
|
973
|
973
|
if ($owner != "") |
|
974
|
974
|
{ |
|
@@ -985,8 +985,8 @@ discard block |
|
|
block discarded – undo |
|
985
|
985
|
{ |
|
986
|
986
|
$limit_array = explode(",", $limit); |
|
987
|
987
|
|
|
988
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
989
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
988
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
989
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
990
|
990
|
|
|
991
|
991
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
992
|
992
|
{ |
|
@@ -1026,7 +1026,7 @@ discard block |
|
|
block discarded – undo |
|
1026
|
1026
|
$query_values = array(); |
|
1027
|
1027
|
$limit_query = ''; |
|
1028
|
1028
|
$additional_query = ''; |
|
1029
|
|
- $filter_query = $this->getFilter($filter,true,true); |
|
|
1029
|
+ $filter_query = $this->getFilter($filter, true, true); |
|
1030
|
1030
|
|
|
1031
|
1031
|
if ($pilot != "") |
|
1032
|
1032
|
{ |
|
@@ -1038,8 +1038,8 @@ discard block |
|
|
block discarded – undo |
|
1038
|
1038
|
{ |
|
1039
|
1039
|
$limit_array = explode(",", $limit); |
|
1040
|
1040
|
|
|
1041
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
1041
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
1042
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1043
|
1043
|
|
|
1044
|
1044
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1045
|
1045
|
{ |
|
@@ -1069,7 +1069,7 @@ discard block |
|
|
block discarded – undo |
|
1069
|
1069
|
* @return Array the airline country list |
|
1070
|
1070
|
* |
|
1071
|
1071
|
*/ |
|
1072
|
|
- public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
|
1072
|
+ public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1073
|
1073
|
{ |
|
1074
|
1074
|
global $globalDBdriver; |
|
1075
|
1075
|
/* |
|
@@ -1098,7 +1098,7 @@ discard block |
|
|
block discarded – undo |
|
1098
|
1098
|
$flight_array = array(); |
|
1099
|
1099
|
$temp_array = array(); |
|
1100
|
1100
|
|
|
1101
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1101
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1102
|
1102
|
{ |
|
1103
|
1103
|
$temp_array['flight_count'] = $row['nb']; |
|
1104
|
1104
|
$temp_array['flight_country'] = $row['name']; |
|
@@ -1115,7 +1115,7 @@ discard block |
|
|
block discarded – undo |
|
1115
|
1115
|
* @return Array the airline country list |
|
1116
|
1116
|
* |
|
1117
|
1117
|
*/ |
|
1118
|
|
- public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
|
1118
|
+ public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1119
|
1119
|
{ |
|
1120
|
1120
|
global $globalDBdriver; |
|
1121
|
1121
|
/* |
|
@@ -1144,7 +1144,7 @@ discard block |
|
|
block discarded – undo |
|
1144
|
1144
|
$flight_array = array(); |
|
1145
|
1145
|
$temp_array = array(); |
|
1146
|
1146
|
|
|
1147
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1147
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1148
|
1148
|
{ |
|
1149
|
1149
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
1150
|
1150
|
$temp_array['flight_count'] = $row['nb']; |
|
@@ -1162,14 +1162,14 @@ discard block |
|
|
block discarded – undo |
|
1162
|
1162
|
* @return Array the spotter information |
|
1163
|
1163
|
* |
|
1164
|
1164
|
*/ |
|
1165
|
|
- public function getDateArchiveMarineDataById($id,$date) |
|
|
1165
|
+ public function getDateArchiveMarineDataById($id, $date) |
|
1166
|
1166
|
{ |
|
1167
|
1167
|
$Marine = new Marine($this->db); |
|
1168
|
1168
|
date_default_timezone_set('UTC'); |
|
1169
|
1169
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
1170
|
1170
|
$query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
|
1171
|
|
- $date = date('c',$date); |
|
1172
|
|
- $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
|
1171
|
+ $date = date('c', $date); |
|
|
1172
|
+ $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1173
|
1173
|
return $spotter_array; |
|
1174
|
1174
|
} |
|
1175
|
1175
|
|
|
@@ -1179,14 +1179,14 @@ discard block |
|
|
block discarded – undo |
|
1179
|
1179
|
* @return Array the spotter information |
|
1180
|
1180
|
* |
|
1181
|
1181
|
*/ |
|
1182
|
|
- public function getDateArchiveMarineDataByIdent($ident,$date) |
|
|
1182
|
+ public function getDateArchiveMarineDataByIdent($ident, $date) |
|
1183
|
1183
|
{ |
|
1184
|
1184
|
$Marine = new Marine($this->db); |
|
1185
|
1185
|
date_default_timezone_set('UTC'); |
|
1186
|
1186
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1187
|
1187
|
$query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
|
1188
|
|
- $date = date('c',$date); |
|
1189
|
|
- $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
|
1188
|
+ $date = date('c', $date); |
|
|
1189
|
+ $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1190
|
1190
|
return $spotter_array; |
|
1191
|
1191
|
} |
|
1192
|
1192
|
|
|
@@ -1196,7 +1196,7 @@ discard block |
|
|
block discarded – undo |
|
1196
|
1196
|
* @return Array the spotter information |
|
1197
|
1197
|
* |
|
1198
|
1198
|
*/ |
|
1199
|
|
- public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
|
1199
|
+ public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1200
|
1200
|
{ |
|
1201
|
1201
|
global $global_query; |
|
1202
|
1202
|
$Marine = new Marine(); |
|
@@ -1204,7 +1204,7 @@ discard block |
|
|
block discarded – undo |
|
1204
|
1204
|
$query_values = array(); |
|
1205
|
1205
|
$limit_query = ''; |
|
1206
|
1206
|
$additional_query = ''; |
|
1207
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
|
1207
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
1208
|
1208
|
|
|
1209
|
1209
|
if ($airport != "") |
|
1210
|
1210
|
{ |
|
@@ -1221,8 +1221,8 @@ discard block |
|
|
block discarded – undo |
|
1221
|
1221
|
{ |
|
1222
|
1222
|
$limit_array = explode(",", $limit); |
|
1223
|
1223
|
|
|
1224
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1225
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
1224
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
1225
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1226
|
1226
|
|
|
1227
|
1227
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1228
|
1228
|
{ |