@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | $Spotter = new Spotter(); |
29 | 29 | $alliances = $Spotter->getAllAllianceNames(); |
30 | 30 | if (!empty($alliances)) { |
31 | - foreach($alliances as $alliance) { |
|
32 | - if (isset($airline_icao) && str_replace('_',' ',str_replace('alliance_','',$airline_icao)) == $alliance['alliance']) { |
|
33 | - print '<option value="alliance_'.str_replace(' ','_',$alliance['alliance']).'" selected>'.$alliance['alliance'].'</option>'; |
|
31 | + foreach ($alliances as $alliance) { |
|
32 | + if (isset($airline_icao) && str_replace('_', ' ', str_replace('alliance_', '', $airline_icao)) == $alliance['alliance']) { |
|
33 | + print '<option value="alliance_'.str_replace(' ', '_', $alliance['alliance']).'" selected>'.$alliance['alliance'].'</option>'; |
|
34 | 34 | } else { |
35 | - print '<option value="alliance_'.str_replace(' ','_',$alliance['alliance']).'">'.$alliance['alliance'].'</option>'; |
|
35 | + print '<option value="alliance_'.str_replace(' ', '_', $alliance['alliance']).'">'.$alliance['alliance'].'</option>'; |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | print '<option disabled>──────────</option>'; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $Stats = new Stats(); |
41 | 41 | if (!isset($filter_name)) $filter_name = ''; |
42 | 42 | $airlines = $Stats->getAllAirlineNames($filter_name); |
43 | - foreach($airlines as $airline) { |
|
43 | + foreach ($airlines as $airline) { |
|
44 | 44 | if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) { |
45 | 45 | print '<option value="'.$airline['airline_icao'].'" selected>'.$airline['airline_name'].'</option>'; |
46 | 46 | } else { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | if (!isset($type) || $type == 'aircraft') { |
64 | 64 | ?> |
65 | 65 | <li class="dropdown"> |
66 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
66 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
67 | 67 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
68 | 68 | </a> |
69 | 69 | <ul class="dropdown-menu"> |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | </ul> |
75 | 75 | </li> |
76 | 76 | <li class="dropdown"> |
77 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
77 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
78 | 78 | <?php echo _("Airline"); ?> <span class="caret"></span> |
79 | 79 | </a> |
80 | 80 | <ul class="dropdown-menu" role="menu"> |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | </ul> |
91 | 91 | </li> |
92 | 92 | <li class="dropdown"> |
93 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
93 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
94 | 94 | <?php echo _("Airport"); ?> <span class="caret"></span> |
95 | 95 | </a> |
96 | 96 | <ul class="dropdown-menu" role="menu"> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | </ul> |
102 | 102 | </li> |
103 | 103 | <li class="dropdown"> |
104 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
104 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
105 | 105 | <?php echo _("Route"); ?> <span class="caret"></span> |
106 | 106 | </a> |
107 | 107 | <ul class="dropdown-menu" role="menu"> |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | </ul> |
111 | 111 | </li> |
112 | 112 | <li class="dropdown"> |
113 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
113 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
114 | 114 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
115 | 115 | </a> |
116 | 116 | <ul class="dropdown-menu" role="menu"> |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) { |
123 | 123 | ?> |
124 | 124 | <li class="dropdown"> |
125 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
125 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
126 | 126 | <?php echo _("Fatalities"); ?> <span class="caret"></span> |
127 | 127 | </a> |
128 | 128 | <ul class="dropdown-menu" role="menu"> |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } elseif ($type == 'marine' || $type == 'tracker') { |
138 | 138 | ?> |
139 | 139 | <li class="dropdown"> |
140 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
140 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
141 | 141 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
142 | 142 | </a> |
143 | 143 | <ul class="dropdown-menu" role="menu"> |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if (!isset($type) || $type == 'aircraft') { |
162 | 162 | ?> |
163 | 163 | <li class="dropdown"> |
164 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
164 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
165 | 165 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
166 | 166 | </a> |
167 | 167 | <ul class="dropdown-menu"> |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | </ul> |
173 | 173 | </li> |
174 | 174 | <li class="dropdown"> |
175 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
175 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
176 | 176 | <?php echo _("Airline"); ?> <span class="caret"></span> |
177 | 177 | </a> |
178 | 178 | <ul class="dropdown-menu" role="menu"> |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | </ul> |
189 | 189 | </li> |
190 | 190 | <li class="dropdown"> |
191 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
191 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
192 | 192 | <?php echo _("Airport"); ?> <span class="caret"></span> |
193 | 193 | </a> |
194 | 194 | <ul class="dropdown-menu" role="menu"> |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | </li> |
201 | 201 | <!-- |
202 | 202 | <li class="dropdown"> |
203 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
203 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
204 | 204 | <?php echo _("Route"); ?> <span class="caret"></span> |
205 | 205 | </a> |
206 | 206 | <ul class="dropdown-menu" role="menu"> |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | --> |
212 | 212 | <!-- |
213 | 213 | <li class="dropdown"> |
214 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
214 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
215 | 215 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
216 | 216 | </a> |
217 | 217 | <ul class="dropdown-menu" role="menu"> |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | ?> |
226 | 226 | <!-- |
227 | 227 | <li class="dropdown"> |
228 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
228 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
229 | 229 | <?php echo _("Fatalities"); ?> <span class="caret"></span> |
230 | 230 | </a> |
231 | 231 | <ul class="dropdown-menu" role="menu"> |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | } elseif ($type == 'marine' || $type == 'tracker') { |
242 | 242 | ?> |
243 | 243 | <li class="dropdown"> |
244 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
244 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
245 | 245 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
246 | 246 | </a> |
247 | 247 | <ul class="dropdown-menu" role="menu"> |
@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | die(); |
9 | 9 | } |
10 | 10 | |
11 | -$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING); |
|
11 | +$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING); |
|
12 | 12 | $Spotter = new Spotter(); |
13 | -$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1",""); |
|
13 | +$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, "0,1", ""); |
|
14 | 14 | |
15 | 15 | |
16 | 16 | if (!empty($spotter_array)) |
17 | 17 | { |
18 | - $title = sprintf(_("Most Common Arrival Airports by Country for %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']); |
|
18 | + $title = sprintf(_("Most Common Arrival Airports by Country for %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']); |
|
19 | 19 | require_once('header.php'); |
20 | 20 | print '<div class="select-item">'; |
21 | 21 | print '<form action="'.$globalURL.'/aircraft" method="get">'; |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | $Stats = new Stats(); |
25 | 25 | $aircraft_types = $Stats->getAllAircraftTypes(); |
26 | 26 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
27 | - foreach($aircraft_types as $aircrafttype) |
|
27 | + foreach ($aircraft_types as $aircrafttype) |
|
28 | 28 | { |
29 | - if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
29 | + if ($aircraft_type == $aircrafttype['aircraft_icao']) |
|
30 | 30 | { |
31 | 31 | print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
32 | 32 | } else { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | include('aircraft-sub-menu.php'); |
54 | 54 | print '<div class="column">'; |
55 | 55 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
56 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>'; |
|
56 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s (%s)</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>'; |
|
57 | 57 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByAircraft($aircraft_type); |
58 | 58 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
59 | 59 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
62 | 62 | print 'var series = ['; |
63 | 63 | $country_data = ''; |
64 | - foreach($airport_country_array as $airport_item) |
|
64 | + foreach ($airport_country_array as $airport_item) |
|
65 | 65 | { |
66 | 66 | $country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],'; |
67 | 67 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | print '</thead>'; |
110 | 110 | print '<tbody>'; |
111 | 111 | $i = 1; |
112 | - foreach($airport_country_array as $airport_item) |
|
112 | + foreach ($airport_country_array as $airport_item) |
|
113 | 113 | { |
114 | 114 | print '<tr>'; |
115 | 115 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | |
8 | 8 | $type = 'marine'; |
9 | 9 | if (!isset($filter_name)) $filter_name = ''; |
10 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
11 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
10 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
11 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
12 | 12 | |
13 | 13 | require_once('header.php'); |
14 | 14 | |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | </div> |
21 | 21 | <p>'._("Below are the <strong>Top 10</strong> most common vessel types.").'</p>'; |
22 | 22 | |
23 | -$type_array = $Marine->countAllMarineTypes(true,0,'',$filter_name,$year,$month); |
|
23 | +$type_array = $Marine->countAllMarineTypes(true, 0, '', $filter_name, $year, $month); |
|
24 | 24 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
25 | 25 | $type_data = ''; |
26 | -foreach($type_array as $type_item) |
|
26 | +foreach ($type_array as $type_item) |
|
27 | 27 | { |
28 | 28 | $type_data .= '["'.$type_item['marine_type'].'",'.$type_item['marine_type_count'].'],'; |
29 | 29 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | print '</thead>'; |
49 | 49 | print '<tbody>'; |
50 | 50 | $i = 1; |
51 | - foreach($type_array as $type_item) |
|
51 | + foreach ($type_array as $type_item) |
|
52 | 52 | { |
53 | 53 | print '<tr>'; |
54 | 54 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
4 | 4 | |
5 | -class Marine{ |
|
5 | +class Marine { |
|
6 | 6 | public $db; |
7 | 7 | |
8 | 8 | public function __construct($dbc = null) { |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | 19 | |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
76 | 76 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
77 | 77 | if ($filter_query_where != '') { |
78 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
78 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
79 | 79 | } |
80 | 80 | $filter_query = $filter_query_join.$filter_query_where; |
81 | 81 | return $filter_query; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return Array the spotter information |
91 | 91 | * |
92 | 92 | */ |
93 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
93 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
94 | 94 | { |
95 | 95 | date_default_timezone_set('UTC'); |
96 | 96 | if (!is_string($query)) |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $sth = $this->db->prepare($query.$limitQuery); |
111 | 111 | $sth->execute($params); |
112 | 112 | } catch (PDOException $e) { |
113 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
113 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
114 | 114 | exit(); |
115 | 115 | } |
116 | 116 | |
117 | 117 | $num_rows = 0; |
118 | 118 | $spotter_array = array(); |
119 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
119 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
120 | 120 | { |
121 | 121 | $num_rows++; |
122 | 122 | $temp_array = array(); |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | } |
152 | 152 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
153 | 153 | |
154 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
154 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
155 | 155 | { |
156 | 156 | $Image = new Image($this->db); |
157 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
157 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
158 | 158 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
159 | 159 | unset($Image); |
160 | 160 | if (count($image_array) > 0) { |
@@ -190,17 +190,17 @@ discard block |
||
190 | 190 | { |
191 | 191 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
192 | 192 | } else { |
193 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
193 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
194 | 194 | } |
195 | 195 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
196 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
197 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
196 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
197 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
198 | 198 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
199 | 199 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
200 | 200 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
201 | 201 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
202 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
203 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
202 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
203 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
204 | 204 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
205 | 205 | } |
206 | 206 | } |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | if ($limit != "") |
234 | 234 | { |
235 | 235 | $limit_array = explode(",", $limit); |
236 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
237 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
236 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
237 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
238 | 238 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
239 | 239 | { |
240 | 240 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | } else { |
249 | 249 | $orderby_query = " ORDER BY marine_output.date DESC"; |
250 | 250 | } |
251 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
252 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
251 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
252 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
253 | 253 | return $spotter_array; |
254 | 254 | } |
255 | 255 | |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | if ($id == '') return array(); |
268 | 268 | $additional_query = "marine_output.fammarine_id = :id"; |
269 | 269 | $query_values = array(':id' => $id); |
270 | - $query = $global_query." WHERE ".$additional_query." "; |
|
271 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
270 | + $query = $global_query." WHERE ".$additional_query." "; |
|
271 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
272 | 272 | return $spotter_array; |
273 | 273 | } |
274 | 274 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $query_values = array(); |
288 | 288 | $limit_query = ''; |
289 | 289 | $additional_query = ''; |
290 | - $filter_query = $this->getFilter($filter,true,true); |
|
290 | + $filter_query = $this->getFilter($filter, true, true); |
|
291 | 291 | if ($ident != "") |
292 | 292 | { |
293 | 293 | if (!is_string($ident)) |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | { |
304 | 304 | $limit_array = explode(",", $limit); |
305 | 305 | |
306 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
307 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
306 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
307 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
308 | 308 | |
309 | 309 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
310 | 310 | { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $query_values = array(); |
344 | 344 | $limit_query = ''; |
345 | 345 | $additional_query = ''; |
346 | - $filter_query = $this->getFilter($filter,true,true); |
|
346 | + $filter_query = $this->getFilter($filter, true, true); |
|
347 | 347 | if (!is_string($type)) |
348 | 348 | { |
349 | 349 | return false; |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | { |
357 | 357 | $limit_array = explode(",", $limit); |
358 | 358 | |
359 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
360 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
359 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
360 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
361 | 361 | |
362 | 362 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
363 | 363 | { |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | return $spotter_array; |
382 | 382 | } |
383 | 383 | |
384 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
384 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
385 | 385 | { |
386 | 386 | global $global_query, $globalTimezone, $globalDBdriver; |
387 | 387 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $limit_query = ''; |
390 | 390 | $additional_query = ''; |
391 | 391 | |
392 | - $filter_query = $this->getFilter($filter,true,true); |
|
392 | + $filter_query = $this->getFilter($filter, true, true); |
|
393 | 393 | |
394 | 394 | if ($date != "") |
395 | 395 | { |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | { |
416 | 416 | $limit_array = explode(",", $limit); |
417 | 417 | |
418 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
419 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
418 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
419 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
420 | 420 | |
421 | 421 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
422 | 422 | { |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | * @return Array list of source name |
448 | 448 | * |
449 | 449 | */ |
450 | - public function getAllSourceName($type = '',$filters = array()) |
|
450 | + public function getAllSourceName($type = '', $filters = array()) |
|
451 | 451 | { |
452 | - $filter_query = $this->getFilter($filters,true,true); |
|
452 | + $filter_query = $this->getFilter($filters, true, true); |
|
453 | 453 | $query_values = array(); |
454 | - $query = "SELECT DISTINCT marine_output.source_name |
|
454 | + $query = "SELECT DISTINCT marine_output.source_name |
|
455 | 455 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
456 | 456 | if ($type != '') { |
457 | 457 | $query_values = array(':type' => $type); |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | $source_array = array(); |
467 | 467 | $temp_array = array(); |
468 | 468 | |
469 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
469 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
470 | 470 | { |
471 | 471 | $temp_array['source_name'] = $row['source_name']; |
472 | 472 | $source_array[] = $temp_array; |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | */ |
484 | 484 | public function getAllIdents($filters = array()) |
485 | 485 | { |
486 | - $filter_query = $this->getFilter($filters,true,true); |
|
487 | - $query = "SELECT DISTINCT marine_output.ident |
|
486 | + $filter_query = $this->getFilter($filters, true, true); |
|
487 | + $query = "SELECT DISTINCT marine_output.ident |
|
488 | 488 | FROM marine_output".$filter_query." marine_output.ident <> '' |
489 | 489 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
490 | 490 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $ident_array = array(); |
495 | 495 | $temp_array = array(); |
496 | 496 | |
497 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
497 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
498 | 498 | { |
499 | 499 | $temp_array['ident'] = $row['ident']; |
500 | 500 | $ident_array[] = $temp_array; |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | */ |
512 | 512 | public function getIdentity($mmsi) |
513 | 513 | { |
514 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
514 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
515 | 515 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
516 | 516 | $sth = $this->db->prepare($query); |
517 | 517 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -524,23 +524,23 @@ discard block |
||
524 | 524 | * Add identity |
525 | 525 | * |
526 | 526 | */ |
527 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
527 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
528 | 528 | { |
529 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
529 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
530 | 530 | if ($mmsi != '') { |
531 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
532 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
533 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
534 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
531 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
532 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
533 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
534 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
535 | 535 | $identinfo = $this->getIdentity($mmsi); |
536 | 536 | if (empty($identinfo)) { |
537 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
537 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
538 | 538 | $sth = $this->db->prepare($query); |
539 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
539 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
540 | 540 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
541 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
541 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
542 | 542 | $sth = $this->db->prepare($query); |
543 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
543 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
544 | 544 | } |
545 | 545 | } |
546 | 546 | } |
@@ -561,12 +561,12 @@ discard block |
||
561 | 561 | } else $offset = '+00:00'; |
562 | 562 | |
563 | 563 | if ($globalDBdriver == 'mysql') { |
564 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
564 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
565 | 565 | FROM marine_output |
566 | 566 | WHERE marine_output.date <> '' |
567 | 567 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
568 | 568 | } else { |
569 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
569 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
570 | 570 | FROM marine_output |
571 | 571 | WHERE marine_output.date <> '' |
572 | 572 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | $date_array = array(); |
579 | 579 | $temp_array = array(); |
580 | 580 | |
581 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
581 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
582 | 582 | { |
583 | 583 | $temp_array['date'] = $row['date']; |
584 | 584 | |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | * @return String success or false |
597 | 597 | * |
598 | 598 | */ |
599 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
599 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
600 | 600 | { |
601 | 601 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
602 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
602 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
603 | 603 | try { |
604 | 604 | $sth = $this->db->prepare($query); |
605 | 605 | $sth->execute($query_values); |
@@ -617,10 +617,10 @@ discard block |
||
617 | 617 | * @return String success or false |
618 | 618 | * |
619 | 619 | */ |
620 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
620 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
621 | 621 | { |
622 | 622 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
623 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
623 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
624 | 624 | try { |
625 | 625 | $sth = $this->db->prepare($query); |
626 | 626 | $sth->execute($query_values); |
@@ -639,11 +639,11 @@ discard block |
||
639 | 639 | * @return String success or false |
640 | 640 | * |
641 | 641 | */ |
642 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
642 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
643 | 643 | { |
644 | 644 | |
645 | 645 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
646 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
646 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
647 | 647 | |
648 | 648 | try { |
649 | 649 | $sth = $this->db->prepare($query); |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
667 | 667 | { |
668 | 668 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
669 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
669 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
670 | 670 | |
671 | 671 | try { |
672 | 672 | $sth = $this->db->prepare($query); |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @param String $verticalrate vertival rate of flight |
705 | 705 | * @return String success or false |
706 | 706 | */ |
707 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
707 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
708 | 708 | { |
709 | 709 | global $globalURL, $globalMarineImageFetch; |
710 | 710 | |
@@ -771,32 +771,32 @@ discard block |
||
771 | 771 | } |
772 | 772 | |
773 | 773 | |
774 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
774 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
775 | 775 | { |
776 | 776 | $date = date("Y-m-d H:i:s", time()); |
777 | 777 | } |
778 | 778 | |
779 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
780 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
781 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
782 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
783 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
784 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
785 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
786 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
787 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
788 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
789 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
790 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
791 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
792 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
793 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
794 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
779 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
780 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
781 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
782 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
783 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
784 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
785 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
786 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
787 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
788 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
789 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
790 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
791 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
792 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
793 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
794 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
795 | 795 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
796 | 796 | $Image = new Image($this->db); |
797 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
797 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
798 | 798 | if (!isset($image_array[0]['mmsi'])) { |
799 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
799 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
800 | 800 | } |
801 | 801 | unset($Image); |
802 | 802 | } |
@@ -809,10 +809,10 @@ discard block |
||
809 | 809 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
810 | 810 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
811 | 811 | if ($arrival_date == '') $arrival_date = NULL; |
812 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date) |
|
812 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date) |
|
813 | 813 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date)"; |
814 | 814 | |
815 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
815 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
816 | 816 | try { |
817 | 817 | $sth = $this->db->prepare($query); |
818 | 818 | $sth->execute($query_values); |
@@ -836,13 +836,13 @@ discard block |
||
836 | 836 | { |
837 | 837 | global $globalDBdriver, $globalTimezone; |
838 | 838 | if ($globalDBdriver == 'mysql') { |
839 | - $query = "SELECT marine_output.ident FROM marine_output |
|
839 | + $query = "SELECT marine_output.ident FROM marine_output |
|
840 | 840 | WHERE marine_output.ident = :ident |
841 | 841 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
842 | 842 | AND marine_output.date < UTC_TIMESTAMP()"; |
843 | 843 | $query_data = array(':ident' => $ident); |
844 | 844 | } else { |
845 | - $query = "SELECT marine_output.ident FROM marine_output |
|
845 | + $query = "SELECT marine_output.ident FROM marine_output |
|
846 | 846 | WHERE marine_output.ident = :ident |
847 | 847 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
848 | 848 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | |
852 | 852 | $sth = $this->db->prepare($query); |
853 | 853 | $sth->execute($query_data); |
854 | - $ident_result=''; |
|
855 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
854 | + $ident_result = ''; |
|
855 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
856 | 856 | { |
857 | 857 | $ident_result = $row['ident']; |
858 | 858 | } |
@@ -878,8 +878,8 @@ discard block |
||
878 | 878 | return false; |
879 | 879 | } else { |
880 | 880 | $q_array = explode(" ", $q); |
881 | - foreach ($q_array as $q_item){ |
|
882 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
881 | + foreach ($q_array as $q_item) { |
|
882 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
883 | 883 | $additional_query .= " AND ("; |
884 | 884 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
885 | 885 | $additional_query .= ")"; |
@@ -887,11 +887,11 @@ discard block |
||
887 | 887 | } |
888 | 888 | } |
889 | 889 | if ($globalDBdriver == 'mysql') { |
890 | - $query = "SELECT marine_output.* FROM marine_output |
|
890 | + $query = "SELECT marine_output.* FROM marine_output |
|
891 | 891 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
892 | 892 | AND marine_output.date < UTC_TIMESTAMP()"; |
893 | 893 | } else { |
894 | - $query = "SELECT marine_output.* FROM marine_output |
|
894 | + $query = "SELECT marine_output.* FROM marine_output |
|
895 | 895 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
896 | 896 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
897 | 897 | } |
@@ -910,16 +910,16 @@ discard block |
||
910 | 910 | * |
911 | 911 | */ |
912 | 912 | |
913 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
913 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
914 | 914 | { |
915 | 915 | global $globalDBdriver, $globalArchive; |
916 | 916 | //$filter_query = $this->getFilter($filters,true,true); |
917 | - $Connection= new Connection($this->db); |
|
917 | + $Connection = new Connection($this->db); |
|
918 | 918 | if (!$Connection->tableExists('countries')) return array(); |
919 | 919 | require_once('class.SpotterLive.php'); |
920 | 920 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
921 | 921 | $MarineLive = new MarineLive($this->db); |
922 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
922 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
923 | 923 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
924 | 924 | if ($olderthanmonths > 0) { |
925 | 925 | if ($globalDBdriver == 'mysql') { |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | } else { |
940 | 940 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
941 | 941 | $MarineArchive = new MarineArchive($this->db); |
942 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
942 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
943 | 943 | $filter_query .= " over_country <> ''"; |
944 | 944 | if ($olderthanmonths > 0) { |
945 | 945 | if ($globalDBdriver == 'mysql') { |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | $flight_array = array(); |
968 | 968 | $temp_array = array(); |
969 | 969 | |
970 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
970 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
971 | 971 | { |
972 | 972 | $temp_array['marine_count'] = $row['nb']; |
973 | 973 | $temp_array['marine_country'] = $row['name']; |
@@ -986,11 +986,11 @@ discard block |
||
986 | 986 | * @return Array the callsign list |
987 | 987 | * |
988 | 988 | */ |
989 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
989 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
990 | 990 | { |
991 | 991 | global $globalDBdriver; |
992 | - $filter_query = $this->getFilter($filters,true,true); |
|
993 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
992 | + $filter_query = $this->getFilter($filters, true, true); |
|
993 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
994 | 994 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
995 | 995 | if ($olderthanmonths > 0) { |
996 | 996 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1004,28 +1004,28 @@ discard block |
||
1004 | 1004 | if ($year != '') { |
1005 | 1005 | if ($globalDBdriver == 'mysql') { |
1006 | 1006 | $query .= " AND YEAR(marine_output.date) = :year"; |
1007 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1007 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1008 | 1008 | } else { |
1009 | 1009 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1010 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1010 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1011 | 1011 | } |
1012 | 1012 | } |
1013 | 1013 | if ($month != '') { |
1014 | 1014 | if ($globalDBdriver == 'mysql') { |
1015 | 1015 | $query .= " AND MONTH(marine_output.date) = :month"; |
1016 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1016 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1017 | 1017 | } else { |
1018 | 1018 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1019 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1019 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1020 | 1020 | } |
1021 | 1021 | } |
1022 | 1022 | if ($day != '') { |
1023 | 1023 | if ($globalDBdriver == 'mysql') { |
1024 | 1024 | $query .= " AND DAY(marine_output.date) = :day"; |
1025 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1025 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1026 | 1026 | } else { |
1027 | 1027 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1028 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1028 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1029 | 1029 | } |
1030 | 1030 | } |
1031 | 1031 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | $callsign_array = array(); |
1038 | 1038 | $temp_array = array(); |
1039 | 1039 | |
1040 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1040 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1041 | 1041 | { |
1042 | 1042 | $temp_array['callsign_icao'] = $row['ident']; |
1043 | 1043 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | $date_array = array(); |
1090 | 1090 | $temp_array = array(); |
1091 | 1091 | |
1092 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1092 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1093 | 1093 | { |
1094 | 1094 | $temp_array['date_name'] = $row['date_name']; |
1095 | 1095 | $temp_array['date_count'] = $row['date_count']; |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | $datetime = new DateTime(); |
1116 | 1116 | $offset = $datetime->format('P'); |
1117 | 1117 | } else $offset = '+00:00'; |
1118 | - $filter_query = $this->getFilter($filters,true,true); |
|
1118 | + $filter_query = $this->getFilter($filters, true, true); |
|
1119 | 1119 | if ($globalDBdriver == 'mysql') { |
1120 | 1120 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1121 | 1121 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | $date_array = array(); |
1137 | 1137 | $temp_array = array(); |
1138 | 1138 | |
1139 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1139 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1140 | 1140 | { |
1141 | 1141 | $temp_array['date_name'] = $row['date_name']; |
1142 | 1142 | $temp_array['date_count'] = $row['date_count']; |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | $datetime = new DateTime(); |
1162 | 1162 | $offset = $datetime->format('P'); |
1163 | 1163 | } else $offset = '+00:00'; |
1164 | - $filter_query = $this->getFilter($filters,true,true); |
|
1164 | + $filter_query = $this->getFilter($filters, true, true); |
|
1165 | 1165 | if ($globalDBdriver == 'mysql') { |
1166 | 1166 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1167 | 1167 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | $date_array = array(); |
1183 | 1183 | $temp_array = array(); |
1184 | 1184 | |
1185 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1185 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1186 | 1186 | { |
1187 | 1187 | $temp_array['date_name'] = $row['date_name']; |
1188 | 1188 | $temp_array['date_count'] = $row['date_count']; |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | $date_array = array(); |
1230 | 1230 | $temp_array = array(); |
1231 | 1231 | |
1232 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1232 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1233 | 1233 | { |
1234 | 1234 | $temp_array['month_name'] = $row['month_name']; |
1235 | 1235 | $temp_array['year_name'] = $row['year_name']; |
@@ -1258,7 +1258,7 @@ discard block |
||
1258 | 1258 | $datetime = new DateTime(); |
1259 | 1259 | $offset = $datetime->format('P'); |
1260 | 1260 | } else $offset = '+00:00'; |
1261 | - $filter_query = $this->getFilter($filters,true,true); |
|
1261 | + $filter_query = $this->getFilter($filters, true, true); |
|
1262 | 1262 | if ($globalDBdriver == 'mysql') { |
1263 | 1263 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1264 | 1264 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1279,7 +1279,7 @@ discard block |
||
1279 | 1279 | $date_array = array(); |
1280 | 1280 | $temp_array = array(); |
1281 | 1281 | |
1282 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1282 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1283 | 1283 | { |
1284 | 1284 | $temp_array['year_name'] = $row['year_name']; |
1285 | 1285 | $temp_array['month_name'] = $row['month_name']; |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | * @return Array the hour list |
1300 | 1300 | * |
1301 | 1301 | */ |
1302 | - public function countAllHours($orderby,$filters = array()) |
|
1302 | + public function countAllHours($orderby, $filters = array()) |
|
1303 | 1303 | { |
1304 | 1304 | global $globalTimezone, $globalDBdriver; |
1305 | 1305 | if ($globalTimezone != '') { |
@@ -1347,7 +1347,7 @@ discard block |
||
1347 | 1347 | $hour_array = array(); |
1348 | 1348 | $temp_array = array(); |
1349 | 1349 | |
1350 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1350 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1351 | 1351 | { |
1352 | 1352 | $temp_array['hour_name'] = $row['hour_name']; |
1353 | 1353 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1369,8 +1369,8 @@ discard block |
||
1369 | 1369 | public function countAllHoursByDate($date, $filters = array()) |
1370 | 1370 | { |
1371 | 1371 | global $globalTimezone, $globalDBdriver; |
1372 | - $filter_query = $this->getFilter($filters,true,true); |
|
1373 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1372 | + $filter_query = $this->getFilter($filters, true, true); |
|
1373 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1374 | 1374 | if ($globalTimezone != '') { |
1375 | 1375 | date_default_timezone_set($globalTimezone); |
1376 | 1376 | $datetime = new DateTime($date); |
@@ -1378,12 +1378,12 @@ discard block |
||
1378 | 1378 | } else $offset = '+00:00'; |
1379 | 1379 | |
1380 | 1380 | if ($globalDBdriver == 'mysql') { |
1381 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1381 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1382 | 1382 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1383 | 1383 | GROUP BY hour_name |
1384 | 1384 | ORDER BY hour_name ASC"; |
1385 | 1385 | } else { |
1386 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1386 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1387 | 1387 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1388 | 1388 | GROUP BY hour_name |
1389 | 1389 | ORDER BY hour_name ASC"; |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | $hour_array = array(); |
1396 | 1396 | $temp_array = array(); |
1397 | 1397 | |
1398 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1398 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1399 | 1399 | { |
1400 | 1400 | $temp_array['hour_name'] = $row['hour_name']; |
1401 | 1401 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1417,8 +1417,8 @@ discard block |
||
1417 | 1417 | public function countAllHoursByIdent($ident, $filters = array()) |
1418 | 1418 | { |
1419 | 1419 | global $globalTimezone, $globalDBdriver; |
1420 | - $filter_query = $this->getFilter($filters,true,true); |
|
1421 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1420 | + $filter_query = $this->getFilter($filters, true, true); |
|
1421 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1422 | 1422 | if ($globalTimezone != '') { |
1423 | 1423 | date_default_timezone_set($globalTimezone); |
1424 | 1424 | $datetime = new DateTime(); |
@@ -1426,12 +1426,12 @@ discard block |
||
1426 | 1426 | } else $offset = '+00:00'; |
1427 | 1427 | |
1428 | 1428 | if ($globalDBdriver == 'mysql') { |
1429 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1429 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1430 | 1430 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1431 | 1431 | GROUP BY hour_name |
1432 | 1432 | ORDER BY hour_name ASC"; |
1433 | 1433 | } else { |
1434 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1434 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1435 | 1435 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1436 | 1436 | GROUP BY hour_name |
1437 | 1437 | ORDER BY hour_name ASC"; |
@@ -1439,12 +1439,12 @@ discard block |
||
1439 | 1439 | |
1440 | 1440 | |
1441 | 1441 | $sth = $this->db->prepare($query); |
1442 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1442 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1443 | 1443 | |
1444 | 1444 | $hour_array = array(); |
1445 | 1445 | $temp_array = array(); |
1446 | 1446 | |
1447 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1447 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1448 | 1448 | { |
1449 | 1449 | $temp_array['hour_name'] = $row['hour_name']; |
1450 | 1450 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1463,33 +1463,33 @@ discard block |
||
1463 | 1463 | * @return Integer the number of vessels |
1464 | 1464 | * |
1465 | 1465 | */ |
1466 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1466 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1467 | 1467 | { |
1468 | 1468 | global $globalDBdriver; |
1469 | 1469 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1470 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1470 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1471 | 1471 | $query_values = array(); |
1472 | 1472 | $query = ''; |
1473 | 1473 | if ($year != '') { |
1474 | 1474 | if ($globalDBdriver == 'mysql') { |
1475 | 1475 | $query .= " AND YEAR(marine_output.date) = :year"; |
1476 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1476 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1477 | 1477 | } else { |
1478 | 1478 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1479 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1479 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1480 | 1480 | } |
1481 | 1481 | } |
1482 | 1482 | if ($month != '') { |
1483 | 1483 | if ($globalDBdriver == 'mysql') { |
1484 | 1484 | $query .= " AND MONTH(marine_output.date) = :month"; |
1485 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1485 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1486 | 1486 | } else { |
1487 | 1487 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1488 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1488 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1489 | 1489 | } |
1490 | 1490 | } |
1491 | 1491 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1492 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1492 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1493 | 1493 | |
1494 | 1494 | $sth = $this->db->prepare($queryi); |
1495 | 1495 | $sth->execute($query_values); |
@@ -1502,32 +1502,32 @@ discard block |
||
1502 | 1502 | * @return Integer the number of vessels |
1503 | 1503 | * |
1504 | 1504 | */ |
1505 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1505 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1506 | 1506 | { |
1507 | 1507 | global $globalDBdriver; |
1508 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1508 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1509 | 1509 | $query_values = array(); |
1510 | 1510 | $query = ''; |
1511 | 1511 | if ($year != '') { |
1512 | 1512 | if ($globalDBdriver == 'mysql') { |
1513 | 1513 | $query .= " AND YEAR(marine_output.date) = :year"; |
1514 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1514 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1515 | 1515 | } else { |
1516 | 1516 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1517 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1517 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1518 | 1518 | } |
1519 | 1519 | } |
1520 | 1520 | if ($month != '') { |
1521 | 1521 | if ($globalDBdriver == 'mysql') { |
1522 | 1522 | $query .= " AND MONTH(marine_output.date) = :month"; |
1523 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1523 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1524 | 1524 | } else { |
1525 | 1525 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1526 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1526 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1527 | 1527 | } |
1528 | 1528 | } |
1529 | 1529 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1530 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1530 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1531 | 1531 | |
1532 | 1532 | $sth = $this->db->prepare($queryi); |
1533 | 1533 | $sth->execute($query_values); |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | public function countAllHoursFromToday($filters = array()) |
1545 | 1545 | { |
1546 | 1546 | global $globalTimezone, $globalDBdriver; |
1547 | - $filter_query = $this->getFilter($filters,true,true); |
|
1547 | + $filter_query = $this->getFilter($filters, true, true); |
|
1548 | 1548 | if ($globalTimezone != '') { |
1549 | 1549 | date_default_timezone_set($globalTimezone); |
1550 | 1550 | $datetime = new DateTime(); |
@@ -1552,12 +1552,12 @@ discard block |
||
1552 | 1552 | } else $offset = '+00:00'; |
1553 | 1553 | |
1554 | 1554 | if ($globalDBdriver == 'mysql') { |
1555 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1555 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1556 | 1556 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1557 | 1557 | GROUP BY hour_name |
1558 | 1558 | ORDER BY hour_name ASC"; |
1559 | 1559 | } else { |
1560 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1560 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1561 | 1561 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1562 | 1562 | GROUP BY hour_name |
1563 | 1563 | ORDER BY hour_name ASC"; |
@@ -1569,7 +1569,7 @@ discard block |
||
1569 | 1569 | $hour_array = array(); |
1570 | 1570 | $temp_array = array(); |
1571 | 1571 | |
1572 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1572 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1573 | 1573 | { |
1574 | 1574 | $temp_array['hour_name'] = $row['hour_name']; |
1575 | 1575 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1588,9 +1588,9 @@ discard block |
||
1588 | 1588 | */ |
1589 | 1589 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1590 | 1590 | { |
1591 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1591 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1592 | 1592 | |
1593 | - $query = "SELECT marine_output.marine_id |
|
1593 | + $query = "SELECT marine_output.marine_id |
|
1594 | 1594 | FROM marine_output |
1595 | 1595 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1596 | 1596 | |
@@ -1598,7 +1598,7 @@ discard block |
||
1598 | 1598 | $sth = $this->db->prepare($query); |
1599 | 1599 | $sth->execute(); |
1600 | 1600 | |
1601 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1601 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1602 | 1602 | { |
1603 | 1603 | return $row['marine_id']; |
1604 | 1604 | } |
@@ -1623,23 +1623,23 @@ discard block |
||
1623 | 1623 | } |
1624 | 1624 | |
1625 | 1625 | $current_date = date("Y-m-d H:i:s"); |
1626 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1626 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1627 | 1627 | |
1628 | 1628 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1629 | 1629 | |
1630 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1630 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1631 | 1631 | $years = $time_array['years']; |
1632 | 1632 | |
1633 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1633 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1634 | 1634 | $months = $time_array['months']; |
1635 | 1635 | |
1636 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1636 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1637 | 1637 | $days = $time_array['days']; |
1638 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1638 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1639 | 1639 | $hours = $time_array['hours']; |
1640 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1640 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1641 | 1641 | $minutes = $time_array['minutes']; |
1642 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1642 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1643 | 1643 | |
1644 | 1644 | return $time_array; |
1645 | 1645 | } |
@@ -1662,63 +1662,63 @@ discard block |
||
1662 | 1662 | $temp_array['direction_degree'] = $direction; |
1663 | 1663 | $temp_array['direction_shortname'] = "N"; |
1664 | 1664 | $temp_array['direction_fullname'] = "North"; |
1665 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1665 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1666 | 1666 | $temp_array['direction_degree'] = $direction; |
1667 | 1667 | $temp_array['direction_shortname'] = "NNE"; |
1668 | 1668 | $temp_array['direction_fullname'] = "North-Northeast"; |
1669 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1669 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1670 | 1670 | $temp_array['direction_degree'] = $direction; |
1671 | 1671 | $temp_array['direction_shortname'] = "NE"; |
1672 | 1672 | $temp_array['direction_fullname'] = "Northeast"; |
1673 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1673 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1674 | 1674 | $temp_array['direction_degree'] = $direction; |
1675 | 1675 | $temp_array['direction_shortname'] = "ENE"; |
1676 | 1676 | $temp_array['direction_fullname'] = "East-Northeast"; |
1677 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1677 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1678 | 1678 | $temp_array['direction_degree'] = $direction; |
1679 | 1679 | $temp_array['direction_shortname'] = "E"; |
1680 | 1680 | $temp_array['direction_fullname'] = "East"; |
1681 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1681 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1682 | 1682 | $temp_array['direction_degree'] = $direction; |
1683 | 1683 | $temp_array['direction_shortname'] = "ESE"; |
1684 | 1684 | $temp_array['direction_fullname'] = "East-Southeast"; |
1685 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1685 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1686 | 1686 | $temp_array['direction_degree'] = $direction; |
1687 | 1687 | $temp_array['direction_shortname'] = "SE"; |
1688 | 1688 | $temp_array['direction_fullname'] = "Southeast"; |
1689 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1689 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1690 | 1690 | $temp_array['direction_degree'] = $direction; |
1691 | 1691 | $temp_array['direction_shortname'] = "SSE"; |
1692 | 1692 | $temp_array['direction_fullname'] = "South-Southeast"; |
1693 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1693 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1694 | 1694 | $temp_array['direction_degree'] = $direction; |
1695 | 1695 | $temp_array['direction_shortname'] = "S"; |
1696 | 1696 | $temp_array['direction_fullname'] = "South"; |
1697 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1697 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1698 | 1698 | $temp_array['direction_degree'] = $direction; |
1699 | 1699 | $temp_array['direction_shortname'] = "SSW"; |
1700 | 1700 | $temp_array['direction_fullname'] = "South-Southwest"; |
1701 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1701 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1702 | 1702 | $temp_array['direction_degree'] = $direction; |
1703 | 1703 | $temp_array['direction_shortname'] = "SW"; |
1704 | 1704 | $temp_array['direction_fullname'] = "Southwest"; |
1705 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1705 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1706 | 1706 | $temp_array['direction_degree'] = $direction; |
1707 | 1707 | $temp_array['direction_shortname'] = "WSW"; |
1708 | 1708 | $temp_array['direction_fullname'] = "West-Southwest"; |
1709 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1709 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1710 | 1710 | $temp_array['direction_degree'] = $direction; |
1711 | 1711 | $temp_array['direction_shortname'] = "W"; |
1712 | 1712 | $temp_array['direction_fullname'] = "West"; |
1713 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1713 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1714 | 1714 | $temp_array['direction_degree'] = $direction; |
1715 | 1715 | $temp_array['direction_shortname'] = "WNW"; |
1716 | 1716 | $temp_array['direction_fullname'] = "West-Northwest"; |
1717 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1717 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1718 | 1718 | $temp_array['direction_degree'] = $direction; |
1719 | 1719 | $temp_array['direction_shortname'] = "NW"; |
1720 | 1720 | $temp_array['direction_fullname'] = "Northwest"; |
1721 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1721 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1722 | 1722 | $temp_array['direction_degree'] = $direction; |
1723 | 1723 | $temp_array['direction_shortname'] = "NNW"; |
1724 | 1724 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1735,11 +1735,11 @@ discard block |
||
1735 | 1735 | * @param Float $longitude longitute of the flight |
1736 | 1736 | * @return String the countrie |
1737 | 1737 | */ |
1738 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1738 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1739 | 1739 | { |
1740 | 1740 | global $globalDBdriver, $globalDebug; |
1741 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1742 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1741 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1742 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1743 | 1743 | |
1744 | 1744 | $Connection = new Connection($this->db); |
1745 | 1745 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1779,7 +1779,7 @@ discard block |
||
1779 | 1779 | public function getCountryFromISO2($iso2) |
1780 | 1780 | { |
1781 | 1781 | global $globalDBdriver, $globalDebug; |
1782 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1782 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1783 | 1783 | |
1784 | 1784 | $Connection = new Connection($this->db); |
1785 | 1785 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1827,7 +1827,7 @@ discard block |
||
1827 | 1827 | |
1828 | 1828 | $bitly_data = json_decode($bitly_data); |
1829 | 1829 | $bitly_url = ''; |
1830 | - if ($bitly_data->status_txt = "OK"){ |
|
1830 | + if ($bitly_data->status_txt = "OK") { |
|
1831 | 1831 | $bitly_url = $bitly_data->data->url; |
1832 | 1832 | } |
1833 | 1833 | |
@@ -1841,11 +1841,11 @@ discard block |
||
1841 | 1841 | * @return Array the vessel type list |
1842 | 1842 | * |
1843 | 1843 | */ |
1844 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1844 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1845 | 1845 | { |
1846 | 1846 | global $globalDBdriver; |
1847 | - $filter_query = $this->getFilter($filters,true,true); |
|
1848 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
1847 | + $filter_query = $this->getFilter($filters, true, true); |
|
1848 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
1849 | 1849 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
1850 | 1850 | if ($olderthanmonths > 0) { |
1851 | 1851 | if ($globalDBdriver == 'mysql') { |
@@ -1865,28 +1865,28 @@ discard block |
||
1865 | 1865 | if ($year != '') { |
1866 | 1866 | if ($globalDBdriver == 'mysql') { |
1867 | 1867 | $query .= " AND YEAR(marine_output.date) = :year"; |
1868 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1868 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1869 | 1869 | } else { |
1870 | 1870 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1871 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1871 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1872 | 1872 | } |
1873 | 1873 | } |
1874 | 1874 | if ($month != '') { |
1875 | 1875 | if ($globalDBdriver == 'mysql') { |
1876 | 1876 | $query .= " AND MONTH(marine_output.date) = :month"; |
1877 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1877 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1878 | 1878 | } else { |
1879 | 1879 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1880 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1880 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1881 | 1881 | } |
1882 | 1882 | } |
1883 | 1883 | if ($day != '') { |
1884 | 1884 | if ($globalDBdriver == 'mysql') { |
1885 | 1885 | $query .= " AND DAY(marine_output.date) = :day"; |
1886 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1886 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1887 | 1887 | } else { |
1888 | 1888 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1889 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1889 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1890 | 1890 | } |
1891 | 1891 | } |
1892 | 1892 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -1895,7 +1895,7 @@ discard block |
||
1895 | 1895 | $sth->execute($query_values); |
1896 | 1896 | $marine_array = array(); |
1897 | 1897 | $temp_array = array(); |
1898 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1898 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1899 | 1899 | { |
1900 | 1900 | $temp_array['marine_type'] = $row['marine_type']; |
1901 | 1901 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
@@ -1911,13 +1911,13 @@ discard block |
||
1911 | 1911 | * @return Array the tracker information |
1912 | 1912 | * |
1913 | 1913 | */ |
1914 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
1914 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
1915 | 1915 | { |
1916 | 1916 | global $globalTimezone, $globalDBdriver; |
1917 | 1917 | date_default_timezone_set('UTC'); |
1918 | 1918 | $query_values = array(); |
1919 | 1919 | $additional_query = ''; |
1920 | - $filter_query = $this->getFilter($filters,true,true); |
|
1920 | + $filter_query = $this->getFilter($filters, true, true); |
|
1921 | 1921 | if ($q != "") |
1922 | 1922 | { |
1923 | 1923 | if (!is_string($q)) |
@@ -1925,8 +1925,8 @@ discard block |
||
1925 | 1925 | return false; |
1926 | 1926 | } else { |
1927 | 1927 | $q_array = explode(" ", $q); |
1928 | - foreach ($q_array as $q_item){ |
|
1929 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1928 | + foreach ($q_array as $q_item) { |
|
1929 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1930 | 1930 | $additional_query .= " AND ("; |
1931 | 1931 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
1932 | 1932 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -1938,42 +1938,42 @@ discard block |
||
1938 | 1938 | } |
1939 | 1939 | if ($callsign != "") |
1940 | 1940 | { |
1941 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1941 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1942 | 1942 | if (!is_string($callsign)) |
1943 | 1943 | { |
1944 | 1944 | return false; |
1945 | 1945 | } else { |
1946 | 1946 | $additional_query .= " AND marine_output.ident = :callsign"; |
1947 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
1947 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
1948 | 1948 | } |
1949 | 1949 | } |
1950 | 1950 | if ($mmsi != "") |
1951 | 1951 | { |
1952 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
1952 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
1953 | 1953 | if (!is_numeric($mmsi)) |
1954 | 1954 | { |
1955 | 1955 | return false; |
1956 | 1956 | } else { |
1957 | 1957 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
1958 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
1958 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
1959 | 1959 | } |
1960 | 1960 | } |
1961 | 1961 | if ($imo != "") |
1962 | 1962 | { |
1963 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
1963 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
1964 | 1964 | if (!is_numeric($imo)) |
1965 | 1965 | { |
1966 | 1966 | return false; |
1967 | 1967 | } else { |
1968 | 1968 | $additional_query .= " AND marine_output.imo = :imo"; |
1969 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
1969 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
1970 | 1970 | } |
1971 | 1971 | } |
1972 | 1972 | if ($date_posted != "") |
1973 | 1973 | { |
1974 | 1974 | $date_array = explode(",", $date_posted); |
1975 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
1976 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
1975 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
1976 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
1977 | 1977 | if ($globalTimezone != '') { |
1978 | 1978 | date_default_timezone_set($globalTimezone); |
1979 | 1979 | $datetime = new DateTime(); |
@@ -2000,8 +2000,8 @@ discard block |
||
2000 | 2000 | if ($limit != "") |
2001 | 2001 | { |
2002 | 2002 | $limit_array = explode(",", $limit); |
2003 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
2004 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
2003 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
2004 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
2005 | 2005 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2006 | 2006 | { |
2007 | 2007 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2019,28 +2019,28 @@ discard block |
||
2019 | 2019 | } |
2020 | 2020 | } |
2021 | 2021 | if ($origLat != "" && $origLon != "" && $dist != "") { |
2022 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
2022 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
2023 | 2023 | if ($globalDBdriver == 'mysql') { |
2024 | - $query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
2024 | + $query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
2025 | 2025 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
2026 | 2026 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
2027 | 2027 | } else { |
2028 | - $query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
2028 | + $query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
2029 | 2029 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
2030 | 2030 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
2031 | 2031 | } |
2032 | 2032 | } else { |
2033 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2033 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2034 | 2034 | ".$additional_query." |
2035 | 2035 | ".$orderby_query; |
2036 | 2036 | } |
2037 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
2037 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
2038 | 2038 | return $marine_array; |
2039 | 2039 | } |
2040 | 2040 | |
2041 | 2041 | public function getOrderBy() |
2042 | 2042 | { |
2043 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
2043 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
2044 | 2044 | |
2045 | 2045 | return $orderby; |
2046 | 2046 |
@@ -8,15 +8,15 @@ discard block |
||
8 | 8 | die(); |
9 | 9 | } |
10 | 10 | |
11 | -$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING); |
|
11 | +$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING); |
|
12 | 12 | |
13 | 13 | $Spotter = new Spotter(); |
14 | -$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1",""); |
|
14 | +$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, "0,1", ""); |
|
15 | 15 | |
16 | 16 | |
17 | 17 | if (!empty($spotter_array)) |
18 | 18 | { |
19 | - $title = sprintf(_("Most Common Time of Day from %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']); |
|
19 | + $title = sprintf(_("Most Common Time of Day from %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']); |
|
20 | 20 | require_once('header.php'); |
21 | 21 | print '<div class="select-item">'; |
22 | 22 | print '<form action="'.$globalURL.'/aircraft" method="get">'; |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | $Stats = new Stats(); |
26 | 26 | $aircraft_types = $Stats->getAllAircraftTypes(); |
27 | 27 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
28 | - foreach($aircraft_types as $aircrafttype) |
|
28 | + foreach ($aircraft_types as $aircrafttype) |
|
29 | 29 | { |
30 | - if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
30 | + if ($aircraft_type == $aircrafttype['aircraft_icao']) |
|
31 | 31 | { |
32 | 32 | print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
33 | 33 | } else { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | include('aircraft-sub-menu.php'); |
54 | 54 | print '<div class="column">'; |
55 | 55 | print '<h2>'._("Most Common Time of Day").'</h2>'; |
56 | - print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>'; |
|
56 | + print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>'; |
|
57 | 57 | |
58 | 58 | $hour_array = $Spotter->countAllHoursByAircraft($aircraft_type); |
59 | 59 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | $hour_data = ''; |
64 | 64 | $hour_cnt = ''; |
65 | 65 | $last = 0; |
66 | - foreach($hour_array as $hour_item) |
|
66 | + foreach ($hour_array as $hour_item) |
|
67 | 67 | { |
68 | - while($last != $hour_item['hour_name']) { |
|
68 | + while ($last != $hour_item['hour_name']) { |
|
69 | 69 | $hour_data .= '"'.$last.':00",'; |
70 | 70 | $hour_cnt .= '0,'; |
71 | 71 | $last++; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $hour_cnt .= $hour_item['hour_count'].','; |
76 | 76 | } |
77 | 77 | $hour_data = "[".substr($hour_data, 0, -1)."]"; |
78 | - $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
|
78 | + $hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]"; |
|
79 | 79 | print 'c3.generate({ |
80 | 80 | bindto: "#chartHour", |
81 | 81 | data: { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | print '</thead>'; |
99 | 99 | print '<tbody>'; |
100 | 100 | $i = 1; |
101 | - foreach($hour_array as $hour_item) |
|
101 | + foreach ($hour_array as $hour_item) |
|
102 | 102 | { |
103 | 103 | print '<tr>'; |
104 | 104 | print '<td>'.$hour_item['hour_name'].':00</td>'; |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | die(); |
10 | 10 | } |
11 | 11 | |
12 | -$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING); |
|
12 | +$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING); |
|
13 | 13 | |
14 | 14 | $Spotter = new Spotter(); |
15 | -$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1",""); |
|
15 | +$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, "0,1", ""); |
|
16 | 16 | |
17 | 17 | |
18 | 18 | if (!empty($spotter_array)) |
19 | 19 | { |
20 | - $title = sprintf(_("Most Common Arrival Airports for %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']); |
|
20 | + $title = sprintf(_("Most Common Arrival Airports for %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']); |
|
21 | 21 | require_once('header.php'); |
22 | 22 | print '<div class="select-item">'; |
23 | 23 | print '<form action="'.$globalURL.'/aircraft" method="get">'; |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | $Stats = new Stats(); |
27 | 27 | $aircraft_types = $Stats->getAllAircraftTypes(); |
28 | 28 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
29 | - foreach($aircraft_types as $aircrafttype) |
|
29 | + foreach ($aircraft_types as $aircrafttype) |
|
30 | 30 | { |
31 | - if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
31 | + if ($aircraft_type == $aircrafttype['aircraft_icao']) |
|
32 | 32 | { |
33 | 33 | print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
34 | 34 | } else { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | include('aircraft-sub-menu.php'); |
56 | 56 | print '<div class="column">'; |
57 | 57 | print '<h2>'._("Most Common Arrival Airports").'</h2>'; |
58 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>'; |
|
58 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights from <strong>%s (%s)</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>'; |
|
59 | 59 | $airport_airport_array = $Spotter->countAllArrivalAirportsByAircraft($aircraft_type); |
60 | 60 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
61 | 61 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | print '<script>'; |
65 | 65 | print 'var series = ['; |
66 | 66 | $airport_data = ''; |
67 | - foreach($airport_airport_array as $airport_item) |
|
67 | + foreach ($airport_airport_array as $airport_item) |
|
68 | 68 | { |
69 | 69 | $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_name'].' ('.$airport_item['airport_arrival_icao'].')",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],'; |
70 | 70 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | print '</thead>'; |
120 | 120 | print '<tbody>'; |
121 | 121 | $i = 1; |
122 | - foreach($airport_airport_array as $airport_item) |
|
122 | + foreach ($airport_airport_array as $airport_item) |
|
123 | 123 | { |
124 | 124 | print '<tr>'; |
125 | 125 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,14 +7,14 @@ discard block |
||
7 | 7 | header('Location: '.$globalURL.'/aircraft'); |
8 | 8 | die(); |
9 | 9 | } |
10 | -$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING); |
|
10 | +$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING); |
|
11 | 11 | $Spotter = new Spotter(); |
12 | -$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1",""); |
|
12 | +$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, "0,1", ""); |
|
13 | 13 | |
14 | 14 | |
15 | 15 | if (!empty($spotter_array)) |
16 | 16 | { |
17 | - $title = sprintf(_("Most Common Departure Airports by Country for %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']); |
|
17 | + $title = sprintf(_("Most Common Departure Airports by Country for %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']); |
|
18 | 18 | require_once('header.php'); |
19 | 19 | print '<div class="select-item">'; |
20 | 20 | print '<form action="'.$globalURL.'/aircraft" method="get">'; |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | $Stats = new Stats(); |
24 | 24 | $aircraft_types = $Stats->getAllAircraftTypes(); |
25 | 25 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
26 | - foreach($aircraft_types as $aircrafttype) |
|
26 | + foreach ($aircraft_types as $aircrafttype) |
|
27 | 27 | { |
28 | - if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
28 | + if ($aircraft_type == $aircrafttype['aircraft_icao']) |
|
29 | 29 | { |
30 | 30 | print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
31 | 31 | } else { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | include('aircraft-sub-menu.php'); |
52 | 52 | print '<div class="column">'; |
53 | 53 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
54 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>'; |
|
54 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s (%s)</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>'; |
|
55 | 55 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByAircraft($aircraft_type); |
56 | 56 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
57 | 57 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
60 | 60 | print 'var series = ['; |
61 | 61 | $country_data = ''; |
62 | - foreach($airport_country_array as $airport_item) |
|
62 | + foreach ($airport_country_array as $airport_item) |
|
63 | 63 | { |
64 | 64 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
65 | 65 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | print '</thead>'; |
108 | 108 | print '<tbody>'; |
109 | 109 | $i = 1; |
110 | - foreach($airport_country_array as $airport_item) |
|
110 | + foreach ($airport_country_array as $airport_item) |
|
111 | 111 | { |
112 | 112 | print '<tr>'; |
113 | 113 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | die; |
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
53 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
|
57 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); |
|
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | 61 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
63 | 63 | else $globalSources[] = array('host' => $options['s']); |
64 | 64 | } elseif (isset($options['source'])) { |
65 | 65 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
67 | 67 | else $globalSources[] = array('host' => $options['source']); |
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | else $id_source = 1; |
105 | 105 | if (isset($globalServer) && $globalServer) { |
106 | 106 | if ($globalDebug) echo "Using Server Mode\n"; |
107 | - $SI=new SpotterServer(); |
|
107 | + $SI = new SpotterServer(); |
|
108 | 108 | /* |
109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 110 | $SI = new adsb2aprs(); |
111 | 111 | $SI->connect(); |
112 | 112 | */ |
113 | -} else $SI=new SpotterImport($Connection->db); |
|
113 | +} else $SI = new SpotterImport($Connection->db); |
|
114 | 114 | |
115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
116 | 116 | if (isset($globalMarine) && $globalMarine) { |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | $MI = new MarineImport($Connection->db); |
125 | 125 | } |
126 | 126 | //$APRS=new APRS($Connection->db); |
127 | -$SBS=new SBS(); |
|
127 | +$SBS = new SBS(); |
|
128 | 128 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
129 | - $ACARS=new ACARS($Connection->db,true); |
|
130 | - $Source=new Source($Connection->db); |
|
129 | + $ACARS = new ACARS($Connection->db, true); |
|
130 | + $Source = new Source($Connection->db); |
|
131 | 131 | } |
132 | -$Common=new Common(); |
|
132 | +$Common = new Common(); |
|
133 | 133 | date_default_timezone_set('UTC'); |
134 | 134 | //$servertz = system('date +%Z'); |
135 | 135 | // signal handler - playing nice with sockets and dump1090 |
136 | 136 | if (function_exists('pcntl_fork')) { |
137 | - pcntl_signal(SIGINT, function() { |
|
137 | + pcntl_signal(SIGINT, function() { |
|
138 | 138 | global $sockets; |
139 | 139 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
140 | 140 | die("Bye!\n"); |
@@ -150,30 +150,30 @@ discard block |
||
150 | 150 | |
151 | 151 | function connect_all($hosts) { |
152 | 152 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
153 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
154 | 154 | $reset++; |
155 | 155 | if ($globalDebug) echo 'Connect to all...'."\n"; |
156 | 156 | foreach ($hosts as $id => $value) { |
157 | 157 | $host = $value['host']; |
158 | 158 | $globalSources[$id]['last_exec'] = 0; |
159 | 159 | // Here we check type of source(s) |
160 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
160 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
161 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
162 | 162 | //$formats[$id] = 'deltadbtxt'; |
163 | 163 | $globalSources[$id]['format'] = 'deltadbtxt'; |
164 | 164 | //$last_exec['deltadbtxt'] = 0; |
165 | 165 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
166 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
167 | 167 | //$formats[$id] = 'vatsimtxt'; |
168 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; |
169 | 169 | //$last_exec['vatsimtxt'] = 0; |
170 | 170 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
171 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
172 | 172 | //$formats[$id] = 'aircraftlistjson'; |
173 | 173 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
174 | 174 | //$last_exec['aircraftlistjson'] = 0; |
175 | 175 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
176 | - } else if (preg_match('/opensky/i',$host)) { |
|
176 | + } else if (preg_match('/opensky/i', $host)) { |
|
177 | 177 | //$formats[$id] = 'aircraftlistjson'; |
178 | 178 | $globalSources[$id]['format'] = 'opensky'; |
179 | 179 | //$last_exec['aircraftlistjson'] = 0; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | exit(0); |
191 | 191 | } |
192 | 192 | */ |
193 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
193 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
194 | 194 | //$formats[$id] = 'planeupdatefaa'; |
195 | 195 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
196 | 196 | //$last_exec['planeupdatefaa'] = 0; |
@@ -199,37 +199,37 @@ discard block |
||
199 | 199 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
200 | 200 | exit(0); |
201 | 201 | } |
202 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
202 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
203 | 203 | //$formats[$id] = 'phpvmacars'; |
204 | 204 | $globalSources[$id]['format'] = 'phpvmacars'; |
205 | 205 | //$last_exec['phpvmacars'] = 0; |
206 | 206 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
207 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
207 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { |
|
208 | 208 | //$formats[$id] = 'phpvmacars'; |
209 | 209 | $globalSources[$id]['format'] = 'vaos'; |
210 | 210 | //$last_exec['phpvmacars'] = 0; |
211 | 211 | if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
212 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
212 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
213 | 213 | //$formats[$id] = 'phpvmacars'; |
214 | 214 | $globalSources[$id]['format'] = 'vam'; |
215 | 215 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
216 | - } else if (preg_match('/whazzup/i',$host)) { |
|
216 | + } else if (preg_match('/whazzup/i', $host)) { |
|
217 | 217 | //$formats[$id] = 'whazzup'; |
218 | 218 | $globalSources[$id]['format'] = 'whazzup'; |
219 | 219 | //$last_exec['whazzup'] = 0; |
220 | 220 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
221 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
221 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
222 | 222 | $globalSources[$id]['format'] = 'blitzortung'; |
223 | 223 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
224 | - } else if (preg_match('/airwhere/i',$host)) { |
|
224 | + } else if (preg_match('/airwhere/i', $host)) { |
|
225 | 225 | $globalSources[$id]['format'] = 'airwhere'; |
226 | 226 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
227 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
227 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
228 | 228 | //$formats[$id] = 'pirepsjson'; |
229 | 229 | $globalSources[$id]['format'] = 'pirepsjson'; |
230 | 230 | //$last_exec['pirepsjson'] = 0; |
231 | 231 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
232 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
232 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
233 | 233 | //$formats[$id] = 'fr24json'; |
234 | 234 | $globalSources[$id]['format'] = 'fr24json'; |
235 | 235 | //$last_exec['fr24json'] = 0; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
239 | 239 | exit(0); |
240 | 240 | } |
241 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
241 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
242 | 242 | //$formats[$id] = 'fr24json'; |
243 | 243 | $globalSources[$id]['format'] = 'myshiptracking'; |
244 | 244 | //$last_exec['fr24json'] = 0; |
@@ -248,21 +248,21 @@ discard block |
||
248 | 248 | exit(0); |
249 | 249 | } |
250 | 250 | //} else if (preg_match('/10001/',$host)) { |
251 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
251 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
252 | 252 | //$formats[$id] = 'tsv'; |
253 | 253 | $globalSources[$id]['format'] = 'tsv'; |
254 | 254 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
255 | 255 | } |
256 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
256 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
257 | 257 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
258 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
258 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
259 | 259 | if ($idf !== false) { |
260 | 260 | $httpfeeds[$id] = $idf; |
261 | 261 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
262 | 262 | } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
263 | 263 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
264 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
265 | - $hostport = explode(':',$host); |
|
264 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
265 | + $hostport = explode(':', $host); |
|
266 | 266 | if (isset($hostport[1])) { |
267 | 267 | $port = $hostport[1]; |
268 | 268 | $hostn = $hostport[0]; |
@@ -272,19 +272,19 @@ discard block |
||
272 | 272 | } |
273 | 273 | $Common = new Common(); |
274 | 274 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
275 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
275 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
276 | 276 | } else { |
277 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
277 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
278 | 278 | } |
279 | 279 | if ($s) { |
280 | 280 | $sockets[$id] = $s; |
281 | 281 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
282 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
282 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
283 | 283 | //$formats[$id] = 'aprs'; |
284 | 284 | $globalSources[$id]['format'] = 'aprs'; |
285 | 285 | //$aprs_connect = 0; |
286 | 286 | //$use_aprs = true; |
287 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
287 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
288 | 288 | $globalSources[$id]['format'] = 'vrstcp'; |
289 | 289 | } elseif ($port == '10001') { |
290 | 290 | //$formats[$id] = 'tsv'; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
324 | 324 | else $timeout = 20; |
325 | 325 | $errno = ''; |
326 | -$errstr=''; |
|
326 | +$errstr = ''; |
|
327 | 327 | |
328 | 328 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
329 | 329 | /* Initiate connections to all the hosts simultaneously */ |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | //connect_all($globalSources); |
332 | 332 | |
333 | 333 | if (isset($globalProxy) && $globalProxy) { |
334 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
334 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
335 | 335 | } else { |
336 | 336 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
337 | 337 | } |
@@ -361,16 +361,16 @@ discard block |
||
361 | 361 | |
362 | 362 | if ($use_aprs) { |
363 | 363 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
364 | - $APRS=new APRS(); |
|
364 | + $APRS = new APRS(); |
|
365 | 365 | $aprs_connect = 0; |
366 | 366 | $aprs_keep = 120; |
367 | 367 | $aprs_last_tx = time(); |
368 | 368 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
369 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
369 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
370 | 370 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
371 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
371 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
372 | 372 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
373 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
373 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
374 | 374 | if ($aprs_full) $aprs_filter = ''; |
375 | 375 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
376 | 376 | else $aprs_pass = '-1'; |
@@ -384,12 +384,12 @@ discard block |
||
384 | 384 | sleep(1); |
385 | 385 | if ($globalDebug) echo "SCAN MODE \n\n"; |
386 | 386 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
387 | -$endtime = time()+$globalCronEnd; |
|
387 | +$endtime = time() + $globalCronEnd; |
|
388 | 388 | $i = 1; |
389 | 389 | $tt = array(); |
390 | 390 | // Delete all ATC |
391 | 391 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
392 | - $ATC=new ATC($Connection->db); |
|
392 | + $ATC = new ATC($Connection->db); |
|
393 | 393 | } |
394 | 394 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
395 | 395 | $ATC->deleteAll(); |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | |
398 | 398 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
399 | 399 | while ($i > 0) { |
400 | - if (!$globalDaemon) $i = $endtime-time(); |
|
400 | + if (!$globalDaemon) $i = $endtime - time(); |
|
401 | 401 | // Delete old ATC |
402 | 402 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
403 | 403 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | } |
412 | 412 | if ($max != $globalMinFetch) { |
413 | 413 | if ($globalDebug) echo 'Sleeping...'."\n"; |
414 | - sleep($globalMinFetch-$max+2); |
|
414 | + sleep($globalMinFetch - $max + 2); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | //$buffer = $Common->getData($hosts[$id]); |
431 | 431 | $buffer = $Common->getData($value['host']); |
432 | 432 | if ($buffer != '') $reset = 0; |
433 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | - $buffer = explode('\n',$buffer); |
|
433 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
434 | + $buffer = explode('\n', $buffer); |
|
435 | 435 | foreach ($buffer as $line) { |
436 | 436 | if ($line != '' && count($line) > 7) { |
437 | 437 | $line = explode(',', $line); |
@@ -464,11 +464,11 @@ discard block |
||
464 | 464 | ) |
465 | 465 | ) { |
466 | 466 | date_default_timezone_set('CET'); |
467 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
467 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
468 | 468 | date_default_timezone_set('UTC'); |
469 | 469 | if ($buffer != '') $reset = 0; |
470 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
471 | - $buffer = explode('\n',$buffer); |
|
470 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
471 | + $buffer = explode('\n', $buffer); |
|
472 | 472 | foreach ($buffer as $line) { |
473 | 473 | if ($line != '') { |
474 | 474 | //echo "'".$line."'\n"; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $ais_data = $AIS->parse_line(trim($line)); |
477 | 477 | $data = array(); |
478 | 478 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
479 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
479 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
480 | 480 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
481 | 481 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
482 | 482 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
489 | 489 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
490 | 490 | if (isset($ais_data['timestamp'])) { |
491 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
491 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
492 | 492 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
493 | 493 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
494 | 494 | $add = true; |
@@ -511,21 +511,21 @@ discard block |
||
511 | 511 | $w = $e = null; |
512 | 512 | |
513 | 513 | if (isset($arr[$id])) { |
514 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
514 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
515 | 515 | if ($nn > 0) { |
516 | 516 | foreach ($httpfeeds as $feed) { |
517 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
517 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
518 | 518 | if ($buffer === FALSE) { |
519 | 519 | connect_all($globalSources); |
520 | 520 | } |
521 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
522 | - $buffer = explode('\n',$buffer); |
|
521 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
522 | + $buffer = explode('\n', $buffer); |
|
523 | 523 | foreach ($buffer as $line) { |
524 | 524 | if ($line != '') { |
525 | 525 | $ais_data = $AIS->parse_line(trim($line)); |
526 | 526 | $data = array(); |
527 | 527 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
528 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
528 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
529 | 529 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
530 | 530 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
531 | 531 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
538 | 538 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
539 | 539 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
540 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
540 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
541 | 541 | if (isset($ais_data['timestamp'])) { |
542 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
542 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
543 | 543 | } else { |
544 | 544 | $data['datetime'] = date('Y-m-d H:i:s'); |
545 | 545 | } |
@@ -571,10 +571,10 @@ discard block |
||
571 | 571 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
572 | 572 | ) |
573 | 573 | ) { |
574 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
574 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
575 | 575 | if ($buffer != '') { |
576 | 576 | //echo $buffer; |
577 | - $all_data = json_decode($buffer,true); |
|
577 | + $all_data = json_decode($buffer, true); |
|
578 | 578 | //print_r($all_data); |
579 | 579 | if (isset($all_data[0]['DATA'])) { |
580 | 580 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | $data['ident'] = $line['NAME']; |
584 | 584 | $data['mmsi'] = $line['MMSI']; |
585 | 585 | if (strlen($data['mmsi']) > 9) { |
586 | - $data['mmsi'] = substr($data['mmsi'],-9); |
|
586 | + $data['mmsi'] = substr($data['mmsi'], -9); |
|
587 | 587 | } |
588 | 588 | $data['speed'] = $line['SOG']; |
589 | 589 | $data['heading'] = $line['COG']; |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | //$data['type_id'] = $line['TYPE']; |
594 | 594 | $data['imo'] = $line['IMO']; |
595 | 595 | if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
596 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
597 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
596 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV'])); |
|
597 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
598 | 598 | $data['format_source'] = 'myshiptracking'; |
599 | 599 | $data['id_source'] = $id_source; |
600 | 600 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -611,16 +611,16 @@ discard block |
||
611 | 611 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
612 | 612 | ) |
613 | 613 | ) { |
614 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
614 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
615 | 615 | if ($buffer != '') { |
616 | - $all_data = json_decode($buffer,true); |
|
616 | + $all_data = json_decode($buffer, true); |
|
617 | 617 | if (isset($all_data[0]['mmsi'])) { |
618 | 618 | foreach ($all_data as $line) { |
619 | 619 | if ($line != '') { |
620 | 620 | $data = array(); |
621 | 621 | $data['ident'] = $line['shipname']; |
622 | 622 | $data['callsign'] = $line['callsign']; |
623 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
623 | + $data['mmsi'] = substr($line['mmsi'], -9); |
|
624 | 624 | $data['speed'] = $line['sog']; |
625 | 625 | if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
626 | 626 | $data['latitude'] = $line['latitude']; |
@@ -647,14 +647,14 @@ discard block |
||
647 | 647 | ) { |
648 | 648 | $buffer = $Common->getData($value['host']); |
649 | 649 | if ($buffer != '') { |
650 | - $all_data = json_decode($buffer,true); |
|
650 | + $all_data = json_decode($buffer, true); |
|
651 | 651 | if (isset($all_data['features'][0]['id'])) { |
652 | 652 | foreach ($all_data['features'] as $line) { |
653 | 653 | print_r($line); |
654 | 654 | $data = array(); |
655 | 655 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
656 | 656 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
657 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
657 | + if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9); |
|
658 | 658 | if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
659 | 659 | if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
660 | 660 | if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
@@ -681,31 +681,31 @@ discard block |
||
681 | 681 | ) |
682 | 682 | ) { |
683 | 683 | echo 'download...'; |
684 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
684 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
685 | 685 | echo 'done !'."\n"; |
686 | 686 | // FIXME: Need more work |
687 | 687 | if ($buffer != '') $reset = 0; |
688 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | - $buffer = explode('\n',$buffer); |
|
688 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
689 | + $buffer = explode('\n', $buffer); |
|
690 | 690 | foreach ($buffer as $line) { |
691 | 691 | if ($line != '') { |
692 | 692 | $data = array(); |
693 | 693 | echo $line."\n"; |
694 | - $data['mmsi'] = (int)substr($line,0,9); |
|
695 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
696 | - $data['status_id'] = substr($line,21,2); |
|
697 | - $data['type_id'] = substr($line,24,3); |
|
698 | - $data['latitude'] = substr($line,29,9); |
|
699 | - $data['longitude'] = substr($line,41,9); |
|
700 | - $data['speed'] = round(substr($line,51,5)); |
|
694 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
695 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
696 | + $data['status_id'] = substr($line, 21, 2); |
|
697 | + $data['type_id'] = substr($line, 24, 3); |
|
698 | + $data['latitude'] = substr($line, 29, 9); |
|
699 | + $data['longitude'] = substr($line, 41, 9); |
|
700 | + $data['speed'] = round(substr($line, 51, 5)); |
|
701 | 701 | //$data['course'] = substr($line,57,5); |
702 | - $data['heading'] = round(substr($line,63,3)); |
|
702 | + $data['heading'] = round(substr($line, 63, 3)); |
|
703 | 703 | //$data['draft'] = substr($line,67,4); |
704 | 704 | //$data['length'] = substr($line,72,3); |
705 | 705 | //$data['beam'] = substr($line,76,2); |
706 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
706 | + $data['ident'] = trim(utf8_encode(substr($line, 78, 20))); |
|
707 | 707 | //$data['callsign'] = trim(substr($line,100,7); |
708 | - $data['arrival_code'] = substr($line,108,20); |
|
708 | + $data['arrival_code'] = substr($line, 108, 20); |
|
709 | 709 | //$data['etaDate'] = substr($line,129,5); |
710 | 710 | //$data['etaTime'] = substr($line,135,5); |
711 | 711 | $data['format_source'] = 'shipplotter'; |
@@ -736,8 +736,8 @@ discard block |
||
736 | 736 | ) { |
737 | 737 | //$buffer = $Common->getData($hosts[$id]); |
738 | 738 | $buffer = $Common->getData($value['host']); |
739 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
740 | - $buffer = explode('\n',$buffer); |
|
739 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
740 | + $buffer = explode('\n', $buffer); |
|
741 | 741 | $reset = 0; |
742 | 742 | foreach ($buffer as $line) { |
743 | 743 | if ($line != '') { |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
749 | 749 | $data['pilot_id'] = $line[1]; |
750 | 750 | $data['pilot_name'] = $line[2]; |
751 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
751 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
752 | 752 | $data['ident'] = $line[0]; // ident |
753 | 753 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
754 | 754 | $data['speed'] = $line[8]; // speed |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
765 | 765 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
766 | 766 | $data['departure_airport_icao'] = $line[11]; |
767 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
767 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
768 | 768 | $data['arrival_airport_icao'] = $line[13]; |
769 | 769 | $data['frequency'] = $line[4]; |
770 | 770 | $data['type'] = $line[18]; |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | $data['id_source'] = $id_source; |
774 | 774 | //$data['arrival_airport_time'] = ; |
775 | 775 | if ($line[9] != '') { |
776 | - $aircraft_data = explode('/',$line[9]); |
|
776 | + $aircraft_data = explode('/', $line[9]); |
|
777 | 777 | if (isset($aircraft_data[1])) { |
778 | 778 | $data['aircraft_icao'] = $aircraft_data[1]; |
779 | 779 | } |
@@ -788,9 +788,9 @@ discard block |
||
788 | 788 | if ($line[3] == 'PILOT') $SI->add($data); |
789 | 789 | elseif ($line[3] == 'ATC') { |
790 | 790 | //print_r($data); |
791 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
792 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
793 | - $typec = substr($data['ident'],-3); |
|
791 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
792 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
793 | + $typec = substr($data['ident'], -3); |
|
794 | 794 | if ($typec == 'APP') $data['type'] = 'Approach'; |
795 | 795 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
796 | 796 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
803 | 803 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
804 | 804 | if (isset($ATC)) { |
805 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
806 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
805 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
806 | + else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
807 | 807 | } |
808 | 808 | } |
809 | 809 | unset($data); |
@@ -819,24 +819,24 @@ discard block |
||
819 | 819 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
820 | 820 | ) |
821 | 821 | ) { |
822 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
822 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
823 | 823 | if ($buffer != '') { |
824 | 824 | $all_data = simplexml_load_string($buffer); |
825 | - foreach($all_data->children() as $childdata) { |
|
825 | + foreach ($all_data->children() as $childdata) { |
|
826 | 826 | $data = array(); |
827 | 827 | $line = $childdata; |
828 | 828 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
829 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
830 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
831 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
832 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
833 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
834 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
835 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
829 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
830 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
831 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
832 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
833 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
834 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
835 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
836 | 836 | $data['altitude_relative'] = 'AMSL'; |
837 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
837 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
838 | 838 | $data['aircraft_icao'] = 'PARAGLIDER'; |
839 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
839 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
840 | 840 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
841 | 841 | $data['format_source'] = $value['format']; |
842 | 842 | $SI->add($data); |
@@ -844,22 +844,22 @@ discard block |
||
844 | 844 | } |
845 | 845 | } |
846 | 846 | $Source->deleteOldLocationByType('gs'); |
847 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
847 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
848 | 848 | if ($buffer != '') { |
849 | 849 | $all_data = simplexml_load_string($buffer); |
850 | - foreach($all_data->children() as $childdata) { |
|
850 | + foreach ($all_data->children() as $childdata) { |
|
851 | 851 | $data = array(); |
852 | 852 | $line = $childdata; |
853 | - $data['id'] = (int)$line['gsID']; |
|
854 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
855 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
856 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
853 | + $data['id'] = (int) $line['gsID']; |
|
854 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
855 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
856 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
857 | 857 | $data['altitude_relative'] = 'AMSL'; |
858 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
858 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
859 | 859 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
860 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
860 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
861 | 861 | } else { |
862 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
862 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
863 | 863 | } |
864 | 864 | unset($data); |
865 | 865 | } |
@@ -877,9 +877,9 @@ discard block |
||
877 | 877 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
878 | 878 | ) |
879 | 879 | ) { |
880 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
880 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
881 | 881 | if ($buffer != '') { |
882 | - $all_data = json_decode($buffer,true); |
|
882 | + $all_data = json_decode($buffer, true); |
|
883 | 883 | if (isset($all_data['acList'])) { |
884 | 884 | $reset = 0; |
885 | 885 | foreach ($all_data['acList'] as $line) { |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
896 | 896 | $data['emergency'] = ''; // emergency |
897 | 897 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
898 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
898 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
899 | 899 | else $data['datetime'] = date('Y-m-d H:i:s'); |
900 | 900 | //$data['datetime'] = date('Y-m-d H:i:s'); |
901 | 901 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | $data['verticalrate'] = $line['vrt']; // verticale rate |
921 | 921 | $data['squawk'] = $line['squawk']; // squawk |
922 | 922 | $data['emergency'] = ''; // emergency |
923 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
923 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
924 | 924 | else $data['datetime'] = date('Y-m-d H:i:s'); |
925 | 925 | $data['format_source'] = 'aircraftlistjson'; |
926 | 926 | $data['id_source'] = $id_source; |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | ) |
942 | 942 | ) { |
943 | 943 | $buffer = $Common->getData($value['host']); |
944 | - $all_data = json_decode($buffer,true); |
|
944 | + $all_data = json_decode($buffer, true); |
|
945 | 945 | if (isset($all_data['planes'])) { |
946 | 946 | $reset = 0; |
947 | 947 | foreach ($all_data['planes'] as $key => $line) { |
@@ -958,12 +958,12 @@ discard block |
||
958 | 958 | $data['emergency'] = ''; // emergency |
959 | 959 | $data['registration'] = $line[2]; |
960 | 960 | $data['aircraft_icao'] = $line[0]; |
961 | - $deparr = explode('-',$line[1]); |
|
961 | + $deparr = explode('-', $line[1]); |
|
962 | 962 | if (count($deparr) == 2) { |
963 | 963 | $data['departure_airport_icao'] = $deparr[0]; |
964 | 964 | $data['arrival_airport_icao'] = $deparr[1]; |
965 | 965 | } |
966 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
966 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
967 | 967 | $data['format_source'] = 'planeupdatefaa'; |
968 | 968 | $data['id_source'] = $id_source; |
969 | 969 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | ) |
982 | 982 | ) { |
983 | 983 | $buffer = $Common->getData($value['host']); |
984 | - $all_data = json_decode($buffer,true); |
|
984 | + $all_data = json_decode($buffer, true); |
|
985 | 985 | if (isset($all_data['states'])) { |
986 | 986 | $reset = 0; |
987 | 987 | foreach ($all_data['states'] as $key => $line) { |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | //$data['emergency'] = ''; // emergency |
999 | 999 | //$data['registration'] = $line[2]; |
1000 | 1000 | //$data['aircraft_icao'] = $line[0]; |
1001 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1001 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
1002 | 1002 | $data['format_source'] = 'opensky'; |
1003 | 1003 | $data['id_source'] = $id_source; |
1004 | 1004 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | ) { |
1018 | 1018 | //$buffer = $Common->getData($hosts[$id]); |
1019 | 1019 | $buffer = $Common->getData($value['host']); |
1020 | - $all_data = json_decode($buffer,true); |
|
1020 | + $all_data = json_decode($buffer, true); |
|
1021 | 1021 | if (!empty($all_data)) $reset = 0; |
1022 | 1022 | foreach ($all_data as $key => $line) { |
1023 | 1023 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1055,11 +1055,11 @@ discard block |
||
1055 | 1055 | ) |
1056 | 1056 | ) { |
1057 | 1057 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
1058 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1058 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1059 | 1059 | //echo $buffer; |
1060 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1061 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1062 | - $all_data = json_decode($buffer,true); |
|
1060 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
1061 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
1062 | + $all_data = json_decode($buffer, true); |
|
1063 | 1063 | if (json_last_error() != JSON_ERROR_NONE) { |
1064 | 1064 | die(json_last_error_msg()); |
1065 | 1065 | } |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | //$data['departure_airport_iata'] = $line[11]; |
1083 | 1083 | //$data['arrival_airport_iata'] = $line[12]; |
1084 | 1084 | //$data['emergency'] = ''; // emergency |
1085 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
1085 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1086 | 1086 | $data['format_source'] = 'radarvirtueljson'; |
1087 | 1087 | $data['id_source'] = $id_source; |
1088 | 1088 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1103,14 +1103,14 @@ discard block |
||
1103 | 1103 | ) { |
1104 | 1104 | //$buffer = $Common->getData($hosts[$id]); |
1105 | 1105 | $buffer = $Common->getData($value['host'].'?'.time()); |
1106 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1106 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
1107 | 1107 | |
1108 | 1108 | if (isset($all_data['pireps'])) { |
1109 | 1109 | $reset = 0; |
1110 | 1110 | foreach ($all_data['pireps'] as $line) { |
1111 | 1111 | $data = array(); |
1112 | 1112 | $data['id'] = $line['id']; |
1113 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1113 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1114 | 1114 | $data['ident'] = $line['callsign']; // ident |
1115 | 1115 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
1116 | 1116 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1140,9 +1140,9 @@ discard block |
||
1140 | 1140 | $SI->add($data); |
1141 | 1141 | // print_r($data); |
1142 | 1142 | } elseif ($line['icon'] == 'ct') { |
1143 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1144 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1145 | - $typec = substr($data['ident'],-3); |
|
1143 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1144 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1145 | + $typec = substr($data['ident'], -3); |
|
1146 | 1146 | $data['type'] = ''; |
1147 | 1147 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1148 | 1148 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1154 | 1154 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1155 | 1155 | else $data['type'] = 'Observer'; |
1156 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1156 | + if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
1157 | 1157 | } |
1158 | 1158 | unset($data); |
1159 | 1159 | } |
@@ -1170,14 +1170,14 @@ discard block |
||
1170 | 1170 | //$buffer = $Common->getData($hosts[$id]); |
1171 | 1171 | if ($globalDebug) echo 'Get Data...'."\n"; |
1172 | 1172 | $buffer = $Common->getData($value['host']); |
1173 | - $all_data = json_decode($buffer,true); |
|
1173 | + $all_data = json_decode($buffer, true); |
|
1174 | 1174 | if ($buffer != '' && is_array($all_data)) { |
1175 | 1175 | $reset = 0; |
1176 | 1176 | foreach ($all_data as $line) { |
1177 | 1177 | $data = array(); |
1178 | 1178 | //$data['id'] = $line['id']; // id not usable |
1179 | 1179 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1180 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1180 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1181 | 1181 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1182 | 1182 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1183 | 1183 | $data['ident'] = $line['flightnum']; // ident |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | //$data['datetime'] = $line['lastupdate']; |
1193 | 1193 | //$data['last_update'] = $line['lastupdate']; |
1194 | 1194 | if (isset($value['timezone'])) { |
1195 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1195 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1196 | 1196 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1197 | 1197 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1198 | 1198 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1208,14 +1208,14 @@ discard block |
||
1208 | 1208 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1209 | 1209 | if (isset($line['aircraftname'])) { |
1210 | 1210 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1211 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1212 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1211 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1212 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1213 | 1213 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1214 | 1214 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1215 | 1215 | else { |
1216 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1217 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1218 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1216 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1217 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1218 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1219 | 1219 | } |
1220 | 1220 | } |
1221 | 1221 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | //$buffer = $Common->getData($hosts[$id]); |
1241 | 1241 | if ($globalDebug) echo 'Get Data...'."\n"; |
1242 | 1242 | $buffer = $Common->getData($value['host']); |
1243 | - $all_data = json_decode($buffer,true); |
|
1243 | + $all_data = json_decode($buffer, true); |
|
1244 | 1244 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
1245 | 1245 | $reset = 0; |
1246 | 1246 | foreach ($all_data['ACARSData'] as $line) { |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1252 | 1252 | if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
1253 | 1253 | if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
1254 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1254 | + $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
1255 | 1255 | if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
1256 | 1256 | $data['altitude'] = $line['altitude']; // altitude |
1257 | 1257 | $data['speed'] = $line['groundspeed']; // speed |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | //$data['squawk'] = ''; // squawk |
1263 | 1263 | //$data['emergency'] = ''; // emergency |
1264 | 1264 | if (isset($value['timezone'])) { |
1265 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1265 | + $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
1266 | 1266 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1267 | 1267 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1268 | 1268 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1298,14 +1298,14 @@ discard block |
||
1298 | 1298 | //$buffer = $Common->getData($hosts[$id]); |
1299 | 1299 | if ($globalDebug) echo 'Get Data...'."\n"; |
1300 | 1300 | $buffer = $Common->getData($value['host']); |
1301 | - $all_data = json_decode($buffer,true); |
|
1301 | + $all_data = json_decode($buffer, true); |
|
1302 | 1302 | if ($buffer != '' && is_array($all_data)) { |
1303 | 1303 | $reset = 0; |
1304 | 1304 | foreach ($all_data as $line) { |
1305 | 1305 | $data = array(); |
1306 | 1306 | //$data['id'] = $line['id']; // id not usable |
1307 | 1307 | $data['id'] = trim($line['flight_id']); |
1308 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1308 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1309 | 1309 | $data['pilot_name'] = $line['pilot_name']; |
1310 | 1310 | $data['pilot_id'] = $line['pilot_id']; |
1311 | 1311 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1349,24 +1349,24 @@ discard block |
||
1349 | 1349 | //$buffer = $Common->getData($hosts[$id]); |
1350 | 1350 | if ($globalDebug) echo 'Get Data...'."\n"; |
1351 | 1351 | $buffer = $Common->getData($value['host']); |
1352 | - $all_data = json_decode($buffer,true); |
|
1352 | + $all_data = json_decode($buffer, true); |
|
1353 | 1353 | if ($buffer != '') { |
1354 | 1354 | $Source->deleteLocationBySource('blitzortung'); |
1355 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1356 | - $buffer = explode('\n',$buffer); |
|
1355 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1356 | + $buffer = explode('\n', $buffer); |
|
1357 | 1357 | foreach ($buffer as $buffer_line) { |
1358 | - $line = json_decode($buffer_line,true); |
|
1358 | + $line = json_decode($buffer_line, true); |
|
1359 | 1359 | if (isset($line['time'])) { |
1360 | 1360 | $data = array(); |
1361 | 1361 | $data['altitude'] = $line['alt']; // altitude |
1362 | 1362 | $data['latitude'] = $line['lat']; // lat |
1363 | 1363 | $data['longitude'] = $line['lon']; // long |
1364 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
1364 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1365 | 1365 | $data['id_source'] = $id_source; |
1366 | 1366 | $data['format_source'] = 'blitzortung'; |
1367 | 1367 | $SI->add($data); |
1368 | 1368 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1369 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
1369 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1370 | 1370 | unset($data); |
1371 | 1371 | } |
1372 | 1372 | } |
@@ -1391,11 +1391,11 @@ discard block |
||
1391 | 1391 | //$value = $formats[$nb]; |
1392 | 1392 | $format = $globalSources[$nb]['format']; |
1393 | 1393 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1394 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1394 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1395 | 1395 | } elseif ($format == 'vrstcp') { |
1396 | 1396 | $buffer = @socket_read($r, 6000); |
1397 | 1397 | } else { |
1398 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1398 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1399 | 1399 | } |
1400 | 1400 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1401 | 1401 | //echo $buffer."\n"; |
@@ -1405,8 +1405,8 @@ discard block |
||
1405 | 1405 | //$SI::del(); |
1406 | 1406 | if ($buffer !== FALSE) { |
1407 | 1407 | if ($format == 'vrstcp') { |
1408 | - $buffer = explode('},{',$buffer); |
|
1409 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1408 | + $buffer = explode('},{', $buffer); |
|
1409 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1410 | 1410 | } |
1411 | 1411 | // SBS format is CSV format |
1412 | 1412 | if ($buffer !== FALSE && $buffer !== '') { |
@@ -1430,7 +1430,7 @@ discard block |
||
1430 | 1430 | $ais_data = $AIS->parse_line(trim($buffer)); |
1431 | 1431 | $data = array(); |
1432 | 1432 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
1433 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1433 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
1434 | 1434 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
1435 | 1435 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
1436 | 1436 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -1441,13 +1441,13 @@ discard block |
||
1441 | 1441 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1442 | 1442 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1443 | 1443 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1444 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1444 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1445 | 1445 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1446 | 1446 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1447 | 1447 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1448 | 1448 | |
1449 | 1449 | if (isset($ais_data['timestamp'])) { |
1450 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1450 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1451 | 1451 | } else { |
1452 | 1452 | $data['datetime'] = date('Y-m-d H:i:s'); |
1453 | 1453 | } |
@@ -1458,10 +1458,10 @@ discard block |
||
1458 | 1458 | } elseif ($format == 'flightgearsp') { |
1459 | 1459 | //echo $buffer."\n"; |
1460 | 1460 | if (strlen($buffer) > 5) { |
1461 | - $line = explode(',',$buffer); |
|
1461 | + $line = explode(',', $buffer); |
|
1462 | 1462 | $data = array(); |
1463 | 1463 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1464 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1464 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1465 | 1465 | $data['ident'] = $line[6]; |
1466 | 1466 | $data['aircraft_name'] = $line[7]; |
1467 | 1467 | $data['longitude'] = $line[1]; |
@@ -1478,16 +1478,16 @@ discard block |
||
1478 | 1478 | } elseif ($format == 'acars') { |
1479 | 1479 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1480 | 1480 | $ACARS->add(trim($buffer)); |
1481 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1481 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1482 | 1482 | $ACARS->deleteLiveAcarsData(); |
1483 | 1483 | } elseif ($format == 'flightgearmp') { |
1484 | - if (substr($buffer,0,1) != '#') { |
|
1484 | + if (substr($buffer, 0, 1) != '#') { |
|
1485 | 1485 | $data = array(); |
1486 | 1486 | //echo $buffer."\n"; |
1487 | - $line = explode(' ',$buffer); |
|
1487 | + $line = explode(' ', $buffer); |
|
1488 | 1488 | if (count($line) == 11) { |
1489 | - $userserver = explode('@',$line[0]); |
|
1490 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1489 | + $userserver = explode('@', $line[0]); |
|
1490 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1491 | 1491 | $data['ident'] = $userserver[0]; |
1492 | 1492 | $data['registration'] = $userserver[0]; |
1493 | 1493 | $data['latitude'] = $line[4]; |
@@ -1495,8 +1495,8 @@ discard block |
||
1495 | 1495 | $data['altitude'] = $line[6]; |
1496 | 1496 | $data['datetime'] = date('Y-m-d H:i:s'); |
1497 | 1497 | $aircraft_type = $line[10]; |
1498 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1499 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1498 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1499 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1500 | 1500 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1501 | 1501 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1502 | 1502 | } |
@@ -1505,8 +1505,8 @@ discard block |
||
1505 | 1505 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1506 | 1506 | die; |
1507 | 1507 | } elseif ($format == 'vrstcp') { |
1508 | - foreach($buffer as $all_data) { |
|
1509 | - $line = json_decode('{'.$all_data.'}',true); |
|
1508 | + foreach ($buffer as $all_data) { |
|
1509 | + $line = json_decode('{'.$all_data.'}', true); |
|
1510 | 1510 | $data = array(); |
1511 | 1511 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1512 | 1512 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1532,16 +1532,16 @@ discard block |
||
1532 | 1532 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1533 | 1533 | unset($data); |
1534 | 1534 | } |
1535 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1535 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1536 | 1536 | $line = explode("\t", $buffer); |
1537 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1537 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1538 | 1538 | $key = $line[$k]; |
1539 | - $lined[$key] = $line[$k+1]; |
|
1539 | + $lined[$key] = $line[$k + 1]; |
|
1540 | 1540 | } |
1541 | 1541 | if (count($lined) > 3) { |
1542 | 1542 | $data['hex'] = $lined['hexid']; |
1543 | 1543 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1544 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1544 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1545 | 1545 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1546 | 1546 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1547 | 1547 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1560,23 +1560,23 @@ discard block |
||
1560 | 1560 | } else $error = true; |
1561 | 1561 | } elseif ($format == 'aprs' && $use_aprs) { |
1562 | 1562 | if ($aprs_connect == 0) { |
1563 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1563 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1564 | 1564 | $aprs_connect = 1; |
1565 | 1565 | } |
1566 | 1566 | |
1567 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1567 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1568 | 1568 | $aprs_last_tx = time(); |
1569 | 1569 | $data_aprs = "# Keep alive"; |
1570 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1570 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1571 | 1571 | } |
1572 | 1572 | |
1573 | 1573 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1574 | 1574 | //echo 'APRS data : '.$buffer."\n"; |
1575 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1576 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1575 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1576 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1577 | 1577 | //echo $buffer."\n"; |
1578 | 1578 | date_default_timezone_set('UTC'); |
1579 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1579 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1580 | 1580 | $line = $APRS->parse($buffer); |
1581 | 1581 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1582 | 1582 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1591,7 +1591,7 @@ discard block |
||
1591 | 1591 | if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
1592 | 1592 | if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
1593 | 1593 | if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
1594 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1594 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1595 | 1595 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1596 | 1596 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1597 | 1597 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1674,29 +1674,29 @@ discard block |
||
1674 | 1674 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1675 | 1675 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1676 | 1676 | $Source->deleteOldLocationByType('gs'); |
1677 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1678 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1677 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
1678 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1679 | 1679 | } else { |
1680 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1680 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1681 | 1681 | } |
1682 | 1682 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1683 | 1683 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1684 | 1684 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1685 | 1685 | $Source->deleteOldLocationByType('wx'); |
1686 | 1686 | $weather_data = json_encode($line); |
1687 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1688 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1687 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
1688 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1689 | 1689 | } else { |
1690 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1690 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1691 | 1691 | } |
1692 | 1692 | } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
1693 | 1693 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1694 | 1694 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1695 | 1695 | $Source->deleteOldLocationByType('lightning'); |
1696 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
1697 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1696 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
1697 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1698 | 1698 | } else { |
1699 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1699 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1700 | 1700 | } |
1701 | 1701 | } elseif ($globalDebug) { |
1702 | 1702 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1705,7 +1705,7 @@ discard block |
||
1705 | 1705 | unset($data); |
1706 | 1706 | } |
1707 | 1707 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1708 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1708 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1709 | 1709 | } |
1710 | 1710 | /* |
1711 | 1711 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
@@ -1714,7 +1714,7 @@ discard block |
||
1714 | 1714 | */ |
1715 | 1715 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1716 | 1716 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1717 | - if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1717 | + if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1718 | 1718 | $Source->deleteOldLocationByType('lightning'); |
1719 | 1719 | $Source->deleteOldLocationByType('wx'); |
1720 | 1720 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -1799,7 +1799,7 @@ discard block |
||
1799 | 1799 | connect_all($sourceee); |
1800 | 1800 | $sourceee = array(); |
1801 | 1801 | //connect_all($globalSources); |
1802 | - $tt[$format]=0; |
|
1802 | + $tt[$format] = 0; |
|
1803 | 1803 | break; |
1804 | 1804 | } |
1805 | 1805 | //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
@@ -1809,14 +1809,14 @@ discard block |
||
1809 | 1809 | } else { |
1810 | 1810 | $error = socket_strerror(socket_last_error()); |
1811 | 1811 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1812 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1812 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1813 | 1813 | if (isset($globalDebug)) echo "Restarting...\n"; |
1814 | 1814 | // Restart the script if possible |
1815 | 1815 | if (is_array($sockets)) { |
1816 | 1816 | if ($globalDebug) echo "Shutdown all sockets..."; |
1817 | 1817 | |
1818 | 1818 | foreach ($sockets as $sock) { |
1819 | - @socket_shutdown($sock,2); |
|
1819 | + @socket_shutdown($sock, 2); |
|
1820 | 1820 | @socket_close($sock); |
1821 | 1821 | } |
1822 | 1822 |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 60 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
61 | 61 | $Marine = new Marine($this->db); |
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | 73 | if (isset($flight['lastupdate'])) { |
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
74 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
75 | 75 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 76 | if (isset($this->all_tracked[$key]['id'])) { |
77 | 77 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | //$real_arrival = $this->arrival($key); |
84 | 84 | $Marine = new Marine($this->db); |
85 | 85 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
86 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | 88 | } |
89 | 89 | // Put in archive |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | public function add($line) { |
100 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
|
100 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine; |
|
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
103 | 103 | $dataFound = false; |
104 | 104 | $send = false; |
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | - if(is_array($line) && isset($line['mmsi'])) { |
|
107 | + if (is_array($line) && isset($line['mmsi'])) { |
|
108 | 108 | //print_r($line); |
109 | 109 | if (isset($line['mmsi'])) { |
110 | 110 | |
@@ -129,25 +129,25 @@ discard block |
||
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | 131 | $this->all_tracked[$id] = array(); |
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
135 | 135 | if (!isset($line['id'])) { |
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
139 | 139 | if ($globalAllTracked !== FALSE) $dataFound = true; |
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
144 | 144 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
147 | 147 | if (!empty($identity)) { |
148 | 148 | $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
149 | 149 | $this->all_tracked[$id]['type'] = $identity['type']; |
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
151 | 151 | } |
152 | 152 | //print_r($identity); |
153 | 153 | unset($Marine); |
@@ -155,23 +155,23 @@ discard block |
||
155 | 155 | } |
156 | 156 | } |
157 | 157 | if (isset($line['type_id'])) { |
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id'])); |
|
160 | 160 | } |
161 | 161 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
164 | 164 | } |
165 | 165 | if (isset($line['status']) && $line['status'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
170 | 170 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
171 | 171 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
172 | 172 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
173 | 173 | $Marine = new Marine($this->db); |
174 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
174 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
175 | 175 | unset($Marine); |
176 | 176 | } |
177 | 177 | } |
@@ -180,24 +180,24 @@ discard block |
||
180 | 180 | |
181 | 181 | |
182 | 182 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
184 | 184 | } |
185 | 185 | if (isset($line['imo']) && $line['imo'] != '') { |
186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
187 | 187 | } |
188 | 188 | if (isset($line['callsign']) && $line['callsign'] != '') { |
189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
190 | 190 | } |
191 | 191 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
192 | 192 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
193 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
193 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
194 | 194 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
195 | 195 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
196 | 196 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
197 | 197 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
198 | 198 | $Marine = new Marine($this->db); |
199 | 199 | $fromsource = NULL; |
200 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
200 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource); |
|
201 | 201 | $Marine->db = null; |
202 | 202 | } |
203 | 203 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | } |
215 | 215 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
216 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
@@ -222,44 +222,44 @@ discard block |
||
222 | 222 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
223 | 223 | $timeelapsed = microtime(true); |
224 | 224 | $Marine = new Marine($this->db); |
225 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
225 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['type']); |
|
226 | 226 | $Marine->db = null; |
227 | 227 | } |
228 | 228 | } |
229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
230 | 230 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
231 | 231 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
232 | 232 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
233 | 233 | $timeelapsed = microtime(true); |
234 | 234 | $Marine = new Marine($this->db); |
235 | 235 | $fromsource = NULL; |
236 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
236 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
237 | 237 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
238 | 238 | $Marine->db = null; |
239 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
239 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
243 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
243 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
244 | 244 | } |
245 | 245 | |
246 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
246 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
247 | 247 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
248 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
248 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
249 | 249 | } else { |
250 | 250 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
251 | 251 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
252 | 252 | return ''; |
253 | 253 | } |
254 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
254 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
255 | 255 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
256 | 256 | return ''; |
257 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
257 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
258 | 258 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
259 | 259 | return ''; |
260 | 260 | } elseif (!isset($line['datetime'])) { |
261 | 261 | date_default_timezone_set('UTC'); |
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
263 | 263 | } else { |
264 | 264 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
265 | 265 | return ''; |
@@ -267,24 +267,24 @@ discard block |
||
267 | 267 | |
268 | 268 | |
269 | 269 | if (isset($line['speed'])) { |
270 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
271 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
270 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
272 | 272 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
273 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
273 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
274 | 274 | if ($distance > 1000 && $distance < 10000) { |
275 | 275 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
276 | 276 | $speed = $speed*3.6; |
277 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
277 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
278 | 278 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
282 | 282 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
283 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
283 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
284 | 284 | else unset($timediff); |
285 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
285 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
286 | 286 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
287 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
287 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
288 | 288 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
289 | 289 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
290 | 290 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | $timeelapsed = microtime(true); |
294 | 294 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
295 | 295 | $Marine = new Marine($this->db); |
296 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
296 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
297 | 297 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
298 | 298 | $Marine->db = null; |
299 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
299 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
300 | 300 | } |
301 | 301 | $this->tmd = 0; |
302 | 302 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -305,55 +305,55 @@ discard block |
||
305 | 305 | |
306 | 306 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
307 | 307 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
308 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
308 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
309 | 309 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
310 | 310 | $dataFound = true; |
311 | 311 | $this->all_tracked[$id]['time_last_coord'] = time(); |
312 | 312 | } |
313 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
313 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
314 | 314 | } |
315 | 315 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
316 | 316 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
317 | 317 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
318 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
318 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
319 | 319 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
320 | 320 | $dataFound = true; |
321 | 321 | $this->all_tracked[$id]['time_last_coord'] = time(); |
322 | 322 | } |
323 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
323 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | } else if ($globalDebug && $timediff > 20) { |
327 | 327 | $this->tmd = $this->tmd + 1; |
328 | 328 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
329 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
330 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
329 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
330 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
331 | 331 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
332 | 332 | } |
333 | 333 | } |
334 | 334 | if (isset($line['last_update']) && $line['last_update'] != '') { |
335 | 335 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
336 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
336 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
337 | 337 | } |
338 | 338 | if (isset($line['format_source']) && $line['format_source'] != '') { |
339 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
339 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
340 | 340 | } |
341 | 341 | if (isset($line['source_name']) && $line['source_name'] != '') { |
342 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
342 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
343 | 343 | } |
344 | 344 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
345 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
345 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | if (isset($line['heading']) && $line['heading'] != '') { |
349 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
350 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
351 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
349 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
350 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
351 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
352 | 352 | //$dataFound = true; |
353 | 353 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
354 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
355 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
356 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
354 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
355 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
356 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
357 | 357 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
358 | 358 | } |
359 | 359 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
364 | 364 | $this->all_tracked[$id]['lastupdate'] = time(); |
365 | 365 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
366 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
366 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
367 | 367 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
368 | 368 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
369 | 369 | if ($globalDebug) echo "Check if vessel is already in DB..."; |
@@ -371,37 +371,37 @@ discard block |
||
371 | 371 | $MarineLive = new MarineLive($this->db); |
372 | 372 | if (isset($line['id'])) { |
373 | 373 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
374 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
374 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
375 | 375 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
376 | 376 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
377 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
377 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
378 | 378 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
379 | 379 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
380 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
380 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
381 | 381 | } else $recent_ident = ''; |
382 | - $MarineLive->db=null; |
|
382 | + $MarineLive->db = null; |
|
383 | 383 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
384 | 384 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
385 | 385 | } else $recent_ident = ''; |
386 | 386 | } else { |
387 | 387 | $recent_ident = ''; |
388 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
388 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
389 | 389 | } |
390 | 390 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
391 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
391 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
392 | 392 | { |
393 | 393 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
394 | 394 | //adds the spotter data for the archive |
395 | 395 | $highlight = ''; |
396 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
396 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
397 | 397 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
398 | 398 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
399 | 399 | $timeelapsed = microtime(true); |
400 | 400 | $Marine = new Marine($this->db); |
401 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
401 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
402 | 402 | $Marine->db = null; |
403 | 403 | if ($globalDebug && isset($result)) echo $result."\n"; |
404 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
404 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -409,15 +409,15 @@ discard block |
||
409 | 409 | $Stats = new Stats($this->db); |
410 | 410 | if (!empty($this->stats)) { |
411 | 411 | if ($globalDebug) echo 'Add source stats : '; |
412 | - foreach($this->stats as $date => $data) { |
|
413 | - foreach($data as $source => $sourced) { |
|
412 | + foreach ($this->stats as $date => $data) { |
|
413 | + foreach ($data as $source => $sourced) { |
|
414 | 414 | //print_r($sourced); |
415 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
416 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
415 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
416 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
417 | 417 | if (isset($sourced['msg'])) { |
418 | 418 | if (time() - $sourced['msg']['date'] > 10) { |
419 | 419 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
420 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
420 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
421 | 421 | unset($this->stats[$date][$source]['msg']); |
422 | 422 | } |
423 | 423 | } |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 442 | $MarineLive = new MarineLive($this->db); |
443 | 443 | $MarineLive->deleteLiveMarineData(); |
444 | - $MarineLive->db=null; |
|
444 | + $MarineLive->db = null; |
|
445 | 445 | if ($globalDebug) echo " Done\n"; |
446 | 446 | } |
447 | 447 | $this->last_delete = time(); |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
453 | 453 | if (isset($globalDaemon) && !$globalDaemon) { |
454 | 454 | $Marine = new Marine($this->db); |
455 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
455 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
456 | 456 | $Marine->db = null; |
457 | 457 | } |
458 | 458 | } |
@@ -467,20 +467,20 @@ discard block |
||
467 | 467 | $ignoreImport = false; |
468 | 468 | |
469 | 469 | if (!$ignoreImport) { |
470 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
470 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
471 | 471 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
472 | 472 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
473 | 473 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
474 | 474 | $timeelapsed = microtime(true); |
475 | 475 | $MarineLive = new MarineLive($this->db); |
476 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
476 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
477 | 477 | $MarineLive->db = null; |
478 | 478 | if ($globalDebug) echo $result."\n"; |
479 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
479 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
483 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
483 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
484 | 484 | } |
485 | 485 | $this->all_tracked[$id]['putinarchive'] = false; |
486 | 486 | |
@@ -499,19 +499,19 @@ discard block |
||
499 | 499 | $latitude = $globalCenterLatitude; |
500 | 500 | $longitude = $globalCenterLongitude; |
501 | 501 | } |
502 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
502 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
503 | 503 | } else { |
504 | 504 | $latitude = $this->source_location[$source]['latitude']; |
505 | 505 | $longitude = $this->source_location[$source]['longitude']; |
506 | 506 | } |
507 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
507 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
508 | 508 | //$stats_heading = $stats_heading%22.5; |
509 | 509 | $stats_heading = round($stats_heading/22.5); |
510 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
510 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
511 | 511 | $current_date = date('Y-m-d'); |
512 | 512 | if ($stats_heading == 16) $stats_heading = 0; |
513 | 513 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
514 | - for ($i=0;$i<=15;$i++) { |
|
514 | + for ($i = 0; $i <= 15; $i++) { |
|
515 | 515 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
516 | 516 | } |
517 | 517 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
527 | 527 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
528 | 528 | end($this->stats[$current_date][$source]['hist']); |
529 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
529 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
530 | 530 | } else $mini = 0; |
531 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
531 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
532 | 532 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
533 | 533 | } |
534 | 534 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | |
541 | 541 | $this->all_tracked[$id]['lastupdate'] = time(); |
542 | 542 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
543 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
543 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
544 | 544 | //$this->del(); |
545 | 545 | |
546 | 546 |