@@ -13,7 +13,9 @@ discard block |
||
13 | 13 | |
14 | 14 | public function __construct($dbc = null) { |
15 | 15 | global $globalFilterName; |
16 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
16 | + if (isset($globalFilterName)) { |
|
17 | + $this->filter_name = $globalFilterName; |
|
18 | + } |
|
17 | 19 | $Connection = new Connection($dbc); |
18 | 20 | $this->db = $Connection->db(); |
19 | 21 | } |
@@ -81,7 +83,9 @@ discard block |
||
81 | 83 | } |
82 | 84 | } |
83 | 85 | public function getAllAirlineNames($filter_name = '') { |
84 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
86 | + if ($filter_name == '') { |
|
87 | + $filter_name = $this->filter_name; |
|
88 | + } |
|
85 | 89 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
86 | 90 | try { |
87 | 91 | $sth = $this->db->prepare($query); |
@@ -93,7 +97,9 @@ discard block |
||
93 | 97 | return $all; |
94 | 98 | } |
95 | 99 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
96 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
100 | + if ($filter_name == '') { |
|
101 | + $filter_name = $this->filter_name; |
|
102 | + } |
|
97 | 103 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
98 | 104 | try { |
99 | 105 | $sth = $this->db->prepare($query); |
@@ -105,7 +111,9 @@ discard block |
||
105 | 111 | return $all; |
106 | 112 | } |
107 | 113 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
108 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
114 | + if ($filter_name == '') { |
|
115 | + $filter_name = $this->filter_name; |
|
116 | + } |
|
109 | 117 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
110 | 118 | try { |
111 | 119 | $sth = $this->db->prepare($query); |
@@ -117,7 +125,9 @@ discard block |
||
117 | 125 | return $all; |
118 | 126 | } |
119 | 127 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
120 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
128 | + if ($filter_name == '') { |
|
129 | + $filter_name = $this->filter_name; |
|
130 | + } |
|
121 | 131 | $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"; |
122 | 132 | try { |
123 | 133 | $sth = $this->db->prepare($query); |
@@ -130,7 +140,9 @@ discard block |
||
130 | 140 | } |
131 | 141 | |
132 | 142 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
133 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
143 | + if ($filter_name == '') { |
|
144 | + $filter_name = $this->filter_name; |
|
145 | + } |
|
134 | 146 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
135 | 147 | try { |
136 | 148 | $sth = $this->db->prepare($query); |
@@ -143,7 +155,9 @@ discard block |
||
143 | 155 | } |
144 | 156 | |
145 | 157 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
146 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
158 | + if ($filter_name == '') { |
|
159 | + $filter_name = $this->filter_name; |
|
160 | + } |
|
147 | 161 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
148 | 162 | try { |
149 | 163 | $sth = $this->db->prepare($query); |
@@ -158,10 +172,15 @@ discard block |
||
158 | 172 | |
159 | 173 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
160 | 174 | global $globalStatsFilters; |
161 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
175 | + if ($filter_name == '') { |
|
176 | + $filter_name = $this->filter_name; |
|
177 | + } |
|
162 | 178 | if ($year == '' && $month == '') { |
163 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
164 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
179 | + if ($limit) { |
|
180 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
181 | + } else { |
|
182 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
183 | + } |
|
165 | 184 | try { |
166 | 185 | $sth = $this->db->prepare($query); |
167 | 186 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -169,7 +188,9 @@ discard block |
||
169 | 188 | echo "error : ".$e->getMessage(); |
170 | 189 | } |
171 | 190 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
172 | - } else $all = array(); |
|
191 | + } else { |
|
192 | + $all = array(); |
|
193 | + } |
|
173 | 194 | if (empty($all)) { |
174 | 195 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
175 | 196 | if ($filter_name != '') { |
@@ -183,10 +204,15 @@ discard block |
||
183 | 204 | } |
184 | 205 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
185 | 206 | global $globalStatsFilters; |
186 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
207 | + if ($filter_name == '') { |
|
208 | + $filter_name = $this->filter_name; |
|
209 | + } |
|
187 | 210 | if ($year == '' && $month == '') { |
188 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
189 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
211 | + if ($limit) { |
|
212 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
213 | + } else { |
|
214 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
215 | + } |
|
190 | 216 | try { |
191 | 217 | $sth = $this->db->prepare($query); |
192 | 218 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -194,7 +220,9 @@ discard block |
||
194 | 220 | echo "error : ".$e->getMessage(); |
195 | 221 | } |
196 | 222 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
197 | - } else $all = array(); |
|
223 | + } else { |
|
224 | + $all = array(); |
|
225 | + } |
|
198 | 226 | if (empty($all)) { |
199 | 227 | $Spotter = new Spotter($this->db); |
200 | 228 | $filters = array(); |
@@ -209,10 +237,15 @@ discard block |
||
209 | 237 | } |
210 | 238 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
211 | 239 | global $globalStatsFilters; |
212 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
240 | + if ($filter_name == '') { |
|
241 | + $filter_name = $this->filter_name; |
|
242 | + } |
|
213 | 243 | if ($year == '' && $month == '') { |
214 | - 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"; |
|
215 | - 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"; |
|
244 | + if ($limit) { |
|
245 | + $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"; |
|
246 | + } else { |
|
247 | + $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"; |
|
248 | + } |
|
216 | 249 | try { |
217 | 250 | $sth = $this->db->prepare($query); |
218 | 251 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -220,7 +253,9 @@ discard block |
||
220 | 253 | echo "error : ".$e->getMessage(); |
221 | 254 | } |
222 | 255 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
223 | - } else $all = array(); |
|
256 | + } else { |
|
257 | + $all = array(); |
|
258 | + } |
|
224 | 259 | if (empty($all)) { |
225 | 260 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
226 | 261 | if ($filter_name != '') { |
@@ -235,10 +270,15 @@ discard block |
||
235 | 270 | |
236 | 271 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
237 | 272 | global $globalStatsFilters; |
238 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
273 | + if ($filter_name == '') { |
|
274 | + $filter_name = $this->filter_name; |
|
275 | + } |
|
239 | 276 | if ($year == '' && $month == '') { |
240 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
241 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
277 | + if ($limit) { |
|
278 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
279 | + } else { |
|
280 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
281 | + } |
|
242 | 282 | try { |
243 | 283 | $sth = $this->db->prepare($query); |
244 | 284 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -246,7 +286,9 @@ discard block |
||
246 | 286 | echo "error : ".$e->getMessage(); |
247 | 287 | } |
248 | 288 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
249 | - } else $all = array(); |
|
289 | + } else { |
|
290 | + $all = array(); |
|
291 | + } |
|
250 | 292 | if (empty($all)) { |
251 | 293 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
252 | 294 | if ($filter_name != '') { |
@@ -260,9 +302,14 @@ discard block |
||
260 | 302 | } |
261 | 303 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
262 | 304 | global $globalStatsFilters; |
263 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
264 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
265 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
305 | + if ($filter_name == '') { |
|
306 | + $filter_name = $this->filter_name; |
|
307 | + } |
|
308 | + if ($limit) { |
|
309 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
310 | + } else { |
|
311 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
312 | + } |
|
266 | 313 | try { |
267 | 314 | $sth = $this->db->prepare($query); |
268 | 315 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -284,17 +331,29 @@ discard block |
||
284 | 331 | |
285 | 332 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
286 | 333 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
287 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
334 | + if ($filter_name == '') { |
|
335 | + $filter_name = $this->filter_name; |
|
336 | + } |
|
288 | 337 | if ($year == '' && $month == '') { |
289 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
290 | - if ($globalIVAO) $forsource = 'ivao'; |
|
338 | + if ($globalVATSIM) { |
|
339 | + $forsource = 'vatsim'; |
|
340 | + } |
|
341 | + if ($globalIVAO) { |
|
342 | + $forsource = 'ivao'; |
|
343 | + } |
|
291 | 344 | if (isset($forsource)) { |
292 | - 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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
293 | - 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 AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
345 | + if ($limit) { |
|
346 | + $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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
347 | + } else { |
|
348 | + $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 AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
349 | + } |
|
294 | 350 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
295 | 351 | } else { |
296 | - 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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
297 | - 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 AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
352 | + if ($limit) { |
|
353 | + $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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
354 | + } else { |
|
355 | + $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 AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
356 | + } |
|
298 | 357 | $query_values = array(':filter_name' => $filter_name); |
299 | 358 | } |
300 | 359 | try { |
@@ -304,7 +363,9 @@ discard block |
||
304 | 363 | echo "error : ".$e->getMessage(); |
305 | 364 | } |
306 | 365 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
307 | - } else $all = array(); |
|
366 | + } else { |
|
367 | + $all = array(); |
|
368 | + } |
|
308 | 369 | if (empty($all)) { |
309 | 370 | $Spotter = new Spotter($this->db); |
310 | 371 | $filters = array(); |
@@ -319,10 +380,15 @@ discard block |
||
319 | 380 | } |
320 | 381 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
321 | 382 | global $globalStatsFilters; |
322 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
383 | + if ($filter_name == '') { |
|
384 | + $filter_name = $this->filter_name; |
|
385 | + } |
|
323 | 386 | if ($year == '' && $month == '') { |
324 | - 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"; |
|
325 | - 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"; |
|
387 | + if ($limit) { |
|
388 | + $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"; |
|
389 | + } else { |
|
390 | + $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"; |
|
391 | + } |
|
326 | 392 | try { |
327 | 393 | $sth = $this->db->prepare($query); |
328 | 394 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -330,7 +396,9 @@ discard block |
||
330 | 396 | echo "error : ".$e->getMessage(); |
331 | 397 | } |
332 | 398 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
333 | - } else $all = array(); |
|
399 | + } else { |
|
400 | + $all = array(); |
|
401 | + } |
|
334 | 402 | if (empty($all)) { |
335 | 403 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
336 | 404 | if ($filter_name != '') { |
@@ -344,10 +412,15 @@ discard block |
||
344 | 412 | } |
345 | 413 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
346 | 414 | global $globalStatsFilters; |
347 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
415 | + if ($filter_name == '') { |
|
416 | + $filter_name = $this->filter_name; |
|
417 | + } |
|
348 | 418 | if ($year == '' && $month == '') { |
349 | - 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"; |
|
350 | - 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"; |
|
419 | + if ($limit) { |
|
420 | + $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"; |
|
421 | + } else { |
|
422 | + $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"; |
|
423 | + } |
|
351 | 424 | try { |
352 | 425 | $sth = $this->db->prepare($query); |
353 | 426 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -355,7 +428,9 @@ discard block |
||
355 | 428 | echo "error : ".$e->getMessage(); |
356 | 429 | } |
357 | 430 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
358 | - } else $all = array(); |
|
431 | + } else { |
|
432 | + $all = array(); |
|
433 | + } |
|
359 | 434 | if (empty($all)) { |
360 | 435 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
361 | 436 | if ($filter_name != '') { |
@@ -369,11 +444,16 @@ discard block |
||
369 | 444 | } |
370 | 445 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
371 | 446 | $Connection = new Connection(); |
372 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
447 | + if ($filter_name == '') { |
|
448 | + $filter_name = $this->filter_name; |
|
449 | + } |
|
373 | 450 | if ($Connection->tableExists('countries')) { |
374 | 451 | if ($year == '' && $month == '') { |
375 | - 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"; |
|
376 | - 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"; |
|
452 | + if ($limit) { |
|
453 | + $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"; |
|
454 | + } else { |
|
455 | + $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"; |
|
456 | + } |
|
377 | 457 | try { |
378 | 458 | $sth = $this->db->prepare($query); |
379 | 459 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -388,17 +468,24 @@ discard block |
||
388 | 468 | } |
389 | 469 | */ |
390 | 470 | return $all; |
391 | - } else return array(); |
|
471 | + } else { |
|
472 | + return array(); |
|
473 | + } |
|
392 | 474 | } else { |
393 | 475 | return array(); |
394 | 476 | } |
395 | 477 | } |
396 | 478 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
397 | 479 | global $globalStatsFilters; |
398 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
480 | + if ($filter_name == '') { |
|
481 | + $filter_name = $this->filter_name; |
|
482 | + } |
|
399 | 483 | if ($year == '' && $month == '') { |
400 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
401 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
484 | + if ($limit) { |
|
485 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
486 | + } else { |
|
487 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
488 | + } |
|
402 | 489 | try { |
403 | 490 | $sth = $this->db->prepare($query); |
404 | 491 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -406,7 +493,9 @@ discard block |
||
406 | 493 | echo "error : ".$e->getMessage(); |
407 | 494 | } |
408 | 495 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
409 | - } else $all = array(); |
|
496 | + } else { |
|
497 | + $all = array(); |
|
498 | + } |
|
410 | 499 | if (empty($all)) { |
411 | 500 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
412 | 501 | if ($filter_name != '') { |
@@ -421,10 +510,15 @@ discard block |
||
421 | 510 | |
422 | 511 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
423 | 512 | global $globalStatsFilters; |
424 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
513 | + if ($filter_name == '') { |
|
514 | + $filter_name = $this->filter_name; |
|
515 | + } |
|
425 | 516 | if ($year == '' && $month == '') { |
426 | - 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"; |
|
427 | - 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"; |
|
517 | + if ($limit) { |
|
518 | + $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"; |
|
519 | + } else { |
|
520 | + $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"; |
|
521 | + } |
|
428 | 522 | try { |
429 | 523 | $sth = $this->db->prepare($query); |
430 | 524 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -432,7 +526,9 @@ discard block |
||
432 | 526 | echo "error : ".$e->getMessage(); |
433 | 527 | } |
434 | 528 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
435 | - } else $all = array(); |
|
529 | + } else { |
|
530 | + $all = array(); |
|
531 | + } |
|
436 | 532 | if (empty($all)) { |
437 | 533 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
438 | 534 | if ($filter_name != '') { |
@@ -446,10 +542,15 @@ discard block |
||
446 | 542 | } |
447 | 543 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
448 | 544 | global $globalStatsFilters; |
449 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
545 | + if ($filter_name == '') { |
|
546 | + $filter_name = $this->filter_name; |
|
547 | + } |
|
450 | 548 | if ($year == '' && $month == '') { |
451 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
452 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
549 | + if ($limit) { |
|
550 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
551 | + } else { |
|
552 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
553 | + } |
|
453 | 554 | try { |
454 | 555 | $sth = $this->db->prepare($query); |
455 | 556 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -457,7 +558,9 @@ discard block |
||
457 | 558 | echo "error : ".$e->getMessage(); |
458 | 559 | } |
459 | 560 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
460 | - } else $all = array(); |
|
561 | + } else { |
|
562 | + $all = array(); |
|
563 | + } |
|
461 | 564 | if (empty($all)) { |
462 | 565 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
463 | 566 | if ($filter_name != '') { |
@@ -478,7 +581,9 @@ discard block |
||
478 | 581 | $icao = $value['airport_departure_icao']; |
479 | 582 | if (isset($all[$icao])) { |
480 | 583 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
481 | - } else $all[$icao] = $value; |
|
584 | + } else { |
|
585 | + $all[$icao] = $value; |
|
586 | + } |
|
482 | 587 | } |
483 | 588 | $count = array(); |
484 | 589 | foreach ($all as $key => $row) { |
@@ -490,10 +595,15 @@ discard block |
||
490 | 595 | } |
491 | 596 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
492 | 597 | global $globalStatsFilters; |
493 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
598 | + if ($filter_name == '') { |
|
599 | + $filter_name = $this->filter_name; |
|
600 | + } |
|
494 | 601 | if ($year == '' && $month == '') { |
495 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
496 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
602 | + if ($limit) { |
|
603 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
604 | + } else { |
|
605 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
606 | + } |
|
497 | 607 | try { |
498 | 608 | $sth = $this->db->prepare($query); |
499 | 609 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -501,7 +611,9 @@ discard block |
||
501 | 611 | echo "error : ".$e->getMessage(); |
502 | 612 | } |
503 | 613 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
504 | - } else $all = array(); |
|
614 | + } else { |
|
615 | + $all = array(); |
|
616 | + } |
|
505 | 617 | if (empty($all)) { |
506 | 618 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
507 | 619 | if ($filter_name != '') { |
@@ -522,7 +634,9 @@ discard block |
||
522 | 634 | $icao = $value['airport_arrival_icao']; |
523 | 635 | if (isset($all[$icao])) { |
524 | 636 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
525 | - } else $all[$icao] = $value; |
|
637 | + } else { |
|
638 | + $all[$icao] = $value; |
|
639 | + } |
|
526 | 640 | } |
527 | 641 | $count = array(); |
528 | 642 | foreach ($all as $key => $row) { |
@@ -535,13 +649,21 @@ discard block |
||
535 | 649 | } |
536 | 650 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
537 | 651 | global $globalDBdriver, $globalStatsFilters; |
538 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
652 | + if ($filter_name == '') { |
|
653 | + $filter_name = $this->filter_name; |
|
654 | + } |
|
539 | 655 | if ($globalDBdriver == 'mysql') { |
540 | - 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"; |
|
541 | - 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"; |
|
656 | + if ($limit) { |
|
657 | + $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"; |
|
658 | + } else { |
|
659 | + $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"; |
|
660 | + } |
|
542 | 661 | } else { |
543 | - 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"; |
|
544 | - 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"; |
|
662 | + if ($limit) { |
|
663 | + $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"; |
|
664 | + } else { |
|
665 | + $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"; |
|
666 | + } |
|
545 | 667 | } |
546 | 668 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
547 | 669 | try { |
@@ -565,7 +687,9 @@ discard block |
||
565 | 687 | |
566 | 688 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
567 | 689 | global $globalStatsFilters; |
568 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
690 | + if ($filter_name == '') { |
|
691 | + $filter_name = $this->filter_name; |
|
692 | + } |
|
569 | 693 | $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"; |
570 | 694 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
571 | 695 | try { |
@@ -587,7 +711,9 @@ discard block |
||
587 | 711 | } |
588 | 712 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
589 | 713 | global $globalDBdriver, $globalStatsFilters; |
590 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
714 | + if ($filter_name == '') { |
|
715 | + $filter_name = $this->filter_name; |
|
716 | + } |
|
591 | 717 | if ($globalDBdriver == 'mysql') { |
592 | 718 | $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"; |
593 | 719 | } else { |
@@ -613,7 +739,9 @@ discard block |
||
613 | 739 | } |
614 | 740 | public function countAllDates($stats_airline = '',$filter_name = '') { |
615 | 741 | global $globalStatsFilters; |
616 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
742 | + if ($filter_name == '') { |
|
743 | + $filter_name = $this->filter_name; |
|
744 | + } |
|
617 | 745 | $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 ORDER BY date_count DESC"; |
618 | 746 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
619 | 747 | try { |
@@ -635,7 +763,9 @@ discard block |
||
635 | 763 | } |
636 | 764 | public function countAllDatesByAirlines($filter_name = '') { |
637 | 765 | global $globalStatsFilters; |
638 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
766 | + if ($filter_name == '') { |
|
767 | + $filter_name = $this->filter_name; |
|
768 | + } |
|
639 | 769 | $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"; |
640 | 770 | $query_data = array('filter_name' => $filter_name); |
641 | 771 | try { |
@@ -657,7 +787,9 @@ discard block |
||
657 | 787 | } |
658 | 788 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
659 | 789 | global $globalStatsFilters, $globalDBdriver; |
660 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
790 | + if ($filter_name == '') { |
|
791 | + $filter_name = $this->filter_name; |
|
792 | + } |
|
661 | 793 | if ($globalDBdriver == 'mysql') { |
662 | 794 | $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 ORDER BY date_count DESC"; |
663 | 795 | } else { |
@@ -726,7 +858,9 @@ discard block |
||
726 | 858 | } |
727 | 859 | public function countAllMilitaryMonths($filter_name = '') { |
728 | 860 | global $globalStatsFilters; |
729 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
861 | + if ($filter_name == '') { |
|
862 | + $filter_name = $this->filter_name; |
|
863 | + } |
|
730 | 864 | $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"; |
731 | 865 | try { |
732 | 866 | $sth = $this->db->prepare($query); |
@@ -747,9 +881,14 @@ discard block |
||
747 | 881 | } |
748 | 882 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
749 | 883 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
750 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
751 | - 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"; |
|
752 | - 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"; |
|
884 | + if ($filter_name == '') { |
|
885 | + $filter_name = $this->filter_name; |
|
886 | + } |
|
887 | + if ($limit) { |
|
888 | + $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"; |
|
889 | + } else { |
|
890 | + $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"; |
|
891 | + } |
|
753 | 892 | if ($orderby == 'hour') { |
754 | 893 | if ($globalDBdriver == 'mysql') { |
755 | 894 | //$query .= " ORDER BY flight_date ASC"; |
@@ -758,7 +897,9 @@ discard block |
||
758 | 897 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
759 | 898 | } |
760 | 899 | } |
761 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
900 | + if ($orderby == 'count') { |
|
901 | + $query .= " ORDER BY hour_count DESC"; |
|
902 | + } |
|
762 | 903 | try { |
763 | 904 | $sth = $this->db->prepare($query); |
764 | 905 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -779,8 +920,12 @@ discard block |
||
779 | 920 | |
780 | 921 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
781 | 922 | global $globalStatsFilters; |
782 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
783 | - if ($year == '') $year = date('Y'); |
|
923 | + if ($filter_name == '') { |
|
924 | + $filter_name = $this->filter_name; |
|
925 | + } |
|
926 | + if ($year == '') { |
|
927 | + $year = date('Y'); |
|
928 | + } |
|
784 | 929 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
785 | 930 | if (empty($all)) { |
786 | 931 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
@@ -795,8 +940,12 @@ discard block |
||
795 | 940 | } |
796 | 941 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
797 | 942 | global $globalStatsFilters; |
798 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
799 | - if ($year == '') $year = date('Y'); |
|
943 | + if ($filter_name == '') { |
|
944 | + $filter_name = $this->filter_name; |
|
945 | + } |
|
946 | + if ($year == '') { |
|
947 | + $year = date('Y'); |
|
948 | + } |
|
800 | 949 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
801 | 950 | if (empty($all)) { |
802 | 951 | $filters = array(); |
@@ -812,8 +961,12 @@ discard block |
||
812 | 961 | } |
813 | 962 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
814 | 963 | global $globalStatsFilters; |
815 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
816 | - if ($year == '') $year = date('Y'); |
|
964 | + if ($filter_name == '') { |
|
965 | + $filter_name = $this->filter_name; |
|
966 | + } |
|
967 | + if ($year == '') { |
|
968 | + $year = date('Y'); |
|
969 | + } |
|
817 | 970 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
818 | 971 | if (empty($all)) { |
819 | 972 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
@@ -828,7 +981,9 @@ discard block |
||
828 | 981 | } |
829 | 982 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
830 | 983 | global $globalStatsFilters; |
831 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
984 | + if ($filter_name == '') { |
|
985 | + $filter_name = $this->filter_name; |
|
986 | + } |
|
832 | 987 | if ($year == '' && $month == '') { |
833 | 988 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
834 | 989 | try { |
@@ -839,7 +994,9 @@ discard block |
||
839 | 994 | } |
840 | 995 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
841 | 996 | $all = $result[0]['nb']; |
842 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
997 | + } else { |
|
998 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
999 | + } |
|
843 | 1000 | if (empty($all)) { |
844 | 1001 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
845 | 1002 | if ($filter_name != '') { |
@@ -853,7 +1010,9 @@ discard block |
||
853 | 1010 | } |
854 | 1011 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
855 | 1012 | global $globalStatsFilters; |
856 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1013 | + if ($filter_name == '') { |
|
1014 | + $filter_name = $this->filter_name; |
|
1015 | + } |
|
857 | 1016 | if ($year == '' && $month == '') { |
858 | 1017 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
859 | 1018 | try { |
@@ -864,7 +1023,9 @@ discard block |
||
864 | 1023 | } |
865 | 1024 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
866 | 1025 | $all = $result[0]['nb_airline']; |
867 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1026 | + } else { |
|
1027 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1028 | + } |
|
868 | 1029 | if (empty($all)) { |
869 | 1030 | $filters = array(); |
870 | 1031 | $filters = array('year' => $year,'month' => $month); |
@@ -879,7 +1040,9 @@ discard block |
||
879 | 1040 | } |
880 | 1041 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
881 | 1042 | global $globalStatsFilters; |
882 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1043 | + if ($filter_name == '') { |
|
1044 | + $filter_name = $this->filter_name; |
|
1045 | + } |
|
883 | 1046 | if ($year == '' && $month == '') { |
884 | 1047 | $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
885 | 1048 | $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
@@ -907,7 +1070,9 @@ discard block |
||
907 | 1070 | } |
908 | 1071 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
909 | 1072 | global $globalStatsFilters; |
910 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1073 | + if ($filter_name == '') { |
|
1074 | + $filter_name = $this->filter_name; |
|
1075 | + } |
|
911 | 1076 | //if ($year == '') $year = date('Y'); |
912 | 1077 | if ($year == '' && $month == '') { |
913 | 1078 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -936,7 +1101,9 @@ discard block |
||
936 | 1101 | } |
937 | 1102 | |
938 | 1103 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
939 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1104 | + if ($filter_name == '') { |
|
1105 | + $filter_name = $this->filter_name; |
|
1106 | + } |
|
940 | 1107 | $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"; |
941 | 1108 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
942 | 1109 | try { |
@@ -949,7 +1116,9 @@ discard block |
||
949 | 1116 | return $all; |
950 | 1117 | } |
951 | 1118 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
952 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1119 | + if ($filter_name == '') { |
|
1120 | + $filter_name = $this->filter_name; |
|
1121 | + } |
|
953 | 1122 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
954 | 1123 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
955 | 1124 | try { |
@@ -962,7 +1131,9 @@ discard block |
||
962 | 1131 | return $all; |
963 | 1132 | } |
964 | 1133 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
965 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1134 | + if ($filter_name == '') { |
|
1135 | + $filter_name = $this->filter_name; |
|
1136 | + } |
|
966 | 1137 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
967 | 1138 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
968 | 1139 | try { |
@@ -973,7 +1144,9 @@ discard block |
||
973 | 1144 | } |
974 | 1145 | } |
975 | 1146 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
976 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1147 | + if ($filter_name == '') { |
|
1148 | + $filter_name = $this->filter_name; |
|
1149 | + } |
|
977 | 1150 | global $globalArchiveMonths, $globalDBdriver; |
978 | 1151 | if ($globalDBdriver == 'mysql') { |
979 | 1152 | if ($month == '') { |
@@ -1003,7 +1176,9 @@ discard block |
||
1003 | 1176 | } |
1004 | 1177 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1005 | 1178 | global $globalArchiveMonths, $globalDBdriver; |
1006 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1179 | + if ($filter_name == '') { |
|
1180 | + $filter_name = $this->filter_name; |
|
1181 | + } |
|
1007 | 1182 | if ($globalDBdriver == 'mysql') { |
1008 | 1183 | $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"; |
1009 | 1184 | } else { |
@@ -1021,7 +1196,9 @@ discard block |
||
1021 | 1196 | } |
1022 | 1197 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1023 | 1198 | global $globalArchiveMonths, $globalDBdriver; |
1024 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1199 | + if ($filter_name == '') { |
|
1200 | + $filter_name = $this->filter_name; |
|
1201 | + } |
|
1025 | 1202 | if ($globalDBdriver == 'mysql') { |
1026 | 1203 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
1027 | 1204 | } else { |
@@ -1038,7 +1215,9 @@ discard block |
||
1038 | 1215 | } |
1039 | 1216 | public function getStatsAirlineTotal($filter_name = '') { |
1040 | 1217 | global $globalArchiveMonths, $globalDBdriver; |
1041 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1218 | + if ($filter_name == '') { |
|
1219 | + $filter_name = $this->filter_name; |
|
1220 | + } |
|
1042 | 1221 | if ($globalDBdriver == 'mysql') { |
1043 | 1222 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1044 | 1223 | } else { |
@@ -1055,7 +1234,9 @@ discard block |
||
1055 | 1234 | } |
1056 | 1235 | public function getStatsOwnerTotal($filter_name = '') { |
1057 | 1236 | global $globalArchiveMonths, $globalDBdriver; |
1058 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1237 | + if ($filter_name == '') { |
|
1238 | + $filter_name = $this->filter_name; |
|
1239 | + } |
|
1059 | 1240 | if ($globalDBdriver == 'mysql') { |
1060 | 1241 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1061 | 1242 | } else { |
@@ -1072,7 +1253,9 @@ discard block |
||
1072 | 1253 | } |
1073 | 1254 | public function getStatsOwner($owner_name,$filter_name = '') { |
1074 | 1255 | global $globalArchiveMonths, $globalDBdriver; |
1075 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1256 | + if ($filter_name == '') { |
|
1257 | + $filter_name = $this->filter_name; |
|
1258 | + } |
|
1076 | 1259 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1077 | 1260 | try { |
1078 | 1261 | $sth = $this->db->prepare($query); |
@@ -1081,12 +1264,17 @@ discard block |
||
1081 | 1264 | echo "error : ".$e->getMessage(); |
1082 | 1265 | } |
1083 | 1266 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1084 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1085 | - else return 0; |
|
1267 | + if (isset($all[0]['cnt'])) { |
|
1268 | + return $all[0]['cnt']; |
|
1269 | + } else { |
|
1270 | + return 0; |
|
1271 | + } |
|
1086 | 1272 | } |
1087 | 1273 | public function getStatsPilotTotal($filter_name = '') { |
1088 | 1274 | global $globalArchiveMonths, $globalDBdriver; |
1089 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1275 | + if ($filter_name == '') { |
|
1276 | + $filter_name = $this->filter_name; |
|
1277 | + } |
|
1090 | 1278 | if ($globalDBdriver == 'mysql') { |
1091 | 1279 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
1092 | 1280 | } else { |
@@ -1103,7 +1291,9 @@ discard block |
||
1103 | 1291 | } |
1104 | 1292 | public function getStatsPilot($pilot,$filter_name = '') { |
1105 | 1293 | global $globalArchiveMonths, $globalDBdriver; |
1106 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1294 | + if ($filter_name == '') { |
|
1295 | + $filter_name = $this->filter_name; |
|
1296 | + } |
|
1107 | 1297 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1108 | 1298 | try { |
1109 | 1299 | $sth = $this->db->prepare($query); |
@@ -1112,13 +1302,18 @@ discard block |
||
1112 | 1302 | echo "error : ".$e->getMessage(); |
1113 | 1303 | } |
1114 | 1304 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1115 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1116 | - else return 0; |
|
1305 | + if (isset($all[0]['cnt'])) { |
|
1306 | + return $all[0]['cnt']; |
|
1307 | + } else { |
|
1308 | + return 0; |
|
1309 | + } |
|
1117 | 1310 | } |
1118 | 1311 | |
1119 | 1312 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1120 | 1313 | global $globalDBdriver; |
1121 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1314 | + if ($filter_name == '') { |
|
1315 | + $filter_name = $this->filter_name; |
|
1316 | + } |
|
1122 | 1317 | if ($globalDBdriver == 'mysql') { |
1123 | 1318 | $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"; |
1124 | 1319 | } else { |
@@ -1134,7 +1329,9 @@ discard block |
||
1134 | 1329 | } |
1135 | 1330 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1136 | 1331 | global $globalDBdriver; |
1137 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1332 | + if ($filter_name == '') { |
|
1333 | + $filter_name = $this->filter_name; |
|
1334 | + } |
|
1138 | 1335 | if ($globalDBdriver == 'mysql') { |
1139 | 1336 | $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"; |
1140 | 1337 | } else { |
@@ -1520,10 +1717,14 @@ discard block |
||
1520 | 1717 | $Connection = new Connection(); |
1521 | 1718 | date_default_timezone_set('UTC'); |
1522 | 1719 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
1523 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1720 | + if ($globalDebug) { |
|
1721 | + echo 'Update stats !'."\n"; |
|
1722 | + } |
|
1524 | 1723 | if (isset($last_update[0]['value'])) { |
1525 | 1724 | $last_update_day = $last_update[0]['value']; |
1526 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1725 | + } else { |
|
1726 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1727 | + } |
|
1527 | 1728 | $reset = false; |
1528 | 1729 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
1529 | 1730 | if ($globalStatsResetYear) { |
@@ -1532,43 +1733,63 @@ discard block |
||
1532 | 1733 | } |
1533 | 1734 | $Spotter = new Spotter($this->db); |
1534 | 1735 | |
1535 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1736 | + if ($globalDebug) { |
|
1737 | + echo 'Count all aircraft types...'."\n"; |
|
1738 | + } |
|
1536 | 1739 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1537 | 1740 | foreach ($alldata as $number) { |
1538 | 1741 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
1539 | 1742 | } |
1540 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1743 | + if ($globalDebug) { |
|
1744 | + echo 'Count all airlines...'."\n"; |
|
1745 | + } |
|
1541 | 1746 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1542 | 1747 | foreach ($alldata as $number) { |
1543 | 1748 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
1544 | 1749 | } |
1545 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1750 | + if ($globalDebug) { |
|
1751 | + echo 'Count all registrations...'."\n"; |
|
1752 | + } |
|
1546 | 1753 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1547 | 1754 | foreach ($alldata as $number) { |
1548 | 1755 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
1549 | 1756 | } |
1550 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1757 | + if ($globalDebug) { |
|
1758 | + echo 'Count all callsigns...'."\n"; |
|
1759 | + } |
|
1551 | 1760 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1552 | 1761 | foreach ($alldata as $number) { |
1553 | 1762 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1554 | 1763 | } |
1555 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1764 | + if ($globalDebug) { |
|
1765 | + echo 'Count all owners...'."\n"; |
|
1766 | + } |
|
1556 | 1767 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1557 | 1768 | foreach ($alldata as $number) { |
1558 | 1769 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
1559 | 1770 | } |
1560 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1771 | + if ($globalDebug) { |
|
1772 | + echo 'Count all pilots...'."\n"; |
|
1773 | + } |
|
1561 | 1774 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1562 | 1775 | foreach ($alldata as $number) { |
1563 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
1776 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
1777 | + $number['pilot_id'] = $number['pilot_name']; |
|
1778 | + } |
|
1564 | 1779 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
1565 | 1780 | } |
1566 | 1781 | |
1567 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1782 | + if ($globalDebug) { |
|
1783 | + echo 'Count all departure airports...'."\n"; |
|
1784 | + } |
|
1568 | 1785 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1569 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1786 | + if ($globalDebug) { |
|
1787 | + echo 'Count all detected departure airports...'."\n"; |
|
1788 | + } |
|
1570 | 1789 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1571 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1790 | + if ($globalDebug) { |
|
1791 | + echo 'Order departure airports...'."\n"; |
|
1792 | + } |
|
1572 | 1793 | $alldata = array(); |
1573 | 1794 | |
1574 | 1795 | foreach ($pall as $value) { |
@@ -1579,7 +1800,9 @@ discard block |
||
1579 | 1800 | $icao = $value['airport_departure_icao']; |
1580 | 1801 | if (isset($alldata[$icao])) { |
1581 | 1802 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1582 | - } else $alldata[$icao] = $value; |
|
1803 | + } else { |
|
1804 | + $alldata[$icao] = $value; |
|
1805 | + } |
|
1583 | 1806 | } |
1584 | 1807 | $count = array(); |
1585 | 1808 | foreach ($alldata as $key => $row) { |
@@ -1589,11 +1812,17 @@ discard block |
||
1589 | 1812 | foreach ($alldata as $number) { |
1590 | 1813 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
1591 | 1814 | } |
1592 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1815 | + if ($globalDebug) { |
|
1816 | + echo 'Count all arrival airports...'."\n"; |
|
1817 | + } |
|
1593 | 1818 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1594 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1819 | + if ($globalDebug) { |
|
1820 | + echo 'Count all detected arrival airports...'."\n"; |
|
1821 | + } |
|
1595 | 1822 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1596 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1823 | + if ($globalDebug) { |
|
1824 | + echo 'Order arrival airports...'."\n"; |
|
1825 | + } |
|
1597 | 1826 | $alldata = array(); |
1598 | 1827 | foreach ($pall as $value) { |
1599 | 1828 | $icao = $value['airport_arrival_icao']; |
@@ -1603,7 +1832,9 @@ discard block |
||
1603 | 1832 | $icao = $value['airport_arrival_icao']; |
1604 | 1833 | if (isset($alldata[$icao])) { |
1605 | 1834 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1606 | - } else $alldata[$icao] = $value; |
|
1835 | + } else { |
|
1836 | + $alldata[$icao] = $value; |
|
1837 | + } |
|
1607 | 1838 | } |
1608 | 1839 | $count = array(); |
1609 | 1840 | foreach ($alldata as $key => $row) { |
@@ -1614,7 +1845,9 @@ discard block |
||
1614 | 1845 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
1615 | 1846 | } |
1616 | 1847 | if ($Connection->tableExists('countries')) { |
1617 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1848 | + if ($globalDebug) { |
|
1849 | + echo 'Count all flights by countries...'."\n"; |
|
1850 | + } |
|
1618 | 1851 | //$SpotterArchive = new SpotterArchive(); |
1619 | 1852 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1620 | 1853 | $Spotter = new Spotter($this->db); |
@@ -1625,7 +1858,9 @@ discard block |
||
1625 | 1858 | } |
1626 | 1859 | |
1627 | 1860 | if (isset($globalAccidents) && $globalAccidents) { |
1628 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
1861 | + if ($globalDebug) { |
|
1862 | + echo 'Count fatalities stats...'."\n"; |
|
1863 | + } |
|
1629 | 1864 | $Accident = new Accident(); |
1630 | 1865 | $this->deleteStatsByType('fatalities_byyear'); |
1631 | 1866 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -1643,48 +1878,68 @@ discard block |
||
1643 | 1878 | // Add by month using getstat if month finish... |
1644 | 1879 | |
1645 | 1880 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1646 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1881 | + if ($globalDebug) { |
|
1882 | + echo 'Count all flights by months...'."\n"; |
|
1883 | + } |
|
1647 | 1884 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
1648 | 1885 | $filter_last_month = array('since_date' => $last_month); |
1649 | 1886 | $Spotter = new Spotter($this->db); |
1650 | 1887 | $alldata = $Spotter->countAllMonths($filter_last_month); |
1651 | 1888 | $lastyear = false; |
1652 | 1889 | foreach ($alldata as $number) { |
1653 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1890 | + if ($number['year_name'] != date('Y')) { |
|
1891 | + $lastyear = true; |
|
1892 | + } |
|
1654 | 1893 | $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']))); |
1655 | 1894 | } |
1656 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1895 | + if ($globalDebug) { |
|
1896 | + echo 'Count all military flights by months...'."\n"; |
|
1897 | + } |
|
1657 | 1898 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
1658 | 1899 | foreach ($alldata as $number) { |
1659 | 1900 | $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']))); |
1660 | 1901 | } |
1661 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1902 | + if ($globalDebug) { |
|
1903 | + echo 'Count all owners by months...'."\n"; |
|
1904 | + } |
|
1662 | 1905 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
1663 | 1906 | foreach ($alldata as $number) { |
1664 | 1907 | $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']))); |
1665 | 1908 | } |
1666 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1909 | + if ($globalDebug) { |
|
1910 | + echo 'Count all pilots by months...'."\n"; |
|
1911 | + } |
|
1667 | 1912 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
1668 | 1913 | foreach ($alldata as $number) { |
1669 | 1914 | $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']))); |
1670 | 1915 | } |
1671 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1916 | + if ($globalDebug) { |
|
1917 | + echo 'Count all airlines by months...'."\n"; |
|
1918 | + } |
|
1672 | 1919 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
1673 | 1920 | foreach ($alldata as $number) { |
1674 | 1921 | $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']))); |
1675 | 1922 | } |
1676 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1923 | + if ($globalDebug) { |
|
1924 | + echo 'Count all aircrafts by months...'."\n"; |
|
1925 | + } |
|
1677 | 1926 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
1678 | 1927 | foreach ($alldata as $number) { |
1679 | 1928 | $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']))); |
1680 | 1929 | } |
1681 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1930 | + if ($globalDebug) { |
|
1931 | + echo 'Count all real arrivals by months...'."\n"; |
|
1932 | + } |
|
1682 | 1933 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
1683 | 1934 | foreach ($alldata as $number) { |
1684 | 1935 | $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']))); |
1685 | 1936 | } |
1686 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1687 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1937 | + if ($globalDebug) { |
|
1938 | + echo 'Airports data...'."\n"; |
|
1939 | + } |
|
1940 | + if ($globalDebug) { |
|
1941 | + echo '...Departure'."\n"; |
|
1942 | + } |
|
1688 | 1943 | $this->deleteStatAirport('daily'); |
1689 | 1944 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1690 | 1945 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1805,7 +2060,9 @@ discard block |
||
1805 | 2060 | // Count by airlines |
1806 | 2061 | echo '--- Stats by airlines ---'."\n"; |
1807 | 2062 | if ($Connection->tableExists('countries')) { |
1808 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
2063 | + if ($globalDebug) { |
|
2064 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
2065 | + } |
|
1809 | 2066 | $SpotterArchive = new SpotterArchive(); |
1810 | 2067 | //$Spotter = new Spotter($this->db); |
1811 | 2068 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -1814,37 +2071,53 @@ discard block |
||
1814 | 2071 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
1815 | 2072 | } |
1816 | 2073 | } |
1817 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
2074 | + if ($globalDebug) { |
|
2075 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
2076 | + } |
|
1818 | 2077 | $Spotter = new Spotter($this->db); |
1819 | 2078 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1820 | 2079 | foreach ($alldata as $number) { |
1821 | 2080 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
1822 | 2081 | } |
1823 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
2082 | + if ($globalDebug) { |
|
2083 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
2084 | + } |
|
1824 | 2085 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1825 | 2086 | foreach ($alldata as $number) { |
1826 | 2087 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
1827 | 2088 | } |
1828 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
2089 | + if ($globalDebug) { |
|
2090 | + echo 'Count all callsigns by airlines...'."\n"; |
|
2091 | + } |
|
1829 | 2092 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1830 | 2093 | foreach ($alldata as $number) { |
1831 | 2094 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1832 | 2095 | } |
1833 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
2096 | + if ($globalDebug) { |
|
2097 | + echo 'Count all owners by airlines...'."\n"; |
|
2098 | + } |
|
1834 | 2099 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1835 | 2100 | foreach ($alldata as $number) { |
1836 | 2101 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
1837 | 2102 | } |
1838 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
2103 | + if ($globalDebug) { |
|
2104 | + echo 'Count all pilots by airlines...'."\n"; |
|
2105 | + } |
|
1839 | 2106 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1840 | 2107 | foreach ($alldata as $number) { |
1841 | 2108 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
1842 | 2109 | } |
1843 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
2110 | + if ($globalDebug) { |
|
2111 | + echo 'Count all departure airports by airlines...'."\n"; |
|
2112 | + } |
|
1844 | 2113 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1845 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
2114 | + if ($globalDebug) { |
|
2115 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
2116 | + } |
|
1846 | 2117 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1847 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
2118 | + if ($globalDebug) { |
|
2119 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
2120 | + } |
|
1848 | 2121 | //$alldata = array(); |
1849 | 2122 | foreach ($dall as $value) { |
1850 | 2123 | $icao = $value['airport_departure_icao']; |
@@ -1865,11 +2138,17 @@ discard block |
||
1865 | 2138 | foreach ($alldata as $number) { |
1866 | 2139 | 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'],'',$reset); |
1867 | 2140 | } |
1868 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
2141 | + if ($globalDebug) { |
|
2142 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
2143 | + } |
|
1869 | 2144 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1870 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2145 | + if ($globalDebug) { |
|
2146 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2147 | + } |
|
1871 | 2148 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1872 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
2149 | + if ($globalDebug) { |
|
2150 | + echo 'Order arrival airports by airlines...'."\n"; |
|
2151 | + } |
|
1873 | 2152 | //$alldata = array(); |
1874 | 2153 | foreach ($dall as $value) { |
1875 | 2154 | $icao = $value['airport_arrival_icao']; |
@@ -1888,37 +2167,53 @@ discard block |
||
1888 | 2167 | } |
1889 | 2168 | $alldata = $pall; |
1890 | 2169 | foreach ($alldata as $number) { |
1891 | - if ($number['airline_icao'] != '') 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'],'',$reset); |
|
2170 | + if ($number['airline_icao'] != '') { |
|
2171 | + 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'],'',$reset); |
|
2172 | + } |
|
2173 | + } |
|
2174 | + if ($globalDebug) { |
|
2175 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1892 | 2176 | } |
1893 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1894 | 2177 | $Spotter = new Spotter($this->db); |
1895 | 2178 | $alldata = $Spotter->countAllMonthsByAirlines($filter_last_month); |
1896 | 2179 | $lastyear = false; |
1897 | 2180 | foreach ($alldata as $number) { |
1898 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2181 | + if ($number['year_name'] != date('Y')) { |
|
2182 | + $lastyear = true; |
|
2183 | + } |
|
1899 | 2184 | $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']); |
1900 | 2185 | } |
1901 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
2186 | + if ($globalDebug) { |
|
2187 | + echo 'Count all owners by months by airlines...'."\n"; |
|
2188 | + } |
|
1902 | 2189 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
1903 | 2190 | foreach ($alldata as $number) { |
1904 | 2191 | $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']); |
1905 | 2192 | } |
1906 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
2193 | + if ($globalDebug) { |
|
2194 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
2195 | + } |
|
1907 | 2196 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
1908 | 2197 | foreach ($alldata as $number) { |
1909 | 2198 | $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']); |
1910 | 2199 | } |
1911 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2200 | + if ($globalDebug) { |
|
2201 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2202 | + } |
|
1912 | 2203 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
1913 | 2204 | foreach ($alldata as $number) { |
1914 | 2205 | $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']); |
1915 | 2206 | } |
1916 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2207 | + if ($globalDebug) { |
|
2208 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2209 | + } |
|
1917 | 2210 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
1918 | 2211 | foreach ($alldata as $number) { |
1919 | 2212 | $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']); |
1920 | 2213 | } |
1921 | - if ($globalDebug) echo '...Departure'."\n"; |
|
2214 | + if ($globalDebug) { |
|
2215 | + echo '...Departure'."\n"; |
|
2216 | + } |
|
1922 | 2217 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1923 | 2218 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1924 | 2219 | foreach ($dall as $value) { |
@@ -1941,7 +2236,9 @@ discard block |
||
1941 | 2236 | foreach ($alldata as $number) { |
1942 | 2237 | $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']); |
1943 | 2238 | } |
1944 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2239 | + if ($globalDebug) { |
|
2240 | + echo '...Arrival'."\n"; |
|
2241 | + } |
|
1945 | 2242 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1946 | 2243 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1947 | 2244 | foreach ($dall as $value) { |
@@ -1965,13 +2262,19 @@ discard block |
||
1965 | 2262 | $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']); |
1966 | 2263 | } |
1967 | 2264 | |
1968 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1969 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2265 | + if ($globalDebug) { |
|
2266 | + echo 'Flights data...'."\n"; |
|
2267 | + } |
|
2268 | + if ($globalDebug) { |
|
2269 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2270 | + } |
|
1970 | 2271 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
1971 | 2272 | foreach ($alldata as $number) { |
1972 | 2273 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1973 | 2274 | } |
1974 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2275 | + if ($globalDebug) { |
|
2276 | + echo '-> countAllDates...'."\n"; |
|
2277 | + } |
|
1975 | 2278 | //$previousdata = $this->countAllDatesByAirlines(); |
1976 | 2279 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
1977 | 2280 | $values = array(); |
@@ -1984,7 +2287,9 @@ discard block |
||
1984 | 2287 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1985 | 2288 | } |
1986 | 2289 | |
1987 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2290 | + if ($globalDebug) { |
|
2291 | + echo '-> countAllHours...'."\n"; |
|
2292 | + } |
|
1988 | 2293 | $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
1989 | 2294 | foreach ($alldata as $number) { |
1990 | 2295 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
@@ -1992,14 +2297,18 @@ discard block |
||
1992 | 2297 | |
1993 | 2298 | |
1994 | 2299 | // Stats by filters |
1995 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2300 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2301 | + $globalStatsFilters = array(); |
|
2302 | + } |
|
1996 | 2303 | foreach ($globalStatsFilters as $name => $filter) { |
1997 | 2304 | //$filter_name = $filter['name']; |
1998 | 2305 | $filter_name = $name; |
1999 | 2306 | $reset = false; |
2000 | 2307 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
2001 | 2308 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
2002 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
2309 | + if ($globalDebug) { |
|
2310 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
2311 | + } |
|
2003 | 2312 | $this->deleteOldStats($filter_name); |
2004 | 2313 | unset($last_update); |
2005 | 2314 | } |
@@ -2018,7 +2327,9 @@ discard block |
||
2018 | 2327 | |
2019 | 2328 | |
2020 | 2329 | // Count by filter |
2021 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2330 | + if ($globalDebug) { |
|
2331 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2332 | + } |
|
2022 | 2333 | $Spotter = new Spotter($this->db); |
2023 | 2334 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
2024 | 2335 | foreach ($alldata as $number) { |
@@ -2055,7 +2366,9 @@ discard block |
||
2055 | 2366 | $icao = $value['airport_departure_icao']; |
2056 | 2367 | if (isset($alldata[$icao])) { |
2057 | 2368 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
2058 | - } else $alldata[$icao] = $value; |
|
2369 | + } else { |
|
2370 | + $alldata[$icao] = $value; |
|
2371 | + } |
|
2059 | 2372 | } |
2060 | 2373 | $count = array(); |
2061 | 2374 | foreach ($alldata as $key => $row) { |
@@ -2076,7 +2389,9 @@ discard block |
||
2076 | 2389 | $icao = $value['airport_arrival_icao']; |
2077 | 2390 | if (isset($alldata[$icao])) { |
2078 | 2391 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
2079 | - } else $alldata[$icao] = $value; |
|
2392 | + } else { |
|
2393 | + $alldata[$icao] = $value; |
|
2394 | + } |
|
2080 | 2395 | } |
2081 | 2396 | $count = array(); |
2082 | 2397 | foreach ($alldata as $key => $row) { |
@@ -2090,7 +2405,9 @@ discard block |
||
2090 | 2405 | $alldata = $Spotter->countAllMonths($filter); |
2091 | 2406 | $lastyear = false; |
2092 | 2407 | foreach ($alldata as $number) { |
2093 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2408 | + if ($number['year_name'] != date('Y')) { |
|
2409 | + $lastyear = true; |
|
2410 | + } |
|
2094 | 2411 | $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); |
2095 | 2412 | } |
2096 | 2413 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -27,15 +27,21 @@ discard block |
||
27 | 27 | } |
28 | 28 | } |
29 | 29 | } |
30 | -if ($authorize === false) die; |
|
30 | +if ($authorize === false) { |
|
31 | + die; |
|
32 | +} |
|
31 | 33 | |
32 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
34 | +if (isset($globalTracker) && $globalTracker) { |
|
35 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
36 | +} |
|
33 | 37 | if (isset($globalMarine) && $globalMarine) { |
34 | 38 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
35 | 39 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
36 | 40 | } |
37 | 41 | |
38 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
42 | +if (!isset($globalDebug)) { |
|
43 | + $globalDebug = FALSE; |
|
44 | +} |
|
39 | 45 | |
40 | 46 | // Check if schema is at latest version |
41 | 47 | $Connection = new Connection(); |
@@ -45,10 +51,16 @@ discard block |
||
45 | 51 | } |
46 | 52 | |
47 | 53 | if (isset($globalServer) && $globalServer) { |
48 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
54 | + if ($globalDebug) { |
|
55 | + echo "Using Server Mode\n"; |
|
56 | + } |
|
49 | 57 | $SI=new SpotterServer(); |
50 | -} else $SI=new SpotterImport($Connection->db); |
|
51 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
58 | +} else { |
|
59 | + $SI=new SpotterImport($Connection->db); |
|
60 | +} |
|
61 | +if (isset($globalTracker) && $globalTracker) { |
|
62 | + $TI = new TrackerImport($Connection->db); |
|
63 | +} |
|
52 | 64 | if (isset($globalMarine) && $globalMarine) { |
53 | 65 | $AIS = new AIS(); |
54 | 66 | $MI = new MarineImport($Connection->db); |
@@ -57,7 +69,9 @@ discard block |
||
57 | 69 | date_default_timezone_set('UTC'); |
58 | 70 | |
59 | 71 | $buffer = ''; |
60 | -if (isset($_POST)) $buffer = $_POST; |
|
72 | +if (isset($_POST)) { |
|
73 | + $buffer = $_POST; |
|
74 | +} |
|
61 | 75 | $data = array(); |
62 | 76 | if (isset($buffer['type_event']) && isset($buffer['lat']) && isset($buffer['lon'])) { |
63 | 77 | $data['ident'] = $buffer['device_id']; |
@@ -68,15 +82,27 @@ discard block |
||
68 | 82 | //$data['heading'] = $buffer['cap']; // Only N/S/E/W |
69 | 83 | $data['datetime'] = date('Y-m-d H:i:s',$buffer['timestamp']); |
70 | 84 | $data['comment'] = ''; |
71 | - if (isset($buffer['battery']) && $buffer['battery'] != '') $data['comment'] .= 'Battery: '.$buffer['battery'].'% '; |
|
85 | + if (isset($buffer['battery']) && $buffer['battery'] != '') { |
|
86 | + $data['comment'] .= 'Battery: '.$buffer['battery'].'% '; |
|
87 | + } |
|
72 | 88 | //if (isset($buffer['snr']) && $buffer['snr'] != '') $data['comment'] .= 'SNR: '.$buffer['snr'].' '; |
73 | - if (isset($buffer['temp']) && $buffer['temp'] != '') $data['comment'] .= 'Temperature: '.$buffer['temp'].'°C '; |
|
74 | - if (isset($buffer['press']) && $buffer['press'] != '') $data['comment'] .= 'Pressure: '.$buffer['press'].'hPa '; |
|
89 | + if (isset($buffer['temp']) && $buffer['temp'] != '') { |
|
90 | + $data['comment'] .= 'Temperature: '.$buffer['temp'].'°C '; |
|
91 | + } |
|
92 | + if (isset($buffer['press']) && $buffer['press'] != '') { |
|
93 | + $data['comment'] .= 'Pressure: '.$buffer['press'].'hPa '; |
|
94 | + } |
|
75 | 95 | $TI->add($data); |
76 | 96 | unset($data); |
77 | 97 | } |
78 | -if (isset($SI)) $SI->checkAll(); |
|
79 | -if (isset($MI)) $MI->checkAll(); |
|
80 | -if (isset($TI)) $TI->checkAll(); |
|
98 | +if (isset($SI)) { |
|
99 | + $SI->checkAll(); |
|
100 | +} |
|
101 | +if (isset($MI)) { |
|
102 | + $MI->checkAll(); |
|
103 | +} |
|
104 | +if (isset($TI)) { |
|
105 | + $TI->checkAll(); |
|
106 | +} |
|
81 | 107 | |
82 | 108 | ?> |
@@ -61,8 +61,11 @@ |
||
61 | 61 | print '<div class="col-sm-6">'.round($altitude-$geoid,3).'</div>'; |
62 | 62 | } |
63 | 63 | print '<div class="col-sm-6"><b>Earth Gravity Model</b></div>'; |
64 | - if (isset($globalGeoidSource) && $globalGeoidSource != '') $geoidsource = $globalGeoidSource; |
|
65 | - else $geoidsource = 'EGM96-15'; |
|
64 | + if (isset($globalGeoidSource) && $globalGeoidSource != '') { |
|
65 | + $geoidsource = $globalGeoidSource; |
|
66 | + } else { |
|
67 | + $geoidsource = 'EGM96-15'; |
|
68 | + } |
|
66 | 69 | print '<div class="col-sm-6">'.$geoidsource.'</div>'; |
67 | 70 | print '</div>'; |
68 | 71 | } |
@@ -17,7 +17,9 @@ discard block |
||
17 | 17 | curl_setopt($ch, CURLOPT_URL, $url); |
18 | 18 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
19 | 19 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
20 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
20 | + if ($referer != '') { |
|
21 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
22 | + } |
|
21 | 23 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
22 | 24 | curl_setopt($ch, CURLOPT_FILE, $fp); |
23 | 25 | curl_exec($ch); |
@@ -28,12 +30,16 @@ discard block |
||
28 | 30 | public static function gunzip($in_file,$out_file_name = '') { |
29 | 31 | //echo $in_file.' -> '.$out_file_name."\n"; |
30 | 32 | $buffer_size = 4096; // read 4kb at a time |
31 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
33 | + if ($out_file_name == '') { |
|
34 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
35 | + } |
|
32 | 36 | if ($in_file != '' && file_exists($in_file)) { |
33 | 37 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
34 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
35 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
36 | - else { |
|
38 | + if (function_exists('gzopen')) { |
|
39 | + $file = gzopen($in_file,'rb'); |
|
40 | + } elseif (function_exists('gzopen64')) { |
|
41 | + $file = gzopen64($in_file,'rb'); |
|
42 | + } else { |
|
37 | 43 | echo 'gzopen not available'; |
38 | 44 | die; |
39 | 45 | } |
@@ -54,8 +60,12 @@ discard block |
||
54 | 60 | if ($res === TRUE) { |
55 | 61 | $zip->extractTo($path); |
56 | 62 | $zip->close(); |
57 | - } else return false; |
|
58 | - } else return false; |
|
63 | + } else { |
|
64 | + return false; |
|
65 | + } |
|
66 | + } else { |
|
67 | + return false; |
|
68 | + } |
|
59 | 69 | } |
60 | 70 | |
61 | 71 | public static function connect_sqlite($database) { |
@@ -70,7 +80,9 @@ discard block |
||
70 | 80 | public static function retrieve_route_sqlite_to_dest($database_file) { |
71 | 81 | global $globalDebug, $globalTransaction; |
72 | 82 | //$query = 'TRUNCATE TABLE routes'; |
73 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
83 | + if ($globalDebug) { |
|
84 | + echo " - Delete previous routes from DB -"; |
|
85 | + } |
|
74 | 86 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
75 | 87 | $Connection = new Connection(); |
76 | 88 | try { |
@@ -81,7 +93,9 @@ discard block |
||
81 | 93 | return "error : ".$e->getMessage(); |
82 | 94 | } |
83 | 95 | |
84 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
96 | + if ($globalDebug) { |
|
97 | + echo " - Add routes to DB -"; |
|
98 | + } |
|
85 | 99 | update_db::connect_sqlite($database_file); |
86 | 100 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
87 | 101 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -96,15 +110,21 @@ discard block |
||
96 | 110 | $Connection = new Connection(); |
97 | 111 | $sth_dest = $Connection->db->prepare($query_dest); |
98 | 112 | try { |
99 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
113 | + if ($globalTransaction) { |
|
114 | + $Connection->db->beginTransaction(); |
|
115 | + } |
|
100 | 116 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
101 | 117 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | 118 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
103 | 119 | $sth_dest->execute($query_dest_values); |
104 | 120 | } |
105 | - if ($globalTransaction) $Connection->db->commit(); |
|
121 | + if ($globalTransaction) { |
|
122 | + $Connection->db->commit(); |
|
123 | + } |
|
106 | 124 | } catch(PDOException $e) { |
107 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
125 | + if ($globalTransaction) { |
|
126 | + $Connection->db->rollBack(); |
|
127 | + } |
|
108 | 128 | return "error : ".$e->getMessage(); |
109 | 129 | } |
110 | 130 | return ''; |
@@ -112,7 +132,9 @@ discard block |
||
112 | 132 | public static function retrieve_route_oneworld($database_file) { |
113 | 133 | global $globalDebug, $globalTransaction; |
114 | 134 | //$query = 'TRUNCATE TABLE routes'; |
115 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
135 | + if ($globalDebug) { |
|
136 | + echo " - Delete previous routes from DB -"; |
|
137 | + } |
|
116 | 138 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
117 | 139 | $Connection = new Connection(); |
118 | 140 | try { |
@@ -123,14 +145,18 @@ discard block |
||
123 | 145 | return "error : ".$e->getMessage(); |
124 | 146 | } |
125 | 147 | |
126 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
148 | + if ($globalDebug) { |
|
149 | + echo " - Add routes to DB -"; |
|
150 | + } |
|
127 | 151 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
128 | 152 | $Spotter = new Spotter(); |
129 | 153 | if ($fh = fopen($database_file,"r")) { |
130 | 154 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
131 | 155 | $Connection = new Connection(); |
132 | 156 | $sth_dest = $Connection->db->prepare($query_dest); |
133 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
157 | + if ($globalTransaction) { |
|
158 | + $Connection->db->beginTransaction(); |
|
159 | + } |
|
134 | 160 | while (!feof($fh)) { |
135 | 161 | $line = fgetcsv($fh,9999,','); |
136 | 162 | if ($line[0] != '') { |
@@ -139,13 +165,17 @@ discard block |
||
139 | 165 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
140 | 166 | $sth_dest->execute($query_dest_values); |
141 | 167 | } catch(PDOException $e) { |
142 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
168 | + if ($globalTransaction) { |
|
169 | + $Connection->db->rollBack(); |
|
170 | + } |
|
143 | 171 | return "error : ".$e->getMessage(); |
144 | 172 | } |
145 | 173 | } |
146 | 174 | } |
147 | 175 | } |
148 | - if ($globalTransaction) $Connection->db->commit(); |
|
176 | + if ($globalTransaction) { |
|
177 | + $Connection->db->commit(); |
|
178 | + } |
|
149 | 179 | } |
150 | 180 | return ''; |
151 | 181 | } |
@@ -153,7 +183,9 @@ discard block |
||
153 | 183 | public static function retrieve_route_skyteam($database_file) { |
154 | 184 | global $globalDebug, $globalTransaction; |
155 | 185 | //$query = 'TRUNCATE TABLE routes'; |
156 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
186 | + if ($globalDebug) { |
|
187 | + echo " - Delete previous routes from DB -"; |
|
188 | + } |
|
157 | 189 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
158 | 190 | $Connection = new Connection(); |
159 | 191 | try { |
@@ -164,7 +196,9 @@ discard block |
||
164 | 196 | return "error : ".$e->getMessage(); |
165 | 197 | } |
166 | 198 | |
167 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
199 | + if ($globalDebug) { |
|
200 | + echo " - Add routes to DB -"; |
|
201 | + } |
|
168 | 202 | |
169 | 203 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
170 | 204 | $Spotter = new Spotter(); |
@@ -173,7 +207,9 @@ discard block |
||
173 | 207 | $Connection = new Connection(); |
174 | 208 | $sth_dest = $Connection->db->prepare($query_dest); |
175 | 209 | try { |
176 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
210 | + if ($globalTransaction) { |
|
211 | + $Connection->db->beginTransaction(); |
|
212 | + } |
|
177 | 213 | while (!feof($fh)) { |
178 | 214 | $line = fgetcsv($fh,9999,','); |
179 | 215 | if ($line[0] != '') { |
@@ -184,9 +220,13 @@ discard block |
||
184 | 220 | } |
185 | 221 | } |
186 | 222 | } |
187 | - if ($globalTransaction) $Connection->db->commit(); |
|
223 | + if ($globalTransaction) { |
|
224 | + $Connection->db->commit(); |
|
225 | + } |
|
188 | 226 | } catch(PDOException $e) { |
189 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
227 | + if ($globalTransaction) { |
|
228 | + $Connection->db->rollBack(); |
|
229 | + } |
|
190 | 230 | return "error : ".$e->getMessage(); |
191 | 231 | } |
192 | 232 | } |
@@ -229,11 +269,16 @@ discard block |
||
229 | 269 | $sth_dest = $Connection->db->prepare($query_dest); |
230 | 270 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
231 | 271 | try { |
232 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
272 | + if ($globalTransaction) { |
|
273 | + $Connection->db->beginTransaction(); |
|
274 | + } |
|
233 | 275 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
234 | 276 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
235 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
236 | - else $type = null; |
|
277 | + if ($values['UserString4'] == 'M') { |
|
278 | + $type = 'military'; |
|
279 | + } else { |
|
280 | + $type = null; |
|
281 | + } |
|
237 | 282 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
238 | 283 | $sth_dest->execute($query_dest_values); |
239 | 284 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -241,7 +286,9 @@ discard block |
||
241 | 286 | $sth_dest_owner->execute($query_dest_owner_values); |
242 | 287 | } |
243 | 288 | } |
244 | - if ($globalTransaction) $Connection->db->commit(); |
|
289 | + if ($globalTransaction) { |
|
290 | + $Connection->db->commit(); |
|
291 | + } |
|
245 | 292 | } catch(PDOException $e) { |
246 | 293 | return "error : ".$e->getMessage(); |
247 | 294 | } |
@@ -278,7 +325,9 @@ discard block |
||
278 | 325 | $Connection = new Connection(); |
279 | 326 | $sth_dest = $Connection->db->prepare($query_dest); |
280 | 327 | try { |
281 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
328 | + if ($globalTransaction) { |
|
329 | + $Connection->db->beginTransaction(); |
|
330 | + } |
|
282 | 331 | while (!feof($fh)) { |
283 | 332 | $values = array(); |
284 | 333 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -289,7 +338,9 @@ discard block |
||
289 | 338 | // Check if we can find ICAO, else set it to GLID |
290 | 339 | $aircraft_name_split = explode(' ',$aircraft_name); |
291 | 340 | $search_more = ''; |
292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
341 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
342 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
343 | + } |
|
293 | 344 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
294 | 345 | $sth_search = $Connection->db->prepare($query_search); |
295 | 346 | try { |
@@ -302,7 +353,9 @@ discard block |
||
302 | 353 | } catch(PDOException $e) { |
303 | 354 | return "error : ".$e->getMessage(); |
304 | 355 | } |
305 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
356 | + if (!isset($values['ICAOTypeCode'])) { |
|
357 | + $values['ICAOTypeCode'] = 'GLID'; |
|
358 | + } |
|
306 | 359 | // Add data to db |
307 | 360 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
308 | 361 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -311,7 +364,9 @@ discard block |
||
311 | 364 | $sth_dest->execute($query_dest_values); |
312 | 365 | } |
313 | 366 | } |
314 | - if ($globalTransaction) $Connection->db->commit(); |
|
367 | + if ($globalTransaction) { |
|
368 | + $Connection->db->commit(); |
|
369 | + } |
|
315 | 370 | } catch(PDOException $e) { |
316 | 371 | return "error : ".$e->getMessage(); |
317 | 372 | } |
@@ -347,7 +402,9 @@ discard block |
||
347 | 402 | $Connection = new Connection(); |
348 | 403 | $sth_dest = $Connection->db->prepare($query_dest); |
349 | 404 | try { |
350 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
405 | + if ($globalTransaction) { |
|
406 | + $Connection->db->beginTransaction(); |
|
407 | + } |
|
351 | 408 | $tmp = fgetcsv($fh,9999,',',"'"); |
352 | 409 | while (!feof($fh)) { |
353 | 410 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -361,13 +418,17 @@ discard block |
||
361 | 418 | // Check if we can find ICAO, else set it to GLID |
362 | 419 | $aircraft_name_split = explode(' ',$aircraft_name); |
363 | 420 | $search_more = ''; |
364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
421 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
422 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
423 | + } |
|
365 | 424 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
366 | 425 | $sth_search = $Connection->db->prepare($query_search); |
367 | 426 | try { |
368 | 427 | $sth_search->execute(); |
369 | 428 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
429 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
430 | + $values['ICAOTypeCode'] = $result['icao']; |
|
431 | + } |
|
371 | 432 | } catch(PDOException $e) { |
372 | 433 | return "error : ".$e->getMessage(); |
373 | 434 | } |
@@ -380,7 +441,9 @@ discard block |
||
380 | 441 | $sth_dest->execute($query_dest_values); |
381 | 442 | } |
382 | 443 | } |
383 | - if ($globalTransaction) $Connection->db->commit(); |
|
444 | + if ($globalTransaction) { |
|
445 | + $Connection->db->commit(); |
|
446 | + } |
|
384 | 447 | } catch(PDOException $e) { |
385 | 448 | return "error : ".$e->getMessage(); |
386 | 449 | } |
@@ -419,7 +482,9 @@ discard block |
||
419 | 482 | $sth_dest = $Connection->db->prepare($query_dest); |
420 | 483 | $sth_modes = $Connection->db->prepare($query_modes); |
421 | 484 | try { |
422 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
485 | + if ($globalTransaction) { |
|
486 | + $Connection->db->beginTransaction(); |
|
487 | + } |
|
423 | 488 | $tmp = fgetcsv($fh,9999,',','"'); |
424 | 489 | while (!feof($fh)) { |
425 | 490 | $line = fgetcsv($fh,9999,',','"'); |
@@ -429,16 +494,22 @@ discard block |
||
429 | 494 | $values['registration'] = $line[0]; |
430 | 495 | $values['base'] = $line[4]; |
431 | 496 | $values['owner'] = $line[5]; |
432 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
497 | + if ($line[6] == '') { |
|
498 | + $values['date_first_reg'] = null; |
|
499 | + } else { |
|
500 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
501 | + } |
|
434 | 502 | $values['cancel'] = $line[7]; |
435 | 503 | } elseif ($country == 'EI') { |
436 | 504 | // TODO : add modeS & reg to aircraft_modes |
437 | 505 | $values['registration'] = $line[0]; |
438 | 506 | $values['base'] = $line[3]; |
439 | 507 | $values['owner'] = $line[2]; |
440 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
508 | + if ($line[1] == '') { |
|
509 | + $values['date_first_reg'] = null; |
|
510 | + } else { |
|
511 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
512 | + } |
|
442 | 513 | $values['cancel'] = ''; |
443 | 514 | $values['modes'] = $line[7]; |
444 | 515 | $values['icao'] = $line[8]; |
@@ -457,16 +528,22 @@ discard block |
||
457 | 528 | $values['registration'] = $line[3]; |
458 | 529 | $values['base'] = null; |
459 | 530 | $values['owner'] = $line[5]; |
460 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
531 | + if ($line[18] == '') { |
|
532 | + $values['date_first_reg'] = null; |
|
533 | + } else { |
|
534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
535 | + } |
|
462 | 536 | $values['cancel'] = ''; |
463 | 537 | } elseif ($country == 'VH') { |
464 | 538 | // TODO : add modeS & reg to aircraft_modes |
465 | 539 | $values['registration'] = $line[0]; |
466 | 540 | $values['base'] = null; |
467 | 541 | $values['owner'] = $line[12]; |
468 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
542 | + if ($line[28] == '') { |
|
543 | + $values['date_first_reg'] = null; |
|
544 | + } else { |
|
545 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
546 | + } |
|
470 | 547 | |
471 | 548 | $values['cancel'] = $line[39]; |
472 | 549 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -485,29 +562,41 @@ discard block |
||
485 | 562 | $values['registration'] = $line[0]; |
486 | 563 | $values['base'] = null; |
487 | 564 | $values['owner'] = $line[8]; |
488 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
565 | + if ($line[7] == '') { |
|
566 | + $values['date_first_reg'] = null; |
|
567 | + } else { |
|
568 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
569 | + } |
|
490 | 570 | $values['cancel'] = ''; |
491 | 571 | } elseif ($country == 'PP') { |
492 | 572 | $values['registration'] = $line[0]; |
493 | 573 | $values['base'] = null; |
494 | 574 | $values['owner'] = $line[4]; |
495 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
575 | + if ($line[6] == '') { |
|
576 | + $values['date_first_reg'] = null; |
|
577 | + } else { |
|
578 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
579 | + } |
|
497 | 580 | $values['cancel'] = $line[7]; |
498 | 581 | } elseif ($country == 'E7') { |
499 | 582 | $values['registration'] = $line[0]; |
500 | 583 | $values['base'] = null; |
501 | 584 | $values['owner'] = $line[4]; |
502 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
585 | + if ($line[5] == '') { |
|
586 | + $values['date_first_reg'] = null; |
|
587 | + } else { |
|
588 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
589 | + } |
|
504 | 590 | $values['cancel'] = ''; |
505 | 591 | } elseif ($country == '8Q') { |
506 | 592 | $values['registration'] = $line[0]; |
507 | 593 | $values['base'] = null; |
508 | 594 | $values['owner'] = $line[3]; |
509 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
595 | + if ($line[7] == '') { |
|
596 | + $values['date_first_reg'] = null; |
|
597 | + } else { |
|
598 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
599 | + } |
|
511 | 600 | $values['cancel'] = ''; |
512 | 601 | } elseif ($country == 'ZK') { |
513 | 602 | $values['registration'] = $line[0]; |
@@ -552,7 +641,9 @@ discard block |
||
552 | 641 | $sth_modes->execute($query_modes_values); |
553 | 642 | } |
554 | 643 | } |
555 | - if ($globalTransaction) $Connection->db->commit(); |
|
644 | + if ($globalTransaction) { |
|
645 | + $Connection->db->commit(); |
|
646 | + } |
|
556 | 647 | } catch(PDOException $e) { |
557 | 648 | return "error : ".$e->getMessage(); |
558 | 649 | } |
@@ -688,25 +779,45 @@ discard block |
||
688 | 779 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
689 | 780 | $Connection = new Connection(); |
690 | 781 | $sth_dest = $Connection->db->prepare($query_dest); |
691 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
782 | + if ($globalTransaction) { |
|
783 | + $Connection->db->beginTransaction(); |
|
784 | + } |
|
692 | 785 | |
693 | 786 | $i = 0; |
694 | 787 | while($row = sparql_fetch_array($result)) |
695 | 788 | { |
696 | 789 | if ($i >= 1) { |
697 | 790 | //print_r($row); |
698 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
699 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
700 | - if (!isset($row['type'])) $row['type'] = ''; |
|
701 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
791 | + if (!isset($row['iata'])) { |
|
792 | + $row['iata'] = ''; |
|
793 | + } |
|
794 | + if (!isset($row['icao'])) { |
|
795 | + $row['icao'] = ''; |
|
796 | + } |
|
797 | + if (!isset($row['type'])) { |
|
798 | + $row['type'] = ''; |
|
799 | + } |
|
800 | + if (!isset($row['altitude'])) { |
|
801 | + $row['altitude'] = ''; |
|
802 | + } |
|
702 | 803 | if (isset($row['city_bis'])) { |
703 | 804 | $row['city'] = $row['city_bis']; |
704 | 805 | } |
705 | - if (!isset($row['city'])) $row['city'] = ''; |
|
706 | - if (!isset($row['country'])) $row['country'] = ''; |
|
707 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
708 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
709 | - if (!isset($row['name'])) continue; |
|
806 | + if (!isset($row['city'])) { |
|
807 | + $row['city'] = ''; |
|
808 | + } |
|
809 | + if (!isset($row['country'])) { |
|
810 | + $row['country'] = ''; |
|
811 | + } |
|
812 | + if (!isset($row['homepage'])) { |
|
813 | + $row['homepage'] = ''; |
|
814 | + } |
|
815 | + if (!isset($row['wikipedia_page'])) { |
|
816 | + $row['wikipedia_page'] = ''; |
|
817 | + } |
|
818 | + if (!isset($row['name'])) { |
|
819 | + continue; |
|
820 | + } |
|
710 | 821 | if (!isset($row['image'])) { |
711 | 822 | $row['image'] = ''; |
712 | 823 | $row['image_thumb'] = ''; |
@@ -762,7 +873,9 @@ discard block |
||
762 | 873 | |
763 | 874 | $i++; |
764 | 875 | } |
765 | - if ($globalTransaction) $Connection->db->commit(); |
|
876 | + if ($globalTransaction) { |
|
877 | + $Connection->db->commit(); |
|
878 | + } |
|
766 | 879 | /* |
767 | 880 | echo "Delete duplicate rows...\n"; |
768 | 881 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -805,7 +918,9 @@ discard block |
||
805 | 918 | $delimiter = ','; |
806 | 919 | $out_file = $tmp_dir.'airports.csv'; |
807 | 920 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
808 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
921 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
922 | + return FALSE; |
|
923 | + } |
|
809 | 924 | echo "Add data from ourairports.com...\n"; |
810 | 925 | |
811 | 926 | $header = NULL; |
@@ -815,8 +930,9 @@ discard block |
||
815 | 930 | //$Connection->db->beginTransaction(); |
816 | 931 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
817 | 932 | { |
818 | - if(!$header) $header = $row; |
|
819 | - else { |
|
933 | + if(!$header) { |
|
934 | + $header = $row; |
|
935 | + } else { |
|
820 | 936 | $data = array(); |
821 | 937 | $data = array_combine($header, $row); |
822 | 938 | try { |
@@ -857,7 +973,9 @@ discard block |
||
857 | 973 | echo "Download data from another free database...\n"; |
858 | 974 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
859 | 975 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
860 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
976 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
977 | + return FALSE; |
|
978 | + } |
|
861 | 979 | update_db::unzip($out_file); |
862 | 980 | $header = NULL; |
863 | 981 | echo "Add data from another free database...\n"; |
@@ -868,8 +986,9 @@ discard block |
||
868 | 986 | //$Connection->db->beginTransaction(); |
869 | 987 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
870 | 988 | { |
871 | - if(!$header) $header = $row; |
|
872 | - else { |
|
989 | + if(!$header) { |
|
990 | + $header = $row; |
|
991 | + } else { |
|
873 | 992 | $data = $row; |
874 | 993 | |
875 | 994 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1042,7 +1161,9 @@ discard block |
||
1042 | 1161 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
1043 | 1162 | { |
1044 | 1163 | $i = 0; |
1045 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1164 | + if ($globalTransaction) { |
|
1165 | + $Connection->db->beginTransaction(); |
|
1166 | + } |
|
1046 | 1167 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1047 | 1168 | { |
1048 | 1169 | if ($i > 0) { |
@@ -1055,7 +1176,9 @@ discard block |
||
1055 | 1176 | } |
1056 | 1177 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
1057 | 1178 | if (!empty($result_search)) { |
1058 | - if ($globalDebug) echo '.'; |
|
1179 | + if ($globalDebug) { |
|
1180 | + echo '.'; |
|
1181 | + } |
|
1059 | 1182 | //if ($globalDBdriver == 'mysql') { |
1060 | 1183 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
1061 | 1184 | //} else { |
@@ -1077,8 +1200,12 @@ discard block |
||
1077 | 1200 | } |
1078 | 1201 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1079 | 1202 | if (!empty($result_search_mfr)) { |
1080 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1081 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1203 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1204 | + $data[16] = $data[23]; |
|
1205 | + } |
|
1206 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1207 | + $data[16] = $data[15]; |
|
1208 | + } |
|
1082 | 1209 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1083 | 1210 | try { |
1084 | 1211 | $sthf = $Connection->db->prepare($queryf); |
@@ -1089,7 +1216,9 @@ discard block |
||
1089 | 1216 | } |
1090 | 1217 | } |
1091 | 1218 | if (strtotime($data[29]) > time()) { |
1092 | - if ($globalDebug) echo 'i'; |
|
1219 | + if ($globalDebug) { |
|
1220 | + echo 'i'; |
|
1221 | + } |
|
1093 | 1222 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1094 | 1223 | try { |
1095 | 1224 | $sth = $Connection->db->prepare($query); |
@@ -1100,13 +1229,19 @@ discard block |
||
1100 | 1229 | } |
1101 | 1230 | } |
1102 | 1231 | if ($i % 90 == 0) { |
1103 | - if ($globalTransaction) $Connection->db->commit(); |
|
1104 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1232 | + if ($globalTransaction) { |
|
1233 | + $Connection->db->commit(); |
|
1234 | + } |
|
1235 | + if ($globalTransaction) { |
|
1236 | + $Connection->db->beginTransaction(); |
|
1237 | + } |
|
1105 | 1238 | } |
1106 | 1239 | $i++; |
1107 | 1240 | } |
1108 | 1241 | fclose($handle); |
1109 | - if ($globalTransaction) $Connection->db->commit(); |
|
1242 | + if ($globalTransaction) { |
|
1243 | + $Connection->db->commit(); |
|
1244 | + } |
|
1110 | 1245 | } |
1111 | 1246 | print_r($mfr); |
1112 | 1247 | return ''; |
@@ -1131,11 +1266,15 @@ discard block |
||
1131 | 1266 | $i = 0; |
1132 | 1267 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1133 | 1268 | //$Connection->db->beginTransaction(); |
1134 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1269 | + if ($globalTransaction) { |
|
1270 | + $Connection->db->beginTransaction(); |
|
1271 | + } |
|
1135 | 1272 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1136 | 1273 | { |
1137 | 1274 | if ($i > 0) { |
1138 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1275 | + if ($data[1] == 'NULL') { |
|
1276 | + $data[1] = $data[0]; |
|
1277 | + } |
|
1139 | 1278 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1140 | 1279 | try { |
1141 | 1280 | $sth = $Connection->db->prepare($query); |
@@ -1147,7 +1286,9 @@ discard block |
||
1147 | 1286 | $i++; |
1148 | 1287 | } |
1149 | 1288 | fclose($handle); |
1150 | - if ($globalTransaction) $Connection->db->commit(); |
|
1289 | + if ($globalTransaction) { |
|
1290 | + $Connection->db->commit(); |
|
1291 | + } |
|
1151 | 1292 | } |
1152 | 1293 | return ''; |
1153 | 1294 | } |
@@ -1168,7 +1309,9 @@ discard block |
||
1168 | 1309 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1169 | 1310 | { |
1170 | 1311 | $i = 0; |
1171 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1312 | + if ($globalTransaction) { |
|
1313 | + $Connection->db->beginTransaction(); |
|
1314 | + } |
|
1172 | 1315 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1173 | 1316 | { |
1174 | 1317 | if ($i > 0) { |
@@ -1184,7 +1327,9 @@ discard block |
||
1184 | 1327 | $i++; |
1185 | 1328 | } |
1186 | 1329 | fclose($handle); |
1187 | - if ($globalTransaction) $Connection->db->commit(); |
|
1330 | + if ($globalTransaction) { |
|
1331 | + $Connection->db->commit(); |
|
1332 | + } |
|
1188 | 1333 | } |
1189 | 1334 | return ''; |
1190 | 1335 | } |
@@ -1204,7 +1349,9 @@ discard block |
||
1204 | 1349 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
1205 | 1350 | { |
1206 | 1351 | $i = 0; |
1207 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1352 | + if ($globalTransaction) { |
|
1353 | + $Connection->db->beginTransaction(); |
|
1354 | + } |
|
1208 | 1355 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1209 | 1356 | { |
1210 | 1357 | if ($i > 0) { |
@@ -1213,13 +1360,17 @@ discard block |
||
1213 | 1360 | $sth = $Connection->db->prepare($query); |
1214 | 1361 | $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
1215 | 1362 | } catch(PDOException $e) { |
1216 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1363 | + if ($globalDebug) { |
|
1364 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1365 | + } |
|
1217 | 1366 | } |
1218 | 1367 | } |
1219 | 1368 | $i++; |
1220 | 1369 | } |
1221 | 1370 | fclose($handle); |
1222 | - if ($globalTransaction) $Connection->db->commit(); |
|
1371 | + if ($globalTransaction) { |
|
1372 | + $Connection->db->commit(); |
|
1373 | + } |
|
1223 | 1374 | } |
1224 | 1375 | return ''; |
1225 | 1376 | } |
@@ -1244,7 +1395,9 @@ discard block |
||
1244 | 1395 | $i = 0; |
1245 | 1396 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1246 | 1397 | //$Connection->db->beginTransaction(); |
1247 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1398 | + if ($globalTransaction) { |
|
1399 | + $Connection->db->beginTransaction(); |
|
1400 | + } |
|
1248 | 1401 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1249 | 1402 | { |
1250 | 1403 | if ($i > 0) { |
@@ -1260,7 +1413,9 @@ discard block |
||
1260 | 1413 | $i++; |
1261 | 1414 | } |
1262 | 1415 | fclose($handle); |
1263 | - if ($globalTransaction) $Connection->db->commit(); |
|
1416 | + if ($globalTransaction) { |
|
1417 | + $Connection->db->commit(); |
|
1418 | + } |
|
1264 | 1419 | } |
1265 | 1420 | return ''; |
1266 | 1421 | } |
@@ -1279,7 +1434,9 @@ discard block |
||
1279 | 1434 | $Connection = new Connection(); |
1280 | 1435 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1281 | 1436 | { |
1282 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1437 | + if ($globalTransaction) { |
|
1438 | + $Connection->db->beginTransaction(); |
|
1439 | + } |
|
1283 | 1440 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1284 | 1441 | { |
1285 | 1442 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1294,7 +1451,9 @@ discard block |
||
1294 | 1451 | } |
1295 | 1452 | } |
1296 | 1453 | fclose($handle); |
1297 | - if ($globalTransaction) $Connection->db->commit(); |
|
1454 | + if ($globalTransaction) { |
|
1455 | + $Connection->db->commit(); |
|
1456 | + } |
|
1298 | 1457 | } |
1299 | 1458 | return ''; |
1300 | 1459 | } |
@@ -1445,7 +1604,9 @@ discard block |
||
1445 | 1604 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1446 | 1605 | { |
1447 | 1606 | $i = 0; |
1448 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1607 | + if ($globalTransaction) { |
|
1608 | + $Connection->db->beginTransaction(); |
|
1609 | + } |
|
1449 | 1610 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1450 | 1611 | { |
1451 | 1612 | $i++; |
@@ -1473,7 +1634,9 @@ discard block |
||
1473 | 1634 | } |
1474 | 1635 | } |
1475 | 1636 | fclose($handle); |
1476 | - if ($globalTransaction) $Connection->db->commit(); |
|
1637 | + if ($globalTransaction) { |
|
1638 | + $Connection->db->commit(); |
|
1639 | + } |
|
1477 | 1640 | } |
1478 | 1641 | return ''; |
1479 | 1642 | } |
@@ -1496,7 +1659,9 @@ discard block |
||
1496 | 1659 | $Connection = new Connection(); |
1497 | 1660 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1498 | 1661 | { |
1499 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1662 | + if ($globalTransaction) { |
|
1663 | + $Connection->db->beginTransaction(); |
|
1664 | + } |
|
1500 | 1665 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1501 | 1666 | { |
1502 | 1667 | if(count($row) > 1) { |
@@ -1510,7 +1675,9 @@ discard block |
||
1510 | 1675 | } |
1511 | 1676 | } |
1512 | 1677 | fclose($handle); |
1513 | - if ($globalTransaction) $Connection->db->commit(); |
|
1678 | + if ($globalTransaction) { |
|
1679 | + $Connection->db->commit(); |
|
1680 | + } |
|
1514 | 1681 | } |
1515 | 1682 | return ''; |
1516 | 1683 | } |
@@ -1530,8 +1697,9 @@ discard block |
||
1530 | 1697 | } |
1531 | 1698 | |
1532 | 1699 | |
1533 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1534 | - else { |
|
1700 | + if ($globalDBdriver == 'mysql') { |
|
1701 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1702 | + } else { |
|
1535 | 1703 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1536 | 1704 | $query = "CREATE EXTENSION postgis"; |
1537 | 1705 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1550,20 +1718,30 @@ discard block |
||
1550 | 1718 | global $tmp_dir, $globalDebug; |
1551 | 1719 | include_once('class.create_db.php'); |
1552 | 1720 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1553 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
1721 | + if ($globalDebug) { |
|
1722 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
1723 | + } |
|
1554 | 1724 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1555 | 1725 | $error = ''; |
1556 | 1726 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1557 | - if ($globalDebug) echo "Gunzip..."; |
|
1727 | + if ($globalDebug) { |
|
1728 | + echo "Gunzip..."; |
|
1729 | + } |
|
1558 | 1730 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1559 | - if ($globalDebug) echo "Add to DB..."; |
|
1731 | + if ($globalDebug) { |
|
1732 | + echo "Add to DB..."; |
|
1733 | + } |
|
1560 | 1734 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1561 | 1735 | $NOTAM = new NOTAM(); |
1562 | 1736 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1563 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1737 | + } else { |
|
1738 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1739 | + } |
|
1564 | 1740 | if ($error != '') { |
1565 | 1741 | return $error; |
1566 | - } elseif ($globalDebug) echo "Done\n"; |
|
1742 | + } elseif ($globalDebug) { |
|
1743 | + echo "Done\n"; |
|
1744 | + } |
|
1567 | 1745 | return ''; |
1568 | 1746 | } |
1569 | 1747 | |
@@ -1617,67 +1795,111 @@ discard block |
||
1617 | 1795 | //if ($globalDebug) echo "IVAO : Download..."; |
1618 | 1796 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
1619 | 1797 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
1620 | - if ($globalDebug) echo "Unzip..."; |
|
1798 | + if ($globalDebug) { |
|
1799 | + echo "Unzip..."; |
|
1800 | + } |
|
1621 | 1801 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
1622 | - if ($globalDebug) echo "Add to DB..."; |
|
1802 | + if ($globalDebug) { |
|
1803 | + echo "Add to DB..."; |
|
1804 | + } |
|
1623 | 1805 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1624 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
1806 | + if ($globalDebug) { |
|
1807 | + echo "Copy airlines logos to airlines images directory..."; |
|
1808 | + } |
|
1625 | 1809 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1626 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1627 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1628 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1810 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
1811 | + $error = "Failed to copy airlines logo."; |
|
1812 | + } |
|
1813 | + } else { |
|
1814 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1815 | + } |
|
1816 | + } else { |
|
1817 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1818 | + } |
|
1629 | 1819 | if ($error != '') { |
1630 | 1820 | return $error; |
1631 | - } elseif ($globalDebug) echo "Done\n"; |
|
1821 | + } elseif ($globalDebug) { |
|
1822 | + echo "Done\n"; |
|
1823 | + } |
|
1632 | 1824 | return ''; |
1633 | 1825 | } |
1634 | 1826 | |
1635 | 1827 | public static function update_routes() { |
1636 | 1828 | global $tmp_dir, $globalDebug; |
1637 | 1829 | $error = ''; |
1638 | - if ($globalDebug) echo "Routes : Download..."; |
|
1830 | + if ($globalDebug) { |
|
1831 | + echo "Routes : Download..."; |
|
1832 | + } |
|
1639 | 1833 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
1640 | 1834 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1641 | - if ($globalDebug) echo "Gunzip..."; |
|
1835 | + if ($globalDebug) { |
|
1836 | + echo "Gunzip..."; |
|
1837 | + } |
|
1642 | 1838 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
1643 | - if ($globalDebug) echo "Add to DB..."; |
|
1839 | + if ($globalDebug) { |
|
1840 | + echo "Add to DB..."; |
|
1841 | + } |
|
1644 | 1842 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
1645 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1843 | + } else { |
|
1844 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1845 | + } |
|
1646 | 1846 | if ($error != '') { |
1647 | 1847 | return $error; |
1648 | - } elseif ($globalDebug) echo "Done\n"; |
|
1848 | + } elseif ($globalDebug) { |
|
1849 | + echo "Done\n"; |
|
1850 | + } |
|
1649 | 1851 | return ''; |
1650 | 1852 | } |
1651 | 1853 | public static function update_oneworld() { |
1652 | 1854 | global $tmp_dir, $globalDebug; |
1653 | 1855 | $error = ''; |
1654 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
1856 | + if ($globalDebug) { |
|
1857 | + echo "Schedules Oneworld : Download..."; |
|
1858 | + } |
|
1655 | 1859 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
1656 | 1860 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1657 | - if ($globalDebug) echo "Gunzip..."; |
|
1861 | + if ($globalDebug) { |
|
1862 | + echo "Gunzip..."; |
|
1863 | + } |
|
1658 | 1864 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
1659 | - if ($globalDebug) echo "Add to DB..."; |
|
1865 | + if ($globalDebug) { |
|
1866 | + echo "Add to DB..."; |
|
1867 | + } |
|
1660 | 1868 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
1661 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1869 | + } else { |
|
1870 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1871 | + } |
|
1662 | 1872 | if ($error != '') { |
1663 | 1873 | return $error; |
1664 | - } elseif ($globalDebug) echo "Done\n"; |
|
1874 | + } elseif ($globalDebug) { |
|
1875 | + echo "Done\n"; |
|
1876 | + } |
|
1665 | 1877 | return ''; |
1666 | 1878 | } |
1667 | 1879 | public static function update_skyteam() { |
1668 | 1880 | global $tmp_dir, $globalDebug; |
1669 | 1881 | $error = ''; |
1670 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
1882 | + if ($globalDebug) { |
|
1883 | + echo "Schedules Skyteam : Download..."; |
|
1884 | + } |
|
1671 | 1885 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
1672 | 1886 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1673 | - if ($globalDebug) echo "Gunzip..."; |
|
1887 | + if ($globalDebug) { |
|
1888 | + echo "Gunzip..."; |
|
1889 | + } |
|
1674 | 1890 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
1675 | - if ($globalDebug) echo "Add to DB..."; |
|
1891 | + if ($globalDebug) { |
|
1892 | + echo "Add to DB..."; |
|
1893 | + } |
|
1676 | 1894 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
1677 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1895 | + } else { |
|
1896 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1897 | + } |
|
1678 | 1898 | if ($error != '') { |
1679 | 1899 | return $error; |
1680 | - } elseif ($globalDebug) echo "Done\n"; |
|
1900 | + } elseif ($globalDebug) { |
|
1901 | + echo "Done\n"; |
|
1902 | + } |
|
1681 | 1903 | return ''; |
1682 | 1904 | } |
1683 | 1905 | public static function update_ModeS() { |
@@ -1694,355 +1916,619 @@ discard block |
||
1694 | 1916 | exit; |
1695 | 1917 | } elseif ($globalDebug) echo "Done\n"; |
1696 | 1918 | */ |
1697 | - if ($globalDebug) echo "Modes : Download..."; |
|
1698 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1919 | + if ($globalDebug) { |
|
1920 | + echo "Modes : Download..."; |
|
1921 | + } |
|
1922 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1699 | 1923 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
1700 | 1924 | |
1701 | 1925 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1702 | 1926 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
1703 | - if ($globalDebug) echo "Unzip..."; |
|
1704 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1927 | + if ($globalDebug) { |
|
1928 | + echo "Unzip..."; |
|
1929 | + } |
|
1930 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1705 | 1931 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
1706 | - if ($globalDebug) echo "Add to DB..."; |
|
1932 | + if ($globalDebug) { |
|
1933 | + echo "Add to DB..."; |
|
1934 | + } |
|
1707 | 1935 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
1708 | 1936 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
1709 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1937 | + } else { |
|
1938 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1939 | + } |
|
1710 | 1940 | if ($error != '') { |
1711 | 1941 | return $error; |
1712 | - } elseif ($globalDebug) echo "Done\n"; |
|
1942 | + } elseif ($globalDebug) { |
|
1943 | + echo "Done\n"; |
|
1944 | + } |
|
1713 | 1945 | return ''; |
1714 | 1946 | } |
1715 | 1947 | |
1716 | 1948 | public static function update_ModeS_faa() { |
1717 | 1949 | global $tmp_dir, $globalDebug; |
1718 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
1950 | + if ($globalDebug) { |
|
1951 | + echo "Modes FAA: Download..."; |
|
1952 | + } |
|
1719 | 1953 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
1720 | 1954 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1721 | - if ($globalDebug) echo "Unzip..."; |
|
1955 | + if ($globalDebug) { |
|
1956 | + echo "Unzip..."; |
|
1957 | + } |
|
1722 | 1958 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
1723 | - if ($globalDebug) echo "Add to DB..."; |
|
1959 | + if ($globalDebug) { |
|
1960 | + echo "Add to DB..."; |
|
1961 | + } |
|
1724 | 1962 | $error = update_db::modes_faa(); |
1725 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1963 | + } else { |
|
1964 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1965 | + } |
|
1726 | 1966 | if ($error != '') { |
1727 | 1967 | return $error; |
1728 | - } elseif ($globalDebug) echo "Done\n"; |
|
1968 | + } elseif ($globalDebug) { |
|
1969 | + echo "Done\n"; |
|
1970 | + } |
|
1729 | 1971 | return ''; |
1730 | 1972 | } |
1731 | 1973 | |
1732 | 1974 | public static function update_ModeS_flarm() { |
1733 | 1975 | global $tmp_dir, $globalDebug; |
1734 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
1976 | + if ($globalDebug) { |
|
1977 | + echo "Modes Flarmnet: Download..."; |
|
1978 | + } |
|
1735 | 1979 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
1736 | 1980 | if (file_exists($tmp_dir.'data.fln')) { |
1737 | - if ($globalDebug) echo "Add to DB..."; |
|
1981 | + if ($globalDebug) { |
|
1982 | + echo "Add to DB..."; |
|
1983 | + } |
|
1738 | 1984 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
1739 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1985 | + } else { |
|
1986 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1987 | + } |
|
1740 | 1988 | if ($error != '') { |
1741 | 1989 | return $error; |
1742 | - } elseif ($globalDebug) echo "Done\n"; |
|
1990 | + } elseif ($globalDebug) { |
|
1991 | + echo "Done\n"; |
|
1992 | + } |
|
1743 | 1993 | return ''; |
1744 | 1994 | } |
1745 | 1995 | |
1746 | 1996 | public static function update_ModeS_ogn() { |
1747 | 1997 | global $tmp_dir, $globalDebug; |
1748 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
1998 | + if ($globalDebug) { |
|
1999 | + echo "Modes OGN: Download..."; |
|
2000 | + } |
|
1749 | 2001 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
1750 | 2002 | if (file_exists($tmp_dir.'ogn.csv')) { |
1751 | - if ($globalDebug) echo "Add to DB..."; |
|
2003 | + if ($globalDebug) { |
|
2004 | + echo "Add to DB..."; |
|
2005 | + } |
|
1752 | 2006 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
1753 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2007 | + } else { |
|
2008 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2009 | + } |
|
1754 | 2010 | if ($error != '') { |
1755 | 2011 | return $error; |
1756 | - } elseif ($globalDebug) echo "Done\n"; |
|
2012 | + } elseif ($globalDebug) { |
|
2013 | + echo "Done\n"; |
|
2014 | + } |
|
1757 | 2015 | return ''; |
1758 | 2016 | } |
1759 | 2017 | |
1760 | 2018 | public static function update_owner() { |
1761 | 2019 | global $tmp_dir, $globalDebug, $globalMasterSource; |
1762 | 2020 | |
1763 | - if ($globalDebug) echo "Owner France: Download..."; |
|
2021 | + if ($globalDebug) { |
|
2022 | + echo "Owner France: Download..."; |
|
2023 | + } |
|
1764 | 2024 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
1765 | 2025 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1766 | - if ($globalDebug) echo "Add to DB..."; |
|
2026 | + if ($globalDebug) { |
|
2027 | + echo "Add to DB..."; |
|
2028 | + } |
|
1767 | 2029 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
1768 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2030 | + } else { |
|
2031 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2032 | + } |
|
1769 | 2033 | if ($error != '') { |
1770 | 2034 | return $error; |
1771 | - } elseif ($globalDebug) echo "Done\n"; |
|
2035 | + } elseif ($globalDebug) { |
|
2036 | + echo "Done\n"; |
|
2037 | + } |
|
1772 | 2038 | |
1773 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
2039 | + if ($globalDebug) { |
|
2040 | + echo "Owner Ireland: Download..."; |
|
2041 | + } |
|
1774 | 2042 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
1775 | 2043 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1776 | - if ($globalDebug) echo "Add to DB..."; |
|
2044 | + if ($globalDebug) { |
|
2045 | + echo "Add to DB..."; |
|
2046 | + } |
|
1777 | 2047 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
1778 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2048 | + } else { |
|
2049 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2050 | + } |
|
1779 | 2051 | if ($error != '') { |
1780 | 2052 | return $error; |
1781 | - } elseif ($globalDebug) echo "Done\n"; |
|
1782 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
2053 | + } elseif ($globalDebug) { |
|
2054 | + echo "Done\n"; |
|
2055 | + } |
|
2056 | + if ($globalDebug) { |
|
2057 | + echo "Owner Switzerland: Download..."; |
|
2058 | + } |
|
1783 | 2059 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
1784 | 2060 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1785 | - if ($globalDebug) echo "Add to DB..."; |
|
2061 | + if ($globalDebug) { |
|
2062 | + echo "Add to DB..."; |
|
2063 | + } |
|
1786 | 2064 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
1787 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2065 | + } else { |
|
2066 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2067 | + } |
|
1788 | 2068 | if ($error != '') { |
1789 | 2069 | return $error; |
1790 | - } elseif ($globalDebug) echo "Done\n"; |
|
1791 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
2070 | + } elseif ($globalDebug) { |
|
2071 | + echo "Done\n"; |
|
2072 | + } |
|
2073 | + if ($globalDebug) { |
|
2074 | + echo "Owner Czech Republic: Download..."; |
|
2075 | + } |
|
1792 | 2076 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
1793 | 2077 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1794 | - if ($globalDebug) echo "Add to DB..."; |
|
2078 | + if ($globalDebug) { |
|
2079 | + echo "Add to DB..."; |
|
2080 | + } |
|
1795 | 2081 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
1796 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2082 | + } else { |
|
2083 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2084 | + } |
|
1797 | 2085 | if ($error != '') { |
1798 | 2086 | return $error; |
1799 | - } elseif ($globalDebug) echo "Done\n"; |
|
1800 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
2087 | + } elseif ($globalDebug) { |
|
2088 | + echo "Done\n"; |
|
2089 | + } |
|
2090 | + if ($globalDebug) { |
|
2091 | + echo "Owner Australia: Download..."; |
|
2092 | + } |
|
1801 | 2093 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
1802 | 2094 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1803 | - if ($globalDebug) echo "Add to DB..."; |
|
2095 | + if ($globalDebug) { |
|
2096 | + echo "Add to DB..."; |
|
2097 | + } |
|
1804 | 2098 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
1805 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2099 | + } else { |
|
2100 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2101 | + } |
|
1806 | 2102 | if ($error != '') { |
1807 | 2103 | return $error; |
1808 | - } elseif ($globalDebug) echo "Done\n"; |
|
1809 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
2104 | + } elseif ($globalDebug) { |
|
2105 | + echo "Done\n"; |
|
2106 | + } |
|
2107 | + if ($globalDebug) { |
|
2108 | + echo "Owner Austria: Download..."; |
|
2109 | + } |
|
1810 | 2110 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
1811 | 2111 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1812 | - if ($globalDebug) echo "Add to DB..."; |
|
2112 | + if ($globalDebug) { |
|
2113 | + echo "Add to DB..."; |
|
2114 | + } |
|
1813 | 2115 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
1814 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2116 | + } else { |
|
2117 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2118 | + } |
|
1815 | 2119 | if ($error != '') { |
1816 | 2120 | return $error; |
1817 | - } elseif ($globalDebug) echo "Done\n"; |
|
1818 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2121 | + } elseif ($globalDebug) { |
|
2122 | + echo "Done\n"; |
|
2123 | + } |
|
2124 | + if ($globalDebug) { |
|
2125 | + echo "Owner Chile: Download..."; |
|
2126 | + } |
|
1819 | 2127 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
1820 | 2128 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1821 | - if ($globalDebug) echo "Add to DB..."; |
|
2129 | + if ($globalDebug) { |
|
2130 | + echo "Add to DB..."; |
|
2131 | + } |
|
1822 | 2132 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
1823 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2133 | + } else { |
|
2134 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2135 | + } |
|
1824 | 2136 | if ($error != '') { |
1825 | 2137 | return $error; |
1826 | - } elseif ($globalDebug) echo "Done\n"; |
|
1827 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2138 | + } elseif ($globalDebug) { |
|
2139 | + echo "Done\n"; |
|
2140 | + } |
|
2141 | + if ($globalDebug) { |
|
2142 | + echo "Owner Colombia: Download..."; |
|
2143 | + } |
|
1828 | 2144 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
1829 | 2145 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1830 | - if ($globalDebug) echo "Add to DB..."; |
|
2146 | + if ($globalDebug) { |
|
2147 | + echo "Add to DB..."; |
|
2148 | + } |
|
1831 | 2149 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
1832 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2150 | + } else { |
|
2151 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2152 | + } |
|
1833 | 2153 | if ($error != '') { |
1834 | 2154 | return $error; |
1835 | - } elseif ($globalDebug) echo "Done\n"; |
|
1836 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2155 | + } elseif ($globalDebug) { |
|
2156 | + echo "Done\n"; |
|
2157 | + } |
|
2158 | + if ($globalDebug) { |
|
2159 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2160 | + } |
|
1837 | 2161 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
1838 | 2162 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1839 | - if ($globalDebug) echo "Add to DB..."; |
|
2163 | + if ($globalDebug) { |
|
2164 | + echo "Add to DB..."; |
|
2165 | + } |
|
1840 | 2166 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
1841 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2167 | + } else { |
|
2168 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2169 | + } |
|
1842 | 2170 | if ($error != '') { |
1843 | 2171 | return $error; |
1844 | - } elseif ($globalDebug) echo "Done\n"; |
|
1845 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2172 | + } elseif ($globalDebug) { |
|
2173 | + echo "Done\n"; |
|
2174 | + } |
|
2175 | + if ($globalDebug) { |
|
2176 | + echo "Owner Brazil: Download..."; |
|
2177 | + } |
|
1846 | 2178 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
1847 | 2179 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1848 | - if ($globalDebug) echo "Add to DB..."; |
|
2180 | + if ($globalDebug) { |
|
2181 | + echo "Add to DB..."; |
|
2182 | + } |
|
1849 | 2183 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
1850 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2184 | + } else { |
|
2185 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2186 | + } |
|
1851 | 2187 | if ($error != '') { |
1852 | 2188 | return $error; |
1853 | - } elseif ($globalDebug) echo "Done\n"; |
|
1854 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2189 | + } elseif ($globalDebug) { |
|
2190 | + echo "Done\n"; |
|
2191 | + } |
|
2192 | + if ($globalDebug) { |
|
2193 | + echo "Owner Cayman Islands: Download..."; |
|
2194 | + } |
|
1855 | 2195 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
1856 | 2196 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1857 | - if ($globalDebug) echo "Add to DB..."; |
|
2197 | + if ($globalDebug) { |
|
2198 | + echo "Add to DB..."; |
|
2199 | + } |
|
1858 | 2200 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
1859 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2201 | + } else { |
|
2202 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2203 | + } |
|
1860 | 2204 | if ($error != '') { |
1861 | 2205 | return $error; |
1862 | - } elseif ($globalDebug) echo "Done\n"; |
|
1863 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2206 | + } elseif ($globalDebug) { |
|
2207 | + echo "Done\n"; |
|
2208 | + } |
|
2209 | + if ($globalDebug) { |
|
2210 | + echo "Owner Croatia: Download..."; |
|
2211 | + } |
|
1864 | 2212 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
1865 | 2213 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1866 | - if ($globalDebug) echo "Add to DB..."; |
|
2214 | + if ($globalDebug) { |
|
2215 | + echo "Add to DB..."; |
|
2216 | + } |
|
1867 | 2217 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
1868 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2218 | + } else { |
|
2219 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2220 | + } |
|
1869 | 2221 | if ($error != '') { |
1870 | 2222 | return $error; |
1871 | - } elseif ($globalDebug) echo "Done\n"; |
|
1872 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2223 | + } elseif ($globalDebug) { |
|
2224 | + echo "Done\n"; |
|
2225 | + } |
|
2226 | + if ($globalDebug) { |
|
2227 | + echo "Owner Luxembourg: Download..."; |
|
2228 | + } |
|
1873 | 2229 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
1874 | 2230 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1875 | - if ($globalDebug) echo "Add to DB..."; |
|
2231 | + if ($globalDebug) { |
|
2232 | + echo "Add to DB..."; |
|
2233 | + } |
|
1876 | 2234 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
1877 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2235 | + } else { |
|
2236 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2237 | + } |
|
1878 | 2238 | if ($error != '') { |
1879 | 2239 | return $error; |
1880 | - } elseif ($globalDebug) echo "Done\n"; |
|
1881 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2240 | + } elseif ($globalDebug) { |
|
2241 | + echo "Done\n"; |
|
2242 | + } |
|
2243 | + if ($globalDebug) { |
|
2244 | + echo "Owner Maldives: Download..."; |
|
2245 | + } |
|
1882 | 2246 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
1883 | 2247 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1884 | - if ($globalDebug) echo "Add to DB..."; |
|
2248 | + if ($globalDebug) { |
|
2249 | + echo "Add to DB..."; |
|
2250 | + } |
|
1885 | 2251 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
1886 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2252 | + } else { |
|
2253 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2254 | + } |
|
1887 | 2255 | if ($error != '') { |
1888 | 2256 | return $error; |
1889 | - } elseif ($globalDebug) echo "Done\n"; |
|
1890 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2257 | + } elseif ($globalDebug) { |
|
2258 | + echo "Done\n"; |
|
2259 | + } |
|
2260 | + if ($globalDebug) { |
|
2261 | + echo "Owner New Zealand: Download..."; |
|
2262 | + } |
|
1891 | 2263 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
1892 | 2264 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1893 | - if ($globalDebug) echo "Add to DB..."; |
|
2265 | + if ($globalDebug) { |
|
2266 | + echo "Add to DB..."; |
|
2267 | + } |
|
1894 | 2268 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
1895 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2269 | + } else { |
|
2270 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2271 | + } |
|
1896 | 2272 | if ($error != '') { |
1897 | 2273 | return $error; |
1898 | - } elseif ($globalDebug) echo "Done\n"; |
|
1899 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2274 | + } elseif ($globalDebug) { |
|
2275 | + echo "Done\n"; |
|
2276 | + } |
|
2277 | + if ($globalDebug) { |
|
2278 | + echo "Owner Papua New Guinea: Download..."; |
|
2279 | + } |
|
1900 | 2280 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
1901 | 2281 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1902 | - if ($globalDebug) echo "Add to DB..."; |
|
2282 | + if ($globalDebug) { |
|
2283 | + echo "Add to DB..."; |
|
2284 | + } |
|
1903 | 2285 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
1904 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2286 | + } else { |
|
2287 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2288 | + } |
|
1905 | 2289 | if ($error != '') { |
1906 | 2290 | return $error; |
1907 | - } elseif ($globalDebug) echo "Done\n"; |
|
1908 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2291 | + } elseif ($globalDebug) { |
|
2292 | + echo "Done\n"; |
|
2293 | + } |
|
2294 | + if ($globalDebug) { |
|
2295 | + echo "Owner Slovakia: Download..."; |
|
2296 | + } |
|
1909 | 2297 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
1910 | 2298 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1911 | - if ($globalDebug) echo "Add to DB..."; |
|
2299 | + if ($globalDebug) { |
|
2300 | + echo "Add to DB..."; |
|
2301 | + } |
|
1912 | 2302 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
1913 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2303 | + } else { |
|
2304 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2305 | + } |
|
1914 | 2306 | if ($error != '') { |
1915 | 2307 | return $error; |
1916 | - } elseif ($globalDebug) echo "Done\n"; |
|
1917 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2308 | + } elseif ($globalDebug) { |
|
2309 | + echo "Done\n"; |
|
2310 | + } |
|
2311 | + if ($globalDebug) { |
|
2312 | + echo "Owner Ecuador: Download..."; |
|
2313 | + } |
|
1918 | 2314 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
1919 | 2315 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1920 | - if ($globalDebug) echo "Add to DB..."; |
|
2316 | + if ($globalDebug) { |
|
2317 | + echo "Add to DB..."; |
|
2318 | + } |
|
1921 | 2319 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
1922 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2320 | + } else { |
|
2321 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2322 | + } |
|
1923 | 2323 | if ($error != '') { |
1924 | 2324 | return $error; |
1925 | - } elseif ($globalDebug) echo "Done\n"; |
|
1926 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2325 | + } elseif ($globalDebug) { |
|
2326 | + echo "Done\n"; |
|
2327 | + } |
|
2328 | + if ($globalDebug) { |
|
2329 | + echo "Owner Iceland: Download..."; |
|
2330 | + } |
|
1927 | 2331 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
1928 | 2332 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1929 | - if ($globalDebug) echo "Add to DB..."; |
|
2333 | + if ($globalDebug) { |
|
2334 | + echo "Add to DB..."; |
|
2335 | + } |
|
1930 | 2336 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
1931 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2337 | + } else { |
|
2338 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2339 | + } |
|
1932 | 2340 | if ($error != '') { |
1933 | 2341 | return $error; |
1934 | - } elseif ($globalDebug) echo "Done\n"; |
|
1935 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
2342 | + } elseif ($globalDebug) { |
|
2343 | + echo "Done\n"; |
|
2344 | + } |
|
2345 | + if ($globalDebug) { |
|
2346 | + echo "Owner Isle of Man: Download..."; |
|
2347 | + } |
|
1936 | 2348 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
1937 | 2349 | if (file_exists($tmp_dir.'owner_m.csv')) { |
1938 | - if ($globalDebug) echo "Add to DB..."; |
|
2350 | + if ($globalDebug) { |
|
2351 | + echo "Add to DB..."; |
|
2352 | + } |
|
1939 | 2353 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
1940 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2354 | + } else { |
|
2355 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2356 | + } |
|
1941 | 2357 | if ($error != '') { |
1942 | 2358 | return $error; |
1943 | - } elseif ($globalDebug) echo "Done\n"; |
|
2359 | + } elseif ($globalDebug) { |
|
2360 | + echo "Done\n"; |
|
2361 | + } |
|
1944 | 2362 | if ($globalMasterSource) { |
1945 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
2363 | + if ($globalDebug) { |
|
2364 | + echo "ModeS Netherlands: Download..."; |
|
2365 | + } |
|
1946 | 2366 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
1947 | 2367 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
1948 | - if ($globalDebug) echo "Add to DB..."; |
|
2368 | + if ($globalDebug) { |
|
2369 | + echo "Add to DB..."; |
|
2370 | + } |
|
1949 | 2371 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
1950 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2372 | + } else { |
|
2373 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2374 | + } |
|
1951 | 2375 | if ($error != '') { |
1952 | 2376 | return $error; |
1953 | - } elseif ($globalDebug) echo "Done\n"; |
|
1954 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
2377 | + } elseif ($globalDebug) { |
|
2378 | + echo "Done\n"; |
|
2379 | + } |
|
2380 | + if ($globalDebug) { |
|
2381 | + echo "ModeS Denmark: Download..."; |
|
2382 | + } |
|
1955 | 2383 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
1956 | 2384 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
1957 | - if ($globalDebug) echo "Add to DB..."; |
|
2385 | + if ($globalDebug) { |
|
2386 | + echo "Add to DB..."; |
|
2387 | + } |
|
1958 | 2388 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
1959 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2389 | + } else { |
|
2390 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2391 | + } |
|
1960 | 2392 | if ($error != '') { |
1961 | 2393 | return $error; |
1962 | - } elseif ($globalDebug) echo "Done\n"; |
|
1963 | - } elseif ($globalDebug) echo "Done\n"; |
|
2394 | + } elseif ($globalDebug) { |
|
2395 | + echo "Done\n"; |
|
2396 | + } |
|
2397 | + } elseif ($globalDebug) { |
|
2398 | + echo "Done\n"; |
|
2399 | + } |
|
1964 | 2400 | return ''; |
1965 | 2401 | } |
1966 | 2402 | |
1967 | 2403 | public static function update_translation() { |
1968 | 2404 | global $tmp_dir, $globalDebug; |
1969 | 2405 | $error = ''; |
1970 | - if ($globalDebug) echo "Translation : Download..."; |
|
2406 | + if ($globalDebug) { |
|
2407 | + echo "Translation : Download..."; |
|
2408 | + } |
|
1971 | 2409 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
1972 | 2410 | if (file_exists($tmp_dir.'translation.zip')) { |
1973 | - if ($globalDebug) echo "Unzip..."; |
|
2411 | + if ($globalDebug) { |
|
2412 | + echo "Unzip..."; |
|
2413 | + } |
|
1974 | 2414 | update_db::unzip($tmp_dir.'translation.zip'); |
1975 | - if ($globalDebug) echo "Add to DB..."; |
|
2415 | + if ($globalDebug) { |
|
2416 | + echo "Add to DB..."; |
|
2417 | + } |
|
1976 | 2418 | $error = update_db::translation(); |
1977 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2419 | + } else { |
|
2420 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2421 | + } |
|
1978 | 2422 | if ($error != '') { |
1979 | 2423 | return $error; |
1980 | - } elseif ($globalDebug) echo "Done\n"; |
|
2424 | + } elseif ($globalDebug) { |
|
2425 | + echo "Done\n"; |
|
2426 | + } |
|
1981 | 2427 | return ''; |
1982 | 2428 | } |
1983 | 2429 | |
1984 | 2430 | public static function update_translation_fam() { |
1985 | 2431 | global $tmp_dir, $globalDebug; |
1986 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2432 | + if ($globalDebug) { |
|
2433 | + echo "Translation from FlightAirMap website : Download..."; |
|
2434 | + } |
|
1987 | 2435 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
1988 | 2436 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1989 | - if ($globalDebug) echo "Gunzip..."; |
|
2437 | + if ($globalDebug) { |
|
2438 | + echo "Gunzip..."; |
|
2439 | + } |
|
1990 | 2440 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
1991 | - if ($globalDebug) echo "Add to DB..."; |
|
2441 | + if ($globalDebug) { |
|
2442 | + echo "Add to DB..."; |
|
2443 | + } |
|
1992 | 2444 | $error = update_db::translation_fam(); |
1993 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2445 | + } else { |
|
2446 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2447 | + } |
|
1994 | 2448 | if ($error != '') { |
1995 | 2449 | return $error; |
1996 | - } elseif ($globalDebug) echo "Done\n"; |
|
2450 | + } elseif ($globalDebug) { |
|
2451 | + echo "Done\n"; |
|
2452 | + } |
|
1997 | 2453 | return ''; |
1998 | 2454 | } |
1999 | 2455 | public static function update_ModeS_fam() { |
2000 | 2456 | global $tmp_dir, $globalDebug; |
2001 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2457 | + if ($globalDebug) { |
|
2458 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2459 | + } |
|
2002 | 2460 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
2003 | 2461 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
2004 | - if ($globalDebug) echo "Gunzip..."; |
|
2462 | + if ($globalDebug) { |
|
2463 | + echo "Gunzip..."; |
|
2464 | + } |
|
2005 | 2465 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
2006 | - if ($globalDebug) echo "Add to DB..."; |
|
2466 | + if ($globalDebug) { |
|
2467 | + echo "Add to DB..."; |
|
2468 | + } |
|
2007 | 2469 | $error = update_db::modes_fam(); |
2008 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2470 | + } else { |
|
2471 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2472 | + } |
|
2009 | 2473 | if ($error != '') { |
2010 | 2474 | return $error; |
2011 | - } elseif ($globalDebug) echo "Done\n"; |
|
2475 | + } elseif ($globalDebug) { |
|
2476 | + echo "Done\n"; |
|
2477 | + } |
|
2012 | 2478 | return ''; |
2013 | 2479 | } |
2014 | 2480 | public static function update_owner_fam() { |
2015 | 2481 | global $tmp_dir, $globalDebug, $globalOwner; |
2016 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
2482 | + if ($globalDebug) { |
|
2483 | + echo "owner from FlightAirMap website : Download..."; |
|
2484 | + } |
|
2017 | 2485 | if ($globalOwner === TRUE) { |
2018 | 2486 | update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
2019 | 2487 | } else { |
2020 | 2488 | update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
2021 | 2489 | } |
2022 | 2490 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
2023 | - if ($globalDebug) echo "Gunzip..."; |
|
2491 | + if ($globalDebug) { |
|
2492 | + echo "Gunzip..."; |
|
2493 | + } |
|
2024 | 2494 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
2025 | - if ($globalDebug) echo "Add to DB..."; |
|
2495 | + if ($globalDebug) { |
|
2496 | + echo "Add to DB..."; |
|
2497 | + } |
|
2026 | 2498 | $error = update_db::owner_fam(); |
2027 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2499 | + } else { |
|
2500 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2501 | + } |
|
2028 | 2502 | if ($error != '') { |
2029 | 2503 | return $error; |
2030 | - } elseif ($globalDebug) echo "Done\n"; |
|
2504 | + } elseif ($globalDebug) { |
|
2505 | + echo "Done\n"; |
|
2506 | + } |
|
2031 | 2507 | return ''; |
2032 | 2508 | } |
2033 | 2509 | public static function update_routes_fam() { |
2034 | 2510 | global $tmp_dir, $globalDebug; |
2035 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
2511 | + if ($globalDebug) { |
|
2512 | + echo "Routes from FlightAirMap website : Download..."; |
|
2513 | + } |
|
2036 | 2514 | update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
2037 | 2515 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
2038 | - if ($globalDebug) echo "Gunzip..."; |
|
2516 | + if ($globalDebug) { |
|
2517 | + echo "Gunzip..."; |
|
2518 | + } |
|
2039 | 2519 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
2040 | - if ($globalDebug) echo "Add to DB..."; |
|
2520 | + if ($globalDebug) { |
|
2521 | + echo "Add to DB..."; |
|
2522 | + } |
|
2041 | 2523 | $error = update_db::routes_fam(); |
2042 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2524 | + } else { |
|
2525 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2526 | + } |
|
2043 | 2527 | if ($error != '') { |
2044 | 2528 | return $error; |
2045 | - } elseif ($globalDebug) echo "Done\n"; |
|
2529 | + } elseif ($globalDebug) { |
|
2530 | + echo "Done\n"; |
|
2531 | + } |
|
2046 | 2532 | return ''; |
2047 | 2533 | } |
2048 | 2534 | public static function update_marine_identity_fam() { |
@@ -2052,14 +2538,22 @@ discard block |
||
2052 | 2538 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
2053 | 2539 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2054 | 2540 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2055 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
2541 | + if ($globalDebug) { |
|
2542 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
2543 | + } |
|
2056 | 2544 | update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
2057 | 2545 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2058 | - if ($globalDebug) echo "Gunzip..."; |
|
2546 | + if ($globalDebug) { |
|
2547 | + echo "Gunzip..."; |
|
2548 | + } |
|
2059 | 2549 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
2060 | - if ($globalDebug) echo "Add to DB..."; |
|
2550 | + if ($globalDebug) { |
|
2551 | + echo "Add to DB..."; |
|
2552 | + } |
|
2061 | 2553 | $error = update_db::marine_identity_fam(); |
2062 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
2554 | + } else { |
|
2555 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
2556 | + } |
|
2063 | 2557 | if ($error != '') { |
2064 | 2558 | return $error; |
2065 | 2559 | } elseif ($globalDebug) { |
@@ -2072,17 +2566,25 @@ discard block |
||
2072 | 2566 | } |
2073 | 2567 | public static function update_banned_fam() { |
2074 | 2568 | global $tmp_dir, $globalDebug; |
2075 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2569 | + if ($globalDebug) { |
|
2570 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2571 | + } |
|
2076 | 2572 | update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
2077 | 2573 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2078 | 2574 | //if ($globalDebug) echo "Gunzip..."; |
2079 | 2575 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
2080 | - if ($globalDebug) echo "Add to DB..."; |
|
2576 | + if ($globalDebug) { |
|
2577 | + echo "Add to DB..."; |
|
2578 | + } |
|
2081 | 2579 | $error = update_db::banned_fam(); |
2082 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
2580 | + } else { |
|
2581 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
2582 | + } |
|
2083 | 2583 | if ($error != '') { |
2084 | 2584 | return $error; |
2085 | - } elseif ($globalDebug) echo "Done\n"; |
|
2585 | + } elseif ($globalDebug) { |
|
2586 | + echo "Done\n"; |
|
2587 | + } |
|
2086 | 2588 | return ''; |
2087 | 2589 | } |
2088 | 2590 | |
@@ -2090,7 +2592,9 @@ discard block |
||
2090 | 2592 | global $tmp_dir, $globalDebug, $globalDBdriver; |
2091 | 2593 | include_once('class.create_db.php'); |
2092 | 2594 | $error = ''; |
2093 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
2595 | + if ($globalDebug) { |
|
2596 | + echo "Airspace from FlightAirMap website : Download..."; |
|
2597 | + } |
|
2094 | 2598 | if ($globalDBdriver == 'mysql') { |
2095 | 2599 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
2096 | 2600 | } else { |
@@ -2106,9 +2610,13 @@ discard block |
||
2106 | 2610 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
2107 | 2611 | } |
2108 | 2612 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2109 | - if ($globalDebug) echo "Gunzip..."; |
|
2613 | + if ($globalDebug) { |
|
2614 | + echo "Gunzip..."; |
|
2615 | + } |
|
2110 | 2616 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
2111 | - if ($globalDebug) echo "Add to DB..."; |
|
2617 | + if ($globalDebug) { |
|
2618 | + echo "Add to DB..."; |
|
2619 | + } |
|
2112 | 2620 | $Connection = new Connection(); |
2113 | 2621 | if ($Connection->tableExists('airspace')) { |
2114 | 2622 | $query = 'DROP TABLE airspace'; |
@@ -2121,19 +2629,27 @@ discard block |
||
2121 | 2629 | } |
2122 | 2630 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2123 | 2631 | update_db::insert_airspace_version($airspace_md5); |
2124 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2632 | + } else { |
|
2633 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2634 | + } |
|
2125 | 2635 | } |
2126 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2636 | + } else { |
|
2637 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2638 | + } |
|
2127 | 2639 | if ($error != '') { |
2128 | 2640 | return $error; |
2129 | - } elseif ($globalDebug) echo "Done\n"; |
|
2641 | + } elseif ($globalDebug) { |
|
2642 | + echo "Done\n"; |
|
2643 | + } |
|
2130 | 2644 | return ''; |
2131 | 2645 | } |
2132 | 2646 | |
2133 | 2647 | public static function update_geoid_fam() { |
2134 | 2648 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2135 | 2649 | $error = ''; |
2136 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
2650 | + if ($globalDebug) { |
|
2651 | + echo "Geoid from FlightAirMap website : Download..."; |
|
2652 | + } |
|
2137 | 2653 | update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
2138 | 2654 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2139 | 2655 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2141,36 +2657,54 @@ discard block |
||
2141 | 2657 | if (!update_db::check_geoid_version($geoid_md5)) { |
2142 | 2658 | update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
2143 | 2659 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2144 | - if ($globalDebug) echo "Gunzip..."; |
|
2660 | + if ($globalDebug) { |
|
2661 | + echo "Gunzip..."; |
|
2662 | + } |
|
2145 | 2663 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
2146 | 2664 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
2147 | 2665 | update_db::insert_geoid_version($geoid_md5); |
2148 | 2666 | } |
2149 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
2667 | + } else { |
|
2668 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
2669 | + } |
|
2150 | 2670 | } |
2151 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
2671 | + } else { |
|
2672 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
2673 | + } |
|
2152 | 2674 | if ($error != '') { |
2153 | 2675 | return $error; |
2154 | - } elseif ($globalDebug) echo "Done\n"; |
|
2676 | + } elseif ($globalDebug) { |
|
2677 | + echo "Done\n"; |
|
2678 | + } |
|
2155 | 2679 | return ''; |
2156 | 2680 | } |
2157 | 2681 | |
2158 | 2682 | public static function update_tle() { |
2159 | 2683 | global $tmp_dir, $globalDebug; |
2160 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
2684 | + if ($globalDebug) { |
|
2685 | + echo "Download TLE : Download..."; |
|
2686 | + } |
|
2161 | 2687 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
2162 | 2688 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
2163 | 2689 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
2164 | 2690 | foreach ($alltle as $filename) { |
2165 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
2691 | + if ($globalDebug) { |
|
2692 | + echo "downloading ".$filename.'...'; |
|
2693 | + } |
|
2166 | 2694 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
2167 | 2695 | if (file_exists($tmp_dir.$filename)) { |
2168 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
2696 | + if ($globalDebug) { |
|
2697 | + echo "Add to DB ".$filename."..."; |
|
2698 | + } |
|
2169 | 2699 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
2170 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2700 | + } else { |
|
2701 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2702 | + } |
|
2171 | 2703 | if ($error != '') { |
2172 | 2704 | echo $error."\n"; |
2173 | - } elseif ($globalDebug) echo "Done\n"; |
|
2705 | + } elseif ($globalDebug) { |
|
2706 | + echo "Done\n"; |
|
2707 | + } |
|
2174 | 2708 | } |
2175 | 2709 | return ''; |
2176 | 2710 | } |
@@ -2178,10 +2712,14 @@ discard block |
||
2178 | 2712 | public static function update_models() { |
2179 | 2713 | global $tmp_dir, $globalDebug; |
2180 | 2714 | $error = ''; |
2181 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
2715 | + if ($globalDebug) { |
|
2716 | + echo "Models from FlightAirMap website : Download..."; |
|
2717 | + } |
|
2182 | 2718 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2183 | 2719 | if (file_exists($tmp_dir.'models.md5sum')) { |
2184 | - if ($globalDebug) echo "Check files...\n"; |
|
2720 | + if ($globalDebug) { |
|
2721 | + echo "Check files...\n"; |
|
2722 | + } |
|
2185 | 2723 | $newmodelsdb = array(); |
2186 | 2724 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2187 | 2725 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2200,25 +2738,35 @@ discard block |
||
2200 | 2738 | } |
2201 | 2739 | $diff = array_diff($newmodelsdb,$modelsdb); |
2202 | 2740 | foreach ($diff as $key => $value) { |
2203 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
2741 | + if ($globalDebug) { |
|
2742 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
2743 | + } |
|
2204 | 2744 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2205 | 2745 | |
2206 | 2746 | } |
2207 | 2747 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2208 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2748 | + } else { |
|
2749 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2750 | + } |
|
2209 | 2751 | if ($error != '') { |
2210 | 2752 | return $error; |
2211 | - } elseif ($globalDebug) echo "Done\n"; |
|
2753 | + } elseif ($globalDebug) { |
|
2754 | + echo "Done\n"; |
|
2755 | + } |
|
2212 | 2756 | return ''; |
2213 | 2757 | } |
2214 | 2758 | |
2215 | 2759 | public static function update_space_models() { |
2216 | 2760 | global $tmp_dir, $globalDebug; |
2217 | 2761 | $error = ''; |
2218 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
2762 | + if ($globalDebug) { |
|
2763 | + echo "Space models from FlightAirMap website : Download..."; |
|
2764 | + } |
|
2219 | 2765 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
2220 | 2766 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2221 | - if ($globalDebug) echo "Check files...\n"; |
|
2767 | + if ($globalDebug) { |
|
2768 | + echo "Check files...\n"; |
|
2769 | + } |
|
2222 | 2770 | $newmodelsdb = array(); |
2223 | 2771 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
2224 | 2772 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2237,25 +2785,35 @@ discard block |
||
2237 | 2785 | } |
2238 | 2786 | $diff = array_diff($newmodelsdb,$modelsdb); |
2239 | 2787 | foreach ($diff as $key => $value) { |
2240 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
2788 | + if ($globalDebug) { |
|
2789 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
2790 | + } |
|
2241 | 2791 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
2242 | 2792 | |
2243 | 2793 | } |
2244 | 2794 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
2245 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2795 | + } else { |
|
2796 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2797 | + } |
|
2246 | 2798 | if ($error != '') { |
2247 | 2799 | return $error; |
2248 | - } elseif ($globalDebug) echo "Done\n"; |
|
2800 | + } elseif ($globalDebug) { |
|
2801 | + echo "Done\n"; |
|
2802 | + } |
|
2249 | 2803 | return ''; |
2250 | 2804 | } |
2251 | 2805 | |
2252 | 2806 | public static function update_vehicules_models() { |
2253 | 2807 | global $tmp_dir, $globalDebug; |
2254 | 2808 | $error = ''; |
2255 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
2809 | + if ($globalDebug) { |
|
2810 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
2811 | + } |
|
2256 | 2812 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
2257 | 2813 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2258 | - if ($globalDebug) echo "Check files...\n"; |
|
2814 | + if ($globalDebug) { |
|
2815 | + echo "Check files...\n"; |
|
2816 | + } |
|
2259 | 2817 | $newmodelsdb = array(); |
2260 | 2818 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
2261 | 2819 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2274,15 +2832,21 @@ discard block |
||
2274 | 2832 | } |
2275 | 2833 | $diff = array_diff($newmodelsdb,$modelsdb); |
2276 | 2834 | foreach ($diff as $key => $value) { |
2277 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
2835 | + if ($globalDebug) { |
|
2836 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
2837 | + } |
|
2278 | 2838 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
2279 | 2839 | |
2280 | 2840 | } |
2281 | 2841 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
2282 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2842 | + } else { |
|
2843 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2844 | + } |
|
2283 | 2845 | if ($error != '') { |
2284 | 2846 | return $error; |
2285 | - } elseif ($globalDebug) echo "Done\n"; |
|
2847 | + } elseif ($globalDebug) { |
|
2848 | + echo "Done\n"; |
|
2849 | + } |
|
2286 | 2850 | return ''; |
2287 | 2851 | } |
2288 | 2852 | |
@@ -2325,7 +2889,9 @@ discard block |
||
2325 | 2889 | } |
2326 | 2890 | |
2327 | 2891 | $error = ''; |
2328 | - if ($globalDebug) echo "Notam : Download..."; |
|
2892 | + if ($globalDebug) { |
|
2893 | + echo "Notam : Download..."; |
|
2894 | + } |
|
2329 | 2895 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
2330 | 2896 | if (file_exists($tmp_dir.'notam.rss')) { |
2331 | 2897 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2340,14 +2906,30 @@ discard block |
||
2340 | 2906 | $data['fir'] = $q[0]; |
2341 | 2907 | $data['code'] = $q[1]; |
2342 | 2908 | $ifrvfr = $q[2]; |
2343 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
2344 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
2345 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
2346 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
2347 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
2348 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
2349 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
2350 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
2909 | + if ($ifrvfr == 'IV') { |
|
2910 | + $data['rules'] = 'IFR/VFR'; |
|
2911 | + } |
|
2912 | + if ($ifrvfr == 'I') { |
|
2913 | + $data['rules'] = 'IFR'; |
|
2914 | + } |
|
2915 | + if ($ifrvfr == 'V') { |
|
2916 | + $data['rules'] = 'VFR'; |
|
2917 | + } |
|
2918 | + if ($q[4] == 'A') { |
|
2919 | + $data['scope'] = 'Airport warning'; |
|
2920 | + } |
|
2921 | + if ($q[4] == 'E') { |
|
2922 | + $data['scope'] = 'Enroute warning'; |
|
2923 | + } |
|
2924 | + if ($q[4] == 'W') { |
|
2925 | + $data['scope'] = 'Navigation warning'; |
|
2926 | + } |
|
2927 | + if ($q[4] == 'AE') { |
|
2928 | + $data['scope'] = 'Airport/Enroute warning'; |
|
2929 | + } |
|
2930 | + if ($q[4] == 'AW') { |
|
2931 | + $data['scope'] = 'Airport/Navigation warning'; |
|
2932 | + } |
|
2351 | 2933 | //$data['scope'] = $q[4]; |
2352 | 2934 | $data['lower_limit'] = $q[5]; |
2353 | 2935 | $data['upper_limit'] = $q[6]; |
@@ -2355,8 +2937,12 @@ discard block |
||
2355 | 2937 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
2356 | 2938 | $latitude = $Common->convertDec($las,'latitude'); |
2357 | 2939 | $longitude = $Common->convertDec($lns,'longitude'); |
2358 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
2359 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
2940 | + if ($lac == 'S') { |
|
2941 | + $latitude = '-'.$latitude; |
|
2942 | + } |
|
2943 | + if ($lnc == 'W') { |
|
2944 | + $longitude = '-'.$longitude; |
|
2945 | + } |
|
2360 | 2946 | $data['center_latitude'] = $latitude; |
2361 | 2947 | $data['center_longitude'] = $longitude; |
2362 | 2948 | $data['radius'] = intval($radius); |
@@ -2386,10 +2972,14 @@ discard block |
||
2386 | 2972 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
2387 | 2973 | unset($data); |
2388 | 2974 | } |
2389 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2975 | + } else { |
|
2976 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2977 | + } |
|
2390 | 2978 | if ($error != '') { |
2391 | 2979 | return $error; |
2392 | - } elseif ($globalDebug) echo "Done\n"; |
|
2980 | + } elseif ($globalDebug) { |
|
2981 | + echo "Done\n"; |
|
2982 | + } |
|
2393 | 2983 | return ''; |
2394 | 2984 | } |
2395 | 2985 | |
@@ -2414,7 +3004,9 @@ discard block |
||
2414 | 3004 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2415 | 3005 | $airspace_json = json_decode($airspace_lst,true); |
2416 | 3006 | foreach ($airspace_json['records'] as $airspace) { |
2417 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
3007 | + if ($globalDebug) { |
|
3008 | + echo $airspace['name']."...\n"; |
|
3009 | + } |
|
2418 | 3010 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
2419 | 3011 | if (file_exists($tmp_dir.$airspace['name'])) { |
2420 | 3012 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2458,8 +3050,11 @@ discard block |
||
2458 | 3050 | return "error : ".$e->getMessage(); |
2459 | 3051 | } |
2460 | 3052 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2461 | - if ($row['nb'] > 0) return false; |
|
2462 | - else return true; |
|
3053 | + if ($row['nb'] > 0) { |
|
3054 | + return false; |
|
3055 | + } else { |
|
3056 | + return true; |
|
3057 | + } |
|
2463 | 3058 | } |
2464 | 3059 | |
2465 | 3060 | public static function insert_last_update() { |
@@ -2484,8 +3079,11 @@ discard block |
||
2484 | 3079 | return "error : ".$e->getMessage(); |
2485 | 3080 | } |
2486 | 3081 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2487 | - if ($row['nb'] > 0) return true; |
|
2488 | - else return false; |
|
3082 | + if ($row['nb'] > 0) { |
|
3083 | + return true; |
|
3084 | + } else { |
|
3085 | + return false; |
|
3086 | + } |
|
2489 | 3087 | } |
2490 | 3088 | |
2491 | 3089 | public static function check_geoid_version($version) { |
@@ -2498,8 +3096,11 @@ discard block |
||
2498 | 3096 | return "error : ".$e->getMessage(); |
2499 | 3097 | } |
2500 | 3098 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2501 | - if ($row['nb'] > 0) return true; |
|
2502 | - else return false; |
|
3099 | + if ($row['nb'] > 0) { |
|
3100 | + return true; |
|
3101 | + } else { |
|
3102 | + return false; |
|
3103 | + } |
|
2503 | 3104 | } |
2504 | 3105 | |
2505 | 3106 | public static function check_marine_identity_version($version) { |
@@ -2512,8 +3113,11 @@ discard block |
||
2512 | 3113 | return "error : ".$e->getMessage(); |
2513 | 3114 | } |
2514 | 3115 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2515 | - if ($row['nb'] > 0) return true; |
|
2516 | - else return false; |
|
3116 | + if ($row['nb'] > 0) { |
|
3117 | + return true; |
|
3118 | + } else { |
|
3119 | + return false; |
|
3120 | + } |
|
2517 | 3121 | } |
2518 | 3122 | |
2519 | 3123 | |
@@ -2568,8 +3172,11 @@ discard block |
||
2568 | 3172 | return "error : ".$e->getMessage(); |
2569 | 3173 | } |
2570 | 3174 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2571 | - if ($row['nb'] > 0) return false; |
|
2572 | - else return true; |
|
3175 | + if ($row['nb'] > 0) { |
|
3176 | + return false; |
|
3177 | + } else { |
|
3178 | + return true; |
|
3179 | + } |
|
2573 | 3180 | } |
2574 | 3181 | |
2575 | 3182 | public static function insert_last_notam_update() { |
@@ -2599,8 +3206,11 @@ discard block |
||
2599 | 3206 | return "error : ".$e->getMessage(); |
2600 | 3207 | } |
2601 | 3208 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2602 | - if ($row['nb'] > 0) return false; |
|
2603 | - else return true; |
|
3209 | + if ($row['nb'] > 0) { |
|
3210 | + return false; |
|
3211 | + } else { |
|
3212 | + return true; |
|
3213 | + } |
|
2604 | 3214 | } |
2605 | 3215 | |
2606 | 3216 | public static function insert_last_airspace_update() { |
@@ -2630,8 +3240,11 @@ discard block |
||
2630 | 3240 | return "error : ".$e->getMessage(); |
2631 | 3241 | } |
2632 | 3242 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2633 | - if ($row['nb'] > 0) return false; |
|
2634 | - else return true; |
|
3243 | + if ($row['nb'] > 0) { |
|
3244 | + return false; |
|
3245 | + } else { |
|
3246 | + return true; |
|
3247 | + } |
|
2635 | 3248 | } |
2636 | 3249 | |
2637 | 3250 | public static function insert_last_geoid_update() { |
@@ -2661,8 +3274,11 @@ discard block |
||
2661 | 3274 | return "error : ".$e->getMessage(); |
2662 | 3275 | } |
2663 | 3276 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2664 | - if ($row['nb'] > 0) return false; |
|
2665 | - else return true; |
|
3277 | + if ($row['nb'] > 0) { |
|
3278 | + return false; |
|
3279 | + } else { |
|
3280 | + return true; |
|
3281 | + } |
|
2666 | 3282 | } |
2667 | 3283 | |
2668 | 3284 | public static function insert_last_owner_update() { |
@@ -2691,8 +3307,11 @@ discard block |
||
2691 | 3307 | return "error : ".$e->getMessage(); |
2692 | 3308 | } |
2693 | 3309 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2694 | - if ($row['nb'] > 0) return false; |
|
2695 | - else return true; |
|
3310 | + if ($row['nb'] > 0) { |
|
3311 | + return false; |
|
3312 | + } else { |
|
3313 | + return true; |
|
3314 | + } |
|
2696 | 3315 | } |
2697 | 3316 | |
2698 | 3317 | public static function insert_last_schedules_update() { |
@@ -2721,8 +3340,11 @@ discard block |
||
2721 | 3340 | return "error : ".$e->getMessage(); |
2722 | 3341 | } |
2723 | 3342 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2724 | - if ($row['nb'] > 0) return false; |
|
2725 | - else return true; |
|
3343 | + if ($row['nb'] > 0) { |
|
3344 | + return false; |
|
3345 | + } else { |
|
3346 | + return true; |
|
3347 | + } |
|
2726 | 3348 | } |
2727 | 3349 | |
2728 | 3350 | public static function insert_last_tle_update() { |
@@ -2751,8 +3373,11 @@ discard block |
||
2751 | 3373 | return "error : ".$e->getMessage(); |
2752 | 3374 | } |
2753 | 3375 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2754 | - if ($row['nb'] > 0) return false; |
|
2755 | - else return true; |
|
3376 | + if ($row['nb'] > 0) { |
|
3377 | + return false; |
|
3378 | + } else { |
|
3379 | + return true; |
|
3380 | + } |
|
2756 | 3381 | } |
2757 | 3382 | |
2758 | 3383 | public static function insert_last_marine_identity_update() { |
@@ -23,14 +23,19 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function ident2icao($ident) { |
25 | 25 | if (substr($ident,0,2) == 'AF') { |
26 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
27 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
26 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
27 | + $icao = $ident; |
|
28 | + } else { |
|
29 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
30 | + } |
|
28 | 31 | } else { |
29 | 32 | $Spotter = new Spotter($this->db); |
30 | 33 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
31 | 34 | if (isset($identicao[0])) { |
32 | 35 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
33 | - } else $icao = $ident; |
|
36 | + } else { |
|
37 | + $icao = $ident; |
|
38 | + } |
|
34 | 39 | } |
35 | 40 | return $icao; |
36 | 41 | } |
@@ -103,14 +108,24 @@ discard block |
||
103 | 108 | $message = ''; |
104 | 109 | $result = array(); |
105 | 110 | $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
106 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
107 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
108 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
111 | + if ($n == 0) { |
|
112 | + $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
113 | + } |
|
114 | + if ($n == 0) { |
|
115 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
116 | + } |
|
117 | + if ($n == 0) { |
|
118 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
119 | + } |
|
109 | 120 | if ($n != 0) { |
110 | 121 | $registration = str_replace('.','',$registration); |
111 | 122 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
112 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
113 | - } else $message = $data; |
|
123 | + if ($globalDebug) { |
|
124 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
125 | + } |
|
126 | + } else { |
|
127 | + $message = $data; |
|
128 | + } |
|
114 | 129 | $decode = array(); |
115 | 130 | $found = false; |
116 | 131 | // if ($registration != '' && $ident != '' && $registration != '!') { |
@@ -130,12 +145,21 @@ discard block |
||
130 | 145 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
131 | 146 | $latitude = $la / 10000.0; |
132 | 147 | $longitude = $ln / 10000.0; |
133 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
134 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
148 | + if ($lac == 'S') { |
|
149 | + $latitude = '-'.$latitude; |
|
150 | + } |
|
151 | + if ($lnc == 'W') { |
|
152 | + $longitude = '-'.$longitude; |
|
153 | + } |
|
135 | 154 | // Temp not always available |
136 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
137 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
138 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
155 | + if ($globalDebug) { |
|
156 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
157 | + } |
|
158 | + if ($temp == '') { |
|
159 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
160 | + } else { |
|
161 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
162 | + } |
|
139 | 163 | |
140 | 164 | //$icao = $Translation->checkTranslation($ident); |
141 | 165 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -149,25 +173,35 @@ discard block |
||
149 | 173 | $ahour = ''; |
150 | 174 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
151 | 175 | if ($n == 4 && strlen($darr) == 4) { |
152 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
153 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
154 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
176 | + if ($dhour != '') { |
|
177 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
178 | + } |
|
179 | + if ($ahour != '') { |
|
180 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
181 | + } |
|
182 | + if ($globalDebug) { |
|
183 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
184 | + } |
|
155 | 185 | //$icao = ACARS->ident2icao($ident); |
156 | 186 | //$icao = $Translation->checkTranslation($ident); |
157 | 187 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
158 | 188 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
159 | 189 | $found = true; |
160 | - } |
|
161 | - elseif ($n == 2 || $n == 4) { |
|
162 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
163 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
190 | + } elseif ($n == 2 || $n == 4) { |
|
191 | + if ($dhour != '') { |
|
192 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
193 | + } |
|
194 | + if ($globalDebug) { |
|
195 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
196 | + } |
|
164 | 197 | //$icao = ACARS->ident2icao($ident); |
165 | 198 | //$icao = $Translation->checkTranslation($ident); |
166 | 199 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
167 | 200 | $found = true; |
168 | - } |
|
169 | - elseif ($n == 1) { |
|
170 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
201 | + } elseif ($n == 1) { |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'airport arrival : '.$darr."\n"; |
|
204 | + } |
|
171 | 205 | //$icao = ACARS->ident2icao($ident); |
172 | 206 | //$icao = $Translation->checkTranslation($ident); |
173 | 207 | $decode = array('Arrival airport' => $darr); |
@@ -185,7 +219,9 @@ discard block |
||
185 | 219 | $darr = ''; |
186 | 220 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
187 | 221 | if ($n == 4) { |
188 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
222 | + if ($globalDebug) { |
|
223 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
224 | + } |
|
189 | 225 | //$icao = ACARS->ident2icao($ident); |
190 | 226 | //$icao = $Translation->checkTranslation($ident); |
191 | 227 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -219,14 +255,23 @@ discard block |
||
219 | 255 | $apiste = ''; |
220 | 256 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
221 | 257 | if ($n > 8) { |
222 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
223 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
224 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
258 | + if ($globalDebug) { |
|
259 | + echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
260 | + } |
|
261 | + if ($dhour != '') { |
|
262 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
263 | + } |
|
264 | + if ($ahour != '') { |
|
265 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
266 | + } |
|
225 | 267 | $icao = trim($aident); |
226 | 268 | |
227 | 269 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
228 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
229 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
270 | + if ($ahour == '') { |
|
271 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
272 | + } else { |
|
273 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
274 | + } |
|
230 | 275 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
231 | 276 | $decode['icao'] = $icao; |
232 | 277 | $found = true; |
@@ -248,9 +293,15 @@ discard block |
||
248 | 293 | $lns = $lns.'.'.$lns; |
249 | 294 | $latitude = $las / 1000.0; |
250 | 295 | $longitude = $lns / 1000.0; |
251 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
252 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
253 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
296 | + if ($lac == 'S') { |
|
297 | + $latitude = '-'.$latitude; |
|
298 | + } |
|
299 | + if ($lnc == 'W') { |
|
300 | + $longitude = '-'.$longitude; |
|
301 | + } |
|
302 | + if ($globalDebug) { |
|
303 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
304 | + } |
|
254 | 305 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
255 | 306 | $found = true; |
256 | 307 | } |
@@ -268,7 +319,9 @@ discard block |
||
268 | 319 | $darr = ''; |
269 | 320 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
270 | 321 | if ($n == 4) { |
271 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
322 | + if ($globalDebug) { |
|
323 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
324 | + } |
|
272 | 325 | //$icao = $Translation->checkTranslation($ident); |
273 | 326 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
274 | 327 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -281,7 +334,9 @@ discard block |
||
281 | 334 | $darr = ''; |
282 | 335 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
283 | 336 | if ($n == 4) { |
284 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
337 | + if ($globalDebug) { |
|
338 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
339 | + } |
|
285 | 340 | //$icao = $Translation->checkTranslation($ident); |
286 | 341 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
287 | 342 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -294,7 +349,9 @@ discard block |
||
294 | 349 | $darr = ''; |
295 | 350 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
296 | 351 | if ($n == 2) { |
297 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
352 | + if ($globalDebug) { |
|
353 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
354 | + } |
|
298 | 355 | //$icao = $Translation->checkTranslation($ident); |
299 | 356 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
300 | 357 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -308,7 +365,9 @@ discard block |
||
308 | 365 | $darr = ''; |
309 | 366 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
310 | 367 | if ($n == 6) { |
311 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
368 | + if ($globalDebug) { |
|
369 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
370 | + } |
|
312 | 371 | //$icao = $Translation->checkTranslation($ident); |
313 | 372 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
314 | 373 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -321,7 +380,9 @@ discard block |
||
321 | 380 | $darr = ''; |
322 | 381 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
323 | 382 | if ($n == 7) { |
324 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
383 | + if ($globalDebug) { |
|
384 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
385 | + } |
|
325 | 386 | //$icao = $Translation->checkTranslation($ident); |
326 | 387 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
327 | 388 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -349,8 +410,12 @@ discard block |
||
349 | 410 | $decode['icao'] = $icao; |
350 | 411 | $latitude = $las / 100.0; |
351 | 412 | $longitude = $lns / 100.0; |
352 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
353 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
413 | + if ($lac == 'S') { |
|
414 | + $latitude = '-'.$latitude; |
|
415 | + } |
|
416 | + if ($lnc == 'W') { |
|
417 | + $longitude = '-'.$longitude; |
|
418 | + } |
|
354 | 419 | |
355 | 420 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
356 | 421 | $found = true; |
@@ -368,8 +433,12 @@ discard block |
||
368 | 433 | if ($n == 4) { |
369 | 434 | $latitude = $las; |
370 | 435 | $longitude = $lns; |
371 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
372 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
436 | + if ($lac == 'S') { |
|
437 | + $latitude = '-'.$latitude; |
|
438 | + } |
|
439 | + if ($lnc == 'W') { |
|
440 | + $longitude = '-'.$longitude; |
|
441 | + } |
|
373 | 442 | |
374 | 443 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
375 | 444 | $found = true; |
@@ -385,7 +454,9 @@ discard block |
||
385 | 454 | $darr = ''; |
386 | 455 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
387 | 456 | if ($n == 5) { |
388 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
457 | + if ($globalDebug) { |
|
458 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
459 | + } |
|
389 | 460 | //$icao = $Translation->checkTranslation($ident); |
390 | 461 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
391 | 462 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -406,7 +477,9 @@ discard block |
||
406 | 477 | $aident = ''; |
407 | 478 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
408 | 479 | if ($n == 8) { |
409 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
480 | + if ($globalDebug) { |
|
481 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
482 | + } |
|
410 | 483 | $icao = trim($aident); |
411 | 484 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
412 | 485 | $decode['icao'] = $icao; |
@@ -423,7 +496,9 @@ discard block |
||
423 | 496 | $darr = ''; |
424 | 497 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
425 | 498 | if ($n == 5) { |
426 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
499 | + if ($globalDebug) { |
|
500 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
501 | + } |
|
427 | 502 | //$icao = $Translation->checkTranslation($ident); |
428 | 503 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
429 | 504 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -438,7 +513,9 @@ discard block |
||
438 | 513 | $darr = ''; |
439 | 514 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
440 | 515 | if ($n == 3) { |
441 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
516 | + if ($globalDebug) { |
|
517 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
518 | + } |
|
442 | 519 | //$icao = $Translation->checkTranslation($ident); |
443 | 520 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
444 | 521 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -453,7 +530,9 @@ discard block |
||
453 | 530 | $darr = ''; |
454 | 531 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
455 | 532 | if ($n == 3) { |
456 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
533 | + if ($globalDebug) { |
|
534 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
535 | + } |
|
457 | 536 | //$icao = $Translation->checkTranslation($ident); |
458 | 537 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
459 | 538 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -463,7 +542,9 @@ discard block |
||
463 | 542 | if (!$found) { |
464 | 543 | $n = sscanf($message,'MET01%4c',$airport); |
465 | 544 | if ($n == 1) { |
466 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
545 | + if ($globalDebug) { |
|
546 | + echo 'airport name : '.$airport; |
|
547 | + } |
|
467 | 548 | $decode = array('Airport/Waypoint name' => $airport); |
468 | 549 | $found = true; |
469 | 550 | } |
@@ -471,184 +552,126 @@ discard block |
||
471 | 552 | if ($label == 'H1') { |
472 | 553 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
473 | 554 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
474 | - } |
|
475 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
555 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
476 | 556 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
477 | - } |
|
478 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
557 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
479 | 558 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
480 | - } |
|
481 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
559 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
482 | 560 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
483 | - } |
|
484 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
561 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
485 | 562 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
486 | - } |
|
487 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
563 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
488 | 564 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
489 | - } |
|
490 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
565 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
491 | 566 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
492 | - } |
|
493 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
567 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
494 | 568 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
495 | - } |
|
496 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
569 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
497 | 570 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
498 | - } |
|
499 | - elseif (preg_match(':^#CF:',$message)) { |
|
571 | + } elseif (preg_match(':^#CF:',$message)) { |
|
500 | 572 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
501 | - } |
|
502 | - elseif (preg_match(':^#DF:',$message)) { |
|
573 | + } elseif (preg_match(':^#DF:',$message)) { |
|
503 | 574 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
504 | - } |
|
505 | - elseif (preg_match(':^#EC:',$message)) { |
|
575 | + } elseif (preg_match(':^#EC:',$message)) { |
|
506 | 576 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
507 | - } |
|
508 | - elseif (preg_match(':^#EI:',$message)) { |
|
577 | + } elseif (preg_match(':^#EI:',$message)) { |
|
509 | 578 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
510 | - } |
|
511 | - elseif (preg_match(':^#H1:',$message)) { |
|
579 | + } elseif (preg_match(':^#H1:',$message)) { |
|
512 | 580 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
513 | - } |
|
514 | - elseif (preg_match(':^#H2:',$message)) { |
|
581 | + } elseif (preg_match(':^#H2:',$message)) { |
|
515 | 582 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
516 | - } |
|
517 | - elseif (preg_match(':^#HD:',$message)) { |
|
583 | + } elseif (preg_match(':^#HD:',$message)) { |
|
518 | 584 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
519 | - } |
|
520 | - elseif (preg_match(':^#M1:',$message)) { |
|
585 | + } elseif (preg_match(':^#M1:',$message)) { |
|
521 | 586 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
522 | - } |
|
523 | - elseif (preg_match(':^#M2:',$message)) { |
|
587 | + } elseif (preg_match(':^#M2:',$message)) { |
|
524 | 588 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
525 | - } |
|
526 | - elseif (preg_match(':^#M3:',$message)) { |
|
589 | + } elseif (preg_match(':^#M3:',$message)) { |
|
527 | 590 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
528 | - } |
|
529 | - elseif (preg_match(':^#MD:',$message)) { |
|
591 | + } elseif (preg_match(':^#MD:',$message)) { |
|
530 | 592 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
531 | - } |
|
532 | - elseif (preg_match(':^#PS:',$message)) { |
|
593 | + } elseif (preg_match(':^#PS:',$message)) { |
|
533 | 594 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
534 | - } |
|
535 | - elseif (preg_match(':^#S1:',$message)) { |
|
595 | + } elseif (preg_match(':^#S1:',$message)) { |
|
536 | 596 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
537 | - } |
|
538 | - elseif (preg_match(':^#S2:',$message)) { |
|
597 | + } elseif (preg_match(':^#S2:',$message)) { |
|
539 | 598 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
540 | - } |
|
541 | - elseif (preg_match(':^#SD:',$message)) { |
|
599 | + } elseif (preg_match(':^#SD:',$message)) { |
|
542 | 600 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
543 | - } |
|
544 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
601 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
545 | 602 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
546 | - } |
|
547 | - elseif (preg_match(':^#WO:',$message)) { |
|
603 | + } elseif (preg_match(':^#WO:',$message)) { |
|
548 | 604 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
549 | - } |
|
550 | - elseif (preg_match(':^#A1:',$message)) { |
|
605 | + } elseif (preg_match(':^#A1:',$message)) { |
|
551 | 606 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
552 | - } |
|
553 | - elseif (preg_match(':^#A3:',$message)) { |
|
607 | + } elseif (preg_match(':^#A3:',$message)) { |
|
554 | 608 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
555 | - } |
|
556 | - elseif (preg_match(':^#A4:',$message)) { |
|
609 | + } elseif (preg_match(':^#A4:',$message)) { |
|
557 | 610 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
558 | - } |
|
559 | - elseif (preg_match(':^#A6:',$message)) { |
|
611 | + } elseif (preg_match(':^#A6:',$message)) { |
|
560 | 612 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
561 | - } |
|
562 | - elseif (preg_match(':^#A8:',$message)) { |
|
613 | + } elseif (preg_match(':^#A8:',$message)) { |
|
563 | 614 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
564 | - } |
|
565 | - elseif (preg_match(':^#A9:',$message)) { |
|
615 | + } elseif (preg_match(':^#A9:',$message)) { |
|
566 | 616 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
567 | - } |
|
568 | - elseif (preg_match(':^#A0:',$message)) { |
|
617 | + } elseif (preg_match(':^#A0:',$message)) { |
|
569 | 618 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
570 | - } |
|
571 | - elseif (preg_match(':^#AA:',$message)) { |
|
619 | + } elseif (preg_match(':^#AA:',$message)) { |
|
572 | 620 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
573 | - } |
|
574 | - elseif (preg_match(':^#AB:',$message)) { |
|
621 | + } elseif (preg_match(':^#AB:',$message)) { |
|
575 | 622 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
576 | - } |
|
577 | - elseif (preg_match(':^#AC:',$message)) { |
|
623 | + } elseif (preg_match(':^#AC:',$message)) { |
|
578 | 624 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
579 | - } |
|
580 | - elseif (preg_match(':^#AD:',$message)) { |
|
625 | + } elseif (preg_match(':^#AD:',$message)) { |
|
581 | 626 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
582 | - } |
|
583 | - elseif (preg_match(':^#AF:',$message)) { |
|
627 | + } elseif (preg_match(':^#AF:',$message)) { |
|
584 | 628 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
585 | - } |
|
586 | - elseif (preg_match(':^#B1:',$message)) { |
|
629 | + } elseif (preg_match(':^#B1:',$message)) { |
|
587 | 630 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
588 | - } |
|
589 | - elseif (preg_match(':^#B2:',$message)) { |
|
631 | + } elseif (preg_match(':^#B2:',$message)) { |
|
590 | 632 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
591 | - } |
|
592 | - elseif (preg_match(':^#B3:',$message)) { |
|
633 | + } elseif (preg_match(':^#B3:',$message)) { |
|
593 | 634 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
594 | - } |
|
595 | - elseif (preg_match(':^#B4:',$message)) { |
|
635 | + } elseif (preg_match(':^#B4:',$message)) { |
|
596 | 636 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
597 | - } |
|
598 | - elseif (preg_match(':^#B6:',$message)) { |
|
637 | + } elseif (preg_match(':^#B6:',$message)) { |
|
599 | 638 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
600 | - } |
|
601 | - elseif (preg_match(':^#B8:',$message)) { |
|
639 | + } elseif (preg_match(':^#B8:',$message)) { |
|
602 | 640 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
603 | - } |
|
604 | - elseif (preg_match(':^#B9:',$message)) { |
|
641 | + } elseif (preg_match(':^#B9:',$message)) { |
|
605 | 642 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
606 | - } |
|
607 | - elseif (preg_match(':^#B0:',$message)) { |
|
643 | + } elseif (preg_match(':^#B0:',$message)) { |
|
608 | 644 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
609 | - } |
|
610 | - elseif (preg_match(':^#BA:',$message)) { |
|
645 | + } elseif (preg_match(':^#BA:',$message)) { |
|
611 | 646 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
612 | - } |
|
613 | - elseif (preg_match(':^#BB:',$message)) { |
|
647 | + } elseif (preg_match(':^#BB:',$message)) { |
|
614 | 648 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
615 | - } |
|
616 | - elseif (preg_match(':^#BC:',$message)) { |
|
649 | + } elseif (preg_match(':^#BC:',$message)) { |
|
617 | 650 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
618 | - } |
|
619 | - elseif (preg_match(':^#BD:',$message)) { |
|
651 | + } elseif (preg_match(':^#BD:',$message)) { |
|
620 | 652 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
621 | - } |
|
622 | - elseif (preg_match(':^#BE:',$message)) { |
|
653 | + } elseif (preg_match(':^#BE:',$message)) { |
|
623 | 654 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
624 | - } |
|
625 | - elseif (preg_match(':^#BF:',$message)) { |
|
655 | + } elseif (preg_match(':^#BF:',$message)) { |
|
626 | 656 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
627 | - } |
|
628 | - elseif (preg_match(':^#H3:',$message)) { |
|
657 | + } elseif (preg_match(':^#H3:',$message)) { |
|
629 | 658 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
630 | 659 | } |
631 | 660 | } |
632 | 661 | if ($label == '10') { |
633 | 662 | if (preg_match(':^DTO01:',$message)) { |
634 | 663 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
635 | - } |
|
636 | - elseif (preg_match(':^AIS01:',$message)) { |
|
664 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
637 | 665 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
638 | - } |
|
639 | - elseif (preg_match(':^FTX01:',$message)) { |
|
666 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
640 | 667 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
641 | - } |
|
642 | - elseif (preg_match(':^FPL01:',$message)) { |
|
668 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
643 | 669 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
644 | - } |
|
645 | - elseif (preg_match(':^WAB01:',$message)) { |
|
670 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
646 | 671 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
647 | - } |
|
648 | - elseif (preg_match(':^MET01:',$message)) { |
|
672 | + } elseif (preg_match(':^MET01:',$message)) { |
|
649 | 673 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
650 | - } |
|
651 | - elseif (preg_match(':^WAB02:',$message)) { |
|
674 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
652 | 675 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
653 | 676 | } |
654 | 677 | } |
@@ -663,38 +686,28 @@ discard block |
||
663 | 686 | $vsta = array('Version' => $version); |
664 | 687 | if ($state == 'E') { |
665 | 688 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
666 | - } |
|
667 | - elseif ($state == 'L') { |
|
689 | + } elseif ($state == 'L') { |
|
668 | 690 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
669 | - } |
|
670 | - else { |
|
691 | + } else { |
|
671 | 692 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
672 | 693 | } |
673 | 694 | if ($type == 'V') { |
674 | 695 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
675 | - } |
|
676 | - elseif ($type == 'S') { |
|
696 | + } elseif ($type == 'S') { |
|
677 | 697 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
678 | - } |
|
679 | - elseif ($type == 'H') { |
|
698 | + } elseif ($type == 'H') { |
|
680 | 699 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
681 | - } |
|
682 | - elseif ($type == 'G') { |
|
700 | + } elseif ($type == 'G') { |
|
683 | 701 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
684 | - } |
|
685 | - elseif ($type == 'C') { |
|
702 | + } elseif ($type == 'C') { |
|
686 | 703 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
687 | - } |
|
688 | - elseif ($type == '2') { |
|
704 | + } elseif ($type == '2') { |
|
689 | 705 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
690 | - } |
|
691 | - elseif ($type == 'X') { |
|
706 | + } elseif ($type == 'X') { |
|
692 | 707 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
693 | - } |
|
694 | - elseif ($type == 'I') { |
|
708 | + } elseif ($type == 'I') { |
|
695 | 709 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
696 | - } |
|
697 | - else { |
|
710 | + } else { |
|
698 | 711 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
699 | 712 | } |
700 | 713 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -703,7 +716,9 @@ discard block |
||
703 | 716 | } |
704 | 717 | |
705 | 718 | $title = $this->getTitlefromLabel($label); |
706 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
719 | + if ($title != '') { |
|
720 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
721 | + } |
|
707 | 722 | /* |
708 | 723 | // Business jets always use GS0001 |
709 | 724 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -738,31 +753,54 @@ discard block |
||
738 | 753 | $msg = $message['message']; |
739 | 754 | $decode = $message['decode']; |
740 | 755 | $registration = (string)$message['registration']; |
741 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
742 | - else $latitude = ''; |
|
743 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
744 | - else $longitude = ''; |
|
745 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
746 | - else $airicao = ''; |
|
747 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
748 | - else $icao = $Translation->checkTranslation($ident); |
|
756 | + if (isset($decode['latitude'])) { |
|
757 | + $latitude = $decode['latitude']; |
|
758 | + } else { |
|
759 | + $latitude = ''; |
|
760 | + } |
|
761 | + if (isset($decode['longitude'])) { |
|
762 | + $longitude = $decode['longitude']; |
|
763 | + } else { |
|
764 | + $longitude = ''; |
|
765 | + } |
|
766 | + if (isset($decode['airicao'])) { |
|
767 | + $airicao = $decode['airicao']; |
|
768 | + } else { |
|
769 | + $airicao = ''; |
|
770 | + } |
|
771 | + if (isset($decode['icao'])) { |
|
772 | + $icao = $decode['icao']; |
|
773 | + } else { |
|
774 | + $icao = $Translation->checkTranslation($ident); |
|
775 | + } |
|
749 | 776 | $image_array = $Image->getSpotterImage($registration); |
750 | 777 | if (!isset($image_array[0]['registration'])) { |
751 | 778 | $Image->addSpotterImage($registration); |
752 | 779 | } |
753 | 780 | // Business jets always use GS0001 |
754 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
755 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
756 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
757 | - else $decode_json = ''; |
|
781 | + if ($ident != 'GS0001') { |
|
782 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
783 | + } |
|
784 | + if ($globalDebug && isset($info) && $info != '') { |
|
785 | + echo $info; |
|
786 | + } |
|
787 | + if (count($decode) > 0) { |
|
788 | + $decode_json = json_encode($decode); |
|
789 | + } else { |
|
790 | + $decode_json = ''; |
|
791 | + } |
|
758 | 792 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
759 | 793 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
760 | 794 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
761 | 795 | $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
762 | 796 | } |
763 | 797 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
764 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
765 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
798 | + if (!isset($globalACARSArchive)) { |
|
799 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
800 | + } |
|
801 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
802 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
803 | + } |
|
766 | 804 | if ($globalDebug && count($decode) > 0) { |
767 | 805 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
768 | 806 | } |
@@ -785,7 +823,9 @@ discard block |
||
785 | 823 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
786 | 824 | $Connection = new Connection($this->db); |
787 | 825 | $this->db = $Connection->db; |
788 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
826 | + if ($globalDebug) { |
|
827 | + echo "Test if not already in Live ACARS table..."; |
|
828 | + } |
|
789 | 829 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
790 | 830 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
791 | 831 | try { |
@@ -795,7 +835,9 @@ discard block |
||
795 | 835 | return "error : ".$e->getMessage(); |
796 | 836 | } |
797 | 837 | if ($stht->fetchColumn() == 0) { |
798 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
838 | + if ($globalDebug) { |
|
839 | + echo "Add Live ACARS data..."; |
|
840 | + } |
|
799 | 841 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
800 | 842 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
801 | 843 | try { |
@@ -805,10 +847,14 @@ discard block |
||
805 | 847 | return "error : ".$e->getMessage(); |
806 | 848 | } |
807 | 849 | } else { |
808 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
850 | + if ($globalDebug) { |
|
851 | + echo "Data already in DB...\n"; |
|
852 | + } |
|
809 | 853 | return false; |
810 | 854 | } |
811 | - if ($globalDebug) echo "Done\n"; |
|
855 | + if ($globalDebug) { |
|
856 | + echo "Done\n"; |
|
857 | + } |
|
812 | 858 | return true; |
813 | 859 | } |
814 | 860 | } |
@@ -839,7 +885,9 @@ discard block |
||
839 | 885 | } |
840 | 886 | if ($stht->fetchColumn() == 0) { |
841 | 887 | */ |
842 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
888 | + if ($globalDebug) { |
|
889 | + echo "Add Live ACARS data..."; |
|
890 | + } |
|
843 | 891 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
844 | 892 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
845 | 893 | try { |
@@ -848,7 +896,9 @@ discard block |
||
848 | 896 | } catch(PDOException $e) { |
849 | 897 | return "error : ".$e->getMessage(); |
850 | 898 | } |
851 | - if ($globalDebug) echo "Done\n"; |
|
899 | + if ($globalDebug) { |
|
900 | + echo "Done\n"; |
|
901 | + } |
|
852 | 902 | } |
853 | 903 | } |
854 | 904 | |
@@ -871,8 +921,11 @@ discard block |
||
871 | 921 | die; |
872 | 922 | } |
873 | 923 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
874 | - if (count($row) > 0) return $row[0]['title']; |
|
875 | - else return ''; |
|
924 | + if (count($row) > 0) { |
|
925 | + return $row[0]['title']; |
|
926 | + } else { |
|
927 | + return ''; |
|
928 | + } |
|
876 | 929 | } |
877 | 930 | |
878 | 931 | /** |
@@ -891,8 +944,11 @@ discard block |
||
891 | 944 | die; |
892 | 945 | } |
893 | 946 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
894 | - if (count($row) > 0) return $row; |
|
895 | - else return array(); |
|
947 | + if (count($row) > 0) { |
|
948 | + return $row; |
|
949 | + } else { |
|
950 | + return array(); |
|
951 | + } |
|
896 | 952 | } |
897 | 953 | |
898 | 954 | /** |
@@ -912,8 +968,11 @@ discard block |
||
912 | 968 | die; |
913 | 969 | } |
914 | 970 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
915 | - if (count($row) > 0) return $row[0]; |
|
916 | - else return array(); |
|
971 | + if (count($row) > 0) { |
|
972 | + return $row[0]; |
|
973 | + } else { |
|
974 | + return array(); |
|
975 | + } |
|
917 | 976 | } |
918 | 977 | |
919 | 978 | /** |
@@ -958,19 +1017,35 @@ discard block |
||
958 | 1017 | if ($row['registration'] != '') { |
959 | 1018 | $row['registration'] = str_replace('.','',$row['registration']); |
960 | 1019 | $image_array = $Image->getSpotterImage($row['registration']); |
961 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
962 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
963 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
964 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
965 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1020 | + if (count($image_array) > 0) { |
|
1021 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1022 | + } else { |
|
1023 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1024 | + } |
|
1025 | + } else { |
|
1026 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1027 | + } |
|
1028 | + if ($row['registration'] == '') { |
|
1029 | + $row['registration'] = 'NA'; |
|
1030 | + } |
|
1031 | + if ($row['ident'] == '') { |
|
1032 | + $row['ident'] = 'NA'; |
|
1033 | + } |
|
966 | 1034 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
967 | 1035 | if (isset($identicao[0])) { |
968 | 1036 | if (substr($row['ident'],0,2) == 'AF') { |
969 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
970 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
971 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1037 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1038 | + $icao = $row['ident']; |
|
1039 | + } else { |
|
1040 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1041 | + } |
|
1042 | + } else { |
|
1043 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1044 | + } |
|
972 | 1045 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
973 | - } else $icao = $row['ident']; |
|
1046 | + } else { |
|
1047 | + $icao = $row['ident']; |
|
1048 | + } |
|
974 | 1049 | $icao = $Translation->checkTranslation($icao,false); |
975 | 1050 | $decode = json_decode($row['decode'],true); |
976 | 1051 | $found = false; |
@@ -995,7 +1070,9 @@ discard block |
||
995 | 1070 | $found = true; |
996 | 1071 | } |
997 | 1072 | } |
998 | - if ($found) $row['decode'] = json_encode($decode); |
|
1073 | + if ($found) { |
|
1074 | + $row['decode'] = json_encode($decode); |
|
1075 | + } |
|
999 | 1076 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1000 | 1077 | $result[] = $data; |
1001 | 1078 | $i++; |
@@ -1003,8 +1080,9 @@ discard block |
||
1003 | 1080 | if (isset($result)) { |
1004 | 1081 | $result[0]['query_number_rows'] = $i; |
1005 | 1082 | return $result; |
1083 | + } else { |
|
1084 | + return array(); |
|
1006 | 1085 | } |
1007 | - else return array(); |
|
1008 | 1086 | } |
1009 | 1087 | |
1010 | 1088 | /** |
@@ -1053,31 +1131,51 @@ discard block |
||
1053 | 1131 | if ($row['registration'] != '') { |
1054 | 1132 | $row['registration'] = str_replace('.','',$row['registration']); |
1055 | 1133 | $image_array = $Image->getSpotterImage($row['registration']); |
1056 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1057 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1058 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1134 | + if (count($image_array) > 0) { |
|
1135 | + $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1136 | + } else { |
|
1137 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1138 | + } |
|
1139 | + } else { |
|
1140 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1141 | + } |
|
1059 | 1142 | $icao = ''; |
1060 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
1061 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1143 | + if ($row['registration'] == '') { |
|
1144 | + $row['registration'] = 'NA'; |
|
1145 | + } |
|
1146 | + if ($row['ident'] == '') { |
|
1147 | + $row['ident'] = 'NA'; |
|
1148 | + } |
|
1062 | 1149 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
1063 | 1150 | if (isset($identicao[0])) { |
1064 | 1151 | if (substr($row['ident'],0,2) == 'AF') { |
1065 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1066 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1067 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1152 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1153 | + $icao = $row['ident']; |
|
1154 | + } else { |
|
1155 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1156 | + } |
|
1157 | + } else { |
|
1158 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1159 | + } |
|
1068 | 1160 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
1069 | - } else $icao = $row['ident']; |
|
1161 | + } else { |
|
1162 | + $icao = $row['ident']; |
|
1163 | + } |
|
1070 | 1164 | $icao = $Translation->checkTranslation($icao); |
1071 | 1165 | $decode = json_decode($row['decode'],true); |
1072 | 1166 | $found = false; |
1073 | 1167 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
1074 | 1168 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1075 | - if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1169 | + if (isset($airport_info[0]['icao'])) { |
|
1170 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1171 | + } |
|
1076 | 1172 | $found = true; |
1077 | 1173 | } |
1078 | 1174 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
1079 | 1175 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1080 | - if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1176 | + if (isset($airport_info[0]['icao'])) { |
|
1177 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1178 | + } |
|
1081 | 1179 | $found = true; |
1082 | 1180 | } |
1083 | 1181 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1087,7 +1185,9 @@ discard block |
||
1087 | 1185 | $found = true; |
1088 | 1186 | } |
1089 | 1187 | } |
1090 | - if ($found) $row['decode'] = json_encode($decode); |
|
1188 | + if ($found) { |
|
1189 | + $row['decode'] = json_encode($decode); |
|
1190 | + } |
|
1091 | 1191 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1092 | 1192 | $result[] = $data; |
1093 | 1193 | $i++; |
@@ -1095,7 +1195,9 @@ discard block |
||
1095 | 1195 | if (isset($result)) { |
1096 | 1196 | $result[0]['query_number_rows'] = $i; |
1097 | 1197 | return $result; |
1098 | - } else return array(); |
|
1198 | + } else { |
|
1199 | + return array(); |
|
1200 | + } |
|
1099 | 1201 | } |
1100 | 1202 | |
1101 | 1203 | /** |
@@ -1111,25 +1213,37 @@ discard block |
||
1111 | 1213 | $ident = trim($ident); |
1112 | 1214 | $Translation = new Translation($this->db); |
1113 | 1215 | $Spotter = new Spotter($this->db); |
1114 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
1216 | + if ($globalDebug) { |
|
1217 | + echo "Test if we add ModeS data..."; |
|
1218 | + } |
|
1115 | 1219 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
1116 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
1117 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
1220 | + if ($icao == '') { |
|
1221 | + $icao = $Translation->checkTranslation($ident); |
|
1222 | + } |
|
1223 | + if ($globalDebug) { |
|
1224 | + echo '- Ident : '.$icao.' - '; |
|
1225 | + } |
|
1118 | 1226 | if ($ident == '' || $registration == '') { |
1119 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
1227 | + if ($globalDebug) { |
|
1228 | + echo "Ident or registration null, exit\n"; |
|
1229 | + } |
|
1120 | 1230 | return ''; |
1121 | 1231 | } |
1122 | 1232 | $registration = str_replace('.','',$registration); |
1123 | 1233 | $ident = $Translation->ident2icao($ident); |
1124 | 1234 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1125 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
1235 | + if ($globalDebug) { |
|
1236 | + echo "Check if needed to add translation ".$ident.'... '; |
|
1237 | + } |
|
1126 | 1238 | $querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1"; |
1127 | 1239 | $querysi_values = array(':registration' => $registration); |
1128 | 1240 | try { |
1129 | 1241 | $sthsi = $this->db->prepare($querysi); |
1130 | 1242 | $sthsi->execute($querysi_values); |
1131 | 1243 | } catch(PDOException $e) { |
1132 | - if ($globalDebug) echo $e->getMessage(); |
|
1244 | + if ($globalDebug) { |
|
1245 | + echo $e->getMessage(); |
|
1246 | + } |
|
1133 | 1247 | return "error : ".$e->getMessage(); |
1134 | 1248 | } |
1135 | 1249 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1137,9 +1251,14 @@ discard block |
||
1137 | 1251 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
1138 | 1252 | $Translation = new Translation($this->db); |
1139 | 1253 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1140 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1141 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1142 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1254 | + if ($globalDebug) { |
|
1255 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1256 | + } |
|
1257 | + if ($ident != $trans_ident) { |
|
1258 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1259 | + } elseif ($trans_ident == $ident) { |
|
1260 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1261 | + } |
|
1143 | 1262 | } else { |
1144 | 1263 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1145 | 1264 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1148,32 +1267,44 @@ discard block |
||
1148 | 1267 | $sth = $this->db->prepare($query); |
1149 | 1268 | $sth->execute($query_values); |
1150 | 1269 | } catch(PDOException $e) { |
1151 | - if ($globalDebug) echo $e->getMessage(); |
|
1270 | + if ($globalDebug) { |
|
1271 | + echo $e->getMessage(); |
|
1272 | + } |
|
1152 | 1273 | return "error : ".$e->getMessage(); |
1153 | 1274 | } |
1154 | 1275 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1155 | 1276 | $sth->closeCursor(); |
1156 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
1157 | - else $hex = ''; |
|
1277 | + if (isset($result['modes'])) { |
|
1278 | + $hex = $result['modes']; |
|
1279 | + } else { |
|
1280 | + $hex = ''; |
|
1281 | + } |
|
1158 | 1282 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
1159 | 1283 | $this->SI->add($SI_data); |
1160 | 1284 | } |
1161 | 1285 | } |
1162 | - if ($globalDebug) echo 'Done'."\n"; |
|
1286 | + if ($globalDebug) { |
|
1287 | + echo 'Done'."\n"; |
|
1288 | + } |
|
1163 | 1289 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
1164 | 1290 | $query_values = array(':ident' => $icao); |
1165 | 1291 | try { |
1166 | 1292 | $sth = $this->db->prepare($query); |
1167 | 1293 | $sth->execute($query_values); |
1168 | 1294 | } catch(PDOException $e) { |
1169 | - if ($globalDebug) echo $e->getMessage(); |
|
1295 | + if ($globalDebug) { |
|
1296 | + echo $e->getMessage(); |
|
1297 | + } |
|
1170 | 1298 | return "error : ".$e->getMessage(); |
1171 | 1299 | } |
1172 | 1300 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1173 | 1301 | $sth->closeCursor(); |
1174 | 1302 | if (isset($result['flightaware_id'])) { |
1175 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
1176 | - else $ModeS = ''; |
|
1303 | + if (isset($result['ModeS'])) { |
|
1304 | + $ModeS = $result['ModeS']; |
|
1305 | + } else { |
|
1306 | + $ModeS = ''; |
|
1307 | + } |
|
1177 | 1308 | if ($ModeS == '') { |
1178 | 1309 | $id = explode('-',$result['flightaware_id']); |
1179 | 1310 | $ModeS = $id[0]; |
@@ -1186,24 +1317,32 @@ discard block |
||
1186 | 1317 | $sthc = $this->db->prepare($queryc); |
1187 | 1318 | $sthc->execute($queryc_values); |
1188 | 1319 | } catch(PDOException $e) { |
1189 | - if ($globalDebug) echo $e->getMessage(); |
|
1320 | + if ($globalDebug) { |
|
1321 | + echo $e->getMessage(); |
|
1322 | + } |
|
1190 | 1323 | return "error : ".$e->getMessage(); |
1191 | 1324 | } |
1192 | 1325 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1193 | 1326 | $sthc->closeCursor(); |
1194 | 1327 | if (count($row) == 0) { |
1195 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
1328 | + if ($globalDebug) { |
|
1329 | + echo " Add to ModeS table - "; |
|
1330 | + } |
|
1196 | 1331 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1197 | 1332 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
1198 | 1333 | try { |
1199 | 1334 | $sthi = $this->db->prepare($queryi); |
1200 | 1335 | $sthi->execute($queryi_values); |
1201 | 1336 | } catch(PDOException $e) { |
1202 | - if ($globalDebug) echo $e->getMessage(); |
|
1337 | + if ($globalDebug) { |
|
1338 | + echo $e->getMessage(); |
|
1339 | + } |
|
1203 | 1340 | return "error : ".$e->getMessage(); |
1204 | 1341 | } |
1205 | 1342 | } else { |
1206 | - if ($globalDebug) echo " Update ModeS table - "; |
|
1343 | + if ($globalDebug) { |
|
1344 | + echo " Update ModeS table - "; |
|
1345 | + } |
|
1207 | 1346 | if ($ICAOTypeCode != '') { |
1208 | 1347 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1209 | 1348 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1215,7 +1354,9 @@ discard block |
||
1215 | 1354 | $sthi = $this->db->prepare($queryi); |
1216 | 1355 | $sthi->execute($queryi_values); |
1217 | 1356 | } catch(PDOException $e) { |
1218 | - if ($globalDebug) echo $e->getMessage(); |
|
1357 | + if ($globalDebug) { |
|
1358 | + echo $e->getMessage(); |
|
1359 | + } |
|
1219 | 1360 | return "error : ".$e->getMessage(); |
1220 | 1361 | } |
1221 | 1362 | } |
@@ -1236,7 +1377,9 @@ discard block |
||
1236 | 1377 | return "error : ".$e->getMessage(); |
1237 | 1378 | } |
1238 | 1379 | */ |
1239 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
1380 | + if ($globalDebug) { |
|
1381 | + echo " Update Spotter_output table - "; |
|
1382 | + } |
|
1240 | 1383 | if ($ICAOTypeCode != '') { |
1241 | 1384 | if ($globalDBdriver == 'mysql') { |
1242 | 1385 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1247,8 +1390,7 @@ discard block |
||
1247 | 1390 | } else { |
1248 | 1391 | if ($globalDBdriver == 'mysql') { |
1249 | 1392 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
1250 | - } |
|
1251 | - elseif ($globalDBdriver == 'pgsql') { |
|
1393 | + } elseif ($globalDBdriver == 'pgsql') { |
|
1252 | 1394 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1253 | 1395 | } |
1254 | 1396 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1257,14 +1399,20 @@ discard block |
||
1257 | 1399 | $sthi = $this->db->prepare($queryi); |
1258 | 1400 | $sthi->execute($queryi_values); |
1259 | 1401 | } catch(PDOException $e) { |
1260 | - if ($globalDebug) echo $e->getMessage(); |
|
1402 | + if ($globalDebug) { |
|
1403 | + echo $e->getMessage(); |
|
1404 | + } |
|
1261 | 1405 | return "error : ".$e->getMessage(); |
1262 | 1406 | } |
1263 | 1407 | } |
1264 | 1408 | } else { |
1265 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
1409 | + if ($globalDebug) { |
|
1410 | + echo " Can't find ModeS in spotter_output - "; |
|
1411 | + } |
|
1412 | + } |
|
1413 | + if ($globalDebug) { |
|
1414 | + echo "Done\n"; |
|
1266 | 1415 | } |
1267 | - if ($globalDebug) echo "Done\n"; |
|
1268 | 1416 | } |
1269 | 1417 | } |
1270 | 1418 | ?> |
@@ -19,20 +19,27 @@ discard block |
||
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
21 | 21 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
22 | - if (isset($source['source'])) $filter['source'][] = $source['source']; |
|
22 | + if (isset($source['source'])) { |
|
23 | + $filter['source'][] = $source['source']; |
|
24 | + } |
|
23 | 25 | } |
24 | 26 | } else { |
25 | 27 | $filter = $globalStatsFilters[$globalFilterName]; |
26 | 28 | } |
27 | 29 | } |
28 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) { |
|
31 | + $filter = array_merge($filter,$globalFilter); |
|
32 | + } |
|
29 | 33 | $filter_query_join = ''; |
30 | 34 | $filter_query_where = ''; |
31 | 35 | if (isset($filter['source']) && !empty($filter['source'])) { |
32 | 36 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
33 | 37 | } |
34 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
35 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
38 | + if ($filter_query_where == '' && $where) { |
|
39 | + $filter_query_where = ' WHERE'; |
|
40 | + } elseif ($filter_query_where != '' && $and) { |
|
41 | + $filter_query_where .= ' AND'; |
|
42 | + } |
|
36 | 43 | $filter_query = $filter_query_join.$filter_query_where; |
37 | 44 | return $filter_query; |
38 | 45 | } |
@@ -89,7 +96,9 @@ discard block |
||
89 | 96 | $info = str_replace('^','<br />',$info); |
90 | 97 | $info = str_replace('&sect;','',$info); |
91 | 98 | $info = str_replace('"','',$info); |
92 | - if ($type == '') $type = NULL; |
|
99 | + if ($type == '') { |
|
100 | + $type = NULL; |
|
101 | + } |
|
93 | 102 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
94 | 103 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
95 | 104 | try { |
@@ -105,7 +114,9 @@ discard block |
||
105 | 114 | $info = str_replace('^','<br />',$info); |
106 | 115 | $info = str_replace('&sect;','',$info); |
107 | 116 | $info = str_replace('"','',$info); |
108 | - if ($type == '') $type = NULL; |
|
117 | + if ($type == '') { |
|
118 | + $type = NULL; |
|
119 | + } |
|
109 | 120 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
110 | 121 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
111 | 122 | try { |
@@ -59,8 +59,11 @@ discard block |
||
59 | 59 | } |
60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
61 | 61 | $sth->closeCursor(); |
62 | - if ($row['nb'] > 0) return false; |
|
63 | - else return true; |
|
62 | + if ($row['nb'] > 0) { |
|
63 | + return false; |
|
64 | + } else { |
|
65 | + return true; |
|
66 | + } |
|
64 | 67 | } |
65 | 68 | |
66 | 69 | public static function insert_last_update() { |
@@ -82,9 +85,14 @@ discard block |
||
82 | 85 | //$pieces = explode(' ',$data); |
83 | 86 | $pieces = preg_split('/\s/',$data); |
84 | 87 | $pos = 0; |
85 | - if ($pieces[0] == 'METAR') $pos++; |
|
86 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
87 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
88 | + if ($pieces[0] == 'METAR') { |
|
89 | + $pos++; |
|
90 | + } elseif ($pieces[0] == 'SPECI') { |
|
91 | + $pos++; |
|
92 | + } |
|
93 | + if (strlen($pieces[$pos]) != 4) { |
|
94 | + $pos++; |
|
95 | + } |
|
88 | 96 | $result = array(); |
89 | 97 | $result['location'] = $pieces[$pos]; |
90 | 98 | $pos++; |
@@ -93,16 +101,26 @@ discard block |
||
93 | 101 | $c = count($pieces); |
94 | 102 | for($pos++; $pos < $c; $pos++) { |
95 | 103 | $piece = $pieces[$pos]; |
96 | - if ($piece == 'RMK') break; |
|
97 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
98 | - if ($piece == 'COR') $result['correction'] = true; |
|
104 | + if ($piece == 'RMK') { |
|
105 | + break; |
|
106 | + } |
|
107 | + if ($piece == 'AUTO') { |
|
108 | + $result['auto'] = true; |
|
109 | + } |
|
110 | + if ($piece == 'COR') { |
|
111 | + $result['correction'] = true; |
|
112 | + } |
|
99 | 113 | // Wind Speed |
100 | 114 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
101 | 115 | $result['wind']['direction'] = (float)$matches[1]; |
102 | 116 | $result['wind']['unit'] = $matches[4]; |
103 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
104 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
105 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
117 | + if ($result['wind']['unit'] == 'KT') { |
|
118 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
119 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
120 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
121 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
122 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
123 | + } |
|
106 | 124 | $result['wind']['gust'] = (float)$matches[3]; |
107 | 125 | $result['wind']['unit'] = $matches[4]; |
108 | 126 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -185,14 +203,23 @@ discard block |
||
185 | 203 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
186 | 204 | $type = $matches[1]; |
187 | 205 | $cloud = array(); |
188 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
189 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
190 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
191 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
192 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
193 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
194 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
195 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
206 | + if ($type == 'SKC') { |
|
207 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
208 | + } elseif ($type == 'CLR') { |
|
209 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
210 | + } elseif ($type == 'NSC') { |
|
211 | + $cloud['type'] = 'No significant cloud'; |
|
212 | + } elseif ($type == 'FEW') { |
|
213 | + $cloud['type'] = 'Few'; |
|
214 | + } elseif ($type == 'SCT') { |
|
215 | + $cloud['type'] = 'Scattered'; |
|
216 | + } elseif ($type == 'BKN') { |
|
217 | + $cloud['type'] = 'Broken'; |
|
218 | + } elseif ($type == 'OVC') { |
|
219 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
220 | + } elseif ($type == 'VV') { |
|
221 | + $cloud['type'] = 'Vertical visibility'; |
|
222 | + } |
|
196 | 223 | $cloud['type_code'] = $type; |
197 | 224 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
198 | 225 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -218,8 +245,11 @@ discard block |
||
218 | 245 | $result['RVR']['friction'] = $matches[5]; |
219 | 246 | } |
220 | 247 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
221 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
222 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
248 | + if (isset($matches[5])) { |
|
249 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
250 | + } else { |
|
251 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
252 | + } |
|
223 | 253 | if (isset($matches[3])) { |
224 | 254 | $range = Array( |
225 | 255 | 'from' => (float)$matches[2], |
@@ -252,8 +282,11 @@ discard block |
||
252 | 282 | if (isset($matches[3])) { |
253 | 283 | $text[] = $this->texts[$matches[3]]; |
254 | 284 | } |
255 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
256 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
285 | + if (!isset($result['weather'])) { |
|
286 | + $result['weather'] = implode(' ', $text); |
|
287 | + } else { |
|
288 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
289 | + } |
|
257 | 290 | } |
258 | 291 | } |
259 | 292 | return $result; |
@@ -264,8 +297,11 @@ discard block |
||
264 | 297 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
265 | 298 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
266 | 299 | } else { |
267 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
268 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
300 | + if ($globalDBdriver == 'mysql') { |
|
301 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
302 | + } else { |
|
303 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
304 | + } |
|
269 | 305 | } |
270 | 306 | $query_values = array(':icao' => $icao); |
271 | 307 | try { |
@@ -321,7 +357,9 @@ discard block |
||
321 | 357 | |
322 | 358 | public function addMETARCycle() { |
323 | 359 | global $globalDebug, $globalIVAO, $globalTransaction; |
324 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
360 | + if (isset($globalDebug) && $globalDebug) { |
|
361 | + echo "Downloading METAR cycle..."; |
|
362 | + } |
|
325 | 363 | date_default_timezone_set("UTC"); |
326 | 364 | $Common = new Common(); |
327 | 365 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -332,31 +370,47 @@ discard block |
||
332 | 370 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
333 | 371 | } |
334 | 372 | if ($handle) { |
335 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
373 | + if (isset($globalDebug) && $globalDebug) { |
|
374 | + echo "Done - Updating DB..."; |
|
375 | + } |
|
336 | 376 | $date = ''; |
337 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
377 | + if ($globalTransaction) { |
|
378 | + $this->db->beginTransaction(); |
|
379 | + } |
|
338 | 380 | while(($line = fgets($handle,4096)) !== false) { |
339 | 381 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
340 | 382 | $date = $line; |
341 | 383 | } elseif ($line != '') { |
342 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
384 | + if ($date == '') { |
|
385 | + $date = date('Y/m/d H:m'); |
|
386 | + } |
|
343 | 387 | $pos = 0; |
344 | 388 | $pieces = preg_split('/\s/',$line); |
345 | - if ($pieces[0] == 'METAR') $pos++; |
|
346 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
389 | + if ($pieces[0] == 'METAR') { |
|
390 | + $pos++; |
|
391 | + } |
|
392 | + if (strlen($pieces[$pos]) != 4) { |
|
393 | + $pos++; |
|
394 | + } |
|
347 | 395 | $location = $pieces[$pos]; |
348 | 396 | echo $this->addMETAR($location,$line,$date); |
349 | 397 | } |
350 | 398 | } |
351 | 399 | fclose($handle); |
352 | - if ($globalTransaction) $this->db->commit(); |
|
400 | + if ($globalTransaction) { |
|
401 | + $this->db->commit(); |
|
402 | + } |
|
403 | + } |
|
404 | + if (isset($globalDebug) && $globalDebug) { |
|
405 | + echo "Done\n"; |
|
353 | 406 | } |
354 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
355 | 407 | } |
356 | 408 | |
357 | 409 | public function downloadMETAR($icao) { |
358 | 410 | global $globalMETARurl; |
359 | - if ($globalMETARurl == '') return array(); |
|
411 | + if ($globalMETARurl == '') { |
|
412 | + return array(); |
|
413 | + } |
|
360 | 414 | date_default_timezone_set("UTC"); |
361 | 415 | $Common = new Common(); |
362 | 416 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -367,16 +421,24 @@ discard block |
||
367 | 421 | $date = $line; |
368 | 422 | } |
369 | 423 | if ($line != '') { |
370 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
424 | + if ($date == '') { |
|
425 | + $date = date('Y/m/d H:m'); |
|
426 | + } |
|
371 | 427 | $pos = 0; |
372 | 428 | $pieces = preg_split('/\s/',$line); |
373 | - if ($pieces[0] == 'METAR') $pos++; |
|
374 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
429 | + if ($pieces[0] == 'METAR') { |
|
430 | + $pos++; |
|
431 | + } |
|
432 | + if (strlen($pieces[$pos]) != 4) { |
|
433 | + $pos++; |
|
434 | + } |
|
375 | 435 | $location = $pieces[$pos]; |
376 | 436 | if (strlen($location == 4)) { |
377 | 437 | $this->addMETAR($location,$line,$date); |
378 | 438 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
379 | - } else return array(); |
|
439 | + } else { |
|
440 | + return array(); |
|
441 | + } |
|
380 | 442 | } |
381 | 443 | } |
382 | 444 | return array(); |
@@ -48,7 +48,9 @@ discard block |
||
48 | 48 | $all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']); |
49 | 49 | if (isset($globalTimezone)) { |
50 | 50 | date_default_timezone_set($globalTimezone); |
51 | - } else date_default_timezone_set('UTC'); |
|
51 | + } else { |
|
52 | + date_default_timezone_set('UTC'); |
|
53 | + } |
|
52 | 54 | |
53 | 55 | if (is_array($all_data) && count($all_data) > 1) { |
54 | 56 | print '<br/>'; |
@@ -327,9 +329,13 @@ discard block |
||
327 | 329 | print '<div>'; |
328 | 330 | if (isset($spotter_item['pilot_id']) && $spotter_item['pilot_id'] != "") |
329 | 331 | { |
330 | - if ($spotter_item['format_source'] == 'whazzup') print '<a href="https://www.ivao.aero/Member.aspx?ID='.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>'; |
|
331 | - elseif ($spotter_item['format_source'] == 'vatsimtxt') print '<a href="http://www.vataware.com/pilot/'.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>'; |
|
332 | - else print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
332 | + if ($spotter_item['format_source'] == 'whazzup') { |
|
333 | + print '<a href="https://www.ivao.aero/Member.aspx?ID='.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>'; |
|
334 | + } elseif ($spotter_item['format_source'] == 'vatsimtxt') { |
|
335 | + print '<a href="http://www.vataware.com/pilot/'.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>'; |
|
336 | + } else { |
|
337 | + print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
338 | + } |
|
333 | 339 | } else { |
334 | 340 | if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != "") |
335 | 341 | { |
@@ -118,8 +118,12 @@ discard block |
||
118 | 118 | { |
119 | 119 | $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']); |
120 | 120 | $ident = $spotter_array[0]['ident']; |
121 | - if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
|
122 | - if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
|
121 | + if (isset($spotter_array[0]['latitude'])) { |
|
122 | + $latitude = $spotter_array[0]['latitude']; |
|
123 | + } |
|
124 | + if (isset($spotter_array[0]['longitude'])) { |
|
125 | + $longitude = $spotter_array[0]['longitude']; |
|
126 | + } |
|
123 | 127 | require_once('header.php'); |
124 | 128 | if (isset($globalArchive) && $globalArchive && $type == 'aircraft') { |
125 | 129 | // Requirement for altitude graph |
@@ -127,7 +131,9 @@ discard block |
||
127 | 131 | $all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']); |
128 | 132 | if (isset($globalTimezone)) { |
129 | 133 | date_default_timezone_set($globalTimezone); |
130 | - } else date_default_timezone_set('UTC'); |
|
134 | + } else { |
|
135 | + date_default_timezone_set('UTC'); |
|
136 | + } |
|
131 | 137 | if (is_array($all_data) && count($all_data) > 1) { |
132 | 138 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
133 | 139 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -204,14 +210,22 @@ discard block |
||
204 | 210 | if (isset($spotter_array[0]['airline_icao'])) { |
205 | 211 | print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>'; |
206 | 212 | } |
207 | - if ($type == 'aircraft') print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>'; |
|
213 | + if ($type == 'aircraft') { |
|
214 | + print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>'; |
|
215 | + } |
|
208 | 216 | print '</div>'; |
209 | 217 | |
210 | - if ($type == 'aircraft') include('ident-sub-menu.php'); |
|
218 | + if ($type == 'aircraft') { |
|
219 | + include('ident-sub-menu.php'); |
|
220 | + } |
|
211 | 221 | print '<div class="table column">'; |
212 | - if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
213 | - elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
214 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
222 | + if ($type == 'aircraft') { |
|
223 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
224 | + } elseif ($type == 'marine') { |
|
225 | + print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
226 | + } elseif ($type == 'tracker') { |
|
227 | + print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
228 | + } |
|
215 | 229 | |
216 | 230 | include('table-output.php'); |
217 | 231 | print '<div class="pagination">'; |