@@ -7,9 +7,13 @@ discard block |
||
7 | 7 | //echo $buffer."\n"; |
8 | 8 | $data = array(); |
9 | 9 | $typehex = substr($buffer,0,1); |
10 | - if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1); |
|
11 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
|
12 | - else $hex = substr($buffer,1,-1); |
|
10 | + if ($typehex == '*' || $typehex == ':') { |
|
11 | + $hex = substr($buffer,1,-1); |
|
12 | + } elseif ($typehex == '@' || $typehex == '%') { |
|
13 | + $hex = substr($buffer,13,-13); |
|
14 | + } else { |
|
15 | + $hex = substr($buffer,1,-1); |
|
16 | + } |
|
13 | 17 | $bin = gmp_strval( gmp_init($hex,16), 2); |
14 | 18 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
15 | 19 | if (strlen($hex) == 28) { |
@@ -52,8 +56,9 @@ discard block |
||
52 | 56 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
53 | 57 | $cprlat = intval(substr($bin,54,17),2)/131072.0; |
54 | 58 | $cprlon = intval(substr($bin,71,17),2)/131072.0; |
55 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
56 | - elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
59 | + if ($oe == 0) { |
|
60 | + $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
61 | + } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
57 | 62 | $cprlat_odd = $cprlat; |
58 | 63 | $cprlon_odd = $cprlon; |
59 | 64 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
@@ -62,8 +67,12 @@ discard block |
||
62 | 67 | $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
63 | 68 | $lat_even = (360.0/60)*($j%60+$cprlat_even); |
64 | 69 | $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
65 | - if ($lat_even >= 270) $lat_even = $lat_even - 360; |
|
66 | - if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
|
70 | + if ($lat_even >= 270) { |
|
71 | + $lat_even = $lat_even - 360; |
|
72 | + } |
|
73 | + if ($lat_odd >= 270) { |
|
74 | + $lat_odd = $lat_odd - 360; |
|
75 | + } |
|
67 | 76 | // check latitude zone |
68 | 77 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
69 | 78 | if ($this::$latlon[$icao]['created'] > time()) { |
@@ -71,7 +80,9 @@ discard block |
||
71 | 80 | $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
72 | 81 | $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
73 | 82 | $lat = $lat_even; |
74 | - if ($lon > 180) $lon = $lon -360; |
|
83 | + if ($lon > 180) { |
|
84 | + $lon = $lon -360; |
|
85 | + } |
|
75 | 86 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
76 | 87 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
77 | 88 | $data['latitude'] = $lat; |
@@ -82,14 +93,18 @@ discard block |
||
82 | 93 | $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
83 | 94 | $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
84 | 95 | $lat = $lat_odd; |
85 | - if ($lon > 180) $lon = $lon -360; |
|
96 | + if ($lon > 180) { |
|
97 | + $lon = $lon -360; |
|
98 | + } |
|
86 | 99 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
87 | 100 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
88 | 101 | $data['latitude'] = $lat; |
89 | 102 | $data['longitude'] = $lon; |
90 | 103 | } |
91 | 104 | } |
92 | - } else echo "Not cprNL"; |
|
105 | + } else { |
|
106 | + echo "Not cprNL"; |
|
107 | + } |
|
93 | 108 | unset($this::$latlon[$icao]); |
94 | 109 | } |
95 | 110 | } elseif ($tc == 19) { |
@@ -98,11 +113,17 @@ discard block |
||
98 | 113 | $v_ew = intval(substr($bin,46,10),2); |
99 | 114 | $v_ns_dir = intval(substr($bin,56,1)); |
100 | 115 | $v_ns = intval(substr($bin,57,10),2); |
101 | - if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
102 | - if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
116 | + if ($v_ew_dir) { |
|
117 | + $v_ew = -1*$v_ew; |
|
118 | + } |
|
119 | + if ($v_ns_dir) { |
|
120 | + $v_ns = -1*$v_ns; |
|
121 | + } |
|
103 | 122 | $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
104 | 123 | $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
105 | - if ($heading <0) $heading = $heading+360; |
|
124 | + if ($heading <0) { |
|
125 | + $heading = $heading+360; |
|
126 | + } |
|
106 | 127 | $data['speed'] = $speed; |
107 | 128 | $data['heading'] = $heading; |
108 | 129 | } |
@@ -117,72 +138,194 @@ discard block |
||
117 | 138 | |
118 | 139 | public function cprNL($lat) { |
119 | 140 | //Lookup table to convert the latitude to index. |
120 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
121 | - if ($lat < 10.47047130) return 59; |
|
122 | - if ($lat < 14.82817437) return 58; |
|
123 | - if ($lat < 18.18626357) return 57; |
|
124 | - if ($lat < 21.02939493) return 56; |
|
125 | - if ($lat < 23.54504487) return 55; |
|
126 | - if ($lat < 25.82924707) return 54; |
|
127 | - if ($lat < 27.93898710) return 53; |
|
128 | - if ($lat < 29.91135686) return 52; |
|
129 | - if ($lat < 31.77209708) return 51; |
|
130 | - if ($lat < 33.53993436) return 50; |
|
131 | - if ($lat < 35.22899598) return 49; |
|
132 | - if ($lat < 36.85025108) return 48; |
|
133 | - if ($lat < 38.41241892) return 47; |
|
134 | - if ($lat < 39.92256684) return 46; |
|
135 | - if ($lat < 41.38651832) return 45; |
|
136 | - if ($lat < 42.80914012) return 44; |
|
137 | - if ($lat < 44.19454951) return 43; |
|
138 | - if ($lat < 45.54626723) return 42; |
|
139 | - if ($lat < 46.86733252) return 41; |
|
140 | - if ($lat < 48.16039128) return 40; |
|
141 | - if ($lat < 49.42776439) return 39; |
|
142 | - if ($lat < 50.67150166) return 38; |
|
143 | - if ($lat < 51.89342469) return 37; |
|
144 | - if ($lat < 53.09516153) return 36; |
|
145 | - if ($lat < 54.27817472) return 35; |
|
146 | - if ($lat < 55.44378444) return 34; |
|
147 | - if ($lat < 56.59318756) return 33; |
|
148 | - if ($lat < 57.72747354) return 32; |
|
149 | - if ($lat < 58.84763776) return 31; |
|
150 | - if ($lat < 59.95459277) return 30; |
|
151 | - if ($lat < 61.04917774) return 29; |
|
152 | - if ($lat < 62.13216659) return 28; |
|
153 | - if ($lat < 63.20427479) return 27; |
|
154 | - if ($lat < 64.26616523) return 26; |
|
155 | - if ($lat < 65.31845310) return 25; |
|
156 | - if ($lat < 66.36171008) return 24; |
|
157 | - if ($lat < 67.39646774) return 23; |
|
158 | - if ($lat < 68.42322022) return 22; |
|
159 | - if ($lat < 69.44242631) return 21; |
|
160 | - if ($lat < 70.45451075) return 20; |
|
161 | - if ($lat < 71.45986473) return 19; |
|
162 | - if ($lat < 72.45884545) return 18; |
|
163 | - if ($lat < 73.45177442) return 17; |
|
164 | - if ($lat < 74.43893416) return 16; |
|
165 | - if ($lat < 75.42056257) return 15; |
|
166 | - if ($lat < 76.39684391) return 14; |
|
167 | - if ($lat < 77.36789461) return 13; |
|
168 | - if ($lat < 78.33374083) return 12; |
|
169 | - if ($lat < 79.29428225) return 11; |
|
170 | - if ($lat < 80.24923213) return 10; |
|
171 | - if ($lat < 81.19801349) return 9; |
|
172 | - if ($lat < 82.13956981) return 8; |
|
173 | - if ($lat < 83.07199445) return 7; |
|
174 | - if ($lat < 83.99173563) return 6; |
|
175 | - if ($lat < 84.89166191) return 5; |
|
176 | - if ($lat < 85.75541621) return 4; |
|
177 | - if ($lat < 86.53536998) return 3; |
|
178 | - if ($lat < 87.00000000) return 2; |
|
141 | + if ($lat < 0) { |
|
142 | + $lat = -$lat; |
|
143 | + } |
|
144 | + // Table is simmetric about the equator. |
|
145 | + if ($lat < 10.47047130) { |
|
146 | + return 59; |
|
147 | + } |
|
148 | + if ($lat < 14.82817437) { |
|
149 | + return 58; |
|
150 | + } |
|
151 | + if ($lat < 18.18626357) { |
|
152 | + return 57; |
|
153 | + } |
|
154 | + if ($lat < 21.02939493) { |
|
155 | + return 56; |
|
156 | + } |
|
157 | + if ($lat < 23.54504487) { |
|
158 | + return 55; |
|
159 | + } |
|
160 | + if ($lat < 25.82924707) { |
|
161 | + return 54; |
|
162 | + } |
|
163 | + if ($lat < 27.93898710) { |
|
164 | + return 53; |
|
165 | + } |
|
166 | + if ($lat < 29.91135686) { |
|
167 | + return 52; |
|
168 | + } |
|
169 | + if ($lat < 31.77209708) { |
|
170 | + return 51; |
|
171 | + } |
|
172 | + if ($lat < 33.53993436) { |
|
173 | + return 50; |
|
174 | + } |
|
175 | + if ($lat < 35.22899598) { |
|
176 | + return 49; |
|
177 | + } |
|
178 | + if ($lat < 36.85025108) { |
|
179 | + return 48; |
|
180 | + } |
|
181 | + if ($lat < 38.41241892) { |
|
182 | + return 47; |
|
183 | + } |
|
184 | + if ($lat < 39.92256684) { |
|
185 | + return 46; |
|
186 | + } |
|
187 | + if ($lat < 41.38651832) { |
|
188 | + return 45; |
|
189 | + } |
|
190 | + if ($lat < 42.80914012) { |
|
191 | + return 44; |
|
192 | + } |
|
193 | + if ($lat < 44.19454951) { |
|
194 | + return 43; |
|
195 | + } |
|
196 | + if ($lat < 45.54626723) { |
|
197 | + return 42; |
|
198 | + } |
|
199 | + if ($lat < 46.86733252) { |
|
200 | + return 41; |
|
201 | + } |
|
202 | + if ($lat < 48.16039128) { |
|
203 | + return 40; |
|
204 | + } |
|
205 | + if ($lat < 49.42776439) { |
|
206 | + return 39; |
|
207 | + } |
|
208 | + if ($lat < 50.67150166) { |
|
209 | + return 38; |
|
210 | + } |
|
211 | + if ($lat < 51.89342469) { |
|
212 | + return 37; |
|
213 | + } |
|
214 | + if ($lat < 53.09516153) { |
|
215 | + return 36; |
|
216 | + } |
|
217 | + if ($lat < 54.27817472) { |
|
218 | + return 35; |
|
219 | + } |
|
220 | + if ($lat < 55.44378444) { |
|
221 | + return 34; |
|
222 | + } |
|
223 | + if ($lat < 56.59318756) { |
|
224 | + return 33; |
|
225 | + } |
|
226 | + if ($lat < 57.72747354) { |
|
227 | + return 32; |
|
228 | + } |
|
229 | + if ($lat < 58.84763776) { |
|
230 | + return 31; |
|
231 | + } |
|
232 | + if ($lat < 59.95459277) { |
|
233 | + return 30; |
|
234 | + } |
|
235 | + if ($lat < 61.04917774) { |
|
236 | + return 29; |
|
237 | + } |
|
238 | + if ($lat < 62.13216659) { |
|
239 | + return 28; |
|
240 | + } |
|
241 | + if ($lat < 63.20427479) { |
|
242 | + return 27; |
|
243 | + } |
|
244 | + if ($lat < 64.26616523) { |
|
245 | + return 26; |
|
246 | + } |
|
247 | + if ($lat < 65.31845310) { |
|
248 | + return 25; |
|
249 | + } |
|
250 | + if ($lat < 66.36171008) { |
|
251 | + return 24; |
|
252 | + } |
|
253 | + if ($lat < 67.39646774) { |
|
254 | + return 23; |
|
255 | + } |
|
256 | + if ($lat < 68.42322022) { |
|
257 | + return 22; |
|
258 | + } |
|
259 | + if ($lat < 69.44242631) { |
|
260 | + return 21; |
|
261 | + } |
|
262 | + if ($lat < 70.45451075) { |
|
263 | + return 20; |
|
264 | + } |
|
265 | + if ($lat < 71.45986473) { |
|
266 | + return 19; |
|
267 | + } |
|
268 | + if ($lat < 72.45884545) { |
|
269 | + return 18; |
|
270 | + } |
|
271 | + if ($lat < 73.45177442) { |
|
272 | + return 17; |
|
273 | + } |
|
274 | + if ($lat < 74.43893416) { |
|
275 | + return 16; |
|
276 | + } |
|
277 | + if ($lat < 75.42056257) { |
|
278 | + return 15; |
|
279 | + } |
|
280 | + if ($lat < 76.39684391) { |
|
281 | + return 14; |
|
282 | + } |
|
283 | + if ($lat < 77.36789461) { |
|
284 | + return 13; |
|
285 | + } |
|
286 | + if ($lat < 78.33374083) { |
|
287 | + return 12; |
|
288 | + } |
|
289 | + if ($lat < 79.29428225) { |
|
290 | + return 11; |
|
291 | + } |
|
292 | + if ($lat < 80.24923213) { |
|
293 | + return 10; |
|
294 | + } |
|
295 | + if ($lat < 81.19801349) { |
|
296 | + return 9; |
|
297 | + } |
|
298 | + if ($lat < 82.13956981) { |
|
299 | + return 8; |
|
300 | + } |
|
301 | + if ($lat < 83.07199445) { |
|
302 | + return 7; |
|
303 | + } |
|
304 | + if ($lat < 83.99173563) { |
|
305 | + return 6; |
|
306 | + } |
|
307 | + if ($lat < 84.89166191) { |
|
308 | + return 5; |
|
309 | + } |
|
310 | + if ($lat < 85.75541621) { |
|
311 | + return 4; |
|
312 | + } |
|
313 | + if ($lat < 86.53536998) { |
|
314 | + return 3; |
|
315 | + } |
|
316 | + if ($lat < 87.00000000) { |
|
317 | + return 2; |
|
318 | + } |
|
179 | 319 | return 1; |
180 | 320 | } |
181 | 321 | |
182 | 322 | public function cprN($lat,$isodd) { |
183 | 323 | $nl = $this->cprNL($lat) - $isodd; |
184 | - if ($nl > 1) return $nl; |
|
185 | - else return 1; |
|
324 | + if ($nl > 1) { |
|
325 | + return $nl; |
|
326 | + } else { |
|
327 | + return 1; |
|
328 | + } |
|
186 | 329 | } |
187 | 330 | |
188 | 331 | |
@@ -208,10 +351,13 @@ discard block |
||
208 | 351 | $checksum = intval(substr($msg,22,6),16); |
209 | 352 | |
210 | 353 | for ($j = 0; $j < strlen($bin); $j++) { |
211 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
354 | + if ($bin[$j]) { |
|
355 | + $crc = $crc^intval($modes_checksum_table[$j],0); |
|
356 | + } |
|
212 | 357 | } |
213 | - if ($crc == $checksum) return true; |
|
214 | - else { |
|
358 | + if ($crc == $checksum) { |
|
359 | + return true; |
|
360 | + } else { |
|
215 | 361 | //echo "**** CRC ERROR ****\n"; |
216 | 362 | return false; |
217 | 363 | } |
@@ -258,22 +404,37 @@ discard block |
||
258 | 404 | $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
259 | 405 | $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
260 | 406 | $msg['callsign'] = ''; |
261 | - if (isset($data['altitude'])) $msg['altitude'] = $data['altitude']; |
|
262 | - else $msg['altitude'] = ''; |
|
407 | + if (isset($data['altitude'])) { |
|
408 | + $msg['altitude'] = $data['altitude']; |
|
409 | + } else { |
|
410 | + $msg['altitude'] = ''; |
|
411 | + } |
|
263 | 412 | $msg['speed'] = $data['speed']; |
264 | - if (isset($data['heading'])) $msg['track'] = $data['heading']; |
|
265 | - else $msg['track'] = ''; |
|
413 | + if (isset($data['heading'])) { |
|
414 | + $msg['track'] = $data['heading']; |
|
415 | + } else { |
|
416 | + $msg['track'] = ''; |
|
417 | + } |
|
266 | 418 | $msg['latitude'] = $data['latitude']; |
267 | 419 | $msg['longitude'] = $data['longitude']; |
268 | - if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate']; |
|
269 | - else $msg['verticalrate'] = ''; |
|
270 | - if (isset($data['squawk'])) $msg['squawk'] = $data['squawk']; |
|
271 | - else $msg['squawk'] = 0; |
|
420 | + if (isset($data['verticalrate'])) { |
|
421 | + $msg['verticalrate'] = $data['verticalrate']; |
|
422 | + } else { |
|
423 | + $msg['verticalrate'] = ''; |
|
424 | + } |
|
425 | + if (isset($data['squawk'])) { |
|
426 | + $msg['squawk'] = $data['squawk']; |
|
427 | + } else { |
|
428 | + $msg['squawk'] = 0; |
|
429 | + } |
|
272 | 430 | $msg['alert'] = 0; |
273 | 431 | $msg['emergency'] = 0; |
274 | 432 | $msg['SPI'] = 0; |
275 | - if (isset($data['ground'])) $msg['ground'] = 1; |
|
276 | - else $msg['ground'] = 0; |
|
433 | + if (isset($data['ground'])) { |
|
434 | + $msg['ground'] = 1; |
|
435 | + } else { |
|
436 | + $msg['ground'] = 0; |
|
437 | + } |
|
277 | 438 | $result[] = implode(',',$msg); |
278 | 439 | } |
279 | 440 | return $result; |
@@ -16,11 +16,15 @@ discard block |
||
16 | 16 | $Tracker = new Tracker(); |
17 | 17 | } |
18 | 18 | |
19 | -if (!isset($filter_name)) $filter_name = ''; |
|
19 | +if (!isset($filter_name)) { |
|
20 | + $filter_name = ''; |
|
21 | +} |
|
20 | 22 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
21 | 23 | if ($airline_icao == '' && isset($globalFilter)) { |
22 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
23 | -} |
|
24 | + if (isset($globalFilter['airline'])) { |
|
25 | + $airline_icao = $globalFilter['airline'][0]; |
|
26 | + } |
|
27 | + } |
|
24 | 28 | |
25 | 29 | require_once('header.php'); |
26 | 30 | include('statistics-sub-menu.php'); |
@@ -33,9 +37,13 @@ discard block |
||
33 | 37 | </div> |
34 | 38 | <p>'._("Below is a chart that plots the busiest day during the <strong>last 7 days</strong>.").'</p>'; |
35 | 39 | |
36 | -if ($type == 'aircraft') $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
|
37 | -elseif ($type == 'marine') $date_array = $Marine->countAllDatesLast7Days(); |
|
38 | -elseif ($type == 'tracker') $date_array = $Tracker->countAllDatesLast7Days(); |
|
40 | +if ($type == 'aircraft') { |
|
41 | + $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
|
42 | +} elseif ($type == 'marine') { |
|
43 | + $date_array = $Marine->countAllDatesLast7Days(); |
|
44 | +} elseif ($type == 'tracker') { |
|
45 | + $date_array = $Tracker->countAllDatesLast7Days(); |
|
46 | +} |
|
39 | 47 | if (count($date_array) == 0) { |
40 | 48 | print _("No data available"); |
41 | 49 | } else { |
@@ -61,9 +69,13 @@ discard block |
||
61 | 69 | } else { |
62 | 70 | print '<p>'._("Below are the <strong>Top 10</strong> most busiest dates.").'</p>'; |
63 | 71 | } |
64 | -if ($type == 'aircraft') $date_array = $Stats->countAllDates($airline_icao,$filter_name); |
|
65 | -elseif ($type == 'marine') $date_array = $Marine->countAllDates(); |
|
66 | -elseif ($type == 'tracker') $date_array = $Tracker->countAllDates(); |
|
72 | +if ($type == 'aircraft') { |
|
73 | + $date_array = $Stats->countAllDates($airline_icao,$filter_name); |
|
74 | +} elseif ($type == 'marine') { |
|
75 | + $date_array = $Marine->countAllDates(); |
|
76 | +} elseif ($type == 'tracker') { |
|
77 | + $date_array = $Tracker->countAllDates(); |
|
78 | +} |
|
67 | 79 | if (!empty($date_array)) |
68 | 80 | { |
69 | 81 | print '<div class="table-responsive">'; |
@@ -15,11 +15,15 @@ discard block |
||
15 | 15 | require_once('require/class.Tracker.php'); |
16 | 16 | $Tracker = new Tracker(); |
17 | 17 | } |
18 | -if (!isset($filter_name)) $filter_name = ''; |
|
18 | +if (!isset($filter_name)) { |
|
19 | + $filter_name = ''; |
|
20 | +} |
|
19 | 21 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
20 | 22 | if ($airline_icao == '' && isset($globalFilter)) { |
21 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
22 | -} |
|
23 | + if (isset($globalFilter['airline'])) { |
|
24 | + $airline_icao = $globalFilter['airline'][0]; |
|
25 | + } |
|
26 | + } |
|
23 | 27 | |
24 | 28 | require_once('header.php'); |
25 | 29 | include('statistics-sub-menu.php'); |
@@ -32,9 +36,13 @@ discard block |
||
32 | 36 | </div> |
33 | 37 | <p>'._("Below is a chart that plots the busiest day during the <strong>last month</strong>.").'</p>'; |
34 | 38 | |
35 | -if ($type == 'aircraft') $date_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
|
36 | -elseif ($type == 'marine') $date_array = $Marine->countAllDatesLastMonth(); |
|
37 | -elseif ($type == 'tracker') $date_array = $Tracker->countAllDatesLastMonth(); |
|
39 | +if ($type == 'aircraft') { |
|
40 | + $date_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
|
41 | +} elseif ($type == 'marine') { |
|
42 | + $date_array = $Marine->countAllDatesLastMonth(); |
|
43 | +} elseif ($type == 'tracker') { |
|
44 | + $date_array = $Tracker->countAllDatesLastMonth(); |
|
45 | +} |
|
38 | 46 | |
39 | 47 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
40 | 48 | $month_data = ''; |
@@ -75,8 +83,11 @@ discard block |
||
75 | 83 | print '<tr>'; |
76 | 84 | print '<td><strong>'.$i.'</strong></td>'; |
77 | 85 | print '<td>'; |
78 | - if ($type == 'aircraft') print '<a href="'.$globalURL.'/date/'.date('Y-m-d',strtotime($date_item['date_name'])).'">'.date("l F j, Y", strtotime($date_item['date_name'])).'</a>'; |
|
79 | - else print '<a href="'.$globalURL.'/'.$type.'/date/'.date('Y-m-d',strtotime($date_item['date_name'])).'">'.date("l F j, Y", strtotime($date_item['date_name'])).'</a>'; |
|
86 | + if ($type == 'aircraft') { |
|
87 | + print '<a href="'.$globalURL.'/date/'.date('Y-m-d',strtotime($date_item['date_name'])).'">'.date("l F j, Y", strtotime($date_item['date_name'])).'</a>'; |
|
88 | + } else { |
|
89 | + print '<a href="'.$globalURL.'/'.$type.'/date/'.date('Y-m-d',strtotime($date_item['date_name'])).'">'.date("l F j, Y", strtotime($date_item['date_name'])).'</a>'; |
|
90 | + } |
|
80 | 91 | print '</td>'; |
81 | 92 | print '<td>'; |
82 | 93 | print $date_item['date_count']; |
@@ -17,11 +17,15 @@ discard block |
||
17 | 17 | $title = _("Statistics").' - '._("Busiest Month of Last Year"); |
18 | 18 | |
19 | 19 | |
20 | -if (!isset($filter_name)) $filter_name = ''; |
|
20 | +if (!isset($filter_name)) { |
|
21 | + $filter_name = ''; |
|
22 | +} |
|
21 | 23 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
22 | 24 | if ($airline_icao == '' && isset($globalFilter)) { |
23 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
24 | -} |
|
25 | + if (isset($globalFilter['airline'])) { |
|
26 | + $airline_icao = $globalFilter['airline'][0]; |
|
27 | + } |
|
28 | + } |
|
25 | 29 | |
26 | 30 | require_once('header.php'); |
27 | 31 | include('statistics-sub-menu.php'); |
@@ -33,9 +37,13 @@ discard block |
||
33 | 37 | </div> |
34 | 38 | <p>'._("Below is a chart that plots the busiest month during the <strong>last year</strong>.").'</p>'; |
35 | 39 | |
36 | -if ($type == 'aircraft') $date_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
37 | -elseif ($type == 'marine') $date_array = $Marine->countAllMonthsLastYear(true); |
|
38 | -elseif ($type == 'tracker') $date_array = $Tracker->countAllMonthsLastYear(true); |
|
40 | +if ($type == 'aircraft') { |
|
41 | + $date_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
42 | +} elseif ($type == 'marine') { |
|
43 | + $date_array = $Marine->countAllMonthsLastYear(true); |
|
44 | +} elseif ($type == 'tracker') { |
|
45 | + $date_array = $Tracker->countAllMonthsLastYear(true); |
|
46 | +} |
|
39 | 47 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
40 | 48 | $year_data = ''; |
41 | 49 | $year_cnt = ''; |
@@ -53,9 +61,13 @@ discard block |
||
53 | 61 | axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "#"}},legend: { show: false }});'; |
54 | 62 | print '</script>'; |
55 | 63 | |
56 | -if ($type == 'aircraft') $date_array = $Stats->countAllMonths($airline_icao); |
|
57 | -elseif ($type == 'marine') $date_array = $Marine->countAllMonths(); |
|
58 | -elseif ($type == 'tracker') $date_array = $Tracker->countAllMonths(); |
|
64 | +if ($type == 'aircraft') { |
|
65 | + $date_array = $Stats->countAllMonths($airline_icao); |
|
66 | +} elseif ($type == 'marine') { |
|
67 | + $date_array = $Marine->countAllMonths(); |
|
68 | +} elseif ($type == 'tracker') { |
|
69 | + $date_array = $Tracker->countAllMonths(); |
|
70 | +} |
|
59 | 71 | |
60 | 72 | if (!empty($date_array)) |
61 | 73 | { |
@@ -4,7 +4,9 @@ discard block |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Stats = new Stats(); |
6 | 6 | |
7 | -if (!isset($filter_name)) $filter_name = ''; |
|
7 | +if (!isset($filter_name)) { |
|
8 | + $filter_name = ''; |
|
9 | +} |
|
8 | 10 | $type = 'aircraft'; |
9 | 11 | if (isset($_GET['marine'])) { |
10 | 12 | $type = 'marine'; |
@@ -21,8 +23,10 @@ discard block |
||
21 | 23 | } |
22 | 24 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
23 | 25 | if ($airline_icao == '' && isset($globalFilter)) { |
24 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
25 | -} |
|
26 | + if (isset($globalFilter['airline'])) { |
|
27 | + $airline_icao = $globalFilter['airline'][0]; |
|
28 | + } |
|
29 | + } |
|
26 | 30 | |
27 | 31 | require_once('header.php'); |
28 | 32 | include('statistics-sub-menu.php'); |
@@ -16,11 +16,15 @@ discard block |
||
16 | 16 | $Tracker = new Tracker(); |
17 | 17 | } |
18 | 18 | |
19 | -if (!isset($filter_name)) $filter_name = ''; |
|
19 | +if (!isset($filter_name)) { |
|
20 | + $filter_name = ''; |
|
21 | +} |
|
20 | 22 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
21 | 23 | if ($airline_icao == '' && isset($globalFilter)) { |
22 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
23 | -} |
|
24 | + if (isset($globalFilter['airline'])) { |
|
25 | + $airline_icao = $globalFilter['airline'][0]; |
|
26 | + } |
|
27 | + } |
|
24 | 28 | |
25 | 29 | require_once('header.php'); |
26 | 30 | include('statistics-sub-menu.php'); |
@@ -33,9 +37,13 @@ discard block |
||
33 | 37 | </div> |
34 | 38 | <p>'._("Below is a list of the most common <strong>time of day</strong>.").'</p>'; |
35 | 39 | |
36 | -if ($type == 'aircraft') $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
37 | -elseif ($type == 'marine') $hour_array = $Marine->countAllHours('hour',true); |
|
38 | -elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('hour',true); |
|
40 | +if ($type == 'aircraft') { |
|
41 | + $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
42 | +} elseif ($type == 'marine') { |
|
43 | + $hour_array = $Marine->countAllHours('hour',true); |
|
44 | +} elseif ($type == 'tracker') { |
|
45 | + $hour_array = $Tracker->countAllHours('hour',true); |
|
46 | +} |
|
39 | 47 | print '<div id="chartHour" class="chart" width="100%"></div><script>'; |
40 | 48 | $hour_data = ''; |
41 | 49 | $hour_cnt = ''; |
@@ -53,9 +61,13 @@ discard block |
||
53 | 61 | axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});'; |
54 | 62 | print '</script>'; |
55 | 63 | |
56 | -if ($type == 'aircraft') $hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name); |
|
57 | -elseif ($type == 'marine') $hour_array = $Marine->countAllHours('count',true); |
|
58 | -elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('count',true); |
|
64 | +if ($type == 'aircraft') { |
|
65 | + $hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name); |
|
66 | +} elseif ($type == 'marine') { |
|
67 | + $hour_array = $Marine->countAllHours('count',true); |
|
68 | +} elseif ($type == 'tracker') { |
|
69 | + $hour_array = $Tracker->countAllHours('count',true); |
|
70 | +} |
|
59 | 71 | if (!empty($hour_array)) |
60 | 72 | { |
61 | 73 | print '<div class="table-responsive">'; |
@@ -5,11 +5,15 @@ discard block |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Aircraft"); |
7 | 7 | |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 12 | if ($airline_icao == '' && isset($globalFilter)) { |
11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
12 | -} |
|
13 | + if (isset($globalFilter['airline'])) { |
|
14 | + $airline_icao = $globalFilter['airline'][0]; |
|
15 | + } |
|
16 | + } |
|
13 | 17 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
14 | 18 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
15 | 19 | |
@@ -28,9 +32,12 @@ discard block |
||
28 | 32 | $aircraft_data = ''; |
29 | 33 | foreach($aircraft_array as $aircraft_item) |
30 | 34 | { |
31 | - if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
32 | - else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
33 | -} |
|
35 | + if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') { |
|
36 | + $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
37 | + } else { |
|
38 | + $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
39 | + } |
|
40 | + } |
|
34 | 41 | $aircraft_data = substr($aircraft_data, 0, -1); |
35 | 42 | print 'var series = ['.$aircraft_data.'];'; |
36 | 43 | print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug; |
56 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo "Update last seen tracked data...\n"; |
|
58 | + } |
|
57 | 59 | foreach ($this->all_tracked as $key => $flight) { |
58 | 60 | if (isset($this->all_tracked[$key]['id'])) { |
59 | 61 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -66,13 +68,17 @@ discard block |
||
66 | 68 | public function del() { |
67 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
68 | 70 | // Delete old infos |
69 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
71 | + if ($globalDebug) { |
|
72 | + echo 'Delete old values and update latest data...'."\n"; |
|
73 | + } |
|
70 | 74 | foreach ($this->all_tracked as $key => $flight) { |
71 | 75 | if (isset($flight['lastupdate'])) { |
72 | 76 | if ($flight['lastupdate'] < (time()-3000)) { |
73 | 77 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
74 | 78 | if (isset($this->all_tracked[$key]['id'])) { |
75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
79 | + if ($globalDebug) { |
|
80 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + } |
|
76 | 82 | /* |
77 | 83 | $MarineLive = new MarineLive(); |
78 | 84 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -82,7 +88,9 @@ discard block |
||
82 | 88 | $Marine = new Marine($this->db); |
83 | 89 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
84 | 90 | $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']); |
85 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
91 | + if ($globalDebug && $result != 'success') { |
|
92 | + echo '!!! ERROR : '.$result."\n"; |
|
93 | + } |
|
86 | 94 | } |
87 | 95 | // Put in archive |
88 | 96 | // $Marine->db = null; |
@@ -96,7 +104,9 @@ discard block |
||
96 | 104 | |
97 | 105 | public function add($line) { |
98 | 106 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
99 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
107 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
108 | + $globalCoordMinChange = '0.02'; |
|
109 | + } |
|
100 | 110 | date_default_timezone_set('UTC'); |
101 | 111 | $dataFound = false; |
102 | 112 | $send = false; |
@@ -110,20 +120,30 @@ discard block |
||
110 | 120 | // Increment message number |
111 | 121 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
112 | 122 | $current_date = date('Y-m-d'); |
113 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
114 | - else $source = ''; |
|
115 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
123 | + if (isset($line['source_name'])) { |
|
124 | + $source = $line['source_name']; |
|
125 | + } else { |
|
126 | + $source = ''; |
|
127 | + } |
|
128 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
129 | + $source = $line['format_source']; |
|
130 | + } |
|
116 | 131 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
117 | 132 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
118 | 133 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
119 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
134 | + } else { |
|
135 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } |
|
120 | 137 | } |
121 | 138 | |
122 | 139 | |
123 | 140 | $Common = new Common(); |
124 | 141 | $AIS = new AIS(); |
125 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
126 | - else $id = trim($line['id']); |
|
142 | + if (!isset($line['id'])) { |
|
143 | + $id = trim($line['mmsi']); |
|
144 | + } else { |
|
145 | + $id = trim($line['id']); |
|
146 | + } |
|
127 | 147 | |
128 | 148 | if (!isset($this->all_tracked[$id])) { |
129 | 149 | $this->all_tracked[$id] = array(); |
@@ -131,10 +151,16 @@ discard block |
||
131 | 151 | $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' => '')); |
132 | 152 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
133 | 153 | if (!isset($line['id'])) { |
134 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
154 | + if (!isset($globalDaemon)) { |
|
155 | + $globalDaemon = TRUE; |
|
156 | + } |
|
135 | 157 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
136 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
158 | + } else { |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
160 | + } |
|
161 | + if ($globalAllTracked !== FALSE) { |
|
162 | + $dataFound = true; |
|
163 | + } |
|
138 | 164 | } |
139 | 165 | |
140 | 166 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -184,34 +210,49 @@ discard block |
||
184 | 210 | $Marine = new Marine($this->db); |
185 | 211 | $fromsource = NULL; |
186 | 212 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
187 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
213 | + if ($globalDebug && $result != 'success') { |
|
214 | + echo '!!! ERROR : '.$result."\n"; |
|
215 | + } |
|
188 | 216 | $Marine->db = null; |
189 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
217 | + if ($globalDebugTimeElapsed) { |
|
218 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
219 | + } |
|
190 | 220 | } |
191 | 221 | } |
192 | 222 | } |
193 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
223 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
225 | + } |
|
194 | 226 | } |
195 | 227 | |
196 | 228 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
197 | 229 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
198 | 230 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
199 | 231 | } else { |
200 | - 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"; |
|
201 | - 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"; |
|
232 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
233 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
234 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
235 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
236 | + } |
|
202 | 237 | return ''; |
203 | 238 | } |
204 | 239 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
205 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
240 | + if ($globalDebug) { |
|
241 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
242 | + } |
|
206 | 243 | return ''; |
207 | 244 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
208 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
245 | + if ($globalDebug) { |
|
246 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
247 | + } |
|
209 | 248 | return ''; |
210 | 249 | } elseif (!isset($line['datetime'])) { |
211 | 250 | date_default_timezone_set('UTC'); |
212 | 251 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
213 | 252 | } else { |
214 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
253 | + if ($globalDebug) { |
|
254 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
255 | + } |
|
215 | 256 | return ''; |
216 | 257 | } |
217 | 258 | |
@@ -224,14 +265,21 @@ discard block |
||
224 | 265 | if ($distance > 1000 && $distance < 10000) { |
225 | 266 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
226 | 267 | $speed = $speed*3.6; |
227 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
228 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
268 | + if ($speed < 1000) { |
|
269 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
270 | + } |
|
271 | + if ($globalDebug) { |
|
272 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
273 | + } |
|
229 | 274 | } |
230 | 275 | } |
231 | 276 | |
232 | 277 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
233 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
234 | - else unset($timediff); |
|
278 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
279 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
280 | + } else { |
|
281 | + unset($timediff); |
|
282 | + } |
|
235 | 283 | 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')))) { |
236 | 284 | 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'])) { |
237 | 285 | 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'])) { |
@@ -239,22 +287,32 @@ discard block |
||
239 | 287 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
240 | 288 | $this->all_tracked[$id]['putinarchive'] = true; |
241 | 289 | |
242 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
290 | + if ($globalDebug) { |
|
291 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
292 | + } |
|
243 | 293 | $timeelapsed = microtime(true); |
244 | 294 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
245 | 295 | $Marine = new Marine($this->db); |
246 | 296 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
247 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
297 | + if (!empty($all_country)) { |
|
298 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
299 | + } |
|
248 | 300 | $Marine->db = null; |
249 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
301 | + if ($globalDebugTimeElapsed) { |
|
302 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
303 | + } |
|
250 | 304 | } |
251 | 305 | $this->tmd = 0; |
252 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
306 | + if ($globalDebug) { |
|
307 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
308 | + } |
|
253 | 309 | } |
254 | 310 | } |
255 | 311 | |
256 | 312 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
257 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
313 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
314 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
315 | + } |
|
258 | 316 | 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') { |
259 | 317 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
260 | 318 | $dataFound = true; |
@@ -263,8 +321,12 @@ discard block |
||
263 | 321 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
264 | 322 | } |
265 | 323 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
266 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
267 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
324 | + if ($line['longitude'] > 180) { |
|
325 | + $line['longitude'] = $line['longitude'] - 360; |
|
326 | + } |
|
327 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
328 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
329 | + } |
|
268 | 330 | 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') { |
269 | 331 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
270 | 332 | $dataFound = true; |
@@ -282,7 +344,9 @@ discard block |
||
282 | 344 | } |
283 | 345 | } |
284 | 346 | if (isset($line['last_update']) && $line['last_update'] != '') { |
285 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
347 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
348 | + $dataFound = true; |
|
349 | + } |
|
286 | 350 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
287 | 351 | } |
288 | 352 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -312,15 +376,21 @@ discard block |
||
312 | 376 | } |
313 | 377 | |
314 | 378 | if (isset($line['heading']) && $line['heading'] != '') { |
315 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
379 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
380 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
381 | + } |
|
316 | 382 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
317 | 383 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
318 | 384 | //$dataFound = true; |
319 | 385 | } 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']) { |
320 | 386 | $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']); |
321 | 387 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
322 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
323 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
388 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
389 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
390 | + } |
|
391 | + if ($globalDebug) { |
|
392 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
393 | + } |
|
324 | 394 | } |
325 | 395 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
326 | 396 | |
@@ -332,23 +402,38 @@ discard block |
||
332 | 402 | 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'])) { |
333 | 403 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
334 | 404 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
335 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
405 | + if ($globalDebug) { |
|
406 | + echo "Check if aircraft is already in DB..."; |
|
407 | + } |
|
336 | 408 | $timeelapsed = microtime(true); |
337 | 409 | $MarineLive = new MarineLive($this->db); |
338 | 410 | if (isset($line['id'])) { |
339 | 411 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
340 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
412 | + if ($globalDebugTimeElapsed) { |
|
413 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
414 | + } |
|
341 | 415 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
342 | 416 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
417 | + if ($globalDebugTimeElapsed) { |
|
418 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + } |
|
344 | 420 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
345 | 421 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
347 | - } else $recent_ident = ''; |
|
422 | + if ($globalDebugTimeElapsed) { |
|
423 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
424 | + } |
|
425 | + } else { |
|
426 | + $recent_ident = ''; |
|
427 | + } |
|
348 | 428 | $MarineLive->db=null; |
349 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
350 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
351 | - } else $recent_ident = ''; |
|
429 | + if ($globalDebug && $recent_ident == '') { |
|
430 | + echo " Not in DB.\n"; |
|
431 | + } elseif ($globalDebug && $recent_ident != '') { |
|
432 | + echo " Already in DB.\n"; |
|
433 | + } |
|
434 | + } else { |
|
435 | + $recent_ident = ''; |
|
436 | + } |
|
352 | 437 | } else { |
353 | 438 | $recent_ident = ''; |
354 | 439 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -356,30 +441,44 @@ discard block |
||
356 | 441 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
357 | 442 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
358 | 443 | { |
359 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
444 | + if ($globalDebug) { |
|
445 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
446 | + } |
|
360 | 447 | //adds the spotter data for the archive |
361 | 448 | $highlight = ''; |
362 | - 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'))); |
|
449 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
450 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
451 | + } |
|
363 | 452 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
364 | 453 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
365 | 454 | $timeelapsed = microtime(true); |
366 | 455 | $Marine = new Marine($this->db); |
367 | 456 | $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']); |
368 | 457 | $Marine->db = null; |
369 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
370 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
458 | + if ($globalDebug && isset($result)) { |
|
459 | + echo $result."\n"; |
|
460 | + } |
|
461 | + if ($globalDebugTimeElapsed) { |
|
462 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
463 | + } |
|
371 | 464 | } |
372 | 465 | } |
373 | 466 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
374 | 467 | // Add source stat in DB |
375 | 468 | $Stats = new Stats($this->db); |
376 | 469 | if (!empty($this->stats)) { |
377 | - if ($globalDebug) echo 'Add source stats : '; |
|
470 | + if ($globalDebug) { |
|
471 | + echo 'Add source stats : '; |
|
472 | + } |
|
378 | 473 | foreach($this->stats as $date => $data) { |
379 | 474 | foreach($data as $source => $sourced) { |
380 | 475 | //print_r($sourced); |
381 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
382 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
476 | + if (isset($sourced['polar'])) { |
|
477 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
478 | + } |
|
479 | + if (isset($sourced['hist'])) { |
|
480 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
481 | + } |
|
383 | 482 | if (isset($sourced['msg'])) { |
384 | 483 | if (time() - $sourced['msg']['date'] > 10) { |
385 | 484 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -392,7 +491,9 @@ discard block |
||
392 | 491 | unset($this->stats[$date]); |
393 | 492 | } |
394 | 493 | } |
395 | - if ($globalDebug) echo 'Done'."\n"; |
|
494 | + if ($globalDebug) { |
|
495 | + echo 'Done'."\n"; |
|
496 | + } |
|
396 | 497 | } |
397 | 498 | $Stats->db = null; |
398 | 499 | } |
@@ -402,13 +503,17 @@ discard block |
||
402 | 503 | $this->all_tracked[$id]['addedMarine'] = 1; |
403 | 504 | //print_r($this->all_tracked[$id]); |
404 | 505 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
405 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
506 | + if ($globalDebug) { |
|
507 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
508 | + } |
|
406 | 509 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
407 | 510 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
408 | 511 | $MarineLive = new MarineLive($this->db); |
409 | 512 | $MarineLive->deleteLiveMarineData(); |
410 | 513 | $MarineLive->db=null; |
411 | - if ($globalDebug) echo " Done\n"; |
|
514 | + if ($globalDebug) { |
|
515 | + echo " Done\n"; |
|
516 | + } |
|
412 | 517 | } |
413 | 518 | $this->last_delete = time(); |
414 | 519 | } |
@@ -434,15 +539,21 @@ discard block |
||
434 | 539 | |
435 | 540 | if (!$ignoreImport) { |
436 | 541 | 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'])) { |
437 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
542 | + if ($globalDebug) { |
|
543 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
544 | + } |
|
438 | 545 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
439 | 546 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
440 | 547 | $timeelapsed = microtime(true); |
441 | 548 | $MarineLive = new MarineLive($this->db); |
442 | 549 | $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']); |
443 | 550 | $MarineLive->db = null; |
444 | - if ($globalDebug) echo $result."\n"; |
|
445 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
551 | + if ($globalDebug) { |
|
552 | + echo $result."\n"; |
|
553 | + } |
|
554 | + if ($globalDebugTimeElapsed) { |
|
555 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
556 | + } |
|
446 | 557 | } |
447 | 558 | } |
448 | 559 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -454,7 +565,9 @@ discard block |
||
454 | 565 | |
455 | 566 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
456 | 567 | $source = $this->all_tracked[$id]['source_name']; |
457 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
568 | + if ($source == '') { |
|
569 | + $source = $this->all_tracked[$id]['format_source']; |
|
570 | + } |
|
458 | 571 | if (!isset($this->source_location[$source])) { |
459 | 572 | $Location = new Source(); |
460 | 573 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -475,7 +588,9 @@ discard block |
||
475 | 588 | $stats_heading = round($stats_heading/22.5); |
476 | 589 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
477 | 590 | $current_date = date('Y-m-d'); |
478 | - if ($stats_heading == 16) $stats_heading = 0; |
|
591 | + if ($stats_heading == 16) { |
|
592 | + $stats_heading = 0; |
|
593 | + } |
|
479 | 594 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
480 | 595 | for ($i=0;$i<=15;$i++) { |
481 | 596 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -493,7 +608,9 @@ discard block |
||
493 | 608 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
494 | 609 | end($this->stats[$current_date][$source]['hist']); |
495 | 610 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
496 | - } else $mini = 0; |
|
611 | + } else { |
|
612 | + $mini = 0; |
|
613 | + } |
|
497 | 614 | for ($i=$mini;$i<=$distance;$i+=10) { |
498 | 615 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
499 | 616 | } |
@@ -505,19 +622,27 @@ discard block |
||
505 | 622 | |
506 | 623 | |
507 | 624 | $this->all_tracked[$id]['lastupdate'] = time(); |
508 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
509 | - } 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"; |
|
625 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
626 | + $send = true; |
|
627 | + } |
|
628 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
629 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
630 | + } |
|
510 | 631 | //$this->del(); |
511 | 632 | |
512 | 633 | |
513 | 634 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
514 | 635 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
515 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
636 | + if ($globalDebug) { |
|
637 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
638 | + } |
|
516 | 639 | $MarineLive = new MarineLive($this->db); |
517 | 640 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
518 | 641 | $MarineLive->db = null; |
519 | 642 | //MarineLive->deleteLiveMarineData(); |
520 | - if ($globalDebug) echo " Done\n"; |
|
643 | + if ($globalDebug) { |
|
644 | + echo " Done\n"; |
|
645 | + } |
|
521 | 646 | } |
522 | 647 | $this->last_delete_hourly = time(); |
523 | 648 | } |
@@ -526,7 +651,9 @@ discard block |
||
526 | 651 | //$ignoreImport = false; |
527 | 652 | } |
528 | 653 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
529 | - if ($send) return $this->all_tracked[$id]; |
|
654 | + if ($send) { |
|
655 | + return $this->all_tracked[$id]; |
|
656 | + } |
|
530 | 657 | } |
531 | 658 | } |
532 | 659 | } |
@@ -8,7 +8,9 @@ |
||
8 | 8 | $atcid = filter_input(INPUT_GET,'atcid',FILTER_SANITIZE_NUMBER_INT); |
9 | 9 | $atcident = filter_input(INPUT_GET,'atcident',FILTER_SANITIZE_STRING); |
10 | 10 | $atc_data = $ATC->getById($atcid); |
11 | - if (!isset($atc_data[0])) $atc_data = $ATC->getByIdent($atcident); |
|
11 | + if (!isset($atc_data[0])) { |
|
12 | + $atc_data = $ATC->getByIdent($atcident); |
|
13 | + } |
|
12 | 14 | ?> |
13 | 15 | <div class="alldetails"> |
14 | 16 | <button type="button" class="close">×</button> |