@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
9 | 9 | |
10 | 10 | if (!empty($spotter_array)) |
11 | 11 | { |
12 | - $title = sprintf(_("Most Common Departure Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
12 | + $title = sprintf(_("Most Common Departure Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
13 | 13 | |
14 | 14 | require_once('header.php'); |
15 | 15 | print '<div class="select-item">'; |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
28 | 28 | print '<br />'; |
29 | 29 | print '<div class="info column">'; |
30 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
30 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
31 | 31 | print '</div>'; |
32 | 32 | |
33 | 33 | include('date-sub-menu.php'); |
34 | 34 | print '<div class="column">'; |
35 | 35 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
36 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
36 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
37 | 37 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByDate($date); |
38 | 38 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
39 | 39 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
42 | 42 | print 'var series = ['; |
43 | 43 | $country_data = ''; |
44 | - foreach($airport_country_array as $airport_item) |
|
44 | + foreach ($airport_country_array as $airport_item) |
|
45 | 45 | { |
46 | 46 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
47 | 47 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | print '</thead>'; |
90 | 90 | print '<tbody>'; |
91 | 91 | $i = 1; |
92 | - foreach($airport_country_array as $airport_item) |
|
92 | + foreach ($airport_country_array as $airport_item) |
|
93 | 93 | { |
94 | 94 | print '<tr>'; |
95 | 95 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,17 +3,17 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING); |
|
8 | 8 | if ($registration != '') { |
9 | 9 | $spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort); |
10 | 10 | $aircraft_array = $Spotter->getAircraftInfoByRegistration($registration); |
11 | -} else $spotter_array=array(); |
|
11 | +} else $spotter_array = array(); |
|
12 | 12 | |
13 | 13 | |
14 | 14 | if (!empty($spotter_array)) |
15 | 15 | { |
16 | - $title = sprintf(_("Most Common Arrival Airports by Country of aircraft with registration %s"),$registration); |
|
16 | + $title = sprintf(_("Most Common Arrival Airports by Country of aircraft with registration %s"), $registration); |
|
17 | 17 | require_once('header.php'); |
18 | 18 | print '<div class="info column">'; |
19 | 19 | print '<h1>'.$_GET['registration'].' - '.$aircraft_array[0]['aircraft_name'].' ('.$aircraft_array[0]['aircraft_icao'].')</h1>'; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | include('registration-sub-menu.php'); |
26 | 26 | print '<div class="column">'; |
27 | 27 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
28 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights with aircraft registration <strong>%s</strong>."),$registration).'</p>'; |
|
28 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights with aircraft registration <strong>%s</strong>."), $registration).'</p>'; |
|
29 | 29 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByRegistration($registration); |
30 | 30 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
31 | 31 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
34 | 34 | print 'var series = ['; |
35 | 35 | $country_data = ''; |
36 | - foreach($airport_country_array as $airport_item) |
|
36 | + foreach ($airport_country_array as $airport_item) |
|
37 | 37 | { |
38 | 38 | $country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],'; |
39 | 39 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | print '</thead>'; |
82 | 82 | print '<tbody>'; |
83 | 83 | $i = 1; |
84 | - foreach($airport_country_array as $airport_item) |
|
84 | + foreach ($airport_country_array as $airport_item) |
|
85 | 85 | { |
86 | 86 | print '<tr>'; |
87 | 87 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | } |
10 | 10 | |
11 | 11 | $Spotter = new Spotter(); |
12 | -$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))); |
|
13 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
14 | -$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort); |
|
12 | +$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING))); |
|
13 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
14 | +$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $sort); |
|
15 | 15 | |
16 | 16 | if (!empty($spotter_array)) |
17 | 17 | { |
18 | - $title = sprintf(_("Most Common Arrival Airports by Country from %s"),$manufacturer); |
|
18 | + $title = sprintf(_("Most Common Arrival Airports by Country from %s"), $manufacturer); |
|
19 | 19 | |
20 | 20 | require_once('header.php'); |
21 | 21 | print '<div class="select-item">'; |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | $Stats = new Stats(); |
25 | 25 | $all_manufacturers = $Stats->getAllManufacturers(); |
26 | 26 | if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
27 | - foreach($all_manufacturers as $all_manufacturer) |
|
27 | + foreach ($all_manufacturers as $all_manufacturer) |
|
28 | 28 | { |
29 | - if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
29 | + if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
30 | 30 | { |
31 | 31 | print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>'; |
32 | 32 | } else { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | include('manufacturer-sub-menu.php'); |
46 | 46 | print '<div class="column">'; |
47 | 47 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
48 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s</strong>."),$manufacturer).'</p>'; |
|
48 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s</strong>."), $manufacturer).'</p>'; |
|
49 | 49 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByManufacturer($manufacturer); |
50 | 50 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
51 | 51 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
54 | 54 | print 'var series = ['; |
55 | 55 | $country_data = ''; |
56 | - foreach($airport_country_array as $airport_item) |
|
56 | + foreach ($airport_country_array as $airport_item) |
|
57 | 57 | { |
58 | 58 | $country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],'; |
59 | 59 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | print '</thead>'; |
102 | 102 | print '<tbody>'; |
103 | 103 | $i = 1; |
104 | - foreach($airport_country_array as $airport_item) |
|
104 | + foreach ($airport_country_array as $airport_item) |
|
105 | 105 | { |
106 | 106 | print '<tr>'; |
107 | 107 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,16 +3,16 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | 7 | if (isset($_GET['registration'])) { |
8 | - $registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING); |
|
8 | + $registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING); |
|
9 | 9 | $spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort); |
10 | 10 | $aircraft_array = $Spotter->getAircraftInfoByRegistration($registration); |
11 | 11 | } else $spotter_array = array(); |
12 | 12 | |
13 | 13 | if (!empty($spotter_array)) |
14 | 14 | { |
15 | - $title = sprintf(_("Most Common Departure Airports by Country of aircraft with registration %s"),$registration); |
|
15 | + $title = sprintf(_("Most Common Departure Airports by Country of aircraft with registration %s"), $registration); |
|
16 | 16 | require_once('header.php'); |
17 | 17 | print '<div class="info column">'; |
18 | 18 | print '<h1>'.$registration.' - '.$aircraft_array[0]['aircraft_name'].' ('.$aircraft_array[0]['aircraft_icao'].')</h1>'; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | include('registration-sub-menu.php'); |
25 | 25 | print '<div class="column">'; |
26 | 26 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
27 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with aircraft registration <strong>%s</strong>."),$registration).'</p>'; |
|
27 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with aircraft registration <strong>%s</strong>."), $registration).'</p>'; |
|
28 | 28 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByRegistration($registration); |
29 | 29 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
30 | 30 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
33 | 33 | print 'var series = ['; |
34 | 34 | $country_data = ''; |
35 | - foreach($airport_country_array as $airport_item) |
|
35 | + foreach ($airport_country_array as $airport_item) |
|
36 | 36 | { |
37 | 37 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
38 | 38 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | print '</thead>'; |
81 | 81 | print '<tbody>'; |
82 | 82 | $i = 1; |
83 | - foreach($airport_country_array as $airport_item) |
|
83 | + foreach ($airport_country_array as $airport_item) |
|
84 | 84 | { |
85 | 85 | print '<tr>'; |
86 | 86 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | </span> |
4 | 4 | <div class="sub-menu sub-menu-container"> |
5 | 5 | <ul class="nav nav-pills"> |
6 | - <li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
6 | + <li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
7 | 7 | <li class="dropdown"> |
8 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
8 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
9 | 9 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
10 | 10 | </a> |
11 | 11 | <ul class="dropdown-menu" role="menu"> |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | </ul> |
15 | 15 | </li> |
16 | 16 | <li class="dropdown"> |
17 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
17 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
18 | 18 | <?php echo _("Airline"); ?> <span class="caret"></span> |
19 | 19 | </a> |
20 | 20 | <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) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
26 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-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,7 +33,7 @@ discard block |
||
33 | 33 | <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/arrival-airport-country/<?php print $manufacturer; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
34 | 34 | </ul> |
35 | 35 | </li> |
36 | - <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
37 | - <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
36 | + <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
37 | + <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
38 | 38 | </ul> |
39 | 39 | </div> |
40 | 40 | \ No newline at end of file |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | die(); |
9 | 9 | } |
10 | 10 | $Spotter = new Spotter(); |
11 | -$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))); |
|
12 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
13 | -$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort); |
|
11 | +$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING))); |
|
12 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
13 | +$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $sort); |
|
14 | 14 | |
15 | 15 | if (!empty($spotter_array)) |
16 | 16 | { |
17 | - $title = sprintf(_("'Most Common Departure Airports by Country from %s"),$manufacturer); |
|
17 | + $title = sprintf(_("'Most Common Departure Airports by Country from %s"), $manufacturer); |
|
18 | 18 | |
19 | 19 | require_once('header.php'); |
20 | 20 | print '<div class="select-item">'; |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | $Stats = new Stats(); |
24 | 24 | $all_manufacturers = $Stats->getAllManufacturers(); |
25 | 25 | if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
26 | - foreach($all_manufacturers as $all_manufacturer) |
|
26 | + foreach ($all_manufacturers as $all_manufacturer) |
|
27 | 27 | { |
28 | - if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
28 | + if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
29 | 29 | { |
30 | 30 | print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>'; |
31 | 31 | } else { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | include('manufacturer-sub-menu.php'); |
45 | 45 | print '<div class="column">'; |
46 | 46 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
47 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s</strong>."),$manufacturer).'</p>'; |
|
47 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s</strong>."), $manufacturer).'</p>'; |
|
48 | 48 | |
49 | 49 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByManufacturer($manufacturer); |
50 | 50 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
54 | 54 | print 'var series = ['; |
55 | 55 | $country_data = ''; |
56 | - foreach($airport_country_array as $airport_item) |
|
56 | + foreach ($airport_country_array as $airport_item) |
|
57 | 57 | { |
58 | 58 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
59 | 59 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | print '</thead>'; |
102 | 102 | print '<tbody>'; |
103 | 103 | $i = 1; |
104 | - foreach($airport_country_array as $airport_item) |
|
104 | + foreach ($airport_country_array as $airport_item) |
|
105 | 105 | { |
106 | 106 | print '<tr>'; |
107 | 107 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
11 | -$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
12 | -$spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", $sort); |
|
10 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
11 | +$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
12 | +$spotter_array = $Spotter->getSpotterDataByIdent($ident, "0,1", $sort); |
|
13 | 13 | |
14 | 14 | if (!empty($spotter_array)) |
15 | 15 | { |
16 | - $title = sprintf(_("Most Common Departure Airports by Country of %s"),$spotter_array[0]['ident']); |
|
16 | + $title = sprintf(_("Most Common Departure Airports by Country of %s"), $spotter_array[0]['ident']); |
|
17 | 17 | require_once('header.php'); |
18 | 18 | print '<div class="info column">'; |
19 | 19 | print '<h1>'.$spotter_array[0]['ident'].'</h1>'; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | include('ident-sub-menu.php'); |
24 | 24 | print '<div class="column">'; |
25 | 25 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
26 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
26 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with the ident/callsign <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
27 | 27 | |
28 | 28 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByIdent($ident); |
29 | 29 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
33 | 33 | print 'var series = ['; |
34 | 34 | $country_data = ''; |
35 | - foreach($airport_country_array as $airport_item) |
|
35 | + foreach ($airport_country_array as $airport_item) |
|
36 | 36 | { |
37 | 37 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
38 | 38 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | print '</thead>'; |
81 | 81 | print '<tbody>'; |
82 | 82 | $i = 1; |
83 | - foreach($airport_country_array as $airport_item) |
|
83 | + foreach ($airport_country_array as $airport_item) |
|
84 | 84 | { |
85 | 85 | print '<tr>'; |
86 | 86 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | if (isset($_GET['coord'])) |
13 | 13 | { |
14 | - $coords = explode(',',$_GET['coord']); |
|
14 | + $coords = explode(',', $_GET['coord']); |
|
15 | 15 | $spotter_array = $Spotter->getAllAirportInfobyCoord($coords); |
16 | 16 | } else { |
17 | 17 | $spotter_array = $Spotter->getAllAirportInfo(); |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | |
23 | 23 | if (!empty($spotter_array)) |
24 | 24 | { |
25 | - foreach($spotter_array as $spotter_item) |
|
25 | + foreach ($spotter_array as $spotter_item) |
|
26 | 26 | { |
27 | 27 | date_default_timezone_set('UTC'); |
28 | 28 | //waypoint plotting |
29 | 29 | $output .= '{"type": "Feature",'; |
30 | 30 | $output .= '"properties": {'; |
31 | - $output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",'; |
|
32 | - $output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",'; |
|
31 | + $output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",'; |
|
32 | + $output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",'; |
|
33 | 33 | $output .= '"country": "'.$spotter_item['country'].'",'; |
34 | 34 | $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
35 | - $output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
35 | + $output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
36 | 36 | if ($spotter_item['type'] == 'large_airport') { |
37 | 37 | $output .= '"icon": "'.$globalURL.'/images/airport.png",'; |
38 | 38 | } elseif ($spotter_item['type'] == 'heliport') { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $output .= '}'; |
60 | 60 | $output .= '},'; |
61 | 61 | } |
62 | - $output = substr($output, 0, -1); |
|
62 | + $output = substr($output, 0, -1); |
|
63 | 63 | } |
64 | 64 | $output .= ']}'; |
65 | 65 | print $output; |
@@ -29,31 +29,31 @@ discard block |
||
29 | 29 | |
30 | 30 | private function make_latf($temp) { // unsigned long |
31 | 31 | $flat = 0.0; // float |
32 | - $temp = $temp & 0x07FFFFFF; |
|
33 | - if ($temp & 0x04000000) { |
|
34 | - $temp = $temp ^ 0x07FFFFFF; |
|
32 | + $temp = $temp&0x07FFFFFF; |
|
33 | + if ($temp&0x04000000) { |
|
34 | + $temp = $temp^0x07FFFFFF; |
|
35 | 35 | $temp += 1; |
36 | - $flat = (float)($temp / (60.0 * 10000.0)); |
|
36 | + $flat = (float) ($temp/(60.0*10000.0)); |
|
37 | 37 | $flat *= -1.0; |
38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
38 | + } else $flat = (float) ($temp/(60.0*10000.0)); |
|
39 | 39 | return $flat; // float |
40 | 40 | } |
41 | 41 | |
42 | 42 | private function make_lonf($temp) { // unsigned long |
43 | 43 | $flon = 0.0; // float |
44 | - $temp = $temp & 0x0FFFFFFF; |
|
45 | - if ($temp & 0x08000000) { |
|
46 | - $temp = $temp ^ 0x0FFFFFFF; |
|
44 | + $temp = $temp&0x0FFFFFFF; |
|
45 | + if ($temp&0x08000000) { |
|
46 | + $temp = $temp^0x0FFFFFFF; |
|
47 | 47 | $temp += 1; |
48 | - $flon = (float)($temp / (60.0 * 10000.0)); |
|
48 | + $flon = (float) ($temp/(60.0*10000.0)); |
|
49 | 49 | $flon *= -1.0; |
50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
50 | + } else $flon = (float) ($temp/(60.0*10000.0)); |
|
51 | 51 | return $flon; |
52 | 52 | } |
53 | 53 | |
54 | 54 | private function ascii_2_dec($chr) { |
55 | - $dec=ord($chr);//get decimal ascii code |
|
56 | - $hex=dechex($dec);//convert decimal to hex |
|
55 | + $dec = ord($chr); //get decimal ascii code |
|
56 | + $hex = dechex($dec); //convert decimal to hex |
|
57 | 57 | return ($dec); |
58 | 58 | } |
59 | 59 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | //only process in the following range: 48-87, 96-119 |
73 | 73 | if ($ascii < 48) { } |
74 | 74 | else { |
75 | - if($ascii>119) { } |
|
75 | + if ($ascii > 119) { } |
|
76 | 76 | else { |
77 | - if ($ascii>87 && $ascii<96) ; |
|
77 | + if ($ascii > 87 && $ascii < 96); |
|
78 | 78 | else { |
79 | - $ascii=$ascii+40; |
|
80 | - if ($ascii>128){ |
|
81 | - $ascii=$ascii+32; |
|
79 | + $ascii = $ascii + 40; |
|
80 | + if ($ascii > 128) { |
|
81 | + $ascii = $ascii + 32; |
|
82 | 82 | } else { |
83 | - $ascii=$ascii+40; |
|
83 | + $ascii = $ascii + 40; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | private function dec_2_6bit($dec) { |
92 | - $bin=decbin($dec); |
|
92 | + $bin = decbin($dec); |
|
93 | 93 | return(substr($bin, -6)); |
94 | 94 | } |
95 | 95 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | ); |
108 | 108 | // " |
109 | 109 | $rv = ''; |
110 | - if ($_size % 6 == 0) { |
|
111 | - $len = $_size / 6; |
|
112 | - for ($i=0; $i<$len; $i++) { |
|
113 | - $offset = $i * 6; |
|
114 | - $rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ]; |
|
110 | + if ($_size%6 == 0) { |
|
111 | + $len = $_size/6; |
|
112 | + for ($i = 0; $i < $len; $i++) { |
|
113 | + $offset = $i*6; |
|
114 | + $rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))]; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | return $rv; |
@@ -138,93 +138,93 @@ discard block |
||
138 | 138 | $ro->eta_hour = ''; |
139 | 139 | $ro->eta_minute = ''; |
140 | 140 | $ro->ts = time(); |
141 | - $ro->id = bindec(substr($_aisdata,0,6)); |
|
142 | - $ro->mmsi = bindec(substr($_aisdata,8,30)); |
|
141 | + $ro->id = bindec(substr($_aisdata, 0, 6)); |
|
142 | + $ro->mmsi = bindec(substr($_aisdata, 8, 30)); |
|
143 | 143 | if ($ro->id >= 1 && $ro->id <= 3) { |
144 | - $ro->cog = bindec(substr($_aisdata,116,12))/10; |
|
145 | - $ro->sog = bindec(substr($_aisdata,50,10))/10; |
|
146 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
147 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
144 | + $ro->cog = bindec(substr($_aisdata, 116, 12))/10; |
|
145 | + $ro->sog = bindec(substr($_aisdata, 50, 10))/10; |
|
146 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
147 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
148 | 148 | $ro->cls = 1; // class A |
149 | 149 | } else if ($ro->id == 4) { |
150 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28))); |
|
151 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27))); |
|
150 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28))); |
|
151 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27))); |
|
152 | 152 | $ro->cls = 1; // class A |
153 | 153 | } else if ($ro->id == 5) { |
154 | - $ro->imo = bindec(substr($_aisdata,40,30)); |
|
155 | - $ro->callsign = $this->binchar($_aisdata,70,42); |
|
156 | - $ro->name = $this->binchar($_aisdata,112,120); |
|
157 | - $ro->typeid = bindec(substr($_aisdata,232,8)); |
|
154 | + $ro->imo = bindec(substr($_aisdata, 40, 30)); |
|
155 | + $ro->callsign = $this->binchar($_aisdata, 70, 42); |
|
156 | + $ro->name = $this->binchar($_aisdata, 112, 120); |
|
157 | + $ro->typeid = bindec(substr($_aisdata, 232, 8)); |
|
158 | 158 | $ro->type = $this->getShipType($ro->typeid); |
159 | 159 | //$ro->to_bow = bindec(substr($_aisdata,240,9)); |
160 | 160 | //$ro->to_stern = bindec(substr($_aisdata,249,9)); |
161 | 161 | //$ro->to_port = bindec(substr($_aisdata,258,6)); |
162 | 162 | //$ro->to_starboard = bindec(substr($_aisdata,264,6)); |
163 | - $ro->eta_month = bindec(substr($_aisdata,274,4)); |
|
164 | - $ro->eta_day = bindec(substr($_aisdata,278,5)); |
|
165 | - $ro->eta_hour = bindec(substr($_aisdata,283,5)); |
|
166 | - $ro->eta_minute = bindec(substr($_aisdata,288,6)); |
|
163 | + $ro->eta_month = bindec(substr($_aisdata, 274, 4)); |
|
164 | + $ro->eta_day = bindec(substr($_aisdata, 278, 5)); |
|
165 | + $ro->eta_hour = bindec(substr($_aisdata, 283, 5)); |
|
166 | + $ro->eta_minute = bindec(substr($_aisdata, 288, 6)); |
|
167 | 167 | //$ro->draught = bindec(substr($_aisdata,294,8)); |
168 | - $ro->destination = $this->binchar($_aisdata,302,120); |
|
168 | + $ro->destination = $this->binchar($_aisdata, 302, 120); |
|
169 | 169 | $ro->cls = 1; // class A |
170 | 170 | } else if ($ro->id == 9) { |
171 | 171 | // Search and Rescue aircraft position report |
172 | 172 | } else if ($ro->id == 18) { |
173 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
174 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
175 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
|
176 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
|
177 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
173 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
174 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
175 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28))); |
|
176 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27))); |
|
177 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
178 | 178 | if ($ro->heading == 511) $ro->heading = ''; |
179 | 179 | $ro->cls = 2; // class B |
180 | 180 | } else if ($ro->id == 19) { |
181 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
182 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
183 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
184 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
185 | - $ro->name = $this->binchar($_aisdata,143,120); |
|
181 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
182 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
183 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
184 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
185 | + $ro->name = $this->binchar($_aisdata, 143, 120); |
|
186 | 186 | $ro->cls = 2; // class B |
187 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
187 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
188 | 188 | if ($ro->heading == 511) $ro->heading = ''; |
189 | - $ro->typeid = bindec(substr($_aisdata,263,8)); |
|
189 | + $ro->typeid = bindec(substr($_aisdata, 263, 8)); |
|
190 | 190 | $ro->type = $this->getShipType($ro->typeid); |
191 | 191 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
192 | 192 | //$ro->to_stern = bindec(substr($_aisdata,280,9)); |
193 | 193 | //$ro->to_port = bindec(substr($_aisdata,289,6)); |
194 | 194 | //$ro->to_starboard = bindec(substr($_aisdata,295,6)); |
195 | 195 | } else if ($ro->id == 21) { |
196 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28))); |
|
197 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27))); |
|
198 | - $ro->name = $this->binchar($_aisdata,43,120); |
|
196 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28))); |
|
197 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27))); |
|
198 | + $ro->name = $this->binchar($_aisdata, 43, 120); |
|
199 | 199 | //$ro->to_bow = bindec(substr($_aisdata,219,9)); |
200 | 200 | //$ro->to_stern = bindec(substr($_aisdata,228,9)); |
201 | 201 | //$ro->to_port = bindec(substr($_aisdata,237,6)); |
202 | 202 | //$ro->to_starboard = bindec(substr($_aisdata,243,6)); |
203 | 203 | $ro->cls = 2; // class B |
204 | 204 | } else if ($ro->id == 24) { |
205 | - $pn = bindec(substr($_aisdata,38,2)); |
|
205 | + $pn = bindec(substr($_aisdata, 38, 2)); |
|
206 | 206 | if ($pn == 0) { |
207 | - $ro->name = $this->binchar($_aisdata,40,120); |
|
207 | + $ro->name = $this->binchar($_aisdata, 40, 120); |
|
208 | 208 | } |
209 | - $ro->typeid = bindec(substr($_aisdata,40,8)); |
|
209 | + $ro->typeid = bindec(substr($_aisdata, 40, 8)); |
|
210 | 210 | $ro->type = $this->getShipType($ro->typeid); |
211 | - $ro->callsign = $this->binchar($_aisdata,90,42); |
|
211 | + $ro->callsign = $this->binchar($_aisdata, 90, 42); |
|
212 | 212 | //$ro->to_bow = bindec(substr($_aisdata,132,9)); |
213 | 213 | //$ro->to_stern = bindec(substr($_aisdata,141,9)); |
214 | 214 | //$ro->to_port = bindec(substr($_aisdata,150,6)); |
215 | 215 | //$ro->to_starboard = bindec(substr($_aisdata,156,6)); |
216 | 216 | $ro->cls = 2; // class B |
217 | 217 | } else if ($ro->id == 27) { |
218 | - $ro->cog = bindec(substr($_aisdata,85,9)); |
|
218 | + $ro->cog = bindec(substr($_aisdata, 85, 9)); |
|
219 | 219 | if ($ro->cog == 511) $ro->cog = 0.0; |
220 | - $ro->sog = bindec(substr($_aisdata,79,6)); |
|
220 | + $ro->sog = bindec(substr($_aisdata, 79, 6)); |
|
221 | 221 | if ($ro->sog == 63) $ro->sog = 0.0; |
222 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
|
223 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
|
222 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10); |
|
223 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10); |
|
224 | 224 | $ro->cls = 1; // class A |
225 | 225 | |
226 | 226 | } |
227 | - $ro->statusid = bindec(substr($_aisdata,38,4)); |
|
227 | + $ro->statusid = bindec(substr($_aisdata, 38, 4)); |
|
228 | 228 | $ro->status = $this->getStatus($ro->statusid); |
229 | 229 | //var_dump($ro); // dump results here for demo purpose |
230 | 230 | return $ro; |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | global $port; // tcpip port... |
356 | 356 | |
357 | 357 | static $debug_counter = 0; |
358 | - $aisdata168='';//six bit array of ascii characters |
|
358 | + $aisdata168 = ''; //six bit array of ascii characters |
|
359 | 359 | $ais_nmea_array = str_split($_itu); // convert to an array |
360 | 360 | foreach ($ais_nmea_array as $value) { |
361 | 361 | $dec = $this->ascii_2_dec($value); |
362 | 362 | $bit8 = $this->asciidec_2_8bit($dec); |
363 | 363 | $bit6 = $this->dec_2_6bit($bit8); |
364 | 364 | //echo $value ."-" .$bit6 .""; |
365 | - $aisdata168 .=$bit6; |
|
365 | + $aisdata168 .= $bit6; |
|
366 | 366 | } |
367 | 367 | //echo $aisdata168 . "<br/>"; |
368 | 368 | //return $this->decode_ais($aisdata168, $aux); |
@@ -385,20 +385,20 @@ discard block |
||
385 | 385 | // calculate checksum after ! till * |
386 | 386 | // assume 1st ! is valid |
387 | 387 | // find * ensure that it is at correct position |
388 | - $end = strrpos ( $rawdata , '*' ); |
|
388 | + $end = strrpos($rawdata, '*'); |
|
389 | 389 | if ($end === FALSE) return -1; // check for NULLS!!! |
390 | - $cs = substr( $rawdata, $end + 1 ); |
|
391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
392 | - $dcs = (int)hexdec( $cs ); |
|
393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
394 | - if ( $chksum == $dcs ) { // NMEA checksum pass |
|
390 | + $cs = substr($rawdata, $end + 1); |
|
391 | + if (strlen($cs) != 2) return -1; // correct cs length |
|
392 | + $dcs = (int) hexdec($cs); |
|
393 | + for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum |
|
394 | + if ($chksum == $dcs) { // NMEA checksum pass |
|
395 | 395 | $pcs = explode(',', $rawdata); |
396 | 396 | // !AI??? identifier |
397 | - $num_seq = (int)$pcs[1]; // number of sequences |
|
398 | - $seq = (int)$pcs[2]; // get sequence |
|
397 | + $num_seq = (int) $pcs[1]; // number of sequences |
|
398 | + $seq = (int) $pcs[2]; // get sequence |
|
399 | 399 | // get msg sequence id |
400 | 400 | if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
401 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
401 | + else $msg_sid = (int) $pcs[3]; // multipart message |
|
402 | 402 | $ais_ch = $pcs[4]; // get AIS channel |
403 | 403 | // message sequence checking |
404 | 404 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } |
432 | 432 | } |
433 | 433 | $itu = $itu.$pcs[5]; // get itu message |
434 | - $filler += (int)$pcs[6][0]; // get filler |
|
434 | + $filler += (int) $pcs[6][0]; // get filler |
|
435 | 435 | if ($num_seq == 1 // valid single message |
436 | 436 | || $num_seq == $pseq // valid multi-part message |
437 | 437 | ) { |
@@ -451,13 +451,13 @@ discard block |
||
451 | 451 | $cbuf = $cbuf.$ibuf; |
452 | 452 | $last_pos = 0; |
453 | 453 | $result = new stdClass(); |
454 | - while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) { |
|
454 | + while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) { |
|
455 | 455 | //while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) { |
456 | 456 | //DEBUG echo $cbuf; |
457 | - if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
457 | + if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
458 | 458 | $tst = substr($cbuf, $start - 3, ($end - $start + 3)); |
459 | 459 | //DEBUG echo "[$start $end $tst]\n"; |
460 | - $result = $this->process_ais_raw( $tst, "" ); |
|
460 | + $result = $this->process_ais_raw($tst, ""); |
|
461 | 461 | $last_pos = $end + 1; |
462 | 462 | } else break; |
463 | 463 | } |
@@ -469,41 +469,41 @@ discard block |
||
469 | 469 | // incoming data from serial or IP comms |
470 | 470 | public function process_ais_line($cbuf) { |
471 | 471 | $result = new stdClass(); |
472 | - $start = strpos($cbuf,"VDM"); |
|
472 | + $start = strpos($cbuf, "VDM"); |
|
473 | 473 | $tst = substr($cbuf, $start - 3); |
474 | - $result = $this->process_ais_raw( $tst, "" ); |
|
474 | + $result = $this->process_ais_raw($tst, ""); |
|
475 | 475 | return $result; |
476 | 476 | } |
477 | 477 | |
478 | 478 | /* AIS Encoding |
479 | 479 | */ |
480 | - private function mk_ais_lat( $lat ) { |
|
480 | + private function mk_ais_lat($lat) { |
|
481 | 481 | //$lat = 1.2569; |
482 | - if ($lat<0.0) { |
|
482 | + if ($lat < 0.0) { |
|
483 | 483 | $lat = -$lat; |
484 | - $neg=true; |
|
485 | - } else $neg=false; |
|
484 | + $neg = true; |
|
485 | + } else $neg = false; |
|
486 | 486 | $latd = 0x00000000; |
487 | - $latd = intval ($lat * 600000.0); |
|
488 | - if ($neg==true) { |
|
487 | + $latd = intval($lat*600000.0); |
|
488 | + if ($neg == true) { |
|
489 | 489 | $latd = ~$latd; |
490 | - $latd+=1; |
|
490 | + $latd += 1; |
|
491 | 491 | $latd &= 0x07FFFFFF; |
492 | 492 | } |
493 | 493 | return $latd; |
494 | 494 | } |
495 | 495 | |
496 | - private function mk_ais_lon( $lon ) { |
|
496 | + private function mk_ais_lon($lon) { |
|
497 | 497 | //$lon = 103.851; |
498 | - if ($lon<0.0) { |
|
498 | + if ($lon < 0.0) { |
|
499 | 499 | $lon = -$lon; |
500 | - $neg=true; |
|
501 | - } else $neg=false; |
|
500 | + $neg = true; |
|
501 | + } else $neg = false; |
|
502 | 502 | $lond = 0x00000000; |
503 | - $lond = intval ($lon * 600000.0); |
|
504 | - if ($neg==true) { |
|
503 | + $lond = intval($lon*600000.0); |
|
504 | + if ($neg == true) { |
|
505 | 505 | $lond = ~$lond; |
506 | - $lond+=1; |
|
506 | + $lond += 1; |
|
507 | 507 | $lond &= 0x0FFFFFFF; |
508 | 508 | } |
509 | 509 | return $lond; |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | |
512 | 512 | private function char2bin($name, $max_len) { |
513 | 513 | $len = strlen($name); |
514 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
515 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
514 | + if ($len > $max_len) $name = substr($name, 0, $max_len); |
|
515 | + if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6); |
|
516 | 516 | else $pad = ''; |
517 | 517 | $rv = ''; |
518 | 518 | $ais_chars = array( |
@@ -529,26 +529,26 @@ discard block |
||
529 | 529 | if ($_a) foreach ($_a as $_1) { |
530 | 530 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
531 | 531 | else $dec = 0; |
532 | - $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
|
532 | + $bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT); |
|
533 | 533 | $rv .= $bin; |
534 | 534 | //echo "$_1 $dec ($bin)<br/>"; |
535 | 535 | } |
536 | 536 | return $rv.$pad; |
537 | 537 | } |
538 | 538 | |
539 | - private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') { |
|
539 | + private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') { |
|
540 | 540 | $len_bit = strlen($_enc); |
541 | - $rem6 = $len_bit % 6; |
|
541 | + $rem6 = $len_bit%6; |
|
542 | 542 | $pad6_len = 0; |
543 | 543 | if ($rem6) $pad6_len = 6 - $rem6; |
544 | 544 | //echo $pad6_len.'<br>'; |
545 | 545 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
546 | - $len_enc = strlen($_enc) / 6; |
|
546 | + $len_enc = strlen($_enc)/6; |
|
547 | 547 | //echo $_enc.' '.$len_enc.'<br/>'; |
548 | 548 | $itu = ''; |
549 | - for ($i=0; $i<$len_enc; $i++) { |
|
550 | - $offset = $i * 6; |
|
551 | - $dec = bindec(substr($_enc,$offset,6)); |
|
549 | + for ($i = 0; $i < $len_enc; $i++) { |
|
550 | + $offset = $i*6; |
|
551 | + $dec = bindec(substr($_enc, $offset, 6)); |
|
552 | 552 | if ($dec < 40) $dec += 48; |
553 | 553 | else $dec += 56; |
554 | 554 | //echo chr($dec)." $dec<br/>"; |
@@ -558,15 +558,15 @@ discard block |
||
558 | 558 | $chksum = 0; |
559 | 559 | $itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0"; |
560 | 560 | $len_itu = strlen($itu); |
561 | - for ($i=0; $i<$len_itu; $i++) { |
|
562 | - $chksum ^= ord( $itu[$i] ); |
|
561 | + for ($i = 0; $i < $len_itu; $i++) { |
|
562 | + $chksum ^= ord($itu[$i]); |
|
563 | 563 | } |
564 | - $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
565 | - $lsb = $chksum & 0x0F; |
|
566 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
564 | + $hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
565 | + $lsb = $chksum&0x0F; |
|
566 | + if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb]; |
|
567 | 567 | else $lsbc = '0'; |
568 | - $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
|
569 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
568 | + $msb = (($chksum&0xF0) >> 4)&0x0F; |
|
569 | + if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb]; |
|
570 | 570 | else $msbc = '0'; |
571 | 571 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
572 | 572 | return $itu; |
@@ -591,14 +591,14 @@ discard block |
||
591 | 591 | |
592 | 592 | public function mmsitype($mmsi) { |
593 | 593 | if (strlen($mmsi) == 9) { |
594 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
600 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
601 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
594 | + if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | + elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | + elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | + elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | + elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | + elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation'; |
|
600 | + elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations'; |
|
601 | + elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships'; |
|
602 | 602 | else return 'Ship'; |
603 | 603 | } |
604 | 604 | |
@@ -609,19 +609,19 @@ discard block |
||
609 | 609 | global $globalDebug; |
610 | 610 | $result = array(); |
611 | 611 | $data = new stdClass(); |
612 | - $start = strpos($buffer,"VDM"); |
|
612 | + $start = strpos($buffer, "VDM"); |
|
613 | 613 | $tst = substr($buffer, $start - 3); |
614 | - $data = $this->process_ais_raw( $tst, "" ); |
|
614 | + $data = $this->process_ais_raw($tst, ""); |
|
615 | 615 | if (!is_object($data)) { |
616 | 616 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
617 | 617 | return array(); |
618 | 618 | } |
619 | 619 | if ($data->lon != 0) $result['longitude'] = $data->lon; |
620 | 620 | if ($data->lat != 0) $result['latitude'] = $data->lat; |
621 | - $result['ident'] = trim(str_replace('@','',$data->name)); |
|
621 | + $result['ident'] = trim(str_replace('@', '', $data->name)); |
|
622 | 622 | $result['timestamp'] = $data->ts; |
623 | 623 | $result['mmsi'] = $data->mmsi; |
624 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
624 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
625 | 625 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
626 | 626 | if ($data->sog != -1.0) $result['speed'] = $data->sog; |
627 | 627 | if ($data->heading !== '') $result['heading'] = $data->heading; |
@@ -631,16 +631,16 @@ discard block |
||
631 | 631 | if ($data->type !== '') $result['type'] = $data->type; |
632 | 632 | if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
633 | 633 | if ($data->imo !== '') $result['imo'] = $data->imo; |
634 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
634 | + if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign)); |
|
635 | 635 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
636 | - $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
636 | + $eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
637 | 637 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
638 | 638 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
639 | - $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
639 | + $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
640 | 640 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
641 | 641 | } |
642 | 642 | if ($data->destination != '') { |
643 | - $dest = trim(str_replace('@','',$data->destination)); |
|
643 | + $dest = trim(str_replace('@', '', $data->destination)); |
|
644 | 644 | if ($dest != '') $result['destination'] = $dest; |
645 | 645 | } |
646 | 646 | $result['all'] = (array) $data; |