@@ -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]); |
@@ -168,17 +168,17 @@ discard block |
||
168 | 168 | } |
169 | 169 | ?> |
170 | 170 | <?php |
171 | - if (isset($_POST['archive'])) { |
|
171 | + if (isset($_POST['archive'])) { |
|
172 | 172 | ?> |
173 | 173 | <script src="<?php print $globalURL; ?>/js/map.common.js"></script> |
174 | 174 | <?php |
175 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
175 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
176 | 176 | ?> |
177 | 177 | |
178 | 178 | <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> |
179 | 179 | <?php |
180 | - } |
|
181 | - } else { |
|
180 | + } |
|
181 | + } else { |
|
182 | 182 | ?> |
183 | 183 | <?php |
184 | 184 | /* if (isset($globalBeta) && $globalBeta) { |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | */ |
191 | 191 | ?> |
192 | 192 | <?php |
193 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
193 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
194 | 194 | ?> |
195 | 195 | <?php |
196 | 196 | // if (isset($globalBeta) && $globalBeta) { |
@@ -217,13 +217,13 @@ discard block |
||
217 | 217 | <script src="<?php print $globalURL; ?>/js/map-marine.2d.js.php?<?php print time(); ?>"></script> |
218 | 218 | <?php |
219 | 219 | } |
220 | - } |
|
220 | + } |
|
221 | 221 | ?> |
222 | 222 | <?php |
223 | 223 | // } |
224 | 224 | ?> |
225 | 225 | <?php |
226 | - } |
|
226 | + } |
|
227 | 227 | } |
228 | 228 | ?> |
229 | 229 | <?php |
@@ -380,15 +380,15 @@ discard block |
||
380 | 380 | <li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li> |
381 | 381 | <li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li> |
382 | 382 | <?php |
383 | - if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { |
|
383 | + if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { |
|
384 | 384 | ?> |
385 | 385 | <li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li> |
386 | 386 | <?php |
387 | - } else { |
|
387 | + } else { |
|
388 | 388 | ?> |
389 | 389 | <li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li> |
390 | 390 | <?php |
391 | - } |
|
391 | + } |
|
392 | 392 | ?> |
393 | 393 | <li><hr /></li> |
394 | 394 | <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li> |
@@ -396,34 +396,34 @@ discard block |
||
396 | 396 | <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li> |
397 | 397 | <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li> |
398 | 398 | <?php |
399 | - if ($globalACARS) { |
|
400 | - if (isset($globalDemo) && $globalDemo) { |
|
401 | - ?> |
|
399 | + if ($globalACARS) { |
|
400 | + if (isset($globalDemo) && $globalDemo) { |
|
401 | + ?> |
|
402 | 402 | <li><hr /></li> |
403 | 403 | <li><i><?php echo _('ACARS data not available publicly'); ?></i></li> |
404 | 404 | <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li> |
405 | 405 | <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li> |
406 | 406 | <?php |
407 | - } else { |
|
408 | - ?> |
|
407 | + } else { |
|
408 | + ?> |
|
409 | 409 | <li><hr /></li> |
410 | 410 | <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li> |
411 | 411 | <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li> |
412 | 412 | <?php |
413 | - } |
|
414 | - } |
|
415 | - ?> |
|
413 | + } |
|
414 | + } |
|
415 | + ?> |
|
416 | 416 | <?php |
417 | - if (isset($globalAccidents) && $globalAccidents) { |
|
418 | - ?> |
|
417 | + if (isset($globalAccidents) && $globalAccidents) { |
|
418 | + ?> |
|
419 | 419 | <li><hr /></li> |
420 | 420 | <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li> |
421 | 421 | <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li> |
422 | 422 | <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li> |
423 | 423 | <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li> |
424 | 424 | <?php |
425 | - } |
|
426 | - ?> |
|
425 | + } |
|
426 | + ?> |
|
427 | 427 | <li><hr /></li> |
428 | 428 | <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li> |
429 | 429 | <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li> |
@@ -465,14 +465,14 @@ discard block |
||
465 | 465 | <form> |
466 | 466 | <select class="selectpicker" data-width="120px" onchange="language(this);"> |
467 | 467 | <?php |
468 | - $Language = new Language(); |
|
469 | - $alllang = $Language->getLanguages(); |
|
470 | - foreach ($alllang as $key => $lang) { |
|
471 | - print '<option value="'.$key.'"'; |
|
472 | - if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
473 | - print '>'.$lang[0].'</option>'; |
|
474 | - } |
|
475 | - ?> |
|
468 | + $Language = new Language(); |
|
469 | + $alllang = $Language->getLanguages(); |
|
470 | + foreach ($alllang as $key => $lang) { |
|
471 | + print '<option value="'.$key.'"'; |
|
472 | + if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
473 | + print '>'.$lang[0].'</option>'; |
|
474 | + } |
|
475 | + ?> |
|
476 | 476 | </select> |
477 | 477 | </form> |
478 | 478 | </div> |
@@ -503,18 +503,18 @@ discard block |
||
503 | 503 | ?> |
504 | 504 | <div class="top-header clear" role="main"> |
505 | 505 | <?php |
506 | - if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
506 | + if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
507 | 507 | ?> |
508 | 508 | <div id="archive-map"></div> |
509 | 509 | <?php |
510 | - } |
|
510 | + } |
|
511 | 511 | ?> |
512 | 512 | </div> |
513 | 513 | <?php |
514 | 514 | } |
515 | 515 | 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)) |
516 | 516 | { |
517 | - ?> |
|
517 | + ?> |
|
518 | 518 | <div class="top-header clear" role="main"> |
519 | 519 | <div id="map"></div> |
520 | 520 | <link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" /> |
@@ -525,15 +525,15 @@ discard block |
||
525 | 525 | var zoom = 13; |
526 | 526 | //create the map |
527 | 527 | <?php |
528 | - if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
528 | + if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
529 | 529 | ?> |
530 | 530 | map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom); |
531 | 531 | <?php |
532 | - } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
532 | + } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
533 | 533 | ?> |
534 | 534 | map = L.map('map', { zoomControl:true }); |
535 | 535 | <?php |
536 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
536 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
537 | 537 | ?> |
538 | 538 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]); |
539 | 539 | 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); |
@@ -541,22 +541,22 @@ discard block |
||
541 | 541 | 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); |
542 | 542 | 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); |
543 | 543 | <?php |
544 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
544 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
545 | 545 | ?> |
546 | 546 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]); |
547 | 547 | <?php |
548 | - } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
548 | + } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
549 | 549 | ?> |
550 | 550 | map = L.map('map', { zoomControl:true }); |
551 | 551 | <?php |
552 | - } |
|
552 | + } |
|
553 | 553 | ?> |
554 | 554 | //initialize the layer group for the aircrft markers |
555 | 555 | var layer_data = L.layerGroup(); |
556 | 556 | |
557 | 557 | //a few title layers |
558 | 558 | <?php |
559 | - if ($globalMapProvider == 'Mapbox') { |
|
559 | + if ($globalMapProvider == 'Mapbox') { |
|
560 | 560 | ?> |
561 | 561 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
562 | 562 | maxZoom: 18, |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | token : '<?php print $globalMapboxToken; ?>' |
568 | 568 | }).addTo(map); |
569 | 569 | <?php |
570 | - } elseif ($globalMapProvider == 'OpenStreetMap') { |
|
570 | + } elseif ($globalMapProvider == 'OpenStreetMap') { |
|
571 | 571 | ?> |
572 | 572 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
573 | 573 | maxZoom: 18, |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>' |
576 | 576 | }).addTo(map); |
577 | 577 | <?php |
578 | - } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
578 | + } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
579 | 579 | ?> |
580 | 580 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', { |
581 | 581 | maxZoom: 18, |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>' |
585 | 585 | }).addTo(map); |
586 | 586 | <?php |
587 | - } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
587 | + } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
588 | 588 | ?> |
589 | 589 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', { |
590 | 590 | maxZoom: 18, |
@@ -593,27 +593,27 @@ discard block |
||
593 | 593 | '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"' |
594 | 594 | }).addTo(map); |
595 | 595 | <?php |
596 | - } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
596 | + } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
597 | 597 | ?> |
598 | 598 | var googleLayer = new L.Google('ROADMAP'); |
599 | 599 | map.addLayer(googleLayer); |
600 | 600 | <?php |
601 | - } elseif ($globalMapProvider == 'Google-Satellite') { |
|
601 | + } elseif ($globalMapProvider == 'Google-Satellite') { |
|
602 | 602 | ?> |
603 | 603 | var googleLayer = new L.Google('SATELLITE'); |
604 | 604 | map.addLayer(googleLayer); |
605 | 605 | <?php |
606 | - } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
606 | + } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
607 | 607 | ?> |
608 | 608 | var googleLayer = new L.Google('HYBRID'); |
609 | 609 | map.addLayer(googleLayer); |
610 | 610 | <?php |
611 | - } elseif ($globalMapProvider == 'Google-Terrain') { |
|
611 | + } elseif ($globalMapProvider == 'Google-Terrain') { |
|
612 | 612 | ?> |
613 | 613 | var googleLayer = new L.Google('Terrain'); |
614 | 614 | map.addLayer(googleLayer); |
615 | 615 | <?php |
616 | - } |
|
616 | + } |
|
617 | 617 | ?> |
618 | 618 | </script> |
619 | 619 | </div> |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | <div id="showdetails" class="showdetails"></div> |
37 | 37 | <div id="infobox" class="infobox"><h4><?php echo _("Aircrafts detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div> |
38 | 38 | <?php |
39 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
39 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
40 | 40 | |
41 | 41 | ?> |
42 | 42 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script> |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script> |
57 | 57 | <?php |
58 | 58 | } |
59 | - } |
|
59 | + } |
|
60 | 60 | ?> |
61 | 61 | <div id="dialog" title="<?php echo _("Session has timed-out"); ?>"> |
62 | 62 | <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p> |
@@ -70,34 +70,34 @@ discard block |
||
70 | 70 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
71 | 71 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
72 | 72 | <?php |
73 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
73 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
74 | 74 | if (isset($globalArchive) && $globalArchive == TRUE) { |
75 | 75 | ?> |
76 | 76 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
77 | 77 | <?php |
78 | 78 | } |
79 | - } |
|
79 | + } |
|
80 | 80 | ?> |
81 | 81 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
82 | 82 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
83 | 83 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
84 | 84 | <?php |
85 | - if (isset($globalMap3D) && $globalMap3D) { |
|
85 | + if (isset($globalMap3D) && $globalMap3D) { |
|
86 | 86 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
87 | 87 | ?> |
88 | 88 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
89 | 89 | <?php |
90 | - } else { |
|
91 | - if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
90 | + } else { |
|
91 | + if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
92 | 92 | ?> |
93 | 93 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
94 | 94 | <?php |
95 | - } |
|
95 | + } |
|
96 | 96 | ?> |
97 | 97 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
98 | 98 | <?php |
99 | 99 | } |
100 | - } |
|
100 | + } |
|
101 | 101 | ?> |
102 | 102 | </ul> |
103 | 103 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | ?> |
172 | 172 | </div> |
173 | 173 | <?php |
174 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
174 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
175 | 175 | ?> |
176 | 176 | <div class="sidebar-pane" id="archive"> |
177 | 177 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | </form> |
232 | 232 | </div> |
233 | 233 | <?php |
234 | - } |
|
234 | + } |
|
235 | 235 | ?> |
236 | 236 | <div class="sidebar-pane" id="settings"> |
237 | 237 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -242,56 +242,56 @@ discard block |
||
242 | 242 | <?php |
243 | 243 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
244 | 244 | else $MapType = $_COOKIE['MapType']; |
245 | - ?> |
|
245 | + ?> |
|
246 | 246 | <?php |
247 | 247 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
248 | - ?> |
|
248 | + ?> |
|
249 | 249 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
250 | 250 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
251 | 251 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
252 | 252 | <?php |
253 | 253 | } |
254 | - ?> |
|
254 | + ?> |
|
255 | 255 | <?php |
256 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
257 | - ?> |
|
256 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
257 | + ?> |
|
258 | 258 | <?php |
259 | - if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
260 | - ?> |
|
259 | + if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
260 | + ?> |
|
261 | 261 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
262 | 262 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
263 | 263 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
264 | 264 | <?php |
265 | - } |
|
266 | - ?> |
|
265 | + } |
|
266 | + ?> |
|
267 | 267 | <?php |
268 | - if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
269 | - ?> |
|
268 | + if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
269 | + ?> |
|
270 | 270 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
271 | 271 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
272 | 272 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
273 | 273 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
274 | 274 | <?php |
275 | - } |
|
276 | - ?> |
|
275 | + } |
|
276 | + ?> |
|
277 | 277 | <?php |
278 | - if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
279 | - ?> |
|
278 | + if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
279 | + ?> |
|
280 | 280 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
281 | 281 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
282 | 282 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
283 | 283 | <?php |
284 | - } |
|
285 | - ?> |
|
284 | + } |
|
285 | + ?> |
|
286 | 286 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
287 | 287 | <?php |
288 | 288 | } |
289 | - ?> |
|
289 | + ?> |
|
290 | 290 | <?php |
291 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
291 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
292 | 292 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
293 | 293 | else $MapBoxId = $_COOKIE['MapTypeId']; |
294 | - ?> |
|
294 | + ?> |
|
295 | 295 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
296 | 296 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
297 | 297 | <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
306 | 306 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
307 | 307 | <?php |
308 | - } |
|
309 | - ?> |
|
308 | + } |
|
309 | + ?> |
|
310 | 310 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
311 | 311 | </select> |
312 | 312 | </li> |
313 | 313 | <?php |
314 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
314 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
315 | 315 | ?> |
316 | 316 | <li><?php echo _("Type of Terrain:"); ?> |
317 | 317 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | </select> |
322 | 322 | </li> |
323 | 323 | <?php |
324 | - } |
|
324 | + } |
|
325 | 325 | ?> |
326 | 326 | <?php |
327 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
327 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
328 | 328 | ?> |
329 | 329 | |
330 | 330 | <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
@@ -332,59 +332,59 @@ discard block |
||
332 | 332 | <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
333 | 333 | <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
334 | 334 | <?php |
335 | - } |
|
335 | + } |
|
336 | 336 | ?> |
337 | 337 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
338 | 338 | <?php |
339 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
339 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
340 | 340 | ?> |
341 | 341 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
342 | 342 | <?php |
343 | - } |
|
344 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
343 | + } |
|
344 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
345 | 345 | ?> |
346 | 346 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
347 | 347 | <?php |
348 | - } |
|
348 | + } |
|
349 | 349 | ?> |
350 | 350 | |
351 | 351 | <?php |
352 | 352 | if (function_exists('array_column')) { |
353 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
354 | - ?> |
|
353 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
354 | + ?> |
|
355 | 355 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
356 | 356 | <?php |
357 | - } |
|
357 | + } |
|
358 | 358 | } elseif (isset($globalSources)) { |
359 | - $dispolar = false; |
|
360 | - foreach ($globalSources as $testsource) { |
|
361 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
362 | - } |
|
363 | - if ($dispolar) { |
|
364 | - ?> |
|
359 | + $dispolar = false; |
|
360 | + foreach ($globalSources as $testsource) { |
|
361 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
362 | + } |
|
363 | + if ($dispolar) { |
|
364 | + ?> |
|
365 | 365 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
366 | 366 | <?php |
367 | - } |
|
368 | - } |
|
369 | - ?> |
|
367 | + } |
|
368 | + } |
|
369 | + ?> |
|
370 | 370 | <?php |
371 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
371 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
372 | 372 | ?> |
373 | 373 | |
374 | 374 | <?php |
375 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
376 | - ?> |
|
375 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
376 | + ?> |
|
377 | 377 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
378 | 378 | <?php |
379 | 379 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
380 | - ?> |
|
380 | + ?> |
|
381 | 381 | <li><?php echo _("Aircraft icon color:"); ?> |
382 | 382 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
383 | 383 | </li> |
384 | 384 | <?php |
385 | - } |
|
386 | - } |
|
387 | - ?> |
|
385 | + } |
|
386 | + } |
|
387 | + ?> |
|
388 | 388 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
389 | 389 | <div class="range"> |
390 | 390 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | </div> |
393 | 393 | </li> |
394 | 394 | <?php |
395 | - } |
|
395 | + } |
|
396 | 396 | ?> |
397 | 397 | <li><?php echo _("Distance unit:"); ?> |
398 | 398 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -425,16 +425,16 @@ discard block |
||
425 | 425 | <ul> |
426 | 426 | <?php |
427 | 427 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
428 | - ?> |
|
428 | + ?> |
|
429 | 429 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
430 | 430 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
431 | 431 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
432 | 432 | <?php |
433 | 433 | } |
434 | - ?> |
|
434 | + ?> |
|
435 | 435 | <?php |
436 | 436 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
437 | - ?> |
|
437 | + ?> |
|
438 | 438 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
439 | 439 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
440 | 440 | <?php } ?> |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | <?php } ?> |
444 | 444 | <?php |
445 | 445 | } |
446 | - ?> |
|
446 | + ?> |
|
447 | 447 | <li><?php echo _("Display airlines:"); ?> |
448 | 448 | <br/> |
449 | 449 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -463,14 +463,14 @@ discard block |
||
463 | 463 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
464 | 464 | } |
465 | 465 | } |
466 | - ?> |
|
466 | + ?> |
|
467 | 467 | </select> |
468 | 468 | </li> |
469 | 469 | <?php |
470 | 470 | $Spotter = new Spotter(); |
471 | 471 | $allalliancenames = $Spotter->getAllAllianceNames(); |
472 | 472 | if (!empty($allalliancenames)) { |
473 | - ?> |
|
473 | + ?> |
|
474 | 474 | <li><?php echo _("Display alliance:"); ?> |
475 | 475 | <br/> |
476 | 476 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -484,15 +484,15 @@ discard block |
||
484 | 484 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
485 | 485 | } |
486 | 486 | } |
487 | - ?> |
|
487 | + ?> |
|
488 | 488 | </select> |
489 | 489 | </li> |
490 | 490 | <?php |
491 | 491 | } |
492 | - ?> |
|
492 | + ?> |
|
493 | 493 | <?php |
494 | 494 | if (isset($globalAPRS) && $globalAPRS) { |
495 | - ?> |
|
495 | + ?> |
|
496 | 496 | <li><?php echo _("Display APRS sources name:"); ?> |
497 | 497 | <select class="selectpicker" multiple onchange="sources(this);"> |
498 | 498 | <?php |
@@ -504,15 +504,15 @@ discard block |
||
504 | 504 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
505 | 505 | } |
506 | 506 | } |
507 | - ?> |
|
507 | + ?> |
|
508 | 508 | </select> |
509 | 509 | </li> |
510 | 510 | <?php |
511 | 511 | } |
512 | - ?> |
|
512 | + ?> |
|
513 | 513 | <?php |
514 | 514 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
515 | - ?> |
|
515 | + ?> |
|
516 | 516 | <li><?php echo _("Display airlines of type:"); ?><br/> |
517 | 517 | <select class="selectpicker" onchange="airlinestype(this);"> |
518 | 518 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | </li> |
524 | 524 | <?php |
525 | 525 | } |
526 | - ?> |
|
526 | + ?> |
|
527 | 527 | <li> |
528 | 528 | <?php echo _("Display flight with ident:"); ?> |
529 | 529 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | </form> |
537 | 537 | </div> |
538 | 538 | <?php |
539 | - if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
539 | + if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
540 | 540 | ?> |
541 | 541 | <div class="sidebar-pane" id="satellites"> |
542 | 542 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -576,14 +576,14 @@ discard block |
||
576 | 576 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
577 | 577 | } |
578 | 578 | } |
579 | - ?> |
|
579 | + ?> |
|
580 | 580 | </select> |
581 | 581 | </li> |
582 | 582 | </ul> |
583 | 583 | </form> |
584 | 584 | </div> |
585 | 585 | <?php |
586 | - } |
|
586 | + } |
|
587 | 587 | ?> |
588 | 588 | </div> |
589 | 589 | </div> |
@@ -4,31 +4,31 @@ discard block |
||
4 | 4 | $hex = str_replace("#", "", $hex); |
5 | 5 | $color = array(); |
6 | 6 | if (strlen($hex) == 3) { |
7 | - $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1)); |
|
8 | - $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1)); |
|
9 | - $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1)); |
|
7 | + $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1)); |
|
8 | + $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1)); |
|
9 | + $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1)); |
|
10 | 10 | } else if (strlen($hex) == 6) { |
11 | - $color['r'] = hexdec(substr($hex, 0, 2)); |
|
12 | - $color['g'] = hexdec(substr($hex, 2, 2)); |
|
13 | - $color['b'] = hexdec(substr($hex, 4, 2)); |
|
11 | + $color['r'] = hexdec(substr($hex, 0, 2)); |
|
12 | + $color['g'] = hexdec(substr($hex, 2, 2)); |
|
13 | + $color['b'] = hexdec(substr($hex, 4, 2)); |
|
14 | 14 | } |
15 | 15 | return $color; |
16 | 16 | } |
17 | 17 | |
18 | 18 | |
19 | 19 | if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/',$_GET['color'])) { |
20 | - exit(0); |
|
20 | + exit(0); |
|
21 | 21 | } |
22 | 22 | $color = $_GET['color']; |
23 | 23 | if (!isset($_GET['filename']) || !preg_match('/^[a-z0-9-_]+\.png$/', strtolower($_GET['filename']))) { |
24 | - echo "Incorrect filename"; |
|
25 | - exit(0); |
|
24 | + echo "Incorrect filename"; |
|
25 | + exit(0); |
|
26 | 26 | } |
27 | 27 | $filename = $_GET['filename']; |
28 | 28 | if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename)) { |
29 | - header('Content-type: image/png'); |
|
30 | - readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename); |
|
31 | - exit(0); |
|
29 | + header('Content-type: image/png'); |
|
30 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename); |
|
31 | + exit(0); |
|
32 | 32 | } |
33 | 33 | if (isset($_GET['tracker'])) { |
34 | 34 | $original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'vehicules'.DIRECTORY_SEPARATOR.$filename; |
@@ -38,66 +38,66 @@ discard block |
||
38 | 38 | $original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'aircrafts'.DIRECTORY_SEPARATOR.'new'.DIRECTORY_SEPARATOR.$filename; |
39 | 39 | } |
40 | 40 | if (!file_exists($original)) { |
41 | - echo "File not found"; |
|
41 | + echo "File not found"; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | if (extension_loaded('gd') && function_exists('gd_info')) { |
45 | - $image = imagecreatefrompng($original); |
|
46 | - $index = imagecolorexact($image,26,49,81); |
|
47 | - if ($index < 0) { |
|
45 | + $image = imagecreatefrompng($original); |
|
46 | + $index = imagecolorexact($image,26,49,81); |
|
47 | + if ($index < 0) { |
|
48 | 48 | $index = imagecolorexact($image,25,49,79); |
49 | - } |
|
50 | - if ($index < 0) { |
|
49 | + } |
|
50 | + if ($index < 0) { |
|
51 | 51 | $index = imagecolorexact($image,0,0,0); |
52 | - } |
|
53 | - $c = hexToRGB($color); |
|
54 | - imagecolorset($image,$index,$c['r'],$c['g'],$c['b']); |
|
52 | + } |
|
53 | + $c = hexToRGB($color); |
|
54 | + imagecolorset($image,$index,$c['r'],$c['g'],$c['b']); |
|
55 | 55 | /* |
56 | 56 | $ig = imagecolorat($image, 0, 0); |
57 | 57 | imagecolortransparent($image, $ig); |
58 | 58 | */ |
59 | 59 | |
60 | - header('Content-type: image/png'); |
|
61 | - if (isset($_GET['resize']) && function_exists('imagecopyresampled')) { |
|
60 | + header('Content-type: image/png'); |
|
61 | + if (isset($_GET['resize']) && function_exists('imagecopyresampled')) { |
|
62 | 62 | $resize = filter_input(INPUT_GET,'resize',FILTER_SANITIZE_NUMBER_INT); |
63 | 63 | $newimg = imagecreatetruecolor($resize,$resize); |
64 | - imagealphablending($newimg, false); |
|
64 | + imagealphablending($newimg, false); |
|
65 | 65 | imagesavealpha($newimg, true); |
66 | 66 | imagecopyresampled($newimg,$image,0,0,0,0,15,15,imagesx($image),imagesy($image)); |
67 | 67 | if (isset($_GET['heading'])) { |
68 | - $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT); |
|
69 | - $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127)); |
|
70 | - imagealphablending($rotation, false); |
|
71 | - imagesavealpha($rotation, true); |
|
72 | - imagepng($rotation); |
|
73 | - imagedestroy($newimg); |
|
74 | - imagedestroy($image); |
|
75 | - imagedestroy($rotation); |
|
68 | + $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT); |
|
69 | + $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127)); |
|
70 | + imagealphablending($rotation, false); |
|
71 | + imagesavealpha($rotation, true); |
|
72 | + imagepng($rotation); |
|
73 | + imagedestroy($newimg); |
|
74 | + imagedestroy($image); |
|
75 | + imagedestroy($rotation); |
|
76 | 76 | |
77 | 77 | } else { |
78 | - imagepng($newimg); |
|
79 | - imagedestroy($newimg); |
|
80 | - imagedestroy($image); |
|
81 | - } |
|
82 | - } else { |
|
78 | + imagepng($newimg); |
|
79 | + imagedestroy($newimg); |
|
80 | + imagedestroy($image); |
|
81 | + } |
|
82 | + } else { |
|
83 | 83 | imagealphablending($image, false); |
84 | - imagesavealpha($image, true); |
|
84 | + imagesavealpha($image, true); |
|
85 | 85 | imagepng($image); |
86 | 86 | imagepng($image); |
87 | 87 | if (is_writable('cache')) { |
88 | - imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename); |
|
88 | + imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename); |
|
89 | + } |
|
90 | + imagedestroy($image); |
|
89 | 91 | } |
90 | - imagedestroy($image); |
|
91 | - } |
|
92 | 92 | } else { |
93 | - header('Content-type: image/png'); |
|
94 | - if (isset($_GET['tracker'])) { |
|
95 | - readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
96 | - } elseif (isset($_GET['marine'])) { |
|
97 | - readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
98 | - } else { |
|
99 | - if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename); |
|
93 | + header('Content-type: image/png'); |
|
94 | + if (isset($_GET['tracker'])) { |
|
95 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
96 | + } elseif (isset($_GET['marine'])) { |
|
97 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
98 | + } else { |
|
99 | + if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename); |
|
100 | 100 | else readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/'.$filename); |
101 | - } |
|
101 | + } |
|
102 | 102 | } |
103 | 103 | ?> |
104 | 104 | \ No newline at end of file |
@@ -4,23 +4,23 @@ discard block |
||
4 | 4 | $tracker = false; |
5 | 5 | $marine = false; |
6 | 6 | if (isset($_GET['tracker'])) { |
7 | - $tracker = true; |
|
7 | + $tracker = true; |
|
8 | 8 | } |
9 | 9 | if (isset($_GET['marine'])) { |
10 | - $marine = true; |
|
10 | + $marine = true; |
|
11 | 11 | } |
12 | 12 | if ($tracker) { |
13 | - require_once('require/class.Tracker.php'); |
|
14 | - require_once('require/class.TrackerLive.php'); |
|
15 | - //require_once('require/class.TrackerArchive.php'); |
|
13 | + require_once('require/class.Tracker.php'); |
|
14 | + require_once('require/class.TrackerLive.php'); |
|
15 | + //require_once('require/class.TrackerArchive.php'); |
|
16 | 16 | } elseif ($marine) { |
17 | - require_once('require/class.Marine.php'); |
|
18 | - require_once('require/class.MarineLive.php'); |
|
19 | - //require_once('require/class.MarineArchive.php'); |
|
17 | + require_once('require/class.Marine.php'); |
|
18 | + require_once('require/class.MarineLive.php'); |
|
19 | + //require_once('require/class.MarineArchive.php'); |
|
20 | 20 | } else { |
21 | - require_once('require/class.Spotter.php'); |
|
22 | - require_once('require/class.SpotterLive.php'); |
|
23 | - require_once('require/class.SpotterArchive.php'); |
|
21 | + require_once('require/class.Spotter.php'); |
|
22 | + require_once('require/class.SpotterLive.php'); |
|
23 | + require_once('require/class.SpotterArchive.php'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | $begintime = microtime(true); |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | $Common = new Common(); |
41 | 41 | |
42 | 42 | if (isset($_GET['download'])) { |
43 | - if ($_GET['download'] == "true") |
|
44 | - { |
|
43 | + if ($_GET['download'] == "true") |
|
44 | + { |
|
45 | 45 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
46 | - } |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | header('Content-Type: text/javascript'); |
49 | 49 | |
@@ -488,8 +488,8 @@ discard block |
||
488 | 488 | |
489 | 489 | if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
490 | 490 | || (!isset($_COOKIE['flightpath']) |
491 | - && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) |
|
492 | - || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) |
|
491 | + && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) |
|
492 | + || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) |
|
493 | 493 | || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) { |
494 | 494 | if ($tracker) { |
495 | 495 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']); |
@@ -502,19 +502,19 @@ discard block |
||
502 | 502 | $spotter_history_array = $SpotterLive->getAllLiveSpotterDataById($spotter_item['flightaware_id']); |
503 | 503 | } |
504 | 504 | } |
505 | - $d = false; |
|
505 | + $d = false; |
|
506 | 506 | foreach ($spotter_history_array as $key => $spotter_history) |
507 | 507 | { |
508 | 508 | if (isset($spotter_history['altitude'])) { |
509 | 509 | $alt = round($spotter_history['altitude']/10)*10; |
510 | 510 | if (!isset($prev_alt) || $prev_alt != $alt) { |
511 | - if (isset($prev_alt)) { |
|
511 | + if (isset($prev_alt)) { |
|
512 | 512 | $output_history .= '['.$spotter_history['longitude'].', '.$spotter_history['latitude'].', '.$spotter_history['altitude'].']'; |
513 | 513 | $output_history .= ']}},'; |
514 | 514 | $output .= $output_history; |
515 | - } |
|
516 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
517 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
515 | + } |
|
516 | + if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
517 | + else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
518 | 518 | } |
519 | 519 | $output_history .= '['; |
520 | 520 | $output_history .= $spotter_history['longitude'].', '; |
@@ -532,38 +532,38 @@ discard block |
||
532 | 532 | $output_history .= $spotter_history['latitude']; |
533 | 533 | $output_history .= '],'; |
534 | 534 | } |
535 | - //} |
|
535 | + //} |
|
536 | 536 | } |
537 | 537 | if (isset($output_history)) { |
538 | - $output_history = substr($output_history, 0, -1); |
|
539 | - $output_history .= ']}},'; |
|
540 | - $output .= $output_history; |
|
541 | - unset($prev_alt); |
|
542 | - unset($output_history); |
|
538 | + $output_history = substr($output_history, 0, -1); |
|
539 | + $output_history .= ']}},'; |
|
540 | + $output .= $output_history; |
|
541 | + unset($prev_alt); |
|
542 | + unset($output_history); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | |
546 | 546 | if (isset($history) && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
547 | - $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
548 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
547 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
548 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
549 | 549 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
550 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
550 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
551 | 551 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
552 | 552 | if (isset($dairport[0]['latitude'])) { |
553 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
553 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
554 | 554 | } |
555 | - } |
|
556 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
555 | + } |
|
556 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
557 | 557 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
558 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
558 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
559 | 559 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
560 | 560 | if (isset($aairport[0]['latitude'])) { |
561 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
561 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
562 | 562 | } |
563 | - } |
|
564 | - $output_air .= ']}},'; |
|
565 | - $output .= $output_air; |
|
566 | - unset($output_air); |
|
563 | + } |
|
564 | + $output_air .= ']}},'; |
|
565 | + $output .= $output_air; |
|
566 | + unset($output_air); |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | $output = substr($output, 0, -1); |
@@ -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); |
|
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 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
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); |
|
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 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
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); |
@@ -1641,173 +1641,173 @@ discard block |
||
1641 | 1641 | } |
1642 | 1642 | |
1643 | 1643 | |
1644 | - public static function check_version($update = false) { |
|
1645 | - global $globalDBname; |
|
1646 | - $version = 0; |
|
1647 | - $Connection = new Connection(); |
|
1648 | - if ($Connection->tableExists('aircraft')) { |
|
1649 | - if (!$Connection->tableExists('config')) { |
|
1650 | - $version = '1'; |
|
1651 | - if ($update) return self::update_from_1(); |
|
1652 | - else return $version; |
|
1644 | + public static function check_version($update = false) { |
|
1645 | + global $globalDBname; |
|
1646 | + $version = 0; |
|
1647 | + $Connection = new Connection(); |
|
1648 | + if ($Connection->tableExists('aircraft')) { |
|
1649 | + if (!$Connection->tableExists('config')) { |
|
1650 | + $version = '1'; |
|
1651 | + if ($update) return self::update_from_1(); |
|
1652 | + else return $version; |
|
1653 | 1653 | } else { |
1654 | - $Connection = new Connection(); |
|
1655 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1656 | - try { |
|
1657 | - $sth = $Connection->db->prepare($query); |
|
1658 | - $sth->execute(); |
|
1659 | - } catch(PDOException $e) { |
|
1654 | + $Connection = new Connection(); |
|
1655 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1656 | + try { |
|
1657 | + $sth = $Connection->db->prepare($query); |
|
1658 | + $sth->execute(); |
|
1659 | + } catch(PDOException $e) { |
|
1660 | 1660 | return "error : ".$e->getMessage()."\n"; |
1661 | - } |
|
1662 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1663 | - if ($update) { |
|
1664 | - if ($result['value'] == '2') { |
|
1665 | - $error = self::update_from_2(); |
|
1666 | - if ($error != '') return $error; |
|
1667 | - else return self::check_version(true); |
|
1668 | - } elseif ($result['value'] == '3') { |
|
1669 | - $error = self::update_from_3(); |
|
1670 | - if ($error != '') return $error; |
|
1671 | - else return self::check_version(true); |
|
1672 | - } elseif ($result['value'] == '4') { |
|
1673 | - $error = self::update_from_4(); |
|
1674 | - if ($error != '') return $error; |
|
1675 | - else return self::check_version(true); |
|
1676 | - } elseif ($result['value'] == '5') { |
|
1677 | - $error = self::update_from_5(); |
|
1678 | - if ($error != '') return $error; |
|
1679 | - else return self::check_version(true); |
|
1680 | - } elseif ($result['value'] == '6') { |
|
1681 | - $error = self::update_from_6(); |
|
1682 | - if ($error != '') return $error; |
|
1683 | - else return self::check_version(true); |
|
1684 | - } elseif ($result['value'] == '7') { |
|
1685 | - $error = self::update_from_7(); |
|
1686 | - if ($error != '') return $error; |
|
1687 | - else return self::check_version(true); |
|
1688 | - } elseif ($result['value'] == '8') { |
|
1689 | - $error = self::update_from_8(); |
|
1690 | - if ($error != '') return $error; |
|
1691 | - else return self::check_version(true); |
|
1692 | - } elseif ($result['value'] == '9') { |
|
1693 | - $error = self::update_from_9(); |
|
1694 | - if ($error != '') return $error; |
|
1695 | - else return self::check_version(true); |
|
1696 | - } elseif ($result['value'] == '10') { |
|
1697 | - $error = self::update_from_10(); |
|
1698 | - if ($error != '') return $error; |
|
1699 | - else return self::check_version(true); |
|
1700 | - } elseif ($result['value'] == '11') { |
|
1701 | - $error = self::update_from_11(); |
|
1702 | - if ($error != '') return $error; |
|
1703 | - else return self::check_version(true); |
|
1704 | - } elseif ($result['value'] == '12') { |
|
1705 | - $error = self::update_from_12(); |
|
1706 | - if ($error != '') return $error; |
|
1707 | - else return self::check_version(true); |
|
1708 | - } elseif ($result['value'] == '13') { |
|
1709 | - $error = self::update_from_13(); |
|
1710 | - if ($error != '') return $error; |
|
1711 | - else return self::check_version(true); |
|
1712 | - } elseif ($result['value'] == '14') { |
|
1713 | - $error = self::update_from_14(); |
|
1714 | - if ($error != '') return $error; |
|
1715 | - else return self::check_version(true); |
|
1716 | - } elseif ($result['value'] == '15') { |
|
1717 | - $error = self::update_from_15(); |
|
1718 | - if ($error != '') return $error; |
|
1719 | - else return self::check_version(true); |
|
1720 | - } elseif ($result['value'] == '16') { |
|
1721 | - $error = self::update_from_16(); |
|
1722 | - if ($error != '') return $error; |
|
1723 | - else return self::check_version(true); |
|
1724 | - } elseif ($result['value'] == '17') { |
|
1725 | - $error = self::update_from_17(); |
|
1726 | - if ($error != '') return $error; |
|
1727 | - else return self::check_version(true); |
|
1728 | - } elseif ($result['value'] == '18') { |
|
1729 | - $error = self::update_from_18(); |
|
1730 | - if ($error != '') return $error; |
|
1731 | - else return self::check_version(true); |
|
1732 | - } elseif ($result['value'] == '19') { |
|
1733 | - $error = self::update_from_19(); |
|
1734 | - if ($error != '') return $error; |
|
1735 | - else return self::check_version(true); |
|
1736 | - } elseif ($result['value'] == '20') { |
|
1737 | - $error = self::update_from_20(); |
|
1738 | - if ($error != '') return $error; |
|
1739 | - else return self::check_version(true); |
|
1740 | - } elseif ($result['value'] == '21') { |
|
1741 | - $error = self::update_from_21(); |
|
1742 | - if ($error != '') return $error; |
|
1743 | - else return self::check_version(true); |
|
1744 | - } elseif ($result['value'] == '22') { |
|
1745 | - $error = self::update_from_22(); |
|
1746 | - if ($error != '') return $error; |
|
1747 | - else return self::check_version(true); |
|
1748 | - } elseif ($result['value'] == '23') { |
|
1749 | - $error = self::update_from_23(); |
|
1750 | - if ($error != '') return $error; |
|
1751 | - else return self::check_version(true); |
|
1752 | - } elseif ($result['value'] == '24') { |
|
1753 | - $error = self::update_from_24(); |
|
1754 | - if ($error != '') return $error; |
|
1755 | - else return self::check_version(true); |
|
1756 | - } elseif ($result['value'] == '25') { |
|
1757 | - $error = self::update_from_25(); |
|
1758 | - if ($error != '') return $error; |
|
1759 | - else return self::check_version(true); |
|
1760 | - } elseif ($result['value'] == '26') { |
|
1761 | - $error = self::update_from_26(); |
|
1762 | - if ($error != '') return $error; |
|
1763 | - else return self::check_version(true); |
|
1764 | - } elseif ($result['value'] == '27') { |
|
1765 | - $error = self::update_from_27(); |
|
1766 | - if ($error != '') return $error; |
|
1767 | - else return self::check_version(true); |
|
1768 | - } elseif ($result['value'] == '28') { |
|
1769 | - $error = self::update_from_28(); |
|
1770 | - if ($error != '') return $error; |
|
1771 | - else return self::check_version(true); |
|
1772 | - } elseif ($result['value'] == '29') { |
|
1773 | - $error = self::update_from_29(); |
|
1774 | - if ($error != '') return $error; |
|
1775 | - else return self::check_version(true); |
|
1776 | - } elseif ($result['value'] == '30') { |
|
1777 | - $error = self::update_from_30(); |
|
1778 | - if ($error != '') return $error; |
|
1779 | - else return self::check_version(true); |
|
1780 | - } elseif ($result['value'] == '31') { |
|
1781 | - $error = self::update_from_31(); |
|
1782 | - if ($error != '') return $error; |
|
1783 | - else return self::check_version(true); |
|
1784 | - } elseif ($result['value'] == '32') { |
|
1785 | - $error = self::update_from_32(); |
|
1786 | - if ($error != '') return $error; |
|
1787 | - else return self::check_version(true); |
|
1788 | - } elseif ($result['value'] == '33') { |
|
1789 | - $error = self::update_from_33(); |
|
1790 | - if ($error != '') return $error; |
|
1791 | - else return self::check_version(true); |
|
1792 | - } elseif ($result['value'] == '34') { |
|
1793 | - $error = self::update_from_34(); |
|
1794 | - if ($error != '') return $error; |
|
1795 | - else return self::check_version(true); |
|
1796 | - } elseif ($result['value'] == '35') { |
|
1797 | - $error = self::update_from_35(); |
|
1798 | - if ($error != '') return $error; |
|
1799 | - else return self::check_version(true); |
|
1800 | - } elseif ($result['value'] == '36') { |
|
1801 | - $error = self::update_from_36(); |
|
1802 | - if ($error != '') return $error; |
|
1803 | - else return self::check_version(true); |
|
1804 | - } else return ''; |
|
1805 | - } |
|
1806 | - else return $result['value']; |
|
1661 | + } |
|
1662 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1663 | + if ($update) { |
|
1664 | + if ($result['value'] == '2') { |
|
1665 | + $error = self::update_from_2(); |
|
1666 | + if ($error != '') return $error; |
|
1667 | + else return self::check_version(true); |
|
1668 | + } elseif ($result['value'] == '3') { |
|
1669 | + $error = self::update_from_3(); |
|
1670 | + if ($error != '') return $error; |
|
1671 | + else return self::check_version(true); |
|
1672 | + } elseif ($result['value'] == '4') { |
|
1673 | + $error = self::update_from_4(); |
|
1674 | + if ($error != '') return $error; |
|
1675 | + else return self::check_version(true); |
|
1676 | + } elseif ($result['value'] == '5') { |
|
1677 | + $error = self::update_from_5(); |
|
1678 | + if ($error != '') return $error; |
|
1679 | + else return self::check_version(true); |
|
1680 | + } elseif ($result['value'] == '6') { |
|
1681 | + $error = self::update_from_6(); |
|
1682 | + if ($error != '') return $error; |
|
1683 | + else return self::check_version(true); |
|
1684 | + } elseif ($result['value'] == '7') { |
|
1685 | + $error = self::update_from_7(); |
|
1686 | + if ($error != '') return $error; |
|
1687 | + else return self::check_version(true); |
|
1688 | + } elseif ($result['value'] == '8') { |
|
1689 | + $error = self::update_from_8(); |
|
1690 | + if ($error != '') return $error; |
|
1691 | + else return self::check_version(true); |
|
1692 | + } elseif ($result['value'] == '9') { |
|
1693 | + $error = self::update_from_9(); |
|
1694 | + if ($error != '') return $error; |
|
1695 | + else return self::check_version(true); |
|
1696 | + } elseif ($result['value'] == '10') { |
|
1697 | + $error = self::update_from_10(); |
|
1698 | + if ($error != '') return $error; |
|
1699 | + else return self::check_version(true); |
|
1700 | + } elseif ($result['value'] == '11') { |
|
1701 | + $error = self::update_from_11(); |
|
1702 | + if ($error != '') return $error; |
|
1703 | + else return self::check_version(true); |
|
1704 | + } elseif ($result['value'] == '12') { |
|
1705 | + $error = self::update_from_12(); |
|
1706 | + if ($error != '') return $error; |
|
1707 | + else return self::check_version(true); |
|
1708 | + } elseif ($result['value'] == '13') { |
|
1709 | + $error = self::update_from_13(); |
|
1710 | + if ($error != '') return $error; |
|
1711 | + else return self::check_version(true); |
|
1712 | + } elseif ($result['value'] == '14') { |
|
1713 | + $error = self::update_from_14(); |
|
1714 | + if ($error != '') return $error; |
|
1715 | + else return self::check_version(true); |
|
1716 | + } elseif ($result['value'] == '15') { |
|
1717 | + $error = self::update_from_15(); |
|
1718 | + if ($error != '') return $error; |
|
1719 | + else return self::check_version(true); |
|
1720 | + } elseif ($result['value'] == '16') { |
|
1721 | + $error = self::update_from_16(); |
|
1722 | + if ($error != '') return $error; |
|
1723 | + else return self::check_version(true); |
|
1724 | + } elseif ($result['value'] == '17') { |
|
1725 | + $error = self::update_from_17(); |
|
1726 | + if ($error != '') return $error; |
|
1727 | + else return self::check_version(true); |
|
1728 | + } elseif ($result['value'] == '18') { |
|
1729 | + $error = self::update_from_18(); |
|
1730 | + if ($error != '') return $error; |
|
1731 | + else return self::check_version(true); |
|
1732 | + } elseif ($result['value'] == '19') { |
|
1733 | + $error = self::update_from_19(); |
|
1734 | + if ($error != '') return $error; |
|
1735 | + else return self::check_version(true); |
|
1736 | + } elseif ($result['value'] == '20') { |
|
1737 | + $error = self::update_from_20(); |
|
1738 | + if ($error != '') return $error; |
|
1739 | + else return self::check_version(true); |
|
1740 | + } elseif ($result['value'] == '21') { |
|
1741 | + $error = self::update_from_21(); |
|
1742 | + if ($error != '') return $error; |
|
1743 | + else return self::check_version(true); |
|
1744 | + } elseif ($result['value'] == '22') { |
|
1745 | + $error = self::update_from_22(); |
|
1746 | + if ($error != '') return $error; |
|
1747 | + else return self::check_version(true); |
|
1748 | + } elseif ($result['value'] == '23') { |
|
1749 | + $error = self::update_from_23(); |
|
1750 | + if ($error != '') return $error; |
|
1751 | + else return self::check_version(true); |
|
1752 | + } elseif ($result['value'] == '24') { |
|
1753 | + $error = self::update_from_24(); |
|
1754 | + if ($error != '') return $error; |
|
1755 | + else return self::check_version(true); |
|
1756 | + } elseif ($result['value'] == '25') { |
|
1757 | + $error = self::update_from_25(); |
|
1758 | + if ($error != '') return $error; |
|
1759 | + else return self::check_version(true); |
|
1760 | + } elseif ($result['value'] == '26') { |
|
1761 | + $error = self::update_from_26(); |
|
1762 | + if ($error != '') return $error; |
|
1763 | + else return self::check_version(true); |
|
1764 | + } elseif ($result['value'] == '27') { |
|
1765 | + $error = self::update_from_27(); |
|
1766 | + if ($error != '') return $error; |
|
1767 | + else return self::check_version(true); |
|
1768 | + } elseif ($result['value'] == '28') { |
|
1769 | + $error = self::update_from_28(); |
|
1770 | + if ($error != '') return $error; |
|
1771 | + else return self::check_version(true); |
|
1772 | + } elseif ($result['value'] == '29') { |
|
1773 | + $error = self::update_from_29(); |
|
1774 | + if ($error != '') return $error; |
|
1775 | + else return self::check_version(true); |
|
1776 | + } elseif ($result['value'] == '30') { |
|
1777 | + $error = self::update_from_30(); |
|
1778 | + if ($error != '') return $error; |
|
1779 | + else return self::check_version(true); |
|
1780 | + } elseif ($result['value'] == '31') { |
|
1781 | + $error = self::update_from_31(); |
|
1782 | + if ($error != '') return $error; |
|
1783 | + else return self::check_version(true); |
|
1784 | + } elseif ($result['value'] == '32') { |
|
1785 | + $error = self::update_from_32(); |
|
1786 | + if ($error != '') return $error; |
|
1787 | + else return self::check_version(true); |
|
1788 | + } elseif ($result['value'] == '33') { |
|
1789 | + $error = self::update_from_33(); |
|
1790 | + if ($error != '') return $error; |
|
1791 | + else return self::check_version(true); |
|
1792 | + } elseif ($result['value'] == '34') { |
|
1793 | + $error = self::update_from_34(); |
|
1794 | + if ($error != '') return $error; |
|
1795 | + else return self::check_version(true); |
|
1796 | + } elseif ($result['value'] == '35') { |
|
1797 | + $error = self::update_from_35(); |
|
1798 | + if ($error != '') return $error; |
|
1799 | + else return self::check_version(true); |
|
1800 | + } elseif ($result['value'] == '36') { |
|
1801 | + $error = self::update_from_36(); |
|
1802 | + if ($error != '') return $error; |
|
1803 | + else return self::check_version(true); |
|
1804 | + } else return ''; |
|
1805 | + } |
|
1806 | + else return $result['value']; |
|
1807 | 1807 | } |
1808 | 1808 | |
1809 | - } else return $version; |
|
1810 | - } |
|
1809 | + } else return $version; |
|
1810 | + } |
|
1811 | 1811 | |
1812 | 1812 | } |
1813 | 1813 | //echo update_schema::check_version(); |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | public function getFilter($filter = array(),$where = false,$and = false) { |
22 | 22 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | - * Executes the SQL statements to get the spotter information |
|
84 | - * |
|
85 | - * @param String $query the SQL query |
|
86 | - * @param Array $params parameter of the query |
|
87 | - * @param String $limitQuery the limit query |
|
88 | - * @return Array the spotter information |
|
89 | - * |
|
90 | - */ |
|
83 | + * Executes the SQL statements to get the spotter information |
|
84 | + * |
|
85 | + * @param String $query the SQL query |
|
86 | + * @param Array $params parameter of the query |
|
87 | + * @param String $limitQuery the limit query |
|
88 | + * @return Array the spotter information |
|
89 | + * |
|
90 | + */ |
|
91 | 91 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
92 | 92 | { |
93 | 93 | date_default_timezone_set('UTC'); |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | |
201 | 201 | |
202 | 202 | /** |
203 | - * Gets all the spotter information based on the latest data entry |
|
204 | - * |
|
205 | - * @return Array the spotter information |
|
206 | - * |
|
207 | - */ |
|
203 | + * Gets all the spotter information based on the latest data entry |
|
204 | + * |
|
205 | + * @return Array the spotter information |
|
206 | + * |
|
207 | + */ |
|
208 | 208 | public function getLatestTrackerData($limit = '', $sort = '', $filter = array()) |
209 | 209 | { |
210 | 210 | global $global_query; |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Gets all the spotter information based on the callsign |
|
266 | - * |
|
267 | - * @return Array the spotter information |
|
268 | - * |
|
269 | - */ |
|
265 | + * Gets all the spotter information based on the callsign |
|
266 | + * |
|
267 | + * @return Array the spotter information |
|
268 | + * |
|
269 | + */ |
|
270 | 270 | public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
271 | 271 | { |
272 | 272 | global $global_query; |
@@ -377,12 +377,12 @@ discard block |
||
377 | 377 | |
378 | 378 | |
379 | 379 | /** |
380 | - * Gets all source name |
|
381 | - * |
|
382 | - * @param String type format of source |
|
383 | - * @return Array list of source name |
|
384 | - * |
|
385 | - */ |
|
380 | + * Gets all source name |
|
381 | + * |
|
382 | + * @param String type format of source |
|
383 | + * @return Array list of source name |
|
384 | + * |
|
385 | + */ |
|
386 | 386 | public function getAllSourceName($type = '',$filters = array()) |
387 | 387 | { |
388 | 388 | $filter_query = $this->getFilter($filters,true,true); |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | |
413 | 413 | |
414 | 414 | /** |
415 | - * Gets a list of all idents/callsigns |
|
416 | - * |
|
417 | - * @return Array list of ident/callsign names |
|
418 | - * |
|
419 | - */ |
|
415 | + * Gets a list of all idents/callsigns |
|
416 | + * |
|
417 | + * @return Array list of ident/callsign names |
|
418 | + * |
|
419 | + */ |
|
420 | 420 | public function getAllIdents($filters = array()) |
421 | 421 | { |
422 | 422 | $filter_query = $this->getFilter($filters,true,true); |
@@ -484,18 +484,18 @@ discard block |
||
484 | 484 | |
485 | 485 | |
486 | 486 | /** |
487 | - * Update ident spotter data |
|
488 | - * |
|
489 | - * @param String $flightaware_id the ID from flightaware |
|
490 | - * @param String $ident the flight ident |
|
491 | - * @return String success or false |
|
492 | - * |
|
493 | - */ |
|
487 | + * Update ident spotter data |
|
488 | + * |
|
489 | + * @param String $flightaware_id the ID from flightaware |
|
490 | + * @param String $ident the flight ident |
|
491 | + * @return String success or false |
|
492 | + * |
|
493 | + */ |
|
494 | 494 | public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
495 | 495 | { |
496 | 496 | |
497 | 497 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
498 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
498 | + $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
499 | 499 | |
500 | 500 | try { |
501 | 501 | $sth = $this->db->prepare($query); |
@@ -508,18 +508,18 @@ discard block |
||
508 | 508 | |
509 | 509 | } |
510 | 510 | /** |
511 | - * Update latest spotter data |
|
512 | - * |
|
513 | - * @param String $flightaware_id the ID from flightaware |
|
514 | - * @param String $ident the flight ident |
|
515 | - * @param String $arrival_airport_icao the arrival airport |
|
516 | - * @return String success or false |
|
517 | - * |
|
518 | - */ |
|
511 | + * Update latest spotter data |
|
512 | + * |
|
513 | + * @param String $flightaware_id the ID from flightaware |
|
514 | + * @param String $ident the flight ident |
|
515 | + * @param String $arrival_airport_icao the arrival airport |
|
516 | + * @return String success or false |
|
517 | + * |
|
518 | + */ |
|
519 | 519 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
520 | 520 | { |
521 | 521 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
522 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
522 | + $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
523 | 523 | |
524 | 524 | try { |
525 | 525 | $sth = $this->db->prepare($query); |
@@ -533,32 +533,32 @@ discard block |
||
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
536 | - * Adds a new spotter data |
|
537 | - * |
|
538 | - * @param String $flightaware_id the ID from flightaware |
|
539 | - * @param String $ident the flight ident |
|
540 | - * @param String $aircraft_icao the aircraft type |
|
541 | - * @param String $departure_airport_icao the departure airport |
|
542 | - * @param String $arrival_airport_icao the arrival airport |
|
543 | - * @param String $latitude latitude of flight |
|
544 | - * @param String $longitude latitude of flight |
|
545 | - * @param String $waypoints waypoints of flight |
|
546 | - * @param String $altitude altitude of flight |
|
547 | - * @param String $heading heading of flight |
|
548 | - * @param String $groundspeed speed of flight |
|
549 | - * @param String $date date of flight |
|
550 | - * @param String $departure_airport_time departure time of flight |
|
551 | - * @param String $arrival_airport_time arrival time of flight |
|
552 | - * @param String $squawk squawk code of flight |
|
553 | - * @param String $route_stop route stop of flight |
|
554 | - * @param String $highlight highlight or not |
|
555 | - * @param String $ModeS ModesS code of flight |
|
556 | - * @param String $registration registration code of flight |
|
557 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
558 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
559 | - * @param String $verticalrate vertival rate of flight |
|
560 | - * @return String success or false |
|
561 | - */ |
|
536 | + * Adds a new spotter data |
|
537 | + * |
|
538 | + * @param String $flightaware_id the ID from flightaware |
|
539 | + * @param String $ident the flight ident |
|
540 | + * @param String $aircraft_icao the aircraft type |
|
541 | + * @param String $departure_airport_icao the departure airport |
|
542 | + * @param String $arrival_airport_icao the arrival airport |
|
543 | + * @param String $latitude latitude of flight |
|
544 | + * @param String $longitude latitude of flight |
|
545 | + * @param String $waypoints waypoints of flight |
|
546 | + * @param String $altitude altitude of flight |
|
547 | + * @param String $heading heading of flight |
|
548 | + * @param String $groundspeed speed of flight |
|
549 | + * @param String $date date of flight |
|
550 | + * @param String $departure_airport_time departure time of flight |
|
551 | + * @param String $arrival_airport_time arrival time of flight |
|
552 | + * @param String $squawk squawk code of flight |
|
553 | + * @param String $route_stop route stop of flight |
|
554 | + * @param String $highlight highlight or not |
|
555 | + * @param String $ModeS ModesS code of flight |
|
556 | + * @param String $registration registration code of flight |
|
557 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
558 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
559 | + * @param String $verticalrate vertival rate of flight |
|
560 | + * @return String success or false |
|
561 | + */ |
|
562 | 562 | public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
563 | 563 | { |
564 | 564 | global $globalURL; |
@@ -643,16 +643,16 @@ discard block |
||
643 | 643 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
644 | 644 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
645 | 645 | |
646 | - if ($latitude == '' && $longitude == '') { |
|
647 | - $latitude = 0; |
|
648 | - $longitude = 0; |
|
649 | - } |
|
650 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
651 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
652 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
646 | + if ($latitude == '' && $longitude == '') { |
|
647 | + $latitude = 0; |
|
648 | + $longitude = 0; |
|
649 | + } |
|
650 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
651 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
652 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
653 | 653 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
654 | 654 | |
655 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
655 | + $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
656 | 656 | |
657 | 657 | try { |
658 | 658 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $sth->execute($query_values); |
661 | 661 | $this->db = null; |
662 | 662 | } catch (PDOException $e) { |
663 | - return "error : ".$e->getMessage(); |
|
663 | + return "error : ".$e->getMessage(); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | return "success"; |
@@ -669,11 +669,11 @@ discard block |
||
669 | 669 | |
670 | 670 | |
671 | 671 | /** |
672 | - * Gets the aircraft ident within the last hour |
|
673 | - * |
|
674 | - * @return String the ident |
|
675 | - * |
|
676 | - */ |
|
672 | + * Gets the aircraft ident within the last hour |
|
673 | + * |
|
674 | + * @return String the ident |
|
675 | + * |
|
676 | + */ |
|
677 | 677 | public function getIdentFromLastHour($ident) |
678 | 678 | { |
679 | 679 | global $globalDBdriver, $globalTimezone; |
@@ -689,11 +689,11 @@ discard block |
||
689 | 689 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
690 | 690 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
691 | 691 | $query_data = array(':ident' => $ident); |
692 | - } |
|
692 | + } |
|
693 | 693 | |
694 | 694 | $sth = $this->db->prepare($query); |
695 | 695 | $sth->execute($query_data); |
696 | - $ident_result=''; |
|
696 | + $ident_result=''; |
|
697 | 697 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
698 | 698 | { |
699 | 699 | $ident_result = $row['ident']; |
@@ -704,11 +704,11 @@ discard block |
||
704 | 704 | |
705 | 705 | |
706 | 706 | /** |
707 | - * Gets the aircraft data from the last 20 seconds |
|
708 | - * |
|
709 | - * @return Array the spotter data |
|
710 | - * |
|
711 | - */ |
|
707 | + * Gets the aircraft data from the last 20 seconds |
|
708 | + * |
|
709 | + * @return Array the spotter data |
|
710 | + * |
|
711 | + */ |
|
712 | 712 | public function getRealTimeData($q = '') |
713 | 713 | { |
714 | 714 | global $globalDBdriver; |
@@ -746,11 +746,11 @@ discard block |
||
746 | 746 | |
747 | 747 | |
748 | 748 | /** |
749 | - * Gets all number of flight over countries |
|
750 | - * |
|
751 | - * @return Array the airline country list |
|
752 | - * |
|
753 | - */ |
|
749 | + * Gets all number of flight over countries |
|
750 | + * |
|
751 | + * @return Array the airline country list |
|
752 | + * |
|
753 | + */ |
|
754 | 754 | /* |
755 | 755 | public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
756 | 756 | { |
@@ -801,11 +801,11 @@ discard block |
||
801 | 801 | |
802 | 802 | |
803 | 803 | /** |
804 | - * Gets all callsigns that have flown over |
|
805 | - * |
|
806 | - * @return Array the callsign list |
|
807 | - * |
|
808 | - */ |
|
804 | + * Gets all callsigns that have flown over |
|
805 | + * |
|
806 | + * @return Array the callsign list |
|
807 | + * |
|
808 | + */ |
|
809 | 809 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
810 | 810 | { |
811 | 811 | global $globalDBdriver; |
@@ -872,11 +872,11 @@ discard block |
||
872 | 872 | |
873 | 873 | |
874 | 874 | /** |
875 | - * Counts all dates |
|
876 | - * |
|
877 | - * @return Array the date list |
|
878 | - * |
|
879 | - */ |
|
875 | + * Counts all dates |
|
876 | + * |
|
877 | + * @return Array the date list |
|
878 | + * |
|
879 | + */ |
|
880 | 880 | public function countAllDates($filters = array()) |
881 | 881 | { |
882 | 882 | global $globalTimezone, $globalDBdriver; |
@@ -922,11 +922,11 @@ discard block |
||
922 | 922 | |
923 | 923 | |
924 | 924 | /** |
925 | - * Counts all dates during the last 7 days |
|
926 | - * |
|
927 | - * @return Array the date list |
|
928 | - * |
|
929 | - */ |
|
925 | + * Counts all dates during the last 7 days |
|
926 | + * |
|
927 | + * @return Array the date list |
|
928 | + * |
|
929 | + */ |
|
930 | 930 | public function countAllDatesLast7Days($filters = array()) |
931 | 931 | { |
932 | 932 | global $globalTimezone, $globalDBdriver; |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | $query .= " GROUP BY date_name |
949 | 949 | ORDER BY date_name ASC"; |
950 | 950 | $query_data = array(':offset' => $offset); |
951 | - } |
|
951 | + } |
|
952 | 952 | |
953 | 953 | $sth = $this->db->prepare($query); |
954 | 954 | $sth->execute($query_data); |
@@ -968,11 +968,11 @@ discard block |
||
968 | 968 | } |
969 | 969 | |
970 | 970 | /** |
971 | - * Counts all dates during the last month |
|
972 | - * |
|
973 | - * @return Array the date list |
|
974 | - * |
|
975 | - */ |
|
971 | + * Counts all dates during the last month |
|
972 | + * |
|
973 | + * @return Array the date list |
|
974 | + * |
|
975 | + */ |
|
976 | 976 | public function countAllDatesLastMonth($filters = array()) |
977 | 977 | { |
978 | 978 | global $globalTimezone, $globalDBdriver; |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | $query .= " GROUP BY date_name |
995 | 995 | ORDER BY date_name ASC"; |
996 | 996 | $query_data = array(':offset' => $offset); |
997 | - } |
|
997 | + } |
|
998 | 998 | |
999 | 999 | $sth = $this->db->prepare($query); |
1000 | 1000 | $sth->execute($query_data); |
@@ -1016,11 +1016,11 @@ discard block |
||
1016 | 1016 | |
1017 | 1017 | |
1018 | 1018 | /** |
1019 | - * Counts all month |
|
1020 | - * |
|
1021 | - * @return Array the month list |
|
1022 | - * |
|
1023 | - */ |
|
1019 | + * Counts all month |
|
1020 | + * |
|
1021 | + * @return Array the month list |
|
1022 | + * |
|
1023 | + */ |
|
1024 | 1024 | public function countAllMonths($filters = array()) |
1025 | 1025 | { |
1026 | 1026 | global $globalTimezone, $globalDBdriver; |
@@ -1065,11 +1065,11 @@ discard block |
||
1065 | 1065 | |
1066 | 1066 | |
1067 | 1067 | /** |
1068 | - * Counts all dates during the last year |
|
1069 | - * |
|
1070 | - * @return Array the date list |
|
1071 | - * |
|
1072 | - */ |
|
1068 | + * Counts all dates during the last year |
|
1069 | + * |
|
1070 | + * @return Array the date list |
|
1071 | + * |
|
1072 | + */ |
|
1073 | 1073 | public function countAllMonthsLastYear($filters) |
1074 | 1074 | { |
1075 | 1075 | global $globalTimezone, $globalDBdriver; |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | $query .= " GROUP BY year_name, month_name |
1092 | 1092 | ORDER BY year_name, month_name ASC"; |
1093 | 1093 | $query_data = array(':offset' => $offset); |
1094 | - } |
|
1094 | + } |
|
1095 | 1095 | |
1096 | 1096 | $sth = $this->db->prepare($query); |
1097 | 1097 | $sth->execute($query_data); |
@@ -1114,11 +1114,11 @@ discard block |
||
1114 | 1114 | |
1115 | 1115 | |
1116 | 1116 | /** |
1117 | - * Counts all hours |
|
1118 | - * |
|
1119 | - * @return Array the hour list |
|
1120 | - * |
|
1121 | - */ |
|
1117 | + * Counts all hours |
|
1118 | + * |
|
1119 | + * @return Array the hour list |
|
1120 | + * |
|
1121 | + */ |
|
1122 | 1122 | public function countAllHours($orderby,$filters = array()) |
1123 | 1123 | { |
1124 | 1124 | global $globalTimezone, $globalDBdriver; |
@@ -1181,11 +1181,11 @@ discard block |
||
1181 | 1181 | |
1182 | 1182 | |
1183 | 1183 | /** |
1184 | - * Counts all hours by date |
|
1185 | - * |
|
1186 | - * @return Array the hour list |
|
1187 | - * |
|
1188 | - */ |
|
1184 | + * Counts all hours by date |
|
1185 | + * |
|
1186 | + * @return Array the hour list |
|
1187 | + * |
|
1188 | + */ |
|
1189 | 1189 | public function countAllHoursByDate($date, $filters = array()) |
1190 | 1190 | { |
1191 | 1191 | global $globalTimezone, $globalDBdriver; |
@@ -1229,11 +1229,11 @@ discard block |
||
1229 | 1229 | |
1230 | 1230 | |
1231 | 1231 | /** |
1232 | - * Counts all hours by a ident/callsign |
|
1233 | - * |
|
1234 | - * @return Array the hour list |
|
1235 | - * |
|
1236 | - */ |
|
1232 | + * Counts all hours by a ident/callsign |
|
1233 | + * |
|
1234 | + * @return Array the hour list |
|
1235 | + * |
|
1236 | + */ |
|
1237 | 1237 | public function countAllHoursByIdent($ident, $filters = array()) |
1238 | 1238 | { |
1239 | 1239 | global $globalTimezone, $globalDBdriver; |
@@ -1278,11 +1278,11 @@ discard block |
||
1278 | 1278 | |
1279 | 1279 | |
1280 | 1280 | /** |
1281 | - * Counts all flights that have flown over |
|
1282 | - * |
|
1283 | - * @return Integer the number of flights |
|
1284 | - * |
|
1285 | - */ |
|
1281 | + * Counts all flights that have flown over |
|
1282 | + * |
|
1283 | + * @return Integer the number of flights |
|
1284 | + * |
|
1285 | + */ |
|
1286 | 1286 | public function countOverallTracked($filters = array(),$year = '',$month = '') |
1287 | 1287 | { |
1288 | 1288 | global $globalDBdriver; |
@@ -1317,11 +1317,11 @@ discard block |
||
1317 | 1317 | |
1318 | 1318 | |
1319 | 1319 | /** |
1320 | - * Counts all hours of today |
|
1321 | - * |
|
1322 | - * @return Array the hour list |
|
1323 | - * |
|
1324 | - */ |
|
1320 | + * Counts all hours of today |
|
1321 | + * |
|
1322 | + * @return Array the hour list |
|
1323 | + * |
|
1324 | + */ |
|
1325 | 1325 | public function countAllHoursFromToday($filters = array()) |
1326 | 1326 | { |
1327 | 1327 | global $globalTimezone, $globalDBdriver; |
@@ -1361,12 +1361,12 @@ discard block |
||
1361 | 1361 | } |
1362 | 1362 | |
1363 | 1363 | |
1364 | - /** |
|
1365 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1366 | - * |
|
1367 | - * @return Integer the Barrie Spotter ID |
|
1364 | + /** |
|
1365 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1366 | + * |
|
1367 | + * @return Integer the Barrie Spotter ID |
|
1368 | 1368 | q * |
1369 | - */ |
|
1369 | + */ |
|
1370 | 1370 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1371 | 1371 | { |
1372 | 1372 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -1387,13 +1387,13 @@ discard block |
||
1387 | 1387 | |
1388 | 1388 | |
1389 | 1389 | /** |
1390 | - * Parses a date string |
|
1391 | - * |
|
1392 | - * @param String $dateString the date string |
|
1393 | - * @param String $timezone the timezone of a user |
|
1394 | - * @return Array the time information |
|
1395 | - * |
|
1396 | - */ |
|
1390 | + * Parses a date string |
|
1391 | + * |
|
1392 | + * @param String $dateString the date string |
|
1393 | + * @param String $timezone the timezone of a user |
|
1394 | + * @return Array the time information |
|
1395 | + * |
|
1396 | + */ |
|
1397 | 1397 | public function parseDateString($dateString, $timezone = '') |
1398 | 1398 | { |
1399 | 1399 | $time_array = array(); |
@@ -1426,12 +1426,12 @@ discard block |
||
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | /** |
1429 | - * Parses the direction degrees to working |
|
1430 | - * |
|
1431 | - * @param Float $direction the direction in degrees |
|
1432 | - * @return Array the direction information |
|
1433 | - * |
|
1434 | - */ |
|
1429 | + * Parses the direction degrees to working |
|
1430 | + * |
|
1431 | + * @param Float $direction the direction in degrees |
|
1432 | + * @return Array the direction information |
|
1433 | + * |
|
1434 | + */ |
|
1435 | 1435 | public function parseDirection($direction = 0) |
1436 | 1436 | { |
1437 | 1437 | if ($direction == '') $direction = 0; |
@@ -1510,12 +1510,12 @@ discard block |
||
1510 | 1510 | |
1511 | 1511 | |
1512 | 1512 | /** |
1513 | - * Gets Country from latitude/longitude |
|
1514 | - * |
|
1515 | - * @param Float $latitude latitute of the flight |
|
1516 | - * @param Float $longitude longitute of the flight |
|
1517 | - * @return String the countrie |
|
1518 | - */ |
|
1513 | + * Gets Country from latitude/longitude |
|
1514 | + * |
|
1515 | + * @param Float $latitude latitute of the flight |
|
1516 | + * @param Float $longitude longitute of the flight |
|
1517 | + * @return String the countrie |
|
1518 | + */ |
|
1519 | 1519 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1520 | 1520 | { |
1521 | 1521 | global $globalDBdriver, $globalDebug; |
@@ -1552,11 +1552,11 @@ discard block |
||
1552 | 1552 | } |
1553 | 1553 | |
1554 | 1554 | /** |
1555 | - * Gets Country from iso2 |
|
1556 | - * |
|
1557 | - * @param String $iso2 ISO2 country code |
|
1558 | - * @return String the countrie |
|
1559 | - */ |
|
1555 | + * Gets Country from iso2 |
|
1556 | + * |
|
1557 | + * @param String $iso2 ISO2 country code |
|
1558 | + * @return String the countrie |
|
1559 | + */ |
|
1560 | 1560 | public function getCountryFromISO2($iso2) |
1561 | 1561 | { |
1562 | 1562 | global $globalDBdriver, $globalDebug; |
@@ -1585,12 +1585,12 @@ discard block |
||
1585 | 1585 | |
1586 | 1586 | |
1587 | 1587 | /** |
1588 | - * Gets the short url from bit.ly |
|
1589 | - * |
|
1590 | - * @param String $url the full url |
|
1591 | - * @return String the bit.ly url |
|
1592 | - * |
|
1593 | - */ |
|
1588 | + * Gets the short url from bit.ly |
|
1589 | + * |
|
1590 | + * @param String $url the full url |
|
1591 | + * @return String the bit.ly url |
|
1592 | + * |
|
1593 | + */ |
|
1594 | 1594 | public function getBitlyURL($url) |
1595 | 1595 | { |
1596 | 1596 | global $globalBitlyAccessToken; |
@@ -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(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveTrackerData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Gets Minimal Live Spotter data since xx seconds |
|
174 | - * |
|
175 | - * @return Array the spotter information |
|
176 | - * |
|
177 | - */ |
|
173 | + * Gets Minimal Live Spotter data since xx seconds |
|
174 | + * |
|
175 | + * @return Array the spotter information |
|
176 | + * |
|
177 | + */ |
|
178 | 178 | public function getMinLastLiveTrackerData($filter = array()) |
179 | 179 | { |
180 | 180 | global $globalDBdriver, $globalLiveInterval; |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
190 | - } else { |
|
190 | + } else { |
|
191 | 191 | $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
194 | 194 | } |
195 | 195 | |
196 | - try { |
|
196 | + try { |
|
197 | 197 | $sth = $this->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | 199 | } catch(PDOException $e) { |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
208 | - * Gets number of latest data entry |
|
209 | - * |
|
210 | - * @return String number of entry |
|
211 | - * |
|
212 | - */ |
|
208 | + * Gets number of latest data entry |
|
209 | + * |
|
210 | + * @return String number of entry |
|
211 | + * |
|
212 | + */ |
|
213 | 213 | public function getLiveTrackerCount($filter = array()) |
214 | 214 | { |
215 | 215 | global $globalDBdriver, $globalLiveInterval; |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
237 | - * Gets all the spotter information based on the latest data entry and coord |
|
238 | - * |
|
239 | - * @return Array the spotter information |
|
240 | - * |
|
241 | - */ |
|
237 | + * Gets all the spotter information based on the latest data entry and coord |
|
238 | + * |
|
239 | + * @return Array the spotter information |
|
240 | + * |
|
241 | + */ |
|
242 | 242 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
243 | 243 | { |
244 | 244 | global $globalDBdriver, $globalLiveInterval; |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Gets all the spotter information based on a user's latitude and longitude |
|
266 | - * |
|
267 | - * @return Array the spotter information |
|
268 | - * |
|
269 | - */ |
|
265 | + * Gets all the spotter information based on a user's latitude and longitude |
|
266 | + * |
|
267 | + * @return Array the spotter information |
|
268 | + * |
|
269 | + */ |
|
270 | 270 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
271 | 271 | { |
272 | 272 | $Tracker = new Tracker($this->db); |
@@ -279,142 +279,142 @@ discard block |
||
279 | 279 | if ($lng != '') |
280 | 280 | { |
281 | 281 | if (!is_numeric($lng)) |
282 | - { |
|
283 | - return false; |
|
284 | - } |
|
285 | - } |
|
286 | - |
|
287 | - if ($radius != '') |
|
288 | - { |
|
289 | - if (!is_numeric($radius)) |
|
290 | - { |
|
291 | - return false; |
|
292 | - } |
|
293 | - } |
|
282 | + { |
|
283 | + return false; |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + if ($radius != '') |
|
288 | + { |
|
289 | + if (!is_numeric($radius)) |
|
290 | + { |
|
291 | + return false; |
|
292 | + } |
|
293 | + } |
|
294 | 294 | $additional_query = ''; |
295 | 295 | if ($interval != '') |
296 | - { |
|
297 | - if (!is_string($interval)) |
|
298 | - { |
|
299 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
300 | - return false; |
|
301 | - } else { |
|
302 | - if ($interval == '1m') |
|
303 | - { |
|
304 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
305 | - } else if ($interval == '15m'){ |
|
306 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
307 | - } |
|
308 | - } |
|
309 | - } else { |
|
310 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
311 | - } |
|
312 | - |
|
313 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
296 | + { |
|
297 | + if (!is_string($interval)) |
|
298 | + { |
|
299 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
300 | + return false; |
|
301 | + } else { |
|
302 | + if ($interval == '1m') |
|
303 | + { |
|
304 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
305 | + } else if ($interval == '15m'){ |
|
306 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
307 | + } |
|
308 | + } |
|
309 | + } else { |
|
310 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
311 | + } |
|
312 | + |
|
313 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
314 | 314 | WHERE tracker_live.latitude <> '' |
315 | 315 | AND tracker_live.longitude <> '' |
316 | 316 | ".$additional_query." |
317 | 317 | HAVING distance < :radius |
318 | 318 | ORDER BY distance"; |
319 | 319 | |
320 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
320 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
321 | 321 | |
322 | - return $spotter_array; |
|
323 | - } |
|
322 | + return $spotter_array; |
|
323 | + } |
|
324 | 324 | |
325 | 325 | |
326 | - /** |
|
327 | - * Gets all the spotter information based on a particular callsign |
|
328 | - * |
|
329 | - * @return Array the spotter information |
|
330 | - * |
|
331 | - */ |
|
326 | + /** |
|
327 | + * Gets all the spotter information based on a particular callsign |
|
328 | + * |
|
329 | + * @return Array the spotter information |
|
330 | + * |
|
331 | + */ |
|
332 | 332 | public function getLastLiveTrackerDataByIdent($ident) |
333 | 333 | { |
334 | 334 | $Tracker = new Tracker($this->db); |
335 | 335 | date_default_timezone_set('UTC'); |
336 | 336 | |
337 | 337 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
338 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
338 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
339 | 339 | |
340 | 340 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
341 | 341 | |
342 | 342 | return $spotter_array; |
343 | 343 | } |
344 | 344 | |
345 | - /** |
|
346 | - * Gets all the spotter information based on a particular callsign |
|
347 | - * |
|
348 | - * @return Array the spotter information |
|
349 | - * |
|
350 | - */ |
|
345 | + /** |
|
346 | + * Gets all the spotter information based on a particular callsign |
|
347 | + * |
|
348 | + * @return Array the spotter information |
|
349 | + * |
|
350 | + */ |
|
351 | 351 | public function getDateLiveTrackerDataByIdent($ident,$date) |
352 | 352 | { |
353 | 353 | $Tracker = new Tracker($this->db); |
354 | 354 | date_default_timezone_set('UTC'); |
355 | 355 | |
356 | 356 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
357 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
357 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
358 | 358 | |
359 | - $date = date('c',$date); |
|
359 | + $date = date('c',$date); |
|
360 | 360 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
361 | 361 | |
362 | 362 | return $spotter_array; |
363 | 363 | } |
364 | 364 | |
365 | - /** |
|
366 | - * Gets last spotter information based on a particular callsign |
|
367 | - * |
|
368 | - * @return Array the spotter information |
|
369 | - * |
|
370 | - */ |
|
365 | + /** |
|
366 | + * Gets last spotter information based on a particular callsign |
|
367 | + * |
|
368 | + * @return Array the spotter information |
|
369 | + * |
|
370 | + */ |
|
371 | 371 | public function getLastLiveTrackerDataById($id) |
372 | 372 | { |
373 | 373 | $Tracker = new Tracker($this->db); |
374 | 374 | date_default_timezone_set('UTC'); |
375 | 375 | |
376 | 376 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
377 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
377 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
378 | 378 | |
379 | 379 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
380 | 380 | |
381 | 381 | return $spotter_array; |
382 | 382 | } |
383 | 383 | |
384 | - /** |
|
385 | - * Gets last spotter information based on a particular callsign |
|
386 | - * |
|
387 | - * @return Array the spotter information |
|
388 | - * |
|
389 | - */ |
|
384 | + /** |
|
385 | + * Gets last spotter information based on a particular callsign |
|
386 | + * |
|
387 | + * @return Array the spotter information |
|
388 | + * |
|
389 | + */ |
|
390 | 390 | public function getDateLiveTrackerDataById($id,$date) |
391 | 391 | { |
392 | 392 | $Tracker = new Tracker($this->db); |
393 | 393 | date_default_timezone_set('UTC'); |
394 | 394 | |
395 | 395 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
396 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
397 | - $date = date('c',$date); |
|
396 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
397 | + $date = date('c',$date); |
|
398 | 398 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
399 | 399 | |
400 | 400 | return $spotter_array; |
401 | 401 | } |
402 | 402 | |
403 | - /** |
|
404 | - * Gets altitude information based on a particular callsign |
|
405 | - * |
|
406 | - * @return Array the spotter information |
|
407 | - * |
|
408 | - */ |
|
403 | + /** |
|
404 | + * Gets altitude information based on a particular callsign |
|
405 | + * |
|
406 | + * @return Array the spotter information |
|
407 | + * |
|
408 | + */ |
|
409 | 409 | public function getAltitudeLiveTrackerDataByIdent($ident) |
410 | 410 | { |
411 | 411 | |
412 | 412 | date_default_timezone_set('UTC'); |
413 | 413 | |
414 | 414 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
415 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
415 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
416 | 416 | |
417 | - try { |
|
417 | + try { |
|
418 | 418 | |
419 | 419 | $sth = $this->db->prepare($query); |
420 | 420 | $sth->execute(array(':ident' => $ident)); |
@@ -427,12 +427,12 @@ discard block |
||
427 | 427 | return $spotter_array; |
428 | 428 | } |
429 | 429 | |
430 | - /** |
|
431 | - * Gets all the spotter information based on a particular id |
|
432 | - * |
|
433 | - * @return Array the spotter information |
|
434 | - * |
|
435 | - */ |
|
430 | + /** |
|
431 | + * Gets all the spotter information based on a particular id |
|
432 | + * |
|
433 | + * @return Array the spotter information |
|
434 | + * |
|
435 | + */ |
|
436 | 436 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
437 | 437 | { |
438 | 438 | global $globalDBdriver, $globalLiveInterval; |
@@ -460,18 +460,18 @@ discard block |
||
460 | 460 | return $spotter_array; |
461 | 461 | } |
462 | 462 | |
463 | - /** |
|
464 | - * Gets all the spotter information based on a particular ident |
|
465 | - * |
|
466 | - * @return Array the spotter information |
|
467 | - * |
|
468 | - */ |
|
463 | + /** |
|
464 | + * Gets all the spotter information based on a particular ident |
|
465 | + * |
|
466 | + * @return Array the spotter information |
|
467 | + * |
|
468 | + */ |
|
469 | 469 | public function getAllLiveTrackerDataByIdent($ident) |
470 | 470 | { |
471 | 471 | date_default_timezone_set('UTC'); |
472 | 472 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
473 | 473 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
474 | - try { |
|
474 | + try { |
|
475 | 475 | |
476 | 476 | $sth = $this->db->prepare($query); |
477 | 477 | $sth->execute(array(':ident' => $ident)); |
@@ -485,23 +485,23 @@ discard block |
||
485 | 485 | |
486 | 486 | |
487 | 487 | /** |
488 | - * Deletes all info in the table |
|
489 | - * |
|
490 | - * @return String success or false |
|
491 | - * |
|
492 | - */ |
|
488 | + * Deletes all info in the table |
|
489 | + * |
|
490 | + * @return String success or false |
|
491 | + * |
|
492 | + */ |
|
493 | 493 | public function deleteLiveTrackerData() |
494 | 494 | { |
495 | 495 | global $globalDBdriver; |
496 | 496 | if ($globalDBdriver == 'mysql') { |
497 | 497 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
498 | 498 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
499 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
499 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
500 | 500 | } else { |
501 | 501 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
502 | 502 | } |
503 | 503 | |
504 | - try { |
|
504 | + try { |
|
505 | 505 | |
506 | 506 | $sth = $this->db->prepare($query); |
507 | 507 | $sth->execute(); |
@@ -513,18 +513,18 @@ discard block |
||
513 | 513 | } |
514 | 514 | |
515 | 515 | /** |
516 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
517 | - * |
|
518 | - * @return String success or false |
|
519 | - * |
|
520 | - */ |
|
516 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
517 | + * |
|
518 | + * @return String success or false |
|
519 | + * |
|
520 | + */ |
|
521 | 521 | public function deleteLiveTrackerDataNotUpdated() |
522 | 522 | { |
523 | 523 | global $globalDBdriver, $globalDebug; |
524 | 524 | if ($globalDBdriver == 'mysql') { |
525 | 525 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
526 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
527 | - try { |
|
526 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
527 | + try { |
|
528 | 528 | |
529 | 529 | $sth = $this->db->prepare($query); |
530 | 530 | $sth->execute(); |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | return "error"; |
533 | 533 | } |
534 | 534 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
535 | - $i = 0; |
|
536 | - $j =0; |
|
535 | + $i = 0; |
|
536 | + $j =0; |
|
537 | 537 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
538 | 538 | foreach($all as $row) |
539 | 539 | { |
@@ -541,20 +541,20 @@ discard block |
||
541 | 541 | $j++; |
542 | 542 | if ($j == 30) { |
543 | 543 | if ($globalDebug) echo "."; |
544 | - try { |
|
544 | + try { |
|
545 | 545 | |
546 | 546 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
547 | 547 | $sth->execute(); |
548 | 548 | } catch(PDOException $e) { |
549 | 549 | return "error"; |
550 | 550 | } |
551 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
552 | - $j = 0; |
|
551 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
552 | + $j = 0; |
|
553 | 553 | } |
554 | 554 | $query_delete .= "'".$row['famtrackid']."',"; |
555 | 555 | } |
556 | 556 | if ($i > 0) { |
557 | - try { |
|
557 | + try { |
|
558 | 558 | |
559 | 559 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
560 | 560 | $sth->execute(); |
@@ -565,9 +565,9 @@ discard block |
||
565 | 565 | return "success"; |
566 | 566 | } elseif ($globalDBdriver == 'pgsql') { |
567 | 567 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
568 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
569 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
570 | - try { |
|
568 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
569 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
570 | + try { |
|
571 | 571 | |
572 | 572 | $sth = $this->db->prepare($query); |
573 | 573 | $sth->execute(); |
@@ -611,17 +611,17 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | - * Deletes all info in the table for an ident |
|
615 | - * |
|
616 | - * @return String success or false |
|
617 | - * |
|
618 | - */ |
|
614 | + * Deletes all info in the table for an ident |
|
615 | + * |
|
616 | + * @return String success or false |
|
617 | + * |
|
618 | + */ |
|
619 | 619 | public function deleteLiveTrackerDataByIdent($ident) |
620 | 620 | { |
621 | 621 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
622 | 622 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
623 | 623 | |
624 | - try { |
|
624 | + try { |
|
625 | 625 | |
626 | 626 | $sth = $this->db->prepare($query); |
627 | 627 | $sth->execute(array(':ident' => $ident)); |
@@ -633,17 +633,17 @@ discard block |
||
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
636 | - * Deletes all info in the table for an id |
|
637 | - * |
|
638 | - * @return String success or false |
|
639 | - * |
|
640 | - */ |
|
636 | + * Deletes all info in the table for an id |
|
637 | + * |
|
638 | + * @return String success or false |
|
639 | + * |
|
640 | + */ |
|
641 | 641 | public function deleteLiveTrackerDataById($id) |
642 | 642 | { |
643 | 643 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
644 | 644 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
645 | 645 | |
646 | - try { |
|
646 | + try { |
|
647 | 647 | |
648 | 648 | $sth = $this->db->prepare($query); |
649 | 649 | $sth->execute(array(':id' => $id)); |
@@ -656,11 +656,11 @@ discard block |
||
656 | 656 | |
657 | 657 | |
658 | 658 | /** |
659 | - * Gets the aircraft ident within the last hour |
|
660 | - * |
|
661 | - * @return String the ident |
|
662 | - * |
|
663 | - */ |
|
659 | + * Gets the aircraft ident within the last hour |
|
660 | + * |
|
661 | + * @return String the ident |
|
662 | + * |
|
663 | + */ |
|
664 | 664 | public function getIdentFromLastHour($ident) |
665 | 665 | { |
666 | 666 | global $globalDBdriver, $globalTimezone; |
@@ -686,14 +686,14 @@ discard block |
||
686 | 686 | $ident_result = $row['ident']; |
687 | 687 | } |
688 | 688 | return $ident_result; |
689 | - } |
|
689 | + } |
|
690 | 690 | |
691 | 691 | /** |
692 | - * Check recent aircraft |
|
693 | - * |
|
694 | - * @return String the ident |
|
695 | - * |
|
696 | - */ |
|
692 | + * Check recent aircraft |
|
693 | + * |
|
694 | + * @return String the ident |
|
695 | + * |
|
696 | + */ |
|
697 | 697 | public function checkIdentRecent($ident) |
698 | 698 | { |
699 | 699 | global $globalDBdriver, $globalTimezone; |
@@ -719,14 +719,14 @@ discard block |
||
719 | 719 | $ident_result = $row['famtrackid']; |
720 | 720 | } |
721 | 721 | return $ident_result; |
722 | - } |
|
722 | + } |
|
723 | 723 | |
724 | 724 | /** |
725 | - * Check recent aircraft by id |
|
726 | - * |
|
727 | - * @return String the ident |
|
728 | - * |
|
729 | - */ |
|
725 | + * Check recent aircraft by id |
|
726 | + * |
|
727 | + * @return String the ident |
|
728 | + * |
|
729 | + */ |
|
730 | 730 | public function checkIdRecent($id) |
731 | 731 | { |
732 | 732 | global $globalDBdriver, $globalTimezone; |
@@ -752,19 +752,19 @@ discard block |
||
752 | 752 | $ident_result = $row['famtrackid']; |
753 | 753 | } |
754 | 754 | return $ident_result; |
755 | - } |
|
755 | + } |
|
756 | 756 | |
757 | 757 | /** |
758 | - * Adds a new spotter data |
|
759 | - * |
|
760 | - * @param String $famtrackid the ID from flightaware |
|
761 | - * @param String $ident the flight ident |
|
762 | - * @param String $aircraft_icao the aircraft type |
|
763 | - * @param String $departure_airport_icao the departure airport |
|
764 | - * @param String $arrival_airport_icao the arrival airport |
|
765 | - * @return String success or false |
|
766 | - * |
|
767 | - */ |
|
758 | + * Adds a new spotter data |
|
759 | + * |
|
760 | + * @param String $famtrackid the ID from flightaware |
|
761 | + * @param String $ident the flight ident |
|
762 | + * @param String $aircraft_icao the aircraft type |
|
763 | + * @param String $departure_airport_icao the departure airport |
|
764 | + * @param String $arrival_airport_icao the arrival airport |
|
765 | + * @return String success or false |
|
766 | + * |
|
767 | + */ |
|
768 | 768 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
769 | 769 | { |
770 | 770 | global $globalURL, $globalArchive, $globalDebug; |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
838 | 838 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
839 | 839 | |
840 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
841 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
840 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
841 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
842 | 842 | |
843 | 843 | $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
844 | 844 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -848,9 +848,9 @@ discard block |
||
848 | 848 | |
849 | 849 | $sth = $this->db->prepare($query); |
850 | 850 | $sth->execute($query_values); |
851 | - } catch(PDOException $e) { |
|
852 | - return "error : ".$e->getMessage(); |
|
853 | - } |
|
851 | + } catch(PDOException $e) { |
|
852 | + return "error : ".$e->getMessage(); |
|
853 | + } |
|
854 | 854 | /* |
855 | 855 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
856 | 856 | if ($globalDebug) echo '(Add to SBS archive : '; |
@@ -9,16 +9,16 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | |
11 | 11 | class TrackerImport { |
12 | - private $all_tracked = array(); |
|
13 | - private $last_delete_hourly = 0; |
|
14 | - private $last_delete = 0; |
|
15 | - private $stats = array(); |
|
16 | - private $tmd = 0; |
|
17 | - private $source_location = array(); |
|
18 | - public $db = null; |
|
19 | - public $nb = 0; |
|
12 | + private $all_tracked = array(); |
|
13 | + private $last_delete_hourly = 0; |
|
14 | + private $last_delete = 0; |
|
15 | + private $stats = array(); |
|
16 | + private $tmd = 0; |
|
17 | + private $source_location = array(); |
|
18 | + public $db = null; |
|
19 | + public $nb = 0; |
|
20 | 20 | |
21 | - public function __construct($dbc = null) { |
|
21 | + public function __construct($dbc = null) { |
|
22 | 22 | global $globalBeta; |
23 | 23 | $Connection = new Connection($dbc); |
24 | 24 | $this->db = $Connection->db(); |
@@ -40,50 +40,50 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | */ |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - public function checkAll() { |
|
45 | + public function checkAll() { |
|
46 | 46 | global $globalDebug; |
47 | 47 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
48 | 48 | foreach ($this->all_tracked as $key => $flight) { |
49 | - if (isset($this->all_tracked[$key]['id'])) { |
|
49 | + if (isset($this->all_tracked[$key]['id'])) { |
|
50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
51 | - $Tracker = new Tracker($this->db); |
|
52 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
53 | - } |
|
51 | + $Tracker = new Tracker($this->db); |
|
52 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
53 | + } |
|
54 | + } |
|
54 | 55 | } |
55 | - } |
|
56 | 56 | |
57 | - public function del() { |
|
57 | + public function del() { |
|
58 | 58 | global $globalDebug; |
59 | 59 | // Delete old infos |
60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
62 | - if (isset($flight['lastupdate'])) { |
|
63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
64 | - if (isset($this->all_tracked[$key]['id'])) { |
|
65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
62 | + if (isset($flight['lastupdate'])) { |
|
63 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
64 | + if (isset($this->all_tracked[$key]['id'])) { |
|
65 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
66 | 66 | /* |
67 | 67 | $TrackerLive = new TrackerLive(); |
68 | 68 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
69 | 69 | $TrackerLive->db = null; |
70 | 70 | */ |
71 | - //$real_arrival = $this->arrival($key); |
|
72 | - $Tracker = new Tracker($this->db); |
|
73 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
71 | + //$real_arrival = $this->arrival($key); |
|
72 | + $Tracker = new Tracker($this->db); |
|
73 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
74 | 74 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
76 | 76 | } |
77 | 77 | // Put in archive |
78 | 78 | // $Tracker->db = null; |
79 | - } |
|
80 | - unset($this->all_tracked[$key]); |
|
81 | - } |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
79 | + } |
|
80 | + unset($this->all_tracked[$key]); |
|
81 | + } |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - public function add($line) { |
|
86 | + public function add($line) { |
|
87 | 87 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
88 | 88 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
89 | 89 | date_default_timezone_set('UTC'); |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | |
93 | 93 | // SBS format is CSV format |
94 | 94 | if(is_array($line) && isset($line['ident'])) { |
95 | - //print_r($line); |
|
96 | - if (isset($line['ident'])) { |
|
95 | + //print_r($line); |
|
96 | + if (isset($line['ident'])) { |
|
97 | 97 | |
98 | 98 | /* |
99 | 99 | // Increment message number |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | */ |
110 | 110 | |
111 | 111 | $Common = new Common(); |
112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | - else $id = trim($line['id']); |
|
112 | + if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | + else $id = trim($line['id']); |
|
114 | 114 | |
115 | 115 | if (!isset($this->all_tracked[$id])) { |
116 | - $this->all_tracked[$id] = array(); |
|
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
120 | - if (!isset($line['id'])) { |
|
116 | + $this->all_tracked[$id] = array(); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
120 | + if (!isset($line['id'])) { |
|
121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
122 | 122 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
128 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
128 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
129 | 129 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
130 | - } else { |
|
130 | + } else { |
|
131 | 131 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
132 | 132 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
133 | 133 | return ''; |
134 | - } |
|
134 | + } |
|
135 | 135 | } else { |
136 | 136 | date_default_timezone_set('UTC'); |
137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -139,38 +139,38 @@ discard block |
||
139 | 139 | |
140 | 140 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
141 | 141 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
142 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
143 | - if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
142 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
143 | + if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
144 | 144 | $timeelapsed = microtime(true); |
145 | - $Tracker = new Tracker($this->db); |
|
146 | - $fromsource = NULL; |
|
147 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
145 | + $Tracker = new Tracker($this->db); |
|
146 | + $fromsource = NULL; |
|
147 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
148 | 148 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
149 | 149 | $Tracker->db = null; |
150 | 150 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
151 | - } |
|
152 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
151 | + } |
|
152 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | if (isset($line['speed']) && $line['speed'] != '') { |
156 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
156 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
158 | 158 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
159 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
160 | - if ($distance > 1000 && $distance < 10000) { |
|
159 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
160 | + if ($distance > 1000 && $distance < 10000) { |
|
161 | 161 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
162 | 162 | $speed = $speed*3.6; |
163 | 163 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
164 | 164 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
165 | - } |
|
165 | + } |
|
166 | 166 | } |
167 | 167 | |
168 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
169 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
170 | - else unset($timediff); |
|
171 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
168 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
169 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
170 | + else unset($timediff); |
|
171 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
172 | 172 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
173 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
173 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
174 | 174 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
175 | 175 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
176 | 176 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -184,120 +184,120 @@ discard block |
||
184 | 184 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
185 | 185 | $this->tmd = 0; |
186 | 186 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
187 | - } |
|
187 | + } |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
191 | 191 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
192 | 192 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
193 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
194 | - $dataFound = true; |
|
195 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
193 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
194 | + $dataFound = true; |
|
195 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
196 | 196 | } |
197 | 197 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
198 | 198 | } |
199 | 199 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
200 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
200 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
201 | 201 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
202 | 202 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
203 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
204 | - $dataFound = true; |
|
205 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
203 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
204 | + $dataFound = true; |
|
205 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
206 | 206 | } |
207 | 207 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
208 | 208 | } |
209 | 209 | |
210 | - } else if ($globalDebug && $timediff > 20) { |
|
210 | + } else if ($globalDebug && $timediff > 20) { |
|
211 | 211 | $this->tmd = $this->tmd + 1; |
212 | 212 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
213 | 213 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
214 | 214 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
215 | 215 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
216 | - } |
|
216 | + } |
|
217 | 217 | } |
218 | 218 | if (isset($line['last_update']) && $line['last_update'] != '') { |
219 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
220 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
219 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
220 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
221 | 221 | } |
222 | 222 | if (isset($line['format_source']) && $line['format_source'] != '') { |
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
224 | 224 | } |
225 | 225 | if (isset($line['source_name']) && $line['source_name'] != '') { |
226 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
226 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
227 | 227 | } |
228 | 228 | if (isset($line['comment']) && $line['comment'] != '') { |
229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
230 | - //$dataFound = true; |
|
229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
230 | + //$dataFound = true; |
|
231 | 231 | } |
232 | 232 | if (isset($line['type']) && $line['type'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
234 | - //$dataFound = true; |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
234 | + //$dataFound = true; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | if (isset($line['altitude']) && $line['altitude'] != '') { |
238 | - //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
238 | + //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
239 | 239 | if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
240 | 240 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
241 | 241 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
242 | 242 | //$dataFound = true; |
243 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
243 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
247 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
247 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | if (isset($line['heading']) && $line['heading'] != '') { |
251 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
252 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
253 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
254 | - //$dataFound = true; |
|
251 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
252 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
253 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
254 | + //$dataFound = true; |
|
255 | 255 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
256 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
258 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
256 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
258 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
260 | 260 | } |
261 | 261 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
262 | 262 | |
263 | 263 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
264 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
265 | - if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
266 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
267 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
264 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
265 | + if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
266 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
267 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
268 | 268 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
269 | 269 | $timeelapsed = microtime(true); |
270 | 270 | $TrackerLive = new TrackerLive($this->db); |
271 | 271 | if (isset($line['id'])) { |
272 | - $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
273 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
272 | + $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
273 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
274 | 274 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
275 | - $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
276 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
275 | + $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
276 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
277 | 277 | } else $recent_ident = ''; |
278 | 278 | $TrackerLive->db=null; |
279 | 279 | |
280 | 280 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
281 | 281 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
282 | - } else { |
|
282 | + } else { |
|
283 | 283 | $recent_ident = ''; |
284 | 284 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
285 | - } |
|
286 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
287 | - if($recent_ident == "") |
|
288 | - { |
|
285 | + } |
|
286 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
287 | + if($recent_ident == "") |
|
288 | + { |
|
289 | 289 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
290 | 290 | //adds the spotter data for the archive |
291 | - $highlight = ''; |
|
292 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
293 | - $timeelapsed = microtime(true); |
|
294 | - $Tracker = new Tracker($this->db); |
|
295 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
296 | - $Tracker->db = null; |
|
297 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
298 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
291 | + $highlight = ''; |
|
292 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
293 | + $timeelapsed = microtime(true); |
|
294 | + $Tracker = new Tracker($this->db); |
|
295 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
296 | + $Tracker->db = null; |
|
297 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
298 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
299 | 299 | |
300 | - /* |
|
300 | + /* |
|
301 | 301 | // Add source stat in DB |
302 | 302 | $Stats = new Stats($this->db); |
303 | 303 | if (!empty($this->stats)) { |
@@ -324,20 +324,20 @@ discard block |
||
324 | 324 | } |
325 | 325 | $Stats->db = null; |
326 | 326 | */ |
327 | - $this->del(); |
|
327 | + $this->del(); |
|
328 | 328 | //$ignoreImport = false; |
329 | 329 | $this->all_tracked[$id]['addedTracker'] = 1; |
330 | 330 | //print_r($this->all_tracked[$id]); |
331 | 331 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
332 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
333 | - //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
334 | - $TrackerLive = new TrackerLive($this->db); |
|
335 | - $TrackerLive->deleteLiveTrackerData(); |
|
336 | - $TrackerLive->db=null; |
|
337 | - if ($globalDebug) echo " Done\n"; |
|
338 | - $this->last_delete = time(); |
|
332 | + if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
333 | + //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
334 | + $TrackerLive = new TrackerLive($this->db); |
|
335 | + $TrackerLive->deleteLiveTrackerData(); |
|
336 | + $TrackerLive->db=null; |
|
337 | + if ($globalDebug) echo " Done\n"; |
|
338 | + $this->last_delete = time(); |
|
339 | 339 | } |
340 | - } else { |
|
340 | + } else { |
|
341 | 341 | $this->all_tracked[$id]['id'] = $recent_ident; |
342 | 342 | $this->all_tracked[$id]['addedTracker'] = 1; |
343 | 343 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -346,16 +346,16 @@ discard block |
||
346 | 346 | $Tracker->db = null; |
347 | 347 | } |
348 | 348 | |
349 | - } |
|
349 | + } |
|
350 | + } |
|
350 | 351 | } |
351 | - } |
|
352 | - //adds the spotter LIVE data |
|
353 | - if ($globalDebug) { |
|
352 | + //adds the spotter LIVE data |
|
353 | + if ($globalDebug) { |
|
354 | 354 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
355 | - } |
|
356 | - $ignoreImport = false; |
|
355 | + } |
|
356 | + $ignoreImport = false; |
|
357 | 357 | |
358 | - if (!$ignoreImport) { |
|
358 | + if (!$ignoreImport) { |
|
359 | 359 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
360 | 360 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
361 | 361 | $timeelapsed = microtime(true); |
@@ -427,22 +427,22 @@ discard block |
||
427 | 427 | |
428 | 428 | |
429 | 429 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
430 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
431 | - $TrackerLive = new TrackerLive($this->db); |
|
432 | - $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
433 | - $TrackerLive->db = null; |
|
434 | - //TrackerLive->deleteLiveTrackerData(); |
|
435 | - if ($globalDebug) echo " Done\n"; |
|
436 | - $this->last_delete_hourly = time(); |
|
430 | + if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
431 | + $TrackerLive = new TrackerLive($this->db); |
|
432 | + $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
433 | + $TrackerLive->db = null; |
|
434 | + //TrackerLive->deleteLiveTrackerData(); |
|
435 | + if ($globalDebug) echo " Done\n"; |
|
436 | + $this->last_delete_hourly = time(); |
|
437 | 437 | } |
438 | 438 | |
439 | - } |
|
440 | - //$ignoreImport = false; |
|
439 | + } |
|
440 | + //$ignoreImport = false; |
|
441 | 441 | } |
442 | 442 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
443 | 443 | if ($send) return $this->all_tracked[$id]; |
444 | - } |
|
444 | + } |
|
445 | + } |
|
445 | 446 | } |
446 | - } |
|
447 | 447 | } |
448 | 448 | ?> |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | return ($dec); |
58 | 58 | } |
59 | 59 | |
60 | - /* |
|
60 | + /* |
|
61 | 61 | $ais_map64 = array( |
62 | 62 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 48 |
63 | 63 | ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | // ' ' --- '?', // 0x20 - 0x3F |
98 | 98 | // '@' --- '_', // 0x40 - 0x5F |
99 | 99 | $ais_chars = array( |
100 | - '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', |
|
101 | - 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', |
|
102 | - 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', |
|
103 | - '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'', |
|
104 | - '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', |
|
105 | - '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', |
|
106 | - '<', '=', '>', '?' |
|
100 | + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', |
|
101 | + 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', |
|
102 | + 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', |
|
103 | + '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'', |
|
104 | + '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', |
|
105 | + '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', |
|
106 | + '<', '=', '>', '?' |
|
107 | 107 | ); |
108 | 108 | // " |
109 | 109 | $rv = ''; |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | } |
420 | 420 | if ($num_seq > 1) { // for multipart messages |
421 | 421 | if ($cmsg_sid != $msg_sid // different msg_sid |
422 | - || $msg_sid == -1 // invalid initial msg_sid |
|
423 | - || ($seq - $pseq) != 1 // not insequence |
|
422 | + || $msg_sid == -1 // invalid initial msg_sid |
|
423 | + || ($seq - $pseq) != 1 // not insequence |
|
424 | 424 | ) { // invalid for multipart message |
425 | 425 | $msg_sid = -1; |
426 | 426 | $cmsg_sid = -1; |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $itu = $itu.$pcs[5]; // get itu message |
434 | 434 | $filler += (int)$pcs[6][0]; // get filler |
435 | 435 | if ($num_seq == 1 // valid single message |
436 | - || $num_seq == $pseq // valid multi-part message |
|
436 | + || $num_seq == $pseq // valid multi-part message |
|
437 | 437 | ) { |
438 | 438 | if ($num_seq != 1) { // test |
439 | 439 | //echo $rawdata; |
@@ -516,13 +516,13 @@ discard block |
||
516 | 516 | else $pad = ''; |
517 | 517 | $rv = ''; |
518 | 518 | $ais_chars = array( |
519 | - '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
|
520 | - 'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19, |
|
521 | - 'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29, |
|
522 | - '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39, |
|
523 | - '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49, |
|
524 | - '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59, |
|
525 | - '<'=>60, '='=>61, '>'=>62, '?'=>63 |
|
519 | + '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
|
520 | + 'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19, |
|
521 | + 'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29, |
|
522 | + '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39, |
|
523 | + '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49, |
|
524 | + '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59, |
|
525 | + '<'=>60, '='=>61, '>'=>62, '?'=>63 |
|
526 | 526 | ); |
527 | 527 | // " |
528 | 528 | $_a = str_split($name); |