|
@@ -13,15 +13,15 @@ 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; |
18
|
|
- if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
19
|
|
- if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
|
18
|
+ if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName], $filter); |
|
19
|
+ if (is_array($globalFilter)) $filter = array_merge($globalFilter, $filter); |
20
|
20
|
$filter_query_join = ''; |
21
|
21
|
$filter_query_where = ''; |
22
|
22
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
23
|
23
|
if ($filter['airlines'][0] != '') { |
24
|
|
- $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
24
|
+ $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
25
|
25
|
} |
26
|
26
|
} |
27
|
27
|
|
|
@@ -29,19 +29,19 @@ discard block |
|
|
block discarded – undo |
29
|
29
|
$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
30
|
30
|
} |
31
|
31
|
if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
32
|
|
- $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
32
|
+ $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
33
|
33
|
} |
34
|
34
|
if (isset($filter['source']) && !empty($filter['source'])) { |
35
|
|
- $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
35
|
+ $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
36
|
36
|
} |
37
|
37
|
if (isset($filter['ident']) && !empty($filter['ident'])) { |
38
|
38
|
$filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
39
|
39
|
} |
40
|
40
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
41
|
41
|
if ($filter_query_where == '') { |
42
|
|
- $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
42
|
+ $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
43
|
43
|
} else { |
44
|
|
- $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
44
|
+ $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
45
|
45
|
} |
46
|
46
|
} |
47
|
47
|
if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
@@ -51,28 +51,28 @@ discard block |
|
|
block discarded – undo |
51
|
51
|
} |
52
|
52
|
|
53
|
53
|
// Spotter_archive |
54
|
|
- public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
54
|
+ public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
55
|
55
|
require_once(dirname(__FILE__).'/class.Spotter.php'); |
56
|
56
|
if ($over_country == '') { |
57
|
57
|
$Spotter = new Spotter($this->db); |
58
|
|
- $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
58
|
+ $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
59
|
59
|
if (!empty($data_country)) $country = $data_country['iso2']; |
60
|
60
|
else $country = ''; |
61
|
61
|
} else $country = $over_country; |
62
|
|
- if ($airline_type === NULL) $airline_type =''; |
|
62
|
+ if ($airline_type === NULL) $airline_type = ''; |
63
|
63
|
|
64
|
64
|
//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
65
|
65
|
//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
66
|
66
|
|
67
|
67
|
// Route is not added in spotter_archive |
68
|
|
- $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
68
|
+ $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
69
|
69
|
VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
70
|
70
|
|
71
|
|
- $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
71
|
+ $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
72
|
72
|
try { |
73
|
73
|
$sth = $this->db->prepare($query); |
74
|
74
|
$sth->execute($query_values); |
75
|
|
- } catch(PDOException $e) { |
|
75
|
+ } catch (PDOException $e) { |
76
|
76
|
return "error : ".$e->getMessage(); |
77
|
77
|
} |
78
|
78
|
return "success"; |
|
@@ -92,9 +92,9 @@ discard block |
|
|
block discarded – undo |
92
|
92
|
|
93
|
93
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
94
|
94
|
//$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
95
|
|
- $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
95
|
+ $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
96
|
96
|
|
97
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
97
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
98
|
98
|
|
99
|
99
|
return $spotter_array; |
100
|
100
|
} |
|
@@ -113,7 +113,7 @@ discard block |
|
|
block discarded – undo |
113
|
113
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
114
|
114
|
//$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
115
|
115
|
//$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
116
|
|
- $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
116
|
+ $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
117
|
117
|
|
118
|
118
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
119
|
119
|
/* |
|
@@ -126,7 +126,7 @@ discard block |
|
|
block discarded – undo |
126
|
126
|
} |
127
|
127
|
$spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
128
|
128
|
*/ |
129
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
129
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
130
|
130
|
|
131
|
131
|
return $spotter_array; |
132
|
132
|
} |
|
@@ -141,14 +141,14 @@ discard block |
|
|
block discarded – undo |
141
|
141
|
{ |
142
|
142
|
date_default_timezone_set('UTC'); |
143
|
143
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
144
|
|
- $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
144
|
+ $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
145
|
145
|
|
146
|
146
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
147
|
147
|
|
148
|
148
|
try { |
149
|
149
|
$sth = $this->db->prepare($query); |
150
|
150
|
$sth->execute(array(':id' => $id)); |
151
|
|
- } catch(PDOException $e) { |
|
151
|
+ } catch (PDOException $e) { |
152
|
152
|
echo $e->getMessage(); |
153
|
153
|
die; |
154
|
154
|
} |
|
@@ -167,14 +167,14 @@ discard block |
|
|
block discarded – undo |
167
|
167
|
{ |
168
|
168
|
date_default_timezone_set('UTC'); |
169
|
169
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
170
|
|
- $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
170
|
+ $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
171
|
171
|
|
172
|
172
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
173
|
173
|
|
174
|
174
|
try { |
175
|
175
|
$sth = $this->db->prepare($query); |
176
|
176
|
$sth->execute(array(':id' => $id)); |
177
|
|
- } catch(PDOException $e) { |
|
177
|
+ } catch (PDOException $e) { |
178
|
178
|
echo $e->getMessage(); |
179
|
179
|
die; |
180
|
180
|
} |
|
@@ -196,12 +196,12 @@ discard block |
|
|
block discarded – undo |
196
|
196
|
date_default_timezone_set('UTC'); |
197
|
197
|
|
198
|
198
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
199
|
|
- $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
199
|
+ $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
200
|
200
|
|
201
|
201
|
try { |
202
|
202
|
$sth = $this->db->prepare($query); |
203
|
203
|
$sth->execute(array(':ident' => $ident)); |
204
|
|
- } catch(PDOException $e) { |
|
204
|
+ } catch (PDOException $e) { |
205
|
205
|
echo $e->getMessage(); |
206
|
206
|
die; |
207
|
207
|
} |
|
@@ -222,12 +222,12 @@ discard block |
|
|
block discarded – undo |
222
|
222
|
date_default_timezone_set('UTC'); |
223
|
223
|
|
224
|
224
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
225
|
|
- $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
225
|
+ $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
226
|
226
|
|
227
|
227
|
try { |
228
|
228
|
$sth = $this->db->prepare($query); |
229
|
229
|
$sth->execute(array(':id' => $id)); |
230
|
|
- } catch(PDOException $e) { |
|
230
|
+ } catch (PDOException $e) { |
231
|
231
|
echo $e->getMessage(); |
232
|
232
|
die; |
233
|
233
|
} |
|
@@ -248,12 +248,12 @@ discard block |
|
|
block discarded – undo |
248
|
248
|
date_default_timezone_set('UTC'); |
249
|
249
|
|
250
|
250
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
251
|
|
- $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
251
|
+ $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
252
|
252
|
|
253
|
253
|
try { |
254
|
254
|
$sth = $this->db->prepare($query); |
255
|
255
|
$sth->execute(array(':id' => $id)); |
256
|
|
- } catch(PDOException $e) { |
|
256
|
+ } catch (PDOException $e) { |
257
|
257
|
echo $e->getMessage(); |
258
|
258
|
die; |
259
|
259
|
} |
|
@@ -275,13 +275,13 @@ discard block |
|
|
block discarded – undo |
275
|
275
|
date_default_timezone_set('UTC'); |
276
|
276
|
|
277
|
277
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
278
|
|
- $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
278
|
+ $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
279
|
279
|
// $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
280
|
280
|
|
281
|
281
|
try { |
282
|
282
|
$sth = $this->db->prepare($query); |
283
|
283
|
$sth->execute(array(':ident' => $ident)); |
284
|
|
- } catch(PDOException $e) { |
|
284
|
+ } catch (PDOException $e) { |
285
|
285
|
echo $e->getMessage(); |
286
|
286
|
die; |
287
|
287
|
} |
|
@@ -298,13 +298,13 @@ discard block |
|
|
block discarded – undo |
298
|
298
|
* @return Array the spotter information |
299
|
299
|
* |
300
|
300
|
*/ |
301
|
|
- public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
301
|
+ public function getSpotterArchiveData($ident, $flightaware_id, $date) |
302
|
302
|
{ |
303
|
303
|
$Spotter = new Spotter($this->db); |
304
|
304
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
305
|
|
- $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
305
|
+ $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
306
|
306
|
|
307
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
307
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
308
|
308
|
|
309
|
309
|
return $spotter_array; |
310
|
310
|
} |
|
@@ -317,7 +317,7 @@ discard block |
|
|
block discarded – undo |
317
|
317
|
try { |
318
|
318
|
$sth = $this->db->prepare($query); |
319
|
319
|
$sth->execute(); |
320
|
|
- } catch(PDOException $e) { |
|
320
|
+ } catch (PDOException $e) { |
321
|
321
|
echo $e->getMessage(); |
322
|
322
|
die; |
323
|
323
|
} |
|
@@ -329,24 +329,24 @@ discard block |
|
|
block discarded – undo |
329
|
329
|
* @return Array the spotter information |
330
|
330
|
* |
331
|
331
|
*/ |
332
|
|
- public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
332
|
+ public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
333
|
333
|
{ |
334
|
334
|
global $globalDBdriver, $globalLiveInterval; |
335
|
335
|
date_default_timezone_set('UTC'); |
336
|
336
|
|
337
|
337
|
$filter_query = ''; |
338
|
338
|
if (isset($filter['source']) && !empty($filter['source'])) { |
339
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
339
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
340
|
340
|
} |
341
|
341
|
// Use spotter_output also ? |
342
|
342
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
343
|
|
- $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
343
|
+ $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
344
|
344
|
} |
345
|
345
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
346
|
346
|
$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
347
|
347
|
} |
348
|
348
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
349
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
349
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
350
|
350
|
} |
351
|
351
|
|
352
|
352
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -365,14 +365,14 @@ discard block |
|
|
block discarded – undo |
365
|
365
|
GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
366
|
366
|
AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
367
|
367
|
*/ |
368
|
|
- $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
368
|
+ $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
369
|
369
|
FROM spotter_archive |
370
|
370
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
371
|
371
|
WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
372
|
372
|
'.$filter_query.' ORDER BY flightaware_id'; |
373
|
373
|
} else { |
374
|
374
|
//$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
375
|
|
- $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
375
|
+ $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
376
|
376
|
FROM spotter_archive |
377
|
377
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
378
|
378
|
WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
|
@@ -382,7 +382,7 @@ discard block |
|
|
block discarded – undo |
382
|
382
|
try { |
383
|
383
|
$sth = $this->db->prepare($query); |
384
|
384
|
$sth->execute(); |
385
|
|
- } catch(PDOException $e) { |
|
385
|
+ } catch (PDOException $e) { |
386
|
386
|
echo $e->getMessage(); |
387
|
387
|
die; |
388
|
388
|
} |
|
@@ -397,24 +397,24 @@ discard block |
|
|
block discarded – undo |
397
|
397
|
* @return Array the spotter information |
398
|
398
|
* |
399
|
399
|
*/ |
400
|
|
- public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
400
|
+ public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
401
|
401
|
{ |
402
|
402
|
global $globalDBdriver, $globalLiveInterval; |
403
|
403
|
date_default_timezone_set('UTC'); |
404
|
404
|
|
405
|
405
|
$filter_query = ''; |
406
|
406
|
if (isset($filter['source']) && !empty($filter['source'])) { |
407
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
407
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
408
|
408
|
} |
409
|
409
|
// Should use spotter_output also ? |
410
|
410
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
411
|
|
- $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
411
|
+ $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
412
|
412
|
} |
413
|
413
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
414
|
414
|
$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
415
|
415
|
} |
416
|
416
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
417
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
417
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
418
|
418
|
} |
419
|
419
|
|
420
|
420
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -424,7 +424,7 @@ discard block |
|
|
block discarded – undo |
424
|
424
|
FROM spotter_archive |
425
|
425
|
INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
426
|
426
|
*/ |
427
|
|
- $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
427
|
+ $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
428
|
428
|
FROM spotter_archive_output |
429
|
429
|
LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
430
|
430
|
WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
|
@@ -439,7 +439,7 @@ discard block |
|
|
block discarded – undo |
439
|
439
|
WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
440
|
440
|
'.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
441
|
441
|
*/ |
442
|
|
- $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
442
|
+ $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
443
|
443
|
FROM spotter_archive_output |
444
|
444
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
445
|
445
|
WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
|
@@ -451,7 +451,7 @@ discard block |
|
|
block discarded – undo |
451
|
451
|
try { |
452
|
452
|
$sth = $this->db->prepare($query); |
453
|
453
|
$sth->execute(); |
454
|
|
- } catch(PDOException $e) { |
|
454
|
+ } catch (PDOException $e) { |
455
|
455
|
echo $e->getMessage(); |
456
|
456
|
die; |
457
|
457
|
} |
|
@@ -466,23 +466,23 @@ discard block |
|
|
block discarded – undo |
466
|
466
|
* @return Array the spotter information |
467
|
467
|
* |
468
|
468
|
*/ |
469
|
|
- public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
469
|
+ public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
470
|
470
|
{ |
471
|
471
|
global $globalDBdriver, $globalLiveInterval; |
472
|
472
|
date_default_timezone_set('UTC'); |
473
|
473
|
|
474
|
474
|
$filter_query = ''; |
475
|
475
|
if (isset($filter['source']) && !empty($filter['source'])) { |
476
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
476
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
477
|
477
|
} |
478
|
478
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
479
|
|
- $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
479
|
+ $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
480
|
480
|
} |
481
|
481
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
482
|
482
|
$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
483
|
483
|
} |
484
|
484
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
485
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
485
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
486
|
486
|
} |
487
|
487
|
|
488
|
488
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -497,7 +497,7 @@ discard block |
|
|
block discarded – undo |
497
|
497
|
try { |
498
|
498
|
$sth = $this->db->prepare($query); |
499
|
499
|
$sth->execute(); |
500
|
|
- } catch(PDOException $e) { |
|
500
|
+ } catch (PDOException $e) { |
501
|
501
|
echo $e->getMessage(); |
502
|
502
|
die; |
503
|
503
|
} |
|
@@ -517,7 +517,7 @@ discard block |
|
|
block discarded – undo |
517
|
517
|
* @return Array the spotter information |
518
|
518
|
* |
519
|
519
|
*/ |
520
|
|
- public function searchSpotterData($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()) |
|
520
|
+ public function searchSpotterData($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()) |
521
|
521
|
{ |
522
|
522
|
global $globalTimezone, $globalDBdriver; |
523
|
523
|
require_once(dirname(__FILE__).'/class.Translation.php'); |
|
@@ -539,7 +539,7 @@ discard block |
|
|
block discarded – undo |
539
|
539
|
|
540
|
540
|
$q_array = explode(" ", $q); |
541
|
541
|
|
542
|
|
- foreach ($q_array as $q_item){ |
|
542
|
+ foreach ($q_array as $q_item) { |
543
|
543
|
$additional_query .= " AND ("; |
544
|
544
|
$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
545
|
545
|
$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
@@ -571,7 +571,7 @@ discard block |
|
|
block discarded – undo |
571
|
571
|
|
572
|
572
|
if ($registration != "") |
573
|
573
|
{ |
574
|
|
- $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
574
|
+ $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
575
|
575
|
if (!is_string($registration)) |
576
|
576
|
{ |
577
|
577
|
return false; |
|
@@ -582,7 +582,7 @@ discard block |
|
|
block discarded – undo |
582
|
582
|
|
583
|
583
|
if ($aircraft_icao != "") |
584
|
584
|
{ |
585
|
|
- $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
585
|
+ $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
586
|
586
|
if (!is_string($aircraft_icao)) |
587
|
587
|
{ |
588
|
588
|
return false; |
|
@@ -593,7 +593,7 @@ discard block |
|
|
block discarded – undo |
593
|
593
|
|
594
|
594
|
if ($aircraft_manufacturer != "") |
595
|
595
|
{ |
596
|
|
- $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
596
|
+ $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
597
|
597
|
if (!is_string($aircraft_manufacturer)) |
598
|
598
|
{ |
599
|
599
|
return false; |
|
@@ -614,7 +614,7 @@ discard block |
|
|
block discarded – undo |
614
|
614
|
|
615
|
615
|
if ($airline_icao != "") |
616
|
616
|
{ |
617
|
|
- $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
617
|
+ $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
618
|
618
|
if (!is_string($airline_icao)) |
619
|
619
|
{ |
620
|
620
|
return false; |
|
@@ -625,7 +625,7 @@ discard block |
|
|
block discarded – undo |
625
|
625
|
|
626
|
626
|
if ($airline_country != "") |
627
|
627
|
{ |
628
|
|
- $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
628
|
+ $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
629
|
629
|
if (!is_string($airline_country)) |
630
|
630
|
{ |
631
|
631
|
return false; |
|
@@ -636,7 +636,7 @@ discard block |
|
|
block discarded – undo |
636
|
636
|
|
637
|
637
|
if ($airline_type != "") |
638
|
638
|
{ |
639
|
|
- $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
639
|
+ $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
640
|
640
|
if (!is_string($airline_type)) |
641
|
641
|
{ |
642
|
642
|
return false; |
|
@@ -658,7 +658,7 @@ discard block |
|
|
block discarded – undo |
658
|
658
|
|
659
|
659
|
if ($airport != "") |
660
|
660
|
{ |
661
|
|
- $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
661
|
+ $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
662
|
662
|
if (!is_string($airport)) |
663
|
663
|
{ |
664
|
664
|
return false; |
|
@@ -669,7 +669,7 @@ discard block |
|
|
block discarded – undo |
669
|
669
|
|
670
|
670
|
if ($airport_country != "") |
671
|
671
|
{ |
672
|
|
- $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
672
|
+ $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
673
|
673
|
if (!is_string($airport_country)) |
674
|
674
|
{ |
675
|
675
|
return false; |
|
@@ -680,7 +680,7 @@ discard block |
|
|
block discarded – undo |
680
|
680
|
|
681
|
681
|
if ($callsign != "") |
682
|
682
|
{ |
683
|
|
- $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
683
|
+ $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
684
|
684
|
if (!is_string($callsign)) |
685
|
685
|
{ |
686
|
686
|
return false; |
|
@@ -688,7 +688,7 @@ discard block |
|
|
block discarded – undo |
688
|
688
|
$translate = $Translation->ident2icao($callsign); |
689
|
689
|
if ($translate != $callsign) { |
690
|
690
|
$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
691
|
|
- $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
691
|
+ $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
692
|
692
|
} else { |
693
|
693
|
$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
694
|
694
|
} |
|
@@ -697,7 +697,7 @@ discard block |
|
|
block discarded – undo |
697
|
697
|
|
698
|
698
|
if ($owner != "") |
699
|
699
|
{ |
700
|
|
- $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
700
|
+ $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
701
|
701
|
if (!is_string($owner)) |
702
|
702
|
{ |
703
|
703
|
return false; |
|
@@ -708,7 +708,7 @@ discard block |
|
|
block discarded – undo |
708
|
708
|
|
709
|
709
|
if ($pilot_name != "") |
710
|
710
|
{ |
711
|
|
- $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
711
|
+ $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
712
|
712
|
if (!is_string($pilot_name)) |
713
|
713
|
{ |
714
|
714
|
return false; |
|
@@ -719,7 +719,7 @@ discard block |
|
|
block discarded – undo |
719
|
719
|
|
720
|
720
|
if ($pilot_id != "") |
721
|
721
|
{ |
722
|
|
- $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
722
|
+ $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
723
|
723
|
if (!is_string($pilot_id)) |
724
|
724
|
{ |
725
|
725
|
return false; |
|
@@ -730,7 +730,7 @@ discard block |
|
|
block discarded – undo |
730
|
730
|
|
731
|
731
|
if ($departure_airport_route != "") |
732
|
732
|
{ |
733
|
|
- $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
733
|
+ $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
734
|
734
|
if (!is_string($departure_airport_route)) |
735
|
735
|
{ |
736
|
736
|
return false; |
|
@@ -741,7 +741,7 @@ discard block |
|
|
block discarded – undo |
741
|
741
|
|
742
|
742
|
if ($arrival_airport_route != "") |
743
|
743
|
{ |
744
|
|
- $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
744
|
+ $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
745
|
745
|
if (!is_string($arrival_airport_route)) |
746
|
746
|
{ |
747
|
747
|
return false; |
|
@@ -754,8 +754,8 @@ discard block |
|
|
block discarded – undo |
754
|
754
|
{ |
755
|
755
|
$altitude_array = explode(",", $altitude); |
756
|
756
|
|
757
|
|
- $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
758
|
|
- $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
757
|
+ $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
758
|
+ $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
759
|
759
|
|
760
|
760
|
|
761
|
761
|
if ($altitude_array[1] != "") |
|
@@ -773,8 +773,8 @@ discard block |
|
|
block discarded – undo |
773
|
773
|
{ |
774
|
774
|
$date_array = explode(",", $date_posted); |
775
|
775
|
|
776
|
|
- $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
777
|
|
- $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
776
|
+ $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
777
|
+ $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
778
|
778
|
|
779
|
779
|
if ($globalTimezone != '') { |
780
|
780
|
date_default_timezone_set($globalTimezone); |
|
@@ -806,8 +806,8 @@ discard block |
|
|
block discarded – undo |
806
|
806
|
{ |
807
|
807
|
$limit_array = explode(",", $limit); |
808
|
808
|
|
809
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
810
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
809
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
810
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
811
|
811
|
|
812
|
812
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
813
|
813
|
{ |
|
@@ -818,8 +818,8 @@ discard block |
|
|
block discarded – undo |
818
|
818
|
|
819
|
819
|
|
820
|
820
|
if ($origLat != "" && $origLon != "" && $dist != "") { |
821
|
|
- $dist = number_format($dist*0.621371,2,'.',''); |
822
|
|
- $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
821
|
+ $dist = number_format($dist*0.621371, 2, '.', ''); |
|
822
|
+ $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
823
|
823
|
FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
824
|
824
|
AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
825
|
825
|
} else { |
|
@@ -836,12 +836,12 @@ discard block |
|
|
block discarded – undo |
836
|
836
|
$additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
837
|
837
|
} |
838
|
838
|
|
839
|
|
- $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
839
|
+ $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
840
|
840
|
WHERE spotter_archive_output.ident <> '' |
841
|
841
|
".$additional_query." |
842
|
842
|
".$filter_query.$orderby_query; |
843
|
843
|
} |
844
|
|
- $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
844
|
+ $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
845
|
845
|
|
846
|
846
|
return $spotter_array; |
847
|
847
|
} |
|
@@ -858,7 +858,7 @@ discard block |
|
|
block discarded – undo |
858
|
858
|
try { |
859
|
859
|
$sth = $this->db->prepare($query); |
860
|
860
|
$sth->execute(); |
861
|
|
- } catch(PDOException $e) { |
|
861
|
+ } catch (PDOException $e) { |
862
|
862
|
return "error"; |
863
|
863
|
} |
864
|
864
|
} |
|
@@ -895,8 +895,8 @@ discard block |
|
|
block discarded – undo |
895
|
895
|
{ |
896
|
896
|
$limit_array = explode(",", $limit); |
897
|
897
|
|
898
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
899
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
898
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
899
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
900
|
900
|
|
901
|
901
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
902
|
902
|
{ |
|
@@ -926,7 +926,7 @@ discard block |
|
|
block discarded – undo |
926
|
926
|
* @return Array the airline country list |
927
|
927
|
* |
928
|
928
|
*/ |
929
|
|
- public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
929
|
+ public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
930
|
930
|
{ |
931
|
931
|
global $globalDBdriver; |
932
|
932
|
/* |
|
@@ -955,7 +955,7 @@ discard block |
|
|
block discarded – undo |
955
|
955
|
$flight_array = array(); |
956
|
956
|
$temp_array = array(); |
957
|
957
|
|
958
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
958
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
959
|
959
|
{ |
960
|
960
|
$temp_array['flight_count'] = $row['nb']; |
961
|
961
|
$temp_array['flight_country'] = $row['name']; |
|
@@ -972,14 +972,14 @@ discard block |
|
|
block discarded – undo |
972
|
972
|
* @return Array the spotter information |
973
|
973
|
* |
974
|
974
|
*/ |
975
|
|
- public function getDateArchiveSpotterDataById($id,$date) |
|
975
|
+ public function getDateArchiveSpotterDataById($id, $date) |
976
|
976
|
{ |
977
|
977
|
$Spotter = new Spotter($this->db); |
978
|
978
|
date_default_timezone_set('UTC'); |
979
|
979
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
980
|
|
- $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
981
|
|
- $date = date('c',$date); |
982
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
980
|
+ $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
981
|
+ $date = date('c', $date); |
|
982
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
983
|
983
|
return $spotter_array; |
984
|
984
|
} |
985
|
985
|
|
|
@@ -989,14 +989,14 @@ discard block |
|
|
block discarded – undo |
989
|
989
|
* @return Array the spotter information |
990
|
990
|
* |
991
|
991
|
*/ |
992
|
|
- public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
992
|
+ public function getDateArchiveSpotterDataByIdent($ident, $date) |
993
|
993
|
{ |
994
|
994
|
$Spotter = new Spotter($this->db); |
995
|
995
|
date_default_timezone_set('UTC'); |
996
|
996
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
997
|
|
- $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
998
|
|
- $date = date('c',$date); |
999
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
997
|
+ $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
998
|
+ $date = date('c', $date); |
|
999
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
1000
|
1000
|
return $spotter_array; |
1001
|
1001
|
} |
1002
|
1002
|
|
|
@@ -1006,7 +1006,7 @@ discard block |
|
|
block discarded – undo |
1006
|
1006
|
* @return Array the spotter information |
1007
|
1007
|
* |
1008
|
1008
|
*/ |
1009
|
|
- public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1009
|
+ public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
1010
|
1010
|
{ |
1011
|
1011
|
global $global_query; |
1012
|
1012
|
$Spotter = new Spotter(); |
|
@@ -1014,7 +1014,7 @@ discard block |
|
|
block discarded – undo |
1014
|
1014
|
$query_values = array(); |
1015
|
1015
|
$limit_query = ''; |
1016
|
1016
|
$additional_query = ''; |
1017
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
1017
|
+ $filter_query = $this->getFilter($filters, true, true); |
1018
|
1018
|
|
1019
|
1019
|
if ($airport != "") |
1020
|
1020
|
{ |
|
@@ -1031,8 +1031,8 @@ discard block |
|
|
block discarded – undo |
1031
|
1031
|
{ |
1032
|
1032
|
$limit_array = explode(",", $limit); |
1033
|
1033
|
|
1034
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
1035
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1034
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1035
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
1036
|
1036
|
|
1037
|
1037
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1038
|
1038
|
{ |