Completed
Push — master ( 57ec45...7a0770 )
by Yannick
33:58
created
require/class.AIS.php 1 patch
Braces   +331 added lines, -143 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 			$temp += 1;
36 36
 			$flat = (float)($temp / (60.0 * 10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else {
39
+			$flat = (float)($temp / (60.0 * 10000.0));
40
+		}
39 41
 		return $flat; // float
40 42
 	}
41 43
 
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
 			$temp += 1;
48 50
 			$flon = (float)($temp / (60.0 * 10000.0));
49 51
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
52
+		} else {
53
+			$flon = (float)($temp / (60.0 * 10000.0));
54
+		}
51 55
 		return $flon;
52 56
 	}
53 57
 
@@ -70,10 +74,8 @@  discard block
 block discarded – undo
70 74
     */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73
-		if ($ascii < 48) { }
74
-		else {
75
-			if($ascii>119) { }
76
-			else {
77
+		if ($ascii < 48) { } else {
78
+			if($ascii>119) { } else {
77 79
 				if ($ascii>87 && $ascii<96) ;
78 80
 				else {
79 81
 					$ascii=$ascii+40;
@@ -175,7 +177,9 @@  discard block
 block discarded – undo
175 177
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176 178
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177 179
 			$ro->heading = bindec(substr($_aisdata,124,9));
178
-			if ($ro->heading == 511) $ro->heading = '';
180
+			if ($ro->heading == 511) {
181
+				$ro->heading = '';
182
+			}
179 183
 			$ro->cls = 2; // class B
180 184
 		} else if ($ro->id == 19) {
181 185
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -185,7 +189,9 @@  discard block
 block discarded – undo
185 189
 			$ro->name = $this->binchar($_aisdata,143,120);
186 190
 			$ro->cls = 2; // class B
187 191
 			$ro->heading = bindec(substr($_aisdata,124,9));
188
-			if ($ro->heading == 511) $ro->heading = '';
192
+			if ($ro->heading == 511) {
193
+				$ro->heading = '';
194
+			}
189 195
 			$ro->typeid = bindec(substr($_aisdata,263,8));
190 196
 			$ro->type = $this->getShipType($ro->typeid);
191 197
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -216,9 +222,13 @@  discard block
 block discarded – undo
216 222
 			$ro->cls = 2; // class B
217 223
 		} else if ($ro->id == 27) {
218 224
 			$ro->cog = bindec(substr($_aisdata,85,9));
219
-			if ($ro->cog == 511) $ro->cog = 0.0;
225
+			if ($ro->cog == 511) {
226
+				$ro->cog = 0.0;
227
+			}
220 228
 			$ro->sog = bindec(substr($_aisdata,79,6));
221
-			if ($ro->sog == 63) $ro->sog = 0.0;
229
+			if ($ro->sog == 63) {
230
+				$ro->sog = 0.0;
231
+			}
222 232
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223 233
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
224 234
 			$ro->cls = 1; // class A
@@ -267,88 +277,171 @@  discard block
 block discarded – undo
267 277
 	}
268 278
 	
269 279
 	public function getShipType($code) {
270
-		if ($code == 0) return 'Not available (default)';
271
-		elseif ($code >= 1 && $code <= 19) return 'Reserved for future use';
272
-		elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type';
273
-		elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A';
274
-		elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B';
275
-		elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C';
276
-		elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D';
277
-		elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use';
278
-		elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use';
279
-		elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use';
280
-		elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use';
281
-		elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use';
282
-		elseif ($code == 30) return 'Fishing';
283
-		elseif ($code == 31) return 'Towing';
284
-		elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m';
285
-		elseif ($code == 33) return 'Dredging or underwater ops';
286
-		elseif ($code == 34) return 'Diving ops';
287
-		elseif ($code == 35) return 'Military ops';
288
-		elseif ($code == 36) return 'Sailing';
289
-		elseif ($code == 37) return 'Pleasure Craft';
290
-		elseif ($code == 38) return 'Reserved';
291
-		elseif ($code == 39) return 'Reserved';
292
-		elseif ($code == 40) return 'High speed craft (HSC), all ships of this type';
293
-		elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A';
294
-		elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B';
295
-		elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C';
296
-		elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D';
297
-		elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use';
298
-		elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use';
299
-		elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use';
300
-		elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use';
301
-		elseif ($code == 49) return 'High speed craft (HSC), No additional information';
302
-		elseif ($code == 50) return 'Pilot Vessel';
303
-		elseif ($code == 51) return 'Search and Rescue vessel';
304
-		elseif ($code == 52) return 'Tug';
305
-		elseif ($code == 53) return 'Port Tender';
306
-		elseif ($code == 54) return 'Anti-pollution equipment';
307
-		elseif ($code == 55) return 'Law Enforcement';
308
-		elseif ($code == 56) return 'Spare - Local Vessel';
309
-		elseif ($code == 57) return 'Spare - Local Vessel';
310
-		elseif ($code == 58) return 'Medical Transport';
311
-		elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18';
312
-		elseif ($code == 60) return 'Passenger, all ships of this type';
313
-		elseif ($code == 61) return 'Passenger, Hazardous category A';
314
-		elseif ($code == 62) return 'Passenger, Hazardous category B';
315
-		elseif ($code == 63) return 'Passenger, Hazardous category C';
316
-		elseif ($code == 64) return 'Passenger, Hazardous category D';
317
-		elseif ($code == 65) return 'Passenger, Reserved for future use';
318
-		elseif ($code == 66) return 'Passenger, Reserved for future use';
319
-		elseif ($code == 67) return 'Passenger, Reserved for future use';
320
-		elseif ($code == 68) return 'Passenger, Reserved for future use';
321
-		elseif ($code == 69) return 'Passenger, No additional information';
322
-		elseif ($code == 70) return 'Cargo, all ships of this type';
323
-		elseif ($code == 71) return 'Cargo, Hazardous category A';
324
-		elseif ($code == 72) return 'Cargo, Hazardous category B';
325
-		elseif ($code == 73) return 'Cargo, Hazardous category C';
326
-		elseif ($code == 74) return 'Cargo, Hazardous category D';
327
-		elseif ($code == 75) return 'Cargo, Reserved for future use';
328
-		elseif ($code == 76) return 'Cargo, Reserved for future use';
329
-		elseif ($code == 77) return 'Cargo, Reserved for future use';
330
-		elseif ($code == 78) return 'Cargo, Reserved for future use';
331
-		elseif ($code == 79) return 'Cargo, No additional information';
332
-		elseif ($code == 80) return 'Tanker, all ships of this type';
333
-		elseif ($code == 81) return 'Tanker, Hazardous category A';
334
-		elseif ($code == 82) return 'Tanker, Hazardous category B';
335
-		elseif ($code == 83) return 'Tanker, Hazardous category C';
336
-		elseif ($code == 84) return 'Tanker, Hazardous category D';
337
-		elseif ($code == 85) return 'Tanker, Reserved for future use';
338
-		elseif ($code == 86) return 'Tanker, Reserved for future use';
339
-		elseif ($code == 87) return 'Tanker, Reserved for future use';
340
-		elseif ($code == 88) return 'Tanker, Reserved for future use';
341
-		elseif ($code == 89) return 'Tanker, No additional information';
342
-		elseif ($code == 90) return 'Other Type, all ships of this type';
343
-		elseif ($code == 91) return 'Other Type, Hazardous category A';
344
-		elseif ($code == 92) return 'Other Type, Hazardous category B';
345
-		elseif ($code == 93) return 'Other Type, Hazardous category C';
346
-		elseif ($code == 94) return 'Other Type, Hazardous category D';
347
-		elseif ($code == 95) return 'Other Type, Reserved for future use';
348
-		elseif ($code == 96) return 'Other Type, Reserved for future use';
349
-		elseif ($code == 97) return 'Other Type, Reserved for future use';
350
-		elseif ($code == 98) return 'Other Type, Reserved for future use';
351
-		elseif ($code == 99) return 'Other Type, no additional information';
280
+		if ($code == 0) {
281
+			return 'Not available (default)';
282
+		} elseif ($code >= 1 && $code <= 19) {
283
+			return 'Reserved for future use';
284
+		} elseif ($code == 20) {
285
+			return 'Wing in ground (WIG), all ships of this type';
286
+		} elseif ($code == 21) {
287
+			return 'Wing in ground (WIG), Hazardous category A';
288
+		} elseif ($code == 22) {
289
+			return 'Wing in ground (WIG), Hazardous category B';
290
+		} elseif ($code == 23) {
291
+			return 'Wing in ground (WIG), Hazardous category C';
292
+		} elseif ($code == 24) {
293
+			return 'Wing in ground (WIG), Hazardous category D';
294
+		} elseif ($code == 25) {
295
+			return 'Wing in ground (WIG), Reserved for future use';
296
+		} elseif ($code == 26) {
297
+			return 'Wing in ground (WIG), Reserved for future use';
298
+		} elseif ($code == 27) {
299
+			return 'Wing in ground (WIG), Reserved for future use';
300
+		} elseif ($code == 28) {
301
+			return 'Wing in ground (WIG), Reserved for future use';
302
+		} elseif ($code == 29) {
303
+			return 'Wing in ground (WIG), Reserved for future use';
304
+		} elseif ($code == 30) {
305
+			return 'Fishing';
306
+		} elseif ($code == 31) {
307
+			return 'Towing';
308
+		} elseif ($code == 32) {
309
+			return 'Towing: length exceeds 200m or breadth exceeds 25m';
310
+		} elseif ($code == 33) {
311
+			return 'Dredging or underwater ops';
312
+		} elseif ($code == 34) {
313
+			return 'Diving ops';
314
+		} elseif ($code == 35) {
315
+			return 'Military ops';
316
+		} elseif ($code == 36) {
317
+			return 'Sailing';
318
+		} elseif ($code == 37) {
319
+			return 'Pleasure Craft';
320
+		} elseif ($code == 38) {
321
+			return 'Reserved';
322
+		} elseif ($code == 39) {
323
+			return 'Reserved';
324
+		} elseif ($code == 40) {
325
+			return 'High speed craft (HSC), all ships of this type';
326
+		} elseif ($code == 41) {
327
+			return 'High speed craft (HSC), Hazardous category A';
328
+		} elseif ($code == 42) {
329
+			return 'High speed craft (HSC), Hazardous category B';
330
+		} elseif ($code == 43) {
331
+			return 'High speed craft (HSC), Hazardous category C';
332
+		} elseif ($code == 44) {
333
+			return 'High speed craft (HSC), Hazardous category D';
334
+		} elseif ($code == 45) {
335
+			return 'High speed craft (HSC), Reserved for future use';
336
+		} elseif ($code == 46) {
337
+			return 'High speed craft (HSC), Reserved for future use';
338
+		} elseif ($code == 47) {
339
+			return 'High speed craft (HSC), Reserved for future use';
340
+		} elseif ($code == 48) {
341
+			return 'High speed craft (HSC), Reserved for future use';
342
+		} elseif ($code == 49) {
343
+			return 'High speed craft (HSC), No additional information';
344
+		} elseif ($code == 50) {
345
+			return 'Pilot Vessel';
346
+		} elseif ($code == 51) {
347
+			return 'Search and Rescue vessel';
348
+		} elseif ($code == 52) {
349
+			return 'Tug';
350
+		} elseif ($code == 53) {
351
+			return 'Port Tender';
352
+		} elseif ($code == 54) {
353
+			return 'Anti-pollution equipment';
354
+		} elseif ($code == 55) {
355
+			return 'Law Enforcement';
356
+		} elseif ($code == 56) {
357
+			return 'Spare - Local Vessel';
358
+		} elseif ($code == 57) {
359
+			return 'Spare - Local Vessel';
360
+		} elseif ($code == 58) {
361
+			return 'Medical Transport';
362
+		} elseif ($code == 59) {
363
+			return 'Noncombatant ship according to RR Resolution No. 18';
364
+		} elseif ($code == 60) {
365
+			return 'Passenger, all ships of this type';
366
+		} elseif ($code == 61) {
367
+			return 'Passenger, Hazardous category A';
368
+		} elseif ($code == 62) {
369
+			return 'Passenger, Hazardous category B';
370
+		} elseif ($code == 63) {
371
+			return 'Passenger, Hazardous category C';
372
+		} elseif ($code == 64) {
373
+			return 'Passenger, Hazardous category D';
374
+		} elseif ($code == 65) {
375
+			return 'Passenger, Reserved for future use';
376
+		} elseif ($code == 66) {
377
+			return 'Passenger, Reserved for future use';
378
+		} elseif ($code == 67) {
379
+			return 'Passenger, Reserved for future use';
380
+		} elseif ($code == 68) {
381
+			return 'Passenger, Reserved for future use';
382
+		} elseif ($code == 69) {
383
+			return 'Passenger, No additional information';
384
+		} elseif ($code == 70) {
385
+			return 'Cargo, all ships of this type';
386
+		} elseif ($code == 71) {
387
+			return 'Cargo, Hazardous category A';
388
+		} elseif ($code == 72) {
389
+			return 'Cargo, Hazardous category B';
390
+		} elseif ($code == 73) {
391
+			return 'Cargo, Hazardous category C';
392
+		} elseif ($code == 74) {
393
+			return 'Cargo, Hazardous category D';
394
+		} elseif ($code == 75) {
395
+			return 'Cargo, Reserved for future use';
396
+		} elseif ($code == 76) {
397
+			return 'Cargo, Reserved for future use';
398
+		} elseif ($code == 77) {
399
+			return 'Cargo, Reserved for future use';
400
+		} elseif ($code == 78) {
401
+			return 'Cargo, Reserved for future use';
402
+		} elseif ($code == 79) {
403
+			return 'Cargo, No additional information';
404
+		} elseif ($code == 80) {
405
+			return 'Tanker, all ships of this type';
406
+		} elseif ($code == 81) {
407
+			return 'Tanker, Hazardous category A';
408
+		} elseif ($code == 82) {
409
+			return 'Tanker, Hazardous category B';
410
+		} elseif ($code == 83) {
411
+			return 'Tanker, Hazardous category C';
412
+		} elseif ($code == 84) {
413
+			return 'Tanker, Hazardous category D';
414
+		} elseif ($code == 85) {
415
+			return 'Tanker, Reserved for future use';
416
+		} elseif ($code == 86) {
417
+			return 'Tanker, Reserved for future use';
418
+		} elseif ($code == 87) {
419
+			return 'Tanker, Reserved for future use';
420
+		} elseif ($code == 88) {
421
+			return 'Tanker, Reserved for future use';
422
+		} elseif ($code == 89) {
423
+			return 'Tanker, No additional information';
424
+		} elseif ($code == 90) {
425
+			return 'Other Type, all ships of this type';
426
+		} elseif ($code == 91) {
427
+			return 'Other Type, Hazardous category A';
428
+		} elseif ($code == 92) {
429
+			return 'Other Type, Hazardous category B';
430
+		} elseif ($code == 93) {
431
+			return 'Other Type, Hazardous category C';
432
+		} elseif ($code == 94) {
433
+			return 'Other Type, Hazardous category D';
434
+		} elseif ($code == 95) {
435
+			return 'Other Type, Reserved for future use';
436
+		} elseif ($code == 96) {
437
+			return 'Other Type, Reserved for future use';
438
+		} elseif ($code == 97) {
439
+			return 'Other Type, Reserved for future use';
440
+		} elseif ($code == 98) {
441
+			return 'Other Type, Reserved for future use';
442
+		} elseif ($code == 99) {
443
+			return 'Other Type, no additional information';
444
+		}
352 445
 	}
353 446
 
354 447
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -386,19 +479,34 @@  discard block
 block discarded – undo
386 479
 		// assume 1st ! is valid
387 480
 		// find * ensure that it is at correct position
388 481
 		$end = strrpos ( $rawdata , '*' );
389
-		if ($end === FALSE) return -1; // check for NULLS!!!
482
+		if ($end === FALSE) {
483
+			return -1;
484
+		}
485
+		// check for NULLS!!!
390 486
 		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
487
+		if ( strlen($cs) != 2 ) {
488
+			return -1;
489
+		}
490
+		// correct cs length
392 491
 		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
492
+		for ( $alias=1; $alias<$end; $alias++) {
493
+			$chksum ^= ord( $rawdata[$alias] );
494
+		}
495
+		// perform XOR for NMEA checksum
394 496
 		if ( $chksum == $dcs ) { // NMEA checksum pass
395 497
 			$pcs = explode(',', $rawdata);
396 498
 			// !AI??? identifier
397 499
 			$num_seq = (int)$pcs[1]; // number of sequences
398 500
 			$seq = (int)$pcs[2]; // get sequence
399 501
 			// get msg sequence id
400
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
401
-			else $msg_sid = (int)$pcs[3]; // multipart message
502
+			if ($pcs[3] == '') {
503
+				$msg_sid = -1;
504
+			}
505
+			// non-multipart message, set to -1
506
+			else {
507
+				$msg_sid = (int)$pcs[3];
508
+			}
509
+			// multipart message
402 510
 			$ais_ch = $pcs[4]; // get AIS channel
403 511
 			// message sequence checking
404 512
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -459,10 +567,18 @@  discard block
 block discarded – undo
459 567
 				//DEBUG echo "[$start $end $tst]\n";
460 568
 				$result = $this->process_ais_raw( $tst, "" );
461 569
 				$last_pos = $end + 1;
462
-			} else break;
570
+			} else {
571
+				break;
572
+			}
573
+		}
574
+		if ($last_pos > 0) {
575
+			$cbuf = substr($cbuf, $last_pos);
576
+		}
577
+		// move...
578
+		if (strlen($cbuf) > 1024) {
579
+			$cbuf = "";
463 580
 		}
464
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
465
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
581
+		// prevent overflow simple mode...
466 582
 		return $result;
467 583
 	}
468 584
 
@@ -482,7 +598,9 @@  discard block
 block discarded – undo
482 598
 		if ($lat<0.0) {
483 599
 			$lat = -$lat;
484 600
 			$neg=true;
485
-		} else $neg=false;
601
+		} else {
602
+			$neg=false;
603
+		}
486 604
 		$latd = 0x00000000;
487 605
 		$latd = intval ($lat * 600000.0);
488 606
 		if ($neg==true) {
@@ -498,7 +616,9 @@  discard block
 block discarded – undo
498 616
 		if ($lon<0.0) {
499 617
 			$lon = -$lon;
500 618
 			$neg=true;
501
-		} else $neg=false;
619
+		} else {
620
+			$neg=false;
621
+		}
502 622
 		$lond = 0x00000000;
503 623
 		$lond = intval ($lon * 600000.0);
504 624
 		if ($neg==true) {
@@ -511,9 +631,14 @@  discard block
 block discarded – undo
511 631
 
512 632
 	private function char2bin($name, $max_len) {
513 633
 		$len = strlen($name);
514
-		if ($len > $max_len) $name = substr($name,0,$max_len);
515
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
516
-		else $pad = '';
634
+		if ($len > $max_len) {
635
+			$name = substr($name,0,$max_len);
636
+		}
637
+		if ($len < $max_len) {
638
+			$pad = str_repeat('0', ($max_len - $len) * 6);
639
+		} else {
640
+			$pad = '';
641
+		}
517 642
 		$rv = '';
518 643
 		$ais_chars = array(
519 644
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -526,9 +651,12 @@  discard block
 block discarded – undo
526 651
 		);
527 652
 		// "
528 653
 		$_a = str_split($name);
529
-		if ($_a) foreach ($_a as $_1) {
654
+		if ($_a) {
655
+			foreach ($_a as $_1) {
530 656
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
531
-			else $dec = 0;
657
+		} else {
658
+				$dec = 0;
659
+			}
532 660
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
533 661
 			$rv .= $bin;
534 662
 			//echo "$_1 $dec ($bin)<br/>";
@@ -540,7 +668,9 @@  discard block
 block discarded – undo
540 668
 		$len_bit = strlen($_enc);
541 669
 		$rem6 = $len_bit % 6;
542 670
 		$pad6_len = 0;
543
-		if ($rem6) $pad6_len = 6 - $rem6;
671
+		if ($rem6) {
672
+			$pad6_len = 6 - $rem6;
673
+		}
544 674
 		//echo  $pad6_len.'<br>';
545 675
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
546 676
 		$len_enc = strlen($_enc) / 6;
@@ -549,8 +679,11 @@  discard block
 block discarded – undo
549 679
 		for ($i=0; $i<$len_enc; $i++) {
550 680
 			$offset = $i * 6;
551 681
 			$dec = bindec(substr($_enc,$offset,6));
552
-			if ($dec < 40) $dec += 48;
553
-			else $dec += 56;
682
+			if ($dec < 40) {
683
+				$dec += 48;
684
+			} else {
685
+				$dec += 56;
686
+			}
554 687
 			//echo chr($dec)." $dec<br/>";
555 688
 			$itu .= chr($dec);
556 689
 		}
@@ -563,25 +696,41 @@  discard block
 block discarded – undo
563 696
 		}
564 697
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
565 698
 		$lsb = $chksum & 0x0F;
566
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
567
-		else $lsbc = '0';
699
+		if ($lsb >=0 && $lsb <= 15 ) {
700
+			$lsbc = $hex_arr[$lsb];
701
+		} else {
702
+			$lsbc = '0';
703
+		}
568 704
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
569
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
570
-		else $msbc = '0';
705
+		if ($msb >=0 && $msb <= 15 ) {
706
+			$msbc = $hex_arr[$msb];
707
+		} else {
708
+			$msbc = '0';
709
+		}
571 710
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
572 711
 		return $itu;
573 712
 	}
574 713
 
575 714
 	public function parse($buffer) {
576 715
 		$data = $this->process_ais_buf($buffer);
577
-		if (!is_object($data)) return array();
578
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
579
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
716
+		if (!is_object($data)) {
717
+			return array();
718
+		}
719
+		if ($data->lon != 0) {
720
+			$result['longitude'] = $data->lon;
721
+		}
722
+		if ($data->lat != 0) {
723
+			$result['latitude'] = $data->lat;
724
+		}
580 725
 		$result['ident'] = trim($data->name);
581 726
 		$result['timestamp'] = $data->ts;
582 727
 		$result['mmsi'] = $data->mmsi;
583
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
584
-		if ($data->cog != 0) $result['heading'] = $data->cog;
728
+		if ($data->sog != -1.0) {
729
+			$result['speed'] = $data->sog;
730
+		}
731
+		if ($data->cog != 0) {
732
+			$result['heading'] = $data->cog;
733
+		}
585 734
 		/*
586 735
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
587 736
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -591,15 +740,25 @@  discard block
 block discarded – undo
591 740
 
592 741
 	public function mmsitype($mmsi) {
593 742
 		if (strlen($mmsi) == 9) {
594
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
595
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
596
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
597
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
598
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
599
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
600
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
601
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
602
-			else return 'Ship';
743
+			if (substr($mmsi,0,3) == '974') {
744
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
745
+			} elseif (substr($mmsi,0,3) == '972') {
746
+				return 'MOB (Man Overboard) device';
747
+			} elseif (substr($mmsi,0,3) == '970') {
748
+				return 'AIS SART (Search and Rescue Transmitter)';
749
+			} elseif (substr($mmsi,0,3) == '111') {
750
+				return 'SAR (Search and Rescue) aircraft';
751
+			} elseif (substr($mmsi,0,2) == '98') {
752
+				return 'Auxiliary craft associated with a parent ship';
753
+			} elseif (substr($mmsi,0,2) == '99') {
754
+				return 'Aids to Navigation';
755
+			} elseif (substr($mmsi,0,2) == '00') {
756
+				return 'Coastal stations';
757
+			} elseif (substr($mmsi,0,1) == '0') {
758
+				return 'Group of ships';
759
+			} else {
760
+				return 'Ship';
761
+			}
603 762
 		}
604 763
 
605 764
 	
@@ -616,32 +775,61 @@  discard block
 block discarded – undo
616 775
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
617 776
 			return array();
618 777
 		}
619
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
620
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
778
+		if ($data->lon != 0) {
779
+			$result['longitude'] = $data->lon;
780
+		}
781
+		if ($data->lat != 0) {
782
+			$result['latitude'] = $data->lat;
783
+		}
621 784
 		$result['ident'] = trim(str_replace('@','',$data->name));
622 785
 		$result['timestamp'] = $data->ts;
623 786
 		$result['mmsi'] = $data->mmsi;
624
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
787
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') {
788
+			$result['mmsi'] = '3'.$result['mmsi'];
789
+		}
625 790
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
626
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
627
-		if ($data->heading !== '') $result['heading'] = $data->heading;
628
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
629
-		if ($data->status != '') $result['status'] = $data->status;
630
-		if ($data->statusid !== '') $result['statusid'] = $data->statusid;
631
-		if ($data->type !== '') $result['type'] = $data->type;
632
-		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
633
-		if ($data->imo !== '') $result['imo'] = $data->imo;
634
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
791
+		if ($data->sog != -1.0) {
792
+			$result['speed'] = $data->sog;
793
+		}
794
+		if ($data->heading !== '') {
795
+			$result['heading'] = $data->heading;
796
+		} elseif ($data->cog != 0) {
797
+			$result['heading'] = $data->cog;
798
+		}
799
+		if ($data->status != '') {
800
+			$result['status'] = $data->status;
801
+		}
802
+		if ($data->statusid !== '') {
803
+			$result['statusid'] = $data->statusid;
804
+		}
805
+		if ($data->type !== '') {
806
+			$result['type'] = $data->type;
807
+		}
808
+		if ($data->typeid !== '') {
809
+			$result['typeid'] = $data->typeid;
810
+		}
811
+		if ($data->imo !== '') {
812
+			$result['imo'] = $data->imo;
813
+		}
814
+		if ($data->callsign !== '') {
815
+			$result['callsign'] = trim(str_replace('@','',$data->callsign));
816
+		}
635 817
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
636 818
 			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
637
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
819
+			if ($eta_ts != '') {
820
+				$result['eta_ts'] = $eta_ts;
821
+			}
638 822
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
639 823
 			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
640
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
824
+			if ($eta_ts != '') {
825
+				$result['eta_ts'] = $eta_ts;
826
+			}
641 827
 		}
642 828
 		if ($data->destination != '') {
643 829
 			$dest = trim(str_replace('@','',$data->destination));
644
-			if ($dest != '') $result['destination'] = $dest;
830
+			if ($dest != '') {
831
+				$result['destination'] = $dest;
832
+			}
645 833
 		}
646 834
 		$result['all'] = (array) $data;
647 835
 		/*
Please login to merge, or discard this patch.
ident.php 1 patch
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,13 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $ident = '';
4
-if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
5
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
4
+if (isset($_POST['ident'])) {
5
+	$ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
6
+}
7
+if (isset($_GET['ident'])) {
8
+	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
9
+}
6 10
 if ($ident != '')
7 11
 {
8
-	if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident);
9
-	else header('Location: '.$globalURL.'/ident/'.$ident);
10
-} else {
12
+	if (isset($_GET['marine'])) {
13
+		header('Location: '.$globalURL.'/marine/ident/'.$ident);
14
+	} else {
15
+		header('Location: '.$globalURL.'/ident/'.$ident);
16
+	}
17
+	} else {
11 18
 	header('Location: '.$globalURL);
12 19
 }
13 20
 ?>
14 21
\ No newline at end of file
Please login to merge, or discard this patch.
currently.php 1 patch
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	$limit_start = 0;
32 32
 	$limit_end = 25;
33 33
 	$absolute_difference = 25;
34
-}  else {
34
+} else {
35 35
 	$limit_explode = explode(",", $_GET['limit']);
36 36
 	$limit_start = $limit_explode[0];
37 37
 	$limit_end = $limit_explode[1];
@@ -50,20 +50,32 @@  discard block
 block discarded – undo
50 50
 print '</div>';
51 51
 
52 52
 print '<div class="table column">';
53
-if ($type == 'aircraft') print '<p>'._("The table below shows the detailed information of all current flights.").'</p>';
54
-elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
55
-elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
53
+if ($type == 'aircraft') {
54
+	print '<p>'._("The table below shows the detailed information of all current flights.").'</p>';
55
+} elseif ($type == 'marine') {
56
+	print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
57
+} elseif ($type == 'tracker') {
58
+	print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
59
+}
56 60
 
57 61
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
58 62
 if ($sort != '') {
59
-	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
60
-	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
61
-	elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort);
62
-} else {
63
-	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference);
64
-	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference);
65
-	elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference);
66
-}
63
+	if ($type == 'aircraft') {
64
+		$spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
65
+	} elseif ($type == 'marine') {
66
+		$spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
67
+	} elseif ($type == 'tracker') {
68
+		$spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort);
69
+	}
70
+	} else {
71
+	if ($type == 'aircraft') {
72
+		$spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference);
73
+	} elseif ($type == 'marine') {
74
+		$spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference);
75
+	} elseif ($type == 'tracker') {
76
+		$spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference);
77
+	}
78
+	}
67 79
 
68 80
 if (!empty($spotter_array))
69 81
 {
Please login to merge, or discard this patch.
date.php 1 patch
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $type = 'aircraft';
4
-if (isset($_GET['marine'])) $type = 'marine';
5
-elseif (isset($_GET['tracker'])) $type = 'tracker';
4
+if (isset($_GET['marine'])) {
5
+	$type = 'marine';
6
+} elseif (isset($_GET['tracker'])) {
7
+	$type = 'tracker';
8
+}
6 9
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
7
-if ($date == '') $date = date('Y-m-d');
8
-if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date);
9
-elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date);
10
-else header('Location: '.$globalURL.'/date/'.$date);
10
+if ($date == '') {
11
+	$date = date('Y-m-d');
12
+}
13
+if ($type == 'marine') {
14
+	header('Location: '.$globalURL.'/marine/date/'.$date);
15
+} elseif ($type == 'tracker') {
16
+	header('Location: '.$globalURL.'/tracker/date/'.$date);
17
+} else {
18
+	header('Location: '.$globalURL.'/date/'.$date);
19
+}
11 20
 ?>
12 21
\ No newline at end of file
Please login to merge, or discard this patch.
date-detailed.php 1 patch
Braces   +37 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		$limit_start = 0;
30 30
 		$limit_end = 25;
31 31
 		$absolute_difference = 25;
32
-	}  else {
32
+	} else {
33 33
 		$limit_explode = explode(",", $_GET['limit']);
34 34
 		$limit_start = $limit_explode[0];
35 35
 		$limit_end = $limit_explode[1];
@@ -46,21 +46,33 @@  discard block
 block discarded – undo
46 46
 	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
47 47
 	if ($sort != '') 
48 48
 	{
49
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
50
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
49
+		if ($type == 'marine') {
50
+			$spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
+		} elseif ($type == 'tracker') {
52
+			$spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
53
+		} else {
54
+			$spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
55
+		}
52 56
 	} else {
53
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
54
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
55
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
57
+		if ($type == 'marine') {
58
+			$spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
59
+		} elseif ($type == 'tracker') {
60
+			$spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
61
+		} else {
62
+			$spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
63
+		}
56 64
 	}
57 65
 	
58 66
 	if (!empty($spotter_array))
59 67
 	{
60 68
 		date_default_timezone_set($globalTimezone);
61
-		if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
62
-		elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
63
-		else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
69
+		if ($type == 'marine') {
70
+			$title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
71
+		} elseif ($type == 'tracker') {
72
+			$title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
73
+		} else {
74
+			$title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
75
+		}
64 76
 
65 77
 		require_once('header.php');
66 78
 		print '<div class="select-item">';
@@ -78,15 +90,24 @@  discard block
 block discarded – undo
78 90
 		print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
79 91
 		print '<br />';
80 92
 		print '<div class="info column">';
81
-		if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
82
-		else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
93
+		if ($type == 'marine') {
94
+			print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
95
+		} else {
96
+			print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
97
+		}
83 98
 		print '</div>';
84 99
 
85
-		if ($type == 'aircraft') include('date-sub-menu.php');
100
+		if ($type == 'aircraft') {
101
+			include('date-sub-menu.php');
102
+		}
86 103
 		print '<div class="table column">';
87
-		if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
88
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
89
-		else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
104
+		if ($type == 'marine') {
105
+			print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
106
+		} elseif ($type == 'tracker') {
107
+			print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
108
+		} else {
109
+			print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
110
+		}
90 111
  
91 112
 		include('table-output.php');
92 113
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
latest.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	$limit_start = 0;
29 29
 	$limit_end = 25;
30 30
 	$absolute_difference = 25;
31
-}  else {
31
+} else {
32 32
 	$limit_explode = explode(",", $_GET['limit']);
33 33
 	$limit_start = $limit_explode[0];
34 34
 	$limit_end = $limit_explode[1];
@@ -47,9 +47,13 @@  discard block
 block discarded – undo
47 47
 print '<h1>'._("Latest Activity").'</h1>';
48 48
 print '</div>';
49 49
 print '<div class="table column">';
50
-if ($type == 'marine') print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>';
51
-elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
52
-else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
50
+if ($type == 'marine') {
51
+	print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>';
52
+} elseif ($type == 'tracker') {
53
+	print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
54
+} else {
55
+	print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
56
+}
53 57
 
54 58
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
55 59
 $sql_begin = microtime(true);
Please login to merge, or discard this patch.
table-output.php 1 patch
Braces   +63 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@  discard block
 block discarded – undo
7 7
 $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
8 8
 $showDuration = $Common->multiKeyExists($spotter_array,'duration');
9 9
 
10
-if (!isset($type)) $type = 'aircraft';
10
+if (!isset($type)) {
11
+	$type = 'aircraft';
12
+}
11 13
 
12 14
 if (!isset($_GET['sort'])) 
13 15
 {
@@ -440,7 +442,9 @@  discard block
 block discarded – undo
440 442
 	if (isset($globalTimezone))
441 443
 	{
442 444
 		date_default_timezone_set($globalTimezone);
443
-	} else date_default_timezone_set('UTC');
445
+	} else {
446
+		date_default_timezone_set('UTC');
447
+	}
444 448
 	if ($showSpecial === true)
445 449
 	{
446 450
 		print '<tr class="special">'."\n";
@@ -455,7 +459,9 @@  discard block
 block discarded – undo
455 459
 			print '<tr class="active">';
456 460
 		} elseif (isset($spotter_item['spotted_registration'])) {
457 461
 			print '<tr class="info">';
458
-		} else print '<tr>';
462
+		} else {
463
+			print '<tr>';
464
+		}
459 465
 	}
460 466
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") {
461 467
 		if ($type == 'aircraft') {
@@ -463,8 +469,9 @@  discard block
 block discarded – undo
463 469
 			{
464 470
 				print '<td class="aircraft_thumbnail">'."\n";
465 471
 				if ($spotter_item['image_source'] == 'planespotters') {
466
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
467
-					else {
472
+					if ($spotter_item['image_source_website'] != '') {
473
+						$image_src = $spotter_item['image_source_website'];
474
+					} else {
468 475
 						$planespotter_url_array = explode("_", $spotter_item['image']);
469 476
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
470 477
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -477,7 +484,9 @@  discard block
 block discarded – undo
477 484
 				} else {
478 485
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
479 486
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
480
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
487
+					} else {
488
+						$image_thumbnail = $spotter_item['image_thumbnail'];
489
+					}
481 490
 					if (isset($spotter_item['airline_name'])) {
482 491
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
483 492
 					} else {
@@ -496,7 +505,9 @@  discard block
 block discarded – undo
496 505
 				print '<td class="aircraft_thumbnail">'."\n";
497 506
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
498 507
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
499
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
508
+				} else {
509
+					$image_thumbnail = $spotter_item['image_thumbnail'];
510
+				}
500 511
 				if (isset($spotter_item['airline_name'])) {
501 512
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
502 513
 				} else {
@@ -514,7 +525,9 @@  discard block
 block discarded – undo
514 525
 				print '<td class="aircraft_thumbnail">'."\n";
515 526
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
516 527
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
517
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
528
+				} else {
529
+					$image_thumbnail = $spotter_item['image_thumbnail'];
530
+				}
518 531
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
519 532
 				print '</td>'."\n";
520 533
 			} else {
@@ -565,8 +578,9 @@  discard block
 block discarded – undo
565 578
 				print '<td class="aircraft_thumbnail">'."\n";
566 579
 				//print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
567 580
 				if ($spotter_item['image_source'] == 'planespotters') {
568
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
569
-					else {
581
+					if ($spotter_item['image_source_website'] != '') {
582
+						$image_src = $spotter_item['image_source_website'];
583
+					} else {
570 584
 						$planespotter_url_array = explode("_", $spotter_array[0]['image']);
571 585
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
572 586
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -583,7 +597,9 @@  discard block
 block discarded – undo
583 597
 				} else {
584 598
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
585 599
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
586
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
600
+					} else {
601
+						$image_thumbnail = $spotter_item['image_thumbnail'];
602
+					}
587 603
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
588 604
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
589 605
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -616,7 +632,9 @@  discard block
 block discarded – undo
616 632
 				print '<td class="aircraft_thumbnail">'."\n";
617 633
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
618 634
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
619
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
635
+				} else {
636
+					$image_thumbnail = $spotter_item['image_thumbnail'];
637
+				}
620 638
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
621 639
 				print '</td>'."\n";
622 640
 			} else {
@@ -630,7 +648,9 @@  discard block
 block discarded – undo
630 648
 				print '<td class="aircraft_thumbnail">'."\n";
631 649
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
632 650
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
633
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
651
+				} else {
652
+					$image_thumbnail = $spotter_item['image_thumbnail'];
653
+				}
634 654
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
635 655
 				print '</td>'."\n";
636 656
 			} else {
@@ -783,15 +803,21 @@  discard block
 block discarded – undo
783 803
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
784 804
 				if ($spotter_item['departure_airport_time'] > 2460) {
785 805
 					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
786
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
806
+				} else {
807
+					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
808
+				}
787 809
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
788 810
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
789
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
811
+				} else {
812
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
813
+				}
790 814
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
791 815
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
792 816
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
793 817
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
794
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
818
+				} else {
819
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
820
+				}
795 821
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
796 822
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
797 823
 				if ($spotter_item['departure_airport_time'] > 2460) {
@@ -813,7 +839,9 @@  discard block
 block discarded – undo
813 839
 						$longitude = $spotter_item['longitude'];
814 840
 					}
815 841
 					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
816
-				} else $distance = '';
842
+				} else {
843
+					$distance = '';
844
+				}
817 845
 				if ($distance != '') {
818 846
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
819 847
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -840,7 +868,9 @@  discard block
 block discarded – undo
840 868
 			} else {
841 869
 				if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
842 870
 					print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
843
-					if (!isset($Spotter)) $Spotter = new Spotter();
871
+					if (!isset($Spotter)) {
872
+						$Spotter = new Spotter();
873
+					}
844 874
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
845 875
 					print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
846 876
 					print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
@@ -856,20 +886,28 @@  discard block
 block discarded – undo
856 886
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
857 887
 				if ($spotter_item['arrival_airport_time'] > 2460) {
858 888
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
859
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
889
+				} else {
890
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
891
+				}
860 892
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
861 893
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
862
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
894
+				} else {
895
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
896
+				}
863 897
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
864 898
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
865 899
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
866 900
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
867
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
901
+				} else {
902
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
903
+				}
868 904
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
869 905
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
870 906
 				if ($spotter_item['arrival_airport_time'] > 2460) {
871 907
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
872
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
908
+				} else {
909
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
910
+				}
873 911
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
874 912
 			}
875 913
 			if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -882,7 +920,9 @@  discard block
 block discarded – undo
882 920
 						$longitude = $spotter_item['longitude'];
883 921
 					}
884 922
 					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
885
-				} else $distance = '';
923
+				} else {
924
+					$distance = '';
925
+				}
886 926
 				if ($distance != '') {
887 927
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
888 928
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
Please login to merge, or discard this patch.
pilot-detailed.php 1 patch
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,8 +40,12 @@  discard block
 block discarded – undo
40 40
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
41 41
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
42 42
 	$filter = array();
43
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
44
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
43
+	if ($year != '') {
44
+		$filter = array_merge($filter,array('year' => $year));
45
+	}
46
+	if ($month != '') {
47
+		$filter = array_merge($filter,array('month' => $month));
48
+	}
45 49
 	if ($sort != '') 
46 50
 	{
47 51
 		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -59,8 +63,12 @@  discard block
 block discarded – undo
59 63
 	{
60 64
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
61 65
 		$ident = $spotter_array[0]['ident'];
62
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
63
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
66
+		if (isset($spotter_array[0]['latitude'])) {
67
+			$latitude = $spotter_array[0]['latitude'];
68
+		}
69
+		if (isset($spotter_array[0]['longitude'])) {
70
+			$longitude = $spotter_array[0]['longitude'];
71
+		}
64 72
 		require_once('header.php');
65 73
 		/*
66 74
 		if (isset($globalArchive) && $globalArchive) {
@@ -113,12 +121,18 @@  discard block
 block discarded – undo
113 121
 		*/
114 122
 		print '<div class="info column">';
115 123
 		print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
116
-		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
124
+		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') {
125
+			print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
126
+		}
117 127
 		if ($year == '' && $month == '') {
118 128
 			$Stats = new Stats();
119 129
 			$flights = $Stats->getStatsPilot($pilot);
120
-		} else $flights = 0;
121
-		if ($flights == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter);
130
+		} else {
131
+			$flights = 0;
132
+		}
133
+		if ($flights == 0) {
134
+			$flights = $Spotter->countFlightsByPilot($pilot,$filter);
135
+		}
122 136
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
123 137
 		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter));
124 138
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
@@ -129,7 +143,9 @@  discard block
 block discarded – undo
129 143
 		$airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter));
130 144
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
131 145
 		$duration = $Spotter->getFlightDurationByPilot($pilot,$filter);
132
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
146
+		if ($duration != '0') {
147
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
148
+		}
133 149
 		print '</div>';
134 150
 	
135 151
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
require/class.SBS.php 1 patch
Braces   +248 added lines, -87 removed lines patch added patch discarded remove patch
@@ -7,9 +7,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.