Completed
Push — master ( 438a8c...d8fba4 )
by Yannick
35:59
created
require/class.AIS.php 1 patch
Braces   +204 added lines, -79 removed lines patch added patch discarded remove patch
@@ -123,7 +123,9 @@  discard block
 block discarded – undo
123 123
 			$temp += 1;
124 124
 			$flat = (float)($temp / (60.0 * 10000.0));
125 125
 			$flat *= -1.0;
126
-		} else $flat = (float)($temp / (60.0 * 10000.0));
126
+		} else {
127
+			$flat = (float)($temp / (60.0 * 10000.0));
128
+		}
127 129
 		return $flat; // float
128 130
 	}
129 131
 
@@ -135,7 +137,9 @@  discard block
 block discarded – undo
135 137
 			$temp += 1;
136 138
 			$flon = (float)($temp / (60.0 * 10000.0));
137 139
 			$flon *= -1.0;
138
-		} else $flon = (float)($temp / (60.0 * 10000.0));
140
+		} else {
141
+			$flon = (float)($temp / (60.0 * 10000.0));
142
+		}
139 143
 		return $flon;
140 144
 	}
141 145
 
@@ -158,10 +162,8 @@  discard block
 block discarded – undo
158 162
     */
159 163
 	private function asciidec_2_8bit($ascii) {
160 164
 		//only process in the following range: 48-87, 96-119
161
-		if ($ascii < 48) { }
162
-		else {
163
-			if($ascii>119) { }
164
-			else {
165
+		if ($ascii < 48) { } else {
166
+			if($ascii>119) { } else {
165 167
 				if ($ascii>87 && $ascii<96) ;
166 168
 				else {
167 169
 					$ascii=$ascii+40;
@@ -263,7 +265,9 @@  discard block
 block discarded – undo
263 265
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
264 266
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
265 267
 			$ro->heading = bindec(substr($_aisdata,124,9));
266
-			if ($ro->heading == 511) $ro->heading = '';
268
+			if ($ro->heading == 511) {
269
+				$ro->heading = '';
270
+			}
267 271
 			$ro->cls = 2; // class B
268 272
 		} else if ($ro->id == 19) {
269 273
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -273,7 +277,9 @@  discard block
 block discarded – undo
273 277
 			$ro->name = $this->binchar($_aisdata,143,120);
274 278
 			$ro->cls = 2; // class B
275 279
 			$ro->heading = bindec(substr($_aisdata,124,9));
276
-			if ($ro->heading == 511) $ro->heading = '';
280
+			if ($ro->heading == 511) {
281
+				$ro->heading = '';
282
+			}
277 283
 			$ro->typeid = bindec(substr($_aisdata,263,8));
278 284
 			$ro->type = $this->getShipType($ro->typeid);
279 285
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -304,9 +310,13 @@  discard block
 block discarded – undo
304 310
 			$ro->cls = 2; // class B
305 311
 		} else if ($ro->id == 27) {
306 312
 			$ro->cog = bindec(substr($_aisdata,85,9));
307
-			if ($ro->cog == 511) $ro->cog = 0.0;
313
+			if ($ro->cog == 511) {
314
+				$ro->cog = 0.0;
315
+			}
308 316
 			$ro->sog = bindec(substr($_aisdata,79,6));
309
-			if ($ro->sog == 63) $ro->sog = 0.0;
317
+			if ($ro->sog == 63) {
318
+				$ro->sog = 0.0;
319
+			}
310 320
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
311 321
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
312 322
 			$ro->cls = 1; // class A
@@ -354,28 +364,48 @@  discard block
 block discarded – undo
354 364
 	}
355 365
 	
356 366
 	public function getShipType($code) {
357
-		if (isset($this->shiptype[$code])) return $this->shiptype[$code];
358
-		else return '';
367
+		if (isset($this->shiptype[$code])) {
368
+			return $this->shiptype[$code];
369
+		} else {
370
+			return '';
371
+		}
359 372
 	}
360 373
 
361 374
 	public function getShipTypeID($type) {
362 375
 		$typeid = array_search($type,$this->shiptype);
363
-		if ($typeid !== FALSE) return $typeid;
364
-		elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') return 70;
365
-		elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') return 60;
366
-		elseif ($type == 'Tanker' || $type == 'Crude Oil Tanker' || $type == 'Oil Products Tanker' || $type == 'Oil/Chemical Tanker' || $type == 'Bunkering Tanker') return 80;
367
-		elseif ($type == 'Lpg Tanker' || $type == 'Lng Tanker') return 84;
368
-		elseif ($type == 'Sailing Vessel') return 36;
369
-		elseif ($type == 'Yacht') return 37;
370
-		elseif ($type == 'Trailing Suction Hopper Dredger' || $type == 'Drilling Jack Up' || $type == 'Suction Dredger' || $type == 'Hopper Dredger') return 33;
371
-		elseif ($type == 'High speed craft') return 40;
372
-		elseif ($type == 'Crew Boat') return 53;
373
-		elseif ($type == 'Icebreaker') return 52;
374
-		elseif ($type == 'Pollution Control Vessel') return 54;
375
-		elseif ($type == 'Other Type') return 90;
376
-		elseif ($type == 'Anchor Handling Vessel' || $type == 'Offshore Supply Ship' || $type == 'Research/Survey Vessel' || $type == 'Utility Vessel' || $type == 'Pipe Burying Vessel' || $type == 'Heavy Lift Vessel' || $type == 'Crane Ship' || $type == 'Buoy-laying Vessel') return 59;
377
-		elseif ($type == 'Fish Carrier' || $type == 'Trawler' || $type == 'Trawlers' || $type == 'Fishing Vessel' || $type == 'Trawlers|unknown Not Fishing' || $type == 'Purse Seines|trawlers' || $type == 'Purse Seines' || $type == 'Trollers' || $type == 'Set Longlines' || $type == 'Set Gillnets|trawlers') return 30;
378
-		else return 0;
376
+		if ($typeid !== FALSE) {
377
+			return $typeid;
378
+		} elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') {
379
+			return 70;
380
+		} elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') {
381
+			return 60;
382
+		} elseif ($type == 'Tanker' || $type == 'Crude Oil Tanker' || $type == 'Oil Products Tanker' || $type == 'Oil/Chemical Tanker' || $type == 'Bunkering Tanker') {
383
+			return 80;
384
+		} elseif ($type == 'Lpg Tanker' || $type == 'Lng Tanker') {
385
+			return 84;
386
+		} elseif ($type == 'Sailing Vessel') {
387
+			return 36;
388
+		} elseif ($type == 'Yacht') {
389
+			return 37;
390
+		} elseif ($type == 'Trailing Suction Hopper Dredger' || $type == 'Drilling Jack Up' || $type == 'Suction Dredger' || $type == 'Hopper Dredger') {
391
+			return 33;
392
+		} elseif ($type == 'High speed craft') {
393
+			return 40;
394
+		} elseif ($type == 'Crew Boat') {
395
+			return 53;
396
+		} elseif ($type == 'Icebreaker') {
397
+			return 52;
398
+		} elseif ($type == 'Pollution Control Vessel') {
399
+			return 54;
400
+		} elseif ($type == 'Other Type') {
401
+			return 90;
402
+		} elseif ($type == 'Anchor Handling Vessel' || $type == 'Offshore Supply Ship' || $type == 'Research/Survey Vessel' || $type == 'Utility Vessel' || $type == 'Pipe Burying Vessel' || $type == 'Heavy Lift Vessel' || $type == 'Crane Ship' || $type == 'Buoy-laying Vessel') {
403
+			return 59;
404
+		} elseif ($type == 'Fish Carrier' || $type == 'Trawler' || $type == 'Trawlers' || $type == 'Fishing Vessel' || $type == 'Trawlers|unknown Not Fishing' || $type == 'Purse Seines|trawlers' || $type == 'Purse Seines' || $type == 'Trollers' || $type == 'Set Longlines' || $type == 'Set Gillnets|trawlers') {
405
+			return 30;
406
+		} else {
407
+			return 0;
408
+		}
379 409
 	}
380 410
 
381 411
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -412,11 +442,20 @@  discard block
 block discarded – undo
412 442
 		// assume 1st ! is valid
413 443
 		// find * ensure that it is at correct position
414 444
 		$end = strrpos ( $rawdata , '*' );
415
-		if ($end === FALSE) return -1; // check for NULLS!!!
445
+		if ($end === FALSE) {
446
+			return -1;
447
+		}
448
+		// check for NULLS!!!
416 449
 		$cs = substr( $rawdata, $end + 1 );
417
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
450
+		if ( strlen($cs) != 2 ) {
451
+			return -1;
452
+		}
453
+		// correct cs length
418 454
 		$dcs = (int)hexdec( $cs );
419
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
455
+		for ( $alias=1; $alias<$end; $alias++) {
456
+			$chksum ^= ord( $rawdata[$alias] );
457
+		}
458
+		// perform XOR for NMEA checksum
420 459
 		if ( $chksum == $dcs ) { // NMEA checksum pass
421 460
 			$pcs = explode(',', $rawdata);
422 461
 			// !AI??? identifier
@@ -427,8 +466,14 @@  discard block
 block discarded – undo
427 466
 			$num_seq = (int)$pcs[1]; // number of sequences
428 467
 			$seq = (int)$pcs[2]; // get sequence
429 468
 			// get msg sequence id
430
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
431
-			else $msg_sid = (int)$pcs[3]; // multipart message
469
+			if ($pcs[3] == '') {
470
+				$msg_sid = -1;
471
+			}
472
+			// non-multipart message, set to -1
473
+			else {
474
+				$msg_sid = (int)$pcs[3];
475
+			}
476
+			// multipart message
432 477
 			$ais_ch = $pcs[4]; // get AIS channel
433 478
 			// message sequence checking
434 479
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -491,10 +536,18 @@  discard block
 block discarded – undo
491 536
 				//DEBUG echo "[$start $end $tst]\n";
492 537
 				$result = $this->process_ais_raw( $tst, "" );
493 538
 				$last_pos = $end + 1;
494
-			} else break;
539
+			} else {
540
+				break;
541
+			}
542
+		}
543
+		if ($last_pos > 0) {
544
+			$cbuf = substr($cbuf, $last_pos);
495 545
 		}
496
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
497
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
546
+		// move...
547
+		if (strlen($cbuf) > 1024) {
548
+			$cbuf = "";
549
+		}
550
+		// prevent overflow simple mode...
498 551
 		return $result;
499 552
 	}
500 553
 
@@ -514,7 +567,9 @@  discard block
 block discarded – undo
514 567
 		if ($lat<0.0) {
515 568
 			$lat = -$lat;
516 569
 			$neg=true;
517
-		} else $neg=false;
570
+		} else {
571
+			$neg=false;
572
+		}
518 573
 		$latd = 0x00000000;
519 574
 		$latd = intval ($lat * 600000.0);
520 575
 		if ($neg==true) {
@@ -530,7 +585,9 @@  discard block
 block discarded – undo
530 585
 		if ($lon<0.0) {
531 586
 			$lon = -$lon;
532 587
 			$neg=true;
533
-		} else $neg=false;
588
+		} else {
589
+			$neg=false;
590
+		}
534 591
 		$lond = 0x00000000;
535 592
 		$lond = intval ($lon * 600000.0);
536 593
 		if ($neg==true) {
@@ -543,9 +600,14 @@  discard block
 block discarded – undo
543 600
 
544 601
 	private function char2bin($name, $max_len) {
545 602
 		$len = strlen($name);
546
-		if ($len > $max_len) $name = substr($name,0,$max_len);
547
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
548
-		else $pad = '';
603
+		if ($len > $max_len) {
604
+			$name = substr($name,0,$max_len);
605
+		}
606
+		if ($len < $max_len) {
607
+			$pad = str_repeat('0', ($max_len - $len) * 6);
608
+		} else {
609
+			$pad = '';
610
+		}
549 611
 		$rv = '';
550 612
 		$ais_chars = array(
551 613
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -560,8 +622,11 @@  discard block
 block discarded – undo
560 622
 		$_a = str_split($name);
561 623
 		if (!empty($_a)) {
562 624
 			foreach ($_a as $_1) {
563
-				if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
564
-				else $dec = 0;
625
+				if (isset($ais_chars[$_1])) {
626
+					$dec = $ais_chars[$_1];
627
+				} else {
628
+					$dec = 0;
629
+				}
565 630
 				$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
566 631
 				$rv .= $bin;
567 632
 				//echo "$_1 $dec ($bin)<br/>";
@@ -574,7 +639,9 @@  discard block
 block discarded – undo
574 639
 		$len_bit = strlen($_enc);
575 640
 		$rem6 = $len_bit % 6;
576 641
 		$pad6_len = 0;
577
-		if ($rem6) $pad6_len = 6 - $rem6;
642
+		if ($rem6) {
643
+			$pad6_len = 6 - $rem6;
644
+		}
578 645
 		//echo  $pad6_len.'<br>';
579 646
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
580 647
 		$len_enc = strlen($_enc) / 6;
@@ -583,8 +650,11 @@  discard block
 block discarded – undo
583 650
 		for ($i=0; $i<$len_enc; $i++) {
584 651
 			$offset = $i * 6;
585 652
 			$dec = bindec(substr($_enc,$offset,6));
586
-			if ($dec < 40) $dec += 48;
587
-			else $dec += 56;
653
+			if ($dec < 40) {
654
+				$dec += 48;
655
+			} else {
656
+				$dec += 56;
657
+			}
588 658
 			//echo chr($dec)." $dec<br/>";
589 659
 			$itu .= chr($dec);
590 660
 		}
@@ -597,26 +667,42 @@  discard block
 block discarded – undo
597 667
 		}
598 668
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
599 669
 		$lsb = $chksum & 0x0F;
600
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
601
-		else $lsbc = '0';
670
+		if ($lsb >=0 && $lsb <= 15 ) {
671
+			$lsbc = $hex_arr[$lsb];
672
+		} else {
673
+			$lsbc = '0';
674
+		}
602 675
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
603
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
604
-		else $msbc = '0';
676
+		if ($msb >=0 && $msb <= 15 ) {
677
+			$msbc = $hex_arr[$msb];
678
+		} else {
679
+			$msbc = '0';
680
+		}
605 681
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
606 682
 		return $itu;
607 683
 	}
608 684
 
609 685
 	public function parse($buffer) {
610 686
 		$data = $this->process_ais_buf($buffer);
611
-		if (!is_object($data)) return array();
687
+		if (!is_object($data)) {
688
+			return array();
689
+		}
612 690
 		$result = array();
613
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
614
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
691
+		if ($data->lon != 0) {
692
+			$result['longitude'] = $data->lon;
693
+		}
694
+		if ($data->lat != 0) {
695
+			$result['latitude'] = $data->lat;
696
+		}
615 697
 		$result['ident'] = trim($data->name);
616 698
 		$result['timestamp'] = $data->ts;
617 699
 		$result['mmsi'] = $data->mmsi;
618
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
619
-		if ($data->cog != 0) $result['heading'] = $data->cog;
700
+		if ($data->sog != -1.0) {
701
+			$result['speed'] = $data->sog;
702
+		}
703
+		if ($data->cog != 0) {
704
+			$result['heading'] = $data->cog;
705
+		}
620 706
 		/*
621 707
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
622 708
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -626,15 +712,25 @@  discard block
 block discarded – undo
626 712
 
627 713
 	public function mmsitype($mmsi) {
628 714
 		if (strlen($mmsi) == 9) {
629
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
630
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
631
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
632
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
633
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
634
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
635
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
636
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
637
-			else return 'Ship';
715
+			if (substr($mmsi,0,3) == '974') {
716
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
717
+			} elseif (substr($mmsi,0,3) == '972') {
718
+				return 'MOB (Man Overboard) device';
719
+			} elseif (substr($mmsi,0,3) == '970') {
720
+				return 'AIS SART (Search and Rescue Transmitter)';
721
+			} elseif (substr($mmsi,0,3) == '111') {
722
+				return 'SAR (Search and Rescue) aircraft';
723
+			} elseif (substr($mmsi,0,2) == '98') {
724
+				return 'Auxiliary craft associated with a parent ship';
725
+			} elseif (substr($mmsi,0,2) == '99') {
726
+				return 'Aids to Navigation';
727
+			} elseif (substr($mmsi,0,2) == '00') {
728
+				return 'Coastal stations';
729
+			} elseif (substr($mmsi,0,1) == '0') {
730
+				return 'Group of ships';
731
+			} else {
732
+				return 'Ship';
733
+			}
638 734
 		}
639 735
 
640 736
 	
@@ -650,32 +746,61 @@  discard block
 block discarded – undo
650 746
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
651 747
 			return array();
652 748
 		}
653
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
654
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
749
+		if ($data->lon != 0) {
750
+			$result['longitude'] = $data->lon;
751
+		}
752
+		if ($data->lat != 0) {
753
+			$result['latitude'] = $data->lat;
754
+		}
655 755
 		$result['ident'] = trim(str_replace('@','',$data->name));
656 756
 		$result['timestamp'] = $data->ts;
657 757
 		$result['mmsi'] = $data->mmsi;
658
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
758
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') {
759
+			$result['mmsi'] = '3'.$result['mmsi'];
760
+		}
659 761
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
660
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
661
-		if ($data->heading !== '') $result['heading'] = $data->heading;
662
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
663
-		if ($data->status != '') $result['status'] = $data->status;
664
-		if ($data->statusid !== '') $result['statusid'] = $data->statusid;
665
-		if ($data->type !== '') $result['type'] = $data->type;
666
-		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
667
-		if ($data->imo !== '') $result['imo'] = $data->imo;
668
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
762
+		if ($data->sog != -1.0) {
763
+			$result['speed'] = $data->sog;
764
+		}
765
+		if ($data->heading !== '') {
766
+			$result['heading'] = $data->heading;
767
+		} elseif ($data->cog != 0) {
768
+			$result['heading'] = $data->cog;
769
+		}
770
+		if ($data->status != '') {
771
+			$result['status'] = $data->status;
772
+		}
773
+		if ($data->statusid !== '') {
774
+			$result['statusid'] = $data->statusid;
775
+		}
776
+		if ($data->type !== '') {
777
+			$result['type'] = $data->type;
778
+		}
779
+		if ($data->typeid !== '') {
780
+			$result['typeid'] = $data->typeid;
781
+		}
782
+		if ($data->imo !== '') {
783
+			$result['imo'] = $data->imo;
784
+		}
785
+		if ($data->callsign !== '') {
786
+			$result['callsign'] = trim(str_replace('@','',$data->callsign));
787
+		}
669 788
 		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 !== '') {
670 789
 			$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');
671
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
790
+			if ($eta_ts != '') {
791
+				$result['eta_ts'] = $eta_ts;
792
+			}
672 793
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
673 794
 			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
674
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
795
+			if ($eta_ts != '') {
796
+				$result['eta_ts'] = $eta_ts;
797
+			}
675 798
 		}
676 799
 		if ($data->destination != '') {
677 800
 			$dest = trim(str_replace('@','',$data->destination));
678
-			if ($dest != '') $result['destination'] = $dest;
801
+			if ($dest != '') {
802
+				$result['destination'] = $dest;
803
+			}
679 804
 		}
680 805
 		$result['all'] = (array) $data;
681 806
 		/*
Please login to merge, or discard this patch.
require/class.ACARS.php 1 patch
Braces   +415 added lines, -263 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null,$fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection. (ACARS)');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection. (ACARS)');
29
+		}
28 30
 		if ($fromACARSscript) {
29 31
 			$this->fromACARSscript = true;
30 32
 			$this->SI = new SpotterImport($this->db);
@@ -39,14 +41,19 @@  discard block
 block discarded – undo
39 41
 	*/
40 42
 	public function ident2icao($ident) {
41 43
 		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
44
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
45
+				$icao = $ident;
46
+			} else {
47
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
48
+			}
44 49
 		} else {
45 50
 			$Spotter = new Spotter($this->db);
46 51
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
47 52
 			if (isset($identicao[0])) {
48 53
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
49
-			} else $icao = $ident;
54
+			} else {
55
+				$icao = $ident;
56
+			}
50 57
 		}
51 58
 		return $icao;
52 59
 	}
@@ -119,14 +126,24 @@  discard block
 block discarded – undo
119 126
 		$message = '';
120 127
 		$result = array();
121 128
 		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
122
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
129
+		if ($n == 0) {
130
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
131
+		}
132
+		if ($n == 0) {
133
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
134
+		}
135
+		if ($n == 0) {
136
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
137
+		}
125 138
 		if ($n != 0) {
126 139
 			$registration = str_replace('.','',$registration);
127 140
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
128
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
129
-		} else $message = $data;
141
+			if ($globalDebug) {
142
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
143
+			}
144
+		} else {
145
+			$message = $data;
146
+		}
130 147
 		$decode = array();
131 148
 		$found = false;
132 149
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -146,12 +163,21 @@  discard block
 block discarded – undo
146 163
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
147 164
 					$latitude = $la / 10000.0;
148 165
 					$longitude = $ln / 10000.0;
149
-					if ($lac == 'S') $latitude = '-'.$latitude;
150
-					if ($lnc == 'W') $longitude = '-'.$longitude;
166
+					if ($lac == 'S') {
167
+						$latitude = '-'.$latitude;
168
+					}
169
+					if ($lnc == 'W') {
170
+						$longitude = '-'.$longitude;
171
+					}
151 172
 					// Temp not always available
152
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
153
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
154
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
173
+					if ($globalDebug) {
174
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
175
+					}
176
+					if ($temp == '') {
177
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
178
+					} else {
179
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
180
+					}
155 181
 
156 182
 					//$icao = $Translation->checkTranslation($ident);
157 183
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -165,25 +191,35 @@  discard block
 block discarded – undo
165 191
 				$ahour = '';
166 192
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
167 193
 				if ($n == 4 && strlen($darr) == 4) {
168
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
169
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
170
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
194
+					if ($dhour != '') {
195
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
196
+					}
197
+					if ($ahour != '') {
198
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
199
+					}
200
+					if ($globalDebug) {
201
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
202
+					}
171 203
 					//$icao = ACARS->ident2icao($ident);
172 204
 					//$icao = $Translation->checkTranslation($ident);
173 205
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
174 206
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
175 207
 					$found = true;
176
-				}
177
-				elseif ($n == 2 || $n  == 4) {
178
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
179
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
208
+				} elseif ($n == 2 || $n  == 4) {
209
+					if ($dhour != '') {
210
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
211
+					}
212
+					if ($globalDebug) {
213
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
214
+					}
180 215
 					//$icao = ACARS->ident2icao($ident);
181 216
 					//$icao = $Translation->checkTranslation($ident);
182 217
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
183 218
 					$found = true;
184
-				}
185
-				elseif ($n == 1) {
186
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
219
+				} elseif ($n == 1) {
220
+					if ($globalDebug) {
221
+						echo 'airport arrival : '.$darr."\n";
222
+					}
187 223
 					//$icao = ACARS->ident2icao($ident);
188 224
 					//$icao = $Translation->checkTranslation($ident);
189 225
 					$decode = array('Arrival airport' => $darr);
@@ -201,7 +237,9 @@  discard block
 block discarded – undo
201 237
 				$darr = '';
202 238
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
203 239
 				if ($n == 4) {
204
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
240
+					if ($globalDebug) {
241
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
242
+					}
205 243
 					//$icao = ACARS->ident2icao($ident);
206 244
 					//$icao = $Translation->checkTranslation($ident);
207 245
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -235,14 +273,23 @@  discard block
 block discarded – undo
235 273
 				$apiste = '';
236 274
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
237 275
 				if ($n > 8) {
238
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
239
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
240
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
276
+					if ($globalDebug) {
277
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
278
+					}
279
+					if ($dhour != '') {
280
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
281
+					}
282
+					if ($ahour != '') {
283
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
284
+					}
241 285
 					$icao = trim($aident);
242 286
 
243 287
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
244
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
245
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
288
+					if ($ahour == '') {
289
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
290
+					} else {
291
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
292
+					}
246 293
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
247 294
 					$decode['icao'] = $icao;
248 295
 					$found = true;
@@ -264,9 +311,15 @@  discard block
 block discarded – undo
264 311
 					$lns = $lns.'.'.$lns;
265 312
 					$latitude = $las / 1000.0;
266 313
 					$longitude = $lns / 1000.0;
267
-					if ($lac == 'S') $latitude = '-'.$latitude;
268
-					if ($lnc == 'W') $longitude = '-'.$longitude;
269
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
314
+					if ($lac == 'S') {
315
+						$latitude = '-'.$latitude;
316
+					}
317
+					if ($lnc == 'W') {
318
+						$longitude = '-'.$longitude;
319
+					}
320
+					if ($globalDebug) {
321
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
322
+					}
270 323
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
271 324
 					$found = true;
272 325
 				}
@@ -284,7 +337,9 @@  discard block
 block discarded – undo
284 337
 				$darr = '';
285 338
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
286 339
 				if ($n == 4) {
287
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
340
+					if ($globalDebug) {
341
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
342
+					}
288 343
 					//$icao = $Translation->checkTranslation($ident);
289 344
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
290 345
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -297,7 +352,9 @@  discard block
 block discarded – undo
297 352
 				$darr = '';
298 353
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
299 354
 				if ($n == 4) {
300
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
355
+					if ($globalDebug) {
356
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
357
+					}
301 358
 					//$icao = $Translation->checkTranslation($ident);
302 359
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
303 360
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -310,7 +367,9 @@  discard block
 block discarded – undo
310 367
 				$darr = '';
311 368
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
312 369
 				if ($n == 2) {
313
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
370
+					if ($globalDebug) {
371
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
372
+					}
314 373
 					//$icao = $Translation->checkTranslation($ident);
315 374
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
316 375
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -324,7 +383,9 @@  discard block
 block discarded – undo
324 383
 				$darr = '';
325 384
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
326 385
 				if ($n == 6) {
327
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
386
+					if ($globalDebug) {
387
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
388
+					}
328 389
 					//$icao = $Translation->checkTranslation($ident);
329 390
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
330 391
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -337,7 +398,9 @@  discard block
 block discarded – undo
337 398
 				$darr = '';
338 399
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
339 400
 				if ($n == 7) {
340
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
401
+					if ($globalDebug) {
402
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
403
+					}
341 404
 					//$icao = $Translation->checkTranslation($ident);
342 405
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
343 406
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -365,8 +428,12 @@  discard block
 block discarded – undo
365 428
 					$decode['icao'] = $icao;
366 429
 					$latitude = $las / 100.0;
367 430
 					$longitude = $lns / 100.0;
368
-					if ($lac == 'S') $latitude = '-'.$latitude;
369
-					if ($lnc == 'W') $longitude = '-'.$longitude;
431
+					if ($lac == 'S') {
432
+						$latitude = '-'.$latitude;
433
+					}
434
+					if ($lnc == 'W') {
435
+						$longitude = '-'.$longitude;
436
+					}
370 437
 
371 438
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
372 439
 					$found = true;
@@ -384,8 +451,12 @@  discard block
 block discarded – undo
384 451
 				if ($n == 4) {
385 452
 					$latitude = $las;
386 453
 					$longitude = $lns;
387
-					if ($lac == 'S') $latitude = '-'.$latitude;
388
-					if ($lnc == 'W') $longitude = '-'.$longitude;
454
+					if ($lac == 'S') {
455
+						$latitude = '-'.$latitude;
456
+					}
457
+					if ($lnc == 'W') {
458
+						$longitude = '-'.$longitude;
459
+					}
389 460
 
390 461
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
391 462
 					$found = true;
@@ -401,7 +472,9 @@  discard block
 block discarded – undo
401 472
 				$darr = '';
402 473
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
403 474
 				if ($n == 5) {
404
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
475
+					if ($globalDebug) {
476
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
477
+					}
405 478
 					//$icao = $Translation->checkTranslation($ident);
406 479
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
407 480
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -422,7 +495,9 @@  discard block
 block discarded – undo
422 495
 				$aident = '';
423 496
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
424 497
 				if ($n == 8) {
425
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
498
+					if ($globalDebug) {
499
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
500
+					}
426 501
 					$icao = trim($aident);
427 502
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
428 503
 					$decode['icao'] = $icao;
@@ -439,7 +514,9 @@  discard block
 block discarded – undo
439 514
 				$darr = '';
440 515
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
441 516
 				if ($n == 5) {
442
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
517
+					if ($globalDebug) {
518
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
519
+					}
443 520
 					//$icao = $Translation->checkTranslation($ident);
444 521
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
445 522
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -454,7 +531,9 @@  discard block
 block discarded – undo
454 531
 				$darr = '';
455 532
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
456 533
 				if ($n == 3) {
457
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
534
+					if ($globalDebug) {
535
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
536
+					}
458 537
 					//$icao = $Translation->checkTranslation($ident);
459 538
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
460 539
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -469,7 +548,9 @@  discard block
 block discarded – undo
469 548
 				$darr = '';
470 549
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
471 550
 				if ($n == 3) {
472
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
551
+					if ($globalDebug) {
552
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
553
+					}
473 554
 					//$icao = $Translation->checkTranslation($ident);
474 555
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
475 556
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -479,7 +560,9 @@  discard block
 block discarded – undo
479 560
 			if (!$found) {
480 561
 				$n = sscanf($message,'MET01%4c',$airport);
481 562
 				if ($n == 1) {
482
-					if ($globalDebug) echo 'airport name : '.$airport;
563
+					if ($globalDebug) {
564
+						echo 'airport name : '.$airport;
565
+					}
483 566
 					$decode = array('Airport/Waypoint name' => $airport);
484 567
 					$found = true;
485 568
 				}
@@ -487,184 +570,126 @@  discard block
 block discarded – undo
487 570
 			if ($label == 'H1') {
488 571
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
489 572
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
490
-				}
491
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
573
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
492 574
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
493
-				}
494
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
575
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
495 576
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
496
-				}
497
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
577
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
498 578
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
499
-				}
500
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
579
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
501 580
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
502
-				}
503
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
581
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
504 582
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
505
-				}
506
-				elseif (preg_match(':^#M1AAEP:',$message)) {
583
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
507 584
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
508
-				}
509
-				elseif (preg_match(':^#M2APWD:',$message)) {
585
+				} elseif (preg_match(':^#M2APWD:',$message)) {
510 586
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
511
-				}
512
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
587
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
513 588
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
514
-				}
515
-				elseif (preg_match(':^#CF:',$message)) {
589
+				} elseif (preg_match(':^#CF:',$message)) {
516 590
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
517
-				}
518
-				elseif (preg_match(':^#DF:',$message)) {
591
+				} elseif (preg_match(':^#DF:',$message)) {
519 592
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
520
-				}
521
-				elseif (preg_match(':^#EC:',$message)) {
593
+				} elseif (preg_match(':^#EC:',$message)) {
522 594
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
523
-				}
524
-				elseif (preg_match(':^#EI:',$message)) {
595
+				} elseif (preg_match(':^#EI:',$message)) {
525 596
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
526
-				}
527
-				elseif (preg_match(':^#H1:',$message)) {
597
+				} elseif (preg_match(':^#H1:',$message)) {
528 598
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
529
-				}
530
-				elseif (preg_match(':^#H2:',$message)) {
599
+				} elseif (preg_match(':^#H2:',$message)) {
531 600
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
532
-				}
533
-				elseif (preg_match(':^#HD:',$message)) {
601
+				} elseif (preg_match(':^#HD:',$message)) {
534 602
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
535
-				}
536
-				elseif (preg_match(':^#M1:',$message)) {
603
+				} elseif (preg_match(':^#M1:',$message)) {
537 604
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
538
-				}
539
-				elseif (preg_match(':^#M2:',$message)) {
605
+				} elseif (preg_match(':^#M2:',$message)) {
540 606
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
541
-				}
542
-				elseif (preg_match(':^#M3:',$message)) {
607
+				} elseif (preg_match(':^#M3:',$message)) {
543 608
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
544
-				}
545
-				elseif (preg_match(':^#MD:',$message)) {
609
+				} elseif (preg_match(':^#MD:',$message)) {
546 610
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
547
-				}
548
-				elseif (preg_match(':^#PS:',$message)) {
611
+				} elseif (preg_match(':^#PS:',$message)) {
549 612
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
550
-				}
551
-				elseif (preg_match(':^#S1:',$message)) {
613
+				} elseif (preg_match(':^#S1:',$message)) {
552 614
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
553
-				}
554
-				elseif (preg_match(':^#S2:',$message)) {
615
+				} elseif (preg_match(':^#S2:',$message)) {
555 616
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
556
-				}
557
-				elseif (preg_match(':^#SD:',$message)) {
617
+				} elseif (preg_match(':^#SD:',$message)) {
558 618
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
559
-				}
560
-				elseif (preg_match(':^#T[0-8]:',$message)) {
619
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
561 620
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
562
-				}
563
-				elseif (preg_match(':^#WO:',$message)) {
621
+				} elseif (preg_match(':^#WO:',$message)) {
564 622
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
565
-				}
566
-				elseif (preg_match(':^#A1:',$message)) {
623
+				} elseif (preg_match(':^#A1:',$message)) {
567 624
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
568
-				}
569
-				elseif (preg_match(':^#A3:',$message)) {
625
+				} elseif (preg_match(':^#A3:',$message)) {
570 626
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
571
-				}
572
-				elseif (preg_match(':^#A4:',$message)) {
627
+				} elseif (preg_match(':^#A4:',$message)) {
573 628
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
574
-				}
575
-				elseif (preg_match(':^#A6:',$message)) {
629
+				} elseif (preg_match(':^#A6:',$message)) {
576 630
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
577
-				}
578
-				elseif (preg_match(':^#A8:',$message)) {
631
+				} elseif (preg_match(':^#A8:',$message)) {
579 632
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
580
-				}
581
-				elseif (preg_match(':^#A9:',$message)) {
633
+				} elseif (preg_match(':^#A9:',$message)) {
582 634
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
583
-				}
584
-				elseif (preg_match(':^#A0:',$message)) {
635
+				} elseif (preg_match(':^#A0:',$message)) {
585 636
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
586
-				}
587
-				elseif (preg_match(':^#AA:',$message)) {
637
+				} elseif (preg_match(':^#AA:',$message)) {
588 638
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
589
-				}
590
-				elseif (preg_match(':^#AB:',$message)) {
639
+				} elseif (preg_match(':^#AB:',$message)) {
591 640
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
592
-				}
593
-				elseif (preg_match(':^#AC:',$message)) {
641
+				} elseif (preg_match(':^#AC:',$message)) {
594 642
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
595
-				}
596
-				elseif (preg_match(':^#AD:',$message)) {
643
+				} elseif (preg_match(':^#AD:',$message)) {
597 644
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
598
-				}
599
-				elseif (preg_match(':^#AF:',$message)) {
645
+				} elseif (preg_match(':^#AF:',$message)) {
600 646
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
601
-				}
602
-				elseif (preg_match(':^#B1:',$message)) {
647
+				} elseif (preg_match(':^#B1:',$message)) {
603 648
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
604
-				}
605
-				elseif (preg_match(':^#B2:',$message)) {
649
+				} elseif (preg_match(':^#B2:',$message)) {
606 650
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
607
-				}
608
-				elseif (preg_match(':^#B3:',$message)) {
651
+				} elseif (preg_match(':^#B3:',$message)) {
609 652
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
610
-				}
611
-				elseif (preg_match(':^#B4:',$message)) {
653
+				} elseif (preg_match(':^#B4:',$message)) {
612 654
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
613
-				}
614
-				elseif (preg_match(':^#B6:',$message)) {
655
+				} elseif (preg_match(':^#B6:',$message)) {
615 656
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
616
-				}
617
-				elseif (preg_match(':^#B8:',$message)) {
657
+				} elseif (preg_match(':^#B8:',$message)) {
618 658
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
619
-				}
620
-				elseif (preg_match(':^#B9:',$message)) {
659
+				} elseif (preg_match(':^#B9:',$message)) {
621 660
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
622
-				}
623
-				elseif (preg_match(':^#B0:',$message)) {
661
+				} elseif (preg_match(':^#B0:',$message)) {
624 662
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
625
-				}
626
-				elseif (preg_match(':^#BA:',$message)) {
663
+				} elseif (preg_match(':^#BA:',$message)) {
627 664
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
628
-				}
629
-				elseif (preg_match(':^#BB:',$message)) {
665
+				} elseif (preg_match(':^#BB:',$message)) {
630 666
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
631
-				}
632
-				elseif (preg_match(':^#BC:',$message)) {
667
+				} elseif (preg_match(':^#BC:',$message)) {
633 668
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
634
-				}
635
-				elseif (preg_match(':^#BD:',$message)) {
669
+				} elseif (preg_match(':^#BD:',$message)) {
636 670
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
637
-				}
638
-				elseif (preg_match(':^#BE:',$message)) {
671
+				} elseif (preg_match(':^#BE:',$message)) {
639 672
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
640
-				}
641
-				elseif (preg_match(':^#BF:',$message)) {
673
+				} elseif (preg_match(':^#BF:',$message)) {
642 674
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
643
-				}
644
-				elseif (preg_match(':^#H3:',$message)) {
675
+				} elseif (preg_match(':^#H3:',$message)) {
645 676
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
646 677
 				}
647 678
 			}
648 679
 			if ($label == '10') {
649 680
 				if (preg_match(':^DTO01:',$message)) {
650 681
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
651
-				}
652
-				elseif (preg_match(':^AIS01:',$message)) {
682
+				} elseif (preg_match(':^AIS01:',$message)) {
653 683
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
654
-				}
655
-				elseif (preg_match(':^FTX01:',$message)) {
684
+				} elseif (preg_match(':^FTX01:',$message)) {
656 685
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
657
-				}
658
-				elseif (preg_match(':^FPL01:',$message)) {
686
+				} elseif (preg_match(':^FPL01:',$message)) {
659 687
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
660
-				}
661
-				elseif (preg_match(':^WAB01:',$message)) {
688
+				} elseif (preg_match(':^WAB01:',$message)) {
662 689
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
663
-				}
664
-				elseif (preg_match(':^MET01:',$message)) {
690
+				} elseif (preg_match(':^MET01:',$message)) {
665 691
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
666
-				}
667
-				elseif (preg_match(':^WAB02:',$message)) {
692
+				} elseif (preg_match(':^WAB02:',$message)) {
668 693
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
669 694
 				}
670 695
 			}
@@ -679,38 +704,28 @@  discard block
 block discarded – undo
679 704
 					$vsta = array('Version' => $version);
680 705
 					if ($state == 'E') {
681 706
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
682
-					}
683
-					elseif ($state == 'L') {
707
+					} elseif ($state == 'L') {
684 708
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
685
-					}
686
-					else {
709
+					} else {
687 710
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
688 711
 					}
689 712
 					if ($type == 'V') {
690 713
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
691
-					}
692
-					elseif ($type == 'S') {
714
+					} elseif ($type == 'S') {
693 715
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
694
-					}
695
-					elseif ($type == 'H') {
716
+					} elseif ($type == 'H') {
696 717
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
697
-					}
698
-					elseif ($type == 'G') {
718
+					} elseif ($type == 'G') {
699 719
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
700
-					}
701
-					elseif ($type == 'C') {
720
+					} elseif ($type == 'C') {
702 721
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
703
-					}
704
-					elseif ($type == '2') {
722
+					} elseif ($type == '2') {
705 723
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
706
-					}
707
-					elseif ($type == 'X') {
724
+					} elseif ($type == 'X') {
708 725
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
709
-					}
710
-					elseif ($type == 'I') {
726
+					} elseif ($type == 'I') {
711 727
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
712
-					}
713
-					else {
728
+					} else {
714 729
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
715 730
 					}
716 731
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -719,7 +734,9 @@  discard block
 block discarded – undo
719 734
 			}
720 735
 
721 736
 			$title = $this->getTitlefromLabel($label);
722
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
737
+			if ($title != '') {
738
+				$decode = array_merge(array('Message title' => $title),$decode);
739
+			}
723 740
 			/*
724 741
 			// Business jets always use GS0001
725 742
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -754,31 +771,54 @@  discard block
 block discarded – undo
754 771
 			$msg = $message['message'];
755 772
 			$decode = $message['decode'];
756 773
 			$registration = (string)$message['registration'];
757
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
758
-			else $latitude = '';
759
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
760
-			else $longitude = '';
761
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
762
-			else $airicao = '';
763
-			if (isset($decode['icao'])) $icao = $decode['icao'];
764
-			else $icao = $Translation->checkTranslation($ident);
774
+			if (isset($decode['latitude'])) {
775
+				$latitude = $decode['latitude'];
776
+			} else {
777
+				$latitude = '';
778
+			}
779
+			if (isset($decode['longitude'])) {
780
+				$longitude = $decode['longitude'];
781
+			} else {
782
+				$longitude = '';
783
+			}
784
+			if (isset($decode['airicao'])) {
785
+				$airicao = $decode['airicao'];
786
+			} else {
787
+				$airicao = '';
788
+			}
789
+			if (isset($decode['icao'])) {
790
+				$icao = $decode['icao'];
791
+			} else {
792
+				$icao = $Translation->checkTranslation($ident);
793
+			}
765 794
 			$image_array = $Image->getSpotterImage($registration);
766 795
 			if (!isset($image_array[0]['registration'])) {
767 796
 				$Image->addSpotterImage($registration);
768 797
 			}
769 798
 			// Business jets always use GS0001
770
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
771
-			if ($globalDebug && isset($info) && $info != '') echo $info;
772
-			if (count($decode) > 0) $decode_json = json_encode($decode);
773
-			else $decode_json = '';
799
+			if ($ident != 'GS0001') {
800
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
801
+			}
802
+			if ($globalDebug && isset($info) && $info != '') {
803
+				echo $info;
804
+			}
805
+			if (count($decode) > 0) {
806
+				$decode_json = json_encode($decode);
807
+			} else {
808
+				$decode_json = '';
809
+			}
774 810
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
775 811
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
776 812
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
777 813
 				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
778 814
 			}
779 815
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
780
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
781
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
816
+			if (!isset($globalACARSArchive)) {
817
+				$globalACARSArchive = array('10','80','81','82','3F');
818
+			}
819
+			if ($result && in_array($label,$globalACARSArchive)) {
820
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
821
+			}
782 822
 			if ($globalDebug && count($decode) > 0) {
783 823
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
784 824
 			}
@@ -801,7 +841,9 @@  discard block
 block discarded – undo
801 841
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
802 842
 			$Connection = new Connection($this->db);
803 843
 			$this->db = $Connection->db;
804
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
844
+			if ($globalDebug) {
845
+				echo "Test if not already in Live ACARS table...";
846
+			}
805 847
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806 848
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
807 849
 			try {
@@ -811,7 +853,9 @@  discard block
 block discarded – undo
811 853
 				return "error : ".$e->getMessage();
812 854
 			}
813 855
 			if ($stht->fetchColumn() == 0) {
814
-				if ($globalDebug) echo "Add Live ACARS data...";
856
+				if ($globalDebug) {
857
+					echo "Add Live ACARS data...";
858
+				}
815 859
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816 860
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
817 861
 				try {
@@ -821,10 +865,14 @@  discard block
 block discarded – undo
821 865
 					return "error : ".$e->getMessage();
822 866
 				}
823 867
 			} else {
824
-				if ($globalDebug) echo "Data already in DB...\n";
868
+				if ($globalDebug) {
869
+					echo "Data already in DB...\n";
870
+				}
825 871
 				return false;
826 872
 			}
827
-			if ($globalDebug) echo "Done\n";
873
+			if ($globalDebug) {
874
+				echo "Done\n";
875
+			}
828 876
 			return true;
829 877
 		}
830 878
 	}
@@ -855,7 +903,9 @@  discard block
 block discarded – undo
855 903
 			    	    }
856 904
 				    if ($stht->fetchColumn() == 0) {
857 905
 			*/
858
-			if ($globalDebug) echo "Add Live ACARS data...";
906
+			if ($globalDebug) {
907
+				echo "Add Live ACARS data...";
908
+			}
859 909
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
860 910
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
861 911
 			try {
@@ -864,7 +914,9 @@  discard block
 block discarded – undo
864 914
 			} catch(PDOException $e) {
865 915
 				return "error : ".$e->getMessage();
866 916
 			}
867
-			if ($globalDebug) echo "Done\n";
917
+			if ($globalDebug) {
918
+				echo "Done\n";
919
+			}
868 920
 		}
869 921
 	}
870 922
 
@@ -887,8 +939,11 @@  discard block
 block discarded – undo
887 939
 			return '';
888 940
 		}
889 941
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
890
-		if (count($row) > 0) return $row[0]['title'];
891
-		else return '';
942
+		if (count($row) > 0) {
943
+			return $row[0]['title'];
944
+		} else {
945
+			return '';
946
+		}
892 947
 	}
893 948
 
894 949
 	/**
@@ -907,8 +962,11 @@  discard block
 block discarded – undo
907 962
 			return array();
908 963
 		}
909 964
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
910
-		if (count($row) > 0) return $row;
911
-		else return array();
965
+		if (count($row) > 0) {
966
+			return $row;
967
+		} else {
968
+			return array();
969
+		}
912 970
 	}
913 971
 
914 972
 	/**
@@ -928,8 +986,11 @@  discard block
 block discarded – undo
928 986
 			return array();
929 987
 		}
930 988
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
931
-		if (count($row) > 0) return $row[0];
932
-		else return array();
989
+		if (count($row) > 0) {
990
+			return $row[0];
991
+		} else {
992
+			return array();
993
+		}
933 994
 	}
934 995
 
935 996
 	/**
@@ -974,19 +1035,35 @@  discard block
 block discarded – undo
974 1035
 			if ($row['registration'] != '') {
975 1036
 				$row['registration'] = str_replace('.','',$row['registration']);
976 1037
 				$image_array = $Image->getSpotterImage($row['registration']);
977
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
978
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
979
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
980
-			if ($row['registration'] == '') $row['registration'] = 'NA';
981
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1038
+				if (count($image_array) > 0) {
1039
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1040
+				} else {
1041
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1042
+				}
1043
+			} else {
1044
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1045
+			}
1046
+			if ($row['registration'] == '') {
1047
+				$row['registration'] = 'NA';
1048
+			}
1049
+			if ($row['ident'] == '') {
1050
+				$row['ident'] = 'NA';
1051
+			}
982 1052
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
983 1053
 			if (isset($identicao[0])) {
984 1054
 				if (substr($row['ident'],0,2) == 'AF') {
985
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
986
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
987
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1055
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1056
+						$icao = $row['ident'];
1057
+					} else {
1058
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1059
+					}
1060
+				} else {
1061
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1062
+				}
988 1063
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
989
-			} else $icao = $row['ident'];
1064
+			} else {
1065
+				$icao = $row['ident'];
1066
+			}
990 1067
 			$icao = $Translation->checkTranslation($icao,false);
991 1068
 			$decode = json_decode($row['decode'],true);
992 1069
 			$found = false;
@@ -1011,7 +1088,9 @@  discard block
 block discarded – undo
1011 1088
 					$found = true;
1012 1089
 				}
1013 1090
 			}
1014
-			if ($found) $row['decode'] = json_encode($decode);
1091
+			if ($found) {
1092
+				$row['decode'] = json_encode($decode);
1093
+			}
1015 1094
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1016 1095
 			$result[] = $data;
1017 1096
 			$i++;
@@ -1019,8 +1098,9 @@  discard block
 block discarded – undo
1019 1098
 		if (isset($result)) {
1020 1099
 			$result[0]['query_number_rows'] = $i;
1021 1100
 			return $result;
1101
+		} else {
1102
+			return array();
1022 1103
 		}
1023
-		else return array();
1024 1104
 	}
1025 1105
 
1026 1106
 	/**
@@ -1070,31 +1150,51 @@  discard block
 block discarded – undo
1070 1150
 			if ($row['registration'] != '') {
1071 1151
 				$row['registration'] = str_replace('.','',$row['registration']);
1072 1152
 				$image_array = $Image->getSpotterImage($row['registration']);
1073
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1074
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1075
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1153
+				if (count($image_array) > 0) {
1154
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1155
+				} else {
1156
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1157
+				}
1158
+			} else {
1159
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1160
+			}
1076 1161
 			$icao = '';
1077
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1078
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1162
+			if ($row['registration'] == '') {
1163
+				$row['registration'] = 'NA';
1164
+			}
1165
+			if ($row['ident'] == '') {
1166
+				$row['ident'] = 'NA';
1167
+			}
1079 1168
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1080 1169
 			if (isset($identicao[0])) {
1081 1170
 				if (substr($row['ident'],0,2) == 'AF') {
1082
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1083
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1084
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1171
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1172
+						$icao = $row['ident'];
1173
+					} else {
1174
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1175
+					}
1176
+				} else {
1177
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1178
+				}
1085 1179
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1086
-			} else $icao = $row['ident'];
1180
+			} else {
1181
+				$icao = $row['ident'];
1182
+			}
1087 1183
 			$icao = $Translation->checkTranslation($icao);
1088 1184
 			$decode = json_decode($row['decode'],true);
1089 1185
 			$found = false;
1090 1186
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1091 1187
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1092
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1188
+				if (isset($airport_info[0]['icao'])) {
1189
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1190
+				}
1093 1191
 				$found = true;
1094 1192
 			}
1095 1193
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1096 1194
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1097
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1195
+				if (isset($airport_info[0]['icao'])) {
1196
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1197
+				}
1098 1198
 				$found = true;
1099 1199
 			}
1100 1200
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1104,7 +1204,9 @@  discard block
 block discarded – undo
1104 1204
 					$found = true;
1105 1205
 				}
1106 1206
 			}
1107
-			if ($found) $row['decode'] = json_encode($decode);
1207
+			if ($found) {
1208
+				$row['decode'] = json_encode($decode);
1209
+			}
1108 1210
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1109 1211
 			$result[] = $data;
1110 1212
 			$i++;
@@ -1112,7 +1214,9 @@  discard block
 block discarded – undo
1112 1214
 		if (!empty($result)) {
1113 1215
 			$result[0]['query_number_rows'] = $i;
1114 1216
 			return $result;
1115
-		} else return array();
1217
+		} else {
1218
+			return array();
1219
+		}
1116 1220
 	}
1117 1221
 
1118 1222
 	/**
@@ -1128,25 +1232,37 @@  discard block
 block discarded – undo
1128 1232
 		$ident = trim($ident);
1129 1233
 		$Translation = new Translation($this->db);
1130 1234
 		$Spotter = new Spotter($this->db);
1131
-		if ($globalDebug) echo "Test if we add ModeS data...";
1235
+		if ($globalDebug) {
1236
+			echo "Test if we add ModeS data...";
1237
+		}
1132 1238
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1133
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1134
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1239
+		if ($icao == '') {
1240
+			$icao = $Translation->checkTranslation($ident);
1241
+		}
1242
+		if ($globalDebug) {
1243
+			echo '- Ident : '.$icao.' - ';
1244
+		}
1135 1245
 		if ($ident == '' || $registration == '') {
1136
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1246
+			if ($globalDebug) {
1247
+				echo "Ident or registration null, exit\n";
1248
+			}
1137 1249
 			return '';
1138 1250
 		}
1139 1251
 		$registration = str_replace('.','',$registration);
1140 1252
 		$ident = $Translation->ident2icao($ident);
1141 1253
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1142
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1254
+		if ($globalDebug) {
1255
+			echo "Check if needed to add translation ".$ident.'... ';
1256
+		}
1143 1257
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1144 1258
 		$querysi_values = array(':registration' => $registration);
1145 1259
 		try {
1146 1260
 			$sthsi = $this->db->prepare($querysi);
1147 1261
 			$sthsi->execute($querysi_values);
1148 1262
 		} catch(PDOException $e) {
1149
-			if ($globalDebug) echo $e->getMessage();
1263
+			if ($globalDebug) {
1264
+				echo $e->getMessage();
1265
+			}
1150 1266
 			return "error : ".$e->getMessage();
1151 1267
 		}
1152 1268
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1154,9 +1270,14 @@  discard block
 block discarded – undo
1154 1270
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1155 1271
 			$Translation = new Translation($this->db);
1156 1272
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1157
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1158
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1159
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1273
+			if ($globalDebug) {
1274
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1275
+			}
1276
+			if ($ident != $trans_ident) {
1277
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1278
+			} elseif ($trans_ident == $ident) {
1279
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1280
+			}
1160 1281
 		} else {
1161 1282
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1162 1283
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1165,32 +1286,46 @@  discard block
 block discarded – undo
1165 1286
 					$sth = $this->db->prepare($query);
1166 1287
 					$sth->execute($query_values);
1167 1288
 				} catch(PDOException $e) {
1168
-					if ($globalDebug) echo $e->getMessage();
1289
+					if ($globalDebug) {
1290
+						echo $e->getMessage();
1291
+					}
1169 1292
 					return "error : ".$e->getMessage();
1170 1293
 				}
1171 1294
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1172 1295
 				$sth->closeCursor();
1173
-				if (isset($result['modes'])) $hex = $result['modes'];
1174
-				else $hex = '';
1296
+				if (isset($result['modes'])) {
1297
+					$hex = $result['modes'];
1298
+				} else {
1299
+					$hex = '';
1300
+				}
1175 1301
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1176
-				if ($this->fromACARSscript) $this->SI->add($SI_data);
1302
+				if ($this->fromACARSscript) {
1303
+					$this->SI->add($SI_data);
1304
+				}
1177 1305
 			}
1178 1306
 		}
1179
-		if ($globalDebug) echo 'Done'."\n";
1307
+		if ($globalDebug) {
1308
+			echo 'Done'."\n";
1309
+		}
1180 1310
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1181 1311
 		$query_values = array(':ident' => $icao);
1182 1312
 		try {
1183 1313
 			$sth = $this->db->prepare($query);
1184 1314
 			$sth->execute($query_values);
1185 1315
 		} catch(PDOException $e) {
1186
-			if ($globalDebug) echo $e->getMessage();
1316
+			if ($globalDebug) {
1317
+				echo $e->getMessage();
1318
+			}
1187 1319
 			return "error : ".$e->getMessage();
1188 1320
 		}
1189 1321
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1190 1322
 		$sth->closeCursor();
1191 1323
 		if (isset($result['flightaware_id'])) {
1192
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1193
-			else $ModeS = '';
1324
+			if (isset($result['ModeS'])) {
1325
+				$ModeS = $result['ModeS'];
1326
+			} else {
1327
+				$ModeS = '';
1328
+			}
1194 1329
 			if ($ModeS == '') {
1195 1330
 				$id = explode('-',$result['flightaware_id']);
1196 1331
 				$ModeS = $id[0];
@@ -1203,24 +1338,32 @@  discard block
 block discarded – undo
1203 1338
 					$sthc = $this->db->prepare($queryc);
1204 1339
 					$sthc->execute($queryc_values);
1205 1340
 				} catch(PDOException $e) {
1206
-					if ($globalDebug) echo $e->getMessage();
1341
+					if ($globalDebug) {
1342
+						echo $e->getMessage();
1343
+					}
1207 1344
 					return "error : ".$e->getMessage();
1208 1345
 				}
1209 1346
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1210 1347
 				$sthc->closeCursor();
1211 1348
 				if (count($row) ==  0) {
1212
-					if ($globalDebug) echo " Add to ModeS table - ";
1349
+					if ($globalDebug) {
1350
+						echo " Add to ModeS table - ";
1351
+					}
1213 1352
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1214 1353
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1215 1354
 					try {
1216 1355
 						$sthi = $this->db->prepare($queryi);
1217 1356
 						$sthi->execute($queryi_values);
1218 1357
 					} catch(PDOException $e) {
1219
-						if ($globalDebug) echo $e->getMessage();
1358
+						if ($globalDebug) {
1359
+							echo $e->getMessage();
1360
+						}
1220 1361
 						return "error : ".$e->getMessage();
1221 1362
 					}
1222 1363
 				} else {
1223
-					if ($globalDebug) echo " Update ModeS table - ";
1364
+					if ($globalDebug) {
1365
+						echo " Update ModeS table - ";
1366
+					}
1224 1367
 					if ($ICAOTypeCode != '') {
1225 1368
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1226 1369
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1232,7 +1375,9 @@  discard block
 block discarded – undo
1232 1375
 						$sthi = $this->db->prepare($queryi);
1233 1376
 						$sthi->execute($queryi_values);
1234 1377
 					} catch(PDOException $e) {
1235
-						if ($globalDebug) echo $e->getMessage();
1378
+						if ($globalDebug) {
1379
+							echo $e->getMessage();
1380
+						}
1236 1381
 						return "error : ".$e->getMessage();
1237 1382
 					}
1238 1383
 				}
@@ -1253,7 +1398,9 @@  discard block
 block discarded – undo
1253 1398
 					    return "error : ".$e->getMessage();
1254 1399
 				}
1255 1400
 				*/
1256
-				if ($globalDebug) echo " Update Spotter_output table - ";
1401
+				if ($globalDebug) {
1402
+					echo " Update Spotter_output table - ";
1403
+				}
1257 1404
 				if ($ICAOTypeCode != '') {
1258 1405
 					if ($globalDBdriver == 'mysql') {
1259 1406
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1264,8 +1411,7 @@  discard block
 block discarded – undo
1264 1411
 				} else {
1265 1412
 					if ($globalDBdriver == 'mysql') {
1266 1413
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1267
-					}
1268
-					elseif ($globalDBdriver == 'pgsql') {
1414
+					} elseif ($globalDBdriver == 'pgsql') {
1269 1415
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1270 1416
 					}
1271 1417
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1274,14 +1420,20 @@  discard block
 block discarded – undo
1274 1420
 					$sthi = $this->db->prepare($queryi);
1275 1421
 					$sthi->execute($queryi_values);
1276 1422
 				} catch(PDOException $e) {
1277
-					if ($globalDebug) echo $e->getMessage();
1423
+					if ($globalDebug) {
1424
+						echo $e->getMessage();
1425
+					}
1278 1426
 					return "error : ".$e->getMessage();
1279 1427
 				}
1280 1428
 			}
1281 1429
 		} else {
1282
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1430
+			if ($globalDebug) {
1431
+				echo " Can't find ModeS in spotter_output - ";
1432
+			}
1433
+		}
1434
+		if ($globalDebug) {
1435
+			echo "Done\n";
1283 1436
 		}
1284
-		if ($globalDebug) echo "Done\n";
1285 1437
 	}
1286 1438
 }
1287 1439
 ?>
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +364 added lines, -147 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 $tracker = false;
13 13
 $marine = false;
14 14
 $usecoord = false;
15
-if (isset($_GET['test'])) exit();
15
+if (isset($_GET['test'])) {
16
+	exit();
17
+}
16 18
 if (isset($_GET['tracker'])) {
17 19
     $tracker = true;
18 20
 }
@@ -57,31 +59,62 @@  discard block
 block discarded – undo
57 59
 }
58 60
 header('Content-Type: text/javascript');
59 61
 
60
-if (!isset($globalJsonCompress)) $compress = true;
61
-else $compress = $globalJsonCompress;
62
+if (!isset($globalJsonCompress)) {
63
+	$compress = true;
64
+} else {
65
+	$compress = $globalJsonCompress;
66
+}
62 67
 
63 68
 $limit = 0;
64 69
 $from_archive = false;
65 70
 $min = true;
66 71
 $allhistory = false;
67 72
 $filter['source'] = array();
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
70
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
73
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
79
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
80
-if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') $filter['blocked'] = true;
73
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
75
+}
76
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
77
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
78
+}
79
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
80
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
81
+}
82
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
83
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
84
+}
85
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
86
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
87
+}
88
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
89
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
90
+}
91
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
92
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
93
+}
94
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
95
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
96
+}
97
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
98
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
99
+}
100
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
101
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
102
+}
103
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
104
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
105
+}
106
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') {
107
+	$filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
108
+}
109
+if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') {
110
+	$filter['blocked'] = true;
111
+}
81 112
 
82 113
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
83 114
 	$min = true;
84
-} else $min = false;
115
+} else {
116
+	$min = false;
117
+}
85 118
 
86 119
 
87 120
 if (isset($_COOKIE['map_2d_limit'])) {
@@ -197,24 +230,38 @@  discard block
 block discarded – undo
197 230
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
198 231
 		}
199 232
 	}
200
-	if ($flightcnt == '') $flightcnt = 0;
201
-} else $flightcnt = 0;
233
+	if ($flightcnt == '') {
234
+		$flightcnt = 0;
235
+	}
236
+	} else {
237
+	$flightcnt = 0;
238
+}
202 239
 
203 240
 $sqltime = round(microtime(true)-$begintime,2);
204 241
 
205 242
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
206
-if ($currenttime != '') $currenttime = round($currenttime/1000);
243
+if ($currenttime != '') {
244
+	$currenttime = round($currenttime/1000);
245
+}
207 246
 
208
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation === FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
209
-else $usenextlatlon = true;
210
-if ($usenextlatlon === false) $currenttime = '';
247
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation === FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
248
+	$usenextlatlon = false;
249
+} else {
250
+	$usenextlatlon = true;
251
+}
252
+if ($usenextlatlon === false) {
253
+	$currenttime = '';
254
+}
211 255
 $j = 0;
212 256
 $prev_flightaware_id = '';
213 257
 $aircrafts_shadow = array();
214 258
 $output = '{';
215 259
 	$output .= '"type": "FeatureCollection",';
216
-		if ($min) $output .= '"minimal": "true",';
217
-		else $output .= '"minimal": "false",';
260
+		if ($min) {
261
+			$output .= '"minimal": "true",';
262
+		} else {
263
+			$output .= '"minimal": "false",';
264
+		}
218 265
 		//$output .= '"fc": "'.$flightcnt.'",';
219 266
 		$output .= '"sqt": "'.$sqltime.'",';
220 267
 
@@ -259,18 +306,29 @@  discard block
 block discarded – undo
259 306
 						}
260 307
 						$output .= '"properties": {';
261 308
 						if (isset($spotter_item['flightaware_id'])) {
262
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
263
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
309
+							if ($compress) {
310
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
311
+							} else {
312
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
313
+							}
264 314
 						} elseif (isset($spotter_item['famtrackid'])) {
265
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
266
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
315
+							if ($compress) {
316
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
317
+							} else {
318
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
319
+							}
267 320
 						} elseif (isset($spotter_item['fammarine_id'])) {
268
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
269
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
321
+							if ($compress) {
322
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
323
+							} else {
324
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
325
+							}
270 326
 						}
271 327
 						$output .= '"fc": "'.$flightcnt.'",';
272 328
 						$output .= '"sqt": "'.$sqltime.'",';
273
-						if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
329
+						if (isset($begindate)) {
330
+							$output .= '"archive_date": "'.$begindate.'",';
331
+						}
274 332
 
275 333
 /*
276 334
 							if ($min) $output .= '"minimal": "true",';
@@ -278,16 +336,25 @@  discard block
 block discarded – undo
278 336
 */
279 337
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
280 338
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
281
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
282
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
339
+							if ($compress) {
340
+								$output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
341
+							} else {
342
+								$output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
343
+							}
283 344
 							//'
284 345
 						} else {
285
-							if ($compress) $output .= '"c": "NA",';
286
-							else $output .= '"callsign": "NA",';
346
+							if ($compress) {
347
+								$output .= '"c": "NA",';
348
+							} else {
349
+								$output .= '"callsign": "NA",';
350
+							}
287 351
 						}
288 352
 						if (isset($spotter_item['registration'])) {
289
-							if ($compress) $output .= '"reg": '.json_encode($spotter_item['registration']).',';
290
-							else $output .= '"registration": '.json_encode($spotter_item['registration']).',';
353
+							if ($compress) {
354
+								$output .= '"reg": '.json_encode($spotter_item['registration']).',';
355
+							} else {
356
+								$output .= '"registration": '.json_encode($spotter_item['registration']).',';
357
+							}
291 358
 						}
292 359
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
293 360
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
@@ -298,20 +365,30 @@  discard block
 block discarded – undo
298 365
 							$output .= '"aircraft_name": "NA",';
299 366
 						}
300 367
 						if (isset($spotter_item['aircraft_icao'])) {
301
-							if ($compress) $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
302
-							else $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
368
+							if ($compress) {
369
+								$output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
370
+							} else {
371
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
372
+							}
303 373
 						}
304 374
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) {
305
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
306
-							else {
375
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
376
+								$spotter_item['aircraft_shadow'] = '';
377
+							} else {
307 378
 								$aircraft_icao = $spotter_item['aircraft_icao'];
308
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
309
-								else {
379
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
380
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
381
+								} else {
310 382
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
311
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
312
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
313
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
314
-									else $spotter_item['aircraft_shadow'] = '';
383
+									if (count($aircraft_info) > 0) {
384
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
385
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
386
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
387
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
388
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
389
+									} else {
390
+										$spotter_item['aircraft_shadow'] = '';
391
+									}
315 392
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
316 393
 								}
317 394
 							}
@@ -319,90 +396,171 @@  discard block
 block discarded – undo
319 396
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
320 397
 							if ($tracker) {
321 398
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
322
-									if ($compress) $output .= '"as": "ambulance.png",';
323
-									else $output .= '"aircraft_shadow": "ambulance.png",';
399
+									if ($compress) {
400
+										$output .= '"as": "ambulance.png",';
401
+									} else {
402
+										$output .= '"aircraft_shadow": "ambulance.png",';
403
+									}
324 404
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
325
-									if ($compress) $output .= '"as": "police.png",';
326
-									else $output .= '"aircraft_shadow": "police.png",';
405
+									if ($compress) {
406
+										$output .= '"as": "police.png",';
407
+									} else {
408
+										$output .= '"aircraft_shadow": "police.png",';
409
+									}
327 410
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
328
-									if ($compress) $output .= '"as": "ship.png",';
329
-									else $output .= '"aircraft_shadow": "ship.png",';
411
+									if ($compress) {
412
+										$output .= '"as": "ship.png",';
413
+									} else {
414
+										$output .= '"aircraft_shadow": "ship.png",';
415
+									}
330 416
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
331
-									if ($compress) $output .= '"as": "ship.png",';
332
-									else $output .= '"aircraft_shadow": "ship.png",';
417
+									if ($compress) {
418
+										$output .= '"as": "ship.png",';
419
+									} else {
420
+										$output .= '"aircraft_shadow": "ship.png",';
421
+									}
333 422
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
334
-									if ($compress) $output .= '"as": "ship.png",';
335
-									else $output .= '"aircraft_shadow": "ship.png",';
423
+									if ($compress) {
424
+										$output .= '"as": "ship.png",';
425
+									} else {
426
+										$output .= '"aircraft_shadow": "ship.png",';
427
+									}
336 428
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
337
-									if ($compress) $output .= '"as": "truck.png",';
338
-									else $output .= '"aircraft_shadow": "truck.png",';
429
+									if ($compress) {
430
+										$output .= '"as": "truck.png",';
431
+									} else {
432
+										$output .= '"aircraft_shadow": "truck.png",';
433
+									}
339 434
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
340
-									if ($compress) $output .= '"as": "truck.png",';
341
-									else $output .= '"aircraft_shadow": "truck.png",';
435
+									if ($compress) {
436
+										$output .= '"as": "truck.png",';
437
+									} else {
438
+										$output .= '"aircraft_shadow": "truck.png",';
439
+									}
342 440
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
343
-									if ($compress) $output .= '"as": "aircraft.png",';
344
-									else $output .= '"aircraft_shadow": "aircraft.png",';
441
+									if ($compress) {
442
+										$output .= '"as": "aircraft.png",';
443
+									} else {
444
+										$output .= '"aircraft_shadow": "aircraft.png",';
445
+									}
345 446
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
346
-									if ($compress) $output .= '"as": "aircraft.png",';
347
-									else $output .= '"aircraft_shadow": "aircraft.png",';
447
+									if ($compress) {
448
+										$output .= '"as": "aircraft.png",';
449
+									} else {
450
+										$output .= '"aircraft_shadow": "aircraft.png",';
451
+									}
348 452
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
349
-									if ($compress) $output .= '"as": "helico.png",';
350
-									else $output .= '"aircraft_shadow": "helico.png",';
453
+									if ($compress) {
454
+										$output .= '"as": "helico.png",';
455
+									} else {
456
+										$output .= '"aircraft_shadow": "helico.png",';
457
+									}
351 458
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
352
-									if ($compress) $output .= '"as": "rail.png",';
353
-									else $output .= '"aircraft_shadow": "rail.png",';
459
+									if ($compress) {
460
+										$output .= '"as": "rail.png",';
461
+									} else {
462
+										$output .= '"aircraft_shadow": "rail.png",';
463
+									}
354 464
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
355
-									if ($compress) $output .= '"as": "firetruck.png",';
356
-									else $output .= '"aircraft_shadow": "firetruck.png",';
465
+									if ($compress) {
466
+										$output .= '"as": "firetruck.png",';
467
+									} else {
468
+										$output .= '"aircraft_shadow": "firetruck.png",';
469
+									}
357 470
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
358
-									if ($compress) $output .= '"as": "bus.png",';
359
-									else $output .= '"aircraft_shadow": "bus.png",';
471
+									if ($compress) {
472
+										$output .= '"as": "bus.png",';
473
+									} else {
474
+										$output .= '"aircraft_shadow": "bus.png",';
475
+									}
360 476
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
361
-									if ($compress) $output .= '"as": "phone.png",';
362
-									else $output .= '"aircraft_shadow": "phone.png",';
477
+									if ($compress) {
478
+										$output .= '"as": "phone.png",';
479
+									} else {
480
+										$output .= '"aircraft_shadow": "phone.png",';
481
+									}
363 482
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
364
-									if ($compress) $output .= '"as": "jogger.png",';
365
-									else $output .= '"aircraft_shadow": "jogger.png",';
483
+									if ($compress) {
484
+										$output .= '"as": "jogger.png",';
485
+									} else {
486
+										$output .= '"aircraft_shadow": "jogger.png",';
487
+									}
366 488
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
367
-									if ($compress) $output .= '"as": "bike.png",';
368
-									else $output .= '"aircraft_shadow": "bike.png",';
489
+									if ($compress) {
490
+										$output .= '"as": "bike.png",';
491
+									} else {
492
+										$output .= '"aircraft_shadow": "bike.png",';
493
+									}
369 494
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
370
-									if ($compress) $output .= '"as": "motorcycle.png",';
371
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
495
+									if ($compress) {
496
+										$output .= '"as": "motorcycle.png",';
497
+									} else {
498
+										$output .= '"aircraft_shadow": "motorcycle.png",';
499
+									}
372 500
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
373
-									if ($compress) $output .= '"as": "balloon.png",';
374
-									else $output .= '"aircraft_shadow": "balloon.png",';
501
+									if ($compress) {
502
+										$output .= '"as": "balloon.png",';
503
+									} else {
504
+										$output .= '"aircraft_shadow": "balloon.png",';
505
+									}
375 506
 								} else {
376
-									if ($compress) $output .= '"as": "car.png",';
377
-									else $output .= '"aircraft_shadow": "car.png",';
507
+									if ($compress) {
508
+										$output .= '"as": "car.png",';
509
+									} else {
510
+										$output .= '"aircraft_shadow": "car.png",';
511
+									}
378 512
 								}
379 513
 							} elseif ($marine) {
380 514
 								if (isset($spotter_item['type']) && ($spotter_item['type']  == '50&#39; Performance Cruiser' || $spotter_item['type']  == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
381
-									if ($compress) $output .= '"as": "50perfcruiser.png",';
382
-									else $output .= '"aircraft_shadow": "50perfcruiser.png",';
515
+									if ($compress) {
516
+										$output .= '"as": "50perfcruiser.png",';
517
+									} else {
518
+										$output .= '"aircraft_shadow": "50perfcruiser.png",';
519
+									}
383 520
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Sailaway Cruiser 38') {
384
-									if ($compress) $output .= '"as": "cruiser38.png",';
385
-									else $output .= '"aircraft_shadow": "cruiser38.png",';
521
+									if ($compress) {
522
+										$output .= '"as": "cruiser38.png",';
523
+									} else {
524
+										$output .= '"aircraft_shadow": "cruiser38.png",';
525
+									}
386 526
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Mini Transat') {
387
-									if ($compress) $output .= '"as": "transat.png",';
388
-									else $output .= '"aircraft_shadow": "transat.png",';
527
+									if ($compress) {
528
+										$output .= '"as": "transat.png",';
529
+									} else {
530
+										$output .= '"aircraft_shadow": "transat.png",';
531
+									}
389 532
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == '52&#39; Cruising Cat') {
390
-									if ($compress) $output .= '"as": "catamaran.png",';
391
-									else $output .= '"aircraft_shadow": "catamaran.png",';
533
+									if ($compress) {
534
+										$output .= '"as": "catamaran.png",';
535
+									} else {
536
+										$output .= '"aircraft_shadow": "catamaran.png",';
537
+									}
392 538
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Caribbean Rose') {
393
-									if ($compress) $output .= '"as": "carib.png",';
394
-									else $output .= '"aircraft_shadow": "carib.png",';
539
+									if ($compress) {
540
+										$output .= '"as": "carib.png",';
541
+									} else {
542
+										$output .= '"aircraft_shadow": "carib.png",';
543
+									}
395 544
 								} else {
396
-									if ($compress) $output .= '"as": "ship.png",';
397
-									else $output .= '"aircraft_shadow": "ship.png",';
545
+									if ($compress) {
546
+										$output .= '"as": "ship.png",';
547
+									} else {
548
+										$output .= '"aircraft_shadow": "ship.png",';
549
+									}
398 550
 								}
399 551
 							} else {
400
-								if ($compress) $output .= '"as": "default.png",';
401
-								else $output .= '"aircraft_shadow": "default.png",';
552
+								if ($compress) {
553
+									$output .= '"as": "default.png",';
554
+								} else {
555
+									$output .= '"aircraft_shadow": "default.png",';
556
+								}
402 557
 							}
403 558
 						} else {
404
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
405
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
559
+							if ($compress) {
560
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
561
+							} else {
562
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
563
+							}
406 564
 						}
407 565
 						if (isset($spotter_item['airline_name'])) {
408 566
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -410,8 +568,11 @@  discard block
 block discarded – undo
410 568
 							$output .= '"airline_name": "NA",';
411 569
 						}
412 570
 						if (isset($spotter_item['departure_airport'])) {
413
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
414
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
571
+							if ($compress) {
572
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
573
+							} else {
574
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
575
+							}
415 576
 						}
416 577
 						if (isset($spotter_item['departure_airport_city'])) {
417 578
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -423,8 +584,11 @@  discard block
 block discarded – undo
423 584
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
424 585
 						}
425 586
 						if (isset($spotter_item['arrival_airport'])) {
426
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
427
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
587
+							if ($compress) {
588
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
589
+							} else {
590
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
591
+							}
428 592
 						}
429 593
 						if (isset($spotter_item['arrival_airport_city'])) {
430 594
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -443,11 +607,17 @@  discard block
 block discarded – undo
443 607
 						}
444 608
 						
445 609
 						if (isset($spotter_item['real_altitude'])) {
446
-							if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
447
-							else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
610
+							if ($compress) {
611
+								$output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
612
+							} else {
613
+								$output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
614
+							}
448 615
 						} elseif (isset($spotter_item['altitude'])) {
449
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
450
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
616
+							if ($compress) {
617
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
618
+							} else {
619
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
620
+							}
451 621
 						}
452 622
 						
453 623
 						$heading = $spotter_item['heading'];
@@ -471,19 +641,24 @@  discard block
 block discarded – undo
471 641
 							}
472 642
 						}
473 643
 						
474
-						if ($compress)$output .= '"h": "'.$heading.'",';
475
-						else $output .= '"heading": "'.$heading.'",';
644
+						if ($compress) {
645
+							$output .= '"h": "'.$heading.'",';
646
+						} else {
647
+							$output .= '"heading": "'.$heading.'",';
648
+						}
476 649
 						if ($currenttime != '') {
477 650
 							if (strtotime($spotter_item['date']) < $currenttime) {
478 651
 								if (isset($archivespeed)) {
479 652
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
480 653
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
481
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
482
-									else {
654
+									if (!isset($idistance) || $fdistance < $idistance) {
655
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
656
+									} else {
483 657
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
484 658
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
485
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
486
-										else {
659
+										if (!isset($idistance) || $fdistance < $idistance) {
660
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
661
+										} else {
487 662
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
488 663
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
489 664
 										}
@@ -491,12 +666,14 @@  discard block
 block discarded – undo
491 666
 								} elseif ($usenextlatlon) {
492 667
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
493 668
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
494
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
495
-									else {
669
+									if (!isset($idistance) || $fdistance < $idistance) {
670
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
671
+									} else {
496 672
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
497 673
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
498
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
499
-										else {
674
+										if (!isset($idistance) || $fdistance < $idistance) {
675
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
676
+										} else {
500 677
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
501 678
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
502 679
 										}
@@ -535,7 +712,9 @@  discard block
 block discarded – undo
535 712
 							}
536 713
 						}
537 714
 
538
-						if (!$min) $output .= '"image": "'.$image.'",';
715
+						if (!$min) {
716
+							$output .= '"image": "'.$image.'",';
717
+						}
539 718
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
540 719
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
541 720
 						}
@@ -543,8 +722,11 @@  discard block
 block discarded – undo
543 722
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
544 723
 						}
545 724
 						if (isset($spotter_item['squawk'])) {
546
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
547
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
725
+							if ($compress) {
726
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
727
+							} else {
728
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
729
+							}
548 730
 						}
549 731
 						if (isset($spotter_item['squawk_usage'])) {
550 732
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -575,14 +757,23 @@  discard block
 block discarded – undo
575 757
 						}
576 758
 						// type when not aircraft ?
577 759
 						if (isset($spotter_item['type'])) {
578
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
579
-							else $output .= '"type": "'.$spotter_item['type'].'"';
760
+							if ($compress) {
761
+								$output .= '"t": "'.$spotter_item['type'].'"';
762
+							} else {
763
+								$output .= '"type": "'.$spotter_item['type'].'"';
764
+							}
580 765
 						} elseif ($marine) {
581
-							if ($compress) $output .= '"t": "ship"';
582
-							else $output .= '"type": "ship"';
766
+							if ($compress) {
767
+								$output .= '"t": "ship"';
768
+							} else {
769
+								$output .= '"type": "ship"';
770
+							}
583 771
 						} else {
584
-							if ($compress) $output .= '"t": "aircraft"';
585
-							else $output .= '"type": "aircraft"';
772
+							if ($compress) {
773
+								$output .= '"t": "aircraft"';
774
+							} else {
775
+								$output .= '"type": "aircraft"';
776
+							}
586 777
 						}
587 778
 						$output .= '},';
588 779
 						$output .= '"geometry": {';
@@ -590,15 +781,19 @@  discard block
 block discarded – undo
590 781
 								$output .= '"coordinates": [';
591 782
 								if ($currenttime != '') {
592 783
 									if (strtotime($spotter_item['date']) < $currenttime) {
593
-										if (!isset($archivespeed)) $archivespeed = 1;
784
+										if (!isset($archivespeed)) {
785
+											$archivespeed = 1;
786
+										}
594 787
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
595 788
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
596
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
597
-										else {
789
+										if (!isset($idistance) || $fdistance < $idistance) {
790
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
791
+										} else {
598 792
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
599 793
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
600
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
601
-											else {
794
+											if (!isset($idistance) || $fdistance < $idistance) {
795
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
796
+											} else {
602 797
 												$output .= $spotter_item['longitude'].', ';
603 798
 												$output .= $spotter_item['latitude'];
604 799
 											}
@@ -676,7 +871,9 @@  discard block
 block discarded – undo
676 871
 			}
677 872
 */
678 873
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
679
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
874
+				if ($history == '' && isset($_COOKIE['history'])) {
875
+					$history = $_COOKIE['history'];
876
+				}
680 877
 				
681 878
 				if (
682 879
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -746,8 +943,11 @@  discard block
 block discarded – undo
746 943
 									$output_history .= ']}},';
747 944
 									$output .= $output_history;
748 945
 								}
749
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
750
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
946
+								if ($compress) {
947
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
948
+								} else {
949
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
950
+								}
751 951
 							}
752 952
 							$output_history .= '[';
753 953
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -768,10 +968,15 @@  discard block
 block discarded – undo
768 968
 							if ($d === false) {
769 969
 								if ($compress) {
770 970
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
771
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
772
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
971
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
972
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
973
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
974
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
975
+									}
773 976
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
774
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
977
+								} else {
978
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
979
+								}
775 980
 								$d = true;
776 981
 							}
777 982
 							$output_history .= '[';
@@ -794,7 +999,9 @@  discard block
 block discarded – undo
794 999
 							$output_historyd = '[';
795 1000
 							$output_historyd .=  $spotter_item['longitude'].', ';
796 1001
 							$output_historyd .=  $spotter_item['latitude'];
797
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
1002
+							if (isset($spotter_history['altitude'])) {
1003
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
1004
+							}
798 1005
 							$output_historyd .= '],';
799 1006
 							//$output_history = $output_historyd.$output_history;
800 1007
 							$output_history = $output_history.$output_historyd;
@@ -822,8 +1029,11 @@  discard block
 block discarded – undo
822 1029
 				        && $spotter_item['arrival_airport'] != 'NA' 
823 1030
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
824 1031
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
825
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
826
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
1032
+				    if ($compress) {
1033
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
1034
+				    } else {
1035
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
1036
+				    }
827 1037
 				    if (isset($spotter_item['departure_airport_latitude'])) {
828 1038
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
829 1039
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -856,8 +1066,11 @@  discard block
 block discarded – undo
856 1066
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
857 1067
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
858 1068
 				    $havedata = false;
859
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
860
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1069
+				    if ($compress) {
1070
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1071
+				    } else {
1072
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1073
+				    }
861 1074
 				    
862 1075
 				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
863 1076
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -882,7 +1095,9 @@  discard block
 block discarded – undo
882 1095
 					$output_dest  = substr($output_dest, 0, -1);
883 1096
 				    }
884 1097
 				    $output_dest .= ']}},';
885
-				    if ($havedata) $output .= $output_dest;
1098
+				    if ($havedata) {
1099
+				    	$output .= $output_dest;
1100
+				    }
886 1101
 				    unset($output_dest);
887 1102
 				}
888 1103
 			}
@@ -890,7 +1105,9 @@  discard block
 block discarded – undo
890 1105
 			$output .= ']';
891 1106
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
892 1107
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
893
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1108
+			if (isset($begindate)) {
1109
+				$output .= '"archive_date": "'.$begindate.'",';
1110
+			}
894 1111
 			$output .= '"fc": "'.$j.'"';
895 1112
 		} else {
896 1113
 			$output .= '"features": ';
Please login to merge, or discard this patch.