@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | require_once('header.php'); |
8 | 8 | |
9 | 9 | //calculuation for the pagination |
10 | -if(!isset($_GET['limit'])) |
|
10 | +if (!isset($_GET['limit'])) |
|
11 | 11 | { |
12 | 12 | $limit_start = 0; |
13 | 13 | $limit_end = 25; |
14 | 14 | $absolute_difference = 25; |
15 | -} else { |
|
15 | +} else { |
|
16 | 16 | $limit_explode = explode(",", $_GET['limit']); |
17 | 17 | $limit_start = $limit_explode[0]; |
18 | 18 | $limit_end = $limit_explode[1]; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | print '<div class="table column">'; |
36 | 36 | print '<p>'._("This page shows all upcoming flights within the next 3 hours calculated using historical data, based on the number of same flights on the current day of the week & current time. This does not take into account real-time delays and other factors.").'</p>'; |
37 | 37 | |
38 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
38 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
39 | 39 | if ($sort != '') { |
40 | 40 | $spotter_array = $Spotter->getUpcomingFlights($limit_start.",".$absolute_difference, $sort); |
41 | 41 | } else { |
@@ -12,7 +12,7 @@ |
||
12 | 12 | $limit_start = 0; |
13 | 13 | $limit_end = 25; |
14 | 14 | $absolute_difference = 25; |
15 | -} else { |
|
15 | +} else { |
|
16 | 16 | $limit_explode = explode(",", $_GET['limit']); |
17 | 17 | $limit_start = $limit_explode[0]; |
18 | 18 | $limit_end = $limit_explode[1]; |
@@ -6,8 +6,11 @@ |
||
6 | 6 | $Spotter = new Spotter(); |
7 | 7 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
8 | 8 | $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
9 | -if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
10 | -else $spotter_array = ''; |
|
9 | +if (isset($_GET['date'])) { |
|
10 | + $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
11 | +} else { |
|
12 | + $spotter_array = ''; |
|
13 | +} |
|
11 | 14 | |
12 | 15 | if (!empty($spotter_array)) |
13 | 16 | { |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | |
6 | 6 | $Spotter = new Spotter(); |
7 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
8 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
9 | -if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
7 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
8 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
9 | +if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
10 | 10 | else $spotter_array = ''; |
11 | 11 | |
12 | 12 | if (!empty($spotter_array)) |
13 | 13 | { |
14 | - $title = sprintf(_("Most Common Airlines on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
14 | + $title = sprintf(_("Most Common Airlines on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
15 | 15 | |
16 | 16 | require_once('header.php'); |
17 | 17 | print '<div class="select-item">'; |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
30 | 30 | print '<br />'; |
31 | 31 | print '<div class="info column">'; |
32 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
32 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
33 | 33 | print '</div>'; |
34 | 34 | |
35 | 35 | include('date-sub-menu.php'); |
36 | 36 | print '<div class="column">'; |
37 | 37 | print '<h2>'._("Most Common Airlines").'</h2>'; |
38 | - print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
38 | + print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
39 | 39 | |
40 | 40 | $airline_array = $Spotter->countAllAirlinesByDate($date); |
41 | 41 | if (!empty($airline_array)) |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | print '</thead>'; |
53 | 53 | print '<tbody>'; |
54 | 54 | $i = 1; |
55 | - foreach($airline_array as $airline_item) |
|
55 | + foreach ($airline_array as $airline_item) |
|
56 | 56 | { |
57 | 57 | print '<tr>'; |
58 | 58 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -8,8 +8,11 @@ |
||
8 | 8 | $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
9 | 9 | |
10 | 10 | $Spotter = new Spotter(); |
11 | -if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
12 | -else $spotter_array = array(); |
|
11 | +if (isset($_GET['date'])) { |
|
12 | + $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
13 | +} else { |
|
14 | + $spotter_array = array(); |
|
15 | +} |
|
13 | 16 | |
14 | 17 | if (!empty($spotter_array)) |
15 | 18 | { |
@@ -3,16 +3,16 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
8 | 8 | |
9 | 9 | $Spotter = new Spotter(); |
10 | -if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
10 | +if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
11 | 11 | else $spotter_array = array(); |
12 | 12 | |
13 | 13 | if (!empty($spotter_array)) |
14 | 14 | { |
15 | - $title = sprintf(_("Most Common Airlines by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
15 | + $title = sprintf(_("Most Common Airlines by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
16 | 16 | require_once('header.php'); |
17 | 17 | print '<div class="select-item">'; |
18 | 18 | print '<form action="'.$globalURL.'/date" method="post" class="form-inline">'; |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
30 | 30 | print '<br />'; |
31 | 31 | print '<div class="info column">'; |
32 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
32 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
33 | 33 | print '</div>'; |
34 | 34 | |
35 | 35 | include('date-sub-menu.php'); |
36 | 36 | print '<div class="column">'; |
37 | 37 | print '<h2>'._("Most Common Airlines by Country").'</h2>'; |
38 | - print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
38 | + print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
39 | 39 | |
40 | 40 | $airline_array = $Spotter->countAllAirlineCountriesByDate($date); |
41 | 41 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>'; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | var data = google.visualization.arrayToDataTable([ |
48 | 48 | ["'._("Country").'", "'._("# of times").'"], '; |
49 | 49 | $country_data = ''; |
50 | - foreach($airline_array as $airline_item) |
|
50 | + foreach ($airline_array as $airline_item) |
|
51 | 51 | { |
52 | 52 | $country_data .= '[ "'.$airline_item['airline_country'].'",'.$airline_item['airline_country_count'].'],'; |
53 | 53 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | print '</thead>'; |
82 | 82 | print '<tbody>'; |
83 | 83 | $i = 1; |
84 | - foreach($airline_array as $airline_item) |
|
84 | + foreach ($airline_array as $airline_item) |
|
85 | 85 | { |
86 | 86 | print '<tr>'; |
87 | 87 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -38,8 +38,12 @@ |
||
38 | 38 | if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) { |
39 | 39 | include('table-output.php'); |
40 | 40 | print '<div class="pagination">'; |
41 | - if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
42 | - if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
41 | + if ($limit_previous_1 >= 0) { |
|
42 | + print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
43 | + } |
|
44 | + if ($spotter_array[0]['query_number_rows'] == $absolute_difference) { |
|
45 | + print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
46 | + } |
|
43 | 47 | print '</div>'; |
44 | 48 | } |
45 | 49 | print '</div>'; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | $page_url = $globalURL.'/accident-latest'; |
10 | 10 | |
11 | -if(!isset($_GET['limit'])) |
|
11 | +if (!isset($_GET['limit'])) |
|
12 | 12 | { |
13 | 13 | $limit_start = 0; |
14 | 14 | $limit_end = 25; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | print '<div class="table column">'; |
36 | 36 | print '<p>'._("The table below shows the latest Accidents.").'</p>'; |
37 | -$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'accident'); |
|
37 | +$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'accident'); |
|
38 | 38 | //print_r($spotter_array); |
39 | 39 | if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) { |
40 | 40 | include('table-output.php'); |
@@ -365,7 +365,9 @@ discard block |
||
365 | 365 | if (isset($globalTimezone)) |
366 | 366 | { |
367 | 367 | date_default_timezone_set($globalTimezone); |
368 | - } else date_default_timezone_set('UTC'); |
|
368 | + } else { |
|
369 | + date_default_timezone_set('UTC'); |
|
370 | + } |
|
369 | 371 | if ($showSpecial === true) |
370 | 372 | { |
371 | 373 | print '<tr class="special">'."\n"; |
@@ -384,8 +386,9 @@ discard block |
||
384 | 386 | print '<td class="aircraft_thumbnail">'."\n"; |
385 | 387 | |
386 | 388 | if ($spotter_item['image_source'] == 'planespotters') { |
387 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
388 | - else { |
|
389 | + if ($spotter_item['image_source_website'] != '') { |
|
390 | + $image_src = $spotter_item['image_source_website']; |
|
391 | + } else { |
|
389 | 392 | $planespotter_url_array = explode("_", $spotter_item['image']); |
390 | 393 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
391 | 394 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -398,7 +401,9 @@ discard block |
||
398 | 401 | } else { |
399 | 402 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
400 | 403 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
401 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
404 | + } else { |
|
405 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
406 | + } |
|
402 | 407 | if (isset($spotter_item['airline_name'])) { |
403 | 408 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
404 | 409 | } else { |
@@ -420,8 +425,9 @@ discard block |
||
420 | 425 | print '<td class="aircraft_thumbnail">'."\n"; |
421 | 426 | //print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
422 | 427 | if ($spotter_item['image_source'] == 'planespotters') { |
423 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
424 | - else { |
|
428 | + if ($spotter_item['image_source_website'] != '') { |
|
429 | + $image_src = $spotter_item['image_source_website']; |
|
430 | + } else { |
|
425 | 431 | $planespotter_url_array = explode("_", $spotter_array[0]['image']); |
426 | 432 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
427 | 433 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -438,7 +444,9 @@ discard block |
||
438 | 444 | } else { |
439 | 445 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
440 | 446 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
441 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
447 | + } else { |
|
448 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
449 | + } |
|
442 | 450 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
443 | 451 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
444 | 452 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
@@ -525,15 +533,21 @@ discard block |
||
525 | 533 | if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) { |
526 | 534 | if ($spotter_item['departure_airport_time'] > 2460) { |
527 | 535 | $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
528 | - } else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
536 | + } else { |
|
537 | + $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
538 | + } |
|
529 | 539 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
530 | 540 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
531 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
541 | + } else { |
|
542 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
543 | + } |
|
532 | 544 | print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n"; |
533 | 545 | } elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') { |
534 | 546 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
535 | 547 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
536 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
548 | + } else { |
|
549 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
550 | + } |
|
537 | 551 | print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n"; |
538 | 552 | } elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
539 | 553 | if ($spotter_item['departure_airport_time'] > 2460) { |
@@ -555,7 +569,9 @@ discard block |
||
555 | 569 | $longitude = $spotter_item['longitude']; |
556 | 570 | } |
557 | 571 | $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
558 | - } else $distance = ''; |
|
572 | + } else { |
|
573 | + $distance = ''; |
|
574 | + } |
|
559 | 575 | if ($distance != '') { |
560 | 576 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
561 | 577 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -580,7 +596,9 @@ discard block |
||
580 | 596 | } else { |
581 | 597 | if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) { |
582 | 598 | print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n"; |
583 | - if (!isset($Spotter)) $Spotter = new Spotter(); |
|
599 | + if (!isset($Spotter)) { |
|
600 | + $Spotter = new Spotter(); |
|
601 | + } |
|
584 | 602 | $arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']); |
585 | 603 | print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n"; |
586 | 604 | print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n"; |
@@ -596,20 +614,28 @@ discard block |
||
596 | 614 | if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) { |
597 | 615 | if ($spotter_item['arrival_airport_time'] > 2460) { |
598 | 616 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
599 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
617 | + } else { |
|
618 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
619 | + } |
|
600 | 620 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
601 | 621 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
602 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
622 | + } else { |
|
623 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
624 | + } |
|
603 | 625 | print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n"; |
604 | 626 | } elseif (isset($spotter_item['real_arrival_airport_time'])) { |
605 | 627 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
606 | 628 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
607 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
629 | + } else { |
|
630 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
631 | + } |
|
608 | 632 | print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n"; |
609 | 633 | } elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
610 | 634 | if ($spotter_item['arrival_airport_time'] > 2460) { |
611 | 635 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
612 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
636 | + } else { |
|
637 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
638 | + } |
|
613 | 639 | print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n"; |
614 | 640 | } |
615 | 641 | if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
@@ -622,7 +648,9 @@ discard block |
||
622 | 648 | $longitude = $spotter_item['longitude']; |
623 | 649 | } |
624 | 650 | $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
625 | - } else $distance = ''; |
|
651 | + } else { |
|
652 | + $distance = ''; |
|
653 | + } |
|
626 | 654 | if ($distance != '') { |
627 | 655 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
628 | 656 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | print '<th class="more"></th>'; |
94 | 94 | print '</thead>'; |
95 | -} else if (strtolower($current_page) == "upcoming"){ |
|
95 | +} else if (strtolower($current_page) == "upcoming") { |
|
96 | 96 | print '<thead>'; |
97 | 97 | if ($_GET['sort'] == "airline_name_asc") |
98 | 98 | { |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | */ |
144 | 144 | print '</thead>'; |
145 | -} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive"){ |
|
145 | +} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") { |
|
146 | 146 | print '<thead>'; |
147 | 147 | print '<th class="aircraft_thumbnail"></th>'; |
148 | 148 | print '<th class="logo">'._("Airline").'</th>'; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | print '</thead>'; |
180 | 180 | } else { |
181 | 181 | |
182 | - if ($hide_th_links === true){ |
|
182 | + if ($hide_th_links === true) { |
|
183 | 183 | print '<thead>'; |
184 | 184 | print '<th class="aircraft_thumbnail"></th>'; |
185 | 185 | if ($_GET['sort'] == "airline_name_asc") |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | print '<tbody>'."\n"; |
363 | -foreach($spotter_array as $spotter_item) |
|
363 | +foreach ($spotter_array as $spotter_item) |
|
364 | 364 | { |
365 | 365 | if (isset($globalTimezone)) |
366 | 366 | { |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
392 | 392 | } |
393 | 393 | if (isset($spotter_item['airline_name'])) { |
394 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
394 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
395 | 395 | } else { |
396 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
396 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
397 | 397 | } |
398 | 398 | } else { |
399 | 399 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
400 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
400 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
401 | 401 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
402 | 402 | if (isset($spotter_item['airline_name'])) { |
403 | 403 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | print '<img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" />'."\n"; |
412 | 412 | print '</td>'."\n"; |
413 | 413 | } |
414 | - } elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){ |
|
414 | + } elseif (strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed") { |
|
415 | 415 | if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) { |
416 | 416 | $spotter_item['squawk'] = '-'; |
417 | 417 | } |
@@ -427,17 +427,17 @@ discard block |
||
427 | 427 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
428 | 428 | } |
429 | 429 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
430 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
430 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
431 | 431 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
432 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
432 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
433 | 433 | } elseif (!isset($spotter_item['aircraft_name']) && !isset($spotter_item['airline_name'])) { |
434 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
434 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
435 | 435 | } else { |
436 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
436 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
437 | 437 | } |
438 | 438 | } else { |
439 | 439 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
440 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
440 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
441 | 441 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
442 | 442 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
443 | 443 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | } |
501 | 501 | print '</td>'."\n"; |
502 | 502 | // Aircraft type |
503 | - if(strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive"){ |
|
503 | + if (strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive") { |
|
504 | 504 | print '<td class="type">'."\n"; |
505 | 505 | if (!isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_name'])) { |
506 | 506 | print '<span class="nomobile">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</span>'."\n"; |
@@ -524,22 +524,22 @@ discard block |
||
524 | 524 | } |
525 | 525 | if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) { |
526 | 526 | if ($spotter_item['departure_airport_time'] > 2460) { |
527 | - $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
|
528 | - } else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
527 | + $departure_airport_time = date('H:m', $spotter_item['departure_airport_time']); |
|
528 | + } else $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2); |
|
529 | 529 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
530 | - $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
|
530 | + $real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']); |
|
531 | 531 | } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
532 | 532 | print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n"; |
533 | 533 | } elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') { |
534 | 534 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
535 | - $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
|
535 | + $real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']); |
|
536 | 536 | } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
537 | 537 | print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n"; |
538 | 538 | } elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
539 | 539 | if ($spotter_item['departure_airport_time'] > 2460) { |
540 | - $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
|
540 | + $departure_airport_time = date('H:m', $spotter_item['departure_airport_time']); |
|
541 | 541 | } else { |
542 | - $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
542 | + $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2); |
|
543 | 543 | } |
544 | 544 | print '<br /><span class="airport_time">'.$departure_airport_time.'</span>'."\n"; |
545 | 545 | } |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | $latitude = $spotter_item['latitude']; |
555 | 555 | $longitude = $spotter_item['longitude']; |
556 | 556 | } |
557 | - $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
|
557 | + $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'], $latitude, $longitude); |
|
558 | 558 | } else $distance = ''; |
559 | 559 | if ($distance != '') { |
560 | 560 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
@@ -595,20 +595,20 @@ discard block |
||
595 | 595 | } |
596 | 596 | if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) { |
597 | 597 | if ($spotter_item['arrival_airport_time'] > 2460) { |
598 | - $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
|
598 | + $arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']); |
|
599 | 599 | } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
600 | 600 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
601 | - $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
|
601 | + $real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']); |
|
602 | 602 | } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
603 | 603 | print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n"; |
604 | 604 | } elseif (isset($spotter_item['real_arrival_airport_time'])) { |
605 | 605 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
606 | - $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
|
606 | + $real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']); |
|
607 | 607 | } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
608 | 608 | print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n"; |
609 | 609 | } elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
610 | 610 | if ($spotter_item['arrival_airport_time'] > 2460) { |
611 | - $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
|
611 | + $arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']); |
|
612 | 612 | } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
613 | 613 | print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n"; |
614 | 614 | } |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | $latitude = $spotter_item['latitude']; |
622 | 622 | $longitude = $spotter_item['longitude']; |
623 | 623 | } |
624 | - $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
|
624 | + $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'], $latitude, $longitude); |
|
625 | 625 | } else $distance = ''; |
626 | 626 | if ($distance != '') { |
627 | 627 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | } |
636 | 636 | print '</td>'."\n"; |
637 | 637 | // Route stop |
638 | - if(strtolower($current_page) != "upcoming"){ |
|
638 | + if (strtolower($current_page) != "upcoming") { |
|
639 | 639 | print '<td class="route_stop">'."\n"; |
640 | 640 | if (!isset($spotter_item['route_stop']) || $spotter_item['route_stop'] == '' || $spotter_item['route_stop'] == 'NULL') { |
641 | 641 | print '<span class="nomobile">-</span>'."\n"; |
@@ -659,21 +659,21 @@ discard block |
||
659 | 659 | } else { |
660 | 660 | //if (!isset($globalUnitDistance) || $globalUnitDistance == 'km') { |
661 | 661 | if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
662 | - print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n"; |
|
663 | - print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n"; |
|
662 | + print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n"; |
|
663 | + print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n"; |
|
664 | 664 | //} elseif ($globalUnitDistance == 'mi') { |
665 | 665 | } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
666 | - print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n"; |
|
667 | - print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n"; |
|
666 | + print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n"; |
|
667 | + print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n"; |
|
668 | 668 | //} elseif ($globalUnitDistance == 'nm') { |
669 | 669 | } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
670 | - print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n"; |
|
671 | - print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n"; |
|
670 | + print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n"; |
|
671 | + print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n"; |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | print '</td>'."\n"; |
675 | 675 | } |
676 | - if(strtolower($current_page) != "upcoming"){ |
|
676 | + if (strtolower($current_page) != "upcoming") { |
|
677 | 677 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
678 | 678 | print '<td class="pilot">'."\n"; |
679 | 679 | if ((!isset($spotter_item['pilot_id']) || $spotter_item['pilot_id'] == '') && (!isset($spotter_item['pilot_name']) || $spotter_item['pilot_name'] == '')) { |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") { |
709 | 709 | if (isset($spotter_item['decode']) && $spotter_item['decode'] != '') { |
710 | 710 | print '<td class="message"><p>'."\n"; |
711 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
711 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
712 | 712 | print '</p><p class="decode">'; |
713 | 713 | $decode_array = json_decode($spotter_item['decode']); |
714 | 714 | foreach ($decode_array as $key => $value) { |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | print '</td>'."\n"; |
719 | 719 | } else { |
720 | 720 | print '<td class="message">'."\n"; |
721 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
721 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
722 | 722 | print '</td>'."\n"; |
723 | 723 | } |
724 | 724 | } |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | } |
744 | 744 | print '</td>'."\n"; |
745 | 745 | print '<td class="message">'."\n"; |
746 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
746 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
747 | 747 | print '</td>'."\n"; |
748 | 748 | } |
749 | 749 | if (strtolower($current_page) == "incident-latest" || strtolower($current_page) == "incident-detailed") { |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | print '</td>'."\n"; |
770 | 770 | */ |
771 | 771 | print '<td class="message">'."\n"; |
772 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
772 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
773 | 773 | print '</td>'."\n"; |
774 | 774 | } |
775 | 775 | // Date |
@@ -388,17 +388,17 @@ discard block |
||
388 | 388 | else { |
389 | 389 | $planespotter_url_array = explode("_", $spotter_item['image']); |
390 | 390 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
391 | - $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
|
391 | + $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
|
392 | 392 | } |
393 | 393 | if (isset($spotter_item['airline_name'])) { |
394 | 394 | print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
395 | 395 | } else { |
396 | 396 | print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
397 | 397 | } |
398 | - } else { |
|
399 | - if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
|
400 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
401 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
398 | + } else { |
|
399 | + if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
|
400 | + $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
401 | + } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
402 | 402 | if (isset($spotter_item['airline_name'])) { |
403 | 403 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
404 | 404 | } else { |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | } |
414 | 414 | } elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){ |
415 | 415 | if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) { |
416 | - $spotter_item['squawk'] = '-'; |
|
416 | + $spotter_item['squawk'] = '-'; |
|
417 | 417 | } |
418 | 418 | if ($spotter_item['image_thumbnail'] != "") |
419 | 419 | { |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | else { |
425 | 425 | $planespotter_url_array = explode("_", $spotter_array[0]['image']); |
426 | 426 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
427 | - $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
|
427 | + $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
|
428 | 428 | } |
429 | 429 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
430 | 430 | print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -436,9 +436,9 @@ discard block |
||
436 | 436 | print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
437 | 437 | } |
438 | 438 | } else { |
439 | - if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
|
440 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
441 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
439 | + if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
|
440 | + $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
441 | + } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
442 | 442 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
443 | 443 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
444 | 444 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | print '</td>'."\n"; |
453 | 453 | } else { |
454 | 454 | print '<td class="aircraft_thumbnail">'."\n"; |
455 | - // print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
|
455 | + // print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
|
456 | 456 | //} |
457 | 457 | if (!isset($spotter_item['airline_name']) && !isset($spotter_item['aircraft_name'])) { |
458 | 458 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '._("Not available").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n"; |
@@ -557,13 +557,13 @@ discard block |
||
557 | 557 | $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
558 | 558 | } else $distance = ''; |
559 | 559 | if ($distance != '') { |
560 | - if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
|
561 | - echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
|
562 | - } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
|
563 | - echo '<br/><i>'.round($distance*0.621371).' mi</i>'; |
|
564 | - } elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
|
565 | - echo '<br/><i>'.$distance.' km</i>'; |
|
566 | - } |
|
560 | + if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
|
561 | + echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
|
562 | + } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
|
563 | + echo '<br/><i>'.round($distance*0.621371).' mi</i>'; |
|
564 | + } elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
|
565 | + echo '<br/><i>'.$distance.' km</i>'; |
|
566 | + } |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | print '</td>'."\n"; |
@@ -624,13 +624,13 @@ discard block |
||
624 | 624 | $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
625 | 625 | } else $distance = ''; |
626 | 626 | if ($distance != '') { |
627 | - if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
|
628 | - echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
|
629 | - } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
|
630 | - echo '<br/><i>'.round($distance*0.621371).' mi</i>'; |
|
631 | - } elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
|
632 | - echo '<br/><i>'.$distance.' km</i>'; |
|
633 | - } |
|
627 | + if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
|
628 | + echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
|
629 | + } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
|
630 | + echo '<br/><i>'.round($distance*0.621371).' mi</i>'; |
|
631 | + } elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
|
632 | + echo '<br/><i>'.$distance.' km</i>'; |
|
633 | + } |
|
634 | 634 | } |
635 | 635 | } |
636 | 636 | print '</td>'."\n"; |
@@ -38,8 +38,12 @@ |
||
38 | 38 | if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) { |
39 | 39 | include('table-output.php'); |
40 | 40 | print '<div class="pagination">'; |
41 | - if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
42 | - if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
41 | + if ($limit_previous_1 >= 0) { |
|
42 | + print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
43 | + } |
|
44 | + if ($spotter_array[0]['query_number_rows'] == $absolute_difference) { |
|
45 | + print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
46 | + } |
|
43 | 47 | print '</div>'; |
44 | 48 | } |
45 | 49 | print '</div>'; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | $page_url = $globalURL.'/accident-latest'; |
10 | 10 | |
11 | -if(!isset($_GET['limit'])) |
|
11 | +if (!isset($_GET['limit'])) |
|
12 | 12 | { |
13 | 13 | $limit_start = 0; |
14 | 14 | $limit_end = 25; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | print '<div class="table column">'; |
36 | 36 | print '<p>'._("The table below shows the latest Incidents.").'</p>'; |
37 | -$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'incident'); |
|
37 | +$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'incident'); |
|
38 | 38 | //print_r($spotter_array); |
39 | 39 | if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) { |
40 | 40 | include('table-output.php'); |
@@ -7,109 +7,109 @@ discard block |
||
7 | 7 | public $db; |
8 | 8 | |
9 | 9 | protected $texts = Array( |
10 | - 'MI' => 'Shallow', |
|
11 | - 'PR' => 'Partial', |
|
12 | - 'BC' => 'Low drifting', |
|
13 | - 'BL' => 'Blowing', |
|
14 | - 'SH' => 'Showers', |
|
15 | - 'TS' => 'Thunderstorm', |
|
16 | - 'FZ' => 'Freezing', |
|
17 | - 'DZ' => 'Drizzle', |
|
18 | - 'RA' => 'Rain', |
|
19 | - 'SN' => 'Snow', |
|
20 | - 'SG' => 'Snow Grains', |
|
21 | - 'IC' => 'Ice crystals', |
|
22 | - 'PL' => 'Ice pellets', |
|
23 | - 'GR' => 'Hail', |
|
24 | - 'GS' => 'Small hail', |
|
25 | - 'UP' => 'Unknown', |
|
26 | - 'BR' => 'Mist', |
|
27 | - 'FG' => 'Fog', |
|
28 | - 'FU' => 'Smoke', |
|
29 | - 'VA' => 'Volcanic ash', |
|
30 | - 'DU' => 'Widespread dust', |
|
31 | - 'SA' => 'Sand', |
|
32 | - 'HZ' => 'Haze', |
|
33 | - 'PY' => 'Spray', |
|
34 | - 'PO' => 'Well developed dust / sand whirls', |
|
35 | - 'SQ' => 'Squalls', |
|
36 | - 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
37 | - 'SS' => 'Sandstorm', |
|
38 | - 'DS' => 'Duststorm' |
|
10 | + 'MI' => 'Shallow', |
|
11 | + 'PR' => 'Partial', |
|
12 | + 'BC' => 'Low drifting', |
|
13 | + 'BL' => 'Blowing', |
|
14 | + 'SH' => 'Showers', |
|
15 | + 'TS' => 'Thunderstorm', |
|
16 | + 'FZ' => 'Freezing', |
|
17 | + 'DZ' => 'Drizzle', |
|
18 | + 'RA' => 'Rain', |
|
19 | + 'SN' => 'Snow', |
|
20 | + 'SG' => 'Snow Grains', |
|
21 | + 'IC' => 'Ice crystals', |
|
22 | + 'PL' => 'Ice pellets', |
|
23 | + 'GR' => 'Hail', |
|
24 | + 'GS' => 'Small hail', |
|
25 | + 'UP' => 'Unknown', |
|
26 | + 'BR' => 'Mist', |
|
27 | + 'FG' => 'Fog', |
|
28 | + 'FU' => 'Smoke', |
|
29 | + 'VA' => 'Volcanic ash', |
|
30 | + 'DU' => 'Widespread dust', |
|
31 | + 'SA' => 'Sand', |
|
32 | + 'HZ' => 'Haze', |
|
33 | + 'PY' => 'Spray', |
|
34 | + 'PO' => 'Well developed dust / sand whirls', |
|
35 | + 'SQ' => 'Squalls', |
|
36 | + 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
37 | + 'SS' => 'Sandstorm', |
|
38 | + 'DS' => 'Duststorm' |
|
39 | 39 | ); |
40 | 40 | |
41 | 41 | public function __construct($dbc = null) { |
42 | - $Connection = new Connection($dbc); |
|
43 | - $this->db = $Connection->db; |
|
44 | - } |
|
42 | + $Connection = new Connection($dbc); |
|
43 | + $this->db = $Connection->db; |
|
44 | + } |
|
45 | 45 | |
46 | - public static function check_last_update() { |
|
47 | - global $globalDBdriver; |
|
48 | - if ($globalDBdriver == 'mysql') { |
|
46 | + public static function check_last_update() { |
|
47 | + global $globalDBdriver; |
|
48 | + if ($globalDBdriver == 'mysql') { |
|
49 | 49 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)"; |
50 | 50 | } else { |
51 | 51 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'"; |
52 | 52 | } |
53 | - try { |
|
54 | - $Connection = new Connection(); |
|
55 | - $sth = $Connection->db->prepare($query); |
|
56 | - $sth->execute(); |
|
57 | - } catch(PDOException $e) { |
|
58 | - return "error : ".$e->getMessage(); |
|
59 | - } |
|
60 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
61 | - $sth->closeCursor(); |
|
62 | - if ($row['nb'] > 0) return false; |
|
63 | - else return true; |
|
64 | - } |
|
53 | + try { |
|
54 | + $Connection = new Connection(); |
|
55 | + $sth = $Connection->db->prepare($query); |
|
56 | + $sth->execute(); |
|
57 | + } catch(PDOException $e) { |
|
58 | + return "error : ".$e->getMessage(); |
|
59 | + } |
|
60 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
61 | + $sth->closeCursor(); |
|
62 | + if ($row['nb'] > 0) return false; |
|
63 | + else return true; |
|
64 | + } |
|
65 | 65 | |
66 | - public static function insert_last_update() { |
|
67 | - $query = "DELETE FROM config WHERE name = 'last_update_metar'; |
|
66 | + public static function insert_last_update() { |
|
67 | + $query = "DELETE FROM config WHERE name = 'last_update_metar'; |
|
68 | 68 | INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());"; |
69 | - try { |
|
70 | - $Connection = new Connection(); |
|
71 | - $sth = $Connection->db->prepare($query); |
|
72 | - $sth->execute(); |
|
73 | - } catch(PDOException $e) { |
|
74 | - return "error : ".$e->getMessage(); |
|
75 | - } |
|
76 | - } |
|
69 | + try { |
|
70 | + $Connection = new Connection(); |
|
71 | + $sth = $Connection->db->prepare($query); |
|
72 | + $sth->execute(); |
|
73 | + } catch(PDOException $e) { |
|
74 | + return "error : ".$e->getMessage(); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | 79 | |
80 | - public function parse($data) { |
|
81 | - //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
|
82 | - $codes = implode('|', array_keys($this->texts)); |
|
83 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
84 | - //$pieces = explode(' ',$data); |
|
85 | - $pieces = preg_split('/\s/',$data); |
|
86 | - $pos = 0; |
|
87 | - if ($pieces[0] == 'METAR') $pos++; |
|
88 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | - $result = array(); |
|
91 | - $result['location'] = $pieces[$pos]; |
|
92 | - $pos++; |
|
93 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | - $result['time'] = substr($pieces[$pos],2,4); |
|
95 | - $c = count($pieces); |
|
96 | - for($pos++; $pos < $c; $pos++) { |
|
97 | - $piece = $pieces[$pos]; |
|
98 | - if ($piece == 'RMK') break; |
|
99 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | - if ($piece == 'COR') $result['correction'] = true; |
|
101 | - // Wind Speed |
|
102 | - if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
|
103 | - $result['wind']['direction'] = (float)$matches[1]; |
|
80 | + public function parse($data) { |
|
81 | + //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
|
82 | + $codes = implode('|', array_keys($this->texts)); |
|
83 | + $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
84 | + //$pieces = explode(' ',$data); |
|
85 | + $pieces = preg_split('/\s/',$data); |
|
86 | + $pos = 0; |
|
87 | + if ($pieces[0] == 'METAR') $pos++; |
|
88 | + elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | + $result = array(); |
|
91 | + $result['location'] = $pieces[$pos]; |
|
92 | + $pos++; |
|
93 | + $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | + $result['time'] = substr($pieces[$pos],2,4); |
|
95 | + $c = count($pieces); |
|
96 | + for($pos++; $pos < $c; $pos++) { |
|
97 | + $piece = $pieces[$pos]; |
|
98 | + if ($piece == 'RMK') break; |
|
99 | + if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | + if ($piece == 'COR') $result['correction'] = true; |
|
101 | + // Wind Speed |
|
102 | + if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
|
103 | + $result['wind']['direction'] = (float)$matches[1]; |
|
104 | 104 | $result['wind']['unit'] = $matches[4]; |
105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
105 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
108 | 108 | $result['wind']['gust'] = (float)$matches[3]; |
109 | 109 | $result['wind']['unit'] = $matches[4]; |
110 | 110 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
111 | 111 | $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | 114 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
115 | 115 | $result['wind_direction'] = (float)$matches[1]; |
@@ -126,35 +126,35 @@ discard block |
||
126 | 126 | } |
127 | 127 | } |
128 | 128 | */ |
129 | - // Temperature |
|
130 | - if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
|
131 | - $temp = (float)$matches[1]; |
|
129 | + // Temperature |
|
130 | + if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
|
131 | + $temp = (float)$matches[1]; |
|
132 | 132 | if ($matches[1]{0} == 'M') { |
133 | 133 | $temp = ((float)substr($matches[1], 1)) * -1; |
134 | 134 | } |
135 | - $result['temperature'] = $temp; |
|
136 | - $dew = (float)$matches[2]; |
|
135 | + $result['temperature'] = $temp; |
|
136 | + $dew = (float)$matches[2]; |
|
137 | 137 | if ($matches[2]{0} == 'M') { |
138 | 138 | $dew = ((float)substr($matches[2], 1)) * -1; |
139 | 139 | } |
140 | 140 | $result['dew'] = $dew; |
141 | - } |
|
142 | - // QNH |
|
143 | - if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) { |
|
144 | - // #^(Q|A)(////|[0-9]{4})( )# |
|
145 | - if ($matches[1] == 'Q') { |
|
146 | - // hPa |
|
147 | - $result['QNH'] = $matches[2]; |
|
148 | - } else { |
|
149 | - // inHg |
|
150 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
151 | 141 | } |
152 | - /* |
|
142 | + // QNH |
|
143 | + if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) { |
|
144 | + // #^(Q|A)(////|[0-9]{4})( )# |
|
145 | + if ($matches[1] == 'Q') { |
|
146 | + // hPa |
|
147 | + $result['QNH'] = $matches[2]; |
|
148 | + } else { |
|
149 | + // inHg |
|
150 | + $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
151 | + } |
|
152 | + /* |
|
153 | 153 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
154 | 154 | $result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg'; |
155 | 155 | */ |
156 | - } |
|
157 | - /* |
|
156 | + } |
|
157 | + /* |
|
158 | 158 | // Wind Direction |
159 | 159 | if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) { |
160 | 160 | $result['wind_direction'] = $matches[1]; |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | $result['speed_variable'] = $matches[1]; |
166 | 166 | } |
167 | 167 | */ |
168 | - // Visibility |
|
169 | - if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
|
170 | - if (isset($matches[3]) && strlen($matches[3]) > 0) { |
|
168 | + // Visibility |
|
169 | + if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
|
170 | + if (isset($matches[3]) && strlen($matches[3]) > 0) { |
|
171 | 171 | $result['visibility'] = (float)$matches[3] * 1609.34; |
172 | 172 | } else { |
173 | 173 | if ($matches[1] == '9999') { |
@@ -180,28 +180,28 @@ discard block |
||
180 | 180 | $result['visibility'] = '> 10000'; |
181 | 181 | $result['weather'] = "CAVOK"; |
182 | 182 | } |
183 | - } |
|
184 | - // Cloud Coverage |
|
185 | - if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) { |
|
186 | - //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
|
187 | - $type = $matches[1]; |
|
188 | - $cloud = array(); |
|
189 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
197 | - $cloud['type_code'] = $type; |
|
198 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
199 | - $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
|
200 | - $result['cloud'][] = $cloud; |
|
201 | - } |
|
202 | - // RVR |
|
203 | - if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) { |
|
204 | - $rvr = array(); |
|
183 | + } |
|
184 | + // Cloud Coverage |
|
185 | + if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) { |
|
186 | + //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
|
187 | + $type = $matches[1]; |
|
188 | + $cloud = array(); |
|
189 | + if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | + elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | + elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | + elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | + elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | + elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | + elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | + elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
197 | + $cloud['type_code'] = $type; |
|
198 | + $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
199 | + $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
|
200 | + $result['cloud'][] = $cloud; |
|
201 | + } |
|
202 | + // RVR |
|
203 | + if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) { |
|
204 | + $rvr = array(); |
|
205 | 205 | $rvr['runway'] = $matches[1]; |
206 | 206 | $rvr['assessment'] = $matches[2]; |
207 | 207 | $rvr['rvr'] = $matches[3]; |
@@ -210,33 +210,33 @@ discard block |
||
210 | 210 | $result['RVR'] = $rvr; |
211 | 211 | } |
212 | 212 | |
213 | - //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
214 | - if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) { |
|
215 | - //print_r($matches); |
|
216 | - // https://github.com/davidmegginson/metar-taf/blob/master/Metar.php |
|
217 | - $result['RVR']['runway'] = $matches[1]; |
|
218 | - $result['RVR']['deposits'] = $matches[2]; |
|
219 | - $result['RVR']['extent'] = $matches[3]; |
|
220 | - $result['RVR']['depth'] = $matches[4]; |
|
221 | - $result['RVR']['friction'] = $matches[5]; |
|
222 | - } |
|
223 | - if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
224 | - //echo $piece; |
|
225 | - //print_r($matches); |
|
226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
213 | + //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
214 | + if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) { |
|
215 | + //print_r($matches); |
|
216 | + // https://github.com/davidmegginson/metar-taf/blob/master/Metar.php |
|
217 | + $result['RVR']['runway'] = $matches[1]; |
|
218 | + $result['RVR']['deposits'] = $matches[2]; |
|
219 | + $result['RVR']['extent'] = $matches[3]; |
|
220 | + $result['RVR']['depth'] = $matches[4]; |
|
221 | + $result['RVR']['friction'] = $matches[5]; |
|
222 | + } |
|
223 | + if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
224 | + //echo $piece; |
|
225 | + //print_r($matches); |
|
226 | + if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | + else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
228 | 228 | if (isset($matches[3])) { |
229 | 229 | $range = Array( |
230 | - 'from' => (float)$matches[2], |
|
231 | - 'to' => (float)$matches[4], |
|
232 | - 'unit' => $matches[5] ? 'FT' : 'M' |
|
230 | + 'from' => (float)$matches[2], |
|
231 | + 'to' => (float)$matches[4], |
|
232 | + 'unit' => $matches[5] ? 'FT' : 'M' |
|
233 | 233 | ); |
234 | 234 | } |
235 | 235 | $result['RVR'] = $matches[1]; |
236 | 236 | $result['RVR_range'] = $range; |
237 | - } |
|
238 | - // Weather |
|
239 | - if (preg_match($regWeather, $piece, $matches)) { |
|
237 | + } |
|
238 | + // Weather |
|
239 | + if (preg_match($regWeather, $piece, $matches)) { |
|
240 | 240 | $text = Array(); |
241 | 241 | switch ($matches[1]) { |
242 | 242 | case '+': |
@@ -259,35 +259,35 @@ discard block |
||
259 | 259 | } |
260 | 260 | if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
261 | 261 | else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
262 | - } |
|
263 | - } |
|
264 | - return $result; |
|
262 | + } |
|
263 | + } |
|
264 | + return $result; |
|
265 | 265 | |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | 268 | public function getMETAR($icao) { |
269 | - global $globalMETARcycle, $globalDBdriver; |
|
270 | - if (isset($globalMETARcycle) && $globalMETARcycle) { |
|
271 | - $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
|
272 | - } else { |
|
273 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
275 | - } |
|
276 | - $query_values = array(':icao' => $icao); |
|
277 | - try { |
|
278 | - $sth = $this->db->prepare($query); |
|
279 | - $sth->execute($query_values); |
|
280 | - } catch(PDOException $e) { |
|
281 | - return "error : ".$e->getMessage(); |
|
282 | - } |
|
283 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | - if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) { |
|
285 | - $all = $this->downloadMETAR($icao); |
|
286 | - } |
|
287 | - return $all; |
|
288 | - } |
|
269 | + global $globalMETARcycle, $globalDBdriver; |
|
270 | + if (isset($globalMETARcycle) && $globalMETARcycle) { |
|
271 | + $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
|
272 | + } else { |
|
273 | + if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | + else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
275 | + } |
|
276 | + $query_values = array(':icao' => $icao); |
|
277 | + try { |
|
278 | + $sth = $this->db->prepare($query); |
|
279 | + $sth->execute($query_values); |
|
280 | + } catch(PDOException $e) { |
|
281 | + return "error : ".$e->getMessage(); |
|
282 | + } |
|
283 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | + if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) { |
|
285 | + $all = $this->downloadMETAR($icao); |
|
286 | + } |
|
287 | + return $all; |
|
288 | + } |
|
289 | 289 | |
290 | - public function addMETAR($location,$metar,$date) { |
|
290 | + public function addMETAR($location,$metar,$date) { |
|
291 | 291 | global $globalDBdriver; |
292 | 292 | $date = date('Y-m-d H:i:s',strtotime($date)); |
293 | 293 | if ($globalDBdriver == 'mysql') { |
@@ -295,104 +295,104 @@ discard block |
||
295 | 295 | } else { |
296 | 296 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
297 | 297 | } |
298 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
299 | - try { |
|
300 | - $sth = $this->db->prepare($query); |
|
301 | - $sth->execute($query_values); |
|
302 | - } catch(PDOException $e) { |
|
303 | - return "error : ".$e->getMessage(); |
|
304 | - } |
|
305 | - } |
|
298 | + $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
299 | + try { |
|
300 | + $sth = $this->db->prepare($query); |
|
301 | + $sth->execute($query_values); |
|
302 | + } catch(PDOException $e) { |
|
303 | + return "error : ".$e->getMessage(); |
|
304 | + } |
|
305 | + } |
|
306 | 306 | |
307 | - public function deleteMETAR($id) { |
|
308 | - $query = "DELETE FROM metar WHERE id = :id"; |
|
309 | - $query_values = array(':id' => $id); |
|
310 | - try { |
|
311 | - $sth = $this->db->prepare($query); |
|
312 | - $sth->execute($query_values); |
|
313 | - } catch(PDOException $e) { |
|
314 | - return "error : ".$e->getMessage(); |
|
315 | - } |
|
316 | - } |
|
317 | - public function deleteAllMETARLocation() { |
|
318 | - $query = "DELETE FROM metar"; |
|
319 | - try { |
|
320 | - $sth = $this->db->prepare($query); |
|
321 | - $sth->execute(); |
|
322 | - } catch(PDOException $e) { |
|
323 | - return "error : ".$e->getMessage(); |
|
324 | - } |
|
325 | - } |
|
307 | + public function deleteMETAR($id) { |
|
308 | + $query = "DELETE FROM metar WHERE id = :id"; |
|
309 | + $query_values = array(':id' => $id); |
|
310 | + try { |
|
311 | + $sth = $this->db->prepare($query); |
|
312 | + $sth->execute($query_values); |
|
313 | + } catch(PDOException $e) { |
|
314 | + return "error : ".$e->getMessage(); |
|
315 | + } |
|
316 | + } |
|
317 | + public function deleteAllMETARLocation() { |
|
318 | + $query = "DELETE FROM metar"; |
|
319 | + try { |
|
320 | + $sth = $this->db->prepare($query); |
|
321 | + $sth->execute(); |
|
322 | + } catch(PDOException $e) { |
|
323 | + return "error : ".$e->getMessage(); |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | - public function addMETARCycle() { |
|
328 | - global $globalDebug, $globalIVAO; |
|
329 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
330 | - date_default_timezone_set("UTC"); |
|
331 | - $Common = new Common(); |
|
332 | - if (isset($globalIVAO) && $globalIVAO) { |
|
333 | - //$cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
|
327 | + public function addMETARCycle() { |
|
328 | + global $globalDebug, $globalIVAO; |
|
329 | + if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
330 | + date_default_timezone_set("UTC"); |
|
331 | + $Common = new Common(); |
|
332 | + if (isset($globalIVAO) && $globalIVAO) { |
|
333 | + //$cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
|
334 | 334 | $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
335 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
336 | - } else { |
|
335 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
336 | + } else { |
|
337 | 337 | //$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT'); |
338 | 338 | $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
339 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
340 | - } |
|
341 | - if ($handle) { |
|
339 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
340 | + } |
|
341 | + if ($handle) { |
|
342 | 342 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
343 | 343 | $date = ''; |
344 | - //foreach(explode("\n",$cycle) as $line) { |
|
345 | - while(($line = fgets($handle,4096)) !== false) { |
|
344 | + //foreach(explode("\n",$cycle) as $line) { |
|
345 | + while(($line = fgets($handle,4096)) !== false) { |
|
346 | 346 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
347 | 347 | $date = $line; |
348 | - } elseif ($line != '') { |
|
349 | - //$this->parse($line); |
|
350 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
351 | - $pos = 0; |
|
352 | - $pieces = preg_split('/\s/',$line); |
|
353 | - if ($pieces[0] == 'METAR') $pos++; |
|
354 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
355 | - $location = $pieces[$pos]; |
|
356 | - echo $this->addMETAR($location,$line,$date); |
|
357 | - } |
|
358 | - } |
|
359 | - fclose($handle); |
|
360 | - } |
|
361 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
348 | + } elseif ($line != '') { |
|
349 | + //$this->parse($line); |
|
350 | + if ($date == '') $date = date('Y/m/d H:m'); |
|
351 | + $pos = 0; |
|
352 | + $pieces = preg_split('/\s/',$line); |
|
353 | + if ($pieces[0] == 'METAR') $pos++; |
|
354 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
355 | + $location = $pieces[$pos]; |
|
356 | + echo $this->addMETAR($location,$line,$date); |
|
357 | + } |
|
358 | + } |
|
359 | + fclose($handle); |
|
360 | + } |
|
361 | + if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
362 | 362 | |
363 | - } |
|
364 | - public function downloadMETAR($icao) { |
|
365 | - global $globalMETARurl; |
|
366 | - if ($globalMETARurl == '') return array(); |
|
367 | - date_default_timezone_set("UTC"); |
|
368 | - $Common = new Common(); |
|
369 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
370 | - $cycle = $Common->getData($url); |
|
371 | - $date = ''; |
|
372 | - foreach(explode("\n",$cycle) as $line) { |
|
373 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
374 | - //echo "date : ".$line."\n"; |
|
375 | - $date = $line; |
|
376 | - } |
|
377 | - if ($line != '') { |
|
378 | - //$this->parse($line); |
|
379 | - //echo $line; |
|
380 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
381 | - $pos = 0; |
|
382 | - $pieces = preg_split('/\s/',$line); |
|
383 | - if ($pieces[0] == 'METAR') $pos++; |
|
384 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
385 | - $location = $pieces[$pos]; |
|
386 | - if (strlen($location == 4)) { |
|
387 | - $this->addMETAR($location,$line,$date); |
|
388 | - return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
|
389 | - } else return array(); |
|
390 | - } |
|
391 | - //echo $line."\n"; |
|
392 | - } |
|
393 | - return array(); |
|
363 | + } |
|
364 | + public function downloadMETAR($icao) { |
|
365 | + global $globalMETARurl; |
|
366 | + if ($globalMETARurl == '') return array(); |
|
367 | + date_default_timezone_set("UTC"); |
|
368 | + $Common = new Common(); |
|
369 | + $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
370 | + $cycle = $Common->getData($url); |
|
371 | + $date = ''; |
|
372 | + foreach(explode("\n",$cycle) as $line) { |
|
373 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
374 | + //echo "date : ".$line."\n"; |
|
375 | + $date = $line; |
|
376 | + } |
|
377 | + if ($line != '') { |
|
378 | + //$this->parse($line); |
|
379 | + //echo $line; |
|
380 | + if ($date == '') $date = date('Y/m/d H:m'); |
|
381 | + $pos = 0; |
|
382 | + $pieces = preg_split('/\s/',$line); |
|
383 | + if ($pieces[0] == 'METAR') $pos++; |
|
384 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
385 | + $location = $pieces[$pos]; |
|
386 | + if (strlen($location == 4)) { |
|
387 | + $this->addMETAR($location,$line,$date); |
|
388 | + return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
|
389 | + } else return array(); |
|
390 | + } |
|
391 | + //echo $line."\n"; |
|
392 | + } |
|
393 | + return array(); |
|
394 | 394 | |
395 | - } |
|
395 | + } |
|
396 | 396 | } |
397 | 397 | /* |
398 | 398 | $METAR = new METAR(); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $Connection = new Connection(); |
55 | 55 | $sth = $Connection->db->prepare($query); |
56 | 56 | $sth->execute(); |
57 | - } catch(PDOException $e) { |
|
57 | + } catch (PDOException $e) { |
|
58 | 58 | return "error : ".$e->getMessage(); |
59 | 59 | } |
60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $Connection = new Connection(); |
71 | 71 | $sth = $Connection->db->prepare($query); |
72 | 72 | $sth->execute(); |
73 | - } catch(PDOException $e) { |
|
73 | + } catch (PDOException $e) { |
|
74 | 74 | return "error : ".$e->getMessage(); |
75 | 75 | } |
76 | 76 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | public function parse($data) { |
81 | 81 | //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
82 | 82 | $codes = implode('|', array_keys($this->texts)); |
83 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
83 | + $regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#'; |
|
84 | 84 | //$pieces = explode(' ',$data); |
85 | - $pieces = preg_split('/\s/',$data); |
|
85 | + $pieces = preg_split('/\s/', $data); |
|
86 | 86 | $pos = 0; |
87 | 87 | if ($pieces[0] == 'METAR') $pos++; |
88 | 88 | elseif ($pieces[0] == 'SPECI') $pos++; |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | $result = array(); |
91 | 91 | $result['location'] = $pieces[$pos]; |
92 | 92 | $pos++; |
93 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | - $result['time'] = substr($pieces[$pos],2,4); |
|
93 | + $result['dayofmonth'] = substr($pieces[$pos], 0, 2); |
|
94 | + $result['time'] = substr($pieces[$pos], 2, 4); |
|
95 | 95 | $c = count($pieces); |
96 | - for($pos++; $pos < $c; $pos++) { |
|
96 | + for ($pos++; $pos < $c; $pos++) { |
|
97 | 97 | $piece = $pieces[$pos]; |
98 | 98 | if ($piece == 'RMK') break; |
99 | 99 | if ($piece == 'AUTO') $result['auto'] = true; |
100 | 100 | if ($piece == 'COR') $result['correction'] = true; |
101 | 101 | // Wind Speed |
102 | 102 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
103 | - $result['wind']['direction'] = (float)$matches[1]; |
|
103 | + $result['wind']['direction'] = (float) $matches[1]; |
|
104 | 104 | $result['wind']['unit'] = $matches[4]; |
105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
108 | - $result['wind']['gust'] = (float)$matches[3]; |
|
105 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2); |
|
106 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2); |
|
107 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2); |
|
108 | + $result['wind']['gust'] = (float) $matches[3]; |
|
109 | 109 | $result['wind']['unit'] = $matches[4]; |
110 | - $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
|
111 | - $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
|
110 | + $result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0; |
|
111 | + $result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | */ |
129 | 129 | // Temperature |
130 | 130 | if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
131 | - $temp = (float)$matches[1]; |
|
131 | + $temp = (float) $matches[1]; |
|
132 | 132 | if ($matches[1]{0} == 'M') { |
133 | - $temp = ((float)substr($matches[1], 1)) * -1; |
|
133 | + $temp = ((float) substr($matches[1], 1))*-1; |
|
134 | 134 | } |
135 | 135 | $result['temperature'] = $temp; |
136 | - $dew = (float)$matches[2]; |
|
136 | + $dew = (float) $matches[2]; |
|
137 | 137 | if ($matches[2]{0} == 'M') { |
138 | - $dew = ((float)substr($matches[2], 1)) * -1; |
|
138 | + $dew = ((float) substr($matches[2], 1))*-1; |
|
139 | 139 | } |
140 | 140 | $result['dew'] = $dew; |
141 | 141 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $result['QNH'] = $matches[2]; |
148 | 148 | } else { |
149 | 149 | // inHg |
150 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
150 | + $result['QNH'] = round(($matches[2]/100)*33.86389, 2); |
|
151 | 151 | } |
152 | 152 | /* |
153 | 153 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | // Visibility |
169 | 169 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
170 | 170 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
171 | - $result['visibility'] = (float)$matches[3] * 1609.34; |
|
171 | + $result['visibility'] = (float) $matches[3]*1609.34; |
|
172 | 172 | } else { |
173 | 173 | if ($matches[1] == '9999') { |
174 | 174 | $result['visibility'] = '> 10000'; |
175 | 175 | } else { |
176 | - $result['visibility'] = (float)$matches[1]; |
|
176 | + $result['visibility'] = (float) $matches[1]; |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | if (preg_match('#^CAVOK$#', $piece, $matches)) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
196 | 196 | elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
197 | 197 | $cloud['type_code'] = $type; |
198 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
198 | + $cloud['level'] = round(((float) $matches[2])*100*0.3048); |
|
199 | 199 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
200 | 200 | $result['cloud'][] = $cloud; |
201 | 201 | } |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | $rvr['runway'] = $matches[1]; |
206 | 206 | $rvr['assessment'] = $matches[2]; |
207 | 207 | $rvr['rvr'] = $matches[3]; |
208 | - $rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0; |
|
209 | - $rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : ''; |
|
208 | + $rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0; |
|
209 | + $rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : ''; |
|
210 | 210 | $result['RVR'] = $rvr; |
211 | 211 | } |
212 | 212 | |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
224 | 224 | //echo $piece; |
225 | 225 | //print_r($matches); |
226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
226 | + if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | + else $range = array('exact' => (float) $matches[2], 'unit' => 'M'); |
|
228 | 228 | if (isset($matches[3])) { |
229 | 229 | $range = Array( |
230 | - 'from' => (float)$matches[2], |
|
231 | - 'to' => (float)$matches[4], |
|
230 | + 'from' => (float) $matches[2], |
|
231 | + 'to' => (float) $matches[4], |
|
232 | 232 | 'unit' => $matches[5] ? 'FT' : 'M' |
233 | 233 | ); |
234 | 234 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | try { |
278 | 278 | $sth = $this->db->prepare($query); |
279 | 279 | $sth->execute($query_values); |
280 | - } catch(PDOException $e) { |
|
280 | + } catch (PDOException $e) { |
|
281 | 281 | return "error : ".$e->getMessage(); |
282 | 282 | } |
283 | 283 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -287,19 +287,19 @@ discard block |
||
287 | 287 | return $all; |
288 | 288 | } |
289 | 289 | |
290 | - public function addMETAR($location,$metar,$date) { |
|
290 | + public function addMETAR($location, $metar, $date) { |
|
291 | 291 | global $globalDBdriver; |
292 | - $date = date('Y-m-d H:i:s',strtotime($date)); |
|
292 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
293 | 293 | if ($globalDBdriver == 'mysql') { |
294 | 294 | $query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar"; |
295 | 295 | } else { |
296 | 296 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
297 | 297 | } |
298 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
298 | + $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar)); |
|
299 | 299 | try { |
300 | 300 | $sth = $this->db->prepare($query); |
301 | 301 | $sth->execute($query_values); |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | return "error : ".$e->getMessage(); |
304 | 304 | } |
305 | 305 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | try { |
311 | 311 | $sth = $this->db->prepare($query); |
312 | 312 | $sth->execute($query_values); |
313 | - } catch(PDOException $e) { |
|
313 | + } catch (PDOException $e) { |
|
314 | 314 | return "error : ".$e->getMessage(); |
315 | 315 | } |
316 | 316 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | try { |
320 | 320 | $sth = $this->db->prepare($query); |
321 | 321 | $sth->execute(); |
322 | - } catch(PDOException $e) { |
|
322 | + } catch (PDOException $e) { |
|
323 | 323 | return "error : ".$e->getMessage(); |
324 | 324 | } |
325 | 325 | } |
@@ -331,29 +331,29 @@ discard block |
||
331 | 331 | $Common = new Common(); |
332 | 332 | if (isset($globalIVAO) && $globalIVAO) { |
333 | 333 | //$cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
334 | - $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
335 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
334 | + $Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
335 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r"); |
|
336 | 336 | } else { |
337 | 337 | //$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT'); |
338 | - $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
339 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
338 | + $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
339 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r"); |
|
340 | 340 | } |
341 | 341 | if ($handle) { |
342 | 342 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
343 | 343 | $date = ''; |
344 | 344 | //foreach(explode("\n",$cycle) as $line) { |
345 | - while(($line = fgets($handle,4096)) !== false) { |
|
346 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
345 | + while (($line = fgets($handle, 4096)) !== false) { |
|
346 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
347 | 347 | $date = $line; |
348 | 348 | } elseif ($line != '') { |
349 | 349 | //$this->parse($line); |
350 | 350 | if ($date == '') $date = date('Y/m/d H:m'); |
351 | 351 | $pos = 0; |
352 | - $pieces = preg_split('/\s/',$line); |
|
352 | + $pieces = preg_split('/\s/', $line); |
|
353 | 353 | if ($pieces[0] == 'METAR') $pos++; |
354 | 354 | if (strlen($pieces[$pos]) != 4) $pos++; |
355 | 355 | $location = $pieces[$pos]; |
356 | - echo $this->addMETAR($location,$line,$date); |
|
356 | + echo $this->addMETAR($location, $line, $date); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | fclose($handle); |
@@ -366,11 +366,11 @@ discard block |
||
366 | 366 | if ($globalMETARurl == '') return array(); |
367 | 367 | date_default_timezone_set("UTC"); |
368 | 368 | $Common = new Common(); |
369 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
369 | + $url = str_replace('{icao}', $icao, $globalMETARurl); |
|
370 | 370 | $cycle = $Common->getData($url); |
371 | 371 | $date = ''; |
372 | - foreach(explode("\n",$cycle) as $line) { |
|
373 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
372 | + foreach (explode("\n", $cycle) as $line) { |
|
373 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
374 | 374 | //echo "date : ".$line."\n"; |
375 | 375 | $date = $line; |
376 | 376 | } |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | //echo $line; |
380 | 380 | if ($date == '') $date = date('Y/m/d H:m'); |
381 | 381 | $pos = 0; |
382 | - $pieces = preg_split('/\s/',$line); |
|
382 | + $pieces = preg_split('/\s/', $line); |
|
383 | 383 | if ($pieces[0] == 'METAR') $pos++; |
384 | 384 | if (strlen($pieces[$pos]) != 4) $pos++; |
385 | 385 | $location = $pieces[$pos]; |
386 | 386 | if (strlen($location == 4)) { |
387 | - $this->addMETAR($location,$line,$date); |
|
387 | + $this->addMETAR($location, $line, $date); |
|
388 | 388 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
389 | 389 | } else return array(); |
390 | 390 | } |
@@ -59,8 +59,11 @@ discard block |
||
59 | 59 | } |
60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
61 | 61 | $sth->closeCursor(); |
62 | - if ($row['nb'] > 0) return false; |
|
63 | - else return true; |
|
62 | + if ($row['nb'] > 0) { |
|
63 | + return false; |
|
64 | + } else { |
|
65 | + return true; |
|
66 | + } |
|
64 | 67 | } |
65 | 68 | |
66 | 69 | public static function insert_last_update() { |
@@ -84,9 +87,14 @@ discard block |
||
84 | 87 | //$pieces = explode(' ',$data); |
85 | 88 | $pieces = preg_split('/\s/',$data); |
86 | 89 | $pos = 0; |
87 | - if ($pieces[0] == 'METAR') $pos++; |
|
88 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | + if ($pieces[0] == 'METAR') { |
|
91 | + $pos++; |
|
92 | + } elseif ($pieces[0] == 'SPECI') { |
|
93 | + $pos++; |
|
94 | + } |
|
95 | + if (strlen($pieces[$pos]) != 4) { |
|
96 | + $pos++; |
|
97 | + } |
|
90 | 98 | $result = array(); |
91 | 99 | $result['location'] = $pieces[$pos]; |
92 | 100 | $pos++; |
@@ -95,16 +103,26 @@ discard block |
||
95 | 103 | $c = count($pieces); |
96 | 104 | for($pos++; $pos < $c; $pos++) { |
97 | 105 | $piece = $pieces[$pos]; |
98 | - if ($piece == 'RMK') break; |
|
99 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | - if ($piece == 'COR') $result['correction'] = true; |
|
106 | + if ($piece == 'RMK') { |
|
107 | + break; |
|
108 | + } |
|
109 | + if ($piece == 'AUTO') { |
|
110 | + $result['auto'] = true; |
|
111 | + } |
|
112 | + if ($piece == 'COR') { |
|
113 | + $result['correction'] = true; |
|
114 | + } |
|
101 | 115 | // Wind Speed |
102 | 116 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
103 | 117 | $result['wind']['direction'] = (float)$matches[1]; |
104 | 118 | $result['wind']['unit'] = $matches[4]; |
105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
119 | + if ($result['wind']['unit'] == 'KT') { |
|
120 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
121 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
122 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
123 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
124 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
125 | + } |
|
108 | 126 | $result['wind']['gust'] = (float)$matches[3]; |
109 | 127 | $result['wind']['unit'] = $matches[4]; |
110 | 128 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -186,14 +204,23 @@ discard block |
||
186 | 204 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
187 | 205 | $type = $matches[1]; |
188 | 206 | $cloud = array(); |
189 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
207 | + if ($type == 'SKC') { |
|
208 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
209 | + } elseif ($type == 'CLR') { |
|
210 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
211 | + } elseif ($type == 'NSC') { |
|
212 | + $cloud['type'] = 'No significant cloud'; |
|
213 | + } elseif ($type == 'FEW') { |
|
214 | + $cloud['type'] = 'Few'; |
|
215 | + } elseif ($type == 'SCT') { |
|
216 | + $cloud['type'] = 'Scattered'; |
|
217 | + } elseif ($type == 'BKN') { |
|
218 | + $cloud['type'] = 'Broken'; |
|
219 | + } elseif ($type == 'OVC') { |
|
220 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
221 | + } elseif ($type == 'VV') { |
|
222 | + $cloud['type'] = 'Vertical visibility'; |
|
223 | + } |
|
197 | 224 | $cloud['type_code'] = $type; |
198 | 225 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
199 | 226 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -223,8 +250,11 @@ discard block |
||
223 | 250 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
224 | 251 | //echo $piece; |
225 | 252 | //print_r($matches); |
226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
253 | + if (isset($matches[5])) { |
|
254 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
255 | + } else { |
|
256 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
257 | + } |
|
228 | 258 | if (isset($matches[3])) { |
229 | 259 | $range = Array( |
230 | 260 | 'from' => (float)$matches[2], |
@@ -257,8 +287,11 @@ discard block |
||
257 | 287 | if (isset($matches[3])) { |
258 | 288 | $text[] = $this->texts[$matches[3]]; |
259 | 289 | } |
260 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
261 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
290 | + if (!isset($result['weather'])) { |
|
291 | + $result['weather'] = implode(' ', $text); |
|
292 | + } else { |
|
293 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
294 | + } |
|
262 | 295 | } |
263 | 296 | } |
264 | 297 | return $result; |
@@ -270,8 +303,11 @@ discard block |
||
270 | 303 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
271 | 304 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
272 | 305 | } else { |
273 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
306 | + if ($globalDBdriver == 'mysql') { |
|
307 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
308 | + } else { |
|
309 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
310 | + } |
|
275 | 311 | } |
276 | 312 | $query_values = array(':icao' => $icao); |
277 | 313 | try { |
@@ -326,7 +362,9 @@ discard block |
||
326 | 362 | |
327 | 363 | public function addMETARCycle() { |
328 | 364 | global $globalDebug, $globalIVAO; |
329 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
365 | + if (isset($globalDebug) && $globalDebug) { |
|
366 | + echo "Downloading METAR cycle..."; |
|
367 | + } |
|
330 | 368 | date_default_timezone_set("UTC"); |
331 | 369 | $Common = new Common(); |
332 | 370 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -339,7 +377,9 @@ discard block |
||
339 | 377 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
340 | 378 | } |
341 | 379 | if ($handle) { |
342 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
380 | + if (isset($globalDebug) && $globalDebug) { |
|
381 | + echo "Done - Updating DB..."; |
|
382 | + } |
|
343 | 383 | $date = ''; |
344 | 384 | //foreach(explode("\n",$cycle) as $line) { |
345 | 385 | while(($line = fgets($handle,4096)) !== false) { |
@@ -347,23 +387,33 @@ discard block |
||
347 | 387 | $date = $line; |
348 | 388 | } elseif ($line != '') { |
349 | 389 | //$this->parse($line); |
350 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
390 | + if ($date == '') { |
|
391 | + $date = date('Y/m/d H:m'); |
|
392 | + } |
|
351 | 393 | $pos = 0; |
352 | 394 | $pieces = preg_split('/\s/',$line); |
353 | - if ($pieces[0] == 'METAR') $pos++; |
|
354 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
395 | + if ($pieces[0] == 'METAR') { |
|
396 | + $pos++; |
|
397 | + } |
|
398 | + if (strlen($pieces[$pos]) != 4) { |
|
399 | + $pos++; |
|
400 | + } |
|
355 | 401 | $location = $pieces[$pos]; |
356 | 402 | echo $this->addMETAR($location,$line,$date); |
357 | 403 | } |
358 | 404 | } |
359 | 405 | fclose($handle); |
360 | 406 | } |
361 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
407 | + if (isset($globalDebug) && $globalDebug) { |
|
408 | + echo "Done\n"; |
|
409 | + } |
|
362 | 410 | |
363 | 411 | } |
364 | 412 | public function downloadMETAR($icao) { |
365 | 413 | global $globalMETARurl; |
366 | - if ($globalMETARurl == '') return array(); |
|
414 | + if ($globalMETARurl == '') { |
|
415 | + return array(); |
|
416 | + } |
|
367 | 417 | date_default_timezone_set("UTC"); |
368 | 418 | $Common = new Common(); |
369 | 419 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -377,16 +427,24 @@ discard block |
||
377 | 427 | if ($line != '') { |
378 | 428 | //$this->parse($line); |
379 | 429 | //echo $line; |
380 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
430 | + if ($date == '') { |
|
431 | + $date = date('Y/m/d H:m'); |
|
432 | + } |
|
381 | 433 | $pos = 0; |
382 | 434 | $pieces = preg_split('/\s/',$line); |
383 | - if ($pieces[0] == 'METAR') $pos++; |
|
384 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
435 | + if ($pieces[0] == 'METAR') { |
|
436 | + $pos++; |
|
437 | + } |
|
438 | + if (strlen($pieces[$pos]) != 4) { |
|
439 | + $pos++; |
|
440 | + } |
|
385 | 441 | $location = $pieces[$pos]; |
386 | 442 | if (strlen($location == 4)) { |
387 | 443 | $this->addMETAR($location,$line,$date); |
388 | 444 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
389 | - } else return array(); |
|
445 | + } else { |
|
446 | + return array(); |
|
447 | + } |
|
390 | 448 | } |
391 | 449 | //echo $line."\n"; |
392 | 450 | } |
@@ -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 | } |
@@ -77,7 +79,9 @@ discard block |
||
77 | 79 | } |
78 | 80 | } |
79 | 81 | public function getAllAirlineNames($filter_name = '') { |
80 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
82 | + if ($filter_name == '') { |
|
83 | + $filter_name = $this->filter_name; |
|
84 | + } |
|
81 | 85 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
82 | 86 | try { |
83 | 87 | $sth = $this->db->prepare($query); |
@@ -89,7 +93,9 @@ discard block |
||
89 | 93 | return $all; |
90 | 94 | } |
91 | 95 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
92 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
96 | + if ($filter_name == '') { |
|
97 | + $filter_name = $this->filter_name; |
|
98 | + } |
|
93 | 99 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
94 | 100 | try { |
95 | 101 | $sth = $this->db->prepare($query); |
@@ -101,7 +107,9 @@ discard block |
||
101 | 107 | return $all; |
102 | 108 | } |
103 | 109 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
104 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
110 | + if ($filter_name == '') { |
|
111 | + $filter_name = $this->filter_name; |
|
112 | + } |
|
105 | 113 | $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"; |
106 | 114 | try { |
107 | 115 | $sth = $this->db->prepare($query); |
@@ -113,7 +121,9 @@ discard block |
||
113 | 121 | return $all; |
114 | 122 | } |
115 | 123 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
116 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
124 | + if ($filter_name == '') { |
|
125 | + $filter_name = $this->filter_name; |
|
126 | + } |
|
117 | 127 | $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"; |
118 | 128 | try { |
119 | 129 | $sth = $this->db->prepare($query); |
@@ -128,9 +138,14 @@ discard block |
||
128 | 138 | |
129 | 139 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
130 | 140 | global $globalStatsFilters; |
131 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
132 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
133 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
141 | + if ($filter_name == '') { |
|
142 | + $filter_name = $this->filter_name; |
|
143 | + } |
|
144 | + if ($limit) { |
|
145 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
146 | + } else { |
|
147 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
148 | + } |
|
134 | 149 | try { |
135 | 150 | $sth = $this->db->prepare($query); |
136 | 151 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -150,9 +165,14 @@ discard block |
||
150 | 165 | } |
151 | 166 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
152 | 167 | global $globalStatsFilters; |
153 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
154 | - 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"; |
|
155 | - 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"; |
|
168 | + if ($filter_name == '') { |
|
169 | + $filter_name = $this->filter_name; |
|
170 | + } |
|
171 | + if ($limit) { |
|
172 | + $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"; |
|
173 | + } else { |
|
174 | + $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"; |
|
175 | + } |
|
156 | 176 | try { |
157 | 177 | $sth = $this->db->prepare($query); |
158 | 178 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -172,9 +192,14 @@ discard block |
||
172 | 192 | } |
173 | 193 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
174 | 194 | global $globalStatsFilters; |
175 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
176 | - 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"; |
|
177 | - 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"; |
|
195 | + if ($filter_name == '') { |
|
196 | + $filter_name = $this->filter_name; |
|
197 | + } |
|
198 | + if ($limit) { |
|
199 | + $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"; |
|
200 | + } else { |
|
201 | + $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"; |
|
202 | + } |
|
178 | 203 | try { |
179 | 204 | $sth = $this->db->prepare($query); |
180 | 205 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -195,9 +220,14 @@ discard block |
||
195 | 220 | |
196 | 221 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
197 | 222 | global $globalStatsFilters; |
198 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
199 | - 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"; |
|
200 | - 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"; |
|
223 | + if ($filter_name == '') { |
|
224 | + $filter_name = $this->filter_name; |
|
225 | + } |
|
226 | + if ($limit) { |
|
227 | + $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"; |
|
228 | + } else { |
|
229 | + $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"; |
|
230 | + } |
|
201 | 231 | try { |
202 | 232 | $sth = $this->db->prepare($query); |
203 | 233 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -217,9 +247,14 @@ discard block |
||
217 | 247 | } |
218 | 248 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
219 | 249 | global $globalStatsFilters; |
220 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
221 | - 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"; |
|
222 | - 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"; |
|
250 | + if ($filter_name == '') { |
|
251 | + $filter_name = $this->filter_name; |
|
252 | + } |
|
253 | + if ($limit) { |
|
254 | + $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"; |
|
255 | + } else { |
|
256 | + $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"; |
|
257 | + } |
|
223 | 258 | try { |
224 | 259 | $sth = $this->db->prepare($query); |
225 | 260 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -240,9 +275,14 @@ discard block |
||
240 | 275 | |
241 | 276 | public function countAllAirlines($limit = true,$filter_name = '') { |
242 | 277 | global $globalStatsFilters; |
243 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
244 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
245 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
|
278 | + if ($filter_name == '') { |
|
279 | + $filter_name = $this->filter_name; |
|
280 | + } |
|
281 | + if ($limit) { |
|
282 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
283 | + } else { |
|
284 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
|
285 | + } |
|
246 | 286 | try { |
247 | 287 | $sth = $this->db->prepare($query); |
248 | 288 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -263,9 +303,14 @@ discard block |
||
263 | 303 | } |
264 | 304 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
265 | 305 | global $globalStatsFilters; |
266 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
267 | - 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"; |
|
268 | - 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"; |
|
306 | + if ($filter_name == '') { |
|
307 | + $filter_name = $this->filter_name; |
|
308 | + } |
|
309 | + if ($limit) { |
|
310 | + $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"; |
|
311 | + } else { |
|
312 | + $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"; |
|
313 | + } |
|
269 | 314 | try { |
270 | 315 | $sth = $this->db->prepare($query); |
271 | 316 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -285,9 +330,14 @@ discard block |
||
285 | 330 | } |
286 | 331 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
287 | 332 | global $globalStatsFilters; |
288 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
289 | - 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"; |
|
290 | - 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"; |
|
333 | + if ($filter_name == '') { |
|
334 | + $filter_name = $this->filter_name; |
|
335 | + } |
|
336 | + if ($limit) { |
|
337 | + $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"; |
|
338 | + } else { |
|
339 | + $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"; |
|
340 | + } |
|
291 | 341 | try { |
292 | 342 | $sth = $this->db->prepare($query); |
293 | 343 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -307,10 +357,15 @@ discard block |
||
307 | 357 | } |
308 | 358 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
309 | 359 | $Connection = new Connection(); |
310 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
360 | + if ($filter_name == '') { |
|
361 | + $filter_name = $this->filter_name; |
|
362 | + } |
|
311 | 363 | if ($Connection->tableExists('countries')) { |
312 | - 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"; |
|
313 | - 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"; |
|
364 | + if ($limit) { |
|
365 | + $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"; |
|
366 | + } else { |
|
367 | + $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"; |
|
368 | + } |
|
314 | 369 | try { |
315 | 370 | $sth = $this->db->prepare($query); |
316 | 371 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -331,9 +386,14 @@ discard block |
||
331 | 386 | } |
332 | 387 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
333 | 388 | global $globalStatsFilters; |
334 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
335 | - 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"; |
|
336 | - 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"; |
|
389 | + if ($filter_name == '') { |
|
390 | + $filter_name = $this->filter_name; |
|
391 | + } |
|
392 | + if ($limit) { |
|
393 | + $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"; |
|
394 | + } else { |
|
395 | + $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"; |
|
396 | + } |
|
337 | 397 | try { |
338 | 398 | $sth = $this->db->prepare($query); |
339 | 399 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -353,9 +413,14 @@ discard block |
||
353 | 413 | } |
354 | 414 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
355 | 415 | global $globalStatsFilters; |
356 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
357 | - 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"; |
|
358 | - 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"; |
|
416 | + if ($filter_name == '') { |
|
417 | + $filter_name = $this->filter_name; |
|
418 | + } |
|
419 | + if ($limit) { |
|
420 | + $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"; |
|
421 | + } else { |
|
422 | + $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"; |
|
423 | + } |
|
359 | 424 | try { |
360 | 425 | $sth = $this->db->prepare($query); |
361 | 426 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -375,9 +440,14 @@ discard block |
||
375 | 440 | } |
376 | 441 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
377 | 442 | global $globalStatsFilters; |
378 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
379 | - 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"; |
|
380 | - 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"; |
|
443 | + if ($filter_name == '') { |
|
444 | + $filter_name = $this->filter_name; |
|
445 | + } |
|
446 | + if ($limit) { |
|
447 | + $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"; |
|
448 | + } else { |
|
449 | + $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"; |
|
450 | + } |
|
381 | 451 | try { |
382 | 452 | $sth = $this->db->prepare($query); |
383 | 453 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -403,7 +473,9 @@ discard block |
||
403 | 473 | $icao = $value['airport_departure_icao']; |
404 | 474 | if (isset($all[$icao])) { |
405 | 475 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
406 | - } else $all[$icao] = $value; |
|
476 | + } else { |
|
477 | + $all[$icao] = $value; |
|
478 | + } |
|
407 | 479 | } |
408 | 480 | $count = array(); |
409 | 481 | foreach ($all as $key => $row) { |
@@ -415,9 +487,14 @@ discard block |
||
415 | 487 | } |
416 | 488 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
417 | 489 | global $globalStatsFilters; |
418 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
419 | - 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"; |
|
420 | - 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"; |
|
490 | + if ($filter_name == '') { |
|
491 | + $filter_name = $this->filter_name; |
|
492 | + } |
|
493 | + if ($limit) { |
|
494 | + $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 { |
|
496 | + $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"; |
|
497 | + } |
|
421 | 498 | try { |
422 | 499 | $sth = $this->db->prepare($query); |
423 | 500 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -443,7 +520,9 @@ discard block |
||
443 | 520 | $icao = $value['airport_arrival_icao']; |
444 | 521 | if (isset($all[$icao])) { |
445 | 522 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
446 | - } else $all[$icao] = $value; |
|
523 | + } else { |
|
524 | + $all[$icao] = $value; |
|
525 | + } |
|
447 | 526 | } |
448 | 527 | $count = array(); |
449 | 528 | foreach ($all as $key => $row) { |
@@ -456,13 +535,21 @@ discard block |
||
456 | 535 | } |
457 | 536 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
458 | 537 | global $globalDBdriver, $globalStatsFilters; |
459 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
538 | + if ($filter_name == '') { |
|
539 | + $filter_name = $this->filter_name; |
|
540 | + } |
|
460 | 541 | if ($globalDBdriver == 'mysql') { |
461 | - 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"; |
|
462 | - 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"; |
|
542 | + if ($limit) { |
|
543 | + $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"; |
|
544 | + } else { |
|
545 | + $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"; |
|
546 | + } |
|
463 | 547 | } else { |
464 | - 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"; |
|
465 | - 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"; |
|
548 | + if ($limit) { |
|
549 | + $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"; |
|
550 | + } else { |
|
551 | + $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"; |
|
552 | + } |
|
466 | 553 | } |
467 | 554 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
468 | 555 | try { |
@@ -486,7 +573,9 @@ discard block |
||
486 | 573 | |
487 | 574 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
488 | 575 | global $globalStatsFilters; |
489 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
576 | + if ($filter_name == '') { |
|
577 | + $filter_name = $this->filter_name; |
|
578 | + } |
|
490 | 579 | $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"; |
491 | 580 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
492 | 581 | try { |
@@ -508,7 +597,9 @@ discard block |
||
508 | 597 | } |
509 | 598 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
510 | 599 | global $globalDBdriver, $globalStatsFilters; |
511 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
600 | + if ($filter_name == '') { |
|
601 | + $filter_name = $this->filter_name; |
|
602 | + } |
|
512 | 603 | if ($globalDBdriver == 'mysql') { |
513 | 604 | $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"; |
514 | 605 | } else { |
@@ -534,7 +625,9 @@ discard block |
||
534 | 625 | } |
535 | 626 | public function countAllDates($stats_airline = '',$filter_name = '') { |
536 | 627 | global $globalStatsFilters; |
537 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
628 | + if ($filter_name == '') { |
|
629 | + $filter_name = $this->filter_name; |
|
630 | + } |
|
538 | 631 | $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"; |
539 | 632 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
540 | 633 | try { |
@@ -556,7 +649,9 @@ discard block |
||
556 | 649 | } |
557 | 650 | public function countAllDatesByAirlines($filter_name = '') { |
558 | 651 | global $globalStatsFilters; |
559 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
652 | + if ($filter_name == '') { |
|
653 | + $filter_name = $this->filter_name; |
|
654 | + } |
|
560 | 655 | $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"; |
561 | 656 | $query_data = array('filter_name' => $filter_name); |
562 | 657 | try { |
@@ -578,7 +673,9 @@ discard block |
||
578 | 673 | } |
579 | 674 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
580 | 675 | global $globalStatsFilters; |
581 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
676 | + if ($filter_name == '') { |
|
677 | + $filter_name = $this->filter_name; |
|
678 | + } |
|
582 | 679 | $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"; |
583 | 680 | try { |
584 | 681 | $sth = $this->db->prepare($query); |
@@ -599,7 +696,9 @@ discard block |
||
599 | 696 | } |
600 | 697 | public function countAllMilitaryMonths($filter_name = '') { |
601 | 698 | global $globalStatsFilters; |
602 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
699 | + if ($filter_name == '') { |
|
700 | + $filter_name = $this->filter_name; |
|
701 | + } |
|
603 | 702 | $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"; |
604 | 703 | try { |
605 | 704 | $sth = $this->db->prepare($query); |
@@ -620,9 +719,14 @@ discard block |
||
620 | 719 | } |
621 | 720 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
622 | 721 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
623 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
624 | - 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"; |
|
625 | - 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"; |
|
722 | + if ($filter_name == '') { |
|
723 | + $filter_name = $this->filter_name; |
|
724 | + } |
|
725 | + if ($limit) { |
|
726 | + $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"; |
|
727 | + } else { |
|
728 | + $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"; |
|
729 | + } |
|
626 | 730 | if ($orderby == 'hour') { |
627 | 731 | /* |
628 | 732 | if ($globalDBdriver == 'mysql') { |
@@ -631,7 +735,9 @@ discard block |
||
631 | 735 | */ |
632 | 736 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
633 | 737 | } |
634 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
738 | + if ($orderby == 'count') { |
|
739 | + $query .= " ORDER BY hour_count DESC"; |
|
740 | + } |
|
635 | 741 | try { |
636 | 742 | $sth = $this->db->prepare($query); |
637 | 743 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -652,7 +758,9 @@ discard block |
||
652 | 758 | |
653 | 759 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
654 | 760 | global $globalStatsFilters; |
655 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
761 | + if ($filter_name == '') { |
|
762 | + $filter_name = $this->filter_name; |
|
763 | + } |
|
656 | 764 | $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
657 | 765 | if (empty($all)) { |
658 | 766 | $filters = array('airlines' => array($stats_airline)); |
@@ -666,7 +774,9 @@ discard block |
||
666 | 774 | } |
667 | 775 | public function countOverallMilitaryFlights($filter_name = '') { |
668 | 776 | global $globalStatsFilters; |
669 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
777 | + if ($filter_name == '') { |
|
778 | + $filter_name = $this->filter_name; |
|
779 | + } |
|
670 | 780 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
671 | 781 | if (empty($all)) { |
672 | 782 | $filters = array(); |
@@ -680,7 +790,9 @@ discard block |
||
680 | 790 | } |
681 | 791 | public function countOverallArrival($stats_airline = '',$filter_name = '') { |
682 | 792 | global $globalStatsFilters; |
683 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
793 | + if ($filter_name == '') { |
|
794 | + $filter_name = $this->filter_name; |
|
795 | + } |
|
684 | 796 | $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
685 | 797 | if (empty($all)) { |
686 | 798 | $filters = array('airlines' => array($stats_airline)); |
@@ -694,7 +806,9 @@ discard block |
||
694 | 806 | } |
695 | 807 | public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
696 | 808 | global $globalStatsFilters; |
697 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
809 | + if ($filter_name == '') { |
|
810 | + $filter_name = $this->filter_name; |
|
811 | + } |
|
698 | 812 | $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
699 | 813 | if (empty($all)) { |
700 | 814 | $filters = array('airlines' => array($stats_airline)); |
@@ -708,7 +822,9 @@ discard block |
||
708 | 822 | } |
709 | 823 | public function countOverallAirlines($filter_name = '') { |
710 | 824 | global $globalStatsFilters; |
711 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
825 | + if ($filter_name == '') { |
|
826 | + $filter_name = $this->filter_name; |
|
827 | + } |
|
712 | 828 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
713 | 829 | try { |
714 | 830 | $sth = $this->db->prepare($query); |
@@ -731,7 +847,9 @@ discard block |
||
731 | 847 | } |
732 | 848 | public function countOverallOwners($stats_airline = '',$filter_name = '') { |
733 | 849 | global $globalStatsFilters; |
734 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
850 | + if ($filter_name == '') { |
|
851 | + $filter_name = $this->filter_name; |
|
852 | + } |
|
735 | 853 | /* |
736 | 854 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner"; |
737 | 855 | try { |
@@ -756,7 +874,9 @@ discard block |
||
756 | 874 | } |
757 | 875 | public function countOverallPilots($stats_airline = '',$filter_name = '') { |
758 | 876 | global $globalStatsFilters; |
759 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
877 | + if ($filter_name == '') { |
|
878 | + $filter_name = $this->filter_name; |
|
879 | + } |
|
760 | 880 | $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
761 | 881 | if (empty($all)) { |
762 | 882 | $filters = array('airlines' => array($stats_airline)); |
@@ -770,7 +890,9 @@ discard block |
||
770 | 890 | } |
771 | 891 | |
772 | 892 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
773 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
893 | + if ($filter_name == '') { |
|
894 | + $filter_name = $this->filter_name; |
|
895 | + } |
|
774 | 896 | $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"; |
775 | 897 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
776 | 898 | try { |
@@ -783,7 +905,9 @@ discard block |
||
783 | 905 | return $all; |
784 | 906 | } |
785 | 907 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
786 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
908 | + if ($filter_name == '') { |
|
909 | + $filter_name = $this->filter_name; |
|
910 | + } |
|
787 | 911 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
788 | 912 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
789 | 913 | try { |
@@ -796,7 +920,9 @@ discard block |
||
796 | 920 | return $all; |
797 | 921 | } |
798 | 922 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
799 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
923 | + if ($filter_name == '') { |
|
924 | + $filter_name = $this->filter_name; |
|
925 | + } |
|
800 | 926 | global $globalArchiveMonths, $globalDBdriver; |
801 | 927 | if ($globalDBdriver == 'mysql') { |
802 | 928 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -815,7 +941,9 @@ discard block |
||
815 | 941 | } |
816 | 942 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
817 | 943 | global $globalArchiveMonths, $globalDBdriver; |
818 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
944 | + if ($filter_name == '') { |
|
945 | + $filter_name = $this->filter_name; |
|
946 | + } |
|
819 | 947 | if ($globalDBdriver == 'mysql') { |
820 | 948 | $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"; |
821 | 949 | } else { |
@@ -833,7 +961,9 @@ discard block |
||
833 | 961 | } |
834 | 962 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
835 | 963 | global $globalArchiveMonths, $globalDBdriver; |
836 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
964 | + if ($filter_name == '') { |
|
965 | + $filter_name = $this->filter_name; |
|
966 | + } |
|
837 | 967 | if ($globalDBdriver == 'mysql') { |
838 | 968 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
839 | 969 | } else { |
@@ -850,7 +980,9 @@ discard block |
||
850 | 980 | } |
851 | 981 | public function getStatsAirlineTotal($filter_name = '') { |
852 | 982 | global $globalArchiveMonths, $globalDBdriver; |
853 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
983 | + if ($filter_name == '') { |
|
984 | + $filter_name = $this->filter_name; |
|
985 | + } |
|
854 | 986 | if ($globalDBdriver == 'mysql') { |
855 | 987 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
856 | 988 | } else { |
@@ -867,7 +999,9 @@ discard block |
||
867 | 999 | } |
868 | 1000 | public function getStatsOwnerTotal($filter_name = '') { |
869 | 1001 | global $globalArchiveMonths, $globalDBdriver; |
870 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1002 | + if ($filter_name == '') { |
|
1003 | + $filter_name = $this->filter_name; |
|
1004 | + } |
|
871 | 1005 | if ($globalDBdriver == 'mysql') { |
872 | 1006 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
873 | 1007 | } else { |
@@ -884,7 +1018,9 @@ discard block |
||
884 | 1018 | } |
885 | 1019 | public function getStatsPilotTotal($filter_name = '') { |
886 | 1020 | global $globalArchiveMonths, $globalDBdriver; |
887 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1021 | + if ($filter_name == '') { |
|
1022 | + $filter_name = $this->filter_name; |
|
1023 | + } |
|
888 | 1024 | if ($globalDBdriver == 'mysql') { |
889 | 1025 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
890 | 1026 | } else { |
@@ -902,7 +1038,9 @@ discard block |
||
902 | 1038 | |
903 | 1039 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
904 | 1040 | global $globalDBdriver; |
905 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1041 | + if ($filter_name == '') { |
|
1042 | + $filter_name = $this->filter_name; |
|
1043 | + } |
|
906 | 1044 | if ($globalDBdriver == 'mysql') { |
907 | 1045 | $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"; |
908 | 1046 | } else { |
@@ -918,7 +1056,9 @@ discard block |
||
918 | 1056 | } |
919 | 1057 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
920 | 1058 | global $globalDBdriver; |
921 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1059 | + if ($filter_name == '') { |
|
1060 | + $filter_name = $this->filter_name; |
|
1061 | + } |
|
922 | 1062 | if ($globalDBdriver == 'mysql') { |
923 | 1063 | $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"; |
924 | 1064 | } else { |
@@ -1401,47 +1541,69 @@ discard block |
||
1401 | 1541 | $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
1402 | 1542 | } else { |
1403 | 1543 | */ |
1404 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1405 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1544 | + if ($globalDebug) { |
|
1545 | + echo 'Update stats !'."\n"; |
|
1546 | + } |
|
1547 | + if ($globalDebug) { |
|
1548 | + echo 'Count all aircraft types...'."\n"; |
|
1549 | + } |
|
1406 | 1550 | if (isset($last_update[0]['value'])) { |
1407 | 1551 | $last_update_day = $last_update[0]['value']; |
1408 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1552 | + } else { |
|
1553 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1554 | + } |
|
1409 | 1555 | $Spotter = new Spotter($this->db); |
1410 | 1556 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1411 | 1557 | foreach ($alldata as $number) { |
1412 | 1558 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
1413 | 1559 | } |
1414 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1560 | + if ($globalDebug) { |
|
1561 | + echo 'Count all airlines...'."\n"; |
|
1562 | + } |
|
1415 | 1563 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1416 | 1564 | foreach ($alldata as $number) { |
1417 | 1565 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
1418 | 1566 | } |
1419 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1567 | + if ($globalDebug) { |
|
1568 | + echo 'Count all registrations...'."\n"; |
|
1569 | + } |
|
1420 | 1570 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1421 | 1571 | foreach ($alldata as $number) { |
1422 | 1572 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
1423 | 1573 | } |
1424 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1574 | + if ($globalDebug) { |
|
1575 | + echo 'Count all callsigns...'."\n"; |
|
1576 | + } |
|
1425 | 1577 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1426 | 1578 | foreach ($alldata as $number) { |
1427 | 1579 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1428 | 1580 | } |
1429 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1581 | + if ($globalDebug) { |
|
1582 | + echo 'Count all owners...'."\n"; |
|
1583 | + } |
|
1430 | 1584 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1431 | 1585 | foreach ($alldata as $number) { |
1432 | 1586 | $this->addStatOwner($number['owner_name'],$number['owner_count']); |
1433 | 1587 | } |
1434 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1588 | + if ($globalDebug) { |
|
1589 | + echo 'Count all pilots...'."\n"; |
|
1590 | + } |
|
1435 | 1591 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1436 | 1592 | foreach ($alldata as $number) { |
1437 | 1593 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']); |
1438 | 1594 | } |
1439 | 1595 | |
1440 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1596 | + if ($globalDebug) { |
|
1597 | + echo 'Count all departure airports...'."\n"; |
|
1598 | + } |
|
1441 | 1599 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1442 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1600 | + if ($globalDebug) { |
|
1601 | + echo 'Count all detected departure airports...'."\n"; |
|
1602 | + } |
|
1443 | 1603 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1444 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1604 | + if ($globalDebug) { |
|
1605 | + echo 'Order departure airports...'."\n"; |
|
1606 | + } |
|
1445 | 1607 | $alldata = array(); |
1446 | 1608 | |
1447 | 1609 | foreach ($pall as $value) { |
@@ -1452,7 +1614,9 @@ discard block |
||
1452 | 1614 | $icao = $value['airport_departure_icao']; |
1453 | 1615 | if (isset($alldata[$icao])) { |
1454 | 1616 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1455 | - } else $alldata[$icao] = $value; |
|
1617 | + } else { |
|
1618 | + $alldata[$icao] = $value; |
|
1619 | + } |
|
1456 | 1620 | } |
1457 | 1621 | $count = array(); |
1458 | 1622 | foreach ($alldata as $key => $row) { |
@@ -1462,11 +1626,17 @@ discard block |
||
1462 | 1626 | foreach ($alldata as $number) { |
1463 | 1627 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
1464 | 1628 | } |
1465 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1629 | + if ($globalDebug) { |
|
1630 | + echo 'Count all arrival airports...'."\n"; |
|
1631 | + } |
|
1466 | 1632 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1467 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1633 | + if ($globalDebug) { |
|
1634 | + echo 'Count all detected arrival airports...'."\n"; |
|
1635 | + } |
|
1468 | 1636 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1469 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1637 | + if ($globalDebug) { |
|
1638 | + echo 'Order arrival airports...'."\n"; |
|
1639 | + } |
|
1470 | 1640 | $alldata = array(); |
1471 | 1641 | foreach ($pall as $value) { |
1472 | 1642 | $icao = $value['airport_arrival_icao']; |
@@ -1476,7 +1646,9 @@ discard block |
||
1476 | 1646 | $icao = $value['airport_arrival_icao']; |
1477 | 1647 | if (isset($alldata[$icao])) { |
1478 | 1648 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1479 | - } else $alldata[$icao] = $value; |
|
1649 | + } else { |
|
1650 | + $alldata[$icao] = $value; |
|
1651 | + } |
|
1480 | 1652 | } |
1481 | 1653 | $count = array(); |
1482 | 1654 | foreach ($alldata as $key => $row) { |
@@ -1487,7 +1659,9 @@ discard block |
||
1487 | 1659 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1488 | 1660 | } |
1489 | 1661 | if ($Connection->tableExists('countries')) { |
1490 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1662 | + if ($globalDebug) { |
|
1663 | + echo 'Count all flights by countries...'."\n"; |
|
1664 | + } |
|
1491 | 1665 | $SpotterArchive = new SpotterArchive(); |
1492 | 1666 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1493 | 1667 | foreach ($alldata as $number) { |
@@ -1499,46 +1673,66 @@ discard block |
||
1499 | 1673 | // Add by month using getstat if month finish... |
1500 | 1674 | |
1501 | 1675 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1502 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1676 | + if ($globalDebug) { |
|
1677 | + echo 'Count all flights by months...'."\n"; |
|
1678 | + } |
|
1503 | 1679 | $Spotter = new Spotter($this->db); |
1504 | 1680 | $alldata = $Spotter->countAllMonths(); |
1505 | 1681 | $lastyear = false; |
1506 | 1682 | foreach ($alldata as $number) { |
1507 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1683 | + if ($number['year_name'] != date('Y')) { |
|
1684 | + $lastyear = true; |
|
1685 | + } |
|
1508 | 1686 | $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']))); |
1509 | 1687 | } |
1510 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1688 | + if ($globalDebug) { |
|
1689 | + echo 'Count all military flights by months...'."\n"; |
|
1690 | + } |
|
1511 | 1691 | $alldata = $Spotter->countAllMilitaryMonths(); |
1512 | 1692 | foreach ($alldata as $number) { |
1513 | 1693 | $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']))); |
1514 | 1694 | } |
1515 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1695 | + if ($globalDebug) { |
|
1696 | + echo 'Count all owners by months...'."\n"; |
|
1697 | + } |
|
1516 | 1698 | $alldata = $Spotter->countAllMonthsOwners(); |
1517 | 1699 | foreach ($alldata as $number) { |
1518 | 1700 | $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']))); |
1519 | 1701 | } |
1520 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1702 | + if ($globalDebug) { |
|
1703 | + echo 'Count all pilots by months...'."\n"; |
|
1704 | + } |
|
1521 | 1705 | $alldata = $Spotter->countAllMonthsPilots(); |
1522 | 1706 | foreach ($alldata as $number) { |
1523 | 1707 | $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']))); |
1524 | 1708 | } |
1525 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1709 | + if ($globalDebug) { |
|
1710 | + echo 'Count all airlines by months...'."\n"; |
|
1711 | + } |
|
1526 | 1712 | $alldata = $Spotter->countAllMonthsAirlines(); |
1527 | 1713 | foreach ($alldata as $number) { |
1528 | 1714 | $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']))); |
1529 | 1715 | } |
1530 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1716 | + if ($globalDebug) { |
|
1717 | + echo 'Count all aircrafts by months...'."\n"; |
|
1718 | + } |
|
1531 | 1719 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1532 | 1720 | foreach ($alldata as $number) { |
1533 | 1721 | $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']))); |
1534 | 1722 | } |
1535 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1723 | + if ($globalDebug) { |
|
1724 | + echo 'Count all real arrivals by months...'."\n"; |
|
1725 | + } |
|
1536 | 1726 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1537 | 1727 | foreach ($alldata as $number) { |
1538 | 1728 | $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']))); |
1539 | 1729 | } |
1540 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1541 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1730 | + if ($globalDebug) { |
|
1731 | + echo 'Airports data...'."\n"; |
|
1732 | + } |
|
1733 | + if ($globalDebug) { |
|
1734 | + echo '...Departure'."\n"; |
|
1735 | + } |
|
1542 | 1736 | $this->deleteStatAirport('daily'); |
1543 | 1737 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1544 | 1738 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1658,37 +1852,53 @@ discard block |
||
1658 | 1852 | |
1659 | 1853 | // Count by airlines |
1660 | 1854 | echo '--- Stats by airlines ---'."\n"; |
1661 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
1855 | + if ($globalDebug) { |
|
1856 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
1857 | + } |
|
1662 | 1858 | $Spotter = new Spotter($this->db); |
1663 | 1859 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1664 | 1860 | foreach ($alldata as $number) { |
1665 | 1861 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
1666 | 1862 | } |
1667 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1863 | + if ($globalDebug) { |
|
1864 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1865 | + } |
|
1668 | 1866 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1669 | 1867 | foreach ($alldata as $number) { |
1670 | 1868 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
1671 | 1869 | } |
1672 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
1870 | + if ($globalDebug) { |
|
1871 | + echo 'Count all callsigns by airlines...'."\n"; |
|
1872 | + } |
|
1673 | 1873 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1674 | 1874 | foreach ($alldata as $number) { |
1675 | 1875 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1676 | 1876 | } |
1677 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
1877 | + if ($globalDebug) { |
|
1878 | + echo 'Count all owners by airlines...'."\n"; |
|
1879 | + } |
|
1678 | 1880 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1679 | 1881 | foreach ($alldata as $number) { |
1680 | 1882 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
1681 | 1883 | } |
1682 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
1884 | + if ($globalDebug) { |
|
1885 | + echo 'Count all pilots by airlines...'."\n"; |
|
1886 | + } |
|
1683 | 1887 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1684 | 1888 | foreach ($alldata as $number) { |
1685 | 1889 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']); |
1686 | 1890 | } |
1687 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
1891 | + if ($globalDebug) { |
|
1892 | + echo 'Count all departure airports by airlines...'."\n"; |
|
1893 | + } |
|
1688 | 1894 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1689 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
1895 | + if ($globalDebug) { |
|
1896 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
1897 | + } |
|
1690 | 1898 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1691 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
1899 | + if ($globalDebug) { |
|
1900 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
1901 | + } |
|
1692 | 1902 | //$alldata = array(); |
1693 | 1903 | foreach ($dall as $value) { |
1694 | 1904 | $icao = $value['airport_departure_icao']; |
@@ -1709,11 +1919,17 @@ discard block |
||
1709 | 1919 | foreach ($alldata as $number) { |
1710 | 1920 | 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']); |
1711 | 1921 | } |
1712 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
1922 | + if ($globalDebug) { |
|
1923 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
1924 | + } |
|
1713 | 1925 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1714 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1926 | + if ($globalDebug) { |
|
1927 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1928 | + } |
|
1715 | 1929 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1716 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
1930 | + if ($globalDebug) { |
|
1931 | + echo 'Order arrival airports by airlines...'."\n"; |
|
1932 | + } |
|
1717 | 1933 | //$alldata = array(); |
1718 | 1934 | foreach ($dall as $value) { |
1719 | 1935 | $icao = $value['airport_arrival_icao']; |
@@ -1732,37 +1948,53 @@ discard block |
||
1732 | 1948 | } |
1733 | 1949 | $alldata = $pall; |
1734 | 1950 | foreach ($alldata as $number) { |
1735 | - 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']); |
|
1951 | + if ($number['airline_icao'] != '') { |
|
1952 | + 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']); |
|
1953 | + } |
|
1954 | + } |
|
1955 | + if ($globalDebug) { |
|
1956 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1736 | 1957 | } |
1737 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1738 | 1958 | $Spotter = new Spotter($this->db); |
1739 | 1959 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1740 | 1960 | $lastyear = false; |
1741 | 1961 | foreach ($alldata as $number) { |
1742 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1962 | + if ($number['year_name'] != date('Y')) { |
|
1963 | + $lastyear = true; |
|
1964 | + } |
|
1743 | 1965 | $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']); |
1744 | 1966 | } |
1745 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
1967 | + if ($globalDebug) { |
|
1968 | + echo 'Count all owners by months by airlines...'."\n"; |
|
1969 | + } |
|
1746 | 1970 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1747 | 1971 | foreach ($alldata as $number) { |
1748 | 1972 | $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']); |
1749 | 1973 | } |
1750 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
1974 | + if ($globalDebug) { |
|
1975 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
1976 | + } |
|
1751 | 1977 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1752 | 1978 | foreach ($alldata as $number) { |
1753 | 1979 | $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']); |
1754 | 1980 | } |
1755 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1981 | + if ($globalDebug) { |
|
1982 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1983 | + } |
|
1756 | 1984 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1757 | 1985 | foreach ($alldata as $number) { |
1758 | 1986 | $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']); |
1759 | 1987 | } |
1760 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1988 | + if ($globalDebug) { |
|
1989 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1990 | + } |
|
1761 | 1991 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1762 | 1992 | foreach ($alldata as $number) { |
1763 | 1993 | $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']); |
1764 | 1994 | } |
1765 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1995 | + if ($globalDebug) { |
|
1996 | + echo '...Departure'."\n"; |
|
1997 | + } |
|
1766 | 1998 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1767 | 1999 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1768 | 2000 | foreach ($dall as $value) { |
@@ -1785,7 +2017,9 @@ discard block |
||
1785 | 2017 | foreach ($alldata as $number) { |
1786 | 2018 | $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']); |
1787 | 2019 | } |
1788 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2020 | + if ($globalDebug) { |
|
2021 | + echo '...Arrival'."\n"; |
|
2022 | + } |
|
1789 | 2023 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1790 | 2024 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1791 | 2025 | foreach ($dall as $value) { |
@@ -1809,13 +2043,19 @@ discard block |
||
1809 | 2043 | $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']); |
1810 | 2044 | } |
1811 | 2045 | |
1812 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1813 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2046 | + if ($globalDebug) { |
|
2047 | + echo 'Flights data...'."\n"; |
|
2048 | + } |
|
2049 | + if ($globalDebug) { |
|
2050 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2051 | + } |
|
1814 | 2052 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1815 | 2053 | foreach ($alldata as $number) { |
1816 | 2054 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1817 | 2055 | } |
1818 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2056 | + if ($globalDebug) { |
|
2057 | + echo '-> countAllDates...'."\n"; |
|
2058 | + } |
|
1819 | 2059 | //$previousdata = $this->countAllDatesByAirlines(); |
1820 | 2060 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1821 | 2061 | $values = array(); |
@@ -1828,14 +2068,18 @@ discard block |
||
1828 | 2068 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1829 | 2069 | } |
1830 | 2070 | |
1831 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2071 | + if ($globalDebug) { |
|
2072 | + echo '-> countAllHours...'."\n"; |
|
2073 | + } |
|
1832 | 2074 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1833 | 2075 | foreach ($alldata as $number) { |
1834 | 2076 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
1835 | 2077 | } |
1836 | 2078 | |
1837 | 2079 | |
1838 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2080 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2081 | + $globalStatsFilters = array(); |
|
2082 | + } |
|
1839 | 2083 | foreach ($globalStatsFilters as $name => $filter) { |
1840 | 2084 | //$filter_name = $filter['name']; |
1841 | 2085 | $filter_name = $name; |
@@ -1843,10 +2087,14 @@ discard block |
||
1843 | 2087 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
1844 | 2088 | if (isset($last_update[0]['value'])) { |
1845 | 2089 | $last_update_day = $last_update[0]['value']; |
1846 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2090 | + } else { |
|
2091 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2092 | + } |
|
1847 | 2093 | |
1848 | 2094 | // Count by filter |
1849 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2095 | + if ($globalDebug) { |
|
2096 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2097 | + } |
|
1850 | 2098 | $Spotter = new Spotter($this->db); |
1851 | 2099 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
1852 | 2100 | foreach ($alldata as $number) { |
@@ -1883,7 +2131,9 @@ discard block |
||
1883 | 2131 | $icao = $value['airport_departure_icao']; |
1884 | 2132 | if (isset($alldata[$icao])) { |
1885 | 2133 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1886 | - } else $alldata[$icao] = $value; |
|
2134 | + } else { |
|
2135 | + $alldata[$icao] = $value; |
|
2136 | + } |
|
1887 | 2137 | } |
1888 | 2138 | $count = array(); |
1889 | 2139 | foreach ($alldata as $key => $row) { |
@@ -1904,7 +2154,9 @@ discard block |
||
1904 | 2154 | $icao = $value['airport_arrival_icao']; |
1905 | 2155 | if (isset($alldata[$icao])) { |
1906 | 2156 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1907 | - } else $alldata[$icao] = $value; |
|
2157 | + } else { |
|
2158 | + $alldata[$icao] = $value; |
|
2159 | + } |
|
1908 | 2160 | } |
1909 | 2161 | $count = array(); |
1910 | 2162 | foreach ($alldata as $key => $row) { |
@@ -1918,7 +2170,9 @@ discard block |
||
1918 | 2170 | $alldata = $Spotter->countAllMonths($filter); |
1919 | 2171 | $lastyear = false; |
1920 | 2172 | foreach ($alldata as $number) { |
1921 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2173 | + if ($number['year_name'] != date('Y')) { |
|
2174 | + $lastyear = true; |
|
2175 | + } |
|
1922 | 2176 | $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); |
1923 | 2177 | } |
1924 | 2178 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -15,33 +15,33 @@ discard block |
||
15 | 15 | if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
16 | 16 | $Connection = new Connection($dbc); |
17 | 17 | $this->db = $Connection->db(); |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | 20 | public function addLastStatsUpdate($type,$stats_date) { |
21 | - $query = "DELETE FROM config WHERE name = :type; |
|
21 | + $query = "DELETE FROM config WHERE name = :type; |
|
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | - try { |
|
25 | - $sth = $this->db->prepare($query); |
|
26 | - $sth->execute($query_values); |
|
27 | - } catch(PDOException $e) { |
|
28 | - return "error : ".$e->getMessage(); |
|
29 | - } |
|
30 | - } |
|
23 | + $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | + try { |
|
25 | + $sth = $this->db->prepare($query); |
|
26 | + $sth->execute($query_values); |
|
27 | + } catch(PDOException $e) { |
|
28 | + return "error : ".$e->getMessage(); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | 32 | public function getLastStatsUpdate($type = 'last_update_stats') { |
33 | - $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | - try { |
|
35 | - $sth = $this->db->prepare($query); |
|
36 | - $sth->execute(array(':type' => $type)); |
|
37 | - } catch(PDOException $e) { |
|
38 | - echo "error : ".$e->getMessage(); |
|
39 | - } |
|
40 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | - return $all; |
|
42 | - } |
|
43 | - public function deleteStats($filter_name = '') { |
|
44 | - /* |
|
33 | + $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | + try { |
|
35 | + $sth = $this->db->prepare($query); |
|
36 | + $sth->execute(array(':type' => $type)); |
|
37 | + } catch(PDOException $e) { |
|
38 | + echo "error : ".$e->getMessage(); |
|
39 | + } |
|
40 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | + return $all; |
|
42 | + } |
|
43 | + public function deleteStats($filter_name = '') { |
|
44 | + /* |
|
45 | 45 | $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
46 | 46 | try { |
47 | 47 | $sth = $this->db->prepare($query); |
@@ -50,80 +50,80 @@ discard block |
||
50 | 50 | return "error : ".$e->getMessage(); |
51 | 51 | } |
52 | 52 | */ |
53 | - $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
54 | - try { |
|
55 | - $sth = $this->db->prepare($query); |
|
56 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
57 | - } catch(PDOException $e) { |
|
58 | - return "error : ".$e->getMessage(); |
|
59 | - } |
|
60 | - } |
|
61 | - public function deleteOldStats($filter_name = '') { |
|
53 | + $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
54 | + try { |
|
55 | + $sth = $this->db->prepare($query); |
|
56 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
57 | + } catch(PDOException $e) { |
|
58 | + return "error : ".$e->getMessage(); |
|
59 | + } |
|
60 | + } |
|
61 | + public function deleteOldStats($filter_name = '') { |
|
62 | 62 | |
63 | - $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
64 | - try { |
|
65 | - $sth = $this->db->prepare($query); |
|
66 | - $sth->execute(); |
|
67 | - } catch(PDOException $e) { |
|
68 | - return "error : ".$e->getMessage(); |
|
69 | - } |
|
63 | + $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
64 | + try { |
|
65 | + $sth = $this->db->prepare($query); |
|
66 | + $sth->execute(); |
|
67 | + } catch(PDOException $e) { |
|
68 | + return "error : ".$e->getMessage(); |
|
69 | + } |
|
70 | 70 | |
71 | - $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
72 | - try { |
|
73 | - $sth = $this->db->prepare($query); |
|
74 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
75 | - } catch(PDOException $e) { |
|
76 | - return "error : ".$e->getMessage(); |
|
77 | - } |
|
78 | - } |
|
71 | + $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
72 | + try { |
|
73 | + $sth = $this->db->prepare($query); |
|
74 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
75 | + } catch(PDOException $e) { |
|
76 | + return "error : ".$e->getMessage(); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | public function getAllAirlineNames($filter_name = '') { |
80 | 80 | if ($filter_name == '') $filter_name = $this->filter_name; |
81 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
82 | - try { |
|
83 | - $sth = $this->db->prepare($query); |
|
84 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
85 | - } catch(PDOException $e) { |
|
86 | - echo "error : ".$e->getMessage(); |
|
87 | - } |
|
88 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
89 | - return $all; |
|
90 | - } |
|
81 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
82 | + try { |
|
83 | + $sth = $this->db->prepare($query); |
|
84 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
85 | + } catch(PDOException $e) { |
|
86 | + echo "error : ".$e->getMessage(); |
|
87 | + } |
|
88 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
89 | + return $all; |
|
90 | + } |
|
91 | 91 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
92 | 92 | if ($filter_name == '') $filter_name = $this->filter_name; |
93 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
94 | - try { |
|
95 | - $sth = $this->db->prepare($query); |
|
96 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | - } catch(PDOException $e) { |
|
98 | - echo "error : ".$e->getMessage(); |
|
99 | - } |
|
100 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
101 | - return $all; |
|
102 | - } |
|
93 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
94 | + try { |
|
95 | + $sth = $this->db->prepare($query); |
|
96 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | + } catch(PDOException $e) { |
|
98 | + echo "error : ".$e->getMessage(); |
|
99 | + } |
|
100 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
101 | + return $all; |
|
102 | + } |
|
103 | 103 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
104 | 104 | if ($filter_name == '') $filter_name = $this->filter_name; |
105 | - $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"; |
|
106 | - try { |
|
107 | - $sth = $this->db->prepare($query); |
|
108 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | - } catch(PDOException $e) { |
|
110 | - echo "error : ".$e->getMessage(); |
|
111 | - } |
|
112 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
113 | - return $all; |
|
114 | - } |
|
105 | + $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"; |
|
106 | + try { |
|
107 | + $sth = $this->db->prepare($query); |
|
108 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | + } catch(PDOException $e) { |
|
110 | + echo "error : ".$e->getMessage(); |
|
111 | + } |
|
112 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
113 | + return $all; |
|
114 | + } |
|
115 | 115 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
116 | 116 | if ($filter_name == '') $filter_name = $this->filter_name; |
117 | - $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"; |
|
118 | - try { |
|
119 | - $sth = $this->db->prepare($query); |
|
120 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | - } catch(PDOException $e) { |
|
122 | - echo "error : ".$e->getMessage(); |
|
123 | - } |
|
124 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
125 | - return $all; |
|
126 | - } |
|
117 | + $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"; |
|
118 | + try { |
|
119 | + $sth = $this->db->prepare($query); |
|
120 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | + } catch(PDOException $e) { |
|
122 | + echo "error : ".$e->getMessage(); |
|
123 | + } |
|
124 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
125 | + return $all; |
|
126 | + } |
|
127 | 127 | |
128 | 128 | |
129 | 129 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -131,66 +131,66 @@ discard block |
||
131 | 131 | if ($filter_name == '') $filter_name = $this->filter_name; |
132 | 132 | if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
133 | 133 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
134 | - try { |
|
135 | - $sth = $this->db->prepare($query); |
|
136 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
137 | - } catch(PDOException $e) { |
|
138 | - echo "error : ".$e->getMessage(); |
|
139 | - } |
|
140 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
141 | - if (empty($all)) { |
|
142 | - $filters = array('airlines' => array($stats_airline)); |
|
143 | - if ($filter_name != '') { |
|
144 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
145 | - } |
|
146 | - $Spotter = new Spotter($this->db); |
|
147 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
148 | - } |
|
149 | - return $all; |
|
134 | + try { |
|
135 | + $sth = $this->db->prepare($query); |
|
136 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
137 | + } catch(PDOException $e) { |
|
138 | + echo "error : ".$e->getMessage(); |
|
139 | + } |
|
140 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
141 | + if (empty($all)) { |
|
142 | + $filters = array('airlines' => array($stats_airline)); |
|
143 | + if ($filter_name != '') { |
|
144 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
145 | + } |
|
146 | + $Spotter = new Spotter($this->db); |
|
147 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
148 | + } |
|
149 | + return $all; |
|
150 | 150 | } |
151 | 151 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
152 | 152 | global $globalStatsFilters; |
153 | 153 | if ($filter_name == '') $filter_name = $this->filter_name; |
154 | 154 | 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"; |
155 | 155 | 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"; |
156 | - try { |
|
157 | - $sth = $this->db->prepare($query); |
|
158 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
159 | - } catch(PDOException $e) { |
|
160 | - echo "error : ".$e->getMessage(); |
|
161 | - } |
|
162 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
163 | - if (empty($all)) { |
|
164 | - $Spotter = new Spotter($this->db); |
|
165 | - $filters = array(); |
|
166 | - if ($filter_name != '') { |
|
167 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
168 | - } |
|
169 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
170 | - } |
|
171 | - return $all; |
|
156 | + try { |
|
157 | + $sth = $this->db->prepare($query); |
|
158 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
159 | + } catch(PDOException $e) { |
|
160 | + echo "error : ".$e->getMessage(); |
|
161 | + } |
|
162 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
163 | + if (empty($all)) { |
|
164 | + $Spotter = new Spotter($this->db); |
|
165 | + $filters = array(); |
|
166 | + if ($filter_name != '') { |
|
167 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
168 | + } |
|
169 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
170 | + } |
|
171 | + return $all; |
|
172 | 172 | } |
173 | 173 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
174 | 174 | global $globalStatsFilters; |
175 | 175 | if ($filter_name == '') $filter_name = $this->filter_name; |
176 | 176 | 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"; |
177 | 177 | 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"; |
178 | - try { |
|
179 | - $sth = $this->db->prepare($query); |
|
180 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
181 | - } catch(PDOException $e) { |
|
182 | - echo "error : ".$e->getMessage(); |
|
183 | - } |
|
184 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
185 | - if (empty($all)) { |
|
186 | - $filters = array('airlines' => array($stats_airline)); |
|
187 | - if ($filter_name != '') { |
|
188 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
178 | + try { |
|
179 | + $sth = $this->db->prepare($query); |
|
180 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
181 | + } catch(PDOException $e) { |
|
182 | + echo "error : ".$e->getMessage(); |
|
183 | + } |
|
184 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
185 | + if (empty($all)) { |
|
186 | + $filters = array('airlines' => array($stats_airline)); |
|
187 | + if ($filter_name != '') { |
|
188 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
189 | 189 | } |
190 | - $Spotter = new Spotter($this->db); |
|
190 | + $Spotter = new Spotter($this->db); |
|
191 | 191 | $all = $Spotter->countAllAircraftManufacturers($filters); |
192 | - } |
|
193 | - return $all; |
|
192 | + } |
|
193 | + return $all; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -198,44 +198,44 @@ discard block |
||
198 | 198 | if ($filter_name == '') $filter_name = $this->filter_name; |
199 | 199 | 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"; |
200 | 200 | 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"; |
201 | - try { |
|
202 | - $sth = $this->db->prepare($query); |
|
203 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
204 | - } catch(PDOException $e) { |
|
205 | - echo "error : ".$e->getMessage(); |
|
206 | - } |
|
207 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
208 | - if (empty($all)) { |
|
201 | + try { |
|
202 | + $sth = $this->db->prepare($query); |
|
203 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
204 | + } catch(PDOException $e) { |
|
205 | + echo "error : ".$e->getMessage(); |
|
206 | + } |
|
207 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
208 | + if (empty($all)) { |
|
209 | 209 | $filters = array('airlines' => array($stats_airline)); |
210 | 210 | if ($filter_name != '') { |
211 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
211 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
212 | 212 | } |
213 | 213 | $Spotter = new Spotter($this->db); |
214 | 214 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
215 | - } |
|
216 | - return $all; |
|
215 | + } |
|
216 | + return $all; |
|
217 | 217 | } |
218 | 218 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
219 | 219 | global $globalStatsFilters; |
220 | 220 | if ($filter_name == '') $filter_name = $this->filter_name; |
221 | 221 | 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"; |
222 | 222 | 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"; |
223 | - try { |
|
224 | - $sth = $this->db->prepare($query); |
|
225 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
226 | - } catch(PDOException $e) { |
|
227 | - echo "error : ".$e->getMessage(); |
|
228 | - } |
|
229 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
230 | - if (empty($all)) { |
|
223 | + try { |
|
224 | + $sth = $this->db->prepare($query); |
|
225 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
226 | + } catch(PDOException $e) { |
|
227 | + echo "error : ".$e->getMessage(); |
|
228 | + } |
|
229 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
230 | + if (empty($all)) { |
|
231 | 231 | $filters = array('airlines' => array($stats_airline)); |
232 | 232 | if ($filter_name != '') { |
233 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
233 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
234 | 234 | } |
235 | 235 | $Spotter = new Spotter($this->db); |
236 | 236 | $all = $Spotter->countAllDepartureCountries($filters); |
237 | - } |
|
238 | - return $all; |
|
237 | + } |
|
238 | + return $all; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | public function countAllAirlines($limit = true,$filter_name = '') { |
@@ -243,45 +243,45 @@ discard block |
||
243 | 243 | if ($filter_name == '') $filter_name = $this->filter_name; |
244 | 244 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
245 | 245 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
246 | - try { |
|
247 | - $sth = $this->db->prepare($query); |
|
248 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
249 | - } catch(PDOException $e) { |
|
250 | - echo "error : ".$e->getMessage(); |
|
251 | - } |
|
252 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
253 | - if (empty($all)) { |
|
254 | - $Spotter = new Spotter($this->db); |
|
255 | - $filters = array(); |
|
256 | - if ($filter_name != '') { |
|
257 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
246 | + try { |
|
247 | + $sth = $this->db->prepare($query); |
|
248 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
249 | + } catch(PDOException $e) { |
|
250 | + echo "error : ".$e->getMessage(); |
|
251 | + } |
|
252 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
253 | + if (empty($all)) { |
|
254 | + $Spotter = new Spotter($this->db); |
|
255 | + $filters = array(); |
|
256 | + if ($filter_name != '') { |
|
257 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
258 | 258 | } |
259 | 259 | |
260 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
261 | - } |
|
262 | - return $all; |
|
260 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
261 | + } |
|
262 | + return $all; |
|
263 | 263 | } |
264 | 264 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
265 | 265 | global $globalStatsFilters; |
266 | 266 | if ($filter_name == '') $filter_name = $this->filter_name; |
267 | 267 | 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"; |
268 | 268 | 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"; |
269 | - try { |
|
270 | - $sth = $this->db->prepare($query); |
|
271 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
272 | - } catch(PDOException $e) { |
|
273 | - echo "error : ".$e->getMessage(); |
|
274 | - } |
|
275 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
276 | - if (empty($all)) { |
|
269 | + try { |
|
270 | + $sth = $this->db->prepare($query); |
|
271 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
272 | + } catch(PDOException $e) { |
|
273 | + echo "error : ".$e->getMessage(); |
|
274 | + } |
|
275 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
276 | + if (empty($all)) { |
|
277 | 277 | $filters = array('airlines' => array($stats_airline)); |
278 | 278 | if ($filter_name != '') { |
279 | 279 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
280 | 280 | } |
281 | - $Spotter = new Spotter($this->db); |
|
282 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
283 | - } |
|
284 | - return $all; |
|
281 | + $Spotter = new Spotter($this->db); |
|
282 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
283 | + } |
|
284 | + return $all; |
|
285 | 285 | } |
286 | 286 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
287 | 287 | global $globalStatsFilters; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | echo "error : ".$e->getMessage(); |
319 | 319 | } |
320 | 320 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
321 | - /* |
|
321 | + /* |
|
322 | 322 | if (empty($all)) { |
323 | 323 | $Spotter = new Spotter($this->db); |
324 | 324 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -334,84 +334,84 @@ discard block |
||
334 | 334 | if ($filter_name == '') $filter_name = $this->filter_name; |
335 | 335 | 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"; |
336 | 336 | 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"; |
337 | - try { |
|
338 | - $sth = $this->db->prepare($query); |
|
339 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
340 | - } catch(PDOException $e) { |
|
341 | - echo "error : ".$e->getMessage(); |
|
342 | - } |
|
343 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
344 | - if (empty($all)) { |
|
337 | + try { |
|
338 | + $sth = $this->db->prepare($query); |
|
339 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
340 | + } catch(PDOException $e) { |
|
341 | + echo "error : ".$e->getMessage(); |
|
342 | + } |
|
343 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
344 | + if (empty($all)) { |
|
345 | 345 | $filters = array('airlines' => array($stats_airline)); |
346 | 346 | if ($filter_name != '') { |
347 | 347 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
348 | 348 | } |
349 | - $Spotter = new Spotter($this->db); |
|
350 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
351 | - } |
|
352 | - return $all; |
|
349 | + $Spotter = new Spotter($this->db); |
|
350 | + $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
351 | + } |
|
352 | + return $all; |
|
353 | 353 | } |
354 | 354 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
355 | 355 | global $globalStatsFilters; |
356 | 356 | if ($filter_name == '') $filter_name = $this->filter_name; |
357 | 357 | 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"; |
358 | 358 | 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"; |
359 | - try { |
|
360 | - $sth = $this->db->prepare($query); |
|
361 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
362 | - } catch(PDOException $e) { |
|
363 | - echo "error : ".$e->getMessage(); |
|
364 | - } |
|
365 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
366 | - if (empty($all)) { |
|
359 | + try { |
|
360 | + $sth = $this->db->prepare($query); |
|
361 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
362 | + } catch(PDOException $e) { |
|
363 | + echo "error : ".$e->getMessage(); |
|
364 | + } |
|
365 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
366 | + if (empty($all)) { |
|
367 | 367 | $filters = array('airlines' => array($stats_airline)); |
368 | 368 | if ($filter_name != '') { |
369 | 369 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
370 | 370 | } |
371 | - $Spotter = new Spotter($this->db); |
|
372 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
373 | - } |
|
374 | - return $all; |
|
371 | + $Spotter = new Spotter($this->db); |
|
372 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
373 | + } |
|
374 | + return $all; |
|
375 | 375 | } |
376 | 376 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
377 | 377 | global $globalStatsFilters; |
378 | 378 | if ($filter_name == '') $filter_name = $this->filter_name; |
379 | 379 | 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"; |
380 | 380 | 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"; |
381 | - try { |
|
382 | - $sth = $this->db->prepare($query); |
|
383 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
384 | - } catch(PDOException $e) { |
|
385 | - echo "error : ".$e->getMessage(); |
|
386 | - } |
|
387 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
388 | - if (empty($all)) { |
|
381 | + try { |
|
382 | + $sth = $this->db->prepare($query); |
|
383 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
384 | + } catch(PDOException $e) { |
|
385 | + echo "error : ".$e->getMessage(); |
|
386 | + } |
|
387 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
388 | + if (empty($all)) { |
|
389 | 389 | $filters = array('airlines' => array($stats_airline)); |
390 | - if ($filter_name != '') { |
|
391 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
392 | - } |
|
393 | - $Spotter = new Spotter($this->db); |
|
394 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
395 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
396 | - $all = array(); |
|
397 | - foreach ($pall as $value) { |
|
398 | - $icao = $value['airport_departure_icao']; |
|
399 | - $all[$icao] = $value; |
|
400 | - } |
|
390 | + if ($filter_name != '') { |
|
391 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
392 | + } |
|
393 | + $Spotter = new Spotter($this->db); |
|
394 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
395 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
396 | + $all = array(); |
|
397 | + foreach ($pall as $value) { |
|
398 | + $icao = $value['airport_departure_icao']; |
|
399 | + $all[$icao] = $value; |
|
400 | + } |
|
401 | 401 | |
402 | - foreach ($dall as $value) { |
|
403 | - $icao = $value['airport_departure_icao']; |
|
404 | - if (isset($all[$icao])) { |
|
405 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
406 | - } else $all[$icao] = $value; |
|
407 | - } |
|
408 | - $count = array(); |
|
409 | - foreach ($all as $key => $row) { |
|
410 | - $count[$key] = $row['airport_departure_icao_count']; |
|
411 | - } |
|
412 | - array_multisort($count,SORT_DESC,$all); |
|
413 | - } |
|
414 | - return $all; |
|
402 | + foreach ($dall as $value) { |
|
403 | + $icao = $value['airport_departure_icao']; |
|
404 | + if (isset($all[$icao])) { |
|
405 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
406 | + } else $all[$icao] = $value; |
|
407 | + } |
|
408 | + $count = array(); |
|
409 | + foreach ($all as $key => $row) { |
|
410 | + $count[$key] = $row['airport_departure_icao_count']; |
|
411 | + } |
|
412 | + array_multisort($count,SORT_DESC,$all); |
|
413 | + } |
|
414 | + return $all; |
|
415 | 415 | } |
416 | 416 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
417 | 417 | global $globalStatsFilters; |
@@ -433,26 +433,26 @@ discard block |
||
433 | 433 | $Spotter = new Spotter($this->db); |
434 | 434 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
435 | 435 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
436 | - $all = array(); |
|
437 | - foreach ($pall as $value) { |
|
438 | - $icao = $value['airport_arrival_icao']; |
|
439 | - $all[$icao] = $value; |
|
440 | - } |
|
436 | + $all = array(); |
|
437 | + foreach ($pall as $value) { |
|
438 | + $icao = $value['airport_arrival_icao']; |
|
439 | + $all[$icao] = $value; |
|
440 | + } |
|
441 | 441 | |
442 | - foreach ($dall as $value) { |
|
443 | - $icao = $value['airport_arrival_icao']; |
|
444 | - if (isset($all[$icao])) { |
|
445 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
446 | - } else $all[$icao] = $value; |
|
447 | - } |
|
448 | - $count = array(); |
|
449 | - foreach ($all as $key => $row) { |
|
450 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
451 | - } |
|
452 | - array_multisort($count,SORT_DESC,$all); |
|
453 | - } |
|
442 | + foreach ($dall as $value) { |
|
443 | + $icao = $value['airport_arrival_icao']; |
|
444 | + if (isset($all[$icao])) { |
|
445 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
446 | + } else $all[$icao] = $value; |
|
447 | + } |
|
448 | + $count = array(); |
|
449 | + foreach ($all as $key => $row) { |
|
450 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
451 | + } |
|
452 | + array_multisort($count,SORT_DESC,$all); |
|
453 | + } |
|
454 | 454 | |
455 | - return $all; |
|
455 | + return $all; |
|
456 | 456 | } |
457 | 457 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
458 | 458 | global $globalDBdriver, $globalStatsFilters; |
@@ -465,23 +465,23 @@ discard block |
||
465 | 465 | 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"; |
466 | 466 | } |
467 | 467 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
468 | - try { |
|
469 | - $sth = $this->db->prepare($query); |
|
470 | - $sth->execute($query_data); |
|
471 | - } catch(PDOException $e) { |
|
472 | - echo "error : ".$e->getMessage(); |
|
473 | - } |
|
474 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
475 | - if (empty($all)) { |
|
468 | + try { |
|
469 | + $sth = $this->db->prepare($query); |
|
470 | + $sth->execute($query_data); |
|
471 | + } catch(PDOException $e) { |
|
472 | + echo "error : ".$e->getMessage(); |
|
473 | + } |
|
474 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
475 | + if (empty($all)) { |
|
476 | 476 | $filters = array('airlines' => array($stats_airline)); |
477 | 477 | if ($filter_name != '') { |
478 | 478 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
479 | 479 | } |
480 | - $Spotter = new Spotter($this->db); |
|
481 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
482 | - } |
|
480 | + $Spotter = new Spotter($this->db); |
|
481 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
482 | + } |
|
483 | 483 | |
484 | - return $all; |
|
484 | + return $all; |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -489,22 +489,22 @@ discard block |
||
489 | 489 | if ($filter_name == '') $filter_name = $this->filter_name; |
490 | 490 | $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"; |
491 | 491 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
492 | - try { |
|
493 | - $sth = $this->db->prepare($query); |
|
494 | - $sth->execute($query_data); |
|
495 | - } catch(PDOException $e) { |
|
496 | - echo "error : ".$e->getMessage(); |
|
497 | - } |
|
498 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
499 | - if (empty($all)) { |
|
492 | + try { |
|
493 | + $sth = $this->db->prepare($query); |
|
494 | + $sth->execute($query_data); |
|
495 | + } catch(PDOException $e) { |
|
496 | + echo "error : ".$e->getMessage(); |
|
497 | + } |
|
498 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
499 | + if (empty($all)) { |
|
500 | 500 | $filters = array('airlines' => array($stats_airline)); |
501 | 501 | if ($filter_name != '') { |
502 | 502 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
503 | 503 | } |
504 | - $Spotter = new Spotter($this->db); |
|
505 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
506 | - } |
|
507 | - return $all; |
|
504 | + $Spotter = new Spotter($this->db); |
|
505 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
506 | + } |
|
507 | + return $all; |
|
508 | 508 | } |
509 | 509 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
510 | 510 | global $globalDBdriver, $globalStatsFilters; |
@@ -515,108 +515,108 @@ discard block |
||
515 | 515 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
516 | 516 | } |
517 | 517 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
518 | - try { |
|
519 | - $sth = $this->db->prepare($query); |
|
520 | - $sth->execute($query_data); |
|
521 | - } catch(PDOException $e) { |
|
522 | - echo "error : ".$e->getMessage(); |
|
523 | - } |
|
524 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
525 | - if (empty($all)) { |
|
518 | + try { |
|
519 | + $sth = $this->db->prepare($query); |
|
520 | + $sth->execute($query_data); |
|
521 | + } catch(PDOException $e) { |
|
522 | + echo "error : ".$e->getMessage(); |
|
523 | + } |
|
524 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
525 | + if (empty($all)) { |
|
526 | 526 | $filters = array('airlines' => array($stats_airline)); |
527 | 527 | if ($filter_name != '') { |
528 | 528 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
529 | 529 | } |
530 | - $Spotter = new Spotter($this->db); |
|
531 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
532 | - } |
|
533 | - return $all; |
|
530 | + $Spotter = new Spotter($this->db); |
|
531 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
532 | + } |
|
533 | + return $all; |
|
534 | 534 | } |
535 | 535 | public function countAllDates($stats_airline = '',$filter_name = '') { |
536 | 536 | global $globalStatsFilters; |
537 | 537 | if ($filter_name == '') $filter_name = $this->filter_name; |
538 | 538 | $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"; |
539 | 539 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
540 | - try { |
|
541 | - $sth = $this->db->prepare($query); |
|
542 | - $sth->execute($query_data); |
|
543 | - } catch(PDOException $e) { |
|
544 | - echo "error : ".$e->getMessage(); |
|
545 | - } |
|
546 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
547 | - if (empty($all)) { |
|
540 | + try { |
|
541 | + $sth = $this->db->prepare($query); |
|
542 | + $sth->execute($query_data); |
|
543 | + } catch(PDOException $e) { |
|
544 | + echo "error : ".$e->getMessage(); |
|
545 | + } |
|
546 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
547 | + if (empty($all)) { |
|
548 | 548 | $filters = array('airlines' => array($stats_airline)); |
549 | 549 | if ($filter_name != '') { |
550 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
550 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
551 | 551 | } |
552 | - $Spotter = new Spotter($this->db); |
|
553 | - $all = $Spotter->countAllDates($filters); |
|
554 | - } |
|
555 | - return $all; |
|
552 | + $Spotter = new Spotter($this->db); |
|
553 | + $all = $Spotter->countAllDates($filters); |
|
554 | + } |
|
555 | + return $all; |
|
556 | 556 | } |
557 | 557 | public function countAllDatesByAirlines($filter_name = '') { |
558 | 558 | global $globalStatsFilters; |
559 | 559 | if ($filter_name == '') $filter_name = $this->filter_name; |
560 | 560 | $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"; |
561 | 561 | $query_data = array('filter_name' => $filter_name); |
562 | - try { |
|
563 | - $sth = $this->db->prepare($query); |
|
564 | - $sth->execute($query_data); |
|
565 | - } catch(PDOException $e) { |
|
566 | - echo "error : ".$e->getMessage(); |
|
567 | - } |
|
568 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
569 | - if (empty($all)) { |
|
570 | - $filters = array(); |
|
571 | - if ($filter_name != '') { |
|
572 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
573 | - } |
|
574 | - $Spotter = new Spotter($this->db); |
|
575 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
576 | - } |
|
577 | - return $all; |
|
562 | + try { |
|
563 | + $sth = $this->db->prepare($query); |
|
564 | + $sth->execute($query_data); |
|
565 | + } catch(PDOException $e) { |
|
566 | + echo "error : ".$e->getMessage(); |
|
567 | + } |
|
568 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
569 | + if (empty($all)) { |
|
570 | + $filters = array(); |
|
571 | + if ($filter_name != '') { |
|
572 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
573 | + } |
|
574 | + $Spotter = new Spotter($this->db); |
|
575 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
576 | + } |
|
577 | + return $all; |
|
578 | 578 | } |
579 | 579 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
580 | 580 | global $globalStatsFilters; |
581 | 581 | if ($filter_name == '') $filter_name = $this->filter_name; |
582 | - $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"; |
|
583 | - try { |
|
584 | - $sth = $this->db->prepare($query); |
|
585 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
586 | - } catch(PDOException $e) { |
|
587 | - echo "error : ".$e->getMessage(); |
|
588 | - } |
|
589 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
590 | - if (empty($all)) { |
|
582 | + $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"; |
|
583 | + try { |
|
584 | + $sth = $this->db->prepare($query); |
|
585 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
586 | + } catch(PDOException $e) { |
|
587 | + echo "error : ".$e->getMessage(); |
|
588 | + } |
|
589 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
590 | + if (empty($all)) { |
|
591 | 591 | $filters = array('airlines' => array($stats_airline)); |
592 | 592 | if ($filter_name != '') { |
593 | 593 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
594 | 594 | } |
595 | - $Spotter = new Spotter($this->db); |
|
596 | - $all = $Spotter->countAllMonths($filters); |
|
597 | - } |
|
598 | - return $all; |
|
595 | + $Spotter = new Spotter($this->db); |
|
596 | + $all = $Spotter->countAllMonths($filters); |
|
597 | + } |
|
598 | + return $all; |
|
599 | 599 | } |
600 | 600 | public function countAllMilitaryMonths($filter_name = '') { |
601 | 601 | global $globalStatsFilters; |
602 | 602 | if ($filter_name == '') $filter_name = $this->filter_name; |
603 | - $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"; |
|
604 | - try { |
|
605 | - $sth = $this->db->prepare($query); |
|
606 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
607 | - } catch(PDOException $e) { |
|
608 | - echo "error : ".$e->getMessage(); |
|
609 | - } |
|
610 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
611 | - if (empty($all)) { |
|
612 | - $filters = array(); |
|
613 | - if ($filter_name != '') { |
|
614 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
615 | - } |
|
616 | - $Spotter = new Spotter($this->db); |
|
617 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
618 | - } |
|
619 | - return $all; |
|
603 | + $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"; |
|
604 | + try { |
|
605 | + $sth = $this->db->prepare($query); |
|
606 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
607 | + } catch(PDOException $e) { |
|
608 | + echo "error : ".$e->getMessage(); |
|
609 | + } |
|
610 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
611 | + if (empty($all)) { |
|
612 | + $filters = array(); |
|
613 | + if ($filter_name != '') { |
|
614 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
615 | + } |
|
616 | + $Spotter = new Spotter($this->db); |
|
617 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
618 | + } |
|
619 | + return $all; |
|
620 | 620 | } |
621 | 621 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
622 | 622 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -632,22 +632,22 @@ discard block |
||
632 | 632 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
633 | 633 | } |
634 | 634 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
635 | - try { |
|
636 | - $sth = $this->db->prepare($query); |
|
637 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
638 | - } catch(PDOException $e) { |
|
639 | - echo "error : ".$e->getMessage(); |
|
640 | - } |
|
641 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
642 | - if (empty($all)) { |
|
635 | + try { |
|
636 | + $sth = $this->db->prepare($query); |
|
637 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
638 | + } catch(PDOException $e) { |
|
639 | + echo "error : ".$e->getMessage(); |
|
640 | + } |
|
641 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
642 | + if (empty($all)) { |
|
643 | 643 | $filters = array('airlines' => array($stats_airline)); |
644 | 644 | if ($filter_name != '') { |
645 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
645 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
646 | 646 | } |
647 | - $Spotter = new Spotter($this->db); |
|
648 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
649 | - } |
|
650 | - return $all; |
|
647 | + $Spotter = new Spotter($this->db); |
|
648 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
649 | + } |
|
650 | + return $all; |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
@@ -669,9 +669,9 @@ discard block |
||
669 | 669 | if ($filter_name == '') $filter_name = $this->filter_name; |
670 | 670 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
671 | 671 | if (empty($all)) { |
672 | - $filters = array(); |
|
673 | - if ($filter_name != '') { |
|
674 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
672 | + $filters = array(); |
|
673 | + if ($filter_name != '') { |
|
674 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
675 | 675 | } |
676 | 676 | $Spotter = new Spotter($this->db); |
677 | 677 | $all = $Spotter->countOverallMilitaryFlights($filters); |
@@ -710,19 +710,19 @@ discard block |
||
710 | 710 | global $globalStatsFilters; |
711 | 711 | if ($filter_name == '') $filter_name = $this->filter_name; |
712 | 712 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
713 | - try { |
|
714 | - $sth = $this->db->prepare($query); |
|
715 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
716 | - } catch(PDOException $e) { |
|
717 | - echo "error : ".$e->getMessage(); |
|
718 | - } |
|
719 | - $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
720 | - $all = $result[0]['nb_airline']; |
|
713 | + try { |
|
714 | + $sth = $this->db->prepare($query); |
|
715 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
716 | + } catch(PDOException $e) { |
|
717 | + echo "error : ".$e->getMessage(); |
|
718 | + } |
|
719 | + $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
720 | + $all = $result[0]['nb_airline']; |
|
721 | 721 | //$all = $this->getSumStats('airlines_bymonth',date('Y')); |
722 | 722 | if (empty($all)) { |
723 | - $filters = array(); |
|
724 | - if ($filter_name != '') { |
|
725 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
723 | + $filters = array(); |
|
724 | + if ($filter_name != '') { |
|
725 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
726 | 726 | } |
727 | 727 | $Spotter = new Spotter($this->db); |
728 | 728 | $all = $Spotter->countOverallAirlines($filters); |
@@ -773,166 +773,166 @@ discard block |
||
773 | 773 | if ($filter_name == '') $filter_name = $this->filter_name; |
774 | 774 | $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"; |
775 | 775 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
776 | - try { |
|
777 | - $sth = $this->db->prepare($query); |
|
778 | - $sth->execute($query_values); |
|
779 | - } catch(PDOException $e) { |
|
780 | - echo "error : ".$e->getMessage(); |
|
781 | - } |
|
782 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
783 | - return $all; |
|
776 | + try { |
|
777 | + $sth = $this->db->prepare($query); |
|
778 | + $sth->execute($query_values); |
|
779 | + } catch(PDOException $e) { |
|
780 | + echo "error : ".$e->getMessage(); |
|
781 | + } |
|
782 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
783 | + return $all; |
|
784 | 784 | } |
785 | 785 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
786 | 786 | if ($filter_name == '') $filter_name = $this->filter_name; |
787 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
788 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
789 | - try { |
|
790 | - $sth = $this->db->prepare($query); |
|
791 | - $sth->execute($query_values); |
|
792 | - } catch(PDOException $e) { |
|
793 | - echo "error : ".$e->getMessage(); |
|
794 | - } |
|
795 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
796 | - return $all; |
|
797 | - } |
|
787 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
788 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
789 | + try { |
|
790 | + $sth = $this->db->prepare($query); |
|
791 | + $sth->execute($query_values); |
|
792 | + } catch(PDOException $e) { |
|
793 | + echo "error : ".$e->getMessage(); |
|
794 | + } |
|
795 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
796 | + return $all; |
|
797 | + } |
|
798 | 798 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
799 | 799 | if ($filter_name == '') $filter_name = $this->filter_name; |
800 | - global $globalArchiveMonths, $globalDBdriver; |
|
801 | - if ($globalDBdriver == 'mysql') { |
|
802 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
803 | - } else { |
|
804 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
805 | - } |
|
806 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
807 | - try { |
|
808 | - $sth = $this->db->prepare($query); |
|
809 | - $sth->execute($query_values); |
|
810 | - } catch(PDOException $e) { |
|
811 | - echo "error : ".$e->getMessage(); |
|
812 | - } |
|
813 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
814 | - return $all[0]['total']; |
|
815 | - } |
|
800 | + global $globalArchiveMonths, $globalDBdriver; |
|
801 | + if ($globalDBdriver == 'mysql') { |
|
802 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
803 | + } else { |
|
804 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
805 | + } |
|
806 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
807 | + try { |
|
808 | + $sth = $this->db->prepare($query); |
|
809 | + $sth->execute($query_values); |
|
810 | + } catch(PDOException $e) { |
|
811 | + echo "error : ".$e->getMessage(); |
|
812 | + } |
|
813 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
814 | + return $all[0]['total']; |
|
815 | + } |
|
816 | 816 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
817 | - global $globalArchiveMonths, $globalDBdriver; |
|
817 | + global $globalArchiveMonths, $globalDBdriver; |
|
818 | 818 | if ($filter_name == '') $filter_name = $this->filter_name; |
819 | - if ($globalDBdriver == 'mysql') { |
|
819 | + if ($globalDBdriver == 'mysql') { |
|
820 | 820 | $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"; |
821 | 821 | } else { |
822 | 822 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
823 | - } |
|
824 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
825 | - try { |
|
826 | - $sth = $this->db->prepare($query); |
|
827 | - $sth->execute($query_values); |
|
828 | - } catch(PDOException $e) { |
|
829 | - echo "error : ".$e->getMessage(); |
|
830 | - } |
|
831 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
832 | - return $all[0]['total']; |
|
833 | - } |
|
823 | + } |
|
824 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
825 | + try { |
|
826 | + $sth = $this->db->prepare($query); |
|
827 | + $sth->execute($query_values); |
|
828 | + } catch(PDOException $e) { |
|
829 | + echo "error : ".$e->getMessage(); |
|
830 | + } |
|
831 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
832 | + return $all[0]['total']; |
|
833 | + } |
|
834 | 834 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
835 | - global $globalArchiveMonths, $globalDBdriver; |
|
835 | + global $globalArchiveMonths, $globalDBdriver; |
|
836 | 836 | if ($filter_name == '') $filter_name = $this->filter_name; |
837 | - if ($globalDBdriver == 'mysql') { |
|
837 | + if ($globalDBdriver == 'mysql') { |
|
838 | 838 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
839 | - } else { |
|
839 | + } else { |
|
840 | 840 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
841 | - } |
|
842 | - try { |
|
843 | - $sth = $this->db->prepare($query); |
|
844 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
845 | - } catch(PDOException $e) { |
|
846 | - echo "error : ".$e->getMessage(); |
|
847 | - } |
|
848 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
849 | - return $all[0]['total']; |
|
850 | - } |
|
841 | + } |
|
842 | + try { |
|
843 | + $sth = $this->db->prepare($query); |
|
844 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
845 | + } catch(PDOException $e) { |
|
846 | + echo "error : ".$e->getMessage(); |
|
847 | + } |
|
848 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
849 | + return $all[0]['total']; |
|
850 | + } |
|
851 | 851 | public function getStatsAirlineTotal($filter_name = '') { |
852 | - global $globalArchiveMonths, $globalDBdriver; |
|
852 | + global $globalArchiveMonths, $globalDBdriver; |
|
853 | 853 | if ($filter_name == '') $filter_name = $this->filter_name; |
854 | - if ($globalDBdriver == 'mysql') { |
|
854 | + if ($globalDBdriver == 'mysql') { |
|
855 | 855 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
856 | - } else { |
|
856 | + } else { |
|
857 | 857 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
858 | - } |
|
859 | - try { |
|
860 | - $sth = $this->db->prepare($query); |
|
861 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
862 | - } catch(PDOException $e) { |
|
863 | - echo "error : ".$e->getMessage(); |
|
864 | - } |
|
865 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
866 | - return $all[0]['total']; |
|
867 | - } |
|
858 | + } |
|
859 | + try { |
|
860 | + $sth = $this->db->prepare($query); |
|
861 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
862 | + } catch(PDOException $e) { |
|
863 | + echo "error : ".$e->getMessage(); |
|
864 | + } |
|
865 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
866 | + return $all[0]['total']; |
|
867 | + } |
|
868 | 868 | public function getStatsOwnerTotal($filter_name = '') { |
869 | - global $globalArchiveMonths, $globalDBdriver; |
|
869 | + global $globalArchiveMonths, $globalDBdriver; |
|
870 | 870 | if ($filter_name == '') $filter_name = $this->filter_name; |
871 | - if ($globalDBdriver == 'mysql') { |
|
871 | + if ($globalDBdriver == 'mysql') { |
|
872 | 872 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
873 | 873 | } else { |
874 | 874 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
875 | - } |
|
876 | - try { |
|
877 | - $sth = $this->db->prepare($query); |
|
878 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
879 | - } catch(PDOException $e) { |
|
880 | - echo "error : ".$e->getMessage(); |
|
881 | - } |
|
882 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
883 | - return $all[0]['total']; |
|
884 | - } |
|
875 | + } |
|
876 | + try { |
|
877 | + $sth = $this->db->prepare($query); |
|
878 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
879 | + } catch(PDOException $e) { |
|
880 | + echo "error : ".$e->getMessage(); |
|
881 | + } |
|
882 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
883 | + return $all[0]['total']; |
|
884 | + } |
|
885 | 885 | public function getStatsPilotTotal($filter_name = '') { |
886 | - global $globalArchiveMonths, $globalDBdriver; |
|
886 | + global $globalArchiveMonths, $globalDBdriver; |
|
887 | 887 | if ($filter_name == '') $filter_name = $this->filter_name; |
888 | - if ($globalDBdriver == 'mysql') { |
|
889 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
890 | - } else { |
|
891 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
892 | - } |
|
893 | - try { |
|
894 | - $sth = $this->db->prepare($query); |
|
895 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
896 | - } catch(PDOException $e) { |
|
897 | - echo "error : ".$e->getMessage(); |
|
898 | - } |
|
899 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
900 | - return $all[0]['total']; |
|
901 | - } |
|
888 | + if ($globalDBdriver == 'mysql') { |
|
889 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
890 | + } else { |
|
891 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
892 | + } |
|
893 | + try { |
|
894 | + $sth = $this->db->prepare($query); |
|
895 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
896 | + } catch(PDOException $e) { |
|
897 | + echo "error : ".$e->getMessage(); |
|
898 | + } |
|
899 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
900 | + return $all[0]['total']; |
|
901 | + } |
|
902 | 902 | |
903 | 903 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
904 | 904 | global $globalDBdriver; |
905 | 905 | if ($filter_name == '') $filter_name = $this->filter_name; |
906 | 906 | if ($globalDBdriver == 'mysql') { |
907 | 907 | $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"; |
908 | - } else { |
|
908 | + } else { |
|
909 | 909 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
910 | 910 | } |
911 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
912 | - try { |
|
913 | - $sth = $this->db->prepare($query); |
|
914 | - $sth->execute($query_values); |
|
915 | - } catch(PDOException $e) { |
|
916 | - return "error : ".$e->getMessage(); |
|
917 | - } |
|
918 | - } |
|
911 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
912 | + try { |
|
913 | + $sth = $this->db->prepare($query); |
|
914 | + $sth->execute($query_values); |
|
915 | + } catch(PDOException $e) { |
|
916 | + return "error : ".$e->getMessage(); |
|
917 | + } |
|
918 | + } |
|
919 | 919 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
920 | 920 | global $globalDBdriver; |
921 | 921 | if ($filter_name == '') $filter_name = $this->filter_name; |
922 | 922 | if ($globalDBdriver == 'mysql') { |
923 | 923 | $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"; |
924 | 924 | } else { |
925 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
925 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
926 | 926 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
927 | - } |
|
928 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
929 | - try { |
|
930 | - $sth = $this->db->prepare($query); |
|
931 | - $sth->execute($query_values); |
|
932 | - } catch(PDOException $e) { |
|
933 | - return "error : ".$e->getMessage(); |
|
934 | - } |
|
935 | - } |
|
927 | + } |
|
928 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
929 | + try { |
|
930 | + $sth = $this->db->prepare($query); |
|
931 | + $sth->execute($query_values); |
|
932 | + } catch(PDOException $e) { |
|
933 | + return "error : ".$e->getMessage(); |
|
934 | + } |
|
935 | + } |
|
936 | 936 | public function getStatsSource($date,$stats_type = '') { |
937 | 937 | if ($stats_type == '') { |
938 | 938 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -941,15 +941,15 @@ discard block |
||
941 | 941 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
942 | 942 | $query_values = array(':date' => $date,':stats_type' => $stats_type); |
943 | 943 | } |
944 | - try { |
|
945 | - $sth = $this->db->prepare($query); |
|
946 | - $sth->execute($query_values); |
|
947 | - } catch(PDOException $e) { |
|
948 | - echo "error : ".$e->getMessage(); |
|
949 | - } |
|
950 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
951 | - return $all; |
|
952 | - } |
|
944 | + try { |
|
945 | + $sth = $this->db->prepare($query); |
|
946 | + $sth->execute($query_values); |
|
947 | + } catch(PDOException $e) { |
|
948 | + echo "error : ".$e->getMessage(); |
|
949 | + } |
|
950 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
951 | + return $all; |
|
952 | + } |
|
953 | 953 | |
954 | 954 | public function addStatSource($data,$source_name,$stats_type,$date) { |
955 | 955 | global $globalDBdriver; |
@@ -957,25 +957,25 @@ discard block |
||
957 | 957 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
958 | 958 | } else { |
959 | 959 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
960 | - } |
|
961 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
962 | - try { |
|
963 | - $sth = $this->db->prepare($query); |
|
964 | - $sth->execute($query_values); |
|
965 | - } catch(PDOException $e) { |
|
966 | - return "error : ".$e->getMessage(); |
|
967 | - } |
|
968 | - } |
|
960 | + } |
|
961 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
962 | + try { |
|
963 | + $sth = $this->db->prepare($query); |
|
964 | + $sth->execute($query_values); |
|
965 | + } catch(PDOException $e) { |
|
966 | + return "error : ".$e->getMessage(); |
|
967 | + } |
|
968 | + } |
|
969 | 969 | public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
970 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
971 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
972 | - try { |
|
973 | - $sth = $this->db->prepare($query); |
|
974 | - $sth->execute($query_values); |
|
975 | - } catch(PDOException $e) { |
|
976 | - return "error : ".$e->getMessage(); |
|
977 | - } |
|
978 | - } |
|
970 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
971 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
972 | + try { |
|
973 | + $sth = $this->db->prepare($query); |
|
974 | + $sth->execute($query_values); |
|
975 | + } catch(PDOException $e) { |
|
976 | + return "error : ".$e->getMessage(); |
|
977 | + } |
|
978 | + } |
|
979 | 979 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
980 | 980 | global $globalDBdriver; |
981 | 981 | if ($globalDBdriver == 'mysql') { |
@@ -983,14 +983,14 @@ discard block |
||
983 | 983 | } else { |
984 | 984 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
985 | 985 | } |
986 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
987 | - try { |
|
988 | - $sth = $this->db->prepare($query); |
|
989 | - $sth->execute($query_values); |
|
990 | - } catch(PDOException $e) { |
|
991 | - return "error : ".$e->getMessage(); |
|
992 | - } |
|
993 | - } |
|
986 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
987 | + try { |
|
988 | + $sth = $this->db->prepare($query); |
|
989 | + $sth->execute($query_values); |
|
990 | + } catch(PDOException $e) { |
|
991 | + return "error : ".$e->getMessage(); |
|
992 | + } |
|
993 | + } |
|
994 | 994 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
995 | 995 | global $globalDBdriver; |
996 | 996 | if ($globalDBdriver == 'mysql') { |
@@ -998,14 +998,14 @@ discard block |
||
998 | 998 | } else { |
999 | 999 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1000 | 1000 | } |
1001 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1002 | - try { |
|
1003 | - $sth = $this->db->prepare($query); |
|
1004 | - $sth->execute($query_values); |
|
1005 | - } catch(PDOException $e) { |
|
1006 | - return "error : ".$e->getMessage(); |
|
1007 | - } |
|
1008 | - } |
|
1001 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1002 | + try { |
|
1003 | + $sth = $this->db->prepare($query); |
|
1004 | + $sth->execute($query_values); |
|
1005 | + } catch(PDOException $e) { |
|
1006 | + return "error : ".$e->getMessage(); |
|
1007 | + } |
|
1008 | + } |
|
1009 | 1009 | public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
1010 | 1010 | global $globalDBdriver; |
1011 | 1011 | if ($globalDBdriver == 'mysql') { |
@@ -1013,14 +1013,14 @@ discard block |
||
1013 | 1013 | } else { |
1014 | 1014 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
1015 | 1015 | } |
1016 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1017 | - try { |
|
1018 | - $sth = $this->db->prepare($query); |
|
1019 | - $sth->execute($query_values); |
|
1020 | - } catch(PDOException $e) { |
|
1021 | - return "error : ".$e->getMessage(); |
|
1022 | - } |
|
1023 | - } |
|
1016 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1017 | + try { |
|
1018 | + $sth = $this->db->prepare($query); |
|
1019 | + $sth->execute($query_values); |
|
1020 | + } catch(PDOException $e) { |
|
1021 | + return "error : ".$e->getMessage(); |
|
1022 | + } |
|
1023 | + } |
|
1024 | 1024 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
1025 | 1025 | global $globalDBdriver; |
1026 | 1026 | if ($globalDBdriver == 'mysql') { |
@@ -1028,14 +1028,14 @@ discard block |
||
1028 | 1028 | } else { |
1029 | 1029 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1030 | 1030 | } |
1031 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1032 | - try { |
|
1033 | - $sth = $this->db->prepare($query); |
|
1034 | - $sth->execute($query_values); |
|
1035 | - } catch(PDOException $e) { |
|
1036 | - return "error : ".$e->getMessage(); |
|
1037 | - } |
|
1038 | - } |
|
1031 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1032 | + try { |
|
1033 | + $sth = $this->db->prepare($query); |
|
1034 | + $sth->execute($query_values); |
|
1035 | + } catch(PDOException $e) { |
|
1036 | + return "error : ".$e->getMessage(); |
|
1037 | + } |
|
1038 | + } |
|
1039 | 1039 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
1040 | 1040 | global $globalDBdriver; |
1041 | 1041 | if ($globalDBdriver == 'mysql') { |
@@ -1043,14 +1043,14 @@ discard block |
||
1043 | 1043 | } else { |
1044 | 1044 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1045 | 1045 | } |
1046 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1047 | - try { |
|
1048 | - $sth = $this->db->prepare($query); |
|
1049 | - $sth->execute($query_values); |
|
1050 | - } catch(PDOException $e) { |
|
1051 | - return "error : ".$e->getMessage(); |
|
1052 | - } |
|
1053 | - } |
|
1046 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1047 | + try { |
|
1048 | + $sth = $this->db->prepare($query); |
|
1049 | + $sth->execute($query_values); |
|
1050 | + } catch(PDOException $e) { |
|
1051 | + return "error : ".$e->getMessage(); |
|
1052 | + } |
|
1053 | + } |
|
1054 | 1054 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
1055 | 1055 | global $globalDBdriver; |
1056 | 1056 | if ($globalDBdriver == 'mysql') { |
@@ -1058,14 +1058,14 @@ discard block |
||
1058 | 1058 | } else { |
1059 | 1059 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1060 | 1060 | } |
1061 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1062 | - try { |
|
1063 | - $sth = $this->db->prepare($query); |
|
1064 | - $sth->execute($query_values); |
|
1065 | - } catch(PDOException $e) { |
|
1066 | - return "error : ".$e->getMessage(); |
|
1067 | - } |
|
1068 | - } |
|
1061 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1062 | + try { |
|
1063 | + $sth = $this->db->prepare($query); |
|
1064 | + $sth->execute($query_values); |
|
1065 | + } catch(PDOException $e) { |
|
1066 | + return "error : ".$e->getMessage(); |
|
1067 | + } |
|
1068 | + } |
|
1069 | 1069 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') { |
1070 | 1070 | global $globalDBdriver; |
1071 | 1071 | if ($globalDBdriver == 'mysql') { |
@@ -1073,14 +1073,14 @@ discard block |
||
1073 | 1073 | } else { |
1074 | 1074 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1075 | 1075 | } |
1076 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1077 | - try { |
|
1078 | - $sth = $this->db->prepare($query); |
|
1079 | - $sth->execute($query_values); |
|
1080 | - } catch(PDOException $e) { |
|
1081 | - return "error : ".$e->getMessage(); |
|
1082 | - } |
|
1083 | - } |
|
1076 | + $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1077 | + try { |
|
1078 | + $sth = $this->db->prepare($query); |
|
1079 | + $sth->execute($query_values); |
|
1080 | + } catch(PDOException $e) { |
|
1081 | + return "error : ".$e->getMessage(); |
|
1082 | + } |
|
1083 | + } |
|
1084 | 1084 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1085 | 1085 | global $globalDBdriver; |
1086 | 1086 | if ($airport_icao != '') { |
@@ -1096,8 +1096,8 @@ discard block |
||
1096 | 1096 | } catch(PDOException $e) { |
1097 | 1097 | return "error : ".$e->getMessage(); |
1098 | 1098 | } |
1099 | - } |
|
1100 | - } |
|
1099 | + } |
|
1100 | + } |
|
1101 | 1101 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1102 | 1102 | global $globalDBdriver; |
1103 | 1103 | if ($airport_icao != '') { |
@@ -1113,8 +1113,8 @@ discard block |
||
1113 | 1113 | } catch(PDOException $e) { |
1114 | 1114 | return "error : ".$e->getMessage(); |
1115 | 1115 | } |
1116 | - } |
|
1117 | - } |
|
1116 | + } |
|
1117 | + } |
|
1118 | 1118 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | if ($airport_icao != '') { |
@@ -1123,15 +1123,15 @@ discard block |
||
1123 | 1123 | } else { |
1124 | 1124 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1125 | 1125 | } |
1126 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1126 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1127 | 1127 | try { |
1128 | - $sth = $this->db->prepare($query); |
|
1129 | - $sth->execute($query_values); |
|
1130 | - } catch(PDOException $e) { |
|
1131 | - return "error : ".$e->getMessage(); |
|
1132 | - } |
|
1133 | - } |
|
1134 | - } |
|
1128 | + $sth = $this->db->prepare($query); |
|
1129 | + $sth->execute($query_values); |
|
1130 | + } catch(PDOException $e) { |
|
1131 | + return "error : ".$e->getMessage(); |
|
1132 | + } |
|
1133 | + } |
|
1134 | + } |
|
1135 | 1135 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1136 | 1136 | global $globalDBdriver; |
1137 | 1137 | if ($airport_icao != '') { |
@@ -1147,46 +1147,46 @@ discard block |
||
1147 | 1147 | } catch(PDOException $e) { |
1148 | 1148 | return "error : ".$e->getMessage(); |
1149 | 1149 | } |
1150 | - } |
|
1151 | - } |
|
1150 | + } |
|
1151 | + } |
|
1152 | 1152 | |
1153 | 1153 | public function deleteStat($id) { |
1154 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1155 | - $query_values = array(':id' => $id); |
|
1156 | - try { |
|
1157 | - $sth = $this->db->prepare($query); |
|
1158 | - $sth->execute($query_values); |
|
1159 | - } catch(PDOException $e) { |
|
1160 | - return "error : ".$e->getMessage(); |
|
1161 | - } |
|
1162 | - } |
|
1154 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1155 | + $query_values = array(':id' => $id); |
|
1156 | + try { |
|
1157 | + $sth = $this->db->prepare($query); |
|
1158 | + $sth->execute($query_values); |
|
1159 | + } catch(PDOException $e) { |
|
1160 | + return "error : ".$e->getMessage(); |
|
1161 | + } |
|
1162 | + } |
|
1163 | 1163 | public function deleteStatFlight($type) { |
1164 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1165 | - $query_values = array(':type' => $type); |
|
1166 | - try { |
|
1167 | - $sth = $this->db->prepare($query); |
|
1168 | - $sth->execute($query_values); |
|
1169 | - } catch(PDOException $e) { |
|
1170 | - return "error : ".$e->getMessage(); |
|
1171 | - } |
|
1172 | - } |
|
1164 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1165 | + $query_values = array(':type' => $type); |
|
1166 | + try { |
|
1167 | + $sth = $this->db->prepare($query); |
|
1168 | + $sth->execute($query_values); |
|
1169 | + } catch(PDOException $e) { |
|
1170 | + return "error : ".$e->getMessage(); |
|
1171 | + } |
|
1172 | + } |
|
1173 | 1173 | public function deleteStatAirport($type) { |
1174 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1175 | - $query_values = array(':type' => $type); |
|
1176 | - try { |
|
1177 | - $sth = $this->db->prepare($query); |
|
1178 | - $sth->execute($query_values); |
|
1179 | - } catch(PDOException $e) { |
|
1180 | - return "error : ".$e->getMessage(); |
|
1181 | - } |
|
1182 | - } |
|
1174 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1175 | + $query_values = array(':type' => $type); |
|
1176 | + try { |
|
1177 | + $sth = $this->db->prepare($query); |
|
1178 | + $sth->execute($query_values); |
|
1179 | + } catch(PDOException $e) { |
|
1180 | + return "error : ".$e->getMessage(); |
|
1181 | + } |
|
1182 | + } |
|
1183 | 1183 | |
1184 | - public function addOldStats() { |
|
1185 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats; |
|
1186 | - $Common = new Common(); |
|
1187 | - $Connection = new Connection(); |
|
1188 | - date_default_timezone_set('UTC'); |
|
1189 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1184 | + public function addOldStats() { |
|
1185 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats; |
|
1186 | + $Common = new Common(); |
|
1187 | + $Connection = new Connection(); |
|
1188 | + date_default_timezone_set('UTC'); |
|
1189 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1190 | 1190 | //print_r($last_update); |
1191 | 1191 | /* |
1192 | 1192 | $flightsbymonth = $this->getStats('flights_by_month'); |
@@ -1448,24 +1448,24 @@ discard block |
||
1448 | 1448 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1449 | 1449 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1450 | 1450 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1451 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1451 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1452 | 1452 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1453 | - $alldata = array(); |
|
1453 | + $alldata = array(); |
|
1454 | 1454 | |
1455 | - foreach ($pall as $value) { |
|
1456 | - $icao = $value['airport_departure_icao']; |
|
1457 | - $alldata[$icao] = $value; |
|
1458 | - } |
|
1459 | - foreach ($dall as $value) { |
|
1460 | - $icao = $value['airport_departure_icao']; |
|
1461 | - if (isset($alldata[$icao])) { |
|
1462 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1463 | - } else $alldata[$icao] = $value; |
|
1464 | - } |
|
1465 | - $count = array(); |
|
1466 | - foreach ($alldata as $key => $row) { |
|
1467 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1468 | - } |
|
1455 | + foreach ($pall as $value) { |
|
1456 | + $icao = $value['airport_departure_icao']; |
|
1457 | + $alldata[$icao] = $value; |
|
1458 | + } |
|
1459 | + foreach ($dall as $value) { |
|
1460 | + $icao = $value['airport_departure_icao']; |
|
1461 | + if (isset($alldata[$icao])) { |
|
1462 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1463 | + } else $alldata[$icao] = $value; |
|
1464 | + } |
|
1465 | + $count = array(); |
|
1466 | + foreach ($alldata as $key => $row) { |
|
1467 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1468 | + } |
|
1469 | 1469 | array_multisort($count,SORT_DESC,$alldata); |
1470 | 1470 | foreach ($alldata as $number) { |
1471 | 1471 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
@@ -1473,25 +1473,25 @@ discard block |
||
1473 | 1473 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1474 | 1474 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1475 | 1475 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1476 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1476 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1477 | 1477 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1478 | - $alldata = array(); |
|
1479 | - foreach ($pall as $value) { |
|
1480 | - $icao = $value['airport_arrival_icao']; |
|
1481 | - $alldata[$icao] = $value; |
|
1482 | - } |
|
1483 | - foreach ($dall as $value) { |
|
1484 | - $icao = $value['airport_arrival_icao']; |
|
1485 | - if (isset($alldata[$icao])) { |
|
1486 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1487 | - } else $alldata[$icao] = $value; |
|
1488 | - } |
|
1489 | - $count = array(); |
|
1490 | - foreach ($alldata as $key => $row) { |
|
1491 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1492 | - } |
|
1493 | - array_multisort($count,SORT_DESC,$alldata); |
|
1494 | - foreach ($alldata as $number) { |
|
1478 | + $alldata = array(); |
|
1479 | + foreach ($pall as $value) { |
|
1480 | + $icao = $value['airport_arrival_icao']; |
|
1481 | + $alldata[$icao] = $value; |
|
1482 | + } |
|
1483 | + foreach ($dall as $value) { |
|
1484 | + $icao = $value['airport_arrival_icao']; |
|
1485 | + if (isset($alldata[$icao])) { |
|
1486 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1487 | + } else $alldata[$icao] = $value; |
|
1488 | + } |
|
1489 | + $count = array(); |
|
1490 | + foreach ($alldata as $key => $row) { |
|
1491 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1492 | + } |
|
1493 | + array_multisort($count,SORT_DESC,$alldata); |
|
1494 | + foreach ($alldata as $number) { |
|
1495 | 1495 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1496 | 1496 | } |
1497 | 1497 | if ($Connection->tableExists('countries')) { |
@@ -1551,8 +1551,8 @@ discard block |
||
1551 | 1551 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1552 | 1552 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1553 | 1553 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1554 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1555 | - /* |
|
1554 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1555 | + /* |
|
1556 | 1556 | $alldata = array(); |
1557 | 1557 | foreach ($pall as $value) { |
1558 | 1558 | $icao = $value['departure_airport_icao']; |
@@ -1571,29 +1571,29 @@ discard block |
||
1571 | 1571 | } |
1572 | 1572 | array_multisort($count,SORT_DESC,$alldata); |
1573 | 1573 | */ |
1574 | - foreach ($dall as $value) { |
|
1575 | - $icao = $value['departure_airport_icao']; |
|
1576 | - $ddate = $value['date']; |
|
1577 | - $find = false; |
|
1578 | - foreach ($pall as $pvalue) { |
|
1579 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1580 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1581 | - $find = true; |
|
1582 | - break; |
|
1583 | - } |
|
1584 | - } |
|
1585 | - if ($find === false) { |
|
1586 | - $pall[] = $value; |
|
1587 | - } |
|
1588 | - } |
|
1589 | - $alldata = $pall; |
|
1574 | + foreach ($dall as $value) { |
|
1575 | + $icao = $value['departure_airport_icao']; |
|
1576 | + $ddate = $value['date']; |
|
1577 | + $find = false; |
|
1578 | + foreach ($pall as $pvalue) { |
|
1579 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1580 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1581 | + $find = true; |
|
1582 | + break; |
|
1583 | + } |
|
1584 | + } |
|
1585 | + if ($find === false) { |
|
1586 | + $pall[] = $value; |
|
1587 | + } |
|
1588 | + } |
|
1589 | + $alldata = $pall; |
|
1590 | 1590 | foreach ($alldata as $number) { |
1591 | 1591 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1592 | 1592 | } |
1593 | 1593 | echo '...Arrival'."\n"; |
1594 | 1594 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1595 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1596 | - /* |
|
1595 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1596 | + /* |
|
1597 | 1597 | $alldata = array(); |
1598 | 1598 | foreach ($pall as $value) { |
1599 | 1599 | $icao = $value['arrival_airport_icao']; |
@@ -1613,22 +1613,22 @@ discard block |
||
1613 | 1613 | */ |
1614 | 1614 | |
1615 | 1615 | |
1616 | - foreach ($dall as $value) { |
|
1617 | - $icao = $value['arrival_airport_icao']; |
|
1618 | - $ddate = $value['date']; |
|
1619 | - $find = false; |
|
1620 | - foreach ($pall as $pvalue) { |
|
1621 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1622 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1623 | - $find = true; |
|
1624 | - break; |
|
1625 | - } |
|
1626 | - } |
|
1627 | - if ($find === false) { |
|
1628 | - $pall[] = $value; |
|
1629 | - } |
|
1630 | - } |
|
1631 | - $alldata = $pall; |
|
1616 | + foreach ($dall as $value) { |
|
1617 | + $icao = $value['arrival_airport_icao']; |
|
1618 | + $ddate = $value['date']; |
|
1619 | + $find = false; |
|
1620 | + foreach ($pall as $pvalue) { |
|
1621 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1622 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1623 | + $find = true; |
|
1624 | + break; |
|
1625 | + } |
|
1626 | + } |
|
1627 | + if ($find === false) { |
|
1628 | + $pall[] = $value; |
|
1629 | + } |
|
1630 | + } |
|
1631 | + $alldata = $pall; |
|
1632 | 1632 | foreach ($alldata as $number) { |
1633 | 1633 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1634 | 1634 | } |
@@ -1695,51 +1695,51 @@ discard block |
||
1695 | 1695 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1696 | 1696 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1697 | 1697 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1698 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1698 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1699 | 1699 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1700 | - //$alldata = array(); |
|
1701 | - foreach ($dall as $value) { |
|
1702 | - $icao = $value['airport_departure_icao']; |
|
1703 | - $dicao = $value['airline_icao']; |
|
1704 | - $find = false; |
|
1705 | - foreach ($pall as $pvalue) { |
|
1706 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1707 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1708 | - $find = true; |
|
1709 | - break; |
|
1710 | - } |
|
1711 | - } |
|
1712 | - if ($find === false) { |
|
1713 | - $pall[] = $value; |
|
1714 | - } |
|
1715 | - } |
|
1716 | - $alldata = $pall; |
|
1700 | + //$alldata = array(); |
|
1701 | + foreach ($dall as $value) { |
|
1702 | + $icao = $value['airport_departure_icao']; |
|
1703 | + $dicao = $value['airline_icao']; |
|
1704 | + $find = false; |
|
1705 | + foreach ($pall as $pvalue) { |
|
1706 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1707 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1708 | + $find = true; |
|
1709 | + break; |
|
1710 | + } |
|
1711 | + } |
|
1712 | + if ($find === false) { |
|
1713 | + $pall[] = $value; |
|
1714 | + } |
|
1715 | + } |
|
1716 | + $alldata = $pall; |
|
1717 | 1717 | foreach ($alldata as $number) { |
1718 | 1718 | 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']); |
1719 | 1719 | } |
1720 | 1720 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1721 | 1721 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1722 | 1722 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1723 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1723 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1724 | 1724 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1725 | - //$alldata = array(); |
|
1726 | - foreach ($dall as $value) { |
|
1727 | - $icao = $value['airport_arrival_icao']; |
|
1728 | - $dicao = $value['airline_icao']; |
|
1729 | - $find = false; |
|
1730 | - foreach ($pall as $pvalue) { |
|
1731 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1732 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1733 | - $find = true; |
|
1734 | - break; |
|
1735 | - } |
|
1736 | - } |
|
1737 | - if ($find === false) { |
|
1738 | - $pall[] = $value; |
|
1739 | - } |
|
1740 | - } |
|
1741 | - $alldata = $pall; |
|
1742 | - foreach ($alldata as $number) { |
|
1725 | + //$alldata = array(); |
|
1726 | + foreach ($dall as $value) { |
|
1727 | + $icao = $value['airport_arrival_icao']; |
|
1728 | + $dicao = $value['airline_icao']; |
|
1729 | + $find = false; |
|
1730 | + foreach ($pall as $pvalue) { |
|
1731 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1732 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1733 | + $find = true; |
|
1734 | + break; |
|
1735 | + } |
|
1736 | + } |
|
1737 | + if ($find === false) { |
|
1738 | + $pall[] = $value; |
|
1739 | + } |
|
1740 | + } |
|
1741 | + $alldata = $pall; |
|
1742 | + foreach ($alldata as $number) { |
|
1743 | 1743 | 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']); |
1744 | 1744 | } |
1745 | 1745 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
@@ -1772,47 +1772,47 @@ discard block |
||
1772 | 1772 | } |
1773 | 1773 | if ($globalDebug) echo '...Departure'."\n"; |
1774 | 1774 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1775 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1776 | - foreach ($dall as $value) { |
|
1777 | - $icao = $value['departure_airport_icao']; |
|
1778 | - $airline = $value['airline_icao']; |
|
1779 | - $ddate = $value['date']; |
|
1780 | - $find = false; |
|
1781 | - foreach ($pall as $pvalue) { |
|
1782 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1783 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1784 | - $find = true; |
|
1785 | - break; |
|
1786 | - } |
|
1787 | - } |
|
1788 | - if ($find === false) { |
|
1789 | - $pall[] = $value; |
|
1790 | - } |
|
1791 | - } |
|
1792 | - $alldata = $pall; |
|
1775 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1776 | + foreach ($dall as $value) { |
|
1777 | + $icao = $value['departure_airport_icao']; |
|
1778 | + $airline = $value['airline_icao']; |
|
1779 | + $ddate = $value['date']; |
|
1780 | + $find = false; |
|
1781 | + foreach ($pall as $pvalue) { |
|
1782 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1783 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1784 | + $find = true; |
|
1785 | + break; |
|
1786 | + } |
|
1787 | + } |
|
1788 | + if ($find === false) { |
|
1789 | + $pall[] = $value; |
|
1790 | + } |
|
1791 | + } |
|
1792 | + $alldata = $pall; |
|
1793 | 1793 | foreach ($alldata as $number) { |
1794 | 1794 | $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']); |
1795 | 1795 | } |
1796 | 1796 | if ($globalDebug) echo '...Arrival'."\n"; |
1797 | 1797 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1798 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1799 | - foreach ($dall as $value) { |
|
1800 | - $icao = $value['arrival_airport_icao']; |
|
1801 | - $airline = $value['airline_icao']; |
|
1802 | - $ddate = $value['date']; |
|
1803 | - $find = false; |
|
1804 | - foreach ($pall as $pvalue) { |
|
1805 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1806 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1807 | - $find = true; |
|
1808 | - break; |
|
1809 | - } |
|
1810 | - } |
|
1811 | - if ($find === false) { |
|
1812 | - $pall[] = $value; |
|
1813 | - } |
|
1814 | - } |
|
1815 | - $alldata = $pall; |
|
1798 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1799 | + foreach ($dall as $value) { |
|
1800 | + $icao = $value['arrival_airport_icao']; |
|
1801 | + $airline = $value['airline_icao']; |
|
1802 | + $ddate = $value['date']; |
|
1803 | + $find = false; |
|
1804 | + foreach ($pall as $pvalue) { |
|
1805 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1806 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1807 | + $find = true; |
|
1808 | + break; |
|
1809 | + } |
|
1810 | + } |
|
1811 | + if ($find === false) { |
|
1812 | + $pall[] = $value; |
|
1813 | + } |
|
1814 | + } |
|
1815 | + $alldata = $pall; |
|
1816 | 1816 | foreach ($alldata as $number) { |
1817 | 1817 | $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']); |
1818 | 1818 | } |
@@ -1881,44 +1881,44 @@ discard block |
||
1881 | 1881 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source']); |
1882 | 1882 | } |
1883 | 1883 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
1884 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1885 | - $alldata = array(); |
|
1886 | - foreach ($pall as $value) { |
|
1887 | - $icao = $value['airport_departure_icao']; |
|
1888 | - $alldata[$icao] = $value; |
|
1889 | - } |
|
1890 | - foreach ($dall as $value) { |
|
1891 | - $icao = $value['airport_departure_icao']; |
|
1892 | - if (isset($alldata[$icao])) { |
|
1893 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1894 | - } else $alldata[$icao] = $value; |
|
1895 | - } |
|
1896 | - $count = array(); |
|
1897 | - foreach ($alldata as $key => $row) { |
|
1898 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1899 | - } |
|
1884 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1885 | + $alldata = array(); |
|
1886 | + foreach ($pall as $value) { |
|
1887 | + $icao = $value['airport_departure_icao']; |
|
1888 | + $alldata[$icao] = $value; |
|
1889 | + } |
|
1890 | + foreach ($dall as $value) { |
|
1891 | + $icao = $value['airport_departure_icao']; |
|
1892 | + if (isset($alldata[$icao])) { |
|
1893 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1894 | + } else $alldata[$icao] = $value; |
|
1895 | + } |
|
1896 | + $count = array(); |
|
1897 | + foreach ($alldata as $key => $row) { |
|
1898 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1899 | + } |
|
1900 | 1900 | array_multisort($count,SORT_DESC,$alldata); |
1901 | 1901 | foreach ($alldata as $number) { |
1902 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name); |
|
1902 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name); |
|
1903 | 1903 | } |
1904 | 1904 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
1905 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
1905 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
1906 | 1906 | $alldata = array(); |
1907 | - foreach ($pall as $value) { |
|
1908 | - $icao = $value['airport_arrival_icao']; |
|
1909 | - $alldata[$icao] = $value; |
|
1910 | - } |
|
1911 | - foreach ($dall as $value) { |
|
1912 | - $icao = $value['airport_arrival_icao']; |
|
1913 | - if (isset($alldata[$icao])) { |
|
1914 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1915 | - } else $alldata[$icao] = $value; |
|
1916 | - } |
|
1917 | - $count = array(); |
|
1918 | - foreach ($alldata as $key => $row) { |
|
1919 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1920 | - } |
|
1921 | - array_multisort($count,SORT_DESC,$alldata); |
|
1907 | + foreach ($pall as $value) { |
|
1908 | + $icao = $value['airport_arrival_icao']; |
|
1909 | + $alldata[$icao] = $value; |
|
1910 | + } |
|
1911 | + foreach ($dall as $value) { |
|
1912 | + $icao = $value['airport_arrival_icao']; |
|
1913 | + if (isset($alldata[$icao])) { |
|
1914 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1915 | + } else $alldata[$icao] = $value; |
|
1916 | + } |
|
1917 | + $count = array(); |
|
1918 | + foreach ($alldata as $key => $row) { |
|
1919 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1920 | + } |
|
1921 | + array_multisort($count,SORT_DESC,$alldata); |
|
1922 | 1922 | foreach ($alldata as $number) { |
1923 | 1923 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name); |
1924 | 1924 | } |
@@ -1951,45 +1951,45 @@ discard block |
||
1951 | 1951 | } |
1952 | 1952 | echo '...Departure'."\n"; |
1953 | 1953 | $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
1954 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1954 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1955 | 1955 | foreach ($dall as $value) { |
1956 | - $icao = $value['departure_airport_icao']; |
|
1957 | - $ddate = $value['date']; |
|
1958 | - $find = false; |
|
1959 | - foreach ($pall as $pvalue) { |
|
1960 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1961 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1962 | - $find = true; |
|
1963 | - break; |
|
1964 | - } |
|
1965 | - } |
|
1966 | - if ($find === false) { |
|
1967 | - $pall[] = $value; |
|
1968 | - } |
|
1969 | - } |
|
1970 | - $alldata = $pall; |
|
1956 | + $icao = $value['departure_airport_icao']; |
|
1957 | + $ddate = $value['date']; |
|
1958 | + $find = false; |
|
1959 | + foreach ($pall as $pvalue) { |
|
1960 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1961 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1962 | + $find = true; |
|
1963 | + break; |
|
1964 | + } |
|
1965 | + } |
|
1966 | + if ($find === false) { |
|
1967 | + $pall[] = $value; |
|
1968 | + } |
|
1969 | + } |
|
1970 | + $alldata = $pall; |
|
1971 | 1971 | foreach ($alldata as $number) { |
1972 | 1972 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
1973 | 1973 | } |
1974 | 1974 | echo '...Arrival'."\n"; |
1975 | 1975 | $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
1976 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1976 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1977 | 1977 | foreach ($dall as $value) { |
1978 | 1978 | $icao = $value['arrival_airport_icao']; |
1979 | 1979 | $ddate = $value['date']; |
1980 | - $find = false; |
|
1980 | + $find = false; |
|
1981 | 1981 | foreach ($pall as $pvalue) { |
1982 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1983 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1984 | - $find = true; |
|
1985 | - break; |
|
1986 | - } |
|
1987 | - } |
|
1988 | - if ($find === false) { |
|
1989 | - $pall[] = $value; |
|
1990 | - } |
|
1991 | - } |
|
1992 | - $alldata = $pall; |
|
1982 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1983 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1984 | + $find = true; |
|
1985 | + break; |
|
1986 | + } |
|
1987 | + } |
|
1988 | + if ($find === false) { |
|
1989 | + $pall[] = $value; |
|
1990 | + } |
|
1991 | + } |
|
1992 | + $alldata = $pall; |
|
1993 | 1993 | foreach ($alldata as $number) { |
1994 | 1994 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
1995 | 1995 | } |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | $this->db = $Connection->db(); |
18 | 18 | } |
19 | 19 | |
20 | - public function addLastStatsUpdate($type,$stats_date) { |
|
20 | + public function addLastStatsUpdate($type, $stats_date) { |
|
21 | 21 | $query = "DELETE FROM config WHERE name = :type; |
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
23 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
24 | 24 | try { |
25 | 25 | $sth = $this->db->prepare($query); |
26 | 26 | $sth->execute($query_values); |
27 | - } catch(PDOException $e) { |
|
27 | + } catch (PDOException $e) { |
|
28 | 28 | return "error : ".$e->getMessage(); |
29 | 29 | } |
30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | try { |
35 | 35 | $sth = $this->db->prepare($query); |
36 | 36 | $sth->execute(array(':type' => $type)); |
37 | - } catch(PDOException $e) { |
|
37 | + } catch (PDOException $e) { |
|
38 | 38 | echo "error : ".$e->getMessage(); |
39 | 39 | } |
40 | 40 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | try { |
55 | 55 | $sth = $this->db->prepare($query); |
56 | 56 | $sth->execute(array(':filter_name' => $filter_name)); |
57 | - } catch(PDOException $e) { |
|
57 | + } catch (PDOException $e) { |
|
58 | 58 | return "error : ".$e->getMessage(); |
59 | 59 | } |
60 | 60 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | try { |
65 | 65 | $sth = $this->db->prepare($query); |
66 | 66 | $sth->execute(); |
67 | - } catch(PDOException $e) { |
|
67 | + } catch (PDOException $e) { |
|
68 | 68 | return "error : ".$e->getMessage(); |
69 | 69 | } |
70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | try { |
73 | 73 | $sth = $this->db->prepare($query); |
74 | 74 | $sth->execute(array(':filter_name' => $filter_name)); |
75 | - } catch(PDOException $e) { |
|
75 | + } catch (PDOException $e) { |
|
76 | 76 | return "error : ".$e->getMessage(); |
77 | 77 | } |
78 | 78 | } |
@@ -82,43 +82,43 @@ discard block |
||
82 | 82 | try { |
83 | 83 | $sth = $this->db->prepare($query); |
84 | 84 | $sth->execute(array(':filter_name' => $filter_name)); |
85 | - } catch(PDOException $e) { |
|
85 | + } catch (PDOException $e) { |
|
86 | 86 | echo "error : ".$e->getMessage(); |
87 | 87 | } |
88 | 88 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
89 | 89 | return $all; |
90 | 90 | } |
91 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
91 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
92 | 92 | if ($filter_name == '') $filter_name = $this->filter_name; |
93 | 93 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
94 | 94 | try { |
95 | 95 | $sth = $this->db->prepare($query); |
96 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | - } catch(PDOException $e) { |
|
96 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
97 | + } catch (PDOException $e) { |
|
98 | 98 | echo "error : ".$e->getMessage(); |
99 | 99 | } |
100 | 100 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
101 | 101 | return $all; |
102 | 102 | } |
103 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
103 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
104 | 104 | if ($filter_name == '') $filter_name = $this->filter_name; |
105 | 105 | $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"; |
106 | 106 | try { |
107 | 107 | $sth = $this->db->prepare($query); |
108 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | - } catch(PDOException $e) { |
|
108 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
109 | + } catch (PDOException $e) { |
|
110 | 110 | echo "error : ".$e->getMessage(); |
111 | 111 | } |
112 | 112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
113 | 113 | return $all; |
114 | 114 | } |
115 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
115 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
116 | 116 | if ($filter_name == '') $filter_name = $this->filter_name; |
117 | 117 | $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"; |
118 | 118 | try { |
119 | 119 | $sth = $this->db->prepare($query); |
120 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | - } catch(PDOException $e) { |
|
120 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
121 | + } catch (PDOException $e) { |
|
122 | 122 | echo "error : ".$e->getMessage(); |
123 | 123 | } |
124 | 124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -133,22 +133,22 @@ discard block |
||
133 | 133 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
134 | 134 | try { |
135 | 135 | $sth = $this->db->prepare($query); |
136 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
137 | - } catch(PDOException $e) { |
|
136 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | echo "error : ".$e->getMessage(); |
139 | 139 | } |
140 | 140 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
141 | 141 | if (empty($all)) { |
142 | 142 | $filters = array('airlines' => array($stats_airline)); |
143 | 143 | if ($filter_name != '') { |
144 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
144 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
145 | 145 | } |
146 | 146 | $Spotter = new Spotter($this->db); |
147 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
147 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
148 | 148 | } |
149 | 149 | return $all; |
150 | 150 | } |
151 | - public function countAllAirlineCountries($limit = true,$filter_name = '') { |
|
151 | + public function countAllAirlineCountries($limit = true, $filter_name = '') { |
|
152 | 152 | global $globalStatsFilters; |
153 | 153 | if ($filter_name == '') $filter_name = $this->filter_name; |
154 | 154 | 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"; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | try { |
157 | 157 | $sth = $this->db->prepare($query); |
158 | 158 | $sth->execute(array(':filter_name' => $filter_name)); |
159 | - } catch(PDOException $e) { |
|
159 | + } catch (PDOException $e) { |
|
160 | 160 | echo "error : ".$e->getMessage(); |
161 | 161 | } |
162 | 162 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -164,28 +164,28 @@ discard block |
||
164 | 164 | $Spotter = new Spotter($this->db); |
165 | 165 | $filters = array(); |
166 | 166 | if ($filter_name != '') { |
167 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
167 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
168 | 168 | } |
169 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
169 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
170 | 170 | } |
171 | 171 | return $all; |
172 | 172 | } |
173 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
|
173 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') { |
|
174 | 174 | global $globalStatsFilters; |
175 | 175 | if ($filter_name == '') $filter_name = $this->filter_name; |
176 | 176 | 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"; |
177 | 177 | 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"; |
178 | 178 | try { |
179 | 179 | $sth = $this->db->prepare($query); |
180 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
181 | - } catch(PDOException $e) { |
|
180 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
181 | + } catch (PDOException $e) { |
|
182 | 182 | echo "error : ".$e->getMessage(); |
183 | 183 | } |
184 | 184 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
185 | 185 | if (empty($all)) { |
186 | 186 | $filters = array('airlines' => array($stats_airline)); |
187 | 187 | if ($filter_name != '') { |
188 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
188 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
189 | 189 | } |
190 | 190 | $Spotter = new Spotter($this->db); |
191 | 191 | $all = $Spotter->countAllAircraftManufacturers($filters); |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | 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"; |
201 | 201 | try { |
202 | 202 | $sth = $this->db->prepare($query); |
203 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
204 | - } catch(PDOException $e) { |
|
203 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
204 | + } catch (PDOException $e) { |
|
205 | 205 | echo "error : ".$e->getMessage(); |
206 | 206 | } |
207 | 207 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
208 | 208 | if (empty($all)) { |
209 | 209 | $filters = array('airlines' => array($stats_airline)); |
210 | 210 | if ($filter_name != '') { |
211 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
211 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
212 | 212 | } |
213 | 213 | $Spotter = new Spotter($this->db); |
214 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
214 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
215 | 215 | } |
216 | 216 | return $all; |
217 | 217 | } |
@@ -222,15 +222,15 @@ discard block |
||
222 | 222 | 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"; |
223 | 223 | try { |
224 | 224 | $sth = $this->db->prepare($query); |
225 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
226 | - } catch(PDOException $e) { |
|
225 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
226 | + } catch (PDOException $e) { |
|
227 | 227 | echo "error : ".$e->getMessage(); |
228 | 228 | } |
229 | 229 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
230 | 230 | if (empty($all)) { |
231 | 231 | $filters = array('airlines' => array($stats_airline)); |
232 | 232 | if ($filter_name != '') { |
233 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
233 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
234 | 234 | } |
235 | 235 | $Spotter = new Spotter($this->db); |
236 | 236 | $all = $Spotter->countAllDepartureCountries($filters); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | return $all; |
239 | 239 | } |
240 | 240 | |
241 | - public function countAllAirlines($limit = true,$filter_name = '') { |
|
241 | + public function countAllAirlines($limit = true, $filter_name = '') { |
|
242 | 242 | global $globalStatsFilters; |
243 | 243 | if ($filter_name == '') $filter_name = $this->filter_name; |
244 | 244 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | try { |
247 | 247 | $sth = $this->db->prepare($query); |
248 | 248 | $sth->execute(array(':filter_name' => $filter_name)); |
249 | - } catch(PDOException $e) { |
|
249 | + } catch (PDOException $e) { |
|
250 | 250 | echo "error : ".$e->getMessage(); |
251 | 251 | } |
252 | 252 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -254,58 +254,58 @@ discard block |
||
254 | 254 | $Spotter = new Spotter($this->db); |
255 | 255 | $filters = array(); |
256 | 256 | if ($filter_name != '') { |
257 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
257 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
258 | 258 | } |
259 | 259 | |
260 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
260 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
261 | 261 | } |
262 | 262 | return $all; |
263 | 263 | } |
264 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
|
264 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') { |
|
265 | 265 | global $globalStatsFilters; |
266 | 266 | if ($filter_name == '') $filter_name = $this->filter_name; |
267 | 267 | 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"; |
268 | 268 | 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"; |
269 | 269 | try { |
270 | 270 | $sth = $this->db->prepare($query); |
271 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
272 | - } catch(PDOException $e) { |
|
271 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
272 | + } catch (PDOException $e) { |
|
273 | 273 | echo "error : ".$e->getMessage(); |
274 | 274 | } |
275 | 275 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
276 | 276 | if (empty($all)) { |
277 | 277 | $filters = array('airlines' => array($stats_airline)); |
278 | 278 | if ($filter_name != '') { |
279 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
279 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
280 | 280 | } |
281 | 281 | $Spotter = new Spotter($this->db); |
282 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
282 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
283 | 283 | } |
284 | 284 | return $all; |
285 | 285 | } |
286 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
|
286 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') { |
|
287 | 287 | global $globalStatsFilters; |
288 | 288 | if ($filter_name == '') $filter_name = $this->filter_name; |
289 | 289 | 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"; |
290 | 290 | 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"; |
291 | 291 | try { |
292 | 292 | $sth = $this->db->prepare($query); |
293 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
294 | - } catch(PDOException $e) { |
|
293 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
294 | + } catch (PDOException $e) { |
|
295 | 295 | echo "error : ".$e->getMessage(); |
296 | 296 | } |
297 | 297 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
298 | 298 | if (empty($all)) { |
299 | 299 | $filters = array('airlines' => array($stats_airline)); |
300 | 300 | if ($filter_name != '') { |
301 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
301 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
302 | 302 | } |
303 | 303 | $Spotter = new Spotter($this->db); |
304 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
304 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
305 | 305 | } |
306 | 306 | return $all; |
307 | 307 | } |
308 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
|
308 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') { |
|
309 | 309 | $Connection = new Connection(); |
310 | 310 | if ($filter_name == '') $filter_name = $this->filter_name; |
311 | 311 | if ($Connection->tableExists('countries')) { |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
314 | 314 | try { |
315 | 315 | $sth = $this->db->prepare($query); |
316 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
317 | - } catch(PDOException $e) { |
|
316 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
317 | + } catch (PDOException $e) { |
|
318 | 318 | echo "error : ".$e->getMessage(); |
319 | 319 | } |
320 | 320 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -329,70 +329,70 @@ discard block |
||
329 | 329 | return array(); |
330 | 330 | } |
331 | 331 | } |
332 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
|
332 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') { |
|
333 | 333 | global $globalStatsFilters; |
334 | 334 | if ($filter_name == '') $filter_name = $this->filter_name; |
335 | 335 | 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"; |
336 | 336 | 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"; |
337 | 337 | try { |
338 | 338 | $sth = $this->db->prepare($query); |
339 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
340 | - } catch(PDOException $e) { |
|
339 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
340 | + } catch (PDOException $e) { |
|
341 | 341 | echo "error : ".$e->getMessage(); |
342 | 342 | } |
343 | 343 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
344 | 344 | if (empty($all)) { |
345 | 345 | $filters = array('airlines' => array($stats_airline)); |
346 | 346 | if ($filter_name != '') { |
347 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
347 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
348 | 348 | } |
349 | 349 | $Spotter = new Spotter($this->db); |
350 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
350 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
351 | 351 | } |
352 | 352 | return $all; |
353 | 353 | } |
354 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
|
354 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') { |
|
355 | 355 | global $globalStatsFilters; |
356 | 356 | if ($filter_name == '') $filter_name = $this->filter_name; |
357 | 357 | 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"; |
358 | 358 | 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"; |
359 | 359 | try { |
360 | 360 | $sth = $this->db->prepare($query); |
361 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
362 | - } catch(PDOException $e) { |
|
361 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | echo "error : ".$e->getMessage(); |
364 | 364 | } |
365 | 365 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
366 | 366 | if (empty($all)) { |
367 | 367 | $filters = array('airlines' => array($stats_airline)); |
368 | 368 | if ($filter_name != '') { |
369 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
369 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
370 | 370 | } |
371 | 371 | $Spotter = new Spotter($this->db); |
372 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
372 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
373 | 373 | } |
374 | 374 | return $all; |
375 | 375 | } |
376 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
|
376 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') { |
|
377 | 377 | global $globalStatsFilters; |
378 | 378 | if ($filter_name == '') $filter_name = $this->filter_name; |
379 | 379 | 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"; |
380 | 380 | 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"; |
381 | 381 | try { |
382 | 382 | $sth = $this->db->prepare($query); |
383 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
384 | - } catch(PDOException $e) { |
|
383 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
384 | + } catch (PDOException $e) { |
|
385 | 385 | echo "error : ".$e->getMessage(); |
386 | 386 | } |
387 | 387 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
388 | 388 | if (empty($all)) { |
389 | 389 | $filters = array('airlines' => array($stats_airline)); |
390 | 390 | if ($filter_name != '') { |
391 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
391 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
392 | 392 | } |
393 | 393 | $Spotter = new Spotter($this->db); |
394 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
395 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
394 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
395 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
396 | 396 | $all = array(); |
397 | 397 | foreach ($pall as $value) { |
398 | 398 | $icao = $value['airport_departure_icao']; |
@@ -409,30 +409,30 @@ discard block |
||
409 | 409 | foreach ($all as $key => $row) { |
410 | 410 | $count[$key] = $row['airport_departure_icao_count']; |
411 | 411 | } |
412 | - array_multisort($count,SORT_DESC,$all); |
|
412 | + array_multisort($count, SORT_DESC, $all); |
|
413 | 413 | } |
414 | 414 | return $all; |
415 | 415 | } |
416 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
|
416 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') { |
|
417 | 417 | global $globalStatsFilters; |
418 | 418 | if ($filter_name == '') $filter_name = $this->filter_name; |
419 | 419 | 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"; |
420 | 420 | 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"; |
421 | 421 | try { |
422 | 422 | $sth = $this->db->prepare($query); |
423 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
424 | - } catch(PDOException $e) { |
|
423 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | echo "error : ".$e->getMessage(); |
426 | 426 | } |
427 | 427 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
428 | 428 | if (empty($all)) { |
429 | 429 | $filters = array('airlines' => array($stats_airline)); |
430 | 430 | if ($filter_name != '') { |
431 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
431 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
432 | 432 | } |
433 | 433 | $Spotter = new Spotter($this->db); |
434 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
435 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
434 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
435 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
436 | 436 | $all = array(); |
437 | 437 | foreach ($pall as $value) { |
438 | 438 | $icao = $value['airport_arrival_icao']; |
@@ -449,12 +449,12 @@ discard block |
||
449 | 449 | foreach ($all as $key => $row) { |
450 | 450 | $count[$key] = $row['airport_arrival_icao_count']; |
451 | 451 | } |
452 | - array_multisort($count,SORT_DESC,$all); |
|
452 | + array_multisort($count, SORT_DESC, $all); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | return $all; |
456 | 456 | } |
457 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
457 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
458 | 458 | global $globalDBdriver, $globalStatsFilters; |
459 | 459 | if ($filter_name == '') $filter_name = $this->filter_name; |
460 | 460 | if ($globalDBdriver == 'mysql') { |
@@ -464,18 +464,18 @@ discard block |
||
464 | 464 | 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"; |
465 | 465 | 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"; |
466 | 466 | } |
467 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
467 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
468 | 468 | try { |
469 | 469 | $sth = $this->db->prepare($query); |
470 | 470 | $sth->execute($query_data); |
471 | - } catch(PDOException $e) { |
|
471 | + } catch (PDOException $e) { |
|
472 | 472 | echo "error : ".$e->getMessage(); |
473 | 473 | } |
474 | 474 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
475 | 475 | if (empty($all)) { |
476 | 476 | $filters = array('airlines' => array($stats_airline)); |
477 | 477 | if ($filter_name != '') { |
478 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
478 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
479 | 479 | } |
480 | 480 | $Spotter = new Spotter($this->db); |
481 | 481 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -484,29 +484,29 @@ discard block |
||
484 | 484 | return $all; |
485 | 485 | } |
486 | 486 | |
487 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
487 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
488 | 488 | global $globalStatsFilters; |
489 | 489 | if ($filter_name == '') $filter_name = $this->filter_name; |
490 | 490 | $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"; |
491 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
491 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
492 | 492 | try { |
493 | 493 | $sth = $this->db->prepare($query); |
494 | 494 | $sth->execute($query_data); |
495 | - } catch(PDOException $e) { |
|
495 | + } catch (PDOException $e) { |
|
496 | 496 | echo "error : ".$e->getMessage(); |
497 | 497 | } |
498 | 498 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
499 | 499 | if (empty($all)) { |
500 | 500 | $filters = array('airlines' => array($stats_airline)); |
501 | 501 | if ($filter_name != '') { |
502 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
502 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
503 | 503 | } |
504 | 504 | $Spotter = new Spotter($this->db); |
505 | 505 | $all = $Spotter->countAllDatesLastMonth($filters); |
506 | 506 | } |
507 | 507 | return $all; |
508 | 508 | } |
509 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
509 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
510 | 510 | global $globalDBdriver, $globalStatsFilters; |
511 | 511 | if ($filter_name == '') $filter_name = $this->filter_name; |
512 | 512 | if ($globalDBdriver == 'mysql') { |
@@ -514,40 +514,40 @@ discard block |
||
514 | 514 | } else { |
515 | 515 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
516 | 516 | } |
517 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
517 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
518 | 518 | try { |
519 | 519 | $sth = $this->db->prepare($query); |
520 | 520 | $sth->execute($query_data); |
521 | - } catch(PDOException $e) { |
|
521 | + } catch (PDOException $e) { |
|
522 | 522 | echo "error : ".$e->getMessage(); |
523 | 523 | } |
524 | 524 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
525 | 525 | if (empty($all)) { |
526 | 526 | $filters = array('airlines' => array($stats_airline)); |
527 | 527 | if ($filter_name != '') { |
528 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
528 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
529 | 529 | } |
530 | 530 | $Spotter = new Spotter($this->db); |
531 | 531 | $all = $Spotter->countAllDatesLast7Days($filters); |
532 | 532 | } |
533 | 533 | return $all; |
534 | 534 | } |
535 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
535 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
536 | 536 | global $globalStatsFilters; |
537 | 537 | if ($filter_name == '') $filter_name = $this->filter_name; |
538 | 538 | $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"; |
539 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
539 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
540 | 540 | try { |
541 | 541 | $sth = $this->db->prepare($query); |
542 | 542 | $sth->execute($query_data); |
543 | - } catch(PDOException $e) { |
|
543 | + } catch (PDOException $e) { |
|
544 | 544 | echo "error : ".$e->getMessage(); |
545 | 545 | } |
546 | 546 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
547 | 547 | if (empty($all)) { |
548 | 548 | $filters = array('airlines' => array($stats_airline)); |
549 | 549 | if ($filter_name != '') { |
550 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
550 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
551 | 551 | } |
552 | 552 | $Spotter = new Spotter($this->db); |
553 | 553 | $all = $Spotter->countAllDates($filters); |
@@ -562,35 +562,35 @@ discard block |
||
562 | 562 | try { |
563 | 563 | $sth = $this->db->prepare($query); |
564 | 564 | $sth->execute($query_data); |
565 | - } catch(PDOException $e) { |
|
565 | + } catch (PDOException $e) { |
|
566 | 566 | echo "error : ".$e->getMessage(); |
567 | 567 | } |
568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
569 | 569 | if (empty($all)) { |
570 | 570 | $filters = array(); |
571 | 571 | if ($filter_name != '') { |
572 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
572 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
573 | 573 | } |
574 | 574 | $Spotter = new Spotter($this->db); |
575 | 575 | $all = $Spotter->countAllDatesByAirlines($filters); |
576 | 576 | } |
577 | 577 | return $all; |
578 | 578 | } |
579 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
579 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
580 | 580 | global $globalStatsFilters; |
581 | 581 | if ($filter_name == '') $filter_name = $this->filter_name; |
582 | 582 | $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"; |
583 | 583 | try { |
584 | 584 | $sth = $this->db->prepare($query); |
585 | 585 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
586 | - } catch(PDOException $e) { |
|
586 | + } catch (PDOException $e) { |
|
587 | 587 | echo "error : ".$e->getMessage(); |
588 | 588 | } |
589 | 589 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
590 | 590 | if (empty($all)) { |
591 | 591 | $filters = array('airlines' => array($stats_airline)); |
592 | 592 | if ($filter_name != '') { |
593 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
593 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
594 | 594 | } |
595 | 595 | $Spotter = new Spotter($this->db); |
596 | 596 | $all = $Spotter->countAllMonths($filters); |
@@ -604,21 +604,21 @@ discard block |
||
604 | 604 | try { |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(array(':filter_name' => $filter_name)); |
607 | - } catch(PDOException $e) { |
|
607 | + } catch (PDOException $e) { |
|
608 | 608 | echo "error : ".$e->getMessage(); |
609 | 609 | } |
610 | 610 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
611 | 611 | if (empty($all)) { |
612 | 612 | $filters = array(); |
613 | 613 | if ($filter_name != '') { |
614 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
614 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
615 | 615 | } |
616 | 616 | $Spotter = new Spotter($this->db); |
617 | 617 | $all = $Spotter->countAllMilitaryMonths($filters); |
618 | 618 | } |
619 | 619 | return $all; |
620 | 620 | } |
621 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
621 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
622 | 622 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
623 | 623 | if ($filter_name == '') $filter_name = $this->filter_name; |
624 | 624 | 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"; |
@@ -635,17 +635,17 @@ discard block |
||
635 | 635 | try { |
636 | 636 | $sth = $this->db->prepare($query); |
637 | 637 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
638 | - } catch(PDOException $e) { |
|
638 | + } catch (PDOException $e) { |
|
639 | 639 | echo "error : ".$e->getMessage(); |
640 | 640 | } |
641 | 641 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
642 | 642 | if (empty($all)) { |
643 | 643 | $filters = array('airlines' => array($stats_airline)); |
644 | 644 | if ($filter_name != '') { |
645 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
645 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
646 | 646 | } |
647 | 647 | $Spotter = new Spotter($this->db); |
648 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
648 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
649 | 649 | } |
650 | 650 | return $all; |
651 | 651 | } |
@@ -653,11 +653,11 @@ discard block |
||
653 | 653 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
654 | 654 | global $globalStatsFilters; |
655 | 655 | if ($filter_name == '') $filter_name = $this->filter_name; |
656 | - $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
|
656 | + $all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name); |
|
657 | 657 | if (empty($all)) { |
658 | 658 | $filters = array('airlines' => array($stats_airline)); |
659 | 659 | if ($filter_name != '') { |
660 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
660 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
661 | 661 | } |
662 | 662 | $Spotter = new Spotter($this->db); |
663 | 663 | $all = $Spotter->countOverallFlights($filters); |
@@ -667,39 +667,39 @@ discard block |
||
667 | 667 | public function countOverallMilitaryFlights($filter_name = '') { |
668 | 668 | global $globalStatsFilters; |
669 | 669 | if ($filter_name == '') $filter_name = $this->filter_name; |
670 | - $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
|
670 | + $all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name); |
|
671 | 671 | if (empty($all)) { |
672 | 672 | $filters = array(); |
673 | 673 | if ($filter_name != '') { |
674 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
674 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
675 | 675 | } |
676 | 676 | $Spotter = new Spotter($this->db); |
677 | 677 | $all = $Spotter->countOverallMilitaryFlights($filters); |
678 | 678 | } |
679 | 679 | return $all; |
680 | 680 | } |
681 | - public function countOverallArrival($stats_airline = '',$filter_name = '') { |
|
681 | + public function countOverallArrival($stats_airline = '', $filter_name = '') { |
|
682 | 682 | global $globalStatsFilters; |
683 | 683 | if ($filter_name == '') $filter_name = $this->filter_name; |
684 | - $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
|
684 | + $all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name); |
|
685 | 685 | if (empty($all)) { |
686 | 686 | $filters = array('airlines' => array($stats_airline)); |
687 | 687 | if ($filter_name != '') { |
688 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
688 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
689 | 689 | } |
690 | 690 | $Spotter = new Spotter($this->db); |
691 | 691 | $all = $Spotter->countOverallArrival($filters); |
692 | 692 | } |
693 | 693 | return $all; |
694 | 694 | } |
695 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
|
695 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '') { |
|
696 | 696 | global $globalStatsFilters; |
697 | 697 | if ($filter_name == '') $filter_name = $this->filter_name; |
698 | - $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
|
698 | + $all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name); |
|
699 | 699 | if (empty($all)) { |
700 | 700 | $filters = array('airlines' => array($stats_airline)); |
701 | 701 | if ($filter_name != '') { |
702 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
702 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
703 | 703 | } |
704 | 704 | $Spotter = new Spotter($this->db); |
705 | 705 | $all = $Spotter->countOverallAircrafts($filters); |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | try { |
714 | 714 | $sth = $this->db->prepare($query); |
715 | 715 | $sth->execute(array(':filter_name' => $filter_name)); |
716 | - } catch(PDOException $e) { |
|
716 | + } catch (PDOException $e) { |
|
717 | 717 | echo "error : ".$e->getMessage(); |
718 | 718 | } |
719 | 719 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -722,14 +722,14 @@ discard block |
||
722 | 722 | if (empty($all)) { |
723 | 723 | $filters = array(); |
724 | 724 | if ($filter_name != '') { |
725 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
725 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
726 | 726 | } |
727 | 727 | $Spotter = new Spotter($this->db); |
728 | 728 | $all = $Spotter->countOverallAirlines($filters); |
729 | 729 | } |
730 | 730 | return $all; |
731 | 731 | } |
732 | - public function countOverallOwners($stats_airline = '',$filter_name = '') { |
|
732 | + public function countOverallOwners($stats_airline = '', $filter_name = '') { |
|
733 | 733 | global $globalStatsFilters; |
734 | 734 | if ($filter_name == '') $filter_name = $this->filter_name; |
735 | 735 | /* |
@@ -743,25 +743,25 @@ discard block |
||
743 | 743 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
744 | 744 | $all = $result[0]['nb_owner']; |
745 | 745 | */ |
746 | - $all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name); |
|
746 | + $all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name); |
|
747 | 747 | if (empty($all)) { |
748 | 748 | $filters = array('airlines' => array($stats_airline)); |
749 | 749 | if ($filter_name != '') { |
750 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
750 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
751 | 751 | } |
752 | 752 | $Spotter = new Spotter($this->db); |
753 | 753 | $all = $Spotter->countOverallOwners($filters); |
754 | 754 | } |
755 | 755 | return $all; |
756 | 756 | } |
757 | - public function countOverallPilots($stats_airline = '',$filter_name = '') { |
|
757 | + public function countOverallPilots($stats_airline = '', $filter_name = '') { |
|
758 | 758 | global $globalStatsFilters; |
759 | 759 | if ($filter_name == '') $filter_name = $this->filter_name; |
760 | - $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
|
760 | + $all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name); |
|
761 | 761 | if (empty($all)) { |
762 | 762 | $filters = array('airlines' => array($stats_airline)); |
763 | 763 | if ($filter_name != '') { |
764 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
764 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
765 | 765 | } |
766 | 766 | $Spotter = new Spotter($this->db); |
767 | 767 | $all = $Spotter->countOverallPilots($filters); |
@@ -769,33 +769,33 @@ discard block |
||
769 | 769 | return $all; |
770 | 770 | } |
771 | 771 | |
772 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
772 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
773 | 773 | if ($filter_name == '') $filter_name = $this->filter_name; |
774 | 774 | $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"; |
775 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
775 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
776 | 776 | try { |
777 | 777 | $sth = $this->db->prepare($query); |
778 | 778 | $sth->execute($query_values); |
779 | - } catch(PDOException $e) { |
|
779 | + } catch (PDOException $e) { |
|
780 | 780 | echo "error : ".$e->getMessage(); |
781 | 781 | } |
782 | 782 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
783 | 783 | return $all; |
784 | 784 | } |
785 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
785 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
786 | 786 | if ($filter_name == '') $filter_name = $this->filter_name; |
787 | 787 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
788 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
788 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
789 | 789 | try { |
790 | 790 | $sth = $this->db->prepare($query); |
791 | 791 | $sth->execute($query_values); |
792 | - } catch(PDOException $e) { |
|
792 | + } catch (PDOException $e) { |
|
793 | 793 | echo "error : ".$e->getMessage(); |
794 | 794 | } |
795 | 795 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
796 | 796 | return $all; |
797 | 797 | } |
798 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
|
798 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') { |
|
799 | 799 | if ($filter_name == '') $filter_name = $this->filter_name; |
800 | 800 | global $globalArchiveMonths, $globalDBdriver; |
801 | 801 | if ($globalDBdriver == 'mysql') { |
@@ -803,11 +803,11 @@ discard block |
||
803 | 803 | } else { |
804 | 804 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
805 | 805 | } |
806 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
806 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
807 | 807 | try { |
808 | 808 | $sth = $this->db->prepare($query); |
809 | 809 | $sth->execute($query_values); |
810 | - } catch(PDOException $e) { |
|
810 | + } catch (PDOException $e) { |
|
811 | 811 | echo "error : ".$e->getMessage(); |
812 | 812 | } |
813 | 813 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | try { |
826 | 826 | $sth = $this->db->prepare($query); |
827 | 827 | $sth->execute($query_values); |
828 | - } catch(PDOException $e) { |
|
828 | + } catch (PDOException $e) { |
|
829 | 829 | echo "error : ".$e->getMessage(); |
830 | 830 | } |
831 | 831 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | try { |
843 | 843 | $sth = $this->db->prepare($query); |
844 | 844 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
845 | - } catch(PDOException $e) { |
|
845 | + } catch (PDOException $e) { |
|
846 | 846 | echo "error : ".$e->getMessage(); |
847 | 847 | } |
848 | 848 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | try { |
860 | 860 | $sth = $this->db->prepare($query); |
861 | 861 | $sth->execute(array(':filter_name' => $filter_name)); |
862 | - } catch(PDOException $e) { |
|
862 | + } catch (PDOException $e) { |
|
863 | 863 | echo "error : ".$e->getMessage(); |
864 | 864 | } |
865 | 865 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | try { |
877 | 877 | $sth = $this->db->prepare($query); |
878 | 878 | $sth->execute(array(':filter_name' => $filter_name)); |
879 | - } catch(PDOException $e) { |
|
879 | + } catch (PDOException $e) { |
|
880 | 880 | echo "error : ".$e->getMessage(); |
881 | 881 | } |
882 | 882 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -893,14 +893,14 @@ discard block |
||
893 | 893 | try { |
894 | 894 | $sth = $this->db->prepare($query); |
895 | 895 | $sth->execute(array(':filter_name' => $filter_name)); |
896 | - } catch(PDOException $e) { |
|
896 | + } catch (PDOException $e) { |
|
897 | 897 | echo "error : ".$e->getMessage(); |
898 | 898 | } |
899 | 899 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
900 | 900 | return $all[0]['total']; |
901 | 901 | } |
902 | 902 | |
903 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
903 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
904 | 904 | global $globalDBdriver; |
905 | 905 | if ($filter_name == '') $filter_name = $this->filter_name; |
906 | 906 | if ($globalDBdriver == 'mysql') { |
@@ -908,15 +908,15 @@ discard block |
||
908 | 908 | } else { |
909 | 909 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
910 | 910 | } |
911 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
911 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
912 | 912 | try { |
913 | 913 | $sth = $this->db->prepare($query); |
914 | 914 | $sth->execute($query_values); |
915 | - } catch(PDOException $e) { |
|
915 | + } catch (PDOException $e) { |
|
916 | 916 | return "error : ".$e->getMessage(); |
917 | 917 | } |
918 | 918 | } |
919 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
919 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
920 | 920 | global $globalDBdriver; |
921 | 921 | if ($filter_name == '') $filter_name = $this->filter_name; |
922 | 922 | if ($globalDBdriver == 'mysql') { |
@@ -925,163 +925,163 @@ discard block |
||
925 | 925 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
926 | 926 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
927 | 927 | } |
928 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
928 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
929 | 929 | try { |
930 | 930 | $sth = $this->db->prepare($query); |
931 | 931 | $sth->execute($query_values); |
932 | - } catch(PDOException $e) { |
|
932 | + } catch (PDOException $e) { |
|
933 | 933 | return "error : ".$e->getMessage(); |
934 | 934 | } |
935 | 935 | } |
936 | - public function getStatsSource($date,$stats_type = '') { |
|
936 | + public function getStatsSource($date, $stats_type = '') { |
|
937 | 937 | if ($stats_type == '') { |
938 | 938 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
939 | 939 | $query_values = array(':date' => $date); |
940 | 940 | } else { |
941 | 941 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
942 | - $query_values = array(':date' => $date,':stats_type' => $stats_type); |
|
942 | + $query_values = array(':date' => $date, ':stats_type' => $stats_type); |
|
943 | 943 | } |
944 | 944 | try { |
945 | 945 | $sth = $this->db->prepare($query); |
946 | 946 | $sth->execute($query_values); |
947 | - } catch(PDOException $e) { |
|
947 | + } catch (PDOException $e) { |
|
948 | 948 | echo "error : ".$e->getMessage(); |
949 | 949 | } |
950 | 950 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
951 | 951 | return $all; |
952 | 952 | } |
953 | 953 | |
954 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
954 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
955 | 955 | global $globalDBdriver; |
956 | 956 | if ($globalDBdriver == 'mysql') { |
957 | 957 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
958 | 958 | } else { |
959 | 959 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
960 | 960 | } |
961 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
961 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
962 | 962 | try { |
963 | 963 | $sth = $this->db->prepare($query); |
964 | 964 | $sth->execute($query_values); |
965 | - } catch(PDOException $e) { |
|
965 | + } catch (PDOException $e) { |
|
966 | 966 | return "error : ".$e->getMessage(); |
967 | 967 | } |
968 | 968 | } |
969 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
969 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
970 | 970 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
971 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
971 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
972 | 972 | try { |
973 | 973 | $sth = $this->db->prepare($query); |
974 | 974 | $sth->execute($query_values); |
975 | - } catch(PDOException $e) { |
|
975 | + } catch (PDOException $e) { |
|
976 | 976 | return "error : ".$e->getMessage(); |
977 | 977 | } |
978 | 978 | } |
979 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
|
979 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '') { |
|
980 | 980 | global $globalDBdriver; |
981 | 981 | if ($globalDBdriver == 'mysql') { |
982 | 982 | $query = "INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) VALUES (:aircraft_icao,:registration,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
983 | 983 | } else { |
984 | 984 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
985 | 985 | } |
986 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
986 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
987 | 987 | try { |
988 | 988 | $sth = $this->db->prepare($query); |
989 | 989 | $sth->execute($query_values); |
990 | - } catch(PDOException $e) { |
|
990 | + } catch (PDOException $e) { |
|
991 | 991 | return "error : ".$e->getMessage(); |
992 | 992 | } |
993 | 993 | } |
994 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
|
994 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '') { |
|
995 | 995 | global $globalDBdriver; |
996 | 996 | if ($globalDBdriver == 'mysql') { |
997 | 997 | $query = "INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) VALUES (:callsign_icao,:airline_icao,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
998 | 998 | } else { |
999 | 999 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1000 | 1000 | } |
1001 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1001 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1002 | 1002 | try { |
1003 | 1003 | $sth = $this->db->prepare($query); |
1004 | 1004 | $sth->execute($query_values); |
1005 | - } catch(PDOException $e) { |
|
1005 | + } catch (PDOException $e) { |
|
1006 | 1006 | return "error : ".$e->getMessage(); |
1007 | 1007 | } |
1008 | 1008 | } |
1009 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
|
1009 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '') { |
|
1010 | 1010 | global $globalDBdriver; |
1011 | 1011 | if ($globalDBdriver == 'mysql') { |
1012 | 1012 | $query = "INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) VALUES (:iso2,:iso3,:name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
1013 | 1013 | } else { |
1014 | 1014 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
1015 | 1015 | } |
1016 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1016 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1017 | 1017 | try { |
1018 | 1018 | $sth = $this->db->prepare($query); |
1019 | 1019 | $sth->execute($query_values); |
1020 | - } catch(PDOException $e) { |
|
1020 | + } catch (PDOException $e) { |
|
1021 | 1021 | return "error : ".$e->getMessage(); |
1022 | 1022 | } |
1023 | 1023 | } |
1024 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
|
1024 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
|
1025 | 1025 | global $globalDBdriver; |
1026 | 1026 | if ($globalDBdriver == 'mysql') { |
1027 | 1027 | $query = "INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline, filter_name) VALUES (:aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, stats_airline = :stats_airline"; |
1028 | 1028 | } else { |
1029 | 1029 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1030 | 1030 | } |
1031 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1031 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1032 | 1032 | try { |
1033 | 1033 | $sth = $this->db->prepare($query); |
1034 | 1034 | $sth->execute($query_values); |
1035 | - } catch(PDOException $e) { |
|
1035 | + } catch (PDOException $e) { |
|
1036 | 1036 | return "error : ".$e->getMessage(); |
1037 | 1037 | } |
1038 | 1038 | } |
1039 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
|
1039 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '') { |
|
1040 | 1040 | global $globalDBdriver; |
1041 | 1041 | if ($globalDBdriver == 'mysql') { |
1042 | 1042 | $query = "INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) VALUES (:airline_icao,:airline_name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt,airline_name = :airline_name"; |
1043 | 1043 | } else { |
1044 | 1044 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1045 | 1045 | } |
1046 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1046 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1047 | 1047 | try { |
1048 | 1048 | $sth = $this->db->prepare($query); |
1049 | 1049 | $sth->execute($query_values); |
1050 | - } catch(PDOException $e) { |
|
1050 | + } catch (PDOException $e) { |
|
1051 | 1051 | return "error : ".$e->getMessage(); |
1052 | 1052 | } |
1053 | 1053 | } |
1054 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
|
1054 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
1055 | 1055 | global $globalDBdriver; |
1056 | 1056 | if ($globalDBdriver == 'mysql') { |
1057 | 1057 | $query = "INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) VALUES (:owner_name,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
1058 | 1058 | } else { |
1059 | 1059 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1060 | 1060 | } |
1061 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1061 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1062 | 1062 | try { |
1063 | 1063 | $sth = $this->db->prepare($query); |
1064 | 1064 | $sth->execute($query_values); |
1065 | - } catch(PDOException $e) { |
|
1065 | + } catch (PDOException $e) { |
|
1066 | 1066 | return "error : ".$e->getMessage(); |
1067 | 1067 | } |
1068 | 1068 | } |
1069 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') { |
|
1069 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '') { |
|
1070 | 1070 | global $globalDBdriver; |
1071 | 1071 | if ($globalDBdriver == 'mysql') { |
1072 | 1072 | $query = "INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) VALUES (:pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, pilot_name = :pilot_name"; |
1073 | 1073 | } else { |
1074 | 1074 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1075 | 1075 | } |
1076 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1076 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source); |
|
1077 | 1077 | try { |
1078 | 1078 | $sth = $this->db->prepare($query); |
1079 | 1079 | $sth->execute($query_values); |
1080 | - } catch(PDOException $e) { |
|
1080 | + } catch (PDOException $e) { |
|
1081 | 1081 | return "error : ".$e->getMessage(); |
1082 | 1082 | } |
1083 | 1083 | } |
1084 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1084 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1085 | 1085 | global $globalDBdriver; |
1086 | 1086 | if ($airport_icao != '') { |
1087 | 1087 | if ($globalDBdriver == 'mysql') { |
@@ -1089,16 +1089,16 @@ discard block |
||
1089 | 1089 | } else { |
1090 | 1090 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1091 | 1091 | } |
1092 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1092 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1093 | 1093 | try { |
1094 | 1094 | $sth = $this->db->prepare($query); |
1095 | 1095 | $sth->execute($query_values); |
1096 | - } catch(PDOException $e) { |
|
1096 | + } catch (PDOException $e) { |
|
1097 | 1097 | return "error : ".$e->getMessage(); |
1098 | 1098 | } |
1099 | 1099 | } |
1100 | 1100 | } |
1101 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1101 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1102 | 1102 | global $globalDBdriver; |
1103 | 1103 | if ($airport_icao != '') { |
1104 | 1104 | if ($globalDBdriver == 'mysql') { |
@@ -1106,16 +1106,16 @@ discard block |
||
1106 | 1106 | } else { |
1107 | 1107 | $query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1108 | 1108 | } |
1109 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1109 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1110 | 1110 | try { |
1111 | 1111 | $sth = $this->db->prepare($query); |
1112 | 1112 | $sth->execute($query_values); |
1113 | - } catch(PDOException $e) { |
|
1113 | + } catch (PDOException $e) { |
|
1114 | 1114 | return "error : ".$e->getMessage(); |
1115 | 1115 | } |
1116 | 1116 | } |
1117 | 1117 | } |
1118 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1118 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | if ($airport_icao != '') { |
1121 | 1121 | if ($globalDBdriver == 'mysql') { |
@@ -1123,16 +1123,16 @@ discard block |
||
1123 | 1123 | } else { |
1124 | 1124 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1125 | 1125 | } |
1126 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1126 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1127 | 1127 | try { |
1128 | 1128 | $sth = $this->db->prepare($query); |
1129 | 1129 | $sth->execute($query_values); |
1130 | - } catch(PDOException $e) { |
|
1130 | + } catch (PDOException $e) { |
|
1131 | 1131 | return "error : ".$e->getMessage(); |
1132 | 1132 | } |
1133 | 1133 | } |
1134 | 1134 | } |
1135 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1135 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1136 | 1136 | global $globalDBdriver; |
1137 | 1137 | if ($airport_icao != '') { |
1138 | 1138 | if ($globalDBdriver == 'mysql') { |
@@ -1140,11 +1140,11 @@ discard block |
||
1140 | 1140 | } else { |
1141 | 1141 | $query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1142 | 1142 | } |
1143 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1143 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1144 | 1144 | try { |
1145 | 1145 | $sth = $this->db->prepare($query); |
1146 | 1146 | $sth->execute($query_values); |
1147 | - } catch(PDOException $e) { |
|
1147 | + } catch (PDOException $e) { |
|
1148 | 1148 | return "error : ".$e->getMessage(); |
1149 | 1149 | } |
1150 | 1150 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | try { |
1157 | 1157 | $sth = $this->db->prepare($query); |
1158 | 1158 | $sth->execute($query_values); |
1159 | - } catch(PDOException $e) { |
|
1159 | + } catch (PDOException $e) { |
|
1160 | 1160 | return "error : ".$e->getMessage(); |
1161 | 1161 | } |
1162 | 1162 | } |
@@ -1166,7 +1166,7 @@ discard block |
||
1166 | 1166 | try { |
1167 | 1167 | $sth = $this->db->prepare($query); |
1168 | 1168 | $sth->execute($query_values); |
1169 | - } catch(PDOException $e) { |
|
1169 | + } catch (PDOException $e) { |
|
1170 | 1170 | return "error : ".$e->getMessage(); |
1171 | 1171 | } |
1172 | 1172 | } |
@@ -1176,13 +1176,13 @@ discard block |
||
1176 | 1176 | try { |
1177 | 1177 | $sth = $this->db->prepare($query); |
1178 | 1178 | $sth->execute($query_values); |
1179 | - } catch(PDOException $e) { |
|
1179 | + } catch (PDOException $e) { |
|
1180 | 1180 | return "error : ".$e->getMessage(); |
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | public function addOldStats() { |
1185 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats; |
|
1185 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats; |
|
1186 | 1186 | $Common = new Common(); |
1187 | 1187 | $Connection = new Connection(); |
1188 | 1188 | date_default_timezone_set('UTC'); |
@@ -1415,40 +1415,40 @@ discard block |
||
1415 | 1415 | $last_update_day = $last_update[0]['value']; |
1416 | 1416 | } else $last_update_day = '2012-12-12 12:12:12'; |
1417 | 1417 | $Spotter = new Spotter($this->db); |
1418 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
1418 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
1419 | 1419 | foreach ($alldata as $number) { |
1420 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
|
1420 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer']); |
|
1421 | 1421 | } |
1422 | 1422 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
1423 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
1423 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
1424 | 1424 | foreach ($alldata as $number) { |
1425 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
|
1425 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']); |
|
1426 | 1426 | } |
1427 | 1427 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
1428 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
1428 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
1429 | 1429 | foreach ($alldata as $number) { |
1430 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
|
1430 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']); |
|
1431 | 1431 | } |
1432 | 1432 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
1433 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
1433 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
1434 | 1434 | foreach ($alldata as $number) { |
1435 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
|
1435 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']); |
|
1436 | 1436 | } |
1437 | 1437 | if ($globalDebug) echo 'Count all owners...'."\n"; |
1438 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
1438 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
1439 | 1439 | foreach ($alldata as $number) { |
1440 | - $this->addStatOwner($number['owner_name'],$number['owner_count']); |
|
1440 | + $this->addStatOwner($number['owner_name'], $number['owner_count']); |
|
1441 | 1441 | } |
1442 | 1442 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
1443 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
1443 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
1444 | 1444 | foreach ($alldata as $number) { |
1445 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']); |
|
1445 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source']); |
|
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1449 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
1449 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
1450 | 1450 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1451 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1451 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
1452 | 1452 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1453 | 1453 | $alldata = array(); |
1454 | 1454 | |
@@ -1466,14 +1466,14 @@ discard block |
||
1466 | 1466 | foreach ($alldata as $key => $row) { |
1467 | 1467 | $count[$key] = $row['airport_departure_icao_count']; |
1468 | 1468 | } |
1469 | - array_multisort($count,SORT_DESC,$alldata); |
|
1469 | + array_multisort($count, SORT_DESC, $alldata); |
|
1470 | 1470 | foreach ($alldata as $number) { |
1471 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
|
1471 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']); |
|
1472 | 1472 | } |
1473 | 1473 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1474 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
1474 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
1475 | 1475 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1476 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1476 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
1477 | 1477 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1478 | 1478 | $alldata = array(); |
1479 | 1479 | foreach ($pall as $value) { |
@@ -1490,16 +1490,16 @@ discard block |
||
1490 | 1490 | foreach ($alldata as $key => $row) { |
1491 | 1491 | $count[$key] = $row['airport_arrival_icao_count']; |
1492 | 1492 | } |
1493 | - array_multisort($count,SORT_DESC,$alldata); |
|
1493 | + array_multisort($count, SORT_DESC, $alldata); |
|
1494 | 1494 | foreach ($alldata as $number) { |
1495 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
|
1495 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']); |
|
1496 | 1496 | } |
1497 | 1497 | if ($Connection->tableExists('countries')) { |
1498 | 1498 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
1499 | 1499 | $SpotterArchive = new SpotterArchive(); |
1500 | - $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
|
1500 | + $alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day); |
|
1501 | 1501 | foreach ($alldata as $number) { |
1502 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']); |
|
1502 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']); |
|
1503 | 1503 | } |
1504 | 1504 | } |
1505 | 1505 | |
@@ -1513,37 +1513,37 @@ discard block |
||
1513 | 1513 | $lastyear = false; |
1514 | 1514 | foreach ($alldata as $number) { |
1515 | 1515 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1516 | - $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']))); |
|
1516 | + $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']))); |
|
1517 | 1517 | } |
1518 | 1518 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
1519 | 1519 | $alldata = $Spotter->countAllMilitaryMonths(); |
1520 | 1520 | foreach ($alldata as $number) { |
1521 | - $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']))); |
|
1521 | + $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']))); |
|
1522 | 1522 | } |
1523 | 1523 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
1524 | 1524 | $alldata = $Spotter->countAllMonthsOwners(); |
1525 | 1525 | foreach ($alldata as $number) { |
1526 | - $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']))); |
|
1526 | + $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']))); |
|
1527 | 1527 | } |
1528 | 1528 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
1529 | 1529 | $alldata = $Spotter->countAllMonthsPilots(); |
1530 | 1530 | foreach ($alldata as $number) { |
1531 | - $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']))); |
|
1531 | + $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']))); |
|
1532 | 1532 | } |
1533 | 1533 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
1534 | 1534 | $alldata = $Spotter->countAllMonthsAirlines(); |
1535 | 1535 | foreach ($alldata as $number) { |
1536 | - $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']))); |
|
1536 | + $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']))); |
|
1537 | 1537 | } |
1538 | 1538 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
1539 | 1539 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1540 | 1540 | foreach ($alldata as $number) { |
1541 | - $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']))); |
|
1541 | + $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']))); |
|
1542 | 1542 | } |
1543 | 1543 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
1544 | 1544 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1545 | 1545 | foreach ($alldata as $number) { |
1546 | - $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']))); |
|
1546 | + $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']))); |
|
1547 | 1547 | } |
1548 | 1548 | if ($globalDebug) echo 'Airports data...'."\n"; |
1549 | 1549 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | } |
1589 | 1589 | $alldata = $pall; |
1590 | 1590 | foreach ($alldata as $number) { |
1591 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
1591 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
1592 | 1592 | } |
1593 | 1593 | echo '...Arrival'."\n"; |
1594 | 1594 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -1630,7 +1630,7 @@ discard block |
||
1630 | 1630 | } |
1631 | 1631 | $alldata = $pall; |
1632 | 1632 | foreach ($alldata as $number) { |
1633 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
1633 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
1634 | 1634 | } |
1635 | 1635 | |
1636 | 1636 | echo 'Flights data...'."\n"; |
@@ -1638,28 +1638,28 @@ discard block |
||
1638 | 1638 | echo '-> countAllDatesLastMonth...'."\n"; |
1639 | 1639 | $alldata = $Spotter->countAllDatesLastMonth(); |
1640 | 1640 | foreach ($alldata as $number) { |
1641 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
1641 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
1642 | 1642 | } |
1643 | 1643 | echo '-> countAllDates...'."\n"; |
1644 | 1644 | $previousdata = $this->countAllDates(); |
1645 | 1645 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
1646 | 1646 | $this->deleteStatFlight('date'); |
1647 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates()); |
|
1647 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates()); |
|
1648 | 1648 | $values = array(); |
1649 | 1649 | foreach ($alldata as $cnt) { |
1650 | 1650 | $values[] = $cnt['date_count']; |
1651 | 1651 | } |
1652 | - array_multisort($values,SORT_DESC,$alldata); |
|
1653 | - array_splice($alldata,11); |
|
1652 | + array_multisort($values, SORT_DESC, $alldata); |
|
1653 | + array_splice($alldata, 11); |
|
1654 | 1654 | foreach ($alldata as $number) { |
1655 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
1655 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
1656 | 1656 | } |
1657 | 1657 | |
1658 | 1658 | $this->deleteStatFlight('hour'); |
1659 | 1659 | echo '-> countAllHours...'."\n"; |
1660 | 1660 | $alldata = $Spotter->countAllHours('hour'); |
1661 | 1661 | foreach ($alldata as $number) { |
1662 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
1662 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | |
@@ -1668,34 +1668,34 @@ discard block |
||
1668 | 1668 | echo '--- Stats by airlines ---'."\n"; |
1669 | 1669 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
1670 | 1670 | $Spotter = new Spotter($this->db); |
1671 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
1671 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
1672 | 1672 | foreach ($alldata as $number) { |
1673 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
|
1673 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao']); |
|
1674 | 1674 | } |
1675 | 1675 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
1676 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
1676 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
1677 | 1677 | foreach ($alldata as $number) { |
1678 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
|
1678 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao']); |
|
1679 | 1679 | } |
1680 | 1680 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
1681 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
1681 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
1682 | 1682 | foreach ($alldata as $number) { |
1683 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
|
1683 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']); |
|
1684 | 1684 | } |
1685 | 1685 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
1686 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
1686 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
1687 | 1687 | foreach ($alldata as $number) { |
1688 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
|
1688 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao']); |
|
1689 | 1689 | } |
1690 | 1690 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
1691 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
1691 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
1692 | 1692 | foreach ($alldata as $number) { |
1693 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']); |
|
1693 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source']); |
|
1694 | 1694 | } |
1695 | 1695 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1696 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1696 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1697 | 1697 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1698 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1698 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1699 | 1699 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1700 | 1700 | //$alldata = array(); |
1701 | 1701 | foreach ($dall as $value) { |
@@ -1715,12 +1715,12 @@ discard block |
||
1715 | 1715 | } |
1716 | 1716 | $alldata = $pall; |
1717 | 1717 | foreach ($alldata as $number) { |
1718 | - 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']); |
|
1718 | + 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']); |
|
1719 | 1719 | } |
1720 | 1720 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1721 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1721 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1722 | 1722 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1723 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1723 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1724 | 1724 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1725 | 1725 | //$alldata = array(); |
1726 | 1726 | foreach ($dall as $value) { |
@@ -1740,7 +1740,7 @@ discard block |
||
1740 | 1740 | } |
1741 | 1741 | $alldata = $pall; |
1742 | 1742 | foreach ($alldata as $number) { |
1743 | - 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']); |
|
1743 | + 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']); |
|
1744 | 1744 | } |
1745 | 1745 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
1746 | 1746 | $Spotter = new Spotter($this->db); |
@@ -1748,27 +1748,27 @@ discard block |
||
1748 | 1748 | $lastyear = false; |
1749 | 1749 | foreach ($alldata as $number) { |
1750 | 1750 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1751 | - $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']); |
|
1751 | + $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']); |
|
1752 | 1752 | } |
1753 | 1753 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
1754 | 1754 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1755 | 1755 | foreach ($alldata as $number) { |
1756 | - $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']); |
|
1756 | + $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']); |
|
1757 | 1757 | } |
1758 | 1758 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
1759 | 1759 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1760 | 1760 | foreach ($alldata as $number) { |
1761 | - $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']); |
|
1761 | + $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']); |
|
1762 | 1762 | } |
1763 | 1763 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
1764 | 1764 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1765 | 1765 | foreach ($alldata as $number) { |
1766 | - $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']); |
|
1766 | + $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']); |
|
1767 | 1767 | } |
1768 | 1768 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
1769 | 1769 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1770 | 1770 | foreach ($alldata as $number) { |
1771 | - $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']); |
|
1771 | + $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']); |
|
1772 | 1772 | } |
1773 | 1773 | if ($globalDebug) echo '...Departure'."\n"; |
1774 | 1774 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -1791,7 +1791,7 @@ discard block |
||
1791 | 1791 | } |
1792 | 1792 | $alldata = $pall; |
1793 | 1793 | foreach ($alldata as $number) { |
1794 | - $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']); |
|
1794 | + $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']); |
|
1795 | 1795 | } |
1796 | 1796 | if ($globalDebug) echo '...Arrival'."\n"; |
1797 | 1797 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -1814,32 +1814,32 @@ discard block |
||
1814 | 1814 | } |
1815 | 1815 | $alldata = $pall; |
1816 | 1816 | foreach ($alldata as $number) { |
1817 | - $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']); |
|
1817 | + $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']); |
|
1818 | 1818 | } |
1819 | 1819 | |
1820 | 1820 | if ($globalDebug) echo 'Flights data...'."\n"; |
1821 | 1821 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
1822 | 1822 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1823 | 1823 | foreach ($alldata as $number) { |
1824 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
1824 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1825 | 1825 | } |
1826 | 1826 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
1827 | 1827 | //$previousdata = $this->countAllDatesByAirlines(); |
1828 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
|
1828 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines()); |
|
1829 | 1829 | $values = array(); |
1830 | 1830 | foreach ($alldata as $cnt) { |
1831 | 1831 | $values[] = $cnt['date_count']; |
1832 | 1832 | } |
1833 | - array_multisort($values,SORT_DESC,$alldata); |
|
1834 | - array_splice($alldata,11); |
|
1833 | + array_multisort($values, SORT_DESC, $alldata); |
|
1834 | + array_splice($alldata, 11); |
|
1835 | 1835 | foreach ($alldata as $number) { |
1836 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
1836 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1837 | 1837 | } |
1838 | 1838 | |
1839 | 1839 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
1840 | 1840 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1841 | 1841 | foreach ($alldata as $number) { |
1842 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
1842 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
1843 | 1843 | } |
1844 | 1844 | |
1845 | 1845 | |
@@ -1856,32 +1856,32 @@ discard block |
||
1856 | 1856 | // Count by filter |
1857 | 1857 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
1858 | 1858 | $Spotter = new Spotter($this->db); |
1859 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
1859 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
1860 | 1860 | foreach ($alldata as $number) { |
1861 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name); |
|
1861 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name); |
|
1862 | 1862 | } |
1863 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
1863 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
1864 | 1864 | foreach ($alldata as $number) { |
1865 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name); |
|
1865 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name); |
|
1866 | 1866 | } |
1867 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
1867 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
1868 | 1868 | foreach ($alldata as $number) { |
1869 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name); |
|
1869 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name); |
|
1870 | 1870 | } |
1871 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
1871 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
1872 | 1872 | foreach ($alldata as $number) { |
1873 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name); |
|
1873 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name); |
|
1874 | 1874 | } |
1875 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
1875 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
1876 | 1876 | foreach ($alldata as $number) { |
1877 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name); |
|
1877 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name); |
|
1878 | 1878 | } |
1879 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
1879 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
1880 | 1880 | foreach ($alldata as $number) { |
1881 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source']); |
|
1881 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source']); |
|
1882 | 1882 | } |
1883 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
1884 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1883 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
1884 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
1885 | 1885 | $alldata = array(); |
1886 | 1886 | foreach ($pall as $value) { |
1887 | 1887 | $icao = $value['airport_departure_icao']; |
@@ -1897,12 +1897,12 @@ discard block |
||
1897 | 1897 | foreach ($alldata as $key => $row) { |
1898 | 1898 | $count[$key] = $row['airport_departure_icao_count']; |
1899 | 1899 | } |
1900 | - array_multisort($count,SORT_DESC,$alldata); |
|
1900 | + array_multisort($count, SORT_DESC, $alldata); |
|
1901 | 1901 | foreach ($alldata as $number) { |
1902 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name); |
|
1902 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name); |
|
1903 | 1903 | } |
1904 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
|
1905 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
1904 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
1905 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
1906 | 1906 | $alldata = array(); |
1907 | 1907 | foreach ($pall as $value) { |
1908 | 1908 | $icao = $value['airport_arrival_icao']; |
@@ -1918,40 +1918,40 @@ discard block |
||
1918 | 1918 | foreach ($alldata as $key => $row) { |
1919 | 1919 | $count[$key] = $row['airport_arrival_icao_count']; |
1920 | 1920 | } |
1921 | - array_multisort($count,SORT_DESC,$alldata); |
|
1921 | + array_multisort($count, SORT_DESC, $alldata); |
|
1922 | 1922 | foreach ($alldata as $number) { |
1923 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name); |
|
1923 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name); |
|
1924 | 1924 | } |
1925 | 1925 | $Spotter = new Spotter($this->db); |
1926 | 1926 | $alldata = $Spotter->countAllMonths($filter); |
1927 | 1927 | $lastyear = false; |
1928 | 1928 | foreach ($alldata as $number) { |
1929 | 1929 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1930 | - $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); |
|
1930 | + $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); |
|
1931 | 1931 | } |
1932 | 1932 | $alldata = $Spotter->countAllMonthsOwners($filter); |
1933 | 1933 | foreach ($alldata as $number) { |
1934 | - $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'])),'',$filter_name); |
|
1934 | + $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'])), '', $filter_name); |
|
1935 | 1935 | } |
1936 | 1936 | $alldata = $Spotter->countAllMonthsPilots($filter); |
1937 | 1937 | foreach ($alldata as $number) { |
1938 | - $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'])),'',$filter_name); |
|
1938 | + $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'])), '', $filter_name); |
|
1939 | 1939 | } |
1940 | 1940 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
1941 | 1941 | foreach ($alldata as $number) { |
1942 | - $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'])),'',$filter_name); |
|
1942 | + $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'])), '', $filter_name); |
|
1943 | 1943 | } |
1944 | 1944 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
1945 | 1945 | foreach ($alldata as $number) { |
1946 | - $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'])),'',$filter_name); |
|
1946 | + $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'])), '', $filter_name); |
|
1947 | 1947 | } |
1948 | 1948 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
1949 | 1949 | foreach ($alldata as $number) { |
1950 | - $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'])),'',$filter_name); |
|
1950 | + $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'])), '', $filter_name); |
|
1951 | 1951 | } |
1952 | 1952 | echo '...Departure'."\n"; |
1953 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
1954 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1953 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
1954 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
1955 | 1955 | foreach ($dall as $value) { |
1956 | 1956 | $icao = $value['departure_airport_icao']; |
1957 | 1957 | $ddate = $value['date']; |
@@ -1969,11 +1969,11 @@ discard block |
||
1969 | 1969 | } |
1970 | 1970 | $alldata = $pall; |
1971 | 1971 | foreach ($alldata as $number) { |
1972 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
|
1972 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name); |
|
1973 | 1973 | } |
1974 | 1974 | echo '...Arrival'."\n"; |
1975 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
1976 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1975 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
1976 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
1977 | 1977 | foreach ($dall as $value) { |
1978 | 1978 | $icao = $value['arrival_airport_icao']; |
1979 | 1979 | $ddate = $value['date']; |
@@ -1991,40 +1991,40 @@ discard block |
||
1991 | 1991 | } |
1992 | 1992 | $alldata = $pall; |
1993 | 1993 | foreach ($alldata as $number) { |
1994 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
|
1994 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name); |
|
1995 | 1995 | } |
1996 | 1996 | |
1997 | 1997 | echo 'Flights data...'."\n"; |
1998 | 1998 | echo '-> countAllDatesLastMonth...'."\n"; |
1999 | 1999 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
2000 | 2000 | foreach ($alldata as $number) { |
2001 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
2001 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
2002 | 2002 | } |
2003 | 2003 | echo '-> countAllDates...'."\n"; |
2004 | - $previousdata = $this->countAllDates('',$filter_name); |
|
2005 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
2004 | + $previousdata = $this->countAllDates('', $filter_name); |
|
2005 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
2006 | 2006 | $values = array(); |
2007 | 2007 | foreach ($alldata as $cnt) { |
2008 | 2008 | $values[] = $cnt['date_count']; |
2009 | 2009 | } |
2010 | - array_multisort($values,SORT_DESC,$alldata); |
|
2011 | - array_splice($alldata,11); |
|
2010 | + array_multisort($values, SORT_DESC, $alldata); |
|
2011 | + array_splice($alldata, 11); |
|
2012 | 2012 | foreach ($alldata as $number) { |
2013 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
2013 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
2014 | 2014 | } |
2015 | 2015 | |
2016 | 2016 | echo '-> countAllHours...'."\n"; |
2017 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
2017 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
2018 | 2018 | foreach ($alldata as $number) { |
2019 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
2019 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
2020 | 2020 | } |
2021 | 2021 | echo 'Insert last stats update date...'."\n"; |
2022 | 2022 | date_default_timezone_set('UTC'); |
2023 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
2023 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
2024 | 2024 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
2025 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
2025 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
2026 | 2026 | $this->deleteOldStats($filter_name); |
2027 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
2027 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
2028 | 2028 | } |
2029 | 2029 | } |
2030 | 2030 | |
@@ -2037,16 +2037,16 @@ discard block |
||
2037 | 2037 | // SUM all previous month to put as year |
2038 | 2038 | $previous_year = date('Y'); |
2039 | 2039 | $previous_year--; |
2040 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2041 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2042 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2043 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2040 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2041 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2042 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2043 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2044 | 2044 | $allairlines = $this->getAllAirlineNames(); |
2045 | 2045 | foreach ($allairlines as $data) { |
2046 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2047 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2048 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2049 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2046 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2047 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2048 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2049 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2050 | 2050 | } |
2051 | 2051 | |
2052 | 2052 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -2055,7 +2055,7 @@ discard block |
||
2055 | 2055 | try { |
2056 | 2056 | $sth = $this->db->prepare($query); |
2057 | 2057 | $sth->execute(); |
2058 | - } catch(PDOException $e) { |
|
2058 | + } catch (PDOException $e) { |
|
2059 | 2059 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2060 | 2060 | } |
2061 | 2061 | } |
@@ -2064,15 +2064,15 @@ discard block |
||
2064 | 2064 | try { |
2065 | 2065 | $sth = $this->db->prepare($query); |
2066 | 2066 | $sth->execute(); |
2067 | - } catch(PDOException $e) { |
|
2067 | + } catch (PDOException $e) { |
|
2068 | 2068 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2069 | 2069 | } |
2070 | 2070 | } |
2071 | 2071 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
2072 | 2072 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
2073 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
2073 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
2074 | 2074 | $this->deleteOldStats(); |
2075 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
2075 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
2076 | 2076 | $lastyearupdate = true; |
2077 | 2077 | } |
2078 | 2078 | } |
@@ -2094,7 +2094,7 @@ discard block |
||
2094 | 2094 | try { |
2095 | 2095 | $sth = $this->db->prepare($query); |
2096 | 2096 | $sth->execute(); |
2097 | - } catch(PDOException $e) { |
|
2097 | + } catch (PDOException $e) { |
|
2098 | 2098 | return "error : ".$e->getMessage(); |
2099 | 2099 | } |
2100 | 2100 | } |
@@ -2108,14 +2108,14 @@ discard block |
||
2108 | 2108 | try { |
2109 | 2109 | $sth = $this->db->prepare($query); |
2110 | 2110 | $sth->execute(); |
2111 | - } catch(PDOException $e) { |
|
2111 | + } catch (PDOException $e) { |
|
2112 | 2112 | return "error : ".$e->getMessage(); |
2113 | 2113 | } |
2114 | 2114 | } |
2115 | 2115 | if (!isset($lastyearupdate)) { |
2116 | 2116 | echo 'Insert last stats update date...'."\n"; |
2117 | 2117 | date_default_timezone_set('UTC'); |
2118 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
2118 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
2119 | 2119 | } |
2120 | 2120 | //} |
2121 | 2121 | } |
@@ -17,6 +17,10 @@ discard block |
||
17 | 17 | $this->db = $Connection->db(); |
18 | 18 | } |
19 | 19 | |
20 | + /** |
|
21 | + * @param string $type |
|
22 | + * @param string $stats_date |
|
23 | + */ |
|
20 | 24 | public function addLastStatsUpdate($type,$stats_date) { |
21 | 25 | $query = "DELETE FROM config WHERE name = :type; |
22 | 26 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
@@ -795,6 +799,11 @@ discard block |
||
795 | 799 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
796 | 800 | return $all; |
797 | 801 | } |
802 | + |
|
803 | + /** |
|
804 | + * @param string $type |
|
805 | + * @param string $year |
|
806 | + */ |
|
798 | 807 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
799 | 808 | if ($filter_name == '') $filter_name = $this->filter_name; |
800 | 809 | global $globalArchiveMonths, $globalDBdriver; |
@@ -900,6 +909,10 @@ discard block |
||
900 | 909 | return $all[0]['total']; |
901 | 910 | } |
902 | 911 | |
912 | + /** |
|
913 | + * @param string $type |
|
914 | + * @param string $stats_date |
|
915 | + */ |
|
903 | 916 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
904 | 917 | global $globalDBdriver; |
905 | 918 | if ($filter_name == '') $filter_name = $this->filter_name; |
@@ -933,6 +946,10 @@ discard block |
||
933 | 946 | return "error : ".$e->getMessage(); |
934 | 947 | } |
935 | 948 | } |
949 | + |
|
950 | + /** |
|
951 | + * @param string $date |
|
952 | + */ |
|
936 | 953 | public function getStatsSource($date,$stats_type = '') { |
937 | 954 | if ($stats_type == '') { |
938 | 955 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -951,6 +968,9 @@ discard block |
||
951 | 968 | return $all; |
952 | 969 | } |
953 | 970 | |
971 | + /** |
|
972 | + * @param string $stats_type |
|
973 | + */ |
|
954 | 974 | public function addStatSource($data,$source_name,$stats_type,$date) { |
955 | 975 | global $globalDBdriver; |
956 | 976 | if ($globalDBdriver == 'mysql') { |
@@ -966,6 +986,10 @@ discard block |
||
966 | 986 | return "error : ".$e->getMessage(); |
967 | 987 | } |
968 | 988 | } |
989 | + |
|
990 | + /** |
|
991 | + * @param string $type |
|
992 | + */ |
|
969 | 993 | public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
970 | 994 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
971 | 995 | $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
@@ -1160,6 +1184,10 @@ discard block |
||
1160 | 1184 | return "error : ".$e->getMessage(); |
1161 | 1185 | } |
1162 | 1186 | } |
1187 | + |
|
1188 | + /** |
|
1189 | + * @param string $type |
|
1190 | + */ |
|
1163 | 1191 | public function deleteStatFlight($type) { |
1164 | 1192 | $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
1165 | 1193 | $query_values = array(':type' => $type); |
@@ -1170,6 +1198,10 @@ discard block |
||
1170 | 1198 | return "error : ".$e->getMessage(); |
1171 | 1199 | } |
1172 | 1200 | } |
1201 | + |
|
1202 | + /** |
|
1203 | + * @param string $type |
|
1204 | + */ |
|
1173 | 1205 | public function deleteStatAirport($type) { |
1174 | 1206 | $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
1175 | 1207 | $query_values = array(':type' => $type); |
@@ -29,18 +29,18 @@ discard block |
||
29 | 29 | $currentdate = date('Y-m-d'); |
30 | 30 | $sourcestat = $Stats->getStatsSource($currentdate); |
31 | 31 | if (!empty($sourcestat)) { |
32 | - foreach($sourcestat as $srcst) { |
|
32 | + foreach ($sourcestat as $srcst) { |
|
33 | 33 | $type = $srcst['stats_type']; |
34 | 34 | if ($type == 'polar' || $type == 'hist') { |
35 | 35 | $source = $srcst['source_name']; |
36 | 36 | $data = $srcst['source_data']; |
37 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
37 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | - public function get_Schedule($id,$ident) { |
|
43 | + public function get_Schedule($id, $ident) { |
|
44 | 44 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
45 | 45 | // Get schedule here, so it's done only one time |
46 | 46 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | $schedule = $Schedule->fetchSchedule($operator); |
66 | 66 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
67 | 67 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
68 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
69 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
68 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
69 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
70 | 70 | // Should also check if route schedule = route from DB |
71 | 71 | if ($schedule['DepartureAirportIATA'] != '') { |
72 | 72 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
89 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
89 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
90 | 90 | } |
91 | 91 | } else $scheduleexist = true; |
92 | 92 | } else $scheduleexist = true; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | if ($scheduleexist) { |
95 | 95 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
96 | 96 | $sch = $Schedule->getSchedule($operator); |
97 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
97 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
98 | 98 | } |
99 | 99 | $Spotter->db = null; |
100 | 100 | $Schedule->db = null; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
121 | 121 | $Spotter = new Spotter($this->db); |
122 | 122 | $real_arrival = $this->arrival($key); |
123 | - $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
123 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $airport_time = ''; |
134 | 134 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
135 | 135 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
136 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
136 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
137 | 137 | if (isset($closestAirports[0])) { |
138 | 138 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
139 | 139 | $airport_icao = $closestAirports[0]['icao']; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | break; |
149 | 149 | } |
150 | 150 | } |
151 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
151 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
152 | 152 | $airport_icao = $closestAirports[0]['icao']; |
153 | 153 | $airport_time = $this->all_flights[$key]['datetime']; |
154 | 154 | } else { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } else { |
162 | 162 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
163 | 163 | } |
164 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
164 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
173 | 173 | foreach ($this->all_flights as $key => $flight) { |
174 | 174 | if (isset($flight['lastupdate'])) { |
175 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
175 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
176 | 176 | if (isset($this->all_flights[$key]['id'])) { |
177 | 177 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
178 | 178 | /* |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $real_arrival = $this->arrival($key); |
184 | 184 | $Spotter = new Spotter($this->db); |
185 | 185 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
186 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
186 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
187 | 187 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
188 | 188 | } |
189 | 189 | // Put in archive |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $send = false; |
220 | 220 | |
221 | 221 | // SBS format is CSV format |
222 | - if(is_array($line) && isset($line['hex'])) { |
|
222 | + if (is_array($line) && isset($line['hex'])) { |
|
223 | 223 | //print_r($line); |
224 | 224 | if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) { |
225 | 225 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | //print_r($this->all_flights); |
254 | 254 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
255 | 255 | $this->all_flights[$id] = array('hex' => $hex); |
256 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
256 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
257 | 257 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
258 | 258 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
259 | 259 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $Spotter = new Spotter($this->db); |
264 | 264 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
265 | 265 | $Spotter->db = null; |
266 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
266 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
267 | 267 | |
268 | 268 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
269 | 269 | if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
@@ -271,32 +271,32 @@ discard block |
||
271 | 271 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
272 | 272 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
273 | 273 | } |
274 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
274 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
275 | 275 | } else if (isset($line['aircraft_name'])) { |
276 | 276 | // Get aircraft ICAO from aircraft name |
277 | 277 | $Spotter = new Spotter($this->db); |
278 | 278 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
279 | 279 | $Spotter->db = null; |
280 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
281 | - else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
282 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
283 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
284 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
280 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
281 | + else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
282 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao'])); |
|
283 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true)); |
|
284 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
285 | 285 | if (!isset($line['id'])) { |
286 | 286 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
287 | 287 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
288 | 288 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
289 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
289 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
290 | 290 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
291 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
291 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
292 | 292 | |
293 | 293 | if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
294 | 294 | if ($globalAllFlights !== FALSE) $dataFound = true; |
295 | 295 | } |
296 | 296 | |
297 | - if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
297 | + if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/', $line['datetime'])) { |
|
298 | 298 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
299 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
299 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
300 | 300 | } else { |
301 | 301 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
302 | 302 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -307,23 +307,23 @@ discard block |
||
307 | 307 | */ |
308 | 308 | return ''; |
309 | 309 | } |
310 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
310 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
311 | 311 | |
312 | 312 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
313 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
313 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
314 | 314 | } |
315 | 315 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
316 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
316 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
317 | 317 | } |
318 | 318 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
319 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
319 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id'])); |
|
320 | 320 | } |
321 | 321 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
322 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
322 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name'])); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
326 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
326 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
327 | 327 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
328 | 328 | $timeelapsed = microtime(true); |
329 | 329 | $Spotter = new Spotter($this->db); |
@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
334 | 334 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
335 | 335 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
336 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
336 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
337 | 337 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
338 | 338 | $Spotter->db = null; |
339 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
339 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /* |
@@ -347,24 +347,24 @@ discard block |
||
347 | 347 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
348 | 348 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
349 | 349 | */ |
350 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
350 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
351 | 351 | |
352 | 352 | //$putinarchive = true; |
353 | 353 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
354 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
355 | 355 | } |
356 | 356 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
357 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
357 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
358 | 358 | } |
359 | 359 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
360 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
360 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
361 | 361 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
362 | 362 | $timeelapsed = microtime(true); |
363 | 363 | $Spotter = new Spotter($this->db); |
364 | 364 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
365 | 365 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
366 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
367 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
366 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
367 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
368 | 368 | |
369 | 369 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
370 | 370 | $timeelapsed = microtime(true); |
@@ -377,34 +377,34 @@ discard block |
||
377 | 377 | $Translation->db = null; |
378 | 378 | } |
379 | 379 | $Spotter->db = null; |
380 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
380 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
381 | 381 | |
382 | 382 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
383 | 383 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
384 | 384 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
385 | 385 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | if (!isset($globalFork)) $globalFork = TRUE; |
390 | 390 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
391 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
391 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
396 | 396 | if (isset($line['speed']) && $line['speed'] != '') { |
397 | 397 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
398 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
399 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
398 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
399 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
400 | 400 | //$dataFound = true; |
401 | 401 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
402 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
402 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
403 | 403 | if ($distance > 1000 && $distance < 10000) { |
404 | 404 | // use datetime |
405 | 405 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
406 | 406 | $speed = $speed*3.6; |
407 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
407 | + if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
408 | 408 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
409 | 409 | } |
410 | 410 | } |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | |
413 | 413 | |
414 | 414 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
415 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
415 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
416 | 416 | else unset($timediff); |
417 | - if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
417 | + if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) { |
|
418 | 418 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
419 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
419 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
420 | 420 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
421 | 421 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
422 | 422 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -424,10 +424,10 @@ discard block |
||
424 | 424 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
425 | 425 | $timeelapsed = microtime(true); |
426 | 426 | $Spotter = new Spotter($this->db); |
427 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
427 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
428 | 428 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
429 | 429 | $Spotter->db = null; |
430 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
430 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
431 | 431 | $this->tmd = 0; |
432 | 432 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
433 | 433 | } |
@@ -436,13 +436,13 @@ discard block |
||
436 | 436 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
437 | 437 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
438 | 438 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
439 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
439 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
440 | 440 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
441 | 441 | $dataFound = true; |
442 | 442 | $this->all_flights[$id]['time_last_coord'] = time(); |
443 | 443 | } |
444 | 444 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
445 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
445 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
446 | 446 | /* |
447 | 447 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
448 | 448 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -460,13 +460,13 @@ discard block |
||
460 | 460 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
461 | 461 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
462 | 462 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
463 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
463 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
464 | 464 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
465 | 465 | $dataFound = true; |
466 | 466 | $this->all_flights[$id]['time_last_coord'] = time(); |
467 | 467 | } |
468 | 468 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
469 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
469 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
470 | 470 | /* |
471 | 471 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
472 | 472 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -484,45 +484,45 @@ discard block |
||
484 | 484 | } else if ($globalDebug && $timediff > 20) { |
485 | 485 | $this->tmd = $this->tmd + 1; |
486 | 486 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
487 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
488 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
487 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
488 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
489 | 489 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
490 | 490 | } |
491 | 491 | } |
492 | 492 | if (isset($line['last_update']) && $line['last_update'] != '') { |
493 | 493 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
495 | 495 | } |
496 | 496 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
497 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
497 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
498 | 498 | //$dataFound = true; |
499 | 499 | } |
500 | 500 | if (isset($line['format_source']) && $line['format_source'] != '') { |
501 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
501 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
502 | 502 | } |
503 | 503 | if (isset($line['source_name']) && $line['source_name'] != '') { |
504 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
504 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
505 | 505 | } |
506 | 506 | if (isset($line['emergency']) && $line['emergency'] != '') { |
507 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
507 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
508 | 508 | //$dataFound = true; |
509 | 509 | } |
510 | 510 | if (isset($line['ground']) && $line['ground'] != '') { |
511 | 511 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
512 | 512 | // Here we force archive of flight because after ground it's a new one (or should be) |
513 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
514 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
515 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
516 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
517 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
513 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
514 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
515 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
516 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
517 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
518 | 518 | } |
519 | 519 | if ($line['ground'] != 1) $line['ground'] = 0; |
520 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
520 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
521 | 521 | //$dataFound = true; |
522 | 522 | } |
523 | 523 | if (isset($line['squawk']) && $line['squawk'] != '') { |
524 | 524 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
525 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
525 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
526 | 526 | $highlight = ''; |
527 | 527 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
528 | 528 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -530,48 +530,48 @@ discard block |
||
530 | 530 | if ($highlight != '') { |
531 | 531 | $timeelapsed = microtime(true); |
532 | 532 | $Spotter = new Spotter($this->db); |
533 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
533 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
534 | 534 | $Spotter->db = null; |
535 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
535 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
536 | 536 | |
537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
538 | 538 | //$putinarchive = true; |
539 | 539 | //$highlight = ''; |
540 | 540 | } |
541 | 541 | |
542 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
542 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
543 | 543 | //$dataFound = true; |
544 | 544 | } |
545 | 545 | |
546 | 546 | if (isset($line['altitude']) && $line['altitude'] != '') { |
547 | 547 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
548 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
549 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
550 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
548 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
549 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
550 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
551 | 551 | //$dataFound = true; |
552 | 552 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
553 | 553 | } |
554 | 554 | |
555 | 555 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
556 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
556 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | if (isset($line['heading']) && $line['heading'] != '') { |
560 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
561 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
562 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
560 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
561 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
562 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
563 | 563 | //$dataFound = true; |
564 | 564 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
565 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
566 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
567 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
565 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
566 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
567 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | 568 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
569 | 569 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
570 | 570 | // If not enough messages and ACARS set heading to 0 |
571 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
571 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
572 | 572 | } |
573 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
574 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
573 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
574 | + elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
575 | 575 | |
576 | 576 | // print_r($this->all_flights[$id]); |
577 | 577 | //gets the callsign from the last hour |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
582 | 582 | $this->all_flights[$id]['lastupdate'] = time(); |
583 | 583 | if ($this->all_flights[$id]['addedSpotter'] == 0) { |
584 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
584 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
585 | 585 | //print_r($this->all_flights); |
586 | 586 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
587 | 587 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -591,61 +591,61 @@ discard block |
||
591 | 591 | $SpotterLive = new SpotterLive($this->db); |
592 | 592 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
593 | 593 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
594 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
594 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
595 | 595 | } elseif (isset($line['id'])) { |
596 | 596 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
597 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
597 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
598 | 598 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
599 | 599 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
600 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
600 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
601 | 601 | } else $recent_ident = ''; |
602 | - $SpotterLive->db=null; |
|
602 | + $SpotterLive->db = null; |
|
603 | 603 | |
604 | 604 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
605 | 605 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
606 | 606 | } else { |
607 | 607 | $recent_ident = ''; |
608 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
608 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
609 | 609 | } |
610 | 610 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
611 | - if($recent_ident == "") |
|
611 | + if ($recent_ident == "") |
|
612 | 612 | { |
613 | 613 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
614 | 614 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
615 | 615 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
616 | 616 | //adds the spotter data for the archive |
617 | 617 | $ignoreImport = false; |
618 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
618 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
619 | 619 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
620 | 620 | $ignoreImport = true; |
621 | 621 | } |
622 | 622 | } |
623 | 623 | if (count($globalAirportAccept) > 0) { |
624 | 624 | $ignoreImport = true; |
625 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
625 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
626 | 626 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
627 | 627 | $ignoreImport = false; |
628 | 628 | } |
629 | 629 | } |
630 | 630 | } |
631 | 631 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
632 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
633 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
632 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
633 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
634 | 634 | $ignoreImport = true; |
635 | 635 | } |
636 | 636 | } |
637 | 637 | } |
638 | 638 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
639 | 639 | $ignoreImport = true; |
640 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
641 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
640 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
641 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
642 | 642 | $ignoreImport = false; |
643 | 643 | } |
644 | 644 | } |
645 | 645 | } |
646 | 646 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
647 | 647 | $ignoreImport = true; |
648 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
648 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
649 | 649 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
650 | 650 | $ignoreImport = false; |
651 | 651 | } |
@@ -657,27 +657,27 @@ discard block |
||
657 | 657 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
658 | 658 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
659 | 659 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
660 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
660 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
661 | 661 | $timeelapsed = microtime(true); |
662 | 662 | $Spotter = new Spotter($this->db); |
663 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
|
663 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name']); |
|
664 | 664 | $Spotter->db = null; |
665 | 665 | if ($globalDebug && isset($result)) echo $result."\n"; |
666 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
666 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
667 | 667 | |
668 | 668 | // Add source stat in DB |
669 | 669 | $Stats = new Stats($this->db); |
670 | 670 | if (!empty($this->stats)) { |
671 | 671 | if ($globalDebug) echo 'Add source stats : '; |
672 | - foreach($this->stats as $date => $data) { |
|
673 | - foreach($data as $source => $sourced) { |
|
672 | + foreach ($this->stats as $date => $data) { |
|
673 | + foreach ($data as $source => $sourced) { |
|
674 | 674 | //print_r($sourced); |
675 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
676 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
675 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
676 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
677 | 677 | if (isset($sourced['msg'])) { |
678 | 678 | if (time() - $sourced['msg']['date'] > 10) { |
679 | 679 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
680 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
680 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
681 | 681 | unset($this->stats[$date][$source]['msg']); |
682 | 682 | } |
683 | 683 | } |
@@ -713,18 +713,18 @@ discard block |
||
713 | 713 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
714 | 714 | $SpotterLive = new SpotterLive($this->db); |
715 | 715 | $SpotterLive->deleteLiveSpotterData(); |
716 | - $SpotterLive->db=null; |
|
716 | + $SpotterLive->db = null; |
|
717 | 717 | if ($globalDebug) echo " Done\n"; |
718 | 718 | $this->last_delete = time(); |
719 | 719 | } |
720 | 720 | } else { |
721 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
|
721 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
|
722 | 722 | $this->all_flights[$id]['id'] = $recent_ident; |
723 | 723 | $this->all_flights[$id]['addedSpotter'] = 1; |
724 | 724 | } |
725 | 725 | if (isset($globalDaemon) && !$globalDaemon) { |
726 | 726 | $Spotter = new Spotter($this->db); |
727 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
727 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
728 | 728 | $Spotter->db = null; |
729 | 729 | } |
730 | 730 | |
@@ -748,37 +748,37 @@ discard block |
||
748 | 748 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
749 | 749 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
750 | 750 | |
751 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
751 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
752 | 752 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
753 | 753 | $ignoreImport = true; |
754 | 754 | } |
755 | 755 | } |
756 | 756 | if (count($globalAirportAccept) > 0) { |
757 | 757 | $ignoreImport = true; |
758 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
758 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
759 | 759 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
760 | 760 | $ignoreImport = false; |
761 | 761 | } |
762 | 762 | } |
763 | 763 | } |
764 | 764 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
765 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
766 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
765 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
766 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
767 | 767 | $ignoreImport = true; |
768 | 768 | } |
769 | 769 | } |
770 | 770 | } |
771 | 771 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
772 | 772 | $ignoreImport = true; |
773 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
774 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
773 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
774 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
775 | 775 | $ignoreImport = false; |
776 | 776 | } |
777 | 777 | } |
778 | 778 | } |
779 | 779 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
780 | 780 | $ignoreImport = true; |
781 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
781 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
782 | 782 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
783 | 783 | $ignoreImport = false; |
784 | 784 | } |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | } |
787 | 787 | |
788 | 788 | if (!$ignoreImport) { |
789 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
789 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
790 | 790 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
791 | 791 | $timeelapsed = microtime(true); |
792 | 792 | $SpotterLive = new SpotterLive($this->db); |
793 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
793 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
794 | 794 | $SpotterLive->db = null; |
795 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
795 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
796 | 796 | |
797 | 797 | // Put statistics in $this->stats variable |
798 | 798 | //if ($line['format_source'] != 'aprs') { |
@@ -810,19 +810,19 @@ discard block |
||
810 | 810 | $latitude = $globalCenterLatitude; |
811 | 811 | $longitude = $globalCenterLongitude; |
812 | 812 | } |
813 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
813 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
814 | 814 | } else { |
815 | 815 | $latitude = $this->source_location[$source]['latitude']; |
816 | 816 | $longitude = $this->source_location[$source]['longitude']; |
817 | 817 | } |
818 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
818 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
819 | 819 | //$stats_heading = $stats_heading%22.5; |
820 | 820 | $stats_heading = round($stats_heading/22.5); |
821 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
821 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
822 | 822 | $current_date = date('Y-m-d'); |
823 | 823 | if ($stats_heading == 16) $stats_heading = 0; |
824 | 824 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
825 | - for ($i=0;$i<=15;$i++) { |
|
825 | + for ($i = 0; $i <= 15; $i++) { |
|
826 | 826 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
827 | 827 | } |
828 | 828 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -837,9 +837,9 @@ discard block |
||
837 | 837 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
838 | 838 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
839 | 839 | end($this->stats[$current_date][$source]['hist']); |
840 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
840 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
841 | 841 | } else $mini = 0; |
842 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
842 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
843 | 843 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
844 | 844 | } |
845 | 845 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
853 | 853 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
854 | 854 | if ($globalDebug) echo $result."\n"; |
855 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
855 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
856 | 856 | //$this->del(); |
857 | 857 | |
858 | 858 |
@@ -9,16 +9,16 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | |
11 | 11 | class SpotterImport { |
12 | - private $all_flights = array(); |
|
13 | - private $last_delete_hourly = 0; |
|
14 | - private $last_delete = 0; |
|
15 | - private $stats = array(); |
|
16 | - private $tmd = 0; |
|
17 | - private $source_location = array(); |
|
18 | - public $db = null; |
|
19 | - public $nb = 0; |
|
20 | - |
|
21 | - public function __construct($dbc = null) { |
|
12 | + private $all_flights = array(); |
|
13 | + private $last_delete_hourly = 0; |
|
14 | + private $last_delete = 0; |
|
15 | + private $stats = array(); |
|
16 | + private $tmd = 0; |
|
17 | + private $source_location = array(); |
|
18 | + public $db = null; |
|
19 | + public $nb = 0; |
|
20 | + |
|
21 | + public function __construct($dbc = null) { |
|
22 | 22 | global $globalBeta; |
23 | 23 | $Connection = new Connection($dbc); |
24 | 24 | $this->db = $Connection->db(); |
@@ -29,18 +29,18 @@ discard block |
||
29 | 29 | $currentdate = date('Y-m-d'); |
30 | 30 | $sourcestat = $Stats->getStatsSource($currentdate); |
31 | 31 | if (!empty($sourcestat)) { |
32 | - foreach($sourcestat as $srcst) { |
|
33 | - $type = $srcst['stats_type']; |
|
32 | + foreach($sourcestat as $srcst) { |
|
33 | + $type = $srcst['stats_type']; |
|
34 | 34 | if ($type == 'polar' || $type == 'hist') { |
35 | - $source = $srcst['source_name']; |
|
36 | - $data = $srcst['source_data']; |
|
37 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
38 | - } |
|
39 | - } |
|
35 | + $source = $srcst['source_name']; |
|
36 | + $data = $srcst['source_data']; |
|
37 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
38 | + } |
|
39 | + } |
|
40 | + } |
|
40 | 41 | } |
41 | - } |
|
42 | 42 | |
43 | - public function get_Schedule($id,$ident) { |
|
43 | + public function get_Schedule($id,$ident) { |
|
44 | 44 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
45 | 45 | // Get schedule here, so it's done only one time |
46 | 46 | |
@@ -60,42 +60,42 @@ discard block |
||
60 | 60 | $operator = $Spotter->getOperator($ident); |
61 | 61 | $scheduleexist = false; |
62 | 62 | if ($Schedule->checkSchedule($operator) == 0) { |
63 | - $operator = $Translation->checkTranslation($ident); |
|
64 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
63 | + $operator = $Translation->checkTranslation($ident); |
|
64 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
65 | 65 | $schedule = $Schedule->fetchSchedule($operator); |
66 | 66 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
67 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
68 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
69 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
70 | - // Should also check if route schedule = route from DB |
|
71 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
67 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
68 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
69 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
70 | + // Should also check if route schedule = route from DB |
|
71 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
72 | 72 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
73 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
74 | - if (trim($airport_icao) != '') { |
|
73 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
74 | + if (trim($airport_icao) != '') { |
|
75 | 75 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
76 | 76 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
77 | - } |
|
77 | + } |
|
78 | + } |
|
78 | 79 | } |
79 | - } |
|
80 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
80 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
81 | 81 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
82 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
83 | - if (trim($airport_icao) != '') { |
|
82 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
83 | + if (trim($airport_icao) != '') { |
|
84 | 84 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
85 | 85 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
86 | - } |
|
86 | + } |
|
87 | + } |
|
87 | 88 | } |
88 | - } |
|
89 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
89 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
90 | 90 | } |
91 | - } else $scheduleexist = true; |
|
91 | + } else $scheduleexist = true; |
|
92 | 92 | } else $scheduleexist = true; |
93 | 93 | // close connection, at least one way will work ? |
94 | - if ($scheduleexist) { |
|
94 | + if ($scheduleexist) { |
|
95 | 95 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
96 | - $sch = $Schedule->getSchedule($operator); |
|
96 | + $sch = $Schedule->getSchedule($operator); |
|
97 | 97 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
98 | - } |
|
98 | + } |
|
99 | 99 | $Spotter->db = null; |
100 | 100 | $Schedule->db = null; |
101 | 101 | $Translation->db = null; |
@@ -110,92 +110,92 @@ discard block |
||
110 | 110 | } |
111 | 111 | */ |
112 | 112 | } |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | - public function checkAll() { |
|
115 | + public function checkAll() { |
|
116 | 116 | global $globalDebug; |
117 | 117 | if ($globalDebug) echo "Update last seen flights data...\n"; |
118 | 118 | foreach ($this->all_flights as $key => $flight) { |
119 | - if (isset($this->all_flights[$key]['id'])) { |
|
119 | + if (isset($this->all_flights[$key]['id'])) { |
|
120 | 120 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
121 | - $Spotter = new Spotter($this->db); |
|
122 | - $real_arrival = $this->arrival($key); |
|
123 | - $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
124 | - } |
|
121 | + $Spotter = new Spotter($this->db); |
|
122 | + $real_arrival = $this->arrival($key); |
|
123 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
124 | + } |
|
125 | + } |
|
125 | 126 | } |
126 | - } |
|
127 | 127 | |
128 | - public function arrival($key) { |
|
128 | + public function arrival($key) { |
|
129 | 129 | global $globalClosestMinDist, $globalDebug; |
130 | 130 | if ($globalDebug) echo 'Update arrival...'."\n"; |
131 | 131 | $Spotter = new Spotter($this->db); |
132 | - $airport_icao = ''; |
|
133 | - $airport_time = ''; |
|
134 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
132 | + $airport_icao = ''; |
|
133 | + $airport_time = ''; |
|
134 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
135 | 135 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
136 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
137 | - if (isset($closestAirports[0])) { |
|
138 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
139 | - $airport_icao = $closestAirports[0]['icao']; |
|
140 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
141 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
142 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
143 | - foreach ($closestAirports as $airport) { |
|
144 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
145 | - $airport_icao = $airport['icao']; |
|
146 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
147 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
148 | - break; |
|
149 | - } |
|
150 | - } |
|
151 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
152 | - $airport_icao = $closestAirports[0]['icao']; |
|
153 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
154 | - } else { |
|
155 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
156 | - } |
|
157 | - } else { |
|
158 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
159 | - } |
|
160 | - |
|
161 | - } else { |
|
162 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
163 | - } |
|
164 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - public function del() { |
|
136 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
137 | + if (isset($closestAirports[0])) { |
|
138 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
139 | + $airport_icao = $closestAirports[0]['icao']; |
|
140 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
141 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
142 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
143 | + foreach ($closestAirports as $airport) { |
|
144 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
145 | + $airport_icao = $airport['icao']; |
|
146 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
147 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
148 | + break; |
|
149 | + } |
|
150 | + } |
|
151 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
152 | + $airport_icao = $closestAirports[0]['icao']; |
|
153 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
154 | + } else { |
|
155 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
156 | + } |
|
157 | + } else { |
|
158 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
159 | + } |
|
160 | + |
|
161 | + } else { |
|
162 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
163 | + } |
|
164 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + public function del() { |
|
170 | 170 | global $globalDebug; |
171 | 171 | // Delete old infos |
172 | 172 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
173 | 173 | foreach ($this->all_flights as $key => $flight) { |
174 | - if (isset($flight['lastupdate'])) { |
|
175 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
176 | - if (isset($this->all_flights[$key]['id'])) { |
|
177 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
174 | + if (isset($flight['lastupdate'])) { |
|
175 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
176 | + if (isset($this->all_flights[$key]['id'])) { |
|
177 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
178 | 178 | /* |
179 | 179 | $SpotterLive = new SpotterLive(); |
180 | 180 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
181 | 181 | $SpotterLive->db = null; |
182 | 182 | */ |
183 | - $real_arrival = $this->arrival($key); |
|
184 | - $Spotter = new Spotter($this->db); |
|
185 | - if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
183 | + $real_arrival = $this->arrival($key); |
|
184 | + $Spotter = new Spotter($this->db); |
|
185 | + if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
186 | 186 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
187 | 187 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
188 | 188 | } |
189 | 189 | // Put in archive |
190 | 190 | // $Spotter->db = null; |
191 | - } |
|
192 | - unset($this->all_flights[$key]); |
|
193 | - } |
|
194 | - } |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - public function add($line) { |
|
191 | + } |
|
192 | + unset($this->all_flights[$key]); |
|
193 | + } |
|
194 | + } |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + public function add($line) { |
|
199 | 199 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
200 | 200 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
201 | 201 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -220,18 +220,18 @@ discard block |
||
220 | 220 | |
221 | 221 | // SBS format is CSV format |
222 | 222 | if(is_array($line) && isset($line['hex'])) { |
223 | - //print_r($line); |
|
224 | - if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) { |
|
223 | + //print_r($line); |
|
224 | + if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) { |
|
225 | 225 | |
226 | 226 | // Increment message number |
227 | 227 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
228 | - $current_date = date('Y-m-d'); |
|
229 | - $source = $line['source_name']; |
|
230 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
231 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
232 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
233 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
234 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
228 | + $current_date = date('Y-m-d'); |
|
229 | + $source = $line['source_name']; |
|
230 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
231 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
232 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
233 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
234 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /* |
@@ -247,17 +247,17 @@ discard block |
||
247 | 247 | //$this->db = $dbc; |
248 | 248 | |
249 | 249 | $hex = trim($line['hex']); |
250 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
251 | - else $id = trim($line['id']); |
|
250 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
251 | + else $id = trim($line['id']); |
|
252 | 252 | |
253 | 253 | //print_r($this->all_flights); |
254 | 254 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
255 | - $this->all_flights[$id] = array('hex' => $hex); |
|
256 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
257 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
255 | + $this->all_flights[$id] = array('hex' => $hex); |
|
256 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
257 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
258 | 258 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
259 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
260 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) { |
|
259 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
260 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) { |
|
261 | 261 | |
262 | 262 | $timeelapsed = microtime(true); |
263 | 263 | $Spotter = new Spotter($this->db); |
@@ -266,38 +266,38 @@ discard block |
||
266 | 266 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
267 | 267 | |
268 | 268 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
269 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
270 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
271 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
272 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
269 | + if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
270 | + elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
271 | + elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
272 | + elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
273 | 273 | } |
274 | 274 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
275 | - } else if (isset($line['aircraft_name'])) { |
|
275 | + } else if (isset($line['aircraft_name'])) { |
|
276 | 276 | // Get aircraft ICAO from aircraft name |
277 | 277 | $Spotter = new Spotter($this->db); |
278 | 278 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
279 | 279 | $Spotter->db = null; |
280 | 280 | if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
281 | 281 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
282 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
283 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
284 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
285 | - if (!isset($line['id'])) { |
|
282 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
283 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
284 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
285 | + if (!isset($line['id'])) { |
|
286 | 286 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
287 | 287 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
288 | 288 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
289 | 289 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
290 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
291 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
291 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
292 | 292 | |
293 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
294 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
293 | + if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
294 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
298 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
298 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
299 | 299 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
300 | - } else { |
|
300 | + } else { |
|
301 | 301 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
302 | 302 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
303 | 303 | /* |
@@ -306,38 +306,38 @@ discard block |
||
306 | 306 | print_r($line); |
307 | 307 | */ |
308 | 308 | return ''; |
309 | - } |
|
309 | + } |
|
310 | 310 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
311 | 311 | |
312 | 312 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
313 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
313 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
314 | 314 | } |
315 | 315 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
316 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
316 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
317 | 317 | } |
318 | 318 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
319 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
319 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
320 | 320 | } |
321 | 321 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
322 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
322 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
326 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
327 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
326 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
327 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
328 | 328 | $timeelapsed = microtime(true); |
329 | - $Spotter = new Spotter($this->db); |
|
330 | - $fromsource = NULL; |
|
331 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
332 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
329 | + $Spotter = new Spotter($this->db); |
|
330 | + $fromsource = NULL; |
|
331 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
332 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
333 | 333 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
334 | 334 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
335 | 335 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
336 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
336 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
337 | 337 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
338 | 338 | $Spotter->db = null; |
339 | 339 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
340 | - } |
|
340 | + } |
|
341 | 341 | |
342 | 342 | /* |
343 | 343 | if (!isset($line['id'])) { |
@@ -347,26 +347,26 @@ discard block |
||
347 | 347 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
348 | 348 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
349 | 349 | */ |
350 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
350 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
351 | 351 | |
352 | - //$putinarchive = true; |
|
353 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
352 | + //$putinarchive = true; |
|
353 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
354 | 354 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
355 | - } |
|
356 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
355 | + } |
|
356 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
357 | 357 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
358 | - } |
|
359 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
360 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
361 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
358 | + } |
|
359 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
360 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
361 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
362 | 362 | $timeelapsed = microtime(true); |
363 | 363 | $Spotter = new Spotter($this->db); |
364 | 364 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
365 | 365 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
366 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
366 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
367 | 367 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
368 | 368 | |
369 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
369 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
370 | 370 | $timeelapsed = microtime(true); |
371 | 371 | $Spotter = new Spotter($this->db); |
372 | 372 | $route = $Spotter->getRouteInfo(trim($line['ident'])); |
@@ -380,43 +380,43 @@ discard block |
||
380 | 380 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
381 | 381 | |
382 | 382 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
383 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
384 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
383 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
384 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
385 | 385 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
387 | - } |
|
386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
387 | + } |
|
388 | 388 | } |
389 | 389 | if (!isset($globalFork)) $globalFork = TRUE; |
390 | 390 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
391 | 391 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
392 | 392 | } |
393 | - } |
|
393 | + } |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | if (isset($line['speed']) && $line['speed'] != '') { |
397 | 397 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
398 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
399 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
400 | - //$dataFound = true; |
|
398 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
399 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
400 | + //$dataFound = true; |
|
401 | 401 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
402 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
403 | - if ($distance > 1000 && $distance < 10000) { |
|
404 | - // use datetime |
|
402 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
403 | + if ($distance > 1000 && $distance < 10000) { |
|
404 | + // use datetime |
|
405 | 405 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
406 | 406 | $speed = $speed*3.6; |
407 | 407 | if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
408 | 408 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
409 | - } |
|
409 | + } |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | |
413 | 413 | |
414 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
415 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
416 | - else unset($timediff); |
|
417 | - if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
414 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
415 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
416 | + else unset($timediff); |
|
417 | + if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
418 | 418 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
419 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
419 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
420 | 420 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
421 | 421 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
422 | 422 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -430,16 +430,16 @@ discard block |
||
430 | 430 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
431 | 431 | $this->tmd = 0; |
432 | 432 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
433 | - } |
|
433 | + } |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
437 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
437 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
438 | 438 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
439 | 439 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
440 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
441 | - $dataFound = true; |
|
442 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
440 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
441 | + $dataFound = true; |
|
442 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
443 | 443 | } |
444 | 444 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
445 | 445 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -450,20 +450,20 @@ discard block |
||
450 | 450 | //$putinarchive = true; |
451 | 451 | } |
452 | 452 | */ |
453 | - /* |
|
453 | + /* |
|
454 | 454 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
455 | 455 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
456 | 456 | } |
457 | 457 | */ |
458 | 458 | } |
459 | 459 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
460 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
461 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
460 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
461 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
462 | 462 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
463 | 463 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
464 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
465 | - $dataFound = true; |
|
466 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
464 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
465 | + $dataFound = true; |
|
466 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
467 | 467 | } |
468 | 468 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
469 | 469 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -481,53 +481,53 @@ discard block |
||
481 | 481 | */ |
482 | 482 | } |
483 | 483 | |
484 | - } else if ($globalDebug && $timediff > 20) { |
|
484 | + } else if ($globalDebug && $timediff > 20) { |
|
485 | 485 | $this->tmd = $this->tmd + 1; |
486 | 486 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
487 | 487 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
488 | 488 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
489 | 489 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
490 | - } |
|
490 | + } |
|
491 | 491 | } |
492 | 492 | if (isset($line['last_update']) && $line['last_update'] != '') { |
493 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
493 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
495 | 495 | } |
496 | 496 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
497 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
498 | - //$dataFound = true; |
|
497 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
498 | + //$dataFound = true; |
|
499 | 499 | } |
500 | 500 | if (isset($line['format_source']) && $line['format_source'] != '') { |
501 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
501 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
502 | 502 | } |
503 | 503 | if (isset($line['source_name']) && $line['source_name'] != '') { |
504 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
504 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
505 | 505 | } |
506 | 506 | if (isset($line['emergency']) && $line['emergency'] != '') { |
507 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
508 | - //$dataFound = true; |
|
507 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
508 | + //$dataFound = true; |
|
509 | 509 | } |
510 | 510 | if (isset($line['ground']) && $line['ground'] != '') { |
511 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
511 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
512 | 512 | // Here we force archive of flight because after ground it's a new one (or should be) |
513 | 513 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
514 | 514 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
515 | 515 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
516 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
516 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
517 | 517 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
518 | - } |
|
519 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
520 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
521 | - //$dataFound = true; |
|
518 | + } |
|
519 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
520 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
521 | + //$dataFound = true; |
|
522 | 522 | } |
523 | 523 | if (isset($line['squawk']) && $line['squawk'] != '') { |
524 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
525 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
526 | - $highlight = ''; |
|
527 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
528 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
529 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
530 | - if ($highlight != '') { |
|
524 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
525 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
526 | + $highlight = ''; |
|
527 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
528 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
529 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
530 | + if ($highlight != '') { |
|
531 | 531 | $timeelapsed = microtime(true); |
532 | 532 | $Spotter = new Spotter($this->db); |
533 | 533 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
@@ -537,38 +537,38 @@ discard block |
||
537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
538 | 538 | //$putinarchive = true; |
539 | 539 | //$highlight = ''; |
540 | - } |
|
540 | + } |
|
541 | 541 | |
542 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
543 | - //$dataFound = true; |
|
542 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
543 | + //$dataFound = true; |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | if (isset($line['altitude']) && $line['altitude'] != '') { |
547 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
547 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
548 | 548 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
549 | 549 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
550 | 550 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
551 | 551 | //$dataFound = true; |
552 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
552 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
556 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
556 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | if (isset($line['heading']) && $line['heading'] != '') { |
560 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
561 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
562 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
563 | - //$dataFound = true; |
|
560 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
561 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
562 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
563 | + //$dataFound = true; |
|
564 | 564 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
565 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
566 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
567 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
565 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
566 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
567 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
569 | 569 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
570 | - // If not enough messages and ACARS set heading to 0 |
|
571 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
570 | + // If not enough messages and ACARS set heading to 0 |
|
571 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
572 | 572 | } |
573 | 573 | if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
574 | 574 | elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -579,119 +579,119 @@ discard block |
||
579 | 579 | //if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
580 | 580 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
581 | 581 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
582 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
583 | - if ($this->all_flights[$id]['addedSpotter'] == 0) { |
|
584 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
585 | - //print_r($this->all_flights); |
|
586 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
587 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
588 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
582 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
583 | + if ($this->all_flights[$id]['addedSpotter'] == 0) { |
|
584 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
585 | + //print_r($this->all_flights); |
|
586 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
587 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
588 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
589 | 589 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
590 | 590 | $timeelapsed = microtime(true); |
591 | 591 | $SpotterLive = new SpotterLive($this->db); |
592 | 592 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
593 | - $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
594 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
593 | + $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
594 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
595 | 595 | } elseif (isset($line['id'])) { |
596 | - $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
597 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
596 | + $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
597 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
598 | 598 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
599 | - $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
600 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
599 | + $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
600 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
601 | 601 | } else $recent_ident = ''; |
602 | 602 | $SpotterLive->db=null; |
603 | 603 | |
604 | 604 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
605 | 605 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
606 | - } else { |
|
606 | + } else { |
|
607 | 607 | $recent_ident = ''; |
608 | 608 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
609 | - } |
|
610 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
611 | - if($recent_ident == "") |
|
612 | - { |
|
609 | + } |
|
610 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
611 | + if($recent_ident == "") |
|
612 | + { |
|
613 | 613 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
614 | 614 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
615 | 615 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
616 | 616 | //adds the spotter data for the archive |
617 | 617 | $ignoreImport = false; |
618 | 618 | foreach($globalAirportIgnore as $airportIgnore) { |
619 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
619 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
620 | 620 | $ignoreImport = true; |
621 | - } |
|
621 | + } |
|
622 | 622 | } |
623 | 623 | if (count($globalAirportAccept) > 0) { |
624 | - $ignoreImport = true; |
|
625 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
624 | + $ignoreImport = true; |
|
625 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
626 | 626 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
627 | - $ignoreImport = false; |
|
627 | + $ignoreImport = false; |
|
628 | + } |
|
628 | 629 | } |
629 | - } |
|
630 | 630 | } |
631 | 631 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
632 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
632 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
633 | 633 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
634 | - $ignoreImport = true; |
|
634 | + $ignoreImport = true; |
|
635 | + } |
|
635 | 636 | } |
636 | - } |
|
637 | 637 | } |
638 | 638 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
639 | - $ignoreImport = true; |
|
640 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
639 | + $ignoreImport = true; |
|
640 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
641 | 641 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
642 | - $ignoreImport = false; |
|
642 | + $ignoreImport = false; |
|
643 | + } |
|
643 | 644 | } |
644 | - } |
|
645 | 645 | } |
646 | 646 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
647 | - $ignoreImport = true; |
|
648 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
647 | + $ignoreImport = true; |
|
648 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
649 | 649 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
650 | - $ignoreImport = false; |
|
650 | + $ignoreImport = false; |
|
651 | + } |
|
651 | 652 | } |
652 | - } |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | if (!$ignoreImport) { |
656 | - $highlight = ''; |
|
657 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
658 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
659 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
660 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
661 | - $timeelapsed = microtime(true); |
|
662 | - $Spotter = new Spotter($this->db); |
|
663 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
|
664 | - $Spotter->db = null; |
|
665 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
666 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
656 | + $highlight = ''; |
|
657 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
658 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
659 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
660 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
661 | + $timeelapsed = microtime(true); |
|
662 | + $Spotter = new Spotter($this->db); |
|
663 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
|
664 | + $Spotter->db = null; |
|
665 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
666 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
667 | 667 | |
668 | - // Add source stat in DB |
|
669 | - $Stats = new Stats($this->db); |
|
670 | - if (!empty($this->stats)) { |
|
668 | + // Add source stat in DB |
|
669 | + $Stats = new Stats($this->db); |
|
670 | + if (!empty($this->stats)) { |
|
671 | 671 | if ($globalDebug) echo 'Add source stats : '; |
672 | - foreach($this->stats as $date => $data) { |
|
673 | - foreach($data as $source => $sourced) { |
|
674 | - //print_r($sourced); |
|
675 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
676 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
677 | - if (isset($sourced['msg'])) { |
|
678 | - if (time() - $sourced['msg']['date'] > 10) { |
|
679 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
680 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
681 | - unset($this->stats[$date][$source]['msg']); |
|
682 | - } |
|
683 | - } |
|
684 | - } |
|
685 | - if ($date != date('Y-m-d')) { |
|
686 | - unset($this->stats[$date]); |
|
687 | - } |
|
688 | - } |
|
689 | - if ($globalDebug) echo 'Done'."\n"; |
|
690 | - |
|
691 | - } |
|
692 | - $Stats->db = null; |
|
672 | + foreach($this->stats as $date => $data) { |
|
673 | + foreach($data as $source => $sourced) { |
|
674 | + //print_r($sourced); |
|
675 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
676 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
677 | + if (isset($sourced['msg'])) { |
|
678 | + if (time() - $sourced['msg']['date'] > 10) { |
|
679 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
680 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
681 | + unset($this->stats[$date][$source]['msg']); |
|
682 | + } |
|
683 | + } |
|
684 | + } |
|
685 | + if ($date != date('Y-m-d')) { |
|
686 | + unset($this->stats[$date]); |
|
687 | + } |
|
688 | + } |
|
689 | + if ($globalDebug) echo 'Done'."\n"; |
|
690 | + |
|
691 | + } |
|
692 | + $Stats->db = null; |
|
693 | 693 | |
694 | - $this->del(); |
|
694 | + $this->del(); |
|
695 | 695 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
696 | 696 | //$ignoreImport = false; |
697 | 697 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -709,18 +709,18 @@ discard block |
||
709 | 709 | */ |
710 | 710 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
711 | 711 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
712 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
713 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
714 | - $SpotterLive = new SpotterLive($this->db); |
|
715 | - $SpotterLive->deleteLiveSpotterData(); |
|
716 | - $SpotterLive->db=null; |
|
717 | - if ($globalDebug) echo " Done\n"; |
|
718 | - $this->last_delete = time(); |
|
712 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
713 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
714 | + $SpotterLive = new SpotterLive($this->db); |
|
715 | + $SpotterLive->deleteLiveSpotterData(); |
|
716 | + $SpotterLive->db=null; |
|
717 | + if ($globalDebug) echo " Done\n"; |
|
718 | + $this->last_delete = time(); |
|
719 | 719 | } |
720 | - } else { |
|
720 | + } else { |
|
721 | 721 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
722 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
723 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
722 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
723 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
724 | 724 | } |
725 | 725 | if (isset($globalDaemon) && !$globalDaemon) { |
726 | 726 | $Spotter = new Spotter($this->db); |
@@ -728,14 +728,14 @@ discard block |
||
728 | 728 | $Spotter->db = null; |
729 | 729 | } |
730 | 730 | |
731 | - } |
|
731 | + } |
|
732 | + } |
|
732 | 733 | } |
733 | - } |
|
734 | - //adds the spotter LIVE data |
|
735 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
736 | - //echo "\nAdd in Live !! \n"; |
|
737 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
738 | - if ($globalDebug) { |
|
734 | + //adds the spotter LIVE data |
|
735 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
736 | + //echo "\nAdd in Live !! \n"; |
|
737 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
738 | + if ($globalDebug) { |
|
739 | 739 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
740 | 740 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
741 | 741 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -743,49 +743,49 @@ discard block |
||
743 | 743 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
744 | 744 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
745 | 745 | } |
746 | - } |
|
747 | - $ignoreImport = false; |
|
748 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
749 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
746 | + } |
|
747 | + $ignoreImport = false; |
|
748 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
749 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
750 | 750 | |
751 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
752 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
753 | - $ignoreImport = true; |
|
751 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
752 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
753 | + $ignoreImport = true; |
|
754 | + } |
|
754 | 755 | } |
755 | - } |
|
756 | - if (count($globalAirportAccept) > 0) { |
|
757 | - $ignoreImport = true; |
|
758 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
759 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
756 | + if (count($globalAirportAccept) > 0) { |
|
757 | + $ignoreImport = true; |
|
758 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
759 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
760 | 760 | $ignoreImport = false; |
761 | - } |
|
761 | + } |
|
762 | 762 | } |
763 | - } |
|
764 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
763 | + } |
|
764 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
765 | 765 | foreach($globalAirlineIgnore as $airlineIgnore) { |
766 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
766 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
767 | 767 | $ignoreImport = true; |
768 | - } |
|
768 | + } |
|
769 | 769 | } |
770 | - } |
|
771 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
770 | + } |
|
771 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
772 | 772 | $ignoreImport = true; |
773 | 773 | foreach($globalAirlineAccept as $airlineAccept) { |
774 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
774 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
775 | 775 | $ignoreImport = false; |
776 | - } |
|
776 | + } |
|
777 | 777 | } |
778 | - } |
|
779 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
778 | + } |
|
779 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
780 | 780 | $ignoreImport = true; |
781 | 781 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
782 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
783 | - $ignoreImport = false; |
|
784 | - } |
|
782 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
783 | + $ignoreImport = false; |
|
784 | + } |
|
785 | + } |
|
785 | 786 | } |
786 | - } |
|
787 | 787 | |
788 | - if (!$ignoreImport) { |
|
788 | + if (!$ignoreImport) { |
|
789 | 789 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
790 | 790 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
791 | 791 | $timeelapsed = microtime(true); |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | if ($stats_heading == 16) $stats_heading = 0; |
824 | 824 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
825 | 825 | for ($i=0;$i<=15;$i++) { |
826 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
826 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
827 | 827 | } |
828 | 828 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
829 | 829 | } else { |
@@ -836,11 +836,11 @@ discard block |
||
836 | 836 | //var_dump($this->stats); |
837 | 837 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
838 | 838 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
839 | - end($this->stats[$current_date][$source]['hist']); |
|
840 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
839 | + end($this->stats[$current_date][$source]['hist']); |
|
840 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
841 | 841 | } else $mini = 0; |
842 | 842 | for ($i=$mini;$i<=$distance;$i+=10) { |
843 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
843 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
844 | 844 | } |
845 | 845 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
846 | 846 | } else { |
@@ -857,22 +857,22 @@ discard block |
||
857 | 857 | |
858 | 858 | |
859 | 859 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
860 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
861 | - $SpotterLive = new SpotterLive($this->db); |
|
862 | - $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
863 | - $SpotterLive->db = null; |
|
864 | - //SpotterLive->deleteLiveSpotterData(); |
|
865 | - if ($globalDebug) echo " Done\n"; |
|
866 | - $this->last_delete_hourly = time(); |
|
860 | + if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
861 | + $SpotterLive = new SpotterLive($this->db); |
|
862 | + $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
863 | + $SpotterLive->db = null; |
|
864 | + //SpotterLive->deleteLiveSpotterData(); |
|
865 | + if ($globalDebug) echo " Done\n"; |
|
866 | + $this->last_delete_hourly = time(); |
|
867 | 867 | } |
868 | 868 | |
869 | - } |
|
870 | - //$ignoreImport = false; |
|
869 | + } |
|
870 | + //$ignoreImport = false; |
|
871 | 871 | } |
872 | 872 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
873 | 873 | if ($send) return $this->all_flights[$id]; |
874 | - } |
|
874 | + } |
|
875 | + } |
|
875 | 876 | } |
876 | - } |
|
877 | 877 | } |
878 | 878 | ?> |
@@ -40,6 +40,10 @@ |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | + /** |
|
44 | + * @param string $id |
|
45 | + * @param string $ident |
|
46 | + */ |
|
43 | 47 | public function get_Schedule($id,$ident) { |
44 | 48 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
45 | 49 | // Get schedule here, so it's done only one time |
@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | $dbc = $this->db; |
54 | 54 | $this->all_flights[$id]['schedule_check'] = true; |
55 | 55 | if ($globalSchedulesFetch) { |
56 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo 'Getting schedule info...'."\n"; |
|
58 | + } |
|
57 | 59 | $Spotter = new Spotter($dbc); |
58 | 60 | $Schedule = new Schedule($dbc); |
59 | 61 | $Translation = new Translation($dbc); |
@@ -64,7 +66,9 @@ discard block |
||
64 | 66 | if ($Schedule->checkSchedule($operator) == 0) { |
65 | 67 | $schedule = $Schedule->fetchSchedule($operator); |
66 | 68 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
67 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
69 | + if ($globalDebug) { |
|
70 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
71 | + } |
|
68 | 72 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
69 | 73 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
70 | 74 | // Should also check if route schedule = route from DB |
@@ -73,7 +77,9 @@ discard block |
||
73 | 77 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
74 | 78 | if (trim($airport_icao) != '') { |
75 | 79 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
76 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
80 | + if ($globalDebug) { |
|
81 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
82 | + } |
|
77 | 83 | } |
78 | 84 | } |
79 | 85 | } |
@@ -82,17 +88,25 @@ discard block |
||
82 | 88 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
83 | 89 | if (trim($airport_icao) != '') { |
84 | 90 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
85 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
91 | + if ($globalDebug) { |
|
92 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
93 | + } |
|
86 | 94 | } |
87 | 95 | } |
88 | 96 | } |
89 | 97 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
90 | 98 | } |
91 | - } else $scheduleexist = true; |
|
92 | - } else $scheduleexist = true; |
|
99 | + } else { |
|
100 | + $scheduleexist = true; |
|
101 | + } |
|
102 | + } else { |
|
103 | + $scheduleexist = true; |
|
104 | + } |
|
93 | 105 | // close connection, at least one way will work ? |
94 | 106 | if ($scheduleexist) { |
95 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
107 | + if ($globalDebug) { |
|
108 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
109 | + } |
|
96 | 110 | $sch = $Schedule->getSchedule($operator); |
97 | 111 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
98 | 112 | } |
@@ -114,7 +128,9 @@ discard block |
||
114 | 128 | |
115 | 129 | public function checkAll() { |
116 | 130 | global $globalDebug; |
117 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
131 | + if ($globalDebug) { |
|
132 | + echo "Update last seen flights data...\n"; |
|
133 | + } |
|
118 | 134 | foreach ($this->all_flights as $key => $flight) { |
119 | 135 | if (isset($this->all_flights[$key]['id'])) { |
120 | 136 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
@@ -127,24 +143,32 @@ discard block |
||
127 | 143 | |
128 | 144 | public function arrival($key) { |
129 | 145 | global $globalClosestMinDist, $globalDebug; |
130 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
146 | + if ($globalDebug) { |
|
147 | + echo 'Update arrival...'."\n"; |
|
148 | + } |
|
131 | 149 | $Spotter = new Spotter($this->db); |
132 | 150 | $airport_icao = ''; |
133 | 151 | $airport_time = ''; |
134 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
152 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
153 | + $globalClosestMinDist = 50; |
|
154 | + } |
|
135 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
136 | 156 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
137 | 157 | if (isset($closestAirports[0])) { |
138 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
139 | 159 | $airport_icao = $closestAirports[0]['icao']; |
140 | 160 | $airport_time = $this->all_flights[$key]['datetime']; |
141 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
161 | + if ($globalDebug) { |
|
162 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
163 | + } |
|
142 | 164 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
143 | 165 | foreach ($closestAirports as $airport) { |
144 | 166 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
145 | 167 | $airport_icao = $airport['icao']; |
146 | 168 | $airport_time = $this->all_flights[$key]['datetime']; |
147 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
169 | + if ($globalDebug) { |
|
170 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
171 | + } |
|
148 | 172 | break; |
149 | 173 | } |
150 | 174 | } |
@@ -152,14 +176,20 @@ discard block |
||
152 | 176 | $airport_icao = $closestAirports[0]['icao']; |
153 | 177 | $airport_time = $this->all_flights[$key]['datetime']; |
154 | 178 | } else { |
155 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
181 | + } |
|
156 | 182 | } |
157 | 183 | } else { |
158 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
184 | + if ($globalDebug) { |
|
185 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
186 | + } |
|
159 | 187 | } |
160 | 188 | |
161 | 189 | } else { |
162 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
190 | + if ($globalDebug) { |
|
191 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
192 | + } |
|
163 | 193 | } |
164 | 194 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
165 | 195 | } |
@@ -169,12 +199,16 @@ discard block |
||
169 | 199 | public function del() { |
170 | 200 | global $globalDebug; |
171 | 201 | // Delete old infos |
172 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'Delete old values and update latest data...'."\n"; |
|
204 | + } |
|
173 | 205 | foreach ($this->all_flights as $key => $flight) { |
174 | 206 | if (isset($flight['lastupdate'])) { |
175 | 207 | if ($flight['lastupdate'] < (time()-3000)) { |
176 | 208 | if (isset($this->all_flights[$key]['id'])) { |
177 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
209 | + if ($globalDebug) { |
|
210 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
211 | + } |
|
178 | 212 | /* |
179 | 213 | $SpotterLive = new SpotterLive(); |
180 | 214 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -184,7 +218,9 @@ discard block |
||
184 | 218 | $Spotter = new Spotter($this->db); |
185 | 219 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
186 | 220 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
187 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
221 | + if ($globalDebug && $result != 'success') { |
|
222 | + echo '!!! ERROR : '.$result."\n"; |
|
223 | + } |
|
188 | 224 | } |
189 | 225 | // Put in archive |
190 | 226 | // $Spotter->db = null; |
@@ -198,8 +234,10 @@ discard block |
||
198 | 234 | public function add($line) { |
199 | 235 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
200 | 236 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
201 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
202 | -/* |
|
237 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
238 | + $globalCoordMinChange = '0.02'; |
|
239 | + } |
|
240 | + /* |
|
203 | 241 | $Spotter = new Spotter(); |
204 | 242 | $dbc = $Spotter->db; |
205 | 243 | $SpotterLive = new SpotterLive($dbc); |
@@ -227,11 +265,15 @@ discard block |
||
227 | 265 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
228 | 266 | $current_date = date('Y-m-d'); |
229 | 267 | $source = $line['source_name']; |
230 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
268 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
269 | + $source = $line['format_source']; |
|
270 | + } |
|
231 | 271 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
232 | 272 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
233 | 273 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
234 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
274 | + } else { |
|
275 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
276 | + } |
|
235 | 277 | } |
236 | 278 | |
237 | 279 | /* |
@@ -247,8 +289,11 @@ discard block |
||
247 | 289 | //$this->db = $dbc; |
248 | 290 | |
249 | 291 | $hex = trim($line['hex']); |
250 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
251 | - else $id = trim($line['id']); |
|
292 | + if (!isset($line['id'])) { |
|
293 | + $id = trim($line['hex']); |
|
294 | + } else { |
|
295 | + $id = trim($line['id']); |
|
296 | + } |
|
252 | 297 | |
253 | 298 | //print_r($this->all_flights); |
254 | 299 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
@@ -263,13 +308,20 @@ discard block |
||
263 | 308 | $Spotter = new Spotter($this->db); |
264 | 309 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
265 | 310 | $Spotter->db = null; |
266 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
311 | + if ($globalDebugTimeElapsed) { |
|
312 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | + } |
|
267 | 314 | |
268 | 315 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
269 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
270 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
271 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
272 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
316 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
317 | + $aircraft_icao = 'GLID'; |
|
318 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
319 | + $aircraft_icao = 'UHEL'; |
|
320 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
321 | + $aircraft_icao = 'TOWPLANE'; |
|
322 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
323 | + $aircraft_icao = 'POWAIRC'; |
|
324 | + } |
|
273 | 325 | } |
274 | 326 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
275 | 327 | } else if (isset($line['aircraft_name'])) { |
@@ -277,29 +329,47 @@ discard block |
||
277 | 329 | $Spotter = new Spotter($this->db); |
278 | 330 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
279 | 331 | $Spotter->db = null; |
280 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
281 | - else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
282 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
332 | + if ($aircraft_icao != '') { |
|
333 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
334 | + } else { |
|
335 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
336 | + } |
|
337 | + } else { |
|
338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
339 | + } |
|
283 | 340 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
284 | 341 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
285 | 342 | if (!isset($line['id'])) { |
286 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
287 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
343 | + if (!isset($globalDaemon)) { |
|
344 | + $globalDaemon = TRUE; |
|
345 | + } |
|
346 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
288 | 347 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
289 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
348 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
349 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
350 | + } |
|
290 | 351 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
291 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
352 | + } else { |
|
353 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
354 | + } |
|
292 | 355 | |
293 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
294 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
356 | + if ($globalDebug) { |
|
357 | + echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
358 | + } |
|
359 | + if ($globalAllFlights !== FALSE) { |
|
360 | + $dataFound = true; |
|
361 | + } |
|
295 | 362 | } |
296 | 363 | |
297 | 364 | if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
298 | 365 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
299 | 366 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
300 | 367 | } else { |
301 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
302 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
368 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
369 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
370 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
371 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
372 | + } |
|
303 | 373 | /* |
304 | 374 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
305 | 375 | print_r($this->all_flights[$id]); |
@@ -307,7 +377,9 @@ discard block |
||
307 | 377 | */ |
308 | 378 | return ''; |
309 | 379 | } |
310 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
380 | + } else { |
|
381 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
382 | + } |
|
311 | 383 | |
312 | 384 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
313 | 385 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
@@ -328,15 +400,25 @@ discard block |
||
328 | 400 | $timeelapsed = microtime(true); |
329 | 401 | $Spotter = new Spotter($this->db); |
330 | 402 | $fromsource = NULL; |
331 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
332 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
333 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
334 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
335 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
403 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
404 | + $fromsource = $globalAirlinesSource; |
|
405 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
406 | + $fromsource = 'vatsim'; |
|
407 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
408 | + $fromsource = 'ivao'; |
|
409 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
410 | + $fromsource = 'vatsim'; |
|
411 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
412 | + $fromsource = 'ivao'; |
|
413 | + } |
|
336 | 414 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
337 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
415 | + if ($globalDebug && $result != 'success') { |
|
416 | + echo '!!! ERROR : '.$result."\n"; |
|
417 | + } |
|
338 | 418 | $Spotter->db = null; |
339 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + if ($globalDebugTimeElapsed) { |
|
420 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
421 | + } |
|
340 | 422 | } |
341 | 423 | |
342 | 424 | /* |
@@ -347,7 +429,9 @@ discard block |
||
347 | 429 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
348 | 430 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
349 | 431 | */ |
350 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
432 | + if (!isset($this->all_flights[$id]['id'])) { |
|
433 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
434 | + } |
|
351 | 435 | |
352 | 436 | //$putinarchive = true; |
353 | 437 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -364,7 +448,9 @@ discard block |
||
364 | 448 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
365 | 449 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
366 | 450 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
367 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
451 | + if ($globalDebugTimeElapsed) { |
|
452 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
453 | + } |
|
368 | 454 | |
369 | 455 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
370 | 456 | $timeelapsed = microtime(true); |
@@ -377,7 +463,9 @@ discard block |
||
377 | 463 | $Translation->db = null; |
378 | 464 | } |
379 | 465 | $Spotter->db = null; |
380 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
466 | + if ($globalDebugTimeElapsed) { |
|
467 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
468 | + } |
|
381 | 469 | |
382 | 470 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
383 | 471 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -386,9 +474,13 @@ discard block |
||
386 | 474 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
387 | 475 | } |
388 | 476 | } |
389 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
477 | + if (!isset($globalFork)) { |
|
478 | + $globalFork = TRUE; |
|
479 | + } |
|
390 | 480 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
391 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
481 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
482 | + $this->get_Schedule($id,trim($line['ident'])); |
|
483 | + } |
|
392 | 484 | } |
393 | 485 | } |
394 | 486 | } |
@@ -404,16 +496,23 @@ discard block |
||
404 | 496 | // use datetime |
405 | 497 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
406 | 498 | $speed = $speed*3.6; |
407 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
408 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
499 | + if ($speed < 1000) { |
|
500 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
501 | + } |
|
502 | + if ($globalDebug) { |
|
503 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
504 | + } |
|
409 | 505 | } |
410 | 506 | } |
411 | 507 | |
412 | 508 | |
413 | 509 | |
414 | 510 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
415 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
416 | - else unset($timediff); |
|
511 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
512 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
513 | + } else { |
|
514 | + unset($timediff); |
|
515 | + } |
|
417 | 516 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
418 | 517 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
419 | 518 | if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -421,21 +520,31 @@ discard block |
||
421 | 520 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
422 | 521 | $this->all_flights[$id]['putinarchive'] = true; |
423 | 522 | |
424 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
523 | + if ($globalDebug) { |
|
524 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
525 | + } |
|
425 | 526 | $timeelapsed = microtime(true); |
426 | 527 | $Spotter = new Spotter($this->db); |
427 | 528 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
428 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
529 | + if (!empty($all_country)) { |
|
530 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
531 | + } |
|
429 | 532 | $Spotter->db = null; |
430 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
533 | + if ($globalDebugTimeElapsed) { |
|
534 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
535 | + } |
|
431 | 536 | $this->tmd = 0; |
432 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
537 | + if ($globalDebug) { |
|
538 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
539 | + } |
|
433 | 540 | } |
434 | 541 | } |
435 | 542 | |
436 | 543 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
437 | 544 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
438 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
545 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
546 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
547 | + } |
|
439 | 548 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
440 | 549 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
441 | 550 | $dataFound = true; |
@@ -457,9 +566,13 @@ discard block |
||
457 | 566 | */ |
458 | 567 | } |
459 | 568 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
460 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
569 | + if ($line['longitude'] > 180) { |
|
570 | + $line['longitude'] = $line['longitude'] - 360; |
|
571 | + } |
|
461 | 572 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
462 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
573 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
574 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
575 | + } |
|
463 | 576 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
464 | 577 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
465 | 578 | $dataFound = true; |
@@ -490,7 +603,9 @@ discard block |
||
490 | 603 | } |
491 | 604 | } |
492 | 605 | if (isset($line['last_update']) && $line['last_update'] != '') { |
493 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
606 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
607 | + $dataFound = true; |
|
608 | + } |
|
494 | 609 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
495 | 610 | } |
496 | 611 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -512,11 +627,17 @@ discard block |
||
512 | 627 | // Here we force archive of flight because after ground it's a new one (or should be) |
513 | 628 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
514 | 629 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
515 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
516 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
517 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
630 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
631 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
632 | + } elseif (isset($line['id'])) { |
|
633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
634 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
636 | + } |
|
637 | + } |
|
638 | + if ($line['ground'] != 1) { |
|
639 | + $line['ground'] = 0; |
|
518 | 640 | } |
519 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
520 | 641 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
521 | 642 | //$dataFound = true; |
522 | 643 | } |
@@ -524,28 +645,40 @@ discard block |
||
524 | 645 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
525 | 646 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
526 | 647 | $highlight = ''; |
527 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
528 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
529 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
648 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
649 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
650 | + } |
|
651 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
652 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
653 | + } |
|
654 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
655 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
656 | + } |
|
530 | 657 | if ($highlight != '') { |
531 | 658 | $timeelapsed = microtime(true); |
532 | 659 | $Spotter = new Spotter($this->db); |
533 | 660 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
534 | 661 | $Spotter->db = null; |
535 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
662 | + if ($globalDebugTimeElapsed) { |
|
663 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
664 | + } |
|
536 | 665 | |
537 | 666 | $this->all_flights[$id]['putinarchive'] = true; |
538 | 667 | //$putinarchive = true; |
539 | 668 | //$highlight = ''; |
540 | 669 | } |
541 | 670 | |
542 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
671 | + } else { |
|
672 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
673 | + } |
|
543 | 674 | //$dataFound = true; |
544 | 675 | } |
545 | 676 | |
546 | 677 | if (isset($line['altitude']) && $line['altitude'] != '') { |
547 | 678 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
548 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
679 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) { |
|
680 | + $this->all_flights[$id]['putinarchive'] = true; |
|
681 | + } |
|
549 | 682 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
550 | 683 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
551 | 684 | //$dataFound = true; |
@@ -557,21 +690,30 @@ discard block |
||
557 | 690 | } |
558 | 691 | |
559 | 692 | if (isset($line['heading']) && $line['heading'] != '') { |
560 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
693 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) { |
|
694 | + $this->all_flights[$id]['putinarchive'] = true; |
|
695 | + } |
|
561 | 696 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
562 | 697 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
563 | 698 | //$dataFound = true; |
564 | 699 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
565 | 700 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
566 | 701 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
567 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
702 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) { |
|
703 | + $this->all_flights[$id]['putinarchive'] = true; |
|
704 | + } |
|
705 | + if ($globalDebug) { |
|
706 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
707 | + } |
|
569 | 708 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
570 | 709 | // If not enough messages and ACARS set heading to 0 |
571 | 710 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
572 | 711 | } |
573 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
574 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
712 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
713 | + $dataFound = false; |
|
714 | + } elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
715 | + $dataFound = false; |
|
716 | + } |
|
575 | 717 | |
576 | 718 | // print_r($this->all_flights[$id]); |
577 | 719 | //gets the callsign from the last hour |
@@ -586,23 +728,36 @@ discard block |
||
586 | 728 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
587 | 729 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
588 | 730 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
589 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
731 | + if ($globalDebug) { |
|
732 | + echo "Check if aircraft is already in DB..."; |
|
733 | + } |
|
590 | 734 | $timeelapsed = microtime(true); |
591 | 735 | $SpotterLive = new SpotterLive($this->db); |
592 | 736 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
593 | 737 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
594 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
738 | + if ($globalDebugTimeElapsed) { |
|
739 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
740 | + } |
|
595 | 741 | } elseif (isset($line['id'])) { |
596 | 742 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
597 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
743 | + if ($globalDebugTimeElapsed) { |
|
744 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
745 | + } |
|
598 | 746 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
599 | 747 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
600 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
601 | - } else $recent_ident = ''; |
|
748 | + if ($globalDebugTimeElapsed) { |
|
749 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
750 | + } |
|
751 | + } else { |
|
752 | + $recent_ident = ''; |
|
753 | + } |
|
602 | 754 | $SpotterLive->db=null; |
603 | 755 | |
604 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
605 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
756 | + if ($globalDebug && $recent_ident == '') { |
|
757 | + echo " Not in DB.\n"; |
|
758 | + } elseif ($globalDebug && $recent_ident != '') { |
|
759 | + echo " Already in DB.\n"; |
|
760 | + } |
|
606 | 761 | } else { |
607 | 762 | $recent_ident = ''; |
608 | 763 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -610,7 +765,9 @@ discard block |
||
610 | 765 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
611 | 766 | if($recent_ident == "") |
612 | 767 | { |
613 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
768 | + if ($globalDebug) { |
|
769 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
770 | + } |
|
614 | 771 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
615 | 772 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
616 | 773 | //adds the spotter data for the archive |
@@ -654,26 +811,44 @@ discard block |
||
654 | 811 | |
655 | 812 | if (!$ignoreImport) { |
656 | 813 | $highlight = ''; |
657 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
658 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
659 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
660 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
814 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
815 | + $highlight = 'Squawk 7500 : Hijack'; |
|
816 | + } |
|
817 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
818 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
819 | + } |
|
820 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
821 | + $highlight = 'Squawk 7700 : Emergency'; |
|
822 | + } |
|
823 | + if (!isset($this->all_flights[$id]['id'])) { |
|
824 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
825 | + } |
|
661 | 826 | $timeelapsed = microtime(true); |
662 | 827 | $Spotter = new Spotter($this->db); |
663 | 828 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
664 | 829 | $Spotter->db = null; |
665 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
666 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
830 | + if ($globalDebug && isset($result)) { |
|
831 | + echo $result."\n"; |
|
832 | + } |
|
833 | + if ($globalDebugTimeElapsed) { |
|
834 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
835 | + } |
|
667 | 836 | |
668 | 837 | // Add source stat in DB |
669 | 838 | $Stats = new Stats($this->db); |
670 | 839 | if (!empty($this->stats)) { |
671 | - if ($globalDebug) echo 'Add source stats : '; |
|
840 | + if ($globalDebug) { |
|
841 | + echo 'Add source stats : '; |
|
842 | + } |
|
672 | 843 | foreach($this->stats as $date => $data) { |
673 | 844 | foreach($data as $source => $sourced) { |
674 | 845 | //print_r($sourced); |
675 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
676 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
846 | + if (isset($sourced['polar'])) { |
|
847 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
848 | + } |
|
849 | + if (isset($sourced['hist'])) { |
|
850 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
851 | + } |
|
677 | 852 | if (isset($sourced['msg'])) { |
678 | 853 | if (time() - $sourced['msg']['date'] > 10) { |
679 | 854 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -686,13 +861,17 @@ discard block |
||
686 | 861 | unset($this->stats[$date]); |
687 | 862 | } |
688 | 863 | } |
689 | - if ($globalDebug) echo 'Done'."\n"; |
|
864 | + if ($globalDebug) { |
|
865 | + echo 'Done'."\n"; |
|
866 | + } |
|
690 | 867 | |
691 | 868 | } |
692 | 869 | $Stats->db = null; |
693 | 870 | |
694 | 871 | $this->del(); |
695 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
872 | + } elseif ($globalDebug) { |
|
873 | + echo 'Ignore data'."\n"; |
|
874 | + } |
|
696 | 875 | //$ignoreImport = false; |
697 | 876 | $this->all_flights[$id]['addedSpotter'] = 1; |
698 | 877 | //print_r($this->all_flights[$id]); |
@@ -709,12 +888,16 @@ discard block |
||
709 | 888 | */ |
710 | 889 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
711 | 890 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
712 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
891 | + if ($globalDebug) { |
|
892 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
893 | + } |
|
713 | 894 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
714 | 895 | $SpotterLive = new SpotterLive($this->db); |
715 | 896 | $SpotterLive->deleteLiveSpotterData(); |
716 | 897 | $SpotterLive->db=null; |
717 | - if ($globalDebug) echo " Done\n"; |
|
898 | + if ($globalDebug) { |
|
899 | + echo " Done\n"; |
|
900 | + } |
|
718 | 901 | $this->last_delete = time(); |
719 | 902 | } |
720 | 903 | } else { |
@@ -737,11 +920,17 @@ discard block |
||
737 | 920 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
738 | 921 | if ($globalDebug) { |
739 | 922 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
740 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
741 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
923 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
924 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
925 | + } else { |
|
926 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
927 | + } |
|
742 | 928 | } else { |
743 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
744 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
929 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
930 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
931 | + } else { |
|
932 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
933 | + } |
|
745 | 934 | } |
746 | 935 | } |
747 | 936 | $ignoreImport = false; |
@@ -787,19 +976,25 @@ discard block |
||
787 | 976 | |
788 | 977 | if (!$ignoreImport) { |
789 | 978 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
790 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
979 | + if ($globalDebug) { |
|
980 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
981 | + } |
|
791 | 982 | $timeelapsed = microtime(true); |
792 | 983 | $SpotterLive = new SpotterLive($this->db); |
793 | 984 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
794 | 985 | $SpotterLive->db = null; |
795 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
986 | + if ($globalDebugTimeElapsed) { |
|
987 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
988 | + } |
|
796 | 989 | |
797 | 990 | // Put statistics in $this->stats variable |
798 | 991 | //if ($line['format_source'] != 'aprs') { |
799 | 992 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
800 | 993 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
801 | 994 | $source = $this->all_flights[$id]['source_name']; |
802 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
995 | + if ($source == '') { |
|
996 | + $source = $this->all_flights[$id]['format_source']; |
|
997 | + } |
|
803 | 998 | if (!isset($this->source_location[$source])) { |
804 | 999 | $Location = new Source(); |
805 | 1000 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -820,7 +1015,9 @@ discard block |
||
820 | 1015 | $stats_heading = round($stats_heading/22.5); |
821 | 1016 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
822 | 1017 | $current_date = date('Y-m-d'); |
823 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1018 | + if ($stats_heading == 16) { |
|
1019 | + $stats_heading = 0; |
|
1020 | + } |
|
824 | 1021 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
825 | 1022 | for ($i=0;$i<=15;$i++) { |
826 | 1023 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -838,7 +1035,9 @@ discard block |
||
838 | 1035 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
839 | 1036 | end($this->stats[$current_date][$source]['hist']); |
840 | 1037 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
841 | - } else $mini = 0; |
|
1038 | + } else { |
|
1039 | + $mini = 0; |
|
1040 | + } |
|
842 | 1041 | for ($i=$mini;$i<=$distance;$i+=10) { |
843 | 1042 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
844 | 1043 | } |
@@ -849,20 +1048,30 @@ discard block |
||
849 | 1048 | } |
850 | 1049 | |
851 | 1050 | $this->all_flights[$id]['lastupdate'] = time(); |
852 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1051 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1052 | + $send = true; |
|
1053 | + } |
|
853 | 1054 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
854 | - if ($globalDebug) echo $result."\n"; |
|
855 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1055 | + if ($globalDebug) { |
|
1056 | + echo $result."\n"; |
|
1057 | + } |
|
1058 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1059 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1060 | + } |
|
856 | 1061 | //$this->del(); |
857 | 1062 | |
858 | 1063 | |
859 | 1064 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
860 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1065 | + if ($globalDebug) { |
|
1066 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1067 | + } |
|
861 | 1068 | $SpotterLive = new SpotterLive($this->db); |
862 | 1069 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
863 | 1070 | $SpotterLive->db = null; |
864 | 1071 | //SpotterLive->deleteLiveSpotterData(); |
865 | - if ($globalDebug) echo " Done\n"; |
|
1072 | + if ($globalDebug) { |
|
1073 | + echo " Done\n"; |
|
1074 | + } |
|
866 | 1075 | $this->last_delete_hourly = time(); |
867 | 1076 | } |
868 | 1077 | |
@@ -870,7 +1079,9 @@ discard block |
||
870 | 1079 | //$ignoreImport = false; |
871 | 1080 | } |
872 | 1081 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
873 | - if ($send) return $this->all_flights[$id]; |
|
1082 | + if ($send) { |
|
1083 | + return $this->all_flights[$id]; |
|
1084 | + } |
|
874 | 1085 | } |
875 | 1086 | } |
876 | 1087 | } |