@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct($dbc = null) { |
14 | 14 | global $globalFilterName; |
15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
15 | + if (isset($globalFilterName)) { |
|
16 | + $this->filter_name = $globalFilterName; |
|
17 | + } |
|
16 | 18 | $Connection = new Connection($dbc); |
17 | 19 | $this->db = $Connection->db(); |
18 | 20 | } |
@@ -41,7 +43,9 @@ discard block |
||
41 | 43 | return $all; |
42 | 44 | } |
43 | 45 | public function getAllAirlineNames($filter_name = '') { |
44 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
46 | + if ($filter_name == '') { |
|
47 | + $filter_name = $this->filter_name; |
|
48 | + } |
|
45 | 49 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
46 | 50 | try { |
47 | 51 | $sth = $this->db->prepare($query); |
@@ -53,7 +57,9 @@ discard block |
||
53 | 57 | return $all; |
54 | 58 | } |
55 | 59 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
56 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
60 | + if ($filter_name == '') { |
|
61 | + $filter_name = $this->filter_name; |
|
62 | + } |
|
57 | 63 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
58 | 64 | try { |
59 | 65 | $sth = $this->db->prepare($query); |
@@ -65,7 +71,9 @@ discard block |
||
65 | 71 | return $all; |
66 | 72 | } |
67 | 73 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
68 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
74 | + if ($filter_name == '') { |
|
75 | + $filter_name = $this->filter_name; |
|
76 | + } |
|
69 | 77 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
70 | 78 | try { |
71 | 79 | $sth = $this->db->prepare($query); |
@@ -80,9 +88,14 @@ discard block |
||
80 | 88 | |
81 | 89 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
82 | 90 | global $globalStatsFilters; |
83 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
84 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
85 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
91 | + if ($filter_name == '') { |
|
92 | + $filter_name = $this->filter_name; |
|
93 | + } |
|
94 | + if ($limit) { |
|
95 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
96 | + } else { |
|
97 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
98 | + } |
|
86 | 99 | try { |
87 | 100 | $sth = $this->db->prepare($query); |
88 | 101 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -102,9 +115,14 @@ discard block |
||
102 | 115 | } |
103 | 116 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
104 | 117 | global $globalStatsFilters; |
105 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
106 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
107 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
118 | + if ($filter_name == '') { |
|
119 | + $filter_name = $this->filter_name; |
|
120 | + } |
|
121 | + if ($limit) { |
|
122 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
123 | + } else { |
|
124 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
125 | + } |
|
108 | 126 | try { |
109 | 127 | $sth = $this->db->prepare($query); |
110 | 128 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -124,9 +142,14 @@ discard block |
||
124 | 142 | } |
125 | 143 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
126 | 144 | global $globalStatsFilters; |
127 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
128 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
129 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
145 | + if ($filter_name == '') { |
|
146 | + $filter_name = $this->filter_name; |
|
147 | + } |
|
148 | + if ($limit) { |
|
149 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
150 | + } else { |
|
151 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
152 | + } |
|
130 | 153 | try { |
131 | 154 | $sth = $this->db->prepare($query); |
132 | 155 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -147,9 +170,14 @@ discard block |
||
147 | 170 | |
148 | 171 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
149 | 172 | global $globalStatsFilters; |
150 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
151 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
152 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
173 | + if ($filter_name == '') { |
|
174 | + $filter_name = $this->filter_name; |
|
175 | + } |
|
176 | + if ($limit) { |
|
177 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
178 | + } else { |
|
179 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
180 | + } |
|
153 | 181 | try { |
154 | 182 | $sth = $this->db->prepare($query); |
155 | 183 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -169,9 +197,14 @@ discard block |
||
169 | 197 | } |
170 | 198 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
171 | 199 | global $globalStatsFilters; |
172 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
173 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
174 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
200 | + if ($filter_name == '') { |
|
201 | + $filter_name = $this->filter_name; |
|
202 | + } |
|
203 | + if ($limit) { |
|
204 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
205 | + } else { |
|
206 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
207 | + } |
|
175 | 208 | try { |
176 | 209 | $sth = $this->db->prepare($query); |
177 | 210 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -192,9 +225,14 @@ discard block |
||
192 | 225 | |
193 | 226 | public function countAllAirlines($limit = true,$filter_name = '') { |
194 | 227 | global $globalStatsFilters; |
195 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
196 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
197 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
|
228 | + if ($filter_name == '') { |
|
229 | + $filter_name = $this->filter_name; |
|
230 | + } |
|
231 | + if ($limit) { |
|
232 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
233 | + } else { |
|
234 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
|
235 | + } |
|
198 | 236 | try { |
199 | 237 | $sth = $this->db->prepare($query); |
200 | 238 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -215,9 +253,14 @@ discard block |
||
215 | 253 | } |
216 | 254 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
217 | 255 | global $globalStatsFilters; |
218 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
219 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
220 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
256 | + if ($filter_name == '') { |
|
257 | + $filter_name = $this->filter_name; |
|
258 | + } |
|
259 | + if ($limit) { |
|
260 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
261 | + } else { |
|
262 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
263 | + } |
|
221 | 264 | try { |
222 | 265 | $sth = $this->db->prepare($query); |
223 | 266 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -237,9 +280,14 @@ discard block |
||
237 | 280 | } |
238 | 281 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
239 | 282 | global $globalStatsFilters; |
240 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
241 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
242 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
283 | + if ($filter_name == '') { |
|
284 | + $filter_name = $this->filter_name; |
|
285 | + } |
|
286 | + if ($limit) { |
|
287 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
288 | + } else { |
|
289 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
290 | + } |
|
243 | 291 | try { |
244 | 292 | $sth = $this->db->prepare($query); |
245 | 293 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -259,10 +307,15 @@ discard block |
||
259 | 307 | } |
260 | 308 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
261 | 309 | $Connection = new Connection(); |
262 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
310 | + if ($filter_name == '') { |
|
311 | + $filter_name = $this->filter_name; |
|
312 | + } |
|
263 | 313 | if ($Connection->tableExists('countries')) { |
264 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
265 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
314 | + if ($limit) { |
|
315 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
316 | + } else { |
|
317 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
318 | + } |
|
266 | 319 | try { |
267 | 320 | $sth = $this->db->prepare($query); |
268 | 321 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -283,9 +336,14 @@ discard block |
||
283 | 336 | } |
284 | 337 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
285 | 338 | global $globalStatsFilters; |
286 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
287 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
288 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
339 | + if ($filter_name == '') { |
|
340 | + $filter_name = $this->filter_name; |
|
341 | + } |
|
342 | + if ($limit) { |
|
343 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
344 | + } else { |
|
345 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
346 | + } |
|
289 | 347 | try { |
290 | 348 | $sth = $this->db->prepare($query); |
291 | 349 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -305,9 +363,14 @@ discard block |
||
305 | 363 | } |
306 | 364 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
307 | 365 | global $globalStatsFilters; |
308 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
309 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
310 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
366 | + if ($filter_name == '') { |
|
367 | + $filter_name = $this->filter_name; |
|
368 | + } |
|
369 | + if ($limit) { |
|
370 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
371 | + } else { |
|
372 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
373 | + } |
|
311 | 374 | try { |
312 | 375 | $sth = $this->db->prepare($query); |
313 | 376 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -327,9 +390,14 @@ discard block |
||
327 | 390 | } |
328 | 391 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
329 | 392 | global $globalStatsFilters; |
330 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
331 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
332 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
393 | + if ($filter_name == '') { |
|
394 | + $filter_name = $this->filter_name; |
|
395 | + } |
|
396 | + if ($limit) { |
|
397 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
398 | + } else { |
|
399 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
400 | + } |
|
333 | 401 | try { |
334 | 402 | $sth = $this->db->prepare($query); |
335 | 403 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -355,7 +423,9 @@ discard block |
||
355 | 423 | $icao = $value['airport_departure_icao']; |
356 | 424 | if (isset($all[$icao])) { |
357 | 425 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
358 | - } else $all[$icao] = $value; |
|
426 | + } else { |
|
427 | + $all[$icao] = $value; |
|
428 | + } |
|
359 | 429 | } |
360 | 430 | $count = array(); |
361 | 431 | foreach ($all as $key => $row) { |
@@ -367,9 +437,14 @@ discard block |
||
367 | 437 | } |
368 | 438 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
369 | 439 | global $globalStatsFilters; |
370 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
371 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
372 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
440 | + if ($filter_name == '') { |
|
441 | + $filter_name = $this->filter_name; |
|
442 | + } |
|
443 | + if ($limit) { |
|
444 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
445 | + } else { |
|
446 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
447 | + } |
|
373 | 448 | try { |
374 | 449 | $sth = $this->db->prepare($query); |
375 | 450 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -395,7 +470,9 @@ discard block |
||
395 | 470 | $icao = $value['airport_arrival_icao']; |
396 | 471 | if (isset($all[$icao])) { |
397 | 472 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
398 | - } else $all[$icao] = $value; |
|
473 | + } else { |
|
474 | + $all[$icao] = $value; |
|
475 | + } |
|
399 | 476 | } |
400 | 477 | $count = array(); |
401 | 478 | foreach ($all as $key => $row) { |
@@ -408,13 +485,21 @@ discard block |
||
408 | 485 | } |
409 | 486 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
410 | 487 | global $globalDBdriver, $globalStatsFilters; |
411 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
488 | + if ($filter_name == '') { |
|
489 | + $filter_name = $this->filter_name; |
|
490 | + } |
|
412 | 491 | if ($globalDBdriver == 'mysql') { |
413 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
414 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
492 | + if ($limit) { |
|
493 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
494 | + } else { |
|
495 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
496 | + } |
|
415 | 497 | } else { |
416 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
417 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
498 | + if ($limit) { |
|
499 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
500 | + } else { |
|
501 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
502 | + } |
|
418 | 503 | } |
419 | 504 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
420 | 505 | try { |
@@ -438,7 +523,9 @@ discard block |
||
438 | 523 | |
439 | 524 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
440 | 525 | global $globalStatsFilters; |
441 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
526 | + if ($filter_name == '') { |
|
527 | + $filter_name = $this->filter_name; |
|
528 | + } |
|
442 | 529 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
443 | 530 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
444 | 531 | try { |
@@ -460,7 +547,9 @@ discard block |
||
460 | 547 | } |
461 | 548 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
462 | 549 | global $globalDBdriver, $globalStatsFilters; |
463 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
550 | + if ($filter_name == '') { |
|
551 | + $filter_name = $this->filter_name; |
|
552 | + } |
|
464 | 553 | if ($globalDBdriver == 'mysql') { |
465 | 554 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
466 | 555 | } else { |
@@ -486,7 +575,9 @@ discard block |
||
486 | 575 | } |
487 | 576 | public function countAllDates($stats_airline = '',$filter_name = '') { |
488 | 577 | global $globalStatsFilters; |
489 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
578 | + if ($filter_name == '') { |
|
579 | + $filter_name = $this->filter_name; |
|
580 | + } |
|
490 | 581 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
491 | 582 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
492 | 583 | try { |
@@ -508,7 +599,9 @@ discard block |
||
508 | 599 | } |
509 | 600 | public function countAllDatesByAirlines($filter_name = '') { |
510 | 601 | global $globalStatsFilters; |
511 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
602 | + if ($filter_name == '') { |
|
603 | + $filter_name = $this->filter_name; |
|
604 | + } |
|
512 | 605 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
513 | 606 | $query_data = array('filter_name' => $filter_name); |
514 | 607 | try { |
@@ -530,7 +623,9 @@ discard block |
||
530 | 623 | } |
531 | 624 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
532 | 625 | global $globalStatsFilters; |
533 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
626 | + if ($filter_name == '') { |
|
627 | + $filter_name = $this->filter_name; |
|
628 | + } |
|
534 | 629 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
535 | 630 | try { |
536 | 631 | $sth = $this->db->prepare($query); |
@@ -551,7 +646,9 @@ discard block |
||
551 | 646 | } |
552 | 647 | public function countAllMilitaryMonths($filter_name = '') { |
553 | 648 | global $globalStatsFilters; |
554 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
649 | + if ($filter_name == '') { |
|
650 | + $filter_name = $this->filter_name; |
|
651 | + } |
|
555 | 652 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
556 | 653 | try { |
557 | 654 | $sth = $this->db->prepare($query); |
@@ -572,9 +669,14 @@ discard block |
||
572 | 669 | } |
573 | 670 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
574 | 671 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
575 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
576 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
577 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
672 | + if ($filter_name == '') { |
|
673 | + $filter_name = $this->filter_name; |
|
674 | + } |
|
675 | + if ($limit) { |
|
676 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
677 | + } else { |
|
678 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
679 | + } |
|
578 | 680 | if ($orderby == 'hour') { |
579 | 681 | /* |
580 | 682 | if ($globalDBdriver == 'mysql') { |
@@ -583,7 +685,9 @@ discard block |
||
583 | 685 | */ |
584 | 686 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
585 | 687 | } |
586 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
688 | + if ($orderby == 'count') { |
|
689 | + $query .= " ORDER BY hour_count DESC"; |
|
690 | + } |
|
587 | 691 | try { |
588 | 692 | $sth = $this->db->prepare($query); |
589 | 693 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -604,7 +708,9 @@ discard block |
||
604 | 708 | |
605 | 709 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
606 | 710 | global $globalStatsFilters; |
607 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
711 | + if ($filter_name == '') { |
|
712 | + $filter_name = $this->filter_name; |
|
713 | + } |
|
608 | 714 | $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
609 | 715 | if (empty($all)) { |
610 | 716 | $filters = array('airlines' => array($stats_airline)); |
@@ -618,7 +724,9 @@ discard block |
||
618 | 724 | } |
619 | 725 | public function countOverallMilitaryFlights($filter_name = '') { |
620 | 726 | global $globalStatsFilters; |
621 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
727 | + if ($filter_name == '') { |
|
728 | + $filter_name = $this->filter_name; |
|
729 | + } |
|
622 | 730 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
623 | 731 | if (empty($all)) { |
624 | 732 | $filters = array(); |
@@ -632,7 +740,9 @@ discard block |
||
632 | 740 | } |
633 | 741 | public function countOverallArrival($stats_airline = '',$filter_name = '') { |
634 | 742 | global $globalStatsFilters; |
635 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
743 | + if ($filter_name == '') { |
|
744 | + $filter_name = $this->filter_name; |
|
745 | + } |
|
636 | 746 | $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
637 | 747 | if (empty($all)) { |
638 | 748 | $filters = array('airlines' => array($stats_airline)); |
@@ -646,7 +756,9 @@ discard block |
||
646 | 756 | } |
647 | 757 | public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
648 | 758 | global $globalStatsFilters; |
649 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
759 | + if ($filter_name == '') { |
|
760 | + $filter_name = $this->filter_name; |
|
761 | + } |
|
650 | 762 | $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
651 | 763 | if (empty($all)) { |
652 | 764 | $filters = array('airlines' => array($stats_airline)); |
@@ -660,7 +772,9 @@ discard block |
||
660 | 772 | } |
661 | 773 | public function countOverallAirlines($filter_name = '') { |
662 | 774 | global $globalStatsFilters; |
663 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
775 | + if ($filter_name == '') { |
|
776 | + $filter_name = $this->filter_name; |
|
777 | + } |
|
664 | 778 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
665 | 779 | try { |
666 | 780 | $sth = $this->db->prepare($query); |
@@ -683,7 +797,9 @@ discard block |
||
683 | 797 | } |
684 | 798 | public function countOverallOwners($stats_airline = '',$filter_name = '') { |
685 | 799 | global $globalStatsFilters; |
686 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
800 | + if ($filter_name == '') { |
|
801 | + $filter_name = $this->filter_name; |
|
802 | + } |
|
687 | 803 | /* |
688 | 804 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner"; |
689 | 805 | try { |
@@ -708,7 +824,9 @@ discard block |
||
708 | 824 | } |
709 | 825 | public function countOverallPilots($stats_airline = '',$filter_name = '') { |
710 | 826 | global $globalStatsFilters; |
711 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
827 | + if ($filter_name == '') { |
|
828 | + $filter_name = $this->filter_name; |
|
829 | + } |
|
712 | 830 | $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
713 | 831 | if (empty($all)) { |
714 | 832 | $filters = array('airlines' => array($stats_airline)); |
@@ -722,7 +840,9 @@ discard block |
||
722 | 840 | } |
723 | 841 | |
724 | 842 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
725 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
843 | + if ($filter_name == '') { |
|
844 | + $filter_name = $this->filter_name; |
|
845 | + } |
|
726 | 846 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
727 | 847 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
728 | 848 | try { |
@@ -735,7 +855,9 @@ discard block |
||
735 | 855 | return $all; |
736 | 856 | } |
737 | 857 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
738 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
858 | + if ($filter_name == '') { |
|
859 | + $filter_name = $this->filter_name; |
|
860 | + } |
|
739 | 861 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
740 | 862 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
741 | 863 | try { |
@@ -748,7 +870,9 @@ discard block |
||
748 | 870 | return $all; |
749 | 871 | } |
750 | 872 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
751 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
873 | + if ($filter_name == '') { |
|
874 | + $filter_name = $this->filter_name; |
|
875 | + } |
|
752 | 876 | global $globalArchiveMonths, $globalDBdriver; |
753 | 877 | if ($globalDBdriver == 'mysql') { |
754 | 878 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -767,7 +891,9 @@ discard block |
||
767 | 891 | } |
768 | 892 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
769 | 893 | global $globalArchiveMonths, $globalDBdriver; |
770 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
894 | + if ($filter_name == '') { |
|
895 | + $filter_name = $this->filter_name; |
|
896 | + } |
|
771 | 897 | if ($globalDBdriver == 'mysql') { |
772 | 898 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
773 | 899 | } else { |
@@ -785,7 +911,9 @@ discard block |
||
785 | 911 | } |
786 | 912 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
787 | 913 | global $globalArchiveMonths, $globalDBdriver; |
788 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
914 | + if ($filter_name == '') { |
|
915 | + $filter_name = $this->filter_name; |
|
916 | + } |
|
789 | 917 | if ($globalDBdriver == 'mysql') { |
790 | 918 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
791 | 919 | } else { |
@@ -802,7 +930,9 @@ discard block |
||
802 | 930 | } |
803 | 931 | public function getStatsAirlineTotal($filter_name = '') { |
804 | 932 | global $globalArchiveMonths, $globalDBdriver; |
805 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
933 | + if ($filter_name == '') { |
|
934 | + $filter_name = $this->filter_name; |
|
935 | + } |
|
806 | 936 | if ($globalDBdriver == 'mysql') { |
807 | 937 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
808 | 938 | } else { |
@@ -819,7 +949,9 @@ discard block |
||
819 | 949 | } |
820 | 950 | public function getStatsOwnerTotal($filter_name = '') { |
821 | 951 | global $globalArchiveMonths, $globalDBdriver; |
822 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
952 | + if ($filter_name == '') { |
|
953 | + $filter_name = $this->filter_name; |
|
954 | + } |
|
823 | 955 | if ($globalDBdriver == 'mysql') { |
824 | 956 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
825 | 957 | } else { |
@@ -836,7 +968,9 @@ discard block |
||
836 | 968 | } |
837 | 969 | public function getStatsPilotTotal($filter_name = '') { |
838 | 970 | global $globalArchiveMonths, $globalDBdriver; |
839 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
971 | + if ($filter_name == '') { |
|
972 | + $filter_name = $this->filter_name; |
|
973 | + } |
|
840 | 974 | if ($globalDBdriver == 'mysql') { |
841 | 975 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
842 | 976 | } else { |
@@ -854,7 +988,9 @@ discard block |
||
854 | 988 | |
855 | 989 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
856 | 990 | global $globalDBdriver; |
857 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
991 | + if ($filter_name == '') { |
|
992 | + $filter_name = $this->filter_name; |
|
993 | + } |
|
858 | 994 | if ($globalDBdriver == 'mysql') { |
859 | 995 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
860 | 996 | } else { |
@@ -870,7 +1006,9 @@ discard block |
||
870 | 1006 | } |
871 | 1007 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
872 | 1008 | global $globalDBdriver; |
873 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1009 | + if ($filter_name == '') { |
|
1010 | + $filter_name = $this->filter_name; |
|
1011 | + } |
|
874 | 1012 | if ($globalDBdriver == 'mysql') { |
875 | 1013 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
876 | 1014 | } else { |
@@ -1353,47 +1491,69 @@ discard block |
||
1353 | 1491 | $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
1354 | 1492 | } else { |
1355 | 1493 | */ |
1356 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1357 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1494 | + if ($globalDebug) { |
|
1495 | + echo 'Update stats !'."\n"; |
|
1496 | + } |
|
1497 | + if ($globalDebug) { |
|
1498 | + echo 'Count all aircraft types...'."\n"; |
|
1499 | + } |
|
1358 | 1500 | if (isset($last_update[0]['value'])) { |
1359 | 1501 | $last_update_day = $last_update[0]['value']; |
1360 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1502 | + } else { |
|
1503 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1504 | + } |
|
1361 | 1505 | $Spotter = new Spotter($this->db); |
1362 | 1506 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1363 | 1507 | foreach ($alldata as $number) { |
1364 | 1508 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
1365 | 1509 | } |
1366 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1510 | + if ($globalDebug) { |
|
1511 | + echo 'Count all airlines...'."\n"; |
|
1512 | + } |
|
1367 | 1513 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1368 | 1514 | foreach ($alldata as $number) { |
1369 | 1515 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
1370 | 1516 | } |
1371 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1517 | + if ($globalDebug) { |
|
1518 | + echo 'Count all registrations...'."\n"; |
|
1519 | + } |
|
1372 | 1520 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1373 | 1521 | foreach ($alldata as $number) { |
1374 | 1522 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
1375 | 1523 | } |
1376 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1524 | + if ($globalDebug) { |
|
1525 | + echo 'Count all callsigns...'."\n"; |
|
1526 | + } |
|
1377 | 1527 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1378 | 1528 | foreach ($alldata as $number) { |
1379 | 1529 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1380 | 1530 | } |
1381 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1531 | + if ($globalDebug) { |
|
1532 | + echo 'Count all owners...'."\n"; |
|
1533 | + } |
|
1382 | 1534 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1383 | 1535 | foreach ($alldata as $number) { |
1384 | 1536 | $this->addStatOwner($number['owner_name'],$number['owner_count']); |
1385 | 1537 | } |
1386 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1538 | + if ($globalDebug) { |
|
1539 | + echo 'Count all pilots...'."\n"; |
|
1540 | + } |
|
1387 | 1541 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1388 | 1542 | foreach ($alldata as $number) { |
1389 | 1543 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']); |
1390 | 1544 | } |
1391 | 1545 | |
1392 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1546 | + if ($globalDebug) { |
|
1547 | + echo 'Count all departure airports...'."\n"; |
|
1548 | + } |
|
1393 | 1549 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1394 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1550 | + if ($globalDebug) { |
|
1551 | + echo 'Count all detected departure airports...'."\n"; |
|
1552 | + } |
|
1395 | 1553 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1396 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1554 | + if ($globalDebug) { |
|
1555 | + echo 'Order departure airports...'."\n"; |
|
1556 | + } |
|
1397 | 1557 | $alldata = array(); |
1398 | 1558 | |
1399 | 1559 | foreach ($pall as $value) { |
@@ -1404,7 +1564,9 @@ discard block |
||
1404 | 1564 | $icao = $value['airport_departure_icao']; |
1405 | 1565 | if (isset($alldata[$icao])) { |
1406 | 1566 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1407 | - } else $alldata[$icao] = $value; |
|
1567 | + } else { |
|
1568 | + $alldata[$icao] = $value; |
|
1569 | + } |
|
1408 | 1570 | } |
1409 | 1571 | $count = array(); |
1410 | 1572 | foreach ($alldata as $key => $row) { |
@@ -1414,11 +1576,17 @@ discard block |
||
1414 | 1576 | foreach ($alldata as $number) { |
1415 | 1577 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
1416 | 1578 | } |
1417 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1579 | + if ($globalDebug) { |
|
1580 | + echo 'Count all arrival airports...'."\n"; |
|
1581 | + } |
|
1418 | 1582 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1419 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1583 | + if ($globalDebug) { |
|
1584 | + echo 'Count all detected arrival airports...'."\n"; |
|
1585 | + } |
|
1420 | 1586 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1421 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1587 | + if ($globalDebug) { |
|
1588 | + echo 'Order arrival airports...'."\n"; |
|
1589 | + } |
|
1422 | 1590 | $alldata = array(); |
1423 | 1591 | foreach ($pall as $value) { |
1424 | 1592 | $icao = $value['airport_arrival_icao']; |
@@ -1428,7 +1596,9 @@ discard block |
||
1428 | 1596 | $icao = $value['airport_arrival_icao']; |
1429 | 1597 | if (isset($alldata[$icao])) { |
1430 | 1598 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1431 | - } else $alldata[$icao] = $value; |
|
1599 | + } else { |
|
1600 | + $alldata[$icao] = $value; |
|
1601 | + } |
|
1432 | 1602 | } |
1433 | 1603 | $count = array(); |
1434 | 1604 | foreach ($alldata as $key => $row) { |
@@ -1439,7 +1609,9 @@ discard block |
||
1439 | 1609 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1440 | 1610 | } |
1441 | 1611 | if ($Connection->tableExists('countries')) { |
1442 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1612 | + if ($globalDebug) { |
|
1613 | + echo 'Count all flights by countries...'."\n"; |
|
1614 | + } |
|
1443 | 1615 | $SpotterArchive = new SpotterArchive(); |
1444 | 1616 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1445 | 1617 | foreach ($alldata as $number) { |
@@ -1451,46 +1623,66 @@ discard block |
||
1451 | 1623 | // Add by month using getstat if month finish... |
1452 | 1624 | |
1453 | 1625 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1454 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1626 | + if ($globalDebug) { |
|
1627 | + echo 'Count all flights by months...'."\n"; |
|
1628 | + } |
|
1455 | 1629 | $Spotter = new Spotter($this->db); |
1456 | 1630 | $alldata = $Spotter->countAllMonths(); |
1457 | 1631 | $lastyear = false; |
1458 | 1632 | foreach ($alldata as $number) { |
1459 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1633 | + if ($number['year_name'] != date('Y')) { |
|
1634 | + $lastyear = true; |
|
1635 | + } |
|
1460 | 1636 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1461 | 1637 | } |
1462 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1638 | + if ($globalDebug) { |
|
1639 | + echo 'Count all military flights by months...'."\n"; |
|
1640 | + } |
|
1463 | 1641 | $alldata = $Spotter->countAllMilitaryMonths(); |
1464 | 1642 | foreach ($alldata as $number) { |
1465 | 1643 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1466 | 1644 | } |
1467 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1645 | + if ($globalDebug) { |
|
1646 | + echo 'Count all owners by months...'."\n"; |
|
1647 | + } |
|
1468 | 1648 | $alldata = $Spotter->countAllMonthsOwners(); |
1469 | 1649 | foreach ($alldata as $number) { |
1470 | 1650 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1471 | 1651 | } |
1472 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1652 | + if ($globalDebug) { |
|
1653 | + echo 'Count all pilots by months...'."\n"; |
|
1654 | + } |
|
1473 | 1655 | $alldata = $Spotter->countAllMonthsPilots(); |
1474 | 1656 | foreach ($alldata as $number) { |
1475 | 1657 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1476 | 1658 | } |
1477 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1659 | + if ($globalDebug) { |
|
1660 | + echo 'Count all airlines by months...'."\n"; |
|
1661 | + } |
|
1478 | 1662 | $alldata = $Spotter->countAllMonthsAirlines(); |
1479 | 1663 | foreach ($alldata as $number) { |
1480 | 1664 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1481 | 1665 | } |
1482 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1666 | + if ($globalDebug) { |
|
1667 | + echo 'Count all aircrafts by months...'."\n"; |
|
1668 | + } |
|
1483 | 1669 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1484 | 1670 | foreach ($alldata as $number) { |
1485 | 1671 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1486 | 1672 | } |
1487 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1673 | + if ($globalDebug) { |
|
1674 | + echo 'Count all real arrivals by months...'."\n"; |
|
1675 | + } |
|
1488 | 1676 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1489 | 1677 | foreach ($alldata as $number) { |
1490 | 1678 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1491 | 1679 | } |
1492 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1493 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1680 | + if ($globalDebug) { |
|
1681 | + echo 'Airports data...'."\n"; |
|
1682 | + } |
|
1683 | + if ($globalDebug) { |
|
1684 | + echo '...Departure'."\n"; |
|
1685 | + } |
|
1494 | 1686 | $this->deleteStatAirport('daily'); |
1495 | 1687 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1496 | 1688 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1610,37 +1802,53 @@ discard block |
||
1610 | 1802 | |
1611 | 1803 | // Count by airlines |
1612 | 1804 | echo '--- Stats by airlines ---'."\n"; |
1613 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
1805 | + if ($globalDebug) { |
|
1806 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
1807 | + } |
|
1614 | 1808 | $Spotter = new Spotter($this->db); |
1615 | 1809 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1616 | 1810 | foreach ($alldata as $number) { |
1617 | 1811 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
1618 | 1812 | } |
1619 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1813 | + if ($globalDebug) { |
|
1814 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1815 | + } |
|
1620 | 1816 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1621 | 1817 | foreach ($alldata as $number) { |
1622 | 1818 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
1623 | 1819 | } |
1624 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
1820 | + if ($globalDebug) { |
|
1821 | + echo 'Count all callsigns by airlines...'."\n"; |
|
1822 | + } |
|
1625 | 1823 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1626 | 1824 | foreach ($alldata as $number) { |
1627 | 1825 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1628 | 1826 | } |
1629 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
1827 | + if ($globalDebug) { |
|
1828 | + echo 'Count all owners by airlines...'."\n"; |
|
1829 | + } |
|
1630 | 1830 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1631 | 1831 | foreach ($alldata as $number) { |
1632 | 1832 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
1633 | 1833 | } |
1634 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
1834 | + if ($globalDebug) { |
|
1835 | + echo 'Count all pilots by airlines...'."\n"; |
|
1836 | + } |
|
1635 | 1837 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1636 | 1838 | foreach ($alldata as $number) { |
1637 | 1839 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']); |
1638 | 1840 | } |
1639 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
1841 | + if ($globalDebug) { |
|
1842 | + echo 'Count all departure airports by airlines...'."\n"; |
|
1843 | + } |
|
1640 | 1844 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1641 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
1845 | + if ($globalDebug) { |
|
1846 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
1847 | + } |
|
1642 | 1848 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1643 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
1849 | + if ($globalDebug) { |
|
1850 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
1851 | + } |
|
1644 | 1852 | //$alldata = array(); |
1645 | 1853 | foreach ($dall as $value) { |
1646 | 1854 | $icao = $value['airport_departure_icao']; |
@@ -1661,11 +1869,17 @@ discard block |
||
1661 | 1869 | foreach ($alldata as $number) { |
1662 | 1870 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao']); |
1663 | 1871 | } |
1664 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
1872 | + if ($globalDebug) { |
|
1873 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
1874 | + } |
|
1665 | 1875 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1666 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1876 | + if ($globalDebug) { |
|
1877 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1878 | + } |
|
1667 | 1879 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1668 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
1880 | + if ($globalDebug) { |
|
1881 | + echo 'Order arrival airports by airlines...'."\n"; |
|
1882 | + } |
|
1669 | 1883 | //$alldata = array(); |
1670 | 1884 | foreach ($dall as $value) { |
1671 | 1885 | $icao = $value['airport_arrival_icao']; |
@@ -1686,35 +1900,49 @@ discard block |
||
1686 | 1900 | foreach ($alldata as $number) { |
1687 | 1901 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']); |
1688 | 1902 | } |
1689 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1903 | + if ($globalDebug) { |
|
1904 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1905 | + } |
|
1690 | 1906 | $Spotter = new Spotter($this->db); |
1691 | 1907 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1692 | 1908 | $lastyear = false; |
1693 | 1909 | foreach ($alldata as $number) { |
1694 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1910 | + if ($number['year_name'] != date('Y')) { |
|
1911 | + $lastyear = true; |
|
1912 | + } |
|
1695 | 1913 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1696 | 1914 | } |
1697 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
1915 | + if ($globalDebug) { |
|
1916 | + echo 'Count all owners by months by airlines...'."\n"; |
|
1917 | + } |
|
1698 | 1918 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1699 | 1919 | foreach ($alldata as $number) { |
1700 | 1920 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1701 | 1921 | } |
1702 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
1922 | + if ($globalDebug) { |
|
1923 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
1924 | + } |
|
1703 | 1925 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1704 | 1926 | foreach ($alldata as $number) { |
1705 | 1927 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1706 | 1928 | } |
1707 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1929 | + if ($globalDebug) { |
|
1930 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1931 | + } |
|
1708 | 1932 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1709 | 1933 | foreach ($alldata as $number) { |
1710 | 1934 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1711 | 1935 | } |
1712 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1936 | + if ($globalDebug) { |
|
1937 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1938 | + } |
|
1713 | 1939 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1714 | 1940 | foreach ($alldata as $number) { |
1715 | 1941 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1716 | 1942 | } |
1717 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1943 | + if ($globalDebug) { |
|
1944 | + echo '...Departure'."\n"; |
|
1945 | + } |
|
1718 | 1946 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1719 | 1947 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1720 | 1948 | foreach ($dall as $value) { |
@@ -1737,7 +1965,9 @@ discard block |
||
1737 | 1965 | foreach ($alldata as $number) { |
1738 | 1966 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
1739 | 1967 | } |
1740 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
1968 | + if ($globalDebug) { |
|
1969 | + echo '...Arrival'."\n"; |
|
1970 | + } |
|
1741 | 1971 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1742 | 1972 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1743 | 1973 | foreach ($dall as $value) { |
@@ -1761,13 +1991,19 @@ discard block |
||
1761 | 1991 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
1762 | 1992 | } |
1763 | 1993 | |
1764 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1765 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
1994 | + if ($globalDebug) { |
|
1995 | + echo 'Flights data...'."\n"; |
|
1996 | + } |
|
1997 | + if ($globalDebug) { |
|
1998 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
1999 | + } |
|
1766 | 2000 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1767 | 2001 | foreach ($alldata as $number) { |
1768 | 2002 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1769 | 2003 | } |
1770 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2004 | + if ($globalDebug) { |
|
2005 | + echo '-> countAllDates...'."\n"; |
|
2006 | + } |
|
1771 | 2007 | //$previousdata = $this->countAllDatesByAirlines(); |
1772 | 2008 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1773 | 2009 | $values = array(); |
@@ -1780,19 +2016,25 @@ discard block |
||
1780 | 2016 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1781 | 2017 | } |
1782 | 2018 | |
1783 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2019 | + if ($globalDebug) { |
|
2020 | + echo '-> countAllHours...'."\n"; |
|
2021 | + } |
|
1784 | 2022 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1785 | 2023 | foreach ($alldata as $number) { |
1786 | 2024 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
1787 | 2025 | } |
1788 | 2026 | |
1789 | 2027 | |
1790 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2028 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2029 | + $globalStatsFilters = array(); |
|
2030 | + } |
|
1791 | 2031 | foreach ($globalStatsFilters as $name => $filter) { |
1792 | 2032 | //$filter_name = $filter['name']; |
1793 | 2033 | $filter_name = $name; |
1794 | 2034 | // Count by filter |
1795 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2035 | + if ($globalDebug) { |
|
2036 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2037 | + } |
|
1796 | 2038 | $Spotter = new Spotter($this->db); |
1797 | 2039 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
1798 | 2040 | foreach ($alldata as $number) { |
@@ -1830,7 +2072,9 @@ discard block |
||
1830 | 2072 | $icao = $value['airport_departure_icao']; |
1831 | 2073 | if (isset($alldata[$icao])) { |
1832 | 2074 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1833 | - } else $alldata[$icao] = $value; |
|
2075 | + } else { |
|
2076 | + $alldata[$icao] = $value; |
|
2077 | + } |
|
1834 | 2078 | } |
1835 | 2079 | $count = array(); |
1836 | 2080 | foreach ($alldata as $key => $row) { |
@@ -1851,7 +2095,9 @@ discard block |
||
1851 | 2095 | $icao = $value['airport_arrival_icao']; |
1852 | 2096 | if (isset($alldata[$icao])) { |
1853 | 2097 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1854 | - } else $alldata[$icao] = $value; |
|
2098 | + } else { |
|
2099 | + $alldata[$icao] = $value; |
|
2100 | + } |
|
1855 | 2101 | } |
1856 | 2102 | $count = array(); |
1857 | 2103 | foreach ($alldata as $key => $row) { |
@@ -1865,7 +2111,9 @@ discard block |
||
1865 | 2111 | $alldata = $Spotter->countAllMonths($filter); |
1866 | 2112 | $lastyear = false; |
1867 | 2113 | foreach ($alldata as $number) { |
1868 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2114 | + if ($number['year_name'] != date('Y')) { |
|
2115 | + $lastyear = true; |
|
2116 | + } |
|
1869 | 2117 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
1870 | 2118 | } |
1871 | 2119 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | $dbc = $this->db; |
54 | 54 | $this->all_flights[$id]['schedule_check'] = true; |
55 | 55 | if ($globalSchedulesFetch) { |
56 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo 'Getting schedule info...'."\n"; |
|
58 | + } |
|
57 | 59 | $Spotter = new Spotter($dbc); |
58 | 60 | $Schedule = new Schedule($dbc); |
59 | 61 | $Translation = new Translation($dbc); |
@@ -63,7 +65,9 @@ discard block |
||
63 | 65 | if ($Schedule->checkSchedule($operator) == 0) { |
64 | 66 | $schedule = $Schedule->fetchSchedule($operator); |
65 | 67 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
66 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
68 | + if ($globalDebug) { |
|
69 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
70 | + } |
|
67 | 71 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
68 | 72 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
69 | 73 | // Should also check if route schedule = route from DB |
@@ -72,7 +76,9 @@ discard block |
||
72 | 76 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
73 | 77 | if ($airport_icao != '') { |
74 | 78 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
75 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
79 | + if ($globalDebug) { |
|
80 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
81 | + } |
|
76 | 82 | } |
77 | 83 | } |
78 | 84 | } |
@@ -81,7 +87,9 @@ discard block |
||
81 | 87 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
82 | 88 | if ($airport_icao != '') { |
83 | 89 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
84 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
90 | + if ($globalDebug) { |
|
91 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
92 | + } |
|
85 | 93 | } |
86 | 94 | } |
87 | 95 | } |
@@ -109,7 +117,9 @@ discard block |
||
109 | 117 | |
110 | 118 | public function checkAll() { |
111 | 119 | global $globalDebug; |
112 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
120 | + if ($globalDebug) { |
|
121 | + echo "Update last seen flights data...\n"; |
|
122 | + } |
|
113 | 123 | foreach ($this->all_flights as $key => $flight) { |
114 | 124 | if (isset($this->all_flights[$key]['id'])) { |
115 | 125 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
@@ -122,24 +132,32 @@ discard block |
||
122 | 132 | |
123 | 133 | public function arrival($key) { |
124 | 134 | global $globalClosestMinDist, $globalDebug; |
125 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
135 | + if ($globalDebug) { |
|
136 | + echo 'Update arrival...'."\n"; |
|
137 | + } |
|
126 | 138 | $Spotter = new Spotter($this->db); |
127 | 139 | $airport_icao = ''; |
128 | 140 | $airport_time = ''; |
129 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
141 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
142 | + $globalClosestMinDist = 50; |
|
143 | + } |
|
130 | 144 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
131 | 145 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
132 | 146 | if (isset($closestAirports[0])) { |
133 | 147 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
134 | 148 | $airport_icao = $closestAirports[0]['icao']; |
135 | 149 | $airport_time = $this->all_flights[$key]['datetime']; |
136 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
150 | + if ($globalDebug) { |
|
151 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
152 | + } |
|
137 | 153 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
138 | 154 | foreach ($closestAirports as $airport) { |
139 | 155 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
140 | 156 | $airport_icao = $airport['icao']; |
141 | 157 | $airport_time = $this->all_flights[$key]['datetime']; |
142 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
158 | + if ($globalDebug) { |
|
159 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
160 | + } |
|
143 | 161 | break; |
144 | 162 | } |
145 | 163 | } |
@@ -147,14 +165,20 @@ discard block |
||
147 | 165 | $airport_icao = $closestAirports[0]['icao']; |
148 | 166 | $airport_time = $this->all_flights[$key]['datetime']; |
149 | 167 | } else { |
150 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
168 | + if ($globalDebug) { |
|
169 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
170 | + } |
|
151 | 171 | } |
152 | 172 | } else { |
153 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
173 | + if ($globalDebug) { |
|
174 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
175 | + } |
|
154 | 176 | } |
155 | 177 | |
156 | 178 | } else { |
157 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
181 | + } |
|
158 | 182 | } |
159 | 183 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
160 | 184 | } |
@@ -164,12 +188,16 @@ discard block |
||
164 | 188 | public function del() { |
165 | 189 | global $globalDebug; |
166 | 190 | // Delete old infos |
167 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
191 | + if ($globalDebug) { |
|
192 | + echo 'Delete old values and update latest data...'."\n"; |
|
193 | + } |
|
168 | 194 | foreach ($this->all_flights as $key => $flight) { |
169 | 195 | if (isset($flight['lastupdate'])) { |
170 | 196 | if ($flight['lastupdate'] < (time()-3000)) { |
171 | 197 | if (isset($this->all_flights[$key]['id'])) { |
172 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
198 | + if ($globalDebug) { |
|
199 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
200 | + } |
|
173 | 201 | /* |
174 | 202 | $SpotterLive = new SpotterLive(); |
175 | 203 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -179,7 +207,9 @@ discard block |
||
179 | 207 | $Spotter = new Spotter($this->db); |
180 | 208 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
181 | 209 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
182 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
210 | + if ($globalDebug && $result != 'success') { |
|
211 | + echo '!!! ERROR : '.$result."\n"; |
|
212 | + } |
|
183 | 213 | } |
184 | 214 | // Put in archive |
185 | 215 | // $Spotter->db = null; |
@@ -193,8 +223,10 @@ discard block |
||
193 | 223 | public function add($line) { |
194 | 224 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
195 | 225 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
196 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
197 | -/* |
|
226 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
227 | + $globalCoordMinChange = '0.02'; |
|
228 | + } |
|
229 | + /* |
|
198 | 230 | $Spotter = new Spotter(); |
199 | 231 | $dbc = $Spotter->db; |
200 | 232 | $SpotterLive = new SpotterLive($dbc); |
@@ -222,11 +254,15 @@ discard block |
||
222 | 254 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
223 | 255 | $current_date = date('Y-m-d'); |
224 | 256 | $source = $line['source_name']; |
225 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
257 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
258 | + $source = $line['format_source']; |
|
259 | + } |
|
226 | 260 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
227 | 261 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
228 | 262 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
229 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
263 | + } else { |
|
264 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
265 | + } |
|
230 | 266 | } |
231 | 267 | |
232 | 268 | /* |
@@ -242,8 +278,11 @@ discard block |
||
242 | 278 | //$this->db = $dbc; |
243 | 279 | |
244 | 280 | $hex = trim($line['hex']); |
245 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
246 | - else $id = trim($line['id']); |
|
281 | + if (!isset($line['id'])) { |
|
282 | + $id = trim($line['hex']); |
|
283 | + } else { |
|
284 | + $id = trim($line['id']); |
|
285 | + } |
|
247 | 286 | |
248 | 287 | //print_r($this->all_flights); |
249 | 288 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
@@ -258,13 +297,20 @@ discard block |
||
258 | 297 | $Spotter = new Spotter($this->db); |
259 | 298 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
260 | 299 | $Spotter->db = null; |
261 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | + if ($globalDebugTimeElapsed) { |
|
301 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
302 | + } |
|
262 | 303 | |
263 | 304 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
264 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
265 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
266 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
267 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
305 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
306 | + $aircraft_icao = 'GLID'; |
|
307 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
308 | + $aircraft_icao = 'UHEL'; |
|
309 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
310 | + $aircraft_icao = 'TOWPLANE'; |
|
311 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
312 | + $aircraft_icao = 'POWAIRC'; |
|
313 | + } |
|
268 | 314 | } |
269 | 315 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
270 | 316 | } else if (isset($line['aircraft_name'])) { |
@@ -272,29 +318,47 @@ discard block |
||
272 | 318 | $Spotter = new Spotter($this->db); |
273 | 319 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
274 | 320 | $Spotter->db = null; |
275 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
276 | - else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
277 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
321 | + if ($aircraft_icao != '') { |
|
322 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
323 | + } else { |
|
324 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
325 | + } |
|
326 | + } else { |
|
327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
328 | + } |
|
278 | 329 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
279 | 330 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
280 | 331 | if (!isset($line['id'])) { |
281 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
282 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
332 | + if (!isset($globalDaemon)) { |
|
333 | + $globalDaemon = TRUE; |
|
334 | + } |
|
335 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
283 | 336 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
284 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
337 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
339 | + } |
|
285 | 340 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
286 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
341 | + } else { |
|
342 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
343 | + } |
|
287 | 344 | |
288 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
289 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
345 | + if ($globalDebug) { |
|
346 | + echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
347 | + } |
|
348 | + if ($globalAllFlights !== FALSE) { |
|
349 | + $dataFound = true; |
|
350 | + } |
|
290 | 351 | } |
291 | 352 | |
292 | 353 | if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
293 | 354 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
294 | 355 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
295 | 356 | } else { |
296 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
297 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
357 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
358 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
359 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
360 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
361 | + } |
|
298 | 362 | /* |
299 | 363 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
300 | 364 | print_r($this->all_flights[$id]); |
@@ -302,7 +366,9 @@ discard block |
||
302 | 366 | */ |
303 | 367 | return ''; |
304 | 368 | } |
305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
369 | + } else { |
|
370 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
371 | + } |
|
306 | 372 | |
307 | 373 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
308 | 374 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
@@ -323,15 +389,25 @@ discard block |
||
323 | 389 | $timeelapsed = microtime(true); |
324 | 390 | $Spotter = new Spotter($this->db); |
325 | 391 | $fromsource = NULL; |
326 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
327 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
328 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
329 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
330 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
392 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
393 | + $fromsource = $globalAirlinesSource; |
|
394 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
395 | + $fromsource = 'vatsim'; |
|
396 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
397 | + $fromsource = 'ivao'; |
|
398 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
399 | + $fromsource = 'vatsim'; |
|
400 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
401 | + $fromsource = 'ivao'; |
|
402 | + } |
|
331 | 403 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
332 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
404 | + if ($globalDebug && $result != 'success') { |
|
405 | + echo '!!! ERROR : '.$result."\n"; |
|
406 | + } |
|
333 | 407 | $Spotter->db = null; |
334 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
408 | + if ($globalDebugTimeElapsed) { |
|
409 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
410 | + } |
|
335 | 411 | } |
336 | 412 | |
337 | 413 | /* |
@@ -342,7 +418,9 @@ discard block |
||
342 | 418 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
343 | 419 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
344 | 420 | */ |
345 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
421 | + if (!isset($this->all_flights[$id]['id'])) { |
|
422 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
423 | + } |
|
346 | 424 | |
347 | 425 | //$putinarchive = true; |
348 | 426 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -359,7 +437,9 @@ discard block |
||
359 | 437 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
360 | 438 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
361 | 439 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
362 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
440 | + if ($globalDebugTimeElapsed) { |
|
441 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
442 | + } |
|
363 | 443 | |
364 | 444 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
365 | 445 | $timeelapsed = microtime(true); |
@@ -372,7 +452,9 @@ discard block |
||
372 | 452 | $Translation->db = null; |
373 | 453 | } |
374 | 454 | $Spotter->db = null; |
375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
455 | + if ($globalDebugTimeElapsed) { |
|
456 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
457 | + } |
|
376 | 458 | |
377 | 459 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
378 | 460 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -381,9 +463,13 @@ discard block |
||
381 | 463 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
382 | 464 | } |
383 | 465 | } |
384 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
466 | + if (!isset($globalFork)) { |
|
467 | + $globalFork = TRUE; |
|
468 | + } |
|
385 | 469 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
386 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
470 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
471 | + $this->get_Schedule($id,trim($line['ident'])); |
|
472 | + } |
|
387 | 473 | } |
388 | 474 | } |
389 | 475 | } |
@@ -399,16 +485,23 @@ discard block |
||
399 | 485 | // use datetime |
400 | 486 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
401 | 487 | $speed = $speed*3.6; |
402 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
403 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
488 | + if ($speed < 1000) { |
|
489 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
490 | + } |
|
491 | + if ($globalDebug) { |
|
492 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
493 | + } |
|
404 | 494 | } |
405 | 495 | } |
406 | 496 | |
407 | 497 | |
408 | 498 | |
409 | 499 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
410 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
411 | - else unset($timediff); |
|
500 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
501 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
502 | + } else { |
|
503 | + unset($timediff); |
|
504 | + } |
|
412 | 505 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
413 | 506 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
414 | 507 | if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -416,21 +509,31 @@ discard block |
||
416 | 509 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
417 | 510 | $this->all_flights[$id]['putinarchive'] = true; |
418 | 511 | |
419 | - if ($globalDebug) echo "\n".' ------- Check Country.... '; |
|
512 | + if ($globalDebug) { |
|
513 | + echo "\n".' ------- Check Country.... '; |
|
514 | + } |
|
420 | 515 | $timeelapsed = microtime(true); |
421 | 516 | $Spotter = new Spotter($this->db); |
422 | 517 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
423 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
518 | + if (!empty($all_country)) { |
|
519 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
520 | + } |
|
424 | 521 | $Spotter->db = null; |
425 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
522 | + if ($globalDebugTimeElapsed) { |
|
523 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
524 | + } |
|
426 | 525 | $this->tmd = 0; |
427 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
526 | + if ($globalDebug) { |
|
527 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
528 | + } |
|
428 | 529 | } |
429 | 530 | } |
430 | 531 | |
431 | 532 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
432 | 533 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
433 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
534 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
535 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
536 | + } |
|
434 | 537 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
435 | 538 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
436 | 539 | $dataFound = true; |
@@ -452,9 +555,13 @@ discard block |
||
452 | 555 | */ |
453 | 556 | } |
454 | 557 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
455 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
558 | + if ($line['longitude'] > 180) { |
|
559 | + $line['longitude'] = $line['longitude'] - 360; |
|
560 | + } |
|
456 | 561 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
457 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
562 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
563 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
564 | + } |
|
458 | 565 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
459 | 566 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
460 | 567 | $dataFound = true; |
@@ -485,7 +592,9 @@ discard block |
||
485 | 592 | } |
486 | 593 | } |
487 | 594 | if (isset($line['last_update']) && $line['last_update'] != '') { |
488 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
595 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
596 | + $dataFound = true; |
|
597 | + } |
|
489 | 598 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
490 | 599 | } |
491 | 600 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -507,11 +616,17 @@ discard block |
||
507 | 616 | // Here we force archive of flight because after ground it's a new one (or should be) |
508 | 617 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
509 | 618 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
510 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
511 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
512 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
619 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
620 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
621 | + } elseif (isset($line['id'])) { |
|
622 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
623 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
624 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
625 | + } |
|
626 | + } |
|
627 | + if ($line['ground'] != 1) { |
|
628 | + $line['ground'] = 0; |
|
513 | 629 | } |
514 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
515 | 630 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
516 | 631 | //$dataFound = true; |
517 | 632 | } |
@@ -519,28 +634,40 @@ discard block |
||
519 | 634 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
520 | 635 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
521 | 636 | $highlight = ''; |
522 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
523 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
524 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
637 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
638 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
639 | + } |
|
640 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
641 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
642 | + } |
|
643 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
644 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
645 | + } |
|
525 | 646 | if ($highlight != '') { |
526 | 647 | $timeelapsed = microtime(true); |
527 | 648 | $Spotter = new Spotter($this->db); |
528 | 649 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
529 | 650 | $Spotter->db = null; |
530 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
651 | + if ($globalDebugTimeElapsed) { |
|
652 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
653 | + } |
|
531 | 654 | |
532 | 655 | $this->all_flights[$id]['putinarchive'] = true; |
533 | 656 | //$putinarchive = true; |
534 | 657 | //$highlight = ''; |
535 | 658 | } |
536 | 659 | |
537 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
660 | + } else { |
|
661 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
662 | + } |
|
538 | 663 | //$dataFound = true; |
539 | 664 | } |
540 | 665 | |
541 | 666 | if (isset($line['altitude']) && $line['altitude'] != '') { |
542 | 667 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
543 | - if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
668 | + if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) { |
|
669 | + $this->all_flights[$id]['putinarchive'] = true; |
|
670 | + } |
|
544 | 671 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
545 | 672 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
546 | 673 | //$dataFound = true; |
@@ -552,21 +679,30 @@ discard block |
||
552 | 679 | } |
553 | 680 | |
554 | 681 | if (isset($line['heading']) && $line['heading'] != '') { |
555 | - if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
682 | + if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) { |
|
683 | + $this->all_flights[$id]['putinarchive'] = true; |
|
684 | + } |
|
556 | 685 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
557 | 686 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
558 | 687 | //$dataFound = true; |
559 | 688 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
560 | 689 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
561 | 690 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
562 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
563 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
691 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) { |
|
692 | + $this->all_flights[$id]['putinarchive'] = true; |
|
693 | + } |
|
694 | + if ($globalDebug) { |
|
695 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
696 | + } |
|
564 | 697 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
565 | 698 | // If not enough messages and ACARS set heading to 0 |
566 | 699 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
567 | 700 | } |
568 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
569 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
701 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
702 | + $dataFound = false; |
|
703 | + } elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
704 | + $dataFound = false; |
|
705 | + } |
|
570 | 706 | |
571 | 707 | // print_r($this->all_flights[$id]); |
572 | 708 | //gets the callsign from the last hour |
@@ -581,23 +717,36 @@ discard block |
||
581 | 717 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
582 | 718 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
583 | 719 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
584 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
720 | + if ($globalDebug) { |
|
721 | + echo "Check if aircraft is already in DB..."; |
|
722 | + } |
|
585 | 723 | $timeelapsed = microtime(true); |
586 | 724 | $SpotterLive = new SpotterLive($this->db); |
587 | 725 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
588 | 726 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
589 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
727 | + if ($globalDebugTimeElapsed) { |
|
728 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
729 | + } |
|
590 | 730 | } elseif (isset($line['id'])) { |
591 | 731 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
592 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
732 | + if ($globalDebugTimeElapsed) { |
|
733 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
734 | + } |
|
593 | 735 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
594 | 736 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
595 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
596 | - } else $recent_ident = ''; |
|
737 | + if ($globalDebugTimeElapsed) { |
|
738 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
739 | + } |
|
740 | + } else { |
|
741 | + $recent_ident = ''; |
|
742 | + } |
|
597 | 743 | $SpotterLive->db=null; |
598 | 744 | |
599 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
600 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
745 | + if ($globalDebug && $recent_ident == '') { |
|
746 | + echo " Not in DB.\n"; |
|
747 | + } elseif ($globalDebug && $recent_ident != '') { |
|
748 | + echo " Already in DB.\n"; |
|
749 | + } |
|
601 | 750 | } else { |
602 | 751 | $recent_ident = ''; |
603 | 752 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -605,7 +754,9 @@ discard block |
||
605 | 754 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
606 | 755 | if($recent_ident == "") |
607 | 756 | { |
608 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
757 | + if ($globalDebug) { |
|
758 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
759 | + } |
|
609 | 760 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
610 | 761 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
611 | 762 | //adds the spotter data for the archive |
@@ -649,26 +800,44 @@ discard block |
||
649 | 800 | |
650 | 801 | if (!$ignoreImport) { |
651 | 802 | $highlight = ''; |
652 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
653 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
654 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
655 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
803 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
804 | + $highlight = 'Squawk 7500 : Hijack'; |
|
805 | + } |
|
806 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
807 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
808 | + } |
|
809 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
810 | + $highlight = 'Squawk 7700 : Emergency'; |
|
811 | + } |
|
812 | + if (!isset($this->all_flights[$id]['id'])) { |
|
813 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
814 | + } |
|
656 | 815 | $timeelapsed = microtime(true); |
657 | 816 | $Spotter = new Spotter($this->db); |
658 | 817 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
659 | 818 | $Spotter->db = null; |
660 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
661 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
819 | + if ($globalDebug && isset($result)) { |
|
820 | + echo $result."\n"; |
|
821 | + } |
|
822 | + if ($globalDebugTimeElapsed) { |
|
823 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
824 | + } |
|
662 | 825 | |
663 | 826 | // Add source stat in DB |
664 | 827 | $Stats = new Stats($this->db); |
665 | 828 | if (!empty($this->stats)) { |
666 | - if ($globalDebug) echo 'Add source stats : '; |
|
829 | + if ($globalDebug) { |
|
830 | + echo 'Add source stats : '; |
|
831 | + } |
|
667 | 832 | foreach($this->stats as $date => $data) { |
668 | 833 | foreach($data as $source => $sourced) { |
669 | 834 | //print_r($sourced); |
670 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
671 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
835 | + if (isset($sourced['polar'])) { |
|
836 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
837 | + } |
|
838 | + if (isset($sourced['hist'])) { |
|
839 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
840 | + } |
|
672 | 841 | if (isset($sourced['msg'])) { |
673 | 842 | if (time() - $sourced['msg']['date'] > 10) { |
674 | 843 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -681,13 +850,17 @@ discard block |
||
681 | 850 | unset($this->stats[$date]); |
682 | 851 | } |
683 | 852 | } |
684 | - if ($globalDebug) echo 'Done'."\n"; |
|
853 | + if ($globalDebug) { |
|
854 | + echo 'Done'."\n"; |
|
855 | + } |
|
685 | 856 | |
686 | 857 | } |
687 | 858 | $Stats->db = null; |
688 | 859 | |
689 | 860 | $this->del(); |
690 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
861 | + } elseif ($globalDebug) { |
|
862 | + echo 'Ignore data'."\n"; |
|
863 | + } |
|
691 | 864 | //$ignoreImport = false; |
692 | 865 | $this->all_flights[$id]['addedSpotter'] = 1; |
693 | 866 | //print_r($this->all_flights[$id]); |
@@ -704,12 +877,16 @@ discard block |
||
704 | 877 | */ |
705 | 878 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
706 | 879 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
707 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
880 | + if ($globalDebug) { |
|
881 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
882 | + } |
|
708 | 883 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
709 | 884 | $SpotterLive = new SpotterLive($this->db); |
710 | 885 | $SpotterLive->deleteLiveSpotterData(); |
711 | 886 | $SpotterLive->db=null; |
712 | - if ($globalDebug) echo " Done\n"; |
|
887 | + if ($globalDebug) { |
|
888 | + echo " Done\n"; |
|
889 | + } |
|
713 | 890 | $this->last_delete = time(); |
714 | 891 | } |
715 | 892 | } else { |
@@ -732,11 +909,17 @@ discard block |
||
732 | 909 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
733 | 910 | if ($globalDebug) { |
734 | 911 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
735 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
736 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
912 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
913 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
914 | + } else { |
|
915 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
916 | + } |
|
737 | 917 | } else { |
738 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
739 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
918 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
919 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
920 | + } else { |
|
921 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
922 | + } |
|
740 | 923 | } |
741 | 924 | } |
742 | 925 | $ignoreImport = false; |
@@ -782,19 +965,25 @@ discard block |
||
782 | 965 | |
783 | 966 | if (!$ignoreImport) { |
784 | 967 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
785 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
968 | + if ($globalDebug) { |
|
969 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
970 | + } |
|
786 | 971 | $timeelapsed = microtime(true); |
787 | 972 | $SpotterLive = new SpotterLive($this->db); |
788 | 973 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
789 | 974 | $SpotterLive->db = null; |
790 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
975 | + if ($globalDebugTimeElapsed) { |
|
976 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
977 | + } |
|
791 | 978 | |
792 | 979 | // Put statistics in $this->stats variable |
793 | 980 | //if ($line['format_source'] != 'aprs') { |
794 | 981 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
795 | 982 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
796 | 983 | $source = $this->all_flights[$id]['source_name']; |
797 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
984 | + if ($source == '') { |
|
985 | + $source = $this->all_flights[$id]['format_source']; |
|
986 | + } |
|
798 | 987 | if (!isset($this->source_location[$source])) { |
799 | 988 | $Location = new Source(); |
800 | 989 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -815,7 +1004,9 @@ discard block |
||
815 | 1004 | $stats_heading = round($stats_heading/22.5); |
816 | 1005 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
817 | 1006 | $current_date = date('Y-m-d'); |
818 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1007 | + if ($stats_heading == 16) { |
|
1008 | + $stats_heading = 0; |
|
1009 | + } |
|
819 | 1010 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
820 | 1011 | for ($i=0;$i<=15;$i++) { |
821 | 1012 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -833,7 +1024,9 @@ discard block |
||
833 | 1024 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
834 | 1025 | end($this->stats[$current_date][$source]['hist']); |
835 | 1026 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
836 | - } else $mini = 0; |
|
1027 | + } else { |
|
1028 | + $mini = 0; |
|
1029 | + } |
|
837 | 1030 | for ($i=$mini;$i<=$distance;$i+=10) { |
838 | 1031 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
839 | 1032 | } |
@@ -844,20 +1037,30 @@ discard block |
||
844 | 1037 | } |
845 | 1038 | |
846 | 1039 | $this->all_flights[$id]['lastupdate'] = time(); |
847 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1040 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1041 | + $send = true; |
|
1042 | + } |
|
848 | 1043 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
849 | - if ($globalDebug) echo $result."\n"; |
|
850 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1044 | + if ($globalDebug) { |
|
1045 | + echo $result."\n"; |
|
1046 | + } |
|
1047 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1048 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1049 | + } |
|
851 | 1050 | //$this->del(); |
852 | 1051 | |
853 | 1052 | |
854 | 1053 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
855 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1054 | + if ($globalDebug) { |
|
1055 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1056 | + } |
|
856 | 1057 | $SpotterLive = new SpotterLive($this->db); |
857 | 1058 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
858 | 1059 | $SpotterLive->db = null; |
859 | 1060 | //SpotterLive->deleteLiveSpotterData(); |
860 | - if ($globalDebug) echo " Done\n"; |
|
1061 | + if ($globalDebug) { |
|
1062 | + echo " Done\n"; |
|
1063 | + } |
|
861 | 1064 | $this->last_delete_hourly = time(); |
862 | 1065 | } |
863 | 1066 | |
@@ -865,7 +1068,9 @@ discard block |
||
865 | 1068 | //$ignoreImport = false; |
866 | 1069 | } |
867 | 1070 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
868 | - if ($send) return $this->all_flights[$id]; |
|
1071 | + if ($send) { |
|
1072 | + return $this->all_flights[$id]; |
|
1073 | + } |
|
869 | 1074 | } |
870 | 1075 | } |
871 | 1076 | } |
@@ -18,8 +18,12 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
21 | - if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
|
22 | - if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
|
21 | + if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
|
22 | + $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
|
23 | + } |
|
24 | + if (is_array($globalFilter)) { |
|
25 | + $filter = array_merge($globalFilter,$filter); |
|
26 | + } |
|
23 | 27 | $filter_query_join = ''; |
24 | 28 | $filter_query_where = ''; |
25 | 29 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
@@ -47,8 +51,11 @@ discard block |
||
47 | 51 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
48 | 52 | } |
49 | 53 | } |
50 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
51 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
54 | + if ($filter_query_where == '' && $where) { |
|
55 | + $filter_query_where = ' WHERE'; |
|
56 | + } elseif ($filter_query_where != '' && $and) { |
|
57 | + $filter_query_where .= ' AND'; |
|
58 | + } |
|
52 | 59 | $filter_query = $filter_query_join.$filter_query_where; |
53 | 60 | return $filter_query; |
54 | 61 | } |
@@ -84,7 +91,9 @@ discard block |
||
84 | 91 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
85 | 92 | } |
86 | 93 | |
87 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
94 | + if (!isset($globalLiveInterval)) { |
|
95 | + $globalLiveInterval = '200'; |
|
96 | + } |
|
88 | 97 | if ($globalDBdriver == 'mysql') { |
89 | 98 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
90 | 99 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -109,7 +118,9 @@ discard block |
||
109 | 118 | |
110 | 119 | $filter_query = $this->getFilter($filter,true,true); |
111 | 120 | |
112 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
121 | + if (!isset($globalLiveInterval)) { |
|
122 | + $globalLiveInterval = '200'; |
|
123 | + } |
|
113 | 124 | if ($globalDBdriver == 'mysql') { |
114 | 125 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
115 | 126 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -156,7 +167,9 @@ discard block |
||
156 | 167 | |
157 | 168 | $filter_query = $this->getFilter($filter,true,true); |
158 | 169 | |
159 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
170 | + if (!isset($globalLiveInterval)) { |
|
171 | + $globalLiveInterval = '200'; |
|
172 | + } |
|
160 | 173 | if ($globalDBdriver == 'mysql') { |
161 | 174 | |
162 | 175 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -196,7 +209,9 @@ discard block |
||
196 | 209 | global $globalDBdriver, $globalLiveInterval; |
197 | 210 | $filter_query = $this->getFilter($filter,true,true); |
198 | 211 | |
199 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
212 | + if (!isset($globalLiveInterval)) { |
|
213 | + $globalLiveInterval = '200'; |
|
214 | + } |
|
200 | 215 | if ($globalDBdriver == 'mysql') { |
201 | 216 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
202 | 217 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -226,7 +241,9 @@ discard block |
||
226 | 241 | { |
227 | 242 | global $globalDBdriver, $globalLiveInterval; |
228 | 243 | $Spotter = new Spotter($this->db); |
229 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
244 | + if (!isset($globalLiveInterval)) { |
|
245 | + $globalLiveInterval = '200'; |
|
246 | + } |
|
230 | 247 | $filter_query = $this->getFilter($filter); |
231 | 248 | |
232 | 249 | if (is_array($coord)) { |
@@ -234,7 +251,9 @@ discard block |
||
234 | 251 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
235 | 252 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
236 | 253 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
237 | - } else return array(); |
|
254 | + } else { |
|
255 | + return array(); |
|
256 | + } |
|
238 | 257 | if ($globalDBdriver == 'mysql') { |
239 | 258 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
240 | 259 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -425,11 +444,15 @@ discard block |
||
425 | 444 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
426 | 445 | if ($globalDBdriver == 'mysql') { |
427 | 446 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
428 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
447 | + if ($liveinterval) { |
|
448 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
449 | + } |
|
429 | 450 | $query .= ' ORDER BY date'; |
430 | 451 | } else { |
431 | 452 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
432 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
453 | + if ($liveinterval) { |
|
454 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
455 | + } |
|
433 | 456 | $query .= ' ORDER BY date'; |
434 | 457 | } |
435 | 458 | |
@@ -524,7 +547,9 @@ discard block |
||
524 | 547 | $i++; |
525 | 548 | $j++; |
526 | 549 | if ($j == 30) { |
527 | - if ($globalDebug) echo "."; |
|
550 | + if ($globalDebug) { |
|
551 | + echo "."; |
|
552 | + } |
|
528 | 553 | try { |
529 | 554 | |
530 | 555 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -832,7 +857,9 @@ discard block |
||
832 | 857 | { |
833 | 858 | return false; |
834 | 859 | } |
835 | - } else return ''; |
|
860 | + } else { |
|
861 | + return ''; |
|
862 | + } |
|
836 | 863 | |
837 | 864 | if ($longitude != '') |
838 | 865 | { |
@@ -840,7 +867,9 @@ discard block |
||
840 | 867 | { |
841 | 868 | return false; |
842 | 869 | } |
843 | - } else return ''; |
|
870 | + } else { |
|
871 | + return ''; |
|
872 | + } |
|
844 | 873 | |
845 | 874 | if ($waypoints != '') |
846 | 875 | { |
@@ -856,7 +885,9 @@ discard block |
||
856 | 885 | { |
857 | 886 | return false; |
858 | 887 | } |
859 | - } else $altitude = 0; |
|
888 | + } else { |
|
889 | + $altitude = 0; |
|
890 | + } |
|
860 | 891 | |
861 | 892 | if ($heading != '') |
862 | 893 | { |
@@ -864,7 +895,9 @@ discard block |
||
864 | 895 | { |
865 | 896 | return false; |
866 | 897 | } |
867 | - } else $heading = 0; |
|
898 | + } else { |
|
899 | + $heading = 0; |
|
900 | + } |
|
868 | 901 | |
869 | 902 | if ($groundspeed != '') |
870 | 903 | { |
@@ -872,9 +905,13 @@ discard block |
||
872 | 905 | { |
873 | 906 | return false; |
874 | 907 | } |
875 | - } else $groundspeed = 0; |
|
908 | + } else { |
|
909 | + $groundspeed = 0; |
|
910 | + } |
|
876 | 911 | date_default_timezone_set('UTC'); |
877 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
912 | + if ($date == '') { |
|
913 | + $date = date("Y-m-d H:i:s", time()); |
|
914 | + } |
|
878 | 915 | |
879 | 916 | |
880 | 917 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -918,10 +955,18 @@ discard block |
||
918 | 955 | $arrival_airport_country = ''; |
919 | 956 | |
920 | 957 | |
921 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
922 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
923 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
924 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
959 | + $squawk = NULL; |
|
960 | + } |
|
961 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
962 | + $verticalrate = NULL; |
|
963 | + } |
|
964 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
965 | + $groundspeed = 0; |
|
966 | + } |
|
967 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
968 | + $heading = 0; |
|
969 | + } |
|
925 | 970 | |
926 | 971 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, 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, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
927 | 972 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,: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,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -936,9 +981,13 @@ discard block |
||
936 | 981 | return "error : ".$e->getMessage(); |
937 | 982 | } |
938 | 983 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
939 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
984 | + if ($globalDebug) { |
|
985 | + echo '(Add to SBS archive : '; |
|
986 | + } |
|
940 | 987 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
941 | - if ($globalDebug) echo $result.')'; |
|
988 | + if ($globalDebug) { |
|
989 | + echo $result.')'; |
|
990 | + } |
|
942 | 991 | } |
943 | 992 | return "success"; |
944 | 993 |
@@ -19,8 +19,12 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
22 | - if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
|
23 | - if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
|
22 | + if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
|
23 | + $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
|
24 | + } |
|
25 | + if (is_array($globalFilter)) { |
|
26 | + $filter = array_merge($globalFilter,$filter); |
|
27 | + } |
|
24 | 28 | $filter_query_join = ''; |
25 | 29 | $filter_query_where = ''; |
26 | 30 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
@@ -48,8 +52,11 @@ discard block |
||
48 | 52 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
49 | 53 | } |
50 | 54 | } |
51 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
52 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
55 | + if ($filter_query_where == '' && $where) { |
|
56 | + $filter_query_where = ' WHERE'; |
|
57 | + } elseif ($filter_query_where != '' && $and) { |
|
58 | + $filter_query_where .= ' AND'; |
|
59 | + } |
|
53 | 60 | $filter_query = $filter_query_join.$filter_query_where; |
54 | 61 | return $filter_query; |
55 | 62 | } |
@@ -69,10 +76,18 @@ discard block |
||
69 | 76 | $Image = new Image($this->db); |
70 | 77 | $Schedule = new Schedule($this->db); |
71 | 78 | $ACARS = new ACARS($this->db); |
72 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
73 | - if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
74 | - if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
75 | - if (!isset($globalVAM)) $globalVAM = FALSE; |
|
79 | + if (!isset($globalIVAO)) { |
|
80 | + $globalIVAO = FALSE; |
|
81 | + } |
|
82 | + if (!isset($globalVATSIM)) { |
|
83 | + $globalVATSIM = FALSE; |
|
84 | + } |
|
85 | + if (!isset($globalphpVMS)) { |
|
86 | + $globalphpVMS = FALSE; |
|
87 | + } |
|
88 | + if (!isset($globalVAM)) { |
|
89 | + $globalVAM = FALSE; |
|
90 | + } |
|
76 | 91 | date_default_timezone_set('UTC'); |
77 | 92 | |
78 | 93 | if (!is_string($query)) |
@@ -119,21 +134,35 @@ discard block |
||
119 | 134 | } else { |
120 | 135 | $temp_array['spotter_id'] = ''; |
121 | 136 | } |
122 | - if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id']; |
|
123 | - if (isset($row['modes'])) $temp_array['modes'] = $row['modes']; |
|
137 | + if (isset($row['flightaware_id'])) { |
|
138 | + $temp_array['flightaware_id'] = $row['flightaware_id']; |
|
139 | + } |
|
140 | + if (isset($row['modes'])) { |
|
141 | + $temp_array['modes'] = $row['modes']; |
|
142 | + } |
|
124 | 143 | $temp_array['ident'] = $row['ident']; |
125 | 144 | if (isset($row['registration']) && $row['registration'] != '') { |
126 | 145 | $temp_array['registration'] = $row['registration']; |
127 | 146 | } elseif (isset($temp_array['modes'])) { |
128 | 147 | $temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']); |
129 | - } else $temp_array['registration'] = ''; |
|
130 | - if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao']; |
|
148 | + } else { |
|
149 | + $temp_array['registration'] = ''; |
|
150 | + } |
|
151 | + if (isset($row['aircraft_icao'])) { |
|
152 | + $temp_array['aircraft_type'] = $row['aircraft_icao']; |
|
153 | + } |
|
131 | 154 | |
132 | 155 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
133 | 156 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
134 | - if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
135 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
136 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
157 | + if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) { |
|
158 | + $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
159 | + } |
|
160 | + if (isset($row['latitude'])) { |
|
161 | + $temp_array['latitude'] = $row['latitude']; |
|
162 | + } |
|
163 | + if (isset($row['longitude'])) { |
|
164 | + $temp_array['longitude'] = $row['longitude']; |
|
165 | + } |
|
137 | 166 | /* |
138 | 167 | if (Connection->tableExists('countries')) { |
139 | 168 | $country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']); |
@@ -143,8 +172,12 @@ discard block |
||
143 | 172 | } |
144 | 173 | } |
145 | 174 | */ |
146 | - if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints']; |
|
147 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
175 | + if (isset($row['waypoints'])) { |
|
176 | + $temp_array['waypoints'] = $row['waypoints']; |
|
177 | + } |
|
178 | + if (isset($row['format_source'])) { |
|
179 | + $temp_array['format_source'] = $row['format_source']; |
|
180 | + } |
|
148 | 181 | if (isset($row['route_stop'])) { |
149 | 182 | $temp_array['route_stop'] = $row['route_stop']; |
150 | 183 | if ($row['route_stop'] != '') { |
@@ -163,13 +196,19 @@ discard block |
||
163 | 196 | } |
164 | 197 | } |
165 | 198 | } |
166 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
199 | + if (isset($row['altitude'])) { |
|
200 | + $temp_array['altitude'] = $row['altitude']; |
|
201 | + } |
|
167 | 202 | if (isset($row['heading'])) { |
168 | 203 | $temp_array['heading'] = $row['heading']; |
169 | 204 | $heading_direction = $this->parseDirection($row['heading']); |
170 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
205 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
206 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
207 | + } |
|
208 | + } |
|
209 | + if (isset($row['ground_speed'])) { |
|
210 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
171 | 211 | } |
172 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
173 | 212 | $temp_array['image'] = ""; |
174 | 213 | $temp_array['image_thumbnail'] = ""; |
175 | 214 | $temp_array['image_source'] = ""; |
@@ -177,7 +216,9 @@ discard block |
||
177 | 216 | |
178 | 217 | if (isset($row['highlight'])) { |
179 | 218 | $temp_array['highlight'] = $row['highlight']; |
180 | - } else $temp_array['highlight'] = ''; |
|
219 | + } else { |
|
220 | + $temp_array['highlight'] = ''; |
|
221 | + } |
|
181 | 222 | |
182 | 223 | if (isset($row['date'])) { |
183 | 224 | $dateArray = $this->parseDateString($row['date']); |
@@ -225,7 +266,9 @@ discard block |
||
225 | 266 | |
226 | 267 | if ($aircraft_array[0]['aircraft_shadow'] != NULL) { |
227 | 268 | $temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow']; |
228 | - } else $temp_array['aircraft_shadow'] = 'default.png'; |
|
269 | + } else { |
|
270 | + $temp_array['aircraft_shadow'] = 'default.png'; |
|
271 | + } |
|
229 | 272 | } else { |
230 | 273 | $temp_array['aircraft_shadow'] = 'default.png'; |
231 | 274 | $temp_array['aircraft_name'] = 'N/A'; |
@@ -233,11 +276,17 @@ discard block |
||
233 | 276 | } |
234 | 277 | } |
235 | 278 | $fromsource = NULL; |
236 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
237 | - elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
238 | - elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
239 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
240 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
279 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
280 | + $fromsource = $globalAirlinesSource; |
|
281 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') { |
|
282 | + $fromsource = 'vatsim'; |
|
283 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') { |
|
284 | + $fromsource = 'ivao'; |
|
285 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
286 | + $fromsource = 'vatsim'; |
|
287 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
288 | + $fromsource = 'ivao'; |
|
289 | + } |
|
241 | 290 | if (!isset($row['airline_name']) || $row['airline_name'] == '') { |
242 | 291 | if (!is_numeric(substr($row['ident'], 0, 3))) { |
243 | 292 | if (is_numeric(substr($row['ident'], 2, 1))) { |
@@ -260,12 +309,18 @@ discard block |
||
260 | 309 | } |
261 | 310 | } else { |
262 | 311 | $temp_array['airline_icao'] = $row['airline_icao']; |
263 | - if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata']; |
|
264 | - else $temp_array['airline_iata'] = ''; |
|
312 | + if (isset($row['airline_iata'])) { |
|
313 | + $temp_array['airline_iata'] = $row['airline_iata']; |
|
314 | + } else { |
|
315 | + $temp_array['airline_iata'] = ''; |
|
316 | + } |
|
265 | 317 | $temp_array['airline_name'] = $row['airline_name']; |
266 | 318 | $temp_array['airline_country'] = $row['airline_country']; |
267 | - if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
268 | - else $temp_array['airline_callsign'] = 'N/A'; |
|
319 | + if (isset($row['airline_callsign'])) { |
|
320 | + $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
321 | + } else { |
|
322 | + $temp_array['airline_callsign'] = 'N/A'; |
|
323 | + } |
|
269 | 324 | $temp_array['airline_type'] = $row['airline_type']; |
270 | 325 | } |
271 | 326 | if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') { |
@@ -281,7 +336,9 @@ discard block |
||
281 | 336 | } |
282 | 337 | if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) { |
283 | 338 | $owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']); |
284 | - if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
339 | + if ($owner_info['owner'] != '') { |
|
340 | + $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
341 | + } |
|
285 | 342 | $temp_array['aircraft_base'] = $owner_info['base']; |
286 | 343 | $temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; |
287 | 344 | } |
@@ -289,9 +346,14 @@ discard block |
||
289 | 346 | if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) |
290 | 347 | { |
291 | 348 | if ($globalIVAO) { |
292 | - if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
293 | - else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
294 | - } else $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
349 | + if (isset($temp_array['airline_icao'])) { |
|
350 | + $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
351 | + } else { |
|
352 | + $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
353 | + } |
|
354 | + } else { |
|
355 | + $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
356 | + } |
|
295 | 357 | if (count($image_array) > 0) { |
296 | 358 | $temp_array['image'] = $image_array[0]['image']; |
297 | 359 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -341,7 +403,9 @@ discard block |
||
341 | 403 | //if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') { |
342 | 404 | if ($row['departure_airport_icao'] != '') { |
343 | 405 | $departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']); |
344 | - if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
406 | + if (!isset($departure_airport_array[0]['name'])) { |
|
407 | + $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
408 | + } |
|
345 | 409 | /* |
346 | 410 | } elseif ($row['departure_airport_name'] != '') { |
347 | 411 | $temp_array['departure_airport_name'] = $row['departure_airport_name']; |
@@ -349,7 +413,9 @@ discard block |
||
349 | 413 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
350 | 414 | $temp_array['departure_airport_icao'] = $row['departure_airport_icao']; |
351 | 415 | */ |
352 | - } else $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
416 | + } else { |
|
417 | + $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
418 | + } |
|
353 | 419 | if (isset($departure_airport_array[0]['name'])) { |
354 | 420 | $temp_array['departure_airport_name'] = $departure_airport_array[0]['name']; |
355 | 421 | $temp_array['departure_airport_city'] = $departure_airport_array[0]['city']; |
@@ -369,8 +435,12 @@ discard block |
||
369 | 435 | |
370 | 436 | if ($row['arrival_airport_icao'] != '') { |
371 | 437 | $arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']); |
372 | - if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
373 | - } else $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
438 | + if (count($arrival_airport_array) == 0) { |
|
439 | + $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
440 | + } |
|
441 | + } else { |
|
442 | + $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
443 | + } |
|
374 | 444 | if (isset($arrival_airport_array[0]['name'])) { |
375 | 445 | $temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name']; |
376 | 446 | $temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city']; |
@@ -386,27 +456,45 @@ discard block |
||
386 | 456 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
387 | 457 | } |
388 | 458 | */ |
389 | - if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id']; |
|
390 | - if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name']; |
|
391 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
392 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
393 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
459 | + if (isset($row['pilot_id']) && $row['pilot_id'] != '') { |
|
460 | + $temp_array['pilot_id'] = $row['pilot_id']; |
|
461 | + } |
|
462 | + if (isset($row['pilot_name']) && $row['pilot_name'] != '') { |
|
463 | + $temp_array['pilot_name'] = $row['pilot_name']; |
|
464 | + } |
|
465 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
466 | + $temp_array['source_name'] = $row['source_name']; |
|
467 | + } |
|
468 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
469 | + $temp_array['over_country'] = $row['over_country']; |
|
470 | + } |
|
471 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
472 | + $temp_array['distance'] = $row['distance']; |
|
473 | + } |
|
394 | 474 | if (isset($row['squawk'])) { |
395 | 475 | $temp_array['squawk'] = $row['squawk']; |
396 | 476 | if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { |
397 | 477 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); |
398 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
478 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) { |
|
479 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
480 | + } |
|
399 | 481 | } elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { |
400 | 482 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); |
401 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
402 | - } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
483 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) { |
|
484 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
485 | + } |
|
486 | + } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) { |
|
487 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
488 | + } |
|
403 | 489 | } |
404 | 490 | |
405 | 491 | $temp_array['query_number_rows'] = $num_rows; |
406 | 492 | |
407 | 493 | $spotter_array[] = $temp_array; |
408 | 494 | } |
409 | - if ($num_rows == 0) return array(); |
|
495 | + if ($num_rows == 0) { |
|
496 | + return array(); |
|
497 | + } |
|
410 | 498 | $spotter_array[0]['query_number_rows'] = $num_rows; |
411 | 499 | return $spotter_array; |
412 | 500 | } |
@@ -439,7 +527,9 @@ discard block |
||
439 | 527 | foreach ($q_array as $q_item){ |
440 | 528 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
441 | 529 | $additional_query .= " AND ("; |
442 | - if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
530 | + if (is_int($q_item)) { |
|
531 | + $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
532 | + } |
|
443 | 533 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
444 | 534 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
445 | 535 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
@@ -460,7 +550,9 @@ discard block |
||
460 | 550 | $additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR "; |
461 | 551 | $additional_query .= "(spotter_output.ident like '%".$q_item."%') OR "; |
462 | 552 | $translate = $Translation->ident2icao($q_item); |
463 | - if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
553 | + if ($translate != $q_item) { |
|
554 | + $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
555 | + } |
|
464 | 556 | $additional_query .= "(spotter_output.highlight like '%".$q_item."%')"; |
465 | 557 | $additional_query .= ")"; |
466 | 558 | } |
@@ -687,7 +779,9 @@ discard block |
||
687 | 779 | date_default_timezone_set($globalTimezone); |
688 | 780 | $datetime = new DateTime(); |
689 | 781 | $offset = $datetime->format('P'); |
690 | - } else $offset = '+00:00'; |
|
782 | + } else { |
|
783 | + $offset = '+00:00'; |
|
784 | + } |
|
691 | 785 | |
692 | 786 | if ($date_array[1] != "") |
693 | 787 | { |
@@ -719,8 +813,12 @@ discard block |
||
719 | 813 | { |
720 | 814 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
721 | 815 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
722 | - } else $limit_query = ""; |
|
723 | - } else $limit_query = ""; |
|
816 | + } else { |
|
817 | + $limit_query = ""; |
|
818 | + } |
|
819 | + } else { |
|
820 | + $limit_query = ""; |
|
821 | + } |
|
724 | 822 | |
725 | 823 | |
726 | 824 | if ($sort != "") |
@@ -788,8 +886,12 @@ discard block |
||
788 | 886 | { |
789 | 887 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
790 | 888 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
791 | - } else $limit_query = ""; |
|
792 | - } else $limit_query = ""; |
|
889 | + } else { |
|
890 | + $limit_query = ""; |
|
891 | + } |
|
892 | + } else { |
|
893 | + $limit_query = ""; |
|
894 | + } |
|
793 | 895 | |
794 | 896 | if ($sort != "") |
795 | 897 | { |
@@ -1113,7 +1215,9 @@ discard block |
||
1113 | 1215 | global $global_query; |
1114 | 1216 | |
1115 | 1217 | date_default_timezone_set('UTC'); |
1116 | - if ($id == '') return array(); |
|
1218 | + if ($id == '') { |
|
1219 | + return array(); |
|
1220 | + } |
|
1117 | 1221 | $additional_query = "spotter_output.spotter_id = :id"; |
1118 | 1222 | $query_values = array(':id' => $id); |
1119 | 1223 | |
@@ -1740,7 +1844,9 @@ discard block |
||
1740 | 1844 | { |
1741 | 1845 | $highlight = $row['highlight']; |
1742 | 1846 | } |
1743 | - if (isset($highlight)) return $highlight; |
|
1847 | + if (isset($highlight)) { |
|
1848 | + return $highlight; |
|
1849 | + } |
|
1744 | 1850 | } |
1745 | 1851 | |
1746 | 1852 | |
@@ -1768,7 +1874,9 @@ discard block |
||
1768 | 1874 | $sth->closeCursor(); |
1769 | 1875 | if (count($row) > 0) { |
1770 | 1876 | return $row['usage']; |
1771 | - } else return ''; |
|
1877 | + } else { |
|
1878 | + return ''; |
|
1879 | + } |
|
1772 | 1880 | } |
1773 | 1881 | |
1774 | 1882 | /** |
@@ -1793,7 +1901,9 @@ discard block |
||
1793 | 1901 | $sth->closeCursor(); |
1794 | 1902 | if (count($row) > 0) { |
1795 | 1903 | return $row['icao']; |
1796 | - } else return ''; |
|
1904 | + } else { |
|
1905 | + return ''; |
|
1906 | + } |
|
1797 | 1907 | } |
1798 | 1908 | |
1799 | 1909 | /** |
@@ -1821,7 +1931,9 @@ discard block |
||
1821 | 1931 | $airport_longitude = $row['longitude']; |
1822 | 1932 | $Common = new Common(); |
1823 | 1933 | return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); |
1824 | - } else return ''; |
|
1934 | + } else { |
|
1935 | + return ''; |
|
1936 | + } |
|
1825 | 1937 | } |
1826 | 1938 | |
1827 | 1939 | /** |
@@ -1933,7 +2045,9 @@ discard block |
||
1933 | 2045 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1934 | 2046 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1935 | 2047 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1936 | - } else return array(); |
|
2048 | + } else { |
|
2049 | + return array(); |
|
2050 | + } |
|
1937 | 2051 | if ($globalDBdriver == 'mysql') { |
1938 | 2052 | $query = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
1939 | 2053 | } else { |
@@ -1968,7 +2082,9 @@ discard block |
||
1968 | 2082 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1969 | 2083 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1970 | 2084 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1971 | - } else return array(); |
|
2085 | + } else { |
|
2086 | + return array(); |
|
2087 | + } |
|
1972 | 2088 | //$query = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
1973 | 2089 | $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.")"; |
1974 | 2090 | //$query = "SELECT waypoints.* FROM waypoints"; |
@@ -2003,7 +2119,9 @@ discard block |
||
2003 | 2119 | public function getAllAirlineInfo($airline_icao, $fromsource = NULL) |
2004 | 2120 | { |
2005 | 2121 | global $globalUseRealAirlines; |
2006 | - if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
|
2122 | + if (isset($globalUseRealAirlines) && $globalUseRealAirlines) { |
|
2123 | + $fromsource = NULL; |
|
2124 | + } |
|
2007 | 2125 | $airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING)); |
2008 | 2126 | if ($airline_icao == 'NA') { |
2009 | 2127 | $airline_array = array(); |
@@ -2053,7 +2171,9 @@ discard block |
||
2053 | 2171 | $sth->execute(array(':fromsource' => $fromsource)); |
2054 | 2172 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2055 | 2173 | $sth->closeCursor(); |
2056 | - if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao); |
|
2174 | + if ($row['nb'] == 0) { |
|
2175 | + $result = $this->getAllAirlineInfo($airline_icao); |
|
2176 | + } |
|
2057 | 2177 | } |
2058 | 2178 | return $result; |
2059 | 2179 | } |
@@ -2117,15 +2237,20 @@ discard block |
||
2117 | 2237 | 'A320-211' => 'A320', |
2118 | 2238 | '747-8i' => 'B748', |
2119 | 2239 | 'A380' => 'A388'); |
2120 | - if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type]; |
|
2240 | + if (isset($all_aircraft[$aircraft_type])) { |
|
2241 | + return $all_aircraft[$aircraft_type]; |
|
2242 | + } |
|
2121 | 2243 | |
2122 | 2244 | $query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; |
2123 | 2245 | $aircraft_type = strtoupper($aircraft_type); |
2124 | 2246 | $sth = $this->db->prepare($query); |
2125 | 2247 | $sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,)); |
2126 | 2248 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
2127 | - if (isset($result[0]['icao'])) return $result[0]['icao']; |
|
2128 | - else return ''; |
|
2249 | + if (isset($result[0]['icao'])) { |
|
2250 | + return $result[0]['icao']; |
|
2251 | + } else { |
|
2252 | + return ''; |
|
2253 | + } |
|
2129 | 2254 | } |
2130 | 2255 | |
2131 | 2256 | /** |
@@ -2148,7 +2273,9 @@ discard block |
||
2148 | 2273 | $sth->closeCursor(); |
2149 | 2274 | if (isset($row['icaotypecode'])) { |
2150 | 2275 | return $row['icaotypecode']; |
2151 | - } else return ''; |
|
2276 | + } else { |
|
2277 | + return ''; |
|
2278 | + } |
|
2152 | 2279 | } |
2153 | 2280 | |
2154 | 2281 | /** |
@@ -2170,7 +2297,9 @@ discard block |
||
2170 | 2297 | $sth->closeCursor(); |
2171 | 2298 | if (isset($row['operator_correct'])) { |
2172 | 2299 | return $row['operator_correct']; |
2173 | - } else return $operator; |
|
2300 | + } else { |
|
2301 | + return $operator; |
|
2302 | + } |
|
2174 | 2303 | } |
2175 | 2304 | |
2176 | 2305 | /** |
@@ -2183,7 +2312,9 @@ discard block |
||
2183 | 2312 | public function getRouteInfo($callsign) |
2184 | 2313 | { |
2185 | 2314 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
2186 | - if ($callsign == '') return array(); |
|
2315 | + if ($callsign == '') { |
|
2316 | + return array(); |
|
2317 | + } |
|
2187 | 2318 | $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"; |
2188 | 2319 | |
2189 | 2320 | $sth = $this->db->prepare($query); |
@@ -2193,7 +2324,9 @@ discard block |
||
2193 | 2324 | $sth->closeCursor(); |
2194 | 2325 | if (count($row) > 0) { |
2195 | 2326 | return $row; |
2196 | - } else return array(); |
|
2327 | + } else { |
|
2328 | + return array(); |
|
2329 | + } |
|
2197 | 2330 | } |
2198 | 2331 | |
2199 | 2332 | /** |
@@ -2246,7 +2379,9 @@ discard block |
||
2246 | 2379 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
2247 | 2380 | $sth->closeCursor(); |
2248 | 2381 | return $result; |
2249 | - } else return array(); |
|
2382 | + } else { |
|
2383 | + return array(); |
|
2384 | + } |
|
2250 | 2385 | } |
2251 | 2386 | |
2252 | 2387 | |
@@ -2403,8 +2538,11 @@ discard block |
||
2403 | 2538 | $query .= " ORDER BY spotter_output.source_name ASC"; |
2404 | 2539 | |
2405 | 2540 | $sth = $this->db->prepare($query); |
2406 | - if (!empty($query_values)) $sth->execute($query_values); |
|
2407 | - else $sth->execute(); |
|
2541 | + if (!empty($query_values)) { |
|
2542 | + $sth->execute($query_values); |
|
2543 | + } else { |
|
2544 | + $sth->execute(); |
|
2545 | + } |
|
2408 | 2546 | |
2409 | 2547 | $source_array = array(); |
2410 | 2548 | $temp_array = array(); |
@@ -2437,9 +2575,13 @@ discard block |
||
2437 | 2575 | WHERE spotter_output.airline_icao <> '' |
2438 | 2576 | ORDER BY spotter_output.airline_name ASC"; |
2439 | 2577 | */ |
2440 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
|
2441 | - elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
|
2442 | - elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
|
2578 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
2579 | + $forsource = $globalAirlinesSource; |
|
2580 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
2581 | + $forsource = 'vatsim'; |
|
2582 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
2583 | + $forsource = 'ivao'; |
|
2584 | + } |
|
2443 | 2585 | if ($forsource === NULL) { |
2444 | 2586 | $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"; |
2445 | 2587 | $query_data = array(); |
@@ -2731,7 +2873,9 @@ discard block |
||
2731 | 2873 | date_default_timezone_set($globalTimezone); |
2732 | 2874 | $datetime = new DateTime(); |
2733 | 2875 | $offset = $datetime->format('P'); |
2734 | - } else $offset = '+00:00'; |
|
2876 | + } else { |
|
2877 | + $offset = '+00:00'; |
|
2878 | + } |
|
2735 | 2879 | if ($airport_icao == '') { |
2736 | 2880 | if ($globalDBdriver == 'mysql') { |
2737 | 2881 | $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"; |
@@ -2763,7 +2907,9 @@ discard block |
||
2763 | 2907 | date_default_timezone_set($globalTimezone); |
2764 | 2908 | $datetime = new DateTime(); |
2765 | 2909 | $offset = $datetime->format('P'); |
2766 | - } else $offset = '+00:00'; |
|
2910 | + } else { |
|
2911 | + $offset = '+00:00'; |
|
2912 | + } |
|
2767 | 2913 | if ($airport_icao == '') { |
2768 | 2914 | if ($globalDBdriver == 'mysql') { |
2769 | 2915 | $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"; |
@@ -2796,7 +2942,9 @@ discard block |
||
2796 | 2942 | date_default_timezone_set($globalTimezone); |
2797 | 2943 | $datetime = new DateTime(); |
2798 | 2944 | $offset = $datetime->format('P'); |
2799 | - } else $offset = '+00:00'; |
|
2945 | + } else { |
|
2946 | + $offset = '+00:00'; |
|
2947 | + } |
|
2800 | 2948 | if ($airport_icao == '') { |
2801 | 2949 | if ($globalDBdriver == 'mysql') { |
2802 | 2950 | $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 |
@@ -2835,7 +2983,9 @@ discard block |
||
2835 | 2983 | date_default_timezone_set($globalTimezone); |
2836 | 2984 | $datetime = new DateTime(); |
2837 | 2985 | $offset = $datetime->format('P'); |
2838 | - } else $offset = '+00:00'; |
|
2986 | + } else { |
|
2987 | + $offset = '+00:00'; |
|
2988 | + } |
|
2839 | 2989 | if ($airport_icao == '') { |
2840 | 2990 | if ($globalDBdriver == 'mysql') { |
2841 | 2991 | $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 |
@@ -2880,7 +3030,9 @@ discard block |
||
2880 | 3030 | date_default_timezone_set($globalTimezone); |
2881 | 3031 | $datetime = new DateTime(); |
2882 | 3032 | $offset = $datetime->format('P'); |
2883 | - } else $offset = '+00:00'; |
|
3033 | + } else { |
|
3034 | + $offset = '+00:00'; |
|
3035 | + } |
|
2884 | 3036 | if ($airport_icao == '') { |
2885 | 3037 | if ($globalDBdriver == 'mysql') { |
2886 | 3038 | $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"; |
@@ -2915,7 +3067,9 @@ discard block |
||
2915 | 3067 | date_default_timezone_set($globalTimezone); |
2916 | 3068 | $datetime = new DateTime(); |
2917 | 3069 | $offset = $datetime->format('P'); |
2918 | - } else $offset = '+00:00'; |
|
3070 | + } else { |
|
3071 | + $offset = '+00:00'; |
|
3072 | + } |
|
2919 | 3073 | if ($airport_icao == '') { |
2920 | 3074 | if ($globalDBdriver == 'mysql') { |
2921 | 3075 | $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 |
@@ -2957,7 +3111,9 @@ discard block |
||
2957 | 3111 | date_default_timezone_set($globalTimezone); |
2958 | 3112 | $datetime = new DateTime(); |
2959 | 3113 | $offset = $datetime->format('P'); |
2960 | - } else $offset = '+00:00'; |
|
3114 | + } else { |
|
3115 | + $offset = '+00:00'; |
|
3116 | + } |
|
2961 | 3117 | if ($airport_icao == '') { |
2962 | 3118 | if ($globalDBdriver == 'mysql') { |
2963 | 3119 | $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"; |
@@ -2991,7 +3147,9 @@ discard block |
||
2991 | 3147 | date_default_timezone_set($globalTimezone); |
2992 | 3148 | $datetime = new DateTime(); |
2993 | 3149 | $offset = $datetime->format('P'); |
2994 | - } else $offset = '+00:00'; |
|
3150 | + } else { |
|
3151 | + $offset = '+00:00'; |
|
3152 | + } |
|
2995 | 3153 | if ($airport_icao == '') { |
2996 | 3154 | if ($globalDBdriver == 'mysql') { |
2997 | 3155 | $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 |
@@ -3039,7 +3197,9 @@ discard block |
||
3039 | 3197 | date_default_timezone_set($globalTimezone); |
3040 | 3198 | $datetime = new DateTime(); |
3041 | 3199 | $offset = $datetime->format('P'); |
3042 | - } else $offset = '+00:00'; |
|
3200 | + } else { |
|
3201 | + $offset = '+00:00'; |
|
3202 | + } |
|
3043 | 3203 | |
3044 | 3204 | if ($globalDBdriver == 'mysql') { |
3045 | 3205 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
@@ -3159,7 +3319,9 @@ discard block |
||
3159 | 3319 | */ |
3160 | 3320 | public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') |
3161 | 3321 | { |
3162 | - if ($groundspeed == '') $groundspeed = NULL; |
|
3322 | + if ($groundspeed == '') { |
|
3323 | + $groundspeed = NULL; |
|
3324 | + } |
|
3163 | 3325 | $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'; |
3164 | 3326 | $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); |
3165 | 3327 | |
@@ -3209,10 +3371,18 @@ discard block |
||
3209 | 3371 | $Image = new Image($this->db); |
3210 | 3372 | $Common = new Common(); |
3211 | 3373 | |
3212 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
3213 | - if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
3214 | - if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
3215 | - if (!isset($globalVAM)) $globalVAM = FALSE; |
|
3374 | + if (!isset($globalIVAO)) { |
|
3375 | + $globalIVAO = FALSE; |
|
3376 | + } |
|
3377 | + if (!isset($globalVATSIM)) { |
|
3378 | + $globalVATSIM = FALSE; |
|
3379 | + } |
|
3380 | + if (!isset($globalphpVMS)) { |
|
3381 | + $globalphpVMS = FALSE; |
|
3382 | + } |
|
3383 | + if (!isset($globalVAM)) { |
|
3384 | + $globalVAM = FALSE; |
|
3385 | + } |
|
3216 | 3386 | date_default_timezone_set('UTC'); |
3217 | 3387 | |
3218 | 3388 | //getting the registration |
@@ -3225,23 +3395,33 @@ discard block |
||
3225 | 3395 | if ($ModeS != '') { |
3226 | 3396 | $timeelapsed = microtime(true); |
3227 | 3397 | $registration = $this->getAircraftRegistrationBymodeS($ModeS); |
3228 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3398 | + if ($globalDebugTimeElapsed) { |
|
3399 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3400 | + } |
|
3229 | 3401 | } else { |
3230 | 3402 | $myhex = explode('-',$flightaware_id); |
3231 | 3403 | if (count($myhex) > 0) { |
3232 | 3404 | $timeelapsed = microtime(true); |
3233 | 3405 | $registration = $this->getAircraftRegistrationBymodeS($myhex[0]); |
3234 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3406 | + if ($globalDebugTimeElapsed) { |
|
3407 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3408 | + } |
|
3235 | 3409 | } |
3236 | 3410 | } |
3237 | 3411 | } |
3238 | 3412 | } |
3239 | 3413 | $fromsource = NULL; |
3240 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
3241 | - elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim'; |
|
3242 | - elseif ($format_source == 'whazzup') $fromsource = 'ivao'; |
|
3243 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
3244 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
3414 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
3415 | + $fromsource = $globalAirlinesSource; |
|
3416 | + } elseif ($format_source == 'vatsimtxt') { |
|
3417 | + $fromsource = 'vatsim'; |
|
3418 | + } elseif ($format_source == 'whazzup') { |
|
3419 | + $fromsource = 'ivao'; |
|
3420 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
3421 | + $fromsource = 'vatsim'; |
|
3422 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
3423 | + $fromsource = 'ivao'; |
|
3424 | + } |
|
3245 | 3425 | //getting the airline information |
3246 | 3426 | if ($ident != "") |
3247 | 3427 | { |
@@ -3265,15 +3445,21 @@ discard block |
||
3265 | 3445 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
3266 | 3446 | $airline_array = $this->getAllAirlineInfo("NA"); |
3267 | 3447 | } |
3268 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3448 | + if ($globalDebugTimeElapsed) { |
|
3449 | + echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3450 | + } |
|
3269 | 3451 | |
3270 | 3452 | } else { |
3271 | 3453 | $timeelapsed = microtime(true); |
3272 | 3454 | $airline_array = $this->getAllAirlineInfo("NA"); |
3273 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3455 | + if ($globalDebugTimeElapsed) { |
|
3456 | + echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3457 | + } |
|
3274 | 3458 | } |
3275 | 3459 | } |
3276 | - } else $airline_array = array(); |
|
3460 | + } else { |
|
3461 | + $airline_array = array(); |
|
3462 | + } |
|
3277 | 3463 | |
3278 | 3464 | //getting the aircraft information |
3279 | 3465 | $aircraft_array = array(); |
@@ -3287,27 +3473,37 @@ discard block |
||
3287 | 3473 | { |
3288 | 3474 | $timeelapsed = microtime(true); |
3289 | 3475 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
3290 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3476 | + if ($globalDebugTimeElapsed) { |
|
3477 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3478 | + } |
|
3291 | 3479 | } else { |
3292 | 3480 | $timeelapsed = microtime(true); |
3293 | 3481 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
3294 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3482 | + if ($globalDebugTimeElapsed) { |
|
3483 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3484 | + } |
|
3295 | 3485 | } |
3296 | 3486 | } |
3297 | 3487 | } else { |
3298 | 3488 | if ($ModeS != '') { |
3299 | 3489 | $timeelapsed = microtime(true); |
3300 | 3490 | $aircraft_icao = $this->getAllAircraftType($ModeS); |
3301 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3491 | + if ($globalDebugTimeElapsed) { |
|
3492 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3493 | + } |
|
3302 | 3494 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
3303 | 3495 | { |
3304 | 3496 | $timeelapsed = microtime(true); |
3305 | 3497 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
3306 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3498 | + if ($globalDebugTimeElapsed) { |
|
3499 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3500 | + } |
|
3307 | 3501 | } else { |
3308 | 3502 | $timeelapsed = microtime(true); |
3309 | 3503 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
3310 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3504 | + if ($globalDebugTimeElapsed) { |
|
3505 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3506 | + } |
|
3311 | 3507 | } |
3312 | 3508 | } |
3313 | 3509 | } |
@@ -3322,7 +3518,9 @@ discard block |
||
3322 | 3518 | } else { |
3323 | 3519 | $timeelapsed = microtime(true); |
3324 | 3520 | $departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); |
3325 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3521 | + if ($globalDebugTimeElapsed) { |
|
3522 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3523 | + } |
|
3326 | 3524 | } |
3327 | 3525 | } |
3328 | 3526 | |
@@ -3336,7 +3534,9 @@ discard block |
||
3336 | 3534 | } else { |
3337 | 3535 | $timeelapsed = microtime(true); |
3338 | 3536 | $arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); |
3339 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3537 | + if ($globalDebugTimeElapsed) { |
|
3538 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3539 | + } |
|
3340 | 3540 | } |
3341 | 3541 | } |
3342 | 3542 | |
@@ -3371,7 +3571,9 @@ discard block |
||
3371 | 3571 | { |
3372 | 3572 | return false; |
3373 | 3573 | } |
3374 | - } else $altitude = 0; |
|
3574 | + } else { |
|
3575 | + $altitude = 0; |
|
3576 | + } |
|
3375 | 3577 | |
3376 | 3578 | if ($heading != "") |
3377 | 3579 | { |
@@ -3400,7 +3602,9 @@ discard block |
||
3400 | 3602 | { |
3401 | 3603 | $timeelapsed = microtime(true); |
3402 | 3604 | $image_array = $Image->getSpotterImage($registration); |
3403 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3605 | + if ($globalDebugTimeElapsed) { |
|
3606 | + echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3607 | + } |
|
3404 | 3608 | if (!isset($image_array[0]['registration'])) |
3405 | 3609 | { |
3406 | 3610 | //echo "Add image !!!! \n"; |
@@ -3408,14 +3612,21 @@ discard block |
||
3408 | 3612 | } |
3409 | 3613 | $timeelapsed = microtime(true); |
3410 | 3614 | $owner_info = $this->getAircraftOwnerByRegistration($registration); |
3411 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3412 | - if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
3615 | + if ($globalDebugTimeElapsed) { |
|
3616 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3617 | + } |
|
3618 | + if ($owner_info['owner'] != '') { |
|
3619 | + $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
3620 | + } |
|
3413 | 3621 | } |
3414 | 3622 | |
3415 | 3623 | if ($globalIVAO && $aircraft_icao != '') |
3416 | 3624 | { |
3417 | - if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; |
|
3418 | - else $airline_icao = ''; |
|
3625 | + if (isset($airline_array[0]['icao'])) { |
|
3626 | + $airline_icao = $airline_array[0]['icao']; |
|
3627 | + } else { |
|
3628 | + $airline_icao = ''; |
|
3629 | + } |
|
3419 | 3630 | $image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); |
3420 | 3631 | if (!isset($image_array[0]['registration'])) |
3421 | 3632 | { |
@@ -3460,16 +3671,28 @@ discard block |
||
3460 | 3671 | { |
3461 | 3672 | $arrival_airport_array = $this->getAllAirportInfo('NA'); |
3462 | 3673 | } |
3463 | - if ($registration == '') $registration = 'NA'; |
|
3674 | + if ($registration == '') { |
|
3675 | + $registration = 'NA'; |
|
3676 | + } |
|
3464 | 3677 | if ($latitude == '' && $longitude == '') { |
3465 | 3678 | $latitude = 0; |
3466 | 3679 | $longitude = 0; |
3467 | 3680 | } |
3468 | - if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
3469 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
3470 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
3471 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
3472 | - if (!isset($aircraft_owner)) $aircraft_owner = NULL; |
|
3681 | + if ($squawk == '' || $Common->isInteger($squawk) === false) { |
|
3682 | + $squawk = NULL; |
|
3683 | + } |
|
3684 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) { |
|
3685 | + $verticalrate = NULL; |
|
3686 | + } |
|
3687 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
3688 | + $heading = 0; |
|
3689 | + } |
|
3690 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
3691 | + $groundspeed = 0; |
|
3692 | + } |
|
3693 | + if (!isset($aircraft_owner)) { |
|
3694 | + $aircraft_owner = NULL; |
|
3695 | + } |
|
3473 | 3696 | $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) |
3474 | 3697 | 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)"; |
3475 | 3698 | |
@@ -3480,9 +3703,13 @@ discard block |
||
3480 | 3703 | if ($airline_type == '') { |
3481 | 3704 | $timeelapsed = microtime(true); |
3482 | 3705 | $airline_type = $this->getAircraftTypeBymodeS($ModeS); |
3483 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3706 | + if ($globalDebugTimeElapsed) { |
|
3707 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3708 | + } |
|
3709 | + } |
|
3710 | + if ($airline_type == null) { |
|
3711 | + $airline_type = ''; |
|
3484 | 3712 | } |
3485 | - if ($airline_type == null) $airline_type = ''; |
|
3486 | 3713 | $aircraft_type = $aircraft_array[0]['type']; |
3487 | 3714 | $aircraft_manufacturer = $aircraft_array[0]['manufacturer']; |
3488 | 3715 | $departure_airport_name = $departure_airport_array[0]['name']; |
@@ -3617,7 +3844,9 @@ discard block |
||
3617 | 3844 | } |
3618 | 3845 | } |
3619 | 3846 | $query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; |
3620 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3847 | + if ($limit) { |
|
3848 | + $query .= " LIMIT 10 OFFSET 0"; |
|
3849 | + } |
|
3621 | 3850 | |
3622 | 3851 | $sth = $this->db->prepare($query); |
3623 | 3852 | $sth->execute(); |
@@ -3662,7 +3891,9 @@ discard block |
||
3662 | 3891 | } |
3663 | 3892 | } |
3664 | 3893 | $query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC"; |
3665 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3894 | + if ($limit) { |
|
3895 | + $query .= " LIMIT 10 OFFSET 0"; |
|
3896 | + } |
|
3666 | 3897 | |
3667 | 3898 | |
3668 | 3899 | $sth = $this->db->prepare($query); |
@@ -3707,7 +3938,9 @@ discard block |
||
3707 | 3938 | } |
3708 | 3939 | } |
3709 | 3940 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC"; |
3710 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3941 | + if ($limit) { |
|
3942 | + $query .= " LIMIT 10 OFFSET 0"; |
|
3943 | + } |
|
3711 | 3944 | |
3712 | 3945 | |
3713 | 3946 | $sth = $this->db->prepare($query); |
@@ -3754,7 +3987,9 @@ discard block |
||
3754 | 3987 | } |
3755 | 3988 | } |
3756 | 3989 | $query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; |
3757 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3990 | + if ($limit) { |
|
3991 | + $query .= " LIMIT 10 OFFSET 0"; |
|
3992 | + } |
|
3758 | 3993 | |
3759 | 3994 | |
3760 | 3995 | $sth = $this->db->prepare($query); |
@@ -3799,7 +4034,9 @@ discard block |
||
3799 | 4034 | } |
3800 | 4035 | } |
3801 | 4036 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC"; |
3802 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4037 | + if ($limit) { |
|
4038 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4039 | + } |
|
3803 | 4040 | |
3804 | 4041 | |
3805 | 4042 | $sth = $this->db->prepare($query); |
@@ -4042,7 +4279,9 @@ discard block |
||
4042 | 4279 | date_default_timezone_set($globalTimezone); |
4043 | 4280 | $datetime = new DateTime($date); |
4044 | 4281 | $offset = $datetime->format('P'); |
4045 | - } else $offset = '+00:00'; |
|
4282 | + } else { |
|
4283 | + $offset = '+00:00'; |
|
4284 | + } |
|
4046 | 4285 | |
4047 | 4286 | if ($globalDBdriver == 'mysql') { |
4048 | 4287 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
@@ -4090,7 +4329,9 @@ discard block |
||
4090 | 4329 | date_default_timezone_set($globalTimezone); |
4091 | 4330 | $datetime = new DateTime($date); |
4092 | 4331 | $offset = $datetime->format('P'); |
4093 | - } else $offset = '+00:00'; |
|
4332 | + } else { |
|
4333 | + $offset = '+00:00'; |
|
4334 | + } |
|
4094 | 4335 | |
4095 | 4336 | if ($globalDBdriver == 'mysql') { |
4096 | 4337 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
@@ -4308,7 +4549,9 @@ discard block |
||
4308 | 4549 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' |
4309 | 4550 | GROUP BY spotter_output.airline_country |
4310 | 4551 | ORDER BY airline_country_count DESC"; |
4311 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4552 | + if ($limit) { |
|
4553 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4554 | + } |
|
4312 | 4555 | |
4313 | 4556 | $sth = $this->db->prepare($query); |
4314 | 4557 | $sth->execute(); |
@@ -4336,7 +4579,9 @@ discard block |
||
4336 | 4579 | global $globalDBdriver; |
4337 | 4580 | //$filter_query = $this->getFilter($filters,true,true); |
4338 | 4581 | $Connection= new Connection($this->db); |
4339 | - if (!$Connection->tableExists('countries')) return array(); |
|
4582 | + if (!$Connection->tableExists('countries')) { |
|
4583 | + return array(); |
|
4584 | + } |
|
4340 | 4585 | /* |
4341 | 4586 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
4342 | 4587 | FROM countries c, spotter_output s |
@@ -4361,7 +4606,9 @@ discard block |
||
4361 | 4606 | } |
4362 | 4607 | |
4363 | 4608 | $query .= "GROUP BY c.name ORDER BY nb DESC"; |
4364 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4609 | + if ($limit) { |
|
4610 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4611 | + } |
|
4365 | 4612 | |
4366 | 4613 | |
4367 | 4614 | $sth = $this->db->prepare($query); |
@@ -4411,7 +4658,9 @@ discard block |
||
4411 | 4658 | } |
4412 | 4659 | |
4413 | 4660 | $query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
4414 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4661 | + if ($limit) { |
|
4662 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4663 | + } |
|
4415 | 4664 | |
4416 | 4665 | $sth = $this->db->prepare($query); |
4417 | 4666 | $sth->execute(); |
@@ -4457,7 +4706,9 @@ discard block |
||
4457 | 4706 | } |
4458 | 4707 | |
4459 | 4708 | $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"; |
4460 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4709 | + if ($limit) { |
|
4710 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4711 | + } |
|
4461 | 4712 | |
4462 | 4713 | $sth = $this->db->prepare($query); |
4463 | 4714 | $sth->execute(); |
@@ -4510,7 +4761,9 @@ discard block |
||
4510 | 4761 | if($row['registration'] != "") |
4511 | 4762 | { |
4512 | 4763 | $image_array = $Image->getSpotterImage($row['registration']); |
4513 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4764 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
4765 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4766 | + } |
|
4514 | 4767 | } |
4515 | 4768 | $temp_array['registration_count'] = $row['registration_count']; |
4516 | 4769 | |
@@ -4585,7 +4838,9 @@ discard block |
||
4585 | 4838 | if($row['registration'] != "") |
4586 | 4839 | { |
4587 | 4840 | $image_array = $Image->getSpotterImage($row['registration']); |
4588 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4841 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
4842 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4843 | + } |
|
4589 | 4844 | } |
4590 | 4845 | $temp_array['registration_count'] = $row['registration_count']; |
4591 | 4846 | |
@@ -4692,7 +4947,9 @@ discard block |
||
4692 | 4947 | if($row['registration'] != "") |
4693 | 4948 | { |
4694 | 4949 | $image_array = $Image->getSpotterImage($row['registration']); |
4695 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4950 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
4951 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4952 | + } |
|
4696 | 4953 | } |
4697 | 4954 | $temp_array['registration_count'] = $row['registration_count']; |
4698 | 4955 | $aircraft_array[] = $temp_array; |
@@ -4817,7 +5074,9 @@ discard block |
||
4817 | 5074 | date_default_timezone_set($globalTimezone); |
4818 | 5075 | $datetime = new DateTime($date); |
4819 | 5076 | $offset = $datetime->format('P'); |
4820 | - } else $offset = '+00:00'; |
|
5077 | + } else { |
|
5078 | + $offset = '+00:00'; |
|
5079 | + } |
|
4821 | 5080 | |
4822 | 5081 | if ($globalDBdriver == 'mysql') { |
4823 | 5082 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
@@ -4864,7 +5123,9 @@ discard block |
||
4864 | 5123 | date_default_timezone_set($globalTimezone); |
4865 | 5124 | $datetime = new DateTime($date); |
4866 | 5125 | $offset = $datetime->format('P'); |
4867 | - } else $offset = '+00:00'; |
|
5126 | + } else { |
|
5127 | + $offset = '+00:00'; |
|
5128 | + } |
|
4868 | 5129 | |
4869 | 5130 | if ($globalDBdriver == 'mysql') { |
4870 | 5131 | $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 |
@@ -4893,7 +5154,9 @@ discard block |
||
4893 | 5154 | if($row['registration'] != "") |
4894 | 5155 | { |
4895 | 5156 | $image_array = $Image->getSpotterImage($row['registration']); |
4896 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5157 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5158 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5159 | + } |
|
4897 | 5160 | } |
4898 | 5161 | $temp_array['registration_count'] = $row['registration_count']; |
4899 | 5162 | |
@@ -4918,7 +5181,9 @@ discard block |
||
4918 | 5181 | date_default_timezone_set($globalTimezone); |
4919 | 5182 | $datetime = new DateTime($date); |
4920 | 5183 | $offset = $datetime->format('P'); |
4921 | - } else $offset = '+00:00'; |
|
5184 | + } else { |
|
5185 | + $offset = '+00:00'; |
|
5186 | + } |
|
4922 | 5187 | |
4923 | 5188 | if ($globalDBdriver == 'mysql') { |
4924 | 5189 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
@@ -5016,8 +5281,11 @@ discard block |
||
5016 | 5281 | if($row['registration'] != "") |
5017 | 5282 | { |
5018 | 5283 | $image_array = $Image->getSpotterImage($row['registration']); |
5019 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5020 | - else $temp_array['image_thumbnail'] = ''; |
|
5284 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5285 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5286 | + } else { |
|
5287 | + $temp_array['image_thumbnail'] = ''; |
|
5288 | + } |
|
5021 | 5289 | } |
5022 | 5290 | $temp_array['registration_count'] = $row['registration_count']; |
5023 | 5291 | $aircraft_array[] = $temp_array; |
@@ -5124,7 +5392,9 @@ discard block |
||
5124 | 5392 | if($row['registration'] != "") |
5125 | 5393 | { |
5126 | 5394 | $image_array = $Image->getSpotterImage($row['registration']); |
5127 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5395 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5396 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5397 | + } |
|
5128 | 5398 | } |
5129 | 5399 | $temp_array['registration_count'] = $row['registration_count']; |
5130 | 5400 | |
@@ -5241,7 +5511,9 @@ discard block |
||
5241 | 5511 | if($row['registration'] != "") |
5242 | 5512 | { |
5243 | 5513 | $image_array = $Image->getSpotterImage($row['registration']); |
5244 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5514 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5515 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5516 | + } |
|
5245 | 5517 | } |
5246 | 5518 | $temp_array['registration_count'] = $row['registration_count']; |
5247 | 5519 | |
@@ -5353,7 +5625,9 @@ discard block |
||
5353 | 5625 | // if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
5354 | 5626 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5355 | 5627 | $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
5356 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5628 | + if ($limit) { |
|
5629 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5630 | + } |
|
5357 | 5631 | |
5358 | 5632 | $sth = $this->db->prepare($query); |
5359 | 5633 | $sth->execute(); |
@@ -5372,7 +5646,9 @@ discard block |
||
5372 | 5646 | if($row['registration'] != "") |
5373 | 5647 | { |
5374 | 5648 | $image_array = $Image->getSpotterImage($row['registration']); |
5375 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5649 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5650 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5651 | + } |
|
5376 | 5652 | } |
5377 | 5653 | |
5378 | 5654 | $aircraft_array[] = $temp_array; |
@@ -5413,7 +5689,9 @@ discard block |
||
5413 | 5689 | // if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
5414 | 5690 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5415 | 5691 | $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"; |
5416 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5692 | + if ($limit) { |
|
5693 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5694 | + } |
|
5417 | 5695 | |
5418 | 5696 | $sth = $this->db->prepare($query); |
5419 | 5697 | $sth->execute(); |
@@ -5433,7 +5711,9 @@ discard block |
||
5433 | 5711 | if($row['registration'] != "") |
5434 | 5712 | { |
5435 | 5713 | $image_array = $Image->getSpotterImage($row['registration']); |
5436 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5714 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5715 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5716 | + } |
|
5437 | 5717 | } |
5438 | 5718 | |
5439 | 5719 | $aircraft_array[] = $temp_array; |
@@ -5474,7 +5754,9 @@ discard block |
||
5474 | 5754 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5475 | 5755 | $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
5476 | 5756 | ORDER BY airport_departure_icao_count DESC"; |
5477 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5757 | + if ($limit) { |
|
5758 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5759 | + } |
|
5478 | 5760 | |
5479 | 5761 | $sth = $this->db->prepare($query); |
5480 | 5762 | $sth->execute(); |
@@ -5526,7 +5808,9 @@ discard block |
||
5526 | 5808 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5527 | 5809 | $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 |
5528 | 5810 | ORDER BY airport_departure_icao_count DESC"; |
5529 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5811 | + if ($limit) { |
|
5812 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5813 | + } |
|
5530 | 5814 | |
5531 | 5815 | $sth = $this->db->prepare($query); |
5532 | 5816 | $sth->execute(); |
@@ -5578,7 +5862,9 @@ discard block |
||
5578 | 5862 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5579 | 5863 | $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
5580 | 5864 | ORDER BY airport_departure_icao_count DESC"; |
5581 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5865 | + if ($limit) { |
|
5866 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5867 | + } |
|
5582 | 5868 | //echo $query; |
5583 | 5869 | $sth = $this->db->prepare($query); |
5584 | 5870 | $sth->execute(); |
@@ -5630,7 +5916,9 @@ discard block |
||
5630 | 5916 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5631 | 5917 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
5632 | 5918 | ORDER BY airport_departure_icao_count DESC"; |
5633 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5919 | + if ($limit) { |
|
5920 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5921 | + } |
|
5634 | 5922 | |
5635 | 5923 | $sth = $this->db->prepare($query); |
5636 | 5924 | $sth->execute(); |
@@ -6025,7 +6313,9 @@ discard block |
||
6025 | 6313 | date_default_timezone_set($globalTimezone); |
6026 | 6314 | $datetime = new DateTime($date); |
6027 | 6315 | $offset = $datetime->format('P'); |
6028 | - } else $offset = '+00:00'; |
|
6316 | + } else { |
|
6317 | + $offset = '+00:00'; |
|
6318 | + } |
|
6029 | 6319 | |
6030 | 6320 | if ($globalDBdriver == 'mysql') { |
6031 | 6321 | $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 |
@@ -6075,7 +6365,9 @@ discard block |
||
6075 | 6365 | date_default_timezone_set($globalTimezone); |
6076 | 6366 | $datetime = new DateTime($date); |
6077 | 6367 | $offset = $datetime->format('P'); |
6078 | - } else $offset = '+00:00'; |
|
6368 | + } else { |
|
6369 | + $offset = '+00:00'; |
|
6370 | + } |
|
6079 | 6371 | |
6080 | 6372 | if ($globalDBdriver == 'mysql') { |
6081 | 6373 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
@@ -6288,7 +6580,9 @@ discard block |
||
6288 | 6580 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6289 | 6581 | $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
6290 | 6582 | ORDER BY airport_arrival_icao_count DESC"; |
6291 | - if ($limit) $query .= " LIMIT 10"; |
|
6583 | + if ($limit) { |
|
6584 | + $query .= " LIMIT 10"; |
|
6585 | + } |
|
6292 | 6586 | |
6293 | 6587 | |
6294 | 6588 | $sth = $this->db->prepare($query); |
@@ -6308,7 +6602,9 @@ discard block |
||
6308 | 6602 | if ($icaoaskey) { |
6309 | 6603 | $icao = $row['arrival_airport_icao']; |
6310 | 6604 | $airport_array[$icao] = $temp_array; |
6311 | - } else $airport_array[] = $temp_array; |
|
6605 | + } else { |
|
6606 | + $airport_array[] = $temp_array; |
|
6607 | + } |
|
6312 | 6608 | } |
6313 | 6609 | |
6314 | 6610 | return $airport_array; |
@@ -6350,7 +6646,9 @@ discard block |
||
6350 | 6646 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6351 | 6647 | $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 |
6352 | 6648 | ORDER BY airport_arrival_icao_count DESC"; |
6353 | - if ($limit) $query .= " LIMIT 10"; |
|
6649 | + if ($limit) { |
|
6650 | + $query .= " LIMIT 10"; |
|
6651 | + } |
|
6354 | 6652 | |
6355 | 6653 | |
6356 | 6654 | $sth = $this->db->prepare($query); |
@@ -6371,7 +6669,9 @@ discard block |
||
6371 | 6669 | if ($icaoaskey) { |
6372 | 6670 | $icao = $row['arrival_airport_icao']; |
6373 | 6671 | $airport_array[$icao] = $temp_array; |
6374 | - } else $airport_array[] = $temp_array; |
|
6672 | + } else { |
|
6673 | + $airport_array[] = $temp_array; |
|
6674 | + } |
|
6375 | 6675 | } |
6376 | 6676 | |
6377 | 6677 | return $airport_array; |
@@ -6413,7 +6713,9 @@ discard block |
||
6413 | 6713 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6414 | 6714 | $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
6415 | 6715 | ORDER BY airport_arrival_icao_count DESC"; |
6416 | - if ($limit) $query .= " LIMIT 10"; |
|
6716 | + if ($limit) { |
|
6717 | + $query .= " LIMIT 10"; |
|
6718 | + } |
|
6417 | 6719 | |
6418 | 6720 | |
6419 | 6721 | $sth = $this->db->prepare($query); |
@@ -6433,7 +6735,9 @@ discard block |
||
6433 | 6735 | if ($icaoaskey) { |
6434 | 6736 | $icao = $row['arrival_airport_icao']; |
6435 | 6737 | $airport_array[$icao] = $temp_array; |
6436 | - } else $airport_array[] = $temp_array; |
|
6738 | + } else { |
|
6739 | + $airport_array[] = $temp_array; |
|
6740 | + } |
|
6437 | 6741 | } |
6438 | 6742 | |
6439 | 6743 | return $airport_array; |
@@ -6475,7 +6779,9 @@ discard block |
||
6475 | 6779 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6476 | 6780 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
6477 | 6781 | ORDER BY airport_arrival_icao_count DESC"; |
6478 | - if ($limit) $query .= " LIMIT 10"; |
|
6782 | + if ($limit) { |
|
6783 | + $query .= " LIMIT 10"; |
|
6784 | + } |
|
6479 | 6785 | |
6480 | 6786 | |
6481 | 6787 | $sth = $this->db->prepare($query); |
@@ -6496,7 +6802,9 @@ discard block |
||
6496 | 6802 | if ($icaoaskey) { |
6497 | 6803 | $icao = $row['arrival_airport_icao']; |
6498 | 6804 | $airport_array[$icao] = $temp_array; |
6499 | - } else $airport_array[] = $temp_array; |
|
6805 | + } else { |
|
6806 | + $airport_array[] = $temp_array; |
|
6807 | + } |
|
6500 | 6808 | } |
6501 | 6809 | |
6502 | 6810 | return $airport_array; |
@@ -6877,7 +7185,9 @@ discard block |
||
6877 | 7185 | date_default_timezone_set($globalTimezone); |
6878 | 7186 | $datetime = new DateTime($date); |
6879 | 7187 | $offset = $datetime->format('P'); |
6880 | - } else $offset = '+00:00'; |
|
7188 | + } else { |
|
7189 | + $offset = '+00:00'; |
|
7190 | + } |
|
6881 | 7191 | |
6882 | 7192 | if ($globalDBdriver == 'mysql') { |
6883 | 7193 | $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 |
@@ -6927,7 +7237,9 @@ discard block |
||
6927 | 7237 | date_default_timezone_set($globalTimezone); |
6928 | 7238 | $datetime = new DateTime($date); |
6929 | 7239 | $offset = $datetime->format('P'); |
6930 | - } else $offset = '+00:00'; |
|
7240 | + } else { |
|
7241 | + $offset = '+00:00'; |
|
7242 | + } |
|
6931 | 7243 | |
6932 | 7244 | if ($globalDBdriver == 'mysql') { |
6933 | 7245 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
@@ -7150,7 +7462,9 @@ discard block |
||
7150 | 7462 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA'"; |
7151 | 7463 | $query .= " GROUP BY spotter_output.arrival_airport_country |
7152 | 7464 | ORDER BY airport_arrival_country_count DESC"; |
7153 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7465 | + if ($limit) { |
|
7466 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7467 | + } |
|
7154 | 7468 | |
7155 | 7469 | |
7156 | 7470 | $sth = $this->db->prepare($query); |
@@ -7437,7 +7751,9 @@ discard block |
||
7437 | 7751 | date_default_timezone_set($globalTimezone); |
7438 | 7752 | $datetime = new DateTime($date); |
7439 | 7753 | $offset = $datetime->format('P'); |
7440 | - } else $offset = '+00:00'; |
|
7754 | + } else { |
|
7755 | + $offset = '+00:00'; |
|
7756 | + } |
|
7441 | 7757 | |
7442 | 7758 | if ($globalDBdriver == 'mysql') { |
7443 | 7759 | $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 |
@@ -7613,15 +7929,23 @@ discard block |
||
7613 | 7929 | $query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao |
7614 | 7930 | FROM spotter_output".$filter_query." spotter_output.ident <> '' "; |
7615 | 7931 | if ($olderthanmonths > 0) { |
7616 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
7617 | - else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
7932 | + if ($globalDBdriver == 'mysql') { |
|
7933 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
7934 | + } else { |
|
7935 | + $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
7936 | + } |
|
7618 | 7937 | } |
7619 | 7938 | if ($sincedate != '') { |
7620 | - if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'"; |
|
7621 | - else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
7939 | + if ($globalDBdriver == 'mysql') { |
|
7940 | + $query .= " AND spotter_output.date > '".$sincedate."'"; |
|
7941 | + } else { |
|
7942 | + $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
7943 | + } |
|
7622 | 7944 | } |
7623 | 7945 | $query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
7624 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7946 | + if ($limit) { |
|
7947 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7948 | + } |
|
7625 | 7949 | |
7626 | 7950 | $sth = $this->db->prepare($query); |
7627 | 7951 | $sth->execute(); |
@@ -7655,15 +7979,23 @@ discard block |
||
7655 | 7979 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name |
7656 | 7980 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao <> '' "; |
7657 | 7981 | if ($olderthanmonths > 0) { |
7658 | - if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
7659 | - else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
7982 | + if ($globalDBdriver == 'mysql') { |
|
7983 | + $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
7984 | + } else { |
|
7985 | + $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
7986 | + } |
|
7660 | 7987 | } |
7661 | 7988 | if ($sincedate != '') { |
7662 | - if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' "; |
|
7663 | - else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
7989 | + if ($globalDBdriver == 'mysql') { |
|
7990 | + $query .= "AND spotter_output.date > '".$sincedate."' "; |
|
7991 | + } else { |
|
7992 | + $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
7993 | + } |
|
7664 | 7994 | } |
7665 | 7995 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
7666 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7996 | + if ($limit) { |
|
7997 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7998 | + } |
|
7667 | 7999 | |
7668 | 8000 | $sth = $this->db->prepare($query); |
7669 | 8001 | $sth->execute(); |
@@ -7700,7 +8032,9 @@ discard block |
||
7700 | 8032 | date_default_timezone_set($globalTimezone); |
7701 | 8033 | $datetime = new DateTime(); |
7702 | 8034 | $offset = $datetime->format('P'); |
7703 | - } else $offset = '+00:00'; |
|
8035 | + } else { |
|
8036 | + $offset = '+00:00'; |
|
8037 | + } |
|
7704 | 8038 | |
7705 | 8039 | if ($globalDBdriver == 'mysql') { |
7706 | 8040 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7749,7 +8083,9 @@ discard block |
||
7749 | 8083 | date_default_timezone_set($globalTimezone); |
7750 | 8084 | $datetime = new DateTime(); |
7751 | 8085 | $offset = $datetime->format('P'); |
7752 | - } else $offset = '+00:00'; |
|
8086 | + } else { |
|
8087 | + $offset = '+00:00'; |
|
8088 | + } |
|
7753 | 8089 | $filter_query = $this->getFilter($filters,true,true); |
7754 | 8090 | if ($globalDBdriver == 'mysql') { |
7755 | 8091 | $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7798,7 +8134,9 @@ discard block |
||
7798 | 8134 | date_default_timezone_set($globalTimezone); |
7799 | 8135 | $datetime = new DateTime(); |
7800 | 8136 | $offset = $datetime->format('P'); |
7801 | - } else $offset = '+00:00'; |
|
8137 | + } else { |
|
8138 | + $offset = '+00:00'; |
|
8139 | + } |
|
7802 | 8140 | $filter_query = $this->getFilter($filters,true,true); |
7803 | 8141 | if ($globalDBdriver == 'mysql') { |
7804 | 8142 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7844,7 +8182,9 @@ discard block |
||
7844 | 8182 | date_default_timezone_set($globalTimezone); |
7845 | 8183 | $datetime = new DateTime(); |
7846 | 8184 | $offset = $datetime->format('P'); |
7847 | - } else $offset = '+00:00'; |
|
8185 | + } else { |
|
8186 | + $offset = '+00:00'; |
|
8187 | + } |
|
7848 | 8188 | $filter_query = $this->getFilter($filters,true,true); |
7849 | 8189 | if ($globalDBdriver == 'mysql') { |
7850 | 8190 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7892,7 +8232,9 @@ discard block |
||
7892 | 8232 | date_default_timezone_set($globalTimezone); |
7893 | 8233 | $datetime = new DateTime(); |
7894 | 8234 | $offset = $datetime->format('P'); |
7895 | - } else $offset = '+00:00'; |
|
8235 | + } else { |
|
8236 | + $offset = '+00:00'; |
|
8237 | + } |
|
7896 | 8238 | |
7897 | 8239 | if ($globalDBdriver == 'mysql') { |
7898 | 8240 | $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7940,7 +8282,9 @@ discard block |
||
7940 | 8282 | date_default_timezone_set($globalTimezone); |
7941 | 8283 | $datetime = new DateTime(); |
7942 | 8284 | $offset = $datetime->format('P'); |
7943 | - } else $offset = '+00:00'; |
|
8285 | + } else { |
|
8286 | + $offset = '+00:00'; |
|
8287 | + } |
|
7944 | 8288 | |
7945 | 8289 | if ($globalDBdriver == 'mysql') { |
7946 | 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(*) as date_count |
@@ -7987,7 +8331,9 @@ discard block |
||
7987 | 8331 | date_default_timezone_set($globalTimezone); |
7988 | 8332 | $datetime = new DateTime(); |
7989 | 8333 | $offset = $datetime->format('P'); |
7990 | - } else $offset = '+00:00'; |
|
8334 | + } else { |
|
8335 | + $offset = '+00:00'; |
|
8336 | + } |
|
7991 | 8337 | |
7992 | 8338 | if ($globalDBdriver == 'mysql') { |
7993 | 8339 | $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 |
@@ -8035,7 +8381,9 @@ discard block |
||
8035 | 8381 | date_default_timezone_set($globalTimezone); |
8036 | 8382 | $datetime = new DateTime(); |
8037 | 8383 | $offset = $datetime->format('P'); |
8038 | - } else $offset = '+00:00'; |
|
8384 | + } else { |
|
8385 | + $offset = '+00:00'; |
|
8386 | + } |
|
8039 | 8387 | $filter_query = $this->getFilter($filters,true,true); |
8040 | 8388 | if ($globalDBdriver == 'mysql') { |
8041 | 8389 | $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 |
@@ -8080,7 +8428,9 @@ discard block |
||
8080 | 8428 | date_default_timezone_set($globalTimezone); |
8081 | 8429 | $datetime = new DateTime(); |
8082 | 8430 | $offset = $datetime->format('P'); |
8083 | - } else $offset = '+00:00'; |
|
8431 | + } else { |
|
8432 | + $offset = '+00:00'; |
|
8433 | + } |
|
8084 | 8434 | $filter_query = $this->getFilter($filters,true,true); |
8085 | 8435 | |
8086 | 8436 | if ($globalDBdriver == 'mysql') { |
@@ -8127,7 +8477,9 @@ discard block |
||
8127 | 8477 | date_default_timezone_set($globalTimezone); |
8128 | 8478 | $datetime = new DateTime(); |
8129 | 8479 | $offset = $datetime->format('P'); |
8130 | - } else $offset = '+00:00'; |
|
8480 | + } else { |
|
8481 | + $offset = '+00:00'; |
|
8482 | + } |
|
8131 | 8483 | |
8132 | 8484 | if ($globalDBdriver == 'mysql') { |
8133 | 8485 | $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 |
@@ -8173,7 +8525,9 @@ discard block |
||
8173 | 8525 | date_default_timezone_set($globalTimezone); |
8174 | 8526 | $datetime = new DateTime(); |
8175 | 8527 | $offset = $datetime->format('P'); |
8176 | - } else $offset = '+00:00'; |
|
8528 | + } else { |
|
8529 | + $offset = '+00:00'; |
|
8530 | + } |
|
8177 | 8531 | $filter_query = $this->getFilter($filters,true,true); |
8178 | 8532 | |
8179 | 8533 | if ($globalDBdriver == 'mysql') { |
@@ -8220,7 +8574,9 @@ discard block |
||
8220 | 8574 | date_default_timezone_set($globalTimezone); |
8221 | 8575 | $datetime = new DateTime(); |
8222 | 8576 | $offset = $datetime->format('P'); |
8223 | - } else $offset = '+00:00'; |
|
8577 | + } else { |
|
8578 | + $offset = '+00:00'; |
|
8579 | + } |
|
8224 | 8580 | |
8225 | 8581 | if ($globalDBdriver == 'mysql') { |
8226 | 8582 | $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 |
@@ -8267,7 +8623,9 @@ discard block |
||
8267 | 8623 | date_default_timezone_set($globalTimezone); |
8268 | 8624 | $datetime = new DateTime(); |
8269 | 8625 | $offset = $datetime->format('P'); |
8270 | - } else $offset = '+00:00'; |
|
8626 | + } else { |
|
8627 | + $offset = '+00:00'; |
|
8628 | + } |
|
8271 | 8629 | |
8272 | 8630 | if ($globalDBdriver == 'mysql') { |
8273 | 8631 | $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 |
@@ -8312,7 +8670,9 @@ discard block |
||
8312 | 8670 | date_default_timezone_set($globalTimezone); |
8313 | 8671 | $datetime = new DateTime(); |
8314 | 8672 | $offset = $datetime->format('P'); |
8315 | - } else $offset = '+00:00'; |
|
8673 | + } else { |
|
8674 | + $offset = '+00:00'; |
|
8675 | + } |
|
8316 | 8676 | $filter_query = $this->getFilter($filters,true,true); |
8317 | 8677 | |
8318 | 8678 | if ($globalDBdriver == 'mysql') { |
@@ -8360,7 +8720,9 @@ discard block |
||
8360 | 8720 | date_default_timezone_set($globalTimezone); |
8361 | 8721 | $datetime = new DateTime(); |
8362 | 8722 | $offset = $datetime->format('P'); |
8363 | - } else $offset = '+00:00'; |
|
8723 | + } else { |
|
8724 | + $offset = '+00:00'; |
|
8725 | + } |
|
8364 | 8726 | |
8365 | 8727 | if ($globalDBdriver == 'mysql') { |
8366 | 8728 | $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 |
@@ -8406,7 +8768,9 @@ discard block |
||
8406 | 8768 | date_default_timezone_set($globalTimezone); |
8407 | 8769 | $datetime = new DateTime(); |
8408 | 8770 | $offset = $datetime->format('P'); |
8409 | - } else $offset = '+00:00'; |
|
8771 | + } else { |
|
8772 | + $offset = '+00:00'; |
|
8773 | + } |
|
8410 | 8774 | $filter_query = $this->getFilter($filters,true,true); |
8411 | 8775 | |
8412 | 8776 | if ($globalDBdriver == 'mysql') { |
@@ -8454,7 +8818,9 @@ discard block |
||
8454 | 8818 | date_default_timezone_set($globalTimezone); |
8455 | 8819 | $datetime = new DateTime(); |
8456 | 8820 | $offset = $datetime->format('P'); |
8457 | - } else $offset = '+00:00'; |
|
8821 | + } else { |
|
8822 | + $offset = '+00:00'; |
|
8823 | + } |
|
8458 | 8824 | |
8459 | 8825 | if ($globalDBdriver == 'mysql') { |
8460 | 8826 | $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 |
@@ -8501,7 +8867,9 @@ discard block |
||
8501 | 8867 | date_default_timezone_set($globalTimezone); |
8502 | 8868 | $datetime = new DateTime(); |
8503 | 8869 | $offset = $datetime->format('P'); |
8504 | - } else $offset = '+00:00'; |
|
8870 | + } else { |
|
8871 | + $offset = '+00:00'; |
|
8872 | + } |
|
8505 | 8873 | $filter_query = $this->getFilter($filters,true,true); |
8506 | 8874 | if ($globalDBdriver == 'mysql') { |
8507 | 8875 | $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 |
@@ -8550,7 +8918,9 @@ discard block |
||
8550 | 8918 | date_default_timezone_set($globalTimezone); |
8551 | 8919 | $datetime = new DateTime(); |
8552 | 8920 | $offset = $datetime->format('P'); |
8553 | - } else $offset = '+00:00'; |
|
8921 | + } else { |
|
8922 | + $offset = '+00:00'; |
|
8923 | + } |
|
8554 | 8924 | |
8555 | 8925 | $orderby_sql = ''; |
8556 | 8926 | if ($orderby == "hour") |
@@ -8616,7 +8986,9 @@ discard block |
||
8616 | 8986 | date_default_timezone_set($globalTimezone); |
8617 | 8987 | $datetime = new DateTime(); |
8618 | 8988 | $offset = $datetime->format('P'); |
8619 | - } else $offset = '+00:00'; |
|
8989 | + } else { |
|
8990 | + $offset = '+00:00'; |
|
8991 | + } |
|
8620 | 8992 | |
8621 | 8993 | $orderby_sql = ''; |
8622 | 8994 | if ($orderby == "hour") |
@@ -8683,7 +9055,9 @@ discard block |
||
8683 | 9055 | date_default_timezone_set($globalTimezone); |
8684 | 9056 | $datetime = new DateTime(); |
8685 | 9057 | $offset = $datetime->format('P'); |
8686 | - } else $offset = '+00:00'; |
|
9058 | + } else { |
|
9059 | + $offset = '+00:00'; |
|
9060 | + } |
|
8687 | 9061 | |
8688 | 9062 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
8689 | 9063 | |
@@ -8734,7 +9108,9 @@ discard block |
||
8734 | 9108 | date_default_timezone_set($globalTimezone); |
8735 | 9109 | $datetime = new DateTime(); |
8736 | 9110 | $offset = $datetime->format('P'); |
8737 | - } else $offset = '+00:00'; |
|
9111 | + } else { |
|
9112 | + $offset = '+00:00'; |
|
9113 | + } |
|
8738 | 9114 | |
8739 | 9115 | if ($globalDBdriver == 'mysql') { |
8740 | 9116 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -8781,7 +9157,9 @@ discard block |
||
8781 | 9157 | date_default_timezone_set($globalTimezone); |
8782 | 9158 | $datetime = new DateTime(); |
8783 | 9159 | $offset = $datetime->format('P'); |
8784 | - } else $offset = '+00:00'; |
|
9160 | + } else { |
|
9161 | + $offset = '+00:00'; |
|
9162 | + } |
|
8785 | 9163 | |
8786 | 9164 | if ($globalDBdriver == 'mysql') { |
8787 | 9165 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -8828,7 +9206,9 @@ discard block |
||
8828 | 9206 | date_default_timezone_set($globalTimezone); |
8829 | 9207 | $datetime = new DateTime(); |
8830 | 9208 | $offset = $datetime->format('P'); |
8831 | - } else $offset = '+00:00'; |
|
9209 | + } else { |
|
9210 | + $offset = '+00:00'; |
|
9211 | + } |
|
8832 | 9212 | |
8833 | 9213 | if ($globalDBdriver == 'mysql') { |
8834 | 9214 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -8876,7 +9256,9 @@ discard block |
||
8876 | 9256 | date_default_timezone_set($globalTimezone); |
8877 | 9257 | $datetime = new DateTime(); |
8878 | 9258 | $offset = $datetime->format('P'); |
8879 | - } else $offset = '+00:00'; |
|
9259 | + } else { |
|
9260 | + $offset = '+00:00'; |
|
9261 | + } |
|
8880 | 9262 | |
8881 | 9263 | if ($globalDBdriver == 'mysql') { |
8882 | 9264 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -8924,7 +9306,9 @@ discard block |
||
8924 | 9306 | date_default_timezone_set($globalTimezone); |
8925 | 9307 | $datetime = new DateTime($date); |
8926 | 9308 | $offset = $datetime->format('P'); |
8927 | - } else $offset = '+00:00'; |
|
9309 | + } else { |
|
9310 | + $offset = '+00:00'; |
|
9311 | + } |
|
8928 | 9312 | |
8929 | 9313 | if ($globalDBdriver == 'mysql') { |
8930 | 9314 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -8972,7 +9356,9 @@ discard block |
||
8972 | 9356 | date_default_timezone_set($globalTimezone); |
8973 | 9357 | $datetime = new DateTime(); |
8974 | 9358 | $offset = $datetime->format('P'); |
8975 | - } else $offset = '+00:00'; |
|
9359 | + } else { |
|
9360 | + $offset = '+00:00'; |
|
9361 | + } |
|
8976 | 9362 | |
8977 | 9363 | if ($globalDBdriver == 'mysql') { |
8978 | 9364 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -9022,7 +9408,9 @@ discard block |
||
9022 | 9408 | date_default_timezone_set($globalTimezone); |
9023 | 9409 | $datetime = new DateTime(); |
9024 | 9410 | $offset = $datetime->format('P'); |
9025 | - } else $offset = '+00:00'; |
|
9411 | + } else { |
|
9412 | + $offset = '+00:00'; |
|
9413 | + } |
|
9026 | 9414 | |
9027 | 9415 | if ($globalDBdriver == 'mysql') { |
9028 | 9416 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -9069,7 +9457,9 @@ discard block |
||
9069 | 9457 | date_default_timezone_set($globalTimezone); |
9070 | 9458 | $datetime = new DateTime(); |
9071 | 9459 | $offset = $datetime->format('P'); |
9072 | - } else $offset = '+00:00'; |
|
9460 | + } else { |
|
9461 | + $offset = '+00:00'; |
|
9462 | + } |
|
9073 | 9463 | |
9074 | 9464 | if ($globalDBdriver == 'mysql') { |
9075 | 9465 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -9237,7 +9627,9 @@ discard block |
||
9237 | 9627 | date_default_timezone_set($globalTimezone); |
9238 | 9628 | $datetime = new DateTime(); |
9239 | 9629 | $offset = $datetime->format('P'); |
9240 | - } else $offset = '+00:00'; |
|
9630 | + } else { |
|
9631 | + $offset = '+00:00'; |
|
9632 | + } |
|
9241 | 9633 | |
9242 | 9634 | if ($globalDBdriver == 'mysql') { |
9243 | 9635 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -9423,7 +9815,9 @@ discard block |
||
9423 | 9815 | */ |
9424 | 9816 | public function parseDirection($direction = 0) |
9425 | 9817 | { |
9426 | - if ($direction == '') $direction = 0; |
|
9818 | + if ($direction == '') { |
|
9819 | + $direction = 0; |
|
9820 | + } |
|
9427 | 9821 | $direction_array = array(); |
9428 | 9822 | $temp_array = array(); |
9429 | 9823 | |
@@ -9524,7 +9918,9 @@ discard block |
||
9524 | 9918 | if (isset($result->AirlineFlightInfoResult)) |
9525 | 9919 | { |
9526 | 9920 | $registration = $result->AirlineFlightInfoResult->tailnumber; |
9527 | - } else return ''; |
|
9921 | + } else { |
|
9922 | + return ''; |
|
9923 | + } |
|
9528 | 9924 | |
9529 | 9925 | $registration = $this->convertAircraftRegistration($registration); |
9530 | 9926 | |
@@ -9553,7 +9949,9 @@ discard block |
||
9553 | 9949 | if (count($row) > 0) { |
9554 | 9950 | //return $row['Registration']; |
9555 | 9951 | return $row['registration']; |
9556 | - } else return ''; |
|
9952 | + } else { |
|
9953 | + return ''; |
|
9954 | + } |
|
9557 | 9955 | |
9558 | 9956 | } |
9559 | 9957 | |
@@ -9576,9 +9974,14 @@ discard block |
||
9576 | 9974 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
9577 | 9975 | $sth->closeCursor(); |
9578 | 9976 | if (count($row) > 0) { |
9579 | - if ($row['type_flight'] == null) return ''; |
|
9580 | - else return $row['type_flight']; |
|
9581 | - } else return ''; |
|
9977 | + if ($row['type_flight'] == null) { |
|
9978 | + return ''; |
|
9979 | + } else { |
|
9980 | + return $row['type_flight']; |
|
9981 | + } |
|
9982 | + } else { |
|
9983 | + return ''; |
|
9984 | + } |
|
9582 | 9985 | |
9583 | 9986 | } |
9584 | 9987 | |
@@ -9596,7 +9999,9 @@ discard block |
||
9596 | 9999 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
9597 | 10000 | |
9598 | 10001 | $Connection = new Connection($this->db); |
9599 | - if (!$Connection->tableExists('countries')) return ''; |
|
10002 | + if (!$Connection->tableExists('countries')) { |
|
10003 | + return ''; |
|
10004 | + } |
|
9600 | 10005 | |
9601 | 10006 | try { |
9602 | 10007 | /* |
@@ -9616,9 +10021,13 @@ discard block |
||
9616 | 10021 | $sth->closeCursor(); |
9617 | 10022 | if (count($row) > 0) { |
9618 | 10023 | return $row; |
9619 | - } else return ''; |
|
10024 | + } else { |
|
10025 | + return ''; |
|
10026 | + } |
|
9620 | 10027 | } catch (PDOException $e) { |
9621 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
10028 | + if (isset($globalDebug) && $globalDebug) { |
|
10029 | + echo 'Error : '.$e->getMessage()."\n"; |
|
10030 | + } |
|
9622 | 10031 | return ''; |
9623 | 10032 | } |
9624 | 10033 | |
@@ -9766,7 +10175,9 @@ discard block |
||
9766 | 10175 | { |
9767 | 10176 | global $globalBitlyAccessToken; |
9768 | 10177 | |
9769 | - if ($globalBitlyAccessToken == '') return $url; |
|
10178 | + if ($globalBitlyAccessToken == '') { |
|
10179 | + return $url; |
|
10180 | + } |
|
9770 | 10181 | |
9771 | 10182 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
9772 | 10183 | |
@@ -9915,7 +10326,9 @@ discard block |
||
9915 | 10326 | |
9916 | 10327 | |
9917 | 10328 | // routes |
9918 | - if ($globalDebug) print "Routes...\n"; |
|
10329 | + if ($globalDebug) { |
|
10330 | + print "Routes...\n"; |
|
10331 | + } |
|
9919 | 10332 | if ($globalDBdriver == 'mysql') { |
9920 | 10333 | $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)"; |
9921 | 10334 | } else { |
@@ -9934,7 +10347,9 @@ discard block |
||
9934 | 10347 | } |
9935 | 10348 | } |
9936 | 10349 | |
9937 | - if ($globalDebug) print "Airlines...\n"; |
|
10350 | + if ($globalDebug) { |
|
10351 | + print "Airlines...\n"; |
|
10352 | + } |
|
9938 | 10353 | //airlines |
9939 | 10354 | if ($globalDBdriver == 'mysql') { |
9940 | 10355 | $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)"; |
@@ -9948,10 +10363,15 @@ discard block |
||
9948 | 10363 | if (is_numeric(substr($row['ident'], -1, 1))) |
9949 | 10364 | { |
9950 | 10365 | $fromsource = NULL; |
9951 | - if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
9952 | - elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
9953 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
9954 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
10366 | + if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') { |
|
10367 | + $fromsource = 'vatsim'; |
|
10368 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') { |
|
10369 | + $fromsource = 'ivao'; |
|
10370 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
10371 | + $fromsource = 'vatsim'; |
|
10372 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
10373 | + $fromsource = 'ivao'; |
|
10374 | + } |
|
9955 | 10375 | $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
9956 | 10376 | if (isset($airline_array[0]['name'])) { |
9957 | 10377 | $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"; |
@@ -9961,13 +10381,17 @@ discard block |
||
9961 | 10381 | } |
9962 | 10382 | } |
9963 | 10383 | |
9964 | - if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n"; |
|
10384 | + if ($globalDebug) { |
|
10385 | + print "Remove Duplicate in aircraft_modes...\n"; |
|
10386 | + } |
|
9965 | 10387 | //duplicate modes |
9966 | 10388 | $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"; |
9967 | 10389 | $sth = $this->db->prepare($query); |
9968 | 10390 | $sth->execute(); |
9969 | 10391 | |
9970 | - if ($globalDebug) print "Aircraft...\n"; |
|
10392 | + if ($globalDebug) { |
|
10393 | + print "Aircraft...\n"; |
|
10394 | + } |
|
9971 | 10395 | //aircraft |
9972 | 10396 | if ($globalDBdriver == 'mysql') { |
9973 | 10397 | $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)"; |
@@ -10010,26 +10434,38 @@ discard block |
||
10010 | 10434 | if (isset($closestAirports[0])) { |
10011 | 10435 | if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) { |
10012 | 10436 | $airport_icao = $closestAirports[0]['icao']; |
10013 | - if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
10437 | + if ($globalDebug) { |
|
10438 | + echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
10439 | + } |
|
10014 | 10440 | } elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') { |
10015 | 10441 | foreach ($closestAirports as $airport) { |
10016 | 10442 | if ($row['arrival_airport_icao'] == $airport['icao']) { |
10017 | 10443 | $airport_icao = $airport['icao']; |
10018 | - if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
10444 | + if ($globalDebug) { |
|
10445 | + echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
10446 | + } |
|
10019 | 10447 | break; |
10020 | 10448 | } |
10021 | 10449 | } |
10022 | 10450 | } elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) { |
10023 | 10451 | $airport_icao = $closestAirports[0]['icao']; |
10024 | - 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"; |
|
10452 | + if ($globalDebug) { |
|
10453 | + 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"; |
|
10454 | + } |
|
10025 | 10455 | } else { |
10026 | - 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"; |
|
10456 | + if ($globalDebug) { |
|
10457 | + 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"; |
|
10458 | + } |
|
10027 | 10459 | } |
10028 | 10460 | } else { |
10029 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
10461 | + if ($globalDebug) { |
|
10462 | + echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
10463 | + } |
|
10030 | 10464 | } |
10031 | 10465 | if ($row['real_arrival_airport_icao'] != $airport_icao) { |
10032 | - if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n"; |
|
10466 | + if ($globalDebug) { |
|
10467 | + echo "Updating airport to ".$airport_icao."...\n"; |
|
10468 | + } |
|
10033 | 10469 | $update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id"; |
10034 | 10470 | $sthu = $this->db->prepare($update_query); |
10035 | 10471 | $sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id'])); |
@@ -26,8 +26,12 @@ discard block |
||
26 | 26 | } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
27 | 27 | $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date']." 00:00:00"; |
28 | 28 | $sql_date = $end_date; |
29 | - } else $sql_date = ''; |
|
30 | -} else $sql_date = ''; |
|
29 | + } else { |
|
30 | + $sql_date = ''; |
|
31 | + } |
|
32 | + } else { |
|
33 | + $sql_date = ''; |
|
34 | +} |
|
31 | 35 | |
32 | 36 | if (isset($_GET['highest_altitude'])) { |
33 | 37 | //for altitude manipulation |
@@ -41,8 +45,12 @@ discard block |
||
41 | 45 | } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
42 | 46 | $start_altitude = $_GET['lowest_altitude'].",60000"; |
43 | 47 | $sql_altitude = $start_altitude; |
44 | - } else $sql_altitude = ''; |
|
45 | -} else $sql_altitude = ''; |
|
48 | + } else { |
|
49 | + $sql_altitude = ''; |
|
50 | + } |
|
51 | + } else { |
|
52 | + $sql_altitude = ''; |
|
53 | +} |
|
46 | 54 | |
47 | 55 | //calculuation for the pagination |
48 | 56 | if(!isset($_GET['limit'])) |
@@ -60,7 +68,7 @@ discard block |
||
60 | 68 | $limit_end = $_GET['number_results']; |
61 | 69 | $absolute_difference = $_GET['number_results']; |
62 | 70 | } |
63 | -} else { |
|
71 | +} else { |
|
64 | 72 | $limit_explode = explode(",", $_GET['limit']); |
65 | 73 | $limit_start = $limit_explode[0]; |
66 | 74 | $limit_end = $limit_explode[1]; |
@@ -93,10 +101,15 @@ discard block |
||
93 | 101 | $origlon = filter_input(INPUT_GET,'origlon',FILTER_SANITIZE_STRING); |
94 | 102 | $dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT); |
95 | 103 | if ($dist != '') { |
96 | - if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934; |
|
97 | - elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852; |
|
104 | + if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') { |
|
105 | + $dist = $dist*1.60934; |
|
106 | + } elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') { |
|
107 | + $dist = $dist*1.852; |
|
108 | + } |
|
109 | + } |
|
110 | + if (!isset($sql_date)) { |
|
111 | + $sql_date = ''; |
|
98 | 112 | } |
99 | - if (!isset($sql_date)) $sql_date = ''; |
|
100 | 113 | if ($archive == 1) { |
101 | 114 | $SpotterArchive = new SpotterArchive(); |
102 | 115 | $spotter_array = $SpotterArchive->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist); |
@@ -164,7 +177,10 @@ discard block |
||
164 | 177 | if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$_GET['aircraft'].'</span> '; } |
165 | 178 | if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$_GET['manufacturer'].'</span> '; } |
166 | 179 | if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$_GET['registration'].'</span> '; } |
167 | - if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$_GET['highlights'].'</span> '; } |
|
180 | + if (isset($_GET['highlights'])) { |
|
181 | + if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$_GET['highlights'].'</span> '; |
|
182 | + } |
|
183 | + } |
|
168 | 184 | if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$_GET['airline'].'</span> '; } |
169 | 185 | if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$_GET['airline_country'].'</span> '; } |
170 | 186 | if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$_GET['airline_type'].'</span> '; } |
@@ -275,7 +291,10 @@ discard block |
||
275 | 291 | <div class="form-group"> |
276 | 292 | <label class="control-label col-sm-2"><?php echo _("Keywords"); ?></label> |
277 | 293 | <div class="col-sm-10"> |
278 | - <input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) print $_GET['q']; ?>" size="10" placeholder="<?php echo _("Keywords"); ?>" /> |
|
294 | + <input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) { |
|
295 | + print $_GET['q']; |
|
296 | +} |
|
297 | +?>" size="10" placeholder="<?php echo _("Keywords"); ?>" /> |
|
279 | 298 | </div> |
280 | 299 | </div> |
281 | 300 | </fieldset> |
@@ -290,7 +309,10 @@ discard block |
||
290 | 309 | </select> |
291 | 310 | </div> |
292 | 311 | </div> |
293 | - <script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $_GET['manufacturer']; ?>')</script> |
|
312 | + <script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) { |
|
313 | + print $_GET['manufacturer']; |
|
314 | +} |
|
315 | +?>')</script> |
|
294 | 316 | <div class="form-group"> |
295 | 317 | <label class="control-label col-sm-2"><?php echo _("Type"); ?></label> |
296 | 318 | <div class="col-sm-10"> |
@@ -299,11 +321,17 @@ discard block |
||
299 | 321 | </select> |
300 | 322 | </div> |
301 | 323 | </div> |
302 | - <script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $_GET['aircraft_icao']; ?>');</script> |
|
324 | + <script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) { |
|
325 | + print $_GET['aircraft_icao']; |
|
326 | +} |
|
327 | +?>');</script> |
|
303 | 328 | <div class="form-group"> |
304 | 329 | <label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> |
305 | 330 | <div class="col-sm-10"> |
306 | - <input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) print $_GET['registration']; ?>" size="8" /> |
|
331 | + <input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) { |
|
332 | + print $_GET['registration']; |
|
333 | +} |
|
334 | +?>" size="8" /> |
|
307 | 335 | </div> |
308 | 336 | </div> |
309 | 337 | <?php |
@@ -312,22 +340,31 @@ discard block |
||
312 | 340 | <div class="form-group"> |
313 | 341 | <label class="control-label col-sm-2"><?php echo _("Pilot id"); ?></label> |
314 | 342 | <div class="col-sm-10"> |
315 | - <input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) print $_GET['pilot_id']; ?>" size="15" /> |
|
343 | + <input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) { |
|
344 | + print $_GET['pilot_id']; |
|
345 | +} |
|
346 | +?>" size="15" /> |
|
316 | 347 | </div> |
317 | 348 | </div> |
318 | 349 | <div class="form-group"> |
319 | 350 | <label class="control-label col-sm-2"><?php echo _("Pilot name"); ?></label> |
320 | 351 | <div class="col-sm-10"> |
321 | - <input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) print $_GET['pilot_name']; ?>" size="15" /> |
|
352 | + <input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) { |
|
353 | + print $_GET['pilot_name']; |
|
354 | +} |
|
355 | +?>" size="15" /> |
|
322 | 356 | </div> |
323 | 357 | </div> |
324 | 358 | <?php |
325 | -}else { |
|
359 | +} else { |
|
326 | 360 | ?> |
327 | 361 | <div class="form-group"> |
328 | 362 | <label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> |
329 | 363 | <div class="col-sm-10"> |
330 | - <input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) print $_GET['owner']; ?>" size="15" /> |
|
364 | + <input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) { |
|
365 | + print $_GET['owner']; |
|
366 | +} |
|
367 | +?>" size="15" /> |
|
331 | 368 | </div> |
332 | 369 | </div> |
333 | 370 | <?php |
@@ -335,8 +372,14 @@ discard block |
||
335 | 372 | ?> |
336 | 373 | <div class="form-group"> |
337 | 374 | <div class="col-sm-offset-2 col-sm-10"> |
338 | - <!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>--> |
|
339 | - <label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label> |
|
375 | + <!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) { |
|
376 | + if ($_GET['highlights'] == "true"){ print 'checked="checked"'; |
|
377 | +} |
|
378 | +} ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>--> |
|
379 | + <label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) { |
|
380 | + if ($_GET['highlights'] == "true"){ print 'checked="checked"'; |
|
381 | +} |
|
382 | +} ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label> |
|
340 | 383 | </div> |
341 | 384 | </div> |
342 | 385 | </fieldset> |
@@ -350,7 +393,10 @@ discard block |
||
350 | 393 | </select> |
351 | 394 | </div> |
352 | 395 | </div> |
353 | - <script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $_GET['airline']; ?>');</script> |
|
396 | + <script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) { |
|
397 | + print $_GET['airline']; |
|
398 | +} |
|
399 | +?>');</script> |
|
354 | 400 | <div class="form-group"> |
355 | 401 | <label class="control-label col-sm-2"><?php echo _("Country"); ?></label> |
356 | 402 | <div class="col-sm-10"> |
@@ -359,19 +405,34 @@ discard block |
||
359 | 405 | </select> |
360 | 406 | </div> |
361 | 407 | </div> |
362 | - <script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $_GET['airline_country']; ?>');</script> |
|
408 | + <script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) { |
|
409 | + print $_GET['airline_country']; |
|
410 | +} |
|
411 | +?>');</script> |
|
363 | 412 | <div class="form-group"> |
364 | 413 | <label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> |
365 | 414 | <div class="col-sm-10"> |
366 | - <input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $_GET['callsign']; ?>" size="8" /> |
|
415 | + <input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) { |
|
416 | + print $_GET['callsign']; |
|
417 | +} |
|
418 | +?>" size="8" /> |
|
367 | 419 | </div> |
368 | 420 | </div> |
369 | 421 | <div class="form-group"> |
370 | 422 | <div class="col-sm-offset-2 col-sm-10"> |
371 | 423 | <label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label> |
372 | - <label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label> |
|
373 | - <label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label> |
|
374 | - <label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label> |
|
424 | + <label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) { |
|
425 | + if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; |
|
426 | +} |
|
427 | +} ?>> <?php echo _("Only Passenger airlines"); ?></label> |
|
428 | + <label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) { |
|
429 | + if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; |
|
430 | +} |
|
431 | +} ?>> <?php echo _("Only Cargo airlines"); ?></label> |
|
432 | + <label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) { |
|
433 | + if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; |
|
434 | +} |
|
435 | +} ?>> <?php echo _("Only Military airlines"); ?></label> |
|
375 | 436 | </div> |
376 | 437 | </div> |
377 | 438 | </fieldset> |
@@ -385,7 +446,10 @@ discard block |
||
385 | 446 | </select> |
386 | 447 | </div> |
387 | 448 | </div> |
388 | - <script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $_GET['airport_icao']; ?>');</script> |
|
449 | + <script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) { |
|
450 | + print $_GET['airport_icao']; |
|
451 | +} |
|
452 | +?>');</script> |
|
389 | 453 | <div class="form-group"> |
390 | 454 | <label class="control-label col-sm-2"><?php echo _("Country"); ?></label> |
391 | 455 | <div class="col-sm-10"> |
@@ -394,7 +458,10 @@ discard block |
||
394 | 458 | </select> |
395 | 459 | </div> |
396 | 460 | </div> |
397 | - <script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $_GET['airport_country']; ?>');</script> |
|
461 | + <script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) { |
|
462 | + print $_GET['airport_country']; |
|
463 | +} |
|
464 | +?>');</script> |
|
398 | 465 | </fieldset> |
399 | 466 | <fieldset> |
400 | 467 | <legend><?php echo _("Route"); ?></legend> |
@@ -406,7 +473,10 @@ discard block |
||
406 | 473 | </select> |
407 | 474 | </div> |
408 | 475 | </div> |
409 | - <script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $_GET['departure_airport_route']; ?>');</script> |
|
476 | + <script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) { |
|
477 | + print $_GET['departure_airport_route']; |
|
478 | +} |
|
479 | +?>');</script> |
|
410 | 480 | <div class="form-group"> |
411 | 481 | <label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> |
412 | 482 | <div class="col-sm-10"> |
@@ -415,7 +485,10 @@ discard block |
||
415 | 485 | </select> |
416 | 486 | </div> |
417 | 487 | </div> |
418 | - <script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $_GET['arrival_airport_route']; ?>');</script> |
|
488 | + <script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) { |
|
489 | + print $_GET['arrival_airport_route']; |
|
490 | +} |
|
491 | +?>');</script> |
|
419 | 492 | </fieldset> |
420 | 493 | <fieldset> |
421 | 494 | <legend><?php echo _("Date"); ?></legend> |
@@ -423,7 +496,10 @@ discard block |
||
423 | 496 | <label class="control-label col-sm-2"><?php echo _("Start Date"); ?></label> |
424 | 497 | <div class="col-sm-10"> |
425 | 498 | <div class='input-group date' id='datetimepicker1'> |
426 | - <input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date'])) print $_GET['start_date']; ?>" placeholder="<?php echo _("Start Date/Time"); ?>" /> |
|
499 | + <input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date'])) { |
|
500 | + print $_GET['start_date']; |
|
501 | +} |
|
502 | +?>" placeholder="<?php echo _("Start Date/Time"); ?>" /> |
|
427 | 503 | <span class="input-group-addon"> |
428 | 504 | <span class="glyphicon glyphicon-calendar"></span> |
429 | 505 | </span> |
@@ -434,7 +510,10 @@ discard block |
||
434 | 510 | <label class="control-label col-sm-2"><?php echo _("End Date"); ?></label> |
435 | 511 | <div class="col-sm-10"> |
436 | 512 | <div class='input-group date' id='datetimepicker2'> |
437 | - <input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date'])) print $_GET['end_date']; ?>" placeholder="<?php echo _("End Date/Time"); ?>" /> |
|
513 | + <input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date'])) { |
|
514 | + print $_GET['end_date']; |
|
515 | +} |
|
516 | +?>" placeholder="<?php echo _("End Date/Time"); ?>" /> |
|
438 | 517 | <span class="input-group-addon"> |
439 | 518 | <span class="glyphicon glyphicon-calendar"></span> |
440 | 519 | </span> |
@@ -517,7 +596,12 @@ discard block |
||
517 | 596 | </div> |
518 | 597 | </div> |
519 | 598 | <div class="form-group"> |
520 | - <label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) print $globalDistanceUnit; else print 'km'; print ')'; ?></label> |
|
599 | + <label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) { |
|
600 | + print $globalDistanceUnit; |
|
601 | +} else { |
|
602 | + print 'km'; |
|
603 | +} |
|
604 | +print ')'; ?></label> |
|
521 | 605 | <div class="col-sm-10"> |
522 | 606 | <input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" /> |
523 | 607 | </div> |
@@ -14,7 +14,9 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | |
17 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
17 | +if (!isset($globalDebug)) { |
|
18 | + $globalDebug = FALSE; |
|
19 | +} |
|
18 | 20 | |
19 | 21 | // Check if schema is at latest version |
20 | 22 | $Connection = new Connection(); |
@@ -54,13 +56,22 @@ discard block |
||
54 | 56 | $globalSources = array(); |
55 | 57 | $globalSources[] = array('host' => $options['source']); |
56 | 58 | } |
57 | -if (isset($options['server'])) $globalServer = TRUE; |
|
58 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
59 | -else $id_source = 1; |
|
59 | +if (isset($options['server'])) { |
|
60 | + $globalServer = TRUE; |
|
61 | +} |
|
62 | +if (isset($options['idsource'])) { |
|
63 | + $id_source = $options['idsource']; |
|
64 | +} else { |
|
65 | + $id_source = 1; |
|
66 | +} |
|
60 | 67 | if (isset($globalServer) && $globalServer) { |
61 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
68 | + if ($globalDebug) { |
|
69 | + echo "Using Server Mode\n"; |
|
70 | + } |
|
62 | 71 | $SI=new SpotterServer(); |
63 | -} else $SI=new SpotterImport($Connection->db); |
|
72 | +} else { |
|
73 | + $SI=new SpotterImport($Connection->db); |
|
74 | +} |
|
64 | 75 | //$APRS=new APRS($Connection->db); |
65 | 76 | $SBS=new SBS(); |
66 | 77 | $ACARS=new ACARS($Connection->db); |
@@ -78,7 +89,9 @@ discard block |
||
78 | 89 | } |
79 | 90 | |
80 | 91 | // let's try and connect |
81 | -if ($globalDebug) echo "Connecting...\n"; |
|
92 | +if ($globalDebug) { |
|
93 | + echo "Connecting...\n"; |
|
94 | +} |
|
82 | 95 | $use_aprs = false; |
83 | 96 | $aprs_full = false; |
84 | 97 | |
@@ -86,7 +99,9 @@ discard block |
||
86 | 99 | $ip = gethostbyname($host); |
87 | 100 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
88 | 101 | $r = @socket_connect($s, $ip, $port); |
89 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
102 | + if (!socket_set_nonblock($s)) { |
|
103 | + echo "Unable to set nonblock on socket\n"; |
|
104 | + } |
|
90 | 105 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
91 | 106 | return $s; |
92 | 107 | } |
@@ -113,7 +128,9 @@ discard block |
||
113 | 128 | function connect_all($hosts) { |
114 | 129 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
115 | 130 | global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
116 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
131 | + if ($globalDebug) { |
|
132 | + echo 'Connect to all...'."\n"; |
|
133 | + } |
|
117 | 134 | foreach ($hosts as $id => $value) { |
118 | 135 | $host = $value['host']; |
119 | 136 | $globalSources[$id]['last_exec'] = 0; |
@@ -123,27 +140,37 @@ discard block |
||
123 | 140 | //$formats[$id] = 'deltadbtxt'; |
124 | 141 | $globalSources[$id]['format'] = 'deltadbtxt'; |
125 | 142 | //$last_exec['deltadbtxt'] = 0; |
126 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
143 | + if ($globalDebug) { |
|
144 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
145 | + } |
|
127 | 146 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
128 | 147 | //$formats[$id] = 'vatsimtxt'; |
129 | 148 | $globalSources[$id]['format'] = 'vatsimtxt'; |
130 | 149 | //$last_exec['vatsimtxt'] = 0; |
131 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
150 | + if ($globalDebug) { |
|
151 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
152 | + } |
|
132 | 153 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
133 | 154 | //$formats[$id] = 'aircraftlistjson'; |
134 | 155 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
135 | 156 | //$last_exec['aircraftlistjson'] = 0; |
136 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
157 | + if ($globalDebug) { |
|
158 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
159 | + } |
|
137 | 160 | } else if (preg_match('/opensky/i',$host)) { |
138 | 161 | //$formats[$id] = 'aircraftlistjson'; |
139 | 162 | $globalSources[$id]['format'] = 'opensky'; |
140 | 163 | //$last_exec['aircraftlistjson'] = 0; |
141 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
164 | + if ($globalDebug) { |
|
165 | + echo "Connect to opensky source (".$host.")...\n"; |
|
166 | + } |
|
142 | 167 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
143 | 168 | //$formats[$id] = 'radarvirtueljson'; |
144 | 169 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
145 | 170 | //$last_exec['radarvirtueljson'] = 0; |
146 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
171 | + if ($globalDebug) { |
|
172 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
173 | + } |
|
147 | 174 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
148 | 175 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
149 | 176 | exit(0); |
@@ -152,7 +179,9 @@ discard block |
||
152 | 179 | //$formats[$id] = 'planeupdatefaa'; |
153 | 180 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
154 | 181 | //$last_exec['planeupdatefaa'] = 0; |
155 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
182 | + if ($globalDebug) { |
|
183 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
184 | + } |
|
156 | 185 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
157 | 186 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
158 | 187 | exit(0); |
@@ -161,26 +190,36 @@ discard block |
||
161 | 190 | //$formats[$id] = 'phpvmacars'; |
162 | 191 | $globalSources[$id]['format'] = 'phpvmacars'; |
163 | 192 | //$last_exec['phpvmacars'] = 0; |
164 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
195 | + } |
|
165 | 196 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
166 | 197 | //$formats[$id] = 'phpvmacars'; |
167 | 198 | $globalSources[$id]['format'] = 'vam'; |
168 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
199 | + if ($globalDebug) { |
|
200 | + echo "Connect to Vam source (".$host.")...\n"; |
|
201 | + } |
|
169 | 202 | } else if (preg_match('/whazzup/i',$host)) { |
170 | 203 | //$formats[$id] = 'whazzup'; |
171 | 204 | $globalSources[$id]['format'] = 'whazzup'; |
172 | 205 | //$last_exec['whazzup'] = 0; |
173 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
206 | + if ($globalDebug) { |
|
207 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
208 | + } |
|
174 | 209 | } else if (preg_match('/recentpireps/i',$host)) { |
175 | 210 | //$formats[$id] = 'pirepsjson'; |
176 | 211 | $globalSources[$id]['format'] = 'pirepsjson'; |
177 | 212 | //$last_exec['pirepsjson'] = 0; |
178 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
213 | + if ($globalDebug) { |
|
214 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
215 | + } |
|
179 | 216 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
180 | 217 | //$formats[$id] = 'fr24json'; |
181 | 218 | $globalSources[$id]['format'] = 'fr24json'; |
182 | 219 | //$last_exec['fr24json'] = 0; |
183 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
220 | + if ($globalDebug) { |
|
221 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
222 | + } |
|
184 | 223 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
185 | 224 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
186 | 225 | exit(0); |
@@ -189,10 +228,14 @@ discard block |
||
189 | 228 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
190 | 229 | //$formats[$id] = 'tsv'; |
191 | 230 | $globalSources[$id]['format'] = 'tsv'; |
192 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
231 | + if ($globalDebug) { |
|
232 | + echo "Connect to tsv source (".$host.")...\n"; |
|
233 | + } |
|
193 | 234 | } |
194 | 235 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
195 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
236 | + if ($globalDebug) { |
|
237 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
238 | + } |
|
196 | 239 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
197 | 240 | $hostport = explode(':',$host); |
198 | 241 | if (isset($hostport[1])) { |
@@ -229,17 +272,25 @@ discard block |
||
229 | 272 | //$formats[$id] = 'beast'; |
230 | 273 | $globalSources[$id]['format'] = 'beast'; |
231 | 274 | //} else $formats[$id] = 'sbs'; |
232 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
275 | + } else { |
|
276 | + $globalSources[$id]['format'] = 'sbs'; |
|
277 | + } |
|
233 | 278 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
234 | 279 | } |
235 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
280 | + if ($globalDebug) { |
|
281 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
282 | + } |
|
236 | 283 | } else { |
237 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
284 | + if ($globalDebug) { |
|
285 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
286 | + } |
|
238 | 287 | } |
239 | 288 | } |
240 | 289 | } |
241 | 290 | } |
242 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
291 | +if (!isset($globalMinFetch)) { |
|
292 | + $globalMinFetch = 15; |
|
293 | +} |
|
243 | 294 | |
244 | 295 | // Initialize all |
245 | 296 | $status = array(); |
@@ -247,13 +298,19 @@ discard block |
||
247 | 298 | $formats = array(); |
248 | 299 | $last_exec = array(); |
249 | 300 | $time = time(); |
250 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
251 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
252 | -else $timeout = 20; |
|
301 | +if (isset($globalSourcesTimeout)) { |
|
302 | + $timeout = $globalSourcesTimeOut; |
|
303 | +} else if (isset($globalSBS1TimeOut)) { |
|
304 | + $timeout = $globalSBS1TimeOut; |
|
305 | +} else { |
|
306 | + $timeout = 20; |
|
307 | +} |
|
253 | 308 | $errno = ''; |
254 | 309 | $errstr=''; |
255 | 310 | |
256 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
311 | +if (!isset($globalDaemon)) { |
|
312 | + $globalDaemon = TRUE; |
|
313 | +} |
|
257 | 314 | /* Initiate connections to all the hosts simultaneously */ |
258 | 315 | //connect_all($hosts); |
259 | 316 | //connect_all($globalSources); |
@@ -273,7 +330,9 @@ discard block |
||
273 | 330 | if (isset($source['format']) && $source['format'] == 'aprs') { |
274 | 331 | $aprs_connect = 0; |
275 | 332 | $use_aprs = true; |
276 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
333 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
334 | + $aprs_full = true; |
|
335 | + } |
|
277 | 336 | break; |
278 | 337 | } |
279 | 338 | } |
@@ -284,24 +343,44 @@ discard block |
||
284 | 343 | $aprs_connect = 0; |
285 | 344 | $aprs_keep = 120; |
286 | 345 | $aprs_last_tx = time(); |
287 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
288 | - else $aprs_version = $globalName.' using FlightAirMap'; |
|
346 | + if (isset($globalAPRSversion)) { |
|
347 | + $aprs_version = $globalAPRSversion; |
|
348 | + } else { |
|
349 | + $aprs_version = $globalName.' using FlightAirMap'; |
|
350 | + } |
|
289 | 351 | //else $aprs_version = 'Perl Example App'; |
290 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
291 | - else $aprs_ssid = 'FAM'; |
|
352 | + if (isset($globalAPRSssid)) { |
|
353 | + $aprs_ssid = $globalAPRSssid; |
|
354 | + } else { |
|
355 | + $aprs_ssid = 'FAM'; |
|
356 | + } |
|
292 | 357 | //else $aprs_ssid = 'PerlEx'; |
293 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
294 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
295 | - if ($aprs_full) $aprs_filter = ''; |
|
296 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
|
297 | - else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
|
298 | -} |
|
358 | + if (isset($globalAPRSfilter)) { |
|
359 | + $aprs_filter = $globalAPRSfilter; |
|
360 | + } else { |
|
361 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
362 | + } |
|
363 | + if ($aprs_full) { |
|
364 | + $aprs_filter = ''; |
|
365 | + } |
|
366 | + if ($aprs_filter != '') { |
|
367 | + $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
|
368 | + } else { |
|
369 | + $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
|
370 | + } |
|
371 | + } |
|
299 | 372 | |
300 | 373 | // connected - lets do some work |
301 | -if ($globalDebug) echo "Connected!\n"; |
|
374 | +if ($globalDebug) { |
|
375 | + echo "Connected!\n"; |
|
376 | +} |
|
302 | 377 | sleep(1); |
303 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
304 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
378 | +if ($globalDebug) { |
|
379 | + echo "SCAN MODE \n\n"; |
|
380 | +} |
|
381 | +if (!isset($globalCronEnd)) { |
|
382 | + $globalCronEnd = 60; |
|
383 | +} |
|
305 | 384 | $endtime = time()+$globalCronEnd; |
306 | 385 | $i = 1; |
307 | 386 | $tt = array(); |
@@ -315,20 +394,28 @@ discard block |
||
315 | 394 | |
316 | 395 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
317 | 396 | while ($i > 0) { |
318 | - if (!$globalDaemon) $i = $endtime-time(); |
|
397 | + if (!$globalDaemon) { |
|
398 | + $i = $endtime-time(); |
|
399 | + } |
|
319 | 400 | // Delete old ATC |
320 | 401 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
321 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
402 | + if ($globalDebug) { |
|
403 | + echo 'Delete old ATC...'."\n"; |
|
404 | + } |
|
322 | 405 | $ATC->deleteOldATC(); |
323 | 406 | } |
324 | 407 | |
325 | 408 | if (count($last_exec) > 0) { |
326 | 409 | $max = $globalMinFetch; |
327 | 410 | foreach ($last_exec as $last) { |
328 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
411 | + if ((time() - $last['last']) < $max) { |
|
412 | + $max = time() - $last['last']; |
|
413 | + } |
|
329 | 414 | } |
330 | 415 | if ($max != $globalMinFetch) { |
331 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
416 | + if ($globalDebug) { |
|
417 | + echo 'Sleeping...'."\n"; |
|
418 | + } |
|
332 | 419 | sleep($globalMinFetch-$max+2); |
333 | 420 | } |
334 | 421 | } |
@@ -336,7 +423,9 @@ discard block |
||
336 | 423 | |
337 | 424 | //foreach ($formats as $id => $value) { |
338 | 425 | foreach ($globalSources as $id => $value) { |
339 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
426 | + if (!isset($last_exec[$id]['last'])) { |
|
427 | + $last_exec[$id]['last'] = 0; |
|
428 | + } |
|
340 | 429 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
341 | 430 | //$buffer = $Common->getData($hosts[$id]); |
342 | 431 | $buffer = $Common->getData($value['host']); |
@@ -348,19 +437,38 @@ discard block |
||
348 | 437 | $data = array(); |
349 | 438 | $data['hex'] = $line[1]; // hex |
350 | 439 | $data['ident'] = $line[2]; // ident |
351 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
352 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
353 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
354 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
355 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
440 | + if (isset($line[3])) { |
|
441 | + $data['altitude'] = $line[3]; |
|
442 | + } |
|
443 | + // altitude |
|
444 | + if (isset($line[4])) { |
|
445 | + $data['speed'] = $line[4]; |
|
446 | + } |
|
447 | + // speed |
|
448 | + if (isset($line[5])) { |
|
449 | + $data['heading'] = $line[5]; |
|
450 | + } |
|
451 | + // heading |
|
452 | + if (isset($line[6])) { |
|
453 | + $data['latitude'] = $line[6]; |
|
454 | + } |
|
455 | + // lat |
|
456 | + if (isset($line[7])) { |
|
457 | + $data['longitude'] = $line[7]; |
|
458 | + } |
|
459 | + // long |
|
356 | 460 | $data['verticalrate'] = ''; // vertical rate |
357 | 461 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
358 | 462 | $data['emergency'] = ''; // emergency |
359 | 463 | $data['datetime'] = date('Y-m-d H:i:s'); |
360 | 464 | $data['format_source'] = 'deltadbtxt'; |
361 | 465 | $data['id_source'] = $id_source; |
362 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
363 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
466 | + if (isset($value['name']) && $value['name'] != '') { |
|
467 | + $data['source_name'] = $value['name']; |
|
468 | + } |
|
469 | + if (isset($value['sourcestats'])) { |
|
470 | + $data['sourcestats'] = $value['sourcestats']; |
|
471 | + } |
|
364 | 472 | $SI->add($data); |
365 | 473 | unset($data); |
366 | 474 | } |
@@ -382,10 +490,19 @@ discard block |
||
382 | 490 | $data['pilot_name'] = $line[2]; |
383 | 491 | $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
384 | 492 | $data['ident'] = $line[0]; // ident |
385 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
493 | + if ($line[7] != '' && $line[7] != 0) { |
|
494 | + $data['altitude'] = $line[7]; |
|
495 | + } |
|
496 | + // altitude |
|
386 | 497 | $data['speed'] = $line[8]; // speed |
387 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
388 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
498 | + if (isset($line[45])) { |
|
499 | + $data['heading'] = $line[45]; |
|
500 | + } |
|
501 | + // heading |
|
502 | + elseif (isset($line[38])) { |
|
503 | + $data['heading'] = $line[38]; |
|
504 | + } |
|
505 | + // heading |
|
389 | 506 | $data['latitude'] = $line[5]; // lat |
390 | 507 | $data['longitude'] = $line[6]; // long |
391 | 508 | $data['verticalrate'] = ''; // vertical rate |
@@ -394,14 +511,18 @@ discard block |
||
394 | 511 | $data['waypoints'] = $line[30]; |
395 | 512 | $data['datetime'] = date('Y-m-d H:i:s'); |
396 | 513 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
397 | - if (isset($line[37])) $data['last_update'] = $line[37]; |
|
514 | + if (isset($line[37])) { |
|
515 | + $data['last_update'] = $line[37]; |
|
516 | + } |
|
398 | 517 | $data['departure_airport_icao'] = $line[11]; |
399 | 518 | $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
400 | 519 | $data['arrival_airport_icao'] = $line[13]; |
401 | 520 | $data['frequency'] = $line[4]; |
402 | 521 | $data['type'] = $line[18]; |
403 | 522 | $data['range'] = $line[19]; |
404 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
523 | + if (isset($line[35])) { |
|
524 | + $data['info'] = $line[35]; |
|
525 | + } |
|
405 | 526 | $data['id_source'] = $id_source; |
406 | 527 | //$data['arrival_airport_time'] = ; |
407 | 528 | if ($line[9] != '') { |
@@ -415,23 +536,38 @@ discard block |
||
415 | 536 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
416 | 537 | */ |
417 | 538 | $data['format_source'] = $value['format']; |
418 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
419 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
420 | - elseif ($line[3] == 'ATC') { |
|
539 | + if (isset($value['name']) && $value['name'] != '') { |
|
540 | + $data['source_name'] = $value['name']; |
|
541 | + } |
|
542 | + if ($line[3] == 'PILOT') { |
|
543 | + $SI->add($data); |
|
544 | + } elseif ($line[3] == 'ATC') { |
|
421 | 545 | //print_r($data); |
422 | 546 | $data['info'] = str_replace('^§','<br />',$data['info']); |
423 | 547 | $data['info'] = str_replace('&sect;','',$data['info']); |
424 | 548 | $typec = substr($data['ident'],-3); |
425 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
426 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
427 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
428 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
429 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
430 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
431 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
432 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
433 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
434 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
549 | + if ($typec == 'APP') { |
|
550 | + $data['type'] = 'Approach'; |
|
551 | + } elseif ($typec == 'TWR') { |
|
552 | + $data['type'] = 'Tower'; |
|
553 | + } elseif ($typec == 'OBS') { |
|
554 | + $data['type'] = 'Observer'; |
|
555 | + } elseif ($typec == 'GND') { |
|
556 | + $data['type'] = 'Ground'; |
|
557 | + } elseif ($typec == 'DEL') { |
|
558 | + $data['type'] = 'Delivery'; |
|
559 | + } elseif ($typec == 'DEP') { |
|
560 | + $data['type'] = 'Departure'; |
|
561 | + } elseif ($typec == 'FSS') { |
|
562 | + $data['type'] = 'Flight Service Station'; |
|
563 | + } elseif ($typec == 'CTR') { |
|
564 | + $data['type'] = 'Control Radar or Centre'; |
|
565 | + } elseif ($data['type'] == '') { |
|
566 | + $data['type'] = 'Observer'; |
|
567 | + } |
|
568 | + if (!isset($data['source_name'])) { |
|
569 | + $data['source_name'] = ''; |
|
570 | + } |
|
435 | 571 | echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
436 | 572 | } |
437 | 573 | unset($data); |
@@ -450,26 +586,55 @@ discard block |
||
450 | 586 | foreach ($all_data['acList'] as $line) { |
451 | 587 | $data = array(); |
452 | 588 | $data['hex'] = $line['Icao']; // hex |
453 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
454 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
455 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
456 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
457 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
458 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
589 | + if (isset($line['Call'])) { |
|
590 | + $data['ident'] = $line['Call']; |
|
591 | + } |
|
592 | + // ident |
|
593 | + if (isset($line['Alt'])) { |
|
594 | + $data['altitude'] = $line['Alt']; |
|
595 | + } |
|
596 | + // altitude |
|
597 | + if (isset($line['Spd'])) { |
|
598 | + $data['speed'] = $line['Spd']; |
|
599 | + } |
|
600 | + // speed |
|
601 | + if (isset($line['Trak'])) { |
|
602 | + $data['heading'] = $line['Trak']; |
|
603 | + } |
|
604 | + // heading |
|
605 | + if (isset($line['Lat'])) { |
|
606 | + $data['latitude'] = $line['Lat']; |
|
607 | + } |
|
608 | + // lat |
|
609 | + if (isset($line['Long'])) { |
|
610 | + $data['longitude'] = $line['Long']; |
|
611 | + } |
|
612 | + // long |
|
459 | 613 | //$data['verticalrate'] = $line['']; // verticale rate |
460 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
614 | + if (isset($line['Sqk'])) { |
|
615 | + $data['squawk'] = $line['Sqk']; |
|
616 | + } |
|
617 | + // squawk |
|
461 | 618 | $data['emergency'] = ''; // emergency |
462 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
619 | + if (isset($line['Reg'])) { |
|
620 | + $data['registration'] = $line['Reg']; |
|
621 | + } |
|
463 | 622 | /* |
464 | 623 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
465 | 624 | else $data['datetime'] = date('Y-m-d H:i:s'); |
466 | 625 | */ |
467 | 626 | $data['datetime'] = date('Y-m-d H:i:s'); |
468 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
627 | + if (isset($line['Type'])) { |
|
628 | + $data['aircraft_icao'] = $line['Type']; |
|
629 | + } |
|
469 | 630 | $data['format_source'] = 'aircraftlistjson'; |
470 | 631 | $data['id_source'] = $id_source; |
471 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
472 | - if (isset($data['datetime'])) $SI->add($data); |
|
632 | + if (isset($value['name']) && $value['name'] != '') { |
|
633 | + $data['source_name'] = $value['name']; |
|
634 | + } |
|
635 | + if (isset($data['datetime'])) { |
|
636 | + $SI->add($data); |
|
637 | + } |
|
473 | 638 | unset($data); |
474 | 639 | } |
475 | 640 | } else { |
@@ -488,7 +653,9 @@ discard block |
||
488 | 653 | $data['datetime'] = date('Y-m-d H:i:s'); |
489 | 654 | $data['format_source'] = 'aircraftlistjson'; |
490 | 655 | $data['id_source'] = $id_source; |
491 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
656 | + if (isset($value['name']) && $value['name'] != '') { |
|
657 | + $data['source_name'] = $value['name']; |
|
658 | + } |
|
492 | 659 | $SI->add($data); |
493 | 660 | unset($data); |
494 | 661 | } |
@@ -523,7 +690,9 @@ discard block |
||
523 | 690 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
524 | 691 | $data['format_source'] = 'planeupdatefaa'; |
525 | 692 | $data['id_source'] = $id_source; |
526 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
693 | + if (isset($value['name']) && $value['name'] != '') { |
|
694 | + $data['source_name'] = $value['name']; |
|
695 | + } |
|
527 | 696 | $SI->add($data); |
528 | 697 | unset($data); |
529 | 698 | } |
@@ -582,7 +751,9 @@ discard block |
||
582 | 751 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
583 | 752 | $data['format_source'] = 'fr24json'; |
584 | 753 | $data['id_source'] = $id_source; |
585 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
754 | + if (isset($value['name']) && $value['name'] != '') { |
|
755 | + $data['source_name'] = $value['name']; |
|
756 | + } |
|
586 | 757 | $SI->add($data); |
587 | 758 | unset($data); |
588 | 759 | } |
@@ -605,23 +776,39 @@ discard block |
||
605 | 776 | if (isset($line['inf'])) { |
606 | 777 | $data = array(); |
607 | 778 | $data['hex'] = $line['inf']['ia']; |
608 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
779 | + if (isset($line['inf']['cs'])) { |
|
780 | + $data['ident'] = $line['inf']['cs']; |
|
781 | + } |
|
782 | + //$line[13] |
|
609 | 783 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
610 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
611 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
784 | + if (isset($line['inf']['gs'])) { |
|
785 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
786 | + } |
|
787 | + // speed |
|
788 | + if (isset($line['inf']['tr'])) { |
|
789 | + $data['heading'] = $line['inf']['tr']; |
|
790 | + } |
|
791 | + // heading |
|
612 | 792 | $data['latitude'] = $line['pt'][0]; // lat |
613 | 793 | $data['longitude'] = $line['pt'][1]; // long |
614 | 794 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
615 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
795 | + if (isset($line['inf']['sq'])) { |
|
796 | + $data['squawk'] = $line['inf']['sq']; |
|
797 | + } |
|
798 | + // squawk |
|
616 | 799 | //$data['aircraft_icao'] = $line[8]; |
617 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
800 | + if (isset($line['inf']['rc'])) { |
|
801 | + $data['registration'] = $line['inf']['rc']; |
|
802 | + } |
|
618 | 803 | //$data['departure_airport_iata'] = $line[11]; |
619 | 804 | //$data['arrival_airport_iata'] = $line[12]; |
620 | 805 | //$data['emergency'] = ''; // emergency |
621 | 806 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
622 | 807 | $data['format_source'] = 'radarvirtueljson'; |
623 | 808 | $data['id_source'] = $id_source; |
624 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
809 | + if (isset($value['name']) && $value['name'] != '') { |
|
810 | + $data['source_name'] = $value['name']; |
|
811 | + } |
|
625 | 812 | $SI->add($data); |
626 | 813 | unset($data); |
627 | 814 | } |
@@ -641,29 +828,62 @@ discard block |
||
641 | 828 | $data['id'] = $line['id']; |
642 | 829 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
643 | 830 | $data['ident'] = $line['callsign']; // ident |
644 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
645 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
646 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
647 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
648 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
649 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
831 | + if (isset($line['pilotid'])) { |
|
832 | + $data['pilot_id'] = $line['pilotid']; |
|
833 | + } |
|
834 | + // pilot id |
|
835 | + if (isset($line['name'])) { |
|
836 | + $data['pilot_name'] = $line['name']; |
|
837 | + } |
|
838 | + // pilot name |
|
839 | + if (isset($line['alt'])) { |
|
840 | + $data['altitude'] = $line['alt']; |
|
841 | + } |
|
842 | + // altitude |
|
843 | + if (isset($line['gs'])) { |
|
844 | + $data['speed'] = $line['gs']; |
|
845 | + } |
|
846 | + // speed |
|
847 | + if (isset($line['heading'])) { |
|
848 | + $data['heading'] = $line['heading']; |
|
849 | + } |
|
850 | + // heading |
|
851 | + if (isset($line['route'])) { |
|
852 | + $data['waypoints'] = $line['route']; |
|
853 | + } |
|
854 | + // route |
|
650 | 855 | $data['latitude'] = $line['lat']; // lat |
651 | 856 | $data['longitude'] = $line['lon']; // long |
652 | 857 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
653 | 858 | //$data['squawk'] = $line['squawk']; // squawk |
654 | 859 | //$data['emergency'] = ''; // emergency |
655 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
656 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
657 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
860 | + if (isset($line['depicao'])) { |
|
861 | + $data['departure_airport_icao'] = $line['depicao']; |
|
862 | + } |
|
863 | + if (isset($line['deptime'])) { |
|
864 | + $data['departure_airport_time'] = $line['deptime']; |
|
865 | + } |
|
866 | + if (isset($line['arricao'])) { |
|
867 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
868 | + } |
|
658 | 869 | //$data['arrival_airport_time'] = $line['arrtime']; |
659 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
660 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
661 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
662 | - else $data['info'] = ''; |
|
870 | + if (isset($line['aircraft'])) { |
|
871 | + $data['aircraft_icao'] = $line['aircraft']; |
|
872 | + } |
|
873 | + if (isset($line['transponder'])) { |
|
874 | + $data['squawk'] = $line['transponder']; |
|
875 | + } |
|
876 | + if (isset($line['atis'])) { |
|
877 | + $data['info'] = $line['atis']; |
|
878 | + } else { |
|
879 | + $data['info'] = ''; |
|
880 | + } |
|
663 | 881 | $data['format_source'] = 'pireps'; |
664 | 882 | $data['id_source'] = $id_source; |
665 | 883 | $data['datetime'] = date('Y-m-d H:i:s'); |
666 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
884 | + if (isset($value['name']) && $value['name'] != '') { |
|
885 | + $data['source_name'] = $value['name']; |
|
886 | + } |
|
667 | 887 | if ($line['icon'] == 'plane') { |
668 | 888 | $SI->add($data); |
669 | 889 | // print_r($data); |
@@ -672,15 +892,25 @@ discard block |
||
672 | 892 | $data['info'] = str_replace('&sect;','',$data['info']); |
673 | 893 | $typec = substr($data['ident'],-3); |
674 | 894 | $data['type'] = ''; |
675 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
676 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
677 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
678 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
679 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
680 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
681 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
682 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
683 | - else $data['type'] = 'Observer'; |
|
895 | + if ($typec == 'APP') { |
|
896 | + $data['type'] = 'Approach'; |
|
897 | + } elseif ($typec == 'TWR') { |
|
898 | + $data['type'] = 'Tower'; |
|
899 | + } elseif ($typec == 'OBS') { |
|
900 | + $data['type'] = 'Observer'; |
|
901 | + } elseif ($typec == 'GND') { |
|
902 | + $data['type'] = 'Ground'; |
|
903 | + } elseif ($typec == 'DEL') { |
|
904 | + $data['type'] = 'Delivery'; |
|
905 | + } elseif ($typec == 'DEP') { |
|
906 | + $data['type'] = 'Departure'; |
|
907 | + } elseif ($typec == 'FSS') { |
|
908 | + $data['type'] = 'Flight Service Station'; |
|
909 | + } elseif ($typec == 'CTR') { |
|
910 | + $data['type'] = 'Control Radar or Centre'; |
|
911 | + } else { |
|
912 | + $data['type'] = 'Observer'; |
|
913 | + } |
|
684 | 914 | echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
685 | 915 | } |
686 | 916 | unset($data); |
@@ -691,17 +921,25 @@ discard block |
||
691 | 921 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
692 | 922 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
693 | 923 | //$buffer = $Common->getData($hosts[$id]); |
694 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
924 | + if ($globalDebug) { |
|
925 | + echo 'Get Data...'."\n"; |
|
926 | + } |
|
695 | 927 | $buffer = $Common->getData($value['host']); |
696 | 928 | $all_data = json_decode($buffer,true); |
697 | 929 | if ($buffer != '' && is_array($all_data)) { |
698 | 930 | foreach ($all_data as $line) { |
699 | 931 | $data = array(); |
700 | 932 | //$data['id'] = $line['id']; // id not usable |
701 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
933 | + if (isset($line['pilotid'])) { |
|
934 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
935 | + } |
|
702 | 936 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
703 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
704 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
937 | + if (isset($line['pilotname'])) { |
|
938 | + $data['pilot_name'] = $line['pilotname']; |
|
939 | + } |
|
940 | + if (isset($line['pilotid'])) { |
|
941 | + $data['pilot_id'] = $line['pilotid']; |
|
942 | + } |
|
705 | 943 | $data['ident'] = $line['flightnum']; // ident |
706 | 944 | $data['altitude'] = $line['alt']; // altitude |
707 | 945 | $data['speed'] = $line['gs']; // speed |
@@ -719,27 +957,41 @@ discard block |
||
719 | 957 | $data['arrival_airport_icao'] = $line['arricao']; |
720 | 958 | $data['arrival_airport_time'] = $line['arrtime']; |
721 | 959 | $data['registration'] = $line['aircraft']; |
722 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
960 | + if (isset($line['route'])) { |
|
961 | + $data['waypoints'] = $line['route']; |
|
962 | + } |
|
963 | + // route |
|
723 | 964 | if (isset($line['aircraftname'])) { |
724 | 965 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
725 | 966 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
726 | 967 | $aircraft_data = explode('-',$line['aircraftname']); |
727 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
728 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
729 | - else { |
|
968 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) { |
|
969 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
970 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) { |
|
971 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
972 | + } else { |
|
730 | 973 | $aircraft_data = explode(' ',$line['aircraftname']); |
731 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
732 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
974 | + if (isset($aircraft_data[1])) { |
|
975 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
976 | + } else { |
|
977 | + $data['aircraft_icao'] = $line['aircraftname']; |
|
978 | + } |
|
733 | 979 | } |
734 | 980 | } |
735 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
981 | + if (isset($line['route'])) { |
|
982 | + $data['waypoints'] = $line['route']; |
|
983 | + } |
|
736 | 984 | $data['id_source'] = $id_source; |
737 | 985 | $data['format_source'] = 'phpvmacars'; |
738 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
986 | + if (isset($value['name']) && $value['name'] != '') { |
|
987 | + $data['source_name'] = $value['name']; |
|
988 | + } |
|
739 | 989 | $SI->add($data); |
740 | 990 | unset($data); |
741 | 991 | } |
742 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
992 | + if ($globalDebug) { |
|
993 | + echo 'No more data...'."\n"; |
|
994 | + } |
|
743 | 995 | unset($buffer); |
744 | 996 | unset($all_data); |
745 | 997 | } |
@@ -747,7 +999,9 @@ discard block |
||
747 | 999 | $last_exec[$id]['last'] = time(); |
748 | 1000 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
749 | 1001 | //$buffer = $Common->getData($hosts[$id]); |
750 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1002 | + if ($globalDebug) { |
|
1003 | + echo 'Get Data...'."\n"; |
|
1004 | + } |
|
751 | 1005 | $buffer = $Common->getData($value['host']); |
752 | 1006 | $all_data = json_decode($buffer,true); |
753 | 1007 | if ($buffer != '' && is_array($all_data)) { |
@@ -775,15 +1029,22 @@ discard block |
||
775 | 1029 | $data['arrival_airport_icao'] = $line['arrival']; |
776 | 1030 | //$data['arrival_airport_time'] = $line['arrival_time']; |
777 | 1031 | //$data['registration'] = $line['aircraft']; |
778 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1032 | + if (isset($line['route'])) { |
|
1033 | + $data['waypoints'] = $line['route']; |
|
1034 | + } |
|
1035 | + // route |
|
779 | 1036 | $data['aircraft_icao'] = $line['plane_type']; |
780 | 1037 | $data['id_source'] = $id_source; |
781 | 1038 | $data['format_source'] = 'vam'; |
782 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1039 | + if (isset($value['name']) && $value['name'] != '') { |
|
1040 | + $data['source_name'] = $value['name']; |
|
1041 | + } |
|
783 | 1042 | $SI->add($data); |
784 | 1043 | unset($data); |
785 | 1044 | } |
786 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1045 | + if ($globalDebug) { |
|
1046 | + echo 'No more data...'."\n"; |
|
1047 | + } |
|
787 | 1048 | unset($buffer); |
788 | 1049 | unset($all_data); |
789 | 1050 | } |
@@ -791,7 +1052,9 @@ discard block |
||
791 | 1052 | $last_exec[$id]['last'] = time(); |
792 | 1053 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
793 | 1054 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') { |
794 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1055 | + if (function_exists('pcntl_fork')) { |
|
1056 | + pcntl_signal_dispatch(); |
|
1057 | + } |
|
795 | 1058 | //$last_exec[$id]['last'] = time(); |
796 | 1059 | |
797 | 1060 | //$read = array( $sockets[$id] ); |
@@ -799,7 +1062,9 @@ discard block |
||
799 | 1062 | $write = NULL; |
800 | 1063 | $e = NULL; |
801 | 1064 | $n = socket_select($read, $write, $e, $timeout); |
802 | - if ($e != NULL) var_dump($e); |
|
1065 | + if ($e != NULL) { |
|
1066 | + var_dump($e); |
|
1067 | + } |
|
803 | 1068 | if ($n > 0) { |
804 | 1069 | foreach ($read as $nb => $r) { |
805 | 1070 | //$value = $formats[$nb]; |
@@ -820,7 +1085,9 @@ discard block |
||
820 | 1085 | if ($buffer != '') { |
821 | 1086 | $tt[$format] = 0; |
822 | 1087 | if ($format == 'acarssbs3') { |
823 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1088 | + if ($globalDebug) { |
|
1089 | + echo 'ACARS : '.$buffer."\n"; |
|
1090 | + } |
|
824 | 1091 | $ACARS->add(trim($buffer)); |
825 | 1092 | $ACARS->deleteLiveAcarsData(); |
826 | 1093 | } elseif ($format == 'raw') { |
@@ -829,9 +1096,15 @@ discard block |
||
829 | 1096 | if (is_array($data)) { |
830 | 1097 | $data['datetime'] = date('Y-m-d H:i:s'); |
831 | 1098 | $data['format_source'] = 'raw'; |
832 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
833 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
834 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1099 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1100 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1101 | + } |
|
1102 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1103 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1104 | + } |
|
1105 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1106 | + $SI->add($data); |
|
1107 | + } |
|
835 | 1108 | } |
836 | 1109 | } elseif ($format == 'flightgearsp') { |
837 | 1110 | //echo $buffer."\n"; |
@@ -849,11 +1122,15 @@ discard block |
||
849 | 1122 | $data['speed'] = round($line[5]*1.94384); |
850 | 1123 | $data['datetime'] = date('Y-m-d H:i:s'); |
851 | 1124 | $data['format_source'] = 'flightgearsp'; |
852 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1125 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1126 | + $SI->add($data); |
|
1127 | + } |
|
853 | 1128 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
854 | 1129 | } |
855 | 1130 | } elseif ($format == 'acars') { |
856 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1131 | + if ($globalDebug) { |
|
1132 | + echo 'ACARS : '.$buffer."\n"; |
|
1133 | + } |
|
857 | 1134 | $ACARS->add(trim($buffer)); |
858 | 1135 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
859 | 1136 | $ACARS->deleteLiveAcarsData(); |
@@ -874,7 +1151,9 @@ discard block |
||
874 | 1151 | $aircraft_type = $line[10]; |
875 | 1152 | $aircraft_type = preg_split(':/:',$aircraft_type); |
876 | 1153 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
877 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1154 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1155 | + $SI->add($data); |
|
1156 | + } |
|
878 | 1157 | } |
879 | 1158 | } |
880 | 1159 | } elseif ($format == 'beast') { |
@@ -890,21 +1169,43 @@ discard block |
||
890 | 1169 | $data['hex'] = $lined['hexid']; |
891 | 1170 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
892 | 1171 | $data['datetime'] = date('Y-m-d H:i:s');; |
893 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
894 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
895 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
896 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
897 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
898 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
899 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1172 | + if (isset($lined['ident'])) { |
|
1173 | + $data['ident'] = $lined['ident']; |
|
1174 | + } |
|
1175 | + if (isset($lined['lat'])) { |
|
1176 | + $data['latitude'] = $lined['lat']; |
|
1177 | + } |
|
1178 | + if (isset($lined['lon'])) { |
|
1179 | + $data['longitude'] = $lined['lon']; |
|
1180 | + } |
|
1181 | + if (isset($lined['speed'])) { |
|
1182 | + $data['speed'] = $lined['speed']; |
|
1183 | + } |
|
1184 | + if (isset($lined['squawk'])) { |
|
1185 | + $data['squawk'] = $lined['squawk']; |
|
1186 | + } |
|
1187 | + if (isset($lined['alt'])) { |
|
1188 | + $data['altitude'] = $lined['alt']; |
|
1189 | + } |
|
1190 | + if (isset($lined['heading'])) { |
|
1191 | + $data['heading'] = $lined['heading']; |
|
1192 | + } |
|
900 | 1193 | $data['id_source'] = $id_source; |
901 | 1194 | $data['format_source'] = 'tsv'; |
902 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
903 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
904 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1195 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1196 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1197 | + } |
|
1198 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1199 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1200 | + } |
|
1201 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1202 | + $SI->add($data); |
|
1203 | + } |
|
905 | 1204 | unset($lined); |
906 | 1205 | unset($data); |
907 | - } else $error = true; |
|
1206 | + } else { |
|
1207 | + $error = true; |
|
1208 | + } |
|
908 | 1209 | } elseif ($format == 'aprs' && $use_aprs) { |
909 | 1210 | if ($aprs_connect == 0) { |
910 | 1211 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -930,29 +1231,44 @@ discard block |
||
930 | 1231 | $data['latitude'] = $line['latitude']; |
931 | 1232 | $data['longitude'] = $line['longitude']; |
932 | 1233 | //$data['verticalrate'] = $line[16]; |
933 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
934 | - else $data['speed'] = 0; |
|
1234 | + if (isset($line['speed'])) { |
|
1235 | + $data['speed'] = $line['speed']; |
|
1236 | + } else { |
|
1237 | + $data['speed'] = 0; |
|
1238 | + } |
|
935 | 1239 | $data['altitude'] = $line['altitude']; |
936 | - if (isset($line['course'])) $data['heading'] = $line['course']; |
|
1240 | + if (isset($line['course'])) { |
|
1241 | + $data['heading'] = $line['course']; |
|
1242 | + } |
|
937 | 1243 | //else $data['heading'] = 0; |
938 | 1244 | $data['aircraft_type'] = $line['stealth']; |
939 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1245 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
1246 | + $data['noarchive'] = true; |
|
1247 | + } |
|
940 | 1248 | $data['id_source'] = $id_source; |
941 | 1249 | $data['format_source'] = 'aprs'; |
942 | 1250 | $data['source_name'] = $line['source']; |
943 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1251 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1252 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1253 | + } |
|
944 | 1254 | $currentdate = date('Y-m-d H:i:s'); |
945 | 1255 | $aprsdate = strtotime($data['datetime']); |
946 | 1256 | // Accept data if time <= system time + 20s |
947 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
948 | - else { |
|
949 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
950 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1257 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1258 | + $send = $SI->add($data); |
|
1259 | + } else { |
|
1260 | + if ($line['stealth'] != 0) { |
|
1261 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1262 | + } else { |
|
1263 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1264 | + } |
|
951 | 1265 | } |
952 | 1266 | unset($data); |
953 | 1267 | } |
954 | 1268 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
955 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
1269 | + elseif ($line == true && $globalDebug) { |
|
1270 | + echo '!! Failed : '.$buffer."!!\n"; |
|
1271 | + } |
|
956 | 1272 | } |
957 | 1273 | } else { |
958 | 1274 | $line = explode(',', $buffer); |
@@ -980,25 +1296,42 @@ discard block |
||
980 | 1296 | $data['ground'] = $line[21]; |
981 | 1297 | $data['emergency'] = $line[19]; |
982 | 1298 | $data['format_source'] = 'sbs'; |
983 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
984 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1299 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1300 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1301 | + } |
|
1302 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1303 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1304 | + } |
|
985 | 1305 | $data['id_source'] = $id_source; |
986 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
987 | - else $error = true; |
|
1306 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1307 | + $send = $SI->add($data); |
|
1308 | + } else { |
|
1309 | + $error = true; |
|
1310 | + } |
|
988 | 1311 | unset($data); |
989 | - } else $error = true; |
|
1312 | + } else { |
|
1313 | + $error = true; |
|
1314 | + } |
|
990 | 1315 | if ($error) { |
991 | 1316 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
992 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
1317 | + if ($globalDebug) { |
|
1318 | + echo "Not a message. Ignoring... \n"; |
|
1319 | + } |
|
993 | 1320 | } else { |
994 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
1321 | + if ($globalDebug) { |
|
1322 | + echo "Wrong line format. Ignoring... \n"; |
|
1323 | + } |
|
995 | 1324 | if ($globalDebug) { |
996 | 1325 | echo $buffer; |
997 | 1326 | print_r($line); |
998 | 1327 | } |
999 | 1328 | //socket_close($r); |
1000 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1001 | - if ($format == 'aprs') $aprs_connect = 0; |
|
1329 | + if ($globalDebug) { |
|
1330 | + echo "Reconnect after an error...\n"; |
|
1331 | + } |
|
1332 | + if ($format == 'aprs') { |
|
1333 | + $aprs_connect = 0; |
|
1334 | + } |
|
1002 | 1335 | $sourceer[$nb] = $globalSources[$nb]; |
1003 | 1336 | connect_all($sourceer); |
1004 | 1337 | $sourceer = array(); |
@@ -1006,10 +1339,14 @@ discard block |
||
1006 | 1339 | } |
1007 | 1340 | } |
1008 | 1341 | // Sleep for xxx microseconds |
1009 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
1342 | + if (isset($globalSBSSleep)) { |
|
1343 | + usleep($globalSBSSleep); |
|
1344 | + } |
|
1010 | 1345 | } else { |
1011 | 1346 | if ($format == 'flightgearmp') { |
1012 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1347 | + if ($globalDebug) { |
|
1348 | + echo "Reconnect FlightGear MP..."; |
|
1349 | + } |
|
1013 | 1350 | //@socket_close($r); |
1014 | 1351 | sleep($globalMinFetch); |
1015 | 1352 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1018,10 +1355,15 @@ discard block |
||
1018 | 1355 | break; |
1019 | 1356 | |
1020 | 1357 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1021 | - if (isset($tt[$format])) $tt[$format]++; |
|
1022 | - else $tt[$format] = 0; |
|
1358 | + if (isset($tt[$format])) { |
|
1359 | + $tt[$format]++; |
|
1360 | + } else { |
|
1361 | + $tt[$format] = 0; |
|
1362 | + } |
|
1023 | 1363 | if ($tt[$format] > 30) { |
1024 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
1364 | + if ($globalDebug) { |
|
1365 | + echo "ERROR : Reconnect ".$format."..."; |
|
1366 | + } |
|
1025 | 1367 | //@socket_close($r); |
1026 | 1368 | sleep(2); |
1027 | 1369 | $aprs_connect = 0; |
@@ -1037,12 +1379,18 @@ discard block |
||
1037 | 1379 | } |
1038 | 1380 | } else { |
1039 | 1381 | $error = socket_strerror(socket_last_error()); |
1040 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1382 | + if ($globalDebug) { |
|
1383 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1384 | + } |
|
1041 | 1385 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
1042 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
1386 | + if (isset($globalDebug)) { |
|
1387 | + echo "Restarting...\n"; |
|
1388 | + } |
|
1043 | 1389 | // Restart the script if possible |
1044 | 1390 | if (is_array($sockets)) { |
1045 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1391 | + if ($globalDebug) { |
|
1392 | + echo "Shutdown all sockets..."; |
|
1393 | + } |
|
1046 | 1394 | |
1047 | 1395 | foreach ($sockets as $sock) { |
1048 | 1396 | @socket_shutdown($sock,2); |
@@ -1050,7 +1398,9 @@ discard block |
||
1050 | 1398 | } |
1051 | 1399 | |
1052 | 1400 | } |
1053 | - if ($globalDebug) echo "Restart all connections..."; |
|
1401 | + if ($globalDebug) { |
|
1402 | + echo "Restart all connections..."; |
|
1403 | + } |
|
1054 | 1404 | sleep(2); |
1055 | 1405 | $time = time(); |
1056 | 1406 | //connect_all($hosts); |
@@ -1061,7 +1411,9 @@ discard block |
||
1061 | 1411 | } |
1062 | 1412 | } |
1063 | 1413 | if ($globalDaemon === false) { |
1064 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1414 | + if ($globalDebug) { |
|
1415 | + echo 'Check all...'."\n"; |
|
1416 | + } |
|
1065 | 1417 | $SI->checkAll(); |
1066 | 1418 | } |
1067 | 1419 | } |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -804,12 +856,16 @@ discard block |
||
804 | 856 | if ($globalDBdriver == 'mysql') { |
805 | 857 | if (!$Connection->tableExists('tle')) { |
806 | 858 | $error .= create_db::import_file('../db/tle.sql'); |
807 | - if ($error != '') return $error; |
|
859 | + if ($error != '') { |
|
860 | + return $error; |
|
861 | + } |
|
808 | 862 | } |
809 | 863 | } else { |
810 | 864 | if (!$Connection->tableExists('tle')) { |
811 | 865 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
812 | - if ($error != '') return $error; |
|
866 | + if ($error != '') { |
|
867 | + return $error; |
|
868 | + } |
|
813 | 869 | } |
814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
815 | 871 | try { |
@@ -849,7 +905,9 @@ discard block |
||
849 | 905 | } else { |
850 | 906 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 907 | } |
852 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
908 | + if ($error != '') { |
|
909 | + return 'Import airlines.sql : '.$error; |
|
910 | + } |
|
853 | 911 | if (!$Connection->checkColumnName('airlines','forsource')) { |
854 | 912 | // Add forsource to airlines |
855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1136,8 +1194,11 @@ discard block |
||
1136 | 1194 | if ($Connection->tableExists('aircraft')) { |
1137 | 1195 | if (!$Connection->tableExists('config')) { |
1138 | 1196 | $version = '1'; |
1139 | - if ($update) return self::update_from_1(); |
|
1140 | - else return $version; |
|
1197 | + if ($update) { |
|
1198 | + return self::update_from_1(); |
|
1199 | + } else { |
|
1200 | + return $version; |
|
1201 | + } |
|
1141 | 1202 | } else { |
1142 | 1203 | $Connection = new Connection(); |
1143 | 1204 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1151,110 +1212,190 @@ discard block |
||
1151 | 1212 | if ($update) { |
1152 | 1213 | if ($result['value'] == '2') { |
1153 | 1214 | $error = self::update_from_2(); |
1154 | - if ($error != '') return $error; |
|
1155 | - else return self::check_version(true); |
|
1215 | + if ($error != '') { |
|
1216 | + return $error; |
|
1217 | + } else { |
|
1218 | + return self::check_version(true); |
|
1219 | + } |
|
1156 | 1220 | } elseif ($result['value'] == '3') { |
1157 | 1221 | $error = self::update_from_3(); |
1158 | - if ($error != '') return $error; |
|
1159 | - else return self::check_version(true); |
|
1222 | + if ($error != '') { |
|
1223 | + return $error; |
|
1224 | + } else { |
|
1225 | + return self::check_version(true); |
|
1226 | + } |
|
1160 | 1227 | } elseif ($result['value'] == '4') { |
1161 | 1228 | $error = self::update_from_4(); |
1162 | - if ($error != '') return $error; |
|
1163 | - else return self::check_version(true); |
|
1229 | + if ($error != '') { |
|
1230 | + return $error; |
|
1231 | + } else { |
|
1232 | + return self::check_version(true); |
|
1233 | + } |
|
1164 | 1234 | } elseif ($result['value'] == '5') { |
1165 | 1235 | $error = self::update_from_5(); |
1166 | - if ($error != '') return $error; |
|
1167 | - else return self::check_version(true); |
|
1236 | + if ($error != '') { |
|
1237 | + return $error; |
|
1238 | + } else { |
|
1239 | + return self::check_version(true); |
|
1240 | + } |
|
1168 | 1241 | } elseif ($result['value'] == '6') { |
1169 | 1242 | $error = self::update_from_6(); |
1170 | - if ($error != '') return $error; |
|
1171 | - else return self::check_version(true); |
|
1243 | + if ($error != '') { |
|
1244 | + return $error; |
|
1245 | + } else { |
|
1246 | + return self::check_version(true); |
|
1247 | + } |
|
1172 | 1248 | } elseif ($result['value'] == '7') { |
1173 | 1249 | $error = self::update_from_7(); |
1174 | - if ($error != '') return $error; |
|
1175 | - else return self::check_version(true); |
|
1250 | + if ($error != '') { |
|
1251 | + return $error; |
|
1252 | + } else { |
|
1253 | + return self::check_version(true); |
|
1254 | + } |
|
1176 | 1255 | } elseif ($result['value'] == '8') { |
1177 | 1256 | $error = self::update_from_8(); |
1178 | - if ($error != '') return $error; |
|
1179 | - else return self::check_version(true); |
|
1257 | + if ($error != '') { |
|
1258 | + return $error; |
|
1259 | + } else { |
|
1260 | + return self::check_version(true); |
|
1261 | + } |
|
1180 | 1262 | } elseif ($result['value'] == '9') { |
1181 | 1263 | $error = self::update_from_9(); |
1182 | - if ($error != '') return $error; |
|
1183 | - else return self::check_version(true); |
|
1264 | + if ($error != '') { |
|
1265 | + return $error; |
|
1266 | + } else { |
|
1267 | + return self::check_version(true); |
|
1268 | + } |
|
1184 | 1269 | } elseif ($result['value'] == '10') { |
1185 | 1270 | $error = self::update_from_10(); |
1186 | - if ($error != '') return $error; |
|
1187 | - else return self::check_version(true); |
|
1271 | + if ($error != '') { |
|
1272 | + return $error; |
|
1273 | + } else { |
|
1274 | + return self::check_version(true); |
|
1275 | + } |
|
1188 | 1276 | } elseif ($result['value'] == '11') { |
1189 | 1277 | $error = self::update_from_11(); |
1190 | - if ($error != '') return $error; |
|
1191 | - else return self::check_version(true); |
|
1278 | + if ($error != '') { |
|
1279 | + return $error; |
|
1280 | + } else { |
|
1281 | + return self::check_version(true); |
|
1282 | + } |
|
1192 | 1283 | } elseif ($result['value'] == '12') { |
1193 | 1284 | $error = self::update_from_12(); |
1194 | - if ($error != '') return $error; |
|
1195 | - else return self::check_version(true); |
|
1285 | + if ($error != '') { |
|
1286 | + return $error; |
|
1287 | + } else { |
|
1288 | + return self::check_version(true); |
|
1289 | + } |
|
1196 | 1290 | } elseif ($result['value'] == '13') { |
1197 | 1291 | $error = self::update_from_13(); |
1198 | - if ($error != '') return $error; |
|
1199 | - else return self::check_version(true); |
|
1292 | + if ($error != '') { |
|
1293 | + return $error; |
|
1294 | + } else { |
|
1295 | + return self::check_version(true); |
|
1296 | + } |
|
1200 | 1297 | } elseif ($result['value'] == '14') { |
1201 | 1298 | $error = self::update_from_14(); |
1202 | - if ($error != '') return $error; |
|
1203 | - else return self::check_version(true); |
|
1299 | + if ($error != '') { |
|
1300 | + return $error; |
|
1301 | + } else { |
|
1302 | + return self::check_version(true); |
|
1303 | + } |
|
1204 | 1304 | } elseif ($result['value'] == '15') { |
1205 | 1305 | $error = self::update_from_15(); |
1206 | - if ($error != '') return $error; |
|
1207 | - else return self::check_version(true); |
|
1306 | + if ($error != '') { |
|
1307 | + return $error; |
|
1308 | + } else { |
|
1309 | + return self::check_version(true); |
|
1310 | + } |
|
1208 | 1311 | } elseif ($result['value'] == '16') { |
1209 | 1312 | $error = self::update_from_16(); |
1210 | - if ($error != '') return $error; |
|
1211 | - else return self::check_version(true); |
|
1313 | + if ($error != '') { |
|
1314 | + return $error; |
|
1315 | + } else { |
|
1316 | + return self::check_version(true); |
|
1317 | + } |
|
1212 | 1318 | } elseif ($result['value'] == '17') { |
1213 | 1319 | $error = self::update_from_17(); |
1214 | - if ($error != '') return $error; |
|
1215 | - else return self::check_version(true); |
|
1320 | + if ($error != '') { |
|
1321 | + return $error; |
|
1322 | + } else { |
|
1323 | + return self::check_version(true); |
|
1324 | + } |
|
1216 | 1325 | } elseif ($result['value'] == '18') { |
1217 | 1326 | $error = self::update_from_18(); |
1218 | - if ($error != '') return $error; |
|
1219 | - else return self::check_version(true); |
|
1327 | + if ($error != '') { |
|
1328 | + return $error; |
|
1329 | + } else { |
|
1330 | + return self::check_version(true); |
|
1331 | + } |
|
1220 | 1332 | } elseif ($result['value'] == '19') { |
1221 | 1333 | $error = self::update_from_19(); |
1222 | - if ($error != '') return $error; |
|
1223 | - else return self::check_version(true); |
|
1334 | + if ($error != '') { |
|
1335 | + return $error; |
|
1336 | + } else { |
|
1337 | + return self::check_version(true); |
|
1338 | + } |
|
1224 | 1339 | } elseif ($result['value'] == '20') { |
1225 | 1340 | $error = self::update_from_20(); |
1226 | - if ($error != '') return $error; |
|
1227 | - else return self::check_version(true); |
|
1341 | + if ($error != '') { |
|
1342 | + return $error; |
|
1343 | + } else { |
|
1344 | + return self::check_version(true); |
|
1345 | + } |
|
1228 | 1346 | } elseif ($result['value'] == '21') { |
1229 | 1347 | $error = self::update_from_21(); |
1230 | - if ($error != '') return $error; |
|
1231 | - else return self::check_version(true); |
|
1348 | + if ($error != '') { |
|
1349 | + return $error; |
|
1350 | + } else { |
|
1351 | + return self::check_version(true); |
|
1352 | + } |
|
1232 | 1353 | } elseif ($result['value'] == '22') { |
1233 | 1354 | $error = self::update_from_22(); |
1234 | - if ($error != '') return $error; |
|
1235 | - else return self::check_version(true); |
|
1355 | + if ($error != '') { |
|
1356 | + return $error; |
|
1357 | + } else { |
|
1358 | + return self::check_version(true); |
|
1359 | + } |
|
1236 | 1360 | } elseif ($result['value'] == '23') { |
1237 | 1361 | $error = self::update_from_23(); |
1238 | - if ($error != '') return $error; |
|
1239 | - else return self::check_version(true); |
|
1362 | + if ($error != '') { |
|
1363 | + return $error; |
|
1364 | + } else { |
|
1365 | + return self::check_version(true); |
|
1366 | + } |
|
1240 | 1367 | } elseif ($result['value'] == '24') { |
1241 | 1368 | $error = self::update_from_24(); |
1242 | - if ($error != '') return $error; |
|
1243 | - else return self::check_version(true); |
|
1369 | + if ($error != '') { |
|
1370 | + return $error; |
|
1371 | + } else { |
|
1372 | + return self::check_version(true); |
|
1373 | + } |
|
1244 | 1374 | } elseif ($result['value'] == '25') { |
1245 | 1375 | $error = self::update_from_25(); |
1246 | - if ($error != '') return $error; |
|
1247 | - else return self::check_version(true); |
|
1376 | + if ($error != '') { |
|
1377 | + return $error; |
|
1378 | + } else { |
|
1379 | + return self::check_version(true); |
|
1380 | + } |
|
1248 | 1381 | } elseif ($result['value'] == '26') { |
1249 | 1382 | $error = self::update_from_26(); |
1250 | - if ($error != '') return $error; |
|
1251 | - else return self::check_version(true); |
|
1252 | - } else return ''; |
|
1383 | + if ($error != '') { |
|
1384 | + return $error; |
|
1385 | + } else { |
|
1386 | + return self::check_version(true); |
|
1387 | + } |
|
1388 | + } else { |
|
1389 | + return ''; |
|
1390 | + } |
|
1391 | + } else { |
|
1392 | + return $result['value']; |
|
1253 | 1393 | } |
1254 | - else return $result['value']; |
|
1255 | 1394 | } |
1256 | 1395 | |
1257 | - } else return $version; |
|
1396 | + } else { |
|
1397 | + return $version; |
|
1398 | + } |
|
1258 | 1399 | } |
1259 | 1400 | |
1260 | 1401 | } |