@@ -72,7 +72,9 @@ discard block |
||
72 | 72 | if (isset($filter[0]['source'])) { |
73 | 73 | $filters = array_merge($filters,$filter); |
74 | 74 | } |
75 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
75 | + if (is_array($globalFilter)) { |
|
76 | + $filter = array_merge($filter,$globalFilter); |
|
77 | + } |
|
76 | 78 | $filter_query_join = ''; |
77 | 79 | $filter_query_where = ''; |
78 | 80 | foreach($filters as $flt) { |
@@ -149,8 +151,11 @@ discard block |
||
149 | 151 | $filter_query_where .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
150 | 152 | } |
151 | 153 | } |
152 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
153 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
154 | + if ($filter_query_where == '' && $where) { |
|
155 | + $filter_query_where = ' WHERE'; |
|
156 | + } elseif ($filter_query_where != '' && $and) { |
|
157 | + $filter_query_where .= ' AND'; |
|
158 | + } |
|
154 | 159 | if ($filter_query_where != '') { |
155 | 160 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
156 | 161 | } |
@@ -173,10 +178,18 @@ discard block |
||
173 | 178 | $Image = new Image($this->db); |
174 | 179 | $Schedule = new Schedule($this->db); |
175 | 180 | $ACARS = new ACARS($this->db); |
176 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
177 | - if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
178 | - if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
179 | - if (!isset($globalVAM)) $globalVAM = FALSE; |
|
181 | + if (!isset($globalIVAO)) { |
|
182 | + $globalIVAO = FALSE; |
|
183 | + } |
|
184 | + if (!isset($globalVATSIM)) { |
|
185 | + $globalVATSIM = FALSE; |
|
186 | + } |
|
187 | + if (!isset($globalphpVMS)) { |
|
188 | + $globalphpVMS = FALSE; |
|
189 | + } |
|
190 | + if (!isset($globalVAM)) { |
|
191 | + $globalVAM = FALSE; |
|
192 | + } |
|
180 | 193 | date_default_timezone_set('UTC'); |
181 | 194 | |
182 | 195 | if (!is_string($query)) |
@@ -223,21 +236,35 @@ discard block |
||
223 | 236 | } else { |
224 | 237 | $temp_array['spotter_id'] = ''; |
225 | 238 | } |
226 | - if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id']; |
|
227 | - if (isset($row['modes'])) $temp_array['modes'] = $row['modes']; |
|
239 | + if (isset($row['flightaware_id'])) { |
|
240 | + $temp_array['flightaware_id'] = $row['flightaware_id']; |
|
241 | + } |
|
242 | + if (isset($row['modes'])) { |
|
243 | + $temp_array['modes'] = $row['modes']; |
|
244 | + } |
|
228 | 245 | $temp_array['ident'] = $row['ident']; |
229 | 246 | if (isset($row['registration']) && $row['registration'] != '') { |
230 | 247 | $temp_array['registration'] = $row['registration']; |
231 | 248 | } elseif (isset($temp_array['modes'])) { |
232 | 249 | $temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']); |
233 | - } else $temp_array['registration'] = ''; |
|
234 | - if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao']; |
|
250 | + } else { |
|
251 | + $temp_array['registration'] = ''; |
|
252 | + } |
|
253 | + if (isset($row['aircraft_icao'])) { |
|
254 | + $temp_array['aircraft_type'] = $row['aircraft_icao']; |
|
255 | + } |
|
235 | 256 | |
236 | 257 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
237 | 258 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
238 | - if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
239 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
240 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
259 | + if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) { |
|
260 | + $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
261 | + } |
|
262 | + if (isset($row['latitude'])) { |
|
263 | + $temp_array['latitude'] = $row['latitude']; |
|
264 | + } |
|
265 | + if (isset($row['longitude'])) { |
|
266 | + $temp_array['longitude'] = $row['longitude']; |
|
267 | + } |
|
241 | 268 | /* |
242 | 269 | if (Connection->tableExists('countries')) { |
243 | 270 | $country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']); |
@@ -247,8 +274,12 @@ discard block |
||
247 | 274 | } |
248 | 275 | } |
249 | 276 | */ |
250 | - if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints']; |
|
251 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
277 | + if (isset($row['waypoints'])) { |
|
278 | + $temp_array['waypoints'] = $row['waypoints']; |
|
279 | + } |
|
280 | + if (isset($row['format_source'])) { |
|
281 | + $temp_array['format_source'] = $row['format_source']; |
|
282 | + } |
|
252 | 283 | if (isset($row['route_stop']) && $row['route_stop'] != '') { |
253 | 284 | $temp_array['route_stop'] = $row['route_stop']; |
254 | 285 | $allroute = explode(' ',$row['route_stop']); |
@@ -264,13 +295,19 @@ discard block |
||
264 | 295 | } |
265 | 296 | } |
266 | 297 | } |
267 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
298 | + if (isset($row['altitude'])) { |
|
299 | + $temp_array['altitude'] = $row['altitude']; |
|
300 | + } |
|
268 | 301 | if (isset($row['heading'])) { |
269 | 302 | $temp_array['heading'] = $row['heading']; |
270 | 303 | $heading_direction = $this->parseDirection($row['heading']); |
271 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
304 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
305 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
306 | + } |
|
307 | + } |
|
308 | + if (isset($row['ground_speed'])) { |
|
309 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
272 | 310 | } |
273 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
274 | 311 | $temp_array['image'] = ""; |
275 | 312 | $temp_array['image_thumbnail'] = ""; |
276 | 313 | $temp_array['image_source'] = ""; |
@@ -278,7 +315,9 @@ discard block |
||
278 | 315 | |
279 | 316 | if (isset($row['highlight'])) { |
280 | 317 | $temp_array['highlight'] = $row['highlight']; |
281 | - } else $temp_array['highlight'] = ''; |
|
318 | + } else { |
|
319 | + $temp_array['highlight'] = ''; |
|
320 | + } |
|
282 | 321 | |
283 | 322 | if (isset($row['date'])) { |
284 | 323 | $dateArray = $this->parseDateString($row['date']); |
@@ -334,7 +373,9 @@ discard block |
||
334 | 373 | |
335 | 374 | if ($aircraft_array[0]['aircraft_shadow'] != NULL) { |
336 | 375 | $temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow']; |
337 | - } else $temp_array['aircraft_shadow'] = 'default.png'; |
|
376 | + } else { |
|
377 | + $temp_array['aircraft_shadow'] = 'default.png'; |
|
378 | + } |
|
338 | 379 | } else { |
339 | 380 | $temp_array['aircraft_shadow'] = 'default.png'; |
340 | 381 | $temp_array['aircraft_name'] = 'N/A'; |
@@ -342,11 +383,17 @@ discard block |
||
342 | 383 | } |
343 | 384 | } |
344 | 385 | $fromsource = NULL; |
345 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
346 | - elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
347 | - elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
348 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
349 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
386 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
387 | + $fromsource = $globalAirlinesSource; |
|
388 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') { |
|
389 | + $fromsource = 'vatsim'; |
|
390 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') { |
|
391 | + $fromsource = 'ivao'; |
|
392 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
393 | + $fromsource = 'vatsim'; |
|
394 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
395 | + $fromsource = 'ivao'; |
|
396 | + } |
|
350 | 397 | if (!isset($row['airline_name']) || $row['airline_name'] == '') { |
351 | 398 | if (!is_numeric(substr($row['ident'], 0, 3))) { |
352 | 399 | if (is_numeric(substr($row['ident'], 2, 1))) { |
@@ -369,12 +416,18 @@ discard block |
||
369 | 416 | } |
370 | 417 | } else { |
371 | 418 | $temp_array['airline_icao'] = $row['airline_icao']; |
372 | - if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata']; |
|
373 | - else $temp_array['airline_iata'] = 'N/A'; |
|
419 | + if (isset($row['airline_iata'])) { |
|
420 | + $temp_array['airline_iata'] = $row['airline_iata']; |
|
421 | + } else { |
|
422 | + $temp_array['airline_iata'] = 'N/A'; |
|
423 | + } |
|
374 | 424 | $temp_array['airline_name'] = $row['airline_name']; |
375 | 425 | $temp_array['airline_country'] = $row['airline_country']; |
376 | - if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
377 | - else $temp_array['airline_callsign'] = 'N/A'; |
|
426 | + if (isset($row['airline_callsign'])) { |
|
427 | + $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
428 | + } else { |
|
429 | + $temp_array['airline_callsign'] = 'N/A'; |
|
430 | + } |
|
378 | 431 | $temp_array['airline_type'] = $row['airline_type']; |
379 | 432 | if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') { |
380 | 433 | $airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']); |
@@ -401,7 +454,9 @@ discard block |
||
401 | 454 | } |
402 | 455 | if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) { |
403 | 456 | $owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']); |
404 | - if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
457 | + if ($owner_info['owner'] != '') { |
|
458 | + $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
459 | + } |
|
405 | 460 | $temp_array['aircraft_base'] = $owner_info['base']; |
406 | 461 | $temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; |
407 | 462 | } |
@@ -409,9 +464,14 @@ discard block |
||
409 | 464 | if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) |
410 | 465 | { |
411 | 466 | if ($globalIVAO) { |
412 | - if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
413 | - else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
414 | - } else $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
467 | + if (isset($temp_array['airline_icao'])) { |
|
468 | + $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
469 | + } else { |
|
470 | + $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
471 | + } |
|
472 | + } else { |
|
473 | + $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
474 | + } |
|
415 | 475 | if (count($image_array) > 0) { |
416 | 476 | $temp_array['image'] = $image_array[0]['image']; |
417 | 477 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -463,7 +523,9 @@ discard block |
||
463 | 523 | //if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') { |
464 | 524 | if ($row['departure_airport_icao'] != '') { |
465 | 525 | $departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']); |
466 | - if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
526 | + if (!isset($departure_airport_array[0]['name'])) { |
|
527 | + $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
528 | + } |
|
467 | 529 | /* |
468 | 530 | } elseif ($row['departure_airport_name'] != '') { |
469 | 531 | $temp_array['departure_airport_name'] = $row['departure_airport_name']; |
@@ -471,7 +533,9 @@ discard block |
||
471 | 533 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
472 | 534 | $temp_array['departure_airport_icao'] = $row['departure_airport_icao']; |
473 | 535 | */ |
474 | - } else $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
536 | + } else { |
|
537 | + $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
538 | + } |
|
475 | 539 | if (isset($departure_airport_array[0]['name'])) { |
476 | 540 | $temp_array['departure_airport_name'] = $departure_airport_array[0]['name']; |
477 | 541 | $temp_array['departure_airport_city'] = $departure_airport_array[0]['city']; |
@@ -491,8 +555,12 @@ discard block |
||
491 | 555 | |
492 | 556 | if ($row['arrival_airport_icao'] != '') { |
493 | 557 | $arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']); |
494 | - if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
495 | - } else $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
558 | + if (count($arrival_airport_array) == 0) { |
|
559 | + $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
560 | + } |
|
561 | + } else { |
|
562 | + $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
563 | + } |
|
496 | 564 | if (isset($arrival_airport_array[0]['name'])) { |
497 | 565 | $temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name']; |
498 | 566 | $temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city']; |
@@ -508,27 +576,45 @@ discard block |
||
508 | 576 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
509 | 577 | } |
510 | 578 | */ |
511 | - if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id']; |
|
512 | - if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name']; |
|
513 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
514 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
515 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
579 | + if (isset($row['pilot_id']) && $row['pilot_id'] != '') { |
|
580 | + $temp_array['pilot_id'] = $row['pilot_id']; |
|
581 | + } |
|
582 | + if (isset($row['pilot_name']) && $row['pilot_name'] != '') { |
|
583 | + $temp_array['pilot_name'] = $row['pilot_name']; |
|
584 | + } |
|
585 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
586 | + $temp_array['source_name'] = $row['source_name']; |
|
587 | + } |
|
588 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
589 | + $temp_array['over_country'] = $row['over_country']; |
|
590 | + } |
|
591 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
592 | + $temp_array['distance'] = $row['distance']; |
|
593 | + } |
|
516 | 594 | if (isset($row['squawk'])) { |
517 | 595 | $temp_array['squawk'] = $row['squawk']; |
518 | 596 | if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { |
519 | 597 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); |
520 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
598 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) { |
|
599 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
600 | + } |
|
521 | 601 | } elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { |
522 | 602 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); |
523 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
524 | - } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
603 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) { |
|
604 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
605 | + } |
|
606 | + } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) { |
|
607 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
608 | + } |
|
525 | 609 | } |
526 | 610 | |
527 | 611 | $temp_array['query_number_rows'] = $num_rows; |
528 | 612 | |
529 | 613 | $spotter_array[] = $temp_array; |
530 | 614 | } |
531 | - if ($num_rows == 0) return array(); |
|
615 | + if ($num_rows == 0) { |
|
616 | + return array(); |
|
617 | + } |
|
532 | 618 | $spotter_array[0]['query_number_rows'] = $num_rows; |
533 | 619 | return $spotter_array; |
534 | 620 | } |
@@ -561,7 +647,9 @@ discard block |
||
561 | 647 | foreach ($q_array as $q_item){ |
562 | 648 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
563 | 649 | $additional_query .= " AND ("; |
564 | - if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
650 | + if (is_int($q_item)) { |
|
651 | + $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
652 | + } |
|
565 | 653 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
566 | 654 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
567 | 655 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
@@ -582,7 +670,9 @@ discard block |
||
582 | 670 | $additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR "; |
583 | 671 | $additional_query .= "(spotter_output.ident like '%".$q_item."%') OR "; |
584 | 672 | $translate = $Translation->ident2icao($q_item); |
585 | - if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
673 | + if ($translate != $q_item) { |
|
674 | + $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
675 | + } |
|
586 | 676 | $additional_query .= "(spotter_output.highlight like '%".$q_item."%')"; |
587 | 677 | $additional_query .= ")"; |
588 | 678 | } |
@@ -809,7 +899,9 @@ discard block |
||
809 | 899 | date_default_timezone_set($globalTimezone); |
810 | 900 | $datetime = new DateTime(); |
811 | 901 | $offset = $datetime->format('P'); |
812 | - } else $offset = '+00:00'; |
|
902 | + } else { |
|
903 | + $offset = '+00:00'; |
|
904 | + } |
|
813 | 905 | |
814 | 906 | if ($date_array[1] != "") |
815 | 907 | { |
@@ -841,8 +933,12 @@ discard block |
||
841 | 933 | { |
842 | 934 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
843 | 935 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
844 | - } else $limit_query = ""; |
|
845 | - } else $limit_query = ""; |
|
936 | + } else { |
|
937 | + $limit_query = ""; |
|
938 | + } |
|
939 | + } else { |
|
940 | + $limit_query = ""; |
|
941 | + } |
|
846 | 942 | |
847 | 943 | |
848 | 944 | if ($sort != "") |
@@ -910,8 +1006,12 @@ discard block |
||
910 | 1006 | { |
911 | 1007 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
912 | 1008 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
913 | - } else $limit_query = ""; |
|
914 | - } else $limit_query = ""; |
|
1009 | + } else { |
|
1010 | + $limit_query = ""; |
|
1011 | + } |
|
1012 | + } else { |
|
1013 | + $limit_query = ""; |
|
1014 | + } |
|
915 | 1015 | |
916 | 1016 | if ($sort != "") |
917 | 1017 | { |
@@ -1235,7 +1335,9 @@ discard block |
||
1235 | 1335 | global $global_query; |
1236 | 1336 | |
1237 | 1337 | date_default_timezone_set('UTC'); |
1238 | - if ($id == '') return array(); |
|
1338 | + if ($id == '') { |
|
1339 | + return array(); |
|
1340 | + } |
|
1239 | 1341 | $additional_query = "spotter_output.spotter_id = :id"; |
1240 | 1342 | $query_values = array(':id' => $id); |
1241 | 1343 | |
@@ -1350,8 +1452,11 @@ discard block |
||
1350 | 1452 | if ($sort != "") |
1351 | 1453 | { |
1352 | 1454 | $search_orderby_array = $this->getOrderBy(); |
1353 | - if (isset($search_orderby_array[$sort]['sql'])) $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1354 | - else $orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1455 | + if (isset($search_orderby_array[$sort]['sql'])) { |
|
1456 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1457 | + } else { |
|
1458 | + $orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1459 | + } |
|
1355 | 1460 | } else { |
1356 | 1461 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
1357 | 1462 | } |
@@ -1976,7 +2081,9 @@ discard block |
||
1976 | 2081 | { |
1977 | 2082 | $highlight = $row['highlight']; |
1978 | 2083 | } |
1979 | - if (isset($highlight)) return $highlight; |
|
2084 | + if (isset($highlight)) { |
|
2085 | + return $highlight; |
|
2086 | + } |
|
1980 | 2087 | } |
1981 | 2088 | |
1982 | 2089 | |
@@ -2004,7 +2111,9 @@ discard block |
||
2004 | 2111 | $sth->closeCursor(); |
2005 | 2112 | if (count($row) > 0) { |
2006 | 2113 | return $row['usage']; |
2007 | - } else return ''; |
|
2114 | + } else { |
|
2115 | + return ''; |
|
2116 | + } |
|
2008 | 2117 | } |
2009 | 2118 | |
2010 | 2119 | /** |
@@ -2029,7 +2138,9 @@ discard block |
||
2029 | 2138 | $sth->closeCursor(); |
2030 | 2139 | if (count($row) > 0) { |
2031 | 2140 | return $row['icao']; |
2032 | - } else return ''; |
|
2141 | + } else { |
|
2142 | + return ''; |
|
2143 | + } |
|
2033 | 2144 | } |
2034 | 2145 | |
2035 | 2146 | /** |
@@ -2057,7 +2168,9 @@ discard block |
||
2057 | 2168 | $airport_longitude = $row['longitude']; |
2058 | 2169 | $Common = new Common(); |
2059 | 2170 | return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); |
2060 | - } else return ''; |
|
2171 | + } else { |
|
2172 | + return ''; |
|
2173 | + } |
|
2061 | 2174 | } |
2062 | 2175 | |
2063 | 2176 | /** |
@@ -2169,7 +2282,9 @@ discard block |
||
2169 | 2282 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2170 | 2283 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2171 | 2284 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2172 | - } else return array(); |
|
2285 | + } else { |
|
2286 | + return array(); |
|
2287 | + } |
|
2173 | 2288 | if ($globalDBdriver == 'mysql') { |
2174 | 2289 | $query = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
2175 | 2290 | } else { |
@@ -2204,7 +2319,9 @@ discard block |
||
2204 | 2319 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2205 | 2320 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2206 | 2321 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2207 | - } else return array(); |
|
2322 | + } else { |
|
2323 | + return array(); |
|
2324 | + } |
|
2208 | 2325 | //$query = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
2209 | 2326 | $query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")"; |
2210 | 2327 | //$query = "SELECT waypoints.* FROM waypoints"; |
@@ -2239,7 +2356,9 @@ discard block |
||
2239 | 2356 | public function getAllAirlineInfo($airline_icao, $fromsource = NULL) |
2240 | 2357 | { |
2241 | 2358 | global $globalUseRealAirlines; |
2242 | - if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
|
2359 | + if (isset($globalUseRealAirlines) && $globalUseRealAirlines) { |
|
2360 | + $fromsource = NULL; |
|
2361 | + } |
|
2243 | 2362 | $airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING)); |
2244 | 2363 | if ($airline_icao == 'NA') { |
2245 | 2364 | $airline_array = array(); |
@@ -2308,7 +2427,9 @@ discard block |
||
2308 | 2427 | public function getAllAirlineInfoByName($airline_name, $fromsource = NULL) |
2309 | 2428 | { |
2310 | 2429 | global $globalUseRealAirlines; |
2311 | - if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
|
2430 | + if (isset($globalUseRealAirlines) && $globalUseRealAirlines) { |
|
2431 | + $fromsource = NULL; |
|
2432 | + } |
|
2312 | 2433 | $airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING)); |
2313 | 2434 | $query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; |
2314 | 2435 | $sth = $this->db->prepare($query); |
@@ -2324,7 +2445,9 @@ discard block |
||
2324 | 2445 | $sth->execute(array(':fromsource' => $fromsource)); |
2325 | 2446 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2326 | 2447 | $sth->closeCursor(); |
2327 | - if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name); |
|
2448 | + if ($row['nb'] == 0) { |
|
2449 | + $result = $this->getAllAirlineInfoByName($airline_name); |
|
2450 | + } |
|
2328 | 2451 | } |
2329 | 2452 | return $result; |
2330 | 2453 | } |
@@ -2387,15 +2510,20 @@ discard block |
||
2387 | 2510 | 'A320-211' => 'A320', |
2388 | 2511 | '747-8i' => 'B748', |
2389 | 2512 | 'A380' => 'A388'); |
2390 | - if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type]; |
|
2513 | + if (isset($all_aircraft[$aircraft_type])) { |
|
2514 | + return $all_aircraft[$aircraft_type]; |
|
2515 | + } |
|
2391 | 2516 | |
2392 | 2517 | $query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; |
2393 | 2518 | $aircraft_type = strtoupper($aircraft_type); |
2394 | 2519 | $sth = $this->db->prepare($query); |
2395 | 2520 | $sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,)); |
2396 | 2521 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
2397 | - if (isset($result[0]['icao'])) return $result[0]['icao']; |
|
2398 | - else return ''; |
|
2522 | + if (isset($result[0]['icao'])) { |
|
2523 | + return $result[0]['icao']; |
|
2524 | + } else { |
|
2525 | + return ''; |
|
2526 | + } |
|
2399 | 2527 | } |
2400 | 2528 | |
2401 | 2529 | /** |
@@ -2418,9 +2546,13 @@ discard block |
||
2418 | 2546 | $sth->closeCursor(); |
2419 | 2547 | if (isset($row['icaotypecode'])) { |
2420 | 2548 | $icao = $row['icaotypecode']; |
2421 | - if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao]; |
|
2549 | + if (isset($this->aircraft_correct_icaotype[$icao])) { |
|
2550 | + $icao = $this->aircraft_correct_icaotype[$icao]; |
|
2551 | + } |
|
2422 | 2552 | return $icao; |
2423 | - } else return ''; |
|
2553 | + } else { |
|
2554 | + return ''; |
|
2555 | + } |
|
2424 | 2556 | } |
2425 | 2557 | |
2426 | 2558 | /** |
@@ -2443,7 +2575,9 @@ discard block |
||
2443 | 2575 | $sth->closeCursor(); |
2444 | 2576 | if (isset($row['icaotypecode'])) { |
2445 | 2577 | return $row['icaotypecode']; |
2446 | - } else return ''; |
|
2578 | + } else { |
|
2579 | + return ''; |
|
2580 | + } |
|
2447 | 2581 | } |
2448 | 2582 | |
2449 | 2583 | /** |
@@ -2489,7 +2623,9 @@ discard block |
||
2489 | 2623 | $sth->closeCursor(); |
2490 | 2624 | if (isset($row['operator_correct'])) { |
2491 | 2625 | return $row['operator_correct']; |
2492 | - } else return $operator; |
|
2626 | + } else { |
|
2627 | + return $operator; |
|
2628 | + } |
|
2493 | 2629 | } |
2494 | 2630 | |
2495 | 2631 | /** |
@@ -2502,7 +2638,9 @@ discard block |
||
2502 | 2638 | public function getRouteInfo($callsign) |
2503 | 2639 | { |
2504 | 2640 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
2505 | - if ($callsign == '') return array(); |
|
2641 | + if ($callsign == '') { |
|
2642 | + return array(); |
|
2643 | + } |
|
2506 | 2644 | $query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1"; |
2507 | 2645 | |
2508 | 2646 | $sth = $this->db->prepare($query); |
@@ -2512,7 +2650,9 @@ discard block |
||
2512 | 2650 | $sth->closeCursor(); |
2513 | 2651 | if (count($row) > 0) { |
2514 | 2652 | return $row; |
2515 | - } else return array(); |
|
2653 | + } else { |
|
2654 | + return array(); |
|
2655 | + } |
|
2516 | 2656 | } |
2517 | 2657 | |
2518 | 2658 | /** |
@@ -2565,7 +2705,9 @@ discard block |
||
2565 | 2705 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
2566 | 2706 | $sth->closeCursor(); |
2567 | 2707 | return $result; |
2568 | - } else return array(); |
|
2708 | + } else { |
|
2709 | + return array(); |
|
2710 | + } |
|
2569 | 2711 | } |
2570 | 2712 | |
2571 | 2713 | |
@@ -2724,8 +2866,11 @@ discard block |
||
2724 | 2866 | $query .= " ORDER BY spotter_output.source_name ASC"; |
2725 | 2867 | |
2726 | 2868 | $sth = $this->db->prepare($query); |
2727 | - if (!empty($query_values)) $sth->execute($query_values); |
|
2728 | - else $sth->execute(); |
|
2869 | + if (!empty($query_values)) { |
|
2870 | + $sth->execute($query_values); |
|
2871 | + } else { |
|
2872 | + $sth->execute(); |
|
2873 | + } |
|
2729 | 2874 | |
2730 | 2875 | $source_array = array(); |
2731 | 2876 | $temp_array = array(); |
@@ -2758,9 +2903,13 @@ discard block |
||
2758 | 2903 | WHERE spotter_output.airline_icao <> '' |
2759 | 2904 | ORDER BY spotter_output.airline_name ASC"; |
2760 | 2905 | */ |
2761 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
|
2762 | - elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
|
2763 | - elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
|
2906 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
2907 | + $forsource = $globalAirlinesSource; |
|
2908 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
2909 | + $forsource = 'vatsim'; |
|
2910 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
2911 | + $forsource = 'ivao'; |
|
2912 | + } |
|
2764 | 2913 | if ($forsource === NULL) { |
2765 | 2914 | $query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC"; |
2766 | 2915 | $query_data = array(); |
@@ -2803,9 +2952,13 @@ discard block |
||
2803 | 2952 | { |
2804 | 2953 | global $globalAirlinesSource,$globalVATSIM, $globalIVAO; |
2805 | 2954 | $filter_query = $this->getFilter($filters,true,true); |
2806 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
|
2807 | - elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
|
2808 | - elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
|
2955 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
2956 | + $forsource = $globalAirlinesSource; |
|
2957 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
2958 | + $forsource = 'vatsim'; |
|
2959 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
2960 | + $forsource = 'ivao'; |
|
2961 | + } |
|
2809 | 2962 | if ($forsource === NULL) { |
2810 | 2963 | $query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC"; |
2811 | 2964 | $query_data = array(); |
@@ -3116,7 +3269,9 @@ discard block |
||
3116 | 3269 | date_default_timezone_set($globalTimezone); |
3117 | 3270 | $datetime = new DateTime(); |
3118 | 3271 | $offset = $datetime->format('P'); |
3119 | - } else $offset = '+00:00'; |
|
3272 | + } else { |
|
3273 | + $offset = '+00:00'; |
|
3274 | + } |
|
3120 | 3275 | if ($airport_icao == '') { |
3121 | 3276 | if ($globalDBdriver == 'mysql') { |
3122 | 3277 | $query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
@@ -3148,7 +3303,9 @@ discard block |
||
3148 | 3303 | date_default_timezone_set($globalTimezone); |
3149 | 3304 | $datetime = new DateTime(); |
3150 | 3305 | $offset = $datetime->format('P'); |
3151 | - } else $offset = '+00:00'; |
|
3306 | + } else { |
|
3307 | + $offset = '+00:00'; |
|
3308 | + } |
|
3152 | 3309 | if ($airport_icao == '') { |
3153 | 3310 | if ($globalDBdriver == 'mysql') { |
3154 | 3311 | $query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
@@ -3181,7 +3338,9 @@ discard block |
||
3181 | 3338 | date_default_timezone_set($globalTimezone); |
3182 | 3339 | $datetime = new DateTime(); |
3183 | 3340 | $offset = $datetime->format('P'); |
3184 | - } else $offset = '+00:00'; |
|
3341 | + } else { |
|
3342 | + $offset = '+00:00'; |
|
3343 | + } |
|
3185 | 3344 | if ($airport_icao == '') { |
3186 | 3345 | if ($globalDBdriver == 'mysql') { |
3187 | 3346 | $query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -3220,7 +3379,9 @@ discard block |
||
3220 | 3379 | date_default_timezone_set($globalTimezone); |
3221 | 3380 | $datetime = new DateTime(); |
3222 | 3381 | $offset = $datetime->format('P'); |
3223 | - } else $offset = '+00:00'; |
|
3382 | + } else { |
|
3383 | + $offset = '+00:00'; |
|
3384 | + } |
|
3224 | 3385 | if ($airport_icao == '') { |
3225 | 3386 | if ($globalDBdriver == 'mysql') { |
3226 | 3387 | $query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -3265,7 +3426,9 @@ discard block |
||
3265 | 3426 | date_default_timezone_set($globalTimezone); |
3266 | 3427 | $datetime = new DateTime(); |
3267 | 3428 | $offset = $datetime->format('P'); |
3268 | - } else $offset = '+00:00'; |
|
3429 | + } else { |
|
3430 | + $offset = '+00:00'; |
|
3431 | + } |
|
3269 | 3432 | if ($airport_icao == '') { |
3270 | 3433 | if ($globalDBdriver == 'mysql') { |
3271 | 3434 | $query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
@@ -3300,7 +3463,9 @@ discard block |
||
3300 | 3463 | date_default_timezone_set($globalTimezone); |
3301 | 3464 | $datetime = new DateTime(); |
3302 | 3465 | $offset = $datetime->format('P'); |
3303 | - } else $offset = '+00:00'; |
|
3466 | + } else { |
|
3467 | + $offset = '+00:00'; |
|
3468 | + } |
|
3304 | 3469 | if ($airport_icao == '') { |
3305 | 3470 | if ($globalDBdriver == 'mysql') { |
3306 | 3471 | $query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -3342,7 +3507,9 @@ discard block |
||
3342 | 3507 | date_default_timezone_set($globalTimezone); |
3343 | 3508 | $datetime = new DateTime(); |
3344 | 3509 | $offset = $datetime->format('P'); |
3345 | - } else $offset = '+00:00'; |
|
3510 | + } else { |
|
3511 | + $offset = '+00:00'; |
|
3512 | + } |
|
3346 | 3513 | if ($airport_icao == '') { |
3347 | 3514 | if ($globalDBdriver == 'mysql') { |
3348 | 3515 | $query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
@@ -3376,7 +3543,9 @@ discard block |
||
3376 | 3543 | date_default_timezone_set($globalTimezone); |
3377 | 3544 | $datetime = new DateTime(); |
3378 | 3545 | $offset = $datetime->format('P'); |
3379 | - } else $offset = '+00:00'; |
|
3546 | + } else { |
|
3547 | + $offset = '+00:00'; |
|
3548 | + } |
|
3380 | 3549 | if ($airport_icao == '') { |
3381 | 3550 | if ($globalDBdriver == 'mysql') { |
3382 | 3551 | $query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -3424,7 +3593,9 @@ discard block |
||
3424 | 3593 | date_default_timezone_set($globalTimezone); |
3425 | 3594 | $datetime = new DateTime(); |
3426 | 3595 | $offset = $datetime->format('P'); |
3427 | - } else $offset = '+00:00'; |
|
3596 | + } else { |
|
3597 | + $offset = '+00:00'; |
|
3598 | + } |
|
3428 | 3599 | |
3429 | 3600 | if ($globalDBdriver == 'mysql') { |
3430 | 3601 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
@@ -3544,7 +3715,9 @@ discard block |
||
3544 | 3715 | */ |
3545 | 3716 | public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') |
3546 | 3717 | { |
3547 | - if ($groundspeed == '') $groundspeed = NULL; |
|
3718 | + if ($groundspeed == '') { |
|
3719 | + $groundspeed = NULL; |
|
3720 | + } |
|
3548 | 3721 | $query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id'; |
3549 | 3722 | $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident); |
3550 | 3723 | |
@@ -3594,10 +3767,18 @@ discard block |
||
3594 | 3767 | $Image = new Image($this->db); |
3595 | 3768 | $Common = new Common(); |
3596 | 3769 | |
3597 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
3598 | - if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
3599 | - if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
3600 | - if (!isset($globalVAM)) $globalVAM = FALSE; |
|
3770 | + if (!isset($globalIVAO)) { |
|
3771 | + $globalIVAO = FALSE; |
|
3772 | + } |
|
3773 | + if (!isset($globalVATSIM)) { |
|
3774 | + $globalVATSIM = FALSE; |
|
3775 | + } |
|
3776 | + if (!isset($globalphpVMS)) { |
|
3777 | + $globalphpVMS = FALSE; |
|
3778 | + } |
|
3779 | + if (!isset($globalVAM)) { |
|
3780 | + $globalVAM = FALSE; |
|
3781 | + } |
|
3601 | 3782 | date_default_timezone_set('UTC'); |
3602 | 3783 | |
3603 | 3784 | //getting the registration |
@@ -3610,23 +3791,33 @@ discard block |
||
3610 | 3791 | if ($ModeS != '') { |
3611 | 3792 | $timeelapsed = microtime(true); |
3612 | 3793 | $registration = $this->getAircraftRegistrationBymodeS($ModeS); |
3613 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3794 | + if ($globalDebugTimeElapsed) { |
|
3795 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3796 | + } |
|
3614 | 3797 | } else { |
3615 | 3798 | $myhex = explode('-',$flightaware_id); |
3616 | 3799 | if (count($myhex) > 0) { |
3617 | 3800 | $timeelapsed = microtime(true); |
3618 | 3801 | $registration = $this->getAircraftRegistrationBymodeS($myhex[0]); |
3619 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3802 | + if ($globalDebugTimeElapsed) { |
|
3803 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3804 | + } |
|
3620 | 3805 | } |
3621 | 3806 | } |
3622 | 3807 | } |
3623 | 3808 | } |
3624 | 3809 | $fromsource = NULL; |
3625 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
3626 | - elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim'; |
|
3627 | - elseif ($format_source == 'whazzup') $fromsource = 'ivao'; |
|
3628 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
3629 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
3810 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
3811 | + $fromsource = $globalAirlinesSource; |
|
3812 | + } elseif ($format_source == 'vatsimtxt') { |
|
3813 | + $fromsource = 'vatsim'; |
|
3814 | + } elseif ($format_source == 'whazzup') { |
|
3815 | + $fromsource = 'ivao'; |
|
3816 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
3817 | + $fromsource = 'vatsim'; |
|
3818 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
3819 | + $fromsource = 'ivao'; |
|
3820 | + } |
|
3630 | 3821 | //getting the airline information |
3631 | 3822 | if ($ident != "") |
3632 | 3823 | { |
@@ -3650,15 +3841,21 @@ discard block |
||
3650 | 3841 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
3651 | 3842 | $airline_array = $this->getAllAirlineInfo("NA"); |
3652 | 3843 | } |
3653 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3844 | + if ($globalDebugTimeElapsed) { |
|
3845 | + echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3846 | + } |
|
3654 | 3847 | |
3655 | 3848 | } else { |
3656 | 3849 | $timeelapsed = microtime(true); |
3657 | 3850 | $airline_array = $this->getAllAirlineInfo("NA"); |
3658 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3851 | + if ($globalDebugTimeElapsed) { |
|
3852 | + echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3853 | + } |
|
3659 | 3854 | } |
3660 | 3855 | } |
3661 | - } else $airline_array = array(); |
|
3856 | + } else { |
|
3857 | + $airline_array = array(); |
|
3858 | + } |
|
3662 | 3859 | |
3663 | 3860 | //getting the aircraft information |
3664 | 3861 | $aircraft_array = array(); |
@@ -3672,27 +3869,37 @@ discard block |
||
3672 | 3869 | { |
3673 | 3870 | $timeelapsed = microtime(true); |
3674 | 3871 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
3675 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3872 | + if ($globalDebugTimeElapsed) { |
|
3873 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3874 | + } |
|
3676 | 3875 | } else { |
3677 | 3876 | $timeelapsed = microtime(true); |
3678 | 3877 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
3679 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3878 | + if ($globalDebugTimeElapsed) { |
|
3879 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3880 | + } |
|
3680 | 3881 | } |
3681 | 3882 | } |
3682 | 3883 | } else { |
3683 | 3884 | if ($ModeS != '') { |
3684 | 3885 | $timeelapsed = microtime(true); |
3685 | 3886 | $aircraft_icao = $this->getAllAircraftType($ModeS); |
3686 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3887 | + if ($globalDebugTimeElapsed) { |
|
3888 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3889 | + } |
|
3687 | 3890 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
3688 | 3891 | { |
3689 | 3892 | $timeelapsed = microtime(true); |
3690 | 3893 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
3691 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3894 | + if ($globalDebugTimeElapsed) { |
|
3895 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3896 | + } |
|
3692 | 3897 | } else { |
3693 | 3898 | $timeelapsed = microtime(true); |
3694 | 3899 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
3695 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3900 | + if ($globalDebugTimeElapsed) { |
|
3901 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3902 | + } |
|
3696 | 3903 | } |
3697 | 3904 | } |
3698 | 3905 | } |
@@ -3708,7 +3915,9 @@ discard block |
||
3708 | 3915 | } else { |
3709 | 3916 | $timeelapsed = microtime(true); |
3710 | 3917 | $departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); |
3711 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3918 | + if ($globalDebugTimeElapsed) { |
|
3919 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3920 | + } |
|
3712 | 3921 | } |
3713 | 3922 | } |
3714 | 3923 | |
@@ -3723,7 +3932,9 @@ discard block |
||
3723 | 3932 | } else { |
3724 | 3933 | $timeelapsed = microtime(true); |
3725 | 3934 | $arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); |
3726 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3935 | + if ($globalDebugTimeElapsed) { |
|
3936 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3937 | + } |
|
3727 | 3938 | } |
3728 | 3939 | } |
3729 | 3940 | |
@@ -3757,7 +3968,9 @@ discard block |
||
3757 | 3968 | { |
3758 | 3969 | return false; |
3759 | 3970 | } |
3760 | - } else $altitude = 0; |
|
3971 | + } else { |
|
3972 | + $altitude = 0; |
|
3973 | + } |
|
3761 | 3974 | |
3762 | 3975 | if ($heading != "") |
3763 | 3976 | { |
@@ -3786,7 +3999,9 @@ discard block |
||
3786 | 3999 | { |
3787 | 4000 | $timeelapsed = microtime(true); |
3788 | 4001 | $image_array = $Image->getSpotterImage($registration); |
3789 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
4002 | + if ($globalDebugTimeElapsed) { |
|
4003 | + echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
4004 | + } |
|
3790 | 4005 | if (!isset($image_array[0]['registration'])) |
3791 | 4006 | { |
3792 | 4007 | //echo "Add image !!!! \n"; |
@@ -3794,14 +4009,21 @@ discard block |
||
3794 | 4009 | } |
3795 | 4010 | $timeelapsed = microtime(true); |
3796 | 4011 | $owner_info = $this->getAircraftOwnerByRegistration($registration); |
3797 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3798 | - if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
4012 | + if ($globalDebugTimeElapsed) { |
|
4013 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
4014 | + } |
|
4015 | + if ($owner_info['owner'] != '') { |
|
4016 | + $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
4017 | + } |
|
3799 | 4018 | } |
3800 | 4019 | |
3801 | 4020 | if ($globalIVAO && $aircraft_icao != '') |
3802 | 4021 | { |
3803 | - if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; |
|
3804 | - else $airline_icao = ''; |
|
4022 | + if (isset($airline_array[0]['icao'])) { |
|
4023 | + $airline_icao = $airline_array[0]['icao']; |
|
4024 | + } else { |
|
4025 | + $airline_icao = ''; |
|
4026 | + } |
|
3805 | 4027 | $image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); |
3806 | 4028 | if (!isset($image_array[0]['registration'])) |
3807 | 4029 | { |
@@ -3846,16 +4068,28 @@ discard block |
||
3846 | 4068 | { |
3847 | 4069 | $arrival_airport_array = $this->getAllAirportInfo('NA'); |
3848 | 4070 | } |
3849 | - if ($registration == '') $registration = 'NA'; |
|
4071 | + if ($registration == '') { |
|
4072 | + $registration = 'NA'; |
|
4073 | + } |
|
3850 | 4074 | if ($latitude == '' && $longitude == '') { |
3851 | 4075 | $latitude = 0; |
3852 | 4076 | $longitude = 0; |
3853 | 4077 | } |
3854 | - if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
3855 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
3856 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
3857 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
3858 | - if (!isset($aircraft_owner)) $aircraft_owner = NULL; |
|
4078 | + if ($squawk == '' || $Common->isInteger($squawk) === false) { |
|
4079 | + $squawk = NULL; |
|
4080 | + } |
|
4081 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) { |
|
4082 | + $verticalrate = NULL; |
|
4083 | + } |
|
4084 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
4085 | + $heading = 0; |
|
4086 | + } |
|
4087 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
4088 | + $groundspeed = 0; |
|
4089 | + } |
|
4090 | + if (!isset($aircraft_owner)) { |
|
4091 | + $aircraft_owner = NULL; |
|
4092 | + } |
|
3859 | 4093 | $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) |
3860 | 4094 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)"; |
3861 | 4095 | |
@@ -3866,9 +4100,13 @@ discard block |
||
3866 | 4100 | if ($airline_type == '') { |
3867 | 4101 | $timeelapsed = microtime(true); |
3868 | 4102 | $airline_type = $this->getAircraftTypeBymodeS($ModeS); |
3869 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
4103 | + if ($globalDebugTimeElapsed) { |
|
4104 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
4105 | + } |
|
4106 | + } |
|
4107 | + if ($airline_type == null) { |
|
4108 | + $airline_type = ''; |
|
3870 | 4109 | } |
3871 | - if ($airline_type == null) $airline_type = ''; |
|
3872 | 4110 | $aircraft_type = $aircraft_array[0]['type']; |
3873 | 4111 | $aircraft_manufacturer = $aircraft_array[0]['manufacturer']; |
3874 | 4112 | $departure_airport_name = $departure_airport_array[0]['name']; |
@@ -4032,7 +4270,9 @@ discard block |
||
4032 | 4270 | } |
4033 | 4271 | } |
4034 | 4272 | $query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; |
4035 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4273 | + if ($limit) { |
|
4274 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4275 | + } |
|
4036 | 4276 | |
4037 | 4277 | $sth = $this->db->prepare($query); |
4038 | 4278 | $sth->execute($query_values); |
@@ -4105,7 +4345,9 @@ discard block |
||
4105 | 4345 | } |
4106 | 4346 | |
4107 | 4347 | $query .= " GROUP BY spotter_output.pilot_id,s.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; |
4108 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4348 | + if ($limit) { |
|
4349 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4350 | + } |
|
4109 | 4351 | |
4110 | 4352 | |
4111 | 4353 | $sth = $this->db->prepare($query); |
@@ -4149,7 +4391,9 @@ discard block |
||
4149 | 4391 | } |
4150 | 4392 | } |
4151 | 4393 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; |
4152 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4394 | + if ($limit) { |
|
4395 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4396 | + } |
|
4153 | 4397 | |
4154 | 4398 | |
4155 | 4399 | $sth = $this->db->prepare($query); |
@@ -4225,7 +4469,9 @@ discard block |
||
4225 | 4469 | } |
4226 | 4470 | } |
4227 | 4471 | $query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; |
4228 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4472 | + if ($limit) { |
|
4473 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4474 | + } |
|
4229 | 4475 | |
4230 | 4476 | $sth = $this->db->prepare($query); |
4231 | 4477 | $sth->execute($query_values); |
@@ -4267,7 +4513,9 @@ discard block |
||
4267 | 4513 | } |
4268 | 4514 | } |
4269 | 4515 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC"; |
4270 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4516 | + if ($limit) { |
|
4517 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4518 | + } |
|
4271 | 4519 | |
4272 | 4520 | |
4273 | 4521 | $sth = $this->db->prepare($query); |
@@ -4510,7 +4758,9 @@ discard block |
||
4510 | 4758 | date_default_timezone_set($globalTimezone); |
4511 | 4759 | $datetime = new DateTime($date); |
4512 | 4760 | $offset = $datetime->format('P'); |
4513 | - } else $offset = '+00:00'; |
|
4761 | + } else { |
|
4762 | + $offset = '+00:00'; |
|
4763 | + } |
|
4514 | 4764 | |
4515 | 4765 | if ($globalDBdriver == 'mysql') { |
4516 | 4766 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
@@ -4558,7 +4808,9 @@ discard block |
||
4558 | 4808 | date_default_timezone_set($globalTimezone); |
4559 | 4809 | $datetime = new DateTime($date); |
4560 | 4810 | $offset = $datetime->format('P'); |
4561 | - } else $offset = '+00:00'; |
|
4811 | + } else { |
|
4812 | + $offset = '+00:00'; |
|
4813 | + } |
|
4562 | 4814 | |
4563 | 4815 | if ($globalDBdriver == 'mysql') { |
4564 | 4816 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
@@ -4678,9 +4930,13 @@ discard block |
||
4678 | 4930 | $sth = $this->db->prepare($query); |
4679 | 4931 | $sth->execute($query_values); |
4680 | 4932 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
4681 | - if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
4682 | - elseif ($result[0]['duration'] == '') return 0; |
|
4683 | - else return $result[0]['duration']; |
|
4933 | + if (is_numeric($result[0]['duration'])) { |
|
4934 | + return gmdate('H:i:s',$result[0]['duration']); |
|
4935 | + } elseif ($result[0]['duration'] == '') { |
|
4936 | + return 0; |
|
4937 | + } else { |
|
4938 | + return $result[0]['duration']; |
|
4939 | + } |
|
4684 | 4940 | } |
4685 | 4941 | |
4686 | 4942 | /** |
@@ -4769,8 +5025,11 @@ discard block |
||
4769 | 5025 | $sth = $this->db->prepare($query); |
4770 | 5026 | $sth->execute($query_values); |
4771 | 5027 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
4772 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
4773 | - else return $result[0]['duration']; |
|
5028 | + if (is_int($result[0]['duration'])) { |
|
5029 | + return gmdate('H:i:s',$result[0]['duration']); |
|
5030 | + } else { |
|
5031 | + return $result[0]['duration']; |
|
5032 | + } |
|
4774 | 5033 | } |
4775 | 5034 | |
4776 | 5035 | /** |
@@ -4975,7 +5234,9 @@ discard block |
||
4975 | 5234 | } |
4976 | 5235 | $query .= " GROUP BY spotter_output.airline_country |
4977 | 5236 | ORDER BY airline_country_count DESC"; |
4978 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5237 | + if ($limit) { |
|
5238 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5239 | + } |
|
4979 | 5240 | |
4980 | 5241 | $sth = $this->db->prepare($query); |
4981 | 5242 | $sth->execute($query_values); |
@@ -5003,7 +5264,9 @@ discard block |
||
5003 | 5264 | global $globalDBdriver; |
5004 | 5265 | //$filter_query = $this->getFilter($filters,true,true); |
5005 | 5266 | $Connection= new Connection($this->db); |
5006 | - if (!$Connection->tableExists('countries')) return array(); |
|
5267 | + if (!$Connection->tableExists('countries')) { |
|
5268 | + return array(); |
|
5269 | + } |
|
5007 | 5270 | /* |
5008 | 5271 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
5009 | 5272 | FROM countries c, spotter_output s |
@@ -5035,7 +5298,9 @@ discard block |
||
5035 | 5298 | } |
5036 | 5299 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country "; |
5037 | 5300 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
5038 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5301 | + if ($limit) { |
|
5302 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5303 | + } |
|
5039 | 5304 | |
5040 | 5305 | |
5041 | 5306 | $sth = $this->db->prepare($query); |
@@ -5112,7 +5377,9 @@ discard block |
||
5112 | 5377 | } |
5113 | 5378 | |
5114 | 5379 | $query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
5115 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5380 | + if ($limit) { |
|
5381 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5382 | + } |
|
5116 | 5383 | |
5117 | 5384 | $sth = $this->db->prepare($query); |
5118 | 5385 | $sth->execute($query_values); |
@@ -5186,7 +5453,9 @@ discard block |
||
5186 | 5453 | } |
5187 | 5454 | |
5188 | 5455 | $query .= " GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
5189 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5456 | + if ($limit) { |
|
5457 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5458 | + } |
|
5190 | 5459 | |
5191 | 5460 | $sth = $this->db->prepare($query); |
5192 | 5461 | $sth->execute($query_values); |
@@ -5233,7 +5502,9 @@ discard block |
||
5233 | 5502 | } |
5234 | 5503 | |
5235 | 5504 | $query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
5236 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5505 | + if ($limit) { |
|
5506 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5507 | + } |
|
5237 | 5508 | |
5238 | 5509 | $sth = $this->db->prepare($query); |
5239 | 5510 | $sth->execute(); |
@@ -5286,7 +5557,9 @@ discard block |
||
5286 | 5557 | if($row['registration'] != "") |
5287 | 5558 | { |
5288 | 5559 | $image_array = $Image->getSpotterImage($row['registration']); |
5289 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5560 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5561 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5562 | + } |
|
5290 | 5563 | } |
5291 | 5564 | $temp_array['registration_count'] = $row['registration_count']; |
5292 | 5565 | |
@@ -5361,7 +5634,9 @@ discard block |
||
5361 | 5634 | if($row['registration'] != "") |
5362 | 5635 | { |
5363 | 5636 | $image_array = $Image->getSpotterImage($row['registration']); |
5364 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5637 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5638 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5639 | + } |
|
5365 | 5640 | } |
5366 | 5641 | $temp_array['registration_count'] = $row['registration_count']; |
5367 | 5642 | |
@@ -5468,7 +5743,9 @@ discard block |
||
5468 | 5743 | if($row['registration'] != "") |
5469 | 5744 | { |
5470 | 5745 | $image_array = $Image->getSpotterImage($row['registration']); |
5471 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5746 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5747 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5748 | + } |
|
5472 | 5749 | } |
5473 | 5750 | $temp_array['registration_count'] = $row['registration_count']; |
5474 | 5751 | $aircraft_array[] = $temp_array; |
@@ -5593,7 +5870,9 @@ discard block |
||
5593 | 5870 | date_default_timezone_set($globalTimezone); |
5594 | 5871 | $datetime = new DateTime($date); |
5595 | 5872 | $offset = $datetime->format('P'); |
5596 | - } else $offset = '+00:00'; |
|
5873 | + } else { |
|
5874 | + $offset = '+00:00'; |
|
5875 | + } |
|
5597 | 5876 | |
5598 | 5877 | if ($globalDBdriver == 'mysql') { |
5599 | 5878 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
@@ -5640,7 +5919,9 @@ discard block |
||
5640 | 5919 | date_default_timezone_set($globalTimezone); |
5641 | 5920 | $datetime = new DateTime($date); |
5642 | 5921 | $offset = $datetime->format('P'); |
5643 | - } else $offset = '+00:00'; |
|
5922 | + } else { |
|
5923 | + $offset = '+00:00'; |
|
5924 | + } |
|
5644 | 5925 | |
5645 | 5926 | if ($globalDBdriver == 'mysql') { |
5646 | 5927 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
@@ -5669,7 +5950,9 @@ discard block |
||
5669 | 5950 | if($row['registration'] != "") |
5670 | 5951 | { |
5671 | 5952 | $image_array = $Image->getSpotterImage($row['registration']); |
5672 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5953 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5954 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5955 | + } |
|
5673 | 5956 | } |
5674 | 5957 | $temp_array['registration_count'] = $row['registration_count']; |
5675 | 5958 | |
@@ -5694,7 +5977,9 @@ discard block |
||
5694 | 5977 | date_default_timezone_set($globalTimezone); |
5695 | 5978 | $datetime = new DateTime($date); |
5696 | 5979 | $offset = $datetime->format('P'); |
5697 | - } else $offset = '+00:00'; |
|
5980 | + } else { |
|
5981 | + $offset = '+00:00'; |
|
5982 | + } |
|
5698 | 5983 | |
5699 | 5984 | if ($globalDBdriver == 'mysql') { |
5700 | 5985 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
@@ -5890,8 +6175,11 @@ discard block |
||
5890 | 6175 | if($row['registration'] != "") |
5891 | 6176 | { |
5892 | 6177 | $image_array = $Image->getSpotterImage($row['registration']); |
5893 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5894 | - else $temp_array['image_thumbnail'] = ''; |
|
6178 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6179 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6180 | + } else { |
|
6181 | + $temp_array['image_thumbnail'] = ''; |
|
6182 | + } |
|
5895 | 6183 | } |
5896 | 6184 | $temp_array['registration_count'] = $row['registration_count']; |
5897 | 6185 | $aircraft_array[] = $temp_array; |
@@ -5965,8 +6253,11 @@ discard block |
||
5965 | 6253 | if($row['registration'] != "") |
5966 | 6254 | { |
5967 | 6255 | $image_array = $Image->getSpotterImage($row['registration']); |
5968 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5969 | - else $temp_array['image_thumbnail'] = ''; |
|
6256 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6257 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6258 | + } else { |
|
6259 | + $temp_array['image_thumbnail'] = ''; |
|
6260 | + } |
|
5970 | 6261 | } |
5971 | 6262 | $temp_array['registration_count'] = $row['registration_count']; |
5972 | 6263 | $aircraft_array[] = $temp_array; |
@@ -6040,8 +6331,11 @@ discard block |
||
6040 | 6331 | if($row['registration'] != "") |
6041 | 6332 | { |
6042 | 6333 | $image_array = $Image->getSpotterImage($row['registration']); |
6043 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6044 | - else $temp_array['image_thumbnail'] = ''; |
|
6334 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6335 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6336 | + } else { |
|
6337 | + $temp_array['image_thumbnail'] = ''; |
|
6338 | + } |
|
6045 | 6339 | } |
6046 | 6340 | $temp_array['registration_count'] = $row['registration_count']; |
6047 | 6341 | $aircraft_array[] = $temp_array; |
@@ -6252,7 +6546,9 @@ discard block |
||
6252 | 6546 | if($row['registration'] != "") |
6253 | 6547 | { |
6254 | 6548 | $image_array = $Image->getSpotterImage($row['registration']); |
6255 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6549 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6550 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6551 | + } |
|
6256 | 6552 | } |
6257 | 6553 | $temp_array['registration_count'] = $row['registration_count']; |
6258 | 6554 | |
@@ -6369,7 +6665,9 @@ discard block |
||
6369 | 6665 | if($row['registration'] != "") |
6370 | 6666 | { |
6371 | 6667 | $image_array = $Image->getSpotterImage($row['registration']); |
6372 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6668 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6669 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6670 | + } |
|
6373 | 6671 | } |
6374 | 6672 | $temp_array['registration_count'] = $row['registration_count']; |
6375 | 6673 | |
@@ -6535,7 +6833,9 @@ discard block |
||
6535 | 6833 | } |
6536 | 6834 | } |
6537 | 6835 | $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
6538 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
6836 | + if ($limit) { |
|
6837 | + $query .= " LIMIT 10 OFFSET 0"; |
|
6838 | + } |
|
6539 | 6839 | |
6540 | 6840 | $sth = $this->db->prepare($query); |
6541 | 6841 | $sth->execute($query_values); |
@@ -6554,7 +6854,9 @@ discard block |
||
6554 | 6854 | if($row['registration'] != "") |
6555 | 6855 | { |
6556 | 6856 | $image_array = $Image->getSpotterImage($row['registration']); |
6557 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6857 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6858 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6859 | + } |
|
6558 | 6860 | } |
6559 | 6861 | |
6560 | 6862 | $aircraft_array[] = $temp_array; |
@@ -6595,7 +6897,9 @@ discard block |
||
6595 | 6897 | // if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
6596 | 6898 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6597 | 6899 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
6598 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
6900 | + if ($limit) { |
|
6901 | + $query .= " LIMIT 10 OFFSET 0"; |
|
6902 | + } |
|
6599 | 6903 | |
6600 | 6904 | $sth = $this->db->prepare($query); |
6601 | 6905 | $sth->execute(); |
@@ -6615,7 +6919,9 @@ discard block |
||
6615 | 6919 | if($row['registration'] != "") |
6616 | 6920 | { |
6617 | 6921 | $image_array = $Image->getSpotterImage($row['registration']); |
6618 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6922 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6923 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6924 | + } |
|
6619 | 6925 | } |
6620 | 6926 | |
6621 | 6927 | $aircraft_array[] = $temp_array; |
@@ -6681,7 +6987,9 @@ discard block |
||
6681 | 6987 | } |
6682 | 6988 | $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
6683 | 6989 | ORDER BY airport_departure_icao_count DESC"; |
6684 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
6990 | + if ($limit) { |
|
6991 | + $query .= " LIMIT 10 OFFSET 0"; |
|
6992 | + } |
|
6685 | 6993 | |
6686 | 6994 | $sth = $this->db->prepare($query); |
6687 | 6995 | $sth->execute($query_values); |
@@ -6732,7 +7040,9 @@ discard block |
||
6732 | 7040 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6733 | 7041 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
6734 | 7042 | ORDER BY airport_departure_icao_count DESC"; |
6735 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7043 | + if ($limit) { |
|
7044 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7045 | + } |
|
6736 | 7046 | |
6737 | 7047 | $sth = $this->db->prepare($query); |
6738 | 7048 | $sth->execute(); |
@@ -6810,7 +7120,9 @@ discard block |
||
6810 | 7120 | } |
6811 | 7121 | $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
6812 | 7122 | ORDER BY airport_departure_icao_count DESC"; |
6813 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7123 | + if ($limit) { |
|
7124 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7125 | + } |
|
6814 | 7126 | //echo $query; |
6815 | 7127 | $sth = $this->db->prepare($query); |
6816 | 7128 | $sth->execute($query_values); |
@@ -6862,7 +7174,9 @@ discard block |
||
6862 | 7174 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6863 | 7175 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
6864 | 7176 | ORDER BY airport_departure_icao_count DESC"; |
6865 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7177 | + if ($limit) { |
|
7178 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7179 | + } |
|
6866 | 7180 | |
6867 | 7181 | $sth = $this->db->prepare($query); |
6868 | 7182 | $sth->execute(); |
@@ -7257,7 +7571,9 @@ discard block |
||
7257 | 7571 | date_default_timezone_set($globalTimezone); |
7258 | 7572 | $datetime = new DateTime($date); |
7259 | 7573 | $offset = $datetime->format('P'); |
7260 | - } else $offset = '+00:00'; |
|
7574 | + } else { |
|
7575 | + $offset = '+00:00'; |
|
7576 | + } |
|
7261 | 7577 | |
7262 | 7578 | if ($globalDBdriver == 'mysql') { |
7263 | 7579 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
@@ -7307,7 +7623,9 @@ discard block |
||
7307 | 7623 | date_default_timezone_set($globalTimezone); |
7308 | 7624 | $datetime = new DateTime($date); |
7309 | 7625 | $offset = $datetime->format('P'); |
7310 | - } else $offset = '+00:00'; |
|
7626 | + } else { |
|
7627 | + $offset = '+00:00'; |
|
7628 | + } |
|
7311 | 7629 | |
7312 | 7630 | if ($globalDBdriver == 'mysql') { |
7313 | 7631 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
@@ -7656,7 +7974,9 @@ discard block |
||
7656 | 7974 | } |
7657 | 7975 | $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
7658 | 7976 | ORDER BY airport_arrival_icao_count DESC"; |
7659 | - if ($limit) $query .= " LIMIT 10"; |
|
7977 | + if ($limit) { |
|
7978 | + $query .= " LIMIT 10"; |
|
7979 | + } |
|
7660 | 7980 | |
7661 | 7981 | |
7662 | 7982 | $sth = $this->db->prepare($query); |
@@ -7676,7 +7996,9 @@ discard block |
||
7676 | 7996 | if ($icaoaskey) { |
7677 | 7997 | $icao = $row['arrival_airport_icao']; |
7678 | 7998 | $airport_array[$icao] = $temp_array; |
7679 | - } else $airport_array[] = $temp_array; |
|
7999 | + } else { |
|
8000 | + $airport_array[] = $temp_array; |
|
8001 | + } |
|
7680 | 8002 | } |
7681 | 8003 | |
7682 | 8004 | return $airport_array; |
@@ -7713,7 +8035,9 @@ discard block |
||
7713 | 8035 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
7714 | 8036 | $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
7715 | 8037 | ORDER BY airport_arrival_icao_count DESC"; |
7716 | - if ($limit) $query .= " LIMIT 10"; |
|
8038 | + if ($limit) { |
|
8039 | + $query .= " LIMIT 10"; |
|
8040 | + } |
|
7717 | 8041 | |
7718 | 8042 | |
7719 | 8043 | $sth = $this->db->prepare($query); |
@@ -7734,7 +8058,9 @@ discard block |
||
7734 | 8058 | if ($icaoaskey) { |
7735 | 8059 | $icao = $row['arrival_airport_icao']; |
7736 | 8060 | $airport_array[$icao] = $temp_array; |
7737 | - } else $airport_array[] = $temp_array; |
|
8061 | + } else { |
|
8062 | + $airport_array[] = $temp_array; |
|
8063 | + } |
|
7738 | 8064 | } |
7739 | 8065 | |
7740 | 8066 | return $airport_array; |
@@ -7797,7 +8123,9 @@ discard block |
||
7797 | 8123 | } |
7798 | 8124 | $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
7799 | 8125 | ORDER BY airport_arrival_icao_count DESC"; |
7800 | - if ($limit) $query .= " LIMIT 10"; |
|
8126 | + if ($limit) { |
|
8127 | + $query .= " LIMIT 10"; |
|
8128 | + } |
|
7801 | 8129 | |
7802 | 8130 | |
7803 | 8131 | $sth = $this->db->prepare($query); |
@@ -7816,7 +8144,9 @@ discard block |
||
7816 | 8144 | if ($icaoaskey) { |
7817 | 8145 | $icao = $row['arrival_airport_icao']; |
7818 | 8146 | $airport_array[$icao] = $temp_array; |
7819 | - } else $airport_array[] = $temp_array; |
|
8147 | + } else { |
|
8148 | + $airport_array[] = $temp_array; |
|
8149 | + } |
|
7820 | 8150 | } |
7821 | 8151 | |
7822 | 8152 | return $airport_array; |
@@ -7853,7 +8183,9 @@ discard block |
||
7853 | 8183 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
7854 | 8184 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
7855 | 8185 | ORDER BY airport_arrival_icao_count DESC"; |
7856 | - if ($limit) $query .= " LIMIT 10"; |
|
8186 | + if ($limit) { |
|
8187 | + $query .= " LIMIT 10"; |
|
8188 | + } |
|
7857 | 8189 | |
7858 | 8190 | |
7859 | 8191 | $sth = $this->db->prepare($query); |
@@ -7874,7 +8206,9 @@ discard block |
||
7874 | 8206 | if ($icaoaskey) { |
7875 | 8207 | $icao = $row['arrival_airport_icao']; |
7876 | 8208 | $airport_array[$icao] = $temp_array; |
7877 | - } else $airport_array[] = $temp_array; |
|
8209 | + } else { |
|
8210 | + $airport_array[] = $temp_array; |
|
8211 | + } |
|
7878 | 8212 | } |
7879 | 8213 | |
7880 | 8214 | return $airport_array; |
@@ -8255,7 +8589,9 @@ discard block |
||
8255 | 8589 | date_default_timezone_set($globalTimezone); |
8256 | 8590 | $datetime = new DateTime($date); |
8257 | 8591 | $offset = $datetime->format('P'); |
8258 | - } else $offset = '+00:00'; |
|
8592 | + } else { |
|
8593 | + $offset = '+00:00'; |
|
8594 | + } |
|
8259 | 8595 | |
8260 | 8596 | if ($globalDBdriver == 'mysql') { |
8261 | 8597 | $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
@@ -8305,7 +8641,9 @@ discard block |
||
8305 | 8641 | date_default_timezone_set($globalTimezone); |
8306 | 8642 | $datetime = new DateTime($date); |
8307 | 8643 | $offset = $datetime->format('P'); |
8308 | - } else $offset = '+00:00'; |
|
8644 | + } else { |
|
8645 | + $offset = '+00:00'; |
|
8646 | + } |
|
8309 | 8647 | |
8310 | 8648 | if ($globalDBdriver == 'mysql') { |
8311 | 8649 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
@@ -8696,7 +9034,9 @@ discard block |
||
8696 | 9034 | } |
8697 | 9035 | $query .= " GROUP BY spotter_output.arrival_airport_country |
8698 | 9036 | ORDER BY airport_arrival_country_count DESC"; |
8699 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
9037 | + if ($limit) { |
|
9038 | + $query .= " LIMIT 10 OFFSET 0"; |
|
9039 | + } |
|
8700 | 9040 | |
8701 | 9041 | |
8702 | 9042 | $sth = $this->db->prepare($query); |
@@ -8983,7 +9323,9 @@ discard block |
||
8983 | 9323 | date_default_timezone_set($globalTimezone); |
8984 | 9324 | $datetime = new DateTime($date); |
8985 | 9325 | $offset = $datetime->format('P'); |
8986 | - } else $offset = '+00:00'; |
|
9326 | + } else { |
|
9327 | + $offset = '+00:00'; |
|
9328 | + } |
|
8987 | 9329 | |
8988 | 9330 | if ($globalDBdriver == 'mysql') { |
8989 | 9331 | $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
@@ -9239,12 +9581,18 @@ discard block |
||
9239 | 9581 | $query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao |
9240 | 9582 | FROM spotter_output".$filter_query." spotter_output.ident <> ''"; |
9241 | 9583 | if ($olderthanmonths > 0) { |
9242 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
9243 | - else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
9584 | + if ($globalDBdriver == 'mysql') { |
|
9585 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
9586 | + } else { |
|
9587 | + $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
9588 | + } |
|
9244 | 9589 | } |
9245 | 9590 | if ($sincedate != '') { |
9246 | - if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'"; |
|
9247 | - else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
9591 | + if ($globalDBdriver == 'mysql') { |
|
9592 | + $query .= " AND spotter_output.date > '".$sincedate."'"; |
|
9593 | + } else { |
|
9594 | + $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
9595 | + } |
|
9248 | 9596 | } |
9249 | 9597 | $query_values = array(); |
9250 | 9598 | if ($year != '') { |
@@ -9275,7 +9623,9 @@ discard block |
||
9275 | 9623 | } |
9276 | 9624 | } |
9277 | 9625 | $query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
9278 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
9626 | + if ($limit) { |
|
9627 | + $query .= " LIMIT 10 OFFSET 0"; |
|
9628 | + } |
|
9279 | 9629 | |
9280 | 9630 | $sth = $this->db->prepare($query); |
9281 | 9631 | $sth->execute($query_values); |
@@ -9309,15 +9659,23 @@ discard block |
||
9309 | 9659 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name |
9310 | 9660 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao <> '' "; |
9311 | 9661 | if ($olderthanmonths > 0) { |
9312 | - if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
9313 | - else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
9662 | + if ($globalDBdriver == 'mysql') { |
|
9663 | + $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
9664 | + } else { |
|
9665 | + $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
9666 | + } |
|
9314 | 9667 | } |
9315 | 9668 | if ($sincedate != '') { |
9316 | - if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' "; |
|
9317 | - else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
9669 | + if ($globalDBdriver == 'mysql') { |
|
9670 | + $query .= "AND spotter_output.date > '".$sincedate."' "; |
|
9671 | + } else { |
|
9672 | + $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
9673 | + } |
|
9318 | 9674 | } |
9319 | 9675 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
9320 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
9676 | + if ($limit) { |
|
9677 | + $query .= " LIMIT 10 OFFSET 0"; |
|
9678 | + } |
|
9321 | 9679 | |
9322 | 9680 | $sth = $this->db->prepare($query); |
9323 | 9681 | $sth->execute(); |
@@ -9354,7 +9712,9 @@ discard block |
||
9354 | 9712 | date_default_timezone_set($globalTimezone); |
9355 | 9713 | $datetime = new DateTime(); |
9356 | 9714 | $offset = $datetime->format('P'); |
9357 | - } else $offset = '+00:00'; |
|
9715 | + } else { |
|
9716 | + $offset = '+00:00'; |
|
9717 | + } |
|
9358 | 9718 | |
9359 | 9719 | if ($globalDBdriver == 'mysql') { |
9360 | 9720 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -9403,7 +9763,9 @@ discard block |
||
9403 | 9763 | date_default_timezone_set($globalTimezone); |
9404 | 9764 | $datetime = new DateTime(); |
9405 | 9765 | $offset = $datetime->format('P'); |
9406 | - } else $offset = '+00:00'; |
|
9766 | + } else { |
|
9767 | + $offset = '+00:00'; |
|
9768 | + } |
|
9407 | 9769 | $filter_query = $this->getFilter($filters,true,true); |
9408 | 9770 | if ($globalDBdriver == 'mysql') { |
9409 | 9771 | $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -9452,7 +9814,9 @@ discard block |
||
9452 | 9814 | date_default_timezone_set($globalTimezone); |
9453 | 9815 | $datetime = new DateTime(); |
9454 | 9816 | $offset = $datetime->format('P'); |
9455 | - } else $offset = '+00:00'; |
|
9817 | + } else { |
|
9818 | + $offset = '+00:00'; |
|
9819 | + } |
|
9456 | 9820 | $filter_query = $this->getFilter($filters,true,true); |
9457 | 9821 | if ($globalDBdriver == 'mysql') { |
9458 | 9822 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -9498,7 +9862,9 @@ discard block |
||
9498 | 9862 | date_default_timezone_set($globalTimezone); |
9499 | 9863 | $datetime = new DateTime(); |
9500 | 9864 | $offset = $datetime->format('P'); |
9501 | - } else $offset = '+00:00'; |
|
9865 | + } else { |
|
9866 | + $offset = '+00:00'; |
|
9867 | + } |
|
9502 | 9868 | $filter_query = $this->getFilter($filters,true,true); |
9503 | 9869 | if ($globalDBdriver == 'mysql') { |
9504 | 9870 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -9546,7 +9912,9 @@ discard block |
||
9546 | 9912 | date_default_timezone_set($globalTimezone); |
9547 | 9913 | $datetime = new DateTime(); |
9548 | 9914 | $offset = $datetime->format('P'); |
9549 | - } else $offset = '+00:00'; |
|
9915 | + } else { |
|
9916 | + $offset = '+00:00'; |
|
9917 | + } |
|
9550 | 9918 | |
9551 | 9919 | if ($globalDBdriver == 'mysql') { |
9552 | 9920 | $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -9594,7 +9962,9 @@ discard block |
||
9594 | 9962 | date_default_timezone_set($globalTimezone); |
9595 | 9963 | $datetime = new DateTime(); |
9596 | 9964 | $offset = $datetime->format('P'); |
9597 | - } else $offset = '+00:00'; |
|
9965 | + } else { |
|
9966 | + $offset = '+00:00'; |
|
9967 | + } |
|
9598 | 9968 | |
9599 | 9969 | if ($globalDBdriver == 'mysql') { |
9600 | 9970 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -9641,7 +10011,9 @@ discard block |
||
9641 | 10011 | date_default_timezone_set($globalTimezone); |
9642 | 10012 | $datetime = new DateTime(); |
9643 | 10013 | $offset = $datetime->format('P'); |
9644 | - } else $offset = '+00:00'; |
|
10014 | + } else { |
|
10015 | + $offset = '+00:00'; |
|
10016 | + } |
|
9645 | 10017 | |
9646 | 10018 | if ($globalDBdriver == 'mysql') { |
9647 | 10019 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -9689,7 +10061,9 @@ discard block |
||
9689 | 10061 | date_default_timezone_set($globalTimezone); |
9690 | 10062 | $datetime = new DateTime(); |
9691 | 10063 | $offset = $datetime->format('P'); |
9692 | - } else $offset = '+00:00'; |
|
10064 | + } else { |
|
10065 | + $offset = '+00:00'; |
|
10066 | + } |
|
9693 | 10067 | $filter_query = $this->getFilter($filters,true,true); |
9694 | 10068 | if ($globalDBdriver == 'mysql') { |
9695 | 10069 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -9734,7 +10108,9 @@ discard block |
||
9734 | 10108 | date_default_timezone_set($globalTimezone); |
9735 | 10109 | $datetime = new DateTime(); |
9736 | 10110 | $offset = $datetime->format('P'); |
9737 | - } else $offset = '+00:00'; |
|
10111 | + } else { |
|
10112 | + $offset = '+00:00'; |
|
10113 | + } |
|
9738 | 10114 | $filter_query = $this->getFilter($filters,true,true); |
9739 | 10115 | |
9740 | 10116 | if ($globalDBdriver == 'mysql') { |
@@ -9781,7 +10157,9 @@ discard block |
||
9781 | 10157 | date_default_timezone_set($globalTimezone); |
9782 | 10158 | $datetime = new DateTime(); |
9783 | 10159 | $offset = $datetime->format('P'); |
9784 | - } else $offset = '+00:00'; |
|
10160 | + } else { |
|
10161 | + $offset = '+00:00'; |
|
10162 | + } |
|
9785 | 10163 | |
9786 | 10164 | if ($globalDBdriver == 'mysql') { |
9787 | 10165 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count |
@@ -9827,7 +10205,9 @@ discard block |
||
9827 | 10205 | date_default_timezone_set($globalTimezone); |
9828 | 10206 | $datetime = new DateTime(); |
9829 | 10207 | $offset = $datetime->format('P'); |
9830 | - } else $offset = '+00:00'; |
|
10208 | + } else { |
|
10209 | + $offset = '+00:00'; |
|
10210 | + } |
|
9831 | 10211 | $filter_query = $this->getFilter($filters,true,true); |
9832 | 10212 | |
9833 | 10213 | if ($globalDBdriver == 'mysql') { |
@@ -9874,7 +10254,9 @@ discard block |
||
9874 | 10254 | date_default_timezone_set($globalTimezone); |
9875 | 10255 | $datetime = new DateTime(); |
9876 | 10256 | $offset = $datetime->format('P'); |
9877 | - } else $offset = '+00:00'; |
|
10257 | + } else { |
|
10258 | + $offset = '+00:00'; |
|
10259 | + } |
|
9878 | 10260 | |
9879 | 10261 | if ($globalDBdriver == 'mysql') { |
9880 | 10262 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count |
@@ -9921,7 +10303,9 @@ discard block |
||
9921 | 10303 | date_default_timezone_set($globalTimezone); |
9922 | 10304 | $datetime = new DateTime(); |
9923 | 10305 | $offset = $datetime->format('P'); |
9924 | - } else $offset = '+00:00'; |
|
10306 | + } else { |
|
10307 | + $offset = '+00:00'; |
|
10308 | + } |
|
9925 | 10309 | |
9926 | 10310 | if ($globalDBdriver == 'mysql') { |
9927 | 10311 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count |
@@ -9966,7 +10350,9 @@ discard block |
||
9966 | 10350 | date_default_timezone_set($globalTimezone); |
9967 | 10351 | $datetime = new DateTime(); |
9968 | 10352 | $offset = $datetime->format('P'); |
9969 | - } else $offset = '+00:00'; |
|
10353 | + } else { |
|
10354 | + $offset = '+00:00'; |
|
10355 | + } |
|
9970 | 10356 | $filter_query = $this->getFilter($filters,true,true); |
9971 | 10357 | |
9972 | 10358 | if ($globalDBdriver == 'mysql') { |
@@ -10014,7 +10400,9 @@ discard block |
||
10014 | 10400 | date_default_timezone_set($globalTimezone); |
10015 | 10401 | $datetime = new DateTime(); |
10016 | 10402 | $offset = $datetime->format('P'); |
10017 | - } else $offset = '+00:00'; |
|
10403 | + } else { |
|
10404 | + $offset = '+00:00'; |
|
10405 | + } |
|
10018 | 10406 | |
10019 | 10407 | if ($globalDBdriver == 'mysql') { |
10020 | 10408 | $query = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count |
@@ -10060,7 +10448,9 @@ discard block |
||
10060 | 10448 | date_default_timezone_set($globalTimezone); |
10061 | 10449 | $datetime = new DateTime(); |
10062 | 10450 | $offset = $datetime->format('P'); |
10063 | - } else $offset = '+00:00'; |
|
10451 | + } else { |
|
10452 | + $offset = '+00:00'; |
|
10453 | + } |
|
10064 | 10454 | $filter_query = $this->getFilter($filters,true,true); |
10065 | 10455 | |
10066 | 10456 | if ($globalDBdriver == 'mysql') { |
@@ -10108,7 +10498,9 @@ discard block |
||
10108 | 10498 | date_default_timezone_set($globalTimezone); |
10109 | 10499 | $datetime = new DateTime(); |
10110 | 10500 | $offset = $datetime->format('P'); |
10111 | - } else $offset = '+00:00'; |
|
10501 | + } else { |
|
10502 | + $offset = '+00:00'; |
|
10503 | + } |
|
10112 | 10504 | |
10113 | 10505 | if ($globalDBdriver == 'mysql') { |
10114 | 10506 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count |
@@ -10155,7 +10547,9 @@ discard block |
||
10155 | 10547 | date_default_timezone_set($globalTimezone); |
10156 | 10548 | $datetime = new DateTime(); |
10157 | 10549 | $offset = $datetime->format('P'); |
10158 | - } else $offset = '+00:00'; |
|
10550 | + } else { |
|
10551 | + $offset = '+00:00'; |
|
10552 | + } |
|
10159 | 10553 | $filter_query = $this->getFilter($filters,true,true); |
10160 | 10554 | if ($globalDBdriver == 'mysql') { |
10161 | 10555 | $query = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -10204,7 +10598,9 @@ discard block |
||
10204 | 10598 | date_default_timezone_set($globalTimezone); |
10205 | 10599 | $datetime = new DateTime(); |
10206 | 10600 | $offset = $datetime->format('P'); |
10207 | - } else $offset = '+00:00'; |
|
10601 | + } else { |
|
10602 | + $offset = '+00:00'; |
|
10603 | + } |
|
10208 | 10604 | |
10209 | 10605 | $orderby_sql = ''; |
10210 | 10606 | if ($orderby == "hour") |
@@ -10270,7 +10666,9 @@ discard block |
||
10270 | 10666 | date_default_timezone_set($globalTimezone); |
10271 | 10667 | $datetime = new DateTime(); |
10272 | 10668 | $offset = $datetime->format('P'); |
10273 | - } else $offset = '+00:00'; |
|
10669 | + } else { |
|
10670 | + $offset = '+00:00'; |
|
10671 | + } |
|
10274 | 10672 | |
10275 | 10673 | $orderby_sql = ''; |
10276 | 10674 | if ($orderby == "hour") |
@@ -10337,7 +10735,9 @@ discard block |
||
10337 | 10735 | date_default_timezone_set($globalTimezone); |
10338 | 10736 | $datetime = new DateTime(); |
10339 | 10737 | $offset = $datetime->format('P'); |
10340 | - } else $offset = '+00:00'; |
|
10738 | + } else { |
|
10739 | + $offset = '+00:00'; |
|
10740 | + } |
|
10341 | 10741 | |
10342 | 10742 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
10343 | 10743 | |
@@ -10388,7 +10788,9 @@ discard block |
||
10388 | 10788 | date_default_timezone_set($globalTimezone); |
10389 | 10789 | $datetime = new DateTime(); |
10390 | 10790 | $offset = $datetime->format('P'); |
10391 | - } else $offset = '+00:00'; |
|
10791 | + } else { |
|
10792 | + $offset = '+00:00'; |
|
10793 | + } |
|
10392 | 10794 | |
10393 | 10795 | if ($globalDBdriver == 'mysql') { |
10394 | 10796 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10435,7 +10837,9 @@ discard block |
||
10435 | 10837 | date_default_timezone_set($globalTimezone); |
10436 | 10838 | $datetime = new DateTime(); |
10437 | 10839 | $offset = $datetime->format('P'); |
10438 | - } else $offset = '+00:00'; |
|
10840 | + } else { |
|
10841 | + $offset = '+00:00'; |
|
10842 | + } |
|
10439 | 10843 | |
10440 | 10844 | if ($globalDBdriver == 'mysql') { |
10441 | 10845 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10482,7 +10886,9 @@ discard block |
||
10482 | 10886 | date_default_timezone_set($globalTimezone); |
10483 | 10887 | $datetime = new DateTime(); |
10484 | 10888 | $offset = $datetime->format('P'); |
10485 | - } else $offset = '+00:00'; |
|
10889 | + } else { |
|
10890 | + $offset = '+00:00'; |
|
10891 | + } |
|
10486 | 10892 | |
10487 | 10893 | if ($globalDBdriver == 'mysql') { |
10488 | 10894 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10530,7 +10936,9 @@ discard block |
||
10530 | 10936 | date_default_timezone_set($globalTimezone); |
10531 | 10937 | $datetime = new DateTime(); |
10532 | 10938 | $offset = $datetime->format('P'); |
10533 | - } else $offset = '+00:00'; |
|
10939 | + } else { |
|
10940 | + $offset = '+00:00'; |
|
10941 | + } |
|
10534 | 10942 | |
10535 | 10943 | if ($globalDBdriver == 'mysql') { |
10536 | 10944 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10578,7 +10986,9 @@ discard block |
||
10578 | 10986 | date_default_timezone_set($globalTimezone); |
10579 | 10987 | $datetime = new DateTime($date); |
10580 | 10988 | $offset = $datetime->format('P'); |
10581 | - } else $offset = '+00:00'; |
|
10989 | + } else { |
|
10990 | + $offset = '+00:00'; |
|
10991 | + } |
|
10582 | 10992 | |
10583 | 10993 | if ($globalDBdriver == 'mysql') { |
10584 | 10994 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10626,7 +11036,9 @@ discard block |
||
10626 | 11036 | date_default_timezone_set($globalTimezone); |
10627 | 11037 | $datetime = new DateTime(); |
10628 | 11038 | $offset = $datetime->format('P'); |
10629 | - } else $offset = '+00:00'; |
|
11039 | + } else { |
|
11040 | + $offset = '+00:00'; |
|
11041 | + } |
|
10630 | 11042 | |
10631 | 11043 | if ($globalDBdriver == 'mysql') { |
10632 | 11044 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10673,7 +11085,9 @@ discard block |
||
10673 | 11085 | date_default_timezone_set($globalTimezone); |
10674 | 11086 | $datetime = new DateTime(); |
10675 | 11087 | $offset = $datetime->format('P'); |
10676 | - } else $offset = '+00:00'; |
|
11088 | + } else { |
|
11089 | + $offset = '+00:00'; |
|
11090 | + } |
|
10677 | 11091 | |
10678 | 11092 | if ($globalDBdriver == 'mysql') { |
10679 | 11093 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10720,7 +11134,9 @@ discard block |
||
10720 | 11134 | date_default_timezone_set($globalTimezone); |
10721 | 11135 | $datetime = new DateTime(); |
10722 | 11136 | $offset = $datetime->format('P'); |
10723 | - } else $offset = '+00:00'; |
|
11137 | + } else { |
|
11138 | + $offset = '+00:00'; |
|
11139 | + } |
|
10724 | 11140 | |
10725 | 11141 | if ($globalDBdriver == 'mysql') { |
10726 | 11142 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10770,7 +11186,9 @@ discard block |
||
10770 | 11186 | date_default_timezone_set($globalTimezone); |
10771 | 11187 | $datetime = new DateTime(); |
10772 | 11188 | $offset = $datetime->format('P'); |
10773 | - } else $offset = '+00:00'; |
|
11189 | + } else { |
|
11190 | + $offset = '+00:00'; |
|
11191 | + } |
|
10774 | 11192 | |
10775 | 11193 | if ($globalDBdriver == 'mysql') { |
10776 | 11194 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10817,7 +11235,9 @@ discard block |
||
10817 | 11235 | date_default_timezone_set($globalTimezone); |
10818 | 11236 | $datetime = new DateTime(); |
10819 | 11237 | $offset = $datetime->format('P'); |
10820 | - } else $offset = '+00:00'; |
|
11238 | + } else { |
|
11239 | + $offset = '+00:00'; |
|
11240 | + } |
|
10821 | 11241 | |
10822 | 11242 | if ($globalDBdriver == 'mysql') { |
10823 | 11243 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -11028,8 +11448,11 @@ discard block |
||
11028 | 11448 | $query_values = array_merge($query_values,array(':month' => $month)); |
11029 | 11449 | } |
11030 | 11450 | } |
11031 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
11032 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
11451 | + if (empty($query_values)) { |
|
11452 | + $queryi .= $this->getFilter($filters); |
|
11453 | + } else { |
|
11454 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
11455 | + } |
|
11033 | 11456 | |
11034 | 11457 | $sth = $this->db->prepare($queryi); |
11035 | 11458 | $sth->execute($query_values); |
@@ -11107,8 +11530,11 @@ discard block |
||
11107 | 11530 | $query_values = array_merge($query_values,array(':month' => $month)); |
11108 | 11531 | } |
11109 | 11532 | } |
11110 | - if ($query == '') $queryi .= $this->getFilter($filters); |
|
11111 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
11533 | + if ($query == '') { |
|
11534 | + $queryi .= $this->getFilter($filters); |
|
11535 | + } else { |
|
11536 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
11537 | + } |
|
11112 | 11538 | |
11113 | 11539 | |
11114 | 11540 | $sth = $this->db->prepare($queryi); |
@@ -11131,7 +11557,9 @@ discard block |
||
11131 | 11557 | date_default_timezone_set($globalTimezone); |
11132 | 11558 | $datetime = new DateTime(); |
11133 | 11559 | $offset = $datetime->format('P'); |
11134 | - } else $offset = '+00:00'; |
|
11560 | + } else { |
|
11561 | + $offset = '+00:00'; |
|
11562 | + } |
|
11135 | 11563 | |
11136 | 11564 | if ($globalDBdriver == 'mysql') { |
11137 | 11565 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -11317,7 +11745,9 @@ discard block |
||
11317 | 11745 | */ |
11318 | 11746 | public function parseDirection($direction = 0) |
11319 | 11747 | { |
11320 | - if ($direction == '') $direction = 0; |
|
11748 | + if ($direction == '') { |
|
11749 | + $direction = 0; |
|
11750 | + } |
|
11321 | 11751 | $direction_array = array(); |
11322 | 11752 | $temp_array = array(); |
11323 | 11753 | |
@@ -11418,7 +11848,9 @@ discard block |
||
11418 | 11848 | if (isset($result->AirlineFlightInfoResult)) |
11419 | 11849 | { |
11420 | 11850 | $registration = $result->AirlineFlightInfoResult->tailnumber; |
11421 | - } else return ''; |
|
11851 | + } else { |
|
11852 | + return ''; |
|
11853 | + } |
|
11422 | 11854 | |
11423 | 11855 | $registration = $this->convertAircraftRegistration($registration); |
11424 | 11856 | |
@@ -11447,7 +11879,9 @@ discard block |
||
11447 | 11879 | if (count($row) > 0) { |
11448 | 11880 | //return $row['Registration']; |
11449 | 11881 | return $row['registration']; |
11450 | - } else return ''; |
|
11882 | + } else { |
|
11883 | + return ''; |
|
11884 | + } |
|
11451 | 11885 | |
11452 | 11886 | } |
11453 | 11887 | |
@@ -11470,9 +11904,14 @@ discard block |
||
11470 | 11904 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
11471 | 11905 | $sth->closeCursor(); |
11472 | 11906 | if (count($row) > 0) { |
11473 | - if ($row['type_flight'] == null) return ''; |
|
11474 | - else return $row['type_flight']; |
|
11475 | - } else return ''; |
|
11907 | + if ($row['type_flight'] == null) { |
|
11908 | + return ''; |
|
11909 | + } else { |
|
11910 | + return $row['type_flight']; |
|
11911 | + } |
|
11912 | + } else { |
|
11913 | + return ''; |
|
11914 | + } |
|
11476 | 11915 | |
11477 | 11916 | } |
11478 | 11917 | |
@@ -11490,7 +11929,9 @@ discard block |
||
11490 | 11929 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
11491 | 11930 | |
11492 | 11931 | $Connection = new Connection($this->db); |
11493 | - if (!$Connection->tableExists('countries')) return ''; |
|
11932 | + if (!$Connection->tableExists('countries')) { |
|
11933 | + return ''; |
|
11934 | + } |
|
11494 | 11935 | |
11495 | 11936 | try { |
11496 | 11937 | /* |
@@ -11510,9 +11951,13 @@ discard block |
||
11510 | 11951 | $sth->closeCursor(); |
11511 | 11952 | if (count($row) > 0) { |
11512 | 11953 | return $row; |
11513 | - } else return ''; |
|
11954 | + } else { |
|
11955 | + return ''; |
|
11956 | + } |
|
11514 | 11957 | } catch (PDOException $e) { |
11515 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
11958 | + if (isset($globalDebug) && $globalDebug) { |
|
11959 | + echo 'Error : '.$e->getMessage()."\n"; |
|
11960 | + } |
|
11516 | 11961 | return ''; |
11517 | 11962 | } |
11518 | 11963 | |
@@ -11530,7 +11975,9 @@ discard block |
||
11530 | 11975 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
11531 | 11976 | |
11532 | 11977 | $Connection = new Connection($this->db); |
11533 | - if (!$Connection->tableExists('countries')) return ''; |
|
11978 | + if (!$Connection->tableExists('countries')) { |
|
11979 | + return ''; |
|
11980 | + } |
|
11534 | 11981 | |
11535 | 11982 | try { |
11536 | 11983 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -11542,9 +11989,13 @@ discard block |
||
11542 | 11989 | $sth->closeCursor(); |
11543 | 11990 | if (count($row) > 0) { |
11544 | 11991 | return $row; |
11545 | - } else return ''; |
|
11992 | + } else { |
|
11993 | + return ''; |
|
11994 | + } |
|
11546 | 11995 | } catch (PDOException $e) { |
11547 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
11996 | + if (isset($globalDebug) && $globalDebug) { |
|
11997 | + echo 'Error : '.$e->getMessage()."\n"; |
|
11998 | + } |
|
11548 | 11999 | return ''; |
11549 | 12000 | } |
11550 | 12001 | |
@@ -11794,7 +12245,9 @@ discard block |
||
11794 | 12245 | { |
11795 | 12246 | global $globalBitlyAccessToken; |
11796 | 12247 | |
11797 | - if ($globalBitlyAccessToken == '') return $url; |
|
12248 | + if ($globalBitlyAccessToken == '') { |
|
12249 | + return $url; |
|
12250 | + } |
|
11798 | 12251 | |
11799 | 12252 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
11800 | 12253 | |
@@ -11943,7 +12396,9 @@ discard block |
||
11943 | 12396 | |
11944 | 12397 | |
11945 | 12398 | // routes |
11946 | - if ($globalDebug) print "Routes...\n"; |
|
12399 | + if ($globalDebug) { |
|
12400 | + print "Routes...\n"; |
|
12401 | + } |
|
11947 | 12402 | if ($globalDBdriver == 'mysql') { |
11948 | 12403 | $query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; |
11949 | 12404 | } else { |
@@ -11962,7 +12417,9 @@ discard block |
||
11962 | 12417 | } |
11963 | 12418 | } |
11964 | 12419 | |
11965 | - if ($globalDebug) print "Airlines...\n"; |
|
12420 | + if ($globalDebug) { |
|
12421 | + print "Airlines...\n"; |
|
12422 | + } |
|
11966 | 12423 | //airlines |
11967 | 12424 | if ($globalDBdriver == 'mysql') { |
11968 | 12425 | $query = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; |
@@ -11976,10 +12433,15 @@ discard block |
||
11976 | 12433 | if (is_numeric(substr($row['ident'], -1, 1))) |
11977 | 12434 | { |
11978 | 12435 | $fromsource = NULL; |
11979 | - if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
11980 | - elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
11981 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
11982 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
12436 | + if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') { |
|
12437 | + $fromsource = 'vatsim'; |
|
12438 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') { |
|
12439 | + $fromsource = 'ivao'; |
|
12440 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
12441 | + $fromsource = 'vatsim'; |
|
12442 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
12443 | + $fromsource = 'ivao'; |
|
12444 | + } |
|
11983 | 12445 | $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
11984 | 12446 | if (isset($airline_array[0]['name'])) { |
11985 | 12447 | $update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id"; |
@@ -11989,13 +12451,17 @@ discard block |
||
11989 | 12451 | } |
11990 | 12452 | } |
11991 | 12453 | |
11992 | - if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n"; |
|
12454 | + if ($globalDebug) { |
|
12455 | + print "Remove Duplicate in aircraft_modes...\n"; |
|
12456 | + } |
|
11993 | 12457 | //duplicate modes |
11994 | 12458 | $query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL"; |
11995 | 12459 | $sth = $this->db->prepare($query); |
11996 | 12460 | $sth->execute(); |
11997 | 12461 | |
11998 | - if ($globalDebug) print "Aircraft...\n"; |
|
12462 | + if ($globalDebug) { |
|
12463 | + print "Aircraft...\n"; |
|
12464 | + } |
|
11999 | 12465 | //aircraft |
12000 | 12466 | if ($globalDBdriver == 'mysql') { |
12001 | 12467 | $query = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -12038,26 +12504,38 @@ discard block |
||
12038 | 12504 | if (isset($closestAirports[0])) { |
12039 | 12505 | if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) { |
12040 | 12506 | $airport_icao = $closestAirports[0]['icao']; |
12041 | - if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
12507 | + if ($globalDebug) { |
|
12508 | + echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
12509 | + } |
|
12042 | 12510 | } elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') { |
12043 | 12511 | foreach ($closestAirports as $airport) { |
12044 | 12512 | if ($row['arrival_airport_icao'] == $airport['icao']) { |
12045 | 12513 | $airport_icao = $airport['icao']; |
12046 | - if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
12514 | + if ($globalDebug) { |
|
12515 | + echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
12516 | + } |
|
12047 | 12517 | break; |
12048 | 12518 | } |
12049 | 12519 | } |
12050 | 12520 | } elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) { |
12051 | 12521 | $airport_icao = $closestAirports[0]['icao']; |
12052 | - if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." ! Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
12522 | + if ($globalDebug) { |
|
12523 | + echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." ! Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
12524 | + } |
|
12053 | 12525 | } else { |
12054 | - if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
12526 | + if ($globalDebug) { |
|
12527 | + echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
12528 | + } |
|
12055 | 12529 | } |
12056 | 12530 | } else { |
12057 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
12531 | + if ($globalDebug) { |
|
12532 | + echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
12533 | + } |
|
12058 | 12534 | } |
12059 | 12535 | if ($row['real_arrival_airport_icao'] != $airport_icao) { |
12060 | - if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n"; |
|
12536 | + if ($globalDebug) { |
|
12537 | + echo "Updating airport to ".$airport_icao."...\n"; |
|
12538 | + } |
|
12061 | 12539 | $update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id"; |
12062 | 12540 | $sthu = $this->db->prepare($update_query); |
12063 | 12541 | $sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id'])); |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct($dbc = null) { |
14 | 14 | global $globalFilterName; |
15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
15 | + if (isset($globalFilterName)) { |
|
16 | + $this->filter_name = $globalFilterName; |
|
17 | + } |
|
16 | 18 | $Connection = new Connection($dbc); |
17 | 19 | $this->db = $Connection->db(); |
18 | 20 | } |
@@ -80,7 +82,9 @@ discard block |
||
80 | 82 | } |
81 | 83 | } |
82 | 84 | public function getAllAirlineNames($filter_name = '') { |
83 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
85 | + if ($filter_name == '') { |
|
86 | + $filter_name = $this->filter_name; |
|
87 | + } |
|
84 | 88 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
85 | 89 | try { |
86 | 90 | $sth = $this->db->prepare($query); |
@@ -92,7 +96,9 @@ discard block |
||
92 | 96 | return $all; |
93 | 97 | } |
94 | 98 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
95 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
99 | + if ($filter_name == '') { |
|
100 | + $filter_name = $this->filter_name; |
|
101 | + } |
|
96 | 102 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
97 | 103 | try { |
98 | 104 | $sth = $this->db->prepare($query); |
@@ -104,7 +110,9 @@ discard block |
||
104 | 110 | return $all; |
105 | 111 | } |
106 | 112 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
107 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
113 | + if ($filter_name == '') { |
|
114 | + $filter_name = $this->filter_name; |
|
115 | + } |
|
108 | 116 | $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"; |
109 | 117 | try { |
110 | 118 | $sth = $this->db->prepare($query); |
@@ -116,7 +124,9 @@ discard block |
||
116 | 124 | return $all; |
117 | 125 | } |
118 | 126 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
119 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
127 | + if ($filter_name == '') { |
|
128 | + $filter_name = $this->filter_name; |
|
129 | + } |
|
120 | 130 | $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"; |
121 | 131 | try { |
122 | 132 | $sth = $this->db->prepare($query); |
@@ -129,7 +139,9 @@ discard block |
||
129 | 139 | } |
130 | 140 | |
131 | 141 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
132 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
142 | + if ($filter_name == '') { |
|
143 | + $filter_name = $this->filter_name; |
|
144 | + } |
|
133 | 145 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
134 | 146 | try { |
135 | 147 | $sth = $this->db->prepare($query); |
@@ -142,7 +154,9 @@ discard block |
||
142 | 154 | } |
143 | 155 | |
144 | 156 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
145 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
157 | + if ($filter_name == '') { |
|
158 | + $filter_name = $this->filter_name; |
|
159 | + } |
|
146 | 160 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
147 | 161 | try { |
148 | 162 | $sth = $this->db->prepare($query); |
@@ -157,10 +171,15 @@ discard block |
||
157 | 171 | |
158 | 172 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
159 | 173 | global $globalStatsFilters; |
160 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
174 | + if ($filter_name == '') { |
|
175 | + $filter_name = $this->filter_name; |
|
176 | + } |
|
161 | 177 | if ($year == '' && $month == '') { |
162 | - 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"; |
|
163 | - 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"; |
|
178 | + if ($limit) { |
|
179 | + $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"; |
|
180 | + } else { |
|
181 | + $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"; |
|
182 | + } |
|
164 | 183 | try { |
165 | 184 | $sth = $this->db->prepare($query); |
166 | 185 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -168,7 +187,9 @@ discard block |
||
168 | 187 | echo "error : ".$e->getMessage(); |
169 | 188 | } |
170 | 189 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
171 | - } else $all = array(); |
|
190 | + } else { |
|
191 | + $all = array(); |
|
192 | + } |
|
172 | 193 | if (empty($all)) { |
173 | 194 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
174 | 195 | if ($filter_name != '') { |
@@ -182,10 +203,15 @@ discard block |
||
182 | 203 | } |
183 | 204 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
184 | 205 | global $globalStatsFilters; |
185 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
206 | + if ($filter_name == '') { |
|
207 | + $filter_name = $this->filter_name; |
|
208 | + } |
|
186 | 209 | if ($year == '' && $month == '') { |
187 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
188 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
210 | + if ($limit) { |
|
211 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
212 | + } else { |
|
213 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
214 | + } |
|
189 | 215 | try { |
190 | 216 | $sth = $this->db->prepare($query); |
191 | 217 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -193,7 +219,9 @@ discard block |
||
193 | 219 | echo "error : ".$e->getMessage(); |
194 | 220 | } |
195 | 221 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
196 | - } else $all = array(); |
|
222 | + } else { |
|
223 | + $all = array(); |
|
224 | + } |
|
197 | 225 | if (empty($all)) { |
198 | 226 | $Spotter = new Spotter($this->db); |
199 | 227 | $filters = array(); |
@@ -208,10 +236,15 @@ discard block |
||
208 | 236 | } |
209 | 237 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
210 | 238 | global $globalStatsFilters; |
211 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
239 | + if ($filter_name == '') { |
|
240 | + $filter_name = $this->filter_name; |
|
241 | + } |
|
212 | 242 | if ($year == '' && $month == '') { |
213 | - 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"; |
|
214 | - 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"; |
|
243 | + if ($limit) { |
|
244 | + $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"; |
|
245 | + } else { |
|
246 | + $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"; |
|
247 | + } |
|
215 | 248 | try { |
216 | 249 | $sth = $this->db->prepare($query); |
217 | 250 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -219,7 +252,9 @@ discard block |
||
219 | 252 | echo "error : ".$e->getMessage(); |
220 | 253 | } |
221 | 254 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
222 | - } else $all = array(); |
|
255 | + } else { |
|
256 | + $all = array(); |
|
257 | + } |
|
223 | 258 | if (empty($all)) { |
224 | 259 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
225 | 260 | if ($filter_name != '') { |
@@ -234,10 +269,15 @@ discard block |
||
234 | 269 | |
235 | 270 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
236 | 271 | global $globalStatsFilters; |
237 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
272 | + if ($filter_name == '') { |
|
273 | + $filter_name = $this->filter_name; |
|
274 | + } |
|
238 | 275 | if ($year == '' && $month == '') { |
239 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
240 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
276 | + if ($limit) { |
|
277 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
278 | + } else { |
|
279 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
280 | + } |
|
241 | 281 | try { |
242 | 282 | $sth = $this->db->prepare($query); |
243 | 283 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -245,7 +285,9 @@ discard block |
||
245 | 285 | echo "error : ".$e->getMessage(); |
246 | 286 | } |
247 | 287 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
248 | - } else $all = array(); |
|
288 | + } else { |
|
289 | + $all = array(); |
|
290 | + } |
|
249 | 291 | if (empty($all)) { |
250 | 292 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
251 | 293 | if ($filter_name != '') { |
@@ -259,9 +301,14 @@ discard block |
||
259 | 301 | } |
260 | 302 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
261 | 303 | global $globalStatsFilters; |
262 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
263 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
264 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
304 | + if ($filter_name == '') { |
|
305 | + $filter_name = $this->filter_name; |
|
306 | + } |
|
307 | + if ($limit) { |
|
308 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
309 | + } else { |
|
310 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
311 | + } |
|
265 | 312 | try { |
266 | 313 | $sth = $this->db->prepare($query); |
267 | 314 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -283,17 +330,29 @@ discard block |
||
283 | 330 | |
284 | 331 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
285 | 332 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
286 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
333 | + if ($filter_name == '') { |
|
334 | + $filter_name = $this->filter_name; |
|
335 | + } |
|
287 | 336 | if ($year == '' && $month == '') { |
288 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
289 | - if ($globalIVAO) $forsource = 'ivao'; |
|
337 | + if ($globalVATSIM) { |
|
338 | + $forsource = 'vatsim'; |
|
339 | + } |
|
340 | + if ($globalIVAO) { |
|
341 | + $forsource = 'ivao'; |
|
342 | + } |
|
290 | 343 | if (isset($forsource)) { |
291 | - 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"; |
|
292 | - 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"; |
|
344 | + if ($limit) { |
|
345 | + $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"; |
|
346 | + } else { |
|
347 | + $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"; |
|
348 | + } |
|
293 | 349 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
294 | 350 | } else { |
295 | - 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"; |
|
296 | - 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"; |
|
351 | + if ($limit) { |
|
352 | + $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"; |
|
353 | + } else { |
|
354 | + $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"; |
|
355 | + } |
|
297 | 356 | $query_values = array(':filter_name' => $filter_name); |
298 | 357 | } |
299 | 358 | try { |
@@ -303,7 +362,9 @@ discard block |
||
303 | 362 | echo "error : ".$e->getMessage(); |
304 | 363 | } |
305 | 364 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
306 | - } else $all = array(); |
|
365 | + } else { |
|
366 | + $all = array(); |
|
367 | + } |
|
307 | 368 | if (empty($all)) { |
308 | 369 | $Spotter = new Spotter($this->db); |
309 | 370 | $filters = array(); |
@@ -318,10 +379,15 @@ discard block |
||
318 | 379 | } |
319 | 380 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
320 | 381 | global $globalStatsFilters; |
321 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
382 | + if ($filter_name == '') { |
|
383 | + $filter_name = $this->filter_name; |
|
384 | + } |
|
322 | 385 | if ($year == '' && $month == '') { |
323 | - 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"; |
|
324 | - 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"; |
|
386 | + if ($limit) { |
|
387 | + $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"; |
|
388 | + } else { |
|
389 | + $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"; |
|
390 | + } |
|
325 | 391 | try { |
326 | 392 | $sth = $this->db->prepare($query); |
327 | 393 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -329,7 +395,9 @@ discard block |
||
329 | 395 | echo "error : ".$e->getMessage(); |
330 | 396 | } |
331 | 397 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
332 | - } else $all = array(); |
|
398 | + } else { |
|
399 | + $all = array(); |
|
400 | + } |
|
333 | 401 | if (empty($all)) { |
334 | 402 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
335 | 403 | if ($filter_name != '') { |
@@ -343,10 +411,15 @@ discard block |
||
343 | 411 | } |
344 | 412 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
345 | 413 | global $globalStatsFilters; |
346 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
414 | + if ($filter_name == '') { |
|
415 | + $filter_name = $this->filter_name; |
|
416 | + } |
|
347 | 417 | if ($year == '' && $month == '') { |
348 | - 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"; |
|
349 | - 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"; |
|
418 | + if ($limit) { |
|
419 | + $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"; |
|
420 | + } else { |
|
421 | + $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"; |
|
422 | + } |
|
350 | 423 | try { |
351 | 424 | $sth = $this->db->prepare($query); |
352 | 425 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -354,7 +427,9 @@ discard block |
||
354 | 427 | echo "error : ".$e->getMessage(); |
355 | 428 | } |
356 | 429 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
357 | - } else $all = array(); |
|
430 | + } else { |
|
431 | + $all = array(); |
|
432 | + } |
|
358 | 433 | if (empty($all)) { |
359 | 434 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
360 | 435 | if ($filter_name != '') { |
@@ -368,11 +443,16 @@ discard block |
||
368 | 443 | } |
369 | 444 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
370 | 445 | $Connection = new Connection(); |
371 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
446 | + if ($filter_name == '') { |
|
447 | + $filter_name = $this->filter_name; |
|
448 | + } |
|
372 | 449 | if ($Connection->tableExists('countries')) { |
373 | 450 | if ($year == '' && $month == '') { |
374 | - 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"; |
|
375 | - 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"; |
|
451 | + if ($limit) { |
|
452 | + $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"; |
|
453 | + } else { |
|
454 | + $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"; |
|
455 | + } |
|
376 | 456 | try { |
377 | 457 | $sth = $this->db->prepare($query); |
378 | 458 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -387,17 +467,24 @@ discard block |
||
387 | 467 | } |
388 | 468 | */ |
389 | 469 | return $all; |
390 | - } else return array(); |
|
470 | + } else { |
|
471 | + return array(); |
|
472 | + } |
|
391 | 473 | } else { |
392 | 474 | return array(); |
393 | 475 | } |
394 | 476 | } |
395 | 477 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
396 | 478 | global $globalStatsFilters; |
397 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
479 | + if ($filter_name == '') { |
|
480 | + $filter_name = $this->filter_name; |
|
481 | + } |
|
398 | 482 | if ($year == '' && $month == '') { |
399 | - 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"; |
|
400 | - 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"; |
|
483 | + if ($limit) { |
|
484 | + $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"; |
|
485 | + } else { |
|
486 | + $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"; |
|
487 | + } |
|
401 | 488 | try { |
402 | 489 | $sth = $this->db->prepare($query); |
403 | 490 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -405,7 +492,9 @@ discard block |
||
405 | 492 | echo "error : ".$e->getMessage(); |
406 | 493 | } |
407 | 494 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
408 | - } else $all = array(); |
|
495 | + } else { |
|
496 | + $all = array(); |
|
497 | + } |
|
409 | 498 | if (empty($all)) { |
410 | 499 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
411 | 500 | if ($filter_name != '') { |
@@ -420,10 +509,15 @@ discard block |
||
420 | 509 | |
421 | 510 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
422 | 511 | global $globalStatsFilters; |
423 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
512 | + if ($filter_name == '') { |
|
513 | + $filter_name = $this->filter_name; |
|
514 | + } |
|
424 | 515 | if ($year == '' && $month == '') { |
425 | - 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"; |
|
426 | - 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"; |
|
516 | + if ($limit) { |
|
517 | + $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"; |
|
518 | + } else { |
|
519 | + $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"; |
|
520 | + } |
|
427 | 521 | try { |
428 | 522 | $sth = $this->db->prepare($query); |
429 | 523 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -431,7 +525,9 @@ discard block |
||
431 | 525 | echo "error : ".$e->getMessage(); |
432 | 526 | } |
433 | 527 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
434 | - } else $all = array(); |
|
528 | + } else { |
|
529 | + $all = array(); |
|
530 | + } |
|
435 | 531 | if (empty($all)) { |
436 | 532 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
437 | 533 | if ($filter_name != '') { |
@@ -445,10 +541,15 @@ discard block |
||
445 | 541 | } |
446 | 542 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
447 | 543 | global $globalStatsFilters; |
448 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
544 | + if ($filter_name == '') { |
|
545 | + $filter_name = $this->filter_name; |
|
546 | + } |
|
449 | 547 | if ($year == '' && $month == '') { |
450 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
451 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
548 | + if ($limit) { |
|
549 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
550 | + } else { |
|
551 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
552 | + } |
|
452 | 553 | try { |
453 | 554 | $sth = $this->db->prepare($query); |
454 | 555 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -456,7 +557,9 @@ discard block |
||
456 | 557 | echo "error : ".$e->getMessage(); |
457 | 558 | } |
458 | 559 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
459 | - } else $all = array(); |
|
560 | + } else { |
|
561 | + $all = array(); |
|
562 | + } |
|
460 | 563 | if (empty($all)) { |
461 | 564 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
462 | 565 | if ($filter_name != '') { |
@@ -477,7 +580,9 @@ discard block |
||
477 | 580 | $icao = $value['airport_departure_icao']; |
478 | 581 | if (isset($all[$icao])) { |
479 | 582 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
480 | - } else $all[$icao] = $value; |
|
583 | + } else { |
|
584 | + $all[$icao] = $value; |
|
585 | + } |
|
481 | 586 | } |
482 | 587 | $count = array(); |
483 | 588 | foreach ($all as $key => $row) { |
@@ -489,10 +594,15 @@ discard block |
||
489 | 594 | } |
490 | 595 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
491 | 596 | global $globalStatsFilters; |
492 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
597 | + if ($filter_name == '') { |
|
598 | + $filter_name = $this->filter_name; |
|
599 | + } |
|
493 | 600 | if ($year == '' && $month == '') { |
494 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
495 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
601 | + if ($limit) { |
|
602 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
603 | + } else { |
|
604 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
605 | + } |
|
496 | 606 | try { |
497 | 607 | $sth = $this->db->prepare($query); |
498 | 608 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -500,7 +610,9 @@ discard block |
||
500 | 610 | echo "error : ".$e->getMessage(); |
501 | 611 | } |
502 | 612 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
503 | - } else $all = array(); |
|
613 | + } else { |
|
614 | + $all = array(); |
|
615 | + } |
|
504 | 616 | if (empty($all)) { |
505 | 617 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
506 | 618 | if ($filter_name != '') { |
@@ -521,7 +633,9 @@ discard block |
||
521 | 633 | $icao = $value['airport_arrival_icao']; |
522 | 634 | if (isset($all[$icao])) { |
523 | 635 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
524 | - } else $all[$icao] = $value; |
|
636 | + } else { |
|
637 | + $all[$icao] = $value; |
|
638 | + } |
|
525 | 639 | } |
526 | 640 | $count = array(); |
527 | 641 | foreach ($all as $key => $row) { |
@@ -534,13 +648,21 @@ discard block |
||
534 | 648 | } |
535 | 649 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
536 | 650 | global $globalDBdriver, $globalStatsFilters; |
537 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
651 | + if ($filter_name == '') { |
|
652 | + $filter_name = $this->filter_name; |
|
653 | + } |
|
538 | 654 | if ($globalDBdriver == 'mysql') { |
539 | - 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"; |
|
540 | - 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"; |
|
655 | + if ($limit) { |
|
656 | + $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"; |
|
657 | + } else { |
|
658 | + $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"; |
|
659 | + } |
|
541 | 660 | } else { |
542 | - 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"; |
|
543 | - 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"; |
|
661 | + if ($limit) { |
|
662 | + $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"; |
|
663 | + } else { |
|
664 | + $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"; |
|
665 | + } |
|
544 | 666 | } |
545 | 667 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
546 | 668 | try { |
@@ -564,7 +686,9 @@ discard block |
||
564 | 686 | |
565 | 687 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
566 | 688 | global $globalStatsFilters; |
567 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
689 | + if ($filter_name == '') { |
|
690 | + $filter_name = $this->filter_name; |
|
691 | + } |
|
568 | 692 | $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"; |
569 | 693 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
570 | 694 | try { |
@@ -586,7 +710,9 @@ discard block |
||
586 | 710 | } |
587 | 711 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
588 | 712 | global $globalDBdriver, $globalStatsFilters; |
589 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
713 | + if ($filter_name == '') { |
|
714 | + $filter_name = $this->filter_name; |
|
715 | + } |
|
590 | 716 | if ($globalDBdriver == 'mysql') { |
591 | 717 | $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"; |
592 | 718 | } else { |
@@ -612,7 +738,9 @@ discard block |
||
612 | 738 | } |
613 | 739 | public function countAllDates($stats_airline = '',$filter_name = '') { |
614 | 740 | global $globalStatsFilters; |
615 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
741 | + if ($filter_name == '') { |
|
742 | + $filter_name = $this->filter_name; |
|
743 | + } |
|
616 | 744 | $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"; |
617 | 745 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
618 | 746 | try { |
@@ -634,7 +762,9 @@ discard block |
||
634 | 762 | } |
635 | 763 | public function countAllDatesByAirlines($filter_name = '') { |
636 | 764 | global $globalStatsFilters; |
637 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
765 | + if ($filter_name == '') { |
|
766 | + $filter_name = $this->filter_name; |
|
767 | + } |
|
638 | 768 | $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"; |
639 | 769 | $query_data = array('filter_name' => $filter_name); |
640 | 770 | try { |
@@ -656,7 +786,9 @@ discard block |
||
656 | 786 | } |
657 | 787 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
658 | 788 | global $globalStatsFilters; |
659 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
789 | + if ($filter_name == '') { |
|
790 | + $filter_name = $this->filter_name; |
|
791 | + } |
|
660 | 792 | $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"; |
661 | 793 | try { |
662 | 794 | $sth = $this->db->prepare($query); |
@@ -679,7 +811,9 @@ discard block |
||
679 | 811 | } |
680 | 812 | public function countAllMilitaryMonths($filter_name = '') { |
681 | 813 | global $globalStatsFilters; |
682 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
814 | + if ($filter_name == '') { |
|
815 | + $filter_name = $this->filter_name; |
|
816 | + } |
|
683 | 817 | $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"; |
684 | 818 | try { |
685 | 819 | $sth = $this->db->prepare($query); |
@@ -700,9 +834,14 @@ discard block |
||
700 | 834 | } |
701 | 835 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
702 | 836 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
703 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
704 | - 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"; |
|
705 | - 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"; |
|
837 | + if ($filter_name == '') { |
|
838 | + $filter_name = $this->filter_name; |
|
839 | + } |
|
840 | + if ($limit) { |
|
841 | + $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"; |
|
842 | + } else { |
|
843 | + $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"; |
|
844 | + } |
|
706 | 845 | if ($orderby == 'hour') { |
707 | 846 | /* |
708 | 847 | if ($globalDBdriver == 'mysql') { |
@@ -711,7 +850,9 @@ discard block |
||
711 | 850 | */ |
712 | 851 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
713 | 852 | } |
714 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
853 | + if ($orderby == 'count') { |
|
854 | + $query .= " ORDER BY hour_count DESC"; |
|
855 | + } |
|
715 | 856 | try { |
716 | 857 | $sth = $this->db->prepare($query); |
717 | 858 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -732,8 +873,12 @@ discard block |
||
732 | 873 | |
733 | 874 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
734 | 875 | global $globalStatsFilters; |
735 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
736 | - if ($year == '') $year = date('Y'); |
|
876 | + if ($filter_name == '') { |
|
877 | + $filter_name = $this->filter_name; |
|
878 | + } |
|
879 | + if ($year == '') { |
|
880 | + $year = date('Y'); |
|
881 | + } |
|
737 | 882 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
738 | 883 | if (empty($all)) { |
739 | 884 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
@@ -748,8 +893,12 @@ discard block |
||
748 | 893 | } |
749 | 894 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
750 | 895 | global $globalStatsFilters; |
751 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
752 | - if ($year == '') $year = date('Y'); |
|
896 | + if ($filter_name == '') { |
|
897 | + $filter_name = $this->filter_name; |
|
898 | + } |
|
899 | + if ($year == '') { |
|
900 | + $year = date('Y'); |
|
901 | + } |
|
753 | 902 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
754 | 903 | if (empty($all)) { |
755 | 904 | $filters = array(); |
@@ -765,8 +914,12 @@ discard block |
||
765 | 914 | } |
766 | 915 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
767 | 916 | global $globalStatsFilters; |
768 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
769 | - if ($year == '') $year = date('Y'); |
|
917 | + if ($filter_name == '') { |
|
918 | + $filter_name = $this->filter_name; |
|
919 | + } |
|
920 | + if ($year == '') { |
|
921 | + $year = date('Y'); |
|
922 | + } |
|
770 | 923 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
771 | 924 | if (empty($all)) { |
772 | 925 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
@@ -781,7 +934,9 @@ discard block |
||
781 | 934 | } |
782 | 935 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
783 | 936 | global $globalStatsFilters; |
784 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
937 | + if ($filter_name == '') { |
|
938 | + $filter_name = $this->filter_name; |
|
939 | + } |
|
785 | 940 | if ($year == '' && $month == '') { |
786 | 941 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
787 | 942 | try { |
@@ -792,7 +947,9 @@ discard block |
||
792 | 947 | } |
793 | 948 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
794 | 949 | $all = $result[0]['nb']; |
795 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
950 | + } else { |
|
951 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
952 | + } |
|
796 | 953 | if (empty($all)) { |
797 | 954 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
798 | 955 | if ($filter_name != '') { |
@@ -806,7 +963,9 @@ discard block |
||
806 | 963 | } |
807 | 964 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
808 | 965 | global $globalStatsFilters; |
809 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
966 | + if ($filter_name == '') { |
|
967 | + $filter_name = $this->filter_name; |
|
968 | + } |
|
810 | 969 | if ($year == '' && $month == '') { |
811 | 970 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
812 | 971 | try { |
@@ -817,7 +976,9 @@ discard block |
||
817 | 976 | } |
818 | 977 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
819 | 978 | $all = $result[0]['nb_airline']; |
820 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
979 | + } else { |
|
980 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
981 | + } |
|
821 | 982 | if (empty($all)) { |
822 | 983 | $filters = array(); |
823 | 984 | $filters = array('year' => $year,'month' => $month); |
@@ -832,7 +993,9 @@ discard block |
||
832 | 993 | } |
833 | 994 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
834 | 995 | global $globalStatsFilters; |
835 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
996 | + if ($filter_name == '') { |
|
997 | + $filter_name = $this->filter_name; |
|
998 | + } |
|
836 | 999 | if ($year == '' && $month == '') { |
837 | 1000 | $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
838 | 1001 | $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
@@ -860,7 +1023,9 @@ discard block |
||
860 | 1023 | } |
861 | 1024 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
862 | 1025 | global $globalStatsFilters; |
863 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1026 | + if ($filter_name == '') { |
|
1027 | + $filter_name = $this->filter_name; |
|
1028 | + } |
|
864 | 1029 | //if ($year == '') $year = date('Y'); |
865 | 1030 | if ($year == '' && $month == '') { |
866 | 1031 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -889,7 +1054,9 @@ discard block |
||
889 | 1054 | } |
890 | 1055 | |
891 | 1056 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
892 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1057 | + if ($filter_name == '') { |
|
1058 | + $filter_name = $this->filter_name; |
|
1059 | + } |
|
893 | 1060 | $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"; |
894 | 1061 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
895 | 1062 | try { |
@@ -902,7 +1069,9 @@ discard block |
||
902 | 1069 | return $all; |
903 | 1070 | } |
904 | 1071 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
905 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1072 | + if ($filter_name == '') { |
|
1073 | + $filter_name = $this->filter_name; |
|
1074 | + } |
|
906 | 1075 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
907 | 1076 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
908 | 1077 | try { |
@@ -915,7 +1084,9 @@ discard block |
||
915 | 1084 | return $all; |
916 | 1085 | } |
917 | 1086 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
918 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1087 | + if ($filter_name == '') { |
|
1088 | + $filter_name = $this->filter_name; |
|
1089 | + } |
|
919 | 1090 | global $globalArchiveMonths, $globalDBdriver; |
920 | 1091 | if ($globalDBdriver == 'mysql') { |
921 | 1092 | if ($month == '') { |
@@ -945,7 +1116,9 @@ discard block |
||
945 | 1116 | } |
946 | 1117 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
947 | 1118 | global $globalArchiveMonths, $globalDBdriver; |
948 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1119 | + if ($filter_name == '') { |
|
1120 | + $filter_name = $this->filter_name; |
|
1121 | + } |
|
949 | 1122 | if ($globalDBdriver == 'mysql') { |
950 | 1123 | $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"; |
951 | 1124 | } else { |
@@ -963,7 +1136,9 @@ discard block |
||
963 | 1136 | } |
964 | 1137 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
965 | 1138 | global $globalArchiveMonths, $globalDBdriver; |
966 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1139 | + if ($filter_name == '') { |
|
1140 | + $filter_name = $this->filter_name; |
|
1141 | + } |
|
967 | 1142 | if ($globalDBdriver == 'mysql') { |
968 | 1143 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
969 | 1144 | } else { |
@@ -980,7 +1155,9 @@ discard block |
||
980 | 1155 | } |
981 | 1156 | public function getStatsAirlineTotal($filter_name = '') { |
982 | 1157 | global $globalArchiveMonths, $globalDBdriver; |
983 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1158 | + if ($filter_name == '') { |
|
1159 | + $filter_name = $this->filter_name; |
|
1160 | + } |
|
984 | 1161 | if ($globalDBdriver == 'mysql') { |
985 | 1162 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
986 | 1163 | } else { |
@@ -997,7 +1174,9 @@ discard block |
||
997 | 1174 | } |
998 | 1175 | public function getStatsOwnerTotal($filter_name = '') { |
999 | 1176 | global $globalArchiveMonths, $globalDBdriver; |
1000 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1177 | + if ($filter_name == '') { |
|
1178 | + $filter_name = $this->filter_name; |
|
1179 | + } |
|
1001 | 1180 | if ($globalDBdriver == 'mysql') { |
1002 | 1181 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1003 | 1182 | } else { |
@@ -1014,7 +1193,9 @@ discard block |
||
1014 | 1193 | } |
1015 | 1194 | public function getStatsOwner($owner_name,$filter_name = '') { |
1016 | 1195 | global $globalArchiveMonths, $globalDBdriver; |
1017 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1196 | + if ($filter_name == '') { |
|
1197 | + $filter_name = $this->filter_name; |
|
1198 | + } |
|
1018 | 1199 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1019 | 1200 | try { |
1020 | 1201 | $sth = $this->db->prepare($query); |
@@ -1023,12 +1204,17 @@ discard block |
||
1023 | 1204 | echo "error : ".$e->getMessage(); |
1024 | 1205 | } |
1025 | 1206 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1026 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1027 | - else return 0; |
|
1207 | + if (isset($all[0]['cnt'])) { |
|
1208 | + return $all[0]['cnt']; |
|
1209 | + } else { |
|
1210 | + return 0; |
|
1211 | + } |
|
1028 | 1212 | } |
1029 | 1213 | public function getStatsPilotTotal($filter_name = '') { |
1030 | 1214 | global $globalArchiveMonths, $globalDBdriver; |
1031 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1215 | + if ($filter_name == '') { |
|
1216 | + $filter_name = $this->filter_name; |
|
1217 | + } |
|
1032 | 1218 | if ($globalDBdriver == 'mysql') { |
1033 | 1219 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
1034 | 1220 | } else { |
@@ -1045,7 +1231,9 @@ discard block |
||
1045 | 1231 | } |
1046 | 1232 | public function getStatsPilot($pilot,$filter_name = '') { |
1047 | 1233 | global $globalArchiveMonths, $globalDBdriver; |
1048 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1234 | + if ($filter_name == '') { |
|
1235 | + $filter_name = $this->filter_name; |
|
1236 | + } |
|
1049 | 1237 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1050 | 1238 | try { |
1051 | 1239 | $sth = $this->db->prepare($query); |
@@ -1054,13 +1242,18 @@ discard block |
||
1054 | 1242 | echo "error : ".$e->getMessage(); |
1055 | 1243 | } |
1056 | 1244 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1057 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1058 | - else return 0; |
|
1245 | + if (isset($all[0]['cnt'])) { |
|
1246 | + return $all[0]['cnt']; |
|
1247 | + } else { |
|
1248 | + return 0; |
|
1249 | + } |
|
1059 | 1250 | } |
1060 | 1251 | |
1061 | 1252 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1062 | 1253 | global $globalDBdriver; |
1063 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1254 | + if ($filter_name == '') { |
|
1255 | + $filter_name = $this->filter_name; |
|
1256 | + } |
|
1064 | 1257 | if ($globalDBdriver == 'mysql') { |
1065 | 1258 | $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"; |
1066 | 1259 | } else { |
@@ -1076,7 +1269,9 @@ discard block |
||
1076 | 1269 | } |
1077 | 1270 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1078 | 1271 | global $globalDBdriver; |
1079 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1272 | + if ($filter_name == '') { |
|
1273 | + $filter_name = $this->filter_name; |
|
1274 | + } |
|
1080 | 1275 | if ($globalDBdriver == 'mysql') { |
1081 | 1276 | $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"; |
1082 | 1277 | } else { |
@@ -1462,10 +1657,14 @@ discard block |
||
1462 | 1657 | $Connection = new Connection(); |
1463 | 1658 | date_default_timezone_set('UTC'); |
1464 | 1659 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
1465 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1660 | + if ($globalDebug) { |
|
1661 | + echo 'Update stats !'."\n"; |
|
1662 | + } |
|
1466 | 1663 | if (isset($last_update[0]['value'])) { |
1467 | 1664 | $last_update_day = $last_update[0]['value']; |
1468 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1665 | + } else { |
|
1666 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1667 | + } |
|
1469 | 1668 | $reset = false; |
1470 | 1669 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
1471 | 1670 | if ($globalStatsResetYear) { |
@@ -1474,42 +1673,60 @@ discard block |
||
1474 | 1673 | } |
1475 | 1674 | $Spotter = new Spotter($this->db); |
1476 | 1675 | |
1477 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1676 | + if ($globalDebug) { |
|
1677 | + echo 'Count all aircraft types...'."\n"; |
|
1678 | + } |
|
1478 | 1679 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1479 | 1680 | foreach ($alldata as $number) { |
1480 | 1681 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
1481 | 1682 | } |
1482 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1683 | + if ($globalDebug) { |
|
1684 | + echo 'Count all airlines...'."\n"; |
|
1685 | + } |
|
1483 | 1686 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1484 | 1687 | foreach ($alldata as $number) { |
1485 | 1688 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
1486 | 1689 | } |
1487 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1690 | + if ($globalDebug) { |
|
1691 | + echo 'Count all registrations...'."\n"; |
|
1692 | + } |
|
1488 | 1693 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1489 | 1694 | foreach ($alldata as $number) { |
1490 | 1695 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
1491 | 1696 | } |
1492 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1697 | + if ($globalDebug) { |
|
1698 | + echo 'Count all callsigns...'."\n"; |
|
1699 | + } |
|
1493 | 1700 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1494 | 1701 | foreach ($alldata as $number) { |
1495 | 1702 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1496 | 1703 | } |
1497 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1704 | + if ($globalDebug) { |
|
1705 | + echo 'Count all owners...'."\n"; |
|
1706 | + } |
|
1498 | 1707 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1499 | 1708 | foreach ($alldata as $number) { |
1500 | 1709 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
1501 | 1710 | } |
1502 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1711 | + if ($globalDebug) { |
|
1712 | + echo 'Count all pilots...'."\n"; |
|
1713 | + } |
|
1503 | 1714 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1504 | 1715 | foreach ($alldata as $number) { |
1505 | 1716 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
1506 | 1717 | } |
1507 | 1718 | |
1508 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1719 | + if ($globalDebug) { |
|
1720 | + echo 'Count all departure airports...'."\n"; |
|
1721 | + } |
|
1509 | 1722 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1510 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1723 | + if ($globalDebug) { |
|
1724 | + echo 'Count all detected departure airports...'."\n"; |
|
1725 | + } |
|
1511 | 1726 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1512 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1727 | + if ($globalDebug) { |
|
1728 | + echo 'Order departure airports...'."\n"; |
|
1729 | + } |
|
1513 | 1730 | $alldata = array(); |
1514 | 1731 | |
1515 | 1732 | foreach ($pall as $value) { |
@@ -1520,7 +1737,9 @@ discard block |
||
1520 | 1737 | $icao = $value['airport_departure_icao']; |
1521 | 1738 | if (isset($alldata[$icao])) { |
1522 | 1739 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1523 | - } else $alldata[$icao] = $value; |
|
1740 | + } else { |
|
1741 | + $alldata[$icao] = $value; |
|
1742 | + } |
|
1524 | 1743 | } |
1525 | 1744 | $count = array(); |
1526 | 1745 | foreach ($alldata as $key => $row) { |
@@ -1530,11 +1749,17 @@ discard block |
||
1530 | 1749 | foreach ($alldata as $number) { |
1531 | 1750 | 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); |
1532 | 1751 | } |
1533 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1752 | + if ($globalDebug) { |
|
1753 | + echo 'Count all arrival airports...'."\n"; |
|
1754 | + } |
|
1534 | 1755 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1535 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1756 | + if ($globalDebug) { |
|
1757 | + echo 'Count all detected arrival airports...'."\n"; |
|
1758 | + } |
|
1536 | 1759 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1537 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1760 | + if ($globalDebug) { |
|
1761 | + echo 'Order arrival airports...'."\n"; |
|
1762 | + } |
|
1538 | 1763 | $alldata = array(); |
1539 | 1764 | foreach ($pall as $value) { |
1540 | 1765 | $icao = $value['airport_arrival_icao']; |
@@ -1544,7 +1769,9 @@ discard block |
||
1544 | 1769 | $icao = $value['airport_arrival_icao']; |
1545 | 1770 | if (isset($alldata[$icao])) { |
1546 | 1771 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1547 | - } else $alldata[$icao] = $value; |
|
1772 | + } else { |
|
1773 | + $alldata[$icao] = $value; |
|
1774 | + } |
|
1548 | 1775 | } |
1549 | 1776 | $count = array(); |
1550 | 1777 | foreach ($alldata as $key => $row) { |
@@ -1555,7 +1782,9 @@ discard block |
||
1555 | 1782 | 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); |
1556 | 1783 | } |
1557 | 1784 | if ($Connection->tableExists('countries')) { |
1558 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1785 | + if ($globalDebug) { |
|
1786 | + echo 'Count all flights by countries...'."\n"; |
|
1787 | + } |
|
1559 | 1788 | $SpotterArchive = new SpotterArchive(); |
1560 | 1789 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1561 | 1790 | foreach ($alldata as $number) { |
@@ -1567,46 +1796,66 @@ discard block |
||
1567 | 1796 | // Add by month using getstat if month finish... |
1568 | 1797 | |
1569 | 1798 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1570 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1799 | + if ($globalDebug) { |
|
1800 | + echo 'Count all flights by months...'."\n"; |
|
1801 | + } |
|
1571 | 1802 | $Spotter = new Spotter($this->db); |
1572 | 1803 | $alldata = $Spotter->countAllMonths(); |
1573 | 1804 | $lastyear = false; |
1574 | 1805 | foreach ($alldata as $number) { |
1575 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1806 | + if ($number['year_name'] != date('Y')) { |
|
1807 | + $lastyear = true; |
|
1808 | + } |
|
1576 | 1809 | $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']))); |
1577 | 1810 | } |
1578 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1811 | + if ($globalDebug) { |
|
1812 | + echo 'Count all military flights by months...'."\n"; |
|
1813 | + } |
|
1579 | 1814 | $alldata = $Spotter->countAllMilitaryMonths(); |
1580 | 1815 | foreach ($alldata as $number) { |
1581 | 1816 | $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']))); |
1582 | 1817 | } |
1583 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1818 | + if ($globalDebug) { |
|
1819 | + echo 'Count all owners by months...'."\n"; |
|
1820 | + } |
|
1584 | 1821 | $alldata = $Spotter->countAllMonthsOwners(); |
1585 | 1822 | foreach ($alldata as $number) { |
1586 | 1823 | $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']))); |
1587 | 1824 | } |
1588 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1825 | + if ($globalDebug) { |
|
1826 | + echo 'Count all pilots by months...'."\n"; |
|
1827 | + } |
|
1589 | 1828 | $alldata = $Spotter->countAllMonthsPilots(); |
1590 | 1829 | foreach ($alldata as $number) { |
1591 | 1830 | $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']))); |
1592 | 1831 | } |
1593 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1832 | + if ($globalDebug) { |
|
1833 | + echo 'Count all airlines by months...'."\n"; |
|
1834 | + } |
|
1594 | 1835 | $alldata = $Spotter->countAllMonthsAirlines(); |
1595 | 1836 | foreach ($alldata as $number) { |
1596 | 1837 | $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']))); |
1597 | 1838 | } |
1598 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1839 | + if ($globalDebug) { |
|
1840 | + echo 'Count all aircrafts by months...'."\n"; |
|
1841 | + } |
|
1599 | 1842 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1600 | 1843 | foreach ($alldata as $number) { |
1601 | 1844 | $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']))); |
1602 | 1845 | } |
1603 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1846 | + if ($globalDebug) { |
|
1847 | + echo 'Count all real arrivals by months...'."\n"; |
|
1848 | + } |
|
1604 | 1849 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1605 | 1850 | foreach ($alldata as $number) { |
1606 | 1851 | $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']))); |
1607 | 1852 | } |
1608 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1609 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1853 | + if ($globalDebug) { |
|
1854 | + echo 'Airports data...'."\n"; |
|
1855 | + } |
|
1856 | + if ($globalDebug) { |
|
1857 | + echo '...Departure'."\n"; |
|
1858 | + } |
|
1610 | 1859 | $this->deleteStatAirport('daily'); |
1611 | 1860 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1612 | 1861 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1727,44 +1976,62 @@ discard block |
||
1727 | 1976 | // Count by airlines |
1728 | 1977 | echo '--- Stats by airlines ---'."\n"; |
1729 | 1978 | if ($Connection->tableExists('countries')) { |
1730 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
1979 | + if ($globalDebug) { |
|
1980 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
1981 | + } |
|
1731 | 1982 | $SpotterArchive = new SpotterArchive(); |
1732 | 1983 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
1733 | 1984 | foreach ($alldata as $number) { |
1734 | 1985 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
1735 | 1986 | } |
1736 | 1987 | } |
1737 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
1988 | + if ($globalDebug) { |
|
1989 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
1990 | + } |
|
1738 | 1991 | $Spotter = new Spotter($this->db); |
1739 | 1992 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1740 | 1993 | foreach ($alldata as $number) { |
1741 | 1994 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
1742 | 1995 | } |
1743 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1996 | + if ($globalDebug) { |
|
1997 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1998 | + } |
|
1744 | 1999 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1745 | 2000 | foreach ($alldata as $number) { |
1746 | 2001 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
1747 | 2002 | } |
1748 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
2003 | + if ($globalDebug) { |
|
2004 | + echo 'Count all callsigns by airlines...'."\n"; |
|
2005 | + } |
|
1749 | 2006 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1750 | 2007 | foreach ($alldata as $number) { |
1751 | 2008 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1752 | 2009 | } |
1753 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
2010 | + if ($globalDebug) { |
|
2011 | + echo 'Count all owners by airlines...'."\n"; |
|
2012 | + } |
|
1754 | 2013 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1755 | 2014 | foreach ($alldata as $number) { |
1756 | 2015 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
1757 | 2016 | } |
1758 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
2017 | + if ($globalDebug) { |
|
2018 | + echo 'Count all pilots by airlines...'."\n"; |
|
2019 | + } |
|
1759 | 2020 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1760 | 2021 | foreach ($alldata as $number) { |
1761 | 2022 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
1762 | 2023 | } |
1763 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
2024 | + if ($globalDebug) { |
|
2025 | + echo 'Count all departure airports by airlines...'."\n"; |
|
2026 | + } |
|
1764 | 2027 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1765 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
2028 | + if ($globalDebug) { |
|
2029 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
2030 | + } |
|
1766 | 2031 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1767 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
2032 | + if ($globalDebug) { |
|
2033 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
2034 | + } |
|
1768 | 2035 | //$alldata = array(); |
1769 | 2036 | foreach ($dall as $value) { |
1770 | 2037 | $icao = $value['airport_departure_icao']; |
@@ -1785,11 +2052,17 @@ discard block |
||
1785 | 2052 | foreach ($alldata as $number) { |
1786 | 2053 | 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); |
1787 | 2054 | } |
1788 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
2055 | + if ($globalDebug) { |
|
2056 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
2057 | + } |
|
1789 | 2058 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1790 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2059 | + if ($globalDebug) { |
|
2060 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2061 | + } |
|
1791 | 2062 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1792 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
2063 | + if ($globalDebug) { |
|
2064 | + echo 'Order arrival airports by airlines...'."\n"; |
|
2065 | + } |
|
1793 | 2066 | //$alldata = array(); |
1794 | 2067 | foreach ($dall as $value) { |
1795 | 2068 | $icao = $value['airport_arrival_icao']; |
@@ -1808,37 +2081,53 @@ discard block |
||
1808 | 2081 | } |
1809 | 2082 | $alldata = $pall; |
1810 | 2083 | foreach ($alldata as $number) { |
1811 | - 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); |
|
2084 | + if ($number['airline_icao'] != '') { |
|
2085 | + 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); |
|
2086 | + } |
|
2087 | + } |
|
2088 | + if ($globalDebug) { |
|
2089 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1812 | 2090 | } |
1813 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1814 | 2091 | $Spotter = new Spotter($this->db); |
1815 | 2092 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1816 | 2093 | $lastyear = false; |
1817 | 2094 | foreach ($alldata as $number) { |
1818 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2095 | + if ($number['year_name'] != date('Y')) { |
|
2096 | + $lastyear = true; |
|
2097 | + } |
|
1819 | 2098 | $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']); |
1820 | 2099 | } |
1821 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
2100 | + if ($globalDebug) { |
|
2101 | + echo 'Count all owners by months by airlines...'."\n"; |
|
2102 | + } |
|
1822 | 2103 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1823 | 2104 | foreach ($alldata as $number) { |
1824 | 2105 | $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']); |
1825 | 2106 | } |
1826 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
2107 | + if ($globalDebug) { |
|
2108 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
2109 | + } |
|
1827 | 2110 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1828 | 2111 | foreach ($alldata as $number) { |
1829 | 2112 | $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']); |
1830 | 2113 | } |
1831 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2114 | + if ($globalDebug) { |
|
2115 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2116 | + } |
|
1832 | 2117 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1833 | 2118 | foreach ($alldata as $number) { |
1834 | 2119 | $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']); |
1835 | 2120 | } |
1836 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2121 | + if ($globalDebug) { |
|
2122 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2123 | + } |
|
1837 | 2124 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1838 | 2125 | foreach ($alldata as $number) { |
1839 | 2126 | $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']); |
1840 | 2127 | } |
1841 | - if ($globalDebug) echo '...Departure'."\n"; |
|
2128 | + if ($globalDebug) { |
|
2129 | + echo '...Departure'."\n"; |
|
2130 | + } |
|
1842 | 2131 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1843 | 2132 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1844 | 2133 | foreach ($dall as $value) { |
@@ -1861,7 +2150,9 @@ discard block |
||
1861 | 2150 | foreach ($alldata as $number) { |
1862 | 2151 | $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']); |
1863 | 2152 | } |
1864 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2153 | + if ($globalDebug) { |
|
2154 | + echo '...Arrival'."\n"; |
|
2155 | + } |
|
1865 | 2156 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1866 | 2157 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1867 | 2158 | foreach ($dall as $value) { |
@@ -1885,13 +2176,19 @@ discard block |
||
1885 | 2176 | $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']); |
1886 | 2177 | } |
1887 | 2178 | |
1888 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1889 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2179 | + if ($globalDebug) { |
|
2180 | + echo 'Flights data...'."\n"; |
|
2181 | + } |
|
2182 | + if ($globalDebug) { |
|
2183 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2184 | + } |
|
1890 | 2185 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1891 | 2186 | foreach ($alldata as $number) { |
1892 | 2187 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1893 | 2188 | } |
1894 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2189 | + if ($globalDebug) { |
|
2190 | + echo '-> countAllDates...'."\n"; |
|
2191 | + } |
|
1895 | 2192 | //$previousdata = $this->countAllDatesByAirlines(); |
1896 | 2193 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1897 | 2194 | $values = array(); |
@@ -1904,7 +2201,9 @@ discard block |
||
1904 | 2201 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1905 | 2202 | } |
1906 | 2203 | |
1907 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2204 | + if ($globalDebug) { |
|
2205 | + echo '-> countAllHours...'."\n"; |
|
2206 | + } |
|
1908 | 2207 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1909 | 2208 | foreach ($alldata as $number) { |
1910 | 2209 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
@@ -1912,14 +2211,18 @@ discard block |
||
1912 | 2211 | |
1913 | 2212 | |
1914 | 2213 | // Stats by filters |
1915 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2214 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2215 | + $globalStatsFilters = array(); |
|
2216 | + } |
|
1916 | 2217 | foreach ($globalStatsFilters as $name => $filter) { |
1917 | 2218 | //$filter_name = $filter['name']; |
1918 | 2219 | $filter_name = $name; |
1919 | 2220 | $reset = false; |
1920 | 2221 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
1921 | 2222 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
1922 | - if ($globalDebug) echo '! Delete stats for filter '.$filter_name.' ---'."\n"; |
|
2223 | + if ($globalDebug) { |
|
2224 | + echo '! Delete stats for filter '.$filter_name.' ---'."\n"; |
|
2225 | + } |
|
1923 | 2226 | $this->deleteOldStats($filter_name); |
1924 | 2227 | unset($last_update); |
1925 | 2228 | } |
@@ -1938,7 +2241,9 @@ discard block |
||
1938 | 2241 | |
1939 | 2242 | |
1940 | 2243 | // Count by filter |
1941 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2244 | + if ($globalDebug) { |
|
2245 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2246 | + } |
|
1942 | 2247 | $Spotter = new Spotter($this->db); |
1943 | 2248 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
1944 | 2249 | foreach ($alldata as $number) { |
@@ -1975,7 +2280,9 @@ discard block |
||
1975 | 2280 | $icao = $value['airport_departure_icao']; |
1976 | 2281 | if (isset($alldata[$icao])) { |
1977 | 2282 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1978 | - } else $alldata[$icao] = $value; |
|
2283 | + } else { |
|
2284 | + $alldata[$icao] = $value; |
|
2285 | + } |
|
1979 | 2286 | } |
1980 | 2287 | $count = array(); |
1981 | 2288 | foreach ($alldata as $key => $row) { |
@@ -1996,7 +2303,9 @@ discard block |
||
1996 | 2303 | $icao = $value['airport_arrival_icao']; |
1997 | 2304 | if (isset($alldata[$icao])) { |
1998 | 2305 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1999 | - } else $alldata[$icao] = $value; |
|
2306 | + } else { |
|
2307 | + $alldata[$icao] = $value; |
|
2308 | + } |
|
2000 | 2309 | } |
2001 | 2310 | $count = array(); |
2002 | 2311 | foreach ($alldata as $key => $row) { |
@@ -2010,7 +2319,9 @@ discard block |
||
2010 | 2319 | $alldata = $Spotter->countAllMonths($filter); |
2011 | 2320 | $lastyear = false; |
2012 | 2321 | foreach ($alldata as $number) { |
2013 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2322 | + if ($number['year_name'] != date('Y')) { |
|
2323 | + $lastyear = true; |
|
2324 | + } |
|
2014 | 2325 | $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); |
2015 | 2326 | } |
2016 | 2327 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | if (isset($filter[0]['source'])) { |
27 | 27 | $filters = array_merge($filters,$filter); |
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) { |
|
30 | + $filter = array_merge($filter,$globalFilter); |
|
31 | + } |
|
30 | 32 | $filter_query_join = ''; |
31 | 33 | $filter_query_where = ''; |
32 | 34 | foreach($filters as $flt) { |
@@ -99,8 +101,11 @@ discard block |
||
99 | 101 | } |
100 | 102 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
101 | 103 | } |
102 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
103 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
104 | + if ($filter_query_where == '' && $where) { |
|
105 | + $filter_query_where = ' WHERE'; |
|
106 | + } elseif ($filter_query_where != '' && $and) { |
|
107 | + $filter_query_where .= ' AND'; |
|
108 | + } |
|
104 | 109 | if ($filter_query_where != '') { |
105 | 110 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
106 | 111 | } |
@@ -114,10 +119,17 @@ discard block |
||
114 | 119 | if ($over_country == '') { |
115 | 120 | $Spotter = new Spotter($this->db); |
116 | 121 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
117 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
118 | - else $country = ''; |
|
119 | - } else $country = $over_country; |
|
120 | - if ($airline_type === NULL) $airline_type =''; |
|
122 | + if (!empty($data_country)) { |
|
123 | + $country = $data_country['iso2']; |
|
124 | + } else { |
|
125 | + $country = ''; |
|
126 | + } |
|
127 | + } else { |
|
128 | + $country = $over_country; |
|
129 | + } |
|
130 | + if ($airline_type === NULL) { |
|
131 | + $airline_type =''; |
|
132 | + } |
|
121 | 133 | |
122 | 134 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
123 | 135 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -620,7 +632,9 @@ discard block |
||
620 | 632 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
621 | 633 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
622 | 634 | $translate = $Translation->ident2icao($q_item); |
623 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
635 | + if ($translate != $q_item) { |
|
636 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
637 | + } |
|
624 | 638 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
625 | 639 | $additional_query .= ")"; |
626 | 640 | } |
@@ -838,7 +852,9 @@ discard block |
||
838 | 852 | date_default_timezone_set($globalTimezone); |
839 | 853 | $datetime = new DateTime(); |
840 | 854 | $offset = $datetime->format('P'); |
841 | - } else $offset = '+00:00'; |
|
855 | + } else { |
|
856 | + $offset = '+00:00'; |
|
857 | + } |
|
842 | 858 | |
843 | 859 | |
844 | 860 | if ($date_array[1] != "") |
@@ -1114,9 +1130,13 @@ discard block |
||
1114 | 1130 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1115 | 1131 | } |
1116 | 1132 | } |
1117 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1133 | + if ($sincedate != '') { |
|
1134 | + $query .= "AND date > '".$sincedate."' "; |
|
1135 | + } |
|
1118 | 1136 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1119 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1137 | + if ($limit) { |
|
1138 | + $query .= " LIMIT 0,10"; |
|
1139 | + } |
|
1120 | 1140 | |
1121 | 1141 | |
1122 | 1142 | $sth = $this->db->prepare($query); |
@@ -1160,9 +1180,13 @@ discard block |
||
1160 | 1180 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1161 | 1181 | } |
1162 | 1182 | } |
1163 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1183 | + if ($sincedate != '') { |
|
1184 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1185 | + } |
|
1164 | 1186 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1165 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1187 | + if ($limit) { |
|
1188 | + $query .= " LIMIT 0,10"; |
|
1189 | + } |
|
1166 | 1190 | |
1167 | 1191 | |
1168 | 1192 | $sth = $this->db->prepare($query); |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | if (isset($filter[0]['source'])) { |
30 | 30 | $filters = array_merge($filters,$filter); |
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
33 | 35 | $filter_query_join = ''; |
34 | 36 | $filter_query_where = ''; |
35 | 37 | foreach($filters as $flt) { |
@@ -111,8 +113,11 @@ discard block |
||
111 | 113 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
112 | 114 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
113 | 115 | } |
114 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
115 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
116 | + if ($filter_query_where == '' && $where) { |
|
117 | + $filter_query_where = ' WHERE'; |
|
118 | + } elseif ($filter_query_where != '' && $and) { |
|
119 | + $filter_query_where .= ' AND'; |
|
120 | + } |
|
116 | 121 | if ($filter_query_where != '') { |
117 | 122 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
118 | 123 | } |
@@ -154,7 +159,9 @@ discard block |
||
154 | 159 | } |
155 | 160 | } |
156 | 161 | |
157 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
162 | + if (!isset($globalLiveInterval)) { |
|
163 | + $globalLiveInterval = '200'; |
|
164 | + } |
|
158 | 165 | if ($globalDBdriver == 'mysql') { |
159 | 166 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
160 | 167 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -179,7 +186,9 @@ discard block |
||
179 | 186 | |
180 | 187 | $filter_query = $this->getFilter($filter,true,true); |
181 | 188 | |
182 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
189 | + if (!isset($globalLiveInterval)) { |
|
190 | + $globalLiveInterval = '200'; |
|
191 | + } |
|
183 | 192 | if ($globalDBdriver == 'mysql') { |
184 | 193 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
185 | 194 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -236,7 +245,9 @@ discard block |
||
236 | 245 | |
237 | 246 | $filter_query = $this->getFilter($filter,true,true); |
238 | 247 | |
239 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
248 | + if (!isset($globalLiveInterval)) { |
|
249 | + $globalLiveInterval = '200'; |
|
250 | + } |
|
240 | 251 | if ($globalDBdriver == 'mysql') { |
241 | 252 | /* |
242 | 253 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -280,7 +291,9 @@ discard block |
||
280 | 291 | global $globalDBdriver, $globalLiveInterval; |
281 | 292 | $filter_query = $this->getFilter($filter,true,true); |
282 | 293 | |
283 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
294 | + if (!isset($globalLiveInterval)) { |
|
295 | + $globalLiveInterval = '200'; |
|
296 | + } |
|
284 | 297 | if ($globalDBdriver == 'mysql') { |
285 | 298 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
286 | 299 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -310,7 +323,9 @@ discard block |
||
310 | 323 | { |
311 | 324 | global $globalDBdriver, $globalLiveInterval; |
312 | 325 | $Spotter = new Spotter($this->db); |
313 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
326 | + if (!isset($globalLiveInterval)) { |
|
327 | + $globalLiveInterval = '200'; |
|
328 | + } |
|
314 | 329 | $filter_query = $this->getFilter($filter); |
315 | 330 | |
316 | 331 | if (is_array($coord)) { |
@@ -318,7 +333,9 @@ discard block |
||
318 | 333 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
319 | 334 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
320 | 335 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
321 | - } else return array(); |
|
336 | + } else { |
|
337 | + return array(); |
|
338 | + } |
|
322 | 339 | if ($globalDBdriver == 'mysql') { |
323 | 340 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
324 | 341 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -509,11 +526,15 @@ discard block |
||
509 | 526 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
510 | 527 | if ($globalDBdriver == 'mysql') { |
511 | 528 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
512 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
529 | + if ($liveinterval) { |
|
530 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
531 | + } |
|
513 | 532 | $query .= ' ORDER BY date'; |
514 | 533 | } else { |
515 | 534 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
516 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
535 | + if ($liveinterval) { |
|
536 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
537 | + } |
|
517 | 538 | $query .= ' ORDER BY date'; |
518 | 539 | } |
519 | 540 | |
@@ -608,7 +629,9 @@ discard block |
||
608 | 629 | $i++; |
609 | 630 | $j++; |
610 | 631 | if ($j == 30) { |
611 | - if ($globalDebug) echo "."; |
|
632 | + if ($globalDebug) { |
|
633 | + echo "."; |
|
634 | + } |
|
612 | 635 | try { |
613 | 636 | |
614 | 637 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -915,7 +938,9 @@ discard block |
||
915 | 938 | { |
916 | 939 | return false; |
917 | 940 | } |
918 | - } else return ''; |
|
941 | + } else { |
|
942 | + return ''; |
|
943 | + } |
|
919 | 944 | |
920 | 945 | if ($longitude != '') |
921 | 946 | { |
@@ -923,7 +948,9 @@ discard block |
||
923 | 948 | { |
924 | 949 | return false; |
925 | 950 | } |
926 | - } else return ''; |
|
951 | + } else { |
|
952 | + return ''; |
|
953 | + } |
|
927 | 954 | |
928 | 955 | if ($waypoints != '') |
929 | 956 | { |
@@ -939,7 +966,9 @@ discard block |
||
939 | 966 | { |
940 | 967 | return false; |
941 | 968 | } |
942 | - } else $altitude = 0; |
|
969 | + } else { |
|
970 | + $altitude = 0; |
|
971 | + } |
|
943 | 972 | |
944 | 973 | if ($heading != '') |
945 | 974 | { |
@@ -947,7 +976,9 @@ discard block |
||
947 | 976 | { |
948 | 977 | return false; |
949 | 978 | } |
950 | - } else $heading = 0; |
|
979 | + } else { |
|
980 | + $heading = 0; |
|
981 | + } |
|
951 | 982 | |
952 | 983 | if ($groundspeed != '') |
953 | 984 | { |
@@ -955,9 +986,13 @@ discard block |
||
955 | 986 | { |
956 | 987 | return false; |
957 | 988 | } |
958 | - } else $groundspeed = 0; |
|
989 | + } else { |
|
990 | + $groundspeed = 0; |
|
991 | + } |
|
959 | 992 | date_default_timezone_set('UTC'); |
960 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
993 | + if ($date == '') { |
|
994 | + $date = date("Y-m-d H:i:s", time()); |
|
995 | + } |
|
961 | 996 | |
962 | 997 | |
963 | 998 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1001,10 +1036,18 @@ discard block |
||
1001 | 1036 | $arrival_airport_country = ''; |
1002 | 1037 | |
1003 | 1038 | |
1004 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1005 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1006 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1007 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1039 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1040 | + $squawk = NULL; |
|
1041 | + } |
|
1042 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1043 | + $verticalrate = NULL; |
|
1044 | + } |
|
1045 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1046 | + $groundspeed = 0; |
|
1047 | + } |
|
1048 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1049 | + $heading = 0; |
|
1050 | + } |
|
1008 | 1051 | |
1009 | 1052 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
1010 | 1053 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -1018,10 +1061,14 @@ discard block |
||
1018 | 1061 | return "error : ".$e->getMessage(); |
1019 | 1062 | } |
1020 | 1063 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1021 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1064 | + if ($globalDebug) { |
|
1065 | + echo '(Add to SBS archive : '; |
|
1066 | + } |
|
1022 | 1067 | $SpotterArchive = new SpotterArchive($this->db); |
1023 | 1068 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
1024 | - if ($globalDebug) echo $result.')'; |
|
1069 | + if ($globalDebug) { |
|
1070 | + echo $result.')'; |
|
1071 | + } |
|
1025 | 1072 | } |
1026 | 1073 | return "success"; |
1027 | 1074 |