|
1
|
|
|
<?php |
|
2
|
|
|
require_once(dirname(__FILE__).'/class.Scheduler.php'); |
|
3
|
|
|
require_once(dirname(__FILE__).'/class.ACARS.php'); |
|
4
|
|
|
require_once(dirname(__FILE__).'/class.Image.php'); |
|
5
|
|
|
$global_query = "SELECT spotter_output.* FROM spotter_output"; |
|
6
|
|
|
|
|
7
|
|
|
class Spotter{ |
|
8
|
|
|
public $db; |
|
9
|
|
|
|
|
10
|
|
|
public function __construct($dbc = null) { |
|
11
|
|
|
$Connection = new Connection($dbc); |
|
12
|
|
|
$this->db = $Connection->db(); |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Get SQL query part for filter used |
|
17
|
|
|
* @param Array $filter the filter |
|
18
|
|
|
* @return Array the SQL part |
|
19
|
|
|
*/ |
|
20
|
|
|
public function getFilter($filter = array(),$where = false,$and = false) { |
|
21
|
|
|
global $globalFilter, $globalStatsFilters, $globalFilterName; |
|
22
|
|
|
$filters = array(); |
|
23
|
|
|
if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
|
24
|
|
|
if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
25
|
|
|
$filters = $globalStatsFilters[$globalFilterName]; |
|
26
|
|
|
} else { |
|
27
|
|
|
$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
28
|
|
|
} |
|
29
|
|
|
} |
|
30
|
|
|
if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
31
|
|
|
$filter_query_join = ''; |
|
32
|
|
|
$filter_query_where = ''; |
|
33
|
|
|
foreach($filters as $flt) { |
|
34
|
|
|
if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
35
|
|
|
if ($flt['airlines'][0] != '') { |
|
36
|
|
|
if (isset($flt['source'])) { |
|
37
|
|
|
$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
|
38
|
|
|
} else { |
|
39
|
|
|
$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
44
|
|
|
if (isset($flt['source'])) { |
|
45
|
|
|
$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
|
46
|
|
|
} else { |
|
47
|
|
|
$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
|
51
|
|
|
if (isset($flt['source'])) { |
|
52
|
|
|
$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
57
|
|
|
if ($filter['airlines'][0] != '') { |
|
58
|
|
|
$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
62
|
|
|
$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_output.flightaware_id "; |
|
63
|
|
|
} |
|
64
|
|
|
if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
|
65
|
|
|
$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
|
66
|
|
|
} |
|
67
|
|
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
68
|
|
|
$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
69
|
|
|
} |
|
70
|
|
|
if (isset($filter['ident']) && !empty($filter['ident'])) { |
|
71
|
|
|
$filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
|
72
|
|
|
} |
|
73
|
|
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
74
|
|
|
if ($filter_query_where == '') { |
|
75
|
|
|
$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
76
|
|
|
} else { |
|
77
|
|
|
$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
81
|
|
|
elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
82
|
|
|
$filter_query = $filter_query_join.$filter_query_where; |
|
83
|
|
|
return $filter_query; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Executes the SQL statements to get the spotter information |
|
88
|
|
|
* |
|
89
|
|
|
* @param String $query the SQL query |
|
90
|
|
|
* @param Array $params parameter of the query |
|
91
|
|
|
* @param String $limitQuery the limit query |
|
92
|
|
|
* @return Array the spotter information |
|
93
|
|
|
* |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
96
|
|
|
{ |
|
97
|
|
|
global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM; |
|
98
|
|
|
$Image = new Image($this->db); |
|
99
|
|
|
$Schedule = new Schedule($this->db); |
|
100
|
|
|
$ACARS = new ACARS($this->db); |
|
101
|
|
|
if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
102
|
|
|
if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
103
|
|
|
if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
104
|
|
|
if (!isset($globalVAM)) $globalVAM = FALSE; |
|
105
|
|
|
date_default_timezone_set('UTC'); |
|
106
|
|
|
|
|
107
|
|
|
if (!is_string($query)) |
|
108
|
|
|
{ |
|
109
|
|
|
return false; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
if ($limitQuery != "") |
|
113
|
|
|
{ |
|
114
|
|
|
if (!is_string($limitQuery)) |
|
115
|
|
|
{ |
|
116
|
|
|
return false; |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
try { |
|
122
|
|
|
$sth = $this->db->prepare($query.$limitQuery); |
|
123
|
|
|
$sth->execute($params); |
|
124
|
|
|
} catch (PDOException $e) { |
|
125
|
|
|
printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
126
|
|
|
exit(); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
// $num_rows = count($sth->fetchAll()); |
|
130
|
|
|
$num_rows = 0; |
|
131
|
|
|
|
|
132
|
|
|
$spotter_array = array(); |
|
133
|
|
|
|
|
134
|
|
|
|
|
135
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
136
|
|
|
{ |
|
137
|
|
|
$num_rows++; |
|
138
|
|
|
$temp_array = array(); |
|
139
|
|
|
if (isset($row['spotter_live_id'])) { |
|
140
|
|
|
//$temp_array['spotter_id'] = $row['spotter_live_id']; |
|
141
|
|
|
$temp_array['spotter_id'] = $this->getSpotterIDBasedOnFlightAwareID($row['flightaware_id']); |
|
142
|
|
|
} elseif (isset($row['spotter_archive_id'])) { |
|
143
|
|
|
$temp_array['spotter_id'] = $row['spotter_archive_id']; |
|
144
|
|
|
} elseif (isset($row['spotter_archive_output_id'])) { |
|
145
|
|
|
$temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
|
146
|
|
|
} elseif (isset($row['spotter_id'])) { |
|
147
|
|
|
$temp_array['spotter_id'] = $row['spotter_id']; |
|
148
|
|
|
} else { |
|
149
|
|
|
$temp_array['spotter_id'] = ''; |
|
150
|
|
|
} |
|
151
|
|
|
if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id']; |
|
152
|
|
|
if (isset($row['modes'])) $temp_array['modes'] = $row['modes']; |
|
153
|
|
|
$temp_array['ident'] = $row['ident']; |
|
154
|
|
|
if (isset($row['registration']) && $row['registration'] != '') { |
|
155
|
|
|
$temp_array['registration'] = $row['registration']; |
|
156
|
|
|
} elseif (isset($temp_array['modes'])) { |
|
157
|
|
|
$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']); |
|
158
|
|
|
} else $temp_array['registration'] = ''; |
|
159
|
|
|
if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao']; |
|
160
|
|
|
|
|
161
|
|
|
$temp_array['departure_airport'] = $row['departure_airport_icao']; |
|
162
|
|
|
$temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
|
163
|
|
|
if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
164
|
|
|
if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
165
|
|
|
if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
166
|
|
|
/* |
|
167
|
|
|
if (Connection->tableExists('countries')) { |
|
168
|
|
|
$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']); |
|
169
|
|
|
if (is_array($country_info) && isset($country_info['name']) && isset($country_info['iso2'])) { |
|
170
|
|
|
$temp_array['country'] = $country_info['name']; |
|
171
|
|
|
$temp_array['country_iso2'] = $country_info['iso2']; |
|
172
|
|
|
} |
|
173
|
|
|
} |
|
174
|
|
|
*/ |
|
175
|
|
|
if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints']; |
|
176
|
|
|
if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
177
|
|
|
if (isset($row['route_stop'])) { |
|
178
|
|
|
$temp_array['route_stop'] = $row['route_stop']; |
|
179
|
|
|
if ($row['route_stop'] != '') { |
|
180
|
|
|
$allroute = explode(' ',$row['route_stop']); |
|
181
|
|
|
|
|
182
|
|
|
foreach ($allroute as $route) { |
|
183
|
|
|
$route_airport_array = $this->getAllAirportInfo($route); |
|
184
|
|
|
if (isset($route_airport_array[0]['name'])) { |
|
185
|
|
|
$route_stop_details = array(); |
|
186
|
|
|
$route_stop_details['airport_name'] = $route_airport_array[0]['name']; |
|
187
|
|
|
$route_stop_details['airport_city'] = $route_airport_array[0]['city']; |
|
188
|
|
|
$route_stop_details['airport_country'] = $route_airport_array[0]['country']; |
|
189
|
|
|
$route_stop_details['airport_icao'] = $route_airport_array[0]['icao']; |
|
190
|
|
|
$temp_array['route_stop_details'][] = $route_stop_details; |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
} |
|
194
|
|
|
} |
|
195
|
|
|
if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
196
|
|
|
if (isset($row['heading'])) { |
|
197
|
|
|
$temp_array['heading'] = $row['heading']; |
|
198
|
|
|
$heading_direction = $this->parseDirection($row['heading']); |
|
199
|
|
|
if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
200
|
|
|
} |
|
201
|
|
|
if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
202
|
|
|
$temp_array['image'] = ""; |
|
203
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
204
|
|
|
$temp_array['image_source'] = ""; |
|
205
|
|
|
$temp_array['image_copyright'] = ""; |
|
206
|
|
|
|
|
207
|
|
|
if (isset($row['highlight'])) { |
|
208
|
|
|
$temp_array['highlight'] = $row['highlight']; |
|
209
|
|
|
} else $temp_array['highlight'] = ''; |
|
210
|
|
|
|
|
211
|
|
|
if (isset($row['date'])) { |
|
212
|
|
|
$dateArray = $this->parseDateString($row['date']); |
|
213
|
|
|
if ($dateArray['seconds'] < 10) |
|
214
|
|
|
{ |
|
215
|
|
|
$temp_array['date'] = "a few seconds ago"; |
|
216
|
|
|
} elseif ($dateArray['seconds'] >= 5 && $dateArray['seconds'] < 30) |
|
217
|
|
|
{ |
|
218
|
|
|
$temp_array['date'] = "half a minute ago"; |
|
219
|
|
|
} elseif ($dateArray['seconds'] >= 30 && $dateArray['seconds'] < 60) |
|
220
|
|
|
{ |
|
221
|
|
|
$temp_array['date'] = "about a minute ago"; |
|
222
|
|
|
} elseif ($dateArray['minutes'] < 5) |
|
223
|
|
|
{ |
|
224
|
|
|
$temp_array['date'] = "a few minutes ago"; |
|
225
|
|
|
} elseif ($dateArray['minutes'] >= 5 && $dateArray['minutes'] < 60) |
|
226
|
|
|
{ |
|
227
|
|
|
$temp_array['date'] = "about ".$dateArray['minutes']." minutes ago"; |
|
228
|
|
|
} elseif ($dateArray['hours'] < 2) |
|
229
|
|
|
{ |
|
230
|
|
|
$temp_array['date'] = "about an hour ago"; |
|
231
|
|
|
} elseif ($dateArray['hours'] >= 2 && $dateArray['hours'] < 24) |
|
232
|
|
|
{ |
|
233
|
|
|
$temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
|
234
|
|
|
} else { |
|
235
|
|
|
$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
236
|
|
|
} |
|
237
|
|
|
$temp_array['date_minutes_past'] = $dateArray['minutes']; |
|
238
|
|
|
$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
239
|
|
|
$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
240
|
|
|
$temp_array['date_unix'] = strtotime($row['date']." UTC"); |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
if (isset($row['aircraft_name']) && $row['aircraft_name'] != '' && isset($row['aircraft_shadow']) && $row['aircraft_shadow'] != '') { |
|
244
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
245
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
246
|
|
|
if (isset($row['aircraft_shadow'])) { |
|
247
|
|
|
$temp_array['aircraft_shadow'] = $row['aircraft_shadow']; |
|
248
|
|
|
} |
|
249
|
|
|
} elseif (isset($row['aircraft_icao'])) { |
|
250
|
|
|
$aircraft_array = $this->getAllAircraftInfo($row['aircraft_icao']); |
|
251
|
|
|
if (count($aircraft_array) > 0) { |
|
252
|
|
|
$temp_array['aircraft_name'] = $aircraft_array[0]['type']; |
|
253
|
|
|
$temp_array['aircraft_manufacturer'] = $aircraft_array[0]['manufacturer']; |
|
254
|
|
|
|
|
255
|
|
|
if ($aircraft_array[0]['aircraft_shadow'] != NULL) { |
|
256
|
|
|
$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow']; |
|
257
|
|
|
} else $temp_array['aircraft_shadow'] = 'default.png'; |
|
258
|
|
|
} else { |
|
259
|
|
|
$temp_array['aircraft_shadow'] = 'default.png'; |
|
260
|
|
|
$temp_array['aircraft_name'] = 'N/A'; |
|
261
|
|
|
$temp_array['aircraft_manufacturer'] = 'N/A'; |
|
262
|
|
|
} |
|
263
|
|
|
} |
|
264
|
|
|
$fromsource = NULL; |
|
265
|
|
|
if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
266
|
|
|
elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
267
|
|
|
elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
268
|
|
|
elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
269
|
|
|
elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
270
|
|
|
if (!isset($row['airline_name']) || $row['airline_name'] == '') { |
|
271
|
|
|
if (!is_numeric(substr($row['ident'], 0, 3))) { |
|
272
|
|
|
if (is_numeric(substr($row['ident'], 2, 1))) { |
|
273
|
|
|
$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource); |
|
274
|
|
|
} elseif (is_numeric(substr($row['ident'], 3, 1))) { |
|
275
|
|
|
$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
|
276
|
|
|
} else { |
|
277
|
|
|
$airline_array = $this->getAllAirlineInfo('NA'); |
|
278
|
|
|
} |
|
279
|
|
|
} else { |
|
280
|
|
|
$airline_array = $this->getAllAirlineInfo('NA'); |
|
281
|
|
|
} |
|
282
|
|
|
if (count($airline_array) > 0) { |
|
283
|
|
|
$temp_array['airline_icao'] = $airline_array[0]['icao']; |
|
284
|
|
|
$temp_array['airline_iata'] = $airline_array[0]['iata']; |
|
285
|
|
|
$temp_array['airline_name'] = $airline_array[0]['name']; |
|
286
|
|
|
$temp_array['airline_country'] = $airline_array[0]['country']; |
|
287
|
|
|
$temp_array['airline_callsign'] = $airline_array[0]['callsign']; |
|
288
|
|
|
$temp_array['airline_type'] = $airline_array[0]['type']; |
|
289
|
|
|
} |
|
290
|
|
|
} else { |
|
291
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
292
|
|
|
if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata']; |
|
293
|
|
|
else $temp_array['airline_iata'] = 'N/A'; |
|
294
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
295
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
296
|
|
|
if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
297
|
|
|
else $temp_array['airline_callsign'] = 'N/A'; |
|
298
|
|
|
$temp_array['airline_type'] = $row['airline_type']; |
|
299
|
|
|
if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') { |
|
300
|
|
|
$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']); |
|
301
|
|
|
if (count($airline_array) > 0) { |
|
302
|
|
|
$temp_array['airline_icao'] = $airline_array[0]['icao']; |
|
303
|
|
|
$temp_array['airline_iata'] = $airline_array[0]['iata']; |
|
304
|
|
|
$temp_array['airline_name'] = $airline_array[0]['name']; |
|
305
|
|
|
$temp_array['airline_country'] = $airline_array[0]['country']; |
|
306
|
|
|
$temp_array['airline_callsign'] = $airline_array[0]['callsign']; |
|
307
|
|
|
$temp_array['airline_type'] = $airline_array[0]['type']; |
|
308
|
|
|
} |
|
309
|
|
|
} |
|
310
|
|
|
} |
|
311
|
|
|
if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') { |
|
312
|
|
|
$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3)); |
|
313
|
|
|
//$acars_array = ACARS->getLiveAcarsData('BA40YL'); |
|
314
|
|
|
if (count($acars_array) > 0) { |
|
315
|
|
|
$temp_array['acars'] = $acars_array; |
|
316
|
|
|
//print_r($acars_array); |
|
317
|
|
|
} |
|
318
|
|
|
} |
|
319
|
|
|
if (isset($row['owner_name']) && $row['owner_name'] != '' && $row['owner_name'] != NULL) { |
|
320
|
|
|
$temp_array['aircraft_owner'] = $row['owner_name']; |
|
321
|
|
|
} |
|
322
|
|
|
if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) { |
|
323
|
|
|
$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']); |
|
324
|
|
|
if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
325
|
|
|
$temp_array['aircraft_base'] = $owner_info['base']; |
|
326
|
|
|
$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) |
|
330
|
|
|
{ |
|
331
|
|
|
if ($globalIVAO) { |
|
332
|
|
|
if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
333
|
|
|
else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
334
|
|
|
} else $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
335
|
|
|
if (count($image_array) > 0) { |
|
336
|
|
|
$temp_array['image'] = $image_array[0]['image']; |
|
337
|
|
|
$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
338
|
|
|
$temp_array['image_source'] = $image_array[0]['image_source']; |
|
339
|
|
|
$temp_array['image_source_website'] = $image_array[0]['image_source_website']; |
|
340
|
|
|
if ($temp_array['image_source_website'] == '' && $temp_array['image_source'] == 'planespotters') { |
|
341
|
|
|
$planespotter_url_array = explode("_", $temp_array['image']); |
|
342
|
|
|
$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
|
343
|
|
|
$temp_array['image_source_website'] = 'http://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
|
344
|
|
|
} |
|
345
|
|
|
$temp_array['image_copyright'] = $image_array[0]['image_copyright']; |
|
346
|
|
|
} |
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
|
|
|
|
350
|
|
|
if (isset($row['departure_airport_time']) && $row['departure_airport_time'] != '') { |
|
351
|
|
|
$temp_array['departure_airport_time'] = $row['departure_airport_time']; |
|
352
|
|
|
} |
|
353
|
|
|
if (isset($row['arrival_airport_time']) && $row['arrival_airport_time'] != '') { |
|
354
|
|
|
$temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
|
355
|
|
|
} |
|
356
|
|
|
|
|
357
|
|
|
if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { |
|
358
|
|
|
if ($schedules === true) { |
|
359
|
|
|
$schedule_array = $Schedule->getSchedule($temp_array['ident']); |
|
360
|
|
|
//print_r($schedule_array); |
|
361
|
|
|
if (count($schedule_array) > 0) { |
|
362
|
|
|
if ($schedule_array['departure_airport_icao'] != '') { |
|
363
|
|
|
$row['departure_airport_icao'] = $schedule_array['departure_airport_icao']; |
|
364
|
|
|
$temp_array['departure_airport'] = $row['departure_airport_icao']; |
|
365
|
|
|
} |
|
366
|
|
|
if ($schedule_array['arrival_airport_icao'] != '') { |
|
367
|
|
|
$row['arrival_airport_icao'] = $schedule_array['arrival_airport_icao']; |
|
368
|
|
|
$temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
|
369
|
|
|
} |
|
370
|
|
|
$temp_array['departure_airport_time'] = $schedule_array['departure_airport_time']; |
|
371
|
|
|
$temp_array['arrival_airport_time'] = $schedule_array['arrival_airport_time']; |
|
372
|
|
|
} |
|
373
|
|
|
} |
|
374
|
|
|
} else { |
|
375
|
|
|
if (isset($row['real_departure_airport_time']) && $row['real_departure_airport_time'] != '') { |
|
376
|
|
|
$temp_array['departure_airport_time'] = $row['real_departure_airport_time']; |
|
377
|
|
|
} |
|
378
|
|
|
if (isset($row['real_arrival_airport_time']) && $row['real_arrival_airport_time'] != '') { |
|
379
|
|
|
$temp_array['real_arrival_airport_time'] = $row['real_arrival_airport_time']; |
|
380
|
|
|
} |
|
381
|
|
|
} |
|
382
|
|
|
|
|
383
|
|
|
//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') { |
|
384
|
|
|
if ($row['departure_airport_icao'] != '') { |
|
385
|
|
|
$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']); |
|
386
|
|
|
if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
387
|
|
|
/* |
|
388
|
|
|
} elseif ($row['departure_airport_name'] != '') { |
|
389
|
|
|
$temp_array['departure_airport_name'] = $row['departure_airport_name']; |
|
390
|
|
|
$temp_array['departure_airport_city'] = $row['departure_airport_city']; |
|
391
|
|
|
$temp_array['departure_airport_country'] = $row['departure_airport_country']; |
|
392
|
|
|
$temp_array['departure_airport_icao'] = $row['departure_airport_icao']; |
|
393
|
|
|
*/ |
|
394
|
|
|
} else $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
395
|
|
|
if (isset($departure_airport_array[0]['name'])) { |
|
396
|
|
|
$temp_array['departure_airport_name'] = $departure_airport_array[0]['name']; |
|
397
|
|
|
$temp_array['departure_airport_city'] = $departure_airport_array[0]['city']; |
|
398
|
|
|
$temp_array['departure_airport_country'] = $departure_airport_array[0]['country']; |
|
399
|
|
|
$temp_array['departure_airport_iata'] = $departure_airport_array[0]['iata']; |
|
400
|
|
|
$temp_array['departure_airport_icao'] = $departure_airport_array[0]['icao']; |
|
401
|
|
|
$temp_array['departure_airport_latitude'] = $departure_airport_array[0]['latitude']; |
|
402
|
|
|
$temp_array['departure_airport_longitude'] = $departure_airport_array[0]['longitude']; |
|
403
|
|
|
$temp_array['departure_airport_altitude'] = $departure_airport_array[0]['altitude']; |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
/* |
|
407
|
|
|
if (isset($row['departure_airport_time'])) { |
|
408
|
|
|
$temp_array['departure_airport_time'] = $row['departure_airport_time']; |
|
409
|
|
|
} |
|
410
|
|
|
*/ |
|
411
|
|
|
|
|
412
|
|
|
if ($row['arrival_airport_icao'] != '') { |
|
413
|
|
|
$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']); |
|
414
|
|
|
if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
415
|
|
|
} else $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
416
|
|
|
if (isset($arrival_airport_array[0]['name'])) { |
|
417
|
|
|
$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name']; |
|
418
|
|
|
$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city']; |
|
419
|
|
|
$temp_array['arrival_airport_country'] = $arrival_airport_array[0]['country']; |
|
420
|
|
|
$temp_array['arrival_airport_iata'] = $arrival_airport_array[0]['iata']; |
|
421
|
|
|
$temp_array['arrival_airport_icao'] = $arrival_airport_array[0]['icao']; |
|
422
|
|
|
$temp_array['arrival_airport_latitude'] = $arrival_airport_array[0]['latitude']; |
|
423
|
|
|
$temp_array['arrival_airport_longitude'] = $arrival_airport_array[0]['longitude']; |
|
424
|
|
|
$temp_array['arrival_airport_altitude'] = $arrival_airport_array[0]['altitude']; |
|
425
|
|
|
} |
|
426
|
|
|
/* |
|
427
|
|
|
if (isset($row['arrival_airport_time'])) { |
|
428
|
|
|
$temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
|
429
|
|
|
} |
|
430
|
|
|
*/ |
|
431
|
|
|
if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id']; |
|
432
|
|
|
if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name']; |
|
433
|
|
|
if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
434
|
|
|
if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
435
|
|
|
if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
436
|
|
|
if (isset($row['squawk'])) { |
|
437
|
|
|
$temp_array['squawk'] = $row['squawk']; |
|
438
|
|
|
if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { |
|
439
|
|
|
$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); |
|
440
|
|
|
if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
441
|
|
|
} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { |
|
442
|
|
|
$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); |
|
443
|
|
|
if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
444
|
|
|
} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
$temp_array['query_number_rows'] = $num_rows; |
|
448
|
|
|
|
|
449
|
|
|
$spotter_array[] = $temp_array; |
|
450
|
|
|
} |
|
451
|
|
|
if ($num_rows == 0) return array(); |
|
452
|
|
|
$spotter_array[0]['query_number_rows'] = $num_rows; |
|
453
|
|
|
return $spotter_array; |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
|
|
|
|
457
|
|
|
/** |
|
458
|
|
|
* Gets all the spotter information |
|
459
|
|
|
* |
|
460
|
|
|
* @return Array the spotter information |
|
461
|
|
|
* |
|
462
|
|
|
*/ |
|
463
|
|
|
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()) |
|
464
|
|
|
{ |
|
465
|
|
|
global $globalTimezone, $globalDBdriver; |
|
466
|
|
|
require_once(dirname(__FILE__).'/class.Translation.php'); |
|
467
|
|
|
$Translation = new Translation(); |
|
468
|
|
|
|
|
469
|
|
|
date_default_timezone_set('UTC'); |
|
470
|
|
|
|
|
471
|
|
|
$query_values = array(); |
|
472
|
|
|
$additional_query = ''; |
|
473
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
474
|
|
|
if ($q != "") |
|
475
|
|
|
{ |
|
476
|
|
|
if (!is_string($q)) |
|
477
|
|
|
{ |
|
478
|
|
|
return false; |
|
479
|
|
|
} else { |
|
480
|
|
|
$q_array = explode(" ", $q); |
|
481
|
|
|
foreach ($q_array as $q_item){ |
|
482
|
|
|
$q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
483
|
|
|
$additional_query .= " AND ("; |
|
484
|
|
|
if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
485
|
|
|
$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
|
486
|
|
|
$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
|
487
|
|
|
$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
488
|
|
|
$additional_query .= "(spotter_output.airline_icao like '%".$q_item."%') OR "; |
|
489
|
|
|
$additional_query .= "(spotter_output.airline_name like '%".$q_item."%') OR "; |
|
490
|
|
|
$additional_query .= "(spotter_output.airline_country like '%".$q_item."%') OR "; |
|
491
|
|
|
$additional_query .= "(spotter_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
492
|
|
|
$additional_query .= "(spotter_output.departure_airport_name like '%".$q_item."%') OR "; |
|
493
|
|
|
$additional_query .= "(spotter_output.departure_airport_city like '%".$q_item."%') OR "; |
|
494
|
|
|
$additional_query .= "(spotter_output.departure_airport_country like '%".$q_item."%') OR "; |
|
495
|
|
|
$additional_query .= "(spotter_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
496
|
|
|
$additional_query .= "(spotter_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
497
|
|
|
$additional_query .= "(spotter_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
498
|
|
|
$additional_query .= "(spotter_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
499
|
|
|
$additional_query .= "(spotter_output.registration like '%".$q_item."%') OR "; |
|
500
|
|
|
$additional_query .= "(spotter_output.owner_name like '%".$q_item."%') OR "; |
|
501
|
|
|
$additional_query .= "(spotter_output.pilot_id like '%".$q_item."%') OR "; |
|
502
|
|
|
$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR "; |
|
503
|
|
|
$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR "; |
|
504
|
|
|
$translate = $Translation->ident2icao($q_item); |
|
505
|
|
|
if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
506
|
|
|
$additional_query .= "(spotter_output.highlight like '%".$q_item."%')"; |
|
507
|
|
|
$additional_query .= ")"; |
|
508
|
|
|
} |
|
509
|
|
|
} |
|
510
|
|
|
} |
|
511
|
|
|
|
|
512
|
|
|
if ($registration != "") |
|
513
|
|
|
{ |
|
514
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
515
|
|
|
if (!is_string($registration)) |
|
516
|
|
|
{ |
|
517
|
|
|
return false; |
|
518
|
|
|
} else { |
|
519
|
|
|
$additional_query .= " AND spotter_output.registration = :registration"; |
|
520
|
|
|
$query_values = array_merge($query_values,array(':registration' => $registration)); |
|
521
|
|
|
} |
|
522
|
|
|
} |
|
523
|
|
|
|
|
524
|
|
|
if ($aircraft_icao != "") |
|
525
|
|
|
{ |
|
526
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
527
|
|
|
if (!is_string($aircraft_icao)) |
|
528
|
|
|
{ |
|
529
|
|
|
return false; |
|
530
|
|
|
} else { |
|
531
|
|
|
$additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao"; |
|
532
|
|
|
$query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao)); |
|
533
|
|
|
} |
|
534
|
|
|
} |
|
535
|
|
|
|
|
536
|
|
|
if ($aircraft_manufacturer != "") |
|
537
|
|
|
{ |
|
538
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
539
|
|
|
if (!is_string($aircraft_manufacturer)) |
|
540
|
|
|
{ |
|
541
|
|
|
return false; |
|
542
|
|
|
} else { |
|
543
|
|
|
$additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer"; |
|
544
|
|
|
$query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
545
|
|
|
} |
|
546
|
|
|
} |
|
547
|
|
|
|
|
548
|
|
|
if ($highlights == "true") |
|
549
|
|
|
{ |
|
550
|
|
|
if (!is_string($highlights)) |
|
551
|
|
|
{ |
|
552
|
|
|
return false; |
|
553
|
|
|
} else { |
|
554
|
|
|
$additional_query .= " AND (spotter_output.highlight <> '')"; |
|
555
|
|
|
} |
|
556
|
|
|
} |
|
557
|
|
|
|
|
558
|
|
|
if ($airline_icao != "") |
|
559
|
|
|
{ |
|
560
|
|
|
$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
561
|
|
|
if (!is_string($airline_icao)) |
|
562
|
|
|
{ |
|
563
|
|
|
return false; |
|
564
|
|
|
} else { |
|
565
|
|
|
$additional_query .= " AND spotter_output.airline_icao = :airline_icao"; |
|
566
|
|
|
$query_values = array_merge($query_values,array(':airline_icao' => $airline_icao)); |
|
567
|
|
|
} |
|
568
|
|
|
} |
|
569
|
|
|
|
|
570
|
|
|
if ($airline_country != "") |
|
571
|
|
|
{ |
|
572
|
|
|
$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
573
|
|
|
if (!is_string($airline_country)) |
|
574
|
|
|
{ |
|
575
|
|
|
return false; |
|
576
|
|
|
} else { |
|
577
|
|
|
$additional_query .= " AND spotter_output.airline_country = :airline_country"; |
|
578
|
|
|
$query_values = array_merge($query_values,array(':airline_country' => $airline_country)); |
|
579
|
|
|
} |
|
580
|
|
|
} |
|
581
|
|
|
|
|
582
|
|
|
if ($airline_type != "") |
|
583
|
|
|
{ |
|
584
|
|
|
if (!is_string($airline_type)) |
|
585
|
|
|
{ |
|
586
|
|
|
return false; |
|
587
|
|
|
} else { |
|
588
|
|
|
if ($airline_type == "passenger") |
|
589
|
|
|
{ |
|
590
|
|
|
$additional_query .= " AND (spotter_output.airline_type = 'passenger')"; |
|
591
|
|
|
} |
|
592
|
|
|
if ($airline_type == "cargo") |
|
593
|
|
|
{ |
|
594
|
|
|
$additional_query .= " AND (spotter_output.airline_type = 'cargo')"; |
|
595
|
|
|
} |
|
596
|
|
|
if ($airline_type == "military") |
|
597
|
|
|
{ |
|
598
|
|
|
$additional_query .= " AND (spotter_output.airline_type = 'military')"; |
|
599
|
|
|
} |
|
600
|
|
|
} |
|
601
|
|
|
} |
|
602
|
|
|
|
|
603
|
|
|
if ($airport != "") |
|
604
|
|
|
{ |
|
605
|
|
|
$airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
606
|
|
|
if (!is_string($airport)) |
|
607
|
|
|
{ |
|
608
|
|
|
return false; |
|
609
|
|
|
} else { |
|
610
|
|
|
$additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)"; |
|
611
|
|
|
$query_values = array_merge($query_values,array(':airport' => $airport)); |
|
612
|
|
|
} |
|
613
|
|
|
} |
|
614
|
|
|
|
|
615
|
|
|
if ($airport_country != "") |
|
616
|
|
|
{ |
|
617
|
|
|
$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
618
|
|
|
if (!is_string($airport_country)) |
|
619
|
|
|
{ |
|
620
|
|
|
return false; |
|
621
|
|
|
} else { |
|
622
|
|
|
$additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)"; |
|
623
|
|
|
$query_values = array_merge($query_values,array(':airport_country' => $airport_country)); |
|
624
|
|
|
} |
|
625
|
|
|
} |
|
626
|
|
|
|
|
627
|
|
|
if ($callsign != "") |
|
628
|
|
|
{ |
|
629
|
|
|
$callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
630
|
|
|
if (!is_string($callsign)) |
|
631
|
|
|
{ |
|
632
|
|
|
return false; |
|
633
|
|
|
} else { |
|
634
|
|
|
$translate = $Translation->ident2icao($callsign); |
|
635
|
|
|
if ($translate != $callsign) { |
|
636
|
|
|
$additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)"; |
|
637
|
|
|
$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
638
|
|
|
} else { |
|
639
|
|
|
$additional_query .= " AND spotter_output.ident = :callsign"; |
|
640
|
|
|
$query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
641
|
|
|
} |
|
642
|
|
|
} |
|
643
|
|
|
} |
|
644
|
|
|
|
|
645
|
|
|
if ($owner != "") |
|
646
|
|
|
{ |
|
647
|
|
|
$owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
648
|
|
|
if (!is_string($owner)) |
|
649
|
|
|
{ |
|
650
|
|
|
return false; |
|
651
|
|
|
} else { |
|
652
|
|
|
$additional_query .= " AND spotter_output.owner_name = :owner"; |
|
653
|
|
|
$query_values = array_merge($query_values,array(':owner' => $owner)); |
|
654
|
|
|
} |
|
655
|
|
|
} |
|
656
|
|
|
|
|
657
|
|
|
if ($pilot_name != "") |
|
658
|
|
|
{ |
|
659
|
|
|
$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
660
|
|
|
if (!is_string($pilot_name)) |
|
661
|
|
|
{ |
|
662
|
|
|
return false; |
|
663
|
|
|
} else { |
|
664
|
|
|
$additional_query .= " AND spotter_output.pilot_name = :pilot_name"; |
|
665
|
|
|
$query_values = array_merge($query_values,array(':pilot_name' => $pilot_name)); |
|
666
|
|
|
} |
|
667
|
|
|
} |
|
668
|
|
|
|
|
669
|
|
|
if ($pilot_id != "") |
|
670
|
|
|
{ |
|
671
|
|
|
$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
672
|
|
|
if (!is_string($pilot_id)) |
|
673
|
|
|
{ |
|
674
|
|
|
return false; |
|
675
|
|
|
} else { |
|
676
|
|
|
$additional_query .= " AND spotter_output.pilot_id = :pilot_id"; |
|
677
|
|
|
$query_values = array_merge($query_values,array(':pilot_id' => $pilot_id)); |
|
678
|
|
|
} |
|
679
|
|
|
} |
|
680
|
|
|
|
|
681
|
|
|
if ($departure_airport_route != "") |
|
682
|
|
|
{ |
|
683
|
|
|
$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
684
|
|
|
if (!is_string($departure_airport_route)) |
|
685
|
|
|
{ |
|
686
|
|
|
return false; |
|
687
|
|
|
} else { |
|
688
|
|
|
$additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route"; |
|
689
|
|
|
$query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route)); |
|
690
|
|
|
} |
|
691
|
|
|
} |
|
692
|
|
|
|
|
693
|
|
|
if ($arrival_airport_route != "") |
|
694
|
|
|
{ |
|
695
|
|
|
$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
696
|
|
|
if (!is_string($arrival_airport_route)) |
|
697
|
|
|
{ |
|
698
|
|
|
return false; |
|
699
|
|
|
} else { |
|
700
|
|
|
$additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route"; |
|
701
|
|
|
$query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route)); |
|
702
|
|
|
} |
|
703
|
|
|
} |
|
704
|
|
|
|
|
705
|
|
|
if ($altitude != "") |
|
706
|
|
|
{ |
|
707
|
|
|
$altitude_array = explode(",", $altitude); |
|
708
|
|
|
$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
709
|
|
|
$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
710
|
|
|
|
|
711
|
|
|
if ($altitude_array[1] != "") |
|
712
|
|
|
{ |
|
713
|
|
|
$altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
714
|
|
|
$altitude_array[1] = substr($altitude_array[1], 0, -2); |
|
715
|
|
|
$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
|
716
|
|
|
} else { |
|
717
|
|
|
$altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
718
|
|
|
$additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
|
719
|
|
|
} |
|
720
|
|
|
} |
|
721
|
|
|
|
|
722
|
|
|
if ($date_posted != "") |
|
723
|
|
|
{ |
|
724
|
|
|
$date_array = explode(",", $date_posted); |
|
725
|
|
|
$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
726
|
|
|
$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
727
|
|
|
|
|
728
|
|
|
if ($globalTimezone != '') { |
|
729
|
|
|
date_default_timezone_set($globalTimezone); |
|
730
|
|
|
$datetime = new DateTime(); |
|
731
|
|
|
$offset = $datetime->format('P'); |
|
732
|
|
|
} else $offset = '+00:00'; |
|
733
|
|
|
|
|
734
|
|
|
if ($date_array[1] != "") |
|
735
|
|
|
{ |
|
736
|
|
|
$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
737
|
|
|
$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
|
738
|
|
|
if ($globalDBdriver == 'mysql') { |
|
739
|
|
|
$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; |
|
740
|
|
|
} else { |
|
741
|
|
|
$additional_query .= " AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) >= '".$date_array[0]."' AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) <= '".$date_array[1]."' "; |
|
742
|
|
|
} |
|
743
|
|
|
} else { |
|
744
|
|
|
$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
745
|
|
|
if ($globalDBdriver == 'mysql') { |
|
746
|
|
|
$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
|
747
|
|
|
} else { |
|
748
|
|
|
$additional_query .= " AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) >= '".$date_array[0]."' "; |
|
749
|
|
|
} |
|
750
|
|
|
} |
|
751
|
|
|
} |
|
752
|
|
|
|
|
753
|
|
|
if ($limit != "") |
|
754
|
|
|
{ |
|
755
|
|
|
$limit_array = explode(",", $limit); |
|
756
|
|
|
|
|
757
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
758
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
759
|
|
|
|
|
760
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
761
|
|
|
{ |
|
762
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
763
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
764
|
|
|
} else $limit_query = ""; |
|
765
|
|
|
} else $limit_query = ""; |
|
766
|
|
|
|
|
767
|
|
|
|
|
768
|
|
|
if ($sort != "") |
|
769
|
|
|
{ |
|
770
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
771
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
772
|
|
|
} else { |
|
773
|
|
|
if ($origLat != "" && $origLon != "" && $dist != "") { |
|
774
|
|
|
$orderby_query = " ORDER BY distance ASC"; |
|
775
|
|
|
} else { |
|
776
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
777
|
|
|
} |
|
778
|
|
|
} |
|
779
|
|
|
|
|
780
|
|
|
if ($includegeodata == "true") |
|
781
|
|
|
{ |
|
782
|
|
|
$additional_query .= " AND spotter_output.waypoints <> ''"; |
|
783
|
|
|
} |
|
784
|
|
|
|
|
785
|
|
|
|
|
786
|
|
|
if ($origLat != "" && $origLon != "" && $dist != "") { |
|
787
|
|
|
$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
788
|
|
|
|
|
789
|
|
|
if ($globalDBdriver == 'mysql') { |
|
790
|
|
|
$query="SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance |
|
791
|
|
|
FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND spotter_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and spotter_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
|
792
|
|
|
AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
|
793
|
|
|
} else { |
|
794
|
|
|
$query="SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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 |
|
795
|
|
|
FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
|
796
|
|
|
AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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.$orderby_query; |
|
797
|
|
|
} |
|
798
|
|
|
} else { |
|
799
|
|
|
$query = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' |
|
800
|
|
|
".$additional_query." |
|
801
|
|
|
".$orderby_query; |
|
802
|
|
|
} |
|
803
|
|
|
$spotter_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
804
|
|
|
return $spotter_array; |
|
805
|
|
|
} |
|
806
|
|
|
|
|
807
|
|
|
|
|
808
|
|
|
/** |
|
809
|
|
|
* Gets all the spotter information based on the latest data entry |
|
810
|
|
|
* |
|
811
|
|
|
* @return Array the spotter information |
|
812
|
|
|
* |
|
813
|
|
|
*/ |
|
814
|
|
|
public function getLatestSpotterData($limit = '', $sort = '', $filter = array()) |
|
815
|
|
|
{ |
|
816
|
|
|
global $global_query; |
|
817
|
|
|
|
|
818
|
|
|
date_default_timezone_set('UTC'); |
|
819
|
|
|
|
|
820
|
|
|
$filter_query = $this->getFilter($filter); |
|
821
|
|
|
|
|
822
|
|
|
if ($limit != "") |
|
823
|
|
|
{ |
|
824
|
|
|
$limit_array = explode(",", $limit); |
|
825
|
|
|
|
|
826
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
827
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
828
|
|
|
|
|
829
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
830
|
|
|
{ |
|
831
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
832
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
833
|
|
|
} else $limit_query = ""; |
|
834
|
|
|
} else $limit_query = ""; |
|
835
|
|
|
|
|
836
|
|
|
if ($sort != "") |
|
837
|
|
|
{ |
|
838
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
839
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
840
|
|
|
} else { |
|
841
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
842
|
|
|
} |
|
843
|
|
|
|
|
844
|
|
|
$query = $global_query.$filter_query." ".$orderby_query; |
|
845
|
|
|
|
|
846
|
|
|
$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
847
|
|
|
|
|
848
|
|
|
return $spotter_array; |
|
849
|
|
|
} |
|
850
|
|
|
|
|
851
|
|
|
|
|
852
|
|
|
/** |
|
853
|
|
|
* Gets all the spotter information based on a user's latitude and longitude |
|
854
|
|
|
* |
|
855
|
|
|
* @return Array the spotter information |
|
856
|
|
|
* |
|
857
|
|
|
*/ |
|
858
|
|
|
public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
|
859
|
|
|
{ |
|
860
|
|
|
date_default_timezone_set('UTC'); |
|
861
|
|
|
$limit_query = ''; |
|
862
|
|
|
if ($lat != "") |
|
863
|
|
|
{ |
|
864
|
|
|
if (!is_numeric($lat)) |
|
865
|
|
|
{ |
|
866
|
|
|
return false; |
|
867
|
|
|
} |
|
868
|
|
|
} |
|
869
|
|
|
|
|
870
|
|
|
if ($lng != "") |
|
871
|
|
|
{ |
|
872
|
|
|
if (!is_numeric($lng)) |
|
873
|
|
|
{ |
|
874
|
|
|
return false; |
|
875
|
|
|
} |
|
876
|
|
|
} |
|
877
|
|
|
|
|
878
|
|
|
if ($radius != "") |
|
879
|
|
|
{ |
|
880
|
|
|
if (!is_numeric($radius)) |
|
881
|
|
|
{ |
|
882
|
|
|
return false; |
|
883
|
|
|
} |
|
884
|
|
|
} |
|
885
|
|
|
$additional_query = ''; |
|
886
|
|
|
if ($interval != "") |
|
887
|
|
|
{ |
|
888
|
|
|
if (!is_string($interval)) |
|
889
|
|
|
{ |
|
890
|
|
|
return false; |
|
891
|
|
|
} else { |
|
892
|
|
|
if ($interval == "30m"){ |
|
893
|
|
|
$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date '; |
|
894
|
|
|
} else if ($interval == "1h"){ |
|
895
|
|
|
$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date '; |
|
896
|
|
|
} else if ($interval == "3h"){ |
|
897
|
|
|
$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date '; |
|
898
|
|
|
} else if ($interval == "6h"){ |
|
899
|
|
|
$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date '; |
|
900
|
|
|
} else if ($interval == "12h"){ |
|
901
|
|
|
$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date '; |
|
902
|
|
|
} else if ($interval == "24h"){ |
|
903
|
|
|
$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date '; |
|
904
|
|
|
} else if ($interval == "7d"){ |
|
905
|
|
|
$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date '; |
|
906
|
|
|
} else if ($interval == "30d"){ |
|
907
|
|
|
$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date '; |
|
908
|
|
|
} |
|
909
|
|
|
} |
|
910
|
|
|
} |
|
911
|
|
|
|
|
912
|
|
|
$query = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output |
|
913
|
|
|
WHERE spotter_output.latitude <> '' |
|
914
|
|
|
AND spotter_output.longitude <> '' |
|
915
|
|
|
".$additional_query." |
|
916
|
|
|
HAVING distance < :radius |
|
917
|
|
|
ORDER BY distance"; |
|
918
|
|
|
|
|
919
|
|
|
$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query); |
|
920
|
|
|
|
|
921
|
|
|
return $spotter_array; |
|
922
|
|
|
} |
|
923
|
|
|
|
|
924
|
|
|
|
|
925
|
|
|
/** |
|
926
|
|
|
* Gets all the spotter information sorted by the newest aircraft type |
|
927
|
|
|
* |
|
928
|
|
|
* @return Array the spotter information |
|
929
|
|
|
* |
|
930
|
|
|
*/ |
|
931
|
|
|
public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array()) |
|
932
|
|
|
{ |
|
933
|
|
|
global $global_query; |
|
934
|
|
|
|
|
935
|
|
|
date_default_timezone_set('UTC'); |
|
936
|
|
|
|
|
937
|
|
|
$filter_query = $this->getFilter($filter,true,true); |
|
938
|
|
|
|
|
939
|
|
|
$limit_query = ''; |
|
940
|
|
|
if ($limit != "") |
|
941
|
|
|
{ |
|
942
|
|
|
$limit_array = explode(",", $limit); |
|
943
|
|
|
|
|
944
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
945
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
946
|
|
|
|
|
947
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
948
|
|
|
{ |
|
949
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
950
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
951
|
|
|
} |
|
952
|
|
|
} |
|
953
|
|
|
|
|
954
|
|
|
if ($sort != "") |
|
955
|
|
|
{ |
|
956
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
957
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
958
|
|
|
} else { |
|
959
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC "; |
|
960
|
|
|
} |
|
961
|
|
|
|
|
962
|
|
|
$query = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
963
|
|
|
|
|
964
|
|
|
$spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
|
965
|
|
|
|
|
966
|
|
|
return $spotter_array; |
|
967
|
|
|
} |
|
968
|
|
|
|
|
969
|
|
|
|
|
970
|
|
|
/** |
|
971
|
|
|
* Gets all the spotter information sorted by the newest aircraft registration |
|
972
|
|
|
* |
|
973
|
|
|
* @return Array the spotter information |
|
974
|
|
|
* |
|
975
|
|
|
*/ |
|
976
|
|
|
public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '', $filter = array()) |
|
977
|
|
|
{ |
|
978
|
|
|
global $global_query; |
|
979
|
|
|
|
|
980
|
|
|
date_default_timezone_set('UTC'); |
|
981
|
|
|
$filter_query = $this->getFilter($filter,true,true); |
|
982
|
|
|
|
|
983
|
|
|
$limit_query = ''; |
|
984
|
|
|
if ($limit != "") |
|
985
|
|
|
{ |
|
986
|
|
|
$limit_array = explode(",", $limit); |
|
987
|
|
|
|
|
988
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
989
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
990
|
|
|
|
|
991
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
992
|
|
|
{ |
|
993
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
994
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
995
|
|
|
} |
|
996
|
|
|
} |
|
997
|
|
|
|
|
998
|
|
|
if ($sort != "") |
|
999
|
|
|
{ |
|
1000
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1001
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1002
|
|
|
} else { |
|
1003
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC "; |
|
1004
|
|
|
} |
|
1005
|
|
|
|
|
1006
|
|
|
$query = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
1007
|
|
|
|
|
1008
|
|
|
$spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
|
1009
|
|
|
|
|
1010
|
|
|
return $spotter_array; |
|
1011
|
|
|
} |
|
1012
|
|
|
|
|
1013
|
|
|
|
|
1014
|
|
|
/** |
|
1015
|
|
|
* Gets all the spotter information sorted by the newest airline |
|
1016
|
|
|
* |
|
1017
|
|
|
* @return Array the spotter information |
|
1018
|
|
|
* |
|
1019
|
|
|
*/ |
|
1020
|
|
|
public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array()) |
|
1021
|
|
|
{ |
|
1022
|
|
|
global $global_query; |
|
1023
|
|
|
|
|
1024
|
|
|
date_default_timezone_set('UTC'); |
|
1025
|
|
|
$filter_query = $this->getFilter($filter,true,true); |
|
1026
|
|
|
|
|
1027
|
|
|
$limit_query = ''; |
|
1028
|
|
|
if ($limit != "") |
|
1029
|
|
|
{ |
|
1030
|
|
|
$limit_array = explode(",", $limit); |
|
1031
|
|
|
|
|
1032
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1033
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1034
|
|
|
|
|
1035
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1036
|
|
|
{ |
|
1037
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1038
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1039
|
|
|
} |
|
1040
|
|
|
} |
|
1041
|
|
|
|
|
1042
|
|
|
if ($sort != "") |
|
1043
|
|
|
{ |
|
1044
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1045
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1046
|
|
|
} else { |
|
1047
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC "; |
|
1048
|
|
|
} |
|
1049
|
|
|
|
|
1050
|
|
|
$query = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
1051
|
|
|
|
|
1052
|
|
|
$spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
|
1053
|
|
|
|
|
1054
|
|
|
return $spotter_array; |
|
1055
|
|
|
} |
|
1056
|
|
|
|
|
1057
|
|
|
|
|
1058
|
|
|
/** |
|
1059
|
|
|
* Gets all the spotter information sorted by the newest departure airport |
|
1060
|
|
|
* |
|
1061
|
|
|
* @return Array the spotter information |
|
1062
|
|
|
* |
|
1063
|
|
|
*/ |
|
1064
|
|
|
public function getNewestSpotterDataSortedByDepartureAirport($limit = '', $sort = '', $filter = array()) |
|
1065
|
|
|
{ |
|
1066
|
|
|
global $global_query; |
|
1067
|
|
|
|
|
1068
|
|
|
date_default_timezone_set('UTC'); |
|
1069
|
|
|
|
|
1070
|
|
|
$filter_query = $this->getFilter($filter,true,true); |
|
1071
|
|
|
|
|
1072
|
|
|
$limit_query = ''; |
|
1073
|
|
|
|
|
1074
|
|
|
if ($limit != "") |
|
1075
|
|
|
{ |
|
1076
|
|
|
$limit_array = explode(",", $limit); |
|
1077
|
|
|
|
|
1078
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1079
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1080
|
|
|
|
|
1081
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1082
|
|
|
{ |
|
1083
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1084
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1085
|
|
|
} |
|
1086
|
|
|
} |
|
1087
|
|
|
|
|
1088
|
|
|
if ($sort != "") |
|
1089
|
|
|
{ |
|
1090
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1091
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1092
|
|
|
} else { |
|
1093
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC "; |
|
1094
|
|
|
} |
|
1095
|
|
|
|
|
1096
|
|
|
$query = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
1097
|
|
|
|
|
1098
|
|
|
$spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
|
1099
|
|
|
|
|
1100
|
|
|
return $spotter_array; |
|
1101
|
|
|
} |
|
1102
|
|
|
|
|
1103
|
|
|
|
|
1104
|
|
|
/** |
|
1105
|
|
|
* Gets all the spotter information sorted by the newest arrival airport |
|
1106
|
|
|
* |
|
1107
|
|
|
* @return Array the spotter information |
|
1108
|
|
|
* |
|
1109
|
|
|
*/ |
|
1110
|
|
|
public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '', $filter = array()) |
|
1111
|
|
|
{ |
|
1112
|
|
|
global $global_query; |
|
1113
|
|
|
|
|
1114
|
|
|
date_default_timezone_set('UTC'); |
|
1115
|
|
|
$filter_query = $this->getFilter($filter,true,true); |
|
1116
|
|
|
$limit_query = ''; |
|
1117
|
|
|
if ($limit != "") |
|
1118
|
|
|
{ |
|
1119
|
|
|
$limit_array = explode(",", $limit); |
|
1120
|
|
|
|
|
1121
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1122
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1123
|
|
|
|
|
1124
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1125
|
|
|
{ |
|
1126
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1127
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1128
|
|
|
} |
|
1129
|
|
|
} |
|
1130
|
|
|
|
|
1131
|
|
|
if ($sort != "") |
|
1132
|
|
|
{ |
|
1133
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1134
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1135
|
|
|
} else { |
|
1136
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC "; |
|
1137
|
|
|
} |
|
1138
|
|
|
|
|
1139
|
|
|
$query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
1140
|
|
|
|
|
1141
|
|
|
$spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
|
1142
|
|
|
|
|
1143
|
|
|
return $spotter_array; |
|
1144
|
|
|
} |
|
1145
|
|
|
|
|
1146
|
|
|
|
|
1147
|
|
|
/** |
|
1148
|
|
|
* Gets all the spotter information based on the spotter id |
|
1149
|
|
|
* |
|
1150
|
|
|
* @return Array the spotter information |
|
1151
|
|
|
* |
|
1152
|
|
|
*/ |
|
1153
|
|
|
public function getSpotterDataByID($id = '') |
|
1154
|
|
|
{ |
|
1155
|
|
|
global $global_query; |
|
1156
|
|
|
|
|
1157
|
|
|
date_default_timezone_set('UTC'); |
|
1158
|
|
|
if ($id == '') return array(); |
|
1159
|
|
|
$additional_query = "spotter_output.spotter_id = :id"; |
|
1160
|
|
|
$query_values = array(':id' => $id); |
|
1161
|
|
|
|
|
1162
|
|
|
//$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." "; |
|
1163
|
|
|
$query = $global_query." WHERE ".$additional_query." "; |
|
1164
|
|
|
|
|
1165
|
|
|
$spotter_array = $this->getDataFromDB($query,$query_values); |
|
1166
|
|
|
|
|
1167
|
|
|
return $spotter_array; |
|
1168
|
|
|
} |
|
1169
|
|
|
|
|
1170
|
|
|
|
|
1171
|
|
|
|
|
1172
|
|
|
|
|
1173
|
|
|
/** |
|
1174
|
|
|
* Gets all the spotter information based on the callsign |
|
1175
|
|
|
* |
|
1176
|
|
|
* @return Array the spotter information |
|
1177
|
|
|
* |
|
1178
|
|
|
*/ |
|
1179
|
|
|
public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
1180
|
|
|
{ |
|
1181
|
|
|
global $global_query; |
|
1182
|
|
|
|
|
1183
|
|
|
date_default_timezone_set('UTC'); |
|
1184
|
|
|
|
|
1185
|
|
|
$query_values = array(); |
|
1186
|
|
|
$limit_query = ''; |
|
1187
|
|
|
$additional_query = ''; |
|
1188
|
|
|
if ($ident != "") |
|
1189
|
|
|
{ |
|
1190
|
|
|
if (!is_string($ident)) |
|
1191
|
|
|
{ |
|
1192
|
|
|
return false; |
|
1193
|
|
|
} else { |
|
1194
|
|
|
$additional_query = " AND (spotter_output.ident = :ident)"; |
|
1195
|
|
|
$query_values = array(':ident' => $ident); |
|
1196
|
|
|
} |
|
1197
|
|
|
} |
|
1198
|
|
|
|
|
1199
|
|
|
if ($limit != "") |
|
1200
|
|
|
{ |
|
1201
|
|
|
$limit_array = explode(",", $limit); |
|
1202
|
|
|
|
|
1203
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1204
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1205
|
|
|
|
|
1206
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1207
|
|
|
{ |
|
1208
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1209
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1210
|
|
|
} |
|
1211
|
|
|
} |
|
1212
|
|
|
|
|
1213
|
|
|
if ($sort != "") |
|
1214
|
|
|
{ |
|
1215
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1216
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1217
|
|
|
} else { |
|
1218
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1219
|
|
|
} |
|
1220
|
|
|
|
|
1221
|
|
|
$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
|
1222
|
|
|
|
|
1223
|
|
|
$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1224
|
|
|
|
|
1225
|
|
|
return $spotter_array; |
|
1226
|
|
|
} |
|
1227
|
|
|
|
|
1228
|
|
|
|
|
1229
|
|
|
|
|
1230
|
|
|
/** |
|
1231
|
|
|
* Gets all the spotter information based on the aircraft type |
|
1232
|
|
|
* |
|
1233
|
|
|
* @return Array the spotter information |
|
1234
|
|
|
* |
|
1235
|
|
|
*/ |
|
1236
|
|
|
public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '', $filter = array()) |
|
1237
|
|
|
{ |
|
1238
|
|
|
global $global_query; |
|
1239
|
|
|
|
|
1240
|
|
|
date_default_timezone_set('UTC'); |
|
1241
|
|
|
|
|
1242
|
|
|
$query_values = array(); |
|
1243
|
|
|
$limit_query = ''; |
|
1244
|
|
|
$additional_query = ''; |
|
1245
|
|
|
$filter_query = $this->getFilter($filter,true,true); |
|
1246
|
|
|
|
|
1247
|
|
|
if ($aircraft_type != "") |
|
1248
|
|
|
{ |
|
1249
|
|
|
if (!is_string($aircraft_type)) |
|
1250
|
|
|
{ |
|
1251
|
|
|
return false; |
|
1252
|
|
|
} else { |
|
1253
|
|
|
$additional_query = " AND (spotter_output.aircraft_icao = :aircraft_type)"; |
|
1254
|
|
|
$query_values = array(':aircraft_type' => $aircraft_type); |
|
1255
|
|
|
} |
|
1256
|
|
|
} |
|
1257
|
|
|
|
|
1258
|
|
|
if ($limit != "") |
|
1259
|
|
|
{ |
|
1260
|
|
|
$limit_array = explode(",", $limit); |
|
1261
|
|
|
|
|
1262
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1263
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1264
|
|
|
|
|
1265
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1266
|
|
|
{ |
|
1267
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1268
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1269
|
|
|
} |
|
1270
|
|
|
} |
|
1271
|
|
|
|
|
1272
|
|
|
if ($sort != "") |
|
1273
|
|
|
{ |
|
1274
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1275
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1276
|
|
|
} else { |
|
1277
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1278
|
|
|
} |
|
1279
|
|
|
|
|
1280
|
|
|
$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
|
1281
|
|
|
|
|
1282
|
|
|
$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1283
|
|
|
|
|
1284
|
|
|
return $spotter_array; |
|
1285
|
|
|
} |
|
1286
|
|
|
|
|
1287
|
|
|
|
|
1288
|
|
|
/** |
|
1289
|
|
|
* Gets all the spotter information based on the aircraft registration |
|
1290
|
|
|
* |
|
1291
|
|
|
* @return Array the spotter information |
|
1292
|
|
|
* |
|
1293
|
|
|
*/ |
|
1294
|
|
|
public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '', $filter = array()) |
|
1295
|
|
|
{ |
|
1296
|
|
|
global $global_query; |
|
1297
|
|
|
|
|
1298
|
|
|
date_default_timezone_set('UTC'); |
|
1299
|
|
|
|
|
1300
|
|
|
$query_values = array(); |
|
1301
|
|
|
$limit_query = ''; |
|
1302
|
|
|
$additional_query = ''; |
|
1303
|
|
|
|
|
1304
|
|
|
if ($registration != "") |
|
1305
|
|
|
{ |
|
1306
|
|
|
if (!is_string($registration)) |
|
1307
|
|
|
{ |
|
1308
|
|
|
return false; |
|
1309
|
|
|
} else { |
|
1310
|
|
|
$additional_query = " (spotter_output.registration = :registration)"; |
|
1311
|
|
|
$query_values = array(':registration' => $registration); |
|
1312
|
|
|
} |
|
1313
|
|
|
} |
|
1314
|
|
|
|
|
1315
|
|
|
if ($limit != "") |
|
1316
|
|
|
{ |
|
1317
|
|
|
$limit_array = explode(",", $limit); |
|
1318
|
|
|
|
|
1319
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1320
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1321
|
|
|
|
|
1322
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1323
|
|
|
{ |
|
1324
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1325
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1326
|
|
|
} |
|
1327
|
|
|
} |
|
1328
|
|
|
|
|
1329
|
|
|
if ($sort != "") |
|
1330
|
|
|
{ |
|
1331
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1332
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1333
|
|
|
} else { |
|
1334
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1335
|
|
|
} |
|
1336
|
|
|
$filter_query = $this->getFilter($filter,true,true); |
|
1337
|
|
|
|
|
1338
|
|
|
//$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
|
1339
|
|
|
$query = $global_query.$filter_query." ".$additional_query." ".$orderby_query; |
|
1340
|
|
|
|
|
1341
|
|
|
$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1342
|
|
|
|
|
1343
|
|
|
return $spotter_array; |
|
1344
|
|
|
} |
|
1345
|
|
|
|
|
1346
|
|
|
|
|
1347
|
|
|
|
|
1348
|
|
|
|
|
1349
|
|
|
/** |
|
1350
|
|
|
* Gets all the spotter information based on the airline |
|
1351
|
|
|
* |
|
1352
|
|
|
* @return Array the spotter information |
|
1353
|
|
|
* |
|
1354
|
|
|
*/ |
|
1355
|
|
|
public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array()) |
|
1356
|
|
|
{ |
|
1357
|
|
|
global $global_query; |
|
1358
|
|
|
|
|
1359
|
|
|
date_default_timezone_set('UTC'); |
|
1360
|
|
|
|
|
1361
|
|
|
$query_values = array(); |
|
1362
|
|
|
$limit_query = ''; |
|
1363
|
|
|
$additional_query = ''; |
|
1364
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
1365
|
|
|
|
|
1366
|
|
|
if ($airline != "") |
|
1367
|
|
|
{ |
|
1368
|
|
|
if (!is_string($airline)) |
|
1369
|
|
|
{ |
|
1370
|
|
|
return false; |
|
1371
|
|
|
} else { |
|
1372
|
|
|
$additional_query = " AND (spotter_output.airline_icao = :airline)"; |
|
1373
|
|
|
$query_values = array(':airline' => $airline); |
|
1374
|
|
|
} |
|
1375
|
|
|
} |
|
1376
|
|
|
|
|
1377
|
|
|
if ($limit != "") |
|
1378
|
|
|
{ |
|
1379
|
|
|
$limit_array = explode(",", $limit); |
|
1380
|
|
|
|
|
1381
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1382
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1383
|
|
|
|
|
1384
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1385
|
|
|
{ |
|
1386
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1387
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1388
|
|
|
} |
|
1389
|
|
|
} |
|
1390
|
|
|
|
|
1391
|
|
|
if ($sort != "") |
|
1392
|
|
|
{ |
|
1393
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1394
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1395
|
|
|
} else { |
|
1396
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1397
|
|
|
} |
|
1398
|
|
|
|
|
1399
|
|
|
$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
|
1400
|
|
|
$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1401
|
|
|
|
|
1402
|
|
|
return $spotter_array; |
|
1403
|
|
|
} |
|
1404
|
|
|
|
|
1405
|
|
|
|
|
1406
|
|
|
/** |
|
1407
|
|
|
* Gets all the spotter information based on the airport |
|
1408
|
|
|
* |
|
1409
|
|
|
* @return Array the spotter information |
|
1410
|
|
|
* |
|
1411
|
|
|
*/ |
|
1412
|
|
|
public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1413
|
|
|
{ |
|
1414
|
|
|
global $global_query; |
|
1415
|
|
|
|
|
1416
|
|
|
date_default_timezone_set('UTC'); |
|
1417
|
|
|
$query_values = array(); |
|
1418
|
|
|
$limit_query = ''; |
|
1419
|
|
|
$additional_query = ''; |
|
1420
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
1421
|
|
|
|
|
1422
|
|
|
if ($airport != "") |
|
1423
|
|
|
{ |
|
1424
|
|
|
if (!is_string($airport)) |
|
1425
|
|
|
{ |
|
1426
|
|
|
return false; |
|
1427
|
|
|
} else { |
|
1428
|
|
|
$additional_query .= " AND ((spotter_output.departure_airport_icao = :airport) OR (spotter_output.arrival_airport_icao = :airport))"; |
|
1429
|
|
|
$query_values = array(':airport' => $airport); |
|
1430
|
|
|
} |
|
1431
|
|
|
} |
|
1432
|
|
|
|
|
1433
|
|
|
if ($limit != "") |
|
1434
|
|
|
{ |
|
1435
|
|
|
$limit_array = explode(",", $limit); |
|
1436
|
|
|
|
|
1437
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1438
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1439
|
|
|
|
|
1440
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1441
|
|
|
{ |
|
1442
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1443
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1444
|
|
|
} |
|
1445
|
|
|
} |
|
1446
|
|
|
|
|
1447
|
|
|
if ($sort != "") |
|
1448
|
|
|
{ |
|
1449
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1450
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1451
|
|
|
} else { |
|
1452
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1453
|
|
|
} |
|
1454
|
|
|
|
|
1455
|
|
|
$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." AND ((spotter_output.departure_airport_icao <> 'NA') AND (spotter_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
|
1456
|
|
|
|
|
1457
|
|
|
$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1458
|
|
|
|
|
1459
|
|
|
return $spotter_array; |
|
1460
|
|
|
} |
|
1461
|
|
|
|
|
1462
|
|
|
|
|
1463
|
|
|
|
|
1464
|
|
|
/** |
|
1465
|
|
|
* Gets all the spotter information based on the date |
|
1466
|
|
|
* |
|
1467
|
|
|
* @return Array the spotter information |
|
1468
|
|
|
* |
|
1469
|
|
|
*/ |
|
1470
|
|
|
public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
1471
|
|
|
{ |
|
1472
|
|
|
global $global_query, $globalTimezone, $globalDBdriver; |
|
1473
|
|
|
|
|
1474
|
|
|
$query_values = array(); |
|
1475
|
|
|
$limit_query = ''; |
|
1476
|
|
|
$additional_query = ''; |
|
1477
|
|
|
|
|
1478
|
|
|
$filter_query = $this->getFilter($filter,true,true); |
|
1479
|
|
|
|
|
1480
|
|
|
if ($date != "") |
|
1481
|
|
|
{ |
|
1482
|
|
|
if ($globalTimezone != '') { |
|
1483
|
|
|
date_default_timezone_set($globalTimezone); |
|
1484
|
|
|
$datetime = new DateTime($date); |
|
1485
|
|
|
$offset = $datetime->format('P'); |
|
1486
|
|
|
} else { |
|
1487
|
|
|
date_default_timezone_set('UTC'); |
|
1488
|
|
|
$datetime = new DateTime($date); |
|
1489
|
|
|
$offset = '+00:00'; |
|
1490
|
|
|
} |
|
1491
|
|
|
if ($globalDBdriver == 'mysql') { |
|
1492
|
|
|
$additional_query = " AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date "; |
|
1493
|
|
|
$query_values = array(':date' => $datetime->format('Y-m-d'), ':offset' => $offset); |
|
1494
|
|
|
} elseif ($globalDBdriver == 'pgsql') { |
|
1495
|
|
|
$additional_query = " AND to_char(spotter_output.date AT TIME ZONE :timezone,'YYYY-mm-dd') = :date "; |
|
1496
|
|
|
$query_values = array(':date' => $datetime->format('Y-m-d'), ':timezone' => $globalTimezone); |
|
1497
|
|
|
} |
|
1498
|
|
|
} |
|
1499
|
|
|
|
|
1500
|
|
|
if ($limit != "") |
|
1501
|
|
|
{ |
|
1502
|
|
|
$limit_array = explode(",", $limit); |
|
1503
|
|
|
|
|
1504
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1505
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1506
|
|
|
|
|
1507
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1508
|
|
|
{ |
|
1509
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1510
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1511
|
|
|
} |
|
1512
|
|
|
} |
|
1513
|
|
|
|
|
1514
|
|
|
if ($sort != "") |
|
1515
|
|
|
{ |
|
1516
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1517
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1518
|
|
|
} else { |
|
1519
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1520
|
|
|
} |
|
1521
|
|
|
|
|
1522
|
|
|
$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query.$orderby_query; |
|
1523
|
|
|
$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1524
|
|
|
return $spotter_array; |
|
1525
|
|
|
} |
|
1526
|
|
|
|
|
1527
|
|
|
|
|
1528
|
|
|
|
|
1529
|
|
|
/** |
|
1530
|
|
|
* Gets all the spotter information based on the country name |
|
1531
|
|
|
* |
|
1532
|
|
|
* @return Array the spotter information |
|
1533
|
|
|
* |
|
1534
|
|
|
*/ |
|
1535
|
|
|
public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array()) |
|
1536
|
|
|
{ |
|
1537
|
|
|
global $global_query; |
|
1538
|
|
|
|
|
1539
|
|
|
date_default_timezone_set('UTC'); |
|
1540
|
|
|
|
|
1541
|
|
|
$query_values = array(); |
|
1542
|
|
|
$limit_query = ''; |
|
1543
|
|
|
$additional_query = ''; |
|
1544
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
1545
|
|
|
if ($country != "") |
|
1546
|
|
|
{ |
|
1547
|
|
|
if (!is_string($country)) |
|
1548
|
|
|
{ |
|
1549
|
|
|
return false; |
|
1550
|
|
|
} else { |
|
1551
|
|
|
$additional_query .= " AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country))"; |
|
1552
|
|
|
$additional_query .= " OR spotter_output.airline_country = :country"; |
|
1553
|
|
|
$query_values = array(':country' => $country); |
|
1554
|
|
|
} |
|
1555
|
|
|
} |
|
1556
|
|
|
|
|
1557
|
|
|
if ($limit != "") |
|
1558
|
|
|
{ |
|
1559
|
|
|
$limit_array = explode(",", $limit); |
|
1560
|
|
|
|
|
1561
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1562
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1563
|
|
|
|
|
1564
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1565
|
|
|
{ |
|
1566
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1567
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1568
|
|
|
} |
|
1569
|
|
|
} |
|
1570
|
|
|
|
|
1571
|
|
|
if ($sort != "") |
|
1572
|
|
|
{ |
|
1573
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1574
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1575
|
|
|
} else { |
|
1576
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1577
|
|
|
} |
|
1578
|
|
|
|
|
1579
|
|
|
$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
|
1580
|
|
|
|
|
1581
|
|
|
$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1582
|
|
|
|
|
1583
|
|
|
return $spotter_array; |
|
1584
|
|
|
} |
|
1585
|
|
|
|
|
1586
|
|
|
|
|
1587
|
|
|
/** |
|
1588
|
|
|
* Gets all the spotter information based on the manufacturer name |
|
1589
|
|
|
* |
|
1590
|
|
|
* @return Array the spotter information |
|
1591
|
|
|
* |
|
1592
|
|
|
*/ |
|
1593
|
|
|
public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '', $filters = array()) |
|
1594
|
|
|
{ |
|
1595
|
|
|
global $global_query; |
|
1596
|
|
|
|
|
1597
|
|
|
date_default_timezone_set('UTC'); |
|
1598
|
|
|
|
|
1599
|
|
|
$query_values = array(); |
|
1600
|
|
|
$additional_query = ''; |
|
1601
|
|
|
$limit_query = ''; |
|
1602
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
1603
|
|
|
|
|
1604
|
|
|
if ($aircraft_manufacturer != "") |
|
1605
|
|
|
{ |
|
1606
|
|
|
if (!is_string($aircraft_manufacturer)) |
|
1607
|
|
|
{ |
|
1608
|
|
|
return false; |
|
1609
|
|
|
} else { |
|
1610
|
|
|
$additional_query .= " AND (spotter_output.aircraft_manufacturer = :aircraft_manufacturer)"; |
|
1611
|
|
|
$query_values = array(':aircraft_manufacturer' => $aircraft_manufacturer); |
|
1612
|
|
|
} |
|
1613
|
|
|
} |
|
1614
|
|
|
|
|
1615
|
|
|
if ($limit != "") |
|
1616
|
|
|
{ |
|
1617
|
|
|
$limit_array = explode(",", $limit); |
|
1618
|
|
|
|
|
1619
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1620
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1621
|
|
|
|
|
1622
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1623
|
|
|
{ |
|
1624
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1625
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1626
|
|
|
} |
|
1627
|
|
|
} |
|
1628
|
|
|
|
|
1629
|
|
|
if ($sort != "") |
|
1630
|
|
|
{ |
|
1631
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1632
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1633
|
|
|
} else { |
|
1634
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1635
|
|
|
} |
|
1636
|
|
|
|
|
1637
|
|
|
$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
|
1638
|
|
|
|
|
1639
|
|
|
$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1640
|
|
|
|
|
1641
|
|
|
return $spotter_array; |
|
1642
|
|
|
} |
|
1643
|
|
|
|
|
1644
|
|
|
|
|
1645
|
|
|
|
|
1646
|
|
|
|
|
1647
|
|
|
/** |
|
1648
|
|
|
* Gets a list of all aircraft that take a route |
|
1649
|
|
|
* |
|
1650
|
|
|
* @param String $departure_airport_icao ICAO code of departure airport |
|
1651
|
|
|
* @param String $arrival_airport_icao ICAO code of arrival airport |
|
1652
|
|
|
* @return Array the spotter information |
|
1653
|
|
|
* |
|
1654
|
|
|
*/ |
|
1655
|
|
|
public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '', $filters = array()) |
|
1656
|
|
|
{ |
|
1657
|
|
|
global $global_query; |
|
1658
|
|
|
|
|
1659
|
|
|
$query_values = array(); |
|
1660
|
|
|
$additional_query = ''; |
|
1661
|
|
|
$limit_query = ''; |
|
1662
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
1663
|
|
|
if ($departure_airport_icao != "") |
|
1664
|
|
|
{ |
|
1665
|
|
|
if (!is_string($departure_airport_icao)) |
|
1666
|
|
|
{ |
|
1667
|
|
|
return false; |
|
1668
|
|
|
} else { |
|
1669
|
|
|
$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
1670
|
|
|
$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)"; |
|
1671
|
|
|
//$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao AND spotter_output.real_departure_airport_icao IS NULL) OR spotter_output.real_departure_airport_icao = :departure_airport_icao"; |
|
1672
|
|
|
$query_values = array(':departure_airport_icao' => $departure_airport_icao); |
|
1673
|
|
|
} |
|
1674
|
|
|
} |
|
1675
|
|
|
|
|
1676
|
|
|
if ($arrival_airport_icao != "") |
|
1677
|
|
|
{ |
|
1678
|
|
|
if (!is_string($arrival_airport_icao)) |
|
1679
|
|
|
{ |
|
1680
|
|
|
return false; |
|
1681
|
|
|
} else { |
|
1682
|
|
|
$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
1683
|
|
|
$additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)"; |
|
1684
|
|
|
//$additional_query .= " AND ((spotter_output.arrival_airport_icao = :arrival_airport_icao AND spotter_output.real_arrival_airport_icao IS NULL) OR spotter_output.real_arrival_airport_icao = :arrival_airport_icao)"; |
|
1685
|
|
|
$query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao)); |
|
1686
|
|
|
} |
|
1687
|
|
|
} |
|
1688
|
|
|
|
|
1689
|
|
|
if ($limit != "") |
|
1690
|
|
|
{ |
|
1691
|
|
|
$limit_array = explode(",", $limit); |
|
1692
|
|
|
|
|
1693
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1694
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1695
|
|
|
|
|
1696
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1697
|
|
|
{ |
|
1698
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1699
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1700
|
|
|
} |
|
1701
|
|
|
} |
|
1702
|
|
|
|
|
1703
|
|
|
if ($sort != "") |
|
1704
|
|
|
{ |
|
1705
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1706
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1707
|
|
|
} else { |
|
1708
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1709
|
|
|
} |
|
1710
|
|
|
|
|
1711
|
|
|
$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
|
1712
|
|
|
|
|
1713
|
|
|
//$result = mysqli_query($GLOBALS["___mysqli_ston"], $query); |
|
1714
|
|
|
|
|
1715
|
|
|
$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1716
|
|
|
|
|
1717
|
|
|
return $spotter_array; |
|
1718
|
|
|
} |
|
1719
|
|
|
|
|
1720
|
|
|
|
|
1721
|
|
|
|
|
1722
|
|
|
/** |
|
1723
|
|
|
* Gets all the spotter information based on the special column in the table |
|
1724
|
|
|
* |
|
1725
|
|
|
* @return Array the spotter information |
|
1726
|
|
|
* |
|
1727
|
|
|
*/ |
|
1728
|
|
|
public function getSpotterDataByHighlight($limit = '', $sort = '', $filter = array()) |
|
1729
|
|
|
{ |
|
1730
|
|
|
global $global_query; |
|
1731
|
|
|
|
|
1732
|
|
|
date_default_timezone_set('UTC'); |
|
1733
|
|
|
$filter_query = $this->getFilter($filter,true,true); |
|
1734
|
|
|
$limit_query = ''; |
|
1735
|
|
|
|
|
1736
|
|
|
if ($limit != "") |
|
1737
|
|
|
{ |
|
1738
|
|
|
$limit_array = explode(",", $limit); |
|
1739
|
|
|
|
|
1740
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1741
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1742
|
|
|
|
|
1743
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1744
|
|
|
{ |
|
1745
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
1746
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
1747
|
|
|
} |
|
1748
|
|
|
} |
|
1749
|
|
|
|
|
1750
|
|
|
if ($sort != "") |
|
1751
|
|
|
{ |
|
1752
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
1753
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
1754
|
|
|
} else { |
|
1755
|
|
|
$orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1756
|
|
|
} |
|
1757
|
|
|
|
|
1758
|
|
|
$query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query; |
|
1759
|
|
|
|
|
1760
|
|
|
$spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
|
1761
|
|
|
|
|
1762
|
|
|
return $spotter_array; |
|
1763
|
|
|
} |
|
1764
|
|
|
|
|
1765
|
|
|
/** |
|
1766
|
|
|
* Gets all the highlight based on a aircraft registration |
|
1767
|
|
|
* |
|
1768
|
|
|
* @return String the highlight text |
|
1769
|
|
|
* |
|
1770
|
|
|
*/ |
|
1771
|
|
|
public function getHighlightByRegistration($registration,$filter = array()) |
|
1772
|
|
|
{ |
|
1773
|
|
|
global $global_query; |
|
1774
|
|
|
|
|
1775
|
|
|
date_default_timezone_set('UTC'); |
|
1776
|
|
|
$filter_query = $this->getFilter($filter,true,true); |
|
1777
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
1778
|
|
|
|
|
1779
|
|
|
$query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration"; |
|
1780
|
|
|
$sth = $this->db->prepare($query); |
|
1781
|
|
|
$sth->execute(array(':registration' => $registration)); |
|
1782
|
|
|
|
|
1783
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1784
|
|
|
{ |
|
1785
|
|
|
$highlight = $row['highlight']; |
|
1786
|
|
|
} |
|
1787
|
|
|
if (isset($highlight)) return $highlight; |
|
1788
|
|
|
} |
|
1789
|
|
|
|
|
1790
|
|
|
|
|
1791
|
|
|
/** |
|
1792
|
|
|
* Gets the squawk usage from squawk code |
|
1793
|
|
|
* |
|
1794
|
|
|
* @param String $squawk squawk code |
|
1795
|
|
|
* @param String $country country |
|
1796
|
|
|
* @return String usage |
|
1797
|
|
|
* |
|
1798
|
|
|
*/ |
|
1799
|
|
|
public function getSquawkUsage($squawk = '',$country = 'FR') |
|
1800
|
|
|
{ |
|
1801
|
|
|
|
|
1802
|
|
|
$squawk = filter_var($squawk,FILTER_SANITIZE_STRING); |
|
1803
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
1804
|
|
|
|
|
1805
|
|
|
$query = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1"; |
|
1806
|
|
|
$query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country); |
|
1807
|
|
|
|
|
1808
|
|
|
$sth = $this->db->prepare($query); |
|
1809
|
|
|
$sth->execute($query_values); |
|
1810
|
|
|
|
|
1811
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1812
|
|
|
$sth->closeCursor(); |
|
1813
|
|
|
if (count($row) > 0) { |
|
1814
|
|
|
return $row['usage']; |
|
1815
|
|
|
} else return ''; |
|
1816
|
|
|
} |
|
1817
|
|
|
|
|
1818
|
|
|
/** |
|
1819
|
|
|
* Gets the airport icao from the iata |
|
1820
|
|
|
* |
|
1821
|
|
|
* @param String $airport_iata the iata code of the airport |
|
1822
|
|
|
* @return String airport iata |
|
1823
|
|
|
* |
|
1824
|
|
|
*/ |
|
1825
|
|
|
public function getAirportIcao($airport_iata = '') |
|
1826
|
|
|
{ |
|
1827
|
|
|
|
|
1828
|
|
|
$airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING); |
|
1829
|
|
|
|
|
1830
|
|
|
$query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1"; |
|
1831
|
|
|
$query_values = array(':airport' => $airport_iata); |
|
1832
|
|
|
|
|
1833
|
|
|
$sth = $this->db->prepare($query); |
|
1834
|
|
|
$sth->execute($query_values); |
|
1835
|
|
|
|
|
1836
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1837
|
|
|
$sth->closeCursor(); |
|
1838
|
|
|
if (count($row) > 0) { |
|
1839
|
|
|
return $row['icao']; |
|
1840
|
|
|
} else return ''; |
|
1841
|
|
|
} |
|
1842
|
|
|
|
|
1843
|
|
|
/** |
|
1844
|
|
|
* Gets the airport distance |
|
1845
|
|
|
* |
|
1846
|
|
|
* @param String $airport_icao the icao code of the airport |
|
1847
|
|
|
* @param Float $latitude the latitude |
|
1848
|
|
|
* @param Float $longitude the longitude |
|
1849
|
|
|
* @return Float distance to the airport |
|
1850
|
|
|
* |
|
1851
|
|
|
*/ |
|
1852
|
|
|
public function getAirportDistance($airport_icao,$latitude,$longitude) |
|
1853
|
|
|
{ |
|
1854
|
|
|
|
|
1855
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
1856
|
|
|
|
|
1857
|
|
|
$query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1"; |
|
1858
|
|
|
$query_values = array(':airport' => $airport_icao); |
|
1859
|
|
|
$sth = $this->db->prepare($query); |
|
1860
|
|
|
$sth->execute($query_values); |
|
1861
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1862
|
|
|
$sth->closeCursor(); |
|
1863
|
|
|
if (count($row) > 0) { |
|
1864
|
|
|
$airport_latitude = $row['latitude']; |
|
1865
|
|
|
$airport_longitude = $row['longitude']; |
|
1866
|
|
|
$Common = new Common(); |
|
1867
|
|
|
return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); |
|
1868
|
|
|
} else return ''; |
|
1869
|
|
|
} |
|
1870
|
|
|
|
|
1871
|
|
|
/** |
|
1872
|
|
|
* Gets the airport info based on the icao |
|
1873
|
|
|
* |
|
1874
|
|
|
* @param String $airport the icao code of the airport |
|
1875
|
|
|
* @return Array airport information |
|
1876
|
|
|
* |
|
1877
|
|
|
*/ |
|
1878
|
|
|
public function getAllAirportInfo($airport = '') |
|
1879
|
|
|
{ |
|
1880
|
|
|
|
|
1881
|
|
|
$airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
1882
|
|
|
|
|
1883
|
|
|
$query_values = array(); |
|
1884
|
|
|
if ($airport == 'NA') { |
|
1885
|
|
|
return array(array('name' => 'Not available','city' => 'N/A', 'country' => 'N/A','iata' => 'NA','icao' => 'NA','altitude' => NULL,'latitude' => 0,'longitude' => 0,'type' => 'NA','home_link' => '','wikipedia_link' => '','image_thumb' => '', 'image' => '')); |
|
1886
|
|
|
} elseif ($airport == '') { |
|
1887
|
|
|
$query = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport"; |
|
1888
|
|
|
} else { |
|
1889
|
|
|
$query = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport WHERE airport.icao = :airport LIMIT 1"; |
|
1890
|
|
|
$query_values = array(':airport' => $airport); |
|
1891
|
|
|
} |
|
1892
|
|
|
|
|
1893
|
|
|
$sth = $this->db->prepare($query); |
|
1894
|
|
|
$sth->execute($query_values); |
|
1895
|
|
|
/* |
|
1896
|
|
|
$airport_array = array(); |
|
1897
|
|
|
$temp_array = array(); |
|
1898
|
|
|
|
|
1899
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1900
|
|
|
{ |
|
1901
|
|
|
$temp_array['name'] = $row['name']; |
|
1902
|
|
|
$temp_array['city'] = $row['city']; |
|
1903
|
|
|
$temp_array['country'] = $row['country']; |
|
1904
|
|
|
$temp_array['iata'] = $row['iata']; |
|
1905
|
|
|
$temp_array['icao'] = $row['icao']; |
|
1906
|
|
|
$temp_array['latitude'] = $row['latitude']; |
|
1907
|
|
|
$temp_array['longitude'] = $row['longitude']; |
|
1908
|
|
|
$temp_array['altitude'] = $row['altitude']; |
|
1909
|
|
|
$temp_array['home_link'] = $row['home_link']; |
|
1910
|
|
|
$temp_array['wikipedia_link'] = $row['wikipedia_link']; |
|
1911
|
|
|
$temp_array['image'] = $row['image']; |
|
1912
|
|
|
$temp_array['image_thumb'] = $row['image_thumb']; |
|
1913
|
|
|
|
|
1914
|
|
|
$airport_array[] = $temp_array; |
|
1915
|
|
|
} |
|
1916
|
|
|
|
|
1917
|
|
|
return $airport_array; |
|
1918
|
|
|
*/ |
|
1919
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1920
|
|
|
} |
|
1921
|
|
|
|
|
1922
|
|
|
/** |
|
1923
|
|
|
* Gets the airport info based on the country |
|
1924
|
|
|
* |
|
1925
|
|
|
* @param Array $countries Airports countries |
|
1926
|
|
|
* @return Array airport information |
|
1927
|
|
|
* |
|
1928
|
|
|
*/ |
|
1929
|
|
|
public function getAllAirportInfobyCountry($countries) |
|
1930
|
|
|
{ |
|
1931
|
|
|
$lst_countries = ''; |
|
1932
|
|
|
foreach ($countries as $country) { |
|
1933
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
1934
|
|
|
if ($lst_countries == '') { |
|
1935
|
|
|
$lst_countries = "'".$country."'"; |
|
1936
|
|
|
} else { |
|
1937
|
|
|
$lst_countries .= ",'".$country."'"; |
|
1938
|
|
|
} |
|
1939
|
|
|
} |
|
1940
|
|
|
$query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")"; |
|
1941
|
|
|
|
|
1942
|
|
|
$sth = $this->db->prepare($query); |
|
1943
|
|
|
$sth->execute(); |
|
1944
|
|
|
|
|
1945
|
|
|
$airport_array = array(); |
|
1946
|
|
|
$temp_array = array(); |
|
1947
|
|
|
|
|
1948
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1949
|
|
|
{ |
|
1950
|
|
|
$temp_array['name'] = $row['name']; |
|
1951
|
|
|
$temp_array['city'] = $row['city']; |
|
1952
|
|
|
$temp_array['country'] = $row['country']; |
|
1953
|
|
|
$temp_array['iata'] = $row['iata']; |
|
1954
|
|
|
$temp_array['icao'] = $row['icao']; |
|
1955
|
|
|
$temp_array['latitude'] = $row['latitude']; |
|
1956
|
|
|
$temp_array['longitude'] = $row['longitude']; |
|
1957
|
|
|
$temp_array['altitude'] = $row['altitude']; |
|
1958
|
|
|
|
|
1959
|
|
|
$airport_array[] = $temp_array; |
|
1960
|
|
|
} |
|
1961
|
|
|
|
|
1962
|
|
|
return $airport_array; |
|
1963
|
|
|
} |
|
1964
|
|
|
|
|
1965
|
|
|
/** |
|
1966
|
|
|
* Gets airports info based on the coord |
|
1967
|
|
|
* |
|
1968
|
|
|
* @param Array $coord Airports longitude min,latitude min, longitude max, latitude max |
|
1969
|
|
|
* @return Array airport information |
|
1970
|
|
|
* |
|
1971
|
|
|
*/ |
|
1972
|
|
|
public function getAllAirportInfobyCoord($coord) |
|
1973
|
|
|
{ |
|
1974
|
|
|
global $globalDBdriver; |
|
1975
|
|
|
if (is_array($coord)) { |
|
1976
|
|
|
$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1977
|
|
|
$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1978
|
|
|
$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1979
|
|
|
$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1980
|
|
|
} else return array(); |
|
1981
|
|
|
if ($globalDBdriver == 'mysql') { |
|
1982
|
|
|
$query = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
|
1983
|
|
|
} else { |
|
1984
|
|
|
$query = "SELECT airport.* FROM airport WHERE CAST(airport.latitude AS FLOAT) BETWEEN ".$minlat." AND ".$maxlat." AND CAST(airport.longitude AS FLOAT) BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
|
1985
|
|
|
} |
|
1986
|
|
|
$sth = $this->db->prepare($query); |
|
1987
|
|
|
$sth->execute(); |
|
1988
|
|
|
|
|
1989
|
|
|
$airport_array = array(); |
|
1990
|
|
|
|
|
1991
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1992
|
|
|
{ |
|
1993
|
|
|
$temp_array = $row; |
|
1994
|
|
|
|
|
1995
|
|
|
$airport_array[] = $temp_array; |
|
1996
|
|
|
} |
|
1997
|
|
|
|
|
1998
|
|
|
return $airport_array; |
|
1999
|
|
|
} |
|
2000
|
|
|
|
|
2001
|
|
|
/** |
|
2002
|
|
|
* Gets waypoints info based on the coord |
|
2003
|
|
|
* |
|
2004
|
|
|
* @param Array $coord waypoints coord |
|
2005
|
|
|
* @return Array airport information |
|
2006
|
|
|
* |
|
2007
|
|
|
*/ |
|
2008
|
|
|
public function getAllWaypointsInfobyCoord($coord) |
|
2009
|
|
|
{ |
|
2010
|
|
|
if (is_array($coord)) { |
|
2011
|
|
|
$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
2012
|
|
|
$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
2013
|
|
|
$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
2014
|
|
|
$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
2015
|
|
|
} else return array(); |
|
2016
|
|
|
//$query = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
|
2017
|
|
|
$query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
2018
|
|
|
//$query = "SELECT waypoints.* FROM waypoints"; |
|
2019
|
|
|
//$query = "SELECT waypoints.* FROM waypoints INNER JOIN (SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") w ON w.name_end = waypoints.name_begin OR w.name_begin = waypoints.name_begin OR w.name_begin = waypoints.name_end OR w.name_end = waypoints.name_end"; |
|
2020
|
|
|
//$query = "SELECT * FROM waypoints LEFT JOIN waypoints w ON waypoints.name_end = w.name_begin WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
|
2021
|
|
|
//$query = "SELECT z.name_begin as name_begin, z.name_end as name_end, z.latitude_begin as latitude_begin, z.longitude_begin as longitude_begin, z.latitude_end as latitude_end, z.longitude_end as longitude_end, z.segment_name as segment_name, w.name_end as name_end_seg2, w.latitude_end as latitude_end_seg2, w.longitude_end as longitude_end_seg2, w.segment_name as segment_name_seg2 FROM waypoints z INNER JOIN waypoints w ON z.name_end = w.name_begin WHERE z.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND z.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
|
2022
|
|
|
//echo $query; |
|
2023
|
|
|
|
|
2024
|
|
|
$sth = $this->db->prepare($query); |
|
2025
|
|
|
$sth->execute(); |
|
2026
|
|
|
|
|
2027
|
|
|
$waypoints_array = array(); |
|
2028
|
|
|
|
|
2029
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2030
|
|
|
{ |
|
2031
|
|
|
$temp_array = $row; |
|
2032
|
|
|
|
|
2033
|
|
|
$waypoints_array[] = $temp_array; |
|
2034
|
|
|
} |
|
2035
|
|
|
|
|
2036
|
|
|
return $waypoints_array; |
|
2037
|
|
|
} |
|
2038
|
|
|
|
|
2039
|
|
|
|
|
2040
|
|
|
/** |
|
2041
|
|
|
* Gets the airline info based on the icao code or iata code |
|
2042
|
|
|
* |
|
2043
|
|
|
* @param String $airline_icao the iata code of the airport |
|
2044
|
|
|
* @return Array airport information |
|
2045
|
|
|
* |
|
2046
|
|
|
*/ |
|
2047
|
|
|
public function getAllAirlineInfo($airline_icao, $fromsource = NULL) |
|
2048
|
|
|
{ |
|
2049
|
|
|
global $globalUseRealAirlines; |
|
2050
|
|
|
if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
|
2051
|
|
|
$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING)); |
|
2052
|
|
|
if ($airline_icao == 'NA') { |
|
2053
|
|
|
$airline_array = array(); |
|
2054
|
|
|
$airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>''); |
|
2055
|
|
|
return $airline_array; |
|
2056
|
|
|
} else { |
|
2057
|
|
|
if (strlen($airline_icao) == 2) { |
|
2058
|
|
|
if ($fromsource === NULL) { |
|
2059
|
|
|
$query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.iata = :airline_icao AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; |
|
2060
|
|
|
} else { |
|
2061
|
|
|
$query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.iata = :airline_icao AND airlines.active = 'Y' AND airlines.forsource = :fromsource LIMIT 1"; |
|
2062
|
|
|
} |
|
2063
|
|
|
} else { |
|
2064
|
|
|
if ($fromsource === NULL) { |
|
2065
|
|
|
$query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.icao = :airline_icao AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; |
|
2066
|
|
|
} else { |
|
2067
|
|
|
$query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.icao = :airline_icao AND airlines.active = 'Y' AND airlines.forsource = :fromsource LIMIT 1"; |
|
2068
|
|
|
} |
|
2069
|
|
|
} |
|
2070
|
|
|
|
|
2071
|
|
|
$sth = $this->db->prepare($query); |
|
2072
|
|
|
if ($fromsource === NULL) { |
|
2073
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao)); |
|
2074
|
|
|
} else { |
|
2075
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource)); |
|
2076
|
|
|
} |
|
2077
|
|
|
/* |
|
2078
|
|
|
$airline_array = array(); |
|
2079
|
|
|
$temp_array = array(); |
|
2080
|
|
|
|
|
2081
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2082
|
|
|
{ |
|
2083
|
|
|
$temp_array['name'] = $row['name']; |
|
2084
|
|
|
$temp_array['iata'] = $row['iata']; |
|
2085
|
|
|
$temp_array['icao'] = $row['icao']; |
|
2086
|
|
|
$temp_array['callsign'] = $row['callsign']; |
|
2087
|
|
|
$temp_array['country'] = $row['country']; |
|
2088
|
|
|
$temp_array['type'] = $row['type']; |
|
2089
|
|
|
$airline_array[] = $temp_array; |
|
2090
|
|
|
} |
|
2091
|
|
|
return $airline_array; |
|
2092
|
|
|
*/ |
|
2093
|
|
|
$result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
2094
|
|
|
if (empty($result) && $fromsource !== NULL) { |
|
2095
|
|
|
$query = 'SELECT COUNT(*) AS nb FROM airlines WHERE forsource = :fromsource'; |
|
2096
|
|
|
$sth = $this->db->prepare($query); |
|
2097
|
|
|
$sth->execute(array(':fromsource' => $fromsource)); |
|
2098
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2099
|
|
|
$sth->closeCursor(); |
|
2100
|
|
|
if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao); |
|
2101
|
|
|
} |
|
2102
|
|
|
return $result; |
|
2103
|
|
|
} |
|
2104
|
|
|
} |
|
2105
|
|
|
|
|
2106
|
|
|
|
|
2107
|
|
|
|
|
2108
|
|
|
/** |
|
2109
|
|
|
* Gets the aircraft info based on the aircraft type |
|
2110
|
|
|
* |
|
2111
|
|
|
* @param String $aircraft_type the aircraft type |
|
2112
|
|
|
* @return Array aircraft information |
|
2113
|
|
|
* |
|
2114
|
|
|
*/ |
|
2115
|
|
|
public function getAllAircraftInfo($aircraft_type) |
|
2116
|
|
|
{ |
|
2117
|
|
|
$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); |
|
2118
|
|
|
|
|
2119
|
|
|
if ($aircraft_type == 'NA') { |
|
2120
|
|
|
return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL)); |
|
2121
|
|
|
} |
|
2122
|
|
|
$query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type"; |
|
2123
|
|
|
|
|
2124
|
|
|
$sth = $this->db->prepare($query); |
|
2125
|
|
|
$sth->execute(array(':aircraft_type' => $aircraft_type)); |
|
2126
|
|
|
/* |
|
2127
|
|
|
$aircraft_array = array(); |
|
2128
|
|
|
$temp_array = array(); |
|
2129
|
|
|
|
|
2130
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2131
|
|
|
{ |
|
2132
|
|
|
$temp_array = array(); |
|
2133
|
|
|
$temp_array['icao'] = $row['icao']; |
|
2134
|
|
|
$temp_array['type'] = $row['type']; |
|
2135
|
|
|
$temp_array['manufacturer'] = $row['manufacturer']; |
|
2136
|
|
|
$temp_array['aircraft_shadow'] = $row['aircraft_shadow']; |
|
2137
|
|
|
|
|
2138
|
|
|
$aircraft_array[] = $temp_array; |
|
2139
|
|
|
} |
|
2140
|
|
|
return $aircraft_array; |
|
2141
|
|
|
*/ |
|
2142
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
2143
|
|
|
} |
|
2144
|
|
|
|
|
2145
|
|
|
/** |
|
2146
|
|
|
* Gets the aircraft icao based on the aircraft name/type |
|
2147
|
|
|
* |
|
2148
|
|
|
* @param String $aircraft_type the aircraft type |
|
2149
|
|
|
* @return String aircraft information |
|
2150
|
|
|
* |
|
2151
|
|
|
*/ |
|
2152
|
|
|
public function getAircraftIcao($aircraft_type) |
|
2153
|
|
|
{ |
|
2154
|
|
|
$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); |
|
2155
|
|
|
$all_aircraft = array('737-300' => 'B733', |
|
2156
|
|
|
'777-200' => 'B772', |
|
2157
|
|
|
'777-200ER' => 'B772', |
|
2158
|
|
|
'777-300ER' => 'B77W', |
|
2159
|
|
|
'c172p' => 'C172', |
|
2160
|
|
|
'aerostar' => 'AEST', |
|
2161
|
|
|
'A320-211' => 'A320', |
|
2162
|
|
|
'747-8i' => 'B748', |
|
2163
|
|
|
'A380' => 'A388'); |
|
2164
|
|
|
if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type]; |
|
2165
|
|
|
|
|
2166
|
|
|
$query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; |
|
2167
|
|
|
$aircraft_type = strtoupper($aircraft_type); |
|
2168
|
|
|
$sth = $this->db->prepare($query); |
|
2169
|
|
|
$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,)); |
|
2170
|
|
|
$result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
2171
|
|
|
if (isset($result[0]['icao'])) return $result[0]['icao']; |
|
2172
|
|
|
else return ''; |
|
2173
|
|
|
} |
|
2174
|
|
|
|
|
2175
|
|
|
/** |
|
2176
|
|
|
* Gets the aircraft info based on the aircraft modes |
|
2177
|
|
|
* |
|
2178
|
|
|
* @param String $aircraft_modes the aircraft ident (hex) |
|
2179
|
|
|
* @return String aircraft type |
|
2180
|
|
|
* |
|
2181
|
|
|
*/ |
|
2182
|
|
|
public function getAllAircraftType($aircraft_modes) |
|
2183
|
|
|
{ |
|
2184
|
|
|
$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); |
|
2185
|
|
|
|
|
2186
|
|
|
$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; |
|
2187
|
|
|
|
|
2188
|
|
|
$sth = $this->db->prepare($query); |
|
2189
|
|
|
$sth->execute(array(':aircraft_modes' => $aircraft_modes)); |
|
2190
|
|
|
|
|
2191
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2192
|
|
|
$sth->closeCursor(); |
|
2193
|
|
|
if (isset($row['icaotypecode'])) { |
|
2194
|
|
|
return $row['icaotypecode']; |
|
2195
|
|
|
} else return ''; |
|
2196
|
|
|
} |
|
2197
|
|
|
|
|
2198
|
|
|
/** |
|
2199
|
|
|
* Gets the aircraft info based on the aircraft registration |
|
2200
|
|
|
* |
|
2201
|
|
|
* @param String $registration the aircraft registration |
|
2202
|
|
|
* @return String aircraft type |
|
2203
|
|
|
* |
|
2204
|
|
|
*/ |
|
2205
|
|
|
public function getAllAircraftTypeByRegistration($registration) |
|
2206
|
|
|
{ |
|
2207
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
2208
|
|
|
|
|
2209
|
|
|
$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1"; |
|
2210
|
|
|
|
|
2211
|
|
|
$sth = $this->db->prepare($query); |
|
2212
|
|
|
$sth->execute(array(':registration' => $registration)); |
|
2213
|
|
|
|
|
2214
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2215
|
|
|
$sth->closeCursor(); |
|
2216
|
|
|
if (isset($row['icaotypecode'])) { |
|
2217
|
|
|
return $row['icaotypecode']; |
|
2218
|
|
|
} else return ''; |
|
2219
|
|
|
} |
|
2220
|
|
|
|
|
2221
|
|
|
/** |
|
2222
|
|
|
* Gets correct aircraft operator corde |
|
2223
|
|
|
* |
|
2224
|
|
|
* @param String $operator the aircraft operator code (callsign) |
|
2225
|
|
|
* @return String aircraft operator code |
|
2226
|
|
|
* |
|
2227
|
|
|
*/ |
|
2228
|
|
|
public function getOperator($operator) |
|
2229
|
|
|
{ |
|
2230
|
|
|
$operator = filter_var($operator,FILTER_SANITIZE_STRING); |
|
2231
|
|
|
$query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1"; |
|
2232
|
|
|
|
|
2233
|
|
|
$sth = $this->db->prepare($query); |
|
2234
|
|
|
$sth->execute(array(':operator' => $operator)); |
|
2235
|
|
|
|
|
2236
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2237
|
|
|
$sth->closeCursor(); |
|
2238
|
|
|
if (isset($row['operator_correct'])) { |
|
2239
|
|
|
return $row['operator_correct']; |
|
2240
|
|
|
} else return $operator; |
|
2241
|
|
|
} |
|
2242
|
|
|
|
|
2243
|
|
|
/** |
|
2244
|
|
|
* Gets the aircraft route based on the aircraft callsign |
|
2245
|
|
|
* |
|
2246
|
|
|
* @param String $callsign the aircraft callsign |
|
2247
|
|
|
* @return Array aircraft type |
|
2248
|
|
|
* |
|
2249
|
|
|
*/ |
|
2250
|
|
|
public function getRouteInfo($callsign) |
|
2251
|
|
|
{ |
|
2252
|
|
|
$callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
2253
|
|
|
if ($callsign == '') return array(); |
|
2254
|
|
|
$query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1"; |
|
2255
|
|
|
|
|
2256
|
|
|
$sth = $this->db->prepare($query); |
|
2257
|
|
|
$sth->execute(array(':callsign' => $callsign)); |
|
2258
|
|
|
|
|
2259
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2260
|
|
|
$sth->closeCursor(); |
|
2261
|
|
|
if (count($row) > 0) { |
|
2262
|
|
|
return $row; |
|
2263
|
|
|
} else return array(); |
|
2264
|
|
|
} |
|
2265
|
|
|
|
|
2266
|
|
|
/** |
|
2267
|
|
|
* Gets the aircraft info based on the aircraft registration |
|
2268
|
|
|
* |
|
2269
|
|
|
* @param String $registration the aircraft registration |
|
2270
|
|
|
* @return Array aircraft information |
|
2271
|
|
|
* |
|
2272
|
|
|
*/ |
|
2273
|
|
|
public function getAircraftInfoByRegistration($registration) |
|
2274
|
|
|
{ |
|
2275
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
2276
|
|
|
|
|
2277
|
|
|
$query = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration"; |
|
2278
|
|
|
|
|
2279
|
|
|
$sth = $this->db->prepare($query); |
|
2280
|
|
|
$sth->execute(array(':registration' => $registration)); |
|
2281
|
|
|
|
|
2282
|
|
|
$aircraft_array = array(); |
|
2283
|
|
|
$temp_array = array(); |
|
2284
|
|
|
|
|
2285
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2286
|
|
|
{ |
|
2287
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
2288
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
2289
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
2290
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
2291
|
|
|
|
|
2292
|
|
|
$aircraft_array[] = $temp_array; |
|
2293
|
|
|
} |
|
2294
|
|
|
|
|
2295
|
|
|
return $aircraft_array; |
|
2296
|
|
|
} |
|
2297
|
|
|
|
|
2298
|
|
|
/** |
|
2299
|
|
|
* Gets the aircraft owner & base based on the aircraft registration |
|
2300
|
|
|
* |
|
2301
|
|
|
* @param String $registration the aircraft registration |
|
2302
|
|
|
* @return Array aircraft information |
|
2303
|
|
|
* |
|
2304
|
|
|
*/ |
|
2305
|
|
|
public function getAircraftOwnerByRegistration($registration) |
|
2306
|
|
|
{ |
|
2307
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
2308
|
|
|
$Connection = new Connection($this->db); |
|
2309
|
|
|
if ($Connection->tableExists('aircraft_owner')) { |
|
2310
|
|
|
$query = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1"; |
|
2311
|
|
|
$sth = $this->db->prepare($query); |
|
2312
|
|
|
$sth->execute(array(':registration' => $registration)); |
|
2313
|
|
|
$result = $sth->fetch(PDO::FETCH_ASSOC); |
|
2314
|
|
|
$sth->closeCursor(); |
|
2315
|
|
|
return $result; |
|
2316
|
|
|
} else return array(); |
|
2317
|
|
|
} |
|
2318
|
|
|
|
|
2319
|
|
|
|
|
2320
|
|
|
/** |
|
2321
|
|
|
* Gets all flights (but with only little info) |
|
2322
|
|
|
* |
|
2323
|
|
|
* @return Array basic flight information |
|
2324
|
|
|
* |
|
2325
|
|
|
*/ |
|
2326
|
|
|
public function getAllFlightsforSitemap() |
|
2327
|
|
|
{ |
|
2328
|
|
|
//$query = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT "; |
|
2329
|
|
|
$query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0"; |
|
2330
|
|
|
|
|
2331
|
|
|
$sth = $this->db->prepare($query); |
|
2332
|
|
|
$sth->execute(); |
|
2333
|
|
|
/* |
|
2334
|
|
|
$flight_array = array(); |
|
2335
|
|
|
$temp_array = array(); |
|
2336
|
|
|
|
|
2337
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2338
|
|
|
{ |
|
2339
|
|
|
$temp_array['spotter_id'] = $row['spotter_id']; |
|
2340
|
|
|
// $temp_array['ident'] = $row['ident']; |
|
2341
|
|
|
// $temp_array['airline_name'] = $row['airline_name']; |
|
2342
|
|
|
// $temp_array['aircraft_type'] = $row['aircraft_icao']; |
|
2343
|
|
|
// $temp_array['aircraft_name'] = $row['aircraft_name']; |
|
2344
|
|
|
//$temp_array['image'] = $row['image']; |
|
2345
|
|
|
|
|
2346
|
|
|
$flight_array[] = $temp_array; |
|
2347
|
|
|
} |
|
2348
|
|
|
|
|
2349
|
|
|
return $flight_array; |
|
2350
|
|
|
*/ |
|
2351
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
2352
|
|
|
} |
|
2353
|
|
|
|
|
2354
|
|
|
/** |
|
2355
|
|
|
* Gets a list of all aircraft manufacturers |
|
2356
|
|
|
* |
|
2357
|
|
|
* @return Array list of aircraft types |
|
2358
|
|
|
* |
|
2359
|
|
|
*/ |
|
2360
|
|
|
public function getAllManufacturers() |
|
2361
|
|
|
{ |
|
2362
|
|
|
/* |
|
2363
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer AS aircraft_manufacturer |
|
2364
|
|
|
FROM spotter_output |
|
2365
|
|
|
WHERE spotter_output.aircraft_manufacturer <> '' |
|
2366
|
|
|
ORDER BY spotter_output.aircraft_manufacturer ASC"; |
|
2367
|
|
|
*/ |
|
2368
|
|
|
|
|
2369
|
|
|
$query = "SELECT DISTINCT manufacturer AS aircraft_manufacturer FROM aircraft WHERE manufacturer <> '' ORDER BY manufacturer ASC"; |
|
2370
|
|
|
$sth = $this->db->prepare($query); |
|
2371
|
|
|
$sth->execute(); |
|
2372
|
|
|
|
|
2373
|
|
|
$manufacturer_array = array(); |
|
2374
|
|
|
$temp_array = array(); |
|
2375
|
|
|
|
|
2376
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2377
|
|
|
{ |
|
2378
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
2379
|
|
|
|
|
2380
|
|
|
$manufacturer_array[] = $temp_array; |
|
2381
|
|
|
} |
|
2382
|
|
|
|
|
2383
|
|
|
return $manufacturer_array; |
|
2384
|
|
|
} |
|
2385
|
|
|
|
|
2386
|
|
|
|
|
2387
|
|
|
/** |
|
2388
|
|
|
* Gets a list of all aircraft types |
|
2389
|
|
|
* |
|
2390
|
|
|
* @return Array list of aircraft types |
|
2391
|
|
|
* |
|
2392
|
|
|
*/ |
|
2393
|
|
|
public function getAllAircraftTypes($filters = array()) |
|
|
|
|
|
|
2394
|
|
|
{ |
|
2395
|
|
|
/* |
|
2396
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao AS aircraft_icao, spotter_output.aircraft_name AS aircraft_name |
|
2397
|
|
|
FROM spotter_output |
|
2398
|
|
|
WHERE spotter_output.aircraft_icao <> '' |
|
2399
|
|
|
ORDER BY spotter_output.aircraft_name ASC"; |
|
2400
|
|
|
|
|
2401
|
|
|
*/ |
|
2402
|
|
|
//$filter_query = $this->getFilter($filters,true,true); |
|
2403
|
|
|
//$query = "SELECT DISTINCT icao AS aircraft_icao, type AS aircraft_name, manufacturer AS aircraft_manufacturer FROM aircraft".$filter_query." icao <> '' ORDER BY aircraft_manufacturer ASC"; |
|
2404
|
|
|
|
|
2405
|
|
|
$query = "SELECT DISTINCT icao AS aircraft_icao, type AS aircraft_name, manufacturer AS aircraft_manufacturer FROM aircraft WHERE icao <> '' ORDER BY aircraft_manufacturer ASC"; |
|
2406
|
|
|
|
|
2407
|
|
|
$sth = $this->db->prepare($query); |
|
2408
|
|
|
$sth->execute(); |
|
2409
|
|
|
|
|
2410
|
|
|
$aircraft_array = array(); |
|
2411
|
|
|
$temp_array = array(); |
|
2412
|
|
|
|
|
2413
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2414
|
|
|
{ |
|
2415
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
2416
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
2417
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
2418
|
|
|
|
|
2419
|
|
|
$aircraft_array[] = $temp_array; |
|
2420
|
|
|
} |
|
2421
|
|
|
|
|
2422
|
|
|
return $aircraft_array; |
|
2423
|
|
|
} |
|
2424
|
|
|
|
|
2425
|
|
|
|
|
2426
|
|
|
/** |
|
2427
|
|
|
* Gets a list of all aircraft registrations |
|
2428
|
|
|
* |
|
2429
|
|
|
* @return Array list of aircraft registrations |
|
2430
|
|
|
* |
|
2431
|
|
|
*/ |
|
2432
|
|
|
public function getAllAircraftRegistrations($filters = array()) |
|
2433
|
|
|
{ |
|
2434
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2435
|
|
|
$query = "SELECT DISTINCT spotter_output.registration |
|
2436
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration <> '' |
|
2437
|
|
|
ORDER BY spotter_output.registration ASC"; |
|
2438
|
|
|
|
|
2439
|
|
|
$sth = $this->db->prepare($query); |
|
2440
|
|
|
$sth->execute(); |
|
2441
|
|
|
|
|
2442
|
|
|
$aircraft_array = array(); |
|
2443
|
|
|
$temp_array = array(); |
|
2444
|
|
|
|
|
2445
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2446
|
|
|
{ |
|
2447
|
|
|
$temp_array['registration'] = $row['registration']; |
|
2448
|
|
|
|
|
2449
|
|
|
$aircraft_array[] = $temp_array; |
|
2450
|
|
|
} |
|
2451
|
|
|
|
|
2452
|
|
|
return $aircraft_array; |
|
2453
|
|
|
} |
|
2454
|
|
|
|
|
2455
|
|
|
/** |
|
2456
|
|
|
* Gets all source name |
|
2457
|
|
|
* |
|
2458
|
|
|
* @param String type format of source |
|
2459
|
|
|
* @return Array list of source name |
|
2460
|
|
|
* |
|
2461
|
|
|
*/ |
|
2462
|
|
|
public function getAllSourceName($type = '',$filters = array()) |
|
2463
|
|
|
{ |
|
2464
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2465
|
|
|
$query_values = array(); |
|
2466
|
|
|
$query = "SELECT DISTINCT spotter_output.source_name |
|
2467
|
|
|
FROM spotter_output".$filter_query." spotter_output.source_name <> ''"; |
|
2468
|
|
|
if ($type != '') { |
|
2469
|
|
|
$query_values = array(':type' => $type); |
|
2470
|
|
|
$query .= " AND format_source = :type"; |
|
2471
|
|
|
} |
|
2472
|
|
|
$query .= " ORDER BY spotter_output.source_name ASC"; |
|
2473
|
|
|
|
|
2474
|
|
|
$sth = $this->db->prepare($query); |
|
2475
|
|
|
if (!empty($query_values)) $sth->execute($query_values); |
|
2476
|
|
|
else $sth->execute(); |
|
2477
|
|
|
|
|
2478
|
|
|
$source_array = array(); |
|
2479
|
|
|
$temp_array = array(); |
|
2480
|
|
|
|
|
2481
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2482
|
|
|
{ |
|
2483
|
|
|
$temp_array['source_name'] = $row['source_name']; |
|
2484
|
|
|
$source_array[] = $temp_array; |
|
2485
|
|
|
} |
|
2486
|
|
|
return $source_array; |
|
2487
|
|
|
} |
|
2488
|
|
|
|
|
2489
|
|
|
|
|
2490
|
|
|
|
|
2491
|
|
|
/** |
|
2492
|
|
|
* Gets a list of all airline names |
|
2493
|
|
|
* |
|
2494
|
|
|
* @return Array list of airline names |
|
2495
|
|
|
* |
|
2496
|
|
|
*/ |
|
2497
|
|
|
public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array()) |
|
2498
|
|
|
{ |
|
2499
|
|
|
global $globalAirlinesSource,$globalVATSIM, $globalIVAO; |
|
2500
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2501
|
|
|
$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
2502
|
|
|
if ($airline_type == '' || $airline_type == 'all') { |
|
2503
|
|
|
/* |
|
2504
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
|
2505
|
|
|
FROM spotter_output |
|
2506
|
|
|
WHERE spotter_output.airline_icao <> '' |
|
2507
|
|
|
ORDER BY spotter_output.airline_name ASC"; |
|
2508
|
|
|
*/ |
|
2509
|
|
|
if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
|
2510
|
|
|
elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
|
2511
|
|
|
elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
|
2512
|
|
|
if ($forsource === NULL) { |
|
2513
|
|
|
$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC"; |
|
2514
|
|
|
$query_data = array(); |
|
2515
|
|
|
} else { |
|
2516
|
|
|
$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource = :forsource ORDER BY name ASC"; |
|
2517
|
|
|
$query_data = array(':forsource' => $forsource); |
|
2518
|
|
|
} |
|
2519
|
|
|
} else { |
|
2520
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
|
2521
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
|
2522
|
|
|
AND spotter_output.airline_type = :airline_type |
|
2523
|
|
|
ORDER BY spotter_output.airline_icao ASC"; |
|
2524
|
|
|
$query_data = array(':airline_type' => $airline_type); |
|
2525
|
|
|
} |
|
2526
|
|
|
|
|
2527
|
|
|
$sth = $this->db->prepare($query); |
|
2528
|
|
|
$sth->execute($query_data); |
|
2529
|
|
|
|
|
2530
|
|
|
$airline_array = array(); |
|
2531
|
|
|
$temp_array = array(); |
|
2532
|
|
|
|
|
2533
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2534
|
|
|
{ |
|
2535
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
2536
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
2537
|
|
|
$temp_array['airline_type'] = $row['airline_type']; |
|
2538
|
|
|
|
|
2539
|
|
|
$airline_array[] = $temp_array; |
|
2540
|
|
|
} |
|
2541
|
|
|
return $airline_array; |
|
2542
|
|
|
} |
|
2543
|
|
|
|
|
2544
|
|
|
|
|
2545
|
|
|
/** |
|
2546
|
|
|
* Gets a list of all airline countries |
|
2547
|
|
|
* |
|
2548
|
|
|
* @return Array list of airline countries |
|
2549
|
|
|
* |
|
2550
|
|
|
*/ |
|
2551
|
|
|
public function getAllAirlineCountries($filters = array()) |
|
2552
|
|
|
{ |
|
2553
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2554
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
|
2555
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_country <> '' |
|
2556
|
|
|
ORDER BY spotter_output.airline_country ASC"; |
|
2557
|
|
|
|
|
2558
|
|
|
//$query = "SELECT DISTINCT country AS airline_country FROM airlines WHERE country <> '' AND active = 'Y' ORDER BY country ASC"; |
|
2559
|
|
|
$sth = $this->db->prepare($query); |
|
2560
|
|
|
$sth->execute(); |
|
2561
|
|
|
|
|
2562
|
|
|
$airline_array = array(); |
|
2563
|
|
|
$temp_array = array(); |
|
2564
|
|
|
|
|
2565
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2566
|
|
|
{ |
|
2567
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
2568
|
|
|
|
|
2569
|
|
|
$airline_array[] = $temp_array; |
|
2570
|
|
|
} |
|
2571
|
|
|
|
|
2572
|
|
|
return $airline_array; |
|
2573
|
|
|
} |
|
2574
|
|
|
|
|
2575
|
|
|
|
|
2576
|
|
|
|
|
2577
|
|
|
/** |
|
2578
|
|
|
* Gets a list of all departure & arrival names |
|
2579
|
|
|
* |
|
2580
|
|
|
* @return Array list of airport names |
|
2581
|
|
|
* |
|
2582
|
|
|
*/ |
|
2583
|
|
|
public function getAllAirportNames($filters = array()) |
|
2584
|
|
|
{ |
|
2585
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2586
|
|
|
$airport_array = array(); |
|
2587
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country |
|
2588
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' |
|
2589
|
|
|
ORDER BY spotter_output.departure_airport_city ASC"; |
|
2590
|
|
|
|
|
2591
|
|
|
//$query = "SELECT DISTINCT icao AS airport_icao, name AS airport_name, city AS airport_city, country AS airport_country FROM airport ORDER BY city ASC"; |
|
2592
|
|
|
$sth = $this->db->prepare($query); |
|
2593
|
|
|
$sth->execute(); |
|
2594
|
|
|
|
|
2595
|
|
|
$temp_array = array(); |
|
2596
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2597
|
|
|
{ |
|
2598
|
|
|
$temp_array['airport_icao'] = $row['airport_icao']; |
|
2599
|
|
|
$temp_array['airport_name'] = $row['airport_name']; |
|
2600
|
|
|
$temp_array['airport_city'] = $row['airport_city']; |
|
2601
|
|
|
$temp_array['airport_country'] = $row['airport_country']; |
|
2602
|
|
|
|
|
2603
|
|
|
$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; |
|
2604
|
|
|
} |
|
2605
|
|
|
|
|
2606
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country |
|
2607
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' |
|
2608
|
|
|
ORDER BY spotter_output.arrival_airport_city ASC"; |
|
2609
|
|
|
|
|
2610
|
|
|
$sth = $this->db->prepare($query); |
|
2611
|
|
|
$sth->execute(); |
|
2612
|
|
|
|
|
2613
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2614
|
|
|
{ |
|
2615
|
|
|
// if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao']) |
|
2616
|
|
|
// { |
|
2617
|
|
|
$temp_array['airport_icao'] = $row['airport_icao']; |
|
2618
|
|
|
$temp_array['airport_name'] = $row['airport_name']; |
|
2619
|
|
|
$temp_array['airport_city'] = $row['airport_city']; |
|
2620
|
|
|
$temp_array['airport_country'] = $row['airport_country']; |
|
2621
|
|
|
|
|
2622
|
|
|
$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; |
|
2623
|
|
|
// } |
|
2624
|
|
|
} |
|
2625
|
|
|
|
|
2626
|
|
|
return $airport_array; |
|
2627
|
|
|
} |
|
2628
|
|
|
|
|
2629
|
|
|
|
|
2630
|
|
|
/** |
|
2631
|
|
|
* Gets a list of all departure & arrival airport countries |
|
2632
|
|
|
* |
|
2633
|
|
|
* @return Array list of airport countries |
|
2634
|
|
|
* |
|
2635
|
|
|
*/ |
|
2636
|
|
|
public function getAllAirportCountries($filters = array()) |
|
2637
|
|
|
{ |
|
2638
|
|
|
$airport_array = array(); |
|
2639
|
|
|
|
|
2640
|
|
|
/* |
|
2641
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country |
|
2642
|
|
|
FROM spotter_output |
|
2643
|
|
|
WHERE spotter_output.departure_airport_country <> '' |
|
2644
|
|
|
ORDER BY spotter_output.departure_airport_country ASC"; |
|
2645
|
|
|
*/ |
|
2646
|
|
|
$query = "SELECT DISTINCT country AS airport_country FROM airport ORDER BY country ASC"; |
|
2647
|
|
|
|
|
2648
|
|
|
$sth = $this->db->prepare($query); |
|
2649
|
|
|
$sth->execute(); |
|
2650
|
|
|
|
|
2651
|
|
|
$temp_array = array(); |
|
2652
|
|
|
|
|
2653
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2654
|
|
|
{ |
|
2655
|
|
|
$temp_array['airport_country'] = $row['airport_country']; |
|
2656
|
|
|
|
|
2657
|
|
|
$airport_array[$row['airport_country']] = $temp_array; |
|
2658
|
|
|
} |
|
2659
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2660
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
|
2661
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' |
|
2662
|
|
|
ORDER BY spotter_output.arrival_airport_country ASC"; |
|
2663
|
|
|
|
|
2664
|
|
|
$sth = $this->db->prepare($query); |
|
2665
|
|
|
$sth->execute(); |
|
2666
|
|
|
|
|
2667
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2668
|
|
|
{ |
|
2669
|
|
|
if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country']) |
|
2670
|
|
|
{ |
|
2671
|
|
|
$temp_array['airport_country'] = $row['airport_country']; |
|
2672
|
|
|
$airport_array[$row['airport_country']] = $temp_array; |
|
2673
|
|
|
} |
|
2674
|
|
|
} |
|
2675
|
|
|
|
|
2676
|
|
|
return $airport_array; |
|
2677
|
|
|
} |
|
2678
|
|
|
|
|
2679
|
|
|
|
|
2680
|
|
|
|
|
2681
|
|
|
|
|
2682
|
|
|
/** |
|
2683
|
|
|
* Gets a list of all countries (airline, departure airport & arrival airport) |
|
2684
|
|
|
* |
|
2685
|
|
|
* @return Array list of countries |
|
2686
|
|
|
* |
|
2687
|
|
|
*/ |
|
2688
|
|
|
public function getAllCountries($filters = array()) |
|
2689
|
|
|
{ |
|
2690
|
|
|
$Connection= new Connection($this->db); |
|
2691
|
|
|
if ($Connection->tableExists('countries')) { |
|
2692
|
|
|
$query = "SELECT countries.name AS airport_country |
|
2693
|
|
|
FROM countries |
|
2694
|
|
|
ORDER BY countries.name ASC"; |
|
2695
|
|
|
$sth = $this->db->prepare($query); |
|
2696
|
|
|
$sth->execute(); |
|
2697
|
|
|
|
|
2698
|
|
|
$temp_array = array(); |
|
2699
|
|
|
$country_array = array(); |
|
2700
|
|
|
|
|
2701
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2702
|
|
|
{ |
|
2703
|
|
|
$temp_array['country'] = $row['airport_country']; |
|
2704
|
|
|
$country_array[$row['airport_country']] = $temp_array; |
|
2705
|
|
|
} |
|
2706
|
|
|
} else { |
|
2707
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2708
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country |
|
2709
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' |
|
2710
|
|
|
ORDER BY spotter_output.departure_airport_country ASC"; |
|
2711
|
|
|
|
|
2712
|
|
|
$sth = $this->db->prepare($query); |
|
2713
|
|
|
$sth->execute(); |
|
2714
|
|
|
|
|
2715
|
|
|
$temp_array = array(); |
|
2716
|
|
|
$country_array = array(); |
|
2717
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2718
|
|
|
{ |
|
2719
|
|
|
$temp_array['country'] = $row['airport_country']; |
|
2720
|
|
|
$country_array[$row['airport_country']] = $temp_array; |
|
2721
|
|
|
} |
|
2722
|
|
|
|
|
2723
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
|
2724
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' |
|
2725
|
|
|
ORDER BY spotter_output.arrival_airport_country ASC"; |
|
2726
|
|
|
|
|
2727
|
|
|
$sth = $this->db->prepare($query); |
|
2728
|
|
|
$sth->execute(); |
|
2729
|
|
|
|
|
2730
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2731
|
|
|
{ |
|
2732
|
|
|
if ($country_array[$row['airport_country']]['country'] != $row['airport_country']) |
|
2733
|
|
|
{ |
|
2734
|
|
|
$temp_array['country'] = $row['airport_country']; |
|
2735
|
|
|
|
|
2736
|
|
|
$country_array[$row['country']] = $temp_array; |
|
2737
|
|
|
} |
|
2738
|
|
|
} |
|
2739
|
|
|
|
|
2740
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
|
2741
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_country <> '' |
|
2742
|
|
|
ORDER BY spotter_output.airline_country ASC"; |
|
2743
|
|
|
|
|
2744
|
|
|
$sth = $this->db->prepare($query); |
|
2745
|
|
|
$sth->execute(); |
|
2746
|
|
|
|
|
2747
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2748
|
|
|
{ |
|
2749
|
|
|
if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country']) |
|
2750
|
|
|
{ |
|
2751
|
|
|
$temp_array['country'] = $row['airline_country']; |
|
2752
|
|
|
|
|
2753
|
|
|
$country_array[$row['country']] = $temp_array; |
|
2754
|
|
|
} |
|
2755
|
|
|
} |
|
2756
|
|
|
} |
|
2757
|
|
|
return $country_array; |
|
2758
|
|
|
} |
|
2759
|
|
|
|
|
2760
|
|
|
|
|
2761
|
|
|
|
|
2762
|
|
|
|
|
2763
|
|
|
/** |
|
2764
|
|
|
* Gets a list of all idents/callsigns |
|
2765
|
|
|
* |
|
2766
|
|
|
* @return Array list of ident/callsign names |
|
2767
|
|
|
* |
|
2768
|
|
|
*/ |
|
2769
|
|
|
public function getAllIdents($filters = array()) |
|
2770
|
|
|
{ |
|
2771
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2772
|
|
|
$query = "SELECT DISTINCT spotter_output.ident |
|
2773
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' |
|
2774
|
|
|
ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0"; |
|
2775
|
|
|
|
|
2776
|
|
|
$sth = $this->db->prepare($query); |
|
2777
|
|
|
$sth->execute(); |
|
2778
|
|
|
|
|
2779
|
|
|
$ident_array = array(); |
|
2780
|
|
|
$temp_array = array(); |
|
2781
|
|
|
|
|
2782
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2783
|
|
|
{ |
|
2784
|
|
|
$temp_array['ident'] = $row['ident']; |
|
2785
|
|
|
$ident_array[] = $temp_array; |
|
2786
|
|
|
} |
|
2787
|
|
|
|
|
2788
|
|
|
return $ident_array; |
|
2789
|
|
|
} |
|
2790
|
|
|
|
|
2791
|
|
|
/** |
|
2792
|
|
|
* Get a list of flights from airport since 7 days |
|
2793
|
|
|
* @return Array number, icao, name and city of airports |
|
2794
|
|
|
*/ |
|
2795
|
|
|
|
|
2796
|
|
|
public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) { |
|
2797
|
|
|
global $globalTimezone, $globalDBdriver; |
|
2798
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2799
|
|
|
if ($globalTimezone != '') { |
|
2800
|
|
|
date_default_timezone_set($globalTimezone); |
|
2801
|
|
|
$datetime = new DateTime(); |
|
2802
|
|
|
$offset = $datetime->format('P'); |
|
2803
|
|
|
} else $offset = '+00:00'; |
|
2804
|
|
|
if ($airport_icao == '') { |
|
2805
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2806
|
|
|
$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
|
2807
|
|
|
} else { |
|
2808
|
|
|
$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
|
2809
|
|
|
} |
|
2810
|
|
|
$sth = $this->db->prepare($query); |
|
2811
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
2812
|
|
|
} else { |
|
2813
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2814
|
|
|
$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao = :airport_icao GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
|
2815
|
|
|
} else { |
|
2816
|
|
|
$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao = :airport_icao GROUP BY departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
|
2817
|
|
|
} |
|
2818
|
|
|
$sth = $this->db->prepare($query); |
|
2819
|
|
|
$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
|
2820
|
|
|
} |
|
2821
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
2822
|
|
|
} |
|
2823
|
|
|
|
|
2824
|
|
|
/** |
|
2825
|
|
|
* Get a list of flights from airport since 7 days |
|
2826
|
|
|
* @return Array number, icao, name and city of airports |
|
2827
|
|
|
*/ |
|
2828
|
|
|
|
|
2829
|
|
|
public function getLast7DaysAirportsDepartureByAirlines($airport_icao = '') { |
|
2830
|
|
|
global $globalTimezone, $globalDBdriver; |
|
2831
|
|
|
if ($globalTimezone != '') { |
|
2832
|
|
|
date_default_timezone_set($globalTimezone); |
|
2833
|
|
|
$datetime = new DateTime(); |
|
2834
|
|
|
$offset = $datetime->format('P'); |
|
2835
|
|
|
} else $offset = '+00:00'; |
|
2836
|
|
|
if ($airport_icao == '') { |
|
2837
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2838
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
|
2839
|
|
|
} else { |
|
2840
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
|
2841
|
|
|
} |
|
2842
|
|
|
$sth = $this->db->prepare($query); |
|
2843
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
2844
|
|
|
} else { |
|
2845
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2846
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
|
2847
|
|
|
} else { |
|
2848
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
|
2849
|
|
|
} |
|
2850
|
|
|
$sth = $this->db->prepare($query); |
|
2851
|
|
|
$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
|
2852
|
|
|
} |
|
2853
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
2854
|
|
|
} |
|
2855
|
|
|
|
|
2856
|
|
|
/** |
|
2857
|
|
|
* Get a list of flights from detected airport since 7 days |
|
2858
|
|
|
* @return Array number, icao, name and city of airports |
|
2859
|
|
|
*/ |
|
2860
|
|
|
|
|
2861
|
|
|
public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) { |
|
2862
|
|
|
global $globalTimezone, $globalDBdriver; |
|
2863
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2864
|
|
|
if ($globalTimezone != '') { |
|
2865
|
|
|
date_default_timezone_set($globalTimezone); |
|
2866
|
|
|
$datetime = new DateTime(); |
|
2867
|
|
|
$offset = $datetime->format('P'); |
|
2868
|
|
|
} else $offset = '+00:00'; |
|
2869
|
|
|
if ($airport_icao == '') { |
|
2870
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2871
|
|
|
$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
|
2872
|
|
|
FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao <> 'NA' |
|
2873
|
|
|
GROUP BY real_departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
|
2874
|
|
|
} else { |
|
2875
|
|
|
$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
2876
|
|
|
FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao <> 'NA' |
|
2877
|
|
|
GROUP BY real_departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
|
2878
|
|
|
} |
|
2879
|
|
|
$sth = $this->db->prepare($query); |
|
2880
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
2881
|
|
|
} else { |
|
2882
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2883
|
|
|
$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
|
2884
|
|
|
FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao = :airport_icao |
|
2885
|
|
|
GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
|
2886
|
|
|
} else { |
|
2887
|
|
|
$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
2888
|
|
|
FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao = :airport_icao GROUP BY departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
|
2889
|
|
|
} |
|
2890
|
|
|
$sth = $this->db->prepare($query); |
|
2891
|
|
|
$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
|
2892
|
|
|
} |
|
2893
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
2894
|
|
|
} |
|
2895
|
|
|
|
|
2896
|
|
|
/** |
|
2897
|
|
|
* Get a list of flights from detected airport since 7 days |
|
2898
|
|
|
* @return Array number, icao, name and city of airports |
|
2899
|
|
|
*/ |
|
2900
|
|
|
|
|
2901
|
|
|
public function getLast7DaysDetectedAirportsDepartureByAirlines($airport_icao = '') { |
|
2902
|
|
|
global $globalTimezone, $globalDBdriver; |
|
2903
|
|
|
if ($globalTimezone != '') { |
|
2904
|
|
|
date_default_timezone_set($globalTimezone); |
|
2905
|
|
|
$datetime = new DateTime(); |
|
2906
|
|
|
$offset = $datetime->format('P'); |
|
2907
|
|
|
} else $offset = '+00:00'; |
|
2908
|
|
|
if ($airport_icao == '') { |
|
2909
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2910
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
|
2911
|
|
|
FROM `spotter_output`, airport |
|
2912
|
|
|
WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao <> 'NA' |
|
2913
|
|
|
GROUP BY spotter_output.airline_icao, real_departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
|
2914
|
|
|
} else { |
|
2915
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
2916
|
|
|
FROM spotter_output, airport |
|
2917
|
|
|
WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao <> 'NA' |
|
2918
|
|
|
GROUP BY spotter_output.airline_icao, real_departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
|
2919
|
|
|
} |
|
2920
|
|
|
$sth = $this->db->prepare($query); |
|
2921
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
2922
|
|
|
} else { |
|
2923
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2924
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
|
2925
|
|
|
FROM `spotter_output`, airport |
|
2926
|
|
|
WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao = :airport_icao |
|
2927
|
|
|
GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
|
2928
|
|
|
} else { |
|
2929
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
2930
|
|
|
FROM spotter_output, airport |
|
2931
|
|
|
WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao = :airport_icao GROUP BY spotter_output.airline_icao, departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
|
2932
|
|
|
} |
|
2933
|
|
|
$sth = $this->db->prepare($query); |
|
2934
|
|
|
$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
|
2935
|
|
|
} |
|
2936
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
2937
|
|
|
} |
|
2938
|
|
|
|
|
2939
|
|
|
|
|
2940
|
|
|
/** |
|
2941
|
|
|
* Get a list of flights to airport since 7 days |
|
2942
|
|
|
* @return Array number, icao, name and city of airports |
|
2943
|
|
|
*/ |
|
2944
|
|
|
|
|
2945
|
|
|
public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) { |
|
2946
|
|
|
global $globalTimezone, $globalDBdriver; |
|
2947
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2948
|
|
|
if ($globalTimezone != '') { |
|
2949
|
|
|
date_default_timezone_set($globalTimezone); |
|
2950
|
|
|
$datetime = new DateTime(); |
|
2951
|
|
|
$offset = $datetime->format('P'); |
|
2952
|
|
|
} else $offset = '+00:00'; |
|
2953
|
|
|
if ($airport_icao == '') { |
|
2954
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2955
|
|
|
$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
|
2956
|
|
|
} else { |
|
2957
|
|
|
$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
|
2958
|
|
|
} |
|
2959
|
|
|
$sth = $this->db->prepare($query); |
|
2960
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
2961
|
|
|
} else { |
|
2962
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2963
|
|
|
$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
|
2964
|
|
|
} else { |
|
2965
|
|
|
$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao GROUP BY arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
|
2966
|
|
|
} |
|
2967
|
|
|
$sth = $this->db->prepare($query); |
|
2968
|
|
|
$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
|
2969
|
|
|
} |
|
2970
|
|
|
|
|
2971
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
2972
|
|
|
} |
|
2973
|
|
|
|
|
2974
|
|
|
|
|
2975
|
|
|
/** |
|
2976
|
|
|
* Get a list of flights detected to airport since 7 days |
|
2977
|
|
|
* @return Array number, icao, name and city of airports |
|
2978
|
|
|
*/ |
|
2979
|
|
|
|
|
2980
|
|
|
public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) { |
|
2981
|
|
|
global $globalTimezone, $globalDBdriver; |
|
2982
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
2983
|
|
|
if ($globalTimezone != '') { |
|
2984
|
|
|
date_default_timezone_set($globalTimezone); |
|
2985
|
|
|
$datetime = new DateTime(); |
|
2986
|
|
|
$offset = $datetime->format('P'); |
|
2987
|
|
|
} else $offset = '+00:00'; |
|
2988
|
|
|
if ($airport_icao == '') { |
|
2989
|
|
|
if ($globalDBdriver == 'mysql') { |
|
2990
|
|
|
$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
|
2991
|
|
|
FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' |
|
2992
|
|
|
GROUP BY real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
|
2993
|
|
|
} else { |
|
2994
|
|
|
$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
2995
|
|
|
FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' |
|
2996
|
|
|
GROUP BY real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
|
2997
|
|
|
} |
|
2998
|
|
|
$sth = $this->db->prepare($query); |
|
2999
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
3000
|
|
|
} else { |
|
3001
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3002
|
|
|
$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
|
3003
|
|
|
FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao |
|
3004
|
|
|
GROUP BY real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
|
3005
|
|
|
} else { |
|
3006
|
|
|
$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
3007
|
|
|
FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao |
|
3008
|
|
|
GROUP BY real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
|
3009
|
|
|
} |
|
3010
|
|
|
$sth = $this->db->prepare($query); |
|
3011
|
|
|
$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
|
3012
|
|
|
} |
|
3013
|
|
|
|
|
3014
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
3015
|
|
|
} |
|
3016
|
|
|
|
|
3017
|
|
|
|
|
3018
|
|
|
/** |
|
3019
|
|
|
* Get a list of flights to airport since 7 days |
|
3020
|
|
|
* @return Array number, icao, name and city of airports |
|
3021
|
|
|
*/ |
|
3022
|
|
|
|
|
3023
|
|
|
public function getLast7DaysAirportsArrivalByAirlines($airport_icao = '') { |
|
3024
|
|
|
global $globalTimezone, $globalDBdriver; |
|
3025
|
|
|
if ($globalTimezone != '') { |
|
3026
|
|
|
date_default_timezone_set($globalTimezone); |
|
3027
|
|
|
$datetime = new DateTime(); |
|
3028
|
|
|
$offset = $datetime->format('P'); |
|
3029
|
|
|
} else $offset = '+00:00'; |
|
3030
|
|
|
if ($airport_icao == '') { |
|
3031
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3032
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
|
3033
|
|
|
} else { |
|
3034
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
|
3035
|
|
|
} |
|
3036
|
|
|
$sth = $this->db->prepare($query); |
|
3037
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
3038
|
|
|
} else { |
|
3039
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3040
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
|
3041
|
|
|
} else { |
|
3042
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
|
3043
|
|
|
} |
|
3044
|
|
|
$sth = $this->db->prepare($query); |
|
3045
|
|
|
$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
|
3046
|
|
|
} |
|
3047
|
|
|
|
|
3048
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
3049
|
|
|
} |
|
3050
|
|
|
|
|
3051
|
|
|
|
|
3052
|
|
|
/** |
|
3053
|
|
|
* Get a list of flights detected to airport since 7 days |
|
3054
|
|
|
* @return Array number, icao, name and city of airports |
|
3055
|
|
|
*/ |
|
3056
|
|
|
|
|
3057
|
|
|
public function getLast7DaysDetectedAirportsArrivalByAirlines($airport_icao = '') { |
|
3058
|
|
|
global $globalTimezone, $globalDBdriver; |
|
3059
|
|
|
if ($globalTimezone != '') { |
|
3060
|
|
|
date_default_timezone_set($globalTimezone); |
|
3061
|
|
|
$datetime = new DateTime(); |
|
3062
|
|
|
$offset = $datetime->format('P'); |
|
3063
|
|
|
} else $offset = '+00:00'; |
|
3064
|
|
|
if ($airport_icao == '') { |
|
3065
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3066
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
|
3067
|
|
|
FROM `spotter_output`, airport |
|
3068
|
|
|
WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' |
|
3069
|
|
|
GROUP BY spotter_output.airline_icao, real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
|
3070
|
|
|
} else { |
|
3071
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
3072
|
|
|
FROM spotter_output, airport |
|
3073
|
|
|
WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' |
|
3074
|
|
|
GROUP BY spotter_output.airline_icao, real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
|
3075
|
|
|
} |
|
3076
|
|
|
$sth = $this->db->prepare($query); |
|
3077
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
3078
|
|
|
} else { |
|
3079
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3080
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
|
3081
|
|
|
FROM `spotter_output`, airport |
|
3082
|
|
|
WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao |
|
3083
|
|
|
GROUP BY spotter_output.airline_icao, real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
|
3084
|
|
|
} else { |
|
3085
|
|
|
$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
3086
|
|
|
FROM spotter_output, airport |
|
3087
|
|
|
WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao |
|
3088
|
|
|
GROUP BY spotter_output.airline_icao,real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
|
3089
|
|
|
} |
|
3090
|
|
|
$sth = $this->db->prepare($query); |
|
3091
|
|
|
$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
|
3092
|
|
|
} |
|
3093
|
|
|
|
|
3094
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
3095
|
|
|
} |
|
3096
|
|
|
|
|
3097
|
|
|
|
|
3098
|
|
|
/** |
|
3099
|
|
|
* Gets a list of all dates |
|
3100
|
|
|
* |
|
3101
|
|
|
* @return Array list of date names |
|
3102
|
|
|
* |
|
3103
|
|
|
*/ |
|
3104
|
|
|
public function getAllDates() |
|
3105
|
|
|
{ |
|
3106
|
|
|
global $globalTimezone, $globalDBdriver; |
|
3107
|
|
|
if ($globalTimezone != '') { |
|
3108
|
|
|
date_default_timezone_set($globalTimezone); |
|
3109
|
|
|
$datetime = new DateTime(); |
|
3110
|
|
|
$offset = $datetime->format('P'); |
|
3111
|
|
|
} else $offset = '+00:00'; |
|
3112
|
|
|
|
|
3113
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3114
|
|
|
$query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
|
3115
|
|
|
FROM spotter_output |
|
3116
|
|
|
WHERE spotter_output.date <> '' |
|
3117
|
|
|
ORDER BY spotter_output.date ASC LIMIT 0,200"; |
|
3118
|
|
|
} else { |
|
3119
|
|
|
$query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
3120
|
|
|
FROM spotter_output |
|
3121
|
|
|
WHERE spotter_output.date <> '' |
|
3122
|
|
|
ORDER BY spotter_output.date ASC LIMIT 0,200"; |
|
3123
|
|
|
} |
|
3124
|
|
|
|
|
3125
|
|
|
$sth = $this->db->prepare($query); |
|
3126
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
3127
|
|
|
|
|
3128
|
|
|
$date_array = array(); |
|
3129
|
|
|
$temp_array = array(); |
|
3130
|
|
|
|
|
3131
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3132
|
|
|
{ |
|
3133
|
|
|
$temp_array['date'] = $row['date']; |
|
3134
|
|
|
|
|
3135
|
|
|
$date_array[] = $temp_array; |
|
3136
|
|
|
} |
|
3137
|
|
|
|
|
3138
|
|
|
return $date_array; |
|
3139
|
|
|
} |
|
3140
|
|
|
|
|
3141
|
|
|
|
|
3142
|
|
|
|
|
3143
|
|
|
/** |
|
3144
|
|
|
* Gets all route combinations |
|
3145
|
|
|
* |
|
3146
|
|
|
* @return Array the route list |
|
3147
|
|
|
* |
|
3148
|
|
|
*/ |
|
3149
|
|
|
public function getAllRoutes() |
|
3150
|
|
|
{ |
|
3151
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao |
|
3152
|
|
|
FROM spotter_output |
|
3153
|
|
|
WHERE spotter_output.ident <> '' |
|
3154
|
|
|
GROUP BY route |
|
3155
|
|
|
ORDER BY route ASC"; |
|
3156
|
|
|
|
|
3157
|
|
|
$sth = $this->db->prepare($query); |
|
3158
|
|
|
$sth->execute(); |
|
3159
|
|
|
|
|
3160
|
|
|
$routes_array = array(); |
|
3161
|
|
|
$temp_array = array(); |
|
3162
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3163
|
|
|
{ |
|
3164
|
|
|
$temp_array['route'] = $row['route']; |
|
3165
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
3166
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
3167
|
|
|
|
|
3168
|
|
|
$routes_array[] = $temp_array; |
|
3169
|
|
|
} |
|
3170
|
|
|
return $routes_array; |
|
3171
|
|
|
} |
|
3172
|
|
|
|
|
3173
|
|
|
/** |
|
3174
|
|
|
* Update ident spotter data |
|
3175
|
|
|
* |
|
3176
|
|
|
* @param String $flightaware_id the ID from flightaware |
|
3177
|
|
|
* @param String $ident the flight ident |
|
3178
|
|
|
* @return String success or false |
|
3179
|
|
|
* |
|
3180
|
|
|
*/ |
|
3181
|
|
|
public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL) |
|
3182
|
|
|
{ |
|
3183
|
|
|
if (!is_numeric(substr($ident, 0, 3))) |
|
3184
|
|
|
{ |
|
3185
|
|
|
if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
|
3186
|
|
|
$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); |
|
3187
|
|
|
} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
|
3188
|
|
|
$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); |
|
3189
|
|
|
} else { |
|
3190
|
|
|
$airline_array = $this->getAllAirlineInfo("NA"); |
|
3191
|
|
|
} |
|
3192
|
|
|
if (count($airline_array) == 0) { |
|
3193
|
|
|
$airline_array = $this->getAllAirlineInfo("NA"); |
|
3194
|
|
|
} |
|
3195
|
|
|
if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
|
3196
|
|
|
$airline_array = $this->getAllAirlineInfo("NA"); |
|
3197
|
|
|
} |
|
3198
|
|
|
} else { |
|
3199
|
|
|
$airline_array = $this->getAllAirlineInfo("NA"); |
|
3200
|
|
|
} |
|
3201
|
|
|
$airline_name = $airline_array[0]['name']; |
|
3202
|
|
|
$airline_icao = $airline_array[0]['icao']; |
|
3203
|
|
|
$airline_country = $airline_array[0]['country']; |
|
3204
|
|
|
$airline_type = $airline_array[0]['type']; |
|
3205
|
|
|
|
|
3206
|
|
|
|
|
3207
|
|
|
$query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id'; |
|
3208
|
|
|
$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type); |
|
3209
|
|
|
|
|
3210
|
|
|
try { |
|
3211
|
|
|
$sth = $this->db->prepare($query); |
|
3212
|
|
|
$sth->execute($query_values); |
|
3213
|
|
|
} catch (PDOException $e) { |
|
3214
|
|
|
return "error : ".$e->getMessage(); |
|
3215
|
|
|
} |
|
3216
|
|
|
|
|
3217
|
|
|
return "success"; |
|
3218
|
|
|
|
|
3219
|
|
|
} |
|
3220
|
|
|
/** |
|
3221
|
|
|
* Update latest spotter data |
|
3222
|
|
|
* |
|
3223
|
|
|
* @param String $flightaware_id the ID from flightaware |
|
3224
|
|
|
* @param String $ident the flight ident |
|
3225
|
|
|
* @param String $arrival_airport_icao the arrival airport |
|
3226
|
|
|
* @return String success or false |
|
3227
|
|
|
* |
|
3228
|
|
|
*/ |
|
3229
|
|
|
public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') |
|
3230
|
|
|
{ |
|
3231
|
|
|
if ($groundspeed == '') $groundspeed = NULL; |
|
3232
|
|
|
$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id'; |
|
3233
|
|
|
$query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident); |
|
3234
|
|
|
|
|
3235
|
|
|
try { |
|
3236
|
|
|
$sth = $this->db->prepare($query); |
|
3237
|
|
|
$sth->execute($query_values); |
|
3238
|
|
|
} catch (PDOException $e) { |
|
3239
|
|
|
return "error : ".$e->getMessage(); |
|
3240
|
|
|
} |
|
3241
|
|
|
|
|
3242
|
|
|
return "success"; |
|
3243
|
|
|
|
|
3244
|
|
|
} |
|
3245
|
|
|
|
|
3246
|
|
|
/** |
|
3247
|
|
|
* Adds a new spotter data |
|
3248
|
|
|
* |
|
3249
|
|
|
* @param String $flightaware_id the ID from flightaware |
|
3250
|
|
|
* @param String $ident the flight ident |
|
3251
|
|
|
* @param String $aircraft_icao the aircraft type |
|
3252
|
|
|
* @param String $departure_airport_icao the departure airport |
|
3253
|
|
|
* @param String $arrival_airport_icao the arrival airport |
|
3254
|
|
|
* @param String $latitude latitude of flight |
|
3255
|
|
|
* @param String $longitude latitude of flight |
|
3256
|
|
|
* @param String $waypoints waypoints of flight |
|
3257
|
|
|
* @param String $altitude altitude of flight |
|
3258
|
|
|
* @param String $heading heading of flight |
|
3259
|
|
|
* @param String $groundspeed speed of flight |
|
3260
|
|
|
* @param String $date date of flight |
|
3261
|
|
|
* @param String $departure_airport_time departure time of flight |
|
3262
|
|
|
* @param String $arrival_airport_time arrival time of flight |
|
3263
|
|
|
* @param String $squawk squawk code of flight |
|
3264
|
|
|
* @param String $route_stop route stop of flight |
|
3265
|
|
|
* @param String $highlight highlight or not |
|
3266
|
|
|
* @param String $ModeS ModesS code of flight |
|
3267
|
|
|
* @param String $registration registration code of flight |
|
3268
|
|
|
* @param String $pilot_id pilot id of flight (for virtual airlines) |
|
3269
|
|
|
* @param String $pilot_name pilot name of flight (for virtual airlines) |
|
3270
|
|
|
* @param String $verticalrate vertival rate of flight |
|
3271
|
|
|
* @return String success or false |
|
3272
|
|
|
*/ |
|
3273
|
|
|
public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '') |
|
3274
|
|
|
{ |
|
3275
|
|
|
global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM; |
|
3276
|
|
|
|
|
3277
|
|
|
//if (isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
|
3278
|
|
|
$Image = new Image($this->db); |
|
3279
|
|
|
$Common = new Common(); |
|
3280
|
|
|
|
|
3281
|
|
|
if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
3282
|
|
|
if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
3283
|
|
|
if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
3284
|
|
|
if (!isset($globalVAM)) $globalVAM = FALSE; |
|
3285
|
|
|
date_default_timezone_set('UTC'); |
|
3286
|
|
|
|
|
3287
|
|
|
//getting the registration |
|
3288
|
|
|
if ($flightaware_id != "" && $registration == '') |
|
3289
|
|
|
{ |
|
3290
|
|
|
if (!is_string($flightaware_id)) |
|
3291
|
|
|
{ |
|
3292
|
|
|
return false; |
|
3293
|
|
|
} else { |
|
3294
|
|
|
if ($ModeS != '') { |
|
3295
|
|
|
$timeelapsed = microtime(true); |
|
3296
|
|
|
$registration = $this->getAircraftRegistrationBymodeS($ModeS); |
|
3297
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3298
|
|
|
} else { |
|
3299
|
|
|
$myhex = explode('-',$flightaware_id); |
|
3300
|
|
|
if (count($myhex) > 0) { |
|
3301
|
|
|
$timeelapsed = microtime(true); |
|
3302
|
|
|
$registration = $this->getAircraftRegistrationBymodeS($myhex[0]); |
|
3303
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3304
|
|
|
} |
|
3305
|
|
|
} |
|
3306
|
|
|
} |
|
3307
|
|
|
} |
|
3308
|
|
|
$fromsource = NULL; |
|
3309
|
|
|
if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
3310
|
|
|
elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim'; |
|
3311
|
|
|
elseif ($format_source == 'whazzup') $fromsource = 'ivao'; |
|
3312
|
|
|
elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
3313
|
|
|
elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
3314
|
|
|
//getting the airline information |
|
3315
|
|
|
if ($ident != "") |
|
3316
|
|
|
{ |
|
3317
|
|
|
if (!is_string($ident)) |
|
3318
|
|
|
{ |
|
3319
|
|
|
return false; |
|
3320
|
|
|
} else { |
|
3321
|
|
|
if (!is_numeric(substr($ident, 0, 3)) && !((substr($ident, 0, 3) == 'OGN' || substr($ident, 0, 3) == 'FLR' || substr($ident, 0, 3) == 'ICA') && $format_source == 'aprs')) |
|
3322
|
|
|
{ |
|
3323
|
|
|
$timeelapsed = microtime(true); |
|
3324
|
|
|
if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
|
3325
|
|
|
$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); |
|
3326
|
|
|
} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
|
3327
|
|
|
$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); |
|
3328
|
|
|
} else { |
|
3329
|
|
|
$airline_array = $this->getAllAirlineInfo("NA"); |
|
3330
|
|
|
} |
|
3331
|
|
|
if (count($airline_array) == 0) { |
|
3332
|
|
|
$airline_array = $this->getAllAirlineInfo("NA"); |
|
3333
|
|
|
} |
|
3334
|
|
|
if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
|
3335
|
|
|
$airline_array = $this->getAllAirlineInfo("NA"); |
|
3336
|
|
|
} |
|
3337
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3338
|
|
|
|
|
3339
|
|
|
} else { |
|
3340
|
|
|
$timeelapsed = microtime(true); |
|
3341
|
|
|
$airline_array = $this->getAllAirlineInfo("NA"); |
|
3342
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3343
|
|
|
} |
|
3344
|
|
|
} |
|
3345
|
|
|
} else $airline_array = array(); |
|
3346
|
|
|
|
|
3347
|
|
|
//getting the aircraft information |
|
3348
|
|
|
$aircraft_array = array(); |
|
3349
|
|
|
if ($aircraft_icao != "") |
|
3350
|
|
|
{ |
|
3351
|
|
|
if (!is_string($aircraft_icao)) |
|
3352
|
|
|
{ |
|
3353
|
|
|
return false; |
|
3354
|
|
|
} else { |
|
3355
|
|
|
if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
|
3356
|
|
|
{ |
|
3357
|
|
|
$timeelapsed = microtime(true); |
|
3358
|
|
|
$aircraft_array = $this->getAllAircraftInfo("NA"); |
|
3359
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3360
|
|
|
} else { |
|
3361
|
|
|
$timeelapsed = microtime(true); |
|
3362
|
|
|
$aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
|
3363
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3364
|
|
|
} |
|
3365
|
|
|
} |
|
3366
|
|
|
} else { |
|
3367
|
|
|
if ($ModeS != '') { |
|
3368
|
|
|
$timeelapsed = microtime(true); |
|
3369
|
|
|
$aircraft_icao = $this->getAllAircraftType($ModeS); |
|
3370
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3371
|
|
|
if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
|
3372
|
|
|
{ |
|
3373
|
|
|
$timeelapsed = microtime(true); |
|
3374
|
|
|
$aircraft_array = $this->getAllAircraftInfo("NA"); |
|
3375
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3376
|
|
|
} else { |
|
3377
|
|
|
$timeelapsed = microtime(true); |
|
3378
|
|
|
$aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
|
3379
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3380
|
|
|
} |
|
3381
|
|
|
} |
|
3382
|
|
|
} |
|
3383
|
|
|
|
|
3384
|
|
|
//getting the departure airport information |
|
3385
|
|
|
$departure_airport_array = array(); |
|
3386
|
|
|
if ($departure_airport_icao != "") |
|
3387
|
|
|
{ |
|
3388
|
|
|
if (!is_string($departure_airport_icao)) |
|
3389
|
|
|
{ |
|
3390
|
|
|
return false; |
|
3391
|
|
|
} else { |
|
3392
|
|
|
$timeelapsed = microtime(true); |
|
3393
|
|
|
$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); |
|
3394
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3395
|
|
|
} |
|
3396
|
|
|
} |
|
3397
|
|
|
|
|
3398
|
|
|
//getting the arrival airport information |
|
3399
|
|
|
$arrival_airport_array = array(); |
|
3400
|
|
|
if ($arrival_airport_icao != "") |
|
3401
|
|
|
{ |
|
3402
|
|
|
if (!is_string($arrival_airport_icao)) |
|
3403
|
|
|
{ |
|
3404
|
|
|
return false; |
|
3405
|
|
|
} else { |
|
3406
|
|
|
$timeelapsed = microtime(true); |
|
3407
|
|
|
$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); |
|
3408
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3409
|
|
|
} |
|
3410
|
|
|
} |
|
3411
|
|
|
|
|
3412
|
|
|
|
|
3413
|
|
|
if ($latitude != "") |
|
3414
|
|
|
{ |
|
3415
|
|
|
if (!is_numeric($latitude)) |
|
3416
|
|
|
{ |
|
3417
|
|
|
return false; |
|
3418
|
|
|
} |
|
3419
|
|
|
} |
|
3420
|
|
|
|
|
3421
|
|
|
if ($longitude != "") |
|
3422
|
|
|
{ |
|
3423
|
|
|
if (!is_numeric($longitude)) |
|
3424
|
|
|
{ |
|
3425
|
|
|
return false; |
|
3426
|
|
|
} |
|
3427
|
|
|
} |
|
3428
|
|
|
|
|
3429
|
|
|
if ($waypoints != "") |
|
3430
|
|
|
{ |
|
3431
|
|
|
if (!is_string($waypoints)) |
|
3432
|
|
|
{ |
|
3433
|
|
|
return false; |
|
3434
|
|
|
} |
|
3435
|
|
|
} |
|
3436
|
|
|
|
|
3437
|
|
|
if ($altitude != "") |
|
3438
|
|
|
{ |
|
3439
|
|
|
if (!is_numeric($altitude)) |
|
3440
|
|
|
{ |
|
3441
|
|
|
return false; |
|
3442
|
|
|
} |
|
3443
|
|
|
} else $altitude = 0; |
|
3444
|
|
|
|
|
3445
|
|
|
if ($heading != "") |
|
3446
|
|
|
{ |
|
3447
|
|
|
if (!is_numeric($heading)) |
|
3448
|
|
|
{ |
|
3449
|
|
|
return false; |
|
3450
|
|
|
} |
|
3451
|
|
|
} |
|
3452
|
|
|
|
|
3453
|
|
|
if ($groundspeed != "") |
|
3454
|
|
|
{ |
|
3455
|
|
|
if (!is_numeric($groundspeed)) |
|
3456
|
|
|
{ |
|
3457
|
|
|
return false; |
|
3458
|
|
|
} |
|
3459
|
|
|
} |
|
3460
|
|
|
|
|
3461
|
|
|
|
|
3462
|
|
|
if ($date == "") |
|
3463
|
|
|
{ |
|
3464
|
|
|
$date = date("Y-m-d H:i:s", time()); |
|
3465
|
|
|
} |
|
3466
|
|
|
|
|
3467
|
|
|
//getting the aircraft image |
|
3468
|
|
|
if (($registration != "" || $registration != 'NA') && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM) |
|
3469
|
|
|
{ |
|
3470
|
|
|
$timeelapsed = microtime(true); |
|
3471
|
|
|
$image_array = $Image->getSpotterImage($registration); |
|
3472
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3473
|
|
|
if (!isset($image_array[0]['registration'])) |
|
3474
|
|
|
{ |
|
3475
|
|
|
//echo "Add image !!!! \n"; |
|
3476
|
|
|
$Image->addSpotterImage($registration); |
|
3477
|
|
|
} |
|
3478
|
|
|
$timeelapsed = microtime(true); |
|
3479
|
|
|
$owner_info = $this->getAircraftOwnerByRegistration($registration); |
|
3480
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3481
|
|
|
if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
3482
|
|
|
} |
|
3483
|
|
|
|
|
3484
|
|
|
if ($globalIVAO && $aircraft_icao != '') |
|
3485
|
|
|
{ |
|
3486
|
|
|
if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; |
|
3487
|
|
|
else $airline_icao = ''; |
|
3488
|
|
|
$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
3489
|
|
|
if (!isset($image_array[0]['registration'])) |
|
3490
|
|
|
{ |
|
3491
|
|
|
//echo "Add image !!!! \n"; |
|
3492
|
|
|
$Image->addSpotterImage('',$aircraft_icao,$airline_icao); |
|
3493
|
|
|
} |
|
3494
|
|
|
} |
|
3495
|
|
|
|
|
3496
|
|
|
$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
3497
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
3498
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
3499
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
3500
|
|
|
$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
3501
|
|
|
$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
3502
|
|
|
$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
3503
|
|
|
$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
3504
|
|
|
$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
3505
|
|
|
$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
3506
|
|
|
$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
3507
|
|
|
$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
3508
|
|
|
$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
3509
|
|
|
$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
3510
|
|
|
$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
3511
|
|
|
$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
3512
|
|
|
$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
3513
|
|
|
$format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
3514
|
|
|
$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
3515
|
|
|
|
|
3516
|
|
|
if (count($airline_array) == 0) |
|
3517
|
|
|
{ |
|
3518
|
|
|
$airline_array = $this->getAllAirlineInfo('NA'); |
|
3519
|
|
|
} |
|
3520
|
|
|
if (count($aircraft_array) == 0) |
|
3521
|
|
|
{ |
|
3522
|
|
|
$aircraft_array = $this->getAllAircraftInfo('NA'); |
|
3523
|
|
|
} |
|
3524
|
|
|
if (count($departure_airport_array) == 0) |
|
3525
|
|
|
{ |
|
3526
|
|
|
$departure_airport_array = $this->getAllAirportInfo('NA'); |
|
3527
|
|
|
} |
|
3528
|
|
|
if (count($arrival_airport_array) == 0) |
|
3529
|
|
|
{ |
|
3530
|
|
|
$arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
3531
|
|
|
} |
|
3532
|
|
|
if ($registration == '') $registration = 'NA'; |
|
3533
|
|
|
if ($latitude == '' && $longitude == '') { |
|
3534
|
|
|
$latitude = 0; |
|
3535
|
|
|
$longitude = 0; |
|
3536
|
|
|
} |
|
3537
|
|
|
if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
3538
|
|
|
if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
3539
|
|
|
if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
3540
|
|
|
if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
3541
|
|
|
if (!isset($aircraft_owner)) $aircraft_owner = NULL; |
|
3542
|
|
|
$query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) |
|
3543
|
|
|
VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)"; |
|
3544
|
|
|
|
|
3545
|
|
|
$airline_name = $airline_array[0]['name']; |
|
3546
|
|
|
$airline_icao = $airline_array[0]['icao']; |
|
3547
|
|
|
$airline_country = $airline_array[0]['country']; |
|
3548
|
|
|
$airline_type = $airline_array[0]['type']; |
|
3549
|
|
|
if ($airline_type == '') { |
|
3550
|
|
|
$timeelapsed = microtime(true); |
|
3551
|
|
|
$airline_type = $this->getAircraftTypeBymodeS($ModeS); |
|
3552
|
|
|
if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3553
|
|
|
} |
|
3554
|
|
|
if ($airline_type == null) $airline_type = ''; |
|
3555
|
|
|
$aircraft_type = $aircraft_array[0]['type']; |
|
3556
|
|
|
$aircraft_manufacturer = $aircraft_array[0]['manufacturer']; |
|
3557
|
|
|
$departure_airport_name = $departure_airport_array[0]['name']; |
|
3558
|
|
|
$departure_airport_city = $departure_airport_array[0]['city']; |
|
3559
|
|
|
$departure_airport_country = $departure_airport_array[0]['country']; |
|
3560
|
|
|
$arrival_airport_name = $arrival_airport_array[0]['name']; |
|
3561
|
|
|
$arrival_airport_city = $arrival_airport_array[0]['city']; |
|
3562
|
|
|
$arrival_airport_country = $arrival_airport_array[0]['country']; |
|
3563
|
|
|
$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_type' => $aircraft_type,':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,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name); |
|
3564
|
|
|
|
|
3565
|
|
|
try { |
|
3566
|
|
|
|
|
3567
|
|
|
$sth = $this->db->prepare($query); |
|
3568
|
|
|
$sth->execute($query_values); |
|
3569
|
|
|
$this->db = null; |
|
3570
|
|
|
} catch (PDOException $e) { |
|
3571
|
|
|
return "error : ".$e->getMessage(); |
|
3572
|
|
|
} |
|
3573
|
|
|
|
|
3574
|
|
|
return "success"; |
|
3575
|
|
|
|
|
3576
|
|
|
} |
|
3577
|
|
|
|
|
3578
|
|
|
|
|
3579
|
|
|
/** |
|
3580
|
|
|
* Gets the aircraft ident within the last hour |
|
3581
|
|
|
* |
|
3582
|
|
|
* @return String the ident |
|
3583
|
|
|
* |
|
3584
|
|
|
*/ |
|
3585
|
|
|
public function getIdentFromLastHour($ident) |
|
3586
|
|
|
{ |
|
3587
|
|
|
global $globalDBdriver, $globalTimezone; |
|
3588
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3589
|
|
|
$query = "SELECT spotter_output.ident FROM spotter_output |
|
3590
|
|
|
WHERE spotter_output.ident = :ident |
|
3591
|
|
|
AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
|
3592
|
|
|
AND spotter_output.date < UTC_TIMESTAMP()"; |
|
3593
|
|
|
$query_data = array(':ident' => $ident); |
|
3594
|
|
|
} else { |
|
3595
|
|
|
$query = "SELECT spotter_output.ident FROM spotter_output |
|
3596
|
|
|
WHERE spotter_output.ident = :ident |
|
3597
|
|
|
AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
|
3598
|
|
|
AND spotter_output.date < now() AT TIME ZONE 'UTC'"; |
|
3599
|
|
|
$query_data = array(':ident' => $ident); |
|
3600
|
|
|
} |
|
3601
|
|
|
|
|
3602
|
|
|
$sth = $this->db->prepare($query); |
|
3603
|
|
|
$sth->execute($query_data); |
|
3604
|
|
|
$ident_result=''; |
|
3605
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3606
|
|
|
{ |
|
3607
|
|
|
$ident_result = $row['ident']; |
|
3608
|
|
|
} |
|
3609
|
|
|
|
|
3610
|
|
|
return $ident_result; |
|
3611
|
|
|
} |
|
3612
|
|
|
|
|
3613
|
|
|
|
|
3614
|
|
|
/** |
|
3615
|
|
|
* Gets the aircraft data from the last 20 seconds |
|
3616
|
|
|
* |
|
3617
|
|
|
* @return Array the spotter data |
|
3618
|
|
|
* |
|
3619
|
|
|
*/ |
|
3620
|
|
|
public function getRealTimeData($q = '') |
|
3621
|
|
|
{ |
|
3622
|
|
|
global $globalDBdriver; |
|
3623
|
|
|
$additional_query = ''; |
|
3624
|
|
|
if ($q != "") |
|
3625
|
|
|
{ |
|
3626
|
|
|
if (!is_string($q)) |
|
3627
|
|
|
{ |
|
3628
|
|
|
return false; |
|
3629
|
|
|
} else { |
|
3630
|
|
|
$q_array = explode(" ", $q); |
|
3631
|
|
|
foreach ($q_array as $q_item){ |
|
3632
|
|
|
$q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
3633
|
|
|
$additional_query .= " AND ("; |
|
3634
|
|
|
$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
|
3635
|
|
|
$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
|
3636
|
|
|
$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
3637
|
|
|
$additional_query .= "(spotter_output.airline_icao like '%".$q_item."%') OR "; |
|
3638
|
|
|
$additional_query .= "(spotter_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
3639
|
|
|
$additional_query .= "(spotter_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
3640
|
|
|
$additional_query .= "(spotter_output.registration like '%".$q_item."%') OR "; |
|
3641
|
|
|
$additional_query .= "(spotter_output.ident like '%".$q_item."%')"; |
|
3642
|
|
|
$additional_query .= ")"; |
|
3643
|
|
|
} |
|
3644
|
|
|
} |
|
3645
|
|
|
} |
|
3646
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3647
|
|
|
$query = "SELECT spotter_output.* FROM spotter_output |
|
3648
|
|
|
WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
|
3649
|
|
|
AND spotter_output.date < UTC_TIMESTAMP()"; |
|
3650
|
|
|
} else { |
|
3651
|
|
|
$query = "SELECT spotter_output.* FROM spotter_output |
|
3652
|
|
|
WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
|
3653
|
|
|
AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
|
3654
|
|
|
} |
|
3655
|
|
|
$spotter_array = $this->getDataFromDB($query, array()); |
|
3656
|
|
|
|
|
3657
|
|
|
return $spotter_array; |
|
3658
|
|
|
} |
|
3659
|
|
|
|
|
3660
|
|
|
|
|
3661
|
|
|
|
|
3662
|
|
|
/** |
|
3663
|
|
|
* Gets all airlines that have flown over |
|
3664
|
|
|
* |
|
3665
|
|
|
* @return Array the airline list |
|
3666
|
|
|
* |
|
3667
|
|
|
*/ |
|
3668
|
|
|
public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
3669
|
|
|
{ |
|
3670
|
|
|
global $globalDBdriver; |
|
3671
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
3672
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
3673
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA' "; |
|
3674
|
|
|
if ($olderthanmonths > 0) { |
|
3675
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3676
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
3677
|
|
|
} else { |
|
3678
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
3679
|
|
|
} |
|
3680
|
|
|
} |
|
3681
|
|
|
if ($sincedate != '') { |
|
3682
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3683
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
3684
|
|
|
} else { |
|
3685
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
3686
|
|
|
} |
|
3687
|
|
|
} |
|
3688
|
|
|
$query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; |
|
3689
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3690
|
|
|
|
|
3691
|
|
|
$sth = $this->db->prepare($query); |
|
3692
|
|
|
$sth->execute(); |
|
3693
|
|
|
|
|
3694
|
|
|
$airline_array = array(); |
|
3695
|
|
|
$temp_array = array(); |
|
3696
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3697
|
|
|
{ |
|
3698
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
3699
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
3700
|
|
|
$temp_array['airline_count'] = $row['airline_count']; |
|
3701
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
3702
|
|
|
$airline_array[] = $temp_array; |
|
3703
|
|
|
} |
|
3704
|
|
|
return $airline_array; |
|
3705
|
|
|
} |
|
3706
|
|
|
|
|
3707
|
|
|
/** |
|
3708
|
|
|
* Gets all pilots that have flown over |
|
3709
|
|
|
* |
|
3710
|
|
|
* @return Array the pilots list |
|
3711
|
|
|
* |
|
3712
|
|
|
*/ |
|
3713
|
|
|
public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
3714
|
|
|
{ |
|
3715
|
|
|
global $globalDBdriver; |
|
3716
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
3717
|
|
|
$query = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source |
|
3718
|
|
|
FROM spotter_output".$filter_query." spotter_output.pilot_id <> '' "; |
|
3719
|
|
|
if ($olderthanmonths > 0) { |
|
3720
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3721
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
3722
|
|
|
} else { |
|
3723
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
3724
|
|
|
} |
|
3725
|
|
|
} |
|
3726
|
|
|
if ($sincedate != '') { |
|
3727
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3728
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
3729
|
|
|
} else { |
|
3730
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
3731
|
|
|
} |
|
3732
|
|
|
} |
|
3733
|
|
|
$query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; |
|
3734
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3735
|
|
|
|
|
3736
|
|
|
|
|
3737
|
|
|
$sth = $this->db->prepare($query); |
|
3738
|
|
|
$sth->execute(); |
|
3739
|
|
|
|
|
3740
|
|
|
$airline_array = array(); |
|
3741
|
|
|
$temp_array = array(); |
|
3742
|
|
|
|
|
3743
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3744
|
|
|
{ |
|
3745
|
|
|
$temp_array['pilot_name'] = $row['pilot_name']; |
|
3746
|
|
|
$temp_array['pilot_id'] = $row['pilot_id']; |
|
3747
|
|
|
$temp_array['pilot_count'] = $row['pilot_count']; |
|
3748
|
|
|
$temp_array['format_source'] = $row['format_source']; |
|
3749
|
|
|
$airline_array[] = $temp_array; |
|
3750
|
|
|
} |
|
3751
|
|
|
return $airline_array; |
|
3752
|
|
|
} |
|
3753
|
|
|
|
|
3754
|
|
|
/** |
|
3755
|
|
|
* Gets all pilots that have flown over |
|
3756
|
|
|
* |
|
3757
|
|
|
* @return Array the pilots list |
|
3758
|
|
|
* |
|
3759
|
|
|
*/ |
|
3760
|
|
|
public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
3761
|
|
|
{ |
|
3762
|
|
|
global $globalDBdriver; |
|
3763
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source |
|
3764
|
|
|
FROM spotter_output WHERE spotter_output.pilot_id <> '' "; |
|
3765
|
|
|
if ($olderthanmonths > 0) { |
|
3766
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3767
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
3768
|
|
|
} else { |
|
3769
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
3770
|
|
|
} |
|
3771
|
|
|
} |
|
3772
|
|
|
if ($sincedate != '') { |
|
3773
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3774
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
3775
|
|
|
} else { |
|
3776
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
3777
|
|
|
} |
|
3778
|
|
|
} |
|
3779
|
|
|
$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; |
|
3780
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3781
|
|
|
|
|
3782
|
|
|
|
|
3783
|
|
|
$sth = $this->db->prepare($query); |
|
3784
|
|
|
$sth->execute(); |
|
3785
|
|
|
|
|
3786
|
|
|
$airline_array = array(); |
|
3787
|
|
|
$temp_array = array(); |
|
3788
|
|
|
|
|
3789
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3790
|
|
|
{ |
|
3791
|
|
|
$temp_array['pilot_name'] = $row['pilot_name']; |
|
3792
|
|
|
$temp_array['pilot_id'] = $row['pilot_id']; |
|
3793
|
|
|
$temp_array['pilot_count'] = $row['pilot_count']; |
|
3794
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
3795
|
|
|
$temp_array['format_source'] = $row['format_source']; |
|
3796
|
|
|
$airline_array[] = $temp_array; |
|
3797
|
|
|
} |
|
3798
|
|
|
return $airline_array; |
|
3799
|
|
|
} |
|
3800
|
|
|
|
|
3801
|
|
|
/** |
|
3802
|
|
|
* Gets all owner that have flown over |
|
3803
|
|
|
* |
|
3804
|
|
|
* @return Array the pilots list |
|
3805
|
|
|
* |
|
3806
|
|
|
*/ |
|
3807
|
|
|
public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
3808
|
|
|
{ |
|
3809
|
|
|
global $globalDBdriver; |
|
3810
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
3811
|
|
|
$query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
|
3812
|
|
|
FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL "; |
|
3813
|
|
|
if ($olderthanmonths > 0) { |
|
3814
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3815
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
3816
|
|
|
} else { |
|
3817
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
3818
|
|
|
} |
|
3819
|
|
|
} |
|
3820
|
|
|
if ($sincedate != '') { |
|
3821
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3822
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
3823
|
|
|
} else { |
|
3824
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
3825
|
|
|
} |
|
3826
|
|
|
} |
|
3827
|
|
|
$query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; |
|
3828
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3829
|
|
|
|
|
3830
|
|
|
|
|
3831
|
|
|
$sth = $this->db->prepare($query); |
|
3832
|
|
|
$sth->execute(); |
|
3833
|
|
|
|
|
3834
|
|
|
$airline_array = array(); |
|
3835
|
|
|
$temp_array = array(); |
|
3836
|
|
|
|
|
3837
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3838
|
|
|
{ |
|
3839
|
|
|
$temp_array['owner_name'] = $row['owner_name']; |
|
3840
|
|
|
$temp_array['owner_count'] = $row['owner_count']; |
|
3841
|
|
|
$airline_array[] = $temp_array; |
|
3842
|
|
|
} |
|
3843
|
|
|
return $airline_array; |
|
3844
|
|
|
} |
|
3845
|
|
|
|
|
3846
|
|
|
/** |
|
3847
|
|
|
* Gets all owner that have flown over |
|
3848
|
|
|
* |
|
3849
|
|
|
* @return Array the pilots list |
|
3850
|
|
|
* |
|
3851
|
|
|
*/ |
|
3852
|
|
|
public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
3853
|
|
|
{ |
|
3854
|
|
|
global $globalDBdriver; |
|
3855
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
3856
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
|
3857
|
|
|
FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL "; |
|
3858
|
|
|
if ($olderthanmonths > 0) { |
|
3859
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3860
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
3861
|
|
|
} else { |
|
3862
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
3863
|
|
|
} |
|
3864
|
|
|
} |
|
3865
|
|
|
if ($sincedate != '') { |
|
3866
|
|
|
if ($globalDBdriver == 'mysql') { |
|
3867
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
3868
|
|
|
} else { |
|
3869
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
3870
|
|
|
} |
|
3871
|
|
|
} |
|
3872
|
|
|
$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC"; |
|
3873
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3874
|
|
|
|
|
3875
|
|
|
|
|
3876
|
|
|
$sth = $this->db->prepare($query); |
|
3877
|
|
|
$sth->execute(); |
|
3878
|
|
|
|
|
3879
|
|
|
$airline_array = array(); |
|
3880
|
|
|
$temp_array = array(); |
|
3881
|
|
|
|
|
3882
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3883
|
|
|
{ |
|
3884
|
|
|
$temp_array['owner_name'] = $row['owner_name']; |
|
3885
|
|
|
$temp_array['owner_count'] = $row['owner_count']; |
|
3886
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
3887
|
|
|
$airline_array[] = $temp_array; |
|
3888
|
|
|
} |
|
3889
|
|
|
return $airline_array; |
|
3890
|
|
|
} |
|
3891
|
|
|
|
|
3892
|
|
|
/** |
|
3893
|
|
|
* Gets all airlines that have flown over by aircraft |
|
3894
|
|
|
* |
|
3895
|
|
|
* @return Array the airline list |
|
3896
|
|
|
* |
|
3897
|
|
|
*/ |
|
3898
|
|
|
public function countAllAirlinesByAircraft($aircraft_icao,$filters = array()) |
|
3899
|
|
|
{ |
|
3900
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
3901
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
3902
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
3903
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
|
3904
|
|
|
GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country |
|
3905
|
|
|
ORDER BY airline_count DESC"; |
|
3906
|
|
|
|
|
3907
|
|
|
|
|
3908
|
|
|
$sth = $this->db->prepare($query); |
|
3909
|
|
|
$sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
|
3910
|
|
|
|
|
3911
|
|
|
$airline_array = array(); |
|
3912
|
|
|
$temp_array = array(); |
|
3913
|
|
|
|
|
3914
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3915
|
|
|
{ |
|
3916
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
3917
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
3918
|
|
|
$temp_array['airline_count'] = $row['airline_count']; |
|
3919
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
3920
|
|
|
|
|
3921
|
|
|
$airline_array[] = $temp_array; |
|
3922
|
|
|
} |
|
3923
|
|
|
|
|
3924
|
|
|
return $airline_array; |
|
3925
|
|
|
} |
|
3926
|
|
|
|
|
3927
|
|
|
|
|
3928
|
|
|
/** |
|
3929
|
|
|
* Gets all airline countries that have flown over by aircraft |
|
3930
|
|
|
* |
|
3931
|
|
|
* @return Array the airline country list |
|
3932
|
|
|
* |
|
3933
|
|
|
*/ |
|
3934
|
|
|
public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array()) |
|
3935
|
|
|
{ |
|
3936
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
3937
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
3938
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
3939
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
|
3940
|
|
|
GROUP BY spotter_output.airline_country |
|
3941
|
|
|
ORDER BY airline_country_count DESC |
|
3942
|
|
|
LIMIT 10 OFFSET 0"; |
|
3943
|
|
|
|
|
3944
|
|
|
|
|
3945
|
|
|
$sth = $this->db->prepare($query); |
|
3946
|
|
|
$sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
|
3947
|
|
|
|
|
3948
|
|
|
$airline_country_array = array(); |
|
3949
|
|
|
$temp_array = array(); |
|
3950
|
|
|
|
|
3951
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3952
|
|
|
{ |
|
3953
|
|
|
$temp_array['airline_country_count'] = $row['airline_country_count']; |
|
3954
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
3955
|
|
|
|
|
3956
|
|
|
$airline_country_array[] = $temp_array; |
|
3957
|
|
|
} |
|
3958
|
|
|
return $airline_country_array; |
|
3959
|
|
|
} |
|
3960
|
|
|
|
|
3961
|
|
|
|
|
3962
|
|
|
|
|
3963
|
|
|
|
|
3964
|
|
|
/** |
|
3965
|
|
|
* Gets all airlines that have flown over by airport |
|
3966
|
|
|
* |
|
3967
|
|
|
* @return Array the airline list |
|
3968
|
|
|
* |
|
3969
|
|
|
*/ |
|
3970
|
|
|
public function countAllAirlinesByAirport($airport_icao,$filters = array()) |
|
3971
|
|
|
{ |
|
3972
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
3973
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
3974
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
3975
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) |
|
3976
|
|
|
GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country |
|
3977
|
|
|
ORDER BY airline_count DESC"; |
|
3978
|
|
|
|
|
3979
|
|
|
|
|
3980
|
|
|
$sth = $this->db->prepare($query); |
|
3981
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao)); |
|
3982
|
|
|
|
|
3983
|
|
|
$airline_array = array(); |
|
3984
|
|
|
$temp_array = array(); |
|
3985
|
|
|
|
|
3986
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
3987
|
|
|
{ |
|
3988
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
3989
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
3990
|
|
|
$temp_array['airline_count'] = $row['airline_count']; |
|
3991
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
3992
|
|
|
|
|
3993
|
|
|
$airline_array[] = $temp_array; |
|
3994
|
|
|
} |
|
3995
|
|
|
return $airline_array; |
|
3996
|
|
|
} |
|
3997
|
|
|
|
|
3998
|
|
|
|
|
3999
|
|
|
/** |
|
4000
|
|
|
* Gets all airline countries that have flown over by airport icao |
|
4001
|
|
|
* |
|
4002
|
|
|
* @return Array the airline country list |
|
4003
|
|
|
* |
|
4004
|
|
|
*/ |
|
4005
|
|
|
public function countAllAirlineCountriesByAirport($airport_icao,$filters = array()) |
|
4006
|
|
|
{ |
|
4007
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
4008
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4009
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
4010
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) |
|
4011
|
|
|
GROUP BY spotter_output.airline_country |
|
4012
|
|
|
ORDER BY airline_country_count DESC |
|
4013
|
|
|
LIMIT 10 OFFSET 0"; |
|
4014
|
|
|
|
|
4015
|
|
|
|
|
4016
|
|
|
$sth = $this->db->prepare($query); |
|
4017
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao)); |
|
4018
|
|
|
|
|
4019
|
|
|
$airline_country_array = array(); |
|
4020
|
|
|
$temp_array = array(); |
|
4021
|
|
|
|
|
4022
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4023
|
|
|
{ |
|
4024
|
|
|
$temp_array['airline_country_count'] = $row['airline_country_count']; |
|
4025
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4026
|
|
|
|
|
4027
|
|
|
$airline_country_array[] = $temp_array; |
|
4028
|
|
|
} |
|
4029
|
|
|
return $airline_country_array; |
|
4030
|
|
|
} |
|
4031
|
|
|
|
|
4032
|
|
|
|
|
4033
|
|
|
/** |
|
4034
|
|
|
* Gets all airlines that have flown over by aircraft manufacturer |
|
4035
|
|
|
* |
|
4036
|
|
|
* @return Array the airline list |
|
4037
|
|
|
* |
|
4038
|
|
|
*/ |
|
4039
|
|
|
public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array()) |
|
4040
|
|
|
{ |
|
4041
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
4042
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4043
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
4044
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
4045
|
|
|
GROUP BY spotter_output.airline_name |
|
4046
|
|
|
ORDER BY airline_count DESC"; |
|
4047
|
|
|
|
|
4048
|
|
|
$sth = $this->db->prepare($query); |
|
4049
|
|
|
$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
4050
|
|
|
|
|
4051
|
|
|
$airline_array = array(); |
|
4052
|
|
|
$temp_array = array(); |
|
4053
|
|
|
|
|
4054
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4055
|
|
|
{ |
|
4056
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
4057
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
4058
|
|
|
$temp_array['airline_count'] = $row['airline_count']; |
|
4059
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4060
|
|
|
|
|
4061
|
|
|
$airline_array[] = $temp_array; |
|
4062
|
|
|
} |
|
4063
|
|
|
return $airline_array; |
|
4064
|
|
|
} |
|
4065
|
|
|
|
|
4066
|
|
|
|
|
4067
|
|
|
|
|
4068
|
|
|
/** |
|
4069
|
|
|
* Gets all airline countries that have flown over by aircraft manufacturer |
|
4070
|
|
|
* |
|
4071
|
|
|
* @return Array the airline country list |
|
4072
|
|
|
* |
|
4073
|
|
|
*/ |
|
4074
|
|
|
public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
|
4075
|
|
|
{ |
|
4076
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
4077
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4078
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
4079
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
4080
|
|
|
GROUP BY spotter_output.airline_country |
|
4081
|
|
|
ORDER BY airline_country_count DESC |
|
4082
|
|
|
LIMIT 10 OFFSET 0"; |
|
4083
|
|
|
|
|
4084
|
|
|
|
|
4085
|
|
|
$sth = $this->db->prepare($query); |
|
4086
|
|
|
$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
4087
|
|
|
|
|
4088
|
|
|
$airline_country_array = array(); |
|
4089
|
|
|
$temp_array = array(); |
|
4090
|
|
|
|
|
4091
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4092
|
|
|
{ |
|
4093
|
|
|
$temp_array['airline_country_count'] = $row['airline_country_count']; |
|
4094
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4095
|
|
|
$airline_country_array[] = $temp_array; |
|
4096
|
|
|
} |
|
4097
|
|
|
return $airline_country_array; |
|
4098
|
|
|
} |
|
4099
|
|
|
|
|
4100
|
|
|
|
|
4101
|
|
|
/** |
|
4102
|
|
|
* Gets all airlines that have flown over by date |
|
4103
|
|
|
* |
|
4104
|
|
|
* @return Array the airline list |
|
4105
|
|
|
* |
|
4106
|
|
|
*/ |
|
4107
|
|
|
public function countAllAirlinesByDate($date,$filters = array()) |
|
4108
|
|
|
{ |
|
4109
|
|
|
global $globalTimezone, $globalDBdriver; |
|
4110
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4111
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
4112
|
|
|
if ($globalTimezone != '') { |
|
4113
|
|
|
date_default_timezone_set($globalTimezone); |
|
4114
|
|
|
$datetime = new DateTime($date); |
|
4115
|
|
|
$offset = $datetime->format('P'); |
|
4116
|
|
|
} else $offset = '+00:00'; |
|
4117
|
|
|
|
|
4118
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4119
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
4120
|
|
|
FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
4121
|
|
|
GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country |
|
4122
|
|
|
ORDER BY airline_count DESC"; |
|
4123
|
|
|
} else { |
|
4124
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
4125
|
|
|
FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
|
4126
|
|
|
GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country |
|
4127
|
|
|
ORDER BY airline_count DESC"; |
|
4128
|
|
|
} |
|
4129
|
|
|
|
|
4130
|
|
|
$sth = $this->db->prepare($query); |
|
4131
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
4132
|
|
|
|
|
4133
|
|
|
$airline_array = array(); |
|
4134
|
|
|
$temp_array = array(); |
|
4135
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4136
|
|
|
{ |
|
4137
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
4138
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
4139
|
|
|
$temp_array['airline_count'] = $row['airline_count']; |
|
4140
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4141
|
|
|
|
|
4142
|
|
|
$airline_array[] = $temp_array; |
|
4143
|
|
|
} |
|
4144
|
|
|
|
|
4145
|
|
|
return $airline_array; |
|
4146
|
|
|
} |
|
4147
|
|
|
|
|
4148
|
|
|
|
|
4149
|
|
|
/** |
|
4150
|
|
|
* Gets all airline countries that have flown over by date |
|
4151
|
|
|
* |
|
4152
|
|
|
* @return Array the airline country list |
|
4153
|
|
|
* |
|
4154
|
|
|
*/ |
|
4155
|
|
|
public function countAllAirlineCountriesByDate($date,$filters = array()) |
|
4156
|
|
|
{ |
|
4157
|
|
|
global $globalTimezone, $globalDBdriver; |
|
4158
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4159
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
4160
|
|
|
if ($globalTimezone != '') { |
|
4161
|
|
|
date_default_timezone_set($globalTimezone); |
|
4162
|
|
|
$datetime = new DateTime($date); |
|
4163
|
|
|
$offset = $datetime->format('P'); |
|
4164
|
|
|
} else $offset = '+00:00'; |
|
4165
|
|
|
|
|
4166
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4167
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
4168
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
4169
|
|
|
GROUP BY spotter_output.airline_country |
|
4170
|
|
|
ORDER BY airline_country_count DESC |
|
4171
|
|
|
LIMIT 10 OFFSET 0"; |
|
4172
|
|
|
} else { |
|
4173
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
4174
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
|
4175
|
|
|
GROUP BY spotter_output.airline_country |
|
4176
|
|
|
ORDER BY airline_country_count DESC |
|
4177
|
|
|
LIMIT 10 OFFSET 0"; |
|
4178
|
|
|
} |
|
4179
|
|
|
|
|
4180
|
|
|
$sth = $this->db->prepare($query); |
|
4181
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
4182
|
|
|
|
|
4183
|
|
|
$airline_country_array = array(); |
|
4184
|
|
|
$temp_array = array(); |
|
4185
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4186
|
|
|
{ |
|
4187
|
|
|
$temp_array['airline_country_count'] = $row['airline_country_count']; |
|
4188
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4189
|
|
|
|
|
4190
|
|
|
$airline_country_array[] = $temp_array; |
|
4191
|
|
|
} |
|
4192
|
|
|
return $airline_country_array; |
|
4193
|
|
|
} |
|
4194
|
|
|
|
|
4195
|
|
|
|
|
4196
|
|
|
/** |
|
4197
|
|
|
* Gets all airlines that have flown over by ident/callsign |
|
4198
|
|
|
* |
|
4199
|
|
|
* @return Array the airline list |
|
4200
|
|
|
* |
|
4201
|
|
|
*/ |
|
4202
|
|
|
public function countAllAirlinesByIdent($ident,$filters = array()) |
|
4203
|
|
|
{ |
|
4204
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
4205
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4206
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
4207
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident = :ident |
|
4208
|
|
|
GROUP BY spotter_output.airline_name |
|
4209
|
|
|
ORDER BY airline_count DESC"; |
|
4210
|
|
|
|
|
4211
|
|
|
|
|
4212
|
|
|
$sth = $this->db->prepare($query); |
|
4213
|
|
|
$sth->execute(array(':ident' => $ident)); |
|
4214
|
|
|
|
|
4215
|
|
|
$airline_array = array(); |
|
4216
|
|
|
$temp_array = array(); |
|
4217
|
|
|
|
|
4218
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4219
|
|
|
{ |
|
4220
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
4221
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
4222
|
|
|
$temp_array['airline_count'] = $row['airline_count']; |
|
4223
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4224
|
|
|
|
|
4225
|
|
|
$airline_array[] = $temp_array; |
|
4226
|
|
|
} |
|
4227
|
|
|
return $airline_array; |
|
4228
|
|
|
} |
|
4229
|
|
|
|
|
4230
|
|
|
/** |
|
4231
|
|
|
* Gets all airlines that have flown over by route |
|
4232
|
|
|
* |
|
4233
|
|
|
* @return Array the airline list |
|
4234
|
|
|
* |
|
4235
|
|
|
*/ |
|
4236
|
|
|
public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
|
4237
|
|
|
{ |
|
4238
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4239
|
|
|
$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
4240
|
|
|
$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
4241
|
|
|
|
|
4242
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
4243
|
|
|
FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
|
4244
|
|
|
GROUP BY spotter_output.airline_name |
|
4245
|
|
|
ORDER BY airline_count DESC"; |
|
4246
|
|
|
|
|
4247
|
|
|
|
|
4248
|
|
|
$sth = $this->db->prepare($query); |
|
4249
|
|
|
$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
|
4250
|
|
|
|
|
4251
|
|
|
$airline_array = array(); |
|
4252
|
|
|
$temp_array = array(); |
|
4253
|
|
|
|
|
4254
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4255
|
|
|
{ |
|
4256
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
4257
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
4258
|
|
|
$temp_array['airline_count'] = $row['airline_count']; |
|
4259
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4260
|
|
|
|
|
4261
|
|
|
$airline_array[] = $temp_array; |
|
4262
|
|
|
} |
|
4263
|
|
|
return $airline_array; |
|
4264
|
|
|
} |
|
4265
|
|
|
|
|
4266
|
|
|
/** |
|
4267
|
|
|
* Gets all airline countries that have flown over by route |
|
4268
|
|
|
* |
|
4269
|
|
|
* @return Array the airline country list |
|
4270
|
|
|
* |
|
4271
|
|
|
*/ |
|
4272
|
|
|
public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array()) |
|
4273
|
|
|
{ |
|
4274
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4275
|
|
|
$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
4276
|
|
|
$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
4277
|
|
|
|
|
4278
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
4279
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
|
4280
|
|
|
GROUP BY spotter_output.airline_country |
|
4281
|
|
|
ORDER BY airline_country_count DESC |
|
4282
|
|
|
LIMIT 10 OFFSET 0"; |
|
4283
|
|
|
|
|
4284
|
|
|
|
|
4285
|
|
|
$sth = $this->db->prepare($query); |
|
4286
|
|
|
$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
|
4287
|
|
|
|
|
4288
|
|
|
$airline_country_array = array(); |
|
4289
|
|
|
$temp_array = array(); |
|
4290
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4291
|
|
|
{ |
|
4292
|
|
|
$temp_array['airline_country_count'] = $row['airline_country_count']; |
|
4293
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4294
|
|
|
|
|
4295
|
|
|
$airline_country_array[] = $temp_array; |
|
4296
|
|
|
} |
|
4297
|
|
|
|
|
4298
|
|
|
return $airline_country_array; |
|
4299
|
|
|
} |
|
4300
|
|
|
|
|
4301
|
|
|
|
|
4302
|
|
|
/** |
|
4303
|
|
|
* Gets all airlines that have flown over by country |
|
4304
|
|
|
* |
|
4305
|
|
|
* @return Array the airline list |
|
4306
|
|
|
* |
|
4307
|
|
|
*/ |
|
4308
|
|
|
public function countAllAirlinesByCountry($country,$filters = array()) |
|
4309
|
|
|
{ |
|
4310
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
4311
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4312
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
4313
|
|
|
FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
|
4314
|
|
|
GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country |
|
4315
|
|
|
ORDER BY airline_count DESC"; |
|
4316
|
|
|
|
|
4317
|
|
|
|
|
4318
|
|
|
$sth = $this->db->prepare($query); |
|
4319
|
|
|
$sth->execute(array(':country' => $country)); |
|
4320
|
|
|
|
|
4321
|
|
|
$airline_array = array(); |
|
4322
|
|
|
$temp_array = array(); |
|
4323
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4324
|
|
|
{ |
|
4325
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
4326
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
4327
|
|
|
$temp_array['airline_count'] = $row['airline_count']; |
|
4328
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4329
|
|
|
|
|
4330
|
|
|
$airline_array[] = $temp_array; |
|
4331
|
|
|
} |
|
4332
|
|
|
return $airline_array; |
|
4333
|
|
|
} |
|
4334
|
|
|
|
|
4335
|
|
|
|
|
4336
|
|
|
/** |
|
4337
|
|
|
* Gets all airline countries that have flown over by country |
|
4338
|
|
|
* |
|
4339
|
|
|
* @return Array the airline country list |
|
4340
|
|
|
* |
|
4341
|
|
|
*/ |
|
4342
|
|
|
public function countAllAirlineCountriesByCountry($country,$filters = array()) |
|
4343
|
|
|
{ |
|
4344
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4345
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
4346
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
4347
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
|
4348
|
|
|
GROUP BY spotter_output.airline_country |
|
4349
|
|
|
ORDER BY airline_country_count DESC |
|
4350
|
|
|
LIMIT 10 OFFSET 0"; |
|
4351
|
|
|
|
|
4352
|
|
|
|
|
4353
|
|
|
$sth = $this->db->prepare($query); |
|
4354
|
|
|
$sth->execute(array(':country' => $country)); |
|
4355
|
|
|
|
|
4356
|
|
|
$airline_country_array = array(); |
|
4357
|
|
|
$temp_array = array(); |
|
4358
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4359
|
|
|
{ |
|
4360
|
|
|
$temp_array['airline_country_count'] = $row['airline_country_count']; |
|
4361
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4362
|
|
|
|
|
4363
|
|
|
$airline_country_array[] = $temp_array; |
|
4364
|
|
|
} |
|
4365
|
|
|
return $airline_country_array; |
|
4366
|
|
|
} |
|
4367
|
|
|
|
|
4368
|
|
|
|
|
4369
|
|
|
/** |
|
4370
|
|
|
* Gets all airlines countries |
|
4371
|
|
|
* |
|
4372
|
|
|
* @return Array the airline country list |
|
4373
|
|
|
* |
|
4374
|
|
|
*/ |
|
4375
|
|
|
public function countAllAirlineCountries($limit = true, $filters = array()) |
|
4376
|
|
|
{ |
|
4377
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4378
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
4379
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' |
|
4380
|
|
|
GROUP BY spotter_output.airline_country |
|
4381
|
|
|
ORDER BY airline_country_count DESC"; |
|
4382
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4383
|
|
|
|
|
4384
|
|
|
$sth = $this->db->prepare($query); |
|
4385
|
|
|
$sth->execute(); |
|
4386
|
|
|
|
|
4387
|
|
|
$airline_array = array(); |
|
4388
|
|
|
$temp_array = array(); |
|
4389
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4390
|
|
|
{ |
|
4391
|
|
|
$temp_array['airline_country_count'] = $row['airline_country_count']; |
|
4392
|
|
|
$temp_array['airline_country'] = $row['airline_country']; |
|
4393
|
|
|
|
|
4394
|
|
|
$airline_array[] = $temp_array; |
|
4395
|
|
|
} |
|
4396
|
|
|
return $airline_array; |
|
4397
|
|
|
} |
|
4398
|
|
|
|
|
4399
|
|
|
/** |
|
4400
|
|
|
* Gets all number of flight over countries |
|
4401
|
|
|
* |
|
4402
|
|
|
* @return Array the airline country list |
|
4403
|
|
|
* |
|
4404
|
|
|
*/ |
|
4405
|
|
|
public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
4406
|
|
|
{ |
|
4407
|
|
|
global $globalDBdriver; |
|
4408
|
|
|
//$filter_query = $this->getFilter($filters,true,true); |
|
4409
|
|
|
$Connection= new Connection($this->db); |
|
4410
|
|
|
if (!$Connection->tableExists('countries')) return array(); |
|
4411
|
|
|
/* |
|
4412
|
|
|
$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
|
4413
|
|
|
FROM countries c, spotter_output s |
|
4414
|
|
|
WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) "; |
|
4415
|
|
|
*/ |
|
4416
|
|
|
/* |
|
4417
|
|
|
$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
|
4418
|
|
|
FROM countries c, spotter_live s |
|
4419
|
|
|
WHERE c.iso2 = s.over_country "; |
|
4420
|
|
|
$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spottrer_live) l ON c.iso2 = l.over_country "; |
|
4421
|
|
|
*/ |
|
4422
|
|
|
require_once('class.SpotterLive.php'); |
|
4423
|
|
|
$SpotterLive = new SpotterLive(); |
|
4424
|
|
|
$filter_query = $SpotterLive->getFilter($filters,true,true); |
|
4425
|
|
|
$filter_query .= ' over_country IS NOT NULL'; |
|
4426
|
|
|
if ($olderthanmonths > 0) { |
|
4427
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4428
|
|
|
$filter_query .= ' AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
4429
|
|
|
} else { |
|
4430
|
|
|
$filter_query .= " AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
4431
|
|
|
} |
|
4432
|
|
|
} |
|
4433
|
|
|
if ($sincedate != '') { |
|
4434
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4435
|
|
|
$filter_query .= " AND spotter_live.date > '".$sincedate."' "; |
|
4436
|
|
|
} else { |
|
4437
|
|
|
$filter_query .= " AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
4438
|
|
|
} |
|
4439
|
|
|
} |
|
4440
|
|
|
$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country "; |
|
4441
|
|
|
$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
|
4442
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4443
|
|
|
|
|
4444
|
|
|
|
|
4445
|
|
|
$sth = $this->db->prepare($query); |
|
4446
|
|
|
$sth->execute(); |
|
4447
|
|
|
|
|
4448
|
|
|
$flight_array = array(); |
|
4449
|
|
|
$temp_array = array(); |
|
4450
|
|
|
|
|
4451
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4452
|
|
|
{ |
|
4453
|
|
|
$temp_array['flight_count'] = $row['nb']; |
|
4454
|
|
|
$temp_array['flight_country'] = $row['name']; |
|
4455
|
|
|
$temp_array['flight_country_iso3'] = $row['iso3']; |
|
4456
|
|
|
$temp_array['flight_country_iso2'] = $row['iso2']; |
|
4457
|
|
|
$flight_array[] = $temp_array; |
|
4458
|
|
|
} |
|
4459
|
|
|
return $flight_array; |
|
4460
|
|
|
} |
|
4461
|
|
|
|
|
4462
|
|
|
|
|
4463
|
|
|
/** |
|
4464
|
|
|
* Gets all aircraft types that have flown over |
|
4465
|
|
|
* |
|
4466
|
|
|
* @return Array the aircraft list |
|
4467
|
|
|
* |
|
4468
|
|
|
*/ |
|
4469
|
|
|
public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
4470
|
|
|
{ |
|
4471
|
|
|
global $globalDBdriver; |
|
4472
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4473
|
|
|
|
|
4474
|
|
|
$query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
4475
|
|
|
FROM spotter_output ".$filter_query." spotter_output.aircraft_name <> '' AND spotter_output.aircraft_icao <> ''"; |
|
4476
|
|
|
if ($olderthanmonths > 0) { |
|
4477
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4478
|
|
|
$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
|
4479
|
|
|
} else { |
|
4480
|
|
|
$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
4481
|
|
|
} |
|
4482
|
|
|
} |
|
4483
|
|
|
if ($sincedate != '') { |
|
4484
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4485
|
|
|
$query .= " AND spotter_output.date > '".$sincedate."'"; |
|
4486
|
|
|
} else { |
|
4487
|
|
|
$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
4488
|
|
|
} |
|
4489
|
|
|
} |
|
4490
|
|
|
|
|
4491
|
|
|
$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
|
4492
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4493
|
|
|
|
|
4494
|
|
|
$sth = $this->db->prepare($query); |
|
4495
|
|
|
$sth->execute(); |
|
4496
|
|
|
|
|
4497
|
|
|
$aircraft_array = array(); |
|
4498
|
|
|
$temp_array = array(); |
|
4499
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4500
|
|
|
{ |
|
4501
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4502
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4503
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
4504
|
|
|
$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
|
4505
|
|
|
$aircraft_array[] = $temp_array; |
|
4506
|
|
|
} |
|
4507
|
|
|
return $aircraft_array; |
|
4508
|
|
|
} |
|
4509
|
|
|
|
|
4510
|
|
|
/** |
|
4511
|
|
|
* Gets all aircraft types that have flown over by airline |
|
4512
|
|
|
* |
|
4513
|
|
|
* @return Array the aircraft list |
|
4514
|
|
|
* |
|
4515
|
|
|
*/ |
|
4516
|
|
|
public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
4517
|
|
|
{ |
|
4518
|
|
|
global $globalDBdriver; |
|
4519
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4520
|
|
|
$query = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
4521
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_name <> '' AND spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA' "; |
|
4522
|
|
|
if ($olderthanmonths > 0) { |
|
4523
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4524
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
4525
|
|
|
} else { |
|
4526
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
4527
|
|
|
} |
|
4528
|
|
|
} |
|
4529
|
|
|
if ($sincedate != '') { |
|
4530
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4531
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
4532
|
|
|
} else { |
|
4533
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
4534
|
|
|
} |
|
4535
|
|
|
} |
|
4536
|
|
|
|
|
4537
|
|
|
$query .= "GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
|
4538
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4539
|
|
|
|
|
4540
|
|
|
$sth = $this->db->prepare($query); |
|
4541
|
|
|
$sth->execute(); |
|
4542
|
|
|
|
|
4543
|
|
|
$aircraft_array = array(); |
|
4544
|
|
|
$temp_array = array(); |
|
4545
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4546
|
|
|
{ |
|
4547
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
4548
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4549
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4550
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
4551
|
|
|
$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
|
4552
|
|
|
$aircraft_array[] = $temp_array; |
|
4553
|
|
|
} |
|
4554
|
|
|
return $aircraft_array; |
|
4555
|
|
|
} |
|
4556
|
|
|
|
|
4557
|
|
|
/** |
|
4558
|
|
|
* Gets all aircraft types that have flown over by months |
|
4559
|
|
|
* |
|
4560
|
|
|
* @return Array the aircraft list |
|
4561
|
|
|
* |
|
4562
|
|
|
*/ |
|
4563
|
|
|
public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
4564
|
|
|
{ |
|
4565
|
|
|
global $globalDBdriver; |
|
4566
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4567
|
|
|
$query = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
4568
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_name <> '' AND spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA' "; |
|
4569
|
|
|
if ($olderthanmonths > 0) { |
|
4570
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4571
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
4572
|
|
|
} else { |
|
4573
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
4574
|
|
|
} |
|
4575
|
|
|
} |
|
4576
|
|
|
if ($sincedate != '') { |
|
4577
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4578
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
4579
|
|
|
} else { |
|
4580
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
4581
|
|
|
} |
|
4582
|
|
|
} |
|
4583
|
|
|
|
|
4584
|
|
|
$query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
|
4585
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4586
|
|
|
|
|
4587
|
|
|
$sth = $this->db->prepare($query); |
|
4588
|
|
|
$sth->execute(); |
|
4589
|
|
|
|
|
4590
|
|
|
$aircraft_array = array(); |
|
4591
|
|
|
$temp_array = array(); |
|
4592
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4593
|
|
|
{ |
|
4594
|
|
|
//$temp_array['airline_icao'] = $row['airline_icao']; |
|
4595
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4596
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4597
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
4598
|
|
|
$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
|
4599
|
|
|
$aircraft_array[] = $temp_array; |
|
4600
|
|
|
} |
|
4601
|
|
|
return $aircraft_array; |
|
4602
|
|
|
} |
|
4603
|
|
|
|
|
4604
|
|
|
|
|
4605
|
|
|
/** |
|
4606
|
|
|
* Gets all aircraft registration that have flown over by aircaft icao |
|
4607
|
|
|
* |
|
4608
|
|
|
* @return Array the aircraft list |
|
4609
|
|
|
* |
|
4610
|
|
|
*/ |
|
4611
|
|
|
public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array()) |
|
4612
|
|
|
{ |
|
4613
|
|
|
$Image = new Image($this->db); |
|
4614
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4615
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
4616
|
|
|
|
|
4617
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
4618
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
|
4619
|
|
|
GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
4620
|
|
|
ORDER BY registration_count DESC"; |
|
4621
|
|
|
|
|
4622
|
|
|
$sth = $this->db->prepare($query); |
|
4623
|
|
|
$sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
|
4624
|
|
|
|
|
4625
|
|
|
$aircraft_array = array(); |
|
4626
|
|
|
$temp_array = array(); |
|
4627
|
|
|
|
|
4628
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4629
|
|
|
{ |
|
4630
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4631
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4632
|
|
|
$temp_array['registration'] = $row['registration']; |
|
4633
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
4634
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
4635
|
|
|
if($row['registration'] != "") |
|
4636
|
|
|
{ |
|
4637
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
4638
|
|
|
if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4639
|
|
|
} |
|
4640
|
|
|
$temp_array['registration_count'] = $row['registration_count']; |
|
4641
|
|
|
|
|
4642
|
|
|
$aircraft_array[] = $temp_array; |
|
4643
|
|
|
} |
|
4644
|
|
|
return $aircraft_array; |
|
4645
|
|
|
} |
|
4646
|
|
|
|
|
4647
|
|
|
|
|
4648
|
|
|
/** |
|
4649
|
|
|
* Gets all aircraft types that have flown over by airline icao |
|
4650
|
|
|
* |
|
4651
|
|
|
* @return Array the aircraft list |
|
4652
|
|
|
* |
|
4653
|
|
|
*/ |
|
4654
|
|
|
public function countAllAircraftTypesByAirline($airline_icao,$filters = array()) |
|
4655
|
|
|
{ |
|
4656
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4657
|
|
|
$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
4658
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
4659
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao |
|
4660
|
|
|
GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
|
4661
|
|
|
ORDER BY aircraft_icao_count DESC"; |
|
4662
|
|
|
|
|
4663
|
|
|
$sth = $this->db->prepare($query); |
|
4664
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao)); |
|
4665
|
|
|
|
|
4666
|
|
|
$aircraft_array = array(); |
|
4667
|
|
|
$temp_array = array(); |
|
4668
|
|
|
|
|
4669
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4670
|
|
|
{ |
|
4671
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4672
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4673
|
|
|
$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
|
4674
|
|
|
|
|
4675
|
|
|
$aircraft_array[] = $temp_array; |
|
4676
|
|
|
} |
|
4677
|
|
|
return $aircraft_array; |
|
4678
|
|
|
} |
|
4679
|
|
|
|
|
4680
|
|
|
|
|
4681
|
|
|
/** |
|
4682
|
|
|
* Gets all aircraft registration that have flown over by airline icao |
|
4683
|
|
|
* |
|
4684
|
|
|
* @return Array the aircraft list |
|
4685
|
|
|
* |
|
4686
|
|
|
*/ |
|
4687
|
|
|
public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array()) |
|
4688
|
|
|
{ |
|
4689
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4690
|
|
|
$Image = new Image($this->db); |
|
4691
|
|
|
$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
4692
|
|
|
|
|
4693
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
4694
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao |
|
4695
|
|
|
GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
4696
|
|
|
ORDER BY registration_count DESC"; |
|
4697
|
|
|
|
|
4698
|
|
|
$sth = $this->db->prepare($query); |
|
4699
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao)); |
|
4700
|
|
|
|
|
4701
|
|
|
$aircraft_array = array(); |
|
4702
|
|
|
$temp_array = array(); |
|
4703
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4704
|
|
|
{ |
|
4705
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4706
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4707
|
|
|
$temp_array['registration'] = $row['registration']; |
|
4708
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
4709
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
4710
|
|
|
if($row['registration'] != "") |
|
4711
|
|
|
{ |
|
4712
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
4713
|
|
|
if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4714
|
|
|
} |
|
4715
|
|
|
$temp_array['registration_count'] = $row['registration_count']; |
|
4716
|
|
|
|
|
4717
|
|
|
$aircraft_array[] = $temp_array; |
|
4718
|
|
|
} |
|
4719
|
|
|
return $aircraft_array; |
|
4720
|
|
|
} |
|
4721
|
|
|
|
|
4722
|
|
|
|
|
4723
|
|
|
/** |
|
4724
|
|
|
* Gets all aircraft manufacturer that have flown over by airline icao |
|
4725
|
|
|
* |
|
4726
|
|
|
* @return Array the aircraft list |
|
4727
|
|
|
* |
|
4728
|
|
|
*/ |
|
4729
|
|
|
public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array()) |
|
4730
|
|
|
{ |
|
4731
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4732
|
|
|
$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
4733
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
4734
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao |
|
4735
|
|
|
GROUP BY spotter_output.aircraft_manufacturer |
|
4736
|
|
|
ORDER BY aircraft_manufacturer_count DESC"; |
|
4737
|
|
|
|
|
4738
|
|
|
$sth = $this->db->prepare($query); |
|
4739
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao)); |
|
4740
|
|
|
|
|
4741
|
|
|
$aircraft_array = array(); |
|
4742
|
|
|
$temp_array = array(); |
|
4743
|
|
|
|
|
4744
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4745
|
|
|
{ |
|
4746
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
4747
|
|
|
$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
|
4748
|
|
|
|
|
4749
|
|
|
$aircraft_array[] = $temp_array; |
|
4750
|
|
|
} |
|
4751
|
|
|
return $aircraft_array; |
|
4752
|
|
|
} |
|
4753
|
|
|
|
|
4754
|
|
|
|
|
4755
|
|
|
/** |
|
4756
|
|
|
* Gets all aircraft types that have flown over by airline icao |
|
4757
|
|
|
* |
|
4758
|
|
|
* @return Array the aircraft list |
|
4759
|
|
|
* |
|
4760
|
|
|
*/ |
|
4761
|
|
|
public function countAllAircraftTypesByAirport($airport_icao,$filters = array()) |
|
4762
|
|
|
{ |
|
4763
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4764
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
4765
|
|
|
|
|
4766
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
4767
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
|
4768
|
|
|
GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
|
4769
|
|
|
ORDER BY aircraft_icao_count DESC"; |
|
4770
|
|
|
|
|
4771
|
|
|
$sth = $this->db->prepare($query); |
|
4772
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao)); |
|
4773
|
|
|
|
|
4774
|
|
|
$aircraft_array = array(); |
|
4775
|
|
|
$temp_array = array(); |
|
4776
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4777
|
|
|
{ |
|
4778
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4779
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4780
|
|
|
$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
|
4781
|
|
|
|
|
4782
|
|
|
$aircraft_array[] = $temp_array; |
|
4783
|
|
|
} |
|
4784
|
|
|
return $aircraft_array; |
|
4785
|
|
|
} |
|
4786
|
|
|
|
|
4787
|
|
|
|
|
4788
|
|
|
/** |
|
4789
|
|
|
* Gets all aircraft registration that have flown over by airport icao |
|
4790
|
|
|
* |
|
4791
|
|
|
* @return Array the aircraft list |
|
4792
|
|
|
* |
|
4793
|
|
|
*/ |
|
4794
|
|
|
public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array()) |
|
4795
|
|
|
{ |
|
4796
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4797
|
|
|
$Image = new Image($this->db); |
|
4798
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
4799
|
|
|
|
|
4800
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
4801
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
|
4802
|
|
|
GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
4803
|
|
|
ORDER BY registration_count DESC"; |
|
4804
|
|
|
|
|
4805
|
|
|
$sth = $this->db->prepare($query); |
|
4806
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao)); |
|
4807
|
|
|
|
|
4808
|
|
|
$aircraft_array = array(); |
|
4809
|
|
|
$temp_array = array(); |
|
4810
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4811
|
|
|
{ |
|
4812
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4813
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4814
|
|
|
$temp_array['registration'] = $row['registration']; |
|
4815
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
4816
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
4817
|
|
|
if($row['registration'] != "") |
|
4818
|
|
|
{ |
|
4819
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
4820
|
|
|
if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4821
|
|
|
} |
|
4822
|
|
|
$temp_array['registration_count'] = $row['registration_count']; |
|
4823
|
|
|
$aircraft_array[] = $temp_array; |
|
4824
|
|
|
} |
|
4825
|
|
|
return $aircraft_array; |
|
4826
|
|
|
} |
|
4827
|
|
|
|
|
4828
|
|
|
|
|
4829
|
|
|
/** |
|
4830
|
|
|
* Gets all aircraft manufacturer that have flown over by airport icao |
|
4831
|
|
|
* |
|
4832
|
|
|
* @return Array the aircraft list |
|
4833
|
|
|
* |
|
4834
|
|
|
*/ |
|
4835
|
|
|
public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array()) |
|
4836
|
|
|
{ |
|
4837
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4838
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
4839
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
4840
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
|
4841
|
|
|
GROUP BY spotter_output.aircraft_manufacturer |
|
4842
|
|
|
ORDER BY aircraft_manufacturer_count DESC"; |
|
4843
|
|
|
|
|
4844
|
|
|
|
|
4845
|
|
|
$sth = $this->db->prepare($query); |
|
4846
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao)); |
|
4847
|
|
|
|
|
4848
|
|
|
$aircraft_array = array(); |
|
4849
|
|
|
$temp_array = array(); |
|
4850
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4851
|
|
|
{ |
|
4852
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
4853
|
|
|
$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
|
4854
|
|
|
$aircraft_array[] = $temp_array; |
|
4855
|
|
|
} |
|
4856
|
|
|
return $aircraft_array; |
|
4857
|
|
|
} |
|
4858
|
|
|
|
|
4859
|
|
|
/** |
|
4860
|
|
|
* Gets all aircraft types that have flown over by aircraft manufacturer |
|
4861
|
|
|
* |
|
4862
|
|
|
* @return Array the aircraft list |
|
4863
|
|
|
* |
|
4864
|
|
|
*/ |
|
4865
|
|
|
public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array()) |
|
4866
|
|
|
{ |
|
4867
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4868
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
4869
|
|
|
|
|
4870
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
4871
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
4872
|
|
|
GROUP BY spotter_output.aircraft_name |
|
4873
|
|
|
ORDER BY aircraft_icao_count DESC"; |
|
4874
|
|
|
|
|
4875
|
|
|
$sth = $this->db->prepare($query); |
|
4876
|
|
|
$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
4877
|
|
|
$aircraft_array = array(); |
|
4878
|
|
|
$temp_array = array(); |
|
4879
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4880
|
|
|
{ |
|
4881
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4882
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4883
|
|
|
$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
|
4884
|
|
|
$aircraft_array[] = $temp_array; |
|
4885
|
|
|
} |
|
4886
|
|
|
return $aircraft_array; |
|
4887
|
|
|
} |
|
4888
|
|
|
|
|
4889
|
|
|
|
|
4890
|
|
|
/** |
|
4891
|
|
|
* Gets all aircraft registration that have flown over by aircaft manufacturer |
|
4892
|
|
|
* |
|
4893
|
|
|
* @return Array the aircraft list |
|
4894
|
|
|
* |
|
4895
|
|
|
*/ |
|
4896
|
|
|
public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array()) |
|
4897
|
|
|
{ |
|
4898
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4899
|
|
|
$Image = new Image($this->db); |
|
4900
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
4901
|
|
|
|
|
4902
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
4903
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
4904
|
|
|
GROUP BY spotter_output.registration |
|
4905
|
|
|
ORDER BY registration_count DESC"; |
|
4906
|
|
|
|
|
4907
|
|
|
|
|
4908
|
|
|
$sth = $this->db->prepare($query); |
|
4909
|
|
|
$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
4910
|
|
|
$aircraft_array = array(); |
|
4911
|
|
|
$temp_array = array(); |
|
4912
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4913
|
|
|
{ |
|
4914
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4915
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4916
|
|
|
$temp_array['registration'] = $row['registration']; |
|
4917
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
4918
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
4919
|
|
|
if($row['registration'] != "") |
|
4920
|
|
|
{ |
|
4921
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
4922
|
|
|
$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4923
|
|
|
} |
|
4924
|
|
|
$temp_array['registration_count'] = $row['registration_count']; |
|
4925
|
|
|
$aircraft_array[] = $temp_array; |
|
4926
|
|
|
} |
|
4927
|
|
|
return $aircraft_array; |
|
4928
|
|
|
} |
|
4929
|
|
|
|
|
4930
|
|
|
/** |
|
4931
|
|
|
* Gets all aircraft types that have flown over by date |
|
4932
|
|
|
* |
|
4933
|
|
|
* @return Array the aircraft list |
|
4934
|
|
|
* |
|
4935
|
|
|
*/ |
|
4936
|
|
|
public function countAllAircraftTypesByDate($date,$filters = array()) |
|
4937
|
|
|
{ |
|
4938
|
|
|
global $globalTimezone, $globalDBdriver; |
|
4939
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4940
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
4941
|
|
|
if ($globalTimezone != '') { |
|
4942
|
|
|
date_default_timezone_set($globalTimezone); |
|
4943
|
|
|
$datetime = new DateTime($date); |
|
4944
|
|
|
$offset = $datetime->format('P'); |
|
4945
|
|
|
} else $offset = '+00:00'; |
|
4946
|
|
|
|
|
4947
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4948
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
4949
|
|
|
FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
4950
|
|
|
GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
|
4951
|
|
|
ORDER BY aircraft_icao_count DESC"; |
|
4952
|
|
|
} else { |
|
4953
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
4954
|
|
|
FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
|
4955
|
|
|
GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
|
4956
|
|
|
ORDER BY aircraft_icao_count DESC"; |
|
4957
|
|
|
} |
|
4958
|
|
|
|
|
4959
|
|
|
$sth = $this->db->prepare($query); |
|
4960
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
4961
|
|
|
|
|
4962
|
|
|
$aircraft_array = array(); |
|
4963
|
|
|
$temp_array = array(); |
|
4964
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
4965
|
|
|
{ |
|
4966
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
4967
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
4968
|
|
|
$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
|
4969
|
|
|
|
|
4970
|
|
|
$aircraft_array[] = $temp_array; |
|
4971
|
|
|
} |
|
4972
|
|
|
return $aircraft_array; |
|
4973
|
|
|
} |
|
4974
|
|
|
|
|
4975
|
|
|
|
|
4976
|
|
|
/** |
|
4977
|
|
|
* Gets all aircraft registration that have flown over by date |
|
4978
|
|
|
* |
|
4979
|
|
|
* @return Array the aircraft list |
|
4980
|
|
|
* |
|
4981
|
|
|
*/ |
|
4982
|
|
|
public function countAllAircraftRegistrationByDate($date,$filters = array()) |
|
4983
|
|
|
{ |
|
4984
|
|
|
global $globalTimezone, $globalDBdriver; |
|
4985
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
4986
|
|
|
$Image = new Image($this->db); |
|
4987
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
4988
|
|
|
if ($globalTimezone != '') { |
|
4989
|
|
|
date_default_timezone_set($globalTimezone); |
|
4990
|
|
|
$datetime = new DateTime($date); |
|
4991
|
|
|
$offset = $datetime->format('P'); |
|
4992
|
|
|
} else $offset = '+00:00'; |
|
4993
|
|
|
|
|
4994
|
|
|
if ($globalDBdriver == 'mysql') { |
|
4995
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
4996
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
4997
|
|
|
GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
4998
|
|
|
ORDER BY registration_count DESC"; |
|
4999
|
|
|
} else { |
|
5000
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
5001
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
|
5002
|
|
|
GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
5003
|
|
|
ORDER BY registration_count DESC"; |
|
5004
|
|
|
} |
|
5005
|
|
|
|
|
5006
|
|
|
$sth = $this->db->prepare($query); |
|
5007
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
5008
|
|
|
|
|
5009
|
|
|
$aircraft_array = array(); |
|
5010
|
|
|
$temp_array = array(); |
|
5011
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5012
|
|
|
{ |
|
5013
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
5014
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
5015
|
|
|
$temp_array['registration'] = $row['registration']; |
|
5016
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
5017
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
5018
|
|
|
if($row['registration'] != "") |
|
5019
|
|
|
{ |
|
5020
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
5021
|
|
|
if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5022
|
|
|
} |
|
5023
|
|
|
$temp_array['registration_count'] = $row['registration_count']; |
|
5024
|
|
|
|
|
5025
|
|
|
$aircraft_array[] = $temp_array; |
|
5026
|
|
|
} |
|
5027
|
|
|
return $aircraft_array; |
|
5028
|
|
|
} |
|
5029
|
|
|
|
|
5030
|
|
|
|
|
5031
|
|
|
/** |
|
5032
|
|
|
* Gets all aircraft manufacturer that have flown over by date |
|
5033
|
|
|
* |
|
5034
|
|
|
* @return Array the aircraft manufacturer list |
|
5035
|
|
|
* |
|
5036
|
|
|
*/ |
|
5037
|
|
|
public function countAllAircraftManufacturerByDate($date,$filters = array()) |
|
5038
|
|
|
{ |
|
5039
|
|
|
global $globalTimezone, $globalDBdriver; |
|
5040
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5041
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
5042
|
|
|
if ($globalTimezone != '') { |
|
5043
|
|
|
date_default_timezone_set($globalTimezone); |
|
5044
|
|
|
$datetime = new DateTime($date); |
|
5045
|
|
|
$offset = $datetime->format('P'); |
|
5046
|
|
|
} else $offset = '+00:00'; |
|
5047
|
|
|
|
|
5048
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5049
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
5050
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
5051
|
|
|
GROUP BY spotter_output.aircraft_manufacturer |
|
5052
|
|
|
ORDER BY aircraft_manufacturer_count DESC"; |
|
5053
|
|
|
} else { |
|
5054
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
5055
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
|
5056
|
|
|
GROUP BY spotter_output.aircraft_manufacturer |
|
5057
|
|
|
ORDER BY aircraft_manufacturer_count DESC"; |
|
5058
|
|
|
} |
|
5059
|
|
|
|
|
5060
|
|
|
$sth = $this->db->prepare($query); |
|
5061
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
5062
|
|
|
|
|
5063
|
|
|
$aircraft_array = array(); |
|
5064
|
|
|
$temp_array = array(); |
|
5065
|
|
|
|
|
5066
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5067
|
|
|
{ |
|
5068
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
5069
|
|
|
$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
|
5070
|
|
|
|
|
5071
|
|
|
$aircraft_array[] = $temp_array; |
|
5072
|
|
|
} |
|
5073
|
|
|
return $aircraft_array; |
|
5074
|
|
|
} |
|
5075
|
|
|
|
|
5076
|
|
|
|
|
5077
|
|
|
/** |
|
5078
|
|
|
* Gets all aircraft types that have flown over by ident/callsign |
|
5079
|
|
|
* |
|
5080
|
|
|
* @return Array the aircraft list |
|
5081
|
|
|
* |
|
5082
|
|
|
*/ |
|
5083
|
|
|
public function countAllAircraftTypesByIdent($ident,$filters = array()) |
|
5084
|
|
|
{ |
|
5085
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5086
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
5087
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
5088
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident = :ident |
|
5089
|
|
|
GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
|
5090
|
|
|
ORDER BY aircraft_icao_count DESC"; |
|
5091
|
|
|
|
|
5092
|
|
|
$sth = $this->db->prepare($query); |
|
5093
|
|
|
$sth->execute(array(':ident' => $ident)); |
|
5094
|
|
|
|
|
5095
|
|
|
$aircraft_array = array(); |
|
5096
|
|
|
$temp_array = array(); |
|
5097
|
|
|
|
|
5098
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5099
|
|
|
{ |
|
5100
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
5101
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
5102
|
|
|
$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
|
5103
|
|
|
|
|
5104
|
|
|
$aircraft_array[] = $temp_array; |
|
5105
|
|
|
} |
|
5106
|
|
|
return $aircraft_array; |
|
5107
|
|
|
} |
|
5108
|
|
|
|
|
5109
|
|
|
|
|
5110
|
|
|
/** |
|
5111
|
|
|
* Gets all aircraft registration that have flown over by ident/callsign |
|
5112
|
|
|
* |
|
5113
|
|
|
* @return Array the aircraft list |
|
5114
|
|
|
* |
|
5115
|
|
|
*/ |
|
5116
|
|
|
public function countAllAircraftRegistrationByIdent($ident,$filters = array()) |
|
5117
|
|
|
{ |
|
5118
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5119
|
|
|
$Image = new Image($this->db); |
|
5120
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
5121
|
|
|
|
|
5122
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
5123
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident |
|
5124
|
|
|
GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
5125
|
|
|
ORDER BY registration_count DESC"; |
|
5126
|
|
|
|
|
5127
|
|
|
|
|
5128
|
|
|
$sth = $this->db->prepare($query); |
|
5129
|
|
|
$sth->execute(array(':ident' => $ident)); |
|
5130
|
|
|
|
|
5131
|
|
|
$aircraft_array = array(); |
|
5132
|
|
|
$temp_array = array(); |
|
5133
|
|
|
|
|
5134
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5135
|
|
|
{ |
|
5136
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
5137
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
5138
|
|
|
$temp_array['registration'] = $row['registration']; |
|
5139
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
5140
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
5141
|
|
|
if($row['registration'] != "") |
|
5142
|
|
|
{ |
|
5143
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
5144
|
|
|
if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5145
|
|
|
else $temp_array['image_thumbnail'] = ''; |
|
5146
|
|
|
} |
|
5147
|
|
|
$temp_array['registration_count'] = $row['registration_count']; |
|
5148
|
|
|
$aircraft_array[] = $temp_array; |
|
5149
|
|
|
} |
|
5150
|
|
|
return $aircraft_array; |
|
5151
|
|
|
} |
|
5152
|
|
|
|
|
5153
|
|
|
|
|
5154
|
|
|
/** |
|
5155
|
|
|
* Gets all aircraft manufacturer that have flown over by ident/callsign |
|
5156
|
|
|
* |
|
5157
|
|
|
* @return Array the aircraft manufacturer list |
|
5158
|
|
|
* |
|
5159
|
|
|
*/ |
|
5160
|
|
|
public function countAllAircraftManufacturerByIdent($ident,$filters = array()) |
|
5161
|
|
|
{ |
|
5162
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5163
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
5164
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
5165
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident |
|
5166
|
|
|
GROUP BY spotter_output.aircraft_manufacturer |
|
5167
|
|
|
ORDER BY aircraft_manufacturer_count DESC"; |
|
5168
|
|
|
|
|
5169
|
|
|
|
|
5170
|
|
|
$sth = $this->db->prepare($query); |
|
5171
|
|
|
$sth->execute(array(':ident' => $ident)); |
|
5172
|
|
|
$aircraft_array = array(); |
|
5173
|
|
|
$temp_array = array(); |
|
5174
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5175
|
|
|
{ |
|
5176
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
5177
|
|
|
$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
|
5178
|
|
|
$aircraft_array[] = $temp_array; |
|
5179
|
|
|
} |
|
5180
|
|
|
return $aircraft_array; |
|
5181
|
|
|
} |
|
5182
|
|
|
|
|
5183
|
|
|
|
|
5184
|
|
|
/** |
|
5185
|
|
|
* Gets all aircraft types that have flown over by route |
|
5186
|
|
|
* |
|
5187
|
|
|
* @return Array the aircraft list |
|
5188
|
|
|
* |
|
5189
|
|
|
*/ |
|
5190
|
|
|
public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
|
5191
|
|
|
{ |
|
5192
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5193
|
|
|
$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
5194
|
|
|
$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
5195
|
|
|
|
|
5196
|
|
|
|
|
5197
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
5198
|
|
|
FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
|
5199
|
|
|
GROUP BY spotter_output.aircraft_name |
|
5200
|
|
|
ORDER BY aircraft_icao_count DESC"; |
|
5201
|
|
|
|
|
5202
|
|
|
|
|
5203
|
|
|
$sth = $this->db->prepare($query); |
|
5204
|
|
|
$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
|
5205
|
|
|
$aircraft_array = array(); |
|
5206
|
|
|
$temp_array = array(); |
|
5207
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5208
|
|
|
{ |
|
5209
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
5210
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
5211
|
|
|
$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
|
5212
|
|
|
$aircraft_array[] = $temp_array; |
|
5213
|
|
|
} |
|
5214
|
|
|
return $aircraft_array; |
|
5215
|
|
|
} |
|
5216
|
|
|
|
|
5217
|
|
|
/** |
|
5218
|
|
|
* Gets all aircraft registration that have flown over by route |
|
5219
|
|
|
* |
|
5220
|
|
|
* @return Array the aircraft list |
|
5221
|
|
|
* |
|
5222
|
|
|
*/ |
|
5223
|
|
|
public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
|
5224
|
|
|
{ |
|
5225
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5226
|
|
|
$Image = new Image($this->db); |
|
5227
|
|
|
$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
5228
|
|
|
$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
5229
|
|
|
|
|
5230
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
5231
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
|
5232
|
|
|
GROUP BY spotter_output.registration |
|
5233
|
|
|
ORDER BY registration_count DESC"; |
|
5234
|
|
|
|
|
5235
|
|
|
|
|
5236
|
|
|
$sth = $this->db->prepare($query); |
|
5237
|
|
|
$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
|
5238
|
|
|
|
|
5239
|
|
|
$aircraft_array = array(); |
|
5240
|
|
|
$temp_array = array(); |
|
5241
|
|
|
|
|
5242
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5243
|
|
|
{ |
|
5244
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
5245
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
5246
|
|
|
$temp_array['registration'] = $row['registration']; |
|
5247
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
5248
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
5249
|
|
|
if($row['registration'] != "") |
|
5250
|
|
|
{ |
|
5251
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
5252
|
|
|
if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5253
|
|
|
} |
|
5254
|
|
|
$temp_array['registration_count'] = $row['registration_count']; |
|
5255
|
|
|
|
|
5256
|
|
|
$aircraft_array[] = $temp_array; |
|
5257
|
|
|
} |
|
5258
|
|
|
|
|
5259
|
|
|
return $aircraft_array; |
|
5260
|
|
|
} |
|
5261
|
|
|
|
|
5262
|
|
|
|
|
5263
|
|
|
/** |
|
5264
|
|
|
* Gets all aircraft manufacturer that have flown over by route |
|
5265
|
|
|
* |
|
5266
|
|
|
* @return Array the aircraft manufacturer list |
|
5267
|
|
|
* |
|
5268
|
|
|
*/ |
|
5269
|
|
|
public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
|
5270
|
|
|
{ |
|
5271
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5272
|
|
|
$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
5273
|
|
|
$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
5274
|
|
|
|
|
5275
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
5276
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
|
5277
|
|
|
GROUP BY spotter_output.aircraft_manufacturer |
|
5278
|
|
|
ORDER BY aircraft_manufacturer_count DESC"; |
|
5279
|
|
|
|
|
5280
|
|
|
|
|
5281
|
|
|
$sth = $this->db->prepare($query); |
|
5282
|
|
|
$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
|
5283
|
|
|
|
|
5284
|
|
|
$aircraft_array = array(); |
|
5285
|
|
|
$temp_array = array(); |
|
5286
|
|
|
|
|
5287
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5288
|
|
|
{ |
|
5289
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
5290
|
|
|
$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
|
5291
|
|
|
|
|
5292
|
|
|
$aircraft_array[] = $temp_array; |
|
5293
|
|
|
} |
|
5294
|
|
|
|
|
5295
|
|
|
return $aircraft_array; |
|
5296
|
|
|
} |
|
5297
|
|
|
|
|
5298
|
|
|
|
|
5299
|
|
|
|
|
5300
|
|
|
|
|
5301
|
|
|
/** |
|
5302
|
|
|
* Gets all aircraft types that have flown over by country |
|
5303
|
|
|
* |
|
5304
|
|
|
* @return Array the aircraft list |
|
5305
|
|
|
* |
|
5306
|
|
|
*/ |
|
5307
|
|
|
public function countAllAircraftTypesByCountry($country,$filters = array()) |
|
5308
|
|
|
{ |
|
5309
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5310
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
5311
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
5312
|
|
|
FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
|
5313
|
|
|
GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
|
5314
|
|
|
ORDER BY aircraft_icao_count DESC"; |
|
5315
|
|
|
|
|
5316
|
|
|
|
|
5317
|
|
|
$sth = $this->db->prepare($query); |
|
5318
|
|
|
$sth->execute(array(':country' => $country)); |
|
5319
|
|
|
|
|
5320
|
|
|
$aircraft_array = array(); |
|
5321
|
|
|
$temp_array = array(); |
|
5322
|
|
|
|
|
5323
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5324
|
|
|
{ |
|
5325
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
5326
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
5327
|
|
|
$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
|
5328
|
|
|
|
|
5329
|
|
|
$aircraft_array[] = $temp_array; |
|
5330
|
|
|
} |
|
5331
|
|
|
|
|
5332
|
|
|
return $aircraft_array; |
|
5333
|
|
|
} |
|
5334
|
|
|
|
|
5335
|
|
|
|
|
5336
|
|
|
/** |
|
5337
|
|
|
* Gets all aircraft registration that have flown over by country |
|
5338
|
|
|
* |
|
5339
|
|
|
* @return Array the aircraft list |
|
5340
|
|
|
* |
|
5341
|
|
|
*/ |
|
5342
|
|
|
public function countAllAircraftRegistrationByCountry($country,$filters = array()) |
|
5343
|
|
|
{ |
|
5344
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5345
|
|
|
$Image = new Image($this->db); |
|
5346
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
5347
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
5348
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) |
|
5349
|
|
|
GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
5350
|
|
|
ORDER BY registration_count DESC"; |
|
5351
|
|
|
|
|
5352
|
|
|
|
|
5353
|
|
|
$sth = $this->db->prepare($query); |
|
5354
|
|
|
$sth->execute(array(':country' => $country)); |
|
5355
|
|
|
|
|
5356
|
|
|
$aircraft_array = array(); |
|
5357
|
|
|
$temp_array = array(); |
|
5358
|
|
|
|
|
5359
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5360
|
|
|
{ |
|
5361
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
5362
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
5363
|
|
|
$temp_array['registration'] = $row['registration']; |
|
5364
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
5365
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
5366
|
|
|
if($row['registration'] != "") |
|
5367
|
|
|
{ |
|
5368
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
5369
|
|
|
if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5370
|
|
|
} |
|
5371
|
|
|
$temp_array['registration_count'] = $row['registration_count']; |
|
5372
|
|
|
|
|
5373
|
|
|
$aircraft_array[] = $temp_array; |
|
5374
|
|
|
} |
|
5375
|
|
|
|
|
5376
|
|
|
return $aircraft_array; |
|
5377
|
|
|
} |
|
5378
|
|
|
|
|
5379
|
|
|
|
|
5380
|
|
|
/** |
|
5381
|
|
|
* Gets all aircraft manufacturer that have flown over by country |
|
5382
|
|
|
* |
|
5383
|
|
|
* @return Array the aircraft manufacturer list |
|
5384
|
|
|
* |
|
5385
|
|
|
*/ |
|
5386
|
|
|
public function countAllAircraftManufacturerByCountry($country,$filters = array()) |
|
5387
|
|
|
{ |
|
5388
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5389
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
5390
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
5391
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) |
|
5392
|
|
|
GROUP BY spotter_output.aircraft_manufacturer |
|
5393
|
|
|
ORDER BY aircraft_manufacturer_count DESC"; |
|
5394
|
|
|
|
|
5395
|
|
|
|
|
5396
|
|
|
$sth = $this->db->prepare($query); |
|
5397
|
|
|
$sth->execute(array(':country' => $country)); |
|
5398
|
|
|
|
|
5399
|
|
|
$aircraft_array = array(); |
|
5400
|
|
|
$temp_array = array(); |
|
5401
|
|
|
|
|
5402
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5403
|
|
|
{ |
|
5404
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
5405
|
|
|
$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
|
5406
|
|
|
|
|
5407
|
|
|
$aircraft_array[] = $temp_array; |
|
5408
|
|
|
} |
|
5409
|
|
|
|
|
5410
|
|
|
return $aircraft_array; |
|
5411
|
|
|
} |
|
5412
|
|
|
|
|
5413
|
|
|
|
|
5414
|
|
|
|
|
5415
|
|
|
/** |
|
5416
|
|
|
* Gets all aircraft manufacturers that have flown over |
|
5417
|
|
|
* |
|
5418
|
|
|
* @return Array the aircraft list |
|
5419
|
|
|
* |
|
5420
|
|
|
*/ |
|
5421
|
|
|
public function countAllAircraftManufacturers($filters = array()) |
|
5422
|
|
|
{ |
|
5423
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5424
|
|
|
$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
5425
|
|
|
FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'"; |
|
5426
|
|
|
$query .= " GROUP BY spotter_output.aircraft_manufacturer |
|
5427
|
|
|
ORDER BY aircraft_manufacturer_count DESC |
|
5428
|
|
|
LIMIT 10"; |
|
5429
|
|
|
|
|
5430
|
|
|
|
|
5431
|
|
|
$sth = $this->db->prepare($query); |
|
5432
|
|
|
$sth->execute(); |
|
5433
|
|
|
|
|
5434
|
|
|
$manufacturer_array = array(); |
|
5435
|
|
|
$temp_array = array(); |
|
5436
|
|
|
|
|
5437
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5438
|
|
|
{ |
|
5439
|
|
|
$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
|
5440
|
|
|
$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
|
5441
|
|
|
|
|
5442
|
|
|
$manufacturer_array[] = $temp_array; |
|
5443
|
|
|
} |
|
5444
|
|
|
|
|
5445
|
|
|
return $manufacturer_array; |
|
5446
|
|
|
} |
|
5447
|
|
|
|
|
5448
|
|
|
|
|
5449
|
|
|
|
|
5450
|
|
|
/** |
|
5451
|
|
|
* Gets all aircraft registrations that have flown over |
|
5452
|
|
|
* |
|
5453
|
|
|
* @return Array the aircraft list |
|
5454
|
|
|
* |
|
5455
|
|
|
*/ |
|
5456
|
|
|
public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
5457
|
|
|
{ |
|
5458
|
|
|
global $globalDBdriver; |
|
5459
|
|
|
$Image = new Image($this->db); |
|
5460
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5461
|
|
|
$query = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
5462
|
|
|
FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'"; |
|
5463
|
|
|
if ($olderthanmonths > 0) { |
|
5464
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5465
|
|
|
$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
|
5466
|
|
|
} else { |
|
5467
|
|
|
$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
5468
|
|
|
} |
|
5469
|
|
|
} |
|
5470
|
|
|
if ($sincedate != '') { |
|
5471
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5472
|
|
|
$query .= " AND spotter_output.date > '".$sincedate."'"; |
|
5473
|
|
|
} else { |
|
5474
|
|
|
$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
5475
|
|
|
} |
|
5476
|
|
|
} |
|
5477
|
|
|
|
|
5478
|
|
|
// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
5479
|
|
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
5480
|
|
|
$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
|
5481
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5482
|
|
|
|
|
5483
|
|
|
$sth = $this->db->prepare($query); |
|
5484
|
|
|
$sth->execute(); |
|
5485
|
|
|
|
|
5486
|
|
|
$aircraft_array = array(); |
|
5487
|
|
|
$temp_array = array(); |
|
5488
|
|
|
|
|
5489
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5490
|
|
|
{ |
|
5491
|
|
|
$temp_array['registration'] = $row['registration']; |
|
5492
|
|
|
$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count']; |
|
5493
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
5494
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
5495
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
5496
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
5497
|
|
|
if($row['registration'] != "") |
|
5498
|
|
|
{ |
|
5499
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
5500
|
|
|
if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5501
|
|
|
} |
|
5502
|
|
|
|
|
5503
|
|
|
$aircraft_array[] = $temp_array; |
|
5504
|
|
|
} |
|
5505
|
|
|
|
|
5506
|
|
|
return $aircraft_array; |
|
5507
|
|
|
} |
|
5508
|
|
|
|
|
5509
|
|
|
|
|
5510
|
|
|
/** |
|
5511
|
|
|
* Gets all aircraft registrations that have flown over |
|
5512
|
|
|
* |
|
5513
|
|
|
* @return Array the aircraft list |
|
5514
|
|
|
* |
|
5515
|
|
|
*/ |
|
5516
|
|
|
public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
5517
|
|
|
{ |
|
5518
|
|
|
global $globalDBdriver; |
|
5519
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5520
|
|
|
$Image = new Image($this->db); |
|
5521
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
5522
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' "; |
|
5523
|
|
|
if ($olderthanmonths > 0) { |
|
5524
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5525
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
5526
|
|
|
} else { |
|
5527
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
5528
|
|
|
} |
|
5529
|
|
|
} |
|
5530
|
|
|
if ($sincedate != '') { |
|
5531
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5532
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
5533
|
|
|
} else { |
|
5534
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
5535
|
|
|
} |
|
5536
|
|
|
} |
|
5537
|
|
|
|
|
5538
|
|
|
// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
5539
|
|
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
5540
|
|
|
$query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
|
5541
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5542
|
|
|
|
|
5543
|
|
|
$sth = $this->db->prepare($query); |
|
5544
|
|
|
$sth->execute(); |
|
5545
|
|
|
|
|
5546
|
|
|
$aircraft_array = array(); |
|
5547
|
|
|
$temp_array = array(); |
|
5548
|
|
|
|
|
5549
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5550
|
|
|
{ |
|
5551
|
|
|
$temp_array['registration'] = $row['registration']; |
|
5552
|
|
|
$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count']; |
|
5553
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
5554
|
|
|
$temp_array['aircraft_icao'] = $row['aircraft_icao']; |
|
5555
|
|
|
$temp_array['aircraft_name'] = $row['aircraft_name']; |
|
5556
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
5557
|
|
|
$temp_array['image_thumbnail'] = ""; |
|
5558
|
|
|
if($row['registration'] != "") |
|
5559
|
|
|
{ |
|
5560
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
5561
|
|
|
if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5562
|
|
|
} |
|
5563
|
|
|
|
|
5564
|
|
|
$aircraft_array[] = $temp_array; |
|
5565
|
|
|
} |
|
5566
|
|
|
|
|
5567
|
|
|
return $aircraft_array; |
|
5568
|
|
|
} |
|
5569
|
|
|
|
|
5570
|
|
|
|
|
5571
|
|
|
/** |
|
5572
|
|
|
* Gets all departure airports of the airplanes that have flown over |
|
5573
|
|
|
* |
|
5574
|
|
|
* @return Array the airport list |
|
5575
|
|
|
* |
|
5576
|
|
|
*/ |
|
5577
|
|
|
public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
5578
|
|
|
{ |
|
5579
|
|
|
global $globalDBdriver; |
|
5580
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5581
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
5582
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA'"; |
|
5583
|
|
|
if ($olderthanmonths > 0) { |
|
5584
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5585
|
|
|
$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
|
5586
|
|
|
} else { |
|
5587
|
|
|
$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
5588
|
|
|
} |
|
5589
|
|
|
} |
|
5590
|
|
|
if ($sincedate != '') { |
|
5591
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5592
|
|
|
$query .= " AND spotter_output.date > '".$sincedate."'"; |
|
5593
|
|
|
} else { |
|
5594
|
|
|
$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
5595
|
|
|
} |
|
5596
|
|
|
} |
|
5597
|
|
|
|
|
5598
|
|
|
//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
5599
|
|
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
5600
|
|
|
$query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
5601
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
5602
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5603
|
|
|
|
|
5604
|
|
|
$sth = $this->db->prepare($query); |
|
5605
|
|
|
$sth->execute(); |
|
5606
|
|
|
|
|
5607
|
|
|
$airport_array = array(); |
|
5608
|
|
|
$temp_array = array(); |
|
5609
|
|
|
|
|
5610
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5611
|
|
|
{ |
|
5612
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
5613
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
5614
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
5615
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
5616
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
5617
|
|
|
|
|
5618
|
|
|
$airport_array[] = $temp_array; |
|
5619
|
|
|
} |
|
5620
|
|
|
return $airport_array; |
|
5621
|
|
|
} |
|
5622
|
|
|
|
|
5623
|
|
|
/** |
|
5624
|
|
|
* Gets all departure airports of the airplanes that have flown over |
|
5625
|
|
|
* |
|
5626
|
|
|
* @return Array the airport list |
|
5627
|
|
|
* |
|
5628
|
|
|
*/ |
|
5629
|
|
|
public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
5630
|
|
|
{ |
|
5631
|
|
|
global $globalDBdriver; |
|
5632
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5633
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
5634
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' "; |
|
5635
|
|
|
if ($olderthanmonths > 0) { |
|
5636
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5637
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
5638
|
|
|
} else { |
|
5639
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
5640
|
|
|
} |
|
5641
|
|
|
} |
|
5642
|
|
|
if ($sincedate != '') { |
|
5643
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5644
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
5645
|
|
|
} else { |
|
5646
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
5647
|
|
|
} |
|
5648
|
|
|
} |
|
5649
|
|
|
|
|
5650
|
|
|
//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
5651
|
|
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
5652
|
|
|
$query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
5653
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
5654
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5655
|
|
|
|
|
5656
|
|
|
$sth = $this->db->prepare($query); |
|
5657
|
|
|
$sth->execute(); |
|
5658
|
|
|
|
|
5659
|
|
|
$airport_array = array(); |
|
5660
|
|
|
$temp_array = array(); |
|
5661
|
|
|
|
|
5662
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5663
|
|
|
{ |
|
5664
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
5665
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
5666
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
5667
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
5668
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
5669
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
5670
|
|
|
|
|
5671
|
|
|
$airport_array[] = $temp_array; |
|
5672
|
|
|
} |
|
5673
|
|
|
return $airport_array; |
|
5674
|
|
|
} |
|
5675
|
|
|
|
|
5676
|
|
|
/** |
|
5677
|
|
|
* Gets all detected departure airports of the airplanes that have flown over |
|
5678
|
|
|
* |
|
5679
|
|
|
* @return Array the airport list |
|
5680
|
|
|
* |
|
5681
|
|
|
*/ |
|
5682
|
|
|
public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
5683
|
|
|
{ |
|
5684
|
|
|
global $globalDBdriver; |
|
5685
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5686
|
|
|
$query = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country |
|
5687
|
|
|
FROM airport, spotter_output".$filter_query." spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao"; |
|
5688
|
|
|
if ($olderthanmonths > 0) { |
|
5689
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5690
|
|
|
$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
|
5691
|
|
|
} else { |
|
5692
|
|
|
$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
5693
|
|
|
} |
|
5694
|
|
|
} |
|
5695
|
|
|
if ($sincedate != '') { |
|
5696
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5697
|
|
|
$query .= " AND spotter_output.date > '".$sincedate."'"; |
|
5698
|
|
|
} else { |
|
5699
|
|
|
$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
5700
|
|
|
} |
|
5701
|
|
|
} |
|
5702
|
|
|
//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
5703
|
|
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
5704
|
|
|
$query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
|
5705
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
5706
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5707
|
|
|
//echo $query; |
|
5708
|
|
|
$sth = $this->db->prepare($query); |
|
5709
|
|
|
$sth->execute(); |
|
5710
|
|
|
|
|
5711
|
|
|
$airport_array = array(); |
|
5712
|
|
|
$temp_array = array(); |
|
5713
|
|
|
|
|
5714
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5715
|
|
|
{ |
|
5716
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
5717
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
5718
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
5719
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
5720
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
5721
|
|
|
|
|
5722
|
|
|
$airport_array[] = $temp_array; |
|
5723
|
|
|
} |
|
5724
|
|
|
return $airport_array; |
|
5725
|
|
|
} |
|
5726
|
|
|
|
|
5727
|
|
|
/** |
|
5728
|
|
|
* Gets all detected departure airports of the airplanes that have flown over |
|
5729
|
|
|
* |
|
5730
|
|
|
* @return Array the airport list |
|
5731
|
|
|
* |
|
5732
|
|
|
*/ |
|
5733
|
|
|
public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
5734
|
|
|
{ |
|
5735
|
|
|
global $globalDBdriver; |
|
5736
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5737
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country |
|
5738
|
|
|
FROM airport, spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao "; |
|
5739
|
|
|
if ($olderthanmonths > 0) { |
|
5740
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5741
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
5742
|
|
|
} else { |
|
5743
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
5744
|
|
|
} |
|
5745
|
|
|
} |
|
5746
|
|
|
if ($sincedate != '') { |
|
5747
|
|
|
if ($globalDBdriver == 'mysql') { |
|
5748
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
5749
|
|
|
} else { |
|
5750
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
5751
|
|
|
} |
|
5752
|
|
|
} |
|
5753
|
|
|
|
|
5754
|
|
|
//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
5755
|
|
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
5756
|
|
|
$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
|
5757
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
5758
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5759
|
|
|
|
|
5760
|
|
|
$sth = $this->db->prepare($query); |
|
5761
|
|
|
$sth->execute(); |
|
5762
|
|
|
|
|
5763
|
|
|
$airport_array = array(); |
|
5764
|
|
|
$temp_array = array(); |
|
5765
|
|
|
|
|
5766
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5767
|
|
|
{ |
|
5768
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
5769
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
5770
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
5771
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
5772
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
5773
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
5774
|
|
|
|
|
5775
|
|
|
$airport_array[] = $temp_array; |
|
5776
|
|
|
} |
|
5777
|
|
|
return $airport_array; |
|
5778
|
|
|
} |
|
5779
|
|
|
|
|
5780
|
|
|
/** |
|
5781
|
|
|
* Gets all departure airports of the airplanes that have flown over based on an airline icao |
|
5782
|
|
|
* |
|
5783
|
|
|
* @return Array the airport list |
|
5784
|
|
|
* |
|
5785
|
|
|
*/ |
|
5786
|
|
|
public function countAllDepartureAirportsByAirline($airline_icao,$filters = array()) |
|
5787
|
|
|
{ |
|
5788
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5789
|
|
|
$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
5790
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
5791
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao |
|
5792
|
|
|
GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
5793
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
5794
|
|
|
|
|
5795
|
|
|
|
|
5796
|
|
|
$sth = $this->db->prepare($query); |
|
5797
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao)); |
|
5798
|
|
|
|
|
5799
|
|
|
$airport_array = array(); |
|
5800
|
|
|
$temp_array = array(); |
|
5801
|
|
|
|
|
5802
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5803
|
|
|
{ |
|
5804
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
5805
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
5806
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
5807
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
5808
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
5809
|
|
|
|
|
5810
|
|
|
$airport_array[] = $temp_array; |
|
5811
|
|
|
} |
|
5812
|
|
|
|
|
5813
|
|
|
return $airport_array; |
|
5814
|
|
|
} |
|
5815
|
|
|
|
|
5816
|
|
|
|
|
5817
|
|
|
|
|
5818
|
|
|
/** |
|
5819
|
|
|
* Gets all departure airports by country of the airplanes that have flown over based on an airline icao |
|
5820
|
|
|
* |
|
5821
|
|
|
* @return Array the airport list |
|
5822
|
|
|
* |
|
5823
|
|
|
*/ |
|
5824
|
|
|
public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array()) |
|
5825
|
|
|
{ |
|
5826
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5827
|
|
|
$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
5828
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
5829
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao |
|
5830
|
|
|
GROUP BY spotter_output.departure_airport_country |
|
5831
|
|
|
ORDER BY airport_departure_country_count DESC"; |
|
5832
|
|
|
|
|
5833
|
|
|
|
|
5834
|
|
|
$sth = $this->db->prepare($query); |
|
5835
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao)); |
|
5836
|
|
|
|
|
5837
|
|
|
$airport_array = array(); |
|
5838
|
|
|
$temp_array = array(); |
|
5839
|
|
|
|
|
5840
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5841
|
|
|
{ |
|
5842
|
|
|
$temp_array['departure_airport_country'] = $row['departure_airport_country']; |
|
5843
|
|
|
$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
|
5844
|
|
|
|
|
5845
|
|
|
$airport_array[] = $temp_array; |
|
5846
|
|
|
} |
|
5847
|
|
|
|
|
5848
|
|
|
return $airport_array; |
|
5849
|
|
|
} |
|
5850
|
|
|
|
|
5851
|
|
|
|
|
5852
|
|
|
|
|
5853
|
|
|
/** |
|
5854
|
|
|
* Gets all departure airports of the airplanes that have flown over based on an aircraft icao |
|
5855
|
|
|
* |
|
5856
|
|
|
* @return Array the airport list |
|
5857
|
|
|
* |
|
5858
|
|
|
*/ |
|
5859
|
|
|
public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array()) |
|
5860
|
|
|
{ |
|
5861
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5862
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
5863
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
5864
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao |
|
5865
|
|
|
GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
5866
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
5867
|
|
|
|
|
5868
|
|
|
|
|
5869
|
|
|
$sth = $this->db->prepare($query); |
|
5870
|
|
|
$sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
|
5871
|
|
|
|
|
5872
|
|
|
$airport_array = array(); |
|
5873
|
|
|
$temp_array = array(); |
|
5874
|
|
|
|
|
5875
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5876
|
|
|
{ |
|
5877
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
5878
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
5879
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
5880
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
5881
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
5882
|
|
|
|
|
5883
|
|
|
$airport_array[] = $temp_array; |
|
5884
|
|
|
} |
|
5885
|
|
|
|
|
5886
|
|
|
return $airport_array; |
|
5887
|
|
|
} |
|
5888
|
|
|
|
|
5889
|
|
|
|
|
5890
|
|
|
/** |
|
5891
|
|
|
* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao |
|
5892
|
|
|
* |
|
5893
|
|
|
* @return Array the airport list |
|
5894
|
|
|
* |
|
5895
|
|
|
*/ |
|
5896
|
|
|
public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array()) |
|
5897
|
|
|
{ |
|
5898
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5899
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
5900
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
5901
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
|
5902
|
|
|
GROUP BY spotter_output.departure_airport_country |
|
5903
|
|
|
ORDER BY airport_departure_country_count DESC"; |
|
5904
|
|
|
|
|
5905
|
|
|
|
|
5906
|
|
|
$sth = $this->db->prepare($query); |
|
5907
|
|
|
$sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
|
5908
|
|
|
|
|
5909
|
|
|
$airport_array = array(); |
|
5910
|
|
|
$temp_array = array(); |
|
5911
|
|
|
|
|
5912
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5913
|
|
|
{ |
|
5914
|
|
|
$temp_array['departure_airport_country'] = $row['departure_airport_country']; |
|
5915
|
|
|
$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
|
5916
|
|
|
|
|
5917
|
|
|
$airport_array[] = $temp_array; |
|
5918
|
|
|
} |
|
5919
|
|
|
|
|
5920
|
|
|
return $airport_array; |
|
5921
|
|
|
} |
|
5922
|
|
|
|
|
5923
|
|
|
|
|
5924
|
|
|
/** |
|
5925
|
|
|
* Gets all departure airports of the airplanes that have flown over based on an aircraft registration |
|
5926
|
|
|
* |
|
5927
|
|
|
* @return Array the airport list |
|
5928
|
|
|
* |
|
5929
|
|
|
*/ |
|
5930
|
|
|
public function countAllDepartureAirportsByRegistration($registration,$filters = array()) |
|
5931
|
|
|
{ |
|
5932
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5933
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
5934
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
5935
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration |
|
5936
|
|
|
GROUP BY spotter_output.departure_airport_icao |
|
5937
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
5938
|
|
|
|
|
5939
|
|
|
|
|
5940
|
|
|
$sth = $this->db->prepare($query); |
|
5941
|
|
|
$sth->execute(array(':registration' => $registration)); |
|
5942
|
|
|
|
|
5943
|
|
|
$airport_array = array(); |
|
5944
|
|
|
$temp_array = array(); |
|
5945
|
|
|
|
|
5946
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5947
|
|
|
{ |
|
5948
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
5949
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
5950
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
5951
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
5952
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
5953
|
|
|
|
|
5954
|
|
|
$airport_array[] = $temp_array; |
|
5955
|
|
|
} |
|
5956
|
|
|
|
|
5957
|
|
|
return $airport_array; |
|
5958
|
|
|
} |
|
5959
|
|
|
|
|
5960
|
|
|
|
|
5961
|
|
|
/** |
|
5962
|
|
|
* Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration |
|
5963
|
|
|
* |
|
5964
|
|
|
* @return Array the airport list |
|
5965
|
|
|
* |
|
5966
|
|
|
*/ |
|
5967
|
|
|
public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array()) |
|
5968
|
|
|
{ |
|
5969
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
5970
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
5971
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
5972
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration |
|
5973
|
|
|
GROUP BY spotter_output.departure_airport_country |
|
5974
|
|
|
ORDER BY airport_departure_country_count DESC"; |
|
5975
|
|
|
|
|
5976
|
|
|
|
|
5977
|
|
|
$sth = $this->db->prepare($query); |
|
5978
|
|
|
$sth->execute(array(':registration' => $registration)); |
|
5979
|
|
|
|
|
5980
|
|
|
$airport_array = array(); |
|
5981
|
|
|
$temp_array = array(); |
|
5982
|
|
|
|
|
5983
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
5984
|
|
|
{ |
|
5985
|
|
|
$temp_array['departure_airport_country'] = $row['departure_airport_country']; |
|
5986
|
|
|
$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
|
5987
|
|
|
|
|
5988
|
|
|
$airport_array[] = $temp_array; |
|
5989
|
|
|
} |
|
5990
|
|
|
|
|
5991
|
|
|
return $airport_array; |
|
5992
|
|
|
} |
|
5993
|
|
|
|
|
5994
|
|
|
|
|
5995
|
|
|
/** |
|
5996
|
|
|
* Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao |
|
5997
|
|
|
* |
|
5998
|
|
|
* @return Array the airport list |
|
5999
|
|
|
* |
|
6000
|
|
|
*/ |
|
6001
|
|
|
public function countAllDepartureAirportsByAirport($airport_icao,$filters = array()) |
|
6002
|
|
|
{ |
|
6003
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6004
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
6005
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6006
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao = :airport_icao |
|
6007
|
|
|
GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6008
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
6009
|
|
|
|
|
6010
|
|
|
|
|
6011
|
|
|
$sth = $this->db->prepare($query); |
|
6012
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao)); |
|
6013
|
|
|
|
|
6014
|
|
|
$airport_array = array(); |
|
6015
|
|
|
$temp_array = array(); |
|
6016
|
|
|
|
|
6017
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6018
|
|
|
{ |
|
6019
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
6020
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
6021
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
6022
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
6023
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
6024
|
|
|
|
|
6025
|
|
|
$airport_array[] = $temp_array; |
|
6026
|
|
|
} |
|
6027
|
|
|
|
|
6028
|
|
|
return $airport_array; |
|
6029
|
|
|
} |
|
6030
|
|
|
|
|
6031
|
|
|
|
|
6032
|
|
|
/** |
|
6033
|
|
|
* Gets all departure airports by country of the airplanes that have flown over based on an airport icao |
|
6034
|
|
|
* |
|
6035
|
|
|
* @return Array the airport list |
|
6036
|
|
|
* |
|
6037
|
|
|
*/ |
|
6038
|
|
|
public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array()) |
|
6039
|
|
|
{ |
|
6040
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6041
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
6042
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
6043
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao |
|
6044
|
|
|
GROUP BY spotter_output.departure_airport_country |
|
6045
|
|
|
ORDER BY airport_departure_country_count DESC"; |
|
6046
|
|
|
|
|
6047
|
|
|
|
|
6048
|
|
|
$sth = $this->db->prepare($query); |
|
6049
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao)); |
|
6050
|
|
|
|
|
6051
|
|
|
$airport_array = array(); |
|
6052
|
|
|
$temp_array = array(); |
|
6053
|
|
|
|
|
6054
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6055
|
|
|
{ |
|
6056
|
|
|
$temp_array['departure_airport_country'] = $row['departure_airport_country']; |
|
6057
|
|
|
$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
|
6058
|
|
|
|
|
6059
|
|
|
$airport_array[] = $temp_array; |
|
6060
|
|
|
} |
|
6061
|
|
|
|
|
6062
|
|
|
return $airport_array; |
|
6063
|
|
|
} |
|
6064
|
|
|
|
|
6065
|
|
|
|
|
6066
|
|
|
|
|
6067
|
|
|
/** |
|
6068
|
|
|
* Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer |
|
6069
|
|
|
* |
|
6070
|
|
|
* @return Array the airport list |
|
6071
|
|
|
* |
|
6072
|
|
|
*/ |
|
6073
|
|
|
public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array()) |
|
6074
|
|
|
{ |
|
6075
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6076
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
6077
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6078
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
6079
|
|
|
GROUP BY spotter_output.departure_airport_icao |
|
6080
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
6081
|
|
|
|
|
6082
|
|
|
|
|
6083
|
|
|
$sth = $this->db->prepare($query); |
|
6084
|
|
|
$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
6085
|
|
|
|
|
6086
|
|
|
$airport_array = array(); |
|
6087
|
|
|
$temp_array = array(); |
|
6088
|
|
|
|
|
6089
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6090
|
|
|
{ |
|
6091
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
6092
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
6093
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
6094
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
6095
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
6096
|
|
|
|
|
6097
|
|
|
$airport_array[] = $temp_array; |
|
6098
|
|
|
} |
|
6099
|
|
|
|
|
6100
|
|
|
return $airport_array; |
|
6101
|
|
|
} |
|
6102
|
|
|
|
|
6103
|
|
|
|
|
6104
|
|
|
/** |
|
6105
|
|
|
* Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer |
|
6106
|
|
|
* |
|
6107
|
|
|
* @return Array the airport list |
|
6108
|
|
|
* |
|
6109
|
|
|
*/ |
|
6110
|
|
|
public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
|
6111
|
|
|
{ |
|
6112
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6113
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
6114
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
6115
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
6116
|
|
|
GROUP BY spotter_output.departure_airport_country |
|
6117
|
|
|
ORDER BY airport_departure_country_count DESC"; |
|
6118
|
|
|
|
|
6119
|
|
|
|
|
6120
|
|
|
$sth = $this->db->prepare($query); |
|
6121
|
|
|
$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
6122
|
|
|
|
|
6123
|
|
|
$airport_array = array(); |
|
6124
|
|
|
$temp_array = array(); |
|
6125
|
|
|
|
|
6126
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6127
|
|
|
{ |
|
6128
|
|
|
$temp_array['departure_airport_country'] = $row['departure_airport_country']; |
|
6129
|
|
|
$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
|
6130
|
|
|
|
|
6131
|
|
|
$airport_array[] = $temp_array; |
|
6132
|
|
|
} |
|
6133
|
|
|
|
|
6134
|
|
|
return $airport_array; |
|
6135
|
|
|
} |
|
6136
|
|
|
|
|
6137
|
|
|
|
|
6138
|
|
|
/** |
|
6139
|
|
|
* Gets all departure airports of the airplanes that have flown over based on a date |
|
6140
|
|
|
* |
|
6141
|
|
|
* @return Array the airport list |
|
6142
|
|
|
* |
|
6143
|
|
|
*/ |
|
6144
|
|
|
public function countAllDepartureAirportsByDate($date,$filters = array()) |
|
6145
|
|
|
{ |
|
6146
|
|
|
global $globalTimezone, $globalDBdriver; |
|
6147
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6148
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
6149
|
|
|
if ($globalTimezone != '') { |
|
6150
|
|
|
date_default_timezone_set($globalTimezone); |
|
6151
|
|
|
$datetime = new DateTime($date); |
|
6152
|
|
|
$offset = $datetime->format('P'); |
|
6153
|
|
|
} else $offset = '+00:00'; |
|
6154
|
|
|
|
|
6155
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6156
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6157
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
6158
|
|
|
GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6159
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
6160
|
|
|
} else { |
|
6161
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6162
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
|
6163
|
|
|
GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6164
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
6165
|
|
|
} |
|
6166
|
|
|
|
|
6167
|
|
|
$sth = $this->db->prepare($query); |
|
6168
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
6169
|
|
|
|
|
6170
|
|
|
$airport_array = array(); |
|
6171
|
|
|
$temp_array = array(); |
|
6172
|
|
|
|
|
6173
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6174
|
|
|
{ |
|
6175
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
6176
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
6177
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
6178
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
6179
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
6180
|
|
|
|
|
6181
|
|
|
$airport_array[] = $temp_array; |
|
6182
|
|
|
} |
|
6183
|
|
|
return $airport_array; |
|
6184
|
|
|
} |
|
6185
|
|
|
|
|
6186
|
|
|
|
|
6187
|
|
|
|
|
6188
|
|
|
/** |
|
6189
|
|
|
* Gets all departure airports by country of the airplanes that have flown over based on a date |
|
6190
|
|
|
* |
|
6191
|
|
|
* @return Array the airport list |
|
6192
|
|
|
* |
|
6193
|
|
|
*/ |
|
6194
|
|
|
public function countAllDepartureAirportCountriesByDate($date,$filters = array()) |
|
6195
|
|
|
{ |
|
6196
|
|
|
global $globalTimezone, $globalDBdriver; |
|
6197
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6198
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
6199
|
|
|
if ($globalTimezone != '') { |
|
6200
|
|
|
date_default_timezone_set($globalTimezone); |
|
6201
|
|
|
$datetime = new DateTime($date); |
|
6202
|
|
|
$offset = $datetime->format('P'); |
|
6203
|
|
|
} else $offset = '+00:00'; |
|
6204
|
|
|
|
|
6205
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6206
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
6207
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
6208
|
|
|
GROUP BY spotter_output.departure_airport_country |
|
6209
|
|
|
ORDER BY airport_departure_country_count DESC"; |
|
6210
|
|
|
} else { |
|
6211
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
6212
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
|
6213
|
|
|
GROUP BY spotter_output.departure_airport_country |
|
6214
|
|
|
ORDER BY airport_departure_country_count DESC"; |
|
6215
|
|
|
} |
|
6216
|
|
|
|
|
6217
|
|
|
$sth = $this->db->prepare($query); |
|
6218
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
6219
|
|
|
|
|
6220
|
|
|
$airport_array = array(); |
|
6221
|
|
|
$temp_array = array(); |
|
6222
|
|
|
|
|
6223
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6224
|
|
|
{ |
|
6225
|
|
|
$temp_array['departure_airport_country'] = $row['departure_airport_country']; |
|
6226
|
|
|
$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
|
6227
|
|
|
|
|
6228
|
|
|
$airport_array[] = $temp_array; |
|
6229
|
|
|
} |
|
6230
|
|
|
return $airport_array; |
|
6231
|
|
|
} |
|
6232
|
|
|
|
|
6233
|
|
|
|
|
6234
|
|
|
|
|
6235
|
|
|
/** |
|
6236
|
|
|
* Gets all departure airports of the airplanes that have flown over based on a ident/callsign |
|
6237
|
|
|
* |
|
6238
|
|
|
* @return Array the airport list |
|
6239
|
|
|
* |
|
6240
|
|
|
*/ |
|
6241
|
|
|
public function countAllDepartureAirportsByIdent($ident,$filters = array()) |
|
6242
|
|
|
{ |
|
6243
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6244
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
6245
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6246
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.ident = :ident |
|
6247
|
|
|
GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6248
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
6249
|
|
|
|
|
6250
|
|
|
|
|
6251
|
|
|
$sth = $this->db->prepare($query); |
|
6252
|
|
|
$sth->execute(array(':ident' => $ident)); |
|
6253
|
|
|
|
|
6254
|
|
|
$airport_array = array(); |
|
6255
|
|
|
$temp_array = array(); |
|
6256
|
|
|
|
|
6257
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6258
|
|
|
{ |
|
6259
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
6260
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
6261
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
6262
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
6263
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
6264
|
|
|
|
|
6265
|
|
|
$airport_array[] = $temp_array; |
|
6266
|
|
|
} |
|
6267
|
|
|
|
|
6268
|
|
|
return $airport_array; |
|
6269
|
|
|
} |
|
6270
|
|
|
|
|
6271
|
|
|
|
|
6272
|
|
|
|
|
6273
|
|
|
/** |
|
6274
|
|
|
* Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident |
|
6275
|
|
|
* |
|
6276
|
|
|
* @return Array the airport list |
|
6277
|
|
|
* |
|
6278
|
|
|
*/ |
|
6279
|
|
|
public function countAllDepartureAirportCountriesByIdent($ident,$filters = array()) |
|
6280
|
|
|
{ |
|
6281
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6282
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
6283
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
6284
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident |
|
6285
|
|
|
GROUP BY spotter_output.departure_airport_country |
|
6286
|
|
|
ORDER BY airport_departure_country_count DESC"; |
|
6287
|
|
|
|
|
6288
|
|
|
|
|
6289
|
|
|
$sth = $this->db->prepare($query); |
|
6290
|
|
|
$sth->execute(array(':ident' => $ident)); |
|
6291
|
|
|
|
|
6292
|
|
|
$airport_array = array(); |
|
6293
|
|
|
$temp_array = array(); |
|
6294
|
|
|
|
|
6295
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6296
|
|
|
{ |
|
6297
|
|
|
$temp_array['departure_airport_country'] = $row['departure_airport_country']; |
|
6298
|
|
|
$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
|
6299
|
|
|
|
|
6300
|
|
|
$airport_array[] = $temp_array; |
|
6301
|
|
|
} |
|
6302
|
|
|
|
|
6303
|
|
|
return $airport_array; |
|
6304
|
|
|
} |
|
6305
|
|
|
|
|
6306
|
|
|
|
|
6307
|
|
|
|
|
6308
|
|
|
/** |
|
6309
|
|
|
* Gets all departure airports of the airplanes that have flown over based on a country |
|
6310
|
|
|
* |
|
6311
|
|
|
* @return Array the airport list |
|
6312
|
|
|
* |
|
6313
|
|
|
*/ |
|
6314
|
|
|
public function countAllDepartureAirportsByCountry($country,$filters = array()) |
|
6315
|
|
|
{ |
|
6316
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6317
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
6318
|
|
|
|
|
6319
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6320
|
|
|
FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
|
6321
|
|
|
GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
6322
|
|
|
ORDER BY airport_departure_icao_count DESC"; |
|
6323
|
|
|
|
|
6324
|
|
|
|
|
6325
|
|
|
$sth = $this->db->prepare($query); |
|
6326
|
|
|
$sth->execute(array(':country' => $country)); |
|
6327
|
|
|
|
|
6328
|
|
|
$airport_array = array(); |
|
6329
|
|
|
$temp_array = array(); |
|
6330
|
|
|
|
|
6331
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6332
|
|
|
{ |
|
6333
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
6334
|
|
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
|
6335
|
|
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
|
6336
|
|
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
|
6337
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
6338
|
|
|
|
|
6339
|
|
|
$airport_array[] = $temp_array; |
|
6340
|
|
|
} |
|
6341
|
|
|
|
|
6342
|
|
|
return $airport_array; |
|
6343
|
|
|
} |
|
6344
|
|
|
|
|
6345
|
|
|
|
|
6346
|
|
|
/** |
|
6347
|
|
|
* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao |
|
6348
|
|
|
* |
|
6349
|
|
|
* @return Array the airport list |
|
6350
|
|
|
* |
|
6351
|
|
|
*/ |
|
6352
|
|
|
public function countAllDepartureAirportCountriesByCountry($country,$filters = array()) |
|
6353
|
|
|
{ |
|
6354
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6355
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
6356
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
6357
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
|
6358
|
|
|
GROUP BY spotter_output.departure_airport_country |
|
6359
|
|
|
ORDER BY airport_departure_country_count DESC"; |
|
6360
|
|
|
|
|
6361
|
|
|
|
|
6362
|
|
|
$sth = $this->db->prepare($query); |
|
6363
|
|
|
$sth->execute(array(':country' => $country)); |
|
6364
|
|
|
|
|
6365
|
|
|
$airport_array = array(); |
|
6366
|
|
|
$temp_array = array(); |
|
6367
|
|
|
|
|
6368
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6369
|
|
|
{ |
|
6370
|
|
|
$temp_array['departure_airport_country'] = $row['departure_airport_country']; |
|
6371
|
|
|
$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
|
6372
|
|
|
|
|
6373
|
|
|
$airport_array[] = $temp_array; |
|
6374
|
|
|
} |
|
6375
|
|
|
|
|
6376
|
|
|
return $airport_array; |
|
6377
|
|
|
} |
|
6378
|
|
|
|
|
6379
|
|
|
|
|
6380
|
|
|
/** |
|
6381
|
|
|
* Gets all arrival airports of the airplanes that have flown over |
|
6382
|
|
|
* |
|
6383
|
|
|
* @param Boolean $limit Limit result to 10 or not |
|
6384
|
|
|
* @param Integer $olderthanmonths Only show result older than x months |
|
6385
|
|
|
* @param String $sincedate Only show result since x date |
|
6386
|
|
|
* @param Boolean $icaoaskey Show result by ICAO |
|
6387
|
|
|
* @param Array $filters Filter used here |
|
6388
|
|
|
* @return Array the airport list |
|
6389
|
|
|
* |
|
6390
|
|
|
*/ |
|
6391
|
|
|
public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array()) |
|
6392
|
|
|
{ |
|
6393
|
|
|
global $globalDBdriver; |
|
6394
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6395
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6396
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA'"; |
|
6397
|
|
|
if ($olderthanmonths > 0) { |
|
6398
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6399
|
|
|
$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
|
6400
|
|
|
} else { |
|
6401
|
|
|
$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
6402
|
|
|
} |
|
6403
|
|
|
} |
|
6404
|
|
|
if ($sincedate != '') { |
|
6405
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6406
|
|
|
$query .= " AND spotter_output.date > '".$sincedate."'"; |
|
6407
|
|
|
} else { |
|
6408
|
|
|
$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
6409
|
|
|
} |
|
6410
|
|
|
} |
|
6411
|
|
|
|
|
6412
|
|
|
//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
6413
|
|
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
6414
|
|
|
$query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6415
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
6416
|
|
|
if ($limit) $query .= " LIMIT 10"; |
|
6417
|
|
|
|
|
6418
|
|
|
|
|
6419
|
|
|
$sth = $this->db->prepare($query); |
|
6420
|
|
|
$sth->execute(); |
|
6421
|
|
|
|
|
6422
|
|
|
$airport_array = array(); |
|
6423
|
|
|
$temp_array = array(); |
|
6424
|
|
|
|
|
6425
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6426
|
|
|
{ |
|
6427
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
6428
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
6429
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
6430
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
6431
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
6432
|
|
|
|
|
6433
|
|
|
if ($icaoaskey) { |
|
6434
|
|
|
$icao = $row['arrival_airport_icao']; |
|
6435
|
|
|
$airport_array[$icao] = $temp_array; |
|
6436
|
|
|
} else $airport_array[] = $temp_array; |
|
6437
|
|
|
} |
|
6438
|
|
|
|
|
6439
|
|
|
return $airport_array; |
|
6440
|
|
|
} |
|
6441
|
|
|
|
|
6442
|
|
|
/** |
|
6443
|
|
|
* Gets all arrival airports of the airplanes that have flown over |
|
6444
|
|
|
* |
|
6445
|
|
|
* @return Array the airport list |
|
6446
|
|
|
* |
|
6447
|
|
|
*/ |
|
6448
|
|
|
public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array()) |
|
6449
|
|
|
{ |
|
6450
|
|
|
global $globalDBdriver; |
|
6451
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6452
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6453
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' "; |
|
6454
|
|
|
if ($olderthanmonths > 0) { |
|
6455
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6456
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
6457
|
|
|
} else { |
|
6458
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
6459
|
|
|
} |
|
6460
|
|
|
} |
|
6461
|
|
|
if ($sincedate != '') { |
|
6462
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6463
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
6464
|
|
|
} else { |
|
6465
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
6466
|
|
|
} |
|
6467
|
|
|
} |
|
6468
|
|
|
|
|
6469
|
|
|
//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
6470
|
|
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
6471
|
|
|
$query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6472
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
6473
|
|
|
if ($limit) $query .= " LIMIT 10"; |
|
6474
|
|
|
|
|
6475
|
|
|
|
|
6476
|
|
|
$sth = $this->db->prepare($query); |
|
6477
|
|
|
$sth->execute(); |
|
6478
|
|
|
|
|
6479
|
|
|
$airport_array = array(); |
|
6480
|
|
|
$temp_array = array(); |
|
6481
|
|
|
|
|
6482
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6483
|
|
|
{ |
|
6484
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
6485
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
6486
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
6487
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
6488
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
6489
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
6490
|
|
|
|
|
6491
|
|
|
if ($icaoaskey) { |
|
6492
|
|
|
$icao = $row['arrival_airport_icao']; |
|
6493
|
|
|
$airport_array[$icao] = $temp_array; |
|
6494
|
|
|
} else $airport_array[] = $temp_array; |
|
6495
|
|
|
} |
|
6496
|
|
|
|
|
6497
|
|
|
return $airport_array; |
|
6498
|
|
|
} |
|
6499
|
|
|
|
|
6500
|
|
|
|
|
6501
|
|
|
/** |
|
6502
|
|
|
* Gets all detected arrival airports of the airplanes that have flown over |
|
6503
|
|
|
* |
|
6504
|
|
|
* @return Array the airport list |
|
6505
|
|
|
* |
|
6506
|
|
|
*/ |
|
6507
|
|
|
public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array()) |
|
6508
|
|
|
{ |
|
6509
|
|
|
global $globalDBdriver; |
|
6510
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6511
|
|
|
$query = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country |
|
6512
|
|
|
FROM airport,spotter_output".$filter_query." spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao"; |
|
6513
|
|
|
if ($olderthanmonths > 0) { |
|
6514
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6515
|
|
|
$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
|
6516
|
|
|
} else { |
|
6517
|
|
|
$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
6518
|
|
|
} |
|
6519
|
|
|
} |
|
6520
|
|
|
if ($sincedate != '') { |
|
6521
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6522
|
|
|
$query .= " AND spotter_output.date > '".$sincedate."'"; |
|
6523
|
|
|
} else { |
|
6524
|
|
|
$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
6525
|
|
|
} |
|
6526
|
|
|
} |
|
6527
|
|
|
//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
6528
|
|
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
6529
|
|
|
$query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
|
6530
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
6531
|
|
|
if ($limit) $query .= " LIMIT 10"; |
|
6532
|
|
|
|
|
6533
|
|
|
|
|
6534
|
|
|
$sth = $this->db->prepare($query); |
|
6535
|
|
|
$sth->execute(); |
|
6536
|
|
|
|
|
6537
|
|
|
$airport_array = array(); |
|
6538
|
|
|
$temp_array = array(); |
|
6539
|
|
|
|
|
6540
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6541
|
|
|
{ |
|
6542
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
6543
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
6544
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
6545
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
6546
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
6547
|
|
|
|
|
6548
|
|
|
if ($icaoaskey) { |
|
6549
|
|
|
$icao = $row['arrival_airport_icao']; |
|
6550
|
|
|
$airport_array[$icao] = $temp_array; |
|
6551
|
|
|
} else $airport_array[] = $temp_array; |
|
6552
|
|
|
} |
|
6553
|
|
|
|
|
6554
|
|
|
return $airport_array; |
|
6555
|
|
|
} |
|
6556
|
|
|
|
|
6557
|
|
|
/** |
|
6558
|
|
|
* Gets all detected arrival airports of the airplanes that have flown over |
|
6559
|
|
|
* |
|
6560
|
|
|
* @return Array the airport list |
|
6561
|
|
|
* |
|
6562
|
|
|
*/ |
|
6563
|
|
|
public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array()) |
|
6564
|
|
|
{ |
|
6565
|
|
|
global $globalDBdriver; |
|
6566
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6567
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country |
|
6568
|
|
|
FROM airport,spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao "; |
|
6569
|
|
|
if ($olderthanmonths > 0) { |
|
6570
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6571
|
|
|
$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
|
6572
|
|
|
} else { |
|
6573
|
|
|
$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
6574
|
|
|
} |
|
6575
|
|
|
} |
|
6576
|
|
|
if ($sincedate != '') { |
|
6577
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6578
|
|
|
$query .= "AND spotter_output.date > '".$sincedate."' "; |
|
6579
|
|
|
} else { |
|
6580
|
|
|
$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
6581
|
|
|
} |
|
6582
|
|
|
} |
|
6583
|
|
|
|
|
6584
|
|
|
//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
6585
|
|
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
6586
|
|
|
$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
|
6587
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
6588
|
|
|
if ($limit) $query .= " LIMIT 10"; |
|
6589
|
|
|
|
|
6590
|
|
|
|
|
6591
|
|
|
$sth = $this->db->prepare($query); |
|
6592
|
|
|
$sth->execute(); |
|
6593
|
|
|
|
|
6594
|
|
|
$airport_array = array(); |
|
6595
|
|
|
$temp_array = array(); |
|
6596
|
|
|
|
|
6597
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6598
|
|
|
{ |
|
6599
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
6600
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
6601
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
6602
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
6603
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
6604
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
6605
|
|
|
|
|
6606
|
|
|
if ($icaoaskey) { |
|
6607
|
|
|
$icao = $row['arrival_airport_icao']; |
|
6608
|
|
|
$airport_array[$icao] = $temp_array; |
|
6609
|
|
|
} else $airport_array[] = $temp_array; |
|
6610
|
|
|
} |
|
6611
|
|
|
|
|
6612
|
|
|
return $airport_array; |
|
6613
|
|
|
} |
|
6614
|
|
|
|
|
6615
|
|
|
/** |
|
6616
|
|
|
* Gets all arrival airports of the airplanes that have flown over based on an airline icao |
|
6617
|
|
|
* |
|
6618
|
|
|
* @return Array the airport list |
|
6619
|
|
|
* |
|
6620
|
|
|
*/ |
|
6621
|
|
|
public function countAllArrivalAirportsByAirline($airline_icao, $filters = array()) |
|
6622
|
|
|
{ |
|
6623
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6624
|
|
|
$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
6625
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6626
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao |
|
6627
|
|
|
GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6628
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
6629
|
|
|
|
|
6630
|
|
|
$sth = $this->db->prepare($query); |
|
6631
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao)); |
|
6632
|
|
|
|
|
6633
|
|
|
$airport_array = array(); |
|
6634
|
|
|
$temp_array = array(); |
|
6635
|
|
|
|
|
6636
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6637
|
|
|
{ |
|
6638
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
6639
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
6640
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
6641
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
6642
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
6643
|
|
|
|
|
6644
|
|
|
$airport_array[] = $temp_array; |
|
6645
|
|
|
} |
|
6646
|
|
|
|
|
6647
|
|
|
return $airport_array; |
|
6648
|
|
|
} |
|
6649
|
|
|
|
|
6650
|
|
|
|
|
6651
|
|
|
/** |
|
6652
|
|
|
* Gets all arrival airports by country of the airplanes that have flown over based on an airline icao |
|
6653
|
|
|
* |
|
6654
|
|
|
* @return Array the airport list |
|
6655
|
|
|
* |
|
6656
|
|
|
*/ |
|
6657
|
|
|
public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array()) |
|
6658
|
|
|
{ |
|
6659
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6660
|
|
|
$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
6661
|
|
|
|
|
6662
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
6663
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao |
|
6664
|
|
|
GROUP BY spotter_output.arrival_airport_country |
|
6665
|
|
|
ORDER BY airport_arrival_country_count DESC"; |
|
6666
|
|
|
|
|
6667
|
|
|
|
|
6668
|
|
|
$sth = $this->db->prepare($query); |
|
6669
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao)); |
|
6670
|
|
|
|
|
6671
|
|
|
$airport_array = array(); |
|
6672
|
|
|
$temp_array = array(); |
|
6673
|
|
|
|
|
6674
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6675
|
|
|
{ |
|
6676
|
|
|
$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
|
6677
|
|
|
$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
|
6678
|
|
|
|
|
6679
|
|
|
$airport_array[] = $temp_array; |
|
6680
|
|
|
} |
|
6681
|
|
|
|
|
6682
|
|
|
return $airport_array; |
|
6683
|
|
|
} |
|
6684
|
|
|
|
|
6685
|
|
|
|
|
6686
|
|
|
/** |
|
6687
|
|
|
* Gets all arrival airports of the airplanes that have flown over based on an aircraft icao |
|
6688
|
|
|
* |
|
6689
|
|
|
* @return Array the airport list |
|
6690
|
|
|
* |
|
6691
|
|
|
*/ |
|
6692
|
|
|
public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array()) |
|
6693
|
|
|
{ |
|
6694
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6695
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
6696
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6697
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao |
|
6698
|
|
|
GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6699
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
6700
|
|
|
|
|
6701
|
|
|
|
|
6702
|
|
|
$sth = $this->db->prepare($query); |
|
6703
|
|
|
$sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
|
6704
|
|
|
|
|
6705
|
|
|
$airport_array = array(); |
|
6706
|
|
|
$temp_array = array(); |
|
6707
|
|
|
|
|
6708
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6709
|
|
|
{ |
|
6710
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
6711
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
6712
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
6713
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
6714
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
6715
|
|
|
|
|
6716
|
|
|
$airport_array[] = $temp_array; |
|
6717
|
|
|
} |
|
6718
|
|
|
|
|
6719
|
|
|
return $airport_array; |
|
6720
|
|
|
} |
|
6721
|
|
|
|
|
6722
|
|
|
|
|
6723
|
|
|
|
|
6724
|
|
|
/** |
|
6725
|
|
|
* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao |
|
6726
|
|
|
* |
|
6727
|
|
|
* @return Array the airport list |
|
6728
|
|
|
* |
|
6729
|
|
|
*/ |
|
6730
|
|
|
public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array()) |
|
6731
|
|
|
{ |
|
6732
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6733
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
6734
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
6735
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
|
6736
|
|
|
GROUP BY spotter_output.arrival_airport_country |
|
6737
|
|
|
ORDER BY airport_arrival_country_count DESC"; |
|
6738
|
|
|
|
|
6739
|
|
|
|
|
6740
|
|
|
$sth = $this->db->prepare($query); |
|
6741
|
|
|
$sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
|
6742
|
|
|
|
|
6743
|
|
|
$airport_array = array(); |
|
6744
|
|
|
$temp_array = array(); |
|
6745
|
|
|
|
|
6746
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6747
|
|
|
{ |
|
6748
|
|
|
$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
|
6749
|
|
|
$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
|
6750
|
|
|
|
|
6751
|
|
|
$airport_array[] = $temp_array; |
|
6752
|
|
|
} |
|
6753
|
|
|
|
|
6754
|
|
|
return $airport_array; |
|
6755
|
|
|
} |
|
6756
|
|
|
|
|
6757
|
|
|
|
|
6758
|
|
|
/** |
|
6759
|
|
|
* Gets all arrival airports of the airplanes that have flown over based on an aircraft registration |
|
6760
|
|
|
* |
|
6761
|
|
|
* @return Array the airport list |
|
6762
|
|
|
* |
|
6763
|
|
|
*/ |
|
6764
|
|
|
public function countAllArrivalAirportsByRegistration($registration,$filters = array()) |
|
6765
|
|
|
{ |
|
6766
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6767
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
6768
|
|
|
|
|
6769
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6770
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.registration = :registration |
|
6771
|
|
|
GROUP BY spotter_output.arrival_airport_icao |
|
6772
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
6773
|
|
|
|
|
6774
|
|
|
|
|
6775
|
|
|
$sth = $this->db->prepare($query); |
|
6776
|
|
|
$sth->execute(array(':registration' => $registration)); |
|
6777
|
|
|
|
|
6778
|
|
|
$airport_array = array(); |
|
6779
|
|
|
$temp_array = array(); |
|
6780
|
|
|
|
|
6781
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6782
|
|
|
{ |
|
6783
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
6784
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
6785
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
6786
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
6787
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
6788
|
|
|
|
|
6789
|
|
|
$airport_array[] = $temp_array; |
|
6790
|
|
|
} |
|
6791
|
|
|
|
|
6792
|
|
|
return $airport_array; |
|
6793
|
|
|
} |
|
6794
|
|
|
|
|
6795
|
|
|
|
|
6796
|
|
|
/** |
|
6797
|
|
|
* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration |
|
6798
|
|
|
* |
|
6799
|
|
|
* @return Array the airport list |
|
6800
|
|
|
* |
|
6801
|
|
|
*/ |
|
6802
|
|
|
public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array()) |
|
6803
|
|
|
{ |
|
6804
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6805
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
6806
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
6807
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration |
|
6808
|
|
|
GROUP BY spotter_output.arrival_airport_country |
|
6809
|
|
|
ORDER BY airport_arrival_country_count DESC"; |
|
6810
|
|
|
|
|
6811
|
|
|
|
|
6812
|
|
|
$sth = $this->db->prepare($query); |
|
6813
|
|
|
$sth->execute(array(':registration' => $registration)); |
|
6814
|
|
|
|
|
6815
|
|
|
$airport_array = array(); |
|
6816
|
|
|
$temp_array = array(); |
|
6817
|
|
|
|
|
6818
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6819
|
|
|
{ |
|
6820
|
|
|
$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
|
6821
|
|
|
$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
|
6822
|
|
|
|
|
6823
|
|
|
$airport_array[] = $temp_array; |
|
6824
|
|
|
} |
|
6825
|
|
|
|
|
6826
|
|
|
return $airport_array; |
|
6827
|
|
|
} |
|
6828
|
|
|
|
|
6829
|
|
|
|
|
6830
|
|
|
|
|
6831
|
|
|
/** |
|
6832
|
|
|
* Gets all arrival airports of the airplanes that have flown over based on an departure airport |
|
6833
|
|
|
* |
|
6834
|
|
|
* @return Array the airport list |
|
6835
|
|
|
* |
|
6836
|
|
|
*/ |
|
6837
|
|
|
public function countAllArrivalAirportsByAirport($airport_icao,$filters = array()) |
|
6838
|
|
|
{ |
|
6839
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6840
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
6841
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6842
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.departure_airport_icao = :airport_icao |
|
6843
|
|
|
GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6844
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
6845
|
|
|
|
|
6846
|
|
|
|
|
6847
|
|
|
$sth = $this->db->prepare($query); |
|
6848
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao)); |
|
6849
|
|
|
|
|
6850
|
|
|
$airport_array = array(); |
|
6851
|
|
|
$temp_array = array(); |
|
6852
|
|
|
|
|
6853
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6854
|
|
|
{ |
|
6855
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
6856
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
6857
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
6858
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
6859
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
6860
|
|
|
|
|
6861
|
|
|
$airport_array[] = $temp_array; |
|
6862
|
|
|
} |
|
6863
|
|
|
|
|
6864
|
|
|
return $airport_array; |
|
6865
|
|
|
} |
|
6866
|
|
|
|
|
6867
|
|
|
|
|
6868
|
|
|
/** |
|
6869
|
|
|
* Gets all arrival airports by country of the airplanes that have flown over based on an airport icao |
|
6870
|
|
|
* |
|
6871
|
|
|
* @return Array the airport list |
|
6872
|
|
|
* |
|
6873
|
|
|
*/ |
|
6874
|
|
|
public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array()) |
|
6875
|
|
|
{ |
|
6876
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6877
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
6878
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
6879
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao |
|
6880
|
|
|
GROUP BY spotter_output.arrival_airport_country |
|
6881
|
|
|
ORDER BY airport_arrival_country_count DESC"; |
|
6882
|
|
|
|
|
6883
|
|
|
|
|
6884
|
|
|
$sth = $this->db->prepare($query); |
|
6885
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao)); |
|
6886
|
|
|
|
|
6887
|
|
|
$airport_array = array(); |
|
6888
|
|
|
$temp_array = array(); |
|
6889
|
|
|
|
|
6890
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6891
|
|
|
{ |
|
6892
|
|
|
$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
|
6893
|
|
|
$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
|
6894
|
|
|
|
|
6895
|
|
|
$airport_array[] = $temp_array; |
|
6896
|
|
|
} |
|
6897
|
|
|
|
|
6898
|
|
|
return $airport_array; |
|
6899
|
|
|
} |
|
6900
|
|
|
|
|
6901
|
|
|
|
|
6902
|
|
|
/** |
|
6903
|
|
|
* Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer |
|
6904
|
|
|
* |
|
6905
|
|
|
* @return Array the airport list |
|
6906
|
|
|
* |
|
6907
|
|
|
*/ |
|
6908
|
|
|
public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array()) |
|
6909
|
|
|
{ |
|
6910
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6911
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
6912
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6913
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
6914
|
|
|
GROUP BY spotter_output.arrival_airport_icao |
|
6915
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
6916
|
|
|
|
|
6917
|
|
|
|
|
6918
|
|
|
$sth = $this->db->prepare($query); |
|
6919
|
|
|
$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
6920
|
|
|
|
|
6921
|
|
|
$airport_array = array(); |
|
6922
|
|
|
$temp_array = array(); |
|
6923
|
|
|
|
|
6924
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6925
|
|
|
{ |
|
6926
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
6927
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
6928
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
6929
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
6930
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
6931
|
|
|
|
|
6932
|
|
|
$airport_array[] = $temp_array; |
|
6933
|
|
|
} |
|
6934
|
|
|
|
|
6935
|
|
|
return $airport_array; |
|
6936
|
|
|
} |
|
6937
|
|
|
|
|
6938
|
|
|
|
|
6939
|
|
|
|
|
6940
|
|
|
/** |
|
6941
|
|
|
* Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer |
|
6942
|
|
|
* |
|
6943
|
|
|
* @return Array the airport list |
|
6944
|
|
|
* |
|
6945
|
|
|
*/ |
|
6946
|
|
|
public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
|
6947
|
|
|
{ |
|
6948
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6949
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
6950
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
6951
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
6952
|
|
|
GROUP BY spotter_output.arrival_airport_country |
|
6953
|
|
|
ORDER BY airport_arrival_country_count DESC"; |
|
6954
|
|
|
|
|
6955
|
|
|
|
|
6956
|
|
|
$sth = $this->db->prepare($query); |
|
6957
|
|
|
$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
6958
|
|
|
|
|
6959
|
|
|
$airport_array = array(); |
|
6960
|
|
|
$temp_array = array(); |
|
6961
|
|
|
|
|
6962
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
6963
|
|
|
{ |
|
6964
|
|
|
$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
|
6965
|
|
|
$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
|
6966
|
|
|
|
|
6967
|
|
|
$airport_array[] = $temp_array; |
|
6968
|
|
|
} |
|
6969
|
|
|
|
|
6970
|
|
|
return $airport_array; |
|
6971
|
|
|
} |
|
6972
|
|
|
|
|
6973
|
|
|
|
|
6974
|
|
|
|
|
6975
|
|
|
/** |
|
6976
|
|
|
* Gets all arrival airports of the airplanes that have flown over based on a date |
|
6977
|
|
|
* |
|
6978
|
|
|
* @return Array the airport list |
|
6979
|
|
|
* |
|
6980
|
|
|
*/ |
|
6981
|
|
|
public function countAllArrivalAirportsByDate($date,$filters = array()) |
|
6982
|
|
|
{ |
|
6983
|
|
|
global $globalTimezone, $globalDBdriver; |
|
6984
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
6985
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
6986
|
|
|
if ($globalTimezone != '') { |
|
6987
|
|
|
date_default_timezone_set($globalTimezone); |
|
6988
|
|
|
$datetime = new DateTime($date); |
|
6989
|
|
|
$offset = $datetime->format('P'); |
|
6990
|
|
|
} else $offset = '+00:00'; |
|
6991
|
|
|
|
|
6992
|
|
|
if ($globalDBdriver == 'mysql') { |
|
6993
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6994
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
6995
|
|
|
GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6996
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
6997
|
|
|
} else { |
|
6998
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
6999
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
|
7000
|
|
|
GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7001
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
7002
|
|
|
} |
|
7003
|
|
|
|
|
7004
|
|
|
$sth = $this->db->prepare($query); |
|
7005
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
7006
|
|
|
|
|
7007
|
|
|
$airport_array = array(); |
|
7008
|
|
|
$temp_array = array(); |
|
7009
|
|
|
|
|
7010
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7011
|
|
|
{ |
|
7012
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7013
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
7014
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
7015
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
7016
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
7017
|
|
|
|
|
7018
|
|
|
$airport_array[] = $temp_array; |
|
7019
|
|
|
} |
|
7020
|
|
|
return $airport_array; |
|
7021
|
|
|
} |
|
7022
|
|
|
|
|
7023
|
|
|
|
|
7024
|
|
|
|
|
7025
|
|
|
/** |
|
7026
|
|
|
* Gets all arrival airports by country of the airplanes that have flown over based on a date |
|
7027
|
|
|
* |
|
7028
|
|
|
* @return Array the airport list |
|
7029
|
|
|
* |
|
7030
|
|
|
*/ |
|
7031
|
|
|
public function countAllArrivalAirportCountriesByDate($date, $filters = array()) |
|
7032
|
|
|
{ |
|
7033
|
|
|
global $globalTimezone, $globalDBdriver; |
|
7034
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7035
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
7036
|
|
|
if ($globalTimezone != '') { |
|
7037
|
|
|
date_default_timezone_set($globalTimezone); |
|
7038
|
|
|
$datetime = new DateTime($date); |
|
7039
|
|
|
$offset = $datetime->format('P'); |
|
7040
|
|
|
} else $offset = '+00:00'; |
|
7041
|
|
|
|
|
7042
|
|
|
if ($globalDBdriver == 'mysql') { |
|
7043
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
7044
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
7045
|
|
|
GROUP BY spotter_output.arrival_airport_country |
|
7046
|
|
|
ORDER BY airport_arrival_country_count DESC"; |
|
7047
|
|
|
} else { |
|
7048
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
7049
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
|
7050
|
|
|
GROUP BY spotter_output.arrival_airport_country |
|
7051
|
|
|
ORDER BY airport_arrival_country_count DESC"; |
|
7052
|
|
|
} |
|
7053
|
|
|
|
|
7054
|
|
|
$sth = $this->db->prepare($query); |
|
7055
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
7056
|
|
|
|
|
7057
|
|
|
$airport_array = array(); |
|
7058
|
|
|
$temp_array = array(); |
|
7059
|
|
|
|
|
7060
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7061
|
|
|
{ |
|
7062
|
|
|
$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
|
7063
|
|
|
$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
|
7064
|
|
|
|
|
7065
|
|
|
$airport_array[] = $temp_array; |
|
7066
|
|
|
} |
|
7067
|
|
|
return $airport_array; |
|
7068
|
|
|
} |
|
7069
|
|
|
|
|
7070
|
|
|
|
|
7071
|
|
|
|
|
7072
|
|
|
/** |
|
7073
|
|
|
* Gets all arrival airports of the airplanes that have flown over based on a ident/callsign |
|
7074
|
|
|
* |
|
7075
|
|
|
* @return Array the airport list |
|
7076
|
|
|
* |
|
7077
|
|
|
*/ |
|
7078
|
|
|
public function countAllArrivalAirportsByIdent($ident,$filters = array()) |
|
7079
|
|
|
{ |
|
7080
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7081
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
7082
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7083
|
|
|
FROM spotter_output".$filter_query." WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.ident = :ident |
|
7084
|
|
|
GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7085
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
7086
|
|
|
|
|
7087
|
|
|
|
|
7088
|
|
|
$sth = $this->db->prepare($query); |
|
7089
|
|
|
$sth->execute(array(':ident' => $ident)); |
|
7090
|
|
|
|
|
7091
|
|
|
$airport_array = array(); |
|
7092
|
|
|
$temp_array = array(); |
|
7093
|
|
|
|
|
7094
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7095
|
|
|
{ |
|
7096
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7097
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
7098
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
7099
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
7100
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
7101
|
|
|
|
|
7102
|
|
|
$airport_array[] = $temp_array; |
|
7103
|
|
|
} |
|
7104
|
|
|
|
|
7105
|
|
|
return $airport_array; |
|
7106
|
|
|
} |
|
7107
|
|
|
|
|
7108
|
|
|
|
|
7109
|
|
|
/** |
|
7110
|
|
|
* Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident |
|
7111
|
|
|
* |
|
7112
|
|
|
* @return Array the airport list |
|
7113
|
|
|
* |
|
7114
|
|
|
*/ |
|
7115
|
|
|
public function countAllArrivalAirportCountriesByIdent($ident, $filters = array()) |
|
7116
|
|
|
{ |
|
7117
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7118
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
7119
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
7120
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident |
|
7121
|
|
|
GROUP BY spotter_output.arrival_airport_country |
|
7122
|
|
|
ORDER BY airport_arrival_country_count DESC"; |
|
7123
|
|
|
|
|
7124
|
|
|
|
|
7125
|
|
|
$sth = $this->db->prepare($query); |
|
7126
|
|
|
$sth->execute(array(':ident' => $ident)); |
|
7127
|
|
|
|
|
7128
|
|
|
$airport_array = array(); |
|
7129
|
|
|
$temp_array = array(); |
|
7130
|
|
|
|
|
7131
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7132
|
|
|
{ |
|
7133
|
|
|
$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
|
7134
|
|
|
$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
|
7135
|
|
|
|
|
7136
|
|
|
$airport_array[] = $temp_array; |
|
7137
|
|
|
} |
|
7138
|
|
|
|
|
7139
|
|
|
return $airport_array; |
|
7140
|
|
|
} |
|
7141
|
|
|
|
|
7142
|
|
|
|
|
7143
|
|
|
|
|
7144
|
|
|
/** |
|
7145
|
|
|
* Gets all arrival airports of the airplanes that have flown over based on a country |
|
7146
|
|
|
* |
|
7147
|
|
|
* @return Array the airport list |
|
7148
|
|
|
* |
|
7149
|
|
|
*/ |
|
7150
|
|
|
public function countAllArrivalAirportsByCountry($country,$filters = array()) |
|
7151
|
|
|
{ |
|
7152
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7153
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
7154
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7155
|
|
|
FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
|
7156
|
|
|
GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7157
|
|
|
ORDER BY airport_arrival_icao_count DESC"; |
|
7158
|
|
|
|
|
7159
|
|
|
|
|
7160
|
|
|
$sth = $this->db->prepare($query); |
|
7161
|
|
|
$sth->execute(array(':country' => $country)); |
|
7162
|
|
|
|
|
7163
|
|
|
$airport_array = array(); |
|
7164
|
|
|
$temp_array = array(); |
|
7165
|
|
|
|
|
7166
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7167
|
|
|
{ |
|
7168
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7169
|
|
|
$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
|
7170
|
|
|
$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
|
7171
|
|
|
$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
|
7172
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
7173
|
|
|
|
|
7174
|
|
|
$airport_array[] = $temp_array; |
|
7175
|
|
|
} |
|
7176
|
|
|
|
|
7177
|
|
|
return $airport_array; |
|
7178
|
|
|
} |
|
7179
|
|
|
|
|
7180
|
|
|
|
|
7181
|
|
|
/** |
|
7182
|
|
|
* Gets all arrival airports by country of the airplanes that have flown over based on a country |
|
7183
|
|
|
* |
|
7184
|
|
|
* @return Array the airport list |
|
7185
|
|
|
* |
|
7186
|
|
|
*/ |
|
7187
|
|
|
public function countAllArrivalAirportCountriesByCountry($country,$filters = array()) |
|
7188
|
|
|
{ |
|
7189
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7190
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
7191
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
7192
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
|
7193
|
|
|
GROUP BY spotter_output.arrival_airport_country |
|
7194
|
|
|
ORDER BY airport_arrival_country_count DESC"; |
|
7195
|
|
|
|
|
7196
|
|
|
|
|
7197
|
|
|
$sth = $this->db->prepare($query); |
|
7198
|
|
|
$sth->execute(array(':country' => $country)); |
|
7199
|
|
|
|
|
7200
|
|
|
$airport_array = array(); |
|
7201
|
|
|
$temp_array = array(); |
|
7202
|
|
|
|
|
7203
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7204
|
|
|
{ |
|
7205
|
|
|
$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
|
7206
|
|
|
$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
|
7207
|
|
|
|
|
7208
|
|
|
$airport_array[] = $temp_array; |
|
7209
|
|
|
} |
|
7210
|
|
|
|
|
7211
|
|
|
return $airport_array; |
|
7212
|
|
|
} |
|
7213
|
|
|
|
|
7214
|
|
|
|
|
7215
|
|
|
|
|
7216
|
|
|
/** |
|
7217
|
|
|
* Counts all airport departure countries |
|
7218
|
|
|
* |
|
7219
|
|
|
* @return Array the airport departure list |
|
7220
|
|
|
* |
|
7221
|
|
|
*/ |
|
7222
|
|
|
public function countAllDepartureCountries($filters = array()) |
|
7223
|
|
|
{ |
|
7224
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7225
|
|
|
$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
7226
|
|
|
FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA'"; |
|
7227
|
|
|
$query .= " GROUP BY spotter_output.departure_airport_country |
|
7228
|
|
|
ORDER BY airport_departure_country_count DESC |
|
7229
|
|
|
LIMIT 10 OFFSET 0"; |
|
7230
|
|
|
|
|
7231
|
|
|
|
|
7232
|
|
|
$sth = $this->db->prepare($query); |
|
7233
|
|
|
$sth->execute(); |
|
7234
|
|
|
|
|
7235
|
|
|
$airport_array = array(); |
|
7236
|
|
|
$temp_array = array(); |
|
7237
|
|
|
|
|
7238
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7239
|
|
|
{ |
|
7240
|
|
|
$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
|
7241
|
|
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
|
7242
|
|
|
|
|
7243
|
|
|
$airport_array[] = $temp_array; |
|
7244
|
|
|
} |
|
7245
|
|
|
|
|
7246
|
|
|
return $airport_array; |
|
7247
|
|
|
} |
|
7248
|
|
|
|
|
7249
|
|
|
|
|
7250
|
|
|
/** |
|
7251
|
|
|
* Counts all airport arrival countries |
|
7252
|
|
|
* |
|
7253
|
|
|
* @return Array the airport arrival list |
|
7254
|
|
|
* |
|
7255
|
|
|
*/ |
|
7256
|
|
|
public function countAllArrivalCountries($limit = true,$filters = array()) |
|
7257
|
|
|
{ |
|
7258
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7259
|
|
|
$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
7260
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA'"; |
|
7261
|
|
|
$query .= " GROUP BY spotter_output.arrival_airport_country |
|
7262
|
|
|
ORDER BY airport_arrival_country_count DESC"; |
|
7263
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7264
|
|
|
|
|
7265
|
|
|
|
|
7266
|
|
|
$sth = $this->db->prepare($query); |
|
7267
|
|
|
$sth->execute(); |
|
7268
|
|
|
|
|
7269
|
|
|
$airport_array = array(); |
|
7270
|
|
|
$temp_array = array(); |
|
7271
|
|
|
|
|
7272
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7273
|
|
|
{ |
|
7274
|
|
|
$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
|
7275
|
|
|
$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
|
7276
|
|
|
|
|
7277
|
|
|
$airport_array[] = $temp_array; |
|
7278
|
|
|
} |
|
7279
|
|
|
|
|
7280
|
|
|
return $airport_array; |
|
7281
|
|
|
} |
|
7282
|
|
|
|
|
7283
|
|
|
|
|
7284
|
|
|
|
|
7285
|
|
|
|
|
7286
|
|
|
|
|
7287
|
|
|
/** |
|
7288
|
|
|
* Gets all route combinations |
|
7289
|
|
|
* |
|
7290
|
|
|
* @return Array the route list |
|
7291
|
|
|
* |
|
7292
|
|
|
*/ |
|
7293
|
|
|
public function countAllRoutes($filters = array()) |
|
7294
|
|
|
{ |
|
7295
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7296
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7297
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> 'NA' |
|
7298
|
|
|
GROUP BY route,spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
7299
|
|
|
ORDER BY route_count DESC |
|
7300
|
|
|
LIMIT 10 OFFSET 0"; |
|
7301
|
|
|
|
|
7302
|
|
|
|
|
7303
|
|
|
$sth = $this->db->prepare($query); |
|
7304
|
|
|
$sth->execute(); |
|
7305
|
|
|
|
|
7306
|
|
|
$routes_array = array(); |
|
7307
|
|
|
$temp_array = array(); |
|
7308
|
|
|
|
|
7309
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7310
|
|
|
{ |
|
7311
|
|
|
$temp_array['route_count'] = $row['route_count']; |
|
7312
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
7313
|
|
|
$temp_array['airport_departure_name'] = $row['airport_departure_name']; |
|
7314
|
|
|
$temp_array['airport_departure_city'] = $row['airport_departure_city']; |
|
7315
|
|
|
$temp_array['airport_departure_country'] = $row['airport_departure_country']; |
|
7316
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7317
|
|
|
$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; |
|
7318
|
|
|
$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; |
|
7319
|
|
|
$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; |
|
7320
|
|
|
|
|
7321
|
|
|
$routes_array[] = $temp_array; |
|
7322
|
|
|
} |
|
7323
|
|
|
|
|
7324
|
|
|
return $routes_array; |
|
7325
|
|
|
} |
|
7326
|
|
|
|
|
7327
|
|
|
|
|
7328
|
|
|
|
|
7329
|
|
|
|
|
7330
|
|
|
/** |
|
7331
|
|
|
* Gets all route combinations based on an aircraft |
|
7332
|
|
|
* |
|
7333
|
|
|
* @return Array the route list |
|
7334
|
|
|
* |
|
7335
|
|
|
*/ |
|
7336
|
|
|
public function countAllRoutesByAircraft($aircraft_icao,$filters = array()) |
|
7337
|
|
|
{ |
|
7338
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7339
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
7340
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7341
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
|
7342
|
|
|
GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7343
|
|
|
ORDER BY route_count DESC"; |
|
7344
|
|
|
|
|
7345
|
|
|
$sth = $this->db->prepare($query); |
|
7346
|
|
|
$sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
|
7347
|
|
|
|
|
7348
|
|
|
$routes_array = array(); |
|
7349
|
|
|
$temp_array = array(); |
|
7350
|
|
|
|
|
7351
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7352
|
|
|
{ |
|
7353
|
|
|
$temp_array['route_count'] = $row['route_count']; |
|
7354
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
7355
|
|
|
$temp_array['airport_departure_name'] = $row['airport_departure_name']; |
|
7356
|
|
|
$temp_array['airport_departure_city'] = $row['airport_departure_city']; |
|
7357
|
|
|
$temp_array['airport_departure_country'] = $row['airport_departure_country']; |
|
7358
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7359
|
|
|
$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; |
|
7360
|
|
|
$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; |
|
7361
|
|
|
$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; |
|
7362
|
|
|
|
|
7363
|
|
|
$routes_array[] = $temp_array; |
|
7364
|
|
|
} |
|
7365
|
|
|
|
|
7366
|
|
|
return $routes_array; |
|
7367
|
|
|
} |
|
7368
|
|
|
|
|
7369
|
|
|
|
|
7370
|
|
|
/** |
|
7371
|
|
|
* Gets all route combinations based on an aircraft registration |
|
7372
|
|
|
* |
|
7373
|
|
|
* @return Array the route list |
|
7374
|
|
|
* |
|
7375
|
|
|
*/ |
|
7376
|
|
|
public function countAllRoutesByRegistration($registration, $filters = array()) |
|
7377
|
|
|
{ |
|
7378
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7379
|
|
|
$registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
7380
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7381
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.registration = :registration |
|
7382
|
|
|
GROUP BY route |
|
7383
|
|
|
ORDER BY route_count DESC"; |
|
7384
|
|
|
|
|
7385
|
|
|
|
|
7386
|
|
|
$sth = $this->db->prepare($query); |
|
7387
|
|
|
$sth->execute(array(':registration' => $registration)); |
|
7388
|
|
|
|
|
7389
|
|
|
$routes_array = array(); |
|
7390
|
|
|
$temp_array = array(); |
|
7391
|
|
|
|
|
7392
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7393
|
|
|
{ |
|
7394
|
|
|
$temp_array['route_count'] = $row['route_count']; |
|
7395
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
7396
|
|
|
$temp_array['airport_departure_name'] = $row['airport_departure_name']; |
|
7397
|
|
|
$temp_array['airport_departure_city'] = $row['airport_departure_city']; |
|
7398
|
|
|
$temp_array['airport_departure_country'] = $row['airport_departure_country']; |
|
7399
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7400
|
|
|
$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; |
|
7401
|
|
|
$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; |
|
7402
|
|
|
$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; |
|
7403
|
|
|
|
|
7404
|
|
|
$routes_array[] = $temp_array; |
|
7405
|
|
|
} |
|
7406
|
|
|
|
|
7407
|
|
|
return $routes_array; |
|
7408
|
|
|
} |
|
7409
|
|
|
|
|
7410
|
|
|
|
|
7411
|
|
|
|
|
7412
|
|
|
/** |
|
7413
|
|
|
* Gets all route combinations based on an airline |
|
7414
|
|
|
* |
|
7415
|
|
|
* @return Array the route list |
|
7416
|
|
|
* |
|
7417
|
|
|
*/ |
|
7418
|
|
|
public function countAllRoutesByAirline($airline_icao, $filters = array()) |
|
7419
|
|
|
{ |
|
7420
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7421
|
|
|
$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
7422
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7423
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao |
|
7424
|
|
|
GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7425
|
|
|
ORDER BY route_count DESC"; |
|
7426
|
|
|
|
|
7427
|
|
|
|
|
7428
|
|
|
$sth = $this->db->prepare($query); |
|
7429
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao)); |
|
7430
|
|
|
|
|
7431
|
|
|
$routes_array = array(); |
|
7432
|
|
|
$temp_array = array(); |
|
7433
|
|
|
|
|
7434
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7435
|
|
|
{ |
|
7436
|
|
|
$temp_array['route_count'] = $row['route_count']; |
|
7437
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
7438
|
|
|
$temp_array['airport_departure_name'] = $row['airport_departure_name']; |
|
7439
|
|
|
$temp_array['airport_departure_city'] = $row['airport_departure_city']; |
|
7440
|
|
|
$temp_array['airport_departure_country'] = $row['airport_departure_country']; |
|
7441
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7442
|
|
|
$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; |
|
7443
|
|
|
$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; |
|
7444
|
|
|
$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; |
|
7445
|
|
|
|
|
7446
|
|
|
$routes_array[] = $temp_array; |
|
7447
|
|
|
} |
|
7448
|
|
|
|
|
7449
|
|
|
return $routes_array; |
|
7450
|
|
|
} |
|
7451
|
|
|
|
|
7452
|
|
|
|
|
7453
|
|
|
|
|
7454
|
|
|
/** |
|
7455
|
|
|
* Gets all route combinations based on an airport |
|
7456
|
|
|
* |
|
7457
|
|
|
* @return Array the route list |
|
7458
|
|
|
* |
|
7459
|
|
|
*/ |
|
7460
|
|
|
public function countAllRoutesByAirport($airport_icao, $filters = array()) |
|
7461
|
|
|
{ |
|
7462
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7463
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
7464
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7465
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
|
7466
|
|
|
GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7467
|
|
|
ORDER BY route_count DESC"; |
|
7468
|
|
|
|
|
7469
|
|
|
$sth = $this->db->prepare($query); |
|
7470
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao)); |
|
7471
|
|
|
|
|
7472
|
|
|
$routes_array = array(); |
|
7473
|
|
|
$temp_array = array(); |
|
7474
|
|
|
|
|
7475
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7476
|
|
|
{ |
|
7477
|
|
|
$temp_array['route_count'] = $row['route_count']; |
|
7478
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
7479
|
|
|
$temp_array['airport_departure_name'] = $row['airport_departure_name']; |
|
7480
|
|
|
$temp_array['airport_departure_city'] = $row['airport_departure_city']; |
|
7481
|
|
|
$temp_array['airport_departure_country'] = $row['airport_departure_country']; |
|
7482
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7483
|
|
|
$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; |
|
7484
|
|
|
$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; |
|
7485
|
|
|
$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; |
|
7486
|
|
|
|
|
7487
|
|
|
$routes_array[] = $temp_array; |
|
7488
|
|
|
} |
|
7489
|
|
|
|
|
7490
|
|
|
return $routes_array; |
|
7491
|
|
|
} |
|
7492
|
|
|
|
|
7493
|
|
|
|
|
7494
|
|
|
|
|
7495
|
|
|
/** |
|
7496
|
|
|
* Gets all route combinations based on an country |
|
7497
|
|
|
* |
|
7498
|
|
|
* @return Array the route list |
|
7499
|
|
|
* |
|
7500
|
|
|
*/ |
|
7501
|
|
|
public function countAllRoutesByCountry($country, $filters = array()) |
|
7502
|
|
|
{ |
|
7503
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7504
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
7505
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7506
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
|
7507
|
|
|
GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7508
|
|
|
ORDER BY route_count DESC"; |
|
7509
|
|
|
|
|
7510
|
|
|
$sth = $this->db->prepare($query); |
|
7511
|
|
|
$sth->execute(array(':country' => $country)); |
|
7512
|
|
|
|
|
7513
|
|
|
$routes_array = array(); |
|
7514
|
|
|
$temp_array = array(); |
|
7515
|
|
|
|
|
7516
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7517
|
|
|
{ |
|
7518
|
|
|
$temp_array['route_count'] = $row['route_count']; |
|
7519
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
7520
|
|
|
$temp_array['airport_departure_name'] = $row['airport_departure_name']; |
|
7521
|
|
|
$temp_array['airport_departure_city'] = $row['airport_departure_city']; |
|
7522
|
|
|
$temp_array['airport_departure_country'] = $row['airport_departure_country']; |
|
7523
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7524
|
|
|
$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; |
|
7525
|
|
|
$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; |
|
7526
|
|
|
$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; |
|
7527
|
|
|
|
|
7528
|
|
|
$routes_array[] = $temp_array; |
|
7529
|
|
|
} |
|
7530
|
|
|
|
|
7531
|
|
|
return $routes_array; |
|
7532
|
|
|
} |
|
7533
|
|
|
|
|
7534
|
|
|
|
|
7535
|
|
|
/** |
|
7536
|
|
|
* Gets all route combinations based on an date |
|
7537
|
|
|
* |
|
7538
|
|
|
* @return Array the route list |
|
7539
|
|
|
* |
|
7540
|
|
|
*/ |
|
7541
|
|
|
public function countAllRoutesByDate($date, $filters = array()) |
|
7542
|
|
|
{ |
|
7543
|
|
|
global $globalTimezone, $globalDBdriver; |
|
7544
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7545
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
7546
|
|
|
if ($globalTimezone != '') { |
|
7547
|
|
|
date_default_timezone_set($globalTimezone); |
|
7548
|
|
|
$datetime = new DateTime($date); |
|
7549
|
|
|
$offset = $datetime->format('P'); |
|
7550
|
|
|
} else $offset = '+00:00'; |
|
7551
|
|
|
|
|
7552
|
|
|
if ($globalDBdriver == 'mysql') { |
|
7553
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7554
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
7555
|
|
|
GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7556
|
|
|
ORDER BY route_count DESC"; |
|
7557
|
|
|
} else { |
|
7558
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7559
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
|
7560
|
|
|
GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7561
|
|
|
ORDER BY route_count DESC"; |
|
7562
|
|
|
} |
|
7563
|
|
|
|
|
7564
|
|
|
$sth = $this->db->prepare($query); |
|
7565
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
7566
|
|
|
|
|
7567
|
|
|
$routes_array = array(); |
|
7568
|
|
|
$temp_array = array(); |
|
7569
|
|
|
|
|
7570
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7571
|
|
|
{ |
|
7572
|
|
|
$temp_array['route_count'] = $row['route_count']; |
|
7573
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
7574
|
|
|
$temp_array['airport_departure_name'] = $row['airport_departure_name']; |
|
7575
|
|
|
$temp_array['airport_departure_city'] = $row['airport_departure_city']; |
|
7576
|
|
|
$temp_array['airport_departure_country'] = $row['airport_departure_country']; |
|
7577
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7578
|
|
|
$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; |
|
7579
|
|
|
$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; |
|
7580
|
|
|
$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; |
|
7581
|
|
|
|
|
7582
|
|
|
$routes_array[] = $temp_array; |
|
7583
|
|
|
} |
|
7584
|
|
|
|
|
7585
|
|
|
return $routes_array; |
|
7586
|
|
|
} |
|
7587
|
|
|
|
|
7588
|
|
|
|
|
7589
|
|
|
/** |
|
7590
|
|
|
* Gets all route combinations based on an ident/callsign |
|
7591
|
|
|
* |
|
7592
|
|
|
* @return Array the route list |
|
7593
|
|
|
* |
|
7594
|
|
|
*/ |
|
7595
|
|
|
public function countAllRoutesByIdent($ident, $filters = array()) |
|
7596
|
|
|
{ |
|
7597
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7598
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
7599
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7600
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.ident = :ident |
|
7601
|
|
|
GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7602
|
|
|
ORDER BY route_count DESC"; |
|
7603
|
|
|
|
|
7604
|
|
|
|
|
7605
|
|
|
$sth = $this->db->prepare($query); |
|
7606
|
|
|
$sth->execute(array(':ident' => $ident)); |
|
7607
|
|
|
|
|
7608
|
|
|
$routes_array = array(); |
|
7609
|
|
|
$temp_array = array(); |
|
7610
|
|
|
|
|
7611
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7612
|
|
|
{ |
|
7613
|
|
|
$temp_array['route_count'] = $row['route_count']; |
|
7614
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
7615
|
|
|
$temp_array['airport_departure_name'] = $row['airport_departure_name']; |
|
7616
|
|
|
$temp_array['airport_departure_city'] = $row['airport_departure_city']; |
|
7617
|
|
|
$temp_array['airport_departure_country'] = $row['airport_departure_country']; |
|
7618
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7619
|
|
|
$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; |
|
7620
|
|
|
$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; |
|
7621
|
|
|
$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; |
|
7622
|
|
|
|
|
7623
|
|
|
$routes_array[] = $temp_array; |
|
7624
|
|
|
} |
|
7625
|
|
|
|
|
7626
|
|
|
return $routes_array; |
|
7627
|
|
|
} |
|
7628
|
|
|
|
|
7629
|
|
|
|
|
7630
|
|
|
/** |
|
7631
|
|
|
* Gets all route combinations based on an manufacturer |
|
7632
|
|
|
* |
|
7633
|
|
|
* @return Array the route list |
|
7634
|
|
|
* |
|
7635
|
|
|
*/ |
|
7636
|
|
|
public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array()) |
|
7637
|
|
|
{ |
|
7638
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7639
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
7640
|
|
|
$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7641
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
7642
|
|
|
GROUP BY route |
|
7643
|
|
|
ORDER BY route_count DESC"; |
|
7644
|
|
|
|
|
7645
|
|
|
|
|
7646
|
|
|
$sth = $this->db->prepare($query); |
|
7647
|
|
|
$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
7648
|
|
|
|
|
7649
|
|
|
$routes_array = array(); |
|
7650
|
|
|
$temp_array = array(); |
|
7651
|
|
|
|
|
7652
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7653
|
|
|
{ |
|
7654
|
|
|
$temp_array['route_count'] = $row['route_count']; |
|
7655
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
7656
|
|
|
$temp_array['airport_departure_name'] = $row['airport_departure_name']; |
|
7657
|
|
|
$temp_array['airport_departure_city'] = $row['airport_departure_city']; |
|
7658
|
|
|
$temp_array['airport_departure_country'] = $row['airport_departure_country']; |
|
7659
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7660
|
|
|
$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; |
|
7661
|
|
|
$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; |
|
7662
|
|
|
$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; |
|
7663
|
|
|
|
|
7664
|
|
|
$routes_array[] = $temp_array; |
|
7665
|
|
|
} |
|
7666
|
|
|
|
|
7667
|
|
|
return $routes_array; |
|
7668
|
|
|
} |
|
7669
|
|
|
|
|
7670
|
|
|
|
|
7671
|
|
|
|
|
7672
|
|
|
/** |
|
7673
|
|
|
* Gets all route combinations with waypoints |
|
7674
|
|
|
* |
|
7675
|
|
|
* @return Array the route list |
|
7676
|
|
|
* |
|
7677
|
|
|
*/ |
|
7678
|
|
|
public function countAllRoutesWithWaypoints($filters = array()) |
|
7679
|
|
|
{ |
|
7680
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7681
|
|
|
$query = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
7682
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.waypoints <> '' |
|
7683
|
|
|
GROUP BY route, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
7684
|
|
|
ORDER BY route_count DESC |
|
7685
|
|
|
LIMIT 10 OFFSET 0"; |
|
7686
|
|
|
|
|
7687
|
|
|
|
|
7688
|
|
|
$sth = $this->db->prepare($query); |
|
7689
|
|
|
$sth->execute(); |
|
7690
|
|
|
|
|
7691
|
|
|
$routes_array = array(); |
|
7692
|
|
|
$temp_array = array(); |
|
7693
|
|
|
|
|
7694
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7695
|
|
|
{ |
|
7696
|
|
|
$temp_array['spotter_id'] = $row['spotter_id']; |
|
7697
|
|
|
$temp_array['route_count'] = $row['route_count']; |
|
7698
|
|
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
|
7699
|
|
|
$temp_array['airport_departure_name'] = $row['airport_departure_name']; |
|
7700
|
|
|
$temp_array['airport_departure_city'] = $row['airport_departure_city']; |
|
7701
|
|
|
$temp_array['airport_departure_country'] = $row['airport_departure_country']; |
|
7702
|
|
|
$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
|
7703
|
|
|
$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; |
|
7704
|
|
|
$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; |
|
7705
|
|
|
$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; |
|
7706
|
|
|
|
|
7707
|
|
|
$routes_array[] = $temp_array; |
|
7708
|
|
|
} |
|
7709
|
|
|
|
|
7710
|
|
|
return $routes_array; |
|
7711
|
|
|
} |
|
7712
|
|
|
|
|
7713
|
|
|
/** |
|
7714
|
|
|
* Gets all callsigns that have flown over |
|
7715
|
|
|
* |
|
7716
|
|
|
* @return Array the callsign list |
|
7717
|
|
|
* |
|
7718
|
|
|
*/ |
|
7719
|
|
|
public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
7720
|
|
|
{ |
|
7721
|
|
|
global $globalDBdriver; |
|
7722
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7723
|
|
|
$query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao |
|
7724
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' "; |
|
7725
|
|
|
if ($olderthanmonths > 0) { |
|
7726
|
|
|
if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
7727
|
|
|
else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
7728
|
|
|
} |
|
7729
|
|
|
if ($sincedate != '') { |
|
7730
|
|
|
if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'"; |
|
7731
|
|
|
else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
7732
|
|
|
} |
|
7733
|
|
|
$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
|
7734
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7735
|
|
|
|
|
7736
|
|
|
$sth = $this->db->prepare($query); |
|
7737
|
|
|
$sth->execute(); |
|
7738
|
|
|
|
|
7739
|
|
|
$callsign_array = array(); |
|
7740
|
|
|
$temp_array = array(); |
|
7741
|
|
|
|
|
7742
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7743
|
|
|
{ |
|
7744
|
|
|
$temp_array['callsign_icao'] = $row['ident']; |
|
7745
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
7746
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
7747
|
|
|
$temp_array['callsign_icao_count'] = $row['callsign_icao_count']; |
|
7748
|
|
|
|
|
7749
|
|
|
$callsign_array[] = $temp_array; |
|
7750
|
|
|
} |
|
7751
|
|
|
|
|
7752
|
|
|
return $callsign_array; |
|
7753
|
|
|
} |
|
7754
|
|
|
|
|
7755
|
|
|
/** |
|
7756
|
|
|
* Gets all callsigns that have flown over |
|
7757
|
|
|
* |
|
7758
|
|
|
* @return Array the callsign list |
|
7759
|
|
|
* |
|
7760
|
|
|
*/ |
|
7761
|
|
|
public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
7762
|
|
|
{ |
|
7763
|
|
|
global $globalDBdriver; |
|
7764
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7765
|
|
|
$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name |
|
7766
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao <> '' "; |
|
7767
|
|
|
if ($olderthanmonths > 0) { |
|
7768
|
|
|
if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
7769
|
|
|
else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
7770
|
|
|
} |
|
7771
|
|
|
if ($sincedate != '') { |
|
7772
|
|
|
if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' "; |
|
7773
|
|
|
else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
7774
|
|
|
} |
|
7775
|
|
|
$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
|
7776
|
|
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7777
|
|
|
|
|
7778
|
|
|
$sth = $this->db->prepare($query); |
|
7779
|
|
|
$sth->execute(); |
|
7780
|
|
|
|
|
7781
|
|
|
$callsign_array = array(); |
|
7782
|
|
|
$temp_array = array(); |
|
7783
|
|
|
|
|
7784
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7785
|
|
|
{ |
|
7786
|
|
|
$temp_array['callsign_icao'] = $row['ident']; |
|
7787
|
|
|
$temp_array['airline_name'] = $row['airline_name']; |
|
7788
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
7789
|
|
|
$temp_array['callsign_icao_count'] = $row['callsign_icao_count']; |
|
7790
|
|
|
|
|
7791
|
|
|
$callsign_array[] = $temp_array; |
|
7792
|
|
|
} |
|
7793
|
|
|
|
|
7794
|
|
|
return $callsign_array; |
|
7795
|
|
|
} |
|
7796
|
|
|
|
|
7797
|
|
|
|
|
7798
|
|
|
|
|
7799
|
|
|
|
|
7800
|
|
|
/** |
|
7801
|
|
|
* Counts all dates |
|
7802
|
|
|
* |
|
7803
|
|
|
* @return Array the date list |
|
7804
|
|
|
* |
|
7805
|
|
|
*/ |
|
7806
|
|
|
public function countAllDates($filters = array()) |
|
7807
|
|
|
{ |
|
7808
|
|
|
global $globalTimezone, $globalDBdriver; |
|
7809
|
|
|
if ($globalTimezone != '') { |
|
7810
|
|
|
date_default_timezone_set($globalTimezone); |
|
7811
|
|
|
$datetime = new DateTime(); |
|
7812
|
|
|
$offset = $datetime->format('P'); |
|
7813
|
|
|
} else $offset = '+00:00'; |
|
7814
|
|
|
|
|
7815
|
|
|
if ($globalDBdriver == 'mysql') { |
|
7816
|
|
|
$query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
7817
|
|
|
FROM spotter_output"; |
|
7818
|
|
|
$query .= $this->getFilter($filters); |
|
7819
|
|
|
$query .= " GROUP BY date_name |
|
7820
|
|
|
ORDER BY date_count DESC |
|
7821
|
|
|
LIMIT 10 OFFSET 0"; |
|
7822
|
|
|
} else { |
|
7823
|
|
|
$query = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count |
|
7824
|
|
|
FROM spotter_output"; |
|
7825
|
|
|
$query .= $this->getFilter($filters); |
|
7826
|
|
|
$query .= " GROUP BY date_name |
|
7827
|
|
|
ORDER BY date_count DESC |
|
7828
|
|
|
LIMIT 10 OFFSET 0"; |
|
7829
|
|
|
} |
|
7830
|
|
|
|
|
7831
|
|
|
|
|
7832
|
|
|
$sth = $this->db->prepare($query); |
|
7833
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
7834
|
|
|
|
|
7835
|
|
|
$date_array = array(); |
|
7836
|
|
|
$temp_array = array(); |
|
7837
|
|
|
|
|
7838
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7839
|
|
|
{ |
|
7840
|
|
|
$temp_array['date_name'] = $row['date_name']; |
|
7841
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
7842
|
|
|
|
|
7843
|
|
|
$date_array[] = $temp_array; |
|
7844
|
|
|
} |
|
7845
|
|
|
|
|
7846
|
|
|
return $date_array; |
|
7847
|
|
|
} |
|
7848
|
|
|
|
|
7849
|
|
|
/** |
|
7850
|
|
|
* Counts all dates |
|
7851
|
|
|
* |
|
7852
|
|
|
* @return Array the date list |
|
7853
|
|
|
* |
|
7854
|
|
|
*/ |
|
7855
|
|
|
public function countAllDatesByAirlines($filters = array()) |
|
7856
|
|
|
{ |
|
7857
|
|
|
global $globalTimezone, $globalDBdriver; |
|
7858
|
|
|
if ($globalTimezone != '') { |
|
7859
|
|
|
date_default_timezone_set($globalTimezone); |
|
7860
|
|
|
$datetime = new DateTime(); |
|
7861
|
|
|
$offset = $datetime->format('P'); |
|
7862
|
|
|
} else $offset = '+00:00'; |
|
7863
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7864
|
|
|
if ($globalDBdriver == 'mysql') { |
|
7865
|
|
|
$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
7866
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
|
7867
|
|
|
GROUP BY spotter_output.airline_icao, date_name |
|
7868
|
|
|
ORDER BY date_count DESC |
|
7869
|
|
|
LIMIT 10 OFFSET 0"; |
|
7870
|
|
|
} else { |
|
7871
|
|
|
$query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count |
|
7872
|
|
|
FROM spotter_output |
|
7873
|
|
|
WHERE spotter_output.airline_icao <> '' |
|
7874
|
|
|
GROUP BY spotter_output.airline_icao, date_name |
|
7875
|
|
|
ORDER BY date_count DESC |
|
7876
|
|
|
LIMIT 10 OFFSET 0"; |
|
7877
|
|
|
} |
|
7878
|
|
|
|
|
7879
|
|
|
|
|
7880
|
|
|
$sth = $this->db->prepare($query); |
|
7881
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
7882
|
|
|
|
|
7883
|
|
|
$date_array = array(); |
|
7884
|
|
|
$temp_array = array(); |
|
7885
|
|
|
|
|
7886
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7887
|
|
|
{ |
|
7888
|
|
|
$temp_array['date_name'] = $row['date_name']; |
|
7889
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
7890
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
7891
|
|
|
|
|
7892
|
|
|
$date_array[] = $temp_array; |
|
7893
|
|
|
} |
|
7894
|
|
|
|
|
7895
|
|
|
return $date_array; |
|
7896
|
|
|
} |
|
7897
|
|
|
|
|
7898
|
|
|
/** |
|
7899
|
|
|
* Counts all dates during the last 7 days |
|
7900
|
|
|
* |
|
7901
|
|
|
* @return Array the date list |
|
7902
|
|
|
* |
|
7903
|
|
|
*/ |
|
7904
|
|
|
public function countAllDatesLast7Days($filters = array()) |
|
7905
|
|
|
{ |
|
7906
|
|
|
global $globalTimezone, $globalDBdriver; |
|
7907
|
|
|
if ($globalTimezone != '') { |
|
7908
|
|
|
date_default_timezone_set($globalTimezone); |
|
7909
|
|
|
$datetime = new DateTime(); |
|
7910
|
|
|
$offset = $datetime->format('P'); |
|
7911
|
|
|
} else $offset = '+00:00'; |
|
7912
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7913
|
|
|
if ($globalDBdriver == 'mysql') { |
|
7914
|
|
|
$query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
7915
|
|
|
FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
|
7916
|
|
|
$query .= " GROUP BY date_name |
|
7917
|
|
|
ORDER BY spotter_output.date ASC"; |
|
7918
|
|
|
$query_data = array(':offset' => $offset); |
|
7919
|
|
|
} else { |
|
7920
|
|
|
$query = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count |
|
7921
|
|
|
FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '7 DAYS'"; |
|
7922
|
|
|
$query .= " GROUP BY date_name |
|
7923
|
|
|
ORDER BY date_name ASC"; |
|
7924
|
|
|
$query_data = array(':offset' => $offset); |
|
7925
|
|
|
} |
|
7926
|
|
|
|
|
7927
|
|
|
$sth = $this->db->prepare($query); |
|
7928
|
|
|
$sth->execute($query_data); |
|
7929
|
|
|
|
|
7930
|
|
|
$date_array = array(); |
|
7931
|
|
|
$temp_array = array(); |
|
7932
|
|
|
|
|
7933
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7934
|
|
|
{ |
|
7935
|
|
|
$temp_array['date_name'] = $row['date_name']; |
|
7936
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
7937
|
|
|
|
|
7938
|
|
|
$date_array[] = $temp_array; |
|
7939
|
|
|
} |
|
7940
|
|
|
|
|
7941
|
|
|
return $date_array; |
|
7942
|
|
|
} |
|
7943
|
|
|
|
|
7944
|
|
|
/** |
|
7945
|
|
|
* Counts all dates during the last month |
|
7946
|
|
|
* |
|
7947
|
|
|
* @return Array the date list |
|
7948
|
|
|
* |
|
7949
|
|
|
*/ |
|
7950
|
|
|
public function countAllDatesLastMonth($filters = array()) |
|
7951
|
|
|
{ |
|
7952
|
|
|
global $globalTimezone, $globalDBdriver; |
|
7953
|
|
|
if ($globalTimezone != '') { |
|
7954
|
|
|
date_default_timezone_set($globalTimezone); |
|
7955
|
|
|
$datetime = new DateTime(); |
|
7956
|
|
|
$offset = $datetime->format('P'); |
|
7957
|
|
|
} else $offset = '+00:00'; |
|
7958
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
7959
|
|
|
if ($globalDBdriver == 'mysql') { |
|
7960
|
|
|
$query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
7961
|
|
|
FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
|
7962
|
|
|
$query .= " GROUP BY date_name |
|
7963
|
|
|
ORDER BY spotter_output.date ASC"; |
|
7964
|
|
|
$query_data = array(':offset' => $offset); |
|
7965
|
|
|
} else { |
|
7966
|
|
|
$query = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count |
|
7967
|
|
|
FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'"; |
|
7968
|
|
|
$query .= " GROUP BY date_name |
|
7969
|
|
|
ORDER BY date_name ASC"; |
|
7970
|
|
|
$query_data = array(':offset' => $offset); |
|
7971
|
|
|
} |
|
7972
|
|
|
|
|
7973
|
|
|
$sth = $this->db->prepare($query); |
|
7974
|
|
|
$sth->execute($query_data); |
|
7975
|
|
|
|
|
7976
|
|
|
$date_array = array(); |
|
7977
|
|
|
$temp_array = array(); |
|
7978
|
|
|
|
|
7979
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
7980
|
|
|
{ |
|
7981
|
|
|
$temp_array['date_name'] = $row['date_name']; |
|
7982
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
7983
|
|
|
|
|
7984
|
|
|
$date_array[] = $temp_array; |
|
7985
|
|
|
} |
|
7986
|
|
|
|
|
7987
|
|
|
return $date_array; |
|
7988
|
|
|
} |
|
7989
|
|
|
|
|
7990
|
|
|
|
|
7991
|
|
|
/** |
|
7992
|
|
|
* Counts all dates during the last month |
|
7993
|
|
|
* |
|
7994
|
|
|
* @return Array the date list |
|
7995
|
|
|
* |
|
7996
|
|
|
*/ |
|
7997
|
|
|
public function countAllDatesLastMonthByAirlines($filters = array()) |
|
7998
|
|
|
{ |
|
7999
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8000
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8001
|
|
|
if ($globalTimezone != '') { |
|
8002
|
|
|
date_default_timezone_set($globalTimezone); |
|
8003
|
|
|
$datetime = new DateTime(); |
|
8004
|
|
|
$offset = $datetime->format('P'); |
|
8005
|
|
|
} else $offset = '+00:00'; |
|
8006
|
|
|
|
|
8007
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8008
|
|
|
$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
8009
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH) |
|
8010
|
|
|
GROUP BY spotter_output.airline_icao, date_name |
|
8011
|
|
|
ORDER BY spotter_output.date ASC"; |
|
8012
|
|
|
$query_data = array(':offset' => $offset); |
|
8013
|
|
|
} else { |
|
8014
|
|
|
$query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count |
|
8015
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS' |
|
8016
|
|
|
GROUP BY spotter_output.airline_icao, date_name |
|
8017
|
|
|
ORDER BY date_name ASC"; |
|
8018
|
|
|
$query_data = array(':offset' => $offset); |
|
8019
|
|
|
} |
|
8020
|
|
|
|
|
8021
|
|
|
$sth = $this->db->prepare($query); |
|
8022
|
|
|
$sth->execute($query_data); |
|
8023
|
|
|
|
|
8024
|
|
|
$date_array = array(); |
|
8025
|
|
|
$temp_array = array(); |
|
8026
|
|
|
|
|
8027
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8028
|
|
|
{ |
|
8029
|
|
|
$temp_array['date_name'] = $row['date_name']; |
|
8030
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8031
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
8032
|
|
|
|
|
8033
|
|
|
$date_array[] = $temp_array; |
|
8034
|
|
|
} |
|
8035
|
|
|
|
|
8036
|
|
|
return $date_array; |
|
8037
|
|
|
} |
|
8038
|
|
|
|
|
8039
|
|
|
|
|
8040
|
|
|
/** |
|
8041
|
|
|
* Counts all month |
|
8042
|
|
|
* |
|
8043
|
|
|
* @return Array the month list |
|
8044
|
|
|
* |
|
8045
|
|
|
*/ |
|
8046
|
|
|
public function countAllMonths($filters = array()) |
|
8047
|
|
|
{ |
|
8048
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8049
|
|
|
if ($globalTimezone != '') { |
|
8050
|
|
|
date_default_timezone_set($globalTimezone); |
|
8051
|
|
|
$datetime = new DateTime(); |
|
8052
|
|
|
$offset = $datetime->format('P'); |
|
8053
|
|
|
} else $offset = '+00:00'; |
|
8054
|
|
|
|
|
8055
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8056
|
|
|
$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
|
8057
|
|
|
FROM spotter_output"; |
|
8058
|
|
|
$query .= $this->getFilter($filters); |
|
8059
|
|
|
$query .= " GROUP BY year_name, month_name ORDER BY date_count DESC"; |
|
8060
|
|
|
} else { |
|
8061
|
|
|
$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count |
|
8062
|
|
|
FROM spotter_output"; |
|
8063
|
|
|
$query .= $this->getFilter($filters); |
|
8064
|
|
|
$query .= " GROUP BY year_name, month_name ORDER BY date_count DESC"; |
|
8065
|
|
|
} |
|
8066
|
|
|
|
|
8067
|
|
|
|
|
8068
|
|
|
$sth = $this->db->prepare($query); |
|
8069
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8070
|
|
|
|
|
8071
|
|
|
$date_array = array(); |
|
8072
|
|
|
$temp_array = array(); |
|
8073
|
|
|
|
|
8074
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8075
|
|
|
{ |
|
8076
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8077
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8078
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8079
|
|
|
|
|
8080
|
|
|
$date_array[] = $temp_array; |
|
8081
|
|
|
} |
|
8082
|
|
|
|
|
8083
|
|
|
return $date_array; |
|
8084
|
|
|
} |
|
8085
|
|
|
|
|
8086
|
|
|
/** |
|
8087
|
|
|
* Counts all month |
|
8088
|
|
|
* |
|
8089
|
|
|
* @return Array the month list |
|
8090
|
|
|
* |
|
8091
|
|
|
*/ |
|
8092
|
|
|
public function countAllMonthsByAirlines($filters = array()) |
|
8093
|
|
|
{ |
|
8094
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8095
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8096
|
|
|
if ($globalTimezone != '') { |
|
8097
|
|
|
date_default_timezone_set($globalTimezone); |
|
8098
|
|
|
$datetime = new DateTime(); |
|
8099
|
|
|
$offset = $datetime->format('P'); |
|
8100
|
|
|
} else $offset = '+00:00'; |
|
8101
|
|
|
|
|
8102
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8103
|
|
|
$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
|
8104
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
|
8105
|
|
|
GROUP BY spotter_output.airline_icao, year_name, month_name |
|
8106
|
|
|
ORDER BY date_count DESC"; |
|
8107
|
|
|
} else { |
|
8108
|
|
|
$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count |
|
8109
|
|
|
FROM spotter_output |
|
8110
|
|
|
WHERE spotter_output.airline_icao <> '' |
|
8111
|
|
|
GROUP BY spotter_output.airline_icao, year_name, month_name |
|
8112
|
|
|
ORDER BY date_count DESC"; |
|
8113
|
|
|
} |
|
8114
|
|
|
|
|
8115
|
|
|
|
|
8116
|
|
|
$sth = $this->db->prepare($query); |
|
8117
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8118
|
|
|
|
|
8119
|
|
|
$date_array = array(); |
|
8120
|
|
|
$temp_array = array(); |
|
8121
|
|
|
|
|
8122
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8123
|
|
|
{ |
|
8124
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8125
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8126
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8127
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
8128
|
|
|
|
|
8129
|
|
|
$date_array[] = $temp_array; |
|
8130
|
|
|
} |
|
8131
|
|
|
|
|
8132
|
|
|
return $date_array; |
|
8133
|
|
|
} |
|
8134
|
|
|
|
|
8135
|
|
|
/** |
|
8136
|
|
|
* Counts all military month |
|
8137
|
|
|
* |
|
8138
|
|
|
* @return Array the month list |
|
8139
|
|
|
* |
|
8140
|
|
|
*/ |
|
8141
|
|
|
public function countAllMilitaryMonths($filters = array()) |
|
8142
|
|
|
{ |
|
8143
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8144
|
|
|
if ($globalTimezone != '') { |
|
8145
|
|
|
date_default_timezone_set($globalTimezone); |
|
8146
|
|
|
$datetime = new DateTime(); |
|
8147
|
|
|
$offset = $datetime->format('P'); |
|
8148
|
|
|
} else $offset = '+00:00'; |
|
8149
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8150
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8151
|
|
|
$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
|
8152
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_type = 'military' |
|
8153
|
|
|
GROUP BY year_name, month_name |
|
8154
|
|
|
ORDER BY date_count DESC"; |
|
8155
|
|
|
} else { |
|
8156
|
|
|
$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count |
|
8157
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_type = 'military' |
|
8158
|
|
|
GROUP BY year_name, month_name |
|
8159
|
|
|
ORDER BY date_count DESC"; |
|
8160
|
|
|
} |
|
8161
|
|
|
|
|
8162
|
|
|
$sth = $this->db->prepare($query); |
|
8163
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8164
|
|
|
|
|
8165
|
|
|
$date_array = array(); |
|
8166
|
|
|
$temp_array = array(); |
|
8167
|
|
|
|
|
8168
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8169
|
|
|
{ |
|
8170
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8171
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8172
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8173
|
|
|
|
|
8174
|
|
|
$date_array[] = $temp_array; |
|
8175
|
|
|
} |
|
8176
|
|
|
|
|
8177
|
|
|
return $date_array; |
|
8178
|
|
|
} |
|
8179
|
|
|
|
|
8180
|
|
|
/** |
|
8181
|
|
|
* Counts all month owners |
|
8182
|
|
|
* |
|
8183
|
|
|
* @return Array the month list |
|
8184
|
|
|
* |
|
8185
|
|
|
*/ |
|
8186
|
|
|
public function countAllMonthsOwners($filters = array()) |
|
8187
|
|
|
{ |
|
8188
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8189
|
|
|
if ($globalTimezone != '') { |
|
8190
|
|
|
date_default_timezone_set($globalTimezone); |
|
8191
|
|
|
$datetime = new DateTime(); |
|
8192
|
|
|
$offset = $datetime->format('P'); |
|
8193
|
|
|
} else $offset = '+00:00'; |
|
8194
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8195
|
|
|
|
|
8196
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8197
|
|
|
$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count |
|
8198
|
|
|
FROM spotter_output".$filter_query." owner_name <> '' |
|
8199
|
|
|
GROUP BY year_name, month_name |
|
8200
|
|
|
ORDER BY date_count DESC"; |
|
8201
|
|
|
} else { |
|
8202
|
|
|
$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count |
|
8203
|
|
|
FROM spotter_output".$filter_query." owner_name <> '' |
|
8204
|
|
|
GROUP BY year_name, month_name |
|
8205
|
|
|
ORDER BY date_count DESC"; |
|
8206
|
|
|
} |
|
8207
|
|
|
|
|
8208
|
|
|
$sth = $this->db->prepare($query); |
|
8209
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8210
|
|
|
|
|
8211
|
|
|
$date_array = array(); |
|
8212
|
|
|
$temp_array = array(); |
|
8213
|
|
|
|
|
8214
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8215
|
|
|
{ |
|
8216
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8217
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8218
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8219
|
|
|
|
|
8220
|
|
|
$date_array[] = $temp_array; |
|
8221
|
|
|
} |
|
8222
|
|
|
|
|
8223
|
|
|
return $date_array; |
|
8224
|
|
|
} |
|
8225
|
|
|
|
|
8226
|
|
|
/** |
|
8227
|
|
|
* Counts all month owners |
|
8228
|
|
|
* |
|
8229
|
|
|
* @return Array the month list |
|
8230
|
|
|
* |
|
8231
|
|
|
*/ |
|
8232
|
|
|
public function countAllMonthsOwnersByAirlines($filters = array()) |
|
8233
|
|
|
{ |
|
8234
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8235
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8236
|
|
|
if ($globalTimezone != '') { |
|
8237
|
|
|
date_default_timezone_set($globalTimezone); |
|
8238
|
|
|
$datetime = new DateTime(); |
|
8239
|
|
|
$offset = $datetime->format('P'); |
|
8240
|
|
|
} else $offset = '+00:00'; |
|
8241
|
|
|
|
|
8242
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8243
|
|
|
$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count |
|
8244
|
|
|
FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' |
|
8245
|
|
|
GROUP BY spotter_output.airline_icao, year_name, month_name |
|
8246
|
|
|
ORDER BY date_count DESC"; |
|
8247
|
|
|
} else { |
|
8248
|
|
|
$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count |
|
8249
|
|
|
FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' |
|
8250
|
|
|
GROUP BY spotter_output.airline_icao, year_name, month_name |
|
8251
|
|
|
ORDER BY date_count DESC"; |
|
8252
|
|
|
} |
|
8253
|
|
|
|
|
8254
|
|
|
$sth = $this->db->prepare($query); |
|
8255
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8256
|
|
|
|
|
8257
|
|
|
$date_array = array(); |
|
8258
|
|
|
$temp_array = array(); |
|
8259
|
|
|
|
|
8260
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8261
|
|
|
{ |
|
8262
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8263
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8264
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8265
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
8266
|
|
|
|
|
8267
|
|
|
$date_array[] = $temp_array; |
|
8268
|
|
|
} |
|
8269
|
|
|
|
|
8270
|
|
|
return $date_array; |
|
8271
|
|
|
} |
|
8272
|
|
|
|
|
8273
|
|
|
/** |
|
8274
|
|
|
* Counts all month pilot |
|
8275
|
|
|
* |
|
8276
|
|
|
* @return Array the month list |
|
8277
|
|
|
* |
|
8278
|
|
|
*/ |
|
8279
|
|
|
public function countAllMonthsPilots($filters = array()) |
|
8280
|
|
|
{ |
|
8281
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8282
|
|
|
if ($globalTimezone != '') { |
|
8283
|
|
|
date_default_timezone_set($globalTimezone); |
|
8284
|
|
|
$datetime = new DateTime(); |
|
8285
|
|
|
$offset = $datetime->format('P'); |
|
8286
|
|
|
} else $offset = '+00:00'; |
|
8287
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8288
|
|
|
|
|
8289
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8290
|
|
|
$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count |
|
8291
|
|
|
FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL |
|
8292
|
|
|
GROUP BY year_name, month_name |
|
8293
|
|
|
ORDER BY date_count DESC"; |
|
8294
|
|
|
} else { |
|
8295
|
|
|
$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count |
|
8296
|
|
|
FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL |
|
8297
|
|
|
GROUP BY year_name, month_name |
|
8298
|
|
|
ORDER BY date_count DESC"; |
|
8299
|
|
|
} |
|
8300
|
|
|
|
|
8301
|
|
|
$sth = $this->db->prepare($query); |
|
8302
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8303
|
|
|
|
|
8304
|
|
|
$date_array = array(); |
|
8305
|
|
|
$temp_array = array(); |
|
8306
|
|
|
|
|
8307
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8308
|
|
|
{ |
|
8309
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8310
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8311
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8312
|
|
|
|
|
8313
|
|
|
$date_array[] = $temp_array; |
|
8314
|
|
|
} |
|
8315
|
|
|
|
|
8316
|
|
|
return $date_array; |
|
8317
|
|
|
} |
|
8318
|
|
|
|
|
8319
|
|
|
/** |
|
8320
|
|
|
* Counts all month pilot |
|
8321
|
|
|
* |
|
8322
|
|
|
* @return Array the month list |
|
8323
|
|
|
* |
|
8324
|
|
|
*/ |
|
8325
|
|
|
public function countAllMonthsPilotsByAirlines($filters = array()) |
|
8326
|
|
|
{ |
|
8327
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8328
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8329
|
|
|
if ($globalTimezone != '') { |
|
8330
|
|
|
date_default_timezone_set($globalTimezone); |
|
8331
|
|
|
$datetime = new DateTime(); |
|
8332
|
|
|
$offset = $datetime->format('P'); |
|
8333
|
|
|
} else $offset = '+00:00'; |
|
8334
|
|
|
|
|
8335
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8336
|
|
|
$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count |
|
8337
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL |
|
8338
|
|
|
GROUP BY spotter_output.airline_icao,year_name, month_name |
|
8339
|
|
|
ORDER BY date_count DESC"; |
|
8340
|
|
|
} else { |
|
8341
|
|
|
$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count |
|
8342
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL |
|
8343
|
|
|
GROUP BY spotter_output.airline_icao, year_name, month_name |
|
8344
|
|
|
ORDER BY date_count DESC"; |
|
8345
|
|
|
} |
|
8346
|
|
|
|
|
8347
|
|
|
$sth = $this->db->prepare($query); |
|
8348
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8349
|
|
|
|
|
8350
|
|
|
$date_array = array(); |
|
8351
|
|
|
$temp_array = array(); |
|
8352
|
|
|
|
|
8353
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8354
|
|
|
{ |
|
8355
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8356
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8357
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8358
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
8359
|
|
|
|
|
8360
|
|
|
$date_array[] = $temp_array; |
|
8361
|
|
|
} |
|
8362
|
|
|
|
|
8363
|
|
|
return $date_array; |
|
8364
|
|
|
} |
|
8365
|
|
|
|
|
8366
|
|
|
/** |
|
8367
|
|
|
* Counts all month airline |
|
8368
|
|
|
* |
|
8369
|
|
|
* @return Array the month list |
|
8370
|
|
|
* |
|
8371
|
|
|
*/ |
|
8372
|
|
|
public function countAllMonthsAirlines($filters = array()) |
|
8373
|
|
|
{ |
|
8374
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8375
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8376
|
|
|
if ($globalTimezone != '') { |
|
8377
|
|
|
date_default_timezone_set($globalTimezone); |
|
8378
|
|
|
$datetime = new DateTime(); |
|
8379
|
|
|
$offset = $datetime->format('P'); |
|
8380
|
|
|
} else $offset = '+00:00'; |
|
8381
|
|
|
|
|
8382
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8383
|
|
|
$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count |
|
8384
|
|
|
FROM spotter_output".$filter_query." airline_icao <> '' |
|
8385
|
|
|
GROUP BY year_name, month_name |
|
8386
|
|
|
ORDER BY date_count DESC"; |
|
8387
|
|
|
} else { |
|
8388
|
|
|
$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count |
|
8389
|
|
|
FROM spotter_output".$filter_query." airline_icao <> '' |
|
8390
|
|
|
GROUP BY year_name, month_name |
|
8391
|
|
|
ORDER BY date_count DESC"; |
|
8392
|
|
|
} |
|
8393
|
|
|
|
|
8394
|
|
|
$sth = $this->db->prepare($query); |
|
8395
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8396
|
|
|
|
|
8397
|
|
|
$date_array = array(); |
|
8398
|
|
|
$temp_array = array(); |
|
8399
|
|
|
|
|
8400
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8401
|
|
|
{ |
|
8402
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8403
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8404
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8405
|
|
|
|
|
8406
|
|
|
$date_array[] = $temp_array; |
|
8407
|
|
|
} |
|
8408
|
|
|
|
|
8409
|
|
|
return $date_array; |
|
8410
|
|
|
} |
|
8411
|
|
|
|
|
8412
|
|
|
/** |
|
8413
|
|
|
* Counts all month aircraft |
|
8414
|
|
|
* |
|
8415
|
|
|
* @return Array the month list |
|
8416
|
|
|
* |
|
8417
|
|
|
*/ |
|
8418
|
|
|
public function countAllMonthsAircrafts($filters = array()) |
|
8419
|
|
|
{ |
|
8420
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8421
|
|
|
if ($globalTimezone != '') { |
|
8422
|
|
|
date_default_timezone_set($globalTimezone); |
|
8423
|
|
|
$datetime = new DateTime(); |
|
8424
|
|
|
$offset = $datetime->format('P'); |
|
8425
|
|
|
} else $offset = '+00:00'; |
|
8426
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8427
|
|
|
|
|
8428
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8429
|
|
|
$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count |
|
8430
|
|
|
FROM spotter_output".$filter_query." aircraft_icao <> '' |
|
8431
|
|
|
GROUP BY year_name, month_name |
|
8432
|
|
|
ORDER BY date_count DESC"; |
|
8433
|
|
|
} else { |
|
8434
|
|
|
$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count |
|
8435
|
|
|
FROM spotter_output".$filter_query." aircraft_icao <> '' |
|
8436
|
|
|
GROUP BY year_name, month_name |
|
8437
|
|
|
ORDER BY date_count DESC"; |
|
8438
|
|
|
} |
|
8439
|
|
|
|
|
8440
|
|
|
$sth = $this->db->prepare($query); |
|
8441
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8442
|
|
|
|
|
8443
|
|
|
$date_array = array(); |
|
8444
|
|
|
$temp_array = array(); |
|
8445
|
|
|
|
|
8446
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8447
|
|
|
{ |
|
8448
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8449
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8450
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8451
|
|
|
|
|
8452
|
|
|
$date_array[] = $temp_array; |
|
8453
|
|
|
} |
|
8454
|
|
|
|
|
8455
|
|
|
return $date_array; |
|
8456
|
|
|
} |
|
8457
|
|
|
|
|
8458
|
|
|
|
|
8459
|
|
|
/** |
|
8460
|
|
|
* Counts all month aircraft |
|
8461
|
|
|
* |
|
8462
|
|
|
* @return Array the month list |
|
8463
|
|
|
* |
|
8464
|
|
|
*/ |
|
8465
|
|
|
public function countAllMonthsAircraftsByAirlines($filters = array()) |
|
8466
|
|
|
{ |
|
8467
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8468
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8469
|
|
|
if ($globalTimezone != '') { |
|
8470
|
|
|
date_default_timezone_set($globalTimezone); |
|
8471
|
|
|
$datetime = new DateTime(); |
|
8472
|
|
|
$offset = $datetime->format('P'); |
|
8473
|
|
|
} else $offset = '+00:00'; |
|
8474
|
|
|
|
|
8475
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8476
|
|
|
$query = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count |
|
8477
|
|
|
FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> '' |
|
8478
|
|
|
GROUP BY spotter_output.airline_icao, year_name, month_name |
|
8479
|
|
|
ORDER BY date_count DESC"; |
|
8480
|
|
|
} else { |
|
8481
|
|
|
$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count |
|
8482
|
|
|
FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> '' |
|
8483
|
|
|
GROUP BY spotter_output.airline_icao, year_name, month_name |
|
8484
|
|
|
ORDER BY date_count DESC"; |
|
8485
|
|
|
} |
|
8486
|
|
|
|
|
8487
|
|
|
$sth = $this->db->prepare($query); |
|
8488
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8489
|
|
|
|
|
8490
|
|
|
$date_array = array(); |
|
8491
|
|
|
$temp_array = array(); |
|
8492
|
|
|
|
|
8493
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8494
|
|
|
{ |
|
8495
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8496
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8497
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8498
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
8499
|
|
|
|
|
8500
|
|
|
$date_array[] = $temp_array; |
|
8501
|
|
|
} |
|
8502
|
|
|
|
|
8503
|
|
|
return $date_array; |
|
8504
|
|
|
} |
|
8505
|
|
|
|
|
8506
|
|
|
/** |
|
8507
|
|
|
* Counts all month real arrival |
|
8508
|
|
|
* |
|
8509
|
|
|
* @return Array the month list |
|
8510
|
|
|
* |
|
8511
|
|
|
*/ |
|
8512
|
|
|
public function countAllMonthsRealArrivals($filters = array()) |
|
8513
|
|
|
{ |
|
8514
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8515
|
|
|
if ($globalTimezone != '') { |
|
8516
|
|
|
date_default_timezone_set($globalTimezone); |
|
8517
|
|
|
$datetime = new DateTime(); |
|
8518
|
|
|
$offset = $datetime->format('P'); |
|
8519
|
|
|
} else $offset = '+00:00'; |
|
8520
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8521
|
|
|
|
|
8522
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8523
|
|
|
$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count |
|
8524
|
|
|
FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' |
|
8525
|
|
|
GROUP BY year_name, month_name |
|
8526
|
|
|
ORDER BY date_count DESC"; |
|
8527
|
|
|
} else { |
|
8528
|
|
|
$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count |
|
8529
|
|
|
FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' |
|
8530
|
|
|
GROUP BY year_name, month_name |
|
8531
|
|
|
ORDER BY date_count DESC"; |
|
8532
|
|
|
} |
|
8533
|
|
|
|
|
8534
|
|
|
$sth = $this->db->prepare($query); |
|
8535
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8536
|
|
|
|
|
8537
|
|
|
$date_array = array(); |
|
8538
|
|
|
$temp_array = array(); |
|
8539
|
|
|
|
|
8540
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8541
|
|
|
{ |
|
8542
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8543
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8544
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8545
|
|
|
|
|
8546
|
|
|
$date_array[] = $temp_array; |
|
8547
|
|
|
} |
|
8548
|
|
|
|
|
8549
|
|
|
return $date_array; |
|
8550
|
|
|
} |
|
8551
|
|
|
|
|
8552
|
|
|
|
|
8553
|
|
|
/** |
|
8554
|
|
|
* Counts all month real arrival |
|
8555
|
|
|
* |
|
8556
|
|
|
* @return Array the month list |
|
8557
|
|
|
* |
|
8558
|
|
|
*/ |
|
8559
|
|
|
public function countAllMonthsRealArrivalsByAirlines($filters = array()) |
|
8560
|
|
|
{ |
|
8561
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8562
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8563
|
|
|
if ($globalTimezone != '') { |
|
8564
|
|
|
date_default_timezone_set($globalTimezone); |
|
8565
|
|
|
$datetime = new DateTime(); |
|
8566
|
|
|
$offset = $datetime->format('P'); |
|
8567
|
|
|
} else $offset = '+00:00'; |
|
8568
|
|
|
|
|
8569
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8570
|
|
|
$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count |
|
8571
|
|
|
FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' |
|
8572
|
|
|
GROUP BY spotter_output.airline_icao, year_name, month_name |
|
8573
|
|
|
ORDER BY date_count DESC"; |
|
8574
|
|
|
} else { |
|
8575
|
|
|
$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count |
|
8576
|
|
|
FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' |
|
8577
|
|
|
GROUP BY spotter_output.airline_icao, year_name, month_name |
|
8578
|
|
|
ORDER BY date_count DESC"; |
|
8579
|
|
|
} |
|
8580
|
|
|
|
|
8581
|
|
|
$sth = $this->db->prepare($query); |
|
8582
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
8583
|
|
|
|
|
8584
|
|
|
$date_array = array(); |
|
8585
|
|
|
$temp_array = array(); |
|
8586
|
|
|
|
|
8587
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8588
|
|
|
{ |
|
8589
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8590
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8591
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8592
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
8593
|
|
|
|
|
8594
|
|
|
$date_array[] = $temp_array; |
|
8595
|
|
|
} |
|
8596
|
|
|
|
|
8597
|
|
|
return $date_array; |
|
8598
|
|
|
} |
|
8599
|
|
|
|
|
8600
|
|
|
|
|
8601
|
|
|
/** |
|
8602
|
|
|
* Counts all dates during the last year |
|
8603
|
|
|
* |
|
8604
|
|
|
* @return Array the date list |
|
8605
|
|
|
* |
|
8606
|
|
|
*/ |
|
8607
|
|
|
public function countAllMonthsLastYear($filters) |
|
8608
|
|
|
{ |
|
8609
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8610
|
|
|
if ($globalTimezone != '') { |
|
8611
|
|
|
date_default_timezone_set($globalTimezone); |
|
8612
|
|
|
$datetime = new DateTime(); |
|
8613
|
|
|
$offset = $datetime->format('P'); |
|
8614
|
|
|
} else $offset = '+00:00'; |
|
8615
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8616
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8617
|
|
|
$query = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
|
8618
|
|
|
FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
|
8619
|
|
|
$query .= " GROUP BY year_name, month_name |
|
8620
|
|
|
ORDER BY year_name, month_name ASC"; |
|
8621
|
|
|
$query_data = array(':offset' => $offset); |
|
8622
|
|
|
} else { |
|
8623
|
|
|
$query = "SELECT EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count |
|
8624
|
|
|
FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 YEARS'"; |
|
8625
|
|
|
$query .= " GROUP BY year_name, month_name |
|
8626
|
|
|
ORDER BY year_name, month_name ASC"; |
|
8627
|
|
|
$query_data = array(':offset' => $offset); |
|
8628
|
|
|
} |
|
8629
|
|
|
|
|
8630
|
|
|
$sth = $this->db->prepare($query); |
|
8631
|
|
|
$sth->execute($query_data); |
|
8632
|
|
|
|
|
8633
|
|
|
$date_array = array(); |
|
8634
|
|
|
$temp_array = array(); |
|
8635
|
|
|
|
|
8636
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8637
|
|
|
{ |
|
8638
|
|
|
$temp_array['year_name'] = $row['year_name']; |
|
8639
|
|
|
$temp_array['month_name'] = $row['month_name']; |
|
8640
|
|
|
$temp_array['date_count'] = $row['date_count']; |
|
8641
|
|
|
|
|
8642
|
|
|
$date_array[] = $temp_array; |
|
8643
|
|
|
} |
|
8644
|
|
|
|
|
8645
|
|
|
return $date_array; |
|
8646
|
|
|
} |
|
8647
|
|
|
|
|
8648
|
|
|
|
|
8649
|
|
|
|
|
8650
|
|
|
/** |
|
8651
|
|
|
* Counts all hours |
|
8652
|
|
|
* |
|
8653
|
|
|
* @return Array the hour list |
|
8654
|
|
|
* |
|
8655
|
|
|
*/ |
|
8656
|
|
|
public function countAllHours($orderby,$filters = array()) |
|
8657
|
|
|
{ |
|
8658
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8659
|
|
|
if ($globalTimezone != '') { |
|
8660
|
|
|
date_default_timezone_set($globalTimezone); |
|
8661
|
|
|
$datetime = new DateTime(); |
|
8662
|
|
|
$offset = $datetime->format('P'); |
|
8663
|
|
|
} else $offset = '+00:00'; |
|
8664
|
|
|
|
|
8665
|
|
|
$orderby_sql = ''; |
|
8666
|
|
|
if ($orderby == "hour") |
|
8667
|
|
|
{ |
|
8668
|
|
|
$orderby_sql = "ORDER BY hour_name ASC"; |
|
8669
|
|
|
} |
|
8670
|
|
|
if ($orderby == "count") |
|
8671
|
|
|
{ |
|
8672
|
|
|
$orderby_sql = "ORDER BY hour_count DESC"; |
|
8673
|
|
|
} |
|
8674
|
|
|
|
|
8675
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8676
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
8677
|
|
|
FROM spotter_output"; |
|
8678
|
|
|
$query .= $this->getFilter($filters); |
|
8679
|
|
|
$query .= " GROUP BY hour_name |
|
8680
|
|
|
".$orderby_sql; |
|
8681
|
|
|
|
|
8682
|
|
|
/* $query = "SELECT HOUR(spotter_output.date) AS hour_name, count(*) as hour_count |
|
8683
|
|
|
FROM spotter_output |
|
8684
|
|
|
GROUP BY hour_name |
|
8685
|
|
|
".$orderby_sql." |
|
8686
|
|
|
LIMIT 10 OFFSET 00"; |
|
8687
|
|
|
*/ |
|
8688
|
|
|
$query_data = array(':offset' => $offset); |
|
8689
|
|
|
} else { |
|
8690
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
8691
|
|
|
FROM spotter_output"; |
|
8692
|
|
|
$query .= $this->getFilter($filters); |
|
8693
|
|
|
$query .= " GROUP BY hour_name |
|
8694
|
|
|
".$orderby_sql; |
|
8695
|
|
|
$query_data = array(':offset' => $offset); |
|
8696
|
|
|
} |
|
8697
|
|
|
|
|
8698
|
|
|
$sth = $this->db->prepare($query); |
|
8699
|
|
|
$sth->execute($query_data); |
|
8700
|
|
|
|
|
8701
|
|
|
$hour_array = array(); |
|
8702
|
|
|
$temp_array = array(); |
|
8703
|
|
|
|
|
8704
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8705
|
|
|
{ |
|
8706
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
8707
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
8708
|
|
|
|
|
8709
|
|
|
$hour_array[] = $temp_array; |
|
8710
|
|
|
} |
|
8711
|
|
|
|
|
8712
|
|
|
return $hour_array; |
|
8713
|
|
|
} |
|
8714
|
|
|
|
|
8715
|
|
|
/** |
|
8716
|
|
|
* Counts all hours |
|
8717
|
|
|
* |
|
8718
|
|
|
* @return Array the hour list |
|
8719
|
|
|
* |
|
8720
|
|
|
*/ |
|
8721
|
|
|
public function countAllHoursByAirlines($orderby, $filters = array()) |
|
8722
|
|
|
{ |
|
8723
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8724
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8725
|
|
|
if ($globalTimezone != '') { |
|
8726
|
|
|
date_default_timezone_set($globalTimezone); |
|
8727
|
|
|
$datetime = new DateTime(); |
|
8728
|
|
|
$offset = $datetime->format('P'); |
|
8729
|
|
|
} else $offset = '+00:00'; |
|
8730
|
|
|
|
|
8731
|
|
|
$orderby_sql = ''; |
|
8732
|
|
|
if ($orderby == "hour") |
|
8733
|
|
|
{ |
|
8734
|
|
|
$orderby_sql = "ORDER BY hour_name ASC"; |
|
8735
|
|
|
} |
|
8736
|
|
|
if ($orderby == "count") |
|
8737
|
|
|
{ |
|
8738
|
|
|
$orderby_sql = "ORDER BY hour_count DESC"; |
|
8739
|
|
|
} |
|
8740
|
|
|
|
|
8741
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8742
|
|
|
$query = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
8743
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
|
8744
|
|
|
GROUP BY spotter_output.airline_icao, hour_name |
|
8745
|
|
|
".$orderby_sql; |
|
8746
|
|
|
|
|
8747
|
|
|
/* $query = "SELECT HOUR(spotter_output.date) AS hour_name, count(*) as hour_count |
|
8748
|
|
|
FROM spotter_output |
|
8749
|
|
|
GROUP BY hour_name |
|
8750
|
|
|
".$orderby_sql." |
|
8751
|
|
|
LIMIT 10 OFFSET 00"; |
|
8752
|
|
|
*/ |
|
8753
|
|
|
$query_data = array(':offset' => $offset); |
|
8754
|
|
|
} else { |
|
8755
|
|
|
$query = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
8756
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
|
8757
|
|
|
GROUP BY spotter_output.airline_icao, hour_name |
|
8758
|
|
|
".$orderby_sql; |
|
8759
|
|
|
$query_data = array(':offset' => $offset); |
|
8760
|
|
|
} |
|
8761
|
|
|
|
|
8762
|
|
|
$sth = $this->db->prepare($query); |
|
8763
|
|
|
$sth->execute($query_data); |
|
8764
|
|
|
|
|
8765
|
|
|
$hour_array = array(); |
|
8766
|
|
|
$temp_array = array(); |
|
8767
|
|
|
|
|
8768
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8769
|
|
|
{ |
|
8770
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
8771
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
8772
|
|
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
8773
|
|
|
|
|
8774
|
|
|
$hour_array[] = $temp_array; |
|
8775
|
|
|
} |
|
8776
|
|
|
|
|
8777
|
|
|
return $hour_array; |
|
8778
|
|
|
} |
|
8779
|
|
|
|
|
8780
|
|
|
|
|
8781
|
|
|
|
|
8782
|
|
|
/** |
|
8783
|
|
|
* Counts all hours by airline |
|
8784
|
|
|
* |
|
8785
|
|
|
* @return Array the hour list |
|
8786
|
|
|
* |
|
8787
|
|
|
*/ |
|
8788
|
|
|
public function countAllHoursByAirline($airline_icao, $filters = array()) |
|
8789
|
|
|
{ |
|
8790
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8791
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8792
|
|
|
if ($globalTimezone != '') { |
|
8793
|
|
|
date_default_timezone_set($globalTimezone); |
|
8794
|
|
|
$datetime = new DateTime(); |
|
8795
|
|
|
$offset = $datetime->format('P'); |
|
8796
|
|
|
} else $offset = '+00:00'; |
|
8797
|
|
|
|
|
8798
|
|
|
$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
8799
|
|
|
|
|
8800
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8801
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
8802
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao |
|
8803
|
|
|
GROUP BY hour_name |
|
8804
|
|
|
ORDER BY hour_name ASC"; |
|
8805
|
|
|
} else { |
|
8806
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
8807
|
|
|
FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao |
|
8808
|
|
|
GROUP BY hour_name |
|
8809
|
|
|
ORDER BY hour_name ASC"; |
|
8810
|
|
|
} |
|
8811
|
|
|
|
|
8812
|
|
|
$sth = $this->db->prepare($query); |
|
8813
|
|
|
$sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset)); |
|
8814
|
|
|
|
|
8815
|
|
|
$hour_array = array(); |
|
8816
|
|
|
$temp_array = array(); |
|
8817
|
|
|
|
|
8818
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8819
|
|
|
{ |
|
8820
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
8821
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
8822
|
|
|
|
|
8823
|
|
|
$hour_array[] = $temp_array; |
|
8824
|
|
|
} |
|
8825
|
|
|
|
|
8826
|
|
|
return $hour_array; |
|
8827
|
|
|
} |
|
8828
|
|
|
|
|
8829
|
|
|
|
|
8830
|
|
|
|
|
8831
|
|
|
|
|
8832
|
|
|
/** |
|
8833
|
|
|
* Counts all hours by aircraft |
|
8834
|
|
|
* |
|
8835
|
|
|
* @return Array the hour list |
|
8836
|
|
|
* |
|
8837
|
|
|
*/ |
|
8838
|
|
|
public function countAllHoursByAircraft($aircraft_icao, $filters = array()) |
|
8839
|
|
|
{ |
|
8840
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8841
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8842
|
|
|
$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
8843
|
|
|
if ($globalTimezone != '') { |
|
8844
|
|
|
date_default_timezone_set($globalTimezone); |
|
8845
|
|
|
$datetime = new DateTime(); |
|
8846
|
|
|
$offset = $datetime->format('P'); |
|
8847
|
|
|
} else $offset = '+00:00'; |
|
8848
|
|
|
|
|
8849
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8850
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
8851
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao |
|
8852
|
|
|
GROUP BY hour_name |
|
8853
|
|
|
ORDER BY hour_name ASC"; |
|
8854
|
|
|
} else { |
|
8855
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
8856
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao |
|
8857
|
|
|
GROUP BY hour_name |
|
8858
|
|
|
ORDER BY hour_name ASC"; |
|
8859
|
|
|
} |
|
8860
|
|
|
|
|
8861
|
|
|
$sth = $this->db->prepare($query); |
|
8862
|
|
|
$sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset)); |
|
8863
|
|
|
|
|
8864
|
|
|
$hour_array = array(); |
|
8865
|
|
|
$temp_array = array(); |
|
8866
|
|
|
|
|
8867
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8868
|
|
|
{ |
|
8869
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
8870
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
8871
|
|
|
|
|
8872
|
|
|
$hour_array[] = $temp_array; |
|
8873
|
|
|
} |
|
8874
|
|
|
|
|
8875
|
|
|
return $hour_array; |
|
8876
|
|
|
} |
|
8877
|
|
|
|
|
8878
|
|
|
|
|
8879
|
|
|
/** |
|
8880
|
|
|
* Counts all hours by aircraft registration |
|
8881
|
|
|
* |
|
8882
|
|
|
* @return Array the hour list |
|
8883
|
|
|
* |
|
8884
|
|
|
*/ |
|
8885
|
|
|
public function countAllHoursByRegistration($registration, $filters = array()) |
|
8886
|
|
|
{ |
|
8887
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8888
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8889
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
8890
|
|
|
if ($globalTimezone != '') { |
|
8891
|
|
|
date_default_timezone_set($globalTimezone); |
|
8892
|
|
|
$datetime = new DateTime(); |
|
8893
|
|
|
$offset = $datetime->format('P'); |
|
8894
|
|
|
} else $offset = '+00:00'; |
|
8895
|
|
|
|
|
8896
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8897
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
8898
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration = :registration |
|
8899
|
|
|
GROUP BY hour_name |
|
8900
|
|
|
ORDER BY hour_name ASC"; |
|
8901
|
|
|
} else { |
|
8902
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
8903
|
|
|
FROM spotter_output".$filter_query." spotter_output.registration = :registration |
|
8904
|
|
|
GROUP BY hour_name |
|
8905
|
|
|
ORDER BY hour_name ASC"; |
|
8906
|
|
|
} |
|
8907
|
|
|
|
|
8908
|
|
|
$sth = $this->db->prepare($query); |
|
8909
|
|
|
$sth->execute(array(':registration' => $registration,':offset' => $offset)); |
|
8910
|
|
|
|
|
8911
|
|
|
$hour_array = array(); |
|
8912
|
|
|
$temp_array = array(); |
|
8913
|
|
|
|
|
8914
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8915
|
|
|
{ |
|
8916
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
8917
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
8918
|
|
|
|
|
8919
|
|
|
$hour_array[] = $temp_array; |
|
8920
|
|
|
} |
|
8921
|
|
|
|
|
8922
|
|
|
return $hour_array; |
|
8923
|
|
|
} |
|
8924
|
|
|
|
|
8925
|
|
|
|
|
8926
|
|
|
/** |
|
8927
|
|
|
* Counts all hours by airport |
|
8928
|
|
|
* |
|
8929
|
|
|
* @return Array the hour list |
|
8930
|
|
|
* |
|
8931
|
|
|
*/ |
|
8932
|
|
|
public function countAllHoursByAirport($airport_icao, $filters = array()) |
|
8933
|
|
|
{ |
|
8934
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8935
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8936
|
|
|
$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
8937
|
|
|
if ($globalTimezone != '') { |
|
8938
|
|
|
date_default_timezone_set($globalTimezone); |
|
8939
|
|
|
$datetime = new DateTime(); |
|
8940
|
|
|
$offset = $datetime->format('P'); |
|
8941
|
|
|
} else $offset = '+00:00'; |
|
8942
|
|
|
|
|
8943
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8944
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
8945
|
|
|
FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
|
8946
|
|
|
GROUP BY hour_name |
|
8947
|
|
|
ORDER BY hour_name ASC"; |
|
8948
|
|
|
} else { |
|
8949
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
8950
|
|
|
FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
|
8951
|
|
|
GROUP BY hour_name |
|
8952
|
|
|
ORDER BY hour_name ASC"; |
|
8953
|
|
|
} |
|
8954
|
|
|
|
|
8955
|
|
|
$sth = $this->db->prepare($query); |
|
8956
|
|
|
$sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset)); |
|
8957
|
|
|
|
|
8958
|
|
|
$hour_array = array(); |
|
8959
|
|
|
$temp_array = array(); |
|
8960
|
|
|
|
|
8961
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
8962
|
|
|
{ |
|
8963
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
8964
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
8965
|
|
|
|
|
8966
|
|
|
$hour_array[] = $temp_array; |
|
8967
|
|
|
} |
|
8968
|
|
|
|
|
8969
|
|
|
return $hour_array; |
|
8970
|
|
|
} |
|
8971
|
|
|
|
|
8972
|
|
|
|
|
8973
|
|
|
|
|
8974
|
|
|
/** |
|
8975
|
|
|
* Counts all hours by manufacturer |
|
8976
|
|
|
* |
|
8977
|
|
|
* @return Array the hour list |
|
8978
|
|
|
* |
|
8979
|
|
|
*/ |
|
8980
|
|
|
public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array()) |
|
8981
|
|
|
{ |
|
8982
|
|
|
global $globalTimezone, $globalDBdriver; |
|
8983
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
8984
|
|
|
$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
8985
|
|
|
if ($globalTimezone != '') { |
|
8986
|
|
|
date_default_timezone_set($globalTimezone); |
|
8987
|
|
|
$datetime = new DateTime(); |
|
8988
|
|
|
$offset = $datetime->format('P'); |
|
8989
|
|
|
} else $offset = '+00:00'; |
|
8990
|
|
|
|
|
8991
|
|
|
if ($globalDBdriver == 'mysql') { |
|
8992
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
8993
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
8994
|
|
|
GROUP BY hour_name |
|
8995
|
|
|
ORDER BY hour_name ASC"; |
|
8996
|
|
|
} else { |
|
8997
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
8998
|
|
|
FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
|
8999
|
|
|
GROUP BY hour_name |
|
9000
|
|
|
ORDER BY hour_name ASC"; |
|
9001
|
|
|
} |
|
9002
|
|
|
|
|
9003
|
|
|
$sth = $this->db->prepare($query); |
|
9004
|
|
|
$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset)); |
|
9005
|
|
|
|
|
9006
|
|
|
$hour_array = array(); |
|
9007
|
|
|
$temp_array = array(); |
|
9008
|
|
|
|
|
9009
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9010
|
|
|
{ |
|
9011
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
9012
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
9013
|
|
|
|
|
9014
|
|
|
$hour_array[] = $temp_array; |
|
9015
|
|
|
} |
|
9016
|
|
|
|
|
9017
|
|
|
return $hour_array; |
|
9018
|
|
|
} |
|
9019
|
|
|
|
|
9020
|
|
|
|
|
9021
|
|
|
|
|
9022
|
|
|
/** |
|
9023
|
|
|
* Counts all hours by date |
|
9024
|
|
|
* |
|
9025
|
|
|
* @return Array the hour list |
|
9026
|
|
|
* |
|
9027
|
|
|
*/ |
|
9028
|
|
|
public function countAllHoursByDate($date, $filters = array()) |
|
9029
|
|
|
{ |
|
9030
|
|
|
global $globalTimezone, $globalDBdriver; |
|
9031
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9032
|
|
|
$date = filter_var($date,FILTER_SANITIZE_STRING); |
|
9033
|
|
|
if ($globalTimezone != '') { |
|
9034
|
|
|
date_default_timezone_set($globalTimezone); |
|
9035
|
|
|
$datetime = new DateTime($date); |
|
9036
|
|
|
$offset = $datetime->format('P'); |
|
9037
|
|
|
} else $offset = '+00:00'; |
|
9038
|
|
|
|
|
9039
|
|
|
if ($globalDBdriver == 'mysql') { |
|
9040
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
9041
|
|
|
FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
|
9042
|
|
|
GROUP BY hour_name |
|
9043
|
|
|
ORDER BY hour_name ASC"; |
|
9044
|
|
|
} else { |
|
9045
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
9046
|
|
|
FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
|
9047
|
|
|
GROUP BY hour_name |
|
9048
|
|
|
ORDER BY hour_name ASC"; |
|
9049
|
|
|
} |
|
9050
|
|
|
|
|
9051
|
|
|
$sth = $this->db->prepare($query); |
|
9052
|
|
|
$sth->execute(array(':date' => $date, ':offset' => $offset)); |
|
9053
|
|
|
|
|
9054
|
|
|
$hour_array = array(); |
|
9055
|
|
|
$temp_array = array(); |
|
9056
|
|
|
|
|
9057
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9058
|
|
|
{ |
|
9059
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
9060
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
9061
|
|
|
|
|
9062
|
|
|
$hour_array[] = $temp_array; |
|
9063
|
|
|
} |
|
9064
|
|
|
|
|
9065
|
|
|
return $hour_array; |
|
9066
|
|
|
} |
|
9067
|
|
|
|
|
9068
|
|
|
|
|
9069
|
|
|
|
|
9070
|
|
|
/** |
|
9071
|
|
|
* Counts all hours by a ident/callsign |
|
9072
|
|
|
* |
|
9073
|
|
|
* @return Array the hour list |
|
9074
|
|
|
* |
|
9075
|
|
|
*/ |
|
9076
|
|
|
public function countAllHoursByIdent($ident, $filters = array()) |
|
9077
|
|
|
{ |
|
9078
|
|
|
global $globalTimezone, $globalDBdriver; |
|
9079
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9080
|
|
|
$ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
9081
|
|
|
if ($globalTimezone != '') { |
|
9082
|
|
|
date_default_timezone_set($globalTimezone); |
|
9083
|
|
|
$datetime = new DateTime(); |
|
9084
|
|
|
$offset = $datetime->format('P'); |
|
9085
|
|
|
} else $offset = '+00:00'; |
|
9086
|
|
|
|
|
9087
|
|
|
if ($globalDBdriver == 'mysql') { |
|
9088
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
9089
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident = :ident |
|
9090
|
|
|
GROUP BY hour_name |
|
9091
|
|
|
ORDER BY hour_name ASC"; |
|
9092
|
|
|
} else { |
|
9093
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
9094
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident = :ident |
|
9095
|
|
|
GROUP BY hour_name |
|
9096
|
|
|
ORDER BY hour_name ASC"; |
|
9097
|
|
|
} |
|
9098
|
|
|
|
|
9099
|
|
|
|
|
9100
|
|
|
$sth = $this->db->prepare($query); |
|
9101
|
|
|
$sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
9102
|
|
|
|
|
9103
|
|
|
$hour_array = array(); |
|
9104
|
|
|
$temp_array = array(); |
|
9105
|
|
|
|
|
9106
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9107
|
|
|
{ |
|
9108
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
9109
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
9110
|
|
|
|
|
9111
|
|
|
$hour_array[] = $temp_array; |
|
9112
|
|
|
} |
|
9113
|
|
|
|
|
9114
|
|
|
return $hour_array; |
|
9115
|
|
|
} |
|
9116
|
|
|
|
|
9117
|
|
|
|
|
9118
|
|
|
|
|
9119
|
|
|
/** |
|
9120
|
|
|
* Counts all hours by route |
|
9121
|
|
|
* |
|
9122
|
|
|
* @return Array the hour list |
|
9123
|
|
|
* |
|
9124
|
|
|
*/ |
|
9125
|
|
|
public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array()) |
|
9126
|
|
|
{ |
|
9127
|
|
|
global $globalTimezone, $globalDBdriver; |
|
9128
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9129
|
|
|
$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
9130
|
|
|
$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
9131
|
|
|
if ($globalTimezone != '') { |
|
9132
|
|
|
date_default_timezone_set($globalTimezone); |
|
9133
|
|
|
$datetime = new DateTime(); |
|
9134
|
|
|
$offset = $datetime->format('P'); |
|
9135
|
|
|
} else $offset = '+00:00'; |
|
9136
|
|
|
|
|
9137
|
|
|
if ($globalDBdriver == 'mysql') { |
|
9138
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
9139
|
|
|
FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
|
9140
|
|
|
GROUP BY hour_name |
|
9141
|
|
|
ORDER BY hour_name ASC"; |
|
9142
|
|
|
} else { |
|
9143
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
9144
|
|
|
FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
|
9145
|
|
|
GROUP BY hour_name |
|
9146
|
|
|
ORDER BY hour_name ASC"; |
|
9147
|
|
|
} |
|
9148
|
|
|
|
|
9149
|
|
|
$sth = $this->db->prepare($query); |
|
9150
|
|
|
$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset)); |
|
9151
|
|
|
|
|
9152
|
|
|
$hour_array = array(); |
|
9153
|
|
|
$temp_array = array(); |
|
9154
|
|
|
|
|
9155
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9156
|
|
|
{ |
|
9157
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
9158
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
9159
|
|
|
|
|
9160
|
|
|
$hour_array[] = $temp_array; |
|
9161
|
|
|
} |
|
9162
|
|
|
|
|
9163
|
|
|
return $hour_array; |
|
9164
|
|
|
} |
|
9165
|
|
|
|
|
9166
|
|
|
|
|
9167
|
|
|
/** |
|
9168
|
|
|
* Counts all hours by country |
|
9169
|
|
|
* |
|
9170
|
|
|
* @return Array the hour list |
|
9171
|
|
|
* |
|
9172
|
|
|
*/ |
|
9173
|
|
|
public function countAllHoursByCountry($country, $filters = array()) |
|
9174
|
|
|
{ |
|
9175
|
|
|
global $globalTimezone, $globalDBdriver; |
|
9176
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9177
|
|
|
$country = filter_var($country,FILTER_SANITIZE_STRING); |
|
9178
|
|
|
if ($globalTimezone != '') { |
|
9179
|
|
|
date_default_timezone_set($globalTimezone); |
|
9180
|
|
|
$datetime = new DateTime(); |
|
9181
|
|
|
$offset = $datetime->format('P'); |
|
9182
|
|
|
} else $offset = '+00:00'; |
|
9183
|
|
|
|
|
9184
|
|
|
if ($globalDBdriver == 'mysql') { |
|
9185
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
9186
|
|
|
FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
|
9187
|
|
|
GROUP BY hour_name |
|
9188
|
|
|
ORDER BY hour_name ASC"; |
|
9189
|
|
|
} else { |
|
9190
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
9191
|
|
|
FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
|
9192
|
|
|
GROUP BY hour_name |
|
9193
|
|
|
ORDER BY hour_name ASC"; |
|
9194
|
|
|
} |
|
9195
|
|
|
|
|
9196
|
|
|
$sth = $this->db->prepare($query); |
|
9197
|
|
|
$sth->execute(array(':country' => $country,':offset' => $offset)); |
|
9198
|
|
|
|
|
9199
|
|
|
$hour_array = array(); |
|
9200
|
|
|
$temp_array = array(); |
|
9201
|
|
|
|
|
9202
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9203
|
|
|
{ |
|
9204
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
9205
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
9206
|
|
|
|
|
9207
|
|
|
$hour_array[] = $temp_array; |
|
9208
|
|
|
} |
|
9209
|
|
|
|
|
9210
|
|
|
return $hour_array; |
|
9211
|
|
|
} |
|
9212
|
|
|
|
|
9213
|
|
|
|
|
9214
|
|
|
|
|
9215
|
|
|
|
|
9216
|
|
|
/** |
|
9217
|
|
|
* Counts all aircraft that have flown over |
|
9218
|
|
|
* |
|
9219
|
|
|
* @return Integer the number of aircrafts |
|
9220
|
|
|
* |
|
9221
|
|
|
*/ |
|
9222
|
|
|
public function countOverallAircrafts($filters = array()) |
|
9223
|
|
|
{ |
|
9224
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9225
|
|
|
$query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count |
|
9226
|
|
|
FROM spotter_output".$filter_query." spotter_output.ident <> ''"; |
|
9227
|
|
|
$sth = $this->db->prepare($query); |
|
9228
|
|
|
$sth->execute(); |
|
9229
|
|
|
return $sth->fetchColumn(); |
|
9230
|
|
|
} |
|
9231
|
|
|
|
|
9232
|
|
|
/** |
|
9233
|
|
|
* Counts all flight that really arrival |
|
9234
|
|
|
* |
|
9235
|
|
|
* @return Integer the number of aircrafts |
|
9236
|
|
|
* |
|
9237
|
|
|
*/ |
|
9238
|
|
|
public function countOverallArrival($filters = array()) |
|
9239
|
|
|
{ |
|
9240
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9241
|
|
|
$query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count |
|
9242
|
|
|
FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> ''"; |
|
9243
|
|
|
|
|
9244
|
|
|
$sth = $this->db->prepare($query); |
|
9245
|
|
|
$sth->execute(); |
|
9246
|
|
|
return $sth->fetchColumn(); |
|
9247
|
|
|
} |
|
9248
|
|
|
|
|
9249
|
|
|
/** |
|
9250
|
|
|
* Counts all pilots that have flown over |
|
9251
|
|
|
* |
|
9252
|
|
|
* @return Integer the number of pilots |
|
9253
|
|
|
* |
|
9254
|
|
|
*/ |
|
9255
|
|
|
public function countOverallPilots($filters = array()) |
|
9256
|
|
|
{ |
|
9257
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9258
|
|
|
$query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count |
|
9259
|
|
|
FROM spotter_output".$filter_query." spotter_output.pilot_id <> ''"; |
|
9260
|
|
|
$sth = $this->db->prepare($query); |
|
9261
|
|
|
$sth->execute(); |
|
9262
|
|
|
return $sth->fetchColumn(); |
|
9263
|
|
|
} |
|
9264
|
|
|
|
|
9265
|
|
|
/** |
|
9266
|
|
|
* Counts all owners that have flown over |
|
9267
|
|
|
* |
|
9268
|
|
|
* @return Integer the number of owners |
|
9269
|
|
|
* |
|
9270
|
|
|
*/ |
|
9271
|
|
|
public function countOverallOwners($filters = array()) |
|
9272
|
|
|
{ |
|
9273
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9274
|
|
|
$query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count |
|
9275
|
|
|
FROM spotter_output".$filter_query." spotter_output.owner_name <> ''"; |
|
9276
|
|
|
$sth = $this->db->prepare($query); |
|
9277
|
|
|
$sth->execute(); |
|
9278
|
|
|
return $sth->fetchColumn(); |
|
9279
|
|
|
} |
|
9280
|
|
|
|
|
9281
|
|
|
|
|
9282
|
|
|
/** |
|
9283
|
|
|
* Counts all flights that have flown over |
|
9284
|
|
|
* |
|
9285
|
|
|
* @return Integer the number of flights |
|
9286
|
|
|
* |
|
9287
|
|
|
*/ |
|
9288
|
|
|
public function countOverallFlights($filters = array()) |
|
9289
|
|
|
{ |
|
9290
|
|
|
$query = "SELECT COUNT(spotter_output.spotter_id) AS flight_count |
|
9291
|
|
|
FROM spotter_output"; |
|
9292
|
|
|
$query .= $this->getFilter($filters); |
|
9293
|
|
|
//echo $query; |
|
9294
|
|
|
$sth = $this->db->prepare($query); |
|
9295
|
|
|
$sth->execute(); |
|
9296
|
|
|
return $sth->fetchColumn(); |
|
9297
|
|
|
} |
|
9298
|
|
|
|
|
9299
|
|
|
/** |
|
9300
|
|
|
* Counts all military flights that have flown over |
|
9301
|
|
|
* |
|
9302
|
|
|
* @return Integer the number of flights |
|
9303
|
|
|
* |
|
9304
|
|
|
*/ |
|
9305
|
|
|
public function countOverallMilitaryFlights($filters = array()) |
|
9306
|
|
|
{ |
|
9307
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9308
|
|
|
$query = "SELECT COUNT(spotter_output.spotter_id) AS flight_count |
|
9309
|
|
|
FROM airlines,spotter_output".$filter_query." spotter_output.airline_icao = airlines.icao AND airlines.type = 'military'"; |
|
9310
|
|
|
|
|
9311
|
|
|
$sth = $this->db->prepare($query); |
|
9312
|
|
|
$sth->execute(); |
|
9313
|
|
|
return $sth->fetchColumn(); |
|
9314
|
|
|
} |
|
9315
|
|
|
|
|
9316
|
|
|
|
|
9317
|
|
|
|
|
9318
|
|
|
/** |
|
9319
|
|
|
* Counts all airlines that have flown over |
|
9320
|
|
|
* |
|
9321
|
|
|
* @return Integer the number of airlines |
|
9322
|
|
|
* |
|
9323
|
|
|
*/ |
|
9324
|
|
|
public function countOverallAirlines($filters = array()) |
|
9325
|
|
|
{ |
|
9326
|
|
|
$query = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count |
|
9327
|
|
|
FROM spotter_output"; |
|
9328
|
|
|
|
|
9329
|
|
|
$query .= $this->getFilter($filters); |
|
9330
|
|
|
$sth = $this->db->prepare($query); |
|
9331
|
|
|
$sth->execute(); |
|
9332
|
|
|
return $sth->fetchColumn(); |
|
9333
|
|
|
} |
|
9334
|
|
|
|
|
9335
|
|
|
|
|
9336
|
|
|
/** |
|
9337
|
|
|
* Counts all hours of today |
|
9338
|
|
|
* |
|
9339
|
|
|
* @return Array the hour list |
|
9340
|
|
|
* |
|
9341
|
|
|
*/ |
|
9342
|
|
|
public function countAllHoursFromToday($filters = array()) |
|
9343
|
|
|
{ |
|
9344
|
|
|
global $globalTimezone, $globalDBdriver; |
|
9345
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9346
|
|
|
if ($globalTimezone != '') { |
|
9347
|
|
|
date_default_timezone_set($globalTimezone); |
|
9348
|
|
|
$datetime = new DateTime(); |
|
9349
|
|
|
$offset = $datetime->format('P'); |
|
9350
|
|
|
} else $offset = '+00:00'; |
|
9351
|
|
|
|
|
9352
|
|
|
if ($globalDBdriver == 'mysql') { |
|
9353
|
|
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
9354
|
|
|
FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE() |
|
9355
|
|
|
GROUP BY hour_name |
|
9356
|
|
|
ORDER BY hour_name ASC"; |
|
9357
|
|
|
} else { |
|
9358
|
|
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
9359
|
|
|
FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
|
9360
|
|
|
GROUP BY hour_name |
|
9361
|
|
|
ORDER BY hour_name ASC"; |
|
9362
|
|
|
} |
|
9363
|
|
|
|
|
9364
|
|
|
$sth = $this->db->prepare($query); |
|
9365
|
|
|
$sth->execute(array(':offset' => $offset)); |
|
9366
|
|
|
|
|
9367
|
|
|
$hour_array = array(); |
|
9368
|
|
|
$temp_array = array(); |
|
9369
|
|
|
|
|
9370
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9371
|
|
|
{ |
|
9372
|
|
|
$temp_array['hour_name'] = $row['hour_name']; |
|
9373
|
|
|
$temp_array['hour_count'] = $row['hour_count']; |
|
9374
|
|
|
$hour_array[] = $temp_array; |
|
9375
|
|
|
} |
|
9376
|
|
|
|
|
9377
|
|
|
return $hour_array; |
|
9378
|
|
|
} |
|
9379
|
|
|
|
|
9380
|
|
|
/** |
|
9381
|
|
|
* Gets all the spotter information based on calculated upcoming flights |
|
9382
|
|
|
* |
|
9383
|
|
|
* @return Array the spotter information |
|
9384
|
|
|
* |
|
9385
|
|
|
*/ |
|
9386
|
|
|
public function getUpcomingFlights($limit = '', $sort = '', $filters = array()) |
|
9387
|
|
|
{ |
|
9388
|
|
|
global $global_query, $globalDBdriver, $globalTimezone; |
|
9389
|
|
|
$filter_query = $this->getFilter($filters,true,true); |
|
9390
|
|
|
date_default_timezone_set('UTC'); |
|
9391
|
|
|
$limit_query = ''; |
|
9392
|
|
|
if ($limit != "") |
|
9393
|
|
|
{ |
|
9394
|
|
|
$limit_array = explode(",", $limit); |
|
9395
|
|
|
$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
9396
|
|
|
$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
9397
|
|
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
9398
|
|
|
{ |
|
9399
|
|
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
9400
|
|
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
9401
|
|
|
} |
|
9402
|
|
|
} |
|
9403
|
|
|
$currentHour = date("G"); |
|
9404
|
|
|
$next3Hours = date("G", strtotime("+3 hour")); |
|
9405
|
|
|
//if the next 3 hours is already equal to/past midnight, we limit it to stay there, otherwise the query will fail |
|
9406
|
|
|
if ($currentHour >= 21 && $next3Hours >= 00) |
|
9407
|
|
|
{ |
|
9408
|
|
|
$next3Hours = 24; |
|
9409
|
|
|
} |
|
9410
|
|
|
$currentDayofWeek = date("l"); |
|
9411
|
|
|
if ($globalDBdriver == 'mysql') { |
|
9412
|
|
|
if ($sort != "") |
|
9413
|
|
|
{ |
|
9414
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
9415
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
9416
|
|
|
} else { |
|
9417
|
|
|
$orderby_query = " ORDER BY HOUR(spotter_output.date) ASC"; |
|
9418
|
|
|
} |
|
9419
|
|
|
/* |
|
9420
|
|
|
$query = "SELECT spotter_output.*, count(spotter_output.ident) as ident_count |
|
9421
|
|
|
FROM spotter_output |
|
9422
|
|
|
WHERE DAYNAME(spotter_output.date) = '$currentDayofWeek' AND HOUR(spotter_output.date) >= '$currentHour' AND HOUR(spotter_output.date) <= '$next3Hours' AND spotter_output.ident <> '' AND format_source <> 'aprs' |
|
9423
|
|
|
GROUP BY spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time HAVING count(spotter_output.ident) > 10 $orderby_query"; |
|
9424
|
|
|
*/ |
|
9425
|
|
|
/* $query = "SELECT spotter_output.ident, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time, count(spotter_output.ident) as ident_count |
|
9426
|
|
|
FROM spotter_output |
|
9427
|
|
|
WHERE DAYNAME(spotter_output.date) = '$currentDayofWeek' AND HOUR(spotter_output.date) >= '$currentHour' AND HOUR(spotter_output.date) <= '$next3Hours' AND spotter_output.ident <> '' AND format_source <> 'aprs' |
|
9428
|
|
|
GROUP BY spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time HAVING count(spotter_output.ident) > 10 $orderby_query"; |
|
9429
|
|
|
*/ |
|
9430
|
|
|
$query = "SELECT spotter_output.ident, spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, count(spotter_output.ident) as ident_count |
|
9431
|
|
|
FROM spotter_output".$filter_query." DAYNAME(spotter_output.date) = '$currentDayofWeek' AND HOUR(spotter_output.date) >= '$currentHour' AND HOUR(spotter_output.date) <= '$next3Hours' AND spotter_output.ident <> '' AND format_source <> 'aprs' |
|
9432
|
|
|
GROUP BY spotter_output.ident,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time |
|
9433
|
|
|
HAVING count(spotter_output.ident) > 5$orderby_query"; |
|
9434
|
|
|
|
|
9435
|
|
|
$spotter_array = $this->getDataFromDB($query.$limit_query); |
|
9436
|
|
|
} else { |
|
9437
|
|
|
if ($sort != "") |
|
9438
|
|
|
{ |
|
9439
|
|
|
$search_orderby_array = $this->getOrderBy(); |
|
9440
|
|
|
$orderby_query = $search_orderby_array[$sort]['sql']; |
|
9441
|
|
|
} else { |
|
9442
|
|
|
$orderby_query = " ORDER BY to_char(spotter_output.date,'HH') ASC"; |
|
9443
|
|
|
} |
|
9444
|
|
|
$query = "SELECT spotter_output.ident, spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, count(spotter_output.ident) as ident_count, to_char(spotter_output.date,'HH') |
|
9445
|
|
|
FROM spotter_output".$filter_query." DATE_PART('dow', spotter_output.date) = DATE_PART('dow', date 'now' AT TIME ZONE :timezone) AND EXTRACT (HOUR FROM spotter_output.date AT TIME ZONE :timezone) >= '$currentHour' AND EXTRACT (HOUR FROM spotter_output.date AT TIME ZONE :timezone) <= '$next3Hours' AND ident <> '' |
|
9446
|
|
|
GROUP BY spotter_output.ident,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, to_char(spotter_output.date,'HH') |
|
9447
|
|
|
HAVING count(spotter_output.ident) > 5$orderby_query"; |
|
9448
|
|
|
//echo $query; |
|
9449
|
|
|
$spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone)); |
|
9450
|
|
|
/* |
|
9451
|
|
|
$sth = $this->db->prepare($query); |
|
9452
|
|
|
$sth->execute(array(':timezone' => $globalTimezone)); |
|
9453
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
9454
|
|
|
*/ |
|
9455
|
|
|
} |
|
9456
|
|
|
return $spotter_array; |
|
9457
|
|
|
} |
|
9458
|
|
|
|
|
9459
|
|
|
|
|
9460
|
|
|
/** |
|
9461
|
|
|
* Gets the Barrie Spotter ID based on the FlightAware ID |
|
9462
|
|
|
* |
|
9463
|
|
|
* @return Integer the Barrie Spotter ID |
|
9464
|
|
|
q * |
|
9465
|
|
|
*/ |
|
9466
|
|
|
public function getSpotterIDBasedOnFlightAwareID($flightaware_id) |
|
9467
|
|
|
{ |
|
9468
|
|
|
$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
9469
|
|
|
|
|
9470
|
|
|
$query = "SELECT spotter_output.spotter_id |
|
9471
|
|
|
FROM spotter_output |
|
9472
|
|
|
WHERE spotter_output.flightaware_id = '".$flightaware_id."'"; |
|
9473
|
|
|
|
|
9474
|
|
|
|
|
9475
|
|
|
$sth = $this->db->prepare($query); |
|
9476
|
|
|
$sth->execute(); |
|
9477
|
|
|
|
|
9478
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9479
|
|
|
{ |
|
9480
|
|
|
return $row['spotter_id']; |
|
9481
|
|
|
} |
|
9482
|
|
|
} |
|
9483
|
|
|
|
|
9484
|
|
|
|
|
9485
|
|
|
/** |
|
9486
|
|
|
* Parses a date string |
|
9487
|
|
|
* |
|
9488
|
|
|
* @param String $dateString the date string |
|
9489
|
|
|
* @param String $timezone the timezone of a user |
|
9490
|
|
|
* @return Array the time information |
|
9491
|
|
|
* |
|
9492
|
|
|
*/ |
|
9493
|
|
|
public function parseDateString($dateString, $timezone = '') |
|
9494
|
|
|
{ |
|
9495
|
|
|
$time_array = array(); |
|
9496
|
|
|
|
|
9497
|
|
|
if ($timezone != "") |
|
9498
|
|
|
{ |
|
9499
|
|
|
date_default_timezone_set($timezone); |
|
9500
|
|
|
} |
|
9501
|
|
|
|
|
9502
|
|
|
$current_date = date("Y-m-d H:i:s"); |
|
9503
|
|
|
$date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
9504
|
|
|
|
|
9505
|
|
|
$diff = abs(strtotime($current_date) - strtotime($date)); |
|
9506
|
|
|
|
|
9507
|
|
|
$time_array['years'] = floor($diff / (365*60*60*24)); |
|
9508
|
|
|
$years = $time_array['years']; |
|
9509
|
|
|
|
|
9510
|
|
|
$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
9511
|
|
|
$months = $time_array['months']; |
|
9512
|
|
|
|
|
9513
|
|
|
$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
9514
|
|
|
$days = $time_array['days']; |
|
9515
|
|
|
$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
9516
|
|
|
$hours = $time_array['hours']; |
|
9517
|
|
|
$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
9518
|
|
|
$minutes = $time_array['minutes']; |
|
9519
|
|
|
$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
9520
|
|
|
|
|
9521
|
|
|
return $time_array; |
|
9522
|
|
|
} |
|
9523
|
|
|
|
|
9524
|
|
|
|
|
9525
|
|
|
|
|
9526
|
|
|
|
|
9527
|
|
|
/** |
|
9528
|
|
|
* Parses the direction degrees to working |
|
9529
|
|
|
* |
|
9530
|
|
|
* @param Float $direction the direction in degrees |
|
9531
|
|
|
* @return Array the direction information |
|
9532
|
|
|
* |
|
9533
|
|
|
*/ |
|
9534
|
|
|
public function parseDirection($direction = 0) |
|
9535
|
|
|
{ |
|
9536
|
|
|
if ($direction == '') $direction = 0; |
|
9537
|
|
|
$direction_array = array(); |
|
9538
|
|
|
$temp_array = array(); |
|
9539
|
|
|
|
|
9540
|
|
|
if ($direction == 360 || ($direction >= 0 && $direction < 22.5)) |
|
9541
|
|
|
{ |
|
9542
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9543
|
|
|
$temp_array['direction_shortname'] = "N"; |
|
9544
|
|
|
$temp_array['direction_fullname'] = "North"; |
|
9545
|
|
|
} elseif ($direction >= 22.5 && $direction < 45){ |
|
9546
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9547
|
|
|
$temp_array['direction_shortname'] = "NNE"; |
|
9548
|
|
|
$temp_array['direction_fullname'] = "North-Northeast"; |
|
9549
|
|
|
} elseif ($direction >= 45 && $direction < 67.5){ |
|
9550
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9551
|
|
|
$temp_array['direction_shortname'] = "NE"; |
|
9552
|
|
|
$temp_array['direction_fullname'] = "Northeast"; |
|
9553
|
|
|
} elseif ($direction >= 67.5 && $direction < 90){ |
|
9554
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9555
|
|
|
$temp_array['direction_shortname'] = "ENE"; |
|
9556
|
|
|
$temp_array['direction_fullname'] = "East-Northeast"; |
|
9557
|
|
|
} elseif ($direction >= 90 && $direction < 112.5){ |
|
9558
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9559
|
|
|
$temp_array['direction_shortname'] = "E"; |
|
9560
|
|
|
$temp_array['direction_fullname'] = "East"; |
|
9561
|
|
|
} elseif ($direction >= 112.5 && $direction < 135){ |
|
9562
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9563
|
|
|
$temp_array['direction_shortname'] = "ESE"; |
|
9564
|
|
|
$temp_array['direction_fullname'] = "East-Southeast"; |
|
9565
|
|
|
} elseif ($direction >= 135 && $direction < 157.5){ |
|
9566
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9567
|
|
|
$temp_array['direction_shortname'] = "SE"; |
|
9568
|
|
|
$temp_array['direction_fullname'] = "Southeast"; |
|
9569
|
|
|
} elseif ($direction >= 157.5 && $direction < 180){ |
|
9570
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9571
|
|
|
$temp_array['direction_shortname'] = "SSE"; |
|
9572
|
|
|
$temp_array['direction_fullname'] = "South-Southeast"; |
|
9573
|
|
|
} elseif ($direction >= 180 && $direction < 202.5){ |
|
9574
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9575
|
|
|
$temp_array['direction_shortname'] = "S"; |
|
9576
|
|
|
$temp_array['direction_fullname'] = "South"; |
|
9577
|
|
|
} elseif ($direction >= 202.5 && $direction < 225){ |
|
9578
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9579
|
|
|
$temp_array['direction_shortname'] = "SSW"; |
|
9580
|
|
|
$temp_array['direction_fullname'] = "South-Southwest"; |
|
9581
|
|
|
} elseif ($direction >= 225 && $direction < 247.5){ |
|
9582
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9583
|
|
|
$temp_array['direction_shortname'] = "SW"; |
|
9584
|
|
|
$temp_array['direction_fullname'] = "Southwest"; |
|
9585
|
|
|
} elseif ($direction >= 247.5 && $direction < 270){ |
|
9586
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9587
|
|
|
$temp_array['direction_shortname'] = "WSW"; |
|
9588
|
|
|
$temp_array['direction_fullname'] = "West-Southwest"; |
|
9589
|
|
|
} elseif ($direction >= 270 && $direction < 292.5){ |
|
9590
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9591
|
|
|
$temp_array['direction_shortname'] = "W"; |
|
9592
|
|
|
$temp_array['direction_fullname'] = "West"; |
|
9593
|
|
|
} elseif ($direction >= 292.5 && $direction < 315){ |
|
9594
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9595
|
|
|
$temp_array['direction_shortname'] = "WNW"; |
|
9596
|
|
|
$temp_array['direction_fullname'] = "West-Northwest"; |
|
9597
|
|
|
} elseif ($direction >= 315 && $direction < 337.5){ |
|
9598
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9599
|
|
|
$temp_array['direction_shortname'] = "NW"; |
|
9600
|
|
|
$temp_array['direction_fullname'] = "Northwest"; |
|
9601
|
|
|
} elseif ($direction >= 337.5 && $direction < 360){ |
|
9602
|
|
|
$temp_array['direction_degree'] = $direction; |
|
9603
|
|
|
$temp_array['direction_shortname'] = "NNW"; |
|
9604
|
|
|
$temp_array['direction_fullname'] = "North-Northwest"; |
|
9605
|
|
|
} |
|
9606
|
|
|
$direction_array[] = $temp_array; |
|
9607
|
|
|
return $direction_array; |
|
9608
|
|
|
} |
|
9609
|
|
|
|
|
9610
|
|
|
|
|
9611
|
|
|
/** |
|
9612
|
|
|
* Gets the aircraft registration |
|
9613
|
|
|
* |
|
9614
|
|
|
* @param String $flightaware_id the flight aware id |
|
9615
|
|
|
* @return String the aircraft registration |
|
9616
|
|
|
* |
|
9617
|
|
|
*/ |
|
9618
|
|
|
|
|
9619
|
|
|
public function getAircraftRegistration($flightaware_id) |
|
9620
|
|
|
{ |
|
9621
|
|
|
global $globalFlightAwareUsername, $globalFlightAwarePassword; |
|
9622
|
|
|
|
|
9623
|
|
|
$options = array( |
|
9624
|
|
|
'trace' => true, |
|
9625
|
|
|
'exceptions' => 0, |
|
9626
|
|
|
'login' => $globalFlightAwareUsername, |
|
9627
|
|
|
'password' => $globalFlightAwarePassword, |
|
9628
|
|
|
); |
|
9629
|
|
|
$client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options); |
|
9630
|
|
|
|
|
9631
|
|
|
$params = array('faFlightID' => $flightaware_id); |
|
9632
|
|
|
$result = $client->AirlineFlightInfo($params); |
|
9633
|
|
|
|
|
9634
|
|
|
if (isset($result->AirlineFlightInfoResult)) |
|
9635
|
|
|
{ |
|
9636
|
|
|
$registration = $result->AirlineFlightInfoResult->tailnumber; |
|
9637
|
|
|
} else return ''; |
|
9638
|
|
|
|
|
9639
|
|
|
$registration = $this->convertAircraftRegistration($registration); |
|
9640
|
|
|
|
|
9641
|
|
|
return $registration; |
|
9642
|
|
|
} |
|
9643
|
|
|
|
|
9644
|
|
|
|
|
9645
|
|
|
/** |
|
9646
|
|
|
* Gets the aircraft registration from ModeS |
|
9647
|
|
|
* |
|
9648
|
|
|
* @param String $aircraft_modes the flight ModeS in hex |
|
9649
|
|
|
* @return String the aircraft registration |
|
9650
|
|
|
* |
|
9651
|
|
|
*/ |
|
9652
|
|
|
public function getAircraftRegistrationBymodeS($aircraft_modes) |
|
9653
|
|
|
{ |
|
9654
|
|
|
$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); |
|
9655
|
|
|
|
|
9656
|
|
|
$query = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; |
|
9657
|
|
|
|
|
9658
|
|
|
$sth = $this->db->prepare($query); |
|
9659
|
|
|
$sth->execute(array(':aircraft_modes' => $aircraft_modes)); |
|
9660
|
|
|
|
|
9661
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
9662
|
|
|
$sth->closeCursor(); |
|
9663
|
|
|
if (count($row) > 0) { |
|
9664
|
|
|
//return $row['Registration']; |
|
9665
|
|
|
return $row['registration']; |
|
9666
|
|
|
} else return ''; |
|
9667
|
|
|
|
|
9668
|
|
|
} |
|
9669
|
|
|
|
|
9670
|
|
|
/** |
|
9671
|
|
|
* Gets the aircraft type from ModeS |
|
9672
|
|
|
* |
|
9673
|
|
|
* @param String $aircraft_modes the flight ModeS in hex |
|
9674
|
|
|
* @return String the aircraft type |
|
9675
|
|
|
* |
|
9676
|
|
|
*/ |
|
9677
|
|
|
public function getAircraftTypeBymodeS($aircraft_modes) |
|
9678
|
|
|
{ |
|
9679
|
|
|
$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); |
|
9680
|
|
|
|
|
9681
|
|
|
$query = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; |
|
9682
|
|
|
|
|
9683
|
|
|
$sth = $this->db->prepare($query); |
|
9684
|
|
|
$sth->execute(array(':aircraft_modes' => $aircraft_modes)); |
|
9685
|
|
|
|
|
9686
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
9687
|
|
|
$sth->closeCursor(); |
|
9688
|
|
|
if (count($row) > 0) { |
|
9689
|
|
|
if ($row['type_flight'] == null) return ''; |
|
9690
|
|
|
else return $row['type_flight']; |
|
9691
|
|
|
} else return ''; |
|
9692
|
|
|
|
|
9693
|
|
|
} |
|
9694
|
|
|
|
|
9695
|
|
|
/** |
|
9696
|
|
|
* Gets Country from latitude/longitude |
|
9697
|
|
|
* |
|
9698
|
|
|
* @param Float $latitude latitute of the flight |
|
9699
|
|
|
* @param Float $longitude longitute of the flight |
|
9700
|
|
|
* @return String the countrie |
|
9701
|
|
|
*/ |
|
9702
|
|
|
public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
9703
|
|
|
{ |
|
9704
|
|
|
global $globalDBdriver, $globalDebug; |
|
9705
|
|
|
$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
9706
|
|
|
$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
9707
|
|
|
|
|
9708
|
|
|
$Connection = new Connection($this->db); |
|
9709
|
|
|
if (!$Connection->tableExists('countries')) return ''; |
|
9710
|
|
|
|
|
9711
|
|
|
try { |
|
9712
|
|
|
/* |
|
9713
|
|
|
if ($globalDBdriver == 'mysql') { |
|
9714
|
|
|
//$query = "SELECT name, iso2, iso3 FROM countries WHERE Within(GeomFromText('POINT(:latitude :longitude)'), ogc_geom) LIMIT 1"; |
|
9715
|
|
|
$query = "SELECT name, iso2, iso3 FROM countries WHERE Within(GeomFromText('POINT(".$longitude.' '.$latitude.")'), ogc_geom) LIMIT 1"; |
|
9716
|
|
|
} |
|
9717
|
|
|
*/ |
|
9718
|
|
|
// This query seems to work both for MariaDB and PostgreSQL |
|
9719
|
|
|
$query = "SELECT name,iso2,iso3 FROM countries WHERE ST_Within(ST_GeomFromText('POINT(".$longitude." ".$latitude.")',4326), ogc_geom) LIMIT 1"; |
|
9720
|
|
|
|
|
9721
|
|
|
$sth = $this->db->prepare($query); |
|
9722
|
|
|
//$sth->execute(array(':latitude' => $latitude,':longitude' => $longitude)); |
|
9723
|
|
|
$sth->execute(); |
|
9724
|
|
|
|
|
9725
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
9726
|
|
|
$sth->closeCursor(); |
|
9727
|
|
|
if (count($row) > 0) { |
|
9728
|
|
|
return $row; |
|
9729
|
|
|
} else return ''; |
|
9730
|
|
|
} catch (PDOException $e) { |
|
9731
|
|
|
if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
9732
|
|
|
return ''; |
|
9733
|
|
|
} |
|
9734
|
|
|
|
|
9735
|
|
|
} |
|
9736
|
|
|
|
|
9737
|
|
|
/** |
|
9738
|
|
|
* Gets Country from iso2 |
|
9739
|
|
|
* |
|
9740
|
|
|
* @param String $iso2 ISO2 country code |
|
9741
|
|
|
* @return String the countrie |
|
9742
|
|
|
*/ |
|
9743
|
|
|
public function getCountryFromISO2($iso2) |
|
9744
|
|
|
{ |
|
9745
|
|
|
global $globalDBdriver, $globalDebug; |
|
9746
|
|
|
$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
9747
|
|
|
|
|
9748
|
|
|
$Connection = new Connection($this->db); |
|
9749
|
|
|
if (!$Connection->tableExists('countries')) return ''; |
|
9750
|
|
|
|
|
9751
|
|
|
try { |
|
9752
|
|
|
$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
|
9753
|
|
|
|
|
9754
|
|
|
$sth = $this->db->prepare($query); |
|
9755
|
|
|
$sth->execute(array(':iso2' => $iso2)); |
|
9756
|
|
|
|
|
9757
|
|
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
9758
|
|
|
$sth->closeCursor(); |
|
9759
|
|
|
if (count($row) > 0) { |
|
9760
|
|
|
return $row; |
|
9761
|
|
|
} else return ''; |
|
9762
|
|
|
} catch (PDOException $e) { |
|
9763
|
|
|
if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
9764
|
|
|
return ''; |
|
9765
|
|
|
} |
|
9766
|
|
|
|
|
9767
|
|
|
} |
|
9768
|
|
|
|
|
9769
|
|
|
/** |
|
9770
|
|
|
* converts the registration code using the country prefix |
|
9771
|
|
|
* |
|
9772
|
|
|
* @param String $registration the aircraft registration |
|
9773
|
|
|
* @return String the aircraft registration |
|
9774
|
|
|
* |
|
9775
|
|
|
*/ |
|
9776
|
|
|
public function convertAircraftRegistration($registration) |
|
9777
|
|
|
{ |
|
9778
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
9779
|
|
|
$registration_prefix = ''; |
|
9780
|
|
|
$registration_1 = substr($registration, 0, 1); |
|
9781
|
|
|
$registration_2 = substr($registration, 0, 2); |
|
9782
|
|
|
|
|
9783
|
|
|
//first get the prefix based on two characters |
|
9784
|
|
|
$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2"; |
|
9785
|
|
|
|
|
9786
|
|
|
|
|
9787
|
|
|
$sth = $this->db->prepare($query); |
|
9788
|
|
|
$sth->execute(array(':registration_2' => $registration_2)); |
|
9789
|
|
|
|
|
9790
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9791
|
|
|
{ |
|
9792
|
|
|
$registration_prefix = $row['registration_prefix']; |
|
9793
|
|
|
} |
|
9794
|
|
|
|
|
9795
|
|
|
//if we didn't find a two chracter prefix lets just search the one with one character |
|
9796
|
|
|
if ($registration_prefix == '') |
|
9797
|
|
|
{ |
|
9798
|
|
|
$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1"; |
|
9799
|
|
|
$sth = $this->db->prepare($query); |
|
9800
|
|
|
$sth->execute(array(':registration_1' => $registration_1)); |
|
9801
|
|
|
|
|
9802
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9803
|
|
|
{ |
|
9804
|
|
|
$registration_prefix = $row['registration_prefix']; |
|
9805
|
|
|
} |
|
9806
|
|
|
} |
|
9807
|
|
|
|
|
9808
|
|
|
//determine which characters are being used and convert the registration code appropiately |
|
9809
|
|
|
if (strlen($registration_prefix) == 1) |
|
9810
|
|
|
{ |
|
9811
|
|
|
if (0 === strpos($registration, 'N')) { |
|
9812
|
|
|
$registration = preg_replace("/^(.{1})/", "$1", $registration); |
|
9813
|
|
|
} else { |
|
9814
|
|
|
$registration = preg_replace("/^(.{1})/", "$1-", $registration); |
|
9815
|
|
|
} |
|
9816
|
|
|
} else if(strlen($registration_prefix) == 2){ |
|
9817
|
|
|
if (0 === strpos($registration, 'N')) { |
|
9818
|
|
|
$registration = preg_replace("/^(.{2})/", "$1", $registration); |
|
9819
|
|
|
} else { |
|
9820
|
|
|
$registration = preg_replace("/^(.{2})/", "$1-", $registration); |
|
9821
|
|
|
} |
|
9822
|
|
|
} |
|
9823
|
|
|
return $registration; |
|
9824
|
|
|
} |
|
9825
|
|
|
|
|
9826
|
|
|
/** |
|
9827
|
|
|
* Country from the registration code |
|
9828
|
|
|
* |
|
9829
|
|
|
* @param String $registration the aircraft registration |
|
9830
|
|
|
* @return String the country |
|
9831
|
|
|
* |
|
9832
|
|
|
*/ |
|
9833
|
|
|
public function countryFromAircraftRegistration($registration) |
|
9834
|
|
|
{ |
|
9835
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
9836
|
|
|
|
|
9837
|
|
|
$registration_prefix = ''; |
|
9838
|
|
|
$registration_test = explode('-',$registration); |
|
9839
|
|
|
$country = ''; |
|
9840
|
|
|
if ($registration_test[0] != $registration) { |
|
9841
|
|
|
$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; |
|
9842
|
|
|
|
|
9843
|
|
|
$sth = $this->db->prepare($query); |
|
9844
|
|
|
$sth->execute(array(':registration_1' => $registration_test[0])); |
|
9845
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9846
|
|
|
{ |
|
9847
|
|
|
//$registration_prefix = $row['registration_prefix']; |
|
9848
|
|
|
$country = $row['country']; |
|
9849
|
|
|
} |
|
9850
|
|
|
} else { |
|
9851
|
|
|
$registration_1 = substr($registration, 0, 1); |
|
9852
|
|
|
$registration_2 = substr($registration, 0, 2); |
|
9853
|
|
|
|
|
9854
|
|
|
$country = ''; |
|
9855
|
|
|
//first get the prefix based on two characters |
|
9856
|
|
|
$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1"; |
|
9857
|
|
|
|
|
9858
|
|
|
|
|
9859
|
|
|
$sth = $this->db->prepare($query); |
|
9860
|
|
|
$sth->execute(array(':registration_2' => $registration_2)); |
|
9861
|
|
|
|
|
9862
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9863
|
|
|
{ |
|
9864
|
|
|
$registration_prefix = $row['registration_prefix']; |
|
9865
|
|
|
$country = $row['country']; |
|
9866
|
|
|
} |
|
9867
|
|
|
|
|
9868
|
|
|
//if we didn't find a two chracter prefix lets just search the one with one character |
|
9869
|
|
|
if ($registration_prefix == "") |
|
9870
|
|
|
{ |
|
9871
|
|
|
$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; |
|
9872
|
|
|
|
|
9873
|
|
|
$sth = $this->db->prepare($query); |
|
9874
|
|
|
$sth->execute(array(':registration_1' => $registration_1)); |
|
9875
|
|
|
|
|
9876
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9877
|
|
|
{ |
|
9878
|
|
|
//$registration_prefix = $row['registration_prefix']; |
|
9879
|
|
|
$country = $row['country']; |
|
9880
|
|
|
} |
|
9881
|
|
|
} |
|
9882
|
|
|
} |
|
9883
|
|
|
|
|
9884
|
|
|
return $country; |
|
9885
|
|
|
} |
|
9886
|
|
|
|
|
9887
|
|
|
/** |
|
9888
|
|
|
* Country from the registration code |
|
9889
|
|
|
* |
|
9890
|
|
|
* @param String $registration the aircraft registration |
|
9891
|
|
|
* @return String the country |
|
9892
|
|
|
* |
|
9893
|
|
|
*/ |
|
9894
|
|
|
public function countryFromAircraftRegistrationCode($registration) |
|
9895
|
|
|
{ |
|
9896
|
|
|
$registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
9897
|
|
|
|
|
9898
|
|
|
$country = ''; |
|
9899
|
|
|
$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1"; |
|
9900
|
|
|
$sth = $this->db->prepare($query); |
|
9901
|
|
|
$sth->execute(array(':registration' => $registration)); |
|
9902
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
9903
|
|
|
{ |
|
9904
|
|
|
$country = $row['country']; |
|
9905
|
|
|
} |
|
9906
|
|
|
return $country; |
|
9907
|
|
|
} |
|
9908
|
|
|
|
|
9909
|
|
|
/** |
|
9910
|
|
|
* Set a new highlight value for a flight |
|
9911
|
|
|
* |
|
9912
|
|
|
* @param String $flightaware_id flightaware_id from spotter_output table |
|
9913
|
|
|
* @param String $highlight New highlight value |
|
9914
|
|
|
*/ |
|
9915
|
|
|
public function setHighlightFlight($flightaware_id,$highlight) { |
|
9916
|
|
|
|
|
9917
|
|
|
$query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id"; |
|
9918
|
|
|
$sth = $this->db->prepare($query); |
|
9919
|
|
|
$sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight)); |
|
9920
|
|
|
} |
|
9921
|
|
|
|
|
9922
|
|
|
/** |
|
9923
|
|
|
* Gets the short url from bit.ly |
|
9924
|
|
|
* |
|
9925
|
|
|
* @param String $url the full url |
|
9926
|
|
|
* @return String the bit.ly url |
|
9927
|
|
|
* |
|
9928
|
|
|
*/ |
|
9929
|
|
|
public function getBitlyURL($url) |
|
9930
|
|
|
{ |
|
9931
|
|
|
global $globalBitlyAccessToken; |
|
9932
|
|
|
|
|
9933
|
|
|
if ($globalBitlyAccessToken == '') return $url; |
|
9934
|
|
|
|
|
9935
|
|
|
$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
|
9936
|
|
|
|
|
9937
|
|
|
$ch = curl_init(); |
|
9938
|
|
|
curl_setopt($ch, CURLOPT_HEADER, 0); |
|
9939
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
9940
|
|
|
curl_setopt($ch, CURLOPT_URL, $google_url); |
|
9941
|
|
|
$bitly_data = curl_exec($ch); |
|
9942
|
|
|
curl_close($ch); |
|
9943
|
|
|
|
|
9944
|
|
|
$bitly_data = json_decode($bitly_data); |
|
9945
|
|
|
$bitly_url = ''; |
|
9946
|
|
|
if ($bitly_data->status_txt = "OK"){ |
|
9947
|
|
|
$bitly_url = $bitly_data->data->url; |
|
9948
|
|
|
} |
|
9949
|
|
|
|
|
9950
|
|
|
return $bitly_url; |
|
9951
|
|
|
} |
|
9952
|
|
|
|
|
9953
|
|
|
|
|
9954
|
|
|
public function getOrderBy() |
|
9955
|
|
|
{ |
|
9956
|
|
|
$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
9957
|
|
|
|
|
9958
|
|
|
return $orderby; |
|
9959
|
|
|
|
|
9960
|
|
|
} |
|
9961
|
|
|
|
|
9962
|
|
|
/* |
|
9963
|
|
|
public function importFromFlightAware() |
|
9964
|
|
|
{ |
|
9965
|
|
|
global $globalFlightAwareUsername, $globalFlightAwarePassword, $globalLatitudeMax, $globalLatitudeMin, $globalLongitudeMax, $globalLongitudeMin, $globalAirportIgnore; |
|
9966
|
|
|
$Spotter = new Spotter($this->db); |
|
9967
|
|
|
$SpotterLive = new SpotterLive($this->db); |
|
9968
|
|
|
$options = array( |
|
9969
|
|
|
'trace' => true, |
|
9970
|
|
|
'exceptions' => 0, |
|
9971
|
|
|
'login' => $globalFlightAwareUsername, |
|
9972
|
|
|
'password' => $globalFlightAwarePassword, |
|
9973
|
|
|
); |
|
9974
|
|
|
$client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options); |
|
9975
|
|
|
$params = array('query' => '{range lat '.$globalLatitudeMin.' '.$globalLatitudeMax.'} {range lon '.$globalLongitudeMax.' '.$globalLongitudeMin.'} {true inAir}', 'howMany' => '15', 'offset' => '0'); |
|
9976
|
|
|
$result = $client->SearchBirdseyeInFlight($params); |
|
9977
|
|
|
$dataFound = false; |
|
9978
|
|
|
$ignoreImport = false; |
|
9979
|
|
|
if (isset($result->SearchBirdseyeInFlightResult)) |
|
9980
|
|
|
{ |
|
9981
|
|
|
if (is_array($result->SearchBirdseyeInFlightResult->aircraft)) |
|
9982
|
|
|
{ |
|
9983
|
|
|
foreach($result->SearchBirdseyeInFlightResult->aircraft as $aircraft) |
|
9984
|
|
|
{ |
|
9985
|
|
|
if (!strstr($aircraft->origin, 'L ') && !strstr($aircraft->destination, 'L ')) |
|
9986
|
|
|
{ |
|
9987
|
|
|
foreach($globalAirportIgnore as $airportIgnore) |
|
9988
|
|
|
{ |
|
9989
|
|
|
if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore) |
|
9990
|
|
|
{ |
|
9991
|
|
|
$ignoreImport = true; |
|
9992
|
|
|
} |
|
9993
|
|
|
} |
|
9994
|
|
|
if ($ignoreImport == false) |
|
9995
|
|
|
{ |
|
9996
|
|
|
$flightaware_id = $aircraft->faFlightID; |
|
9997
|
|
|
$ident = $aircraft->ident; |
|
9998
|
|
|
$aircraft_type = $aircraft->type; |
|
9999
|
|
|
$departure_airport = $aircraft->origin; |
|
10000
|
|
|
$arrival_airport = $aircraft->destination; |
|
10001
|
|
|
$latitude = $aircraft->latitude; |
|
10002
|
|
|
$longitude = $aircraft->longitude; |
|
10003
|
|
|
$waypoints = $aircraft->waypoints; |
|
10004
|
|
|
$altitude = $aircraft->altitude; |
|
10005
|
|
|
$heading = $aircraft->heading; |
|
10006
|
|
|
$groundspeed = $aircraft->groundspeed; |
|
10007
|
|
|
$dataFound = true; |
|
10008
|
|
|
//gets the callsign from the last hour |
|
10009
|
|
|
$last_hour_ident = $this->getIdentFromLastHour($ident); |
|
10010
|
|
|
//change the departure/arrival airport to NA if its not available |
|
10011
|
|
|
if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; } |
|
10012
|
|
|
if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; } |
|
10013
|
|
|
//if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
10014
|
|
|
if($last_hour_ident == "") |
|
10015
|
|
|
{ |
|
10016
|
|
|
//adds the spotter data for the archive |
|
10017
|
|
|
$Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
10018
|
|
|
} |
|
10019
|
|
|
|
|
10020
|
|
|
//adds the spotter LIVE data |
|
10021
|
|
|
$SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
10022
|
|
|
} |
|
10023
|
|
|
} |
|
10024
|
|
|
$ignoreImport = false; |
|
10025
|
|
|
} |
|
10026
|
|
|
} else { |
|
10027
|
|
|
if (!strstr($result->SearchBirdseyeInFlightResult->aircraft->origin, 'L ') && !strstr($result->SearchBirdseyeInFlightResult->aircraft->destination, 'L ')) |
|
10028
|
|
|
{ |
|
10029
|
|
|
foreach($globalAirportIgnore as $airportIgnore) |
|
10030
|
|
|
{ |
|
10031
|
|
|
foreach($globalAirportIgnore as $airportIgnore) |
|
10032
|
|
|
{ |
|
10033
|
|
|
if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore) |
|
10034
|
|
|
{ |
|
10035
|
|
|
$ignoreImport = true; |
|
10036
|
|
|
} |
|
10037
|
|
|
} |
|
10038
|
|
|
if ($ignoreImport == false) |
|
10039
|
|
|
{ |
|
10040
|
|
|
$flightaware_id = $result->SearchBirdseyeInFlightResult->aircraft->faFlightID; |
|
10041
|
|
|
$ident = $result->SearchBirdseyeInFlightResult->aircraft->ident; |
|
10042
|
|
|
$aircraft_type = $result->SearchBirdseyeInFlightResult->aircraft->type; |
|
10043
|
|
|
$departure_airport = $result->SearchBirdseyeInFlightResult->aircraft->origin; |
|
10044
|
|
|
$arrival_airport = $result->SearchBirdseyeInFlightResult->aircraft->destination; |
|
10045
|
|
|
$latitude = $result->SearchBirdseyeInFlightResult->aircraft->latitude; |
|
10046
|
|
|
$longitude = $result->SearchBirdseyeInFlightResult->aircraft->longitude; |
|
10047
|
|
|
$waypoints = $result->SearchBirdseyeInFlightResult->aircraft->waypoints; |
|
10048
|
|
|
$altitude = $result->SearchBirdseyeInFlightResult->aircraft->altitude; |
|
10049
|
|
|
$heading = $result->SearchBirdseyeInFlightResult->aircraft->heading; |
|
10050
|
|
|
$groundspeed = $result->SearchBirdseyeInFlightResult->aircraft->groundspeed; |
|
10051
|
|
|
$dataFound = true; |
|
10052
|
|
|
//gets the callsign from the last hour |
|
10053
|
|
|
$last_hour_ident = $this->getIdentFromLastHour($ident); |
|
10054
|
|
|
//change the departure/arrival airport to NA if its not available |
|
10055
|
|
|
if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; } |
|
10056
|
|
|
if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; } |
|
10057
|
|
|
//if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
10058
|
|
|
if($last_hour_ident == "") |
|
10059
|
|
|
{ |
|
10060
|
|
|
//adds the spotter data for the archive |
|
10061
|
|
|
$Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
10062
|
|
|
} |
|
10063
|
|
|
//adds the spotter LIVE data |
|
10064
|
|
|
$SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
10065
|
|
|
} |
|
10066
|
|
|
$ignoreImport = false; |
|
10067
|
|
|
} |
|
10068
|
|
|
} |
|
10069
|
|
|
} |
|
10070
|
|
|
} |
|
10071
|
|
|
} |
|
10072
|
|
|
*/ |
|
10073
|
|
|
|
|
10074
|
|
|
// Update flights data when new data in DB |
|
10075
|
|
|
public function updateFieldsFromOtherTables() |
|
10076
|
|
|
{ |
|
10077
|
|
|
global $globalDebug, $globalDBdriver; |
|
10078
|
|
|
$Image = new Image($this->db); |
|
10079
|
|
|
|
|
10080
|
|
|
|
|
10081
|
|
|
// routes |
|
10082
|
|
|
if ($globalDebug) print "Routes...\n"; |
|
10083
|
|
|
if ($globalDBdriver == 'mysql') { |
|
10084
|
|
|
$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; |
|
10085
|
|
|
} else { |
|
10086
|
|
|
$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '15 DAYS'"; |
|
10087
|
|
|
} |
|
10088
|
|
|
$sth = $this->db->prepare($query); |
|
10089
|
|
|
$sth->execute(); |
|
10090
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
10091
|
|
|
{ |
|
10092
|
|
|
$departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']); |
|
10093
|
|
|
$arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']); |
|
10094
|
|
|
if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) { |
|
10095
|
|
|
$update_query="UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id"; |
|
10096
|
|
|
$sthu = $this->db->prepare($update_query); |
|
10097
|
|
|
$sthu->execute(array(':fromicao' => $row['fromairport_icao'],':toicao' => $row['toairport_icao'],':spotter_id' => $row['spotter_id'],':departure_airport_name' => $departure_airport_array[0]['name'],':departure_airport_city' => $departure_airport_array[0]['city'],':departure_airport_country' => $departure_airport_array[0]['country'],':arrival_airport_name' => $arrival_airport_array[0]['name'],':arrival_airport_city' => $arrival_airport_array[0]['city'],':arrival_airport_country' => $arrival_airport_array[0]['country'])); |
|
10098
|
|
|
} |
|
10099
|
|
|
} |
|
10100
|
|
|
|
|
10101
|
|
|
if ($globalDebug) print "Airlines...\n"; |
|
10102
|
|
|
//airlines |
|
10103
|
|
|
if ($globalDBdriver == 'mysql') { |
|
10104
|
|
|
$query = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; |
|
10105
|
|
|
} elseif ($globalDBdriver == 'pgsql') { |
|
10106
|
|
|
$query = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '15 DAYS'"; |
|
10107
|
|
|
} |
|
10108
|
|
|
$sth = $this->db->prepare($query); |
|
10109
|
|
|
$sth->execute(); |
|
10110
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
10111
|
|
|
{ |
|
10112
|
|
|
if (is_numeric(substr($row['ident'], -1, 1))) |
|
10113
|
|
|
{ |
|
10114
|
|
|
$fromsource = NULL; |
|
10115
|
|
|
if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
10116
|
|
|
elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
10117
|
|
|
elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
10118
|
|
|
elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
10119
|
|
|
$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
|
10120
|
|
|
if (isset($airline_array[0]['name'])) { |
|
10121
|
|
|
$update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id"; |
|
10122
|
|
|
$sthu = $this->db->prepare($update_query); |
|
10123
|
|
|
$sthu->execute(array(':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id'])); |
|
10124
|
|
|
} |
|
10125
|
|
|
} |
|
10126
|
|
|
} |
|
10127
|
|
|
|
|
10128
|
|
|
if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n"; |
|
10129
|
|
|
//duplicate modes |
|
10130
|
|
|
$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL"; |
|
10131
|
|
|
$sth = $this->db->prepare($query); |
|
10132
|
|
|
$sth->execute(); |
|
10133
|
|
|
|
|
10134
|
|
|
if ($globalDebug) print "Aircraft...\n"; |
|
10135
|
|
|
//aircraft |
|
10136
|
|
|
if ($globalDBdriver == 'mysql') { |
|
10137
|
|
|
$query = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
|
10138
|
|
|
} elseif ($globalDBdriver == 'pgsql') { |
|
10139
|
|
|
$query = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INERVAL '15 DAYS'"; |
|
10140
|
|
|
} |
|
10141
|
|
|
$sth = $this->db->prepare($query); |
|
10142
|
|
|
$sth->execute(); |
|
10143
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
10144
|
|
|
{ |
|
10145
|
|
|
if ($row['aircraft_icao'] != '') { |
|
10146
|
|
|
$aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']); |
|
10147
|
|
|
if ($row['registration'] != ""){ |
|
10148
|
|
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
10149
|
|
|
if (!isset($image_array[0]['registration'])) { |
|
10150
|
|
|
$Image->addSpotterImage($row['registration']); |
|
10151
|
|
|
} |
|
10152
|
|
|
} |
|
10153
|
|
|
if (count($aircraft_name) > 0) { |
|
10154
|
|
|
$update_query = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id"; |
|
10155
|
|
|
$sthu = $this->db->prepare($update_query); |
|
10156
|
|
|
$sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id'])); |
|
10157
|
|
|
} |
|
10158
|
|
|
} |
|
10159
|
|
|
} |
|
10160
|
|
|
} |
|
10161
|
|
|
|
|
10162
|
|
|
// Update arrival airports for data already in DB |
|
10163
|
|
|
public function updateArrivalAirports() |
|
10164
|
|
|
{ |
|
10165
|
|
|
global $globalDebug, $globalDBdriver, $globalClosestMinDist; |
|
10166
|
|
|
$query = "SELECT spotter_output.spotter_id, spotter_output.last_latitude, spotter_output.last_longitude, spotter_output.last_altitude, spotter_output.arrival_airport_icao, spotter_output.real_arrival_airport_icao FROM spotter_output"; |
|
10167
|
|
|
$sth = $this->db->prepare($query); |
|
10168
|
|
|
$sth->execute(); |
|
10169
|
|
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
10170
|
|
|
{ |
|
10171
|
|
|
if ($row['last_latitude'] != '' && $row['last_longitude'] != '') { |
|
10172
|
|
|
$closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist); |
|
10173
|
|
|
$airport_icao = ''; |
|
10174
|
|
|
if (isset($closestAirports[0])) { |
|
10175
|
|
|
if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) { |
|
10176
|
|
|
$airport_icao = $closestAirports[0]['icao']; |
|
10177
|
|
|
if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
10178
|
|
|
} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') { |
|
10179
|
|
|
foreach ($closestAirports as $airport) { |
|
10180
|
|
|
if ($row['arrival_airport_icao'] == $airport['icao']) { |
|
10181
|
|
|
$airport_icao = $airport['icao']; |
|
10182
|
|
|
if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
10183
|
|
|
break; |
|
10184
|
|
|
} |
|
10185
|
|
|
} |
|
10186
|
|
|
} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) { |
|
10187
|
|
|
$airport_icao = $closestAirports[0]['icao']; |
|
10188
|
|
|
if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." ! Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
10189
|
|
|
} else { |
|
10190
|
|
|
if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
10191
|
|
|
} |
|
10192
|
|
|
} else { |
|
10193
|
|
|
if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
10194
|
|
|
} |
|
10195
|
|
|
if ($row['real_arrival_airport_icao'] != $airport_icao) { |
|
10196
|
|
|
if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n"; |
|
10197
|
|
|
$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id"; |
|
10198
|
|
|
$sthu = $this->db->prepare($update_query); |
|
10199
|
|
|
$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id'])); |
|
10200
|
|
|
} |
|
10201
|
|
|
} |
|
10202
|
|
|
} |
|
10203
|
|
|
} |
|
10204
|
|
|
|
|
10205
|
|
|
public function closestAirports($origLat,$origLon,$dist = 10) { |
|
10206
|
|
|
global $globalDBdriver; |
|
10207
|
|
|
$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
10208
|
|
|
/* |
|
10209
|
|
|
$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - abs(latitude))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(abs(latitude)*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance |
|
10210
|
|
|
FROM airport WHERE longitude between ($origLon-$dist/abs(cos(radians($origLat))*69)) and ($origLon+$dist/abs(cos(radians($origLat))*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
|
10211
|
|
|
having distance < $dist ORDER BY distance limit 100;"; |
|
10212
|
|
|
*/ |
|
10213
|
|
|
if ($globalDBdriver == 'mysql') { |
|
10214
|
|
|
$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance |
|
10215
|
|
|
FROM airport WHERE longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
|
10216
|
|
|
AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;"; |
|
10217
|
|
|
} else { |
|
10218
|
|
|
$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance |
|
10219
|
|
|
FROM airport WHERE CAST(longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
|
10220
|
|
|
AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;"; |
|
10221
|
|
|
} |
|
10222
|
|
|
$sth = $this->db->prepare($query); |
|
10223
|
|
|
$sth->execute(); |
|
10224
|
|
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
10225
|
|
|
} |
|
10226
|
|
|
} |
|
10227
|
|
|
/* |
|
10228
|
|
|
$Spotter = new Spotter(); |
|
10229
|
|
|
print_r($Spotter->closestAirports('-19.9813','-47.8286',10)); |
|
10230
|
|
|
*/ |
|
10231
|
|
|
/* |
|
10232
|
|
|
$Spotter = new Spotter(); |
|
10233
|
|
|
$da = $Spotter->countAllDetectedArrivalAirports(true,0,'',true); |
|
10234
|
|
|
$aa = $Spotter->countAllArrivalAirports(true,0,'',true); |
|
10235
|
|
|
print_r($da); |
|
10236
|
|
|
print_r($aa); |
|
10237
|
|
|
print_r(array_merge($da,$aa)); |
|
10238
|
|
|
*/ |
|
10239
|
|
|
?> |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.