@@ -102,26 +102,36 @@ discard block |
||
102 | 102 | |
103 | 103 | /* Check that end was found and body has at least one byte. */ |
104 | 104 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
105 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
105 | + if ($globalDebug) { |
|
106 | + echo '!!! APRS invalid : '.$input."\n"; |
|
107 | + } |
|
106 | 108 | return false; |
107 | 109 | } |
108 | 110 | |
109 | - if ($debug) echo 'input : '.$input."\n"; |
|
111 | + if ($debug) { |
|
112 | + echo 'input : '.$input."\n"; |
|
113 | + } |
|
110 | 114 | /* Save header and body. */ |
111 | 115 | $body = substr($input,$splitpos+1,$input_len); |
112 | 116 | $body_len = strlen($body); |
113 | 117 | $header = substr($input,0,$splitpos); |
114 | 118 | //$header_len = strlen($header); |
115 | - if ($debug) echo 'header : '.$header."\n"; |
|
119 | + if ($debug) { |
|
120 | + echo 'header : '.$header."\n"; |
|
121 | + } |
|
116 | 122 | |
117 | 123 | /* Parse source, target and path. */ |
118 | 124 | //FLRDF0A52>APRS,qAS,LSTB |
119 | 125 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
120 | 126 | $ident = $matches[1]; |
121 | 127 | $all_elements = $matches[2]; |
122 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
128 | + if ($debug) { |
|
129 | + echo 'ident : '.$ident."\n"; |
|
130 | + } |
|
123 | 131 | $result['ident'] = $ident; |
124 | - } else return false; |
|
132 | + } else { |
|
133 | + return false; |
|
134 | + } |
|
125 | 135 | $elements = explode(',',$all_elements); |
126 | 136 | $source = end($elements); |
127 | 137 | $result['source'] = $source; |
@@ -130,7 +140,9 @@ discard block |
||
130 | 140 | //echo "ok"; |
131 | 141 | //if ($element == 'TCPIP*') return false; |
132 | 142 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
133 | - if ($debug) echo 'element : '.$element."\n"; |
|
143 | + if ($debug) { |
|
144 | + echo 'element : '.$element."\n"; |
|
145 | + } |
|
134 | 146 | return false; |
135 | 147 | } |
136 | 148 | /* |
@@ -143,7 +155,9 @@ discard block |
||
143 | 155 | } |
144 | 156 | |
145 | 157 | $type = substr($body,0,1); |
146 | - if ($debug) echo 'type : '.$type."\n"; |
|
158 | + if ($debug) { |
|
159 | + echo 'type : '.$type."\n"; |
|
160 | + } |
|
147 | 161 | if ($type == ';') { |
148 | 162 | $result['ident'] = trim(substr($body,1,9)); |
149 | 163 | } elseif ($type == ',') { |
@@ -213,7 +227,9 @@ discard block |
||
213 | 227 | //$symbol_table = $matches[4]; |
214 | 228 | $lat = intval($lat_deg); |
215 | 229 | $lon = intval($lon_deg); |
216 | - if ($lat > 89 || $lon > 179) return false; |
|
230 | + if ($lat > 89 || $lon > 179) { |
|
231 | + return false; |
|
232 | + } |
|
217 | 233 | |
218 | 234 | /* |
219 | 235 | $tmp_5b = str_replace('.','',$lat_min); |
@@ -223,8 +239,12 @@ discard block |
||
223 | 239 | */ |
224 | 240 | $latitude = $lat + floatval($lat_min)/60; |
225 | 241 | $longitude = $lon + floatval($lon_min)/60; |
226 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
227 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
242 | + if ($sind == 'S') { |
|
243 | + $latitude = 0-$latitude; |
|
244 | + } |
|
245 | + if ($wind == 'W') { |
|
246 | + $longitude = 0-$longitude; |
|
247 | + } |
|
228 | 248 | $result['latitude'] = $latitude; |
229 | 249 | $result['longitude'] = $longitude; |
230 | 250 | $body_parse = substr($body_parse,18); |
@@ -257,7 +277,9 @@ discard block |
||
257 | 277 | //echo $body_parse; |
258 | 278 | if ($type != ';') { |
259 | 279 | $result['symbol_code'] = $symbol_code; |
260 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
280 | + if (isset($this->symbols[$symbol_code])) { |
|
281 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
282 | + } |
|
261 | 283 | if ($symbol_code != '_') { |
262 | 284 | } |
263 | 285 | //$body_parse = substr($body_parse,1); |
@@ -268,7 +290,9 @@ discard block |
||
268 | 290 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
269 | 291 | $course = substr($body_parse,0,3); |
270 | 292 | $tmp_s = intval($course); |
271 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
293 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
294 | + $result['heading'] = intval($course); |
|
295 | + } |
|
272 | 296 | $speed = substr($body_parse,4,3); |
273 | 297 | if ($speed != '...') { |
274 | 298 | $result['speed'] = round($speed*1.852); |
@@ -306,10 +330,16 @@ discard block |
||
306 | 330 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
307 | 331 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
308 | 332 | |
309 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
310 | - else $result['latitude'] += $lat_off; |
|
311 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
312 | - else $result['longitude'] += $lon_off; |
|
333 | + if ($result['latitude'] < 0) { |
|
334 | + $result['latitude'] -= $lat_off; |
|
335 | + } else { |
|
336 | + $result['latitude'] += $lat_off; |
|
337 | + } |
|
338 | + if ($result['longitude'] < 0) { |
|
339 | + $result['longitude'] -= $lon_off; |
|
340 | + } else { |
|
341 | + $result['longitude'] += $lon_off; |
|
342 | + } |
|
313 | 343 | } |
314 | 344 | $body_parse = substr($body_parse,6); |
315 | 345 | } |
@@ -323,27 +353,48 @@ discard block |
||
323 | 353 | $address = substr($id,2); |
324 | 354 | //print_r($matches); |
325 | 355 | $addressType = (intval(substr($id,0,2),16))&3; |
326 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
327 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
328 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
329 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
356 | + if ($addressType == 0) { |
|
357 | + $result['addresstype'] = "RANDOM"; |
|
358 | + } elseif ($addressType == 1) { |
|
359 | + $result['addresstype'] = "ICAO"; |
|
360 | + } elseif ($addressType == 2) { |
|
361 | + $result['addresstype'] = "FLARM"; |
|
362 | + } elseif ($addressType == 3) { |
|
363 | + $result['addresstype'] = "OGN"; |
|
364 | + } |
|
330 | 365 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
331 | 366 | $result['aircrafttype_code'] = $aircraftType; |
332 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
333 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
334 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
335 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
336 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
337 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
338 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
339 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
340 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
341 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
342 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
343 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
344 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
345 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
346 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
367 | + if ($aircraftType == 0) { |
|
368 | + $result['aircrafttype'] = "UNKNOWN"; |
|
369 | + } elseif ($aircraftType == 1) { |
|
370 | + $result['aircrafttype'] = "GLIDER"; |
|
371 | + } elseif ($aircraftType == 2) { |
|
372 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
373 | + } elseif ($aircraftType == 3) { |
|
374 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
375 | + } elseif ($aircraftType == 4) { |
|
376 | + $result['aircrafttype'] = "PARACHUTE"; |
|
377 | + } elseif ($aircraftType == 5) { |
|
378 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
379 | + } elseif ($aircraftType == 6) { |
|
380 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
381 | + } elseif ($aircraftType == 7) { |
|
382 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
383 | + } elseif ($aircraftType == 8) { |
|
384 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
385 | + } elseif ($aircraftType == 9) { |
|
386 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
387 | + } elseif ($aircraftType == 10) { |
|
388 | + $result['aircrafttype'] = "UFO"; |
|
389 | + } elseif ($aircraftType == 11) { |
|
390 | + $result['aircrafttype'] = "BALLOON"; |
|
391 | + } elseif ($aircraftType == 12) { |
|
392 | + $result['aircrafttype'] = "AIRSHIP"; |
|
393 | + } elseif ($aircraftType == 13) { |
|
394 | + $result['aircrafttype'] = "UAV"; |
|
395 | + } elseif ($aircraftType == 15) { |
|
396 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
397 | + } |
|
347 | 398 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
348 | 399 | $result['stealth'] = $stealth; |
349 | 400 | $result['address'] = $address; |
@@ -383,13 +434,21 @@ discard block |
||
383 | 434 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
384 | 435 | } |
385 | 436 | } |
386 | - } else $result['comment'] = trim($body_parse); |
|
437 | + } else { |
|
438 | + $result['comment'] = trim($body_parse); |
|
439 | + } |
|
387 | 440 | |
388 | 441 | } |
389 | 442 | //} |
390 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
391 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
392 | - if ($debug) print_r($result); |
|
443 | + if (isset($result['latitude'])) { |
|
444 | + $result['latitude'] = round($result['latitude'],4); |
|
445 | + } |
|
446 | + if (isset($result['longitude'])) { |
|
447 | + $result['longitude'] = round($result['longitude'],4); |
|
448 | + } |
|
449 | + if ($debug) { |
|
450 | + print_r($result); |
|
451 | + } |
|
393 | 452 | return $result; |
394 | 453 | } |
395 | 454 | } |