@@ -14,18 +14,18 @@ discard block |
||
| 14 | 14 | else $type = 'global'; |
| 15 | 15 | |
| 16 | 16 | //calculuation for the pagination |
| 17 | -if(!isset($_GET['limit'])) |
|
| 17 | +if (!isset($_GET['limit'])) |
|
| 18 | 18 | { |
| 19 | 19 | $limit_start = 0; |
| 20 | 20 | $limit_end = 25; |
| 21 | 21 | $absolute_difference = 25; |
| 22 | -} else { |
|
| 22 | +} else { |
|
| 23 | 23 | $limit_explode = explode(",", $_GET['limit']); |
| 24 | 24 | $limit_start = $limit_explode[0]; |
| 25 | 25 | $limit_end = $limit_explode[1]; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 28 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 29 | 29 | |
| 30 | 30 | $absolute_difference = abs($limit_start - $limit_end); |
| 31 | 31 | $limit_next = $limit_end + $absolute_difference; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | if (!empty($anews)) |
| 60 | 60 | { |
| 61 | 61 | $j = 0; |
| 62 | - foreach($anews as $news) { |
|
| 62 | + foreach ($anews as $news) { |
|
| 63 | 63 | if ($j > 10) break; |
| 64 | 64 | $j++; |
| 65 | 65 | print '<div class="news">'; |
@@ -7,11 +7,17 @@ discard block |
||
| 7 | 7 | $title = _("News"); |
| 8 | 8 | require_once('header.php'); |
| 9 | 9 | |
| 10 | -if (isset($_GET['tracker'])) $type = 'tracker'; |
|
| 11 | -elseif (isset($_GET['marine'])) $type = 'marine'; |
|
| 12 | -elseif (isset($_GET['aircraft'])) $type = 'aircraft'; |
|
| 13 | -elseif (isset($_GET['satellite'])) $type = 'satellite'; |
|
| 14 | -else $type = 'global'; |
|
| 10 | +if (isset($_GET['tracker'])) { |
|
| 11 | + $type = 'tracker'; |
|
| 12 | +} elseif (isset($_GET['marine'])) { |
|
| 13 | + $type = 'marine'; |
|
| 14 | +} elseif (isset($_GET['aircraft'])) { |
|
| 15 | + $type = 'aircraft'; |
|
| 16 | +} elseif (isset($_GET['satellite'])) { |
|
| 17 | + $type = 'satellite'; |
|
| 18 | +} else { |
|
| 19 | + $type = 'global'; |
|
| 20 | +} |
|
| 15 | 21 | |
| 16 | 22 | //calculuation for the pagination |
| 17 | 23 | if(!isset($_GET['limit'])) |
@@ -19,7 +25,7 @@ discard block |
||
| 19 | 25 | $limit_start = 0; |
| 20 | 26 | $limit_end = 25; |
| 21 | 27 | $absolute_difference = 25; |
| 22 | -} else { |
|
| 28 | +} else { |
|
| 23 | 29 | $limit_explode = explode(",", $_GET['limit']); |
| 24 | 30 | $limit_start = $limit_explode[0]; |
| 25 | 31 | $limit_end = $limit_explode[1]; |
@@ -46,9 +52,12 @@ discard block |
||
| 46 | 52 | $feeds = $globalNewsFeeds[$type]; |
| 47 | 53 | } else { |
| 48 | 54 | $lg = $lang[1]; |
| 49 | - if (isset($globalNewsFeeds[$type][$lg])) $feeds = $globalNewsFeeds[$type][$lg]; |
|
| 50 | - else $feeds = array_shift($globalNewsFeeds[$type]); |
|
| 51 | -} |
|
| 55 | + if (isset($globalNewsFeeds[$type][$lg])) { |
|
| 56 | + $feeds = $globalNewsFeeds[$type][$lg]; |
|
| 57 | + } else { |
|
| 58 | + $feeds = array_shift($globalNewsFeeds[$type]); |
|
| 59 | + } |
|
| 60 | + } |
|
| 52 | 61 | |
| 53 | 62 | $SimplePie->set_feed_url($feeds); |
| 54 | 63 | $SimplePie->set_cache_duration(3600); |
@@ -60,7 +69,9 @@ discard block |
||
| 60 | 69 | { |
| 61 | 70 | $j = 0; |
| 62 | 71 | foreach($anews as $news) { |
| 63 | - if ($j > 10) break; |
|
| 72 | + if ($j > 10) { |
|
| 73 | + break; |
|
| 74 | + } |
|
| 64 | 75 | $j++; |
| 65 | 76 | print '<div class="news">'; |
| 66 | 77 | print '<h4><a href="'.$news->get_permalink().'">'.$news->get_title().'</a> <span>('.$news->get_date('j M Y, g:i a').')</span></h4>'."\n"; |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | </form> |
| 8 | 8 | </div> |
| 9 | 9 | <?php |
| 10 | - if (isset($owner)) { |
|
| 10 | + if (isset($owner)) { |
|
| 11 | 11 | ?> |
| 12 | 12 | <div class="sub-menu sub-menu-container"> |
| 13 | 13 | <ul class="nav nav-pills"> |
@@ -38,5 +38,5 @@ discard block |
||
| 38 | 38 | </ul> |
| 39 | 39 | </div> |
| 40 | 40 | <?php |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | ?> |
| 43 | 43 | \ No newline at end of file |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | ?> |
| 12 | 12 | <div class="sub-menu sub-menu-container"> |
| 13 | 13 | <ul class="nav nav-pills"> |
| 14 | - <li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
| 14 | + <li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
| 15 | 15 | <li class="dropdown"> |
| 16 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "owner-statistics-aircraft" || strtolower($current_page) == "owner-statistics-registration" || strtolower($current_page) == "owner-statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 16 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "owner-statistics-aircraft" || strtolower($current_page) == "owner-statistics-registration" || strtolower($current_page) == "owner-statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 17 | 17 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
| 18 | 18 | </a> |
| 19 | 19 | <ul class="dropdown-menu" role="menu"> |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | </ul> |
| 24 | 24 | </li> |
| 25 | 25 | <li class="dropdown"> |
| 26 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "owner-statistics-departure-airport" || strtolower($current_page) == "owner-statistics-departure-airport-country" || strtolower($current_page) == "owner-statistics-arrival-airport" || strtolower($current_page) == "owner-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 26 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "owner-statistics-departure-airport" || strtolower($current_page) == "owner-statistics-departure-airport-country" || strtolower($current_page) == "owner-statistics-arrival-airport" || strtolower($current_page) == "owner-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 27 | 27 | <?php echo _("Airport"); ?> <span class="caret"></span> |
| 28 | 28 | </a> |
| 29 | 29 | <ul class="dropdown-menu" role="menu"> |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
| 34 | 34 | </ul> |
| 35 | 35 | </li> |
| 36 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
| 37 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
| 36 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
| 37 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
| 38 | 38 | </ul> |
| 39 | 39 | </div> |
| 40 | 40 | <?php |
@@ -3,7 +3,13 @@ discard block |
||
| 3 | 3 | </span> |
| 4 | 4 | <div class="stats_airline"> |
| 5 | 5 | <form id="changedate" method="post"> |
| 6 | - <input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" /> |
|
| 6 | + <input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') { |
|
| 7 | + echo $year.'-'; |
|
| 8 | +} |
|
| 9 | +?><?php if (isset($month) && $month != '') { |
|
| 10 | + echo $month; |
|
| 11 | +} |
|
| 12 | +?>" /> |
|
| 7 | 13 | </form> |
| 8 | 14 | </div> |
| 9 | 15 | <?php |
@@ -11,15 +17,39 @@ discard block |
||
| 11 | 17 | ?> |
| 12 | 18 | <div class="sub-menu sub-menu-container"> |
| 13 | 19 | <ul class="nav nav-pills"> |
| 14 | - <li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
| 20 | + <li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') { |
|
| 21 | + echo '/'.$year; |
|
| 22 | +} |
|
| 23 | +?><?php if (isset($month) && $month != '') { |
|
| 24 | + echo '/'.$month; |
|
| 25 | +} |
|
| 26 | +?>" <?php if (strtolower($current_page) == "owner-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
| 15 | 27 | <li class="dropdown"> |
| 16 | 28 | <a class="dropdown-toggle <?php if(strtolower($current_page) == "owner-statistics-aircraft" || strtolower($current_page) == "owner-statistics-registration" || strtolower($current_page) == "owner-statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
| 17 | 29 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
| 18 | 30 | </a> |
| 19 | 31 | <ul class="dropdown-menu" role="menu"> |
| 20 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/aircraft/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Aircraft Type"); ?></a></li> |
|
| 21 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/registration/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Registration"); ?></a></li> |
|
| 22 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/manufacturer/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Manufacturer"); ?></a></li> |
|
| 32 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/aircraft/<?php print $owner; ?><?php if (isset($year) && $year != '') { |
|
| 33 | + echo '/'.$year; |
|
| 34 | +} |
|
| 35 | +?><?php if (isset($month) && $month != '') { |
|
| 36 | + echo '/'.$month; |
|
| 37 | +} |
|
| 38 | +?>"><?php echo _("Aircraft Type"); ?></a></li> |
|
| 39 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/registration/<?php print $owner; ?><?php if (isset($year) && $year != '') { |
|
| 40 | + echo '/'.$year; |
|
| 41 | +} |
|
| 42 | +?><?php if (isset($month) && $month != '') { |
|
| 43 | + echo '/'.$month; |
|
| 44 | +} |
|
| 45 | +?>"><?php echo _("Registration"); ?></a></li> |
|
| 46 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/manufacturer/<?php print $owner; ?><?php if (isset($year) && $year != '') { |
|
| 47 | + echo '/'.$year; |
|
| 48 | +} |
|
| 49 | +?><?php if (isset($month) && $month != '') { |
|
| 50 | + echo '/'.$month; |
|
| 51 | +} |
|
| 52 | +?>"><?php echo _("Manufacturer"); ?></a></li> |
|
| 23 | 53 | </ul> |
| 24 | 54 | </li> |
| 25 | 55 | <li class="dropdown"> |
@@ -27,14 +57,50 @@ discard block |
||
| 27 | 57 | <?php echo _("Airport"); ?> <span class="caret"></span> |
| 28 | 58 | </a> |
| 29 | 59 | <ul class="dropdown-menu" role="menu"> |
| 30 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/departure-airport/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Departure Airport"); ?></a></li> |
|
| 31 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/departure-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Departure Airport by Country"); ?></a></li> |
|
| 32 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Arrival Airport"); ?></a></li> |
|
| 33 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
|
| 60 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/departure-airport/<?php print $owner; ?><?php if (isset($year) && $year != '') { |
|
| 61 | + echo '/'.$year; |
|
| 62 | +} |
|
| 63 | +?><?php if (isset($month) && $month != '') { |
|
| 64 | + echo '/'.$month; |
|
| 65 | +} |
|
| 66 | +?>"><?php echo _("Departure Airport"); ?></a></li> |
|
| 67 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/departure-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') { |
|
| 68 | + echo '/'.$year; |
|
| 69 | +} |
|
| 70 | +?><?php if (isset($month) && $month != '') { |
|
| 71 | + echo '/'.$month; |
|
| 72 | +} |
|
| 73 | +?>"><?php echo _("Departure Airport by Country"); ?></a></li> |
|
| 74 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport/<?php print $owner; ?><?php if (isset($year) && $year != '') { |
|
| 75 | + echo '/'.$year; |
|
| 76 | +} |
|
| 77 | +?><?php if (isset($month) && $month != '') { |
|
| 78 | + echo '/'.$month; |
|
| 79 | +} |
|
| 80 | +?>"><?php echo _("Arrival Airport"); ?></a></li> |
|
| 81 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') { |
|
| 82 | + echo '/'.$year; |
|
| 83 | +} |
|
| 84 | +?><?php if (isset($month) && $month != '') { |
|
| 85 | + echo '/'.$month; |
|
| 86 | +} |
|
| 87 | +?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
|
| 34 | 88 | </ul> |
| 35 | 89 | </li> |
| 36 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
| 37 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
| 90 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') { |
|
| 91 | + echo '/'.$year; |
|
| 92 | +} |
|
| 93 | +?><?php if (isset($month) && $month != '') { |
|
| 94 | + echo '/'.$month; |
|
| 95 | +} |
|
| 96 | +?>" <?php if (strtolower($current_page) == "owner-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
| 97 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') { |
|
| 98 | + echo '/'.$year; |
|
| 99 | +} |
|
| 100 | +?><?php if (isset($month) && $month != '') { |
|
| 101 | + echo '/'.$month; |
|
| 102 | +} |
|
| 103 | +?>" <?php if (strtolower($current_page) == "owner-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
| 38 | 104 | </ul> |
| 39 | 105 | </div> |
| 40 | 106 | <?php |
@@ -4,16 +4,16 @@ discard block |
||
| 4 | 4 | require_once('require/class.Stats.php'); |
| 5 | 5 | require_once('require/class.Language.php'); |
| 6 | 6 | $Spotter = new Spotter(); |
| 7 | -if (!isset($_GET['aircraft_manufacturer'])){ |
|
| 7 | +if (!isset($_GET['aircraft_manufacturer'])) { |
|
| 8 | 8 | header('Location: '.$globalURL.''); |
| 9 | 9 | } else { |
| 10 | 10 | //calculuation for the pagination |
| 11 | - if(!isset($_GET['limit'])) |
|
| 11 | + if (!isset($_GET['limit'])) |
|
| 12 | 12 | { |
| 13 | 13 | $limit_start = 0; |
| 14 | 14 | $limit_end = 25; |
| 15 | 15 | $absolute_difference = 25; |
| 16 | - } else { |
|
| 16 | + } else { |
|
| 17 | 17 | $limit_explode = explode(",", $_GET['limit']); |
| 18 | 18 | if (isset($limit_explode[1])) { |
| 19 | 19 | $limit_start = $limit_explode[0]; |
@@ -32,19 +32,19 @@ discard block |
||
| 32 | 32 | $limit_previous_1 = $limit_start - $absolute_difference; |
| 33 | 33 | $limit_previous_2 = $limit_end - $absolute_difference; |
| 34 | 34 | |
| 35 | - $manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)))); |
|
| 36 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 35 | + $manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING)))); |
|
| 36 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 37 | 37 | $page_url = $globalURL.'/manufacturer/'.$manufacturer; |
| 38 | 38 | |
| 39 | 39 | if ($sort != '') { |
| 40 | - $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,$limit_start.",".$absolute_difference, $sort); |
|
| 40 | + $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, $limit_start.",".$absolute_difference, $sort); |
|
| 41 | 41 | } else { |
| 42 | - $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,$limit_start.",".$absolute_difference, ''); |
|
| 42 | + $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, $limit_start.",".$absolute_difference, ''); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | if (!empty($spotter_array)) |
| 46 | 46 | { |
| 47 | - $title = sprintf(_("Detailed View for %s"),$manufacturer); |
|
| 47 | + $title = sprintf(_("Detailed View for %s"), $manufacturer); |
|
| 48 | 48 | |
| 49 | 49 | require_once('header.php'); |
| 50 | 50 | print '<div class="select-item">'; |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | $Stats = new Stats(); |
| 54 | 54 | $all_manufacturers = $Stats->getAllManufacturers(); |
| 55 | 55 | if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
| 56 | - foreach($all_manufacturers as $all_manufacturer) |
|
| 56 | + foreach ($all_manufacturers as $all_manufacturer) |
|
| 57 | 57 | { |
| 58 | - if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
| 58 | + if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
| 59 | 59 | { |
| 60 | 60 | print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>'; |
| 61 | 61 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | print '</div>'; |
| 73 | 73 | |
| 74 | 74 | print '<div class="table column">'; |
| 75 | - print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."),$manufacturer).'</p>'; |
|
| 75 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."), $manufacturer).'</p>'; |
|
| 76 | 76 | |
| 77 | 77 | include('manufacturer-sub-menu.php'); |
| 78 | 78 | include('table-output.php'); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | $limit_start = 0; |
| 14 | 14 | $limit_end = 25; |
| 15 | 15 | $absolute_difference = 25; |
| 16 | - } else { |
|
| 16 | + } else { |
|
| 17 | 17 | $limit_explode = explode(",", $_GET['limit']); |
| 18 | 18 | if (isset($limit_explode[1])) { |
| 19 | 19 | $limit_start = $limit_explode[0]; |
@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">'; |
| 53 | 53 | $Stats = new Stats(); |
| 54 | 54 | $all_manufacturers = $Stats->getAllManufacturers(); |
| 55 | - if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
|
| 55 | + if (empty($all_manufacturers)) { |
|
| 56 | + $all_manufacturers = $Spotter->getAllManufacturers(); |
|
| 57 | + } |
|
| 56 | 58 | foreach($all_manufacturers as $all_manufacturer) |
| 57 | 59 | { |
| 58 | 60 | if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | $id = $spotter_item['Waypoint']['@attributes']['id']; |
| 24 | 24 | if ($id == 0 || !is_numeric($id)) $id = $j; |
| 25 | 25 | $output .= '{"type": "Feature",'; |
| 26 | - $output .= '"id": '.$id.','; |
|
| 27 | - $output .= '"properties": {'; |
|
| 26 | + $output .= '"id": '.$id.','; |
|
| 27 | + $output .= '"properties": {'; |
|
| 28 | 28 | $output .= '"type": "'.$spotter_item['@attributes']['type'].'",'; |
| 29 | 29 | //$output .= '"id": "'.$spotter_item['Waypoint']['@attributes']['id'].'",'; |
| 30 | 30 | $output .= '"name": "'.$spotter_item['Waypoint']['@attributes']['name'].'",'; |
@@ -35,31 +35,31 @@ discard block |
||
| 35 | 35 | } elseif ($spotter_item['@attributes']['type'] == 'Finish') { |
| 36 | 36 | $output .= '"icon": "/images/tsk/tsk-finish.png"'; |
| 37 | 37 | } else $output .= '"icon": "/images/tsk/number_'.$id.'.png"'; |
| 38 | - $output .= '},'; |
|
| 39 | - $output .= '"geometry": {'; |
|
| 38 | + $output .= '},'; |
|
| 39 | + $output .= '"geometry": {'; |
|
| 40 | 40 | $output .= '"type": "Point",'; |
| 41 | 41 | $output .= '"coordinates": ['; |
| 42 | - $output .= $spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude']; |
|
| 42 | + $output .= $spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude']; |
|
| 43 | 43 | $output .= ']'; |
| 44 | - $output .= '}'; |
|
| 44 | + $output .= '}'; |
|
| 45 | 45 | $output .= '},'; |
| 46 | 46 | $j++; |
| 47 | 47 | } |
| 48 | 48 | // Lines |
| 49 | 49 | $output .= '{"type": "Feature",'; |
| 50 | - $output .= '"properties": {'; |
|
| 50 | + $output .= '"properties": {'; |
|
| 51 | 51 | $output .= '"type": "'.$spotter_array['@attributes']['type'].'"'; |
| 52 | - $output .= '},'; |
|
| 53 | - $output .= '"geometry": {'; |
|
| 52 | + $output .= '},'; |
|
| 53 | + $output .= '"geometry": {'; |
|
| 54 | 54 | $output .= '"type": "LineString",'; |
| 55 | 55 | $output .= '"coordinates": ['; |
| 56 | 56 | foreach($spotter_array['Point'] as $spotter_item) |
| 57 | 57 | { |
| 58 | - $output .= '['.$spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'].'],'; |
|
| 58 | + $output .= '['.$spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'].'],'; |
|
| 59 | 59 | } |
| 60 | 60 | $output = substr($output, 0, -1); |
| 61 | 61 | $output .= ']'; |
| 62 | - $output .= '}'; |
|
| 62 | + $output .= '}'; |
|
| 63 | 63 | $output .= '},'; |
| 64 | 64 | $output = substr($output, 0, -1); |
| 65 | 65 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | } |
| 9 | 9 | header('Content-Type: text/javascript'); |
| 10 | 10 | |
| 11 | -$tskfile = filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL); |
|
| 11 | +$tskfile = filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL); |
|
| 12 | 12 | |
| 13 | 13 | $spotter_array = $TSK->parse_xml($tskfile); |
| 14 | 14 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | if (!empty($spotter_array)) |
| 17 | 17 | { |
| 18 | 18 | $j = 0; |
| 19 | - foreach($spotter_array['Point'] as $spotter_item) |
|
| 19 | + foreach ($spotter_array['Point'] as $spotter_item) |
|
| 20 | 20 | { |
| 21 | 21 | date_default_timezone_set('UTC'); |
| 22 | 22 | //waypoint plotting |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $output .= '"geometry": {'; |
| 54 | 54 | $output .= '"type": "LineString",'; |
| 55 | 55 | $output .= '"coordinates": ['; |
| 56 | - foreach($spotter_array['Point'] as $spotter_item) |
|
| 56 | + foreach ($spotter_array['Point'] as $spotter_item) |
|
| 57 | 57 | { |
| 58 | 58 | $output .= '['.$spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'].'],'; |
| 59 | 59 | } |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | date_default_timezone_set('UTC'); |
| 22 | 22 | //waypoint plotting |
| 23 | 23 | $id = $spotter_item['Waypoint']['@attributes']['id']; |
| 24 | - if ($id == 0 || !is_numeric($id)) $id = $j; |
|
| 24 | + if ($id == 0 || !is_numeric($id)) { |
|
| 25 | + $id = $j; |
|
| 26 | + } |
|
| 25 | 27 | $output .= '{"type": "Feature",'; |
| 26 | 28 | $output .= '"id": '.$id.','; |
| 27 | 29 | $output .= '"properties": {'; |
@@ -34,7 +36,9 @@ discard block |
||
| 34 | 36 | $output .= '"icon": "/images/tsk/tsk-start.png"'; |
| 35 | 37 | } elseif ($spotter_item['@attributes']['type'] == 'Finish') { |
| 36 | 38 | $output .= '"icon": "/images/tsk/tsk-finish.png"'; |
| 37 | - } else $output .= '"icon": "/images/tsk/number_'.$id.'.png"'; |
|
| 39 | + } else { |
|
| 40 | + $output .= '"icon": "/images/tsk/number_'.$id.'.png"'; |
|
| 41 | + } |
|
| 38 | 42 | $output .= '},'; |
| 39 | 43 | $output .= '"geometry": {'; |
| 40 | 44 | $output .= '"type": "Point",'; |
@@ -174,6 +174,10 @@ |
||
| 174 | 174 | '\|' => 'TNC Stream SW', |
| 175 | 175 | '\~' => 'TNC Stream SW'); |
| 176 | 176 | |
| 177 | + /** |
|
| 178 | + * @param integer $n |
|
| 179 | + * @param integer $s |
|
| 180 | + */ |
|
| 177 | 181 | private function urshift($n, $s) { |
| 178 | 182 | return ($n >= 0) ? ($n >> $s) : |
| 179 | 183 | (($n & 0x7fffffff) >> $s) | |
@@ -176,8 +176,8 @@ |
||
| 176 | 176 | |
| 177 | 177 | private function urshift($n, $s) { |
| 178 | 178 | return ($n >= 0) ? ($n >> $s) : |
| 179 | - (($n & 0x7fffffff) >> $s) | |
|
| 180 | - (0x40000000 >> ($s - 1)); |
|
| 179 | + (($n & 0x7fffffff) >> $s) | |
|
| 180 | + (0x40000000 >> ($s - 1)); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /* |
@@ -196,16 +196,22 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | /* Check that end was found and body has at least one byte. */ |
| 198 | 198 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
| 199 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
| 199 | + if ($globalDebug) { |
|
| 200 | + echo '!!! APRS invalid : '.$input."\n"; |
|
| 201 | + } |
|
| 200 | 202 | return false; |
| 201 | 203 | } |
| 202 | 204 | |
| 203 | - if ($debug) echo 'input : '.$input."\n"; |
|
| 205 | + if ($debug) { |
|
| 206 | + echo 'input : '.$input."\n"; |
|
| 207 | + } |
|
| 204 | 208 | /* Save header and body. */ |
| 205 | 209 | $body = substr($input,$splitpos+1,$input_len); |
| 206 | 210 | $body_len = strlen($body); |
| 207 | 211 | $header = substr($input,0,$splitpos); |
| 208 | - if ($debug) echo 'header : '.$header."\n"; |
|
| 212 | + if ($debug) { |
|
| 213 | + echo 'header : '.$header."\n"; |
|
| 214 | + } |
|
| 209 | 215 | |
| 210 | 216 | /* Parse source, target and path. */ |
| 211 | 217 | //FLRDF0A52>APRS,qAS,LSTB |
@@ -219,11 +225,15 @@ discard block |
||
| 219 | 225 | $result['format_source'] = 'famaprs'; |
| 220 | 226 | $result['source_type'] = 'ais'; |
| 221 | 227 | } else { |
| 222 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
| 228 | + if ($debug) { |
|
| 229 | + echo 'ident : '.$ident."\n"; |
|
| 230 | + } |
|
| 223 | 231 | $result['ident'] = $ident; |
| 224 | 232 | } |
| 225 | 233 | } else { |
| 226 | - if ($debug) 'No ident'."\n"; |
|
| 234 | + if ($debug) { |
|
| 235 | + 'No ident'."\n"; |
|
| 236 | + } |
|
| 227 | 237 | return false; |
| 228 | 238 | } |
| 229 | 239 | $elements = explode(',',$all_elements); |
@@ -233,7 +243,9 @@ discard block |
||
| 233 | 243 | if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
| 234 | 244 | //if ($element == 'TCPIP*') return false; |
| 235 | 245 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
| 236 | - if ($debug) echo 'element : '.$element."\n"; |
|
| 246 | + if ($debug) { |
|
| 247 | + echo 'element : '.$element."\n"; |
|
| 248 | + } |
|
| 237 | 249 | return false; |
| 238 | 250 | } |
| 239 | 251 | /* |
@@ -246,13 +258,17 @@ discard block |
||
| 246 | 258 | } |
| 247 | 259 | |
| 248 | 260 | $type = substr($body,0,1); |
| 249 | - if ($debug) echo 'type : '.$type."\n"; |
|
| 261 | + if ($debug) { |
|
| 262 | + echo 'type : '.$type."\n"; |
|
| 263 | + } |
|
| 250 | 264 | if ($type == ';') { |
| 251 | 265 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
| 252 | 266 | $result['address'] = trim(substr($body,1,9)); |
| 253 | 267 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
| 254 | 268 | $result['mmsi'] = trim(substr($body,1,9)); |
| 255 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
| 269 | + } else { |
|
| 270 | + $result['ident'] = trim(substr($body,1,9)); |
|
| 271 | + } |
|
| 256 | 272 | } elseif ($type == ',') { |
| 257 | 273 | // Invalid data or test data |
| 258 | 274 | return false; |
@@ -309,7 +325,9 @@ discard block |
||
| 309 | 325 | //$symbol_table = $matches[4]; |
| 310 | 326 | $lat = intval($lat_deg); |
| 311 | 327 | $lon = intval($lon_deg); |
| 312 | - if ($lat > 89 || $lon > 179) return false; |
|
| 328 | + if ($lat > 89 || $lon > 179) { |
|
| 329 | + return false; |
|
| 330 | + } |
|
| 313 | 331 | /* |
| 314 | 332 | $tmp_5b = str_replace('.','',$lat_min); |
| 315 | 333 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
@@ -318,8 +336,12 @@ discard block |
||
| 318 | 336 | */ |
| 319 | 337 | $latitude = $lat + floatval($lat_min)/60; |
| 320 | 338 | $longitude = $lon + floatval($lon_min)/60; |
| 321 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
| 322 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
| 339 | + if ($sind == 'S') { |
|
| 340 | + $latitude = 0-$latitude; |
|
| 341 | + } |
|
| 342 | + if ($wind == 'W') { |
|
| 343 | + $longitude = 0-$longitude; |
|
| 344 | + } |
|
| 323 | 345 | $result['latitude'] = $latitude; |
| 324 | 346 | $result['longitude'] = $longitude; |
| 325 | 347 | $body_parse = substr($body_parse,18); |
@@ -344,22 +366,29 @@ discard block |
||
| 344 | 366 | if ($find) { |
| 345 | 367 | $body_split = str_split($body_parse); |
| 346 | 368 | $symbol_code = $body_split[0]; |
| 347 | - if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code; |
|
| 348 | - else $symbol_code = '\\'.$symbol_code; |
|
| 369 | + if (!isset($symbolll) || $symbolll == '/') { |
|
| 370 | + $symbol_code = '/'.$symbol_code; |
|
| 371 | + } else { |
|
| 372 | + $symbol_code = '\\'.$symbol_code; |
|
| 373 | + } |
|
| 349 | 374 | //' |
| 350 | 375 | //if ($type != ';' && $type != '>') { |
| 351 | 376 | if ($type != '') { |
| 352 | 377 | $body_parse = substr($body_parse,1); |
| 353 | 378 | $body_parse_len = strlen($body_parse); |
| 354 | 379 | $result['symbol_code'] = $symbol_code; |
| 355 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 380 | + if (isset($this->symbols[$symbol_code])) { |
|
| 381 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 382 | + } |
|
| 356 | 383 | if ($symbol_code != '_') { |
| 357 | 384 | } |
| 358 | 385 | if ($body_parse_len >= 7) { |
| 359 | 386 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
| 360 | 387 | $course = substr($body_parse,0,3); |
| 361 | 388 | $tmp_s = intval($course); |
| 362 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
| 389 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
| 390 | + $result['heading'] = intval($course); |
|
| 391 | + } |
|
| 363 | 392 | $speed = substr($body_parse,4,3); |
| 364 | 393 | if ($speed != '...') { |
| 365 | 394 | $result['speed'] = intval($speed); |
@@ -394,10 +423,16 @@ discard block |
||
| 394 | 423 | $dao_split = str_split($dao); |
| 395 | 424 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
| 396 | 425 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
| 397 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
| 398 | - else $result['latitude'] += $lat_off; |
|
| 399 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
| 400 | - else $result['longitude'] += $lon_off; |
|
| 426 | + if ($result['latitude'] < 0) { |
|
| 427 | + $result['latitude'] -= $lat_off; |
|
| 428 | + } else { |
|
| 429 | + $result['latitude'] += $lat_off; |
|
| 430 | + } |
|
| 431 | + if ($result['longitude'] < 0) { |
|
| 432 | + $result['longitude'] -= $lon_off; |
|
| 433 | + } else { |
|
| 434 | + $result['longitude'] += $lon_off; |
|
| 435 | + } |
|
| 401 | 436 | } |
| 402 | 437 | $body_parse = substr($body_parse,6); |
| 403 | 438 | } |
@@ -435,27 +470,48 @@ discard block |
||
| 435 | 470 | //$mode = substr($id,0,2); |
| 436 | 471 | $address = substr($id,2); |
| 437 | 472 | $addressType = (intval(substr($id,0,2),16))&3; |
| 438 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
| 439 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
| 440 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
| 441 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
| 473 | + if ($addressType == 0) { |
|
| 474 | + $result['addresstype'] = "RANDOM"; |
|
| 475 | + } elseif ($addressType == 1) { |
|
| 476 | + $result['addresstype'] = "ICAO"; |
|
| 477 | + } elseif ($addressType == 2) { |
|
| 478 | + $result['addresstype'] = "FLARM"; |
|
| 479 | + } elseif ($addressType == 3) { |
|
| 480 | + $result['addresstype'] = "OGN"; |
|
| 481 | + } |
|
| 442 | 482 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
| 443 | 483 | $result['aircrafttype_code'] = $aircraftType; |
| 444 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
| 445 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
| 446 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
| 447 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 448 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
| 449 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
| 450 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 451 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 452 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 453 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 454 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
| 455 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
| 456 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
| 457 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
| 458 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 484 | + if ($aircraftType == 0) { |
|
| 485 | + $result['aircrafttype'] = "UNKNOWN"; |
|
| 486 | + } elseif ($aircraftType == 1) { |
|
| 487 | + $result['aircrafttype'] = "GLIDER"; |
|
| 488 | + } elseif ($aircraftType == 2) { |
|
| 489 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
| 490 | + } elseif ($aircraftType == 3) { |
|
| 491 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 492 | + } elseif ($aircraftType == 4) { |
|
| 493 | + $result['aircrafttype'] = "PARACHUTE"; |
|
| 494 | + } elseif ($aircraftType == 5) { |
|
| 495 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
| 496 | + } elseif ($aircraftType == 6) { |
|
| 497 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 498 | + } elseif ($aircraftType == 7) { |
|
| 499 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 500 | + } elseif ($aircraftType == 8) { |
|
| 501 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 502 | + } elseif ($aircraftType == 9) { |
|
| 503 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 504 | + } elseif ($aircraftType == 10) { |
|
| 505 | + $result['aircrafttype'] = "UFO"; |
|
| 506 | + } elseif ($aircraftType == 11) { |
|
| 507 | + $result['aircrafttype'] = "BALLOON"; |
|
| 508 | + } elseif ($aircraftType == 12) { |
|
| 509 | + $result['aircrafttype'] = "AIRSHIP"; |
|
| 510 | + } elseif ($aircraftType == 13) { |
|
| 511 | + $result['aircrafttype'] = "UAV"; |
|
| 512 | + } elseif ($aircraftType == 15) { |
|
| 513 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 514 | + } |
|
| 459 | 515 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
| 460 | 516 | $result['stealth'] = $stealth; |
| 461 | 517 | $result['address'] = $address; |
@@ -490,77 +546,181 @@ discard block |
||
| 490 | 546 | //g012t088r000p000P000h38b10110 |
| 491 | 547 | //g011t086r000p000P000h29b10198 |
| 492 | 548 | if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 493 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 494 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 495 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 496 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 497 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 498 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 499 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 549 | + if ($matches[1] != '...') { |
|
| 550 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 551 | + } |
|
| 552 | + if ($matches[2] != '...') { |
|
| 553 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 554 | + } |
|
| 555 | + if ($matches[3] != '...') { |
|
| 556 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 557 | + } |
|
| 558 | + if ($matches[4] != '...') { |
|
| 559 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 560 | + } |
|
| 561 | + if ($matches[5] != '...') { |
|
| 562 | + $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 563 | + } |
|
| 564 | + if ($matches[6] != '...') { |
|
| 565 | + $result['humidity'] = intval($matches[6]); |
|
| 566 | + } |
|
| 567 | + if ($matches[7] != '...') { |
|
| 568 | + $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 569 | + } |
|
| 500 | 570 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 501 | 571 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 502 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 503 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 504 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 505 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
| 506 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 507 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 508 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 572 | + if ($matches[1] != '...') { |
|
| 573 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 574 | + } |
|
| 575 | + if ($matches[2] != '...') { |
|
| 576 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 577 | + } |
|
| 578 | + if ($matches[3] != '...') { |
|
| 579 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 580 | + } |
|
| 581 | + if ($matches[5] != '...') { |
|
| 582 | + $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
| 583 | + } |
|
| 584 | + if ($matches[4] != '...') { |
|
| 585 | + $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 586 | + } |
|
| 587 | + if ($matches[6] != '...') { |
|
| 588 | + $result['humidity'] = intval($matches[6]); |
|
| 589 | + } |
|
| 590 | + if ($matches[7] != '...') { |
|
| 591 | + $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 592 | + } |
|
| 509 | 593 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 510 | 594 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
| 511 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 512 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 513 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 514 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 515 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 516 | - if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
|
| 517 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 595 | + if ($matches[1] != '...') { |
|
| 596 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 597 | + } |
|
| 598 | + if ($matches[2] != '...') { |
|
| 599 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 600 | + } |
|
| 601 | + if ($matches[3] != '...') { |
|
| 602 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 603 | + } |
|
| 604 | + if ($matches[4] != '...') { |
|
| 605 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 606 | + } |
|
| 607 | + if ($matches[5] != '...') { |
|
| 608 | + $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 609 | + } |
|
| 610 | + if ($matches[7] != '...') { |
|
| 611 | + $result['humidity'] = intval($matches[7]); |
|
| 612 | + } |
|
| 613 | + if ($matches[6] != '...') { |
|
| 614 | + $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 615 | + } |
|
| 518 | 616 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 519 | 617 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
| 520 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 521 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 522 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 523 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 524 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 525 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 618 | + if ($matches[1] != '...') { |
|
| 619 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 620 | + } |
|
| 621 | + if ($matches[2] != '...') { |
|
| 622 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 623 | + } |
|
| 624 | + if ($matches[3] != '...') { |
|
| 625 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 626 | + } |
|
| 627 | + if ($matches[4] != '...') { |
|
| 628 | + $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 629 | + } |
|
| 630 | + if ($matches[6] != '...') { |
|
| 631 | + $result['humidity'] = intval($matches[6]); |
|
| 632 | + } |
|
| 633 | + if ($matches[5] != '...') { |
|
| 634 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 635 | + } |
|
| 526 | 636 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 527 | 637 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
| 528 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 529 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 530 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 531 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 532 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 533 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 638 | + if ($matches[1] != '...') { |
|
| 639 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 640 | + } |
|
| 641 | + if ($matches[2] != '...') { |
|
| 642 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 643 | + } |
|
| 644 | + if ($matches[3] != '...') { |
|
| 645 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 646 | + } |
|
| 647 | + if ($matches[4] != '...') { |
|
| 648 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 649 | + } |
|
| 650 | + if ($matches[6] != '...') { |
|
| 651 | + $result['humidity'] = intval($matches[6]); |
|
| 652 | + } |
|
| 653 | + if ($matches[5] != '...') { |
|
| 654 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 655 | + } |
|
| 534 | 656 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 535 | 657 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 536 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 537 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 538 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 539 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 540 | - if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
|
| 541 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 658 | + if ($matches[1] != '...') { |
|
| 659 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 660 | + } |
|
| 661 | + if ($matches[2] != '...') { |
|
| 662 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 663 | + } |
|
| 664 | + if ($matches[3] != '...') { |
|
| 665 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 666 | + } |
|
| 667 | + if ($matches[4] != '...') { |
|
| 668 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 669 | + } |
|
| 670 | + if ($matches[5] != '...') { |
|
| 671 | + $result['humidity'] = intval($matches[5]); |
|
| 672 | + } |
|
| 673 | + if ($matches[6] != '...') { |
|
| 674 | + $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 675 | + } |
|
| 542 | 676 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 543 | 677 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 544 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 545 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 546 | - if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
|
| 547 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
|
| 678 | + if ($matches[1] != '...') { |
|
| 679 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 680 | + } |
|
| 681 | + if ($matches[2] != '...') { |
|
| 682 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 683 | + } |
|
| 684 | + if ($matches[2] != '...') { |
|
| 685 | + $result['humidity'] = intval($matches[3]); |
|
| 686 | + } |
|
| 687 | + if ($matches[4] != '...') { |
|
| 688 | + $result['pressure'] = round((intval($matches[4])/10),1); |
|
| 689 | + } |
|
| 548 | 690 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 549 | 691 | } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
| 550 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 551 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 552 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 553 | - if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
|
| 554 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 692 | + if ($matches[1] != '...') { |
|
| 693 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 694 | + } |
|
| 695 | + if ($matches[2] != '...') { |
|
| 696 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 697 | + } |
|
| 698 | + if ($matches[3] != '...') { |
|
| 699 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 700 | + } |
|
| 701 | + if ($matches[4] != '...') { |
|
| 702 | + $result['humidity'] = intval($matches[4]); |
|
| 703 | + } |
|
| 704 | + if ($matches[5] != '...') { |
|
| 705 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 706 | + } |
|
| 555 | 707 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 556 | 708 | } |
| 557 | 709 | $result['comment'] = trim($body_parse); |
| 558 | 710 | } |
| 559 | - } else $result['comment'] = trim($body_parse); |
|
| 711 | + } else { |
|
| 712 | + $result['comment'] = trim($body_parse); |
|
| 713 | + } |
|
| 714 | + } |
|
| 715 | + if (isset($result['latitude'])) { |
|
| 716 | + $result['latitude'] = round($result['latitude'],4); |
|
| 717 | + } |
|
| 718 | + if (isset($result['longitude'])) { |
|
| 719 | + $result['longitude'] = round($result['longitude'],4); |
|
| 720 | + } |
|
| 721 | + if ($debug) { |
|
| 722 | + print_r($result); |
|
| 560 | 723 | } |
| 561 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
| 562 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
| 563 | - if ($debug) print_r($result); |
|
| 564 | 724 | return $result; |
| 565 | 725 | } |
| 566 | 726 | |
@@ -572,12 +732,21 @@ discard block |
||
| 572 | 732 | $aprs_connect = 0; |
| 573 | 733 | $aprs_keep = 120; |
| 574 | 734 | $aprs_last_tx = time(); |
| 575 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 576 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 577 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
|
| 578 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 579 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
|
| 580 | - else $aprs_pass = '-1'; |
|
| 735 | + if (isset($globalAPRSversion)) { |
|
| 736 | + $aprs_version = $globalAPRSversion; |
|
| 737 | + } else { |
|
| 738 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 739 | + } |
|
| 740 | + if (isset($globalServerAPRSssid)) { |
|
| 741 | + $aprs_ssid = $globalServerAPRSssid; |
|
| 742 | + } else { |
|
| 743 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 744 | + } |
|
| 745 | + if (isset($globalServerAPRSpass)) { |
|
| 746 | + $aprs_pass = $globalServerAPRSpass; |
|
| 747 | + } else { |
|
| 748 | + $aprs_pass = '-1'; |
|
| 749 | + } |
|
| 581 | 750 | $aprs_filter = ''; |
| 582 | 751 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
| 583 | 752 | $Common = new Common(); |
@@ -616,10 +785,14 @@ discard block |
||
| 616 | 785 | */ |
| 617 | 786 | public function send($data) { |
| 618 | 787 | global $globalDebug; |
| 619 | - if ($this->connected === false) $this->connect(); |
|
| 788 | + if ($this->connected === false) { |
|
| 789 | + $this->connect(); |
|
| 790 | + } |
|
| 620 | 791 | $send = socket_send( $this->socket , $data , strlen($data),0); |
| 621 | 792 | if ($send === FALSE) { |
| 622 | - if ($globalDebug) echo 'Reconnect...'; |
|
| 793 | + if ($globalDebug) { |
|
| 794 | + echo 'Reconnect...'; |
|
| 795 | + } |
|
| 623 | 796 | socket_close($this->socket); |
| 624 | 797 | $this->connect(); |
| 625 | 798 | } |
@@ -642,22 +815,32 @@ discard block |
||
| 642 | 815 | //$w = '00'; |
| 643 | 816 | $custom = ''; |
| 644 | 817 | if ($ident != '') { |
| 645 | - if ($custom != '') $custom .= '/'; |
|
| 818 | + if ($custom != '') { |
|
| 819 | + $custom .= '/'; |
|
| 820 | + } |
|
| 646 | 821 | $custom .= 'CS='.$ident; |
| 647 | 822 | } |
| 648 | 823 | if ($squawk != '') { |
| 649 | - if ($custom != '') $custom .= '/'; |
|
| 824 | + if ($custom != '') { |
|
| 825 | + $custom .= '/'; |
|
| 826 | + } |
|
| 650 | 827 | $custom .= 'SQ='.$squawk; |
| 651 | 828 | } |
| 652 | 829 | if ($verticalrate != '') { |
| 653 | - if ($custom != '') $custom .= '/'; |
|
| 830 | + if ($custom != '') { |
|
| 831 | + $custom .= '/'; |
|
| 832 | + } |
|
| 654 | 833 | $custom .= 'VR='.$verticalrate; |
| 655 | 834 | } |
| 656 | 835 | if ($aircraft_icao != '' && $aircraft_icao != 'NA') { |
| 657 | - if ($custom != '') $custom .= '/'; |
|
| 836 | + if ($custom != '') { |
|
| 837 | + $custom .= '/'; |
|
| 838 | + } |
|
| 658 | 839 | $custom .= 'AI='.$aircraft_icao; |
| 659 | 840 | } |
| 660 | - if ($custom != '') $custom = ' '.$custom; |
|
| 841 | + if ($custom != '') { |
|
| 842 | + $custom = ' '.$custom; |
|
| 843 | + } |
|
| 661 | 844 | /* |
| 662 | 845 | // Use AMSL altitude |
| 663 | 846 | $GeoidClass = new GeoidHeight(); |
@@ -682,30 +865,44 @@ discard block |
||
| 682 | 865 | //$w = '00'; |
| 683 | 866 | $custom = ''; |
| 684 | 867 | if ($ident != '') { |
| 685 | - if ($custom != '') $custom .= '/'; |
|
| 868 | + if ($custom != '') { |
|
| 869 | + $custom .= '/'; |
|
| 870 | + } |
|
| 686 | 871 | $custom .= 'CS='.str_replace(' ','_',$ident); |
| 687 | 872 | } |
| 688 | 873 | if ($typeid != '') { |
| 689 | - if ($custom != '') $custom .= '/'; |
|
| 874 | + if ($custom != '') { |
|
| 875 | + $custom .= '/'; |
|
| 876 | + } |
|
| 690 | 877 | $custom .= 'TI='.$typeid; |
| 691 | 878 | } |
| 692 | 879 | if ($statusid != '') { |
| 693 | - if ($custom != '') $custom .= '/'; |
|
| 880 | + if ($custom != '') { |
|
| 881 | + $custom .= '/'; |
|
| 882 | + } |
|
| 694 | 883 | $custom .= 'SI='.$statusid; |
| 695 | 884 | } |
| 696 | 885 | if ($imo != '') { |
| 697 | - if ($custom != '') $custom .= '/'; |
|
| 886 | + if ($custom != '') { |
|
| 887 | + $custom .= '/'; |
|
| 888 | + } |
|
| 698 | 889 | $custom .= 'IMO='.$imo; |
| 699 | 890 | } |
| 700 | 891 | if ($arrival_date != '') { |
| 701 | - if ($custom != '') $custom .= '/'; |
|
| 892 | + if ($custom != '') { |
|
| 893 | + $custom .= '/'; |
|
| 894 | + } |
|
| 702 | 895 | $custom .= 'AD='.strtotime($arrival_date); |
| 703 | 896 | } |
| 704 | 897 | if ($arrival_code != '') { |
| 705 | - if ($custom != '') $custom .= '/'; |
|
| 898 | + if ($custom != '') { |
|
| 899 | + $custom .= '/'; |
|
| 900 | + } |
|
| 706 | 901 | $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
| 707 | 902 | } |
| 708 | - if ($custom != '') $custom = ' '.$custom; |
|
| 903 | + if ($custom != '') { |
|
| 904 | + $custom = ' '.$custom; |
|
| 905 | + } |
|
| 709 | 906 | $altitude = 0; |
| 710 | 907 | $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
| 711 | 908 | } |
@@ -175,8 +175,7 @@ discard block |
||
| 175 | 175 | '\~' => 'TNC Stream SW'); |
| 176 | 176 | |
| 177 | 177 | private function urshift($n, $s) { |
| 178 | - return ($n >= 0) ? ($n >> $s) : |
|
| 179 | - (($n & 0x7fffffff) >> $s) | |
|
| 178 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
| 180 | 179 | (0x40000000 >> ($s - 1)); |
| 181 | 180 | } |
| 182 | 181 | |
@@ -192,7 +191,7 @@ discard block |
||
| 192 | 191 | $input_len = strlen($input); |
| 193 | 192 | |
| 194 | 193 | /* Find the end of header checking for NULL bytes while doing it. */ |
| 195 | - $splitpos = strpos($input,':'); |
|
| 194 | + $splitpos = strpos($input, ':'); |
|
| 196 | 195 | |
| 197 | 196 | /* Check that end was found and body has at least one byte. */ |
| 198 | 197 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -202,14 +201,14 @@ discard block |
||
| 202 | 201 | |
| 203 | 202 | if ($debug) echo 'input : '.$input."\n"; |
| 204 | 203 | /* Save header and body. */ |
| 205 | - $body = substr($input,$splitpos+1,$input_len); |
|
| 204 | + $body = substr($input, $splitpos + 1, $input_len); |
|
| 206 | 205 | $body_len = strlen($body); |
| 207 | - $header = substr($input,0,$splitpos); |
|
| 206 | + $header = substr($input, 0, $splitpos); |
|
| 208 | 207 | if ($debug) echo 'header : '.$header."\n"; |
| 209 | 208 | |
| 210 | 209 | /* Parse source, target and path. */ |
| 211 | 210 | //FLRDF0A52>APRS,qAS,LSTB |
| 212 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
| 211 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
| 213 | 212 | $ident = $matches[1]; |
| 214 | 213 | $all_elements = $matches[2]; |
| 215 | 214 | if ($ident == 'AIRCRAFT') { |
@@ -226,13 +225,13 @@ discard block |
||
| 226 | 225 | if ($debug) 'No ident'."\n"; |
| 227 | 226 | return false; |
| 228 | 227 | } |
| 229 | - $elements = explode(',',$all_elements); |
|
| 228 | + $elements = explode(',', $all_elements); |
|
| 230 | 229 | $source = end($elements); |
| 231 | 230 | $result['source'] = $source; |
| 232 | 231 | foreach ($elements as $element) { |
| 233 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
| 232 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
| 234 | 233 | //if ($element == 'TCPIP*') return false; |
| 235 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
| 234 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
| 236 | 235 | if ($debug) echo 'element : '.$element."\n"; |
| 237 | 236 | return false; |
| 238 | 237 | } |
@@ -245,14 +244,14 @@ discard block |
||
| 245 | 244 | */ |
| 246 | 245 | } |
| 247 | 246 | |
| 248 | - $type = substr($body,0,1); |
|
| 247 | + $type = substr($body, 0, 1); |
|
| 249 | 248 | if ($debug) echo 'type : '.$type."\n"; |
| 250 | 249 | if ($type == ';') { |
| 251 | 250 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
| 252 | - $result['address'] = trim(substr($body,1,9)); |
|
| 251 | + $result['address'] = trim(substr($body, 1, 9)); |
|
| 253 | 252 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
| 254 | - $result['mmsi'] = trim(substr($body,1,9)); |
|
| 255 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
| 253 | + $result['mmsi'] = trim(substr($body, 1, 9)); |
|
| 254 | + } else $result['ident'] = trim(substr($body, 1, 9)); |
|
| 256 | 255 | } elseif ($type == ',') { |
| 257 | 256 | // Invalid data or test data |
| 258 | 257 | return false; |
@@ -260,20 +259,20 @@ discard block |
||
| 260 | 259 | |
| 261 | 260 | // Check for Timestamp |
| 262 | 261 | $find = false; |
| 263 | - $body_parse = substr($body,1); |
|
| 264 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
| 265 | - $body_parse = substr($body_parse,10); |
|
| 262 | + $body_parse = substr($body, 1); |
|
| 263 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
| 264 | + $body_parse = substr($body_parse, 10); |
|
| 266 | 265 | $find = true; |
| 267 | 266 | } |
| 268 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
| 269 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 267 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
| 268 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
| 270 | 269 | $find = true; |
| 271 | 270 | } |
| 272 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
| 273 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 271 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
| 272 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
| 274 | 273 | $find = true; |
| 275 | 274 | } |
| 276 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
| 275 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
| 277 | 276 | $find = true; |
| 278 | 277 | $timestamp = $matches[0]; |
| 279 | 278 | if ($matches[4] == 'h') { |
@@ -286,17 +285,17 @@ discard block |
||
| 286 | 285 | // This work or not ? |
| 287 | 286 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
| 288 | 287 | } |
| 289 | - $body_parse = substr($body_parse,7); |
|
| 288 | + $body_parse = substr($body_parse, 7); |
|
| 290 | 289 | $result['timestamp'] = $timestamp; |
| 291 | 290 | } |
| 292 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
| 291 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
| 293 | 292 | $find = true; |
| 294 | 293 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
| 295 | - $body_parse = substr($body_parse,8); |
|
| 294 | + $body_parse = substr($body_parse, 8); |
|
| 296 | 295 | $result['timestamp'] = $timestamp; |
| 297 | 296 | } |
| 298 | 297 | //if (strlen($body_parse) > 19) { |
| 299 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
| 298 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { |
|
| 300 | 299 | $find = true; |
| 301 | 300 | // 4658.70N/00707.78Ez |
| 302 | 301 | $sind = strtoupper($matches[3]); |
@@ -318,11 +317,11 @@ discard block |
||
| 318 | 317 | */ |
| 319 | 318 | $latitude = $lat + floatval($lat_min)/60; |
| 320 | 319 | $longitude = $lon + floatval($lon_min)/60; |
| 321 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
| 322 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
| 320 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
| 321 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
| 323 | 322 | $result['latitude'] = $latitude; |
| 324 | 323 | $result['longitude'] = $longitude; |
| 325 | - $body_parse = substr($body_parse,18); |
|
| 324 | + $body_parse = substr($body_parse, 18); |
|
| 326 | 325 | $body_parse_len = strlen($body_parse); |
| 327 | 326 | } |
| 328 | 327 | $body_parse_len = strlen($body_parse); |
@@ -349,22 +348,22 @@ discard block |
||
| 349 | 348 | //' |
| 350 | 349 | //if ($type != ';' && $type != '>') { |
| 351 | 350 | if ($type != '') { |
| 352 | - $body_parse = substr($body_parse,1); |
|
| 351 | + $body_parse = substr($body_parse, 1); |
|
| 353 | 352 | $body_parse_len = strlen($body_parse); |
| 354 | 353 | $result['symbol_code'] = $symbol_code; |
| 355 | 354 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
| 356 | 355 | if ($symbol_code != '_') { |
| 357 | 356 | } |
| 358 | 357 | if ($body_parse_len >= 7) { |
| 359 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
| 360 | - $course = substr($body_parse,0,3); |
|
| 358 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
| 359 | + $course = substr($body_parse, 0, 3); |
|
| 361 | 360 | $tmp_s = intval($course); |
| 362 | 361 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
| 363 | - $speed = substr($body_parse,4,3); |
|
| 362 | + $speed = substr($body_parse, 4, 3); |
|
| 364 | 363 | if ($speed != '...') { |
| 365 | 364 | $result['speed'] = intval($speed); |
| 366 | 365 | } |
| 367 | - $body_parse = substr($body_parse,7); |
|
| 366 | + $body_parse = substr($body_parse, 7); |
|
| 368 | 367 | } |
| 369 | 368 | // Check PHGR, PHG, RNG |
| 370 | 369 | } |
@@ -374,11 +373,11 @@ discard block |
||
| 374 | 373 | } |
| 375 | 374 | */ |
| 376 | 375 | if (strlen($body_parse) > 0) { |
| 377 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
| 376 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
| 378 | 377 | $altitude = intval($matches[1]); |
| 379 | 378 | $result['altitude'] = $altitude; |
| 380 | 379 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
| 381 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
| 380 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
| 382 | 381 | } |
| 383 | 382 | } |
| 384 | 383 | // Telemetry |
@@ -388,58 +387,58 @@ discard block |
||
| 388 | 387 | } |
| 389 | 388 | */ |
| 390 | 389 | // DAO |
| 391 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
| 390 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
| 392 | 391 | $dao = $matches[1]; |
| 393 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
| 392 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
| 394 | 393 | $dao_split = str_split($dao); |
| 395 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
| 396 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
| 394 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
| 395 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
| 397 | 396 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
| 398 | 397 | else $result['latitude'] += $lat_off; |
| 399 | 398 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
| 400 | 399 | else $result['longitude'] += $lon_off; |
| 401 | 400 | } |
| 402 | - $body_parse = substr($body_parse,6); |
|
| 401 | + $body_parse = substr($body_parse, 6); |
|
| 403 | 402 | } |
| 404 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
| 405 | - $result['ident'] = str_replace('_',' ',$matches[1]); |
|
| 403 | + if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
| 404 | + $result['ident'] = str_replace('_', ' ', $matches[1]); |
|
| 406 | 405 | } |
| 407 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
| 406 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
| 408 | 407 | $result['squawk'] = $matches[1]; |
| 409 | 408 | } |
| 410 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
| 409 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
| 411 | 410 | $result['aircraft_icao'] = $matches[1]; |
| 412 | 411 | } |
| 413 | - if (preg_match('/VR=([-0-9]*)/',$body_parse,$matches)) { |
|
| 412 | + if (preg_match('/VR=([-0-9]*)/', $body_parse, $matches)) { |
|
| 414 | 413 | $result['verticalrate'] = $matches[1]; |
| 415 | 414 | } |
| 416 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
| 415 | + if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { |
|
| 417 | 416 | $result['typeid'] = $matches[1]; |
| 418 | 417 | } |
| 419 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
| 418 | + if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) { |
|
| 420 | 419 | $result['statusid'] = $matches[1]; |
| 421 | 420 | } |
| 422 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
| 421 | + if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { |
|
| 423 | 422 | $result['imo'] = $matches[1]; |
| 424 | 423 | } |
| 425 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
| 424 | + if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { |
|
| 426 | 425 | $result['arrival_date'] = $matches[1]; |
| 427 | 426 | } |
| 428 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
| 429 | - $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
|
| 427 | + if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
| 428 | + $result['arrival_code'] = str_replace('_', ' ', $matches[1]); |
|
| 430 | 429 | } |
| 431 | 430 | // OGN comment |
| 432 | 431 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
| 433 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
| 432 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
| 434 | 433 | $id = $matches[1]; |
| 435 | 434 | //$mode = substr($id,0,2); |
| 436 | - $address = substr($id,2); |
|
| 437 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
| 435 | + $address = substr($id, 2); |
|
| 436 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
| 438 | 437 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
| 439 | 438 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
| 440 | 439 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
| 441 | 440 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
| 442 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
| 441 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
| 443 | 442 | $result['aircrafttype_code'] = $aircraftType; |
| 444 | 443 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
| 445 | 444 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -456,110 +455,110 @@ discard block |
||
| 456 | 455 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
| 457 | 456 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
| 458 | 457 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
| 459 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
| 458 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
| 460 | 459 | $result['stealth'] = $stealth; |
| 461 | 460 | $result['address'] = $address; |
| 462 | 461 | } |
| 463 | 462 | //Comment |
| 464 | 463 | $result['comment'] = trim($body_parse); |
| 465 | 464 | // parse weather |
| 466 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 465 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 467 | 466 | $result['wind_dir'] = intval($matches[1]); |
| 468 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
| 469 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
| 470 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
| 471 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 472 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 467 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
| 468 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
| 469 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
| 470 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 471 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 473 | 472 | $result['wind_dir'] = intval($matches[1]); |
| 474 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 475 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 476 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
| 477 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 478 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 473 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 474 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 475 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
| 476 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 477 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 479 | 478 | $result['wind_dir'] = intval($matches[1]); |
| 480 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 481 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 482 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 483 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 479 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 480 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 481 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 482 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 484 | 483 | $result['wind_dir'] = intval($matches[1]); |
| 485 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 486 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 487 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 484 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 485 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 486 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 488 | 487 | } |
| 489 | 488 | // temperature |
| 490 | 489 | //g012t088r000p000P000h38b10110 |
| 491 | 490 | //g011t086r000p000P000h29b10198 |
| 492 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
| 493 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 494 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 495 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 496 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 497 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 491 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
| 492 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
| 493 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
| 494 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
| 495 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
| 496 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
| 498 | 497 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
| 499 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 500 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
| 501 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
| 502 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 503 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 504 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 505 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
| 506 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 498 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
| 499 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
| 500 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
| 501 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
| 502 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
| 503 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
| 504 | + if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1); |
|
| 505 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
| 507 | 506 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
| 508 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 509 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
| 510 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
| 511 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 512 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 513 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 514 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 515 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 507 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
| 508 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
| 509 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
| 510 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
| 511 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
| 512 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
| 513 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
| 514 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
| 516 | 515 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
| 517 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 518 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
| 519 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
| 520 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 521 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 522 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 523 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 516 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
| 517 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
| 518 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
| 519 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
| 520 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
| 521 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
| 522 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
| 524 | 523 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
| 525 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 526 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
| 527 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
| 528 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 529 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 530 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 531 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 524 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
| 525 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
| 526 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
| 527 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
| 528 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
| 529 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
| 530 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
| 532 | 531 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
| 533 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 534 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
| 535 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
| 536 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 537 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 538 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 539 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 532 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
| 533 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
| 534 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
| 535 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
| 536 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
| 537 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
| 538 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
| 540 | 539 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
| 541 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 542 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
| 543 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
| 544 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 545 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 540 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
| 541 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
| 542 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
| 543 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
| 544 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
| 546 | 545 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
| 547 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
|
| 548 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
| 549 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
| 550 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 551 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 552 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 546 | + if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1); |
|
| 547 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
| 548 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
| 549 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
| 550 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
| 551 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
| 553 | 552 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
| 554 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 555 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
| 553 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
| 554 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
| 556 | 555 | } |
| 557 | 556 | $result['comment'] = trim($body_parse); |
| 558 | 557 | } |
| 559 | 558 | } else $result['comment'] = trim($body_parse); |
| 560 | 559 | } |
| 561 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
| 562 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
| 560 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
| 561 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
| 563 | 562 | if ($debug) print_r($result); |
| 564 | 563 | return $result; |
| 565 | 564 | } |
@@ -568,34 +567,34 @@ discard block |
||
| 568 | 567 | * Connect to APRS server |
| 569 | 568 | */ |
| 570 | 569 | public function connect() { |
| 571 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
| 570 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
| 572 | 571 | $aprs_connect = 0; |
| 573 | 572 | $aprs_keep = 120; |
| 574 | 573 | $aprs_last_tx = time(); |
| 575 | 574 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 576 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 575 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 577 | 576 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
| 578 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 577 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 579 | 578 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
| 580 | 579 | else $aprs_pass = '-1'; |
| 581 | - $aprs_filter = ''; |
|
| 580 | + $aprs_filter = ''; |
|
| 582 | 581 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
| 583 | 582 | $Common = new Common(); |
| 584 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
| 583 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
| 585 | 584 | if ($s !== false) { |
| 586 | 585 | echo 'Connected to APRS server! '."\n"; |
| 587 | 586 | $authstart = time(); |
| 588 | 587 | $this->socket = $s; |
| 589 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 590 | - socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
|
| 591 | - while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
|
| 588 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
| 589 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1); |
|
| 590 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
| 592 | 591 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
| 593 | 592 | echo 'APRS user verified !'."\n"; |
| 594 | 593 | $this->connected = true; |
| 595 | 594 | return true; |
| 596 | 595 | break; |
| 597 | 596 | } |
| 598 | - if (time()-$authstart > 5) { |
|
| 597 | + if (time() - $authstart > 5) { |
|
| 599 | 598 | echo 'APRS timeout'."\n"; |
| 600 | 599 | break; |
| 601 | 600 | } |
@@ -617,7 +616,7 @@ discard block |
||
| 617 | 616 | public function send($data) { |
| 618 | 617 | global $globalDebug; |
| 619 | 618 | if ($this->connected === false) $this->connect(); |
| 620 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
| 619 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
| 621 | 620 | if ($send === FALSE) { |
| 622 | 621 | if ($globalDebug) echo 'Reconnect...'; |
| 623 | 622 | socket_close($this->socket); |
@@ -627,17 +626,17 @@ discard block |
||
| 627 | 626 | } |
| 628 | 627 | |
| 629 | 628 | class APRSSpotter extends APRS { |
| 630 | - public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { |
|
| 629 | + public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { |
|
| 631 | 630 | $Common = new Common(); |
| 632 | 631 | date_default_timezone_set('UTC'); |
| 633 | 632 | if ($latitude != '' && $longitude != '') { |
| 634 | 633 | $lat = $latitude; |
| 635 | 634 | $long = $longitude; |
| 636 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
| 637 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
| 638 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
| 639 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
| 640 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
| 635 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
| 636 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
| 637 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
| 638 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
| 639 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
| 641 | 640 | $w = $w1.$w2; |
| 642 | 641 | //$w = '00'; |
| 643 | 642 | $custom = ''; |
@@ -664,26 +663,26 @@ discard block |
||
| 664 | 663 | $geoid= round($GeoidClass->get($lat,$long)*3.28084,2); |
| 665 | 664 | $altitude_real = round($altitude_real + $geoid); |
| 666 | 665 | */ |
| 667 | - $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 666 | + $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 668 | 667 | } |
| 669 | 668 | } |
| 670 | 669 | } |
| 671 | 670 | class APRSMarine extends APRS { |
| 672 | - public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) { |
|
| 671 | + public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) { |
|
| 673 | 672 | $Common = new Common(); |
| 674 | 673 | date_default_timezone_set('UTC'); |
| 675 | 674 | if ($latitude != '' && $longitude != '') { |
| 676 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
| 677 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
| 678 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
| 679 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
| 680 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
| 675 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
| 676 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
| 677 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
| 678 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
| 679 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
| 681 | 680 | $w = $w1.$w2; |
| 682 | 681 | //$w = '00'; |
| 683 | 682 | $custom = ''; |
| 684 | 683 | if ($ident != '') { |
| 685 | 684 | if ($custom != '') $custom .= '/'; |
| 686 | - $custom .= 'CS='.str_replace(' ','_',$ident); |
|
| 685 | + $custom .= 'CS='.str_replace(' ', '_', $ident); |
|
| 687 | 686 | } |
| 688 | 687 | if ($typeid != '') { |
| 689 | 688 | if ($custom != '') $custom .= '/'; |
@@ -703,11 +702,11 @@ discard block |
||
| 703 | 702 | } |
| 704 | 703 | if ($arrival_code != '') { |
| 705 | 704 | if ($custom != '') $custom .= '/'; |
| 706 | - $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
|
| 705 | + $custom .= 'AC='.str_replace(' ', '_', $arrival_code); |
|
| 707 | 706 | } |
| 708 | 707 | if ($custom != '') $custom = ' '.$custom; |
| 709 | 708 | $altitude = 0; |
| 710 | - $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 709 | + $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 711 | 710 | } |
| 712 | 711 | } |
| 713 | 712 | } |
@@ -190,12 +190,20 @@ |
||
| 190 | 190 | return 1; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | + /** |
|
| 194 | + * @param double $lat |
|
| 195 | + * @param integer $isodd |
|
| 196 | + */ |
|
| 193 | 197 | private function cprN($lat,$isodd) { |
| 194 | 198 | $nl = $this->cprNL($lat) - $isodd; |
| 195 | 199 | if ($nl > 1) return $nl; |
| 196 | 200 | else return 1; |
| 197 | 201 | } |
| 198 | 202 | |
| 203 | + /** |
|
| 204 | + * @param string $msg |
|
| 205 | + * @param string $bin |
|
| 206 | + */ |
|
| 199 | 207 | private function parityCheck($msg, $bin) { |
| 200 | 208 | $modes_checksum_table = array( |
| 201 | 209 | 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178, |
@@ -198,20 +198,20 @@ |
||
| 198 | 198 | |
| 199 | 199 | private function parityCheck($msg, $bin) { |
| 200 | 200 | $modes_checksum_table = array( |
| 201 | - 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178, |
|
| 202 | - 0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14, |
|
| 203 | - 0x682e0a, 0x341705, 0xe5f186, 0x72f8c3, 0xc68665, 0x9cb936, 0x4e5c9b, 0xd8d449, |
|
| 204 | - 0x939020, 0x49c810, 0x24e408, 0x127204, 0x093902, 0x049c81, 0xfdb444, 0x7eda22, |
|
| 205 | - 0x3f6d11, 0xe04c8c, 0x702646, 0x381323, 0xe3f395, 0x8e03ce, 0x4701e7, 0xdc7af7, |
|
| 206 | - 0x91c77f, 0xb719bb, 0xa476d9, 0xadc168, 0x56e0b4, 0x2b705a, 0x15b82d, 0xf52612, |
|
| 207 | - 0x7a9309, 0xc2b380, 0x6159c0, 0x30ace0, 0x185670, 0x0c2b38, 0x06159c, 0x030ace, |
|
| 208 | - 0x018567, 0xff38b7, 0x80665f, 0xbfc92b, 0xa01e91, 0xaff54c, 0x57faa6, 0x2bfd53, |
|
| 209 | - 0xea04ad, 0x8af852, 0x457c29, 0xdd4410, 0x6ea208, 0x375104, 0x1ba882, 0x0dd441, |
|
| 210 | - 0xf91024, 0x7c8812, 0x3e4409, 0xe0d800, 0x706c00, 0x383600, 0x1c1b00, 0x0e0d80, |
|
| 211 | - 0x0706c0, 0x038360, 0x01c1b0, 0x00e0d8, 0x00706c, 0x003836, 0x001c1b, 0xfff409, |
|
| 212 | - 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, |
|
| 213 | - 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, |
|
| 214 | - 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000 |
|
| 201 | + 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178, |
|
| 202 | + 0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14, |
|
| 203 | + 0x682e0a, 0x341705, 0xe5f186, 0x72f8c3, 0xc68665, 0x9cb936, 0x4e5c9b, 0xd8d449, |
|
| 204 | + 0x939020, 0x49c810, 0x24e408, 0x127204, 0x093902, 0x049c81, 0xfdb444, 0x7eda22, |
|
| 205 | + 0x3f6d11, 0xe04c8c, 0x702646, 0x381323, 0xe3f395, 0x8e03ce, 0x4701e7, 0xdc7af7, |
|
| 206 | + 0x91c77f, 0xb719bb, 0xa476d9, 0xadc168, 0x56e0b4, 0x2b705a, 0x15b82d, 0xf52612, |
|
| 207 | + 0x7a9309, 0xc2b380, 0x6159c0, 0x30ace0, 0x185670, 0x0c2b38, 0x06159c, 0x030ace, |
|
| 208 | + 0x018567, 0xff38b7, 0x80665f, 0xbfc92b, 0xa01e91, 0xaff54c, 0x57faa6, 0x2bfd53, |
|
| 209 | + 0xea04ad, 0x8af852, 0x457c29, 0xdd4410, 0x6ea208, 0x375104, 0x1ba882, 0x0dd441, |
|
| 210 | + 0xf91024, 0x7c8812, 0x3e4409, 0xe0d800, 0x706c00, 0x383600, 0x1c1b00, 0x0e0d80, |
|
| 211 | + 0x0706c0, 0x038360, 0x01c1b0, 0x00e0d8, 0x00706c, 0x003836, 0x001c1b, 0xfff409, |
|
| 212 | + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, |
|
| 213 | + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, |
|
| 214 | + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000 |
|
| 215 | 215 | ); |
| 216 | 216 | $crc = 0; |
| 217 | 217 | $checksum = intval(substr($msg,22,6),16); |
@@ -18,25 +18,25 @@ discard block |
||
| 18 | 18 | public function parse($buffer) { |
| 19 | 19 | // Not yet finished, no CRC checks |
| 20 | 20 | $data = array(); |
| 21 | - $typehex = substr($buffer,0,1); |
|
| 22 | - if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1); |
|
| 21 | + $typehex = substr($buffer, 0, 1); |
|
| 22 | + if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1); |
|
| 23 | 23 | //elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
| 24 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-1); |
|
| 25 | - else $hex = substr($buffer,1,-1); |
|
| 26 | - $bin = gmp_strval( gmp_init($hex,16), 2); |
|
| 24 | + elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -1); |
|
| 25 | + else $hex = substr($buffer, 1, -1); |
|
| 26 | + $bin = gmp_strval(gmp_init($hex, 16), 2); |
|
| 27 | 27 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
| 28 | 28 | //if (strlen($hex) == 28) { |
| 29 | 29 | //echo strlen($hex); |
| 30 | 30 | //echo $hex; |
| 31 | 31 | if (strlen($hex) == 28 || strlen($hex) == 16) { |
| 32 | - $df = intval(substr($bin,0,5),2); |
|
| 32 | + $df = intval(substr($bin, 0, 5), 2); |
|
| 33 | 33 | //$ca = intval(substr($bin,5,3),2); |
| 34 | 34 | // Only support DF17 for now |
| 35 | 35 | //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) { |
| 36 | - if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) { |
|
| 37 | - $icao = substr($hex,2,6); |
|
| 36 | + if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) { |
|
| 37 | + $icao = substr($hex, 2, 6); |
|
| 38 | 38 | $data['hex'] = $icao; |
| 39 | - $tc = intval(substr($bin,32,5),2); |
|
| 39 | + $tc = intval(substr($bin, 32, 5), 2); |
|
| 40 | 40 | if ($tc >= 1 && $tc <= 4) { |
| 41 | 41 | // Category: |
| 42 | 42 | // 1 = light aircraft <= 7000 kg |
@@ -59,67 +59,67 @@ discard block |
||
| 59 | 59 | // 22 = fixed ground or tethered obstruction |
| 60 | 60 | // 23 to 24 = reserved |
| 61 | 61 | //$data['category'] = intval(substr($bin,5,3),2); |
| 62 | - $data['category'] = intval(substr($bin,37,3),2); |
|
| 62 | + $data['category'] = intval(substr($bin, 37, 3), 2); |
|
| 63 | 63 | //callsign |
| 64 | - $csbin = substr($bin,40,56); |
|
| 64 | + $csbin = substr($bin, 40, 56); |
|
| 65 | 65 | $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'); |
| 66 | 66 | $cs = ''; |
| 67 | - $cs .= $charset[intval(substr($csbin,0,6),2)]; |
|
| 68 | - $cs .= $charset[intval(substr($csbin,6,6),2)]; |
|
| 69 | - $cs .= $charset[intval(substr($csbin,12,6),2)]; |
|
| 70 | - $cs .= $charset[intval(substr($csbin,18,6),2)]; |
|
| 71 | - $cs .= $charset[intval(substr($csbin,24,6),2)]; |
|
| 72 | - $cs .= $charset[intval(substr($csbin,30,6),2)]; |
|
| 73 | - $cs .= $charset[intval(substr($csbin,36,6),2)]; |
|
| 74 | - $cs .= $charset[intval(substr($csbin,42,6),2)]; |
|
| 75 | - $cs = str_replace('_','',$cs); |
|
| 76 | - $cs = str_replace('#','',$cs); |
|
| 67 | + $cs .= $charset[intval(substr($csbin, 0, 6), 2)]; |
|
| 68 | + $cs .= $charset[intval(substr($csbin, 6, 6), 2)]; |
|
| 69 | + $cs .= $charset[intval(substr($csbin, 12, 6), 2)]; |
|
| 70 | + $cs .= $charset[intval(substr($csbin, 18, 6), 2)]; |
|
| 71 | + $cs .= $charset[intval(substr($csbin, 24, 6), 2)]; |
|
| 72 | + $cs .= $charset[intval(substr($csbin, 30, 6), 2)]; |
|
| 73 | + $cs .= $charset[intval(substr($csbin, 36, 6), 2)]; |
|
| 74 | + $cs .= $charset[intval(substr($csbin, 42, 6), 2)]; |
|
| 75 | + $cs = str_replace('_', '', $cs); |
|
| 76 | + $cs = str_replace('#', '', $cs); |
|
| 77 | 77 | $callsign = $cs; |
| 78 | 78 | $data['ident'] = $callsign; |
| 79 | 79 | } elseif ($tc >= 9 && $tc <= 18) { |
| 80 | 80 | // Check Q-bit |
| 81 | - $q = substr($bin,47,1); |
|
| 81 | + $q = substr($bin, 47, 1); |
|
| 82 | 82 | if ($q) { |
| 83 | - $n = intval(substr($bin,40,7).substr($bin,48,4),2); |
|
| 84 | - $alt = $n*25-1000; |
|
| 83 | + $n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2); |
|
| 84 | + $alt = $n*25 - 1000; |
|
| 85 | 85 | $data['altitude'] = $alt; |
| 86 | 86 | } |
| 87 | 87 | // Check odd/even flag |
| 88 | - $oe = substr($bin,53,1); |
|
| 88 | + $oe = substr($bin, 53, 1); |
|
| 89 | 89 | //if ($oe) => odd else even |
| 90 | 90 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
| 91 | - $cprlat = intval(substr($bin,54,17),2)/131072.0; |
|
| 92 | - $cprlon = intval(substr($bin,71,17),2)/131072.0; |
|
| 93 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
| 91 | + $cprlat = intval(substr($bin, 54, 17), 2)/131072.0; |
|
| 92 | + $cprlon = intval(substr($bin, 71, 17), 2)/131072.0; |
|
| 93 | + if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time()); |
|
| 94 | 94 | elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
| 95 | 95 | $cprlat_odd = $cprlat; |
| 96 | 96 | $cprlon_odd = $cprlon; |
| 97 | 97 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
| 98 | 98 | $cprlon_even = $this::$latlon[$icao]['longitude']; |
| 99 | - $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
|
| 100 | - $lat_even = (360.0/60)*($j%60+$cprlat_even); |
|
| 101 | - $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
|
| 99 | + $j = 59*$cprlat_even - 60*$cprlat_odd + 0.5; |
|
| 100 | + $lat_even = (360.0/60)*($j%60 + $cprlat_even); |
|
| 101 | + $lat_odd = (360.0/59)*($j%59 + $cprlat_odd); |
|
| 102 | 102 | if ($lat_even >= 270) $lat_even = $lat_even - 360; |
| 103 | 103 | if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
| 104 | 104 | // check latitude zone |
| 105 | 105 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
| 106 | 106 | if ($this::$latlon[$icao]['created'] > time()) { |
| 107 | - $ni = $this->cprN($lat_even,0); |
|
| 108 | - $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
|
| 109 | - $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
|
| 107 | + $ni = $this->cprN($lat_even, 0); |
|
| 108 | + $m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5); |
|
| 109 | + $lon = (360.0/$ni)*($m%$ni + $cprlon_even); |
|
| 110 | 110 | $lat = $lat_even; |
| 111 | - if ($lon > 180) $lon = $lon -360; |
|
| 111 | + if ($lon > 180) $lon = $lon - 360; |
|
| 112 | 112 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
| 113 | 113 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
| 114 | 114 | $data['latitude'] = $lat; |
| 115 | 115 | $data['longitude'] = $lon; |
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | - $ni = $this->cprN($lat_odd,1); |
|
| 119 | - $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
|
| 120 | - $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
|
| 118 | + $ni = $this->cprN($lat_odd, 1); |
|
| 119 | + $m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5); |
|
| 120 | + $lon = (360.0/$ni)*($m%$ni + $cprlon_odd); |
|
| 121 | 121 | $lat = $lat_odd; |
| 122 | - if ($lon > 180) $lon = $lon -360; |
|
| 122 | + if ($lon > 180) $lon = $lon - 360; |
|
| 123 | 123 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
| 124 | 124 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
| 125 | 125 | $data['latitude'] = $lat; |
@@ -131,15 +131,15 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | } elseif ($tc == 19) { |
| 133 | 133 | // speed & heading |
| 134 | - $v_ew_dir = intval(substr($bin,45,1)); |
|
| 135 | - $v_ew = intval(substr($bin,46,10),2); |
|
| 136 | - $v_ns_dir = intval(substr($bin,56,1)); |
|
| 137 | - $v_ns = intval(substr($bin,57,10),2); |
|
| 134 | + $v_ew_dir = intval(substr($bin, 45, 1)); |
|
| 135 | + $v_ew = intval(substr($bin, 46, 10), 2); |
|
| 136 | + $v_ns_dir = intval(substr($bin, 56, 1)); |
|
| 137 | + $v_ns = intval(substr($bin, 57, 10), 2); |
|
| 138 | 138 | if ($v_ew_dir) $v_ew = -1*$v_ew; |
| 139 | 139 | if ($v_ns_dir) $v_ns = -1*$v_ns; |
| 140 | - $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
|
| 141 | - $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
|
| 142 | - if ($heading <0) $heading = $heading+360; |
|
| 140 | + $speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew); |
|
| 141 | + $heading = atan2($v_ew, $v_ns)*360.0/(2*pi()); |
|
| 142 | + if ($heading < 0) $heading = $heading + 360; |
|
| 143 | 143 | $data['speed'] = $speed; |
| 144 | 144 | $data['heading'] = $heading; |
| 145 | 145 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * Lookup table to convert the latitude to index. |
| 155 | 155 | */ |
| 156 | 156 | private function cprNL($lat) { |
| 157 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
| 157 | + if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
| 158 | 158 | if ($lat < 10.47047130) return 59; |
| 159 | 159 | if ($lat < 14.82817437) return 58; |
| 160 | 160 | if ($lat < 18.18626357) return 57; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | return 1; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - private function cprN($lat,$isodd) { |
|
| 219 | + private function cprN($lat, $isodd) { |
|
| 220 | 220 | $nl = $this->cprNL($lat) - $isodd; |
| 221 | 221 | if ($nl > 1) return $nl; |
| 222 | 222 | else return 1; |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000 |
| 241 | 241 | ); |
| 242 | 242 | $crc = 0; |
| 243 | - $checksum = intval(substr($msg,22,6),16); |
|
| 243 | + $checksum = intval(substr($msg, 22, 6), 16); |
|
| 244 | 244 | for ($j = 0; $j < strlen($bin); $j++) { |
| 245 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
| 245 | + if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0); |
|
| 246 | 246 | } |
| 247 | 247 | if ($crc == $checksum) return true; |
| 248 | 248 | else { |
@@ -264,10 +264,10 @@ discard block |
||
| 264 | 264 | $msg['aircraftid'] = hexdec($data['address']); |
| 265 | 265 | $msg['hex'] = $data['address']; |
| 266 | 266 | $msg['flightid'] = hexdec($data['address']); |
| 267 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
| 268 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
| 269 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
| 270 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
| 267 | + $msg['date_gen'] = date('Y/m/d', $data['timestamp']); |
|
| 268 | + $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180'; |
|
| 269 | + $msg['date_log'] = date('Y/m/d', $data['timestamp']); |
|
| 270 | + $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180'; |
|
| 271 | 271 | $msg['callsign'] = $data['ident']; |
| 272 | 272 | $msg['altitude'] = ''; |
| 273 | 273 | $msg['speed'] = ''; |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $msg['emergency'] = ''; |
| 281 | 281 | $msg['SPI'] = ''; |
| 282 | 282 | $msg['ground'] = ''; |
| 283 | - $result[] = implode(',',$msg); |
|
| 283 | + $result[] = implode(',', $msg); |
|
| 284 | 284 | } |
| 285 | 285 | if (isset($data['latitude']) && $data['latitude'] != 0) { |
| 286 | 286 | $msg = array(); |
@@ -290,10 +290,10 @@ discard block |
||
| 290 | 290 | $msg['aircraftid'] = hexdec($data['address']); |
| 291 | 291 | $msg['hex'] = $data['address']; |
| 292 | 292 | $msg['flightid'] = hexdec($data['address']); |
| 293 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
| 294 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
| 295 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
| 296 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
| 293 | + $msg['date_gen'] = date('Y/m/d', $data['timestamp']); |
|
| 294 | + $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180'; |
|
| 295 | + $msg['date_log'] = date('Y/m/d', $data['timestamp']); |
|
| 296 | + $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180'; |
|
| 297 | 297 | $msg['callsign'] = ''; |
| 298 | 298 | if (isset($data['altitude'])) $msg['altitude'] = $data['altitude']; |
| 299 | 299 | else $msg['altitude'] = ''; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | $msg['SPI'] = 0; |
| 312 | 312 | if (isset($data['ground'])) $msg['ground'] = 1; |
| 313 | 313 | else $msg['ground'] = 0; |
| 314 | - $result[] = implode(',',$msg); |
|
| 314 | + $result[] = implode(',', $msg); |
|
| 315 | 315 | } |
| 316 | 316 | return $result; |
| 317 | 317 | } |
@@ -19,10 +19,15 @@ discard block |
||
| 19 | 19 | // Not yet finished, no CRC checks |
| 20 | 20 | $data = array(); |
| 21 | 21 | $typehex = substr($buffer,0,1); |
| 22 | - if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1); |
|
| 22 | + if ($typehex == '*' || $typehex == ':') { |
|
| 23 | + $hex = substr($buffer,1); |
|
| 24 | + } |
|
| 23 | 25 | //elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
| 24 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-1); |
|
| 25 | - else $hex = substr($buffer,1,-1); |
|
| 26 | + elseif ($typehex == '@' || $typehex == '%') { |
|
| 27 | + $hex = substr($buffer,13,-1); |
|
| 28 | + } else { |
|
| 29 | + $hex = substr($buffer,1,-1); |
|
| 30 | + } |
|
| 26 | 31 | $bin = gmp_strval( gmp_init($hex,16), 2); |
| 27 | 32 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
| 28 | 33 | //if (strlen($hex) == 28) { |
@@ -90,8 +95,9 @@ discard block |
||
| 90 | 95 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
| 91 | 96 | $cprlat = intval(substr($bin,54,17),2)/131072.0; |
| 92 | 97 | $cprlon = intval(substr($bin,71,17),2)/131072.0; |
| 93 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
| 94 | - elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
| 98 | + if ($oe == 0) { |
|
| 99 | + $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
| 100 | + } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
| 95 | 101 | $cprlat_odd = $cprlat; |
| 96 | 102 | $cprlon_odd = $cprlon; |
| 97 | 103 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
@@ -99,8 +105,12 @@ discard block |
||
| 99 | 105 | $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
| 100 | 106 | $lat_even = (360.0/60)*($j%60+$cprlat_even); |
| 101 | 107 | $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
| 102 | - if ($lat_even >= 270) $lat_even = $lat_even - 360; |
|
| 103 | - if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
|
| 108 | + if ($lat_even >= 270) { |
|
| 109 | + $lat_even = $lat_even - 360; |
|
| 110 | + } |
|
| 111 | + if ($lat_odd >= 270) { |
|
| 112 | + $lat_odd = $lat_odd - 360; |
|
| 113 | + } |
|
| 104 | 114 | // check latitude zone |
| 105 | 115 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
| 106 | 116 | if ($this::$latlon[$icao]['created'] > time()) { |
@@ -108,7 +118,9 @@ discard block |
||
| 108 | 118 | $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
| 109 | 119 | $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
| 110 | 120 | $lat = $lat_even; |
| 111 | - if ($lon > 180) $lon = $lon -360; |
|
| 121 | + if ($lon > 180) { |
|
| 122 | + $lon = $lon -360; |
|
| 123 | + } |
|
| 112 | 124 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
| 113 | 125 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
| 114 | 126 | $data['latitude'] = $lat; |
@@ -119,14 +131,18 @@ discard block |
||
| 119 | 131 | $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
| 120 | 132 | $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
| 121 | 133 | $lat = $lat_odd; |
| 122 | - if ($lon > 180) $lon = $lon -360; |
|
| 134 | + if ($lon > 180) { |
|
| 135 | + $lon = $lon -360; |
|
| 136 | + } |
|
| 123 | 137 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
| 124 | 138 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
| 125 | 139 | $data['latitude'] = $lat; |
| 126 | 140 | $data['longitude'] = $lon; |
| 127 | 141 | } |
| 128 | 142 | } |
| 129 | - } else echo "Not cprNL"; |
|
| 143 | + } else { |
|
| 144 | + echo "Not cprNL"; |
|
| 145 | + } |
|
| 130 | 146 | unset($this::$latlon[$icao]); |
| 131 | 147 | } |
| 132 | 148 | } elseif ($tc == 19) { |
@@ -135,11 +151,17 @@ discard block |
||
| 135 | 151 | $v_ew = intval(substr($bin,46,10),2); |
| 136 | 152 | $v_ns_dir = intval(substr($bin,56,1)); |
| 137 | 153 | $v_ns = intval(substr($bin,57,10),2); |
| 138 | - if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
| 139 | - if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
| 154 | + if ($v_ew_dir) { |
|
| 155 | + $v_ew = -1*$v_ew; |
|
| 156 | + } |
|
| 157 | + if ($v_ns_dir) { |
|
| 158 | + $v_ns = -1*$v_ns; |
|
| 159 | + } |
|
| 140 | 160 | $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
| 141 | 161 | $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
| 142 | - if ($heading <0) $heading = $heading+360; |
|
| 162 | + if ($heading <0) { |
|
| 163 | + $heading = $heading+360; |
|
| 164 | + } |
|
| 143 | 165 | $data['speed'] = $speed; |
| 144 | 166 | $data['heading'] = $heading; |
| 145 | 167 | } |
@@ -154,72 +176,194 @@ discard block |
||
| 154 | 176 | * Lookup table to convert the latitude to index. |
| 155 | 177 | */ |
| 156 | 178 | private function cprNL($lat) { |
| 157 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
| 158 | - if ($lat < 10.47047130) return 59; |
|
| 159 | - if ($lat < 14.82817437) return 58; |
|
| 160 | - if ($lat < 18.18626357) return 57; |
|
| 161 | - if ($lat < 21.02939493) return 56; |
|
| 162 | - if ($lat < 23.54504487) return 55; |
|
| 163 | - if ($lat < 25.82924707) return 54; |
|
| 164 | - if ($lat < 27.93898710) return 53; |
|
| 165 | - if ($lat < 29.91135686) return 52; |
|
| 166 | - if ($lat < 31.77209708) return 51; |
|
| 167 | - if ($lat < 33.53993436) return 50; |
|
| 168 | - if ($lat < 35.22899598) return 49; |
|
| 169 | - if ($lat < 36.85025108) return 48; |
|
| 170 | - if ($lat < 38.41241892) return 47; |
|
| 171 | - if ($lat < 39.92256684) return 46; |
|
| 172 | - if ($lat < 41.38651832) return 45; |
|
| 173 | - if ($lat < 42.80914012) return 44; |
|
| 174 | - if ($lat < 44.19454951) return 43; |
|
| 175 | - if ($lat < 45.54626723) return 42; |
|
| 176 | - if ($lat < 46.86733252) return 41; |
|
| 177 | - if ($lat < 48.16039128) return 40; |
|
| 178 | - if ($lat < 49.42776439) return 39; |
|
| 179 | - if ($lat < 50.67150166) return 38; |
|
| 180 | - if ($lat < 51.89342469) return 37; |
|
| 181 | - if ($lat < 53.09516153) return 36; |
|
| 182 | - if ($lat < 54.27817472) return 35; |
|
| 183 | - if ($lat < 55.44378444) return 34; |
|
| 184 | - if ($lat < 56.59318756) return 33; |
|
| 185 | - if ($lat < 57.72747354) return 32; |
|
| 186 | - if ($lat < 58.84763776) return 31; |
|
| 187 | - if ($lat < 59.95459277) return 30; |
|
| 188 | - if ($lat < 61.04917774) return 29; |
|
| 189 | - if ($lat < 62.13216659) return 28; |
|
| 190 | - if ($lat < 63.20427479) return 27; |
|
| 191 | - if ($lat < 64.26616523) return 26; |
|
| 192 | - if ($lat < 65.31845310) return 25; |
|
| 193 | - if ($lat < 66.36171008) return 24; |
|
| 194 | - if ($lat < 67.39646774) return 23; |
|
| 195 | - if ($lat < 68.42322022) return 22; |
|
| 196 | - if ($lat < 69.44242631) return 21; |
|
| 197 | - if ($lat < 70.45451075) return 20; |
|
| 198 | - if ($lat < 71.45986473) return 19; |
|
| 199 | - if ($lat < 72.45884545) return 18; |
|
| 200 | - if ($lat < 73.45177442) return 17; |
|
| 201 | - if ($lat < 74.43893416) return 16; |
|
| 202 | - if ($lat < 75.42056257) return 15; |
|
| 203 | - if ($lat < 76.39684391) return 14; |
|
| 204 | - if ($lat < 77.36789461) return 13; |
|
| 205 | - if ($lat < 78.33374083) return 12; |
|
| 206 | - if ($lat < 79.29428225) return 11; |
|
| 207 | - if ($lat < 80.24923213) return 10; |
|
| 208 | - if ($lat < 81.19801349) return 9; |
|
| 209 | - if ($lat < 82.13956981) return 8; |
|
| 210 | - if ($lat < 83.07199445) return 7; |
|
| 211 | - if ($lat < 83.99173563) return 6; |
|
| 212 | - if ($lat < 84.89166191) return 5; |
|
| 213 | - if ($lat < 85.75541621) return 4; |
|
| 214 | - if ($lat < 86.53536998) return 3; |
|
| 215 | - if ($lat < 87.00000000) return 2; |
|
| 179 | + if ($lat < 0) { |
|
| 180 | + $lat = -$lat; |
|
| 181 | + } |
|
| 182 | + // Table is simmetric about the equator. |
|
| 183 | + if ($lat < 10.47047130) { |
|
| 184 | + return 59; |
|
| 185 | + } |
|
| 186 | + if ($lat < 14.82817437) { |
|
| 187 | + return 58; |
|
| 188 | + } |
|
| 189 | + if ($lat < 18.18626357) { |
|
| 190 | + return 57; |
|
| 191 | + } |
|
| 192 | + if ($lat < 21.02939493) { |
|
| 193 | + return 56; |
|
| 194 | + } |
|
| 195 | + if ($lat < 23.54504487) { |
|
| 196 | + return 55; |
|
| 197 | + } |
|
| 198 | + if ($lat < 25.82924707) { |
|
| 199 | + return 54; |
|
| 200 | + } |
|
| 201 | + if ($lat < 27.93898710) { |
|
| 202 | + return 53; |
|
| 203 | + } |
|
| 204 | + if ($lat < 29.91135686) { |
|
| 205 | + return 52; |
|
| 206 | + } |
|
| 207 | + if ($lat < 31.77209708) { |
|
| 208 | + return 51; |
|
| 209 | + } |
|
| 210 | + if ($lat < 33.53993436) { |
|
| 211 | + return 50; |
|
| 212 | + } |
|
| 213 | + if ($lat < 35.22899598) { |
|
| 214 | + return 49; |
|
| 215 | + } |
|
| 216 | + if ($lat < 36.85025108) { |
|
| 217 | + return 48; |
|
| 218 | + } |
|
| 219 | + if ($lat < 38.41241892) { |
|
| 220 | + return 47; |
|
| 221 | + } |
|
| 222 | + if ($lat < 39.92256684) { |
|
| 223 | + return 46; |
|
| 224 | + } |
|
| 225 | + if ($lat < 41.38651832) { |
|
| 226 | + return 45; |
|
| 227 | + } |
|
| 228 | + if ($lat < 42.80914012) { |
|
| 229 | + return 44; |
|
| 230 | + } |
|
| 231 | + if ($lat < 44.19454951) { |
|
| 232 | + return 43; |
|
| 233 | + } |
|
| 234 | + if ($lat < 45.54626723) { |
|
| 235 | + return 42; |
|
| 236 | + } |
|
| 237 | + if ($lat < 46.86733252) { |
|
| 238 | + return 41; |
|
| 239 | + } |
|
| 240 | + if ($lat < 48.16039128) { |
|
| 241 | + return 40; |
|
| 242 | + } |
|
| 243 | + if ($lat < 49.42776439) { |
|
| 244 | + return 39; |
|
| 245 | + } |
|
| 246 | + if ($lat < 50.67150166) { |
|
| 247 | + return 38; |
|
| 248 | + } |
|
| 249 | + if ($lat < 51.89342469) { |
|
| 250 | + return 37; |
|
| 251 | + } |
|
| 252 | + if ($lat < 53.09516153) { |
|
| 253 | + return 36; |
|
| 254 | + } |
|
| 255 | + if ($lat < 54.27817472) { |
|
| 256 | + return 35; |
|
| 257 | + } |
|
| 258 | + if ($lat < 55.44378444) { |
|
| 259 | + return 34; |
|
| 260 | + } |
|
| 261 | + if ($lat < 56.59318756) { |
|
| 262 | + return 33; |
|
| 263 | + } |
|
| 264 | + if ($lat < 57.72747354) { |
|
| 265 | + return 32; |
|
| 266 | + } |
|
| 267 | + if ($lat < 58.84763776) { |
|
| 268 | + return 31; |
|
| 269 | + } |
|
| 270 | + if ($lat < 59.95459277) { |
|
| 271 | + return 30; |
|
| 272 | + } |
|
| 273 | + if ($lat < 61.04917774) { |
|
| 274 | + return 29; |
|
| 275 | + } |
|
| 276 | + if ($lat < 62.13216659) { |
|
| 277 | + return 28; |
|
| 278 | + } |
|
| 279 | + if ($lat < 63.20427479) { |
|
| 280 | + return 27; |
|
| 281 | + } |
|
| 282 | + if ($lat < 64.26616523) { |
|
| 283 | + return 26; |
|
| 284 | + } |
|
| 285 | + if ($lat < 65.31845310) { |
|
| 286 | + return 25; |
|
| 287 | + } |
|
| 288 | + if ($lat < 66.36171008) { |
|
| 289 | + return 24; |
|
| 290 | + } |
|
| 291 | + if ($lat < 67.39646774) { |
|
| 292 | + return 23; |
|
| 293 | + } |
|
| 294 | + if ($lat < 68.42322022) { |
|
| 295 | + return 22; |
|
| 296 | + } |
|
| 297 | + if ($lat < 69.44242631) { |
|
| 298 | + return 21; |
|
| 299 | + } |
|
| 300 | + if ($lat < 70.45451075) { |
|
| 301 | + return 20; |
|
| 302 | + } |
|
| 303 | + if ($lat < 71.45986473) { |
|
| 304 | + return 19; |
|
| 305 | + } |
|
| 306 | + if ($lat < 72.45884545) { |
|
| 307 | + return 18; |
|
| 308 | + } |
|
| 309 | + if ($lat < 73.45177442) { |
|
| 310 | + return 17; |
|
| 311 | + } |
|
| 312 | + if ($lat < 74.43893416) { |
|
| 313 | + return 16; |
|
| 314 | + } |
|
| 315 | + if ($lat < 75.42056257) { |
|
| 316 | + return 15; |
|
| 317 | + } |
|
| 318 | + if ($lat < 76.39684391) { |
|
| 319 | + return 14; |
|
| 320 | + } |
|
| 321 | + if ($lat < 77.36789461) { |
|
| 322 | + return 13; |
|
| 323 | + } |
|
| 324 | + if ($lat < 78.33374083) { |
|
| 325 | + return 12; |
|
| 326 | + } |
|
| 327 | + if ($lat < 79.29428225) { |
|
| 328 | + return 11; |
|
| 329 | + } |
|
| 330 | + if ($lat < 80.24923213) { |
|
| 331 | + return 10; |
|
| 332 | + } |
|
| 333 | + if ($lat < 81.19801349) { |
|
| 334 | + return 9; |
|
| 335 | + } |
|
| 336 | + if ($lat < 82.13956981) { |
|
| 337 | + return 8; |
|
| 338 | + } |
|
| 339 | + if ($lat < 83.07199445) { |
|
| 340 | + return 7; |
|
| 341 | + } |
|
| 342 | + if ($lat < 83.99173563) { |
|
| 343 | + return 6; |
|
| 344 | + } |
|
| 345 | + if ($lat < 84.89166191) { |
|
| 346 | + return 5; |
|
| 347 | + } |
|
| 348 | + if ($lat < 85.75541621) { |
|
| 349 | + return 4; |
|
| 350 | + } |
|
| 351 | + if ($lat < 86.53536998) { |
|
| 352 | + return 3; |
|
| 353 | + } |
|
| 354 | + if ($lat < 87.00000000) { |
|
| 355 | + return 2; |
|
| 356 | + } |
|
| 216 | 357 | return 1; |
| 217 | 358 | } |
| 218 | 359 | |
| 219 | 360 | private function cprN($lat,$isodd) { |
| 220 | 361 | $nl = $this->cprNL($lat) - $isodd; |
| 221 | - if ($nl > 1) return $nl; |
|
| 222 | - else return 1; |
|
| 362 | + if ($nl > 1) { |
|
| 363 | + return $nl; |
|
| 364 | + } else { |
|
| 365 | + return 1; |
|
| 366 | + } |
|
| 223 | 367 | } |
| 224 | 368 | |
| 225 | 369 | private function parityCheck($msg, $bin) { |
@@ -242,10 +386,13 @@ discard block |
||
| 242 | 386 | $crc = 0; |
| 243 | 387 | $checksum = intval(substr($msg,22,6),16); |
| 244 | 388 | for ($j = 0; $j < strlen($bin); $j++) { |
| 245 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
| 389 | + if ($bin[$j]) { |
|
| 390 | + $crc = $crc^intval($modes_checksum_table[$j],0); |
|
| 391 | + } |
|
| 246 | 392 | } |
| 247 | - if ($crc == $checksum) return true; |
|
| 248 | - else { |
|
| 393 | + if ($crc == $checksum) { |
|
| 394 | + return true; |
|
| 395 | + } else { |
|
| 249 | 396 | //echo "**** CRC ERROR ****\n"; |
| 250 | 397 | return false; |
| 251 | 398 | } |
@@ -295,22 +442,37 @@ discard block |
||
| 295 | 442 | $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
| 296 | 443 | $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
| 297 | 444 | $msg['callsign'] = ''; |
| 298 | - if (isset($data['altitude'])) $msg['altitude'] = $data['altitude']; |
|
| 299 | - else $msg['altitude'] = ''; |
|
| 445 | + if (isset($data['altitude'])) { |
|
| 446 | + $msg['altitude'] = $data['altitude']; |
|
| 447 | + } else { |
|
| 448 | + $msg['altitude'] = ''; |
|
| 449 | + } |
|
| 300 | 450 | $msg['speed'] = $data['speed']; |
| 301 | - if (isset($data['heading'])) $msg['track'] = $data['heading']; |
|
| 302 | - else $msg['track'] = ''; |
|
| 451 | + if (isset($data['heading'])) { |
|
| 452 | + $msg['track'] = $data['heading']; |
|
| 453 | + } else { |
|
| 454 | + $msg['track'] = ''; |
|
| 455 | + } |
|
| 303 | 456 | $msg['latitude'] = $data['latitude']; |
| 304 | 457 | $msg['longitude'] = $data['longitude']; |
| 305 | - if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate']; |
|
| 306 | - else $msg['verticalrate'] = ''; |
|
| 307 | - if (isset($data['squawk'])) $msg['squawk'] = $data['squawk']; |
|
| 308 | - else $msg['squawk'] = 0; |
|
| 458 | + if (isset($data['verticalrate'])) { |
|
| 459 | + $msg['verticalrate'] = $data['verticalrate']; |
|
| 460 | + } else { |
|
| 461 | + $msg['verticalrate'] = ''; |
|
| 462 | + } |
|
| 463 | + if (isset($data['squawk'])) { |
|
| 464 | + $msg['squawk'] = $data['squawk']; |
|
| 465 | + } else { |
|
| 466 | + $msg['squawk'] = 0; |
|
| 467 | + } |
|
| 309 | 468 | $msg['alert'] = 0; |
| 310 | 469 | $msg['emergency'] = 0; |
| 311 | 470 | $msg['SPI'] = 0; |
| 312 | - if (isset($data['ground'])) $msg['ground'] = 1; |
|
| 313 | - else $msg['ground'] = 0; |
|
| 471 | + if (isset($data['ground'])) { |
|
| 472 | + $msg['ground'] = 1; |
|
| 473 | + } else { |
|
| 474 | + $msg['ground'] = 0; |
|
| 475 | + } |
|
| 314 | 476 | $result[] = implode(',',$msg); |
| 315 | 477 | } |
| 316 | 478 | return $result; |
@@ -14,35 +14,35 @@ discard block |
||
| 14 | 14 | public $db; |
| 15 | 15 | |
| 16 | 16 | protected $texts = Array( |
| 17 | - 'MI' => 'Shallow', |
|
| 18 | - 'PR' => 'Partial', |
|
| 19 | - 'BC' => 'Low drifting', |
|
| 20 | - 'BL' => 'Blowing', |
|
| 21 | - 'SH' => 'Showers', |
|
| 22 | - 'TS' => 'Thunderstorm', |
|
| 23 | - 'FZ' => 'Freezing', |
|
| 24 | - 'DZ' => 'Drizzle', |
|
| 25 | - 'RA' => 'Rain', |
|
| 26 | - 'SN' => 'Snow', |
|
| 27 | - 'SG' => 'Snow Grains', |
|
| 28 | - 'IC' => 'Ice crystals', |
|
| 29 | - 'PL' => 'Ice pellets', |
|
| 30 | - 'GR' => 'Hail', |
|
| 31 | - 'GS' => 'Small hail', |
|
| 32 | - 'UP' => 'Unknown', |
|
| 33 | - 'BR' => 'Mist', |
|
| 34 | - 'FG' => 'Fog', |
|
| 35 | - 'FU' => 'Smoke', |
|
| 36 | - 'VA' => 'Volcanic ash', |
|
| 37 | - 'DU' => 'Widespread dust', |
|
| 38 | - 'SA' => 'Sand', |
|
| 39 | - 'HZ' => 'Haze', |
|
| 40 | - 'PY' => 'Spray', |
|
| 41 | - 'PO' => 'Well developed dust / sand whirls', |
|
| 42 | - 'SQ' => 'Squalls', |
|
| 43 | - 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
| 44 | - 'SS' => 'Sandstorm', |
|
| 45 | - 'DS' => 'Duststorm' |
|
| 17 | + 'MI' => 'Shallow', |
|
| 18 | + 'PR' => 'Partial', |
|
| 19 | + 'BC' => 'Low drifting', |
|
| 20 | + 'BL' => 'Blowing', |
|
| 21 | + 'SH' => 'Showers', |
|
| 22 | + 'TS' => 'Thunderstorm', |
|
| 23 | + 'FZ' => 'Freezing', |
|
| 24 | + 'DZ' => 'Drizzle', |
|
| 25 | + 'RA' => 'Rain', |
|
| 26 | + 'SN' => 'Snow', |
|
| 27 | + 'SG' => 'Snow Grains', |
|
| 28 | + 'IC' => 'Ice crystals', |
|
| 29 | + 'PL' => 'Ice pellets', |
|
| 30 | + 'GR' => 'Hail', |
|
| 31 | + 'GS' => 'Small hail', |
|
| 32 | + 'UP' => 'Unknown', |
|
| 33 | + 'BR' => 'Mist', |
|
| 34 | + 'FG' => 'Fog', |
|
| 35 | + 'FU' => 'Smoke', |
|
| 36 | + 'VA' => 'Volcanic ash', |
|
| 37 | + 'DU' => 'Widespread dust', |
|
| 38 | + 'SA' => 'Sand', |
|
| 39 | + 'HZ' => 'Haze', |
|
| 40 | + 'PY' => 'Spray', |
|
| 41 | + 'PO' => 'Well developed dust / sand whirls', |
|
| 42 | + 'SQ' => 'Squalls', |
|
| 43 | + 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
| 44 | + 'SS' => 'Sandstorm', |
|
| 45 | + 'DS' => 'Duststorm' |
|
| 46 | 46 | ); |
| 47 | 47 | |
| 48 | 48 | /* |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg'; |
| 178 | 178 | */ |
| 179 | 179 | } |
| 180 | - /* |
|
| 180 | + /* |
|
| 181 | 181 | // Wind Direction |
| 182 | 182 | if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) { |
| 183 | 183 | $result['wind_direction'] = $matches[1]; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $result['speed_variable'] = $matches[1]; |
| 189 | 189 | } |
| 190 | 190 | */ |
| 191 | - // Visibility |
|
| 191 | + // Visibility |
|
| 192 | 192 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
| 193 | 193 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
| 194 | 194 | $result['visibility'] = (float)$matches[3] * 1609.34; |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
| 247 | 247 | if (isset($matches[3])) { |
| 248 | 248 | $range = Array( |
| 249 | - 'from' => (float)$matches[2], |
|
| 250 | - 'to' => (float)$matches[4], |
|
| 251 | - 'unit' => $matches[5] ? 'FT' : 'M' |
|
| 249 | + 'from' => (float)$matches[2], |
|
| 250 | + 'to' => (float)$matches[4], |
|
| 251 | + 'unit' => $matches[5] ? 'FT' : 'M' |
|
| 252 | 252 | ); |
| 253 | 253 | } |
| 254 | 254 | $result['RVR'] = $matches[1]; |
@@ -73,8 +73,11 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 75 | 75 | $sth->closeCursor(); |
| 76 | - if ($row['nb'] > 0) return false; |
|
| 77 | - else return true; |
|
| 76 | + if ($row['nb'] > 0) { |
|
| 77 | + return false; |
|
| 78 | + } else { |
|
| 79 | + return true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | /* |
@@ -104,29 +107,48 @@ discard block |
||
| 104 | 107 | //$pieces = explode(' ',$data); |
| 105 | 108 | $pieces = preg_split('/\s/',$data); |
| 106 | 109 | $pos = 0; |
| 107 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 108 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
| 109 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 110 | + if ($pieces[0] == 'METAR') { |
|
| 111 | + $pos++; |
|
| 112 | + } elseif ($pieces[0] == 'SPECI') { |
|
| 113 | + $pos++; |
|
| 114 | + } |
|
| 115 | + if (strlen($pieces[$pos]) != 4) { |
|
| 116 | + $pos++; |
|
| 117 | + } |
|
| 110 | 118 | $result = array(); |
| 111 | - if (!isset($pieces[$pos])) return $result; |
|
| 119 | + if (!isset($pieces[$pos])) { |
|
| 120 | + return $result; |
|
| 121 | + } |
|
| 112 | 122 | $result['location'] = $pieces[$pos]; |
| 113 | 123 | $pos++; |
| 114 | - if (!isset($pieces[$pos])) return $result; |
|
| 124 | + if (!isset($pieces[$pos])) { |
|
| 125 | + return $result; |
|
| 126 | + } |
|
| 115 | 127 | $result['dayofmonth'] = substr($pieces[$pos],0,2); |
| 116 | 128 | $result['time'] = substr($pieces[$pos],2,4); |
| 117 | 129 | $c = count($pieces); |
| 118 | 130 | for($pos++; $pos < $c; $pos++) { |
| 119 | 131 | $piece = $pieces[$pos]; |
| 120 | - if ($piece == 'RMK') break; |
|
| 121 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
| 122 | - if ($piece == 'COR') $result['correction'] = true; |
|
| 132 | + if ($piece == 'RMK') { |
|
| 133 | + break; |
|
| 134 | + } |
|
| 135 | + if ($piece == 'AUTO') { |
|
| 136 | + $result['auto'] = true; |
|
| 137 | + } |
|
| 138 | + if ($piece == 'COR') { |
|
| 139 | + $result['correction'] = true; |
|
| 140 | + } |
|
| 123 | 141 | // Wind Speed |
| 124 | 142 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 125 | 143 | $result['wind']['direction'] = (float)$matches[1]; |
| 126 | 144 | $result['wind']['unit'] = $matches[4]; |
| 127 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 128 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 129 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 145 | + if ($result['wind']['unit'] == 'KT') { |
|
| 146 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 147 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
| 148 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 149 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
| 150 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 151 | + } |
|
| 130 | 152 | $result['wind']['gust'] = (float)$matches[3]; |
| 131 | 153 | $result['wind']['unit'] = $matches[4]; |
| 132 | 154 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -210,27 +232,49 @@ discard block |
||
| 210 | 232 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
| 211 | 233 | $type = $matches[1]; |
| 212 | 234 | $cloud = array(); |
| 213 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
| 214 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 215 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
| 216 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
| 217 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
| 218 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
| 219 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 220 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
| 235 | + if ($type == 'SKC') { |
|
| 236 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
| 237 | + } elseif ($type == 'CLR') { |
|
| 238 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 239 | + } elseif ($type == 'NSC') { |
|
| 240 | + $cloud['type'] = 'No significant cloud'; |
|
| 241 | + } elseif ($type == 'FEW') { |
|
| 242 | + $cloud['type'] = 'Few'; |
|
| 243 | + } elseif ($type == 'SCT') { |
|
| 244 | + $cloud['type'] = 'Scattered'; |
|
| 245 | + } elseif ($type == 'BKN') { |
|
| 246 | + $cloud['type'] = 'Broken'; |
|
| 247 | + } elseif ($type == 'OVC') { |
|
| 248 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 249 | + } elseif ($type == 'VV') { |
|
| 250 | + $cloud['type'] = 'Vertical visibility'; |
|
| 251 | + } |
|
| 221 | 252 | $cloud['type_code'] = $type; |
| 222 | 253 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
| 223 | - if (isset($matches[3])) $significant = $matches[3]; |
|
| 224 | - else $significant = ''; |
|
| 225 | - if ($significant == 'CB') $cloud['significant'] = 'Cumulonimbus'; |
|
| 226 | - elseif ($significant == 'AC') $cloud['significant'] = 'Altocumulus'; |
|
| 227 | - elseif ($significant == 'CBS') $cloud['significant'] = 'Cumulonimbus'; |
|
| 228 | - elseif ($significant == 'CC') $cloud['significant'] = 'Cirrocumulus'; |
|
| 229 | - elseif ($significant == 'CU') $cloud['significant'] = 'Cumulus'; |
|
| 230 | - elseif ($significant == 'CI') $cloud['significant'] = 'Cirrus'; |
|
| 231 | - elseif ($significant == 'CS') $cloud['significant'] = 'Cirrostratus'; |
|
| 232 | - elseif ($significant == 'TCU') $cloud['significant'] = 'Towering Cumulus'; |
|
| 233 | - else $cloud['significant'] = $significant; |
|
| 254 | + if (isset($matches[3])) { |
|
| 255 | + $significant = $matches[3]; |
|
| 256 | + } else { |
|
| 257 | + $significant = ''; |
|
| 258 | + } |
|
| 259 | + if ($significant == 'CB') { |
|
| 260 | + $cloud['significant'] = 'Cumulonimbus'; |
|
| 261 | + } elseif ($significant == 'AC') { |
|
| 262 | + $cloud['significant'] = 'Altocumulus'; |
|
| 263 | + } elseif ($significant == 'CBS') { |
|
| 264 | + $cloud['significant'] = 'Cumulonimbus'; |
|
| 265 | + } elseif ($significant == 'CC') { |
|
| 266 | + $cloud['significant'] = 'Cirrocumulus'; |
|
| 267 | + } elseif ($significant == 'CU') { |
|
| 268 | + $cloud['significant'] = 'Cumulus'; |
|
| 269 | + } elseif ($significant == 'CI') { |
|
| 270 | + $cloud['significant'] = 'Cirrus'; |
|
| 271 | + } elseif ($significant == 'CS') { |
|
| 272 | + $cloud['significant'] = 'Cirrostratus'; |
|
| 273 | + } elseif ($significant == 'TCU') { |
|
| 274 | + $cloud['significant'] = 'Towering Cumulus'; |
|
| 275 | + } else { |
|
| 276 | + $cloud['significant'] = $significant; |
|
| 277 | + } |
|
| 234 | 278 | //$cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
| 235 | 279 | $result['cloud'][] = $cloud; |
| 236 | 280 | } |
@@ -254,8 +298,11 @@ discard block |
||
| 254 | 298 | $result['RVR']['friction'] = $matches[5]; |
| 255 | 299 | } |
| 256 | 300 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 257 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 258 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 301 | + if (isset($matches[5])) { |
|
| 302 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 303 | + } else { |
|
| 304 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 305 | + } |
|
| 259 | 306 | if (isset($matches[3])) { |
| 260 | 307 | $range = Array( |
| 261 | 308 | 'from' => (float)$matches[2], |
@@ -288,8 +335,11 @@ discard block |
||
| 288 | 335 | if (isset($matches[3])) { |
| 289 | 336 | $text[] = $this->texts[$matches[3]]; |
| 290 | 337 | } |
| 291 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
| 292 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 338 | + if (!isset($result['weather'])) { |
|
| 339 | + $result['weather'] = implode(' ', $text); |
|
| 340 | + } else { |
|
| 341 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 342 | + } |
|
| 293 | 343 | } |
| 294 | 344 | } |
| 295 | 345 | return $result; |
@@ -305,8 +355,11 @@ discard block |
||
| 305 | 355 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
| 306 | 356 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
| 307 | 357 | } else { |
| 308 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 309 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 358 | + if ($globalDBdriver == 'mysql') { |
|
| 359 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 360 | + } else { |
|
| 361 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 362 | + } |
|
| 310 | 363 | } |
| 311 | 364 | $query_values = array(':icao' => $icao); |
| 312 | 365 | try { |
@@ -378,7 +431,9 @@ discard block |
||
| 378 | 431 | */ |
| 379 | 432 | public function addMETARCycle() { |
| 380 | 433 | global $globalDebug, $globalIVAO, $globalTransaction; |
| 381 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
| 434 | + if (isset($globalDebug) && $globalDebug) { |
|
| 435 | + echo "Downloading METAR cycle..."; |
|
| 436 | + } |
|
| 382 | 437 | date_default_timezone_set("UTC"); |
| 383 | 438 | $Common = new Common(); |
| 384 | 439 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -389,28 +444,42 @@ discard block |
||
| 389 | 444 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
| 390 | 445 | } |
| 391 | 446 | if ($handle) { |
| 392 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
| 447 | + if (isset($globalDebug) && $globalDebug) { |
|
| 448 | + echo "Done - Updating DB..."; |
|
| 449 | + } |
|
| 393 | 450 | $date = ''; |
| 394 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 451 | + if ($globalTransaction) { |
|
| 452 | + $this->db->beginTransaction(); |
|
| 453 | + } |
|
| 395 | 454 | while(($line = fgets($handle,4096)) !== false) { |
| 396 | 455 | $line = str_replace(array("\r\n","\r", "\n"), '', $line); |
| 397 | 456 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
| 398 | 457 | $date = $line; |
| 399 | 458 | } elseif (trim($line) != '') { |
| 400 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 459 | + if ($date == '') { |
|
| 460 | + $date = date('Y/m/d H:m'); |
|
| 461 | + } |
|
| 401 | 462 | $pos = 0; |
| 402 | 463 | $pieces = preg_split('/\s/',$line); |
| 403 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 404 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 464 | + if ($pieces[0] == 'METAR') { |
|
| 465 | + $pos++; |
|
| 466 | + } |
|
| 467 | + if (strlen($pieces[$pos]) != 4) { |
|
| 468 | + $pos++; |
|
| 469 | + } |
|
| 405 | 470 | $location = $pieces[$pos]; |
| 406 | 471 | //if ($location == 'LFLL') echo 'location: '.$location.' - date: '.$date.' - data: '.$line."\n"; |
| 407 | 472 | echo $this->addMETAR($location,$line,$date); |
| 408 | 473 | } |
| 409 | 474 | } |
| 410 | 475 | fclose($handle); |
| 411 | - if ($globalTransaction) $this->db->commit(); |
|
| 476 | + if ($globalTransaction) { |
|
| 477 | + $this->db->commit(); |
|
| 478 | + } |
|
| 479 | + } |
|
| 480 | + if (isset($globalDebug) && $globalDebug) { |
|
| 481 | + echo "Done\n"; |
|
| 412 | 482 | } |
| 413 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
| 414 | 483 | } |
| 415 | 484 | |
| 416 | 485 | /* |
@@ -420,7 +489,9 @@ discard block |
||
| 420 | 489 | */ |
| 421 | 490 | public function downloadMETAR($icao) { |
| 422 | 491 | global $globalMETARurl; |
| 423 | - if ($globalMETARurl == '') return array(); |
|
| 492 | + if ($globalMETARurl == '') { |
|
| 493 | + return array(); |
|
| 494 | + } |
|
| 424 | 495 | date_default_timezone_set("UTC"); |
| 425 | 496 | $Common = new Common(); |
| 426 | 497 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -432,16 +503,24 @@ discard block |
||
| 432 | 503 | $date = $line; |
| 433 | 504 | } |
| 434 | 505 | if (trim($line) != '') { |
| 435 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 506 | + if ($date == '') { |
|
| 507 | + $date = date('Y/m/d H:m'); |
|
| 508 | + } |
|
| 436 | 509 | $pos = 0; |
| 437 | 510 | $pieces = preg_split('/\s/',$line); |
| 438 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 439 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 511 | + if ($pieces[0] == 'METAR') { |
|
| 512 | + $pos++; |
|
| 513 | + } |
|
| 514 | + if (strlen($pieces[$pos]) != 4) { |
|
| 515 | + $pos++; |
|
| 516 | + } |
|
| 440 | 517 | $location = $pieces[$pos]; |
| 441 | 518 | if (strlen($location == 4)) { |
| 442 | 519 | $this->addMETAR($location,$line,$date); |
| 443 | 520 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 444 | - } else return array(); |
|
| 521 | + } else { |
|
| 522 | + return array(); |
|
| 523 | + } |
|
| 445 | 524 | } |
| 446 | 525 | } |
| 447 | 526 | return array(); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $Connection = new Connection(); |
| 69 | 69 | $sth = $Connection->db->prepare($query); |
| 70 | 70 | $sth->execute(); |
| 71 | - } catch(PDOException $e) { |
|
| 71 | + } catch (PDOException $e) { |
|
| 72 | 72 | return "error : ".$e->getMessage(); |
| 73 | 73 | } |
| 74 | 74 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $Connection = new Connection(); |
| 88 | 88 | $sth = $Connection->db->prepare($query); |
| 89 | 89 | $sth->execute(); |
| 90 | - } catch(PDOException $e) { |
|
| 90 | + } catch (PDOException $e) { |
|
| 91 | 91 | return "error : ".$e->getMessage(); |
| 92 | 92 | } |
| 93 | 93 | return ''; |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | public function parse($data) { |
| 102 | 102 | //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
| 103 | 103 | $codes = implode('|', array_keys($this->texts)); |
| 104 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
| 104 | + $regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#'; |
|
| 105 | 105 | //$pieces = explode(' ',$data); |
| 106 | - $pieces = preg_split('/\s/',$data); |
|
| 106 | + $pieces = preg_split('/\s/', $data); |
|
| 107 | 107 | $pos = 0; |
| 108 | 108 | if ($pieces[0] == 'METAR') $pos++; |
| 109 | 109 | elseif ($pieces[0] == 'SPECI') $pos++; |
@@ -113,25 +113,25 @@ discard block |
||
| 113 | 113 | $result['location'] = $pieces[$pos]; |
| 114 | 114 | $pos++; |
| 115 | 115 | if (!isset($pieces[$pos])) return $result; |
| 116 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
| 117 | - $result['time'] = substr($pieces[$pos],2,4); |
|
| 116 | + $result['dayofmonth'] = substr($pieces[$pos], 0, 2); |
|
| 117 | + $result['time'] = substr($pieces[$pos], 2, 4); |
|
| 118 | 118 | $c = count($pieces); |
| 119 | - for($pos++; $pos < $c; $pos++) { |
|
| 119 | + for ($pos++; $pos < $c; $pos++) { |
|
| 120 | 120 | $piece = $pieces[$pos]; |
| 121 | 121 | if ($piece == 'RMK') break; |
| 122 | 122 | if ($piece == 'AUTO') $result['auto'] = true; |
| 123 | 123 | if ($piece == 'COR') $result['correction'] = true; |
| 124 | 124 | // Wind Speed |
| 125 | 125 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 126 | - $result['wind']['direction'] = (float)$matches[1]; |
|
| 126 | + $result['wind']['direction'] = (float) $matches[1]; |
|
| 127 | 127 | $result['wind']['unit'] = $matches[4]; |
| 128 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 129 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 130 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 131 | - $result['wind']['gust'] = (float)$matches[3]; |
|
| 128 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2); |
|
| 129 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2); |
|
| 130 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2); |
|
| 131 | + $result['wind']['gust'] = (float) $matches[3]; |
|
| 132 | 132 | $result['wind']['unit'] = $matches[4]; |
| 133 | - $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
|
| 134 | - $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
|
| 133 | + $result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0; |
|
| 134 | + $result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
@@ -152,17 +152,17 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | // Temperature |
| 154 | 154 | if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
| 155 | - $temp = (float)$matches[1]; |
|
| 155 | + $temp = (float) $matches[1]; |
|
| 156 | 156 | if ($matches[1]{0} == 'M') { |
| 157 | - $temp = ((float)substr($matches[1], 1)) * -1; |
|
| 157 | + $temp = ((float) substr($matches[1], 1))*-1; |
|
| 158 | 158 | } |
| 159 | 159 | $result['temperature'] = $temp; |
| 160 | - $dew = (float)$matches[2]; |
|
| 160 | + $dew = (float) $matches[2]; |
|
| 161 | 161 | if ($matches[2]{0} == 'M') { |
| 162 | - $dew = ((float)substr($matches[2], 1)) * -1; |
|
| 162 | + $dew = ((float) substr($matches[2], 1))*-1; |
|
| 163 | 163 | } |
| 164 | 164 | $result['dew'] = $dew; |
| 165 | - $result['rh'] = round(100*(exp((17.625*$dew)/(243.04+$dew))/exp((17.625*$temp)/(243.04+$temp)))); |
|
| 165 | + $result['rh'] = round(100*(exp((17.625*$dew)/(243.04 + $dew))/exp((17.625*$temp)/(243.04 + $temp)))); |
|
| 166 | 166 | } |
| 167 | 167 | // QNH |
| 168 | 168 | if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) { |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $result['QNH'] = $matches[2]; |
| 173 | 173 | } else { |
| 174 | 174 | // inHg |
| 175 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
| 175 | + $result['QNH'] = round(($matches[2]/100)*33.86389, 2); |
|
| 176 | 176 | } |
| 177 | 177 | /* |
| 178 | 178 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | // Visibility |
| 194 | 194 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
| 195 | 195 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
| 196 | - $result['visibility'] = (float)$matches[3] * 1609.34; |
|
| 196 | + $result['visibility'] = (float) $matches[3]*1609.34; |
|
| 197 | 197 | } else { |
| 198 | 198 | if ($matches[1] == '9999') { |
| 199 | 199 | $result['visibility'] = '> 10000'; |
| 200 | 200 | } else { |
| 201 | - $result['visibility'] = (float)$matches[1]; |
|
| 201 | + $result['visibility'] = (float) $matches[1]; |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
| 222 | 222 | elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
| 223 | 223 | $cloud['type_code'] = $type; |
| 224 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
| 224 | + $cloud['level'] = round(((float) $matches[2])*100*0.3048); |
|
| 225 | 225 | if (isset($matches[3])) $significant = $matches[3]; |
| 226 | 226 | else $significant = ''; |
| 227 | 227 | if ($significant == 'CB') $cloud['significant'] = 'Cumulonimbus'; |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | $rvr['runway'] = $matches[1]; |
| 243 | 243 | $rvr['assessment'] = $matches[2]; |
| 244 | 244 | $rvr['rvr'] = $matches[3]; |
| 245 | - $rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0; |
|
| 246 | - $rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : ''; |
|
| 245 | + $rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0; |
|
| 246 | + $rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : ''; |
|
| 247 | 247 | $result['RVR'] = $rvr; |
| 248 | 248 | } |
| 249 | 249 | //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
@@ -256,12 +256,12 @@ discard block |
||
| 256 | 256 | $result['RVR']['friction'] = $matches[5]; |
| 257 | 257 | } |
| 258 | 258 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 259 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 260 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 259 | + if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 260 | + else $range = array('exact' => (float) $matches[2], 'unit' => 'M'); |
|
| 261 | 261 | if (isset($matches[3])) { |
| 262 | 262 | $range = Array( |
| 263 | - 'from' => (float)$matches[2], |
|
| 264 | - 'to' => (float)$matches[4], |
|
| 263 | + 'from' => (float) $matches[2], |
|
| 264 | + 'to' => (float) $matches[4], |
|
| 265 | 265 | 'unit' => $matches[5] ? 'FT' : 'M' |
| 266 | 266 | ); |
| 267 | 267 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | try { |
| 315 | 315 | $sth = $this->db->prepare($query); |
| 316 | 316 | $sth->execute($query_values); |
| 317 | - } catch(PDOException $e) { |
|
| 317 | + } catch (PDOException $e) { |
|
| 318 | 318 | return "error : ".$e->getMessage(); |
| 319 | 319 | } |
| 320 | 320 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -330,19 +330,19 @@ discard block |
||
| 330 | 330 | * @param String $metar METAR text |
| 331 | 331 | * @param String $date date of the METAR |
| 332 | 332 | */ |
| 333 | - public function addMETAR($location,$metar,$date) { |
|
| 333 | + public function addMETAR($location, $metar, $date) { |
|
| 334 | 334 | global $globalDBdriver; |
| 335 | - $date = date('Y-m-d H:i:s',strtotime($date)); |
|
| 335 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 336 | 336 | if ($globalDBdriver == 'mysql') { |
| 337 | 337 | $query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar"; |
| 338 | 338 | } else { |
| 339 | 339 | $query = "UPDATE metar SET metar_date = :date, metar = :metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
| 340 | 340 | } |
| 341 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
| 341 | + $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar)); |
|
| 342 | 342 | try { |
| 343 | 343 | $sth = $this->db->prepare($query); |
| 344 | 344 | $sth->execute($query_values); |
| 345 | - } catch(PDOException $e) { |
|
| 345 | + } catch (PDOException $e) { |
|
| 346 | 346 | return "error : ".$e->getMessage(); |
| 347 | 347 | } |
| 348 | 348 | return ''; |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | try { |
| 359 | 359 | $sth = $this->db->prepare($query); |
| 360 | 360 | $sth->execute($query_values); |
| 361 | - } catch(PDOException $e) { |
|
| 361 | + } catch (PDOException $e) { |
|
| 362 | 362 | return "error : ".$e->getMessage(); |
| 363 | 363 | } |
| 364 | 364 | return ''; |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | try { |
| 373 | 373 | $sth = $this->db->prepare($query); |
| 374 | 374 | $sth->execute(); |
| 375 | - } catch(PDOException $e) { |
|
| 375 | + } catch (PDOException $e) { |
|
| 376 | 376 | return "error : ".$e->getMessage(); |
| 377 | 377 | } |
| 378 | 378 | return ''; |
@@ -387,29 +387,29 @@ discard block |
||
| 387 | 387 | date_default_timezone_set("UTC"); |
| 388 | 388 | $Common = new Common(); |
| 389 | 389 | if (isset($globalIVAO) && $globalIVAO) { |
| 390 | - $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
| 391 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
| 390 | + $Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
| 391 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r"); |
|
| 392 | 392 | } else { |
| 393 | - $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
| 394 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
| 393 | + $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
| 394 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r"); |
|
| 395 | 395 | } |
| 396 | 396 | if ($handle) { |
| 397 | 397 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
| 398 | 398 | $date = ''; |
| 399 | 399 | if ($globalTransaction) $this->db->beginTransaction(); |
| 400 | - while(($line = fgets($handle,4096)) !== false) { |
|
| 401 | - $line = str_replace(array("\r\n","\r", "\n"), '', $line); |
|
| 402 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
| 400 | + while (($line = fgets($handle, 4096)) !== false) { |
|
| 401 | + $line = str_replace(array("\r\n", "\r", "\n"), '', $line); |
|
| 402 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
| 403 | 403 | $date = $line; |
| 404 | 404 | } elseif (trim($line) != '') { |
| 405 | 405 | if ($date == '') $date = date('Y/m/d H:m'); |
| 406 | 406 | $pos = 0; |
| 407 | - $pieces = preg_split('/\s/',$line); |
|
| 407 | + $pieces = preg_split('/\s/', $line); |
|
| 408 | 408 | if ($pieces[0] == 'METAR') $pos++; |
| 409 | 409 | if (strlen($pieces[$pos]) != 4) $pos++; |
| 410 | 410 | $location = $pieces[$pos]; |
| 411 | 411 | //if ($location == 'LFLL') echo 'location: '.$location.' - date: '.$date.' - data: '.$line."\n"; |
| 412 | - echo $this->addMETAR($location,$line,$date); |
|
| 412 | + echo $this->addMETAR($location, $line, $date); |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | fclose($handle); |
@@ -428,23 +428,23 @@ discard block |
||
| 428 | 428 | if ($globalMETARurl == '') return array(); |
| 429 | 429 | date_default_timezone_set("UTC"); |
| 430 | 430 | $Common = new Common(); |
| 431 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
| 431 | + $url = str_replace('{icao}', $icao, $globalMETARurl); |
|
| 432 | 432 | $cycle = $Common->getData($url); |
| 433 | 433 | $date = ''; |
| 434 | - foreach(explode("\n",$cycle) as $line) { |
|
| 435 | - $line = str_replace(array("\r\n","\r", "\n"), '', $line); |
|
| 436 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
| 434 | + foreach (explode("\n", $cycle) as $line) { |
|
| 435 | + $line = str_replace(array("\r\n", "\r", "\n"), '', $line); |
|
| 436 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
| 437 | 437 | $date = $line; |
| 438 | 438 | } |
| 439 | 439 | if (trim($line) != '') { |
| 440 | 440 | if ($date == '') $date = date('Y/m/d H:m'); |
| 441 | 441 | $pos = 0; |
| 442 | - $pieces = preg_split('/\s/',$line); |
|
| 442 | + $pieces = preg_split('/\s/', $line); |
|
| 443 | 443 | if ($pieces[0] == 'METAR') $pos++; |
| 444 | 444 | if (strlen($pieces[$pos]) != 4) $pos++; |
| 445 | 445 | $location = $pieces[$pos]; |
| 446 | 446 | if (strlen($location == 4)) { |
| 447 | - $this->addMETAR($location,$line,$date); |
|
| 447 | + $this->addMETAR($location, $line, $date); |
|
| 448 | 448 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 449 | 449 | } else return array(); |
| 450 | 450 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function parse_xml($url) { |
| 17 | 17 | $Common = new Common(); |
| 18 | - $filedata = $Common->getData($url,'get','','','','','','',true); |
|
| 18 | + $filedata = $Common->getData($url, 'get', '', '', '', '', '', '', true); |
|
| 19 | 19 | if ($filedata != '' && $filedata !== false) { |
| 20 | 20 | $xml = simplexml_load_string($filedata); |
| 21 | 21 | if ($xml !== false) { |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | if ($check_version == '0') { |
| 87 | 87 | |
| 88 | 88 | if ($globalDBdriver == 'mysql') { |
| 89 | - $error .= create_db::import_all_db('../db/'); |
|
| 89 | + $error .= create_db::import_all_db('../db/'); |
|
| 90 | 90 | } elseif ($globalDBdriver == 'pgsql') { |
| 91 | - $error .= create_db::import_all_db('../db/pgsql/'); |
|
| 91 | + $error .= create_db::import_all_db('../db/pgsql/'); |
|
| 92 | 92 | } |
| 93 | 93 | if ($error != '') { |
| 94 | 94 | $_SESSION['error'] = $error; |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | $_SESSION['install'] = 'populate'; |
| 99 | 99 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B'; |
| 100 | 100 | } else { |
| 101 | - $_SESSION['install'] = 'sources'; |
|
| 102 | - $_SESSION['next'] = 'Insert data in source table'; |
|
| 101 | + $_SESSION['install'] = 'sources'; |
|
| 102 | + $_SESSION['next'] = 'Insert data in source table'; |
|
| 103 | 103 | } |
| 104 | 104 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
| 105 | 105 | print json_encode($result); |
@@ -156,10 +156,10 @@ discard block |
||
| 156 | 156 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database')); |
| 157 | 157 | } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
| 158 | 158 | if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
| 159 | - $_SESSION['install'] = 'notam'; |
|
| 160 | - $_SESSION['next'] = 'Populate NOTAM table with externals data'; |
|
| 161 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 162 | - print json_encode($result); |
|
| 159 | + $_SESSION['install'] = 'notam'; |
|
| 160 | + $_SESSION['next'] = 'Populate NOTAM table with externals data'; |
|
| 161 | + $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 162 | + print json_encode($result); |
|
| 163 | 163 | /* |
| 164 | 164 | } elseif (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
| 165 | 165 | $_SESSION['install'] = 'owner'; |
@@ -169,10 +169,10 @@ discard block |
||
| 169 | 169 | print json_encode($result); |
| 170 | 170 | */ |
| 171 | 171 | } else { |
| 172 | - $_SESSION['install'] = 'sources'; |
|
| 173 | - $_SESSION['next'] = 'Insert data in source table'; |
|
| 174 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 175 | - print json_encode($result); |
|
| 172 | + $_SESSION['install'] = 'sources'; |
|
| 173 | + $_SESSION['next'] = 'Insert data in source table'; |
|
| 174 | + $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 175 | + print json_encode($result); |
|
| 176 | 176 | } |
| 177 | 177 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate') { |
| 178 | 178 | if (!is_writable('tmp')) { |
@@ -70,15 +70,15 @@ discard block |
||
| 70 | 70 | $globalDebug = FALSE; |
| 71 | 71 | $dbroot = $_SESSION['database_root']; |
| 72 | 72 | $dbrootpass = $_SESSION['database_rootpass']; |
| 73 | - $error .= create_db::create_database($dbroot,$dbrootpass,$globalDBuser,$globalDBpass,$globalDBname,$globalDBdriver,$globalDBhost); |
|
| 73 | + $error .= create_db::create_database($dbroot, $dbrootpass, $globalDBuser, $globalDBpass, $globalDBname, $globalDBdriver, $globalDBhost); |
|
| 74 | 74 | sleep(5); |
| 75 | 75 | if ($error != '') { |
| 76 | 76 | $_SESSION['error'] = $error; |
| 77 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database')); |
|
| 78 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
| 77 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create database')); |
|
| 78 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Create database')); |
|
| 79 | 79 | $_SESSION['install'] = 'database_import'; |
| 80 | 80 | $_SESSION['next'] = 'Create and import tables'; |
| 81 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 81 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 82 | 82 | print json_encode($result); |
| 83 | 83 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'database_import') { |
| 84 | 84 | $globalDebug = FALSE; |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | if ($error != '') { |
| 94 | 94 | $_SESSION['error'] = $error; |
| 95 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
|
| 96 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
| 95 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create and import tables')); |
|
| 96 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Create and import tables')); |
|
| 97 | 97 | if ((!isset($globalAircraft) || $globalAircraft === TRUE) && (!isset($globalVA) || $globalVA === FALSE)) { |
| 98 | 98 | $_SESSION['install'] = 'populate'; |
| 99 | 99 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B'; |
@@ -101,24 +101,24 @@ discard block |
||
| 101 | 101 | $_SESSION['install'] = 'sources'; |
| 102 | 102 | $_SESSION['next'] = 'Insert data in source table'; |
| 103 | 103 | } |
| 104 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 104 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 105 | 105 | print json_encode($result); |
| 106 | 106 | } elseif (!is_numeric($check_version)) { |
| 107 | 107 | $error .= $check_version; |
| 108 | 108 | $_SESSION['error'] = $error; |
| 109 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
|
| 109 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create and import tables')); |
|
| 110 | 110 | if (!isset($_SESSION['next'])) $_SESSION['next'] = ''; |
| 111 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 111 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 112 | 112 | print json_encode($result); |
| 113 | 113 | } else { |
| 114 | 114 | $error .= update_schema::check_version(true); |
| 115 | 115 | if ($error != '') { |
| 116 | 116 | $_SESSION['error'] = $error; |
| 117 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed')); |
|
| 118 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
| 117 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Update schema if needed')); |
|
| 118 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Update schema if needed')); |
|
| 119 | 119 | $_SESSION['install'] = 'sources'; |
| 120 | 120 | $_SESSION['next'] = 'Insert data in source table'; |
| 121 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 121 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 122 | 122 | print json_encode($result); |
| 123 | 123 | } |
| 124 | 124 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'waypoints') { |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | $error .= update_db::update_waypoints(); |
| 128 | 128 | if ($error != '') { |
| 129 | 129 | $_SESSION['error'] = $error; |
| 130 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database')); |
|
| 131 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
| 130 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate waypoints database')); |
|
| 131 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate waypoints database')); |
|
| 132 | 132 | /* |
| 133 | 133 | $_SESSION['install'] = 'airspace'; |
| 134 | 134 | $_SESSION['next'] = 'Populate airspace table'; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | $_SESSION['install'] = 'countries'; |
| 147 | 147 | $_SESSION['next'] = 'Populate countries table'; |
| 148 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 148 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 149 | 149 | print json_encode($result); |
| 150 | 150 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'countries') { |
| 151 | 151 | include_once('class.update_db.php'); |
@@ -153,12 +153,12 @@ discard block |
||
| 153 | 153 | $error .= update_db::update_countries(); |
| 154 | 154 | if ($error != '') { |
| 155 | 155 | $_SESSION['error'] = $error; |
| 156 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database')); |
|
| 157 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
| 156 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate countries database')); |
|
| 157 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate countries database')); |
|
| 158 | 158 | if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
| 159 | 159 | $_SESSION['install'] = 'notam'; |
| 160 | 160 | $_SESSION['next'] = 'Populate NOTAM table with externals data'; |
| 161 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 161 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 162 | 162 | print json_encode($result); |
| 163 | 163 | /* |
| 164 | 164 | } elseif (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
@@ -171,15 +171,15 @@ discard block |
||
| 171 | 171 | } else { |
| 172 | 172 | $_SESSION['install'] = 'sources'; |
| 173 | 173 | $_SESSION['next'] = 'Insert data in source table'; |
| 174 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 174 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 175 | 175 | print json_encode($result); |
| 176 | 176 | } |
| 177 | 177 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate') { |
| 178 | 178 | if (!is_writable('tmp')) { |
| 179 | 179 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
| 180 | 180 | $_SESSION['error'] = $error; |
| 181 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 182 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 181 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 182 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 183 | 183 | print json_encode($result); |
| 184 | 184 | } else { |
| 185 | 185 | include_once('class.update_db.php'); |
@@ -187,19 +187,19 @@ discard block |
||
| 187 | 187 | $error .= update_db::update_ModeS_fam(); |
| 188 | 188 | if ($error != '') { |
| 189 | 189 | $_SESSION['error'] = $error; |
| 190 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 191 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 190 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 191 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 192 | 192 | $_SESSION['install'] = 'populate_flarm'; |
| 193 | 193 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM'; |
| 194 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 194 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 195 | 195 | print json_encode($result); |
| 196 | 196 | } |
| 197 | 197 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate_flarm') { |
| 198 | 198 | if (!is_writable('tmp')) { |
| 199 | 199 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
| 200 | 200 | $_SESSION['error'] = $error; |
| 201 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 202 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 201 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 202 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 203 | 203 | print json_encode($result); |
| 204 | 204 | } else { |
| 205 | 205 | include_once('class.update_db.php'); |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | $error .= update_db::update_ModeS_ogn(); |
| 209 | 209 | if ($error != '') { |
| 210 | 210 | $_SESSION['error'] = $error; |
| 211 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 212 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 211 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 212 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 213 | 213 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
| 214 | 214 | $_SESSION['install'] = 'vatsim'; |
| 215 | 215 | if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
@@ -228,15 +228,15 @@ discard block |
||
| 228 | 228 | $_SESSION['install'] = 'routes'; |
| 229 | 229 | $_SESSION['next'] = 'Populate routes table with externals data'; |
| 230 | 230 | } |
| 231 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 231 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 232 | 232 | print json_encode($result); |
| 233 | 233 | } |
| 234 | 234 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'routes') { |
| 235 | 235 | if (!is_writable('tmp')) { |
| 236 | 236 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
| 237 | 237 | $_SESSION['error'] = $error; |
| 238 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 239 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 238 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 239 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 240 | 240 | print json_encode($result); |
| 241 | 241 | } else { |
| 242 | 242 | include_once('class.update_db.php'); |
@@ -244,19 +244,19 @@ discard block |
||
| 244 | 244 | $error .= update_db::update_routes_fam(); |
| 245 | 245 | if ($error != '') { |
| 246 | 246 | $_SESSION['error'] = $error; |
| 247 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data')); |
|
| 248 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
| 247 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate routes table with externals data')); |
|
| 248 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate routes table with externals data')); |
|
| 249 | 249 | $_SESSION['install'] = 'translation'; |
| 250 | 250 | $_SESSION['next'] = 'Populate translation table with externals data'; |
| 251 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 251 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 252 | 252 | print json_encode($result); |
| 253 | 253 | } |
| 254 | 254 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'translation') { |
| 255 | 255 | if (!is_writable('tmp')) { |
| 256 | 256 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
| 257 | 257 | $_SESSION['error'] = $error; |
| 258 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
|
| 259 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 258 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate translation table with externals data')); |
|
| 259 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 260 | 260 | print json_encode($result); |
| 261 | 261 | } else { |
| 262 | 262 | include_once('class.update_db.php'); |
@@ -264,8 +264,8 @@ discard block |
||
| 264 | 264 | $error .= update_db::update_translation_fam(); |
| 265 | 265 | if ($error != '') { |
| 266 | 266 | $_SESSION['error'] = $error; |
| 267 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
|
| 268 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
| 267 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate translation table with externals data')); |
|
| 268 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate translation table with externals data')); |
|
| 269 | 269 | if ($_SESSION['waypoints'] == 1) { |
| 270 | 270 | $_SESSION['install'] = 'waypoints'; |
| 271 | 271 | $_SESSION['next'] = 'Populate waypoints table'; |
@@ -283,15 +283,15 @@ discard block |
||
| 283 | 283 | $_SESSION['install'] = 'sources'; |
| 284 | 284 | $_SESSION['next'] = 'Insert data in source table'; |
| 285 | 285 | } |
| 286 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 286 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 287 | 287 | print json_encode($result); |
| 288 | 288 | } |
| 289 | 289 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'owner') { |
| 290 | 290 | if (!is_writable('tmp')) { |
| 291 | 291 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
| 292 | 292 | $_SESSION['error'] = $error; |
| 293 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
|
| 294 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 293 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate owner table with externals data')); |
|
| 294 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 295 | 295 | print json_encode($result); |
| 296 | 296 | } else { |
| 297 | 297 | include_once('class.update_db.php'); |
@@ -299,19 +299,19 @@ discard block |
||
| 299 | 299 | $error = update_db::update_owner_fam(); |
| 300 | 300 | if ($error != '') { |
| 301 | 301 | $_SESSION['error'] = $error; |
| 302 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
|
| 303 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
| 302 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate owner table with externals data')); |
|
| 303 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate owner table with externals data')); |
|
| 304 | 304 | $_SESSION['install'] = 'sources'; |
| 305 | 305 | $_SESSION['next'] = 'Insert data in source table'; |
| 306 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 306 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 307 | 307 | print json_encode($result); |
| 308 | 308 | } |
| 309 | 309 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'notam') { |
| 310 | 310 | if (!is_writable('tmp')) { |
| 311 | 311 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
| 312 | 312 | $_SESSION['error'] = $error; |
| 313 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
|
| 314 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 313 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data')); |
|
| 314 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 315 | 315 | print json_encode($result); |
| 316 | 316 | } else { |
| 317 | 317 | include_once('class.update_db.php'); |
@@ -320,13 +320,13 @@ discard block |
||
| 320 | 320 | $error .= update_db::update_notam(); |
| 321 | 321 | if ($error != '') { |
| 322 | 322 | $_SESSION['error'] = $error; |
| 323 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
|
| 324 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
| 323 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data')); |
|
| 324 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate notam table with externals data')); |
|
| 325 | 325 | } else { |
| 326 | 326 | if ($error != '') { |
| 327 | 327 | $_SESSION['error'] = $error; |
| 328 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)')); |
|
| 329 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
| 328 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data (no source defined)')); |
|
| 329 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate notam table with externals data (no source defined)')); |
|
| 330 | 330 | } |
| 331 | 331 | /* |
| 332 | 332 | if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | $_SESSION['install'] = 'sources'; |
| 341 | 341 | $_SESSION['next'] = 'Insert data in source table'; |
| 342 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 342 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 343 | 343 | print json_encode($result); |
| 344 | 344 | //} |
| 345 | 345 | } |
@@ -376,9 +376,9 @@ discard block |
||
| 376 | 376 | $Source = new Source(); |
| 377 | 377 | $Source->deleteAllLocation(); |
| 378 | 378 | foreach ($sources as $src) { |
| 379 | - if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
| 379 | + if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'], $src['latitude'], $src['longitude'], $src['altitude'], $src['city'], $src['country'], $src['source'], 'antenna.png'); |
|
| 380 | 380 | } |
| 381 | - $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table')); |
|
| 381 | + $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert data in source table')); |
|
| 382 | 382 | unset($_SESSION['sources']); |
| 383 | 383 | } |
| 384 | 384 | /* |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | $_SESSION['install'] = 'finish'; |
| 404 | 404 | $_SESSION['next'] = 'finish'; |
| 405 | 405 | } |
| 406 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 406 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 407 | 407 | print json_encode($result); |
| 408 | 408 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'vatsim') { |
| 409 | 409 | include_once('../install/class.create_db.php'); |
@@ -415,48 +415,48 @@ discard block |
||
| 415 | 415 | $error .= update_db::update_IVAO(); |
| 416 | 416 | if ($error != '') { |
| 417 | 417 | $_SESSION['error'] = $error; |
| 418 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
|
| 419 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 418 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert IVAO data')); |
|
| 419 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert IVAO data')); |
|
| 420 | 420 | } else { |
| 421 | 421 | $error .= update_db::update_vatsim(); |
| 422 | 422 | if ($error != '') { |
| 423 | 423 | $_SESSION['error'] = $error; |
| 424 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
|
| 425 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 424 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data')); |
|
| 425 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data')); |
|
| 426 | 426 | } |
| 427 | 427 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
| 428 | 428 | $error .= update_db::update_vatsim(); |
| 429 | 429 | if ($error != '') { |
| 430 | 430 | $_SESSION['error'] = $error; |
| 431 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
|
| 432 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 431 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data')); |
|
| 432 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data')); |
|
| 433 | 433 | } elseif (isset($globalIVAO) && $globalIVAO) { |
| 434 | 434 | if (file_exists('tmp/ivae_feb2013.zip')) { |
| 435 | 435 | $error .= update_db::update_IVAO(); |
| 436 | 436 | if ($error != '') { |
| 437 | 437 | $_SESSION['error'] = $error; |
| 438 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
|
| 439 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 438 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert IVAO data')); |
|
| 439 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert IVAO data')); |
|
| 440 | 440 | } else { |
| 441 | 441 | $error .= update_db::update_vatsim(); |
| 442 | 442 | if ($error != '') { |
| 443 | 443 | $_SESSION['error'] = $error; |
| 444 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)')); |
|
| 445 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
| 444 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data (IVAO not found)')); |
|
| 445 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data (IVAO not found)')); |
|
| 446 | 446 | } |
| 447 | 447 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
| 448 | - $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data')); |
|
| 448 | + $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert phpVMS data')); |
|
| 449 | 449 | } |
| 450 | 450 | //$_SESSION['install'] = 'routes'; |
| 451 | 451 | //$_SESSION['next'] = 'Populate routes table with externals data'; |
| 452 | 452 | $_SESSION['install'] = 'finish'; |
| 453 | 453 | $_SESSION['next'] = 'finish'; |
| 454 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
| 454 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
| 455 | 455 | print json_encode($result); |
| 456 | 456 | } else { |
| 457 | 457 | //unset($_SESSION['install']); |
| 458 | 458 | $_SESSION['error'] = 'Unknwon task : '.$_SESSION['install']; |
| 459 | - $result = array('error' => 'Unknwon task : '.$_SESSION['install'],'done' => $_SESSION['done'],'next' => 'finish','install' => 'finish'); |
|
| 459 | + $result = array('error' => 'Unknwon task : '.$_SESSION['install'], 'done' => $_SESSION['done'], 'next' => 'finish', 'install' => 'finish'); |
|
| 460 | 460 | print json_encode($result); |
| 461 | 461 | } |
| 462 | 462 | ?> |
| 463 | 463 | \ No newline at end of file |
@@ -75,7 +75,9 @@ discard block |
||
| 75 | 75 | if ($error != '') { |
| 76 | 76 | $_SESSION['error'] = $error; |
| 77 | 77 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database')); |
| 78 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
| 78 | + } else { |
|
| 79 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
| 80 | + } |
|
| 79 | 81 | $_SESSION['install'] = 'database_import'; |
| 80 | 82 | $_SESSION['next'] = 'Create and import tables'; |
| 81 | 83 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -93,7 +95,9 @@ discard block |
||
| 93 | 95 | if ($error != '') { |
| 94 | 96 | $_SESSION['error'] = $error; |
| 95 | 97 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
| 96 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
| 98 | + } else { |
|
| 99 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
| 100 | + } |
|
| 97 | 101 | if ((!isset($globalAircraft) || $globalAircraft === TRUE) && (!isset($globalVA) || $globalVA === FALSE)) { |
| 98 | 102 | $_SESSION['install'] = 'populate'; |
| 99 | 103 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B'; |
@@ -107,7 +111,9 @@ discard block |
||
| 107 | 111 | $error .= $check_version; |
| 108 | 112 | $_SESSION['error'] = $error; |
| 109 | 113 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
| 110 | - if (!isset($_SESSION['next'])) $_SESSION['next'] = ''; |
|
| 114 | + if (!isset($_SESSION['next'])) { |
|
| 115 | + $_SESSION['next'] = ''; |
|
| 116 | + } |
|
| 111 | 117 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
| 112 | 118 | print json_encode($result); |
| 113 | 119 | } else { |
@@ -115,7 +121,9 @@ discard block |
||
| 115 | 121 | if ($error != '') { |
| 116 | 122 | $_SESSION['error'] = $error; |
| 117 | 123 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed')); |
| 118 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
| 124 | + } else { |
|
| 125 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
| 126 | + } |
|
| 119 | 127 | $_SESSION['install'] = 'sources'; |
| 120 | 128 | $_SESSION['next'] = 'Insert data in source table'; |
| 121 | 129 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -128,8 +136,10 @@ discard block |
||
| 128 | 136 | if ($error != '') { |
| 129 | 137 | $_SESSION['error'] = $error; |
| 130 | 138 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database')); |
| 131 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
| 132 | -/* |
|
| 139 | + } else { |
|
| 140 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
| 141 | + } |
|
| 142 | + /* |
|
| 133 | 143 | $_SESSION['install'] = 'airspace'; |
| 134 | 144 | $_SESSION['next'] = 'Populate airspace table'; |
| 135 | 145 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -154,7 +164,9 @@ discard block |
||
| 154 | 164 | if ($error != '') { |
| 155 | 165 | $_SESSION['error'] = $error; |
| 156 | 166 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database')); |
| 157 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
| 167 | + } else { |
|
| 168 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
| 169 | + } |
|
| 158 | 170 | if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
| 159 | 171 | $_SESSION['install'] = 'notam'; |
| 160 | 172 | $_SESSION['next'] = 'Populate NOTAM table with externals data'; |
@@ -188,7 +200,9 @@ discard block |
||
| 188 | 200 | if ($error != '') { |
| 189 | 201 | $_SESSION['error'] = $error; |
| 190 | 202 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
| 191 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 203 | + } else { |
|
| 204 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 205 | + } |
|
| 192 | 206 | $_SESSION['install'] = 'populate_flarm'; |
| 193 | 207 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM'; |
| 194 | 208 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -209,18 +223,26 @@ discard block |
||
| 209 | 223 | if ($error != '') { |
| 210 | 224 | $_SESSION['error'] = $error; |
| 211 | 225 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
| 212 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 226 | + } else { |
|
| 227 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 228 | + } |
|
| 213 | 229 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
| 214 | 230 | $_SESSION['install'] = 'vatsim'; |
| 215 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 216 | - else $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 231 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 232 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 233 | + } else { |
|
| 234 | + $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 235 | + } |
|
| 217 | 236 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
| 218 | 237 | $_SESSION['install'] = 'vatsim'; |
| 219 | 238 | $_SESSION['next'] = 'Insert VATSIM data'; |
| 220 | 239 | } elseif (isset($globalIVAO) && $globalIVAO) { |
| 221 | 240 | $_SESSION['install'] = 'vatsim'; |
| 222 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 223 | - else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 241 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 242 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 243 | + } else { |
|
| 244 | + $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 245 | + } |
|
| 224 | 246 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
| 225 | 247 | $_SESSION['install'] = 'vatsim'; |
| 226 | 248 | $_SESSION['next'] = 'Insert phpVMS data'; |
@@ -245,7 +267,9 @@ discard block |
||
| 245 | 267 | if ($error != '') { |
| 246 | 268 | $_SESSION['error'] = $error; |
| 247 | 269 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data')); |
| 248 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
| 270 | + } else { |
|
| 271 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
| 272 | + } |
|
| 249 | 273 | $_SESSION['install'] = 'translation'; |
| 250 | 274 | $_SESSION['next'] = 'Populate translation table with externals data'; |
| 251 | 275 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -265,7 +289,9 @@ discard block |
||
| 265 | 289 | if ($error != '') { |
| 266 | 290 | $_SESSION['error'] = $error; |
| 267 | 291 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
| 268 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
| 292 | + } else { |
|
| 293 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
| 294 | + } |
|
| 269 | 295 | if ($_SESSION['waypoints'] == 1) { |
| 270 | 296 | $_SESSION['install'] = 'waypoints'; |
| 271 | 297 | $_SESSION['next'] = 'Populate waypoints table'; |
@@ -300,7 +326,9 @@ discard block |
||
| 300 | 326 | if ($error != '') { |
| 301 | 327 | $_SESSION['error'] = $error; |
| 302 | 328 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
| 303 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
| 329 | + } else { |
|
| 330 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
| 331 | + } |
|
| 304 | 332 | $_SESSION['install'] = 'sources'; |
| 305 | 333 | $_SESSION['next'] = 'Insert data in source table'; |
| 306 | 334 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -321,12 +349,16 @@ discard block |
||
| 321 | 349 | if ($error != '') { |
| 322 | 350 | $_SESSION['error'] = $error; |
| 323 | 351 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
| 324 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
| 352 | + } else { |
|
| 353 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
| 354 | + } |
|
| 325 | 355 | } else { |
| 326 | 356 | if ($error != '') { |
| 327 | 357 | $_SESSION['error'] = $error; |
| 328 | 358 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)')); |
| 329 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
| 359 | + } else { |
|
| 360 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
| 361 | + } |
|
| 330 | 362 | } |
| 331 | 363 | /* |
| 332 | 364 | if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
@@ -376,7 +408,9 @@ discard block |
||
| 376 | 408 | $Source = new Source(); |
| 377 | 409 | $Source->deleteAllLocation(); |
| 378 | 410 | foreach ($sources as $src) { |
| 379 | - if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
| 411 | + if (isset($src['latitude']) && $src['latitude'] != '') { |
|
| 412 | + $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
| 413 | + } |
|
| 380 | 414 | } |
| 381 | 415 | $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table')); |
| 382 | 416 | unset($_SESSION['sources']); |
@@ -387,15 +421,21 @@ discard block |
||
| 387 | 421 | */ |
| 388 | 422 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
| 389 | 423 | $_SESSION['install'] = 'vatsim'; |
| 390 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 391 | - else $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 424 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 425 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 426 | + } else { |
|
| 427 | + $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 428 | + } |
|
| 392 | 429 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
| 393 | 430 | $_SESSION['install'] = 'vatsim'; |
| 394 | 431 | $_SESSION['next'] = 'Insert VATSIM data'; |
| 395 | 432 | } elseif (isset($globalIVAO) && $globalIVAO) { |
| 396 | 433 | $_SESSION['install'] = 'vatsim'; |
| 397 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 398 | - else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 434 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 435 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 436 | + } else { |
|
| 437 | + $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 438 | + } |
|
| 399 | 439 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
| 400 | 440 | $_SESSION['install'] = 'vatsim'; |
| 401 | 441 | $_SESSION['next'] = 'Insert phpVMS data'; |
@@ -416,33 +456,43 @@ discard block |
||
| 416 | 456 | if ($error != '') { |
| 417 | 457 | $_SESSION['error'] = $error; |
| 418 | 458 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
| 419 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 459 | + } else { |
|
| 460 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 461 | + } |
|
| 420 | 462 | } else { |
| 421 | 463 | $error .= update_db::update_vatsim(); |
| 422 | 464 | if ($error != '') { |
| 423 | 465 | $_SESSION['error'] = $error; |
| 424 | 466 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
| 425 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 467 | + } else { |
|
| 468 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 469 | + } |
|
| 426 | 470 | } |
| 427 | 471 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
| 428 | 472 | $error .= update_db::update_vatsim(); |
| 429 | 473 | if ($error != '') { |
| 430 | 474 | $_SESSION['error'] = $error; |
| 431 | 475 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
| 432 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 476 | + } else { |
|
| 477 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 478 | + } |
|
| 433 | 479 | } elseif (isset($globalIVAO) && $globalIVAO) { |
| 434 | 480 | if (file_exists('tmp/ivae_feb2013.zip')) { |
| 435 | 481 | $error .= update_db::update_IVAO(); |
| 436 | 482 | if ($error != '') { |
| 437 | 483 | $_SESSION['error'] = $error; |
| 438 | 484 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
| 439 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 485 | + } else { |
|
| 486 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 487 | + } |
|
| 440 | 488 | } else { |
| 441 | 489 | $error .= update_db::update_vatsim(); |
| 442 | 490 | if ($error != '') { |
| 443 | 491 | $_SESSION['error'] = $error; |
| 444 | 492 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)')); |
| 445 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
| 493 | + } else { |
|
| 494 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
| 495 | + } |
|
| 446 | 496 | } |
| 447 | 497 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
| 448 | 498 | $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data')); |