@@ -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> |
@@ -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> |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | class update_schema { |
9 | 9 | |
10 | 10 | public static function update_schedule() { |
11 | - $Connection = new Connection(); |
|
12 | - $Schedule = new Schedule(); |
|
13 | - $query = "SELECT * FROM schedule"; |
|
14 | - try { |
|
15 | - $sth = $Connection->db->prepare($query); |
|
11 | + $Connection = new Connection(); |
|
12 | + $Schedule = new Schedule(); |
|
13 | + $query = "SELECT * FROM schedule"; |
|
14 | + try { |
|
15 | + $sth = $Connection->db->prepare($query); |
|
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch(PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | - } |
|
20 | - while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | - } |
|
19 | + } |
|
20 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | + $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | /* |
@@ -43,198 +43,198 @@ discard block |
||
43 | 43 | } |
44 | 44 | */ |
45 | 45 | private static function update_from_1() { |
46 | - $Connection = new Connection(); |
|
47 | - // Add new column to routes table |
|
48 | - //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
46 | + $Connection = new Connection(); |
|
47 | + // Add new column to routes table |
|
48 | + //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
49 | 49 | $query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL"; |
50 | - try { |
|
51 | - $sth = $Connection->db->prepare($query); |
|
52 | - $sth->execute(); |
|
53 | - } catch(PDOException $e) { |
|
54 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | - } |
|
56 | - // Copy schedules data to routes table |
|
57 | - self::update_schedule(); |
|
58 | - // Delete schedule table |
|
50 | + try { |
|
51 | + $sth = $Connection->db->prepare($query); |
|
52 | + $sth->execute(); |
|
53 | + } catch(PDOException $e) { |
|
54 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | + } |
|
56 | + // Copy schedules data to routes table |
|
57 | + self::update_schedule(); |
|
58 | + // Delete schedule table |
|
59 | 59 | $query = "DROP TABLE `schedule`"; |
60 | - try { |
|
61 | - $sth = $Connection->db->prepare($query); |
|
62 | - $sth->execute(); |
|
63 | - } catch(PDOException $e) { |
|
64 | - return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | - } |
|
66 | - // Add source column |
|
67 | - $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | - try { |
|
69 | - $sth = $Connection->db->prepare($query); |
|
70 | - $sth->execute(); |
|
71 | - } catch(PDOException $e) { |
|
72 | - return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | - } |
|
60 | + try { |
|
61 | + $sth = $Connection->db->prepare($query); |
|
62 | + $sth->execute(); |
|
63 | + } catch(PDOException $e) { |
|
64 | + return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | + } |
|
66 | + // Add source column |
|
67 | + $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | + try { |
|
69 | + $sth = $Connection->db->prepare($query); |
|
70 | + $sth->execute(); |
|
71 | + } catch(PDOException $e) { |
|
72 | + return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | + } |
|
74 | 74 | // Delete unused column |
75 | 75 | $query = "ALTER TABLE `aircraft_modes` DROP `SerialNo`, DROP `OperatorFlagCode`, DROP `Manufacturer`, DROP `Type`, DROP `FirstRegDate`, DROP `CurrentRegDate`, DROP `Country`, DROP `PreviousID`, DROP `DeRegDate`, DROP `Status`, DROP `PopularName`, DROP `GenericName`, DROP `AircraftClass`, DROP `Engines`, DROP `OwnershipStatus`, DROP `RegisteredOwners`, DROP `MTOW`, DROP `TotalHours`, DROP `YearBuilt`, DROP `CofACategory`, DROP `CofAExpiry`, DROP `UserNotes`, DROP `Interested`, DROP `UserTag`, DROP `InfoUrl`, DROP `PictureUrl1`, DROP `PictureUrl2`, DROP `PictureUrl3`, DROP `UserBool1`, DROP `UserBool2`, DROP `UserBool3`, DROP `UserBool4`, DROP `UserBool5`, DROP `UserString1`, DROP `UserString2`, DROP `UserString3`, DROP `UserString4`, DROP `UserString5`, DROP `UserInt1`, DROP `UserInt2`, DROP `UserInt3`, DROP `UserInt4`, DROP `UserInt5`"; |
76 | - try { |
|
77 | - $sth = $Connection->db->prepare($query); |
|
78 | - $sth->execute(); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | - } |
|
76 | + try { |
|
77 | + $sth = $Connection->db->prepare($query); |
|
78 | + $sth->execute(); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | + } |
|
82 | 82 | // Add ModeS column |
83 | 83 | $query = "ALTER TABLE `spotter_output` ADD `ModeS` VARCHAR(255) NULL"; |
84 | - try { |
|
85 | - $sth = $Connection->db->prepare($query); |
|
86 | - $sth->execute(); |
|
87 | - } catch(PDOException $e) { |
|
88 | - return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | - } |
|
84 | + try { |
|
85 | + $sth = $Connection->db->prepare($query); |
|
86 | + $sth->execute(); |
|
87 | + } catch(PDOException $e) { |
|
88 | + return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | + } |
|
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | - try { |
|
92 | - $sth = $Connection->db->prepare($query); |
|
93 | - $sth->execute(); |
|
94 | - } catch(PDOException $e) { |
|
95 | - return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | - } |
|
97 | - // Add auto_increment for aircraft_modes |
|
98 | - $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | - try { |
|
100 | - $sth = $Connection->db->prepare($query); |
|
101 | - $sth->execute(); |
|
102 | - } catch(PDOException $e) { |
|
103 | - return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | - } |
|
105 | - $error = ''; |
|
91 | + try { |
|
92 | + $sth = $Connection->db->prepare($query); |
|
93 | + $sth->execute(); |
|
94 | + } catch(PDOException $e) { |
|
95 | + return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | + } |
|
97 | + // Add auto_increment for aircraft_modes |
|
98 | + $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | + try { |
|
100 | + $sth = $Connection->db->prepare($query); |
|
101 | + $sth->execute(); |
|
102 | + } catch(PDOException $e) { |
|
103 | + return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | + } |
|
105 | + $error = ''; |
|
106 | 106 | $error .= create_db::import_file('../db/acars_live.sql'); |
107 | 107 | $error .= create_db::import_file('../db/config.sql'); |
108 | 108 | // Update schema_version to 2 |
109 | 109 | $query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'"; |
110 | - try { |
|
111 | - $sth = $Connection->db->prepare($query); |
|
112 | - $sth->execute(); |
|
113 | - } catch(PDOException $e) { |
|
114 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | - } |
|
110 | + try { |
|
111 | + $sth = $Connection->db->prepare($query); |
|
112 | + $sth->execute(); |
|
113 | + } catch(PDOException $e) { |
|
114 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | + } |
|
116 | 116 | return $error; |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | 119 | private static function update_from_2() { |
120 | - $Connection = new Connection(); |
|
121 | - // Add new column decode to acars_live table |
|
120 | + $Connection = new Connection(); |
|
121 | + // Add new column decode to acars_live table |
|
122 | 122 | $query = "ALTER TABLE `acars_live` ADD `decode` TEXT"; |
123 | - try { |
|
124 | - $sth = $Connection->db->prepare($query); |
|
125 | - $sth->execute(); |
|
126 | - } catch(PDOException $e) { |
|
127 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | - } |
|
129 | - $error = ''; |
|
130 | - // Create table acars_archive |
|
123 | + try { |
|
124 | + $sth = $Connection->db->prepare($query); |
|
125 | + $sth->execute(); |
|
126 | + } catch(PDOException $e) { |
|
127 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | + } |
|
129 | + $error = ''; |
|
130 | + // Create table acars_archive |
|
131 | 131 | $error .= create_db::import_file('../db/acars_archive.sql'); |
132 | 132 | // Update schema_version to 3 |
133 | 133 | $query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'"; |
134 | - try { |
|
135 | - $sth = $Connection->db->prepare($query); |
|
136 | - $sth->execute(); |
|
137 | - } catch(PDOException $e) { |
|
138 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | - } |
|
134 | + try { |
|
135 | + $sth = $Connection->db->prepare($query); |
|
136 | + $sth->execute(); |
|
137 | + } catch(PDOException $e) { |
|
138 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | + } |
|
140 | 140 | return $error; |
141 | 141 | } |
142 | 142 | |
143 | 143 | private static function update_from_3() { |
144 | - $Connection = new Connection(); |
|
145 | - // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
144 | + $Connection = new Connection(); |
|
145 | + // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
146 | 146 | $query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP"; |
147 | - try { |
|
148 | - $sth = $Connection->db->prepare($query); |
|
149 | - $sth->execute(); |
|
150 | - } catch(PDOException $e) { |
|
151 | - return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | - } |
|
153 | - // Add image_source_website column to spotter_image |
|
147 | + try { |
|
148 | + $sth = $Connection->db->prepare($query); |
|
149 | + $sth->execute(); |
|
150 | + } catch(PDOException $e) { |
|
151 | + return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | + } |
|
153 | + // Add image_source_website column to spotter_image |
|
154 | 154 | $query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL"; |
155 | - try { |
|
156 | - $sth = $Connection->db->prepare($query); |
|
157 | - $sth->execute(); |
|
158 | - } catch(PDOException $e) { |
|
159 | - return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | - } |
|
161 | - $error = ''; |
|
155 | + try { |
|
156 | + $sth = $Connection->db->prepare($query); |
|
157 | + $sth->execute(); |
|
158 | + } catch(PDOException $e) { |
|
159 | + return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | + } |
|
161 | + $error = ''; |
|
162 | 162 | // Update schema_version to 4 |
163 | 163 | $query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'"; |
164 | - try { |
|
165 | - $sth = $Connection->db->prepare($query); |
|
166 | - $sth->execute(); |
|
167 | - } catch(PDOException $e) { |
|
168 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | - } |
|
164 | + try { |
|
165 | + $sth = $Connection->db->prepare($query); |
|
166 | + $sth->execute(); |
|
167 | + } catch(PDOException $e) { |
|
168 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | + } |
|
170 | 170 | return $error; |
171 | 171 | } |
172 | 172 | |
173 | 173 | private static function update_from_4() { |
174 | - $Connection = new Connection(); |
|
174 | + $Connection = new Connection(); |
|
175 | 175 | |
176 | - $error = ''; |
|
177 | - // Create table acars_label |
|
176 | + $error = ''; |
|
177 | + // Create table acars_label |
|
178 | 178 | $error .= create_db::import_file('../db/acars_label.sql'); |
179 | 179 | if ($error == '') { |
180 | - // Update schema_version to 5 |
|
181 | - $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | - try { |
|
183 | - $sth = $Connection->db->prepare($query); |
|
180 | + // Update schema_version to 5 |
|
181 | + $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | + try { |
|
183 | + $sth = $Connection->db->prepare($query); |
|
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch(PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | - } |
|
188 | - } |
|
187 | + } |
|
188 | + } |
|
189 | 189 | return $error; |
190 | 190 | } |
191 | 191 | |
192 | 192 | private static function update_from_5() { |
193 | - $Connection = new Connection(); |
|
194 | - // Add columns to translation |
|
193 | + $Connection = new Connection(); |
|
194 | + // Add columns to translation |
|
195 | 195 | $query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;"; |
196 | - try { |
|
197 | - $sth = $Connection->db->prepare($query); |
|
198 | - $sth->execute(); |
|
199 | - } catch(PDOException $e) { |
|
200 | - return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | - } |
|
202 | - // Add aircraft_shadow column to aircraft |
|
203 | - $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | - try { |
|
205 | - $sth = $Connection->db->prepare($query); |
|
206 | - $sth->execute(); |
|
207 | - } catch(PDOException $e) { |
|
208 | - return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | - } |
|
210 | - // Add aircraft_shadow column to spotter_live |
|
211 | - $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | - try { |
|
213 | - $sth = $Connection->db->prepare($query); |
|
214 | - $sth->execute(); |
|
215 | - } catch(PDOException $e) { |
|
216 | - return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | - } |
|
218 | - $error = ''; |
|
219 | - // Update table aircraft |
|
196 | + try { |
|
197 | + $sth = $Connection->db->prepare($query); |
|
198 | + $sth->execute(); |
|
199 | + } catch(PDOException $e) { |
|
200 | + return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | + } |
|
202 | + // Add aircraft_shadow column to aircraft |
|
203 | + $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | + try { |
|
205 | + $sth = $Connection->db->prepare($query); |
|
206 | + $sth->execute(); |
|
207 | + } catch(PDOException $e) { |
|
208 | + return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | + } |
|
210 | + // Add aircraft_shadow column to spotter_live |
|
211 | + $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | + try { |
|
213 | + $sth = $Connection->db->prepare($query); |
|
214 | + $sth->execute(); |
|
215 | + } catch(PDOException $e) { |
|
216 | + return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | + } |
|
218 | + $error = ''; |
|
219 | + // Update table aircraft |
|
220 | 220 | $error .= create_db::import_file('../db/aircraft.sql'); |
221 | 221 | $error .= create_db::import_file('../db/spotter_archive.sql'); |
222 | 222 | |
223 | 223 | // Update schema_version to 6 |
224 | 224 | $query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'"; |
225 | - try { |
|
226 | - $sth = $Connection->db->prepare($query); |
|
227 | - $sth->execute(); |
|
228 | - } catch(PDOException $e) { |
|
229 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | - } |
|
225 | + try { |
|
226 | + $sth = $Connection->db->prepare($query); |
|
227 | + $sth->execute(); |
|
228 | + } catch(PDOException $e) { |
|
229 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | + } |
|
231 | 231 | return $error; |
232 | 232 | } |
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | - $Connection = new Connection(); |
|
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | - $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
235 | + $Connection = new Connection(); |
|
236 | + if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | + $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
240 | 240 | ALTER TABLE spotter_live ADD INDEX(flightaware_id); |
@@ -247,147 +247,147 @@ discard block |
||
247 | 247 | ALTER TABLE aircraft ADD INDEX(icao); |
248 | 248 | ALTER TABLE airport ADD INDEX(icao); |
249 | 249 | ALTER TABLE translation ADD INDEX(Operator);"; |
250 | - try { |
|
251 | - $sth = $Connection->db->prepare($query); |
|
250 | + try { |
|
251 | + $sth = $Connection->db->prepare($query); |
|
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch(PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | - } |
|
256 | - } |
|
257 | - $error = ''; |
|
258 | - // Update table countries |
|
259 | - if ($Connection->tableExists('airspace')) { |
|
260 | - $error .= update_db::update_countries(); |
|
261 | - if ($error != '') return $error; |
|
255 | + } |
|
256 | + } |
|
257 | + $error = ''; |
|
258 | + // Update table countries |
|
259 | + if ($Connection->tableExists('airspace')) { |
|
260 | + $error .= update_db::update_countries(); |
|
261 | + if ($error != '') return $error; |
|
262 | 262 | } |
263 | 263 | // Update schema_version to 7 |
264 | 264 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
265 | - try { |
|
266 | - $sth = $Connection->db->prepare($query); |
|
267 | - $sth->execute(); |
|
268 | - } catch(PDOException $e) { |
|
269 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | - } |
|
265 | + try { |
|
266 | + $sth = $Connection->db->prepare($query); |
|
267 | + $sth->execute(); |
|
268 | + } catch(PDOException $e) { |
|
269 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | + } |
|
271 | 271 | return $error; |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | - $Connection = new Connection(); |
|
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
276 | + $Connection = new Connection(); |
|
277 | + $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | - try { |
|
280 | - $sth = $Connection->db->prepare($query); |
|
281 | - $sth->execute(); |
|
282 | - } catch(PDOException $e) { |
|
283 | - return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | - } |
|
285 | - if ($globalDBdriver == 'mysql') { |
|
286 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | - try { |
|
288 | - $sth = $Connection->db->prepare($query); |
|
289 | - $sth->execute(); |
|
290 | - } catch(PDOException $e) { |
|
279 | + try { |
|
280 | + $sth = $Connection->db->prepare($query); |
|
281 | + $sth->execute(); |
|
282 | + } catch(PDOException $e) { |
|
283 | + return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | + } |
|
285 | + if ($globalDBdriver == 'mysql') { |
|
286 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | + try { |
|
288 | + $sth = $Connection->db->prepare($query); |
|
289 | + $sth->execute(); |
|
290 | + } catch(PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | - } |
|
293 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | - if ($row['engine'] == 'ARCHIVE') { |
|
292 | + } |
|
293 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | + if ($row['engine'] == 'ARCHIVE') { |
|
295 | 295 | $query = "CREATE TABLE copy LIKE spotter_archive; |
296 | 296 | ALTER TABLE copy ENGINE=ARCHIVE; |
297 | 297 | ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
298 | 298 | INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`; |
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | - } else { |
|
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | - } |
|
304 | - } else { |
|
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | - } |
|
307 | - try { |
|
308 | - $sth = $Connection->db->prepare($query); |
|
309 | - $sth->execute(); |
|
310 | - } catch(PDOException $e) { |
|
311 | - return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | - } |
|
301 | + } else { |
|
302 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | + } |
|
304 | + } else { |
|
305 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | + } |
|
307 | + try { |
|
308 | + $sth = $Connection->db->prepare($query); |
|
309 | + $sth->execute(); |
|
310 | + } catch(PDOException $e) { |
|
311 | + return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | + } |
|
313 | 313 | |
314 | - $error = ''; |
|
315 | - // Update table aircraft |
|
314 | + $error = ''; |
|
315 | + // Update table aircraft |
|
316 | 316 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | 317 | if ($error != '') return $error; |
318 | 318 | // Update schema_version to 6 |
319 | 319 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | - try { |
|
321 | - $sth = $Connection->db->prepare($query); |
|
322 | - $sth->execute(); |
|
323 | - } catch(PDOException $e) { |
|
324 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | - } |
|
320 | + try { |
|
321 | + $sth = $Connection->db->prepare($query); |
|
322 | + $sth->execute(); |
|
323 | + } catch(PDOException $e) { |
|
324 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | + } |
|
326 | 326 | return $error; |
327 | 327 | } |
328 | 328 | |
329 | 329 | private static function update_from_8() { |
330 | - $Connection = new Connection(); |
|
331 | - $error = ''; |
|
332 | - // Update table aircraft |
|
330 | + $Connection = new Connection(); |
|
331 | + $error = ''; |
|
332 | + // Update table aircraft |
|
333 | 333 | $error .= create_db::import_file('../db/notam.sql'); |
334 | 334 | if ($error != '') return $error; |
335 | 335 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 336 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 337 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
338 | 338 | INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; |
339 | - try { |
|
340 | - $sth = $Connection->db->prepare($query); |
|
341 | - $sth->execute(); |
|
342 | - } catch(PDOException $e) { |
|
343 | - return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | - } |
|
339 | + try { |
|
340 | + $sth = $Connection->db->prepare($query); |
|
341 | + $sth->execute(); |
|
342 | + } catch(PDOException $e) { |
|
343 | + return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | + } |
|
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | - try { |
|
347 | - $sth = $Connection->db->prepare($query); |
|
348 | - $sth->execute(); |
|
349 | - } catch(PDOException $e) { |
|
350 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | - } |
|
346 | + try { |
|
347 | + $sth = $Connection->db->prepare($query); |
|
348 | + $sth->execute(); |
|
349 | + } catch(PDOException $e) { |
|
350 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | + } |
|
352 | 352 | return $error; |
353 | 353 | } |
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | - $Connection = new Connection(); |
|
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
356 | + $Connection = new Connection(); |
|
357 | + $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | - try { |
|
360 | - $sth = $Connection->db->prepare($query); |
|
361 | - $sth->execute(); |
|
362 | - } catch(PDOException $e) { |
|
363 | - return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | - } |
|
359 | + try { |
|
360 | + $sth = $Connection->db->prepare($query); |
|
361 | + $sth->execute(); |
|
362 | + } catch(PDOException $e) { |
|
363 | + return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | + } |
|
365 | 365 | $error = ''; |
366 | - // Update table atc |
|
366 | + // Update table atc |
|
367 | 367 | $error .= create_db::import_file('../db/atc.sql'); |
368 | 368 | if ($error != '') return $error; |
369 | 369 | |
370 | 370 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | - try { |
|
372 | - $sth = $Connection->db->prepare($query); |
|
373 | - $sth->execute(); |
|
374 | - } catch(PDOException $e) { |
|
375 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | - } |
|
371 | + try { |
|
372 | + $sth = $Connection->db->prepare($query); |
|
373 | + $sth->execute(); |
|
374 | + } catch(PDOException $e) { |
|
375 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | + } |
|
377 | 377 | return $error; |
378 | 378 | } |
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | - $Connection = new Connection(); |
|
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | - try { |
|
384 | - $sth = $Connection->db->prepare($query); |
|
385 | - $sth->execute(); |
|
386 | - } catch(PDOException $e) { |
|
387 | - return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | - } |
|
381 | + $Connection = new Connection(); |
|
382 | + $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | + try { |
|
384 | + $sth = $Connection->db->prepare($query); |
|
385 | + $sth->execute(); |
|
386 | + } catch(PDOException $e) { |
|
387 | + return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | + } |
|
389 | 389 | $error = ''; |
390 | - // Add tables |
|
390 | + // Add tables |
|
391 | 391 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | 392 | if ($error != '') return $error; |
393 | 393 | $error .= create_db::import_file('../db/metar.sql'); |
@@ -398,76 +398,76 @@ discard block |
||
398 | 398 | if ($error != '') return $error; |
399 | 399 | |
400 | 400 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | - try { |
|
402 | - $sth = $Connection->db->prepare($query); |
|
403 | - $sth->execute(); |
|
404 | - } catch(PDOException $e) { |
|
405 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | - } |
|
401 | + try { |
|
402 | + $sth = $Connection->db->prepare($query); |
|
403 | + $sth->execute(); |
|
404 | + } catch(PDOException $e) { |
|
405 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | + } |
|
407 | 407 | return $error; |
408 | 408 | } |
409 | 409 | |
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | - $Connection = new Connection(); |
|
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | - try { |
|
415 | - $sth = $Connection->db->prepare($query); |
|
416 | - $sth->execute(); |
|
417 | - } catch(PDOException $e) { |
|
418 | - return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | - } |
|
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | - try { |
|
422 | - $sth = $Connection->db->prepare($query); |
|
423 | - $sth->execute(); |
|
424 | - } catch(PDOException $e) { |
|
425 | - return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | - } |
|
427 | - if ($globalDBdriver == 'mysql') { |
|
428 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | - try { |
|
430 | - $sth = $Connection->db->prepare($query); |
|
431 | - $sth->execute(); |
|
432 | - } catch(PDOException $e) { |
|
412 | + $Connection = new Connection(); |
|
413 | + $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | + try { |
|
415 | + $sth = $Connection->db->prepare($query); |
|
416 | + $sth->execute(); |
|
417 | + } catch(PDOException $e) { |
|
418 | + return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | + } |
|
420 | + $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | + try { |
|
422 | + $sth = $Connection->db->prepare($query); |
|
423 | + $sth->execute(); |
|
424 | + } catch(PDOException $e) { |
|
425 | + return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | + } |
|
427 | + if ($globalDBdriver == 'mysql') { |
|
428 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | + try { |
|
430 | + $sth = $Connection->db->prepare($query); |
|
431 | + $sth->execute(); |
|
432 | + } catch(PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | - } |
|
435 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | - if ($row['engine'] == 'ARCHIVE') { |
|
434 | + } |
|
435 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | + if ($row['engine'] == 'ARCHIVE') { |
|
437 | 437 | $query = "CREATE TABLE copy LIKE spotter_archive; |
438 | 438 | ALTER TABLE copy ENGINE=ARCHIVE; |
439 | 439 | ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE; |
440 | 440 | INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`; |
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | - } else { |
|
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | - } |
|
446 | - } else { |
|
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | - } |
|
449 | - try { |
|
450 | - $sth = $Connection->db->prepare($query); |
|
451 | - $sth->execute(); |
|
452 | - } catch(PDOException $e) { |
|
453 | - return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | - } |
|
443 | + } else { |
|
444 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | + } |
|
446 | + } else { |
|
447 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | + } |
|
449 | + try { |
|
450 | + $sth = $Connection->db->prepare($query); |
|
451 | + $sth->execute(); |
|
452 | + } catch(PDOException $e) { |
|
453 | + return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | + } |
|
455 | 455 | |
456 | 456 | $error = ''; |
457 | 457 | |
458 | 458 | $query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'"; |
459 | - try { |
|
460 | - $sth = $Connection->db->prepare($query); |
|
461 | - $sth->execute(); |
|
462 | - } catch(PDOException $e) { |
|
463 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | - } |
|
459 | + try { |
|
460 | + $sth = $Connection->db->prepare($query); |
|
461 | + $sth->execute(); |
|
462 | + } catch(PDOException $e) { |
|
463 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | + } |
|
465 | 465 | return $error; |
466 | 466 | } |
467 | 467 | private static function update_from_12() { |
468 | - $Connection = new Connection(); |
|
468 | + $Connection = new Connection(); |
|
469 | 469 | $error = ''; |
470 | - // Add tables |
|
470 | + // Add tables |
|
471 | 471 | $error .= create_db::import_file('../db/stats.sql'); |
472 | 472 | if ($error != '') return $error; |
473 | 473 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
@@ -484,166 +484,166 @@ discard block |
||
484 | 484 | if ($error != '') return $error; |
485 | 485 | |
486 | 486 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | - try { |
|
488 | - $sth = $Connection->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | - } |
|
487 | + try { |
|
488 | + $sth = $Connection->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | + } |
|
493 | 493 | return $error; |
494 | 494 | } |
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | - $Connection = new Connection(); |
|
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
497 | + $Connection = new Connection(); |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | + $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch(PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | - } |
|
505 | + } |
|
506 | 506 | } |
507 | - $error = ''; |
|
507 | + $error = ''; |
|
508 | 508 | $query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; |
509 | - try { |
|
510 | - $sth = $Connection->db->prepare($query); |
|
511 | - $sth->execute(); |
|
512 | - } catch(PDOException $e) { |
|
513 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | - } |
|
509 | + try { |
|
510 | + $sth = $Connection->db->prepare($query); |
|
511 | + $sth->execute(); |
|
512 | + } catch(PDOException $e) { |
|
513 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | + } |
|
515 | 515 | return $error; |
516 | 516 | } |
517 | 517 | |
518 | 518 | private static function update_from_14() { |
519 | - $Connection = new Connection(); |
|
519 | + $Connection = new Connection(); |
|
520 | 520 | $error = ''; |
521 | - // Add tables |
|
522 | - if (!$Connection->tableExists('stats_flight')) { |
|
521 | + // Add tables |
|
522 | + if (!$Connection->tableExists('stats_flight')) { |
|
523 | 523 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | 524 | if ($error != '') return $error; |
525 | 525 | } |
526 | 526 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | - try { |
|
528 | - $sth = $Connection->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | - } |
|
527 | + try { |
|
528 | + $sth = $Connection->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | + } |
|
533 | 533 | return $error; |
534 | 534 | } |
535 | 535 | |
536 | 536 | |
537 | 537 | private static function update_from_15() { |
538 | - $Connection = new Connection(); |
|
538 | + $Connection = new Connection(); |
|
539 | 539 | $error = ''; |
540 | - // Add tables |
|
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | - try { |
|
543 | - $sth = $Connection->db->prepare($query); |
|
544 | - $sth->execute(); |
|
545 | - } catch(PDOException $e) { |
|
546 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | - } |
|
540 | + // Add tables |
|
541 | + $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | + try { |
|
543 | + $sth = $Connection->db->prepare($query); |
|
544 | + $sth->execute(); |
|
545 | + } catch(PDOException $e) { |
|
546 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | + } |
|
548 | 548 | if ($error != '') return $error; |
549 | 549 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | - try { |
|
551 | - $sth = $Connection->db->prepare($query); |
|
552 | - $sth->execute(); |
|
553 | - } catch(PDOException $e) { |
|
554 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | - } |
|
550 | + try { |
|
551 | + $sth = $Connection->db->prepare($query); |
|
552 | + $sth->execute(); |
|
553 | + } catch(PDOException $e) { |
|
554 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | + } |
|
556 | 556 | return $error; |
557 | 557 | } |
558 | 558 | |
559 | 559 | private static function update_from_16() { |
560 | - $Connection = new Connection(); |
|
560 | + $Connection = new Connection(); |
|
561 | 561 | $error = ''; |
562 | - // Add tables |
|
563 | - if (!$Connection->tableExists('stats_registration')) { |
|
562 | + // Add tables |
|
563 | + if (!$Connection->tableExists('stats_registration')) { |
|
564 | 564 | $error .= create_db::import_file('../db/stats_registration.sql'); |
565 | 565 | } |
566 | - if (!$Connection->tableExists('stats_callsign')) { |
|
566 | + if (!$Connection->tableExists('stats_callsign')) { |
|
567 | 567 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 568 | } |
569 | 569 | if ($error != '') return $error; |
570 | 570 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | - try { |
|
572 | - $sth = $Connection->db->prepare($query); |
|
573 | - $sth->execute(); |
|
574 | - } catch(PDOException $e) { |
|
575 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | - } |
|
571 | + try { |
|
572 | + $sth = $Connection->db->prepare($query); |
|
573 | + $sth->execute(); |
|
574 | + } catch(PDOException $e) { |
|
575 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | + } |
|
577 | 577 | return $error; |
578 | 578 | } |
579 | 579 | |
580 | 580 | private static function update_from_17() { |
581 | - $Connection = new Connection(); |
|
581 | + $Connection = new Connection(); |
|
582 | 582 | $error = ''; |
583 | - // Add tables |
|
584 | - if (!$Connection->tableExists('stats_country')) { |
|
583 | + // Add tables |
|
584 | + if (!$Connection->tableExists('stats_country')) { |
|
585 | 585 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 586 | } |
587 | 587 | if ($error != '') return $error; |
588 | 588 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | - try { |
|
590 | - $sth = $Connection->db->prepare($query); |
|
591 | - $sth->execute(); |
|
592 | - } catch(PDOException $e) { |
|
593 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | - } |
|
589 | + try { |
|
590 | + $sth = $Connection->db->prepare($query); |
|
591 | + $sth->execute(); |
|
592 | + } catch(PDOException $e) { |
|
593 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | + } |
|
595 | 595 | return $error; |
596 | 596 | } |
597 | 597 | private static function update_from_18() { |
598 | - $Connection = new Connection(); |
|
598 | + $Connection = new Connection(); |
|
599 | 599 | $error = ''; |
600 | - // Modify stats_airport table |
|
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | - $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | - try { |
|
604 | - $sth = $Connection->db->prepare($query); |
|
605 | - $sth->execute(); |
|
606 | - } catch(PDOException $e) { |
|
607 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | - } |
|
609 | - } |
|
600 | + // Modify stats_airport table |
|
601 | + if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | + $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | + try { |
|
604 | + $sth = $Connection->db->prepare($query); |
|
605 | + $sth->execute(); |
|
606 | + } catch(PDOException $e) { |
|
607 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | + } |
|
609 | + } |
|
610 | 610 | if ($error != '') return $error; |
611 | 611 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | - try { |
|
613 | - $sth = $Connection->db->prepare($query); |
|
614 | - $sth->execute(); |
|
615 | - } catch(PDOException $e) { |
|
616 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | - } |
|
612 | + try { |
|
613 | + $sth = $Connection->db->prepare($query); |
|
614 | + $sth->execute(); |
|
615 | + } catch(PDOException $e) { |
|
616 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | + } |
|
618 | 618 | return $error; |
619 | 619 | } |
620 | 620 | |
621 | 621 | private static function update_from_19() { |
622 | - $Connection = new Connection(); |
|
622 | + $Connection = new Connection(); |
|
623 | 623 | $error = ''; |
624 | - // Update airport table |
|
624 | + // Update airport table |
|
625 | 625 | $error .= create_db::import_file('../db/airport.sql'); |
626 | 626 | if ($error != '') return 'Import airport.sql : '.$error; |
627 | 627 | // Remove primary key on Spotter_Archive |
628 | 628 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | - try { |
|
630 | - $sth = $Connection->db->prepare($query); |
|
631 | - $sth->execute(); |
|
632 | - } catch(PDOException $e) { |
|
633 | - return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | - } |
|
629 | + try { |
|
630 | + $sth = $Connection->db->prepare($query); |
|
631 | + $sth->execute(); |
|
632 | + } catch(PDOException $e) { |
|
633 | + return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | + } |
|
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | - try { |
|
637 | - $sth = $Connection->db->prepare($query); |
|
638 | - $sth->execute(); |
|
639 | - } catch(PDOException $e) { |
|
640 | - return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | - } |
|
636 | + try { |
|
637 | + $sth = $Connection->db->prepare($query); |
|
638 | + $sth->execute(); |
|
639 | + } catch(PDOException $e) { |
|
640 | + return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | + } |
|
642 | 642 | if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
643 | 643 | // Add column over_country |
644 | - $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
644 | + $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
645 | 645 | try { |
646 | - $sth = $Connection->db->prepare($query); |
|
646 | + $sth = $Connection->db->prepare($query); |
|
647 | 647 | $sth->execute(); |
648 | 648 | } catch(PDOException $e) { |
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | } |
652 | 652 | if (!$Connection->checkColumnName('spotter_live','over_country')) { |
653 | 653 | // Add column over_country |
654 | - $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
654 | + $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
655 | 655 | try { |
656 | - $sth = $Connection->db->prepare($query); |
|
656 | + $sth = $Connection->db->prepare($query); |
|
657 | 657 | $sth->execute(); |
658 | 658 | } catch(PDOException $e) { |
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -661,74 +661,74 @@ discard block |
||
661 | 661 | } |
662 | 662 | if (!$Connection->checkColumnName('spotter_output','source_name')) { |
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | - $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
664 | + $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | 668 | } catch(PDOException $e) { |
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | - } |
|
671 | - } |
|
670 | + } |
|
671 | + } |
|
672 | 672 | if (!$Connection->checkColumnName('spotter_live','source_name')) { |
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | - $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
674 | + $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | 678 | } catch(PDOException $e) { |
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | - } |
|
681 | - } |
|
680 | + } |
|
681 | + } |
|
682 | 682 | if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | - $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
684 | + $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | 688 | } catch(PDOException $e) { |
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | - } |
|
691 | - } |
|
690 | + } |
|
691 | + } |
|
692 | 692 | if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | - $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
694 | + $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | 698 | } catch(PDOException $e) { |
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | - } |
|
701 | - } |
|
700 | + } |
|
701 | + } |
|
702 | 702 | if ($error != '') return $error; |
703 | 703 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | - try { |
|
705 | - $sth = $Connection->db->prepare($query); |
|
706 | - $sth->execute(); |
|
707 | - } catch(PDOException $e) { |
|
708 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | - } |
|
704 | + try { |
|
705 | + $sth = $Connection->db->prepare($query); |
|
706 | + $sth->execute(); |
|
707 | + } catch(PDOException $e) { |
|
708 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | + } |
|
710 | 710 | return $error; |
711 | 711 | } |
712 | 712 | |
713 | 713 | private static function update_from_20() { |
714 | 714 | global $globalIVAO, $globalVATSIM, $globalphpVMS; |
715 | - $Connection = new Connection(); |
|
715 | + $Connection = new Connection(); |
|
716 | 716 | $error = ''; |
717 | - // Update airline table |
|
718 | - if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
717 | + // Update airline table |
|
718 | + if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | 722 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 723 | // Add column over_country |
724 | - $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | - try { |
|
724 | + $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | + try { |
|
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | 728 | } catch(PDOException $e) { |
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | - } |
|
731 | - } |
|
730 | + } |
|
731 | + } |
|
732 | 732 | if ($error != '') return $error; |
733 | 733 | /* |
734 | 734 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | } |
739 | 739 | */ |
740 | 740 | $query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'"; |
741 | - try { |
|
742 | - $sth = $Connection->db->prepare($query); |
|
743 | - $sth->execute(); |
|
744 | - } catch(PDOException $e) { |
|
745 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | - } |
|
741 | + try { |
|
742 | + $sth = $Connection->db->prepare($query); |
|
743 | + $sth->execute(); |
|
744 | + } catch(PDOException $e) { |
|
745 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | + } |
|
747 | 747 | return $error; |
748 | 748 | } |
749 | 749 | |
@@ -762,35 +762,35 @@ discard block |
||
762 | 762 | if ($error != '') return $error; |
763 | 763 | } |
764 | 764 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | - try { |
|
766 | - $sth = $Connection->db->prepare($query); |
|
767 | - $sth->execute(); |
|
768 | - } catch(PDOException $e) { |
|
769 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | - } |
|
765 | + try { |
|
766 | + $sth = $Connection->db->prepare($query); |
|
767 | + $sth->execute(); |
|
768 | + } catch(PDOException $e) { |
|
769 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | + } |
|
771 | 771 | return $error; |
772 | 772 | } |
773 | 773 | |
774 | 774 | private static function update_from_22() { |
775 | 775 | global $globalDBdriver; |
776 | - $Connection = new Connection(); |
|
776 | + $Connection = new Connection(); |
|
777 | 777 | $error = ''; |
778 | 778 | // Add table stats polar |
779 | - if (!$Connection->tableExists('stats_source')) { |
|
779 | + if (!$Connection->tableExists('stats_source')) { |
|
780 | 780 | if ($globalDBdriver == 'mysql') { |
781 | - $error .= create_db::import_file('../db/stats_source.sql'); |
|
781 | + $error .= create_db::import_file('../db/stats_source.sql'); |
|
782 | 782 | } else { |
783 | 783 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 784 | } |
785 | 785 | if ($error != '') return $error; |
786 | 786 | } |
787 | 787 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | - try { |
|
789 | - $sth = $Connection->db->prepare($query); |
|
790 | - $sth->execute(); |
|
791 | - } catch(PDOException $e) { |
|
792 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | - } |
|
788 | + try { |
|
789 | + $sth = $Connection->db->prepare($query); |
|
790 | + $sth->execute(); |
|
791 | + } catch(PDOException $e) { |
|
792 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | + } |
|
794 | 794 | return $error; |
795 | 795 | } |
796 | 796 | |
@@ -821,14 +821,14 @@ discard block |
||
821 | 821 | } |
822 | 822 | if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | - $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
824 | + $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | 828 | } catch(PDOException $e) { |
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | - } |
|
831 | - } |
|
830 | + } |
|
831 | + } |
|
832 | 832 | |
833 | 833 | $query = "UPDATE config SET value = '24' WHERE name = 'schema_version'"; |
834 | 834 | try { |
@@ -1176,7 +1176,7 @@ discard block |
||
1176 | 1176 | } catch(PDOException $e) { |
1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1178 | 1178 | } |
1179 | - } |
|
1179 | + } |
|
1180 | 1180 | if (!$Connection->checkColumnName('aircraft','mfr')) { |
1181 | 1181 | // Add mfr to aircraft |
1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | } catch(PDOException $e) { |
1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1252 | 1252 | } |
1253 | - } |
|
1253 | + } |
|
1254 | 1254 | if (!$Connection->indexExists('accidents','registration_idx')) { |
1255 | 1255 | // Add index key |
1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | } catch(PDOException $e) { |
1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1262 | 1262 | } |
1263 | - } |
|
1263 | + } |
|
1264 | 1264 | if (!$Connection->indexExists('accidents','rdts')) { |
1265 | 1265 | // Add index key |
1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | } catch(PDOException $e) { |
1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1272 | 1272 | } |
1273 | - } |
|
1273 | + } |
|
1274 | 1274 | |
1275 | 1275 | $query = "UPDATE config SET value = '31' WHERE name = 'schema_version'"; |
1276 | 1276 | try { |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | } catch(PDOException $e) { |
1563 | 1563 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; |
1564 | 1564 | } |
1565 | - } |
|
1565 | + } |
|
1566 | 1566 | $query = "UPDATE config SET value = '36' WHERE name = 'schema_version'"; |
1567 | 1567 | try { |
1568 | 1568 | $sth = $Connection->db->prepare($query); |
@@ -1723,7 +1723,7 @@ discard block |
||
1723 | 1723 | } catch(PDOException $e) { |
1724 | 1724 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; |
1725 | 1725 | } |
1726 | - } |
|
1726 | + } |
|
1727 | 1727 | $query = "UPDATE config SET value = '38' WHERE name = 'schema_version'"; |
1728 | 1728 | try { |
1729 | 1729 | $sth = $Connection->db->prepare($query); |
@@ -2129,205 +2129,205 @@ discard block |
||
2129 | 2129 | |
2130 | 2130 | |
2131 | 2131 | |
2132 | - public static function check_version($update = false) { |
|
2133 | - global $globalDBname; |
|
2134 | - $version = 0; |
|
2135 | - $Connection = new Connection(); |
|
2136 | - if ($Connection->tableExists('aircraft')) { |
|
2137 | - if (!$Connection->tableExists('config')) { |
|
2138 | - $version = '1'; |
|
2139 | - if ($update) return self::update_from_1(); |
|
2140 | - else return $version; |
|
2132 | + public static function check_version($update = false) { |
|
2133 | + global $globalDBname; |
|
2134 | + $version = 0; |
|
2135 | + $Connection = new Connection(); |
|
2136 | + if ($Connection->tableExists('aircraft')) { |
|
2137 | + if (!$Connection->tableExists('config')) { |
|
2138 | + $version = '1'; |
|
2139 | + if ($update) return self::update_from_1(); |
|
2140 | + else return $version; |
|
2141 | 2141 | } else { |
2142 | - $Connection = new Connection(); |
|
2143 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
2144 | - try { |
|
2145 | - $sth = $Connection->db->prepare($query); |
|
2146 | - $sth->execute(); |
|
2147 | - } catch(PDOException $e) { |
|
2142 | + $Connection = new Connection(); |
|
2143 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
2144 | + try { |
|
2145 | + $sth = $Connection->db->prepare($query); |
|
2146 | + $sth->execute(); |
|
2147 | + } catch(PDOException $e) { |
|
2148 | 2148 | return "error : ".$e->getMessage()."\n"; |
2149 | - } |
|
2150 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
2151 | - if ($update) { |
|
2152 | - if ($result['value'] == '2') { |
|
2153 | - $error = self::update_from_2(); |
|
2154 | - if ($error != '') return $error; |
|
2155 | - else return self::check_version(true); |
|
2156 | - } elseif ($result['value'] == '3') { |
|
2157 | - $error = self::update_from_3(); |
|
2158 | - if ($error != '') return $error; |
|
2159 | - else return self::check_version(true); |
|
2160 | - } elseif ($result['value'] == '4') { |
|
2161 | - $error = self::update_from_4(); |
|
2162 | - if ($error != '') return $error; |
|
2163 | - else return self::check_version(true); |
|
2164 | - } elseif ($result['value'] == '5') { |
|
2165 | - $error = self::update_from_5(); |
|
2166 | - if ($error != '') return $error; |
|
2167 | - else return self::check_version(true); |
|
2168 | - } elseif ($result['value'] == '6') { |
|
2169 | - $error = self::update_from_6(); |
|
2170 | - if ($error != '') return $error; |
|
2171 | - else return self::check_version(true); |
|
2172 | - } elseif ($result['value'] == '7') { |
|
2173 | - $error = self::update_from_7(); |
|
2174 | - if ($error != '') return $error; |
|
2175 | - else return self::check_version(true); |
|
2176 | - } elseif ($result['value'] == '8') { |
|
2177 | - $error = self::update_from_8(); |
|
2178 | - if ($error != '') return $error; |
|
2179 | - else return self::check_version(true); |
|
2180 | - } elseif ($result['value'] == '9') { |
|
2181 | - $error = self::update_from_9(); |
|
2182 | - if ($error != '') return $error; |
|
2183 | - else return self::check_version(true); |
|
2184 | - } elseif ($result['value'] == '10') { |
|
2185 | - $error = self::update_from_10(); |
|
2186 | - if ($error != '') return $error; |
|
2187 | - else return self::check_version(true); |
|
2188 | - } elseif ($result['value'] == '11') { |
|
2189 | - $error = self::update_from_11(); |
|
2190 | - if ($error != '') return $error; |
|
2191 | - else return self::check_version(true); |
|
2192 | - } elseif ($result['value'] == '12') { |
|
2193 | - $error = self::update_from_12(); |
|
2194 | - if ($error != '') return $error; |
|
2195 | - else return self::check_version(true); |
|
2196 | - } elseif ($result['value'] == '13') { |
|
2197 | - $error = self::update_from_13(); |
|
2198 | - if ($error != '') return $error; |
|
2199 | - else return self::check_version(true); |
|
2200 | - } elseif ($result['value'] == '14') { |
|
2201 | - $error = self::update_from_14(); |
|
2202 | - if ($error != '') return $error; |
|
2203 | - else return self::check_version(true); |
|
2204 | - } elseif ($result['value'] == '15') { |
|
2205 | - $error = self::update_from_15(); |
|
2206 | - if ($error != '') return $error; |
|
2207 | - else return self::check_version(true); |
|
2208 | - } elseif ($result['value'] == '16') { |
|
2209 | - $error = self::update_from_16(); |
|
2210 | - if ($error != '') return $error; |
|
2211 | - else return self::check_version(true); |
|
2212 | - } elseif ($result['value'] == '17') { |
|
2213 | - $error = self::update_from_17(); |
|
2214 | - if ($error != '') return $error; |
|
2215 | - else return self::check_version(true); |
|
2216 | - } elseif ($result['value'] == '18') { |
|
2217 | - $error = self::update_from_18(); |
|
2218 | - if ($error != '') return $error; |
|
2219 | - else return self::check_version(true); |
|
2220 | - } elseif ($result['value'] == '19') { |
|
2221 | - $error = self::update_from_19(); |
|
2222 | - if ($error != '') return $error; |
|
2223 | - else return self::check_version(true); |
|
2224 | - } elseif ($result['value'] == '20') { |
|
2225 | - $error = self::update_from_20(); |
|
2226 | - if ($error != '') return $error; |
|
2227 | - else return self::check_version(true); |
|
2228 | - } elseif ($result['value'] == '21') { |
|
2229 | - $error = self::update_from_21(); |
|
2230 | - if ($error != '') return $error; |
|
2231 | - else return self::check_version(true); |
|
2232 | - } elseif ($result['value'] == '22') { |
|
2233 | - $error = self::update_from_22(); |
|
2234 | - if ($error != '') return $error; |
|
2235 | - else return self::check_version(true); |
|
2236 | - } elseif ($result['value'] == '23') { |
|
2237 | - $error = self::update_from_23(); |
|
2238 | - if ($error != '') return $error; |
|
2239 | - else return self::check_version(true); |
|
2240 | - } elseif ($result['value'] == '24') { |
|
2241 | - $error = self::update_from_24(); |
|
2242 | - if ($error != '') return $error; |
|
2243 | - else return self::check_version(true); |
|
2244 | - } elseif ($result['value'] == '25') { |
|
2245 | - $error = self::update_from_25(); |
|
2246 | - if ($error != '') return $error; |
|
2247 | - else return self::check_version(true); |
|
2248 | - } elseif ($result['value'] == '26') { |
|
2249 | - $error = self::update_from_26(); |
|
2250 | - if ($error != '') return $error; |
|
2251 | - else return self::check_version(true); |
|
2252 | - } elseif ($result['value'] == '27') { |
|
2253 | - $error = self::update_from_27(); |
|
2254 | - if ($error != '') return $error; |
|
2255 | - else return self::check_version(true); |
|
2256 | - } elseif ($result['value'] == '28') { |
|
2257 | - $error = self::update_from_28(); |
|
2258 | - if ($error != '') return $error; |
|
2259 | - else return self::check_version(true); |
|
2260 | - } elseif ($result['value'] == '29') { |
|
2261 | - $error = self::update_from_29(); |
|
2262 | - if ($error != '') return $error; |
|
2263 | - else return self::check_version(true); |
|
2264 | - } elseif ($result['value'] == '30') { |
|
2265 | - $error = self::update_from_30(); |
|
2266 | - if ($error != '') return $error; |
|
2267 | - else return self::check_version(true); |
|
2268 | - } elseif ($result['value'] == '31') { |
|
2269 | - $error = self::update_from_31(); |
|
2270 | - if ($error != '') return $error; |
|
2271 | - else return self::check_version(true); |
|
2272 | - } elseif ($result['value'] == '32') { |
|
2273 | - $error = self::update_from_32(); |
|
2274 | - if ($error != '') return $error; |
|
2275 | - else return self::check_version(true); |
|
2276 | - } elseif ($result['value'] == '33') { |
|
2277 | - $error = self::update_from_33(); |
|
2278 | - if ($error != '') return $error; |
|
2279 | - else return self::check_version(true); |
|
2280 | - } elseif ($result['value'] == '34') { |
|
2281 | - $error = self::update_from_34(); |
|
2282 | - if ($error != '') return $error; |
|
2283 | - else return self::check_version(true); |
|
2284 | - } elseif ($result['value'] == '35') { |
|
2285 | - $error = self::update_from_35(); |
|
2286 | - if ($error != '') return $error; |
|
2287 | - else return self::check_version(true); |
|
2288 | - } elseif ($result['value'] == '36') { |
|
2289 | - $error = self::update_from_36(); |
|
2290 | - if ($error != '') return $error; |
|
2291 | - else return self::check_version(true); |
|
2292 | - } elseif ($result['value'] == '37') { |
|
2293 | - $error = self::update_from_37(); |
|
2294 | - if ($error != '') return $error; |
|
2295 | - else return self::check_version(true); |
|
2296 | - } elseif ($result['value'] == '38') { |
|
2297 | - $error = self::update_from_38(); |
|
2298 | - if ($error != '') return $error; |
|
2299 | - else return self::check_version(true); |
|
2300 | - } elseif ($result['value'] == '39') { |
|
2301 | - $error = self::update_from_39(); |
|
2302 | - if ($error != '') return $error; |
|
2303 | - else return self::check_version(true); |
|
2304 | - } elseif ($result['value'] == '40') { |
|
2305 | - $error = self::update_from_40(); |
|
2306 | - if ($error != '') return $error; |
|
2307 | - else return self::check_version(true); |
|
2308 | - } elseif ($result['value'] == '41') { |
|
2309 | - $error = self::update_from_41(); |
|
2310 | - if ($error != '') return $error; |
|
2311 | - else return self::check_version(true); |
|
2312 | - } elseif ($result['value'] == '42') { |
|
2313 | - $error = self::update_from_42(); |
|
2314 | - if ($error != '') return $error; |
|
2315 | - else return self::check_version(true); |
|
2316 | - } elseif ($result['value'] == '43') { |
|
2317 | - $error = self::update_from_43(); |
|
2318 | - if ($error != '') return $error; |
|
2319 | - else return self::check_version(true); |
|
2320 | - } elseif ($result['value'] == '44') { |
|
2321 | - $error = self::update_from_44(); |
|
2322 | - if ($error != '') return $error; |
|
2323 | - else return self::check_version(true); |
|
2324 | - } else return ''; |
|
2325 | - } |
|
2326 | - else return $result['value']; |
|
2149 | + } |
|
2150 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
2151 | + if ($update) { |
|
2152 | + if ($result['value'] == '2') { |
|
2153 | + $error = self::update_from_2(); |
|
2154 | + if ($error != '') return $error; |
|
2155 | + else return self::check_version(true); |
|
2156 | + } elseif ($result['value'] == '3') { |
|
2157 | + $error = self::update_from_3(); |
|
2158 | + if ($error != '') return $error; |
|
2159 | + else return self::check_version(true); |
|
2160 | + } elseif ($result['value'] == '4') { |
|
2161 | + $error = self::update_from_4(); |
|
2162 | + if ($error != '') return $error; |
|
2163 | + else return self::check_version(true); |
|
2164 | + } elseif ($result['value'] == '5') { |
|
2165 | + $error = self::update_from_5(); |
|
2166 | + if ($error != '') return $error; |
|
2167 | + else return self::check_version(true); |
|
2168 | + } elseif ($result['value'] == '6') { |
|
2169 | + $error = self::update_from_6(); |
|
2170 | + if ($error != '') return $error; |
|
2171 | + else return self::check_version(true); |
|
2172 | + } elseif ($result['value'] == '7') { |
|
2173 | + $error = self::update_from_7(); |
|
2174 | + if ($error != '') return $error; |
|
2175 | + else return self::check_version(true); |
|
2176 | + } elseif ($result['value'] == '8') { |
|
2177 | + $error = self::update_from_8(); |
|
2178 | + if ($error != '') return $error; |
|
2179 | + else return self::check_version(true); |
|
2180 | + } elseif ($result['value'] == '9') { |
|
2181 | + $error = self::update_from_9(); |
|
2182 | + if ($error != '') return $error; |
|
2183 | + else return self::check_version(true); |
|
2184 | + } elseif ($result['value'] == '10') { |
|
2185 | + $error = self::update_from_10(); |
|
2186 | + if ($error != '') return $error; |
|
2187 | + else return self::check_version(true); |
|
2188 | + } elseif ($result['value'] == '11') { |
|
2189 | + $error = self::update_from_11(); |
|
2190 | + if ($error != '') return $error; |
|
2191 | + else return self::check_version(true); |
|
2192 | + } elseif ($result['value'] == '12') { |
|
2193 | + $error = self::update_from_12(); |
|
2194 | + if ($error != '') return $error; |
|
2195 | + else return self::check_version(true); |
|
2196 | + } elseif ($result['value'] == '13') { |
|
2197 | + $error = self::update_from_13(); |
|
2198 | + if ($error != '') return $error; |
|
2199 | + else return self::check_version(true); |
|
2200 | + } elseif ($result['value'] == '14') { |
|
2201 | + $error = self::update_from_14(); |
|
2202 | + if ($error != '') return $error; |
|
2203 | + else return self::check_version(true); |
|
2204 | + } elseif ($result['value'] == '15') { |
|
2205 | + $error = self::update_from_15(); |
|
2206 | + if ($error != '') return $error; |
|
2207 | + else return self::check_version(true); |
|
2208 | + } elseif ($result['value'] == '16') { |
|
2209 | + $error = self::update_from_16(); |
|
2210 | + if ($error != '') return $error; |
|
2211 | + else return self::check_version(true); |
|
2212 | + } elseif ($result['value'] == '17') { |
|
2213 | + $error = self::update_from_17(); |
|
2214 | + if ($error != '') return $error; |
|
2215 | + else return self::check_version(true); |
|
2216 | + } elseif ($result['value'] == '18') { |
|
2217 | + $error = self::update_from_18(); |
|
2218 | + if ($error != '') return $error; |
|
2219 | + else return self::check_version(true); |
|
2220 | + } elseif ($result['value'] == '19') { |
|
2221 | + $error = self::update_from_19(); |
|
2222 | + if ($error != '') return $error; |
|
2223 | + else return self::check_version(true); |
|
2224 | + } elseif ($result['value'] == '20') { |
|
2225 | + $error = self::update_from_20(); |
|
2226 | + if ($error != '') return $error; |
|
2227 | + else return self::check_version(true); |
|
2228 | + } elseif ($result['value'] == '21') { |
|
2229 | + $error = self::update_from_21(); |
|
2230 | + if ($error != '') return $error; |
|
2231 | + else return self::check_version(true); |
|
2232 | + } elseif ($result['value'] == '22') { |
|
2233 | + $error = self::update_from_22(); |
|
2234 | + if ($error != '') return $error; |
|
2235 | + else return self::check_version(true); |
|
2236 | + } elseif ($result['value'] == '23') { |
|
2237 | + $error = self::update_from_23(); |
|
2238 | + if ($error != '') return $error; |
|
2239 | + else return self::check_version(true); |
|
2240 | + } elseif ($result['value'] == '24') { |
|
2241 | + $error = self::update_from_24(); |
|
2242 | + if ($error != '') return $error; |
|
2243 | + else return self::check_version(true); |
|
2244 | + } elseif ($result['value'] == '25') { |
|
2245 | + $error = self::update_from_25(); |
|
2246 | + if ($error != '') return $error; |
|
2247 | + else return self::check_version(true); |
|
2248 | + } elseif ($result['value'] == '26') { |
|
2249 | + $error = self::update_from_26(); |
|
2250 | + if ($error != '') return $error; |
|
2251 | + else return self::check_version(true); |
|
2252 | + } elseif ($result['value'] == '27') { |
|
2253 | + $error = self::update_from_27(); |
|
2254 | + if ($error != '') return $error; |
|
2255 | + else return self::check_version(true); |
|
2256 | + } elseif ($result['value'] == '28') { |
|
2257 | + $error = self::update_from_28(); |
|
2258 | + if ($error != '') return $error; |
|
2259 | + else return self::check_version(true); |
|
2260 | + } elseif ($result['value'] == '29') { |
|
2261 | + $error = self::update_from_29(); |
|
2262 | + if ($error != '') return $error; |
|
2263 | + else return self::check_version(true); |
|
2264 | + } elseif ($result['value'] == '30') { |
|
2265 | + $error = self::update_from_30(); |
|
2266 | + if ($error != '') return $error; |
|
2267 | + else return self::check_version(true); |
|
2268 | + } elseif ($result['value'] == '31') { |
|
2269 | + $error = self::update_from_31(); |
|
2270 | + if ($error != '') return $error; |
|
2271 | + else return self::check_version(true); |
|
2272 | + } elseif ($result['value'] == '32') { |
|
2273 | + $error = self::update_from_32(); |
|
2274 | + if ($error != '') return $error; |
|
2275 | + else return self::check_version(true); |
|
2276 | + } elseif ($result['value'] == '33') { |
|
2277 | + $error = self::update_from_33(); |
|
2278 | + if ($error != '') return $error; |
|
2279 | + else return self::check_version(true); |
|
2280 | + } elseif ($result['value'] == '34') { |
|
2281 | + $error = self::update_from_34(); |
|
2282 | + if ($error != '') return $error; |
|
2283 | + else return self::check_version(true); |
|
2284 | + } elseif ($result['value'] == '35') { |
|
2285 | + $error = self::update_from_35(); |
|
2286 | + if ($error != '') return $error; |
|
2287 | + else return self::check_version(true); |
|
2288 | + } elseif ($result['value'] == '36') { |
|
2289 | + $error = self::update_from_36(); |
|
2290 | + if ($error != '') return $error; |
|
2291 | + else return self::check_version(true); |
|
2292 | + } elseif ($result['value'] == '37') { |
|
2293 | + $error = self::update_from_37(); |
|
2294 | + if ($error != '') return $error; |
|
2295 | + else return self::check_version(true); |
|
2296 | + } elseif ($result['value'] == '38') { |
|
2297 | + $error = self::update_from_38(); |
|
2298 | + if ($error != '') return $error; |
|
2299 | + else return self::check_version(true); |
|
2300 | + } elseif ($result['value'] == '39') { |
|
2301 | + $error = self::update_from_39(); |
|
2302 | + if ($error != '') return $error; |
|
2303 | + else return self::check_version(true); |
|
2304 | + } elseif ($result['value'] == '40') { |
|
2305 | + $error = self::update_from_40(); |
|
2306 | + if ($error != '') return $error; |
|
2307 | + else return self::check_version(true); |
|
2308 | + } elseif ($result['value'] == '41') { |
|
2309 | + $error = self::update_from_41(); |
|
2310 | + if ($error != '') return $error; |
|
2311 | + else return self::check_version(true); |
|
2312 | + } elseif ($result['value'] == '42') { |
|
2313 | + $error = self::update_from_42(); |
|
2314 | + if ($error != '') return $error; |
|
2315 | + else return self::check_version(true); |
|
2316 | + } elseif ($result['value'] == '43') { |
|
2317 | + $error = self::update_from_43(); |
|
2318 | + if ($error != '') return $error; |
|
2319 | + else return self::check_version(true); |
|
2320 | + } elseif ($result['value'] == '44') { |
|
2321 | + $error = self::update_from_44(); |
|
2322 | + if ($error != '') return $error; |
|
2323 | + else return self::check_version(true); |
|
2324 | + } else return ''; |
|
2325 | + } |
|
2326 | + else return $result['value']; |
|
2327 | 2327 | } |
2328 | 2328 | |
2329 | - } else return $version; |
|
2330 | - } |
|
2329 | + } else return $version; |
|
2330 | + } |
|
2331 | 2331 | |
2332 | 2332 | } |
2333 | 2333 | //echo update_schema::check_version(); |
@@ -7,35 +7,35 @@ discard block |
||
7 | 7 | public $latest_schema = 45; |
8 | 8 | |
9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | - global $globalDBdriver, $globalNoDB; |
|
11 | - if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
10 | + global $globalDBdriver, $globalNoDB; |
|
11 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
12 | 12 | $this->db = null; |
13 | - } else { |
|
13 | + } else { |
|
14 | 14 | if ($dbc === null) { |
15 | - if ($this->db === null && $dbname === null) { |
|
15 | + if ($this->db === null && $dbname === null) { |
|
16 | 16 | if ($user === null && $pass === null) { |
17 | - $this->createDBConnection(); |
|
17 | + $this->createDBConnection(); |
|
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null,$user,$pass); |
|
20 | 20 | } |
21 | - } else { |
|
21 | + } else { |
|
22 | 22 | $this->createDBConnection($dbname); |
23 | - } |
|
23 | + } |
|
24 | 24 | } elseif ($dbname === null || $dbname === 'default') { |
25 | - $this->db = $dbc; |
|
26 | - if ($this->connectionExists() === false) { |
|
25 | + $this->db = $dbc; |
|
26 | + if ($this->connectionExists() === false) { |
|
27 | 27 | /* |
28 | 28 | echo 'Restart Connection !!!'."\n"; |
29 | 29 | $e = new \Exception; |
30 | 30 | var_dump($e->getTraceAsString()); |
31 | 31 | */ |
32 | 32 | $this->createDBConnection(); |
33 | - } |
|
33 | + } |
|
34 | 34 | } else { |
35 | - //$this->connectionExists(); |
|
36 | - $this->dbs[$dbname] = $dbc; |
|
35 | + //$this->connectionExists(); |
|
36 | + $this->dbs[$dbname] = $dbc; |
|
37 | + } |
|
37 | 38 | } |
38 | - } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function db() { |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | - * Creates the database connection |
|
60 | - * |
|
61 | - * @return Boolean of the database connection |
|
62 | - * |
|
63 | - */ |
|
59 | + * Creates the database connection |
|
60 | + * |
|
61 | + * @return Boolean of the database connection |
|
62 | + * |
|
63 | + */ |
|
64 | 64 | |
65 | 65 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
66 | 66 | { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | if($results->rowCount()>0) { |
160 | - return true; |
|
160 | + return true; |
|
161 | 161 | } |
162 | 162 | else return false; |
163 | 163 | } |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | $sum = $sum->fetchColumn(0); |
175 | 175 | } else $sum = 0; |
176 | 176 | if (intval($sum) !== 2) { |
177 | - return false; |
|
177 | + return false; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | } catch(PDOException $e) { |
181 | 181 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
182 | - throw $e; |
|
183 | - } |
|
184 | - //echo 'error ! '.$e->getMessage(); |
|
182 | + throw $e; |
|
183 | + } |
|
184 | + //echo 'error ! '.$e->getMessage(); |
|
185 | 185 | return false; |
186 | 186 | } |
187 | 187 | return true; |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | $version = 0; |
286 | 286 | if ($this->tableExists('aircraft')) { |
287 | 287 | if (!$this->tableExists('config')) { |
288 | - $version = '1'; |
|
289 | - return $version; |
|
288 | + $version = '1'; |
|
289 | + return $version; |
|
290 | 290 | } else { |
291 | 291 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
292 | 292 | try { |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | * @return Boolean if latest version or not |
308 | 308 | */ |
309 | 309 | public function latest() { |
310 | - global $globalNoDB; |
|
311 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
312 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
313 | - else return false; |
|
310 | + global $globalNoDB; |
|
311 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
312 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
313 | + else return false; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | } |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
17 | 17 | $Connection = new Connection($dbc); |
18 | 18 | $this->db = $Connection->db(); |
19 | - } |
|
19 | + } |
|
20 | 20 | |
21 | 21 | public function addLastStatsUpdate($type,$stats_date) { |
22 | - $query = "DELETE FROM config WHERE name = :type; |
|
22 | + $query = "DELETE FROM config WHERE name = :type; |
|
23 | 23 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
24 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
25 | - try { |
|
26 | - $sth = $this->db->prepare($query); |
|
27 | - $sth->execute($query_values); |
|
28 | - } catch(PDOException $e) { |
|
29 | - return "error : ".$e->getMessage(); |
|
30 | - } |
|
31 | - } |
|
24 | + $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
25 | + try { |
|
26 | + $sth = $this->db->prepare($query); |
|
27 | + $sth->execute($query_values); |
|
28 | + } catch(PDOException $e) { |
|
29 | + return "error : ".$e->getMessage(); |
|
30 | + } |
|
31 | + } |
|
32 | 32 | |
33 | 33 | public function getLastStatsUpdate($type = 'last_update_stats') { |
34 | - $query = "SELECT value FROM config WHERE name = :type"; |
|
35 | - try { |
|
36 | - $sth = $this->db->prepare($query); |
|
37 | - $sth->execute(array(':type' => $type)); |
|
38 | - } catch(PDOException $e) { |
|
39 | - echo "error : ".$e->getMessage(); |
|
40 | - } |
|
41 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
42 | - return $all; |
|
43 | - } |
|
44 | - public function deleteStats($filter_name = '') { |
|
45 | - /* |
|
34 | + $query = "SELECT value FROM config WHERE name = :type"; |
|
35 | + try { |
|
36 | + $sth = $this->db->prepare($query); |
|
37 | + $sth->execute(array(':type' => $type)); |
|
38 | + } catch(PDOException $e) { |
|
39 | + echo "error : ".$e->getMessage(); |
|
40 | + } |
|
41 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
42 | + return $all; |
|
43 | + } |
|
44 | + public function deleteStats($filter_name = '') { |
|
45 | + /* |
|
46 | 46 | $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
47 | 47 | try { |
48 | 48 | $sth = $this->db->prepare($query); |
@@ -51,109 +51,109 @@ discard block |
||
51 | 51 | return "error : ".$e->getMessage(); |
52 | 52 | } |
53 | 53 | */ |
54 | - $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
55 | - try { |
|
56 | - $sth = $this->db->prepare($query); |
|
57 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
58 | - } catch(PDOException $e) { |
|
59 | - return "error : ".$e->getMessage(); |
|
60 | - } |
|
61 | - } |
|
62 | - public function deleteOldStats($filter_name = '') { |
|
63 | - if ($filter_name == '') { |
|
64 | - $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
65 | - } else { |
|
66 | - $query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'"; |
|
67 | - } |
|
68 | - try { |
|
69 | - $sth = $this->db->prepare($query); |
|
70 | - $sth->execute(); |
|
71 | - } catch(PDOException $e) { |
|
72 | - return "error : ".$e->getMessage(); |
|
73 | - } |
|
54 | + $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
55 | + try { |
|
56 | + $sth = $this->db->prepare($query); |
|
57 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
58 | + } catch(PDOException $e) { |
|
59 | + return "error : ".$e->getMessage(); |
|
60 | + } |
|
61 | + } |
|
62 | + public function deleteOldStats($filter_name = '') { |
|
63 | + if ($filter_name == '') { |
|
64 | + $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
65 | + } else { |
|
66 | + $query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'"; |
|
67 | + } |
|
68 | + try { |
|
69 | + $sth = $this->db->prepare($query); |
|
70 | + $sth->execute(); |
|
71 | + } catch(PDOException $e) { |
|
72 | + return "error : ".$e->getMessage(); |
|
73 | + } |
|
74 | 74 | |
75 | - $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
76 | - try { |
|
77 | - $sth = $this->db->prepare($query); |
|
78 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error : ".$e->getMessage(); |
|
81 | - } |
|
82 | - } |
|
75 | + $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
76 | + try { |
|
77 | + $sth = $this->db->prepare($query); |
|
78 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error : ".$e->getMessage(); |
|
81 | + } |
|
82 | + } |
|
83 | 83 | public function getAllAirlineNames($filter_name = '') { |
84 | 84 | if ($filter_name == '') $filter_name = $this->filter_name; |
85 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
86 | - try { |
|
87 | - $sth = $this->db->prepare($query); |
|
88 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
89 | - } catch(PDOException $e) { |
|
90 | - echo "error : ".$e->getMessage(); |
|
91 | - } |
|
92 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
93 | - return $all; |
|
94 | - } |
|
85 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
86 | + try { |
|
87 | + $sth = $this->db->prepare($query); |
|
88 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
89 | + } catch(PDOException $e) { |
|
90 | + echo "error : ".$e->getMessage(); |
|
91 | + } |
|
92 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
93 | + return $all; |
|
94 | + } |
|
95 | 95 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
96 | 96 | if ($filter_name == '') $filter_name = $this->filter_name; |
97 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
98 | - try { |
|
99 | - $sth = $this->db->prepare($query); |
|
100 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
101 | - } catch(PDOException $e) { |
|
102 | - echo "error : ".$e->getMessage(); |
|
103 | - } |
|
104 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
105 | - return $all; |
|
106 | - } |
|
97 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
98 | + try { |
|
99 | + $sth = $this->db->prepare($query); |
|
100 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
101 | + } catch(PDOException $e) { |
|
102 | + echo "error : ".$e->getMessage(); |
|
103 | + } |
|
104 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
105 | + return $all; |
|
106 | + } |
|
107 | 107 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
108 | 108 | if ($filter_name == '') $filter_name = $this->filter_name; |
109 | - $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
|
110 | - try { |
|
111 | - $sth = $this->db->prepare($query); |
|
112 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
113 | - } catch(PDOException $e) { |
|
114 | - echo "error : ".$e->getMessage(); |
|
115 | - } |
|
116 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
117 | - return $all; |
|
118 | - } |
|
109 | + $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
|
110 | + try { |
|
111 | + $sth = $this->db->prepare($query); |
|
112 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
113 | + } catch(PDOException $e) { |
|
114 | + echo "error : ".$e->getMessage(); |
|
115 | + } |
|
116 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
117 | + return $all; |
|
118 | + } |
|
119 | 119 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
120 | 120 | if ($filter_name == '') $filter_name = $this->filter_name; |
121 | - $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
122 | - try { |
|
123 | - $sth = $this->db->prepare($query); |
|
124 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
125 | - } catch(PDOException $e) { |
|
126 | - echo "error : ".$e->getMessage(); |
|
127 | - } |
|
128 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
129 | - return $all; |
|
130 | - } |
|
121 | + $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
122 | + try { |
|
123 | + $sth = $this->db->prepare($query); |
|
124 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
125 | + } catch(PDOException $e) { |
|
126 | + echo "error : ".$e->getMessage(); |
|
127 | + } |
|
128 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
129 | + return $all; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
133 | 133 | if ($filter_name == '') $filter_name = $this->filter_name; |
134 | - $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
|
135 | - try { |
|
136 | - $sth = $this->db->prepare($query); |
|
137 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
138 | - } catch(PDOException $e) { |
|
139 | - echo "error : ".$e->getMessage(); |
|
140 | - } |
|
141 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
142 | - return $all; |
|
143 | - } |
|
134 | + $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
|
135 | + try { |
|
136 | + $sth = $this->db->prepare($query); |
|
137 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
138 | + } catch(PDOException $e) { |
|
139 | + echo "error : ".$e->getMessage(); |
|
140 | + } |
|
141 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
142 | + return $all; |
|
143 | + } |
|
144 | 144 | |
145 | 145 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
146 | 146 | if ($filter_name == '') $filter_name = $this->filter_name; |
147 | - $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
|
148 | - try { |
|
149 | - $sth = $this->db->prepare($query); |
|
150 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
151 | - } catch(PDOException $e) { |
|
152 | - echo "error : ".$e->getMessage(); |
|
153 | - } |
|
154 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
155 | - return $all; |
|
156 | - } |
|
147 | + $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
|
148 | + try { |
|
149 | + $sth = $this->db->prepare($query); |
|
150 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
151 | + } catch(PDOException $e) { |
|
152 | + echo "error : ".$e->getMessage(); |
|
153 | + } |
|
154 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
155 | + return $all; |
|
156 | + } |
|
157 | 157 | |
158 | 158 | |
159 | 159 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
@@ -170,16 +170,16 @@ discard block |
||
170 | 170 | } |
171 | 171 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
172 | 172 | } else $all = array(); |
173 | - if (empty($all)) { |
|
174 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
175 | - if ($filter_name != '') { |
|
176 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
177 | - } |
|
178 | - $Spotter = new Spotter($this->db); |
|
179 | - //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
|
180 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
181 | - } |
|
182 | - return $all; |
|
173 | + if (empty($all)) { |
|
174 | + $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
175 | + if ($filter_name != '') { |
|
176 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
177 | + } |
|
178 | + $Spotter = new Spotter($this->db); |
|
179 | + //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
|
180 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
181 | + } |
|
182 | + return $all; |
|
183 | 183 | } |
184 | 184 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
185 | 185 | global $globalStatsFilters; |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | } |
196 | 196 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
197 | 197 | } else $all = array(); |
198 | - if (empty($all)) { |
|
199 | - $Spotter = new Spotter($this->db); |
|
200 | - $filters = array(); |
|
201 | - $filters = array('year' => $year,'month' => $month); |
|
202 | - if ($filter_name != '') { |
|
203 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
204 | - } |
|
205 | - //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
|
206 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
207 | - } |
|
208 | - return $all; |
|
198 | + if (empty($all)) { |
|
199 | + $Spotter = new Spotter($this->db); |
|
200 | + $filters = array(); |
|
201 | + $filters = array('year' => $year,'month' => $month); |
|
202 | + if ($filter_name != '') { |
|
203 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
204 | + } |
|
205 | + //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
|
206 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
207 | + } |
|
208 | + return $all; |
|
209 | 209 | } |
210 | 210 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
211 | 211 | global $globalStatsFilters; |
@@ -247,39 +247,39 @@ discard block |
||
247 | 247 | } |
248 | 248 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
249 | 249 | } else $all = array(); |
250 | - if (empty($all)) { |
|
250 | + if (empty($all)) { |
|
251 | 251 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
252 | 252 | if ($filter_name != '') { |
253 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
253 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
254 | 254 | } |
255 | 255 | $Spotter = new Spotter($this->db); |
256 | 256 | //$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
257 | 257 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
258 | - } |
|
259 | - return $all; |
|
258 | + } |
|
259 | + return $all; |
|
260 | 260 | } |
261 | 261 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
262 | 262 | global $globalStatsFilters; |
263 | 263 | if ($filter_name == '') $filter_name = $this->filter_name; |
264 | 264 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
265 | 265 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
266 | - try { |
|
267 | - $sth = $this->db->prepare($query); |
|
268 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
269 | - } catch(PDOException $e) { |
|
270 | - echo "error : ".$e->getMessage(); |
|
271 | - } |
|
272 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
273 | - if (empty($all)) { |
|
266 | + try { |
|
267 | + $sth = $this->db->prepare($query); |
|
268 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
269 | + } catch(PDOException $e) { |
|
270 | + echo "error : ".$e->getMessage(); |
|
271 | + } |
|
272 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
273 | + if (empty($all)) { |
|
274 | 274 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
275 | 275 | if ($filter_name != '') { |
276 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
276 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
277 | 277 | } |
278 | 278 | $Spotter = new Spotter($this->db); |
279 | 279 | //$all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
280 | 280 | $all = $Spotter->countAllDepartureCountries($filters); |
281 | - } |
|
282 | - return $all; |
|
281 | + } |
|
282 | + return $all; |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
@@ -305,17 +305,17 @@ discard block |
||
305 | 305 | } |
306 | 306 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
307 | 307 | } else $all = array(); |
308 | - if (empty($all)) { |
|
309 | - $Spotter = new Spotter($this->db); |
|
310 | - $filters = array(); |
|
308 | + if (empty($all)) { |
|
309 | + $Spotter = new Spotter($this->db); |
|
310 | + $filters = array(); |
|
311 | 311 | $filters = array('year' => $year,'month' => $month); |
312 | - if ($filter_name != '') { |
|
313 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
312 | + if ($filter_name != '') { |
|
313 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
314 | 314 | } |
315 | 315 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
316 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
317 | - } |
|
318 | - return $all; |
|
316 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
317 | + } |
|
318 | + return $all; |
|
319 | 319 | } |
320 | 320 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
321 | 321 | global $globalStatsFilters; |
@@ -331,16 +331,16 @@ discard block |
||
331 | 331 | } |
332 | 332 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
333 | 333 | } else $all = array(); |
334 | - if (empty($all)) { |
|
334 | + if (empty($all)) { |
|
335 | 335 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
336 | 336 | if ($filter_name != '') { |
337 | 337 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
338 | 338 | } |
339 | - $Spotter = new Spotter($this->db); |
|
340 | - //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
|
341 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
342 | - } |
|
343 | - return $all; |
|
339 | + $Spotter = new Spotter($this->db); |
|
340 | + //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
|
341 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
342 | + } |
|
343 | + return $all; |
|
344 | 344 | } |
345 | 345 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
346 | 346 | global $globalStatsFilters; |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | echo "error : ".$e->getMessage(); |
382 | 382 | } |
383 | 383 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
384 | - /* |
|
384 | + /* |
|
385 | 385 | if (empty($all)) { |
386 | 386 | $Spotter = new Spotter($this->db); |
387 | 387 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -433,16 +433,16 @@ discard block |
||
433 | 433 | } |
434 | 434 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
435 | 435 | } else $all = array(); |
436 | - if (empty($all)) { |
|
436 | + if (empty($all)) { |
|
437 | 437 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
438 | 438 | if ($filter_name != '') { |
439 | 439 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
440 | 440 | } |
441 | - $Spotter = new Spotter($this->db); |
|
442 | - //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
|
443 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
444 | - } |
|
445 | - return $all; |
|
441 | + $Spotter = new Spotter($this->db); |
|
442 | + //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
|
443 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
444 | + } |
|
445 | + return $all; |
|
446 | 446 | } |
447 | 447 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
448 | 448 | global $globalStatsFilters; |
@@ -458,35 +458,35 @@ discard block |
||
458 | 458 | } |
459 | 459 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
460 | 460 | } else $all = array(); |
461 | - if (empty($all)) { |
|
461 | + if (empty($all)) { |
|
462 | 462 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
463 | - if ($filter_name != '') { |
|
464 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
463 | + if ($filter_name != '') { |
|
464 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
465 | 465 | } |
466 | - $Spotter = new Spotter($this->db); |
|
466 | + $Spotter = new Spotter($this->db); |
|
467 | 467 | // $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
468 | 468 | // $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
469 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
470 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
471 | - $all = array(); |
|
472 | - foreach ($pall as $value) { |
|
473 | - $icao = $value['airport_departure_icao']; |
|
474 | - $all[$icao] = $value; |
|
475 | - } |
|
469 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
470 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
471 | + $all = array(); |
|
472 | + foreach ($pall as $value) { |
|
473 | + $icao = $value['airport_departure_icao']; |
|
474 | + $all[$icao] = $value; |
|
475 | + } |
|
476 | 476 | |
477 | - foreach ($dall as $value) { |
|
478 | - $icao = $value['airport_departure_icao']; |
|
479 | - if (isset($all[$icao])) { |
|
480 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
481 | - } else $all[$icao] = $value; |
|
482 | - } |
|
483 | - $count = array(); |
|
484 | - foreach ($all as $key => $row) { |
|
485 | - $count[$key] = $row['airport_departure_icao_count']; |
|
486 | - } |
|
487 | - array_multisort($count,SORT_DESC,$all); |
|
488 | - } |
|
489 | - return $all; |
|
477 | + foreach ($dall as $value) { |
|
478 | + $icao = $value['airport_departure_icao']; |
|
479 | + if (isset($all[$icao])) { |
|
480 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
481 | + } else $all[$icao] = $value; |
|
482 | + } |
|
483 | + $count = array(); |
|
484 | + foreach ($all as $key => $row) { |
|
485 | + $count[$key] = $row['airport_departure_icao_count']; |
|
486 | + } |
|
487 | + array_multisort($count,SORT_DESC,$all); |
|
488 | + } |
|
489 | + return $all; |
|
490 | 490 | } |
491 | 491 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
492 | 492 | global $globalStatsFilters; |
@@ -512,26 +512,26 @@ discard block |
||
512 | 512 | // $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
513 | 513 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
514 | 514 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
515 | - $all = array(); |
|
516 | - foreach ($pall as $value) { |
|
517 | - $icao = $value['airport_arrival_icao']; |
|
518 | - $all[$icao] = $value; |
|
519 | - } |
|
515 | + $all = array(); |
|
516 | + foreach ($pall as $value) { |
|
517 | + $icao = $value['airport_arrival_icao']; |
|
518 | + $all[$icao] = $value; |
|
519 | + } |
|
520 | 520 | |
521 | - foreach ($dall as $value) { |
|
522 | - $icao = $value['airport_arrival_icao']; |
|
523 | - if (isset($all[$icao])) { |
|
524 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
525 | - } else $all[$icao] = $value; |
|
526 | - } |
|
527 | - $count = array(); |
|
528 | - foreach ($all as $key => $row) { |
|
529 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
530 | - } |
|
531 | - array_multisort($count,SORT_DESC,$all); |
|
532 | - } |
|
521 | + foreach ($dall as $value) { |
|
522 | + $icao = $value['airport_arrival_icao']; |
|
523 | + if (isset($all[$icao])) { |
|
524 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
525 | + } else $all[$icao] = $value; |
|
526 | + } |
|
527 | + $count = array(); |
|
528 | + foreach ($all as $key => $row) { |
|
529 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
530 | + } |
|
531 | + array_multisort($count,SORT_DESC,$all); |
|
532 | + } |
|
533 | 533 | |
534 | - return $all; |
|
534 | + return $all; |
|
535 | 535 | } |
536 | 536 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
537 | 537 | global $globalDBdriver, $globalStatsFilters; |
@@ -544,23 +544,23 @@ discard block |
||
544 | 544 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
545 | 545 | } |
546 | 546 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
547 | - try { |
|
548 | - $sth = $this->db->prepare($query); |
|
549 | - $sth->execute($query_data); |
|
550 | - } catch(PDOException $e) { |
|
551 | - echo "error : ".$e->getMessage(); |
|
552 | - } |
|
553 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
554 | - if (empty($all)) { |
|
547 | + try { |
|
548 | + $sth = $this->db->prepare($query); |
|
549 | + $sth->execute($query_data); |
|
550 | + } catch(PDOException $e) { |
|
551 | + echo "error : ".$e->getMessage(); |
|
552 | + } |
|
553 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
554 | + if (empty($all)) { |
|
555 | 555 | $filters = array('airlines' => array($stats_airline)); |
556 | 556 | if ($filter_name != '') { |
557 | 557 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
558 | 558 | } |
559 | - $Spotter = new Spotter($this->db); |
|
560 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
561 | - } |
|
559 | + $Spotter = new Spotter($this->db); |
|
560 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
561 | + } |
|
562 | 562 | |
563 | - return $all; |
|
563 | + return $all; |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -568,22 +568,22 @@ discard block |
||
568 | 568 | if ($filter_name == '') $filter_name = $this->filter_name; |
569 | 569 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
570 | 570 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
571 | - try { |
|
572 | - $sth = $this->db->prepare($query); |
|
573 | - $sth->execute($query_data); |
|
574 | - } catch(PDOException $e) { |
|
575 | - echo "error : ".$e->getMessage(); |
|
576 | - } |
|
577 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
578 | - if (empty($all)) { |
|
571 | + try { |
|
572 | + $sth = $this->db->prepare($query); |
|
573 | + $sth->execute($query_data); |
|
574 | + } catch(PDOException $e) { |
|
575 | + echo "error : ".$e->getMessage(); |
|
576 | + } |
|
577 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
578 | + if (empty($all)) { |
|
579 | 579 | $filters = array('airlines' => array($stats_airline)); |
580 | 580 | if ($filter_name != '') { |
581 | 581 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
582 | 582 | } |
583 | - $Spotter = new Spotter($this->db); |
|
584 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
585 | - } |
|
586 | - return $all; |
|
583 | + $Spotter = new Spotter($this->db); |
|
584 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
585 | + } |
|
586 | + return $all; |
|
587 | 587 | } |
588 | 588 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
589 | 589 | global $globalDBdriver, $globalStatsFilters; |
@@ -594,66 +594,66 @@ discard block |
||
594 | 594 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
595 | 595 | } |
596 | 596 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
597 | - try { |
|
598 | - $sth = $this->db->prepare($query); |
|
599 | - $sth->execute($query_data); |
|
600 | - } catch(PDOException $e) { |
|
601 | - echo "error : ".$e->getMessage(); |
|
602 | - } |
|
603 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
604 | - if (empty($all)) { |
|
597 | + try { |
|
598 | + $sth = $this->db->prepare($query); |
|
599 | + $sth->execute($query_data); |
|
600 | + } catch(PDOException $e) { |
|
601 | + echo "error : ".$e->getMessage(); |
|
602 | + } |
|
603 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
604 | + if (empty($all)) { |
|
605 | 605 | $filters = array('airlines' => array($stats_airline)); |
606 | 606 | if ($filter_name != '') { |
607 | 607 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
608 | 608 | } |
609 | - $Spotter = new Spotter($this->db); |
|
610 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
611 | - } |
|
612 | - return $all; |
|
609 | + $Spotter = new Spotter($this->db); |
|
610 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
611 | + } |
|
612 | + return $all; |
|
613 | 613 | } |
614 | 614 | public function countAllDates($stats_airline = '',$filter_name = '') { |
615 | 615 | global $globalStatsFilters; |
616 | 616 | if ($filter_name == '') $filter_name = $this->filter_name; |
617 | 617 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC"; |
618 | 618 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
619 | - try { |
|
620 | - $sth = $this->db->prepare($query); |
|
621 | - $sth->execute($query_data); |
|
622 | - } catch(PDOException $e) { |
|
623 | - echo "error : ".$e->getMessage(); |
|
624 | - } |
|
625 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
626 | - if (empty($all)) { |
|
619 | + try { |
|
620 | + $sth = $this->db->prepare($query); |
|
621 | + $sth->execute($query_data); |
|
622 | + } catch(PDOException $e) { |
|
623 | + echo "error : ".$e->getMessage(); |
|
624 | + } |
|
625 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
626 | + if (empty($all)) { |
|
627 | 627 | $filters = array('airlines' => array($stats_airline)); |
628 | 628 | if ($filter_name != '') { |
629 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
629 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
630 | 630 | } |
631 | - $Spotter = new Spotter($this->db); |
|
632 | - $all = $Spotter->countAllDates($filters); |
|
633 | - } |
|
634 | - return $all; |
|
631 | + $Spotter = new Spotter($this->db); |
|
632 | + $all = $Spotter->countAllDates($filters); |
|
633 | + } |
|
634 | + return $all; |
|
635 | 635 | } |
636 | 636 | public function countAllDatesByAirlines($filter_name = '') { |
637 | 637 | global $globalStatsFilters; |
638 | 638 | if ($filter_name == '') $filter_name = $this->filter_name; |
639 | 639 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
640 | 640 | $query_data = array('filter_name' => $filter_name); |
641 | - try { |
|
642 | - $sth = $this->db->prepare($query); |
|
643 | - $sth->execute($query_data); |
|
644 | - } catch(PDOException $e) { |
|
645 | - echo "error : ".$e->getMessage(); |
|
646 | - } |
|
647 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
648 | - if (empty($all)) { |
|
649 | - $filters = array(); |
|
650 | - if ($filter_name != '') { |
|
651 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
641 | + try { |
|
642 | + $sth = $this->db->prepare($query); |
|
643 | + $sth->execute($query_data); |
|
644 | + } catch(PDOException $e) { |
|
645 | + echo "error : ".$e->getMessage(); |
|
646 | + } |
|
647 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
648 | + if (empty($all)) { |
|
649 | + $filters = array(); |
|
650 | + if ($filter_name != '') { |
|
651 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
652 | 652 | } |
653 | - $Spotter = new Spotter($this->db); |
|
654 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
655 | - } |
|
656 | - return $all; |
|
653 | + $Spotter = new Spotter($this->db); |
|
654 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
655 | + } |
|
656 | + return $all; |
|
657 | 657 | } |
658 | 658 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
659 | 659 | global $globalStatsFilters, $globalDBdriver; |
@@ -663,24 +663,24 @@ discard block |
||
663 | 663 | } else { |
664 | 664 | $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC"; |
665 | 665 | } |
666 | - try { |
|
667 | - $sth = $this->db->prepare($query); |
|
668 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
669 | - } catch(PDOException $e) { |
|
670 | - echo "error : ".$e->getMessage(); |
|
671 | - } |
|
672 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
666 | + try { |
|
667 | + $sth = $this->db->prepare($query); |
|
668 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
669 | + } catch(PDOException $e) { |
|
670 | + echo "error : ".$e->getMessage(); |
|
671 | + } |
|
672 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
673 | 673 | |
674 | - if (empty($all)) { |
|
674 | + if (empty($all)) { |
|
675 | 675 | $filters = array('airlines' => array($stats_airline)); |
676 | 676 | if ($filter_name != '') { |
677 | 677 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
678 | 678 | } |
679 | - $Spotter = new Spotter($this->db); |
|
680 | - $all = $Spotter->countAllMonths($filters); |
|
681 | - } |
|
679 | + $Spotter = new Spotter($this->db); |
|
680 | + $all = $Spotter->countAllMonths($filters); |
|
681 | + } |
|
682 | 682 | |
683 | - return $all; |
|
683 | + return $all; |
|
684 | 684 | } |
685 | 685 | public function countFatalitiesLast12Months() { |
686 | 686 | global $globalStatsFilters, $globalDBdriver; |
@@ -689,19 +689,19 @@ discard block |
||
689 | 689 | } else { |
690 | 690 | $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year, EXTRACT(MONTH FROM stats_date) as month,cnt as count FROM stats WHERE stats_type = 'fatalities_bymonth' ORDER BY stats_date"; |
691 | 691 | } |
692 | - try { |
|
693 | - $sth = $this->db->prepare($query); |
|
694 | - $sth->execute(); |
|
695 | - } catch(PDOException $e) { |
|
696 | - echo "error : ".$e->getMessage(); |
|
697 | - } |
|
698 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
692 | + try { |
|
693 | + $sth = $this->db->prepare($query); |
|
694 | + $sth->execute(); |
|
695 | + } catch(PDOException $e) { |
|
696 | + echo "error : ".$e->getMessage(); |
|
697 | + } |
|
698 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
699 | 699 | |
700 | - if (empty($all)) { |
|
701 | - $Accident = new Accident($this->db); |
|
702 | - $all = $Accident->countFatalitiesLast12Months(); |
|
703 | - } |
|
704 | - return $all; |
|
700 | + if (empty($all)) { |
|
701 | + $Accident = new Accident($this->db); |
|
702 | + $all = $Accident->countFatalitiesLast12Months(); |
|
703 | + } |
|
704 | + return $all; |
|
705 | 705 | } |
706 | 706 | public function countFatalitiesByYear() { |
707 | 707 | global $globalStatsFilters, $globalDBdriver; |
@@ -710,40 +710,40 @@ discard block |
||
710 | 710 | } else { |
711 | 711 | $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year, cnt as count FROM stats WHERE stats_type = 'fatalities_byyear' ORDER BY stats_date"; |
712 | 712 | } |
713 | - try { |
|
714 | - $sth = $this->db->prepare($query); |
|
715 | - $sth->execute(); |
|
716 | - } catch(PDOException $e) { |
|
717 | - echo "error : ".$e->getMessage(); |
|
718 | - } |
|
719 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
713 | + try { |
|
714 | + $sth = $this->db->prepare($query); |
|
715 | + $sth->execute(); |
|
716 | + } catch(PDOException $e) { |
|
717 | + echo "error : ".$e->getMessage(); |
|
718 | + } |
|
719 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
720 | 720 | |
721 | - if (empty($all)) { |
|
722 | - $Accident = new Accident($this->db); |
|
723 | - $all = $Accident->countFatalitiesByYear(); |
|
724 | - } |
|
725 | - return $all; |
|
721 | + if (empty($all)) { |
|
722 | + $Accident = new Accident($this->db); |
|
723 | + $all = $Accident->countFatalitiesByYear(); |
|
724 | + } |
|
725 | + return $all; |
|
726 | 726 | } |
727 | 727 | public function countAllMilitaryMonths($filter_name = '') { |
728 | 728 | global $globalStatsFilters; |
729 | 729 | if ($filter_name == '') $filter_name = $this->filter_name; |
730 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
|
731 | - try { |
|
732 | - $sth = $this->db->prepare($query); |
|
733 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
734 | - } catch(PDOException $e) { |
|
735 | - echo "error : ".$e->getMessage(); |
|
736 | - } |
|
737 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
738 | - if (empty($all)) { |
|
739 | - $filters = array(); |
|
740 | - if ($filter_name != '') { |
|
741 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
730 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
|
731 | + try { |
|
732 | + $sth = $this->db->prepare($query); |
|
733 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
734 | + } catch(PDOException $e) { |
|
735 | + echo "error : ".$e->getMessage(); |
|
736 | + } |
|
737 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
738 | + if (empty($all)) { |
|
739 | + $filters = array(); |
|
740 | + if ($filter_name != '') { |
|
741 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
742 | 742 | } |
743 | - $Spotter = new Spotter($this->db); |
|
744 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
745 | - } |
|
746 | - return $all; |
|
743 | + $Spotter = new Spotter($this->db); |
|
744 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
745 | + } |
|
746 | + return $all; |
|
747 | 747 | } |
748 | 748 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
749 | 749 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -759,22 +759,22 @@ discard block |
||
759 | 759 | } |
760 | 760 | } |
761 | 761 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
762 | - try { |
|
763 | - $sth = $this->db->prepare($query); |
|
764 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
765 | - } catch(PDOException $e) { |
|
766 | - echo "error : ".$e->getMessage(); |
|
767 | - } |
|
768 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
769 | - if (empty($all)) { |
|
762 | + try { |
|
763 | + $sth = $this->db->prepare($query); |
|
764 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
765 | + } catch(PDOException $e) { |
|
766 | + echo "error : ".$e->getMessage(); |
|
767 | + } |
|
768 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
769 | + if (empty($all)) { |
|
770 | 770 | $filters = array('airlines' => array($stats_airline)); |
771 | 771 | if ($filter_name != '') { |
772 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
772 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
773 | 773 | } |
774 | - $Spotter = new Spotter($this->db); |
|
775 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
776 | - } |
|
777 | - return $all; |
|
774 | + $Spotter = new Spotter($this->db); |
|
775 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
776 | + } |
|
777 | + return $all; |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
@@ -799,10 +799,10 @@ discard block |
||
799 | 799 | if ($year == '') $year = date('Y'); |
800 | 800 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
801 | 801 | if (empty($all)) { |
802 | - $filters = array(); |
|
802 | + $filters = array(); |
|
803 | 803 | $filters = array('year' => $year,'month' => $month); |
804 | - if ($filter_name != '') { |
|
805 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
804 | + if ($filter_name != '') { |
|
805 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
806 | 806 | } |
807 | 807 | $Spotter = new Spotter($this->db); |
808 | 808 | //$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -866,10 +866,10 @@ discard block |
||
866 | 866 | $all = $result[0]['nb_airline']; |
867 | 867 | } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
868 | 868 | if (empty($all)) { |
869 | - $filters = array(); |
|
869 | + $filters = array(); |
|
870 | 870 | $filters = array('year' => $year,'month' => $month); |
871 | - if ($filter_name != '') { |
|
872 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
871 | + if ($filter_name != '') { |
|
872 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
873 | 873 | } |
874 | 874 | $Spotter = new Spotter($this->db); |
875 | 875 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -939,44 +939,44 @@ discard block |
||
939 | 939 | if ($filter_name == '') $filter_name = $this->filter_name; |
940 | 940 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
941 | 941 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
942 | - try { |
|
943 | - $sth = $this->db->prepare($query); |
|
944 | - $sth->execute($query_values); |
|
945 | - } catch(PDOException $e) { |
|
946 | - echo "error : ".$e->getMessage(); |
|
947 | - } |
|
948 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
949 | - return $all; |
|
942 | + try { |
|
943 | + $sth = $this->db->prepare($query); |
|
944 | + $sth->execute($query_values); |
|
945 | + } catch(PDOException $e) { |
|
946 | + echo "error : ".$e->getMessage(); |
|
947 | + } |
|
948 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
949 | + return $all; |
|
950 | 950 | } |
951 | 951 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
952 | 952 | if ($filter_name == '') $filter_name = $this->filter_name; |
953 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
954 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
955 | - try { |
|
956 | - $sth = $this->db->prepare($query); |
|
957 | - $sth->execute($query_values); |
|
958 | - } catch(PDOException $e) { |
|
959 | - echo "error : ".$e->getMessage(); |
|
960 | - } |
|
961 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
962 | - return $all; |
|
963 | - } |
|
953 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
954 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
955 | + try { |
|
956 | + $sth = $this->db->prepare($query); |
|
957 | + $sth->execute($query_values); |
|
958 | + } catch(PDOException $e) { |
|
959 | + echo "error : ".$e->getMessage(); |
|
960 | + } |
|
961 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
962 | + return $all; |
|
963 | + } |
|
964 | 964 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
965 | 965 | if ($filter_name == '') $filter_name = $this->filter_name; |
966 | - $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
967 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
968 | - try { |
|
969 | - $sth = $this->db->prepare($query); |
|
970 | - $sth->execute($query_values); |
|
971 | - } catch(PDOException $e) { |
|
972 | - echo "error : ".$e->getMessage(); |
|
973 | - } |
|
974 | - } |
|
966 | + $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
967 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
968 | + try { |
|
969 | + $sth = $this->db->prepare($query); |
|
970 | + $sth->execute($query_values); |
|
971 | + } catch(PDOException $e) { |
|
972 | + echo "error : ".$e->getMessage(); |
|
973 | + } |
|
974 | + } |
|
975 | 975 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
976 | 976 | if ($filter_name == '') $filter_name = $this->filter_name; |
977 | - global $globalArchiveMonths, $globalDBdriver; |
|
978 | - if ($globalDBdriver == 'mysql') { |
|
979 | - if ($month == '') { |
|
977 | + global $globalArchiveMonths, $globalDBdriver; |
|
978 | + if ($globalDBdriver == 'mysql') { |
|
979 | + if ($month == '') { |
|
980 | 980 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
981 | 981 | $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
982 | 982 | } else { |
@@ -991,165 +991,165 @@ discard block |
||
991 | 991 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
992 | 992 | $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
993 | 993 | } |
994 | - } |
|
995 | - try { |
|
996 | - $sth = $this->db->prepare($query); |
|
997 | - $sth->execute($query_values); |
|
998 | - } catch(PDOException $e) { |
|
999 | - echo "error : ".$e->getMessage(); |
|
1000 | - } |
|
1001 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1002 | - return $all[0]['total']; |
|
1003 | - } |
|
994 | + } |
|
995 | + try { |
|
996 | + $sth = $this->db->prepare($query); |
|
997 | + $sth->execute($query_values); |
|
998 | + } catch(PDOException $e) { |
|
999 | + echo "error : ".$e->getMessage(); |
|
1000 | + } |
|
1001 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1002 | + return $all[0]['total']; |
|
1003 | + } |
|
1004 | 1004 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1005 | - global $globalArchiveMonths, $globalDBdriver; |
|
1005 | + global $globalArchiveMonths, $globalDBdriver; |
|
1006 | 1006 | if ($filter_name == '') $filter_name = $this->filter_name; |
1007 | - if ($globalDBdriver == 'mysql') { |
|
1007 | + if ($globalDBdriver == 'mysql') { |
|
1008 | 1008 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1009 | 1009 | } else { |
1010 | 1010 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1011 | - } |
|
1012 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1013 | - try { |
|
1014 | - $sth = $this->db->prepare($query); |
|
1015 | - $sth->execute($query_values); |
|
1016 | - } catch(PDOException $e) { |
|
1017 | - echo "error : ".$e->getMessage(); |
|
1018 | - } |
|
1019 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1020 | - return $all[0]['total']; |
|
1021 | - } |
|
1011 | + } |
|
1012 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1013 | + try { |
|
1014 | + $sth = $this->db->prepare($query); |
|
1015 | + $sth->execute($query_values); |
|
1016 | + } catch(PDOException $e) { |
|
1017 | + echo "error : ".$e->getMessage(); |
|
1018 | + } |
|
1019 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1020 | + return $all[0]['total']; |
|
1021 | + } |
|
1022 | 1022 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1023 | - global $globalArchiveMonths, $globalDBdriver; |
|
1023 | + global $globalArchiveMonths, $globalDBdriver; |
|
1024 | 1024 | if ($filter_name == '') $filter_name = $this->filter_name; |
1025 | - if ($globalDBdriver == 'mysql') { |
|
1025 | + if ($globalDBdriver == 'mysql') { |
|
1026 | 1026 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
1027 | - } else { |
|
1027 | + } else { |
|
1028 | 1028 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
1029 | - } |
|
1030 | - try { |
|
1031 | - $sth = $this->db->prepare($query); |
|
1032 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
1033 | - } catch(PDOException $e) { |
|
1034 | - echo "error : ".$e->getMessage(); |
|
1035 | - } |
|
1036 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1037 | - return $all[0]['total']; |
|
1038 | - } |
|
1029 | + } |
|
1030 | + try { |
|
1031 | + $sth = $this->db->prepare($query); |
|
1032 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
1033 | + } catch(PDOException $e) { |
|
1034 | + echo "error : ".$e->getMessage(); |
|
1035 | + } |
|
1036 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1037 | + return $all[0]['total']; |
|
1038 | + } |
|
1039 | 1039 | public function getStatsAirlineTotal($filter_name = '') { |
1040 | - global $globalArchiveMonths, $globalDBdriver; |
|
1040 | + global $globalArchiveMonths, $globalDBdriver; |
|
1041 | 1041 | if ($filter_name == '') $filter_name = $this->filter_name; |
1042 | - if ($globalDBdriver == 'mysql') { |
|
1042 | + if ($globalDBdriver == 'mysql') { |
|
1043 | 1043 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1044 | - } else { |
|
1044 | + } else { |
|
1045 | 1045 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1046 | - } |
|
1047 | - try { |
|
1048 | - $sth = $this->db->prepare($query); |
|
1049 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
1050 | - } catch(PDOException $e) { |
|
1051 | - echo "error : ".$e->getMessage(); |
|
1052 | - } |
|
1053 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1054 | - return $all[0]['total']; |
|
1055 | - } |
|
1046 | + } |
|
1047 | + try { |
|
1048 | + $sth = $this->db->prepare($query); |
|
1049 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
1050 | + } catch(PDOException $e) { |
|
1051 | + echo "error : ".$e->getMessage(); |
|
1052 | + } |
|
1053 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1054 | + return $all[0]['total']; |
|
1055 | + } |
|
1056 | 1056 | public function getStatsOwnerTotal($filter_name = '') { |
1057 | - global $globalArchiveMonths, $globalDBdriver; |
|
1057 | + global $globalArchiveMonths, $globalDBdriver; |
|
1058 | 1058 | if ($filter_name == '') $filter_name = $this->filter_name; |
1059 | - if ($globalDBdriver == 'mysql') { |
|
1059 | + if ($globalDBdriver == 'mysql') { |
|
1060 | 1060 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1061 | 1061 | } else { |
1062 | 1062 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1063 | - } |
|
1064 | - try { |
|
1065 | - $sth = $this->db->prepare($query); |
|
1066 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
1067 | - } catch(PDOException $e) { |
|
1068 | - echo "error : ".$e->getMessage(); |
|
1069 | - } |
|
1070 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1071 | - return $all[0]['total']; |
|
1072 | - } |
|
1063 | + } |
|
1064 | + try { |
|
1065 | + $sth = $this->db->prepare($query); |
|
1066 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
1067 | + } catch(PDOException $e) { |
|
1068 | + echo "error : ".$e->getMessage(); |
|
1069 | + } |
|
1070 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1071 | + return $all[0]['total']; |
|
1072 | + } |
|
1073 | 1073 | public function getStatsOwner($owner_name,$filter_name = '') { |
1074 | - global $globalArchiveMonths, $globalDBdriver; |
|
1074 | + global $globalArchiveMonths, $globalDBdriver; |
|
1075 | 1075 | if ($filter_name == '') $filter_name = $this->filter_name; |
1076 | 1076 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1077 | - try { |
|
1078 | - $sth = $this->db->prepare($query); |
|
1079 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
1080 | - } catch(PDOException $e) { |
|
1081 | - echo "error : ".$e->getMessage(); |
|
1082 | - } |
|
1083 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1084 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1085 | - else return 0; |
|
1086 | - } |
|
1077 | + try { |
|
1078 | + $sth = $this->db->prepare($query); |
|
1079 | + $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
1080 | + } catch(PDOException $e) { |
|
1081 | + echo "error : ".$e->getMessage(); |
|
1082 | + } |
|
1083 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1084 | + if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1085 | + else return 0; |
|
1086 | + } |
|
1087 | 1087 | public function getStatsPilotTotal($filter_name = '') { |
1088 | - global $globalArchiveMonths, $globalDBdriver; |
|
1088 | + global $globalArchiveMonths, $globalDBdriver; |
|
1089 | 1089 | if ($filter_name == '') $filter_name = $this->filter_name; |
1090 | - if ($globalDBdriver == 'mysql') { |
|
1091 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
1092 | - } else { |
|
1093 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
1094 | - } |
|
1095 | - try { |
|
1096 | - $sth = $this->db->prepare($query); |
|
1097 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
1098 | - } catch(PDOException $e) { |
|
1099 | - echo "error : ".$e->getMessage(); |
|
1100 | - } |
|
1101 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1102 | - return $all[0]['total']; |
|
1103 | - } |
|
1090 | + if ($globalDBdriver == 'mysql') { |
|
1091 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
1092 | + } else { |
|
1093 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
1094 | + } |
|
1095 | + try { |
|
1096 | + $sth = $this->db->prepare($query); |
|
1097 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
1098 | + } catch(PDOException $e) { |
|
1099 | + echo "error : ".$e->getMessage(); |
|
1100 | + } |
|
1101 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1102 | + return $all[0]['total']; |
|
1103 | + } |
|
1104 | 1104 | public function getStatsPilot($pilot,$filter_name = '') { |
1105 | - global $globalArchiveMonths, $globalDBdriver; |
|
1105 | + global $globalArchiveMonths, $globalDBdriver; |
|
1106 | 1106 | if ($filter_name == '') $filter_name = $this->filter_name; |
1107 | 1107 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1108 | - try { |
|
1109 | - $sth = $this->db->prepare($query); |
|
1110 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
1111 | - } catch(PDOException $e) { |
|
1112 | - echo "error : ".$e->getMessage(); |
|
1113 | - } |
|
1114 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1115 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1116 | - else return 0; |
|
1117 | - } |
|
1108 | + try { |
|
1109 | + $sth = $this->db->prepare($query); |
|
1110 | + $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
1111 | + } catch(PDOException $e) { |
|
1112 | + echo "error : ".$e->getMessage(); |
|
1113 | + } |
|
1114 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
1115 | + if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1116 | + else return 0; |
|
1117 | + } |
|
1118 | 1118 | |
1119 | 1119 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1120 | 1120 | global $globalDBdriver; |
1121 | 1121 | if ($filter_name == '') $filter_name = $this->filter_name; |
1122 | 1122 | if ($globalDBdriver == 'mysql') { |
1123 | 1123 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
1124 | - } else { |
|
1124 | + } else { |
|
1125 | 1125 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1126 | 1126 | } |
1127 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1128 | - try { |
|
1129 | - $sth = $this->db->prepare($query); |
|
1130 | - $sth->execute($query_values); |
|
1131 | - } catch(PDOException $e) { |
|
1132 | - return "error : ".$e->getMessage(); |
|
1133 | - } |
|
1134 | - } |
|
1127 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1128 | + try { |
|
1129 | + $sth = $this->db->prepare($query); |
|
1130 | + $sth->execute($query_values); |
|
1131 | + } catch(PDOException $e) { |
|
1132 | + return "error : ".$e->getMessage(); |
|
1133 | + } |
|
1134 | + } |
|
1135 | 1135 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1136 | 1136 | global $globalDBdriver; |
1137 | 1137 | if ($filter_name == '') $filter_name = $this->filter_name; |
1138 | 1138 | if ($globalDBdriver == 'mysql') { |
1139 | 1139 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
1140 | 1140 | } else { |
1141 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
1141 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
1142 | 1142 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1143 | - } |
|
1144 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1145 | - try { |
|
1146 | - $sth = $this->db->prepare($query); |
|
1147 | - $sth->execute($query_values); |
|
1148 | - } catch(PDOException $e) { |
|
1149 | - return "error : ".$e->getMessage(); |
|
1150 | - } |
|
1151 | - } |
|
1152 | - /* |
|
1143 | + } |
|
1144 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1145 | + try { |
|
1146 | + $sth = $this->db->prepare($query); |
|
1147 | + $sth->execute($query_values); |
|
1148 | + } catch(PDOException $e) { |
|
1149 | + return "error : ".$e->getMessage(); |
|
1150 | + } |
|
1151 | + } |
|
1152 | + /* |
|
1153 | 1153 | public function getStatsSource($date,$stats_type = '') { |
1154 | 1154 | if ($stats_type == '') { |
1155 | 1155 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -1218,25 +1218,25 @@ discard block |
||
1218 | 1218 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
1219 | 1219 | } else { |
1220 | 1220 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
1221 | - } |
|
1222 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
1223 | - try { |
|
1224 | - $sth = $this->db->prepare($query); |
|
1225 | - $sth->execute($query_values); |
|
1226 | - } catch(PDOException $e) { |
|
1227 | - return "error : ".$e->getMessage(); |
|
1228 | - } |
|
1229 | - } |
|
1230 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
1231 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
1232 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1233 | - try { |
|
1234 | - $sth = $this->db->prepare($query); |
|
1235 | - $sth->execute($query_values); |
|
1236 | - } catch(PDOException $e) { |
|
1237 | - return "error : ".$e->getMessage(); |
|
1238 | - } |
|
1239 | - } |
|
1221 | + } |
|
1222 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
1223 | + try { |
|
1224 | + $sth = $this->db->prepare($query); |
|
1225 | + $sth->execute($query_values); |
|
1226 | + } catch(PDOException $e) { |
|
1227 | + return "error : ".$e->getMessage(); |
|
1228 | + } |
|
1229 | + } |
|
1230 | + public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
1231 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
1232 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1233 | + try { |
|
1234 | + $sth = $this->db->prepare($query); |
|
1235 | + $sth->execute($query_values); |
|
1236 | + } catch(PDOException $e) { |
|
1237 | + return "error : ".$e->getMessage(); |
|
1238 | + } |
|
1239 | + } |
|
1240 | 1240 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
1241 | 1241 | global $globalDBdriver; |
1242 | 1242 | if ($globalDBdriver == 'mysql') { |
@@ -1252,14 +1252,14 @@ discard block |
||
1252 | 1252 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1253 | 1253 | } |
1254 | 1254 | } |
1255 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1256 | - try { |
|
1257 | - $sth = $this->db->prepare($query); |
|
1258 | - $sth->execute($query_values); |
|
1259 | - } catch(PDOException $e) { |
|
1260 | - return "error : ".$e->getMessage(); |
|
1261 | - } |
|
1262 | - } |
|
1255 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1256 | + try { |
|
1257 | + $sth = $this->db->prepare($query); |
|
1258 | + $sth->execute($query_values); |
|
1259 | + } catch(PDOException $e) { |
|
1260 | + return "error : ".$e->getMessage(); |
|
1261 | + } |
|
1262 | + } |
|
1263 | 1263 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
1264 | 1264 | global $globalDBdriver; |
1265 | 1265 | if ($globalDBdriver == 'mysql') { |
@@ -1275,14 +1275,14 @@ discard block |
||
1275 | 1275 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1276 | 1276 | } |
1277 | 1277 | } |
1278 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1279 | - try { |
|
1280 | - $sth = $this->db->prepare($query); |
|
1281 | - $sth->execute($query_values); |
|
1282 | - } catch(PDOException $e) { |
|
1283 | - return "error : ".$e->getMessage(); |
|
1284 | - } |
|
1285 | - } |
|
1278 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1279 | + try { |
|
1280 | + $sth = $this->db->prepare($query); |
|
1281 | + $sth->execute($query_values); |
|
1282 | + } catch(PDOException $e) { |
|
1283 | + return "error : ".$e->getMessage(); |
|
1284 | + } |
|
1285 | + } |
|
1286 | 1286 | public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
1287 | 1287 | global $globalDBdriver; |
1288 | 1288 | if ($globalDBdriver == 'mysql') { |
@@ -1298,14 +1298,14 @@ discard block |
||
1298 | 1298 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; |
1299 | 1299 | } |
1300 | 1300 | } |
1301 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
1302 | - try { |
|
1303 | - $sth = $this->db->prepare($query); |
|
1304 | - $sth->execute($query_values); |
|
1305 | - } catch(PDOException $e) { |
|
1306 | - return "error : ".$e->getMessage(); |
|
1307 | - } |
|
1308 | - } |
|
1301 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
1302 | + try { |
|
1303 | + $sth = $this->db->prepare($query); |
|
1304 | + $sth->execute($query_values); |
|
1305 | + } catch(PDOException $e) { |
|
1306 | + return "error : ".$e->getMessage(); |
|
1307 | + } |
|
1308 | + } |
|
1309 | 1309 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
1310 | 1310 | global $globalDBdriver; |
1311 | 1311 | if ($globalDBdriver == 'mysql') { |
@@ -1321,14 +1321,14 @@ discard block |
||
1321 | 1321 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1322 | 1322 | } |
1323 | 1323 | } |
1324 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1325 | - try { |
|
1326 | - $sth = $this->db->prepare($query); |
|
1327 | - $sth->execute($query_values); |
|
1328 | - } catch(PDOException $e) { |
|
1329 | - return "error : ".$e->getMessage(); |
|
1330 | - } |
|
1331 | - } |
|
1324 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1325 | + try { |
|
1326 | + $sth = $this->db->prepare($query); |
|
1327 | + $sth->execute($query_values); |
|
1328 | + } catch(PDOException $e) { |
|
1329 | + return "error : ".$e->getMessage(); |
|
1330 | + } |
|
1331 | + } |
|
1332 | 1332 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
1333 | 1333 | global $globalDBdriver; |
1334 | 1334 | if ($globalDBdriver == 'mysql') { |
@@ -1344,14 +1344,14 @@ discard block |
||
1344 | 1344 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1345 | 1345 | } |
1346 | 1346 | } |
1347 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1348 | - try { |
|
1349 | - $sth = $this->db->prepare($query); |
|
1350 | - $sth->execute($query_values); |
|
1351 | - } catch(PDOException $e) { |
|
1352 | - return "error : ".$e->getMessage(); |
|
1353 | - } |
|
1354 | - } |
|
1347 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1348 | + try { |
|
1349 | + $sth = $this->db->prepare($query); |
|
1350 | + $sth->execute($query_values); |
|
1351 | + } catch(PDOException $e) { |
|
1352 | + return "error : ".$e->getMessage(); |
|
1353 | + } |
|
1354 | + } |
|
1355 | 1355 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
1356 | 1356 | global $globalDBdriver; |
1357 | 1357 | if ($globalDBdriver == 'mysql') { |
@@ -1367,14 +1367,14 @@ discard block |
||
1367 | 1367 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1368 | 1368 | } |
1369 | 1369 | } |
1370 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1371 | - try { |
|
1372 | - $sth = $this->db->prepare($query); |
|
1373 | - $sth->execute($query_values); |
|
1374 | - } catch(PDOException $e) { |
|
1375 | - return "error : ".$e->getMessage(); |
|
1376 | - } |
|
1377 | - } |
|
1370 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1371 | + try { |
|
1372 | + $sth = $this->db->prepare($query); |
|
1373 | + $sth->execute($query_values); |
|
1374 | + } catch(PDOException $e) { |
|
1375 | + return "error : ".$e->getMessage(); |
|
1376 | + } |
|
1377 | + } |
|
1378 | 1378 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
1379 | 1379 | global $globalDBdriver; |
1380 | 1380 | if ($globalDBdriver == 'mysql') { |
@@ -1390,14 +1390,14 @@ discard block |
||
1390 | 1390 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1391 | 1391 | } |
1392 | 1392 | } |
1393 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1394 | - try { |
|
1395 | - $sth = $this->db->prepare($query); |
|
1396 | - $sth->execute($query_values); |
|
1397 | - } catch(PDOException $e) { |
|
1398 | - return "error : ".$e->getMessage(); |
|
1399 | - } |
|
1400 | - } |
|
1393 | + $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1394 | + try { |
|
1395 | + $sth = $this->db->prepare($query); |
|
1396 | + $sth->execute($query_values); |
|
1397 | + } catch(PDOException $e) { |
|
1398 | + return "error : ".$e->getMessage(); |
|
1399 | + } |
|
1400 | + } |
|
1401 | 1401 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
1402 | 1402 | global $globalDBdriver; |
1403 | 1403 | if ($airport_icao != '') { |
@@ -1421,8 +1421,8 @@ discard block |
||
1421 | 1421 | } catch(PDOException $e) { |
1422 | 1422 | return "error : ".$e->getMessage(); |
1423 | 1423 | } |
1424 | - } |
|
1425 | - } |
|
1424 | + } |
|
1425 | + } |
|
1426 | 1426 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1427 | 1427 | global $globalDBdriver; |
1428 | 1428 | if ($airport_icao != '') { |
@@ -1438,8 +1438,8 @@ discard block |
||
1438 | 1438 | } catch(PDOException $e) { |
1439 | 1439 | return "error : ".$e->getMessage(); |
1440 | 1440 | } |
1441 | - } |
|
1442 | - } |
|
1441 | + } |
|
1442 | + } |
|
1443 | 1443 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
1444 | 1444 | global $globalDBdriver; |
1445 | 1445 | if ($airport_icao != '') { |
@@ -1456,15 +1456,15 @@ discard block |
||
1456 | 1456 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1457 | 1457 | } |
1458 | 1458 | } |
1459 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1459 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1460 | 1460 | try { |
1461 | - $sth = $this->db->prepare($query); |
|
1462 | - $sth->execute($query_values); |
|
1463 | - } catch(PDOException $e) { |
|
1464 | - return "error : ".$e->getMessage(); |
|
1465 | - } |
|
1466 | - } |
|
1467 | - } |
|
1461 | + $sth = $this->db->prepare($query); |
|
1462 | + $sth->execute($query_values); |
|
1463 | + } catch(PDOException $e) { |
|
1464 | + return "error : ".$e->getMessage(); |
|
1465 | + } |
|
1466 | + } |
|
1467 | + } |
|
1468 | 1468 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1469 | 1469 | global $globalDBdriver; |
1470 | 1470 | if ($airport_icao != '') { |
@@ -1480,46 +1480,46 @@ discard block |
||
1480 | 1480 | } catch(PDOException $e) { |
1481 | 1481 | return "error : ".$e->getMessage(); |
1482 | 1482 | } |
1483 | - } |
|
1484 | - } |
|
1483 | + } |
|
1484 | + } |
|
1485 | 1485 | |
1486 | 1486 | public function deleteStat($id) { |
1487 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1488 | - $query_values = array(':id' => $id); |
|
1489 | - try { |
|
1490 | - $sth = $this->db->prepare($query); |
|
1491 | - $sth->execute($query_values); |
|
1492 | - } catch(PDOException $e) { |
|
1493 | - return "error : ".$e->getMessage(); |
|
1494 | - } |
|
1495 | - } |
|
1487 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1488 | + $query_values = array(':id' => $id); |
|
1489 | + try { |
|
1490 | + $sth = $this->db->prepare($query); |
|
1491 | + $sth->execute($query_values); |
|
1492 | + } catch(PDOException $e) { |
|
1493 | + return "error : ".$e->getMessage(); |
|
1494 | + } |
|
1495 | + } |
|
1496 | 1496 | public function deleteStatFlight($type) { |
1497 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1498 | - $query_values = array(':type' => $type); |
|
1499 | - try { |
|
1500 | - $sth = $this->db->prepare($query); |
|
1501 | - $sth->execute($query_values); |
|
1502 | - } catch(PDOException $e) { |
|
1503 | - return "error : ".$e->getMessage(); |
|
1504 | - } |
|
1505 | - } |
|
1497 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1498 | + $query_values = array(':type' => $type); |
|
1499 | + try { |
|
1500 | + $sth = $this->db->prepare($query); |
|
1501 | + $sth->execute($query_values); |
|
1502 | + } catch(PDOException $e) { |
|
1503 | + return "error : ".$e->getMessage(); |
|
1504 | + } |
|
1505 | + } |
|
1506 | 1506 | public function deleteStatAirport($type) { |
1507 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1508 | - $query_values = array(':type' => $type); |
|
1509 | - try { |
|
1510 | - $sth = $this->db->prepare($query); |
|
1511 | - $sth->execute($query_values); |
|
1512 | - } catch(PDOException $e) { |
|
1513 | - return "error : ".$e->getMessage(); |
|
1514 | - } |
|
1515 | - } |
|
1507 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1508 | + $query_values = array(':type' => $type); |
|
1509 | + try { |
|
1510 | + $sth = $this->db->prepare($query); |
|
1511 | + $sth->execute($query_values); |
|
1512 | + } catch(PDOException $e) { |
|
1513 | + return "error : ".$e->getMessage(); |
|
1514 | + } |
|
1515 | + } |
|
1516 | 1516 | |
1517 | - public function addOldStats() { |
|
1518 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
1519 | - $Common = new Common(); |
|
1520 | - $Connection = new Connection(); |
|
1521 | - date_default_timezone_set('UTC'); |
|
1522 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1517 | + public function addOldStats() { |
|
1518 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
1519 | + $Common = new Common(); |
|
1520 | + $Connection = new Connection(); |
|
1521 | + date_default_timezone_set('UTC'); |
|
1522 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1523 | 1523 | if ($globalDebug) echo 'Update stats !'."\n"; |
1524 | 1524 | if (isset($last_update[0]['value'])) { |
1525 | 1525 | $last_update_day = $last_update[0]['value']; |
@@ -1567,24 +1567,24 @@ discard block |
||
1567 | 1567 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1568 | 1568 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1569 | 1569 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1570 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1570 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1571 | 1571 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1572 | - $alldata = array(); |
|
1572 | + $alldata = array(); |
|
1573 | 1573 | |
1574 | - foreach ($pall as $value) { |
|
1575 | - $icao = $value['airport_departure_icao']; |
|
1576 | - $alldata[$icao] = $value; |
|
1577 | - } |
|
1578 | - foreach ($dall as $value) { |
|
1579 | - $icao = $value['airport_departure_icao']; |
|
1580 | - if (isset($alldata[$icao])) { |
|
1581 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1582 | - } else $alldata[$icao] = $value; |
|
1583 | - } |
|
1584 | - $count = array(); |
|
1585 | - foreach ($alldata as $key => $row) { |
|
1586 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1587 | - } |
|
1574 | + foreach ($pall as $value) { |
|
1575 | + $icao = $value['airport_departure_icao']; |
|
1576 | + $alldata[$icao] = $value; |
|
1577 | + } |
|
1578 | + foreach ($dall as $value) { |
|
1579 | + $icao = $value['airport_departure_icao']; |
|
1580 | + if (isset($alldata[$icao])) { |
|
1581 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1582 | + } else $alldata[$icao] = $value; |
|
1583 | + } |
|
1584 | + $count = array(); |
|
1585 | + foreach ($alldata as $key => $row) { |
|
1586 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1587 | + } |
|
1588 | 1588 | array_multisort($count,SORT_DESC,$alldata); |
1589 | 1589 | foreach ($alldata as $number) { |
1590 | 1590 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
@@ -1592,25 +1592,25 @@ discard block |
||
1592 | 1592 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1593 | 1593 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1594 | 1594 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1595 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1595 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1596 | 1596 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1597 | - $alldata = array(); |
|
1598 | - foreach ($pall as $value) { |
|
1599 | - $icao = $value['airport_arrival_icao']; |
|
1600 | - $alldata[$icao] = $value; |
|
1601 | - } |
|
1602 | - foreach ($dall as $value) { |
|
1603 | - $icao = $value['airport_arrival_icao']; |
|
1604 | - if (isset($alldata[$icao])) { |
|
1605 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1606 | - } else $alldata[$icao] = $value; |
|
1607 | - } |
|
1608 | - $count = array(); |
|
1609 | - foreach ($alldata as $key => $row) { |
|
1610 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1611 | - } |
|
1612 | - array_multisort($count,SORT_DESC,$alldata); |
|
1613 | - foreach ($alldata as $number) { |
|
1597 | + $alldata = array(); |
|
1598 | + foreach ($pall as $value) { |
|
1599 | + $icao = $value['airport_arrival_icao']; |
|
1600 | + $alldata[$icao] = $value; |
|
1601 | + } |
|
1602 | + foreach ($dall as $value) { |
|
1603 | + $icao = $value['airport_arrival_icao']; |
|
1604 | + if (isset($alldata[$icao])) { |
|
1605 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1606 | + } else $alldata[$icao] = $value; |
|
1607 | + } |
|
1608 | + $count = array(); |
|
1609 | + foreach ($alldata as $key => $row) { |
|
1610 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1611 | + } |
|
1612 | + array_multisort($count,SORT_DESC,$alldata); |
|
1613 | + foreach ($alldata as $number) { |
|
1614 | 1614 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
1615 | 1615 | } |
1616 | 1616 | if ($Connection->tableExists('countries')) { |
@@ -1687,8 +1687,8 @@ discard block |
||
1687 | 1687 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1688 | 1688 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1689 | 1689 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1690 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1691 | - /* |
|
1690 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1691 | + /* |
|
1692 | 1692 | $alldata = array(); |
1693 | 1693 | foreach ($pall as $value) { |
1694 | 1694 | $icao = $value['departure_airport_icao']; |
@@ -1707,29 +1707,29 @@ discard block |
||
1707 | 1707 | } |
1708 | 1708 | array_multisort($count,SORT_DESC,$alldata); |
1709 | 1709 | */ |
1710 | - foreach ($dall as $value) { |
|
1711 | - $icao = $value['departure_airport_icao']; |
|
1712 | - $ddate = $value['date']; |
|
1713 | - $find = false; |
|
1714 | - foreach ($pall as $pvalue) { |
|
1715 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1716 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1717 | - $find = true; |
|
1718 | - break; |
|
1719 | - } |
|
1720 | - } |
|
1721 | - if ($find === false) { |
|
1722 | - $pall[] = $value; |
|
1723 | - } |
|
1724 | - } |
|
1725 | - $alldata = $pall; |
|
1710 | + foreach ($dall as $value) { |
|
1711 | + $icao = $value['departure_airport_icao']; |
|
1712 | + $ddate = $value['date']; |
|
1713 | + $find = false; |
|
1714 | + foreach ($pall as $pvalue) { |
|
1715 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1716 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1717 | + $find = true; |
|
1718 | + break; |
|
1719 | + } |
|
1720 | + } |
|
1721 | + if ($find === false) { |
|
1722 | + $pall[] = $value; |
|
1723 | + } |
|
1724 | + } |
|
1725 | + $alldata = $pall; |
|
1726 | 1726 | foreach ($alldata as $number) { |
1727 | 1727 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1728 | 1728 | } |
1729 | 1729 | echo '...Arrival'."\n"; |
1730 | 1730 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1731 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1732 | - /* |
|
1731 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1732 | + /* |
|
1733 | 1733 | $alldata = array(); |
1734 | 1734 | foreach ($pall as $value) { |
1735 | 1735 | $icao = $value['arrival_airport_icao']; |
@@ -1749,22 +1749,22 @@ discard block |
||
1749 | 1749 | */ |
1750 | 1750 | |
1751 | 1751 | |
1752 | - foreach ($dall as $value) { |
|
1753 | - $icao = $value['arrival_airport_icao']; |
|
1754 | - $ddate = $value['date']; |
|
1755 | - $find = false; |
|
1756 | - foreach ($pall as $pvalue) { |
|
1757 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1758 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1759 | - $find = true; |
|
1760 | - break; |
|
1761 | - } |
|
1762 | - } |
|
1763 | - if ($find === false) { |
|
1764 | - $pall[] = $value; |
|
1765 | - } |
|
1766 | - } |
|
1767 | - $alldata = $pall; |
|
1752 | + foreach ($dall as $value) { |
|
1753 | + $icao = $value['arrival_airport_icao']; |
|
1754 | + $ddate = $value['date']; |
|
1755 | + $find = false; |
|
1756 | + foreach ($pall as $pvalue) { |
|
1757 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1758 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1759 | + $find = true; |
|
1760 | + break; |
|
1761 | + } |
|
1762 | + } |
|
1763 | + if ($find === false) { |
|
1764 | + $pall[] = $value; |
|
1765 | + } |
|
1766 | + } |
|
1767 | + $alldata = $pall; |
|
1768 | 1768 | foreach ($alldata as $number) { |
1769 | 1769 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1770 | 1770 | } |
@@ -1841,51 +1841,51 @@ discard block |
||
1841 | 1841 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1842 | 1842 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1843 | 1843 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1844 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1844 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1845 | 1845 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1846 | - //$alldata = array(); |
|
1847 | - foreach ($dall as $value) { |
|
1848 | - $icao = $value['airport_departure_icao']; |
|
1849 | - $dicao = $value['airline_icao']; |
|
1850 | - $find = false; |
|
1851 | - foreach ($pall as $pvalue) { |
|
1852 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1853 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1854 | - $find = true; |
|
1855 | - break; |
|
1856 | - } |
|
1857 | - } |
|
1858 | - if ($find === false) { |
|
1859 | - $pall[] = $value; |
|
1860 | - } |
|
1861 | - } |
|
1862 | - $alldata = $pall; |
|
1846 | + //$alldata = array(); |
|
1847 | + foreach ($dall as $value) { |
|
1848 | + $icao = $value['airport_departure_icao']; |
|
1849 | + $dicao = $value['airline_icao']; |
|
1850 | + $find = false; |
|
1851 | + foreach ($pall as $pvalue) { |
|
1852 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1853 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1854 | + $find = true; |
|
1855 | + break; |
|
1856 | + } |
|
1857 | + } |
|
1858 | + if ($find === false) { |
|
1859 | + $pall[] = $value; |
|
1860 | + } |
|
1861 | + } |
|
1862 | + $alldata = $pall; |
|
1863 | 1863 | foreach ($alldata as $number) { |
1864 | 1864 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
1865 | 1865 | } |
1866 | 1866 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1867 | 1867 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1868 | 1868 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1869 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1869 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1870 | 1870 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1871 | - //$alldata = array(); |
|
1872 | - foreach ($dall as $value) { |
|
1873 | - $icao = $value['airport_arrival_icao']; |
|
1874 | - $dicao = $value['airline_icao']; |
|
1875 | - $find = false; |
|
1876 | - foreach ($pall as $pvalue) { |
|
1877 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1878 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1879 | - $find = true; |
|
1880 | - break; |
|
1881 | - } |
|
1882 | - } |
|
1883 | - if ($find === false) { |
|
1884 | - $pall[] = $value; |
|
1885 | - } |
|
1886 | - } |
|
1887 | - $alldata = $pall; |
|
1888 | - foreach ($alldata as $number) { |
|
1871 | + //$alldata = array(); |
|
1872 | + foreach ($dall as $value) { |
|
1873 | + $icao = $value['airport_arrival_icao']; |
|
1874 | + $dicao = $value['airline_icao']; |
|
1875 | + $find = false; |
|
1876 | + foreach ($pall as $pvalue) { |
|
1877 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1878 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1879 | + $find = true; |
|
1880 | + break; |
|
1881 | + } |
|
1882 | + } |
|
1883 | + if ($find === false) { |
|
1884 | + $pall[] = $value; |
|
1885 | + } |
|
1886 | + } |
|
1887 | + $alldata = $pall; |
|
1888 | + foreach ($alldata as $number) { |
|
1889 | 1889 | if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
1890 | 1890 | } |
1891 | 1891 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
@@ -1918,47 +1918,47 @@ discard block |
||
1918 | 1918 | } |
1919 | 1919 | if ($globalDebug) echo '...Departure'."\n"; |
1920 | 1920 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1921 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1922 | - foreach ($dall as $value) { |
|
1923 | - $icao = $value['departure_airport_icao']; |
|
1924 | - $airline = $value['airline_icao']; |
|
1925 | - $ddate = $value['date']; |
|
1926 | - $find = false; |
|
1927 | - foreach ($pall as $pvalue) { |
|
1928 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1929 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1930 | - $find = true; |
|
1931 | - break; |
|
1932 | - } |
|
1933 | - } |
|
1934 | - if ($find === false) { |
|
1935 | - $pall[] = $value; |
|
1936 | - } |
|
1937 | - } |
|
1938 | - $alldata = $pall; |
|
1921 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1922 | + foreach ($dall as $value) { |
|
1923 | + $icao = $value['departure_airport_icao']; |
|
1924 | + $airline = $value['airline_icao']; |
|
1925 | + $ddate = $value['date']; |
|
1926 | + $find = false; |
|
1927 | + foreach ($pall as $pvalue) { |
|
1928 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1929 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1930 | + $find = true; |
|
1931 | + break; |
|
1932 | + } |
|
1933 | + } |
|
1934 | + if ($find === false) { |
|
1935 | + $pall[] = $value; |
|
1936 | + } |
|
1937 | + } |
|
1938 | + $alldata = $pall; |
|
1939 | 1939 | foreach ($alldata as $number) { |
1940 | 1940 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
1941 | 1941 | } |
1942 | 1942 | if ($globalDebug) echo '...Arrival'."\n"; |
1943 | 1943 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1944 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1945 | - foreach ($dall as $value) { |
|
1946 | - $icao = $value['arrival_airport_icao']; |
|
1947 | - $airline = $value['airline_icao']; |
|
1948 | - $ddate = $value['date']; |
|
1949 | - $find = false; |
|
1950 | - foreach ($pall as $pvalue) { |
|
1951 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1952 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1953 | - $find = true; |
|
1954 | - break; |
|
1955 | - } |
|
1956 | - } |
|
1957 | - if ($find === false) { |
|
1958 | - $pall[] = $value; |
|
1959 | - } |
|
1960 | - } |
|
1961 | - $alldata = $pall; |
|
1944 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1945 | + foreach ($dall as $value) { |
|
1946 | + $icao = $value['arrival_airport_icao']; |
|
1947 | + $airline = $value['airline_icao']; |
|
1948 | + $ddate = $value['date']; |
|
1949 | + $find = false; |
|
1950 | + foreach ($pall as $pvalue) { |
|
1951 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1952 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1953 | + $find = true; |
|
1954 | + break; |
|
1955 | + } |
|
1956 | + } |
|
1957 | + if ($find === false) { |
|
1958 | + $pall[] = $value; |
|
1959 | + } |
|
1960 | + } |
|
1961 | + $alldata = $pall; |
|
1962 | 1962 | foreach ($alldata as $number) { |
1963 | 1963 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
1964 | 1964 | } |
@@ -2043,44 +2043,44 @@ discard block |
||
2043 | 2043 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
2044 | 2044 | } |
2045 | 2045 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
2046 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
2047 | - $alldata = array(); |
|
2048 | - foreach ($pall as $value) { |
|
2049 | - $icao = $value['airport_departure_icao']; |
|
2050 | - $alldata[$icao] = $value; |
|
2051 | - } |
|
2052 | - foreach ($dall as $value) { |
|
2053 | - $icao = $value['airport_departure_icao']; |
|
2054 | - if (isset($alldata[$icao])) { |
|
2055 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
2056 | - } else $alldata[$icao] = $value; |
|
2057 | - } |
|
2058 | - $count = array(); |
|
2059 | - foreach ($alldata as $key => $row) { |
|
2060 | - $count[$key] = $row['airport_departure_icao_count']; |
|
2061 | - } |
|
2046 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
2047 | + $alldata = array(); |
|
2048 | + foreach ($pall as $value) { |
|
2049 | + $icao = $value['airport_departure_icao']; |
|
2050 | + $alldata[$icao] = $value; |
|
2051 | + } |
|
2052 | + foreach ($dall as $value) { |
|
2053 | + $icao = $value['airport_departure_icao']; |
|
2054 | + if (isset($alldata[$icao])) { |
|
2055 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
2056 | + } else $alldata[$icao] = $value; |
|
2057 | + } |
|
2058 | + $count = array(); |
|
2059 | + foreach ($alldata as $key => $row) { |
|
2060 | + $count[$key] = $row['airport_departure_icao_count']; |
|
2061 | + } |
|
2062 | 2062 | array_multisort($count,SORT_DESC,$alldata); |
2063 | 2063 | foreach ($alldata as $number) { |
2064 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
2064 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
2065 | 2065 | } |
2066 | 2066 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
2067 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
2067 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
2068 | 2068 | $alldata = array(); |
2069 | - foreach ($pall as $value) { |
|
2070 | - $icao = $value['airport_arrival_icao']; |
|
2071 | - $alldata[$icao] = $value; |
|
2072 | - } |
|
2073 | - foreach ($dall as $value) { |
|
2074 | - $icao = $value['airport_arrival_icao']; |
|
2075 | - if (isset($alldata[$icao])) { |
|
2076 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
2077 | - } else $alldata[$icao] = $value; |
|
2078 | - } |
|
2079 | - $count = array(); |
|
2080 | - foreach ($alldata as $key => $row) { |
|
2081 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
2082 | - } |
|
2083 | - array_multisort($count,SORT_DESC,$alldata); |
|
2069 | + foreach ($pall as $value) { |
|
2070 | + $icao = $value['airport_arrival_icao']; |
|
2071 | + $alldata[$icao] = $value; |
|
2072 | + } |
|
2073 | + foreach ($dall as $value) { |
|
2074 | + $icao = $value['airport_arrival_icao']; |
|
2075 | + if (isset($alldata[$icao])) { |
|
2076 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
2077 | + } else $alldata[$icao] = $value; |
|
2078 | + } |
|
2079 | + $count = array(); |
|
2080 | + foreach ($alldata as $key => $row) { |
|
2081 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
2082 | + } |
|
2083 | + array_multisort($count,SORT_DESC,$alldata); |
|
2084 | 2084 | foreach ($alldata as $number) { |
2085 | 2085 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
2086 | 2086 | } |
@@ -2113,45 +2113,45 @@ discard block |
||
2113 | 2113 | } |
2114 | 2114 | echo '...Departure'."\n"; |
2115 | 2115 | $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
2116 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
2116 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
2117 | 2117 | foreach ($dall as $value) { |
2118 | - $icao = $value['departure_airport_icao']; |
|
2119 | - $ddate = $value['date']; |
|
2120 | - $find = false; |
|
2121 | - foreach ($pall as $pvalue) { |
|
2122 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
2123 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
2124 | - $find = true; |
|
2125 | - break; |
|
2126 | - } |
|
2127 | - } |
|
2128 | - if ($find === false) { |
|
2129 | - $pall[] = $value; |
|
2130 | - } |
|
2131 | - } |
|
2132 | - $alldata = $pall; |
|
2118 | + $icao = $value['departure_airport_icao']; |
|
2119 | + $ddate = $value['date']; |
|
2120 | + $find = false; |
|
2121 | + foreach ($pall as $pvalue) { |
|
2122 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
2123 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
2124 | + $find = true; |
|
2125 | + break; |
|
2126 | + } |
|
2127 | + } |
|
2128 | + if ($find === false) { |
|
2129 | + $pall[] = $value; |
|
2130 | + } |
|
2131 | + } |
|
2132 | + $alldata = $pall; |
|
2133 | 2133 | foreach ($alldata as $number) { |
2134 | 2134 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
2135 | 2135 | } |
2136 | 2136 | echo '...Arrival'."\n"; |
2137 | 2137 | $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
2138 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
2138 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
2139 | 2139 | foreach ($dall as $value) { |
2140 | 2140 | $icao = $value['arrival_airport_icao']; |
2141 | 2141 | $ddate = $value['date']; |
2142 | - $find = false; |
|
2142 | + $find = false; |
|
2143 | 2143 | foreach ($pall as $pvalue) { |
2144 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
2145 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
2146 | - $find = true; |
|
2147 | - break; |
|
2148 | - } |
|
2149 | - } |
|
2150 | - if ($find === false) { |
|
2151 | - $pall[] = $value; |
|
2152 | - } |
|
2153 | - } |
|
2154 | - $alldata = $pall; |
|
2144 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
2145 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
2146 | + $find = true; |
|
2147 | + break; |
|
2148 | + } |
|
2149 | + } |
|
2150 | + if ($find === false) { |
|
2151 | + $pall[] = $value; |
|
2152 | + } |
|
2153 | + } |
|
2154 | + $alldata = $pall; |
|
2155 | 2155 | foreach ($alldata as $number) { |
2156 | 2156 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
2157 | 2157 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | try { |
6 | 6 | $GeoidHeight = new GeoidHeight(); |
7 | 7 | } catch (Exception $e) { |
8 | - echo $e; |
|
8 | + echo $e; |
|
9 | 9 | } |
10 | 10 | $title = _("Geoid Height Calculator"); |
11 | 11 | require_once('header.php'); |
@@ -76,38 +76,38 @@ discard block |
||
76 | 76 | try { |
77 | 77 | //$Connection = new Connection(); |
78 | 78 | $sth = $Connection->db->prepare($query); |
79 | - $sth->execute(array(':source' => $database_file)); |
|
80 | - } catch(PDOException $e) { |
|
81 | - return "error : ".$e->getMessage(); |
|
82 | - } |
|
79 | + $sth->execute(array(':source' => $database_file)); |
|
80 | + } catch(PDOException $e) { |
|
81 | + return "error : ".$e->getMessage(); |
|
82 | + } |
|
83 | 83 | |
84 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
85 | - update_db::connect_sqlite($database_file); |
|
84 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
85 | + update_db::connect_sqlite($database_file); |
|
86 | 86 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
87 | 87 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
88 | 88 | try { |
89 | - $sth = update_db::$db_sqlite->prepare($query); |
|
90 | - $sth->execute(); |
|
91 | - } catch(PDOException $e) { |
|
92 | - return "error : ".$e->getMessage(); |
|
93 | - } |
|
89 | + $sth = update_db::$db_sqlite->prepare($query); |
|
90 | + $sth->execute(); |
|
91 | + } catch(PDOException $e) { |
|
92 | + return "error : ".$e->getMessage(); |
|
93 | + } |
|
94 | 94 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
95 | 95 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
96 | 96 | $Connection = new Connection(); |
97 | 97 | $sth_dest = $Connection->db->prepare($query_dest); |
98 | 98 | try { |
99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); |
100 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
100 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
101 | 101 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | 102 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
103 | 103 | $sth_dest->execute($query_dest_values); |
104 | - } |
|
104 | + } |
|
105 | 105 | if ($globalTransaction) $Connection->db->commit(); |
106 | 106 | } catch(PDOException $e) { |
107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); |
108 | 108 | return "error : ".$e->getMessage(); |
109 | 109 | } |
110 | - return ''; |
|
110 | + return ''; |
|
111 | 111 | } |
112 | 112 | public static function retrieve_route_oneworld($database_file) { |
113 | 113 | global $globalDebug, $globalTransaction; |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | try { |
119 | 119 | //$Connection = new Connection(); |
120 | 120 | $sth = $Connection->db->prepare($query); |
121 | - $sth->execute(array(':source' => 'oneworld')); |
|
122 | - } catch(PDOException $e) { |
|
123 | - return "error : ".$e->getMessage(); |
|
124 | - } |
|
121 | + $sth->execute(array(':source' => 'oneworld')); |
|
122 | + } catch(PDOException $e) { |
|
123 | + return "error : ".$e->getMessage(); |
|
124 | + } |
|
125 | 125 | |
126 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
126 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
128 | 128 | $Spotter = new Spotter(); |
129 | 129 | if ($fh = fopen($database_file,"r")) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | if ($globalTransaction) $Connection->db->commit(); |
149 | 149 | } |
150 | - return ''; |
|
150 | + return ''; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | public static function retrieve_route_skyteam($database_file) { |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | try { |
160 | 160 | //$Connection = new Connection(); |
161 | 161 | $sth = $Connection->db->prepare($query); |
162 | - $sth->execute(array(':source' => 'skyteam')); |
|
163 | - } catch(PDOException $e) { |
|
164 | - return "error : ".$e->getMessage(); |
|
165 | - } |
|
162 | + $sth->execute(array(':source' => 'skyteam')); |
|
163 | + } catch(PDOException $e) { |
|
164 | + return "error : ".$e->getMessage(); |
|
165 | + } |
|
166 | 166 | |
167 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
167 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
168 | 168 | |
169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
170 | 170 | $Spotter = new Spotter(); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return "error : ".$e->getMessage(); |
191 | 191 | } |
192 | 192 | } |
193 | - return ''; |
|
193 | + return ''; |
|
194 | 194 | } |
195 | 195 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
196 | 196 | global $globalTransaction; |
@@ -199,27 +199,27 @@ discard block |
||
199 | 199 | try { |
200 | 200 | $Connection = new Connection(); |
201 | 201 | $sth = $Connection->db->prepare($query); |
202 | - $sth->execute(array(':source' => $database_file)); |
|
203 | - } catch(PDOException $e) { |
|
204 | - return "error : ".$e->getMessage(); |
|
205 | - } |
|
202 | + $sth->execute(array(':source' => $database_file)); |
|
203 | + } catch(PDOException $e) { |
|
204 | + return "error : ".$e->getMessage(); |
|
205 | + } |
|
206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
207 | 207 | try { |
208 | 208 | $Connection = new Connection(); |
209 | 209 | $sth = $Connection->db->prepare($query); |
210 | - $sth->execute(array(':source' => $database_file)); |
|
211 | - } catch(PDOException $e) { |
|
212 | - return "error : ".$e->getMessage(); |
|
213 | - } |
|
210 | + $sth->execute(array(':source' => $database_file)); |
|
211 | + } catch(PDOException $e) { |
|
212 | + return "error : ".$e->getMessage(); |
|
213 | + } |
|
214 | 214 | |
215 | - update_db::connect_sqlite($database_file); |
|
215 | + update_db::connect_sqlite($database_file); |
|
216 | 216 | $query = 'select * from Aircraft'; |
217 | 217 | try { |
218 | - $sth = update_db::$db_sqlite->prepare($query); |
|
219 | - $sth->execute(); |
|
220 | - } catch(PDOException $e) { |
|
221 | - return "error : ".$e->getMessage(); |
|
222 | - } |
|
218 | + $sth = update_db::$db_sqlite->prepare($query); |
|
219 | + $sth->execute(); |
|
220 | + } catch(PDOException $e) { |
|
221 | + return "error : ".$e->getMessage(); |
|
222 | + } |
|
223 | 223 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
224 | 224 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
225 | 225 | |
@@ -230,17 +230,17 @@ discard block |
||
230 | 230 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
231 | 231 | try { |
232 | 232 | if ($globalTransaction) $Connection->db->beginTransaction(); |
233 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
233 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
234 | 234 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; |
236 | 236 | else $type = null; |
237 | 237 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
238 | 238 | $sth_dest->execute($query_dest_values); |
239 | 239 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
240 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
241 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
240 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
241 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
242 | 242 | } |
243 | - } |
|
243 | + } |
|
244 | 244 | if ($globalTransaction) $Connection->db->commit(); |
245 | 245 | } catch(PDOException $e) { |
246 | 246 | return "error : ".$e->getMessage(); |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | try { |
252 | 252 | $Connection = new Connection(); |
253 | 253 | $sth = $Connection->db->prepare($query); |
254 | - $sth->execute(array(':source' => $database_file)); |
|
255 | - } catch(PDOException $e) { |
|
256 | - return "error : ".$e->getMessage(); |
|
257 | - } |
|
254 | + $sth->execute(array(':source' => $database_file)); |
|
255 | + } catch(PDOException $e) { |
|
256 | + return "error : ".$e->getMessage(); |
|
257 | + } |
|
258 | 258 | return ''; |
259 | 259 | } |
260 | 260 | |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | try { |
267 | 267 | $Connection = new Connection(); |
268 | 268 | $sth = $Connection->db->prepare($query); |
269 | - $sth->execute(array(':source' => $database_file)); |
|
270 | - } catch(PDOException $e) { |
|
271 | - return "error : ".$e->getMessage(); |
|
272 | - } |
|
269 | + $sth->execute(array(':source' => $database_file)); |
|
270 | + } catch(PDOException $e) { |
|
271 | + return "error : ".$e->getMessage(); |
|
272 | + } |
|
273 | 273 | |
274 | 274 | if ($fh = fopen($database_file,"r")) { |
275 | 275 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -279,26 +279,26 @@ discard block |
||
279 | 279 | $sth_dest = $Connection->db->prepare($query_dest); |
280 | 280 | try { |
281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); |
282 | - while (!feof($fh)) { |
|
283 | - $values = array(); |
|
284 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
282 | + while (!feof($fh)) { |
|
283 | + $values = array(); |
|
284 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
286 | - $values['ModeS'] = substr($line,0,6); |
|
287 | - $values['Registration'] = trim(substr($line,69,6)); |
|
288 | - $aircraft_name = trim(substr($line,48,6)); |
|
289 | - // Check if we can find ICAO, else set it to GLID |
|
290 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
291 | - $search_more = ''; |
|
292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
293 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
294 | - $sth_search = $Connection->db->prepare($query_search); |
|
286 | + $values['ModeS'] = substr($line,0,6); |
|
287 | + $values['Registration'] = trim(substr($line,69,6)); |
|
288 | + $aircraft_name = trim(substr($line,48,6)); |
|
289 | + // Check if we can find ICAO, else set it to GLID |
|
290 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
291 | + $search_more = ''; |
|
292 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
293 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
294 | + $sth_search = $Connection->db->prepare($query_search); |
|
295 | 295 | try { |
296 | - $sth_search->execute(); |
|
297 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
298 | - //if (count($result) > 0) { |
|
299 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
300 | - $values['ICAOTypeCode'] = $result['icao']; |
|
301 | - } |
|
296 | + $sth_search->execute(); |
|
297 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
298 | + //if (count($result) > 0) { |
|
299 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
300 | + $values['ICAOTypeCode'] = $result['icao']; |
|
301 | + } |
|
302 | 302 | } catch(PDOException $e) { |
303 | 303 | return "error : ".$e->getMessage(); |
304 | 304 | } |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | try { |
322 | 322 | $Connection = new Connection(); |
323 | 323 | $sth = $Connection->db->prepare($query); |
324 | - $sth->execute(array(':source' => $database_file)); |
|
325 | - } catch(PDOException $e) { |
|
326 | - return "error : ".$e->getMessage(); |
|
327 | - } |
|
324 | + $sth->execute(array(':source' => $database_file)); |
|
325 | + } catch(PDOException $e) { |
|
326 | + return "error : ".$e->getMessage(); |
|
327 | + } |
|
328 | 328 | return ''; |
329 | 329 | } |
330 | 330 | |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | try { |
336 | 336 | $Connection = new Connection(); |
337 | 337 | $sth = $Connection->db->prepare($query); |
338 | - $sth->execute(array(':source' => $database_file)); |
|
339 | - } catch(PDOException $e) { |
|
340 | - return "error : ".$e->getMessage(); |
|
341 | - } |
|
338 | + $sth->execute(array(':source' => $database_file)); |
|
339 | + } catch(PDOException $e) { |
|
340 | + return "error : ".$e->getMessage(); |
|
341 | + } |
|
342 | 342 | |
343 | 343 | if ($fh = fopen($database_file,"r")) { |
344 | 344 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -349,25 +349,25 @@ discard block |
||
349 | 349 | try { |
350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); |
351 | 351 | $tmp = fgetcsv($fh,9999,',',"'"); |
352 | - while (!feof($fh)) { |
|
353 | - $line = fgetcsv($fh,9999,',',"'"); |
|
352 | + while (!feof($fh)) { |
|
353 | + $line = fgetcsv($fh,9999,',',"'"); |
|
354 | 354 | |
355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
356 | 356 | //print_r($line); |
357 | - $values['ModeS'] = $line[1]; |
|
358 | - $values['Registration'] = $line[3]; |
|
359 | - $values['ICAOTypeCode'] = ''; |
|
360 | - $aircraft_name = $line[2]; |
|
361 | - // Check if we can find ICAO, else set it to GLID |
|
362 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
363 | - $search_more = ''; |
|
364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
365 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
366 | - $sth_search = $Connection->db->prepare($query_search); |
|
357 | + $values['ModeS'] = $line[1]; |
|
358 | + $values['Registration'] = $line[3]; |
|
359 | + $values['ICAOTypeCode'] = ''; |
|
360 | + $aircraft_name = $line[2]; |
|
361 | + // Check if we can find ICAO, else set it to GLID |
|
362 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
363 | + $search_more = ''; |
|
364 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
365 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
366 | + $sth_search = $Connection->db->prepare($query_search); |
|
367 | 367 | try { |
368 | - $sth_search->execute(); |
|
369 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
368 | + $sth_search->execute(); |
|
369 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
370 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
371 | 371 | } catch(PDOException $e) { |
372 | 372 | return "error : ".$e->getMessage(); |
373 | 373 | } |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | try { |
391 | 391 | $Connection = new Connection(); |
392 | 392 | $sth = $Connection->db->prepare($query); |
393 | - $sth->execute(array(':source' => $database_file)); |
|
394 | - } catch(PDOException $e) { |
|
395 | - return "error : ".$e->getMessage(); |
|
396 | - } |
|
393 | + $sth->execute(array(':source' => $database_file)); |
|
394 | + } catch(PDOException $e) { |
|
395 | + return "error : ".$e->getMessage(); |
|
396 | + } |
|
397 | 397 | return ''; |
398 | 398 | } |
399 | 399 | |
@@ -404,16 +404,16 @@ discard block |
||
404 | 404 | try { |
405 | 405 | $Connection = new Connection(); |
406 | 406 | $sth = $Connection->db->prepare($query); |
407 | - $sth->execute(array(':source' => $database_file)); |
|
408 | - } catch(PDOException $e) { |
|
409 | - return "error : ".$e->getMessage(); |
|
410 | - } |
|
407 | + $sth->execute(array(':source' => $database_file)); |
|
408 | + } catch(PDOException $e) { |
|
409 | + return "error : ".$e->getMessage(); |
|
410 | + } |
|
411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
412 | 412 | $Spotter = new Spotter(); |
413 | 413 | if ($fh = fopen($database_file,"r")) { |
414 | 414 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
416 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
416 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
417 | 417 | |
418 | 418 | $Connection = new Connection(); |
419 | 419 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -421,126 +421,126 @@ discard block |
||
421 | 421 | try { |
422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); |
423 | 423 | $tmp = fgetcsv($fh,9999,',','"'); |
424 | - while (!feof($fh)) { |
|
425 | - $line = fgetcsv($fh,9999,',','"'); |
|
426 | - $values = array(); |
|
427 | - //print_r($line); |
|
428 | - if ($country == 'F') { |
|
429 | - $values['registration'] = $line[0]; |
|
430 | - $values['base'] = $line[4]; |
|
431 | - $values['owner'] = $line[5]; |
|
432 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
434 | - $values['cancel'] = $line[7]; |
|
424 | + while (!feof($fh)) { |
|
425 | + $line = fgetcsv($fh,9999,',','"'); |
|
426 | + $values = array(); |
|
427 | + //print_r($line); |
|
428 | + if ($country == 'F') { |
|
429 | + $values['registration'] = $line[0]; |
|
430 | + $values['base'] = $line[4]; |
|
431 | + $values['owner'] = $line[5]; |
|
432 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
433 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
434 | + $values['cancel'] = $line[7]; |
|
435 | 435 | } elseif ($country == 'EI') { |
436 | - // TODO : add modeS & reg to aircraft_modes |
|
437 | - $values['registration'] = $line[0]; |
|
438 | - $values['base'] = $line[3]; |
|
439 | - $values['owner'] = $line[2]; |
|
440 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
442 | - $values['cancel'] = ''; |
|
443 | - $values['modes'] = $line[7]; |
|
444 | - $values['icao'] = $line[8]; |
|
436 | + // TODO : add modeS & reg to aircraft_modes |
|
437 | + $values['registration'] = $line[0]; |
|
438 | + $values['base'] = $line[3]; |
|
439 | + $values['owner'] = $line[2]; |
|
440 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
441 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
442 | + $values['cancel'] = ''; |
|
443 | + $values['modes'] = $line[7]; |
|
444 | + $values['icao'] = $line[8]; |
|
445 | 445 | |
446 | 446 | } elseif ($country == 'HB') { |
447 | - // TODO : add modeS & reg to aircraft_modes |
|
448 | - $values['registration'] = $line[0]; |
|
449 | - $values['base'] = null; |
|
450 | - $values['owner'] = $line[5]; |
|
451 | - $values['date_first_reg'] = null; |
|
452 | - $values['cancel'] = ''; |
|
453 | - $values['modes'] = $line[4]; |
|
454 | - $values['icao'] = $line[7]; |
|
447 | + // TODO : add modeS & reg to aircraft_modes |
|
448 | + $values['registration'] = $line[0]; |
|
449 | + $values['base'] = null; |
|
450 | + $values['owner'] = $line[5]; |
|
451 | + $values['date_first_reg'] = null; |
|
452 | + $values['cancel'] = ''; |
|
453 | + $values['modes'] = $line[4]; |
|
454 | + $values['icao'] = $line[7]; |
|
455 | 455 | } elseif ($country == 'OK') { |
456 | - // TODO : add modeS & reg to aircraft_modes |
|
457 | - $values['registration'] = $line[3]; |
|
458 | - $values['base'] = null; |
|
459 | - $values['owner'] = $line[5]; |
|
460 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
462 | - $values['cancel'] = ''; |
|
456 | + // TODO : add modeS & reg to aircraft_modes |
|
457 | + $values['registration'] = $line[3]; |
|
458 | + $values['base'] = null; |
|
459 | + $values['owner'] = $line[5]; |
|
460 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
461 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
462 | + $values['cancel'] = ''; |
|
463 | 463 | } elseif ($country == 'VH') { |
464 | - // TODO : add modeS & reg to aircraft_modes |
|
465 | - $values['registration'] = $line[0]; |
|
466 | - $values['base'] = null; |
|
467 | - $values['owner'] = $line[12]; |
|
468 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
470 | - |
|
471 | - $values['cancel'] = $line[39]; |
|
464 | + // TODO : add modeS & reg to aircraft_modes |
|
465 | + $values['registration'] = $line[0]; |
|
466 | + $values['base'] = null; |
|
467 | + $values['owner'] = $line[12]; |
|
468 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
469 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
470 | + |
|
471 | + $values['cancel'] = $line[39]; |
|
472 | 472 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
473 | - $values['registration'] = $line[0]; |
|
474 | - $values['base'] = null; |
|
475 | - $values['owner'] = $line[4]; |
|
476 | - $values['date_first_reg'] = null; |
|
477 | - $values['cancel'] = ''; |
|
473 | + $values['registration'] = $line[0]; |
|
474 | + $values['base'] = null; |
|
475 | + $values['owner'] = $line[4]; |
|
476 | + $values['date_first_reg'] = null; |
|
477 | + $values['cancel'] = ''; |
|
478 | 478 | } elseif ($country == 'CC') { |
479 | - $values['registration'] = $line[0]; |
|
480 | - $values['base'] = null; |
|
481 | - $values['owner'] = $line[6]; |
|
482 | - $values['date_first_reg'] = null; |
|
483 | - $values['cancel'] = ''; |
|
479 | + $values['registration'] = $line[0]; |
|
480 | + $values['base'] = null; |
|
481 | + $values['owner'] = $line[6]; |
|
482 | + $values['date_first_reg'] = null; |
|
483 | + $values['cancel'] = ''; |
|
484 | 484 | } elseif ($country == 'HJ') { |
485 | - $values['registration'] = $line[0]; |
|
486 | - $values['base'] = null; |
|
487 | - $values['owner'] = $line[8]; |
|
488 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
490 | - $values['cancel'] = ''; |
|
485 | + $values['registration'] = $line[0]; |
|
486 | + $values['base'] = null; |
|
487 | + $values['owner'] = $line[8]; |
|
488 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
489 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
490 | + $values['cancel'] = ''; |
|
491 | 491 | } elseif ($country == 'PP') { |
492 | - $values['registration'] = $line[0]; |
|
493 | - $values['base'] = null; |
|
494 | - $values['owner'] = $line[4]; |
|
495 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
497 | - $values['cancel'] = $line[7]; |
|
492 | + $values['registration'] = $line[0]; |
|
493 | + $values['base'] = null; |
|
494 | + $values['owner'] = $line[4]; |
|
495 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
496 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
497 | + $values['cancel'] = $line[7]; |
|
498 | 498 | } elseif ($country == 'E7') { |
499 | - $values['registration'] = $line[0]; |
|
500 | - $values['base'] = null; |
|
501 | - $values['owner'] = $line[4]; |
|
502 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
504 | - $values['cancel'] = ''; |
|
499 | + $values['registration'] = $line[0]; |
|
500 | + $values['base'] = null; |
|
501 | + $values['owner'] = $line[4]; |
|
502 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
503 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
504 | + $values['cancel'] = ''; |
|
505 | 505 | } elseif ($country == '8Q') { |
506 | - $values['registration'] = $line[0]; |
|
507 | - $values['base'] = null; |
|
508 | - $values['owner'] = $line[3]; |
|
509 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
511 | - $values['cancel'] = ''; |
|
506 | + $values['registration'] = $line[0]; |
|
507 | + $values['base'] = null; |
|
508 | + $values['owner'] = $line[3]; |
|
509 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
510 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
511 | + $values['cancel'] = ''; |
|
512 | 512 | } elseif ($country == 'ZK') { |
513 | - $values['registration'] = $line[0]; |
|
514 | - $values['base'] = null; |
|
515 | - $values['owner'] = $line[3]; |
|
516 | - $values['date_first_reg'] = null; |
|
517 | - $values['cancel'] = ''; |
|
518 | - $values['modes'] = $line[5]; |
|
519 | - $values['icao'] = $line[9]; |
|
513 | + $values['registration'] = $line[0]; |
|
514 | + $values['base'] = null; |
|
515 | + $values['owner'] = $line[3]; |
|
516 | + $values['date_first_reg'] = null; |
|
517 | + $values['cancel'] = ''; |
|
518 | + $values['modes'] = $line[5]; |
|
519 | + $values['icao'] = $line[9]; |
|
520 | 520 | } elseif ($country == 'M') { |
521 | - $values['registration'] = $line[0]; |
|
522 | - $values['base'] = null; |
|
523 | - $values['owner'] = $line[6]; |
|
524 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
525 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
526 | - $values['modes'] = $line[4]; |
|
527 | - $values['icao'] = $line[10]; |
|
521 | + $values['registration'] = $line[0]; |
|
522 | + $values['base'] = null; |
|
523 | + $values['owner'] = $line[6]; |
|
524 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
525 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
526 | + $values['modes'] = $line[4]; |
|
527 | + $values['icao'] = $line[10]; |
|
528 | 528 | } elseif ($country == 'OY') { |
529 | - $values['registration'] = $line[0]; |
|
530 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
531 | - $values['modes'] = $line[5]; |
|
532 | - $values['icao'] = $line[6]; |
|
529 | + $values['registration'] = $line[0]; |
|
530 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
531 | + $values['modes'] = $line[5]; |
|
532 | + $values['icao'] = $line[6]; |
|
533 | 533 | } elseif ($country == 'PH') { |
534 | - $values['registration'] = $line[0]; |
|
535 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
536 | - $values['modes'] = $line[4]; |
|
537 | - $values['icao'] = $line[5]; |
|
534 | + $values['registration'] = $line[0]; |
|
535 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
536 | + $values['modes'] = $line[4]; |
|
537 | + $values['icao'] = $line[5]; |
|
538 | 538 | } elseif ($country == 'OM' || $country == 'TF') { |
539 | - $values['registration'] = $line[0]; |
|
540 | - $values['base'] = null; |
|
541 | - $values['owner'] = $line[3]; |
|
542 | - $values['date_first_reg'] = null; |
|
543 | - $values['cancel'] = ''; |
|
539 | + $values['registration'] = $line[0]; |
|
540 | + $values['base'] = null; |
|
541 | + $values['owner'] = $line[3]; |
|
542 | + $values['date_first_reg'] = null; |
|
543 | + $values['cancel'] = ''; |
|
544 | 544 | } |
545 | 545 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
546 | 546 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | return "error : ".$e->getMessage(); |
674 | 674 | } |
675 | 675 | */ |
676 | - /* |
|
676 | + /* |
|
677 | 677 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
678 | 678 | try { |
679 | 679 | $Connection = new Connection(); |
@@ -918,10 +918,10 @@ discard block |
||
918 | 918 | try { |
919 | 919 | $Connection = new Connection(); |
920 | 920 | $sth = $Connection->db->prepare($query); |
921 | - $sth->execute(array(':source' => 'translation.csv')); |
|
922 | - } catch(PDOException $e) { |
|
923 | - return "error : ".$e->getMessage(); |
|
924 | - } |
|
921 | + $sth->execute(array(':source' => 'translation.csv')); |
|
922 | + } catch(PDOException $e) { |
|
923 | + return "error : ".$e->getMessage(); |
|
924 | + } |
|
925 | 925 | |
926 | 926 | |
927 | 927 | //update_db::unzip($out_file); |
@@ -940,21 +940,21 @@ discard block |
||
940 | 940 | $data = $row; |
941 | 941 | $operator = $data[2]; |
942 | 942 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
943 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
944 | - //echo substr($operator, 0, 2)."\n";; |
|
945 | - if (count($airline_array) > 0) { |
|
943 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
944 | + //echo substr($operator, 0, 2)."\n";; |
|
945 | + if (count($airline_array) > 0) { |
|
946 | 946 | //print_r($airline_array); |
947 | 947 | $operator = $airline_array[0]['icao'].substr($operator,2); |
948 | - } |
|
949 | - } |
|
948 | + } |
|
949 | + } |
|
950 | 950 | |
951 | 951 | $operator_correct = $data[3]; |
952 | 952 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
953 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
954 | - if (count($airline_array) > 0) { |
|
955 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
956 | - } |
|
957 | - } |
|
953 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
954 | + if (count($airline_array) > 0) { |
|
955 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
956 | + } |
|
957 | + } |
|
958 | 958 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
959 | 959 | try { |
960 | 960 | $sth = $Connection->db->prepare($query); |
@@ -968,7 +968,7 @@ discard block |
||
968 | 968 | //$Connection->db->commit(); |
969 | 969 | } |
970 | 970 | return ''; |
971 | - } |
|
971 | + } |
|
972 | 972 | |
973 | 973 | public static function translation_fam() { |
974 | 974 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -978,10 +978,10 @@ discard block |
||
978 | 978 | try { |
979 | 979 | $Connection = new Connection(); |
980 | 980 | $sth = $Connection->db->prepare($query); |
981 | - $sth->execute(array(':source' => 'website_fam')); |
|
982 | - } catch(PDOException $e) { |
|
983 | - return "error : ".$e->getMessage(); |
|
984 | - } |
|
981 | + $sth->execute(array(':source' => 'website_fam')); |
|
982 | + } catch(PDOException $e) { |
|
983 | + return "error : ".$e->getMessage(); |
|
984 | + } |
|
985 | 985 | |
986 | 986 | |
987 | 987 | //update_db::unzip($out_file); |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | //$Connection->db->commit(); |
1011 | 1011 | } |
1012 | 1012 | return ''; |
1013 | - } |
|
1013 | + } |
|
1014 | 1014 | |
1015 | 1015 | /* |
1016 | 1016 | * This function use FAA public data. |
@@ -1022,19 +1022,19 @@ discard block |
||
1022 | 1022 | try { |
1023 | 1023 | $Connection = new Connection(); |
1024 | 1024 | $sth = $Connection->db->prepare($query); |
1025 | - $sth->execute(array(':source' => 'website_faa')); |
|
1026 | - } catch(PDOException $e) { |
|
1027 | - return "error : ".$e->getMessage(); |
|
1028 | - } |
|
1025 | + $sth->execute(array(':source' => 'website_faa')); |
|
1026 | + } catch(PDOException $e) { |
|
1027 | + return "error : ".$e->getMessage(); |
|
1028 | + } |
|
1029 | 1029 | |
1030 | 1030 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
1031 | 1031 | try { |
1032 | 1032 | $Connection = new Connection(); |
1033 | 1033 | $sth = $Connection->db->prepare($query); |
1034 | - $sth->execute(array(':source' => 'website_faa')); |
|
1035 | - } catch(PDOException $e) { |
|
1036 | - return "error : ".$e->getMessage(); |
|
1037 | - } |
|
1034 | + $sth->execute(array(':source' => 'website_faa')); |
|
1035 | + } catch(PDOException $e) { |
|
1036 | + return "error : ".$e->getMessage(); |
|
1037 | + } |
|
1038 | 1038 | |
1039 | 1039 | $delimiter = ","; |
1040 | 1040 | $mfr = array(); |
@@ -1110,17 +1110,17 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | print_r($mfr); |
1112 | 1112 | return ''; |
1113 | - } |
|
1113 | + } |
|
1114 | 1114 | public static function modes_fam() { |
1115 | 1115 | global $tmp_dir, $globalTransaction; |
1116 | 1116 | $query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; |
1117 | 1117 | try { |
1118 | 1118 | $Connection = new Connection(); |
1119 | 1119 | $sth = $Connection->db->prepare($query); |
1120 | - $sth->execute(array(':source' => 'website_fam')); |
|
1121 | - } catch(PDOException $e) { |
|
1122 | - return "error : ".$e->getMessage(); |
|
1123 | - } |
|
1120 | + $sth->execute(array(':source' => 'website_fam')); |
|
1121 | + } catch(PDOException $e) { |
|
1122 | + return "error : ".$e->getMessage(); |
|
1123 | + } |
|
1124 | 1124 | |
1125 | 1125 | |
1126 | 1126 | //update_db::unzip($out_file); |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | if ($globalTransaction) $Connection->db->commit(); |
1151 | 1151 | } |
1152 | 1152 | return ''; |
1153 | - } |
|
1153 | + } |
|
1154 | 1154 | |
1155 | 1155 | public static function owner_fam() { |
1156 | 1156 | global $tmp_dir, $globalTransaction; |
@@ -1158,10 +1158,10 @@ discard block |
||
1158 | 1158 | try { |
1159 | 1159 | $Connection = new Connection(); |
1160 | 1160 | $sth = $Connection->db->prepare($query); |
1161 | - $sth->execute(array(':source' => 'website_fam')); |
|
1162 | - } catch(PDOException $e) { |
|
1163 | - return "error : ".$e->getMessage(); |
|
1164 | - } |
|
1161 | + $sth->execute(array(':source' => 'website_fam')); |
|
1162 | + } catch(PDOException $e) { |
|
1163 | + return "error : ".$e->getMessage(); |
|
1164 | + } |
|
1165 | 1165 | |
1166 | 1166 | $delimiter = "\t"; |
1167 | 1167 | $Connection = new Connection(); |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | if ($globalTransaction) $Connection->db->commit(); |
1188 | 1188 | } |
1189 | 1189 | return ''; |
1190 | - } |
|
1190 | + } |
|
1191 | 1191 | |
1192 | 1192 | public static function routes_fam() { |
1193 | 1193 | global $tmp_dir, $globalTransaction, $globalDebug; |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | if ($globalTransaction) $Connection->db->commit(); |
1223 | 1223 | } |
1224 | 1224 | return ''; |
1225 | - } |
|
1225 | + } |
|
1226 | 1226 | |
1227 | 1227 | public static function marine_identity_fam() { |
1228 | 1228 | global $tmp_dir, $globalTransaction; |
@@ -1230,10 +1230,10 @@ discard block |
||
1230 | 1230 | try { |
1231 | 1231 | $Connection = new Connection(); |
1232 | 1232 | $sth = $Connection->db->prepare($query); |
1233 | - $sth->execute(); |
|
1234 | - } catch(PDOException $e) { |
|
1235 | - return "error : ".$e->getMessage(); |
|
1236 | - } |
|
1233 | + $sth->execute(); |
|
1234 | + } catch(PDOException $e) { |
|
1235 | + return "error : ".$e->getMessage(); |
|
1236 | + } |
|
1237 | 1237 | |
1238 | 1238 | |
1239 | 1239 | //update_db::unzip($out_file); |
@@ -1263,7 +1263,7 @@ discard block |
||
1263 | 1263 | if ($globalTransaction) $Connection->db->commit(); |
1264 | 1264 | } |
1265 | 1265 | return ''; |
1266 | - } |
|
1266 | + } |
|
1267 | 1267 | |
1268 | 1268 | public static function banned_fam() { |
1269 | 1269 | global $tmp_dir, $globalTransaction; |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | if ($globalTransaction) $Connection->db->commit(); |
1298 | 1298 | } |
1299 | 1299 | return ''; |
1300 | - } |
|
1300 | + } |
|
1301 | 1301 | |
1302 | 1302 | public static function tle($filename,$tletype) { |
1303 | 1303 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1308,10 +1308,10 @@ discard block |
||
1308 | 1308 | try { |
1309 | 1309 | $Connection = new Connection(); |
1310 | 1310 | $sth = $Connection->db->prepare($query); |
1311 | - $sth->execute(array(':source' => $filename)); |
|
1312 | - } catch(PDOException $e) { |
|
1313 | - return "error : ".$e->getMessage(); |
|
1314 | - } |
|
1311 | + $sth->execute(array(':source' => $filename)); |
|
1312 | + } catch(PDOException $e) { |
|
1313 | + return "error : ".$e->getMessage(); |
|
1314 | + } |
|
1315 | 1315 | |
1316 | 1316 | $Connection = new Connection(); |
1317 | 1317 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1346,54 +1346,54 @@ discard block |
||
1346 | 1346 | //$Connection->db->commit(); |
1347 | 1347 | } |
1348 | 1348 | return ''; |
1349 | - } |
|
1349 | + } |
|
1350 | 1350 | |
1351 | 1351 | /** |
1352 | - * Convert a HTML table to an array |
|
1353 | - * @param String $data HTML page |
|
1354 | - * @return Array array of the tables in HTML page |
|
1355 | - */ |
|
1356 | - private static function table2array($data) { |
|
1357 | - $html = str_get_html($data); |
|
1358 | - $tabledata=array(); |
|
1359 | - foreach($html->find('tr') as $element) |
|
1360 | - { |
|
1361 | - $td = array(); |
|
1362 | - foreach( $element->find('th') as $row) |
|
1363 | - { |
|
1364 | - $td [] = trim($row->plaintext); |
|
1365 | - } |
|
1366 | - $td=array_filter($td); |
|
1367 | - $tabledata[] = $td; |
|
1368 | - |
|
1369 | - $td = array(); |
|
1370 | - $tdi = array(); |
|
1371 | - foreach( $element->find('td') as $row) |
|
1372 | - { |
|
1373 | - $td [] = trim($row->plaintext); |
|
1374 | - $tdi [] = trim($row->innertext); |
|
1375 | - } |
|
1376 | - $td=array_filter($td); |
|
1377 | - $tdi=array_filter($tdi); |
|
1378 | - // $tabledata[]=array_merge($td,$tdi); |
|
1379 | - $tabledata[]=$td; |
|
1380 | - } |
|
1381 | - return(array_filter($tabledata)); |
|
1382 | - } |
|
1383 | - |
|
1384 | - /** |
|
1385 | - * Get data from form result |
|
1386 | - * @param String $url form URL |
|
1387 | - * @return String the result |
|
1388 | - */ |
|
1389 | - private static function getData($url) { |
|
1390 | - $ch = curl_init(); |
|
1391 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
1392 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1393 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1394 | - curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
1395 | - return curl_exec($ch); |
|
1396 | - } |
|
1352 | + * Convert a HTML table to an array |
|
1353 | + * @param String $data HTML page |
|
1354 | + * @return Array array of the tables in HTML page |
|
1355 | + */ |
|
1356 | + private static function table2array($data) { |
|
1357 | + $html = str_get_html($data); |
|
1358 | + $tabledata=array(); |
|
1359 | + foreach($html->find('tr') as $element) |
|
1360 | + { |
|
1361 | + $td = array(); |
|
1362 | + foreach( $element->find('th') as $row) |
|
1363 | + { |
|
1364 | + $td [] = trim($row->plaintext); |
|
1365 | + } |
|
1366 | + $td=array_filter($td); |
|
1367 | + $tabledata[] = $td; |
|
1368 | + |
|
1369 | + $td = array(); |
|
1370 | + $tdi = array(); |
|
1371 | + foreach( $element->find('td') as $row) |
|
1372 | + { |
|
1373 | + $td [] = trim($row->plaintext); |
|
1374 | + $tdi [] = trim($row->innertext); |
|
1375 | + } |
|
1376 | + $td=array_filter($td); |
|
1377 | + $tdi=array_filter($tdi); |
|
1378 | + // $tabledata[]=array_merge($td,$tdi); |
|
1379 | + $tabledata[]=$td; |
|
1380 | + } |
|
1381 | + return(array_filter($tabledata)); |
|
1382 | + } |
|
1383 | + |
|
1384 | + /** |
|
1385 | + * Get data from form result |
|
1386 | + * @param String $url form URL |
|
1387 | + * @return String the result |
|
1388 | + */ |
|
1389 | + private static function getData($url) { |
|
1390 | + $ch = curl_init(); |
|
1391 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1392 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1393 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1394 | + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
1395 | + return curl_exec($ch); |
|
1396 | + } |
|
1397 | 1397 | /* |
1398 | 1398 | public static function waypoints() { |
1399 | 1399 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1476,7 +1476,7 @@ discard block |
||
1476 | 1476 | if ($globalTransaction) $Connection->db->commit(); |
1477 | 1477 | } |
1478 | 1478 | return ''; |
1479 | - } |
|
1479 | + } |
|
1480 | 1480 | |
1481 | 1481 | public static function ivao_airlines($filename) { |
1482 | 1482 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1486,10 +1486,10 @@ discard block |
||
1486 | 1486 | try { |
1487 | 1487 | $Connection = new Connection(); |
1488 | 1488 | $sth = $Connection->db->prepare($query); |
1489 | - $sth->execute(); |
|
1490 | - } catch(PDOException $e) { |
|
1491 | - return "error : ".$e->getMessage(); |
|
1492 | - } |
|
1489 | + $sth->execute(); |
|
1490 | + } catch(PDOException $e) { |
|
1491 | + return "error : ".$e->getMessage(); |
|
1492 | + } |
|
1493 | 1493 | |
1494 | 1494 | $header = NULL; |
1495 | 1495 | $delimiter = ':'; |
@@ -1513,7 +1513,7 @@ discard block |
||
1513 | 1513 | if ($globalTransaction) $Connection->db->commit(); |
1514 | 1514 | } |
1515 | 1515 | return ''; |
1516 | - } |
|
1516 | + } |
|
1517 | 1517 | |
1518 | 1518 | public static function update_airspace() { |
1519 | 1519 | global $tmp_dir, $globalDBdriver; |
@@ -1523,11 +1523,11 @@ discard block |
||
1523 | 1523 | $query = 'DROP TABLE airspace'; |
1524 | 1524 | try { |
1525 | 1525 | $sth = $Connection->db->prepare($query); |
1526 | - $sth->execute(); |
|
1527 | - } catch(PDOException $e) { |
|
1526 | + $sth->execute(); |
|
1527 | + } catch(PDOException $e) { |
|
1528 | 1528 | return "error : ".$e->getMessage(); |
1529 | - } |
|
1530 | - } |
|
1529 | + } |
|
1530 | + } |
|
1531 | 1531 | |
1532 | 1532 | |
1533 | 1533 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1582,10 +1582,10 @@ discard block |
||
1582 | 1582 | $query = 'DROP TABLE countries'; |
1583 | 1583 | try { |
1584 | 1584 | $sth = $Connection->db->prepare($query); |
1585 | - $sth->execute(); |
|
1586 | - } catch(PDOException $e) { |
|
1587 | - echo "error : ".$e->getMessage(); |
|
1588 | - } |
|
1585 | + $sth->execute(); |
|
1586 | + } catch(PDOException $e) { |
|
1587 | + echo "error : ".$e->getMessage(); |
|
1588 | + } |
|
1589 | 1589 | } |
1590 | 1590 | if ($globalDBdriver == 'mysql') { |
1591 | 1591 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2114,11 +2114,11 @@ discard block |
||
2114 | 2114 | $query = 'DROP TABLE airspace'; |
2115 | 2115 | try { |
2116 | 2116 | $sth = $Connection->db->prepare($query); |
2117 | - $sth->execute(); |
|
2118 | - } catch(PDOException $e) { |
|
2117 | + $sth->execute(); |
|
2118 | + } catch(PDOException $e) { |
|
2119 | 2119 | return "error : ".$e->getMessage(); |
2120 | - } |
|
2121 | - } |
|
2120 | + } |
|
2121 | + } |
|
2122 | 2122 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2123 | 2123 | update_db::insert_airspace_version($airspace_md5); |
2124 | 2124 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -2300,12 +2300,12 @@ discard block |
||
2300 | 2300 | echo $data; |
2301 | 2301 | */ |
2302 | 2302 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2303 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2304 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2305 | - $result = fread($fh,100000000); |
|
2306 | - //echo $result; |
|
2307 | - //var_dump(str_get_html($result)); |
|
2308 | - //print_r(self::table2array($result)); |
|
2303 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2304 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2305 | + $result = fread($fh,100000000); |
|
2306 | + //echo $result; |
|
2307 | + //var_dump(str_get_html($result)); |
|
2308 | + //print_r(self::table2array($result)); |
|
2309 | 2309 | } |
2310 | 2310 | |
2311 | 2311 | } |
@@ -2319,10 +2319,10 @@ discard block |
||
2319 | 2319 | try { |
2320 | 2320 | $Connection = new Connection(); |
2321 | 2321 | $sth = $Connection->db->prepare($query); |
2322 | - $sth->execute(); |
|
2323 | - } catch(PDOException $e) { |
|
2324 | - return "error : ".$e->getMessage(); |
|
2325 | - } |
|
2322 | + $sth->execute(); |
|
2323 | + } catch(PDOException $e) { |
|
2324 | + return "error : ".$e->getMessage(); |
|
2325 | + } |
|
2326 | 2326 | |
2327 | 2327 | $error = ''; |
2328 | 2328 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2378,8 +2378,8 @@ discard block |
||
2378 | 2378 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
2379 | 2379 | $data['permanent'] = 0; |
2380 | 2380 | } else { |
2381 | - $data['date_end'] = NULL; |
|
2382 | - $data['permanent'] = 1; |
|
2381 | + $data['date_end'] = NULL; |
|
2382 | + $data['permanent'] = 1; |
|
2383 | 2383 | } |
2384 | 2384 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2385 | 2385 | $NOTAM = new NOTAM(); |
@@ -2453,13 +2453,13 @@ discard block |
||
2453 | 2453 | try { |
2454 | 2454 | $Connection = new Connection(); |
2455 | 2455 | $sth = $Connection->db->prepare($query); |
2456 | - $sth->execute(); |
|
2457 | - } catch(PDOException $e) { |
|
2458 | - return "error : ".$e->getMessage(); |
|
2459 | - } |
|
2460 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2461 | - if ($row['nb'] > 0) return false; |
|
2462 | - else return true; |
|
2456 | + $sth->execute(); |
|
2457 | + } catch(PDOException $e) { |
|
2458 | + return "error : ".$e->getMessage(); |
|
2459 | + } |
|
2460 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2461 | + if ($row['nb'] > 0) return false; |
|
2462 | + else return true; |
|
2463 | 2463 | } |
2464 | 2464 | |
2465 | 2465 | public static function insert_last_update() { |
@@ -2468,10 +2468,10 @@ discard block |
||
2468 | 2468 | try { |
2469 | 2469 | $Connection = new Connection(); |
2470 | 2470 | $sth = $Connection->db->prepare($query); |
2471 | - $sth->execute(); |
|
2472 | - } catch(PDOException $e) { |
|
2473 | - return "error : ".$e->getMessage(); |
|
2474 | - } |
|
2471 | + $sth->execute(); |
|
2472 | + } catch(PDOException $e) { |
|
2473 | + return "error : ".$e->getMessage(); |
|
2474 | + } |
|
2475 | 2475 | } |
2476 | 2476 | |
2477 | 2477 | public static function check_airspace_version($version) { |
@@ -2479,13 +2479,13 @@ discard block |
||
2479 | 2479 | try { |
2480 | 2480 | $Connection = new Connection(); |
2481 | 2481 | $sth = $Connection->db->prepare($query); |
2482 | - $sth->execute(array(':version' => $version)); |
|
2483 | - } catch(PDOException $e) { |
|
2484 | - return "error : ".$e->getMessage(); |
|
2485 | - } |
|
2486 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2487 | - if ($row['nb'] > 0) return true; |
|
2488 | - else return false; |
|
2482 | + $sth->execute(array(':version' => $version)); |
|
2483 | + } catch(PDOException $e) { |
|
2484 | + return "error : ".$e->getMessage(); |
|
2485 | + } |
|
2486 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2487 | + if ($row['nb'] > 0) return true; |
|
2488 | + else return false; |
|
2489 | 2489 | } |
2490 | 2490 | |
2491 | 2491 | public static function check_geoid_version($version) { |
@@ -2493,13 +2493,13 @@ discard block |
||
2493 | 2493 | try { |
2494 | 2494 | $Connection = new Connection(); |
2495 | 2495 | $sth = $Connection->db->prepare($query); |
2496 | - $sth->execute(array(':version' => $version)); |
|
2497 | - } catch(PDOException $e) { |
|
2498 | - return "error : ".$e->getMessage(); |
|
2499 | - } |
|
2500 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2501 | - if ($row['nb'] > 0) return true; |
|
2502 | - else return false; |
|
2496 | + $sth->execute(array(':version' => $version)); |
|
2497 | + } catch(PDOException $e) { |
|
2498 | + return "error : ".$e->getMessage(); |
|
2499 | + } |
|
2500 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2501 | + if ($row['nb'] > 0) return true; |
|
2502 | + else return false; |
|
2503 | 2503 | } |
2504 | 2504 | |
2505 | 2505 | public static function check_marine_identity_version($version) { |
@@ -2507,13 +2507,13 @@ discard block |
||
2507 | 2507 | try { |
2508 | 2508 | $Connection = new Connection(); |
2509 | 2509 | $sth = $Connection->db->prepare($query); |
2510 | - $sth->execute(array(':version' => $version)); |
|
2511 | - } catch(PDOException $e) { |
|
2512 | - return "error : ".$e->getMessage(); |
|
2513 | - } |
|
2514 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2515 | - if ($row['nb'] > 0) return true; |
|
2516 | - else return false; |
|
2510 | + $sth->execute(array(':version' => $version)); |
|
2511 | + } catch(PDOException $e) { |
|
2512 | + return "error : ".$e->getMessage(); |
|
2513 | + } |
|
2514 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2515 | + if ($row['nb'] > 0) return true; |
|
2516 | + else return false; |
|
2517 | 2517 | } |
2518 | 2518 | |
2519 | 2519 | |
@@ -2535,10 +2535,10 @@ discard block |
||
2535 | 2535 | try { |
2536 | 2536 | $Connection = new Connection(); |
2537 | 2537 | $sth = $Connection->db->prepare($query); |
2538 | - $sth->execute(array(':version' => $version)); |
|
2539 | - } catch(PDOException $e) { |
|
2540 | - return "error : ".$e->getMessage(); |
|
2541 | - } |
|
2538 | + $sth->execute(array(':version' => $version)); |
|
2539 | + } catch(PDOException $e) { |
|
2540 | + return "error : ".$e->getMessage(); |
|
2541 | + } |
|
2542 | 2542 | } |
2543 | 2543 | |
2544 | 2544 | public static function insert_marine_identity_version($version) { |
@@ -2547,10 +2547,10 @@ discard block |
||
2547 | 2547 | try { |
2548 | 2548 | $Connection = new Connection(); |
2549 | 2549 | $sth = $Connection->db->prepare($query); |
2550 | - $sth->execute(array(':version' => $version)); |
|
2551 | - } catch(PDOException $e) { |
|
2552 | - return "error : ".$e->getMessage(); |
|
2553 | - } |
|
2550 | + $sth->execute(array(':version' => $version)); |
|
2551 | + } catch(PDOException $e) { |
|
2552 | + return "error : ".$e->getMessage(); |
|
2553 | + } |
|
2554 | 2554 | } |
2555 | 2555 | |
2556 | 2556 | public static function check_last_notam_update() { |
@@ -2563,13 +2563,13 @@ discard block |
||
2563 | 2563 | try { |
2564 | 2564 | $Connection = new Connection(); |
2565 | 2565 | $sth = $Connection->db->prepare($query); |
2566 | - $sth->execute(); |
|
2567 | - } catch(PDOException $e) { |
|
2568 | - return "error : ".$e->getMessage(); |
|
2569 | - } |
|
2570 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2571 | - if ($row['nb'] > 0) return false; |
|
2572 | - else return true; |
|
2566 | + $sth->execute(); |
|
2567 | + } catch(PDOException $e) { |
|
2568 | + return "error : ".$e->getMessage(); |
|
2569 | + } |
|
2570 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2571 | + if ($row['nb'] > 0) return false; |
|
2572 | + else return true; |
|
2573 | 2573 | } |
2574 | 2574 | |
2575 | 2575 | public static function insert_last_notam_update() { |
@@ -2578,10 +2578,10 @@ discard block |
||
2578 | 2578 | try { |
2579 | 2579 | $Connection = new Connection(); |
2580 | 2580 | $sth = $Connection->db->prepare($query); |
2581 | - $sth->execute(); |
|
2582 | - } catch(PDOException $e) { |
|
2583 | - return "error : ".$e->getMessage(); |
|
2584 | - } |
|
2581 | + $sth->execute(); |
|
2582 | + } catch(PDOException $e) { |
|
2583 | + return "error : ".$e->getMessage(); |
|
2584 | + } |
|
2585 | 2585 | } |
2586 | 2586 | |
2587 | 2587 | public static function check_last_airspace_update() { |
@@ -2594,13 +2594,13 @@ discard block |
||
2594 | 2594 | try { |
2595 | 2595 | $Connection = new Connection(); |
2596 | 2596 | $sth = $Connection->db->prepare($query); |
2597 | - $sth->execute(); |
|
2598 | - } catch(PDOException $e) { |
|
2599 | - return "error : ".$e->getMessage(); |
|
2600 | - } |
|
2601 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2602 | - if ($row['nb'] > 0) return false; |
|
2603 | - else return true; |
|
2597 | + $sth->execute(); |
|
2598 | + } catch(PDOException $e) { |
|
2599 | + return "error : ".$e->getMessage(); |
|
2600 | + } |
|
2601 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2602 | + if ($row['nb'] > 0) return false; |
|
2603 | + else return true; |
|
2604 | 2604 | } |
2605 | 2605 | |
2606 | 2606 | public static function insert_last_airspace_update() { |
@@ -2609,10 +2609,10 @@ discard block |
||
2609 | 2609 | try { |
2610 | 2610 | $Connection = new Connection(); |
2611 | 2611 | $sth = $Connection->db->prepare($query); |
2612 | - $sth->execute(); |
|
2613 | - } catch(PDOException $e) { |
|
2614 | - return "error : ".$e->getMessage(); |
|
2615 | - } |
|
2612 | + $sth->execute(); |
|
2613 | + } catch(PDOException $e) { |
|
2614 | + return "error : ".$e->getMessage(); |
|
2615 | + } |
|
2616 | 2616 | } |
2617 | 2617 | |
2618 | 2618 | public static function check_last_geoid_update() { |
@@ -2625,13 +2625,13 @@ discard block |
||
2625 | 2625 | try { |
2626 | 2626 | $Connection = new Connection(); |
2627 | 2627 | $sth = $Connection->db->prepare($query); |
2628 | - $sth->execute(); |
|
2629 | - } catch(PDOException $e) { |
|
2630 | - return "error : ".$e->getMessage(); |
|
2631 | - } |
|
2632 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2633 | - if ($row['nb'] > 0) return false; |
|
2634 | - else return true; |
|
2628 | + $sth->execute(); |
|
2629 | + } catch(PDOException $e) { |
|
2630 | + return "error : ".$e->getMessage(); |
|
2631 | + } |
|
2632 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2633 | + if ($row['nb'] > 0) return false; |
|
2634 | + else return true; |
|
2635 | 2635 | } |
2636 | 2636 | |
2637 | 2637 | public static function insert_last_geoid_update() { |
@@ -2640,10 +2640,10 @@ discard block |
||
2640 | 2640 | try { |
2641 | 2641 | $Connection = new Connection(); |
2642 | 2642 | $sth = $Connection->db->prepare($query); |
2643 | - $sth->execute(); |
|
2644 | - } catch(PDOException $e) { |
|
2645 | - return "error : ".$e->getMessage(); |
|
2646 | - } |
|
2643 | + $sth->execute(); |
|
2644 | + } catch(PDOException $e) { |
|
2645 | + return "error : ".$e->getMessage(); |
|
2646 | + } |
|
2647 | 2647 | } |
2648 | 2648 | |
2649 | 2649 | public static function check_last_owner_update() { |
@@ -2656,13 +2656,13 @@ discard block |
||
2656 | 2656 | try { |
2657 | 2657 | $Connection = new Connection(); |
2658 | 2658 | $sth = $Connection->db->prepare($query); |
2659 | - $sth->execute(); |
|
2660 | - } catch(PDOException $e) { |
|
2661 | - return "error : ".$e->getMessage(); |
|
2662 | - } |
|
2663 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2664 | - if ($row['nb'] > 0) return false; |
|
2665 | - else return true; |
|
2659 | + $sth->execute(); |
|
2660 | + } catch(PDOException $e) { |
|
2661 | + return "error : ".$e->getMessage(); |
|
2662 | + } |
|
2663 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2664 | + if ($row['nb'] > 0) return false; |
|
2665 | + else return true; |
|
2666 | 2666 | } |
2667 | 2667 | |
2668 | 2668 | public static function insert_last_owner_update() { |
@@ -2671,10 +2671,10 @@ discard block |
||
2671 | 2671 | try { |
2672 | 2672 | $Connection = new Connection(); |
2673 | 2673 | $sth = $Connection->db->prepare($query); |
2674 | - $sth->execute(); |
|
2675 | - } catch(PDOException $e) { |
|
2676 | - return "error : ".$e->getMessage(); |
|
2677 | - } |
|
2674 | + $sth->execute(); |
|
2675 | + } catch(PDOException $e) { |
|
2676 | + return "error : ".$e->getMessage(); |
|
2677 | + } |
|
2678 | 2678 | } |
2679 | 2679 | public static function check_last_schedules_update() { |
2680 | 2680 | global $globalDBdriver; |
@@ -2686,13 +2686,13 @@ discard block |
||
2686 | 2686 | try { |
2687 | 2687 | $Connection = new Connection(); |
2688 | 2688 | $sth = $Connection->db->prepare($query); |
2689 | - $sth->execute(); |
|
2690 | - } catch(PDOException $e) { |
|
2691 | - return "error : ".$e->getMessage(); |
|
2692 | - } |
|
2693 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2694 | - if ($row['nb'] > 0) return false; |
|
2695 | - else return true; |
|
2689 | + $sth->execute(); |
|
2690 | + } catch(PDOException $e) { |
|
2691 | + return "error : ".$e->getMessage(); |
|
2692 | + } |
|
2693 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2694 | + if ($row['nb'] > 0) return false; |
|
2695 | + else return true; |
|
2696 | 2696 | } |
2697 | 2697 | |
2698 | 2698 | public static function insert_last_schedules_update() { |
@@ -2701,10 +2701,10 @@ discard block |
||
2701 | 2701 | try { |
2702 | 2702 | $Connection = new Connection(); |
2703 | 2703 | $sth = $Connection->db->prepare($query); |
2704 | - $sth->execute(); |
|
2705 | - } catch(PDOException $e) { |
|
2706 | - return "error : ".$e->getMessage(); |
|
2707 | - } |
|
2704 | + $sth->execute(); |
|
2705 | + } catch(PDOException $e) { |
|
2706 | + return "error : ".$e->getMessage(); |
|
2707 | + } |
|
2708 | 2708 | } |
2709 | 2709 | public static function check_last_tle_update() { |
2710 | 2710 | global $globalDBdriver; |
@@ -2716,13 +2716,13 @@ discard block |
||
2716 | 2716 | try { |
2717 | 2717 | $Connection = new Connection(); |
2718 | 2718 | $sth = $Connection->db->prepare($query); |
2719 | - $sth->execute(); |
|
2720 | - } catch(PDOException $e) { |
|
2721 | - return "error : ".$e->getMessage(); |
|
2722 | - } |
|
2723 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2724 | - if ($row['nb'] > 0) return false; |
|
2725 | - else return true; |
|
2719 | + $sth->execute(); |
|
2720 | + } catch(PDOException $e) { |
|
2721 | + return "error : ".$e->getMessage(); |
|
2722 | + } |
|
2723 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2724 | + if ($row['nb'] > 0) return false; |
|
2725 | + else return true; |
|
2726 | 2726 | } |
2727 | 2727 | |
2728 | 2728 | public static function insert_last_tle_update() { |
@@ -2731,10 +2731,10 @@ discard block |
||
2731 | 2731 | try { |
2732 | 2732 | $Connection = new Connection(); |
2733 | 2733 | $sth = $Connection->db->prepare($query); |
2734 | - $sth->execute(); |
|
2735 | - } catch(PDOException $e) { |
|
2736 | - return "error : ".$e->getMessage(); |
|
2737 | - } |
|
2734 | + $sth->execute(); |
|
2735 | + } catch(PDOException $e) { |
|
2736 | + return "error : ".$e->getMessage(); |
|
2737 | + } |
|
2738 | 2738 | } |
2739 | 2739 | public static function check_last_marine_identity_update() { |
2740 | 2740 | global $globalDBdriver; |
@@ -2746,13 +2746,13 @@ discard block |
||
2746 | 2746 | try { |
2747 | 2747 | $Connection = new Connection(); |
2748 | 2748 | $sth = $Connection->db->prepare($query); |
2749 | - $sth->execute(); |
|
2750 | - } catch(PDOException $e) { |
|
2751 | - return "error : ".$e->getMessage(); |
|
2752 | - } |
|
2753 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2754 | - if ($row['nb'] > 0) return false; |
|
2755 | - else return true; |
|
2749 | + $sth->execute(); |
|
2750 | + } catch(PDOException $e) { |
|
2751 | + return "error : ".$e->getMessage(); |
|
2752 | + } |
|
2753 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2754 | + if ($row['nb'] > 0) return false; |
|
2755 | + else return true; |
|
2756 | 2756 | } |
2757 | 2757 | |
2758 | 2758 | public static function insert_last_marine_identity_update() { |
@@ -2761,10 +2761,10 @@ discard block |
||
2761 | 2761 | try { |
2762 | 2762 | $Connection = new Connection(); |
2763 | 2763 | $sth = $Connection->db->prepare($query); |
2764 | - $sth->execute(); |
|
2765 | - } catch(PDOException $e) { |
|
2766 | - return "error : ".$e->getMessage(); |
|
2767 | - } |
|
2764 | + $sth->execute(); |
|
2765 | + } catch(PDOException $e) { |
|
2766 | + return "error : ".$e->getMessage(); |
|
2767 | + } |
|
2768 | 2768 | } |
2769 | 2769 | public static function delete_duplicatemodes() { |
2770 | 2770 | global $globalDBdriver; |
@@ -2776,10 +2776,10 @@ discard block |
||
2776 | 2776 | try { |
2777 | 2777 | $Connection = new Connection(); |
2778 | 2778 | $sth = $Connection->db->prepare($query); |
2779 | - $sth->execute(); |
|
2780 | - } catch(PDOException $e) { |
|
2781 | - return "error : ".$e->getMessage(); |
|
2782 | - } |
|
2779 | + $sth->execute(); |
|
2780 | + } catch(PDOException $e) { |
|
2781 | + return "error : ".$e->getMessage(); |
|
2782 | + } |
|
2783 | 2783 | } |
2784 | 2784 | public static function delete_duplicateowner() { |
2785 | 2785 | global $globalDBdriver; |
@@ -2791,10 +2791,10 @@ discard block |
||
2791 | 2791 | try { |
2792 | 2792 | $Connection = new Connection(); |
2793 | 2793 | $sth = $Connection->db->prepare($query); |
2794 | - $sth->execute(); |
|
2795 | - } catch(PDOException $e) { |
|
2796 | - return "error : ".$e->getMessage(); |
|
2797 | - } |
|
2794 | + $sth->execute(); |
|
2795 | + } catch(PDOException $e) { |
|
2796 | + return "error : ".$e->getMessage(); |
|
2797 | + } |
|
2798 | 2798 | } |
2799 | 2799 | |
2800 | 2800 | public static function update_all() { |