@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | // When button "Remove all filters" is clicked |
29 | 29 | if (isset($_POST['removefilters'])) { |
30 | 30 | $allfilters = array_filter(array_keys($_COOKIE),function($key) { |
31 | - return strpos($key,'filter_') === 0; |
|
31 | + return strpos($key,'filter_') === 0; |
|
32 | 32 | }); |
33 | 33 | foreach ($allfilters as $filt) { |
34 | 34 | unset($_COOKIE[$filt]); |
@@ -167,17 +167,17 @@ discard block |
||
167 | 167 | } |
168 | 168 | ?> |
169 | 169 | <?php |
170 | - if (isset($_POST['archive'])) { |
|
170 | + if (isset($_POST['archive'])) { |
|
171 | 171 | ?> |
172 | 172 | <script src="<?php print $globalURL; ?>/js/map.common.js"></script> |
173 | 173 | <?php |
174 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
174 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
175 | 175 | ?> |
176 | 176 | |
177 | 177 | <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script> |
178 | 178 | <?php |
179 | - } |
|
180 | - } else { |
|
179 | + } |
|
180 | + } else { |
|
181 | 181 | ?> |
182 | 182 | <?php |
183 | 183 | /* if (isset($globalBeta) && $globalBeta) { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | ?> |
191 | 191 | <?php |
192 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
192 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
193 | 193 | ?> |
194 | 194 | <?php |
195 | 195 | // if (isset($globalBeta) && $globalBeta) { |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | <script src="<?php print $globalURL; ?>/js/map-marine.2d.js.php?<?php print time(); ?>"></script> |
217 | 217 | <?php |
218 | 218 | } |
219 | - } |
|
219 | + } |
|
220 | 220 | ?> |
221 | 221 | <?php |
222 | 222 | // } |
223 | 223 | ?> |
224 | 224 | <?php |
225 | - } |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | ?> |
228 | 228 | <?php |
@@ -398,48 +398,48 @@ discard block |
||
398 | 398 | <ul class="nav navbar-nav"> |
399 | 399 | |
400 | 400 | <?php |
401 | - $sub = false; |
|
402 | - if (((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))) || (isset($globalMarine) && $globalMarine === TRUE && isset($globalTracker) && $globalTracker === TRUE)) { |
|
401 | + $sub = false; |
|
402 | + if (((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))) || (isset($globalMarine) && $globalMarine === TRUE && isset($globalTracker) && $globalTracker === TRUE)) { |
|
403 | 403 | $sub = true; |
404 | - } |
|
404 | + } |
|
405 | 405 | ?> |
406 | 406 | <?php |
407 | - if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
407 | + if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
408 | 408 | ?> |
409 | 409 | <li class="dropdown"> |
410 | 410 | <?php |
411 | - if ($sub) { |
|
411 | + if ($sub) { |
|
412 | 412 | ?> |
413 | 413 | <li class="dropdown"> |
414 | 414 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Aircrafts"); ?> <b class="caret"></b></a> |
415 | 415 | <ul class="dropdown-menu multi-level"> |
416 | 416 | <li class="dropdown-submenu"> |
417 | 417 | <?php |
418 | - } |
|
418 | + } |
|
419 | 419 | ?> |
420 | 420 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
421 | 421 | <ul class="dropdown-menu"> |
422 | 422 | <li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li> |
423 | 423 | <?php |
424 | - if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) { |
|
424 | + if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) { |
|
425 | 425 | ?> |
426 | 426 | <li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li> |
427 | 427 | <?php |
428 | - } |
|
428 | + } |
|
429 | 429 | ?> |
430 | 430 | <li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li> |
431 | 431 | <?php |
432 | - if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) { |
|
432 | + if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) { |
|
433 | 433 | ?> |
434 | 434 | <li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li> |
435 | 435 | <?php |
436 | - } |
|
437 | - if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) { |
|
436 | + } |
|
437 | + if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) { |
|
438 | 438 | |
439 | 439 | ?> |
440 | 440 | <li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li> |
441 | 441 | <?php |
442 | - } |
|
442 | + } |
|
443 | 443 | ?> |
444 | 444 | <li><hr /></li> |
445 | 445 | <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li> |
@@ -447,43 +447,43 @@ discard block |
||
447 | 447 | <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li> |
448 | 448 | <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li> |
449 | 449 | <?php |
450 | - if ($globalACARS) { |
|
451 | - if (isset($globalDemo) && $globalDemo) { |
|
452 | - ?> |
|
450 | + if ($globalACARS) { |
|
451 | + if (isset($globalDemo) && $globalDemo) { |
|
452 | + ?> |
|
453 | 453 | <li><hr /></li> |
454 | 454 | <li><i><?php echo _('ACARS data not available publicly'); ?></i></li> |
455 | 455 | <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li> |
456 | 456 | <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li> |
457 | 457 | <?php |
458 | - } else { |
|
459 | - ?> |
|
458 | + } else { |
|
459 | + ?> |
|
460 | 460 | <li><hr /></li> |
461 | 461 | <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li> |
462 | 462 | <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li> |
463 | 463 | <?php |
464 | - } |
|
465 | - } |
|
466 | - ?> |
|
464 | + } |
|
465 | + } |
|
466 | + ?> |
|
467 | 467 | <?php |
468 | - if (isset($globalAccidents) && $globalAccidents) { |
|
469 | - ?> |
|
468 | + if (isset($globalAccidents) && $globalAccidents) { |
|
469 | + ?> |
|
470 | 470 | <li><hr /></li> |
471 | 471 | <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li> |
472 | 472 | <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li> |
473 | 473 | <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li> |
474 | 474 | <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li> |
475 | 475 | <?php |
476 | - } |
|
477 | - ?> |
|
476 | + } |
|
477 | + ?> |
|
478 | 478 | <li><hr /></li> |
479 | 479 | <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li> |
480 | 480 | <?php |
481 | 481 | if (!isset($globalNoUpcoming) || $globalNoUpcoming === FALSE) { |
482 | - ?> |
|
482 | + ?> |
|
483 | 483 | <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li> |
484 | 484 | <?php |
485 | 485 | } |
486 | - ?> |
|
486 | + ?> |
|
487 | 487 | </ul> |
488 | 488 | </li> |
489 | 489 | <li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li> |
@@ -503,14 +503,14 @@ discard block |
||
503 | 503 | </ul> |
504 | 504 | <?php |
505 | 505 | } |
506 | - } |
|
506 | + } |
|
507 | 507 | ?> |
508 | 508 | <?php |
509 | - if (isset($globalMarine) && $globalMarine) { |
|
509 | + if (isset($globalMarine) && $globalMarine) { |
|
510 | 510 | ?> |
511 | 511 | <li class="dropdown"> |
512 | 512 | <?php |
513 | - if ($sub) { |
|
513 | + if ($sub) { |
|
514 | 514 | ?> |
515 | 515 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Vessels"); ?> <b class="caret"></b></a> |
516 | 516 | <ul class="dropdown-menu multi-level"> |
@@ -535,14 +535,14 @@ discard block |
||
535 | 535 | } |
536 | 536 | ?> |
537 | 537 | <?php |
538 | - } |
|
538 | + } |
|
539 | 539 | ?> |
540 | 540 | <?php |
541 | - if (isset($globalTracker) && $globalTracker) { |
|
541 | + if (isset($globalTracker) && $globalTracker) { |
|
542 | 542 | ?> |
543 | 543 | <li class="dropdown"> |
544 | 544 | <?php |
545 | - if ($sub) { |
|
545 | + if ($sub) { |
|
546 | 546 | ?> |
547 | 547 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Trackers"); ?> <b class="caret"></b></a> |
548 | 548 | <ul class="dropdown-menu multi-level"> |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | } |
568 | 568 | ?> |
569 | 569 | <?php |
570 | - } |
|
570 | + } |
|
571 | 571 | ?> |
572 | 572 | |
573 | 573 | <li class="dropdown"> |
@@ -576,12 +576,12 @@ discard block |
||
576 | 576 | <li><a href="<?php print $globalURL; ?>/about"><?php echo _("About The Project"); ?></a></li> |
577 | 577 | <li><a href="<?php print $globalURL; ?>/about/export"><?php echo _("Exporting Data"); ?></a></li> |
578 | 578 | <?php |
579 | - if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
579 | + if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
580 | 580 | ?> |
581 | 581 | <li><hr /></li> |
582 | 582 | <li><a href="<?php print $globalURL; ?>/about/tv"><?php echo _("Spotter TV"); ?></a></li> |
583 | 583 | <?php |
584 | - } |
|
584 | + } |
|
585 | 585 | ?> |
586 | 586 | <?php if (isset($globalContribute) && $globalContribute) { ?> |
587 | 587 | <li><hr /></li> |
@@ -602,14 +602,14 @@ discard block |
||
602 | 602 | <form> |
603 | 603 | <select class="selectpicker" data-width="120px" onchange="language(this);"> |
604 | 604 | <?php |
605 | - $Language = new Language(); |
|
606 | - $alllang = $Language->getLanguages(); |
|
607 | - foreach ($alllang as $key => $lang) { |
|
608 | - print '<option value="'.$key.'"'; |
|
609 | - if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
610 | - print '>'.$lang[0].'</option>'; |
|
611 | - } |
|
612 | - ?> |
|
605 | + $Language = new Language(); |
|
606 | + $alllang = $Language->getLanguages(); |
|
607 | + foreach ($alllang as $key => $lang) { |
|
608 | + print '<option value="'.$key.'"'; |
|
609 | + if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
610 | + print '>'.$lang[0].'</option>'; |
|
611 | + } |
|
612 | + ?> |
|
613 | 613 | </select> |
614 | 614 | </form> |
615 | 615 | </div> |
@@ -640,18 +640,18 @@ discard block |
||
640 | 640 | ?> |
641 | 641 | <div class="top-header clear" role="main"> |
642 | 642 | <?php |
643 | - if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
643 | + if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
644 | 644 | ?> |
645 | 645 | <div id="archive-map"></div> |
646 | 646 | <?php |
647 | - } |
|
647 | + } |
|
648 | 648 | ?> |
649 | 649 | </div> |
650 | 650 | <?php |
651 | 651 | } |
652 | 652 | if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false)) |
653 | 653 | { |
654 | - ?> |
|
654 | + ?> |
|
655 | 655 | <div class="top-header clear" role="main"> |
656 | 656 | <div id="map"></div> |
657 | 657 | <link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" /> |
@@ -662,15 +662,15 @@ discard block |
||
662 | 662 | var zoom = 13; |
663 | 663 | //create the map |
664 | 664 | <?php |
665 | - if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
665 | + if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
666 | 666 | ?> |
667 | 667 | map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom); |
668 | 668 | <?php |
669 | - } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
669 | + } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
670 | 670 | ?> |
671 | 671 | map = L.map('map', { zoomControl:true }); |
672 | 672 | <?php |
673 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
673 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
674 | 674 | ?> |
675 | 675 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]); |
676 | 676 | var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map); |
@@ -678,22 +678,22 @@ discard block |
||
678 | 678 | var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map); |
679 | 679 | var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map); |
680 | 680 | <?php |
681 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
681 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
682 | 682 | ?> |
683 | 683 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]); |
684 | 684 | <?php |
685 | - } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
685 | + } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
686 | 686 | ?> |
687 | 687 | map = L.map('map', { zoomControl:true }); |
688 | 688 | <?php |
689 | - } |
|
689 | + } |
|
690 | 690 | ?> |
691 | 691 | //initialize the layer group for the aircrft markers |
692 | 692 | var layer_data = L.layerGroup(); |
693 | 693 | |
694 | 694 | //a few title layers |
695 | 695 | <?php |
696 | - if ($globalMapProvider == 'Mapbox') { |
|
696 | + if ($globalMapProvider == 'Mapbox') { |
|
697 | 697 | ?> |
698 | 698 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
699 | 699 | maxZoom: 18, |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | token : '<?php print $globalMapboxToken; ?>' |
705 | 705 | }).addTo(map); |
706 | 706 | <?php |
707 | - } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
707 | + } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
708 | 708 | ?> |
709 | 709 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', { |
710 | 710 | maxZoom: 18, |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>' |
714 | 714 | }).addTo(map); |
715 | 715 | <?php |
716 | - } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
716 | + } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
717 | 717 | ?> |
718 | 718 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', { |
719 | 719 | maxZoom: 18, |
@@ -722,27 +722,27 @@ discard block |
||
722 | 722 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"' |
723 | 723 | }).addTo(map); |
724 | 724 | <?php |
725 | - } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
725 | + } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
726 | 726 | ?> |
727 | 727 | var googleLayer = new L.Google('ROADMAP'); |
728 | 728 | map.addLayer(googleLayer); |
729 | 729 | <?php |
730 | - } elseif ($globalMapProvider == 'Google-Satellite') { |
|
730 | + } elseif ($globalMapProvider == 'Google-Satellite') { |
|
731 | 731 | ?> |
732 | 732 | var googleLayer = new L.Google('SATELLITE'); |
733 | 733 | map.addLayer(googleLayer); |
734 | 734 | <?php |
735 | - } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
735 | + } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
736 | 736 | ?> |
737 | 737 | var googleLayer = new L.Google('HYBRID'); |
738 | 738 | map.addLayer(googleLayer); |
739 | 739 | <?php |
740 | - } elseif ($globalMapProvider == 'Google-Terrain') { |
|
740 | + } elseif ($globalMapProvider == 'Google-Terrain') { |
|
741 | 741 | ?> |
742 | 742 | var googleLayer = new L.Google('Terrain'); |
743 | 743 | map.addLayer(googleLayer); |
744 | 744 | <?php |
745 | - } elseif (isset($globalMapCustomLayer[$globalMapProvider])) { |
|
745 | + } elseif (isset($globalMapCustomLayer[$globalMapProvider])) { |
|
746 | 746 | $customid = $globalMapProvider; |
747 | 747 | ?> |
748 | 748 | L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', { |
@@ -752,8 +752,8 @@ discard block |
||
752 | 752 | attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>' |
753 | 753 | }).addTo(map); |
754 | 754 | <?php |
755 | - //} elseif ($globalMapProvider == 'OpenStreetMap') { |
|
756 | - } else { |
|
755 | + //} elseif ($globalMapProvider == 'OpenStreetMap') { |
|
756 | + } else { |
|
757 | 757 | ?> |
758 | 758 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
759 | 759 | maxZoom: 18, |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | }).addTo(map); |
763 | 763 | |
764 | 764 | <?php |
765 | - } |
|
765 | + } |
|
766 | 766 | ?> |
767 | 767 | </script> |
768 | 768 | </div> |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); |
4 | 4 | class aprs { |
5 | - private $socket; |
|
6 | - private $connected = false; |
|
5 | + private $socket; |
|
6 | + private $connected = false; |
|
7 | 7 | |
8 | - protected $symbols = array('!' => 'Police', |
|
8 | + protected $symbols = array('!' => 'Police', |
|
9 | 9 | '#' => 'DIGI', |
10 | 10 | '$' => 'Phone', |
11 | 11 | '%' => 'DX Cluster', |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | 'y' => 'Yagi At QTH'); |
90 | 90 | |
91 | 91 | |
92 | - private function urshift($n, $s) { |
|
92 | + private function urshift($n, $s) { |
|
93 | 93 | return ($n >= 0) ? ($n >> $s) : |
94 | - (($n & 0x7fffffff) >> $s) | |
|
94 | + (($n & 0x7fffffff) >> $s) | |
|
95 | 95 | (0x40000000 >> ($s - 1)); |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - public function parse($input) { |
|
98 | + public function parse($input) { |
|
99 | 99 | global $globalDebug; |
100 | 100 | $debug = false; |
101 | 101 | $result = array(); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | |
108 | 108 | /* Check that end was found and body has at least one byte. */ |
109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | - return false; |
|
110 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | + return false; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if ($debug) echo 'input : '.$input."\n"; |
@@ -122,34 +122,34 @@ discard block |
||
122 | 122 | /* Parse source, target and path. */ |
123 | 123 | //FLRDF0A52>APRS,qAS,LSTB |
124 | 124 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
125 | - $ident = $matches[1]; |
|
126 | - $all_elements = $matches[2]; |
|
127 | - if ($ident == 'AIRCRAFT') { |
|
125 | + $ident = $matches[1]; |
|
126 | + $all_elements = $matches[2]; |
|
127 | + if ($ident == 'AIRCRAFT') { |
|
128 | 128 | $result['format_source'] = 'famaprs'; |
129 | 129 | $result['source_type'] = 'modes'; |
130 | - } elseif ($ident == 'MARINE') { |
|
130 | + } elseif ($ident == 'MARINE') { |
|
131 | 131 | $result['format_source'] = 'famaprs'; |
132 | 132 | $result['source_type'] = 'ais'; |
133 | - } else { |
|
133 | + } else { |
|
134 | 134 | if ($debug) echo 'ident : '.$ident."\n"; |
135 | 135 | $result['ident'] = $ident; |
136 | - } |
|
136 | + } |
|
137 | 137 | } else { |
138 | - if ($debug) 'No ident'."\n"; |
|
139 | - return false; |
|
138 | + if ($debug) 'No ident'."\n"; |
|
139 | + return false; |
|
140 | 140 | } |
141 | 141 | $elements = explode(',',$all_elements); |
142 | 142 | $source = end($elements); |
143 | 143 | $result['source'] = $source; |
144 | 144 | foreach ($elements as $element) { |
145 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
146 | - //echo "ok"; |
|
147 | - //if ($element == 'TCPIP*') return false; |
|
148 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
145 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
146 | + //echo "ok"; |
|
147 | + //if ($element == 'TCPIP*') return false; |
|
148 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
149 | 149 | if ($debug) echo 'element : '.$element."\n"; |
150 | 150 | return false; |
151 | - } |
|
152 | - /* |
|
151 | + } |
|
152 | + /* |
|
153 | 153 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
154 | 154 | //echo "ok"; |
155 | 155 | } else { |
@@ -176,49 +176,49 @@ discard block |
||
176 | 176 | $body_parse = substr($body,1); |
177 | 177 | //echo 'Body : '.$body."\n"; |
178 | 178 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
179 | - $body_parse = substr($body_parse,10); |
|
180 | - $find = true; |
|
181 | - //echo $body_parse."\n"; |
|
179 | + $body_parse = substr($body_parse,10); |
|
180 | + $find = true; |
|
181 | + //echo $body_parse."\n"; |
|
182 | 182 | } |
183 | 183 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
184 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
185 | - $find = true; |
|
186 | - //echo $body_parse."\n"; |
|
184 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
185 | + $find = true; |
|
186 | + //echo $body_parse."\n"; |
|
187 | 187 | } |
188 | 188 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
189 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
190 | - $find = true; |
|
191 | - //echo $body_parse."\n"; |
|
189 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
190 | + $find = true; |
|
191 | + //echo $body_parse."\n"; |
|
192 | 192 | } |
193 | 193 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
194 | - $find = true; |
|
195 | - //print_r($matches); |
|
196 | - $timestamp = $matches[0]; |
|
197 | - if ($matches[4] == 'h') { |
|
194 | + $find = true; |
|
195 | + //print_r($matches); |
|
196 | + $timestamp = $matches[0]; |
|
197 | + if ($matches[4] == 'h') { |
|
198 | 198 | $timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]); |
199 | 199 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
200 | 200 | /* |
201 | 201 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
202 | 202 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
203 | 203 | */ |
204 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
204 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
205 | 205 | // This work or not ? |
206 | 206 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
207 | - } |
|
208 | - $body_parse = substr($body_parse,7); |
|
209 | - $result['timestamp'] = $timestamp; |
|
210 | - //echo date('Ymd H:i:s',$timestamp); |
|
207 | + } |
|
208 | + $body_parse = substr($body_parse,7); |
|
209 | + $result['timestamp'] = $timestamp; |
|
210 | + //echo date('Ymd H:i:s',$timestamp); |
|
211 | 211 | } |
212 | 212 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
213 | - $find = true; |
|
214 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
215 | - $body_parse = substr($body_parse,8); |
|
216 | - $result['timestamp'] = $timestamp; |
|
217 | - //echo date('Ymd H:i:s',$timestamp); |
|
213 | + $find = true; |
|
214 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
215 | + $body_parse = substr($body_parse,8); |
|
216 | + $result['timestamp'] = $timestamp; |
|
217 | + //echo date('Ymd H:i:s',$timestamp); |
|
218 | 218 | } |
219 | 219 | //if (strlen($body_parse) > 19) { |
220 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
221 | - $find = true; |
|
220 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
221 | + $find = true; |
|
222 | 222 | // 4658.70N/00707.78Ez |
223 | 223 | //print_r(str_split($body_parse)); |
224 | 224 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $lon = intval($lon_deg); |
236 | 236 | if ($lat > 89 || $lon > 179) return false; |
237 | 237 | |
238 | - /* |
|
238 | + /* |
|
239 | 239 | $tmp_5b = str_replace('.','',$lat_min); |
240 | 240 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
241 | 241 | print_r($matches); |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | $result['longitude'] = $longitude; |
250 | 250 | $body_parse = substr($body_parse,18); |
251 | 251 | $body_parse_len = strlen($body_parse); |
252 | - } |
|
253 | - $body_parse_len = strlen($body_parse); |
|
254 | - if ($body_parse_len > 0) { |
|
252 | + } |
|
253 | + $body_parse_len = strlen($body_parse); |
|
254 | + if ($body_parse_len > 0) { |
|
255 | 255 | /* |
256 | 256 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
257 | 257 | $body_split = str_split($body); |
@@ -281,95 +281,95 @@ discard block |
||
281 | 281 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
282 | 282 | if ($symbol_code != '_') { |
283 | 283 | } |
284 | - //$body_parse = substr($body_parse,1); |
|
285 | - //$body_parse = trim($body_parse); |
|
286 | - //$body_parse_len = strlen($body_parse); |
|
287 | - if ($body_parse_len >= 7) { |
|
284 | + //$body_parse = substr($body_parse,1); |
|
285 | + //$body_parse = trim($body_parse); |
|
286 | + //$body_parse_len = strlen($body_parse); |
|
287 | + if ($body_parse_len >= 7) { |
|
288 | 288 | |
289 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
290 | - $course = substr($body_parse,0,3); |
|
291 | - $tmp_s = intval($course); |
|
292 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
293 | - $speed = substr($body_parse,4,3); |
|
294 | - if ($speed != '...') { |
|
295 | - //$result['speed'] = round($speed*1.852); |
|
296 | - $result['speed'] = intval($speed); |
|
297 | - } |
|
298 | - $body_parse = substr($body_parse,7); |
|
299 | - } |
|
300 | - // Check PHGR, PHG, RNG |
|
301 | - } |
|
302 | - /* |
|
289 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
290 | + $course = substr($body_parse,0,3); |
|
291 | + $tmp_s = intval($course); |
|
292 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
293 | + $speed = substr($body_parse,4,3); |
|
294 | + if ($speed != '...') { |
|
295 | + //$result['speed'] = round($speed*1.852); |
|
296 | + $result['speed'] = intval($speed); |
|
297 | + } |
|
298 | + $body_parse = substr($body_parse,7); |
|
299 | + } |
|
300 | + // Check PHGR, PHG, RNG |
|
301 | + } |
|
302 | + /* |
|
303 | 303 | else if ($body_parse_len > 0) { |
304 | 304 | $rest = $body_parse; |
305 | 305 | } |
306 | 306 | */ |
307 | - if (strlen($body_parse) > 0) { |
|
308 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
309 | - $altitude = intval($matches[1]); |
|
310 | - //$result['altitude'] = round($altitude*0.3048); |
|
311 | - $result['altitude'] = $altitude; |
|
312 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
313 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
314 | - } |
|
315 | - } |
|
307 | + if (strlen($body_parse) > 0) { |
|
308 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
309 | + $altitude = intval($matches[1]); |
|
310 | + //$result['altitude'] = round($altitude*0.3048); |
|
311 | + $result['altitude'] = $altitude; |
|
312 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
313 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
314 | + } |
|
315 | + } |
|
316 | 316 | |
317 | - // Telemetry |
|
318 | - /* |
|
317 | + // Telemetry |
|
318 | + /* |
|
319 | 319 | if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
320 | 320 | // Nothing yet... |
321 | 321 | } |
322 | 322 | */ |
323 | - // DAO |
|
323 | + // DAO |
|
324 | 324 | |
325 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
325 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
326 | 326 | |
327 | - $dao = $matches[1]; |
|
328 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
327 | + $dao = $matches[1]; |
|
328 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
329 | 329 | $dao_split = str_split($dao); |
330 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
331 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
330 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
331 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
332 | 332 | |
333 | 333 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
334 | 334 | else $result['latitude'] += $lat_off; |
335 | 335 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
336 | 336 | else $result['longitude'] += $lon_off; |
337 | - } |
|
337 | + } |
|
338 | 338 | |
339 | - $body_parse = substr($body_parse,6); |
|
340 | - } |
|
339 | + $body_parse = substr($body_parse,6); |
|
340 | + } |
|
341 | 341 | |
342 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
342 | + if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
343 | 343 | $result['ident'] = str_replace('_',' ',$matches[1]); |
344 | - } |
|
345 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
344 | + } |
|
345 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
346 | 346 | $result['squawk'] = $matches[1]; |
347 | - } |
|
348 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
347 | + } |
|
348 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
349 | 349 | $result['aircraft_icao'] = $matches[1]; |
350 | - } |
|
351 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
350 | + } |
|
351 | + if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
352 | 352 | $result['verticalrate'] = $matches[1]; |
353 | - } |
|
354 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
353 | + } |
|
354 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
355 | 355 | $result['typeid'] = $matches[1]; |
356 | - } |
|
357 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
356 | + } |
|
357 | + if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
358 | 358 | $result['statusid'] = $matches[1]; |
359 | - } |
|
360 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
359 | + } |
|
360 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
361 | 361 | $result['imo'] = $matches[1]; |
362 | - } |
|
363 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
362 | + } |
|
363 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
364 | 364 | $result['arrival_date'] = $matches[1]; |
365 | - } |
|
366 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
365 | + } |
|
366 | + if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
367 | 367 | $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
368 | - } |
|
369 | - // OGN comment |
|
368 | + } |
|
369 | + // OGN comment |
|
370 | 370 | // echo "Before OGN : ".$body_parse."\n"; |
371 | - //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
372 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
371 | + //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
372 | + if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
373 | 373 | $id = $matches[1]; |
374 | 374 | //$mode = substr($id,0,2); |
375 | 375 | $address = substr($id,2); |
@@ -399,53 +399,53 @@ discard block |
||
399 | 399 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
400 | 400 | $result['stealth'] = $stealth; |
401 | 401 | $result['address'] = $address; |
402 | - } |
|
402 | + } |
|
403 | 403 | |
404 | - //Comment |
|
405 | - $result['comment'] = trim($body_parse); |
|
404 | + //Comment |
|
405 | + $result['comment'] = trim($body_parse); |
|
406 | 406 | } else { |
407 | - // parse weather |
|
408 | - //$body_parse = substr($body_parse,1); |
|
409 | - //$body_parse_len = strlen($body_parse); |
|
407 | + // parse weather |
|
408 | + //$body_parse = substr($body_parse,1); |
|
409 | + //$body_parse_len = strlen($body_parse); |
|
410 | 410 | |
411 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
412 | - $result['wind_dir'] = intval($matches[1]); |
|
413 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
414 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
415 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
416 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
417 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
411 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
412 | + $result['wind_dir'] = intval($matches[1]); |
|
413 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
414 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
415 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
416 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
417 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
418 | 418 | $result['wind_dir'] = intval($matches[1]); |
419 | 419 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
420 | 420 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
421 | 421 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
422 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
423 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
422 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
423 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
424 | 424 | $result['wind_dir'] = intval($matches[1]); |
425 | 425 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
426 | 426 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
427 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
428 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
427 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
428 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
429 | 429 | $result['wind_dir'] = intval($matches[1]); |
430 | 430 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
431 | 431 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
432 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
433 | - } |
|
434 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
432 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
433 | + } |
|
434 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
435 | 435 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
436 | - } |
|
436 | + } |
|
437 | 437 | } |
438 | 438 | } else $result['comment'] = trim($body_parse); |
439 | 439 | |
440 | - } |
|
440 | + } |
|
441 | 441 | //} |
442 | 442 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
443 | 443 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
444 | 444 | if ($debug) print_r($result); |
445 | 445 | return $result; |
446 | - } |
|
446 | + } |
|
447 | 447 | |
448 | - public function connect() { |
|
448 | + public function connect() { |
|
449 | 449 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
450 | 450 | $aprs_connect = 0; |
451 | 451 | $aprs_keep = 120; |
@@ -469,24 +469,24 @@ discard block |
||
469 | 469 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
470 | 470 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
471 | 471 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
472 | - echo 'APRS user verified !'."\n"; |
|
473 | - $this->connected = true; |
|
474 | - return true; |
|
475 | - break; |
|
472 | + echo 'APRS user verified !'."\n"; |
|
473 | + $this->connected = true; |
|
474 | + return true; |
|
475 | + break; |
|
476 | 476 | } |
477 | 477 | if (time()-$authstart > 5) { |
478 | - echo 'APRS timeout'."\n"; |
|
479 | - break; |
|
478 | + echo 'APRS timeout'."\n"; |
|
479 | + break; |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | } |
483 | - } |
|
483 | + } |
|
484 | 484 | |
485 | - public function disconnect() { |
|
485 | + public function disconnect() { |
|
486 | 486 | socket_close($this->socket); |
487 | - } |
|
487 | + } |
|
488 | 488 | |
489 | - public function send($data) { |
|
489 | + public function send($data) { |
|
490 | 490 | global $globalDebug; |
491 | 491 | if ($this->connected === false) $this->connect(); |
492 | 492 | $send = socket_send( $this->socket , $data , strlen($data),0); |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | socket_close($this->socket); |
496 | 496 | $this->connect(); |
497 | 497 | } |
498 | - } |
|
498 | + } |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | class APRSSpotter extends APRS { |
@@ -46,9 +46,9 @@ |
||
46 | 46 | print '</div>'; |
47 | 47 | |
48 | 48 | if ($spotter_item['description'] != '') { |
49 | - print '<div class="notamtext"><span>'._("Info").'</span>'; |
|
50 | - print $spotter_item['description']; |
|
51 | - print '</div>'; |
|
49 | + print '<div class="notamtext"><span>'._("Info").'</span>'; |
|
50 | + print $spotter_item['description']; |
|
51 | + print '</div>'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | print '</div>'; |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | $coords = explode(',',$_GET['coord']); |
17 | 17 | // $spotter_array = Source::getAllLocationInfobyCoord($coords); |
18 | 18 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
19 | - || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
19 | + || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
20 | 20 | $spotter_array = $Source->getAllLocationInfo(); |
21 | 21 | } else { |
22 | 22 | $spotter_array = $Source->getLocationInfoByType(''); |
23 | 23 | } |
24 | 24 | } else { |
25 | 25 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
26 | - || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
26 | + || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
27 | 27 | $spotter_array = $Source->getAllLocationInfo(); |
28 | 28 | } else { |
29 | 29 | $spotter_array = $Source->getLocationInfoByType(''); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | date_default_timezone_set('UTC'); |
40 | 40 | //waypoint plotting |
41 | 41 | $output .= '{"type": "Feature",'; |
42 | - $output .= '"properties": {'; |
|
42 | + $output .= '"properties": {'; |
|
43 | 43 | $output .= '"id": "'.$spotter_item['id'].'",'; |
44 | 44 | $output .= '"location_id": "'.$spotter_item['location_id'].'",'; |
45 | 45 | $output .= '"name": "'.$spotter_item['name'].'",'; |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | $output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",'; |
54 | 54 | $output .= '"type": "'.$spotter_item['type'].'",'; |
55 | 55 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
56 | - $output .= '},'; |
|
57 | - $output .= '"geometry": {'; |
|
56 | + $output .= '},'; |
|
57 | + $output .= '"geometry": {'; |
|
58 | 58 | $output .= '"type": "Point",'; |
59 | 59 | $output .= '"coordinates": ['; |
60 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
60 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
61 | 61 | $output .= ']'; |
62 | - $output .= '}'; |
|
62 | + $output .= '}'; |
|
63 | 63 | $output .= '},'; |
64 | 64 | } |
65 | 65 | $output = substr($output, 0, -1); |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | $this->db = $Connection->db; |
9 | 9 | } |
10 | 10 | |
11 | - /** |
|
12 | - * Get SQL query part for filter used |
|
13 | - * @param Array $filter the filter |
|
14 | - * @return Array the SQL part |
|
15 | - */ |
|
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
11 | + /** |
|
12 | + * Get SQL query part for filter used |
|
13 | + * @param Array $filter the filter |
|
14 | + * @return Array the SQL part |
|
15 | + */ |
|
16 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -30,88 +30,88 @@ discard block |
||
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | 32 | foreach($filters as $flt) { |
33 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
33 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
34 | 34 | if ($flt['airlines'][0] != '') { |
35 | - if (isset($flt['source'])) { |
|
35 | + if (isset($flt['source'])) { |
|
36 | 36 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
37 | - } else { |
|
37 | + } else { |
|
38 | 38 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
39 | - } |
|
39 | + } |
|
40 | + } |
|
40 | 41 | } |
41 | - } |
|
42 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
42 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
43 | 43 | if (isset($flt['source'])) { |
44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
45 | 45 | } else { |
46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
47 | 47 | } |
48 | - } |
|
49 | - if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
48 | + } |
|
49 | + if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
50 | 50 | if (isset($flt['source'])) { |
51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
52 | 52 | } else { |
53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
54 | + } |
|
54 | 55 | } |
55 | - } |
|
56 | - if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
56 | + if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
57 | 57 | if (isset($flt['source'])) { |
58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
59 | 59 | } else { |
60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
61 | + } |
|
61 | 62 | } |
62 | - } |
|
63 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
63 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
64 | 64 | if (isset($flt['source'])) { |
65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
66 | + } |
|
66 | 67 | } |
67 | - } |
|
68 | 68 | } |
69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
70 | - if ($filter['airlines'][0] != '') { |
|
70 | + if ($filter['airlines'][0] != '') { |
|
71 | 71 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
72 | - } |
|
72 | + } |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
76 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
76 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
77 | 77 | } |
78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
80 | 80 | } |
81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
82 | + $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
83 | 83 | } |
84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
85 | - $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
85 | + $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
86 | 86 | } |
87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
88 | 88 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
89 | 89 | } |
90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
91 | - $filter_query_date = ''; |
|
91 | + $filter_query_date = ''; |
|
92 | 92 | |
93 | - if (isset($filter['year']) && $filter['year'] != '') { |
|
93 | + if (isset($filter['year']) && $filter['year'] != '') { |
|
94 | 94 | if ($globalDBdriver == 'mysql') { |
95 | - $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
95 | + $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
96 | 96 | } else { |
97 | - $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
97 | + $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
98 | + } |
|
98 | 99 | } |
99 | - } |
|
100 | - if (isset($filter['month']) && $filter['month'] != '') { |
|
100 | + if (isset($filter['month']) && $filter['month'] != '') { |
|
101 | 101 | if ($globalDBdriver == 'mysql') { |
102 | - $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
102 | + $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
103 | 103 | } else { |
104 | - $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
104 | + $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
105 | 105 | } |
106 | - } |
|
107 | - if (isset($filter['day']) && $filter['day'] != '') { |
|
106 | + } |
|
107 | + if (isset($filter['day']) && $filter['day'] != '') { |
|
108 | 108 | if ($globalDBdriver == 'mysql') { |
109 | - $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
109 | + $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
110 | 110 | } else { |
111 | - $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
111 | + $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
112 | + } |
|
112 | 113 | } |
113 | - } |
|
114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
115 | 115 | } |
116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
122 | 122 | return $filter_query; |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | 125 | // Spotter_archive |
126 | 126 | public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -152,44 +152,44 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | - /** |
|
156 | - * Gets all the spotter information based on a particular callsign |
|
157 | - * |
|
158 | - * @return Array the spotter information |
|
159 | - * |
|
160 | - */ |
|
161 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
162 | - { |
|
155 | + /** |
|
156 | + * Gets all the spotter information based on a particular callsign |
|
157 | + * |
|
158 | + * @return Array the spotter information |
|
159 | + * |
|
160 | + */ |
|
161 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
162 | + { |
|
163 | 163 | $Spotter = new Spotter($this->db); |
164 | - date_default_timezone_set('UTC'); |
|
164 | + date_default_timezone_set('UTC'); |
|
165 | 165 | |
166 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
167 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
168 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
166 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
167 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
168 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
169 | 169 | |
170 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
170 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
171 | 171 | |
172 | - return $spotter_array; |
|
173 | - } |
|
172 | + return $spotter_array; |
|
173 | + } |
|
174 | 174 | |
175 | 175 | |
176 | - /** |
|
177 | - * Gets last the spotter information based on a particular id |
|
178 | - * |
|
179 | - * @return Array the spotter information |
|
180 | - * |
|
181 | - */ |
|
182 | - public function getLastArchiveSpotterDataById($id) |
|
183 | - { |
|
184 | - $Spotter = new Spotter($this->db); |
|
185 | - date_default_timezone_set('UTC'); |
|
186 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
187 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
188 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
189 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
176 | + /** |
|
177 | + * Gets last the spotter information based on a particular id |
|
178 | + * |
|
179 | + * @return Array the spotter information |
|
180 | + * |
|
181 | + */ |
|
182 | + public function getLastArchiveSpotterDataById($id) |
|
183 | + { |
|
184 | + $Spotter = new Spotter($this->db); |
|
185 | + date_default_timezone_set('UTC'); |
|
186 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
187 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
188 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
189 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
190 | 190 | |
191 | 191 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
192 | - /* |
|
192 | + /* |
|
193 | 193 | try { |
194 | 194 | $Connection = new Connection(); |
195 | 195 | $sth = Connection->$db->prepare($query); |
@@ -199,235 +199,235 @@ discard block |
||
199 | 199 | } |
200 | 200 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
201 | 201 | */ |
202 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
203 | - |
|
204 | - return $spotter_array; |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Gets all the spotter information based on a particular id |
|
209 | - * |
|
210 | - * @return Array the spotter information |
|
211 | - * |
|
212 | - */ |
|
213 | - public function getAllArchiveSpotterDataById($id) |
|
202 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
203 | + |
|
204 | + return $spotter_array; |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * Gets all the spotter information based on a particular id |
|
209 | + * |
|
210 | + * @return Array the spotter information |
|
211 | + * |
|
212 | + */ |
|
213 | + public function getAllArchiveSpotterDataById($id) |
|
214 | 214 | { |
215 | - date_default_timezone_set('UTC'); |
|
216 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
217 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
215 | + date_default_timezone_set('UTC'); |
|
216 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
217 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
218 | 218 | |
219 | 219 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
220 | 220 | |
221 | - try { |
|
222 | - $sth = $this->db->prepare($query); |
|
223 | - $sth->execute(array(':id' => $id)); |
|
224 | - } catch(PDOException $e) { |
|
225 | - echo $e->getMessage(); |
|
226 | - die; |
|
227 | - } |
|
228 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
229 | - |
|
230 | - return $spotter_array; |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Gets coordinate & time spotter information based on a particular id |
|
235 | - * |
|
236 | - * @return Array the spotter information |
|
237 | - * |
|
238 | - */ |
|
239 | - public function getCoordArchiveSpotterDataById($id) |
|
240 | - { |
|
241 | - date_default_timezone_set('UTC'); |
|
242 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
243 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
221 | + try { |
|
222 | + $sth = $this->db->prepare($query); |
|
223 | + $sth->execute(array(':id' => $id)); |
|
224 | + } catch(PDOException $e) { |
|
225 | + echo $e->getMessage(); |
|
226 | + die; |
|
227 | + } |
|
228 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
229 | + |
|
230 | + return $spotter_array; |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Gets coordinate & time spotter information based on a particular id |
|
235 | + * |
|
236 | + * @return Array the spotter information |
|
237 | + * |
|
238 | + */ |
|
239 | + public function getCoordArchiveSpotterDataById($id) |
|
240 | + { |
|
241 | + date_default_timezone_set('UTC'); |
|
242 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
243 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
244 | 244 | |
245 | 245 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
246 | 246 | |
247 | - try { |
|
248 | - $sth = $this->db->prepare($query); |
|
249 | - $sth->execute(array(':id' => $id)); |
|
250 | - } catch(PDOException $e) { |
|
251 | - echo $e->getMessage(); |
|
252 | - die; |
|
253 | - } |
|
254 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
247 | + try { |
|
248 | + $sth = $this->db->prepare($query); |
|
249 | + $sth->execute(array(':id' => $id)); |
|
250 | + } catch(PDOException $e) { |
|
251 | + echo $e->getMessage(); |
|
252 | + die; |
|
253 | + } |
|
254 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
255 | 255 | |
256 | - return $spotter_array; |
|
257 | - } |
|
256 | + return $spotter_array; |
|
257 | + } |
|
258 | 258 | |
259 | 259 | |
260 | - /** |
|
261 | - * Gets altitude information based on a particular callsign |
|
262 | - * |
|
263 | - * @return Array the spotter information |
|
264 | - * |
|
265 | - */ |
|
266 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
267 | - { |
|
260 | + /** |
|
261 | + * Gets altitude information based on a particular callsign |
|
262 | + * |
|
263 | + * @return Array the spotter information |
|
264 | + * |
|
265 | + */ |
|
266 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
267 | + { |
|
268 | 268 | |
269 | - date_default_timezone_set('UTC'); |
|
269 | + date_default_timezone_set('UTC'); |
|
270 | 270 | |
271 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
272 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
271 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
272 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
273 | 273 | |
274 | - try { |
|
275 | - $sth = $this->db->prepare($query); |
|
276 | - $sth->execute(array(':ident' => $ident)); |
|
277 | - } catch(PDOException $e) { |
|
278 | - echo $e->getMessage(); |
|
279 | - die; |
|
280 | - } |
|
281 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
274 | + try { |
|
275 | + $sth = $this->db->prepare($query); |
|
276 | + $sth->execute(array(':ident' => $ident)); |
|
277 | + } catch(PDOException $e) { |
|
278 | + echo $e->getMessage(); |
|
279 | + die; |
|
280 | + } |
|
281 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
282 | 282 | |
283 | - return $spotter_array; |
|
284 | - } |
|
283 | + return $spotter_array; |
|
284 | + } |
|
285 | 285 | |
286 | - /** |
|
287 | - * Gets altitude information based on a particular id |
|
288 | - * |
|
289 | - * @return Array the spotter information |
|
290 | - * |
|
291 | - */ |
|
292 | - public function getAltitudeArchiveSpotterDataById($id) |
|
293 | - { |
|
286 | + /** |
|
287 | + * Gets altitude information based on a particular id |
|
288 | + * |
|
289 | + * @return Array the spotter information |
|
290 | + * |
|
291 | + */ |
|
292 | + public function getAltitudeArchiveSpotterDataById($id) |
|
293 | + { |
|
294 | 294 | |
295 | - date_default_timezone_set('UTC'); |
|
295 | + date_default_timezone_set('UTC'); |
|
296 | 296 | |
297 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
298 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
297 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
298 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
299 | 299 | |
300 | - try { |
|
301 | - $sth = $this->db->prepare($query); |
|
302 | - $sth->execute(array(':id' => $id)); |
|
303 | - } catch(PDOException $e) { |
|
304 | - echo $e->getMessage(); |
|
305 | - die; |
|
306 | - } |
|
307 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
300 | + try { |
|
301 | + $sth = $this->db->prepare($query); |
|
302 | + $sth->execute(array(':id' => $id)); |
|
303 | + } catch(PDOException $e) { |
|
304 | + echo $e->getMessage(); |
|
305 | + die; |
|
306 | + } |
|
307 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
308 | 308 | |
309 | - return $spotter_array; |
|
310 | - } |
|
309 | + return $spotter_array; |
|
310 | + } |
|
311 | 311 | |
312 | - /** |
|
313 | - * Gets altitude & speed information based on a particular id |
|
314 | - * |
|
315 | - * @return Array the spotter information |
|
316 | - * |
|
317 | - */ |
|
318 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
319 | - { |
|
312 | + /** |
|
313 | + * Gets altitude & speed information based on a particular id |
|
314 | + * |
|
315 | + * @return Array the spotter information |
|
316 | + * |
|
317 | + */ |
|
318 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
319 | + { |
|
320 | 320 | |
321 | - date_default_timezone_set('UTC'); |
|
321 | + date_default_timezone_set('UTC'); |
|
322 | 322 | |
323 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
324 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
323 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
324 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
325 | 325 | |
326 | - try { |
|
327 | - $sth = $this->db->prepare($query); |
|
328 | - $sth->execute(array(':id' => $id)); |
|
329 | - } catch(PDOException $e) { |
|
330 | - echo $e->getMessage(); |
|
331 | - die; |
|
332 | - } |
|
333 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
326 | + try { |
|
327 | + $sth = $this->db->prepare($query); |
|
328 | + $sth->execute(array(':id' => $id)); |
|
329 | + } catch(PDOException $e) { |
|
330 | + echo $e->getMessage(); |
|
331 | + die; |
|
332 | + } |
|
333 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
334 | 334 | |
335 | - return $spotter_array; |
|
336 | - } |
|
335 | + return $spotter_array; |
|
336 | + } |
|
337 | 337 | |
338 | 338 | |
339 | - /** |
|
340 | - * Gets altitude information based on a particular callsign |
|
341 | - * |
|
342 | - * @return Array the spotter information |
|
343 | - * |
|
344 | - */ |
|
345 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
346 | - { |
|
339 | + /** |
|
340 | + * Gets altitude information based on a particular callsign |
|
341 | + * |
|
342 | + * @return Array the spotter information |
|
343 | + * |
|
344 | + */ |
|
345 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
346 | + { |
|
347 | 347 | |
348 | - date_default_timezone_set('UTC'); |
|
348 | + date_default_timezone_set('UTC'); |
|
349 | 349 | |
350 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
351 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
350 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
351 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
352 | 352 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
353 | 353 | |
354 | - try { |
|
355 | - $sth = $this->db->prepare($query); |
|
356 | - $sth->execute(array(':ident' => $ident)); |
|
357 | - } catch(PDOException $e) { |
|
358 | - echo $e->getMessage(); |
|
359 | - die; |
|
360 | - } |
|
361 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
354 | + try { |
|
355 | + $sth = $this->db->prepare($query); |
|
356 | + $sth->execute(array(':ident' => $ident)); |
|
357 | + } catch(PDOException $e) { |
|
358 | + echo $e->getMessage(); |
|
359 | + die; |
|
360 | + } |
|
361 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
362 | 362 | |
363 | - return $spotter_array; |
|
364 | - } |
|
363 | + return $spotter_array; |
|
364 | + } |
|
365 | 365 | |
366 | 366 | |
367 | 367 | |
368 | - /** |
|
369 | - * Gets all the archive spotter information |
|
370 | - * |
|
371 | - * @return Array the spotter information |
|
372 | - * |
|
373 | - */ |
|
374 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
375 | - { |
|
376 | - $Spotter = new Spotter($this->db); |
|
377 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
378 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
368 | + /** |
|
369 | + * Gets all the archive spotter information |
|
370 | + * |
|
371 | + * @return Array the spotter information |
|
372 | + * |
|
373 | + */ |
|
374 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
375 | + { |
|
376 | + $Spotter = new Spotter($this->db); |
|
377 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
378 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
379 | 379 | |
380 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
380 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
381 | 381 | |
382 | - return $spotter_array; |
|
383 | - } |
|
382 | + return $spotter_array; |
|
383 | + } |
|
384 | 384 | |
385 | - public function deleteSpotterArchiveTrackData() |
|
386 | - { |
|
385 | + public function deleteSpotterArchiveTrackData() |
|
386 | + { |
|
387 | 387 | global $globalArchiveKeepTrackMonths, $globalDBdriver; |
388 | 388 | if ($globalDBdriver == 'mysql') { |
389 | 389 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
390 | 390 | } else { |
391 | 391 | $query = "DELETE FROM spotter_archive WHERE spotter_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH'"; |
392 | 392 | } |
393 | - try { |
|
394 | - $sth = $this->db->prepare($query); |
|
395 | - $sth->execute(); |
|
396 | - } catch(PDOException $e) { |
|
397 | - echo $e->getMessage(); |
|
398 | - die; |
|
399 | - } |
|
393 | + try { |
|
394 | + $sth = $this->db->prepare($query); |
|
395 | + $sth->execute(); |
|
396 | + } catch(PDOException $e) { |
|
397 | + echo $e->getMessage(); |
|
398 | + die; |
|
399 | + } |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
403 | - * Gets Minimal Live Spotter data |
|
404 | - * |
|
405 | - * @return Array the spotter information |
|
406 | - * |
|
407 | - */ |
|
408 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
409 | - { |
|
410 | - global $globalDBdriver, $globalLiveInterval; |
|
411 | - date_default_timezone_set('UTC'); |
|
412 | - |
|
413 | - $filter_query = ''; |
|
414 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
415 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
416 | - } |
|
417 | - // Use spotter_output also ? |
|
418 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
419 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
420 | - } |
|
421 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
422 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
423 | - } |
|
424 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
425 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
426 | - } |
|
427 | - |
|
428 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
429 | - if ($globalDBdriver == 'mysql') { |
|
430 | - /* |
|
403 | + * Gets Minimal Live Spotter data |
|
404 | + * |
|
405 | + * @return Array the spotter information |
|
406 | + * |
|
407 | + */ |
|
408 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
409 | + { |
|
410 | + global $globalDBdriver, $globalLiveInterval; |
|
411 | + date_default_timezone_set('UTC'); |
|
412 | + |
|
413 | + $filter_query = ''; |
|
414 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
415 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
416 | + } |
|
417 | + // Use spotter_output also ? |
|
418 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
419 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
420 | + } |
|
421 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
422 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
423 | + } |
|
424 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
425 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
426 | + } |
|
427 | + |
|
428 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
429 | + if ($globalDBdriver == 'mysql') { |
|
430 | + /* |
|
431 | 431 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
432 | 432 | FROM spotter_archive |
433 | 433 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -446,56 +446,56 @@ discard block |
||
446 | 446 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
447 | 447 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
448 | 448 | '.$filter_query.' ORDER BY flightaware_id'; |
449 | - } else { |
|
450 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
451 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
449 | + } else { |
|
450 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
451 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
452 | 452 | FROM spotter_archive |
453 | 453 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
454 | 454 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
455 | 455 | '.$filter_query.' ORDER BY flightaware_id'; |
456 | - } |
|
457 | - //echo $query; |
|
458 | - try { |
|
459 | - $sth = $this->db->prepare($query); |
|
460 | - $sth->execute(); |
|
461 | - } catch(PDOException $e) { |
|
462 | - echo $e->getMessage(); |
|
463 | - die; |
|
464 | - } |
|
465 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
466 | - |
|
467 | - return $spotter_array; |
|
468 | - } |
|
456 | + } |
|
457 | + //echo $query; |
|
458 | + try { |
|
459 | + $sth = $this->db->prepare($query); |
|
460 | + $sth->execute(); |
|
461 | + } catch(PDOException $e) { |
|
462 | + echo $e->getMessage(); |
|
463 | + die; |
|
464 | + } |
|
465 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
466 | + |
|
467 | + return $spotter_array; |
|
468 | + } |
|
469 | 469 | |
470 | 470 | /** |
471 | - * Gets Minimal Live Spotter data |
|
472 | - * |
|
473 | - * @return Array the spotter information |
|
474 | - * |
|
475 | - */ |
|
476 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
477 | - { |
|
478 | - global $globalDBdriver, $globalLiveInterval; |
|
479 | - date_default_timezone_set('UTC'); |
|
480 | - |
|
481 | - $filter_query = ''; |
|
482 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
483 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
484 | - } |
|
485 | - // Should use spotter_output also ? |
|
486 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
487 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
488 | - } |
|
489 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
490 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
491 | - } |
|
492 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
493 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
494 | - } |
|
495 | - |
|
496 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
497 | - if ($globalDBdriver == 'mysql') { |
|
498 | - /* |
|
471 | + * Gets Minimal Live Spotter data |
|
472 | + * |
|
473 | + * @return Array the spotter information |
|
474 | + * |
|
475 | + */ |
|
476 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
477 | + { |
|
478 | + global $globalDBdriver, $globalLiveInterval; |
|
479 | + date_default_timezone_set('UTC'); |
|
480 | + |
|
481 | + $filter_query = ''; |
|
482 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
483 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
484 | + } |
|
485 | + // Should use spotter_output also ? |
|
486 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
487 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
488 | + } |
|
489 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
490 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
491 | + } |
|
492 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
493 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
494 | + } |
|
495 | + |
|
496 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
497 | + if ($globalDBdriver == 'mysql') { |
|
498 | + /* |
|
499 | 499 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
500 | 500 | FROM spotter_archive |
501 | 501 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -506,95 +506,95 @@ discard block |
||
506 | 506 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
507 | 507 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
508 | 508 | |
509 | - } else { |
|
510 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
511 | - /* |
|
509 | + } else { |
|
510 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
511 | + /* |
|
512 | 512 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
513 | 513 | FROM spotter_archive_output |
514 | 514 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
515 | 515 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
516 | 516 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
517 | 517 | */ |
518 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
518 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
519 | 519 | FROM spotter_archive_output |
520 | 520 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
521 | 521 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
522 | 522 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
523 | 523 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
524 | 524 | |
525 | - } |
|
526 | - //echo $query; |
|
527 | - try { |
|
528 | - $sth = $this->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - echo $e->getMessage(); |
|
532 | - die; |
|
533 | - } |
|
534 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
535 | - |
|
536 | - return $spotter_array; |
|
537 | - } |
|
525 | + } |
|
526 | + //echo $query; |
|
527 | + try { |
|
528 | + $sth = $this->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + echo $e->getMessage(); |
|
532 | + die; |
|
533 | + } |
|
534 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
535 | + |
|
536 | + return $spotter_array; |
|
537 | + } |
|
538 | 538 | |
539 | 539 | /** |
540 | - * Gets count Live Spotter data |
|
541 | - * |
|
542 | - * @return Array the spotter information |
|
543 | - * |
|
544 | - */ |
|
545 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
546 | - { |
|
547 | - global $globalDBdriver, $globalLiveInterval; |
|
548 | - date_default_timezone_set('UTC'); |
|
549 | - |
|
550 | - $filter_query = ''; |
|
551 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
552 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
553 | - } |
|
554 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
555 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
556 | - } |
|
557 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
558 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
559 | - } |
|
560 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
561 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
562 | - } |
|
563 | - |
|
564 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
565 | - if ($globalDBdriver == 'mysql') { |
|
540 | + * Gets count Live Spotter data |
|
541 | + * |
|
542 | + * @return Array the spotter information |
|
543 | + * |
|
544 | + */ |
|
545 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
546 | + { |
|
547 | + global $globalDBdriver, $globalLiveInterval; |
|
548 | + date_default_timezone_set('UTC'); |
|
549 | + |
|
550 | + $filter_query = ''; |
|
551 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
552 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
553 | + } |
|
554 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
555 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
556 | + } |
|
557 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
558 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
559 | + } |
|
560 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
561 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
562 | + } |
|
563 | + |
|
564 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
565 | + if ($globalDBdriver == 'mysql') { |
|
566 | 566 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
567 | 567 | FROM spotter_archive l |
568 | 568 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
569 | - } else { |
|
569 | + } else { |
|
570 | 570 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
571 | - } |
|
572 | - //echo $query; |
|
573 | - try { |
|
574 | - $sth = $this->db->prepare($query); |
|
575 | - $sth->execute(); |
|
576 | - } catch(PDOException $e) { |
|
577 | - echo $e->getMessage(); |
|
578 | - die; |
|
579 | - } |
|
571 | + } |
|
572 | + //echo $query; |
|
573 | + try { |
|
574 | + $sth = $this->db->prepare($query); |
|
575 | + $sth->execute(); |
|
576 | + } catch(PDOException $e) { |
|
577 | + echo $e->getMessage(); |
|
578 | + die; |
|
579 | + } |
|
580 | 580 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
581 | 581 | $sth->closeCursor(); |
582 | - return $result['nb']; |
|
582 | + return $result['nb']; |
|
583 | 583 | |
584 | - } |
|
584 | + } |
|
585 | 585 | |
586 | 586 | |
587 | 587 | |
588 | 588 | // Spotter_Archive_output |
589 | 589 | |
590 | - /** |
|
591 | - * Gets all the spotter information |
|
592 | - * |
|
593 | - * @return Array the spotter information |
|
594 | - * |
|
595 | - */ |
|
596 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
597 | - { |
|
590 | + /** |
|
591 | + * Gets all the spotter information |
|
592 | + * |
|
593 | + * @return Array the spotter information |
|
594 | + * |
|
595 | + */ |
|
596 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
597 | + { |
|
598 | 598 | global $globalTimezone, $globalDBdriver; |
599 | 599 | require_once(dirname(__FILE__).'/class.Translation.php'); |
600 | 600 | $Translation = new Translation(); |
@@ -608,159 +608,159 @@ discard block |
||
608 | 608 | $filter_query = $this->getFilter($filters); |
609 | 609 | if ($q != "") |
610 | 610 | { |
611 | - if (!is_string($q)) |
|
612 | - { |
|
611 | + if (!is_string($q)) |
|
612 | + { |
|
613 | 613 | return false; |
614 | - } else { |
|
614 | + } else { |
|
615 | 615 | |
616 | 616 | $q_array = explode(" ", $q); |
617 | 617 | |
618 | 618 | foreach ($q_array as $q_item){ |
619 | - $additional_query .= " AND ("; |
|
620 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
621 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
622 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
623 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
624 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
625 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
626 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
627 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
628 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
629 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
630 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
631 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
632 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
633 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
634 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
635 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
636 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
637 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
638 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
639 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
640 | - $translate = $Translation->ident2icao($q_item); |
|
641 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
642 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
643 | - $additional_query .= ")"; |
|
644 | - } |
|
645 | - } |
|
619 | + $additional_query .= " AND ("; |
|
620 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
621 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
622 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
623 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
624 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
625 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
626 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
627 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
628 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
629 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
630 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
631 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
632 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
633 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
634 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
635 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
636 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
637 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
638 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
639 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
640 | + $translate = $Translation->ident2icao($q_item); |
|
641 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
642 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
643 | + $additional_query .= ")"; |
|
644 | + } |
|
645 | + } |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | if ($registration != "") |
649 | 649 | { |
650 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
651 | - if (!is_string($registration)) |
|
652 | - { |
|
650 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
651 | + if (!is_string($registration)) |
|
652 | + { |
|
653 | 653 | return false; |
654 | - } else { |
|
654 | + } else { |
|
655 | 655 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
656 | - } |
|
656 | + } |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | if ($aircraft_icao != "") |
660 | 660 | { |
661 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
662 | - if (!is_string($aircraft_icao)) |
|
663 | - { |
|
661 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
662 | + if (!is_string($aircraft_icao)) |
|
663 | + { |
|
664 | 664 | return false; |
665 | - } else { |
|
665 | + } else { |
|
666 | 666 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
667 | - } |
|
667 | + } |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | if ($aircraft_manufacturer != "") |
671 | 671 | { |
672 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
673 | - if (!is_string($aircraft_manufacturer)) |
|
674 | - { |
|
672 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
673 | + if (!is_string($aircraft_manufacturer)) |
|
674 | + { |
|
675 | 675 | return false; |
676 | - } else { |
|
676 | + } else { |
|
677 | 677 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
678 | - } |
|
678 | + } |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | if ($highlights == "true") |
682 | 682 | { |
683 | - if (!is_string($highlights)) |
|
684 | - { |
|
683 | + if (!is_string($highlights)) |
|
684 | + { |
|
685 | 685 | return false; |
686 | - } else { |
|
686 | + } else { |
|
687 | 687 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
688 | - } |
|
688 | + } |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | if ($airline_icao != "") |
692 | 692 | { |
693 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
694 | - if (!is_string($airline_icao)) |
|
695 | - { |
|
693 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
694 | + if (!is_string($airline_icao)) |
|
695 | + { |
|
696 | 696 | return false; |
697 | - } else { |
|
697 | + } else { |
|
698 | 698 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
699 | - } |
|
699 | + } |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | if ($airline_country != "") |
703 | 703 | { |
704 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
705 | - if (!is_string($airline_country)) |
|
706 | - { |
|
704 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
705 | + if (!is_string($airline_country)) |
|
706 | + { |
|
707 | 707 | return false; |
708 | - } else { |
|
708 | + } else { |
|
709 | 709 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
710 | - } |
|
710 | + } |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | if ($airline_type != "") |
714 | 714 | { |
715 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
716 | - if (!is_string($airline_type)) |
|
717 | - { |
|
715 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
716 | + if (!is_string($airline_type)) |
|
717 | + { |
|
718 | 718 | return false; |
719 | - } else { |
|
719 | + } else { |
|
720 | 720 | if ($airline_type == "passenger") |
721 | 721 | { |
722 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
722 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
723 | 723 | } |
724 | 724 | if ($airline_type == "cargo") |
725 | 725 | { |
726 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
726 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
727 | 727 | } |
728 | 728 | if ($airline_type == "military") |
729 | 729 | { |
730 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
730 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
731 | + } |
|
731 | 732 | } |
732 | - } |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | if ($airport != "") |
736 | 736 | { |
737 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
738 | - if (!is_string($airport)) |
|
739 | - { |
|
737 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
738 | + if (!is_string($airport)) |
|
739 | + { |
|
740 | 740 | return false; |
741 | - } else { |
|
741 | + } else { |
|
742 | 742 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
743 | - } |
|
743 | + } |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | if ($airport_country != "") |
747 | 747 | { |
748 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
749 | - if (!is_string($airport_country)) |
|
750 | - { |
|
748 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
749 | + if (!is_string($airport_country)) |
|
750 | + { |
|
751 | 751 | return false; |
752 | - } else { |
|
752 | + } else { |
|
753 | 753 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
754 | - } |
|
754 | + } |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | if ($callsign != "") |
758 | 758 | { |
759 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
760 | - if (!is_string($callsign)) |
|
761 | - { |
|
759 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
760 | + if (!is_string($callsign)) |
|
761 | + { |
|
762 | 762 | return false; |
763 | - } else { |
|
763 | + } else { |
|
764 | 764 | $translate = $Translation->ident2icao($callsign); |
765 | 765 | if ($translate != $callsign) { |
766 | 766 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -768,99 +768,99 @@ discard block |
||
768 | 768 | } else { |
769 | 769 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
770 | 770 | } |
771 | - } |
|
771 | + } |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | if ($owner != "") |
775 | 775 | { |
776 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
777 | - if (!is_string($owner)) |
|
778 | - { |
|
776 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
777 | + if (!is_string($owner)) |
|
778 | + { |
|
779 | 779 | return false; |
780 | - } else { |
|
780 | + } else { |
|
781 | 781 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
782 | - } |
|
782 | + } |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | if ($pilot_name != "") |
786 | 786 | { |
787 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
788 | - if (!is_string($pilot_name)) |
|
789 | - { |
|
787 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
788 | + if (!is_string($pilot_name)) |
|
789 | + { |
|
790 | 790 | return false; |
791 | - } else { |
|
791 | + } else { |
|
792 | 792 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
793 | - } |
|
793 | + } |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | if ($pilot_id != "") |
797 | 797 | { |
798 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
799 | - if (!is_string($pilot_id)) |
|
800 | - { |
|
798 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
799 | + if (!is_string($pilot_id)) |
|
800 | + { |
|
801 | 801 | return false; |
802 | - } else { |
|
802 | + } else { |
|
803 | 803 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
804 | - } |
|
804 | + } |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | if ($departure_airport_route != "") |
808 | 808 | { |
809 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
810 | - if (!is_string($departure_airport_route)) |
|
811 | - { |
|
809 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
810 | + if (!is_string($departure_airport_route)) |
|
811 | + { |
|
812 | 812 | return false; |
813 | - } else { |
|
813 | + } else { |
|
814 | 814 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
815 | - } |
|
815 | + } |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | if ($arrival_airport_route != "") |
819 | 819 | { |
820 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
821 | - if (!is_string($arrival_airport_route)) |
|
822 | - { |
|
820 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
821 | + if (!is_string($arrival_airport_route)) |
|
822 | + { |
|
823 | 823 | return false; |
824 | - } else { |
|
824 | + } else { |
|
825 | 825 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
826 | - } |
|
826 | + } |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | if ($altitude != "") |
830 | 830 | { |
831 | - $altitude_array = explode(",", $altitude); |
|
831 | + $altitude_array = explode(",", $altitude); |
|
832 | 832 | |
833 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
834 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
833 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
834 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
835 | 835 | |
836 | 836 | |
837 | - if ($altitude_array[1] != "") |
|
838 | - { |
|
837 | + if ($altitude_array[1] != "") |
|
838 | + { |
|
839 | 839 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
840 | 840 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
841 | 841 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
842 | - } else { |
|
842 | + } else { |
|
843 | 843 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
844 | 844 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
845 | - } |
|
845 | + } |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | if ($date_posted != "") |
849 | 849 | { |
850 | - $date_array = explode(",", $date_posted); |
|
850 | + $date_array = explode(",", $date_posted); |
|
851 | 851 | |
852 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
853 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
852 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
853 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
854 | 854 | |
855 | - if ($globalTimezone != '') { |
|
855 | + if ($globalTimezone != '') { |
|
856 | 856 | date_default_timezone_set($globalTimezone); |
857 | 857 | $datetime = new DateTime(); |
858 | 858 | $offset = $datetime->format('P'); |
859 | - } else $offset = '+00:00'; |
|
859 | + } else $offset = '+00:00'; |
|
860 | 860 | |
861 | 861 | |
862 | - if ($date_array[1] != "") |
|
863 | - { |
|
862 | + if ($date_array[1] != "") |
|
863 | + { |
|
864 | 864 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
865 | 865 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
866 | 866 | if ($globalDBdriver == 'mysql') { |
@@ -868,28 +868,28 @@ discard block |
||
868 | 868 | } else { |
869 | 869 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
870 | 870 | } |
871 | - } else { |
|
871 | + } else { |
|
872 | 872 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
873 | - if ($globalDBdriver == 'mysql') { |
|
873 | + if ($globalDBdriver == 'mysql') { |
|
874 | 874 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
875 | 875 | } else { |
876 | 876 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
877 | 877 | } |
878 | - } |
|
878 | + } |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | if ($limit != "") |
882 | 882 | { |
883 | - $limit_array = explode(",", $limit); |
|
883 | + $limit_array = explode(",", $limit); |
|
884 | 884 | |
885 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
886 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
885 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
886 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
887 | 887 | |
888 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
889 | - { |
|
888 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
889 | + { |
|
890 | 890 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
891 | 891 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
892 | - } |
|
892 | + } |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | |
@@ -920,33 +920,33 @@ discard block |
||
920 | 920 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
921 | 921 | |
922 | 922 | return $spotter_array; |
923 | - } |
|
923 | + } |
|
924 | 924 | |
925 | - public function deleteSpotterArchiveData() |
|
926 | - { |
|
925 | + public function deleteSpotterArchiveData() |
|
926 | + { |
|
927 | 927 | global $globalArchiveKeepMonths, $globalDBdriver; |
928 | - date_default_timezone_set('UTC'); |
|
929 | - if ($globalDBdriver == 'mysql') { |
|
928 | + date_default_timezone_set('UTC'); |
|
929 | + if ($globalDBdriver == 'mysql') { |
|
930 | 930 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
931 | 931 | } else { |
932 | 932 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
933 | 933 | } |
934 | - try { |
|
935 | - $sth = $this->db->prepare($query); |
|
936 | - $sth->execute(); |
|
937 | - } catch(PDOException $e) { |
|
938 | - return "error"; |
|
939 | - } |
|
934 | + try { |
|
935 | + $sth = $this->db->prepare($query); |
|
936 | + $sth->execute(); |
|
937 | + } catch(PDOException $e) { |
|
938 | + return "error"; |
|
939 | + } |
|
940 | 940 | } |
941 | 941 | |
942 | - /** |
|
943 | - * Gets all the spotter information based on the callsign |
|
944 | - * |
|
945 | - * @return Array the spotter information |
|
946 | - * |
|
947 | - */ |
|
948 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
949 | - { |
|
942 | + /** |
|
943 | + * Gets all the spotter information based on the callsign |
|
944 | + * |
|
945 | + * @return Array the spotter information |
|
946 | + * |
|
947 | + */ |
|
948 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
949 | + { |
|
950 | 950 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
951 | 951 | |
952 | 952 | date_default_timezone_set('UTC'); |
@@ -958,35 +958,35 @@ discard block |
||
958 | 958 | |
959 | 959 | if ($ident != "") |
960 | 960 | { |
961 | - if (!is_string($ident)) |
|
962 | - { |
|
961 | + if (!is_string($ident)) |
|
962 | + { |
|
963 | 963 | return false; |
964 | - } else { |
|
964 | + } else { |
|
965 | 965 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
966 | 966 | $query_values = array(':ident' => $ident); |
967 | - } |
|
967 | + } |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | if ($limit != "") |
971 | 971 | { |
972 | - $limit_array = explode(",", $limit); |
|
972 | + $limit_array = explode(",", $limit); |
|
973 | 973 | |
974 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
975 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
974 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
975 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
976 | 976 | |
977 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
978 | - { |
|
977 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
978 | + { |
|
979 | 979 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
980 | 980 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
981 | - } |
|
981 | + } |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | if ($sort != "") |
985 | 985 | { |
986 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
987 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
986 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
987 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
988 | 988 | } else { |
989 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
989 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -994,17 +994,17 @@ discard block |
||
994 | 994 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
995 | 995 | |
996 | 996 | return $spotter_array; |
997 | - } |
|
997 | + } |
|
998 | 998 | |
999 | 999 | |
1000 | - /** |
|
1001 | - * Gets all the spotter information based on the owner |
|
1002 | - * |
|
1003 | - * @return Array the spotter information |
|
1004 | - * |
|
1005 | - */ |
|
1006 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
1007 | - { |
|
1000 | + /** |
|
1001 | + * Gets all the spotter information based on the owner |
|
1002 | + * |
|
1003 | + * @return Array the spotter information |
|
1004 | + * |
|
1005 | + */ |
|
1006 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
1007 | + { |
|
1008 | 1008 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1009 | 1009 | |
1010 | 1010 | date_default_timezone_set('UTC'); |
@@ -1017,35 +1017,35 @@ discard block |
||
1017 | 1017 | |
1018 | 1018 | if ($owner != "") |
1019 | 1019 | { |
1020 | - if (!is_string($owner)) |
|
1021 | - { |
|
1020 | + if (!is_string($owner)) |
|
1021 | + { |
|
1022 | 1022 | return false; |
1023 | - } else { |
|
1023 | + } else { |
|
1024 | 1024 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
1025 | 1025 | $query_values = array(':owner' => $owner); |
1026 | - } |
|
1026 | + } |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | if ($limit != "") |
1030 | 1030 | { |
1031 | - $limit_array = explode(",", $limit); |
|
1031 | + $limit_array = explode(",", $limit); |
|
1032 | 1032 | |
1033 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1034 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1033 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1034 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1035 | 1035 | |
1036 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1037 | - { |
|
1036 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1037 | + { |
|
1038 | 1038 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1039 | 1039 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1040 | - } |
|
1040 | + } |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | if ($sort != "") |
1044 | 1044 | { |
1045 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1046 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1045 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1046 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1047 | 1047 | } else { |
1048 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1048 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1053,16 +1053,16 @@ discard block |
||
1053 | 1053 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1054 | 1054 | |
1055 | 1055 | return $spotter_array; |
1056 | - } |
|
1057 | - |
|
1058 | - /** |
|
1059 | - * Gets all the spotter information based on the pilot |
|
1060 | - * |
|
1061 | - * @return Array the spotter information |
|
1062 | - * |
|
1063 | - */ |
|
1064 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1065 | - { |
|
1056 | + } |
|
1057 | + |
|
1058 | + /** |
|
1059 | + * Gets all the spotter information based on the pilot |
|
1060 | + * |
|
1061 | + * @return Array the spotter information |
|
1062 | + * |
|
1063 | + */ |
|
1064 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1065 | + { |
|
1066 | 1066 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1067 | 1067 | |
1068 | 1068 | date_default_timezone_set('UTC'); |
@@ -1081,24 +1081,24 @@ discard block |
||
1081 | 1081 | |
1082 | 1082 | if ($limit != "") |
1083 | 1083 | { |
1084 | - $limit_array = explode(",", $limit); |
|
1084 | + $limit_array = explode(",", $limit); |
|
1085 | 1085 | |
1086 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1087 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1086 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1087 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1088 | 1088 | |
1089 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1090 | - { |
|
1089 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1090 | + { |
|
1091 | 1091 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1092 | 1092 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1093 | - } |
|
1093 | + } |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | if ($sort != "") |
1097 | 1097 | { |
1098 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1099 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1098 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1099 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1100 | 1100 | } else { |
1101 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1101 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1106,16 +1106,16 @@ discard block |
||
1106 | 1106 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1107 | 1107 | |
1108 | 1108 | return $spotter_array; |
1109 | - } |
|
1110 | - |
|
1111 | - /** |
|
1112 | - * Gets all number of flight over countries |
|
1113 | - * |
|
1114 | - * @return Array the airline country list |
|
1115 | - * |
|
1116 | - */ |
|
1117 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1118 | - { |
|
1109 | + } |
|
1110 | + |
|
1111 | + /** |
|
1112 | + * Gets all number of flight over countries |
|
1113 | + * |
|
1114 | + * @return Array the airline country list |
|
1115 | + * |
|
1116 | + */ |
|
1117 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1118 | + { |
|
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | /* |
1121 | 1121 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1125,14 +1125,14 @@ discard block |
||
1125 | 1125 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1126 | 1126 | FROM countries c, spotter_archive s |
1127 | 1127 | WHERE c.iso2 = s.over_country "; |
1128 | - if ($olderthanmonths > 0) { |
|
1129 | - if ($globalDBdriver == 'mysql') { |
|
1128 | + if ($olderthanmonths > 0) { |
|
1129 | + if ($globalDBdriver == 'mysql') { |
|
1130 | 1130 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1131 | 1131 | } else { |
1132 | 1132 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1133 | 1133 | } |
1134 | 1134 | } |
1135 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1135 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1136 | 1136 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1137 | 1137 | if ($limit) $query .= " LIMIT 0,10"; |
1138 | 1138 | |
@@ -1145,23 +1145,23 @@ discard block |
||
1145 | 1145 | |
1146 | 1146 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1147 | 1147 | { |
1148 | - $temp_array['flight_count'] = $row['nb']; |
|
1149 | - $temp_array['flight_country'] = $row['name']; |
|
1150 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1151 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1152 | - $flight_array[] = $temp_array; |
|
1148 | + $temp_array['flight_count'] = $row['nb']; |
|
1149 | + $temp_array['flight_country'] = $row['name']; |
|
1150 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1151 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1152 | + $flight_array[] = $temp_array; |
|
1153 | 1153 | } |
1154 | 1154 | return $flight_array; |
1155 | - } |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * Gets all number of flight over countries |
|
1159 | - * |
|
1160 | - * @return Array the airline country list |
|
1161 | - * |
|
1162 | - */ |
|
1163 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1164 | - { |
|
1155 | + } |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * Gets all number of flight over countries |
|
1159 | + * |
|
1160 | + * @return Array the airline country list |
|
1161 | + * |
|
1162 | + */ |
|
1163 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1164 | + { |
|
1165 | 1165 | global $globalDBdriver; |
1166 | 1166 | /* |
1167 | 1167 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1171,14 +1171,14 @@ discard block |
||
1171 | 1171 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1172 | 1172 | FROM countries c, spotter_archive s, spotter_output o |
1173 | 1173 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
1174 | - if ($olderthanmonths > 0) { |
|
1175 | - if ($globalDBdriver == 'mysql') { |
|
1174 | + if ($olderthanmonths > 0) { |
|
1175 | + if ($globalDBdriver == 'mysql') { |
|
1176 | 1176 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1177 | 1177 | } else { |
1178 | 1178 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1179 | 1179 | } |
1180 | 1180 | } |
1181 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1181 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1182 | 1182 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1183 | 1183 | if ($limit) $query .= " LIMIT 0,10"; |
1184 | 1184 | |
@@ -1191,24 +1191,24 @@ discard block |
||
1191 | 1191 | |
1192 | 1192 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1193 | 1193 | { |
1194 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1195 | - $temp_array['flight_count'] = $row['nb']; |
|
1196 | - $temp_array['flight_country'] = $row['name']; |
|
1197 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1198 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1199 | - $flight_array[] = $temp_array; |
|
1194 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1195 | + $temp_array['flight_count'] = $row['nb']; |
|
1196 | + $temp_array['flight_country'] = $row['name']; |
|
1197 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1198 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1199 | + $flight_array[] = $temp_array; |
|
1200 | 1200 | } |
1201 | 1201 | return $flight_array; |
1202 | - } |
|
1203 | - |
|
1204 | - /** |
|
1205 | - * Gets last spotter information based on a particular callsign |
|
1206 | - * |
|
1207 | - * @return Array the spotter information |
|
1208 | - * |
|
1209 | - */ |
|
1210 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1211 | - { |
|
1202 | + } |
|
1203 | + |
|
1204 | + /** |
|
1205 | + * Gets last spotter information based on a particular callsign |
|
1206 | + * |
|
1207 | + * @return Array the spotter information |
|
1208 | + * |
|
1209 | + */ |
|
1210 | + public function getDateArchiveSpotterDataById($id,$date) |
|
1211 | + { |
|
1212 | 1212 | $Spotter = new Spotter($this->db); |
1213 | 1213 | date_default_timezone_set('UTC'); |
1214 | 1214 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1216,16 +1216,16 @@ discard block |
||
1216 | 1216 | $date = date('c',$date); |
1217 | 1217 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1218 | 1218 | return $spotter_array; |
1219 | - } |
|
1220 | - |
|
1221 | - /** |
|
1222 | - * Gets all the spotter information based on a particular callsign |
|
1223 | - * |
|
1224 | - * @return Array the spotter information |
|
1225 | - * |
|
1226 | - */ |
|
1227 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1228 | - { |
|
1219 | + } |
|
1220 | + |
|
1221 | + /** |
|
1222 | + * Gets all the spotter information based on a particular callsign |
|
1223 | + * |
|
1224 | + * @return Array the spotter information |
|
1225 | + * |
|
1226 | + */ |
|
1227 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1228 | + { |
|
1229 | 1229 | $Spotter = new Spotter($this->db); |
1230 | 1230 | date_default_timezone_set('UTC'); |
1231 | 1231 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1233,16 +1233,16 @@ discard block |
||
1233 | 1233 | $date = date('c',$date); |
1234 | 1234 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1235 | 1235 | return $spotter_array; |
1236 | - } |
|
1237 | - |
|
1238 | - /** |
|
1239 | - * Gets all the spotter information based on the airport |
|
1240 | - * |
|
1241 | - * @return Array the spotter information |
|
1242 | - * |
|
1243 | - */ |
|
1244 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1245 | - { |
|
1236 | + } |
|
1237 | + |
|
1238 | + /** |
|
1239 | + * Gets all the spotter information based on the airport |
|
1240 | + * |
|
1241 | + * @return Array the spotter information |
|
1242 | + * |
|
1243 | + */ |
|
1244 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1245 | + { |
|
1246 | 1246 | global $global_query; |
1247 | 1247 | $Spotter = new Spotter(); |
1248 | 1248 | date_default_timezone_set('UTC'); |
@@ -1253,35 +1253,35 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | if ($airport != "") |
1255 | 1255 | { |
1256 | - if (!is_string($airport)) |
|
1257 | - { |
|
1256 | + if (!is_string($airport)) |
|
1257 | + { |
|
1258 | 1258 | return false; |
1259 | - } else { |
|
1259 | + } else { |
|
1260 | 1260 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
1261 | 1261 | $query_values = array(':airport' => $airport); |
1262 | - } |
|
1262 | + } |
|
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | if ($limit != "") |
1266 | 1266 | { |
1267 | - $limit_array = explode(",", $limit); |
|
1267 | + $limit_array = explode(",", $limit); |
|
1268 | 1268 | |
1269 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1270 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1269 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1270 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1271 | 1271 | |
1272 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1273 | - { |
|
1272 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1273 | + { |
|
1274 | 1274 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1275 | 1275 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1276 | - } |
|
1276 | + } |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | if ($sort != "") |
1280 | 1280 | { |
1281 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1282 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1281 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1282 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1283 | 1283 | } else { |
1284 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1284 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1289,6 +1289,6 @@ discard block |
||
1289 | 1289 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1290 | 1290 | |
1291 | 1291 | return $spotter_array; |
1292 | - } |
|
1292 | + } |
|
1293 | 1293 | } |
1294 | 1294 | ?> |
1295 | 1295 | \ No newline at end of file |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * Gets all the spotter information based on the latest data entry |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
131 | + * Gets all the spotter information based on the latest data entry |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
137 | 137 | { |
138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * Gets Minimal Live Spotter data |
|
179 | - * |
|
180 | - * @return Array the spotter information |
|
181 | - * |
|
182 | - */ |
|
178 | + * Gets Minimal Live Spotter data |
|
179 | + * |
|
180 | + * @return Array the spotter information |
|
181 | + * |
|
182 | + */ |
|
183 | 183 | public function getMinLiveSpotterData($filter = array()) |
184 | 184 | { |
185 | 185 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
219 | - * Gets Minimal Live Spotter data since xx seconds |
|
220 | - * |
|
221 | - * @return Array the spotter information |
|
222 | - * |
|
223 | - */ |
|
219 | + * Gets Minimal Live Spotter data since xx seconds |
|
220 | + * |
|
221 | + * @return Array the spotter information |
|
222 | + * |
|
223 | + */ |
|
224 | 224 | public function getMinLastLiveSpotterData($filter = array()) |
225 | 225 | { |
226 | 226 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
251 | 251 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
252 | 252 | } |
253 | - } else { |
|
253 | + } else { |
|
254 | 254 | if (isset($globalArchive) && $globalArchive === TRUE) { |
255 | 255 | /* |
256 | 256 | $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
275 | 275 | } |
276 | 276 | } |
277 | - try { |
|
277 | + try { |
|
278 | 278 | $sth = $this->db->prepare($query); |
279 | 279 | $sth->execute(); |
280 | 280 | } catch(PDOException $e) { |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
289 | - * Gets number of latest data entry |
|
290 | - * |
|
291 | - * @return String number of entry |
|
292 | - * |
|
293 | - */ |
|
289 | + * Gets number of latest data entry |
|
290 | + * |
|
291 | + * @return String number of entry |
|
292 | + * |
|
293 | + */ |
|
294 | 294 | public function getLiveSpotterCount($filter = array()) |
295 | 295 | { |
296 | 296 | global $globalDBdriver, $globalLiveInterval; |
@@ -317,11 +317,11 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
320 | - * Gets all the spotter information based on the latest data entry and coord |
|
321 | - * |
|
322 | - * @return Array the spotter information |
|
323 | - * |
|
324 | - */ |
|
320 | + * Gets all the spotter information based on the latest data entry and coord |
|
321 | + * |
|
322 | + * @return Array the spotter information |
|
323 | + * |
|
324 | + */ |
|
325 | 325 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
326 | 326 | { |
327 | 327 | global $globalDBdriver, $globalLiveInterval; |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
349 | - * Gets all the spotter information based on the latest data entry and coord |
|
350 | - * |
|
351 | - * @return Array the spotter information |
|
352 | - * |
|
353 | - */ |
|
349 | + * Gets all the spotter information based on the latest data entry and coord |
|
350 | + * |
|
351 | + * @return Array the spotter information |
|
352 | + * |
|
353 | + */ |
|
354 | 354 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
355 | 355 | { |
356 | 356 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
418 | - * Gets all the spotter information based on a user's latitude and longitude |
|
419 | - * |
|
420 | - * @return Array the spotter information |
|
421 | - * |
|
422 | - */ |
|
418 | + * Gets all the spotter information based on a user's latitude and longitude |
|
419 | + * |
|
420 | + * @return Array the spotter information |
|
421 | + * |
|
422 | + */ |
|
423 | 423 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
424 | 424 | { |
425 | 425 | $Spotter = new Spotter($this->db); |
@@ -429,98 +429,98 @@ discard block |
||
429 | 429 | return false; |
430 | 430 | } |
431 | 431 | } |
432 | - if ($lng != '') |
|
433 | - { |
|
434 | - if (!is_numeric($lng)) |
|
435 | - { |
|
436 | - return false; |
|
437 | - } |
|
438 | - } |
|
439 | - |
|
440 | - if ($radius != '') |
|
441 | - { |
|
442 | - if (!is_numeric($radius)) |
|
443 | - { |
|
444 | - return false; |
|
445 | - } |
|
446 | - } |
|
432 | + if ($lng != '') |
|
433 | + { |
|
434 | + if (!is_numeric($lng)) |
|
435 | + { |
|
436 | + return false; |
|
437 | + } |
|
438 | + } |
|
439 | + |
|
440 | + if ($radius != '') |
|
441 | + { |
|
442 | + if (!is_numeric($radius)) |
|
443 | + { |
|
444 | + return false; |
|
445 | + } |
|
446 | + } |
|
447 | 447 | $additional_query = ''; |
448 | - if ($interval != '') |
|
449 | - { |
|
450 | - if (!is_string($interval)) |
|
451 | - { |
|
452 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
453 | - return false; |
|
454 | - } else { |
|
455 | - if ($interval == '1m') |
|
456 | - { |
|
457 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
458 | - } else if ($interval == '15m'){ |
|
459 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
460 | - } |
|
461 | - } |
|
462 | - } else { |
|
463 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
464 | - } |
|
465 | - |
|
466 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
448 | + if ($interval != '') |
|
449 | + { |
|
450 | + if (!is_string($interval)) |
|
451 | + { |
|
452 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
453 | + return false; |
|
454 | + } else { |
|
455 | + if ($interval == '1m') |
|
456 | + { |
|
457 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
458 | + } else if ($interval == '15m'){ |
|
459 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
460 | + } |
|
461 | + } |
|
462 | + } else { |
|
463 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
464 | + } |
|
465 | + |
|
466 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
467 | 467 | WHERE spotter_live.latitude <> '' |
468 | 468 | AND spotter_live.longitude <> '' |
469 | 469 | ".$additional_query." |
470 | 470 | HAVING distance < :radius |
471 | 471 | ORDER BY distance"; |
472 | 472 | |
473 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
473 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
474 | 474 | |
475 | - return $spotter_array; |
|
476 | - } |
|
475 | + return $spotter_array; |
|
476 | + } |
|
477 | 477 | |
478 | 478 | |
479 | - /** |
|
480 | - * Gets all the spotter information based on a particular callsign |
|
481 | - * |
|
482 | - * @return Array the spotter information |
|
483 | - * |
|
484 | - */ |
|
479 | + /** |
|
480 | + * Gets all the spotter information based on a particular callsign |
|
481 | + * |
|
482 | + * @return Array the spotter information |
|
483 | + * |
|
484 | + */ |
|
485 | 485 | public function getLastLiveSpotterDataByIdent($ident) |
486 | 486 | { |
487 | 487 | $Spotter = new Spotter($this->db); |
488 | 488 | date_default_timezone_set('UTC'); |
489 | 489 | |
490 | 490 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
491 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
491 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
492 | 492 | |
493 | 493 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
494 | 494 | |
495 | 495 | return $spotter_array; |
496 | 496 | } |
497 | 497 | |
498 | - /** |
|
499 | - * Gets all the spotter information based on a particular callsign |
|
500 | - * |
|
501 | - * @return Array the spotter information |
|
502 | - * |
|
503 | - */ |
|
498 | + /** |
|
499 | + * Gets all the spotter information based on a particular callsign |
|
500 | + * |
|
501 | + * @return Array the spotter information |
|
502 | + * |
|
503 | + */ |
|
504 | 504 | public function getDateLiveSpotterDataByIdent($ident,$date) |
505 | 505 | { |
506 | 506 | $Spotter = new Spotter($this->db); |
507 | 507 | date_default_timezone_set('UTC'); |
508 | 508 | |
509 | 509 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
510 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
510 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
511 | 511 | |
512 | - $date = date('c',$date); |
|
512 | + $date = date('c',$date); |
|
513 | 513 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
514 | 514 | |
515 | 515 | return $spotter_array; |
516 | 516 | } |
517 | 517 | |
518 | - /** |
|
519 | - * Gets last spotter information based on a particular callsign |
|
520 | - * |
|
521 | - * @return Array the spotter information |
|
522 | - * |
|
523 | - */ |
|
518 | + /** |
|
519 | + * Gets last spotter information based on a particular callsign |
|
520 | + * |
|
521 | + * @return Array the spotter information |
|
522 | + * |
|
523 | + */ |
|
524 | 524 | public function getLastLiveSpotterDataById($id) |
525 | 525 | { |
526 | 526 | $Spotter = new Spotter($this->db); |
@@ -531,12 +531,12 @@ discard block |
||
531 | 531 | return $spotter_array; |
532 | 532 | } |
533 | 533 | |
534 | - /** |
|
535 | - * Gets last spotter information based on a particular callsign |
|
536 | - * |
|
537 | - * @return Array the spotter information |
|
538 | - * |
|
539 | - */ |
|
534 | + /** |
|
535 | + * Gets last spotter information based on a particular callsign |
|
536 | + * |
|
537 | + * @return Array the spotter information |
|
538 | + * |
|
539 | + */ |
|
540 | 540 | public function getDateLiveSpotterDataById($id,$date) |
541 | 541 | { |
542 | 542 | $Spotter = new Spotter($this->db); |
@@ -549,21 +549,21 @@ discard block |
||
549 | 549 | return $spotter_array; |
550 | 550 | } |
551 | 551 | |
552 | - /** |
|
553 | - * Gets altitude information based on a particular callsign |
|
554 | - * |
|
555 | - * @return Array the spotter information |
|
556 | - * |
|
557 | - */ |
|
552 | + /** |
|
553 | + * Gets altitude information based on a particular callsign |
|
554 | + * |
|
555 | + * @return Array the spotter information |
|
556 | + * |
|
557 | + */ |
|
558 | 558 | public function getAltitudeLiveSpotterDataByIdent($ident) |
559 | 559 | { |
560 | 560 | |
561 | 561 | date_default_timezone_set('UTC'); |
562 | 562 | |
563 | 563 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
564 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
564 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
565 | 565 | |
566 | - try { |
|
566 | + try { |
|
567 | 567 | |
568 | 568 | $sth = $this->db->prepare($query); |
569 | 569 | $sth->execute(array(':ident' => $ident)); |
@@ -576,12 +576,12 @@ discard block |
||
576 | 576 | return $spotter_array; |
577 | 577 | } |
578 | 578 | |
579 | - /** |
|
580 | - * Gets all the spotter information based on a particular id |
|
581 | - * |
|
582 | - * @return Array the spotter information |
|
583 | - * |
|
584 | - */ |
|
579 | + /** |
|
580 | + * Gets all the spotter information based on a particular id |
|
581 | + * |
|
582 | + * @return Array the spotter information |
|
583 | + * |
|
584 | + */ |
|
585 | 585 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
586 | 586 | { |
587 | 587 | global $globalDBdriver, $globalLiveInterval; |
@@ -609,18 +609,18 @@ discard block |
||
609 | 609 | return $spotter_array; |
610 | 610 | } |
611 | 611 | |
612 | - /** |
|
613 | - * Gets all the spotter information based on a particular ident |
|
614 | - * |
|
615 | - * @return Array the spotter information |
|
616 | - * |
|
617 | - */ |
|
612 | + /** |
|
613 | + * Gets all the spotter information based on a particular ident |
|
614 | + * |
|
615 | + * @return Array the spotter information |
|
616 | + * |
|
617 | + */ |
|
618 | 618 | public function getAllLiveSpotterDataByIdent($ident) |
619 | 619 | { |
620 | 620 | date_default_timezone_set('UTC'); |
621 | 621 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
622 | 622 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
623 | - try { |
|
623 | + try { |
|
624 | 624 | |
625 | 625 | $sth = $this->db->prepare($query); |
626 | 626 | $sth->execute(array(':ident' => $ident)); |
@@ -634,23 +634,23 @@ discard block |
||
634 | 634 | |
635 | 635 | |
636 | 636 | /** |
637 | - * Deletes all info in the table |
|
638 | - * |
|
639 | - * @return String success or false |
|
640 | - * |
|
641 | - */ |
|
637 | + * Deletes all info in the table |
|
638 | + * |
|
639 | + * @return String success or false |
|
640 | + * |
|
641 | + */ |
|
642 | 642 | public function deleteLiveSpotterData() |
643 | 643 | { |
644 | 644 | global $globalDBdriver; |
645 | 645 | if ($globalDBdriver == 'mysql') { |
646 | 646 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
647 | 647 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
648 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
648 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
649 | 649 | } else { |
650 | 650 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
651 | 651 | } |
652 | 652 | |
653 | - try { |
|
653 | + try { |
|
654 | 654 | |
655 | 655 | $sth = $this->db->prepare($query); |
656 | 656 | $sth->execute(); |
@@ -662,18 +662,18 @@ discard block |
||
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
665 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
666 | - * |
|
667 | - * @return String success or false |
|
668 | - * |
|
669 | - */ |
|
665 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
666 | + * |
|
667 | + * @return String success or false |
|
668 | + * |
|
669 | + */ |
|
670 | 670 | public function deleteLiveSpotterDataNotUpdated() |
671 | 671 | { |
672 | 672 | global $globalDBdriver, $globalDebug; |
673 | 673 | if ($globalDBdriver == 'mysql') { |
674 | 674 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
675 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
676 | - try { |
|
675 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
676 | + try { |
|
677 | 677 | |
678 | 678 | $sth = $this->db->prepare($query); |
679 | 679 | $sth->execute(); |
@@ -681,8 +681,8 @@ discard block |
||
681 | 681 | return "error"; |
682 | 682 | } |
683 | 683 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
684 | - $i = 0; |
|
685 | - $j =0; |
|
684 | + $i = 0; |
|
685 | + $j =0; |
|
686 | 686 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
687 | 687 | foreach($all as $row) |
688 | 688 | { |
@@ -690,20 +690,20 @@ discard block |
||
690 | 690 | $j++; |
691 | 691 | if ($j == 30) { |
692 | 692 | if ($globalDebug) echo "."; |
693 | - try { |
|
693 | + try { |
|
694 | 694 | |
695 | 695 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
696 | 696 | $sth->execute(); |
697 | 697 | } catch(PDOException $e) { |
698 | 698 | return "error"; |
699 | 699 | } |
700 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
701 | - $j = 0; |
|
700 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
701 | + $j = 0; |
|
702 | 702 | } |
703 | 703 | $query_delete .= "'".$row['flightaware_id']."',"; |
704 | 704 | } |
705 | 705 | if ($i > 0) { |
706 | - try { |
|
706 | + try { |
|
707 | 707 | |
708 | 708 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
709 | 709 | $sth->execute(); |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | return "success"; |
715 | 715 | } elseif ($globalDBdriver == 'pgsql') { |
716 | 716 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
717 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
718 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
719 | - try { |
|
717 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
718 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
719 | + try { |
|
720 | 720 | |
721 | 721 | $sth = $this->db->prepare($query); |
722 | 722 | $sth->execute(); |
@@ -760,17 +760,17 @@ discard block |
||
760 | 760 | } |
761 | 761 | |
762 | 762 | /** |
763 | - * Deletes all info in the table for an ident |
|
764 | - * |
|
765 | - * @return String success or false |
|
766 | - * |
|
767 | - */ |
|
763 | + * Deletes all info in the table for an ident |
|
764 | + * |
|
765 | + * @return String success or false |
|
766 | + * |
|
767 | + */ |
|
768 | 768 | public function deleteLiveSpotterDataByIdent($ident) |
769 | 769 | { |
770 | 770 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
771 | 771 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
772 | 772 | |
773 | - try { |
|
773 | + try { |
|
774 | 774 | |
775 | 775 | $sth = $this->db->prepare($query); |
776 | 776 | $sth->execute(array(':ident' => $ident)); |
@@ -782,17 +782,17 @@ discard block |
||
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
785 | - * Deletes all info in the table for an id |
|
786 | - * |
|
787 | - * @return String success or false |
|
788 | - * |
|
789 | - */ |
|
785 | + * Deletes all info in the table for an id |
|
786 | + * |
|
787 | + * @return String success or false |
|
788 | + * |
|
789 | + */ |
|
790 | 790 | public function deleteLiveSpotterDataById($id) |
791 | 791 | { |
792 | 792 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
793 | 793 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
794 | 794 | |
795 | - try { |
|
795 | + try { |
|
796 | 796 | |
797 | 797 | $sth = $this->db->prepare($query); |
798 | 798 | $sth->execute(array(':id' => $id)); |
@@ -805,11 +805,11 @@ discard block |
||
805 | 805 | |
806 | 806 | |
807 | 807 | /** |
808 | - * Gets the aircraft ident within the last hour |
|
809 | - * |
|
810 | - * @return String the ident |
|
811 | - * |
|
812 | - */ |
|
808 | + * Gets the aircraft ident within the last hour |
|
809 | + * |
|
810 | + * @return String the ident |
|
811 | + * |
|
812 | + */ |
|
813 | 813 | public function getIdentFromLastHour($ident) |
814 | 814 | { |
815 | 815 | global $globalDBdriver, $globalTimezone; |
@@ -835,14 +835,14 @@ discard block |
||
835 | 835 | $ident_result = $row['ident']; |
836 | 836 | } |
837 | 837 | return $ident_result; |
838 | - } |
|
838 | + } |
|
839 | 839 | |
840 | 840 | /** |
841 | - * Check recent aircraft |
|
842 | - * |
|
843 | - * @return String the ident |
|
844 | - * |
|
845 | - */ |
|
841 | + * Check recent aircraft |
|
842 | + * |
|
843 | + * @return String the ident |
|
844 | + * |
|
845 | + */ |
|
846 | 846 | public function checkIdentRecent($ident) |
847 | 847 | { |
848 | 848 | global $globalDBdriver, $globalTimezone; |
@@ -868,14 +868,14 @@ discard block |
||
868 | 868 | $ident_result = $row['flightaware_id']; |
869 | 869 | } |
870 | 870 | return $ident_result; |
871 | - } |
|
871 | + } |
|
872 | 872 | |
873 | 873 | /** |
874 | - * Check recent aircraft by id |
|
875 | - * |
|
876 | - * @return String the ident |
|
877 | - * |
|
878 | - */ |
|
874 | + * Check recent aircraft by id |
|
875 | + * |
|
876 | + * @return String the ident |
|
877 | + * |
|
878 | + */ |
|
879 | 879 | public function checkIdRecent($id) |
880 | 880 | { |
881 | 881 | global $globalDBdriver, $globalTimezone; |
@@ -901,14 +901,14 @@ discard block |
||
901 | 901 | $ident_result = $row['flightaware_id']; |
902 | 902 | } |
903 | 903 | return $ident_result; |
904 | - } |
|
904 | + } |
|
905 | 905 | |
906 | 906 | /** |
907 | - * Check recent aircraft by ModeS |
|
908 | - * |
|
909 | - * @return String the ModeS |
|
910 | - * |
|
911 | - */ |
|
907 | + * Check recent aircraft by ModeS |
|
908 | + * |
|
909 | + * @return String the ModeS |
|
910 | + * |
|
911 | + */ |
|
912 | 912 | public function checkModeSRecent($modes) |
913 | 913 | { |
914 | 914 | global $globalDBdriver, $globalTimezone; |
@@ -935,19 +935,19 @@ discard block |
||
935 | 935 | $ident_result = $row['flightaware_id']; |
936 | 936 | } |
937 | 937 | return $ident_result; |
938 | - } |
|
938 | + } |
|
939 | 939 | |
940 | 940 | /** |
941 | - * Adds a new spotter data |
|
942 | - * |
|
943 | - * @param String $flightaware_id the ID from flightaware |
|
944 | - * @param String $ident the flight ident |
|
945 | - * @param String $aircraft_icao the aircraft type |
|
946 | - * @param String $departure_airport_icao the departure airport |
|
947 | - * @param String $arrival_airport_icao the arrival airport |
|
948 | - * @return String success or false |
|
949 | - * |
|
950 | - */ |
|
941 | + * Adds a new spotter data |
|
942 | + * |
|
943 | + * @param String $flightaware_id the ID from flightaware |
|
944 | + * @param String $ident the flight ident |
|
945 | + * @param String $aircraft_icao the aircraft type |
|
946 | + * @param String $departure_airport_icao the departure airport |
|
947 | + * @param String $arrival_airport_icao the arrival airport |
|
948 | + * @return String success or false |
|
949 | + * |
|
950 | + */ |
|
951 | 951 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
952 | 952 | { |
953 | 953 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1090,10 +1090,10 @@ discard block |
||
1090 | 1090 | $arrival_airport_country = ''; |
1091 | 1091 | |
1092 | 1092 | |
1093 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1094 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1095 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1096 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1093 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1094 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1095 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1096 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1097 | 1097 | |
1098 | 1098 | $query = ''; |
1099 | 1099 | if ($globalArchive) { |
@@ -1114,10 +1114,10 @@ discard block |
||
1114 | 1114 | return "error : ".$e->getMessage(); |
1115 | 1115 | } |
1116 | 1116 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1117 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1118 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1119 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1120 | - if ($globalDebug) echo $result.')'; |
|
1117 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1118 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1119 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1120 | + if ($globalDebug) echo $result.')'; |
|
1121 | 1121 | } elseif ($globalDebug && $putinarchive !== true) { |
1122 | 1122 | echo '(Not adding to archive)'; |
1123 | 1123 | } elseif ($globalDebug && $noarchive === true) { |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | print '<div class="details">'; |
79 | 79 | print '<div><span>'._("Altitude").'</span>'; |
80 | 80 | if (isset($globalGroundAltitude) && $globalGroundAltitude) { |
81 | - try { |
|
81 | + try { |
|
82 | 82 | $groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']); |
83 | - } catch(Exception $e) { |
|
84 | - } |
|
83 | + } catch(Exception $e) { |
|
84 | + } |
|
85 | 85 | } |
86 | 86 | if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
87 | 87 | print $spotter_item['altitude'].' feet (FL'.$spotter_item['altitude'].')'; |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | print round($spotter_item['altitude']*0.3048).' m (FL'.round($spotter_item['altitude']/100).')'; |
90 | 90 | } |
91 | 91 | if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*0.3048) { |
92 | - print '<br>'; |
|
93 | - print '<span>'._("Ground Altitude").'</span>'; |
|
94 | - if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
|
92 | + print '<br>'; |
|
93 | + print '<span>'._("Ground Altitude").'</span>'; |
|
94 | + if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
|
95 | 95 | print round($groundAltitude*3.28084).' feet'; |
96 | - } else { |
|
96 | + } else { |
|
97 | 97 | print round($groundAltitude).' m'; |
98 | - } |
|
99 | - print '</i>'; |
|
98 | + } |
|
99 | + print '</i>'; |
|
100 | 100 | } |
101 | 101 | print '</div>'; |
102 | 102 | print '<div><span>'._("Speed").'</span>'; |
@@ -6,12 +6,12 @@ |
||
6 | 6 | </div> |
7 | 7 | <footer class="container"> |
8 | 8 | <?php |
9 | - if (isset($sql_time)) { |
|
9 | + if (isset($sql_time)) { |
|
10 | 10 | ?> |
11 | 11 | <i><?php echo _("Page generated in").' '.round($sql_time+$page_time,2); ?>s (<?php print round($page_time,2); ?>ms PHP - <?php print round($sql_time,2); ?>ms SQL)</i> |
12 | 12 | <br /> |
13 | 13 | <?php |
14 | - } |
|
14 | + } |
|
15 | 15 | ?> |
16 | 16 | <span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) print $globalURL; ?>/about#source">Source & Credits</a></span> - <span><a href="https://www.flightairmap.fr/" target="_blank">Get source code</a></span> |
17 | 17 | </footer> |
@@ -9,20 +9,20 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class SpotterImport { |
16 | - private $all_flights = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_flights = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
27 | 27 | if (!(isset($globalNoDB) && $globalNoDB)) { |
28 | 28 | $Connection = new Connection($dbc); |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | $currentdate = date('Y-m-d'); |
35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
36 | 36 | if (!empty($sourcestat)) { |
37 | - foreach($sourcestat as $srcst) { |
|
38 | - $type = $srcst['stats_type']; |
|
37 | + foreach($sourcestat as $srcst) { |
|
38 | + $type = $srcst['stats_type']; |
|
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | - $source = $srcst['source_name']; |
|
41 | - $data = $srcst['source_data']; |
|
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
43 | - } |
|
44 | - } |
|
40 | + $source = $srcst['source_name']; |
|
41 | + $data = $srcst['source_data']; |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id,$ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -78,42 +78,42 @@ discard block |
||
78 | 78 | $operator = $Spotter->getOperator($ident); |
79 | 79 | $scheduleexist = false; |
80 | 80 | if ($Schedule->checkSchedule($operator) == 0) { |
81 | - $operator = $Translation->checkTranslation($ident); |
|
82 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
81 | + $operator = $Translation->checkTranslation($ident); |
|
82 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | - // Should also check if route schedule = route from DB |
|
89 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
85 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | + // Should also check if route schedule = route from DB |
|
89 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
91 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92 | - if (trim($airport_icao) != '') { |
|
91 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92 | + if (trim($airport_icao) != '') { |
|
93 | 93 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | 94 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
95 | - } |
|
95 | + } |
|
96 | + } |
|
96 | 97 | } |
97 | - } |
|
98 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
98 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
99 | 99 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
100 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101 | - if (trim($airport_icao) != '') { |
|
100 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101 | + if (trim($airport_icao) != '') { |
|
102 | 102 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | 103 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
104 | - } |
|
104 | + } |
|
105 | 105 | } |
106 | - } |
|
107 | - $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']); |
|
106 | + } |
|
107 | + $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']); |
|
108 | 108 | } |
109 | - } else $scheduleexist = true; |
|
109 | + } else $scheduleexist = true; |
|
110 | 110 | } else $scheduleexist = true; |
111 | 111 | // close connection, at least one way will work ? |
112 | - if ($scheduleexist) { |
|
112 | + if ($scheduleexist) { |
|
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | - $sch = $Schedule->getSchedule($operator); |
|
114 | + $sch = $Schedule->getSchedule($operator); |
|
115 | 115 | $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'])); |
116 | - } |
|
116 | + } |
|
117 | 117 | $Spotter->db = null; |
118 | 118 | $Schedule->db = null; |
119 | 119 | $Translation->db = null; |
@@ -128,78 +128,78 @@ discard block |
||
128 | 128 | } |
129 | 129 | */ |
130 | 130 | } |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - public function checkAll() { |
|
133 | + public function checkAll() { |
|
134 | 134 | global $globalDebug, $globalNoImport; |
135 | 135 | if ($globalDebug) echo "Update last seen flights data...\n"; |
136 | 136 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
137 | - foreach ($this->all_flights as $key => $flight) { |
|
137 | + foreach ($this->all_flights as $key => $flight) { |
|
138 | 138 | if (isset($this->all_flights[$key]['id'])) { |
139 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
140 | - $Spotter = new Spotter($this->db); |
|
141 | - $real_arrival = $this->arrival($key); |
|
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']); |
|
143 | - } |
|
144 | - } |
|
139 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
140 | + $Spotter = new Spotter($this->db); |
|
141 | + $real_arrival = $this->arrival($key); |
|
142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']); |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
145 | 146 | } |
146 | - } |
|
147 | 147 | |
148 | - public function arrival($key) { |
|
148 | + public function arrival($key) { |
|
149 | 149 | global $globalClosestMinDist, $globalDebug; |
150 | 150 | if ($globalDebug) echo 'Update arrival...'."\n"; |
151 | 151 | $Spotter = new Spotter($this->db); |
152 | - $airport_icao = ''; |
|
153 | - $airport_time = ''; |
|
154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
152 | + $airport_icao = ''; |
|
153 | + $airport_time = ''; |
|
154 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
157 | - if (isset($closestAirports[0])) { |
|
158 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
159 | - $airport_icao = $closestAirports[0]['icao']; |
|
160 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
162 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
163 | - foreach ($closestAirports as $airport) { |
|
164 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
165 | - $airport_icao = $airport['icao']; |
|
166 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
168 | - break; |
|
169 | - } |
|
170 | - } |
|
171 | - } 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))) { |
|
172 | - $airport_icao = $closestAirports[0]['icao']; |
|
173 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
174 | - } else { |
|
175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
176 | - } |
|
177 | - } else { |
|
178 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
179 | - } |
|
156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
157 | + if (isset($closestAirports[0])) { |
|
158 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
159 | + $airport_icao = $closestAirports[0]['icao']; |
|
160 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
161 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
162 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
163 | + foreach ($closestAirports as $airport) { |
|
164 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
165 | + $airport_icao = $airport['icao']; |
|
166 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
167 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
168 | + break; |
|
169 | + } |
|
170 | + } |
|
171 | + } 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))) { |
|
172 | + $airport_icao = $closestAirports[0]['icao']; |
|
173 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
174 | + } else { |
|
175 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
176 | + } |
|
177 | + } else { |
|
178 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
179 | + } |
|
180 | 180 | |
181 | - } else { |
|
182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
183 | - } |
|
184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
185 | - } |
|
181 | + } else { |
|
182 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
183 | + } |
|
184 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
185 | + } |
|
186 | 186 | |
187 | 187 | |
188 | 188 | |
189 | - public function del() { |
|
189 | + public function del() { |
|
190 | 190 | global $globalDebug, $globalNoImport, $globalNoDB; |
191 | 191 | // Delete old infos |
192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
193 | 193 | foreach ($this->all_flights as $key => $flight) { |
194 | - if (isset($flight['lastupdate'])) { |
|
194 | + if (isset($flight['lastupdate'])) { |
|
195 | 195 | if ($flight['lastupdate'] < (time()-5900)) { |
196 | - $this->delKey($key); |
|
196 | + $this->delKey($key); |
|
197 | 197 | } |
198 | - } |
|
198 | + } |
|
199 | + } |
|
199 | 200 | } |
200 | - } |
|
201 | 201 | |
202 | - public function delKey($key) { |
|
202 | + public function delKey($key) { |
|
203 | 203 | global $globalDebug, $globalNoImport, $globalNoDB; |
204 | 204 | // Delete old infos |
205 | 205 | if (isset($this->all_flights[$key]['id'])) { |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | } |
215 | 215 | } |
216 | 216 | unset($this->all_flights[$key]); |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | - public function add($line) { |
|
219 | + public function add($line) { |
|
220 | 220 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass; |
221 | 221 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
222 | 222 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -242,20 +242,20 @@ discard block |
||
242 | 242 | |
243 | 243 | // SBS format is CSV format |
244 | 244 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
245 | - //print_r($line); |
|
246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
247 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
245 | + //print_r($line); |
|
246 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
247 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
248 | 248 | |
249 | 249 | // Increment message number |
250 | 250 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
251 | - $current_date = date('Y-m-d'); |
|
252 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | - else $source = ''; |
|
254 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
255 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
256 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
257 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
251 | + $current_date = date('Y-m-d'); |
|
252 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | + else $source = ''; |
|
254 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
255 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
256 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
257 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
258 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /* |
@@ -271,54 +271,54 @@ discard block |
||
271 | 271 | //$this->db = $dbc; |
272 | 272 | |
273 | 273 | //$hex = trim($line['hex']); |
274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | - else $id = trim($line['id']); |
|
274 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | + else $id = trim($line['id']); |
|
276 | 276 | |
277 | 277 | if (!isset($this->all_flights[$id])) { |
278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
279 | - $this->all_flights[$id] = array(); |
|
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', '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,'source_type' => '')); |
|
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
283 | - if (!isset($line['id'])) { |
|
278 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
279 | + $this->all_flights[$id] = array(); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', '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,'source_type' => '')); |
|
282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
283 | + if (!isset($line['id'])) { |
|
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | // 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'))); |
286 | 286 | // 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'))); |
287 | 287 | 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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
288 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
288 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
291 | 291 | } |
292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | //print_r($this->all_flights); |
297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
299 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
299 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
302 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
301 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
302 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
303 | 303 | $timeelapsed = microtime(true); |
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | - $Spotter = new Spotter($this->db); |
|
306 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
305 | + $Spotter = new Spotter($this->db); |
|
306 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
307 | 307 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
308 | - } else { |
|
308 | + } else { |
|
309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | - } |
|
311 | - $Spotter->db = null; |
|
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
310 | + } |
|
311 | + $Spotter->db = null; |
|
312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
314 | 314 | } |
315 | - } |
|
316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
315 | + } |
|
316 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
318 | 318 | } |
319 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
321 | - } |
|
319 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
321 | + } |
|
322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 323 | $icao = $line['aircraft_icao']; |
324 | 324 | $Spotter = new Spotter($this->db); |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | } |
348 | 348 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
349 | 349 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
350 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
350 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
351 | 351 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
352 | - } else { |
|
352 | + } else { |
|
353 | 353 | 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"; |
354 | 354 | 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"; |
355 | 355 | /* |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | print_r($line); |
359 | 359 | */ |
360 | 360 | return ''; |
361 | - } |
|
361 | + } |
|
362 | 362 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
363 | 363 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
364 | 364 | return ''; |
@@ -374,21 +374,21 @@ discard block |
||
374 | 374 | } |
375 | 375 | |
376 | 376 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
377 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
377 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
378 | 378 | } |
379 | 379 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
380 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
380 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
381 | 381 | } |
382 | 382 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
383 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
383 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
384 | 384 | } |
385 | 385 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | 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'])) { |
390 | 390 | |
391 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
391 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
392 | 392 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
393 | 393 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
394 | 394 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -397,23 +397,23 @@ discard block |
||
397 | 397 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
398 | 398 | 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'])); |
399 | 399 | } else { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
401 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
401 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
402 | 402 | $timeelapsed = microtime(true); |
403 | - $Spotter = new Spotter($this->db); |
|
404 | - $fromsource = NULL; |
|
405 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
406 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
403 | + $Spotter = new Spotter($this->db); |
|
404 | + $fromsource = NULL; |
|
405 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
406 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
407 | 407 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
408 | 408 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
409 | 409 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
410 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
410 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
411 | 411 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
412 | 412 | $Spotter->db = null; |
413 | 413 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
414 | - } |
|
414 | + } |
|
415 | 415 | } |
416 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
416 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
417 | 417 | |
418 | 418 | /* |
419 | 419 | if (!isset($line['id'])) { |
@@ -423,63 +423,63 @@ discard block |
||
423 | 423 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
424 | 424 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
425 | 425 | */ |
426 | - 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'])); |
|
426 | + 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'])); |
|
427 | 427 | |
428 | - //$putinarchive = true; |
|
429 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
428 | + //$putinarchive = true; |
|
429 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
430 | 430 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
431 | - } |
|
432 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
431 | + } |
|
432 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
433 | 433 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
434 | - } |
|
435 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
436 | - $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' => '')); |
|
437 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
434 | + } |
|
435 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
436 | + $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' => '')); |
|
437 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
438 | 438 | $timeelapsed = microtime(true); |
439 | 439 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
440 | 440 | $Spotter = new Spotter($this->db); |
441 | 441 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
442 | 442 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
443 | - $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' => '')); |
|
443 | + $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' => '')); |
|
444 | 444 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
445 | - } |
|
446 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
445 | + } |
|
446 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
447 | 447 | $timeelapsed = microtime(true); |
448 | 448 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
449 | - $Spotter = new Spotter($this->db); |
|
450 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
451 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
449 | + $Spotter = new Spotter($this->db); |
|
450 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
451 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
452 | 452 | $Translation = new Translation($this->db); |
453 | 453 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
454 | 454 | $route = $Spotter->getRouteInfo($ident); |
455 | 455 | $Translation->db = null; |
456 | - } |
|
457 | - $Spotter->db = null; |
|
458 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
459 | - } |
|
456 | + } |
|
457 | + $Spotter->db = null; |
|
458 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
459 | + } |
|
460 | 460 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
461 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
462 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
461 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
462 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
463 | 463 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
464 | - $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'])); |
|
465 | - } |
|
464 | + $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'])); |
|
465 | + } |
|
466 | 466 | } |
467 | 467 | if (!isset($globalFork)) $globalFork = TRUE; |
468 | 468 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
469 | 469 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
470 | 470 | } |
471 | - } |
|
471 | + } |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
475 | 475 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
476 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
477 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
478 | - //$dataFound = true; |
|
476 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
477 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
478 | + //$dataFound = true; |
|
479 | 479 | } 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'])) { |
480 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
481 | - if ($distance > 1000 && $distance < 10000) { |
|
482 | - // use datetime |
|
480 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
481 | + if ($distance > 1000 && $distance < 10000) { |
|
482 | + // use datetime |
|
483 | 483 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
484 | 484 | $speed = $speed*3.6; |
485 | 485 | if ($speed < 1000) { |
@@ -488,48 +488,48 @@ discard block |
||
488 | 488 | } else { |
489 | 489 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
490 | 490 | } |
491 | - } |
|
491 | + } |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
495 | 495 | |
496 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
497 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
498 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
499 | - return false; |
|
500 | - } |
|
501 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
502 | - else unset($timediff); |
|
503 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
504 | - else unset($timediff_archive); |
|
505 | - if ($this->tmd > 5 |
|
506 | - || (isset($line['format_source']) |
|
507 | - && $line['format_source'] == 'airwhere' |
|
508 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
509 | - || !isset($this->all_flights[$id]['longitude'])) |
|
510 | - || (isset($this->all_flights[$id]['latitude']) |
|
511 | - && isset($this->all_flights[$id]['longitude']) |
|
512 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
513 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
514 | - ) |
|
515 | - ) |
|
516 | - ) |
|
517 | - || (isset($globalVA) && $globalVA) |
|
518 | - || (isset($globalIVAO) && $globalIVAO) |
|
519 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
520 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
521 | - || (isset($globalVAM) && $globalVAM) |
|
522 | - || !isset($timediff) |
|
523 | - || $timediff > $globalLiveInterval |
|
524 | - || ($timediff > 30 |
|
525 | - && isset($this->all_flights[$id]['latitude']) |
|
526 | - && isset($this->all_flights[$id]['longitude']) |
|
527 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
528 | - ) |
|
529 | - ) { |
|
496 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
497 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
498 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
499 | + return false; |
|
500 | + } |
|
501 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
502 | + else unset($timediff); |
|
503 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
504 | + else unset($timediff_archive); |
|
505 | + if ($this->tmd > 5 |
|
506 | + || (isset($line['format_source']) |
|
507 | + && $line['format_source'] == 'airwhere' |
|
508 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
509 | + || !isset($this->all_flights[$id]['longitude'])) |
|
510 | + || (isset($this->all_flights[$id]['latitude']) |
|
511 | + && isset($this->all_flights[$id]['longitude']) |
|
512 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
513 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
514 | + ) |
|
515 | + ) |
|
516 | + ) |
|
517 | + || (isset($globalVA) && $globalVA) |
|
518 | + || (isset($globalIVAO) && $globalIVAO) |
|
519 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
520 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
521 | + || (isset($globalVAM) && $globalVAM) |
|
522 | + || !isset($timediff) |
|
523 | + || $timediff > $globalLiveInterval |
|
524 | + || ($timediff > 30 |
|
525 | + && isset($this->all_flights[$id]['latitude']) |
|
526 | + && isset($this->all_flights[$id]['longitude']) |
|
527 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
528 | + ) |
|
529 | + ) { |
|
530 | 530 | |
531 | 531 | if ((isset($timediff) && !isset($timediff_archive)) || (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']))) { |
532 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
532 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
533 | 533 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
534 | 534 | || !$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'])) { |
535 | 535 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
538 | 538 | $this->tmd = 0; |
539 | 539 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
540 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
541 | - $timeelapsed = microtime(true); |
|
542 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
540 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
541 | + $timeelapsed = microtime(true); |
|
542 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
543 | 543 | $Spotter = new Spotter($this->db); |
544 | 544 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
545 | 545 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -547,11 +547,11 @@ discard block |
||
547 | 547 | $Spotter->db = null; |
548 | 548 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
549 | 549 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
550 | - } |
|
550 | + } |
|
551 | 551 | } |
552 | 552 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
553 | - } |
|
554 | - /* |
|
553 | + } |
|
554 | + /* |
|
555 | 555 | else { |
556 | 556 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
557 | 557 | else { |
@@ -565,16 +565,16 @@ discard block |
||
565 | 565 | } |
566 | 566 | |
567 | 567 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
568 | - //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) { |
|
568 | + //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) { |
|
569 | 569 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
570 | 570 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
571 | 571 | $this->all_flights[$id]['time_last_coord'] = time(); |
572 | 572 | } |
573 | 573 | //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' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
574 | 574 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
575 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
576 | - $dataFound = true; |
|
577 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
575 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
576 | + $dataFound = true; |
|
577 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
578 | 578 | } |
579 | 579 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
580 | 580 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -585,24 +585,24 @@ discard block |
||
585 | 585 | //$putinarchive = true; |
586 | 586 | } |
587 | 587 | */ |
588 | - /* |
|
588 | + /* |
|
589 | 589 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
590 | 590 | 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"; |
591 | 591 | } |
592 | 592 | */ |
593 | 593 | } |
594 | 594 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
595 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
596 | - //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) { |
|
595 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
596 | + //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) { |
|
597 | 597 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
598 | 598 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
599 | 599 | $this->all_flights[$id]['time_last_coord'] = time(); |
600 | 600 | } |
601 | 601 | //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' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
602 | 602 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
603 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
604 | - $dataFound = true; |
|
605 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
603 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
604 | + $dataFound = true; |
|
605 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
606 | 606 | } |
607 | 607 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
608 | 608 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -620,67 +620,67 @@ discard block |
||
620 | 620 | */ |
621 | 621 | } |
622 | 622 | |
623 | - } else if ($globalDebug && $timediff > 30) { |
|
623 | + } else if ($globalDebug && $timediff > 30) { |
|
624 | 624 | $this->tmd = $this->tmd + 1; |
625 | 625 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
626 | 626 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
627 | 627 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
628 | 628 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
629 | - } |
|
629 | + } |
|
630 | 630 | } |
631 | 631 | if (isset($line['last_update']) && $line['last_update'] != '') { |
632 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
633 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
632 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
634 | 634 | } |
635 | 635 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
637 | - //$dataFound = true; |
|
636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
637 | + //$dataFound = true; |
|
638 | 638 | } |
639 | 639 | if (isset($line['format_source']) && $line['format_source'] != '') { |
640 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
640 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
641 | 641 | } |
642 | 642 | if (isset($line['source_name']) && $line['source_name'] != '') { |
643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
644 | 644 | } |
645 | 645 | if (isset($line['emergency']) && $line['emergency'] != '') { |
646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
647 | - //$dataFound = true; |
|
646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
647 | + //$dataFound = true; |
|
648 | 648 | } |
649 | 649 | if (isset($line['ground']) && $line['ground'] != '') { |
650 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
650 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
651 | 651 | // Here we force archive of flight because after ground it's a new one (or should be) |
652 | 652 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
653 | 653 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
654 | 654 | 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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
655 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
655 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
656 | 656 | 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'])); |
657 | - } |
|
658 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
659 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
660 | - //$dataFound = true; |
|
657 | + } |
|
658 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
659 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
660 | + //$dataFound = true; |
|
661 | 661 | } |
662 | 662 | if (isset($line['squawk']) && $line['squawk'] != '') { |
663 | - 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'])) { |
|
664 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
666 | - $highlight = ''; |
|
667 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
668 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
669 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
670 | - if ($highlight != '') { |
|
663 | + 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'])) { |
|
664 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
666 | + $highlight = ''; |
|
667 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
668 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
669 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
670 | + if ($highlight != '') { |
|
671 | 671 | $timeelapsed = microtime(true); |
672 | 672 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
673 | - $Spotter = new Spotter($this->db); |
|
674 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
675 | - $Spotter->db = null; |
|
676 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
673 | + $Spotter = new Spotter($this->db); |
|
674 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
675 | + $Spotter->db = null; |
|
676 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
677 | 677 | } |
678 | 678 | //$putinarchive = true; |
679 | 679 | //$highlight = ''; |
680 | - } |
|
680 | + } |
|
681 | 681 | |
682 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
683 | - //$dataFound = true; |
|
682 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
683 | + //$dataFound = true; |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -691,13 +691,13 @@ discard block |
||
691 | 691 | $line['altitude'] = $line['altitude'] + $geoid; |
692 | 692 | } |
693 | 693 | } |
694 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
694 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
695 | 695 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
696 | 696 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
697 | 697 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
698 | 698 | //$dataFound = true; |
699 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
700 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
699 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
700 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
701 | 701 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
702 | 702 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
703 | 703 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -706,27 +706,27 @@ discard block |
||
706 | 706 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
707 | 707 | 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'])); |
708 | 708 | } |
709 | - } |
|
710 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
709 | + } |
|
710 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
714 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
714 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | if (isset($line['heading']) && $line['heading'] != '') { |
718 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
719 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
720 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
721 | - //$dataFound = true; |
|
718 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
719 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
720 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
721 | + //$dataFound = true; |
|
722 | 722 | } 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']) { |
723 | - $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']); |
|
724 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
725 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
726 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
723 | + $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']); |
|
724 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
725 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
726 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
727 | 727 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
728 | - // If not enough messages and ACARS set heading to 0 |
|
729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
728 | + // If not enough messages and ACARS set heading to 0 |
|
729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
730 | 730 | } |
731 | 731 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
732 | 732 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -739,125 +739,125 @@ discard block |
||
739 | 739 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
740 | 740 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
741 | 741 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
742 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
743 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
744 | - 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'])) { |
|
745 | - //print_r($this->all_flights); |
|
746 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
747 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
748 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
742 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
743 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
744 | + 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'])) { |
|
745 | + //print_r($this->all_flights); |
|
746 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
747 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
748 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
749 | 749 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
750 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
751 | - $timeelapsed = microtime(true); |
|
752 | - $SpotterLive = new SpotterLive($this->db); |
|
753 | - 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' || $line['format_source'] === 'famaprs')) { |
|
750 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
751 | + $timeelapsed = microtime(true); |
|
752 | + $SpotterLive = new SpotterLive($this->db); |
|
753 | + 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' || $line['format_source'] === 'famaprs')) { |
|
754 | 754 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
755 | 755 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
756 | - } elseif (isset($line['id'])) { |
|
756 | + } elseif (isset($line['id'])) { |
|
757 | 757 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
758 | 758 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
759 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
759 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
760 | 760 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
761 | 761 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
762 | - } else $recent_ident = ''; |
|
763 | - $SpotterLive->db=null; |
|
764 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
765 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
762 | + } else $recent_ident = ''; |
|
763 | + $SpotterLive->db=null; |
|
764 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
765 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
766 | 766 | } else $recent_ident = ''; |
767 | - } else { |
|
767 | + } else { |
|
768 | 768 | $recent_ident = ''; |
769 | 769 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
770 | - } |
|
771 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
772 | - if($recent_ident == "") |
|
773 | - { |
|
770 | + } |
|
771 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
772 | + if($recent_ident == "") |
|
773 | + { |
|
774 | 774 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
775 | 775 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
776 | 776 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
777 | 777 | //adds the spotter data for the archive |
778 | 778 | $ignoreImport = false; |
779 | 779 | foreach($globalAirportIgnore as $airportIgnore) { |
780 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
780 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
781 | 781 | $ignoreImport = true; |
782 | - } |
|
782 | + } |
|
783 | 783 | } |
784 | 784 | if (count($globalAirportAccept) > 0) { |
785 | - $ignoreImport = true; |
|
786 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
785 | + $ignoreImport = true; |
|
786 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
787 | 787 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
788 | - $ignoreImport = false; |
|
788 | + $ignoreImport = false; |
|
789 | + } |
|
789 | 790 | } |
790 | - } |
|
791 | 791 | } |
792 | 792 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
793 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
793 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
794 | 794 | 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)) { |
795 | - $ignoreImport = true; |
|
795 | + $ignoreImport = true; |
|
796 | + } |
|
796 | 797 | } |
797 | - } |
|
798 | 798 | } |
799 | 799 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
800 | - $ignoreImport = true; |
|
801 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
800 | + $ignoreImport = true; |
|
801 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
802 | 802 | 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)) { |
803 | - $ignoreImport = false; |
|
803 | + $ignoreImport = false; |
|
804 | + } |
|
804 | 805 | } |
805 | - } |
|
806 | 806 | } |
807 | 807 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
808 | - $ignoreImport = true; |
|
809 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
808 | + $ignoreImport = true; |
|
809 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
810 | 810 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
811 | - $ignoreImport = false; |
|
811 | + $ignoreImport = false; |
|
812 | + } |
|
812 | 813 | } |
813 | - } |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | if (!$ignoreImport) { |
817 | - $highlight = ''; |
|
818 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
819 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
820 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
821 | - 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'))); |
|
822 | - $timeelapsed = microtime(true); |
|
823 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
817 | + $highlight = ''; |
|
818 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
819 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
820 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
821 | + 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'))); |
|
822 | + $timeelapsed = microtime(true); |
|
823 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
824 | 824 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
825 | - $Spotter = new Spotter($this->db); |
|
826 | - $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]['altitude_real'], $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'],$this->all_flights[$id]['source_type']); |
|
827 | - $Spotter->db = null; |
|
828 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
825 | + $Spotter = new Spotter($this->db); |
|
826 | + $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]['altitude_real'], $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'],$this->all_flights[$id]['source_type']); |
|
827 | + $Spotter->db = null; |
|
828 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
829 | 829 | } |
830 | - } |
|
831 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
832 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
830 | + } |
|
831 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
832 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
833 | 833 | |
834 | - // Add source stat in DB |
|
835 | - $Stats = new Stats($this->db); |
|
836 | - if (!empty($this->stats)) { |
|
834 | + // Add source stat in DB |
|
835 | + $Stats = new Stats($this->db); |
|
836 | + if (!empty($this->stats)) { |
|
837 | 837 | if ($globalDebug) echo 'Add source stats : '; |
838 | - foreach($this->stats as $date => $data) { |
|
839 | - foreach($data as $source => $sourced) { |
|
840 | - //print_r($sourced); |
|
841 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
842 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
843 | - if (isset($sourced['msg'])) { |
|
844 | - if (time() - $sourced['msg']['date'] > 10) { |
|
845 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
846 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
847 | - unset($this->stats[$date][$source]['msg']); |
|
848 | - } |
|
849 | - } |
|
850 | - } |
|
851 | - if ($date != date('Y-m-d')) { |
|
852 | - unset($this->stats[$date]); |
|
853 | - } |
|
854 | - } |
|
855 | - if ($globalDebug) echo 'Done'."\n"; |
|
838 | + foreach($this->stats as $date => $data) { |
|
839 | + foreach($data as $source => $sourced) { |
|
840 | + //print_r($sourced); |
|
841 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
842 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
843 | + if (isset($sourced['msg'])) { |
|
844 | + if (time() - $sourced['msg']['date'] > 10) { |
|
845 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
846 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
847 | + unset($this->stats[$date][$source]['msg']); |
|
848 | + } |
|
849 | + } |
|
850 | + } |
|
851 | + if ($date != date('Y-m-d')) { |
|
852 | + unset($this->stats[$date]); |
|
853 | + } |
|
854 | + } |
|
855 | + if ($globalDebug) echo 'Done'."\n"; |
|
856 | 856 | |
857 | - } |
|
858 | - $Stats->db = null; |
|
859 | - } |
|
860 | - $this->del(); |
|
857 | + } |
|
858 | + $Stats->db = null; |
|
859 | + } |
|
860 | + $this->del(); |
|
861 | 861 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
862 | 862 | //$ignoreImport = false; |
863 | 863 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -875,41 +875,41 @@ discard block |
||
875 | 875 | */ |
876 | 876 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
877 | 877 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
878 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
879 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
880 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
878 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
879 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
880 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
881 | 881 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
882 | - $SpotterLive = new SpotterLive($this->db); |
|
883 | - $SpotterLive->deleteLiveSpotterData(); |
|
884 | - $SpotterLive->db=null; |
|
882 | + $SpotterLive = new SpotterLive($this->db); |
|
883 | + $SpotterLive->deleteLiveSpotterData(); |
|
884 | + $SpotterLive->db=null; |
|
885 | 885 | } |
886 | - } |
|
887 | - if ($globalDebug) echo " Done\n"; |
|
888 | - $this->last_delete = time(); |
|
886 | + } |
|
887 | + if ($globalDebug) echo " Done\n"; |
|
888 | + $this->last_delete = time(); |
|
889 | 889 | } |
890 | - } else { |
|
890 | + } else { |
|
891 | 891 | 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'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
892 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
893 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
892 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
893 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
894 | 894 | } |
895 | 895 | if (isset($globalDaemon) && !$globalDaemon) { |
896 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
896 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
897 | 897 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
898 | - $Spotter = new Spotter($this->db); |
|
899 | - $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]['altitude_real'],$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']); |
|
900 | - $Spotter->db = null; |
|
898 | + $Spotter = new Spotter($this->db); |
|
899 | + $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]['altitude_real'],$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']); |
|
900 | + $Spotter->db = null; |
|
901 | + } |
|
901 | 902 | } |
902 | - } |
|
903 | 903 | } |
904 | 904 | |
905 | - } |
|
905 | + } |
|
906 | 906 | } |
907 | - } |
|
908 | - //adds the spotter LIVE data |
|
909 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
910 | - //echo "\nAdd in Live !! \n"; |
|
911 | - //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"; |
|
912 | - if ($globalDebug) { |
|
907 | + } |
|
908 | + //adds the spotter LIVE data |
|
909 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
910 | + //echo "\nAdd in Live !! \n"; |
|
911 | + //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"; |
|
912 | + if ($globalDebug) { |
|
913 | 913 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
914 | 914 | 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"; |
915 | 915 | 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"; |
@@ -917,60 +917,60 @@ discard block |
||
917 | 917 | 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"; |
918 | 918 | 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"; |
919 | 919 | } |
920 | - } |
|
921 | - $ignoreImport = false; |
|
922 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
923 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
920 | + } |
|
921 | + $ignoreImport = false; |
|
922 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
923 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
924 | 924 | |
925 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
926 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
927 | - $ignoreImport = true; |
|
925 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
926 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
927 | + $ignoreImport = true; |
|
928 | + } |
|
928 | 929 | } |
929 | - } |
|
930 | - if (count($globalAirportAccept) > 0) { |
|
931 | - $ignoreImport = true; |
|
932 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
933 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
930 | + if (count($globalAirportAccept) > 0) { |
|
931 | + $ignoreImport = true; |
|
932 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
933 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
934 | 934 | $ignoreImport = false; |
935 | - } |
|
935 | + } |
|
936 | 936 | } |
937 | - } |
|
938 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
937 | + } |
|
938 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
939 | 939 | foreach($globalAirlineIgnore as $airlineIgnore) { |
940 | - 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)) { |
|
940 | + 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)) { |
|
941 | 941 | $ignoreImport = true; |
942 | - } |
|
942 | + } |
|
943 | 943 | } |
944 | - } |
|
945 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
944 | + } |
|
945 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
946 | 946 | $ignoreImport = true; |
947 | 947 | foreach($globalAirlineAccept as $airlineAccept) { |
948 | - 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)) { |
|
948 | + 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)) { |
|
949 | 949 | $ignoreImport = false; |
950 | - } |
|
950 | + } |
|
951 | + } |
|
951 | 952 | } |
952 | - } |
|
953 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
953 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
954 | 954 | $ignoreImport = true; |
955 | 955 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
956 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
957 | - $ignoreImport = false; |
|
958 | - } |
|
956 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
957 | + $ignoreImport = false; |
|
958 | + } |
|
959 | + } |
|
959 | 960 | } |
960 | - } |
|
961 | 961 | |
962 | - if (!$ignoreImport) { |
|
962 | + if (!$ignoreImport) { |
|
963 | 963 | 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'])) { |
964 | 964 | 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'))); |
965 | 965 | $timeelapsed = microtime(true); |
966 | 966 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
967 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
967 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
968 | 968 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
969 | 969 | $SpotterLive = new SpotterLive($this->db); |
970 | 970 | $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]['altitude_real'], $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']); |
971 | 971 | $SpotterLive->db = null; |
972 | 972 | if ($globalDebug) echo $result."\n"; |
973 | - } |
|
973 | + } |
|
974 | 974 | } |
975 | 975 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
976 | 976 | $APRSSpotter->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]['altitude_real'], $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']); |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | //if ($line['format_source'] != 'aprs') { |
983 | 983 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
984 | 984 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
985 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
985 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
986 | 986 | $source = $this->all_flights[$id]['source_name']; |
987 | 987 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
988 | 988 | if (!isset($this->source_location[$source])) { |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | if ($stats_heading == 16) $stats_heading = 0; |
1009 | 1009 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1010 | 1010 | for ($i=0;$i<=15;$i++) { |
1011 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1011 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1012 | 1012 | } |
1013 | 1013 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
1014 | 1014 | } else { |
@@ -1021,17 +1021,17 @@ discard block |
||
1021 | 1021 | //var_dump($this->stats); |
1022 | 1022 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1023 | 1023 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1024 | - end($this->stats[$current_date][$source]['hist']); |
|
1025 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1024 | + end($this->stats[$current_date][$source]['hist']); |
|
1025 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1026 | 1026 | } else $mini = 0; |
1027 | 1027 | for ($i=$mini;$i<=$distance;$i+=10) { |
1028 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1028 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1029 | 1029 | } |
1030 | 1030 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
1031 | 1031 | } else { |
1032 | 1032 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
1033 | 1033 | } |
1034 | - } |
|
1034 | + } |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | //$this->del(); |
1042 | 1042 | |
1043 | 1043 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1044 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1044 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1045 | 1045 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
1046 | 1046 | $SpotterLive = new SpotterLive($this->db); |
1047 | 1047 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1049,19 +1049,19 @@ discard block |
||
1049 | 1049 | //SpotterLive->deleteLiveSpotterData(); |
1050 | 1050 | if ($globalDebug) echo " Done\n"; |
1051 | 1051 | $this->last_delete_hourly = time(); |
1052 | - } else { |
|
1052 | + } else { |
|
1053 | 1053 | $this->del(); |
1054 | 1054 | $this->last_delete_hourly = time(); |
1055 | - } |
|
1055 | + } |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | - } |
|
1059 | - //$ignoreImport = false; |
|
1058 | + } |
|
1059 | + //$ignoreImport = false; |
|
1060 | 1060 | } |
1061 | 1061 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1062 | 1062 | if ($send) return $this->all_flights[$id]; |
1063 | - } |
|
1063 | + } |
|
1064 | + } |
|
1064 | 1065 | } |
1065 | - } |
|
1066 | 1066 | } |
1067 | 1067 | ?> |