|
@@ -11,10 +11,10 @@ discard block |
|
|
block discarded – undo |
|
11
|
11
|
public function getFilter($filter) { |
|
12
|
12
|
$filter_query = ''; |
|
13
|
13
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
14
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
|
14
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
15
|
15
|
} |
|
16
|
16
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
17
|
|
- $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
|
17
|
+ $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
18
|
18
|
} |
|
19
|
19
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
20
|
20
|
$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
|
@@ -23,37 +23,37 @@ discard block |
|
|
block discarded – undo |
|
23
|
23
|
$filter_query .= " AND ident = '".$filter['ident']."'"; |
|
24
|
24
|
} |
|
25
|
25
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
26
|
|
- $filter_query .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
26
|
+ $filter_query .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
27
|
27
|
} |
|
28
|
28
|
if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
|
29
|
|
- $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
|
29
|
+ $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
30
|
30
|
} |
|
31
|
31
|
return $filter_query; |
|
32
|
32
|
} |
|
33
|
33
|
|
|
34
|
34
|
// Spotter_archive |
|
35
|
|
- 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 = '') { |
|
|
35
|
+ 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 = '') { |
|
36
|
36
|
require_once(dirname(__FILE__).'/class.Spotter.php'); |
|
37
|
37
|
if ($over_country == '') { |
|
38
|
38
|
$Spotter = new Spotter($this->db); |
|
39
|
|
- $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
|
39
|
+ $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
40
|
40
|
if (!empty($data_country)) $country = $data_country['iso2']; |
|
41
|
41
|
else $country = ''; |
|
42
|
42
|
} else $country = $over_country; |
|
43
|
|
- if ($airline_type === NULL) $airline_type =''; |
|
|
43
|
+ if ($airline_type === NULL) $airline_type = ''; |
|
44
|
44
|
|
|
45
|
45
|
//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
|
46
|
46
|
//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
|
47
|
47
|
|
|
48
|
48
|
// Route is not added in spotter_archive |
|
49
|
|
- $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) |
|
|
49
|
+ $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) |
|
50
|
50
|
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)"; |
|
51
|
51
|
|
|
52
|
|
- $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); |
|
|
52
|
+ $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); |
|
53
|
53
|
try { |
|
54
|
54
|
$sth = $this->db->prepare($query); |
|
55
|
55
|
$sth->execute($query_values); |
|
56
|
|
- } catch(PDOException $e) { |
|
|
56
|
+ } catch (PDOException $e) { |
|
57
|
57
|
return "error : ".$e->getMessage(); |
|
58
|
58
|
} |
|
59
|
59
|
return "success"; |
|
@@ -73,9 +73,9 @@ discard block |
|
|
block discarded – undo |
|
73
|
73
|
|
|
74
|
74
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
75
|
75
|
//$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"; |
|
76
|
|
- $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
|
76
|
+ $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
77
|
77
|
|
|
78
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
|
78
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
79
|
79
|
|
|
80
|
80
|
return $spotter_array; |
|
81
|
81
|
} |
|
@@ -94,7 +94,7 @@ discard block |
|
|
block discarded – undo |
|
94
|
94
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
95
|
95
|
//$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
96
|
96
|
//$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"; |
|
97
|
|
- $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
|
97
|
+ $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
98
|
98
|
|
|
99
|
99
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
|
100
|
100
|
/* |
|
@@ -107,7 +107,7 @@ discard block |
|
|
block discarded – undo |
|
107
|
107
|
} |
|
108
|
108
|
$spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
|
109
|
109
|
*/ |
|
110
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
|
110
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
111
|
111
|
|
|
112
|
112
|
return $spotter_array; |
|
113
|
113
|
} |
|
@@ -122,14 +122,14 @@ discard block |
|
|
block discarded – undo |
|
122
|
122
|
{ |
|
123
|
123
|
date_default_timezone_set('UTC'); |
|
124
|
124
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
125
|
|
- $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
|
125
|
+ $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
126
|
126
|
|
|
127
|
127
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
|
128
|
128
|
|
|
129
|
129
|
try { |
|
130
|
130
|
$sth = $this->db->prepare($query); |
|
131
|
131
|
$sth->execute(array(':id' => $id)); |
|
132
|
|
- } catch(PDOException $e) { |
|
|
132
|
+ } catch (PDOException $e) { |
|
133
|
133
|
echo $e->getMessage(); |
|
134
|
134
|
die; |
|
135
|
135
|
} |
|
@@ -148,14 +148,14 @@ discard block |
|
|
block discarded – undo |
|
148
|
148
|
{ |
|
149
|
149
|
date_default_timezone_set('UTC'); |
|
150
|
150
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
151
|
|
- $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
|
151
|
+ $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
152
|
152
|
|
|
153
|
153
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
|
154
|
154
|
|
|
155
|
155
|
try { |
|
156
|
156
|
$sth = $this->db->prepare($query); |
|
157
|
157
|
$sth->execute(array(':id' => $id)); |
|
158
|
|
- } catch(PDOException $e) { |
|
|
158
|
+ } catch (PDOException $e) { |
|
159
|
159
|
echo $e->getMessage(); |
|
160
|
160
|
die; |
|
161
|
161
|
} |
|
@@ -177,12 +177,12 @@ discard block |
|
|
block discarded – undo |
|
177
|
177
|
date_default_timezone_set('UTC'); |
|
178
|
178
|
|
|
179
|
179
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
180
|
|
- $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
|
180
|
+ $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
181
|
181
|
|
|
182
|
182
|
try { |
|
183
|
183
|
$sth = $this->db->prepare($query); |
|
184
|
184
|
$sth->execute(array(':ident' => $ident)); |
|
185
|
|
- } catch(PDOException $e) { |
|
|
185
|
+ } catch (PDOException $e) { |
|
186
|
186
|
echo $e->getMessage(); |
|
187
|
187
|
die; |
|
188
|
188
|
} |
|
@@ -203,12 +203,12 @@ discard block |
|
|
block discarded – undo |
|
203
|
203
|
date_default_timezone_set('UTC'); |
|
204
|
204
|
|
|
205
|
205
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
206
|
|
- $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
|
206
|
+ $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
207
|
207
|
|
|
208
|
208
|
try { |
|
209
|
209
|
$sth = $this->db->prepare($query); |
|
210
|
210
|
$sth->execute(array(':id' => $id)); |
|
211
|
|
- } catch(PDOException $e) { |
|
|
211
|
+ } catch (PDOException $e) { |
|
212
|
212
|
echo $e->getMessage(); |
|
213
|
213
|
die; |
|
214
|
214
|
} |
|
@@ -229,12 +229,12 @@ discard block |
|
|
block discarded – undo |
|
229
|
229
|
date_default_timezone_set('UTC'); |
|
230
|
230
|
|
|
231
|
231
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
232
|
|
- $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
|
232
|
+ $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
233
|
233
|
|
|
234
|
234
|
try { |
|
235
|
235
|
$sth = $this->db->prepare($query); |
|
236
|
236
|
$sth->execute(array(':id' => $id)); |
|
237
|
|
- } catch(PDOException $e) { |
|
|
237
|
+ } catch (PDOException $e) { |
|
238
|
238
|
echo $e->getMessage(); |
|
239
|
239
|
die; |
|
240
|
240
|
} |
|
@@ -256,13 +256,13 @@ discard block |
|
|
block discarded – undo |
|
256
|
256
|
date_default_timezone_set('UTC'); |
|
257
|
257
|
|
|
258
|
258
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
259
|
|
- $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"; |
|
|
259
|
+ $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"; |
|
260
|
260
|
// $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
261
|
261
|
|
|
262
|
262
|
try { |
|
263
|
263
|
$sth = $this->db->prepare($query); |
|
264
|
264
|
$sth->execute(array(':ident' => $ident)); |
|
265
|
|
- } catch(PDOException $e) { |
|
|
265
|
+ } catch (PDOException $e) { |
|
266
|
266
|
echo $e->getMessage(); |
|
267
|
267
|
die; |
|
268
|
268
|
} |
|
@@ -279,13 +279,13 @@ discard block |
|
|
block discarded – undo |
|
279
|
279
|
* @return Array the spotter information |
|
280
|
280
|
* |
|
281
|
281
|
*/ |
|
282
|
|
- public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
|
282
|
+ public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
283
|
283
|
{ |
|
284
|
284
|
$Spotter = new Spotter($this->db); |
|
285
|
285
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
286
|
|
- $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"; |
|
|
286
|
+ $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"; |
|
287
|
287
|
|
|
288
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
|
288
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
289
|
289
|
|
|
290
|
290
|
return $spotter_array; |
|
291
|
291
|
} |
|
@@ -298,7 +298,7 @@ discard block |
|
|
block discarded – undo |
|
298
|
298
|
try { |
|
299
|
299
|
$sth = $this->db->prepare($query); |
|
300
|
300
|
$sth->execute(); |
|
301
|
|
- } catch(PDOException $e) { |
|
|
301
|
+ } catch (PDOException $e) { |
|
302
|
302
|
echo $e->getMessage(); |
|
303
|
303
|
die; |
|
304
|
304
|
} |
|
@@ -310,24 +310,24 @@ discard block |
|
|
block discarded – undo |
|
310
|
310
|
* @return Array the spotter information |
|
311
|
311
|
* |
|
312
|
312
|
*/ |
|
313
|
|
- public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
|
313
|
+ public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
314
|
314
|
{ |
|
315
|
315
|
global $globalDBdriver, $globalLiveInterval; |
|
316
|
316
|
date_default_timezone_set('UTC'); |
|
317
|
317
|
|
|
318
|
318
|
$filter_query = ''; |
|
319
|
319
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
320
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
320
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
321
|
321
|
} |
|
322
|
322
|
// Use spotter_output also ? |
|
323
|
323
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
324
|
|
- $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 "; |
|
|
324
|
+ $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 "; |
|
325
|
325
|
} |
|
326
|
326
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
327
|
327
|
$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 "; |
|
328
|
328
|
} |
|
329
|
329
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
330
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
330
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
331
|
331
|
} |
|
332
|
332
|
|
|
333
|
333
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -346,7 +346,7 @@ discard block |
|
|
block discarded – undo |
|
346
|
346
|
GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
|
347
|
347
|
AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
|
348
|
348
|
*/ |
|
349
|
|
- $query = 'SELECT a.aircraft_shadow, 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 |
|
|
349
|
+ $query = 'SELECT a.aircraft_shadow, 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 |
|
350
|
350
|
FROM spotter_archive |
|
351
|
351
|
INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
|
352
|
352
|
FROM spotter_archive l |
|
@@ -355,7 +355,7 @@ discard block |
|
|
block discarded – undo |
|
355
|
355
|
AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
|
356
|
356
|
} else { |
|
357
|
357
|
//$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'; |
|
358
|
|
- $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 |
|
|
358
|
+ $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 |
|
359
|
359
|
FROM spotter_archive |
|
360
|
360
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
|
361
|
361
|
WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
|
@@ -365,7 +365,7 @@ discard block |
|
|
block discarded – undo |
|
365
|
365
|
try { |
|
366
|
366
|
$sth = $this->db->prepare($query); |
|
367
|
367
|
$sth->execute(); |
|
368
|
|
- } catch(PDOException $e) { |
|
|
368
|
+ } catch (PDOException $e) { |
|
369
|
369
|
echo $e->getMessage(); |
|
370
|
370
|
die; |
|
371
|
371
|
} |
|
@@ -380,24 +380,24 @@ discard block |
|
|
block discarded – undo |
|
380
|
380
|
* @return Array the spotter information |
|
381
|
381
|
* |
|
382
|
382
|
*/ |
|
383
|
|
- public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
|
383
|
+ public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
384
|
384
|
{ |
|
385
|
385
|
global $globalDBdriver, $globalLiveInterval; |
|
386
|
386
|
date_default_timezone_set('UTC'); |
|
387
|
387
|
|
|
388
|
388
|
$filter_query = ''; |
|
389
|
389
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
390
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
390
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
391
|
391
|
} |
|
392
|
392
|
// Should use spotter_output also ? |
|
393
|
393
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
394
|
|
- $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 "; |
|
|
394
|
+ $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 "; |
|
395
|
395
|
} |
|
396
|
396
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
397
|
397
|
$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 "; |
|
398
|
398
|
} |
|
399
|
399
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
400
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
400
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
401
|
401
|
} |
|
402
|
402
|
|
|
403
|
403
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -407,7 +407,7 @@ discard block |
|
|
block discarded – undo |
|
407
|
407
|
FROM spotter_archive |
|
408
|
408
|
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'; |
|
409
|
409
|
*/ |
|
410
|
|
- $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 |
|
|
410
|
+ $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 |
|
411
|
411
|
FROM spotter_archive_output |
|
412
|
412
|
LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
|
413
|
413
|
WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
|
@@ -422,7 +422,7 @@ discard block |
|
|
block discarded – undo |
|
422
|
422
|
WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
|
423
|
423
|
'.$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'; |
|
424
|
424
|
*/ |
|
425
|
|
- $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 |
|
|
425
|
+ $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 |
|
426
|
426
|
FROM spotter_archive_output |
|
427
|
427
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
|
428
|
428
|
WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
|
@@ -434,7 +434,7 @@ discard block |
|
|
block discarded – undo |
|
434
|
434
|
try { |
|
435
|
435
|
$sth = $this->db->prepare($query); |
|
436
|
436
|
$sth->execute(); |
|
437
|
|
- } catch(PDOException $e) { |
|
|
437
|
+ } catch (PDOException $e) { |
|
438
|
438
|
echo $e->getMessage(); |
|
439
|
439
|
die; |
|
440
|
440
|
} |
|
@@ -449,23 +449,23 @@ discard block |
|
|
block discarded – undo |
|
449
|
449
|
* @return Array the spotter information |
|
450
|
450
|
* |
|
451
|
451
|
*/ |
|
452
|
|
- public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
|
452
|
+ public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
453
|
453
|
{ |
|
454
|
454
|
global $globalDBdriver, $globalLiveInterval; |
|
455
|
455
|
date_default_timezone_set('UTC'); |
|
456
|
456
|
|
|
457
|
457
|
$filter_query = ''; |
|
458
|
458
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
459
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
459
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
460
|
460
|
} |
|
461
|
461
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
462
|
|
- $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 "; |
|
|
462
|
+ $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 "; |
|
463
|
463
|
} |
|
464
|
464
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
465
|
465
|
$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 "; |
|
466
|
466
|
} |
|
467
|
467
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
468
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
468
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
469
|
469
|
} |
|
470
|
470
|
|
|
471
|
471
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -480,7 +480,7 @@ discard block |
|
|
block discarded – undo |
|
480
|
480
|
try { |
|
481
|
481
|
$sth = $this->db->prepare($query); |
|
482
|
482
|
$sth->execute(); |
|
483
|
|
- } catch(PDOException $e) { |
|
|
483
|
+ } catch (PDOException $e) { |
|
484
|
484
|
echo $e->getMessage(); |
|
485
|
485
|
die; |
|
486
|
486
|
} |
|
@@ -500,7 +500,7 @@ discard block |
|
|
block discarded – undo |
|
500
|
500
|
* @return Array the spotter information |
|
501
|
501
|
* |
|
502
|
502
|
*/ |
|
503
|
|
- 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 = '', $filter=array()) |
|
|
503
|
+ 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 = '', $filter = array()) |
|
504
|
504
|
{ |
|
505
|
505
|
global $globalTimezone, $globalDBdriver; |
|
506
|
506
|
require_once(dirname(__FILE__).'/class.Translation.php'); |
|
@@ -522,7 +522,7 @@ discard block |
|
|
block discarded – undo |
|
522
|
522
|
|
|
523
|
523
|
$q_array = explode(" ", $q); |
|
524
|
524
|
|
|
525
|
|
- foreach ($q_array as $q_item){ |
|
|
525
|
+ foreach ($q_array as $q_item) { |
|
526
|
526
|
$additional_query .= " AND ("; |
|
527
|
527
|
$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
528
|
528
|
$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
@@ -554,7 +554,7 @@ discard block |
|
|
block discarded – undo |
|
554
|
554
|
|
|
555
|
555
|
if ($registration != "") |
|
556
|
556
|
{ |
|
557
|
|
- $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
|
557
|
+ $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
558
|
558
|
if (!is_string($registration)) |
|
559
|
559
|
{ |
|
560
|
560
|
return false; |
|
@@ -565,7 +565,7 @@ discard block |
|
|
block discarded – undo |
|
565
|
565
|
|
|
566
|
566
|
if ($aircraft_icao != "") |
|
567
|
567
|
{ |
|
568
|
|
- $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
|
568
|
+ $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
569
|
569
|
if (!is_string($aircraft_icao)) |
|
570
|
570
|
{ |
|
571
|
571
|
return false; |
|
@@ -576,7 +576,7 @@ discard block |
|
|
block discarded – undo |
|
576
|
576
|
|
|
577
|
577
|
if ($aircraft_manufacturer != "") |
|
578
|
578
|
{ |
|
579
|
|
- $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
|
579
|
+ $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
580
|
580
|
if (!is_string($aircraft_manufacturer)) |
|
581
|
581
|
{ |
|
582
|
582
|
return false; |
|
@@ -597,7 +597,7 @@ discard block |
|
|
block discarded – undo |
|
597
|
597
|
|
|
598
|
598
|
if ($airline_icao != "") |
|
599
|
599
|
{ |
|
600
|
|
- $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
|
600
|
+ $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
601
|
601
|
if (!is_string($airline_icao)) |
|
602
|
602
|
{ |
|
603
|
603
|
return false; |
|
@@ -608,7 +608,7 @@ discard block |
|
|
block discarded – undo |
|
608
|
608
|
|
|
609
|
609
|
if ($airline_country != "") |
|
610
|
610
|
{ |
|
611
|
|
- $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
|
611
|
+ $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
612
|
612
|
if (!is_string($airline_country)) |
|
613
|
613
|
{ |
|
614
|
614
|
return false; |
|
@@ -619,7 +619,7 @@ discard block |
|
|
block discarded – undo |
|
619
|
619
|
|
|
620
|
620
|
if ($airline_type != "") |
|
621
|
621
|
{ |
|
622
|
|
- $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
|
622
|
+ $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
623
|
623
|
if (!is_string($airline_type)) |
|
624
|
624
|
{ |
|
625
|
625
|
return false; |
|
@@ -641,7 +641,7 @@ discard block |
|
|
block discarded – undo |
|
641
|
641
|
|
|
642
|
642
|
if ($airport != "") |
|
643
|
643
|
{ |
|
644
|
|
- $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
|
644
|
+ $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
645
|
645
|
if (!is_string($airport)) |
|
646
|
646
|
{ |
|
647
|
647
|
return false; |
|
@@ -652,7 +652,7 @@ discard block |
|
|
block discarded – undo |
|
652
|
652
|
|
|
653
|
653
|
if ($airport_country != "") |
|
654
|
654
|
{ |
|
655
|
|
- $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
|
655
|
+ $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
656
|
656
|
if (!is_string($airport_country)) |
|
657
|
657
|
{ |
|
658
|
658
|
return false; |
|
@@ -663,7 +663,7 @@ discard block |
|
|
block discarded – undo |
|
663
|
663
|
|
|
664
|
664
|
if ($callsign != "") |
|
665
|
665
|
{ |
|
666
|
|
- $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
|
666
|
+ $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
667
|
667
|
if (!is_string($callsign)) |
|
668
|
668
|
{ |
|
669
|
669
|
return false; |
|
@@ -671,7 +671,7 @@ discard block |
|
|
block discarded – undo |
|
671
|
671
|
$translate = $Translation->ident2icao($callsign); |
|
672
|
672
|
if ($translate != $callsign) { |
|
673
|
673
|
$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
|
674
|
|
- $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
|
674
|
+ $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
675
|
675
|
} else { |
|
676
|
676
|
$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
|
677
|
677
|
} |
|
@@ -680,7 +680,7 @@ discard block |
|
|
block discarded – undo |
|
680
|
680
|
|
|
681
|
681
|
if ($owner != "") |
|
682
|
682
|
{ |
|
683
|
|
- $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
|
683
|
+ $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
684
|
684
|
if (!is_string($owner)) |
|
685
|
685
|
{ |
|
686
|
686
|
return false; |
|
@@ -691,7 +691,7 @@ discard block |
|
|
block discarded – undo |
|
691
|
691
|
|
|
692
|
692
|
if ($pilot_name != "") |
|
693
|
693
|
{ |
|
694
|
|
- $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
|
694
|
+ $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
695
|
695
|
if (!is_string($pilot_name)) |
|
696
|
696
|
{ |
|
697
|
697
|
return false; |
|
@@ -702,7 +702,7 @@ discard block |
|
|
block discarded – undo |
|
702
|
702
|
|
|
703
|
703
|
if ($pilot_id != "") |
|
704
|
704
|
{ |
|
705
|
|
- $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
|
705
|
+ $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
706
|
706
|
if (!is_string($pilot_id)) |
|
707
|
707
|
{ |
|
708
|
708
|
return false; |
|
@@ -713,7 +713,7 @@ discard block |
|
|
block discarded – undo |
|
713
|
713
|
|
|
714
|
714
|
if ($departure_airport_route != "") |
|
715
|
715
|
{ |
|
716
|
|
- $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
|
716
|
+ $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
717
|
717
|
if (!is_string($departure_airport_route)) |
|
718
|
718
|
{ |
|
719
|
719
|
return false; |
|
@@ -724,7 +724,7 @@ discard block |
|
|
block discarded – undo |
|
724
|
724
|
|
|
725
|
725
|
if ($arrival_airport_route != "") |
|
726
|
726
|
{ |
|
727
|
|
- $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
|
727
|
+ $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
728
|
728
|
if (!is_string($arrival_airport_route)) |
|
729
|
729
|
{ |
|
730
|
730
|
return false; |
|
@@ -737,8 +737,8 @@ discard block |
|
|
block discarded – undo |
|
737
|
737
|
{ |
|
738
|
738
|
$altitude_array = explode(",", $altitude); |
|
739
|
739
|
|
|
740
|
|
- $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
741
|
|
- $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
|
740
|
+ $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
|
741
|
+ $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
742
|
742
|
|
|
743
|
743
|
|
|
744
|
744
|
if ($altitude_array[1] != "") |
|
@@ -756,8 +756,8 @@ discard block |
|
|
block discarded – undo |
|
756
|
756
|
{ |
|
757
|
757
|
$date_array = explode(",", $date_posted); |
|
758
|
758
|
|
|
759
|
|
- $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
760
|
|
- $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
|
759
|
+ $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
|
760
|
+ $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
761
|
761
|
|
|
762
|
762
|
if ($globalTimezone != '') { |
|
763
|
763
|
date_default_timezone_set($globalTimezone); |
|
@@ -789,8 +789,8 @@ discard block |
|
|
block discarded – undo |
|
789
|
789
|
{ |
|
790
|
790
|
$limit_array = explode(",", $limit); |
|
791
|
791
|
|
|
792
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
793
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
792
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
793
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
794
|
794
|
|
|
795
|
795
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
796
|
796
|
{ |
|
@@ -801,8 +801,8 @@ discard block |
|
|
block discarded – undo |
|
801
|
801
|
|
|
802
|
802
|
|
|
803
|
803
|
if ($origLat != "" && $origLon != "" && $dist != "") { |
|
804
|
|
- $dist = number_format($dist*0.621371,2,'.',''); |
|
805
|
|
- $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 |
|
|
804
|
+ $dist = number_format($dist*0.621371, 2, '.', ''); |
|
|
805
|
+ $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 |
|
806
|
806
|
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)) |
|
807
|
807
|
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"; |
|
808
|
808
|
} else { |
|
@@ -819,12 +819,12 @@ discard block |
|
|
block discarded – undo |
|
819
|
819
|
$additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
|
820
|
820
|
} |
|
821
|
821
|
|
|
822
|
|
- $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
|
822
|
+ $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
823
|
823
|
WHERE spotter_archive_output.ident <> '' |
|
824
|
824
|
".$additional_query." |
|
825
|
825
|
".$filter_query.$orderby_query; |
|
826
|
826
|
} |
|
827
|
|
- $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
|
827
|
+ $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
828
|
828
|
|
|
829
|
829
|
return $spotter_array; |
|
830
|
830
|
} |
|
@@ -841,7 +841,7 @@ discard block |
|
|
block discarded – undo |
|
841
|
841
|
try { |
|
842
|
842
|
$sth = $this->db->prepare($query); |
|
843
|
843
|
$sth->execute(); |
|
844
|
|
- } catch(PDOException $e) { |
|
|
844
|
+ } catch (PDOException $e) { |
|
845
|
845
|
return "error"; |
|
846
|
846
|
} |
|
847
|
847
|
} |
|
@@ -878,8 +878,8 @@ discard block |
|
|
block discarded – undo |
|
878
|
878
|
{ |
|
879
|
879
|
$limit_array = explode(",", $limit); |
|
880
|
880
|
|
|
881
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
882
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
881
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
882
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
883
|
883
|
|
|
884
|
884
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
885
|
885
|
{ |
|
@@ -909,7 +909,7 @@ discard block |
|
|
block discarded – undo |
|
909
|
909
|
* @return Array the airline country list |
|
910
|
910
|
* |
|
911
|
911
|
*/ |
|
912
|
|
- public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
|
912
|
+ public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
913
|
913
|
{ |
|
914
|
914
|
global $globalDBdriver; |
|
915
|
915
|
/* |
|
@@ -938,7 +938,7 @@ discard block |
|
|
block discarded – undo |
|
938
|
938
|
$flight_array = array(); |
|
939
|
939
|
$temp_array = array(); |
|
940
|
940
|
|
|
941
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
941
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
942
|
942
|
{ |
|
943
|
943
|
$temp_array['flight_count'] = $row['nb']; |
|
944
|
944
|
$temp_array['flight_country'] = $row['name']; |
|
@@ -955,14 +955,14 @@ discard block |
|
|
block discarded – undo |
|
955
|
955
|
* @return Array the spotter information |
|
956
|
956
|
* |
|
957
|
957
|
*/ |
|
958
|
|
- public function getDateArchiveSpotterDataById($id,$date) |
|
|
958
|
+ public function getDateArchiveSpotterDataById($id, $date) |
|
959
|
959
|
{ |
|
960
|
960
|
$Spotter = new Spotter($this->db); |
|
961
|
961
|
date_default_timezone_set('UTC'); |
|
962
|
962
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
963
|
|
- $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'; |
|
964
|
|
- $date = date('c',$date); |
|
965
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
|
963
|
+ $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'; |
|
|
964
|
+ $date = date('c', $date); |
|
|
965
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
966
|
966
|
return $spotter_array; |
|
967
|
967
|
} |
|
968
|
968
|
|
|
@@ -972,14 +972,14 @@ discard block |
|
|
block discarded – undo |
|
972
|
972
|
* @return Array the spotter information |
|
973
|
973
|
* |
|
974
|
974
|
*/ |
|
975
|
|
- public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
|
975
|
+ public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
976
|
976
|
{ |
|
977
|
977
|
$Spotter = new Spotter($this->db); |
|
978
|
978
|
date_default_timezone_set('UTC'); |
|
979
|
979
|
$ident = filter_var($ident, 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.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'; |
|
981
|
|
- $date = date('c',$date); |
|
982
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':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.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'; |
|
|
981
|
+ $date = date('c', $date); |
|
|
982
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
983
|
983
|
return $spotter_array; |
|
984
|
984
|
} |
|
985
|
985
|
|