@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | } |
| 518 | 518 | } |
| 519 | 519 | <?php |
| 520 | - } else { |
|
| 521 | - ?> |
|
| 520 | + } else { |
|
| 521 | + ?> |
|
| 522 | 522 | if (map.getZoom() > 7) { |
| 523 | 523 | var style = { |
| 524 | 524 | "color": "#1a3151", |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | layer_tracker_data.addLayer(layer); |
| 538 | 538 | } |
| 539 | 539 | <?php |
| 540 | - } |
|
| 540 | + } |
|
| 541 | 541 | ?> |
| 542 | 542 | } |
| 543 | 543 | } |
@@ -5,8 +5,11 @@ discard block |
||
| 5 | 5 | setcookie("MapFormat",'2d'); |
| 6 | 6 | |
| 7 | 7 | // Compressed GeoJson is used if true |
| 8 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 9 | -else $compress = $globalJsonCompress; |
|
| 8 | +if (!isset($globalJsonCompress)) { |
|
| 9 | + $compress = true; |
|
| 10 | +} else { |
|
| 11 | + $compress = $globalJsonCompress; |
|
| 12 | +} |
|
| 10 | 13 | ?> |
| 11 | 14 | |
| 12 | 15 | |
@@ -143,9 +146,13 @@ discard block |
||
| 143 | 146 | if (callsign != ""){ markerTrackerLabel += callsign; } |
| 144 | 147 | if (type != ""){ markerTrackerLabel += ' - '+type; } |
| 145 | 148 | <?php |
| 146 | - if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor']; |
|
| 147 | - elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor; |
|
| 148 | - else $IconColor = '1a3151'; |
|
| 149 | + if (isset($_COOKIE['IconColor'])) { |
|
| 150 | + $IconColor = $_COOKIE['IconColor']; |
|
| 151 | + } elseif (isset($globalAircraftIconColor)) { |
|
| 152 | + $IconColor = $globalAircraftIconColor; |
|
| 153 | + } else { |
|
| 154 | + $IconColor = '1a3151'; |
|
| 155 | + } |
|
| 149 | 156 | if (!isset($ident) && !isset($famtrackid)) { |
| 150 | 157 | ?> |
| 151 | 158 | info_tracker_update(feature.properties.fc); |
@@ -179,7 +186,12 @@ discard block |
||
| 179 | 186 | <?php |
| 180 | 187 | } else { |
| 181 | 188 | ?> |
| 182 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
| 189 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
| 190 | + print $archiveupdatetime*1000; |
|
| 191 | +} else { |
|
| 192 | + print $globalMapRefresh*1000+20000; |
|
| 193 | +} |
|
| 194 | +?>+feature.properties.sqt*1000); |
|
| 183 | 195 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
| 184 | 196 | <?php |
| 185 | 197 | } |
@@ -228,7 +240,12 @@ discard block |
||
| 228 | 240 | <?php |
| 229 | 241 | } else { |
| 230 | 242 | ?> |
| 231 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
| 243 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
| 244 | + print $archiveupdatetime*1000; |
|
| 245 | +} else { |
|
| 246 | + print $globalMapRefresh*1000+20000; |
|
| 247 | +} |
|
| 248 | +?>+feature.properties.sqt*1000); |
|
| 232 | 249 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
| 233 | 250 | <?php |
| 234 | 251 | } |
@@ -276,7 +293,12 @@ discard block |
||
| 276 | 293 | <?php |
| 277 | 294 | } else { |
| 278 | 295 | ?> |
| 279 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
| 296 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
| 297 | + print $archiveupdatetime*1000; |
|
| 298 | +} else { |
|
| 299 | + print $globalMapRefresh*1000+20000; |
|
| 300 | +} |
|
| 301 | +?>+feature.properties.sqt*1000); |
|
| 280 | 302 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
| 281 | 303 | <?php |
| 282 | 304 | } |
@@ -559,14 +581,24 @@ discard block |
||
| 559 | 581 | if (isset($archive) && $archive) { |
| 560 | 582 | ?> |
| 561 | 583 | //then load it again every 30 seconds |
| 562 | -// var reload = setInterval(function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>); |
|
| 584 | +// var reload = setInterval(function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) { |
|
| 585 | + print ($globalMapRefresh*1000)/2; |
|
| 586 | +} else { |
|
| 587 | + print '15000'; |
|
| 588 | +} |
|
| 589 | +?>); |
|
| 563 | 590 | reloadTrackerPage = setInterval(function(){if (noTimeout) getLiveTrackerData(0)},<?php print $archiveupdatetime*1000; ?>); |
| 564 | 591 | <?php |
| 565 | 592 | } else { |
| 566 | 593 | ?> |
| 567 | 594 | //then load it again every 30 seconds |
| 568 | 595 | reloadTrackerPage = setInterval( |
| 569 | - function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
| 596 | + function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) { |
|
| 597 | + print $globalMapRefresh*1000; |
|
| 598 | +} else { |
|
| 599 | + print '30000'; |
|
| 600 | +} |
|
| 601 | +?>); |
|
| 570 | 602 | <?php |
| 571 | 603 | } |
| 572 | 604 | ?> |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | require_once('../require/settings.php'); |
| 3 | 3 | require_once('../require/class.Language.php'); |
| 4 | 4 | |
| 5 | -setcookie("MapFormat",'2d'); |
|
| 5 | +setcookie("MapFormat", '2d'); |
|
| 6 | 6 | |
| 7 | 7 | // Compressed GeoJson is used if true |
| 8 | 8 | if (!isset($globalJsonCompress)) $compress = true; |
@@ -17,10 +17,10 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | <?php |
| 19 | 19 | if (isset($_GET['famtrackid'])) { |
| 20 | - $famtrackid = filter_input(INPUT_GET,'famtrackid',FILTER_SANITIZE_STRING); |
|
| 20 | + $famtrackid = filter_input(INPUT_GET, 'famtrackid', FILTER_SANITIZE_STRING); |
|
| 21 | 21 | } |
| 22 | 22 | if (isset($_GET['ident'])) { |
| 23 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
| 23 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
| 24 | 24 | } |
| 25 | 25 | if (!isset($ident) && !isset($famtrackid)) { |
| 26 | 26 | ?> |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | <?php |
| 183 | 183 | } else { |
| 184 | 184 | ?> |
| 185 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
| 185 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000); |
|
| 186 | 186 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
| 187 | 187 | <?php |
| 188 | 188 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | /* |
| 199 | 199 | shadowUrl: iconURLShadowpath, |
| 200 | 200 | shadowSize: [<?php print $globalAircraftSize; ?>, <?php print $globalAircraftSize; ?>], |
| 201 | - shadowAnchor: [<?php print ($globalAircraftSize/2)+1; ?>, <?php print $globalAircraftSize; ?>] |
|
| 201 | + shadowAnchor: [<?php print ($globalAircraftSize/2) + 1; ?>, <?php print $globalAircraftSize; ?>] |
|
| 202 | 202 | */ |
| 203 | 203 | }) |
| 204 | 204 | }) |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | <?php |
| 232 | 232 | } else { |
| 233 | 233 | ?> |
| 234 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
| 234 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000); |
|
| 235 | 235 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
| 236 | 236 | <?php |
| 237 | 237 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | <?php |
| 280 | 280 | } else { |
| 281 | 281 | ?> |
| 282 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
| 282 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000); |
|
| 283 | 283 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
| 284 | 284 | <?php |
| 285 | 285 | } |
@@ -662,9 +662,9 @@ |
||
| 662 | 662 | // var timeline = new Cesium.Timeline(viewer); |
| 663 | 663 | var clockViewModel = new Cesium.ClockViewModel(viewer.clock); |
| 664 | 664 | var animationViewModel = new Cesium.AnimationViewModel(clockViewModel); |
| 665 | - //this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' + '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i> <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a> <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>'; |
|
| 666 | - $(".archivebox").html('<h4><?php echo str_replace("'","\'",_("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>'); |
|
| 667 | - // this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' + '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>'; |
|
| 665 | + //this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' + '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i> <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a> <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>'; |
|
| 666 | + $(".archivebox").html('<h4><?php echo str_replace("'", "\'", _("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>'); |
|
| 667 | + // this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' + '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>'; |
|
| 668 | 668 | |
| 669 | 669 | } |
| 670 | 670 | |
@@ -720,12 +720,12 @@ |
||
| 720 | 720 | update_airportsLayer(); |
| 721 | 721 | } |
| 722 | 722 | <?php |
| 723 | - if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
| 723 | + if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
| 724 | 724 | ?> |
| 725 | 725 | update_atcLayer(); |
| 726 | 726 | setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
| 727 | 727 | <?php |
| 728 | - } |
|
| 728 | + } |
|
| 729 | 729 | ?> |
| 730 | 730 | |
| 731 | 731 | function iconColor(color) { |
@@ -202,7 +202,12 @@ discard block |
||
| 202 | 202 | // viewer.dataSources.get(dsn).entities.remove(entity); |
| 203 | 203 | // } |
| 204 | 204 | //console.log(entity.lastupdate); |
| 205 | - if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
| 205 | + if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
| 206 | + print $globalMapRefresh*2000; |
|
| 207 | +} else { |
|
| 208 | + print '60000'; |
|
| 209 | +} |
|
| 210 | +?>)) { |
|
| 206 | 211 | // console.log('Remove an entity date'); |
| 207 | 212 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 208 | 213 | } else { |
@@ -276,7 +281,12 @@ discard block |
||
| 276 | 281 | } else { |
| 277 | 282 | for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) { |
| 278 | 283 | var entity = viewer.dataSources.get(dsn).entities.values[i]; |
| 279 | - if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
| 284 | + if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
| 285 | + print $globalMapRefresh*2000; |
|
| 286 | +} else { |
|
| 287 | + print '60000'; |
|
| 288 | +} |
|
| 289 | +?>)) { |
|
| 280 | 290 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 281 | 291 | } |
| 282 | 292 | } |
@@ -606,7 +616,12 @@ discard block |
||
| 606 | 616 | if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
| 607 | 617 | ?> |
| 608 | 618 | update_polarLayer(); |
| 609 | -setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
| 619 | +setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) { |
|
| 620 | + print $globalMapRefresh*1000*2; |
|
| 621 | +} else { |
|
| 622 | + print '60000'; |
|
| 623 | +} |
|
| 624 | +?>); |
|
| 610 | 625 | <?php |
| 611 | 626 | } |
| 612 | 627 | ?> |
@@ -704,7 +719,12 @@ discard block |
||
| 704 | 719 | } |
| 705 | 720 | } |
| 706 | 721 | } |
| 707 | - ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
| 722 | + ,<?php if (isset($globalMapRefresh)) { |
|
| 723 | + print $globalMapRefresh*1000; |
|
| 724 | +} else { |
|
| 725 | + print '30000'; |
|
| 726 | +} |
|
| 727 | +?>); |
|
| 708 | 728 | } else { |
| 709 | 729 | //var widget = new Cesium.CesiumWidget('archivebox'); |
| 710 | 730 | // var timeline = new Cesium.Timeline(viewer); |
@@ -723,7 +743,12 @@ discard block |
||
| 723 | 743 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 724 | 744 | ?> |
| 725 | 745 | update_atcLayer(); |
| 726 | -setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
| 746 | +setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) { |
|
| 747 | + print $globalMapRefresh*1000*2; |
|
| 748 | +} else { |
|
| 749 | + print '60000'; |
|
| 750 | +} |
|
| 751 | +?>); |
|
| 727 | 752 | <?php |
| 728 | 753 | } |
| 729 | 754 | ?> |
@@ -352,10 +352,10 @@ discard block |
||
| 352 | 352 | }); |
| 353 | 353 | update_locationsLayer(); |
| 354 | 354 | <?php |
| 355 | - // Add support for custom json via $globalMapJson |
|
| 356 | - if (isset($globalMapJson) && is_array($globalMapJson)) { |
|
| 355 | + // Add support for custom json via $globalMapJson |
|
| 356 | + if (isset($globalMapJson) && is_array($globalMapJson)) { |
|
| 357 | 357 | foreach ($globalMapJson as $json) { |
| 358 | - if (isset($json['url'])) { |
|
| 358 | + if (isset($json['url'])) { |
|
| 359 | 359 | ?> |
| 360 | 360 | update_genLayer('<?php print $json['url']; ?>'); |
| 361 | 361 | <?php |
@@ -364,9 +364,9 @@ discard block |
||
| 364 | 364 | setInterval(function(){update_genLayer('<?php print $json['url']; ?>')}, <?php print $json['refresh']; ?>); |
| 365 | 365 | <?php |
| 366 | 366 | } |
| 367 | - } |
|
| 367 | + } |
|
| 368 | + } |
|
| 368 | 369 | } |
| 369 | - } |
|
| 370 | 370 | |
| 371 | 371 | ?> |
| 372 | 372 | //adds the bootstrap tooltip to the map icons |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | require_once('../require/settings.php'); |
| 3 | 3 | require_once('../require/class.Language.php'); |
| 4 | 4 | |
| 5 | -setcookie("MapFormat",'2d'); |
|
| 5 | +setcookie("MapFormat", '2d'); |
|
| 6 | 6 | |
| 7 | 7 | if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = ''; |
| 8 | 8 | // Compressed GeoJson is used if true |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | $lastupd = $_GET['archivespeed']*$archiveupdatetime; |
| 21 | 21 | if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate']; |
| 22 | 22 | else $enddate = time(); |
| 23 | - setcookie("archive_begin",$begindate); |
|
| 24 | - setcookie("archive_end",$enddate); |
|
| 25 | - setcookie("archive_update",$lastupd); |
|
| 26 | - setcookie("archive_speed",$archivespeed); |
|
| 23 | + setcookie("archive_begin", $begindate); |
|
| 24 | + setcookie("archive_end", $enddate); |
|
| 25 | + setcookie("archive_update", $lastupd); |
|
| 26 | + setcookie("archive_speed", $archivespeed); |
|
| 27 | 27 | ?> |
| 28 | 28 | document.cookie = 'archive_begin=<?php print $begindate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'; |
| 29 | 29 | document.cookie = 'archive_end=<?php print $enddate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'; |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | <?php |
| 75 | 75 | } |
| 76 | 76 | if (isset($_GET['ident'])) { |
| 77 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
| 77 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
| 78 | 78 | } |
| 79 | 79 | if (isset($_GET['flightaware_id'])) { |
| 80 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
| 80 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($_GET['latitude'])) { |
| 83 | - $latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_STRING); |
|
| 83 | + $latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_STRING); |
|
| 84 | 84 | } |
| 85 | 85 | if (isset($_GET['longitude'])) { |
| 86 | - $longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_STRING); |
|
| 86 | + $longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_STRING); |
|
| 87 | 87 | } |
| 88 | 88 | ?> |
| 89 | 89 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | || navigator.userAgent.match(/BlackBerry/i) |
| 120 | 120 | || navigator.userAgent.match(/Windows Phone/i)) |
| 121 | 121 | { |
| 122 | - var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>; |
|
| 122 | + var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom - 1; else print '8'; ?>; |
|
| 123 | 123 | } else { |
| 124 | 124 | var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>; |
| 125 | 125 | } |
@@ -213,19 +213,19 @@ discard block |
||
| 213 | 213 | map.addLayer(yandexLayer); |
| 214 | 214 | <?php |
| 215 | 215 | } elseif ($MapType == 'Bing-Aerial') { |
| 216 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 216 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
| 217 | 217 | ?> |
| 218 | 218 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'}); |
| 219 | 219 | map.addLayer(bingLayer); |
| 220 | 220 | <?php |
| 221 | 221 | } elseif ($MapType == 'Bing-Hybrid') { |
| 222 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 222 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
| 223 | 223 | ?> |
| 224 | 224 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'}); |
| 225 | 225 | map.addLayer(bingLayer); |
| 226 | 226 | <?php |
| 227 | 227 | } elseif ($MapType == 'Bing-Road') { |
| 228 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 228 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
| 229 | 229 | ?> |
| 230 | 230 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'}); |
| 231 | 231 | map.addLayer(bingLayer); |
@@ -4,10 +4,15 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | setcookie("MapFormat",'2d'); |
| 6 | 6 | |
| 7 | -if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = ''; |
|
| 7 | +if (!isset($globalOpenWeatherMapKey)) { |
|
| 8 | + $globalOpenWeatherMapKey = ''; |
|
| 9 | +} |
|
| 8 | 10 | // Compressed GeoJson is used if true |
| 9 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 10 | -else $compress = $globalJsonCompress; |
|
| 11 | +if (!isset($globalJsonCompress)) { |
|
| 12 | + $compress = true; |
|
| 13 | +} else { |
|
| 14 | + $compress = $globalJsonCompress; |
|
| 15 | +} |
|
| 11 | 16 | if (isset($_GET['archive'])) { |
| 12 | 17 | $archive = true; |
| 13 | 18 | //$archiveupdatetime = 50; |
@@ -18,8 +23,11 @@ discard block |
||
| 18 | 23 | //$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10)); |
| 19 | 24 | //$lastupd = 20; |
| 20 | 25 | $lastupd = $_GET['archivespeed']*$archiveupdatetime; |
| 21 | - if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate']; |
|
| 22 | - else $enddate = time(); |
|
| 26 | + if (isset($_GET['enddate']) && $_GET['enddate'] != '') { |
|
| 27 | + $enddate = $_GET['enddate']; |
|
| 28 | + } else { |
|
| 29 | + $enddate = time(); |
|
| 30 | + } |
|
| 23 | 31 | setcookie("archive_begin",$begindate); |
| 24 | 32 | setcookie("archive_end",$enddate); |
| 25 | 33 | setcookie("archive_update",$lastupd); |
@@ -106,7 +114,17 @@ discard block |
||
| 106 | 114 | } |
| 107 | 115 | |
| 108 | 116 | //create the map |
| 109 | - map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom); |
|
| 117 | + map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) { |
|
| 118 | + print $latitude; |
|
| 119 | +} else { |
|
| 120 | + print $globalCenterLatitude; |
|
| 121 | +} |
|
| 122 | +?>,<?php if (isset($longitude)) { |
|
| 123 | + print $longitude; |
|
| 124 | +} else { |
|
| 125 | + print $globalCenterLongitude; |
|
| 126 | +} |
|
| 127 | +?>], zoom); |
|
| 110 | 128 | <?php |
| 111 | 129 | } else { |
| 112 | 130 | ?> |
@@ -119,9 +137,19 @@ discard block |
||
| 119 | 137 | || navigator.userAgent.match(/BlackBerry/i) |
| 120 | 138 | || navigator.userAgent.match(/Windows Phone/i)) |
| 121 | 139 | { |
| 122 | - var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>; |
|
| 140 | + var zoom = <?php if (isset($globalLiveZoom)) { |
|
| 141 | + print $globalLiveZoom-1; |
|
| 142 | +} else { |
|
| 143 | + print '8'; |
|
| 144 | +} |
|
| 145 | +?>; |
|
| 123 | 146 | } else { |
| 124 | - var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>; |
|
| 147 | + var zoom = <?php if (isset($globalLiveZoom)) { |
|
| 148 | + print $globalLiveZoom; |
|
| 149 | +} else { |
|
| 150 | + print '9'; |
|
| 151 | +} |
|
| 152 | +?>; |
|
| 125 | 153 | } |
| 126 | 154 | |
| 127 | 155 | //create the map |
@@ -146,16 +174,27 @@ discard block |
||
| 146 | 174 | bounds = L.latLngBounds(southWest,northEast); |
| 147 | 175 | //a few title layers |
| 148 | 176 | <?php |
| 149 | - if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType']; |
|
| 150 | - else $MapType = $globalMapProvider; |
|
| 177 | + if (isset($_COOKIE['MapType'])) { |
|
| 178 | + $MapType = $_COOKIE['MapType']; |
|
| 179 | + } else { |
|
| 180 | + $MapType = $globalMapProvider; |
|
| 181 | + } |
|
| 151 | 182 | |
| 152 | 183 | if ($MapType == 'Mapbox') { |
| 153 | - if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId; |
|
| 154 | - else $MapBoxId = $_COOKIE['MapTypeId']; |
|
| 155 | -?> |
|
| 184 | + if ($_COOKIE['MapTypeId'] == 'default') { |
|
| 185 | + $MapBoxId = $globalMapboxId; |
|
| 186 | + } else { |
|
| 187 | + $MapBoxId = $_COOKIE['MapTypeId']; |
|
| 188 | + } |
|
| 189 | + ?> |
|
| 156 | 190 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
| 157 | 191 | maxZoom: 18, |
| 158 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
| 192 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
| 193 | + print 'false'; |
|
| 194 | +} else { |
|
| 195 | + print 'true'; |
|
| 196 | +} |
|
| 197 | +?>, |
|
| 159 | 198 | attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + |
| 160 | 199 | '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + |
| 161 | 200 | 'Imagery © <a href="http://mapbox.com">Mapbox</a>', |
@@ -167,7 +206,12 @@ discard block |
||
| 167 | 206 | ?> |
| 168 | 207 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
| 169 | 208 | maxZoom: 18, |
| 170 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
| 209 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
| 210 | + print 'false'; |
|
| 211 | +} else { |
|
| 212 | + print 'true'; |
|
| 213 | +} |
|
| 214 | +?>, |
|
| 171 | 215 | attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + |
| 172 | 216 | '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>' |
| 173 | 217 | }).addTo(map); |
@@ -213,20 +257,26 @@ discard block |
||
| 213 | 257 | map.addLayer(yandexLayer); |
| 214 | 258 | <?php |
| 215 | 259 | } elseif ($MapType == 'Bing-Aerial') { |
| 216 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 217 | -?> |
|
| 260 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
| 261 | + setcookie('MapType','OpenStreetMap'); |
|
| 262 | + } |
|
| 263 | + ?> |
|
| 218 | 264 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'}); |
| 219 | 265 | map.addLayer(bingLayer); |
| 220 | 266 | <?php |
| 221 | 267 | } elseif ($MapType == 'Bing-Hybrid') { |
| 222 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 223 | -?> |
|
| 268 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
| 269 | + setcookie('MapType','OpenStreetMap'); |
|
| 270 | + } |
|
| 271 | + ?> |
|
| 224 | 272 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'}); |
| 225 | 273 | map.addLayer(bingLayer); |
| 226 | 274 | <?php |
| 227 | 275 | } elseif ($MapType == 'Bing-Road') { |
| 228 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 229 | -?> |
|
| 276 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
| 277 | + setcookie('MapType','OpenStreetMap'); |
|
| 278 | + } |
|
| 279 | + ?> |
|
| 230 | 280 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'}); |
| 231 | 281 | map.addLayer(bingLayer); |
| 232 | 282 | <?php |
@@ -249,9 +299,24 @@ discard block |
||
| 249 | 299 | $customid = $MapType; |
| 250 | 300 | ?> |
| 251 | 301 | L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', { |
| 252 | - maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>, |
|
| 253 | - minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>, |
|
| 254 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
| 302 | + maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) { |
|
| 303 | + print $globalMapCustomLayer[$customid]['maxZoom']; |
|
| 304 | +} else { |
|
| 305 | + print '18'; |
|
| 306 | +} |
|
| 307 | +?>, |
|
| 308 | + minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) { |
|
| 309 | + print $globalMapCustomLayer[$customid]['minZoom']; |
|
| 310 | +} else { |
|
| 311 | + print '0'; |
|
| 312 | +} |
|
| 313 | +?>, |
|
| 314 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
| 315 | + print 'false'; |
|
| 316 | +} else { |
|
| 317 | + print 'true'; |
|
| 318 | +} |
|
| 319 | +?>, |
|
| 255 | 320 | attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>' |
| 256 | 321 | }).addTo(map); |
| 257 | 322 | |
@@ -285,7 +350,12 @@ discard block |
||
| 285 | 350 | } |
| 286 | 351 | } elseif ($globalBounding == 'circle') { |
| 287 | 352 | ?> |
| 288 | - var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{ |
|
| 353 | + var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) { |
|
| 354 | + print $globalBoundingCircleSize; |
|
| 355 | +} else { |
|
| 356 | + print '70000'; |
|
| 357 | +} |
|
| 358 | +?>,{ |
|
| 289 | 359 | color: '#92C7D1', |
| 290 | 360 | fillColor: '#92C7D1', |
| 291 | 361 | fillOpacity: 0.3, |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | $from_archive = false; |
| 11 | 11 | if (isset($_GET['ident'])) { |
| 12 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
| 12 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
| 13 | 13 | if (isset($_GET['currenttime'])) { |
| 14 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
| 14 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
| 15 | 15 | $currenttime = round($currenttime/1000); |
| 16 | - $spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident,$currenttime); |
|
| 16 | + $spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident, $currenttime); |
|
| 17 | 17 | /* |
| 18 | 18 | if (empty($spotter_array)) { |
| 19 | 19 | $from_archive = true; |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | if (isset($_GET['fammarine_id'])) { |
| 34 | - $fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING); |
|
| 34 | + $fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING); |
|
| 35 | 35 | if (isset($_GET['currenttime'])) { |
| 36 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
| 36 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
| 37 | 37 | $currenttime = round($currenttime/1000); |
| 38 | - $spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id,$currenttime); |
|
| 38 | + $spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id, $currenttime); |
|
| 39 | 39 | /* |
| 40 | 40 | if (empty($spotter_array)) { |
| 41 | 41 | $from_archive = true; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
| 63 | 63 | { |
| 64 | 64 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
| 65 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
| 65 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
| 66 | 66 | } else $image = $spotter_item['image_thumbnail']; |
| 67 | 67 | |
| 68 | 68 | } |
@@ -63,7 +63,9 @@ |
||
| 63 | 63 | { |
| 64 | 64 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
| 65 | 65 | $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 66 | - } else $image = $spotter_item['image_thumbnail']; |
|
| 66 | + } else { |
|
| 67 | + $image = $spotter_item['image_thumbnail']; |
|
| 68 | + } |
|
| 67 | 69 | |
| 68 | 70 | } |
| 69 | 71 | /* else { |
@@ -63,7 +63,9 @@ |
||
| 63 | 63 | { |
| 64 | 64 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
| 65 | 65 | $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 66 | - } else $image = $spotter_item['image_thumbnail']; |
|
| 66 | + } else { |
|
| 67 | + $image = $spotter_item['image_thumbnail']; |
|
| 68 | + } |
|
| 67 | 69 | |
| 68 | 70 | } |
| 69 | 71 | /* else { |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | print '<div class="details">'; |
| 79 | 79 | print '<div><span>'._("Altitude").'</span>'; |
| 80 | 80 | if (isset($globalGroundAltitude) && $globalGroundAltitude) { |
| 81 | - try { |
|
| 81 | + try { |
|
| 82 | 82 | $groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']); |
| 83 | - } catch(Exception $e) { |
|
| 84 | - } |
|
| 83 | + } catch(Exception $e) { |
|
| 84 | + } |
|
| 85 | 85 | } |
| 86 | 86 | if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
| 87 | 87 | print $spotter_item['altitude'].' feet (FL'.$spotter_item['altitude'].')'; |
@@ -89,14 +89,14 @@ discard block |
||
| 89 | 89 | print round($spotter_item['altitude']*0.3048).' m (FL'.round($spotter_item['altitude']/100).')'; |
| 90 | 90 | } |
| 91 | 91 | if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*0.3048) { |
| 92 | - print '<br>'; |
|
| 93 | - print '<span>'._("Ground Altitude").'</span>'; |
|
| 94 | - if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
|
| 92 | + print '<br>'; |
|
| 93 | + print '<span>'._("Ground Altitude").'</span>'; |
|
| 94 | + if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
|
| 95 | 95 | print round($groundAltitude*3.28084).' feet'; |
| 96 | - } else { |
|
| 96 | + } else { |
|
| 97 | 97 | print round($groundAltitude).' m'; |
| 98 | - } |
|
| 99 | - print '</i>'; |
|
| 98 | + } |
|
| 99 | + print '</i>'; |
|
| 100 | 100 | } |
| 101 | 101 | print '</div>'; |
| 102 | 102 | print '<div><span>'._("Speed").'</span>'; |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | $from_archive = false; |
| 13 | 13 | if (isset($_GET['ident'])) { |
| 14 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
| 14 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
| 15 | 15 | if (isset($_GET['currenttime'])) { |
| 16 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
| 16 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
| 17 | 17 | $currenttime = round($currenttime/1000); |
| 18 | - $spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident,$currenttime); |
|
| 18 | + $spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident, $currenttime); |
|
| 19 | 19 | if (empty($spotter_array)) { |
| 20 | 20 | $from_archive = true; |
| 21 | - $spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident,$currenttime); |
|
| 21 | + $spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident, $currenttime); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | } else { |
@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | if (isset($_GET['famtrackid'])) { |
| 33 | - $famtrackid = urldecode(filter_input(INPUT_GET,'famtrackid',FILTER_SANITIZE_STRING)); |
|
| 33 | + $famtrackid = urldecode(filter_input(INPUT_GET, 'famtrackid', FILTER_SANITIZE_STRING)); |
|
| 34 | 34 | if (isset($_GET['currenttime'])) { |
| 35 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
| 35 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
| 36 | 36 | $currenttime = round($currenttime/1000); |
| 37 | - $spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid,$currenttime); |
|
| 37 | + $spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid, $currenttime); |
|
| 38 | 38 | |
| 39 | 39 | if (empty($spotter_array)) { |
| 40 | 40 | $from_archive = true; |
| 41 | 41 | // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
| 42 | - $spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($flightaware_id,$currenttime); |
|
| 42 | + $spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($flightaware_id, $currenttime); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | } else { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
| 60 | 60 | { |
| 61 | 61 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
| 62 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
| 62 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
| 63 | 63 | } else $image = $spotter_item['image_thumbnail']; |
| 64 | 64 | |
| 65 | 65 | } |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | print '<div><span>'._("Altitude").'</span>'; |
| 80 | 80 | if (isset($globalGroundAltitude) && $globalGroundAltitude) { |
| 81 | 81 | try { |
| 82 | - $groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']); |
|
| 83 | - } catch(Exception $e) { |
|
| 82 | + $groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']); |
|
| 83 | + } catch (Exception $e) { |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
@@ -68,6 +68,10 @@ discard block |
||
| 68 | 68 | 't', 'u', 'v', 'w' // 119 |
| 69 | 69 | ); // char 64 |
| 70 | 70 | */ |
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @param integer $ascii |
|
| 74 | + */ |
|
| 71 | 75 | private function asciidec_2_8bit($ascii) { |
| 72 | 76 | //only process in the following range: 48-87, 96-119 |
| 73 | 77 | if ($ascii < 48) { } |
@@ -93,6 +97,10 @@ discard block |
||
| 93 | 97 | return(substr($bin, -6)); |
| 94 | 98 | } |
| 95 | 99 | |
| 100 | + /** |
|
| 101 | + * @param integer $_start |
|
| 102 | + * @param integer $_size |
|
| 103 | + */ |
|
| 96 | 104 | private function binchar($_str, $_start, $_size) { |
| 97 | 105 | // ' ' --- '?', // 0x20 - 0x3F |
| 98 | 106 | // '@' --- '_', // 0x40 - 0x5F |
@@ -118,6 +126,10 @@ discard block |
||
| 118 | 126 | } |
| 119 | 127 | |
| 120 | 128 | // function for decoding the AIS Message ITU Payload |
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @param string $_aisdata |
|
| 132 | + */ |
|
| 121 | 133 | private function decode_ais($_aisdata) { |
| 122 | 134 | $ro = new stdClass(); // return object |
| 123 | 135 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
@@ -351,6 +363,12 @@ discard block |
||
| 351 | 363 | elseif ($code == 99) return 'Other Type, no additional information'; |
| 352 | 364 | } |
| 353 | 365 | |
| 366 | + /** |
|
| 367 | + * @param string $_itu |
|
| 368 | + * @param integer $_len |
|
| 369 | + * @param integer $_filler |
|
| 370 | + * @param string $aux |
|
| 371 | + */ |
|
| 354 | 372 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
| 355 | 373 | global $port; // tcpip port... |
| 356 | 374 | |
@@ -371,6 +389,10 @@ discard block |
||
| 371 | 389 | |
| 372 | 390 | // char* - AIS \r terminated string |
| 373 | 391 | // TCP based streams which send messages in full can use this instead of calling process_ais_buf |
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * @param string $rawdata |
|
| 395 | + */ |
|
| 374 | 396 | public function process_ais_raw($rawdata, $aux = '') { // return int |
| 375 | 397 | static $num_seq; // 1 to 9 |
| 376 | 398 | static $seq; // 1 to 9 |
@@ -589,6 +611,9 @@ discard block |
||
| 589 | 611 | return $result; |
| 590 | 612 | } |
| 591 | 613 | |
| 614 | + /** |
|
| 615 | + * @param string $mmsi |
|
| 616 | + */ |
|
| 592 | 617 | public function mmsitype($mmsi) { |
| 593 | 618 | if (strlen($mmsi) == 9) { |
| 594 | 619 | if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
@@ -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); |
@@ -29,31 +29,31 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | private function make_latf($temp) { // unsigned long |
| 31 | 31 | $flat = 0.0; // float |
| 32 | - $temp = $temp & 0x07FFFFFF; |
|
| 33 | - if ($temp & 0x04000000) { |
|
| 34 | - $temp = $temp ^ 0x07FFFFFF; |
|
| 32 | + $temp = $temp&0x07FFFFFF; |
|
| 33 | + if ($temp&0x04000000) { |
|
| 34 | + $temp = $temp^0x07FFFFFF; |
|
| 35 | 35 | $temp += 1; |
| 36 | - $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 36 | + $flat = (float) ($temp/(60.0*10000.0)); |
|
| 37 | 37 | $flat *= -1.0; |
| 38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 38 | + } else $flat = (float) ($temp/(60.0*10000.0)); |
|
| 39 | 39 | return $flat; // float |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | private function make_lonf($temp) { // unsigned long |
| 43 | 43 | $flon = 0.0; // float |
| 44 | - $temp = $temp & 0x0FFFFFFF; |
|
| 45 | - if ($temp & 0x08000000) { |
|
| 46 | - $temp = $temp ^ 0x0FFFFFFF; |
|
| 44 | + $temp = $temp&0x0FFFFFFF; |
|
| 45 | + if ($temp&0x08000000) { |
|
| 46 | + $temp = $temp^0x0FFFFFFF; |
|
| 47 | 47 | $temp += 1; |
| 48 | - $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 48 | + $flon = (float) ($temp/(60.0*10000.0)); |
|
| 49 | 49 | $flon *= -1.0; |
| 50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 50 | + } else $flon = (float) ($temp/(60.0*10000.0)); |
|
| 51 | 51 | return $flon; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | private function ascii_2_dec($chr) { |
| 55 | - $dec=ord($chr);//get decimal ascii code |
|
| 56 | - $hex=dechex($dec);//convert decimal to hex |
|
| 55 | + $dec = ord($chr); //get decimal ascii code |
|
| 56 | + $hex = dechex($dec); //convert decimal to hex |
|
| 57 | 57 | return ($dec); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | //only process in the following range: 48-87, 96-119 |
| 73 | 73 | if ($ascii < 48) { } |
| 74 | 74 | else { |
| 75 | - if($ascii>119) { } |
|
| 75 | + if ($ascii > 119) { } |
|
| 76 | 76 | else { |
| 77 | - if ($ascii>87 && $ascii<96) ; |
|
| 77 | + if ($ascii > 87 && $ascii < 96); |
|
| 78 | 78 | else { |
| 79 | - $ascii=$ascii+40; |
|
| 80 | - if ($ascii>128){ |
|
| 81 | - $ascii=$ascii+32; |
|
| 79 | + $ascii = $ascii + 40; |
|
| 80 | + if ($ascii > 128) { |
|
| 81 | + $ascii = $ascii + 32; |
|
| 82 | 82 | } else { |
| 83 | - $ascii=$ascii+40; |
|
| 83 | + $ascii = $ascii + 40; |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | private function dec_2_6bit($dec) { |
| 92 | - $bin=decbin($dec); |
|
| 92 | + $bin = decbin($dec); |
|
| 93 | 93 | return(substr($bin, -6)); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | ); |
| 108 | 108 | // " |
| 109 | 109 | $rv = ''; |
| 110 | - if ($_size % 6 == 0) { |
|
| 111 | - $len = $_size / 6; |
|
| 112 | - for ($i=0; $i<$len; $i++) { |
|
| 113 | - $offset = $i * 6; |
|
| 114 | - $rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ]; |
|
| 110 | + if ($_size%6 == 0) { |
|
| 111 | + $len = $_size/6; |
|
| 112 | + for ($i = 0; $i < $len; $i++) { |
|
| 113 | + $offset = $i*6; |
|
| 114 | + $rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))]; |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | return $rv; |
@@ -138,93 +138,93 @@ discard block |
||
| 138 | 138 | $ro->eta_hour = ''; |
| 139 | 139 | $ro->eta_minute = ''; |
| 140 | 140 | $ro->ts = time(); |
| 141 | - $ro->id = bindec(substr($_aisdata,0,6)); |
|
| 142 | - $ro->mmsi = bindec(substr($_aisdata,8,30)); |
|
| 141 | + $ro->id = bindec(substr($_aisdata, 0, 6)); |
|
| 142 | + $ro->mmsi = bindec(substr($_aisdata, 8, 30)); |
|
| 143 | 143 | if ($ro->id >= 1 && $ro->id <= 3) { |
| 144 | - $ro->cog = bindec(substr($_aisdata,116,12))/10; |
|
| 145 | - $ro->sog = bindec(substr($_aisdata,50,10))/10; |
|
| 146 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
| 147 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
| 144 | + $ro->cog = bindec(substr($_aisdata, 116, 12))/10; |
|
| 145 | + $ro->sog = bindec(substr($_aisdata, 50, 10))/10; |
|
| 146 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
| 147 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
| 148 | 148 | $ro->cls = 1; // class A |
| 149 | 149 | } else if ($ro->id == 4) { |
| 150 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28))); |
|
| 151 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27))); |
|
| 150 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28))); |
|
| 151 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27))); |
|
| 152 | 152 | $ro->cls = 1; // class A |
| 153 | 153 | } else if ($ro->id == 5) { |
| 154 | - $ro->imo = bindec(substr($_aisdata,40,30)); |
|
| 155 | - $ro->callsign = $this->binchar($_aisdata,70,42); |
|
| 156 | - $ro->name = $this->binchar($_aisdata,112,120); |
|
| 157 | - $ro->typeid = bindec(substr($_aisdata,232,8)); |
|
| 154 | + $ro->imo = bindec(substr($_aisdata, 40, 30)); |
|
| 155 | + $ro->callsign = $this->binchar($_aisdata, 70, 42); |
|
| 156 | + $ro->name = $this->binchar($_aisdata, 112, 120); |
|
| 157 | + $ro->typeid = bindec(substr($_aisdata, 232, 8)); |
|
| 158 | 158 | $ro->type = $this->getShipType($ro->typeid); |
| 159 | 159 | //$ro->to_bow = bindec(substr($_aisdata,240,9)); |
| 160 | 160 | //$ro->to_stern = bindec(substr($_aisdata,249,9)); |
| 161 | 161 | //$ro->to_port = bindec(substr($_aisdata,258,6)); |
| 162 | 162 | //$ro->to_starboard = bindec(substr($_aisdata,264,6)); |
| 163 | - $ro->eta_month = bindec(substr($_aisdata,274,4)); |
|
| 164 | - $ro->eta_day = bindec(substr($_aisdata,278,5)); |
|
| 165 | - $ro->eta_hour = bindec(substr($_aisdata,283,5)); |
|
| 166 | - $ro->eta_minute = bindec(substr($_aisdata,288,6)); |
|
| 163 | + $ro->eta_month = bindec(substr($_aisdata, 274, 4)); |
|
| 164 | + $ro->eta_day = bindec(substr($_aisdata, 278, 5)); |
|
| 165 | + $ro->eta_hour = bindec(substr($_aisdata, 283, 5)); |
|
| 166 | + $ro->eta_minute = bindec(substr($_aisdata, 288, 6)); |
|
| 167 | 167 | //$ro->draught = bindec(substr($_aisdata,294,8)); |
| 168 | - $ro->destination = $this->binchar($_aisdata,302,120); |
|
| 168 | + $ro->destination = $this->binchar($_aisdata, 302, 120); |
|
| 169 | 169 | $ro->cls = 1; // class A |
| 170 | 170 | } else if ($ro->id == 9) { |
| 171 | 171 | // Search and Rescue aircraft position report |
| 172 | 172 | } else if ($ro->id == 18) { |
| 173 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
| 174 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
| 175 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
|
| 176 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
|
| 177 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
| 173 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
| 174 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
| 175 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28))); |
|
| 176 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27))); |
|
| 177 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
| 178 | 178 | if ($ro->heading == 511) $ro->heading = ''; |
| 179 | 179 | $ro->cls = 2; // class B |
| 180 | 180 | } else if ($ro->id == 19) { |
| 181 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
| 182 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
| 183 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
| 184 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
| 185 | - $ro->name = $this->binchar($_aisdata,143,120); |
|
| 181 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
| 182 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
| 183 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
| 184 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
| 185 | + $ro->name = $this->binchar($_aisdata, 143, 120); |
|
| 186 | 186 | $ro->cls = 2; // class B |
| 187 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
| 187 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
| 188 | 188 | if ($ro->heading == 511) $ro->heading = ''; |
| 189 | - $ro->typeid = bindec(substr($_aisdata,263,8)); |
|
| 189 | + $ro->typeid = bindec(substr($_aisdata, 263, 8)); |
|
| 190 | 190 | $ro->type = $this->getShipType($ro->typeid); |
| 191 | 191 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
| 192 | 192 | //$ro->to_stern = bindec(substr($_aisdata,280,9)); |
| 193 | 193 | //$ro->to_port = bindec(substr($_aisdata,289,6)); |
| 194 | 194 | //$ro->to_starboard = bindec(substr($_aisdata,295,6)); |
| 195 | 195 | } else if ($ro->id == 21) { |
| 196 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28))); |
|
| 197 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27))); |
|
| 198 | - $ro->name = $this->binchar($_aisdata,43,120); |
|
| 196 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28))); |
|
| 197 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27))); |
|
| 198 | + $ro->name = $this->binchar($_aisdata, 43, 120); |
|
| 199 | 199 | //$ro->to_bow = bindec(substr($_aisdata,219,9)); |
| 200 | 200 | //$ro->to_stern = bindec(substr($_aisdata,228,9)); |
| 201 | 201 | //$ro->to_port = bindec(substr($_aisdata,237,6)); |
| 202 | 202 | //$ro->to_starboard = bindec(substr($_aisdata,243,6)); |
| 203 | 203 | $ro->cls = 2; // class B |
| 204 | 204 | } else if ($ro->id == 24) { |
| 205 | - $pn = bindec(substr($_aisdata,38,2)); |
|
| 205 | + $pn = bindec(substr($_aisdata, 38, 2)); |
|
| 206 | 206 | if ($pn == 0) { |
| 207 | - $ro->name = $this->binchar($_aisdata,40,120); |
|
| 207 | + $ro->name = $this->binchar($_aisdata, 40, 120); |
|
| 208 | 208 | } |
| 209 | - $ro->typeid = bindec(substr($_aisdata,40,8)); |
|
| 209 | + $ro->typeid = bindec(substr($_aisdata, 40, 8)); |
|
| 210 | 210 | $ro->type = $this->getShipType($ro->typeid); |
| 211 | - $ro->callsign = $this->binchar($_aisdata,90,42); |
|
| 211 | + $ro->callsign = $this->binchar($_aisdata, 90, 42); |
|
| 212 | 212 | //$ro->to_bow = bindec(substr($_aisdata,132,9)); |
| 213 | 213 | //$ro->to_stern = bindec(substr($_aisdata,141,9)); |
| 214 | 214 | //$ro->to_port = bindec(substr($_aisdata,150,6)); |
| 215 | 215 | //$ro->to_starboard = bindec(substr($_aisdata,156,6)); |
| 216 | 216 | $ro->cls = 2; // class B |
| 217 | 217 | } else if ($ro->id == 27) { |
| 218 | - $ro->cog = bindec(substr($_aisdata,85,9)); |
|
| 218 | + $ro->cog = bindec(substr($_aisdata, 85, 9)); |
|
| 219 | 219 | if ($ro->cog == 511) $ro->cog = 0.0; |
| 220 | - $ro->sog = bindec(substr($_aisdata,79,6)); |
|
| 220 | + $ro->sog = bindec(substr($_aisdata, 79, 6)); |
|
| 221 | 221 | if ($ro->sog == 63) $ro->sog = 0.0; |
| 222 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
|
| 223 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
|
| 222 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10); |
|
| 223 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10); |
|
| 224 | 224 | $ro->cls = 1; // class A |
| 225 | 225 | |
| 226 | 226 | } |
| 227 | - $ro->statusid = bindec(substr($_aisdata,38,4)); |
|
| 227 | + $ro->statusid = bindec(substr($_aisdata, 38, 4)); |
|
| 228 | 228 | $ro->status = $this->getStatus($ro->statusid); |
| 229 | 229 | //var_dump($ro); // dump results here for demo purpose |
| 230 | 230 | return $ro; |
@@ -355,14 +355,14 @@ discard block |
||
| 355 | 355 | global $port; // tcpip port... |
| 356 | 356 | |
| 357 | 357 | static $debug_counter = 0; |
| 358 | - $aisdata168='';//six bit array of ascii characters |
|
| 358 | + $aisdata168 = ''; //six bit array of ascii characters |
|
| 359 | 359 | $ais_nmea_array = str_split($_itu); // convert to an array |
| 360 | 360 | foreach ($ais_nmea_array as $value) { |
| 361 | 361 | $dec = $this->ascii_2_dec($value); |
| 362 | 362 | $bit8 = $this->asciidec_2_8bit($dec); |
| 363 | 363 | $bit6 = $this->dec_2_6bit($bit8); |
| 364 | 364 | //echo $value ."-" .$bit6 .""; |
| 365 | - $aisdata168 .=$bit6; |
|
| 365 | + $aisdata168 .= $bit6; |
|
| 366 | 366 | } |
| 367 | 367 | //echo $aisdata168 . "<br/>"; |
| 368 | 368 | //return $this->decode_ais($aisdata168, $aux); |
@@ -385,20 +385,20 @@ discard block |
||
| 385 | 385 | // calculate checksum after ! till * |
| 386 | 386 | // assume 1st ! is valid |
| 387 | 387 | // find * ensure that it is at correct position |
| 388 | - $end = strrpos ( $rawdata , '*' ); |
|
| 388 | + $end = strrpos($rawdata, '*'); |
|
| 389 | 389 | if ($end === FALSE) return -1; // check for NULLS!!! |
| 390 | - $cs = substr( $rawdata, $end + 1 ); |
|
| 391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
| 392 | - $dcs = (int)hexdec( $cs ); |
|
| 393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
| 394 | - if ( $chksum == $dcs ) { // NMEA checksum pass |
|
| 390 | + $cs = substr($rawdata, $end + 1); |
|
| 391 | + if (strlen($cs) != 2) return -1; // correct cs length |
|
| 392 | + $dcs = (int) hexdec($cs); |
|
| 393 | + for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum |
|
| 394 | + if ($chksum == $dcs) { // NMEA checksum pass |
|
| 395 | 395 | $pcs = explode(',', $rawdata); |
| 396 | 396 | // !AI??? identifier |
| 397 | - $num_seq = (int)$pcs[1]; // number of sequences |
|
| 398 | - $seq = (int)$pcs[2]; // get sequence |
|
| 397 | + $num_seq = (int) $pcs[1]; // number of sequences |
|
| 398 | + $seq = (int) $pcs[2]; // get sequence |
|
| 399 | 399 | // get msg sequence id |
| 400 | 400 | if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
| 401 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
| 401 | + else $msg_sid = (int) $pcs[3]; // multipart message |
|
| 402 | 402 | $ais_ch = $pcs[4]; // get AIS channel |
| 403 | 403 | // message sequence checking |
| 404 | 404 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | $itu = $itu.$pcs[5]; // get itu message |
| 434 | - $filler += (int)$pcs[6][0]; // get filler |
|
| 434 | + $filler += (int) $pcs[6][0]; // get filler |
|
| 435 | 435 | if ($num_seq == 1 // valid single message |
| 436 | 436 | || $num_seq == $pseq // valid multi-part message |
| 437 | 437 | ) { |
@@ -451,13 +451,13 @@ discard block |
||
| 451 | 451 | $cbuf = $cbuf.$ibuf; |
| 452 | 452 | $last_pos = 0; |
| 453 | 453 | $result = new stdClass(); |
| 454 | - while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) { |
|
| 454 | + while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) { |
|
| 455 | 455 | //while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) { |
| 456 | 456 | //DEBUG echo $cbuf; |
| 457 | - if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
| 457 | + if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
| 458 | 458 | $tst = substr($cbuf, $start - 3, ($end - $start + 3)); |
| 459 | 459 | //DEBUG echo "[$start $end $tst]\n"; |
| 460 | - $result = $this->process_ais_raw( $tst, "" ); |
|
| 460 | + $result = $this->process_ais_raw($tst, ""); |
|
| 461 | 461 | $last_pos = $end + 1; |
| 462 | 462 | } else break; |
| 463 | 463 | } |
@@ -469,41 +469,41 @@ discard block |
||
| 469 | 469 | // incoming data from serial or IP comms |
| 470 | 470 | public function process_ais_line($cbuf) { |
| 471 | 471 | $result = new stdClass(); |
| 472 | - $start = strpos($cbuf,"VDM"); |
|
| 472 | + $start = strpos($cbuf, "VDM"); |
|
| 473 | 473 | $tst = substr($cbuf, $start - 3); |
| 474 | - $result = $this->process_ais_raw( $tst, "" ); |
|
| 474 | + $result = $this->process_ais_raw($tst, ""); |
|
| 475 | 475 | return $result; |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | /* AIS Encoding |
| 479 | 479 | */ |
| 480 | - private function mk_ais_lat( $lat ) { |
|
| 480 | + private function mk_ais_lat($lat) { |
|
| 481 | 481 | //$lat = 1.2569; |
| 482 | - if ($lat<0.0) { |
|
| 482 | + if ($lat < 0.0) { |
|
| 483 | 483 | $lat = -$lat; |
| 484 | - $neg=true; |
|
| 485 | - } else $neg=false; |
|
| 484 | + $neg = true; |
|
| 485 | + } else $neg = false; |
|
| 486 | 486 | $latd = 0x00000000; |
| 487 | - $latd = intval ($lat * 600000.0); |
|
| 488 | - if ($neg==true) { |
|
| 487 | + $latd = intval($lat*600000.0); |
|
| 488 | + if ($neg == true) { |
|
| 489 | 489 | $latd = ~$latd; |
| 490 | - $latd+=1; |
|
| 490 | + $latd += 1; |
|
| 491 | 491 | $latd &= 0x07FFFFFF; |
| 492 | 492 | } |
| 493 | 493 | return $latd; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - private function mk_ais_lon( $lon ) { |
|
| 496 | + private function mk_ais_lon($lon) { |
|
| 497 | 497 | //$lon = 103.851; |
| 498 | - if ($lon<0.0) { |
|
| 498 | + if ($lon < 0.0) { |
|
| 499 | 499 | $lon = -$lon; |
| 500 | - $neg=true; |
|
| 501 | - } else $neg=false; |
|
| 500 | + $neg = true; |
|
| 501 | + } else $neg = false; |
|
| 502 | 502 | $lond = 0x00000000; |
| 503 | - $lond = intval ($lon * 600000.0); |
|
| 504 | - if ($neg==true) { |
|
| 503 | + $lond = intval($lon*600000.0); |
|
| 504 | + if ($neg == true) { |
|
| 505 | 505 | $lond = ~$lond; |
| 506 | - $lond+=1; |
|
| 506 | + $lond += 1; |
|
| 507 | 507 | $lond &= 0x0FFFFFFF; |
| 508 | 508 | } |
| 509 | 509 | return $lond; |
@@ -511,8 +511,8 @@ discard block |
||
| 511 | 511 | |
| 512 | 512 | private function char2bin($name, $max_len) { |
| 513 | 513 | $len = strlen($name); |
| 514 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
| 515 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 514 | + if ($len > $max_len) $name = substr($name, 0, $max_len); |
|
| 515 | + if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6); |
|
| 516 | 516 | else $pad = ''; |
| 517 | 517 | $rv = ''; |
| 518 | 518 | $ais_chars = array( |
@@ -529,26 +529,26 @@ discard block |
||
| 529 | 529 | if ($_a) foreach ($_a as $_1) { |
| 530 | 530 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
| 531 | 531 | else $dec = 0; |
| 532 | - $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
|
| 532 | + $bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT); |
|
| 533 | 533 | $rv .= $bin; |
| 534 | 534 | //echo "$_1 $dec ($bin)<br/>"; |
| 535 | 535 | } |
| 536 | 536 | return $rv.$pad; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') { |
|
| 539 | + private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') { |
|
| 540 | 540 | $len_bit = strlen($_enc); |
| 541 | - $rem6 = $len_bit % 6; |
|
| 541 | + $rem6 = $len_bit%6; |
|
| 542 | 542 | $pad6_len = 0; |
| 543 | 543 | if ($rem6) $pad6_len = 6 - $rem6; |
| 544 | 544 | //echo $pad6_len.'<br>'; |
| 545 | 545 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
| 546 | - $len_enc = strlen($_enc) / 6; |
|
| 546 | + $len_enc = strlen($_enc)/6; |
|
| 547 | 547 | //echo $_enc.' '.$len_enc.'<br/>'; |
| 548 | 548 | $itu = ''; |
| 549 | - for ($i=0; $i<$len_enc; $i++) { |
|
| 550 | - $offset = $i * 6; |
|
| 551 | - $dec = bindec(substr($_enc,$offset,6)); |
|
| 549 | + for ($i = 0; $i < $len_enc; $i++) { |
|
| 550 | + $offset = $i*6; |
|
| 551 | + $dec = bindec(substr($_enc, $offset, 6)); |
|
| 552 | 552 | if ($dec < 40) $dec += 48; |
| 553 | 553 | else $dec += 56; |
| 554 | 554 | //echo chr($dec)." $dec<br/>"; |
@@ -558,15 +558,15 @@ discard block |
||
| 558 | 558 | $chksum = 0; |
| 559 | 559 | $itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0"; |
| 560 | 560 | $len_itu = strlen($itu); |
| 561 | - for ($i=0; $i<$len_itu; $i++) { |
|
| 562 | - $chksum ^= ord( $itu[$i] ); |
|
| 561 | + for ($i = 0; $i < $len_itu; $i++) { |
|
| 562 | + $chksum ^= ord($itu[$i]); |
|
| 563 | 563 | } |
| 564 | - $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
| 565 | - $lsb = $chksum & 0x0F; |
|
| 566 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
| 564 | + $hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
| 565 | + $lsb = $chksum&0x0F; |
|
| 566 | + if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb]; |
|
| 567 | 567 | else $lsbc = '0'; |
| 568 | - $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
|
| 569 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
| 568 | + $msb = (($chksum&0xF0) >> 4)&0x0F; |
|
| 569 | + if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb]; |
|
| 570 | 570 | else $msbc = '0'; |
| 571 | 571 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
| 572 | 572 | return $itu; |
@@ -591,14 +591,14 @@ discard block |
||
| 591 | 591 | |
| 592 | 592 | public function mmsitype($mmsi) { |
| 593 | 593 | if (strlen($mmsi) == 9) { |
| 594 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
| 595 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
| 596 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
| 597 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
| 598 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
| 599 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
| 600 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
| 601 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
| 594 | + if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
| 595 | + elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device'; |
|
| 596 | + elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
| 597 | + elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
| 598 | + elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
| 599 | + elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation'; |
|
| 600 | + elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations'; |
|
| 601 | + elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships'; |
|
| 602 | 602 | else return 'Ship'; |
| 603 | 603 | } |
| 604 | 604 | |
@@ -609,19 +609,19 @@ discard block |
||
| 609 | 609 | global $globalDebug; |
| 610 | 610 | $result = array(); |
| 611 | 611 | $data = new stdClass(); |
| 612 | - $start = strpos($buffer,"VDM"); |
|
| 612 | + $start = strpos($buffer, "VDM"); |
|
| 613 | 613 | $tst = substr($buffer, $start - 3); |
| 614 | - $data = $this->process_ais_raw( $tst, "" ); |
|
| 614 | + $data = $this->process_ais_raw($tst, ""); |
|
| 615 | 615 | if (!is_object($data)) { |
| 616 | 616 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
| 617 | 617 | return array(); |
| 618 | 618 | } |
| 619 | 619 | if ($data->lon != 0) $result['longitude'] = $data->lon; |
| 620 | 620 | if ($data->lat != 0) $result['latitude'] = $data->lat; |
| 621 | - $result['ident'] = trim(str_replace('@','',$data->name)); |
|
| 621 | + $result['ident'] = trim(str_replace('@', '', $data->name)); |
|
| 622 | 622 | $result['timestamp'] = $data->ts; |
| 623 | 623 | $result['mmsi'] = $data->mmsi; |
| 624 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
| 624 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
| 625 | 625 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
| 626 | 626 | if ($data->sog != -1.0) $result['speed'] = $data->sog; |
| 627 | 627 | if ($data->heading !== '') $result['heading'] = $data->heading; |
@@ -631,16 +631,16 @@ discard block |
||
| 631 | 631 | if ($data->type !== '') $result['type'] = $data->type; |
| 632 | 632 | if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
| 633 | 633 | if ($data->imo !== '') $result['imo'] = $data->imo; |
| 634 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
| 634 | + if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign)); |
|
| 635 | 635 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
| 636 | - $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
| 636 | + $eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
| 637 | 637 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
| 638 | 638 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
| 639 | - $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
| 639 | + $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
| 640 | 640 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
| 641 | 641 | } |
| 642 | 642 | if ($data->destination != '') { |
| 643 | - $dest = trim(str_replace('@','',$data->destination)); |
|
| 643 | + $dest = trim(str_replace('@', '', $data->destination)); |
|
| 644 | 644 | if ($dest != '') $result['destination'] = $dest; |
| 645 | 645 | } |
| 646 | 646 | $result['all'] = (array) $data; |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | $temp += 1; |
| 36 | 36 | $flat = (float)($temp / (60.0 * 10000.0)); |
| 37 | 37 | $flat *= -1.0; |
| 38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 38 | + } else { |
|
| 39 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 40 | + } |
|
| 39 | 41 | return $flat; // float |
| 40 | 42 | } |
| 41 | 43 | |
@@ -47,7 +49,9 @@ discard block |
||
| 47 | 49 | $temp += 1; |
| 48 | 50 | $flon = (float)($temp / (60.0 * 10000.0)); |
| 49 | 51 | $flon *= -1.0; |
| 50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 52 | + } else { |
|
| 53 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 54 | + } |
|
| 51 | 55 | return $flon; |
| 52 | 56 | } |
| 53 | 57 | |
@@ -70,10 +74,8 @@ discard block |
||
| 70 | 74 | */ |
| 71 | 75 | private function asciidec_2_8bit($ascii) { |
| 72 | 76 | //only process in the following range: 48-87, 96-119 |
| 73 | - if ($ascii < 48) { } |
|
| 74 | - else { |
|
| 75 | - if($ascii>119) { } |
|
| 76 | - else { |
|
| 77 | + if ($ascii < 48) { } else { |
|
| 78 | + if($ascii>119) { } else { |
|
| 77 | 79 | if ($ascii>87 && $ascii<96) ; |
| 78 | 80 | else { |
| 79 | 81 | $ascii=$ascii+40; |
@@ -175,7 +177,9 @@ discard block |
||
| 175 | 177 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
| 176 | 178 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
| 177 | 179 | $ro->heading = bindec(substr($_aisdata,124,9)); |
| 178 | - if ($ro->heading == 511) $ro->heading = ''; |
|
| 180 | + if ($ro->heading == 511) { |
|
| 181 | + $ro->heading = ''; |
|
| 182 | + } |
|
| 179 | 183 | $ro->cls = 2; // class B |
| 180 | 184 | } else if ($ro->id == 19) { |
| 181 | 185 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -185,7 +189,9 @@ discard block |
||
| 185 | 189 | $ro->name = $this->binchar($_aisdata,143,120); |
| 186 | 190 | $ro->cls = 2; // class B |
| 187 | 191 | $ro->heading = bindec(substr($_aisdata,124,9)); |
| 188 | - if ($ro->heading == 511) $ro->heading = ''; |
|
| 192 | + if ($ro->heading == 511) { |
|
| 193 | + $ro->heading = ''; |
|
| 194 | + } |
|
| 189 | 195 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
| 190 | 196 | $ro->type = $this->getShipType($ro->typeid); |
| 191 | 197 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -216,9 +222,13 @@ discard block |
||
| 216 | 222 | $ro->cls = 2; // class B |
| 217 | 223 | } else if ($ro->id == 27) { |
| 218 | 224 | $ro->cog = bindec(substr($_aisdata,85,9)); |
| 219 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
| 225 | + if ($ro->cog == 511) { |
|
| 226 | + $ro->cog = 0.0; |
|
| 227 | + } |
|
| 220 | 228 | $ro->sog = bindec(substr($_aisdata,79,6)); |
| 221 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
| 229 | + if ($ro->sog == 63) { |
|
| 230 | + $ro->sog = 0.0; |
|
| 231 | + } |
|
| 222 | 232 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
| 223 | 233 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
| 224 | 234 | $ro->cls = 1; // class A |
@@ -267,88 +277,171 @@ discard block |
||
| 267 | 277 | } |
| 268 | 278 | |
| 269 | 279 | public function getShipType($code) { |
| 270 | - if ($code == 0) return 'Not available (default)'; |
|
| 271 | - elseif ($code >= 1 && $code <= 19) return 'Reserved for future use'; |
|
| 272 | - elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type'; |
|
| 273 | - elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A'; |
|
| 274 | - elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B'; |
|
| 275 | - elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C'; |
|
| 276 | - elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D'; |
|
| 277 | - elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use'; |
|
| 278 | - elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use'; |
|
| 279 | - elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use'; |
|
| 280 | - elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use'; |
|
| 281 | - elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use'; |
|
| 282 | - elseif ($code == 30) return 'Fishing'; |
|
| 283 | - elseif ($code == 31) return 'Towing'; |
|
| 284 | - elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
| 285 | - elseif ($code == 33) return 'Dredging or underwater ops'; |
|
| 286 | - elseif ($code == 34) return 'Diving ops'; |
|
| 287 | - elseif ($code == 35) return 'Military ops'; |
|
| 288 | - elseif ($code == 36) return 'Sailing'; |
|
| 289 | - elseif ($code == 37) return 'Pleasure Craft'; |
|
| 290 | - elseif ($code == 38) return 'Reserved'; |
|
| 291 | - elseif ($code == 39) return 'Reserved'; |
|
| 292 | - elseif ($code == 40) return 'High speed craft (HSC), all ships of this type'; |
|
| 293 | - elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A'; |
|
| 294 | - elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B'; |
|
| 295 | - elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C'; |
|
| 296 | - elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D'; |
|
| 297 | - elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use'; |
|
| 298 | - elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use'; |
|
| 299 | - elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use'; |
|
| 300 | - elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use'; |
|
| 301 | - elseif ($code == 49) return 'High speed craft (HSC), No additional information'; |
|
| 302 | - elseif ($code == 50) return 'Pilot Vessel'; |
|
| 303 | - elseif ($code == 51) return 'Search and Rescue vessel'; |
|
| 304 | - elseif ($code == 52) return 'Tug'; |
|
| 305 | - elseif ($code == 53) return 'Port Tender'; |
|
| 306 | - elseif ($code == 54) return 'Anti-pollution equipment'; |
|
| 307 | - elseif ($code == 55) return 'Law Enforcement'; |
|
| 308 | - elseif ($code == 56) return 'Spare - Local Vessel'; |
|
| 309 | - elseif ($code == 57) return 'Spare - Local Vessel'; |
|
| 310 | - elseif ($code == 58) return 'Medical Transport'; |
|
| 311 | - elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18'; |
|
| 312 | - elseif ($code == 60) return 'Passenger, all ships of this type'; |
|
| 313 | - elseif ($code == 61) return 'Passenger, Hazardous category A'; |
|
| 314 | - elseif ($code == 62) return 'Passenger, Hazardous category B'; |
|
| 315 | - elseif ($code == 63) return 'Passenger, Hazardous category C'; |
|
| 316 | - elseif ($code == 64) return 'Passenger, Hazardous category D'; |
|
| 317 | - elseif ($code == 65) return 'Passenger, Reserved for future use'; |
|
| 318 | - elseif ($code == 66) return 'Passenger, Reserved for future use'; |
|
| 319 | - elseif ($code == 67) return 'Passenger, Reserved for future use'; |
|
| 320 | - elseif ($code == 68) return 'Passenger, Reserved for future use'; |
|
| 321 | - elseif ($code == 69) return 'Passenger, No additional information'; |
|
| 322 | - elseif ($code == 70) return 'Cargo, all ships of this type'; |
|
| 323 | - elseif ($code == 71) return 'Cargo, Hazardous category A'; |
|
| 324 | - elseif ($code == 72) return 'Cargo, Hazardous category B'; |
|
| 325 | - elseif ($code == 73) return 'Cargo, Hazardous category C'; |
|
| 326 | - elseif ($code == 74) return 'Cargo, Hazardous category D'; |
|
| 327 | - elseif ($code == 75) return 'Cargo, Reserved for future use'; |
|
| 328 | - elseif ($code == 76) return 'Cargo, Reserved for future use'; |
|
| 329 | - elseif ($code == 77) return 'Cargo, Reserved for future use'; |
|
| 330 | - elseif ($code == 78) return 'Cargo, Reserved for future use'; |
|
| 331 | - elseif ($code == 79) return 'Cargo, No additional information'; |
|
| 332 | - elseif ($code == 80) return 'Tanker, all ships of this type'; |
|
| 333 | - elseif ($code == 81) return 'Tanker, Hazardous category A'; |
|
| 334 | - elseif ($code == 82) return 'Tanker, Hazardous category B'; |
|
| 335 | - elseif ($code == 83) return 'Tanker, Hazardous category C'; |
|
| 336 | - elseif ($code == 84) return 'Tanker, Hazardous category D'; |
|
| 337 | - elseif ($code == 85) return 'Tanker, Reserved for future use'; |
|
| 338 | - elseif ($code == 86) return 'Tanker, Reserved for future use'; |
|
| 339 | - elseif ($code == 87) return 'Tanker, Reserved for future use'; |
|
| 340 | - elseif ($code == 88) return 'Tanker, Reserved for future use'; |
|
| 341 | - elseif ($code == 89) return 'Tanker, No additional information'; |
|
| 342 | - elseif ($code == 90) return 'Other Type, all ships of this type'; |
|
| 343 | - elseif ($code == 91) return 'Other Type, Hazardous category A'; |
|
| 344 | - elseif ($code == 92) return 'Other Type, Hazardous category B'; |
|
| 345 | - elseif ($code == 93) return 'Other Type, Hazardous category C'; |
|
| 346 | - elseif ($code == 94) return 'Other Type, Hazardous category D'; |
|
| 347 | - elseif ($code == 95) return 'Other Type, Reserved for future use'; |
|
| 348 | - elseif ($code == 96) return 'Other Type, Reserved for future use'; |
|
| 349 | - elseif ($code == 97) return 'Other Type, Reserved for future use'; |
|
| 350 | - elseif ($code == 98) return 'Other Type, Reserved for future use'; |
|
| 351 | - elseif ($code == 99) return 'Other Type, no additional information'; |
|
| 280 | + if ($code == 0) { |
|
| 281 | + return 'Not available (default)'; |
|
| 282 | + } elseif ($code >= 1 && $code <= 19) { |
|
| 283 | + return 'Reserved for future use'; |
|
| 284 | + } elseif ($code == 20) { |
|
| 285 | + return 'Wing in ground (WIG), all ships of this type'; |
|
| 286 | + } elseif ($code == 21) { |
|
| 287 | + return 'Wing in ground (WIG), Hazardous category A'; |
|
| 288 | + } elseif ($code == 22) { |
|
| 289 | + return 'Wing in ground (WIG), Hazardous category B'; |
|
| 290 | + } elseif ($code == 23) { |
|
| 291 | + return 'Wing in ground (WIG), Hazardous category C'; |
|
| 292 | + } elseif ($code == 24) { |
|
| 293 | + return 'Wing in ground (WIG), Hazardous category D'; |
|
| 294 | + } elseif ($code == 25) { |
|
| 295 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
| 296 | + } elseif ($code == 26) { |
|
| 297 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
| 298 | + } elseif ($code == 27) { |
|
| 299 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
| 300 | + } elseif ($code == 28) { |
|
| 301 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
| 302 | + } elseif ($code == 29) { |
|
| 303 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
| 304 | + } elseif ($code == 30) { |
|
| 305 | + return 'Fishing'; |
|
| 306 | + } elseif ($code == 31) { |
|
| 307 | + return 'Towing'; |
|
| 308 | + } elseif ($code == 32) { |
|
| 309 | + return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
| 310 | + } elseif ($code == 33) { |
|
| 311 | + return 'Dredging or underwater ops'; |
|
| 312 | + } elseif ($code == 34) { |
|
| 313 | + return 'Diving ops'; |
|
| 314 | + } elseif ($code == 35) { |
|
| 315 | + return 'Military ops'; |
|
| 316 | + } elseif ($code == 36) { |
|
| 317 | + return 'Sailing'; |
|
| 318 | + } elseif ($code == 37) { |
|
| 319 | + return 'Pleasure Craft'; |
|
| 320 | + } elseif ($code == 38) { |
|
| 321 | + return 'Reserved'; |
|
| 322 | + } elseif ($code == 39) { |
|
| 323 | + return 'Reserved'; |
|
| 324 | + } elseif ($code == 40) { |
|
| 325 | + return 'High speed craft (HSC), all ships of this type'; |
|
| 326 | + } elseif ($code == 41) { |
|
| 327 | + return 'High speed craft (HSC), Hazardous category A'; |
|
| 328 | + } elseif ($code == 42) { |
|
| 329 | + return 'High speed craft (HSC), Hazardous category B'; |
|
| 330 | + } elseif ($code == 43) { |
|
| 331 | + return 'High speed craft (HSC), Hazardous category C'; |
|
| 332 | + } elseif ($code == 44) { |
|
| 333 | + return 'High speed craft (HSC), Hazardous category D'; |
|
| 334 | + } elseif ($code == 45) { |
|
| 335 | + return 'High speed craft (HSC), Reserved for future use'; |
|
| 336 | + } elseif ($code == 46) { |
|
| 337 | + return 'High speed craft (HSC), Reserved for future use'; |
|
| 338 | + } elseif ($code == 47) { |
|
| 339 | + return 'High speed craft (HSC), Reserved for future use'; |
|
| 340 | + } elseif ($code == 48) { |
|
| 341 | + return 'High speed craft (HSC), Reserved for future use'; |
|
| 342 | + } elseif ($code == 49) { |
|
| 343 | + return 'High speed craft (HSC), No additional information'; |
|
| 344 | + } elseif ($code == 50) { |
|
| 345 | + return 'Pilot Vessel'; |
|
| 346 | + } elseif ($code == 51) { |
|
| 347 | + return 'Search and Rescue vessel'; |
|
| 348 | + } elseif ($code == 52) { |
|
| 349 | + return 'Tug'; |
|
| 350 | + } elseif ($code == 53) { |
|
| 351 | + return 'Port Tender'; |
|
| 352 | + } elseif ($code == 54) { |
|
| 353 | + return 'Anti-pollution equipment'; |
|
| 354 | + } elseif ($code == 55) { |
|
| 355 | + return 'Law Enforcement'; |
|
| 356 | + } elseif ($code == 56) { |
|
| 357 | + return 'Spare - Local Vessel'; |
|
| 358 | + } elseif ($code == 57) { |
|
| 359 | + return 'Spare - Local Vessel'; |
|
| 360 | + } elseif ($code == 58) { |
|
| 361 | + return 'Medical Transport'; |
|
| 362 | + } elseif ($code == 59) { |
|
| 363 | + return 'Noncombatant ship according to RR Resolution No. 18'; |
|
| 364 | + } elseif ($code == 60) { |
|
| 365 | + return 'Passenger, all ships of this type'; |
|
| 366 | + } elseif ($code == 61) { |
|
| 367 | + return 'Passenger, Hazardous category A'; |
|
| 368 | + } elseif ($code == 62) { |
|
| 369 | + return 'Passenger, Hazardous category B'; |
|
| 370 | + } elseif ($code == 63) { |
|
| 371 | + return 'Passenger, Hazardous category C'; |
|
| 372 | + } elseif ($code == 64) { |
|
| 373 | + return 'Passenger, Hazardous category D'; |
|
| 374 | + } elseif ($code == 65) { |
|
| 375 | + return 'Passenger, Reserved for future use'; |
|
| 376 | + } elseif ($code == 66) { |
|
| 377 | + return 'Passenger, Reserved for future use'; |
|
| 378 | + } elseif ($code == 67) { |
|
| 379 | + return 'Passenger, Reserved for future use'; |
|
| 380 | + } elseif ($code == 68) { |
|
| 381 | + return 'Passenger, Reserved for future use'; |
|
| 382 | + } elseif ($code == 69) { |
|
| 383 | + return 'Passenger, No additional information'; |
|
| 384 | + } elseif ($code == 70) { |
|
| 385 | + return 'Cargo, all ships of this type'; |
|
| 386 | + } elseif ($code == 71) { |
|
| 387 | + return 'Cargo, Hazardous category A'; |
|
| 388 | + } elseif ($code == 72) { |
|
| 389 | + return 'Cargo, Hazardous category B'; |
|
| 390 | + } elseif ($code == 73) { |
|
| 391 | + return 'Cargo, Hazardous category C'; |
|
| 392 | + } elseif ($code == 74) { |
|
| 393 | + return 'Cargo, Hazardous category D'; |
|
| 394 | + } elseif ($code == 75) { |
|
| 395 | + return 'Cargo, Reserved for future use'; |
|
| 396 | + } elseif ($code == 76) { |
|
| 397 | + return 'Cargo, Reserved for future use'; |
|
| 398 | + } elseif ($code == 77) { |
|
| 399 | + return 'Cargo, Reserved for future use'; |
|
| 400 | + } elseif ($code == 78) { |
|
| 401 | + return 'Cargo, Reserved for future use'; |
|
| 402 | + } elseif ($code == 79) { |
|
| 403 | + return 'Cargo, No additional information'; |
|
| 404 | + } elseif ($code == 80) { |
|
| 405 | + return 'Tanker, all ships of this type'; |
|
| 406 | + } elseif ($code == 81) { |
|
| 407 | + return 'Tanker, Hazardous category A'; |
|
| 408 | + } elseif ($code == 82) { |
|
| 409 | + return 'Tanker, Hazardous category B'; |
|
| 410 | + } elseif ($code == 83) { |
|
| 411 | + return 'Tanker, Hazardous category C'; |
|
| 412 | + } elseif ($code == 84) { |
|
| 413 | + return 'Tanker, Hazardous category D'; |
|
| 414 | + } elseif ($code == 85) { |
|
| 415 | + return 'Tanker, Reserved for future use'; |
|
| 416 | + } elseif ($code == 86) { |
|
| 417 | + return 'Tanker, Reserved for future use'; |
|
| 418 | + } elseif ($code == 87) { |
|
| 419 | + return 'Tanker, Reserved for future use'; |
|
| 420 | + } elseif ($code == 88) { |
|
| 421 | + return 'Tanker, Reserved for future use'; |
|
| 422 | + } elseif ($code == 89) { |
|
| 423 | + return 'Tanker, No additional information'; |
|
| 424 | + } elseif ($code == 90) { |
|
| 425 | + return 'Other Type, all ships of this type'; |
|
| 426 | + } elseif ($code == 91) { |
|
| 427 | + return 'Other Type, Hazardous category A'; |
|
| 428 | + } elseif ($code == 92) { |
|
| 429 | + return 'Other Type, Hazardous category B'; |
|
| 430 | + } elseif ($code == 93) { |
|
| 431 | + return 'Other Type, Hazardous category C'; |
|
| 432 | + } elseif ($code == 94) { |
|
| 433 | + return 'Other Type, Hazardous category D'; |
|
| 434 | + } elseif ($code == 95) { |
|
| 435 | + return 'Other Type, Reserved for future use'; |
|
| 436 | + } elseif ($code == 96) { |
|
| 437 | + return 'Other Type, Reserved for future use'; |
|
| 438 | + } elseif ($code == 97) { |
|
| 439 | + return 'Other Type, Reserved for future use'; |
|
| 440 | + } elseif ($code == 98) { |
|
| 441 | + return 'Other Type, Reserved for future use'; |
|
| 442 | + } elseif ($code == 99) { |
|
| 443 | + return 'Other Type, no additional information'; |
|
| 444 | + } |
|
| 352 | 445 | } |
| 353 | 446 | |
| 354 | 447 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -386,19 +479,34 @@ discard block |
||
| 386 | 479 | // assume 1st ! is valid |
| 387 | 480 | // find * ensure that it is at correct position |
| 388 | 481 | $end = strrpos ( $rawdata , '*' ); |
| 389 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
| 482 | + if ($end === FALSE) { |
|
| 483 | + return -1; |
|
| 484 | + } |
|
| 485 | + // check for NULLS!!! |
|
| 390 | 486 | $cs = substr( $rawdata, $end + 1 ); |
| 391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
| 487 | + if ( strlen($cs) != 2 ) { |
|
| 488 | + return -1; |
|
| 489 | + } |
|
| 490 | + // correct cs length |
|
| 392 | 491 | $dcs = (int)hexdec( $cs ); |
| 393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
| 492 | + for ( $alias=1; $alias<$end; $alias++) { |
|
| 493 | + $chksum ^= ord( $rawdata[$alias] ); |
|
| 494 | + } |
|
| 495 | + // perform XOR for NMEA checksum |
|
| 394 | 496 | if ( $chksum == $dcs ) { // NMEA checksum pass |
| 395 | 497 | $pcs = explode(',', $rawdata); |
| 396 | 498 | // !AI??? identifier |
| 397 | 499 | $num_seq = (int)$pcs[1]; // number of sequences |
| 398 | 500 | $seq = (int)$pcs[2]; // get sequence |
| 399 | 501 | // get msg sequence id |
| 400 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
| 401 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
| 502 | + if ($pcs[3] == '') { |
|
| 503 | + $msg_sid = -1; |
|
| 504 | + } |
|
| 505 | + // non-multipart message, set to -1 |
|
| 506 | + else { |
|
| 507 | + $msg_sid = (int)$pcs[3]; |
|
| 508 | + } |
|
| 509 | + // multipart message |
|
| 402 | 510 | $ais_ch = $pcs[4]; // get AIS channel |
| 403 | 511 | // message sequence checking |
| 404 | 512 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -459,10 +567,18 @@ discard block |
||
| 459 | 567 | //DEBUG echo "[$start $end $tst]\n"; |
| 460 | 568 | $result = $this->process_ais_raw( $tst, "" ); |
| 461 | 569 | $last_pos = $end + 1; |
| 462 | - } else break; |
|
| 570 | + } else { |
|
| 571 | + break; |
|
| 572 | + } |
|
| 573 | + } |
|
| 574 | + if ($last_pos > 0) { |
|
| 575 | + $cbuf = substr($cbuf, $last_pos); |
|
| 576 | + } |
|
| 577 | + // move... |
|
| 578 | + if (strlen($cbuf) > 1024) { |
|
| 579 | + $cbuf = ""; |
|
| 463 | 580 | } |
| 464 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
| 465 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
| 581 | + // prevent overflow simple mode... |
|
| 466 | 582 | return $result; |
| 467 | 583 | } |
| 468 | 584 | |
@@ -482,7 +598,9 @@ discard block |
||
| 482 | 598 | if ($lat<0.0) { |
| 483 | 599 | $lat = -$lat; |
| 484 | 600 | $neg=true; |
| 485 | - } else $neg=false; |
|
| 601 | + } else { |
|
| 602 | + $neg=false; |
|
| 603 | + } |
|
| 486 | 604 | $latd = 0x00000000; |
| 487 | 605 | $latd = intval ($lat * 600000.0); |
| 488 | 606 | if ($neg==true) { |
@@ -498,7 +616,9 @@ discard block |
||
| 498 | 616 | if ($lon<0.0) { |
| 499 | 617 | $lon = -$lon; |
| 500 | 618 | $neg=true; |
| 501 | - } else $neg=false; |
|
| 619 | + } else { |
|
| 620 | + $neg=false; |
|
| 621 | + } |
|
| 502 | 622 | $lond = 0x00000000; |
| 503 | 623 | $lond = intval ($lon * 600000.0); |
| 504 | 624 | if ($neg==true) { |
@@ -511,9 +631,14 @@ discard block |
||
| 511 | 631 | |
| 512 | 632 | private function char2bin($name, $max_len) { |
| 513 | 633 | $len = strlen($name); |
| 514 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
| 515 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 516 | - else $pad = ''; |
|
| 634 | + if ($len > $max_len) { |
|
| 635 | + $name = substr($name,0,$max_len); |
|
| 636 | + } |
|
| 637 | + if ($len < $max_len) { |
|
| 638 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 639 | + } else { |
|
| 640 | + $pad = ''; |
|
| 641 | + } |
|
| 517 | 642 | $rv = ''; |
| 518 | 643 | $ais_chars = array( |
| 519 | 644 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -526,9 +651,12 @@ discard block |
||
| 526 | 651 | ); |
| 527 | 652 | // " |
| 528 | 653 | $_a = str_split($name); |
| 529 | - if ($_a) foreach ($_a as $_1) { |
|
| 654 | + if ($_a) { |
|
| 655 | + foreach ($_a as $_1) { |
|
| 530 | 656 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
| 531 | - else $dec = 0; |
|
| 657 | + } else { |
|
| 658 | + $dec = 0; |
|
| 659 | + } |
|
| 532 | 660 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
| 533 | 661 | $rv .= $bin; |
| 534 | 662 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -540,7 +668,9 @@ discard block |
||
| 540 | 668 | $len_bit = strlen($_enc); |
| 541 | 669 | $rem6 = $len_bit % 6; |
| 542 | 670 | $pad6_len = 0; |
| 543 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
| 671 | + if ($rem6) { |
|
| 672 | + $pad6_len = 6 - $rem6; |
|
| 673 | + } |
|
| 544 | 674 | //echo $pad6_len.'<br>'; |
| 545 | 675 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
| 546 | 676 | $len_enc = strlen($_enc) / 6; |
@@ -549,8 +679,11 @@ discard block |
||
| 549 | 679 | for ($i=0; $i<$len_enc; $i++) { |
| 550 | 680 | $offset = $i * 6; |
| 551 | 681 | $dec = bindec(substr($_enc,$offset,6)); |
| 552 | - if ($dec < 40) $dec += 48; |
|
| 553 | - else $dec += 56; |
|
| 682 | + if ($dec < 40) { |
|
| 683 | + $dec += 48; |
|
| 684 | + } else { |
|
| 685 | + $dec += 56; |
|
| 686 | + } |
|
| 554 | 687 | //echo chr($dec)." $dec<br/>"; |
| 555 | 688 | $itu .= chr($dec); |
| 556 | 689 | } |
@@ -563,25 +696,41 @@ discard block |
||
| 563 | 696 | } |
| 564 | 697 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
| 565 | 698 | $lsb = $chksum & 0x0F; |
| 566 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
| 567 | - else $lsbc = '0'; |
|
| 699 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
| 700 | + $lsbc = $hex_arr[$lsb]; |
|
| 701 | + } else { |
|
| 702 | + $lsbc = '0'; |
|
| 703 | + } |
|
| 568 | 704 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
| 569 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
| 570 | - else $msbc = '0'; |
|
| 705 | + if ($msb >=0 && $msb <= 15 ) { |
|
| 706 | + $msbc = $hex_arr[$msb]; |
|
| 707 | + } else { |
|
| 708 | + $msbc = '0'; |
|
| 709 | + } |
|
| 571 | 710 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
| 572 | 711 | return $itu; |
| 573 | 712 | } |
| 574 | 713 | |
| 575 | 714 | public function parse($buffer) { |
| 576 | 715 | $data = $this->process_ais_buf($buffer); |
| 577 | - if (!is_object($data)) return array(); |
|
| 578 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
| 579 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
| 716 | + if (!is_object($data)) { |
|
| 717 | + return array(); |
|
| 718 | + } |
|
| 719 | + if ($data->lon != 0) { |
|
| 720 | + $result['longitude'] = $data->lon; |
|
| 721 | + } |
|
| 722 | + if ($data->lat != 0) { |
|
| 723 | + $result['latitude'] = $data->lat; |
|
| 724 | + } |
|
| 580 | 725 | $result['ident'] = trim($data->name); |
| 581 | 726 | $result['timestamp'] = $data->ts; |
| 582 | 727 | $result['mmsi'] = $data->mmsi; |
| 583 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
| 584 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
| 728 | + if ($data->sog != -1.0) { |
|
| 729 | + $result['speed'] = $data->sog; |
|
| 730 | + } |
|
| 731 | + if ($data->cog != 0) { |
|
| 732 | + $result['heading'] = $data->cog; |
|
| 733 | + } |
|
| 585 | 734 | /* |
| 586 | 735 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
| 587 | 736 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -591,15 +740,25 @@ discard block |
||
| 591 | 740 | |
| 592 | 741 | public function mmsitype($mmsi) { |
| 593 | 742 | if (strlen($mmsi) == 9) { |
| 594 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
| 595 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
| 596 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
| 597 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
| 598 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
| 599 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
| 600 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
| 601 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
| 602 | - else return 'Ship'; |
|
| 743 | + if (substr($mmsi,0,3) == '974') { |
|
| 744 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
| 745 | + } elseif (substr($mmsi,0,3) == '972') { |
|
| 746 | + return 'MOB (Man Overboard) device'; |
|
| 747 | + } elseif (substr($mmsi,0,3) == '970') { |
|
| 748 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
| 749 | + } elseif (substr($mmsi,0,3) == '111') { |
|
| 750 | + return 'SAR (Search and Rescue) aircraft'; |
|
| 751 | + } elseif (substr($mmsi,0,2) == '98') { |
|
| 752 | + return 'Auxiliary craft associated with a parent ship'; |
|
| 753 | + } elseif (substr($mmsi,0,2) == '99') { |
|
| 754 | + return 'Aids to Navigation'; |
|
| 755 | + } elseif (substr($mmsi,0,2) == '00') { |
|
| 756 | + return 'Coastal stations'; |
|
| 757 | + } elseif (substr($mmsi,0,1) == '0') { |
|
| 758 | + return 'Group of ships'; |
|
| 759 | + } else { |
|
| 760 | + return 'Ship'; |
|
| 761 | + } |
|
| 603 | 762 | } |
| 604 | 763 | |
| 605 | 764 | |
@@ -616,32 +775,61 @@ discard block |
||
| 616 | 775 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
| 617 | 776 | return array(); |
| 618 | 777 | } |
| 619 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
| 620 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
| 778 | + if ($data->lon != 0) { |
|
| 779 | + $result['longitude'] = $data->lon; |
|
| 780 | + } |
|
| 781 | + if ($data->lat != 0) { |
|
| 782 | + $result['latitude'] = $data->lat; |
|
| 783 | + } |
|
| 621 | 784 | $result['ident'] = trim(str_replace('@','',$data->name)); |
| 622 | 785 | $result['timestamp'] = $data->ts; |
| 623 | 786 | $result['mmsi'] = $data->mmsi; |
| 624 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
| 787 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
| 788 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
| 789 | + } |
|
| 625 | 790 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
| 626 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
| 627 | - if ($data->heading !== '') $result['heading'] = $data->heading; |
|
| 628 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
| 629 | - if ($data->status != '') $result['status'] = $data->status; |
|
| 630 | - if ($data->statusid !== '') $result['statusid'] = $data->statusid; |
|
| 631 | - if ($data->type !== '') $result['type'] = $data->type; |
|
| 632 | - if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
|
| 633 | - if ($data->imo !== '') $result['imo'] = $data->imo; |
|
| 634 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
| 791 | + if ($data->sog != -1.0) { |
|
| 792 | + $result['speed'] = $data->sog; |
|
| 793 | + } |
|
| 794 | + if ($data->heading !== '') { |
|
| 795 | + $result['heading'] = $data->heading; |
|
| 796 | + } elseif ($data->cog != 0) { |
|
| 797 | + $result['heading'] = $data->cog; |
|
| 798 | + } |
|
| 799 | + if ($data->status != '') { |
|
| 800 | + $result['status'] = $data->status; |
|
| 801 | + } |
|
| 802 | + if ($data->statusid !== '') { |
|
| 803 | + $result['statusid'] = $data->statusid; |
|
| 804 | + } |
|
| 805 | + if ($data->type !== '') { |
|
| 806 | + $result['type'] = $data->type; |
|
| 807 | + } |
|
| 808 | + if ($data->typeid !== '') { |
|
| 809 | + $result['typeid'] = $data->typeid; |
|
| 810 | + } |
|
| 811 | + if ($data->imo !== '') { |
|
| 812 | + $result['imo'] = $data->imo; |
|
| 813 | + } |
|
| 814 | + if ($data->callsign !== '') { |
|
| 815 | + $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
| 816 | + } |
|
| 635 | 817 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
| 636 | 818 | $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
| 637 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
| 819 | + if ($eta_ts != '') { |
|
| 820 | + $result['eta_ts'] = $eta_ts; |
|
| 821 | + } |
|
| 638 | 822 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
| 639 | 823 | $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
| 640 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
| 824 | + if ($eta_ts != '') { |
|
| 825 | + $result['eta_ts'] = $eta_ts; |
|
| 826 | + } |
|
| 641 | 827 | } |
| 642 | 828 | if ($data->destination != '') { |
| 643 | 829 | $dest = trim(str_replace('@','',$data->destination)); |
| 644 | - if ($dest != '') $result['destination'] = $dest; |
|
| 830 | + if ($dest != '') { |
|
| 831 | + $result['destination'] = $dest; |
|
| 832 | + } |
|
| 645 | 833 | } |
| 646 | 834 | $result['all'] = (array) $data; |
| 647 | 835 | /* |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
| 3 | -$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
|
| 3 | +$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING); |
|
| 4 | 4 | if ($date == '') $date = date('Y-m-d'); |
| 5 | 5 | header('Location: '.$globalURL.'/accident/'.$date); |
| 6 | 6 | ?> |
| 7 | 7 | \ No newline at end of file |
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
| 3 | 3 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
| 4 | -if ($date == '') $date = date('Y-m-d'); |
|
| 4 | +if ($date == '') { |
|
| 5 | + $date = date('Y-m-d'); |
|
| 6 | +} |
|
| 5 | 7 | header('Location: '.$globalURL.'/accident/'.$date); |
| 6 | 8 | ?> |
| 7 | 9 | \ No newline at end of file |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 20 | 20 | $year_data = ''; |
| 21 | 21 | $year_cnt = ''; |
| 22 | -foreach($date_array as $year_item) |
|
| 22 | +foreach ($date_array as $year_item) |
|
| 23 | 23 | { |
| 24 | 24 | $year_data .= '"'.$year_item['year'].'-01-01",'; |
| 25 | 25 | $year_cnt .= $year_item['count'].','; |
| 26 | 26 | } |
| 27 | 27 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
| 28 | -$year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
|
| 28 | +$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]"; |
|
| 29 | 29 | print 'c3.generate({ |
| 30 | 30 | bindto: "#chart", |
| 31 | 31 | data: { x: "x", |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | if (!empty($date_array)) |
| 37 | 37 | { |
| 38 | - foreach($date_array as $key => $row) { |
|
| 38 | + foreach ($date_array as $key => $row) { |
|
| 39 | 39 | $years[$key] = $row['year']; |
| 40 | 40 | $counts[$key] = $row['count']; |
| 41 | 41 | } |
| 42 | 42 | //array_multisort($years,SORT_DESC,$date_array); |
| 43 | - array_multisort($counts,SORT_DESC,$date_array); |
|
| 43 | + array_multisort($counts, SORT_DESC, $date_array); |
|
| 44 | 44 | print '<div class="table-responsive">'; |
| 45 | 45 | print '<table class="common-date table-striped">'; |
| 46 | 46 | print '<thead>'; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | print '</thead>'; |
| 51 | 51 | print '<tbody>'; |
| 52 | 52 | $i = 1; |
| 53 | - foreach($date_array as $date_item) |
|
| 53 | + foreach ($date_array as $date_item) |
|
| 54 | 54 | { |
| 55 | 55 | print '<tr>'; |
| 56 | 56 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $route_array = $Spotter->countAllRoutes(); |
| 19 | 19 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 20 | 20 | $route_data = ''; |
| 21 | -foreach($route_array as $route_item) |
|
| 21 | +foreach ($route_array as $route_item) |
|
| 22 | 22 | { |
| 23 | 23 | $route_data .= '[ "'.$route_item['airport_departure_icao'].' - '.$route_item['airport_arrival_icao'].'",'.$route_item['route_count'].'],'; |
| 24 | 24 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | print '</thead>'; |
| 47 | 47 | print '<tbody>'; |
| 48 | 48 | $i = 1; |
| 49 | - foreach($route_array as $route_item) |
|
| 49 | + foreach ($route_array as $route_item) |
|
| 50 | 50 | { |
| 51 | 51 | print '<tr>'; |
| 52 | 52 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -5,7 +5,9 @@ |
||
| 5 | 5 | $Spotter = new Spotter(); |
| 6 | 6 | $title = _("Statistics").' - '._("Most common Route by Airport"); |
| 7 | 7 | require_once('header.php'); |
| 8 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 8 | +if (!isset($filter_name)) { |
|
| 9 | + $filter_name = ''; |
|
| 10 | +} |
|
| 9 | 11 | include('statistics-sub-menu.php'); |
| 10 | 12 | |
| 11 | 13 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |