Completed
Push — master ( a8508e...6e0b95 )
by Yannick
06:03
created
require/class.ACARS.php 3 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 		$this->SI = new SpotterImport($this->db);
17 17
 	}
18 18
 	/**
19
-	* Change IATA to ICAO value for ident
20
-	*
21
-	* @param String $ident ident
22
-	* @return String the icao
23
-	*/
19
+	 * Change IATA to ICAO value for ident
20
+	 *
21
+	 * @param String $ident ident
22
+	 * @return String the icao
23
+	 */
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26 26
 			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	/**
39
-	* Deletes all info in the live table
40
-	*
41
-	* @return String success or false
42
-	*
43
-	*/
39
+	 * Deletes all info in the live table
40
+	 *
41
+	 * @return String success or false
42
+	 *
43
+	 */
44 44
 	public function deleteLiveAcarsData()
45 45
 	{
46 46
 		global $globalDBdriver;
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 	/**
63
-	* Deletes all info in the archive table
64
-	*
65
-	* @return String success or false
66
-	*
67
-	*/
63
+	 * Deletes all info in the archive table
64
+	 *
65
+	 * @return String success or false
66
+	 *
67
+	 */
68 68
 	public function deleteArchiveAcarsData()
69 69
 	{
70 70
 		global $globalACARSArchiveKeepMonths, $globalDBdriver;
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 
86 86
 
87 87
 	/**
88
-	* Parse ACARS data
89
-	*
90
-	* @param String ACARS data in acarsdec data
91
-	*
92
-	*/
88
+	 * Parse ACARS data
89
+	 *
90
+	 * @param String ACARS data in acarsdec data
91
+	 *
92
+	 */
93 93
 	public function parse($data) {
94 94
 		global $globalDebug, $globalACARSArchive;
95 95
 		//$Image = new Image($this->db);
@@ -666,11 +666,11 @@  discard block
 block discarded – undo
666 666
 
667 667
 
668 668
 	/**
669
-	* Add ACARS data
670
-	*
671
-	* @param String ACARS data in acarsdec data
672
-	*
673
-	*/
669
+	 * Add ACARS data
670
+	 *
671
+	 * @param String ACARS data in acarsdec data
672
+	 *
673
+	 */
674 674
 	function add($data) {
675 675
 		global $globalDebug, $globalACARSArchive;
676 676
 		$Image = new Image($this->db);
@@ -725,15 +725,15 @@  discard block
 block discarded – undo
725 725
 	}
726 726
 
727 727
 	/**
728
-	* Add Live ACARS data in DB
729
-	*
730
-	* @param String $ident ident
731
-	* @param String $registration Registration of the aircraft
732
-	* @param String $label Label of the ACARS message
733
-	* @param String $block_id Block id of the ACARS message
734
-	* @param String $msg_no Number of the ACARS message
735
-	* @param String $message ACARS message
736
-	*/
728
+	 * Add Live ACARS data in DB
729
+	 *
730
+	 * @param String $ident ident
731
+	 * @param String $registration Registration of the aircraft
732
+	 * @param String $label Label of the ACARS message
733
+	 * @param String $block_id Block id of the ACARS message
734
+	 * @param String $msg_no Number of the ACARS message
735
+	 * @param String $message ACARS message
736
+	 */
737 737
 	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
738 738
 		global $globalDebug;
739 739
 		date_default_timezone_set('UTC');
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
 	}
772 772
 
773 773
 	/**
774
-	* Add Archive ACARS data in DB
775
-	*
776
-	* @param String $ident ident
777
-	* @param String $registration Registration of the aircraft
778
-	* @param String $label Label of the ACARS message
779
-	* @param String $block_id Block id of the ACARS message
780
-	* @param String $msg_no Number of the ACARS message
781
-	* @param String $message ACARS message
782
-	*/
774
+	 * Add Archive ACARS data in DB
775
+	 *
776
+	 * @param String $ident ident
777
+	 * @param String $registration Registration of the aircraft
778
+	 * @param String $label Label of the ACARS message
779
+	 * @param String $block_id Block id of the ACARS message
780
+	 * @param String $msg_no Number of the ACARS message
781
+	 * @param String $message ACARS message
782
+	 */
783 783
 	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
784 784
 		global $globalDebug;
785 785
 		date_default_timezone_set('UTC');
@@ -813,11 +813,11 @@  discard block
 block discarded – undo
813 813
 	}
814 814
 
815 815
 	/**
816
-	* Get Message title from label from DB
817
-	*
818
-	* @param String $label
819
-	* @return String Return ACARS title
820
-	*/
816
+	 * Get Message title from label from DB
817
+	 *
818
+	 * @param String $label
819
+	 * @return String Return ACARS title
820
+	 */
821 821
 	public function getTitlefromLabel($label) {
822 822
 		$Connection = new Connection($this->db);
823 823
 		$this->db = $Connection->db;
@@ -837,10 +837,10 @@  discard block
 block discarded – undo
837 837
 	}
838 838
 
839 839
 	/**
840
-	* List all Message title & label from DB
841
-	*
842
-	* @return Array Return ACARS data in array
843
-	*/
840
+	 * List all Message title & label from DB
841
+	 *
842
+	 * @return Array Return ACARS data in array
843
+	 */
844 844
 	public function getAllTitleLabel() {
845 845
 		$query = "SELECT * FROM acars_label ORDER BY title";
846 846
 		$query_values = array();
@@ -858,11 +858,11 @@  discard block
 block discarded – undo
858 858
 	}
859 859
 
860 860
 	/**
861
-	* Get Live ACARS data from DB
862
-	*
863
-	* @param String $ident
864
-	* @return Array Return ACARS data in array
865
-	*/
861
+	 * Get Live ACARS data from DB
862
+	 *
863
+	 * @param String $ident
864
+	 * @return Array Return ACARS data in array
865
+	 */
866 866
 	public function getLiveAcarsData($ident) {
867 867
 		$query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC";
868 868
 		$query_values = array(':ident' => $ident);
@@ -880,10 +880,10 @@  discard block
 block discarded – undo
880 880
 	}
881 881
 
882 882
 	/**
883
-	* Get Latest ACARS data from DB
884
-	*
885
-	* @return Array Return ACARS data in array
886
-	*/
883
+	 * Get Latest ACARS data from DB
884
+	 *
885
+	 * @return Array Return ACARS data in array
886
+	 */
887 887
 	public function getLatestAcarsData($limit = '',$label = '') {
888 888
 		global $globalURL, $globalDBdriver;
889 889
 		$Image = new Image($this->db);
@@ -980,10 +980,10 @@  discard block
 block discarded – undo
980 980
 	}
981 981
 
982 982
 	/**
983
-	* Get Archive ACARS data from DB
984
-	*
985
-	* @return Array Return ACARS data in array
986
-	*/
983
+	 * Get Archive ACARS data from DB
984
+	 *
985
+	 * @return Array Return ACARS data in array
986
+	 */
987 987
 	public function getArchiveAcarsData($limit = '',$label = '') {
988 988
 		global $globalURL, $globalDBdriver;
989 989
 		$Image = new Image($this->db);
@@ -1085,13 +1085,13 @@  discard block
 block discarded – undo
1085 1085
 	}
1086 1086
 
1087 1087
 	/**
1088
-	* Add ModeS data to DB
1089
-	*
1090
-	* @param String $ident ident
1091
-	* @param String $registration Registration of the aircraft
1092
-	* @param String $icao
1093
-	* @param String $ICAOTypeCode
1094
-	*/
1088
+	 * Add ModeS data to DB
1089
+	 *
1090
+	 * @param String $ident ident
1091
+	 * @param String $registration Registration of the aircraft
1092
+	 * @param String $icao
1093
+	 * @param String $ICAOTypeCode
1094
+	 */
1095 1095
 	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1096 1096
 		global $globalDebug, $globalDBdriver;
1097 1097
 		$ident = trim($ident);
Please login to merge, or discard this patch.
Spacing   +251 added lines, -251 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	* @return String the icao
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25
-		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
25
+		if (substr($ident, 0, 2) == 'AF') {
26
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
28 28
 		} else {
29 29
 			$Spotter = new Spotter($this->db);
30
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
30
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
31 31
 			if (isset($identicao[0])) {
32
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
32
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
33 33
 			} else $icao = $ident;
34 34
 		}
35 35
 		return $icao;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 			$sth = $this->db->prepare($query);
55 55
 			$sth->execute();
56
-		} catch(PDOException $e) {
56
+		} catch (PDOException $e) {
57 57
 			return "error";
58 58
 		}
59 59
 		return "success";
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 			$sth = $this->db->prepare($query);
79 79
 			$sth->execute();
80
-		} catch(PDOException $e) {
80
+		} catch (PDOException $e) {
81 81
 			return "error";
82 82
 		}
83 83
 		return "success";
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 		$ident = '';
103 103
 		$message = '';
104 104
 		$result = array();
105
-		$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);
106
-		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);
105
+		$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);
106
+		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);
107 107
 		if ($n != 0) {
108
-			$registration = str_replace('.','',$registration);
109
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
108
+			$registration = str_replace('.', '', $registration);
109
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
110 110
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
111 111
 		} else $message = $data;
112 112
 		$icao = '';
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
 				//$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%*11[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $temp);
121 121
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
122 122
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
123
-					$latitude = $la / 10000.0;
124
-					$longitude = $ln / 10000.0;
123
+					$latitude = $la/10000.0;
124
+					$longitude = $ln/10000.0;
125 125
 					if ($lac == 'S') $latitude = '-'.$latitude;
126 126
 					if ($lnc == 'W') $longitude = '-'.$longitude;
127 127
 					// Temp not always available
128 128
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
129
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
130
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
129
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
130
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
131 131
 
132 132
 					//$icao = $Translation->checkTranslation($ident);
133 133
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -135,19 +135,19 @@  discard block
 block discarded – undo
135 135
 				}
136 136
 			}
137 137
 			if (!$found && ($label == '10')) {
138
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
138
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
139 139
 				if ($n == 4 && strlen($darr) == 4) {
140
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
141
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
142
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
140
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
141
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
142
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
143 143
 					//$icao = ACARS->ident2icao($ident);
144 144
 					//$icao = $Translation->checkTranslation($ident);
145 145
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
146 146
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
147 147
 					$found = true;
148 148
 				}
149
-				elseif ($n == 2 || $n  == 4) {
150
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
149
+				elseif ($n == 2 || $n == 4) {
150
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
151 151
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
152 152
 					//$icao = ACARS->ident2icao($ident);
153 153
 					//$icao = $Translation->checkTranslation($ident);
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 				*/
196 196
 
197 197
 				//$n = sscanf($message, "%*[0-9A-Z]/%*3d/%4s/%*c\nSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d\n%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
198
-				$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);
198
+				$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);
199 199
 				if ($n > 8) {
200
-					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";
201
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
202
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
200
+					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";
201
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
202
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
203 203
 					$icao = trim($aident);
204 204
 
205 205
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
220 220
 					$las = $las.'.'.$lass;
221 221
 					$lns = $lns.'.'.$lns;
222
-					$latitude = $las / 1000.0;
223
-					$longitude = $lns / 1000.0;
222
+					$latitude = $las/1000.0;
223
+					$longitude = $lns/1000.0;
224 224
 					if ($lac == 'S') $latitude = '-'.$latitude;
225 225
 					if ($lnc == 'W') $longitude = '-'.$longitude;
226 226
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
 				RMK/FUEL   2.6 M0.79)
298 298
 				*/
299 299
 				//$n = sscanf($message, "#DFB(POS-%s -%4d%c%5d%c/%*d F%d\nRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
300
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
300
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
301 301
 				if ($n == 9) {
302 302
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
303 303
 					$icao = trim($aident);
304 304
 					$decode['icao'] = $icao;
305
-					$latitude = $las / 100.0;
306
-					$longitude = $lns / 100.0;
305
+					$latitude = $las/100.0;
306
+					$longitude = $lns/100.0;
307 307
 					if ($lac == 'S') $latitude = '-'.$latitude;
308 308
 					if ($lnc == 'W') $longitude = '-'.$longitude;
309 309
 
310
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
310
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
311 311
 					$found = true;
312 312
 				}
313 313
 			}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 					if ($lac == 'S') $latitude = '-'.$latitude;
323 323
 					if ($lnc == 'W') $longitude = '-'.$longitude;
324 324
 
325
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
325
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
326 326
 					$found = true;
327 327
 				}
328 328
 			}
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 				DABNK,10100,  7100,02:46, 200, 44068,52.4, 77000, 62500, 66000,3, 4,
351 351
 				*/
352 352
 //    	    $n = sscanf($message, "%*[0-9A-Z],,\n%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,\n%*4[A-Z],\n%[0-9A-Z],", $dair, $darr, $aident);
353
-				$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);
353
+				$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);
354 354
 				if ($n == 8) {
355 355
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
356 356
 					$icao = trim($aident);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 				/* example message :
380 380
 				LFLLLFRS1315U2687X
381 381
 				*/
382
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
382
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
383 383
 				if ($n == 3) {
384 384
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
385 385
 					//$icao = $Translation->checkTranslation($ident);
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 				/* example message :
394 394
 				3J01 DSPTCH 7503/01 LFTH/LFPO .F-HMLF
395 395
 				*/
396
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
396
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
397 397
 				if ($n == 3) {
398 398
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
399 399
 					//$icao = $Translation->checkTranslation($ident);
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 				}
405 405
 			}
406 406
 			if (!$found) {
407
-				$n = sscanf($message,'MET01%4c',$airport);
407
+				$n = sscanf($message, 'MET01%4c', $airport);
408 408
 				if ($n == 1) {
409 409
 					if ($globalDebug) echo 'airport name : '.$airport;
410 410
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -413,241 +413,241 @@  discard block
 block discarded – undo
413 413
 			}
414 414
 
415 415
 			if ($label == 'H1') {
416
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
417
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
416
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
417
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
418 418
 				}
419
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
420
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
419
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
420
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
421 421
 				}
422
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
423
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
422
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
423
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
424 424
 				}
425
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
426
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
425
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
426
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
427 427
 				}
428
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
429
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
428
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
429
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
430 430
 				}
431
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
432
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
431
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
432
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
433 433
 				}
434
-				elseif (preg_match(':^#M1AAEP:',$message)) {
435
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
434
+				elseif (preg_match(':^#M1AAEP:', $message)) {
435
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
436 436
 				}
437
-				elseif (preg_match(':^#M2APWD:',$message)) {
438
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
437
+				elseif (preg_match(':^#M2APWD:', $message)) {
438
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
439 439
 				}
440
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
441
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
440
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
441
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
442 442
 				}
443
-				elseif (preg_match(':^#CF:',$message)) {
444
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
443
+				elseif (preg_match(':^#CF:', $message)) {
444
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
445 445
 				}
446
-				elseif (preg_match(':^#DF:',$message)) {
447
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
446
+				elseif (preg_match(':^#DF:', $message)) {
447
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
448 448
 				}
449
-				elseif (preg_match(':^#EC:',$message)) {
450
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
449
+				elseif (preg_match(':^#EC:', $message)) {
450
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
451 451
 				}
452
-				elseif (preg_match(':^#EI:',$message)) {
453
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
452
+				elseif (preg_match(':^#EI:', $message)) {
453
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
454 454
 				}
455
-				elseif (preg_match(':^#H1:',$message)) {
456
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
455
+				elseif (preg_match(':^#H1:', $message)) {
456
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
457 457
 				}
458
-				elseif (preg_match(':^#H2:',$message)) {
459
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
458
+				elseif (preg_match(':^#H2:', $message)) {
459
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
460 460
 				}
461
-				elseif (preg_match(':^#HD:',$message)) {
462
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
461
+				elseif (preg_match(':^#HD:', $message)) {
462
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
463 463
 				}
464
-				elseif (preg_match(':^#M1:',$message)) {
465
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
464
+				elseif (preg_match(':^#M1:', $message)) {
465
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
466 466
 				}
467
-				elseif (preg_match(':^#M2:',$message)) {
468
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
467
+				elseif (preg_match(':^#M2:', $message)) {
468
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
469 469
 				}
470
-				elseif (preg_match(':^#M3:',$message)) {
471
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
470
+				elseif (preg_match(':^#M3:', $message)) {
471
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
472 472
 				}
473
-				elseif (preg_match(':^#MD:',$message)) {
474
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
473
+				elseif (preg_match(':^#MD:', $message)) {
474
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
475 475
 				}
476
-				elseif (preg_match(':^#PS:',$message)) {
477
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
476
+				elseif (preg_match(':^#PS:', $message)) {
477
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
478 478
 				}
479
-				elseif (preg_match(':^#S1:',$message)) {
480
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
479
+				elseif (preg_match(':^#S1:', $message)) {
480
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
481 481
 				}
482
-				elseif (preg_match(':^#S2:',$message)) {
483
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
482
+				elseif (preg_match(':^#S2:', $message)) {
483
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
484 484
 				}
485
-				elseif (preg_match(':^#SD:',$message)) {
486
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
485
+				elseif (preg_match(':^#SD:', $message)) {
486
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
487 487
 				}
488
-				elseif (preg_match(':^#T[0-8]:',$message)) {
489
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
488
+				elseif (preg_match(':^#T[0-8]:', $message)) {
489
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
490 490
 				}
491
-				elseif (preg_match(':^#WO:',$message)) {
492
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
491
+				elseif (preg_match(':^#WO:', $message)) {
492
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
493 493
 				}
494
-				elseif (preg_match(':^#A1:',$message)) {
495
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
494
+				elseif (preg_match(':^#A1:', $message)) {
495
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
496 496
 				}
497
-				elseif (preg_match(':^#A3:',$message)) {
498
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
497
+				elseif (preg_match(':^#A3:', $message)) {
498
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
499 499
 				}
500
-				elseif (preg_match(':^#A4:',$message)) {
501
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
500
+				elseif (preg_match(':^#A4:', $message)) {
501
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
502 502
 				}
503
-				elseif (preg_match(':^#A6:',$message)) {
504
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
503
+				elseif (preg_match(':^#A6:', $message)) {
504
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
505 505
 				}
506
-				elseif (preg_match(':^#A8:',$message)) {
507
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
506
+				elseif (preg_match(':^#A8:', $message)) {
507
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
508 508
 				}
509
-				elseif (preg_match(':^#A9:',$message)) {
510
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
509
+				elseif (preg_match(':^#A9:', $message)) {
510
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
511 511
 				}
512
-				elseif (preg_match(':^#A0:',$message)) {
513
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
512
+				elseif (preg_match(':^#A0:', $message)) {
513
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
514 514
 				}
515
-				elseif (preg_match(':^#AA:',$message)) {
516
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
515
+				elseif (preg_match(':^#AA:', $message)) {
516
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
517 517
 				}
518
-				elseif (preg_match(':^#AB:',$message)) {
519
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
518
+				elseif (preg_match(':^#AB:', $message)) {
519
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
520 520
 				}
521
-				elseif (preg_match(':^#AC:',$message)) {
522
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
521
+				elseif (preg_match(':^#AC:', $message)) {
522
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
523 523
 				}
524
-				elseif (preg_match(':^#AD:',$message)) {
525
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
524
+				elseif (preg_match(':^#AD:', $message)) {
525
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
526 526
 				}
527
-				elseif (preg_match(':^#AF:',$message)) {
528
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
527
+				elseif (preg_match(':^#AF:', $message)) {
528
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
529 529
 				}
530
-				elseif (preg_match(':^#B1:',$message)) {
531
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
530
+				elseif (preg_match(':^#B1:', $message)) {
531
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
532 532
 				}
533
-				elseif (preg_match(':^#B2:',$message)) {
534
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
533
+				elseif (preg_match(':^#B2:', $message)) {
534
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
535 535
 				}
536
-				elseif (preg_match(':^#B3:',$message)) {
537
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
536
+				elseif (preg_match(':^#B3:', $message)) {
537
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
538 538
 				}
539
-				elseif (preg_match(':^#B4:',$message)) {
540
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
539
+				elseif (preg_match(':^#B4:', $message)) {
540
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
541 541
 				}
542
-				elseif (preg_match(':^#B6:',$message)) {
543
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
542
+				elseif (preg_match(':^#B6:', $message)) {
543
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
544 544
 				}
545
-				elseif (preg_match(':^#B8:',$message)) {
546
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
545
+				elseif (preg_match(':^#B8:', $message)) {
546
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
547 547
 				}
548
-				elseif (preg_match(':^#B9:',$message)) {
549
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
548
+				elseif (preg_match(':^#B9:', $message)) {
549
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
550 550
 				}
551
-				elseif (preg_match(':^#B0:',$message)) {
552
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
551
+				elseif (preg_match(':^#B0:', $message)) {
552
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
553 553
 				}
554
-				elseif (preg_match(':^#BA:',$message)) {
555
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
554
+				elseif (preg_match(':^#BA:', $message)) {
555
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
556 556
 				}
557
-				elseif (preg_match(':^#BB:',$message)) {
558
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
557
+				elseif (preg_match(':^#BB:', $message)) {
558
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
559 559
 				}
560
-				elseif (preg_match(':^#BC:',$message)) {
561
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
560
+				elseif (preg_match(':^#BC:', $message)) {
561
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
562 562
 				}
563
-				elseif (preg_match(':^#BD:',$message)) {
564
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
563
+				elseif (preg_match(':^#BD:', $message)) {
564
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
565 565
 				}
566
-				elseif (preg_match(':^#BE:',$message)) {
567
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
566
+				elseif (preg_match(':^#BE:', $message)) {
567
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
568 568
 				}
569
-				elseif (preg_match(':^#BF:',$message)) {
570
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
569
+				elseif (preg_match(':^#BF:', $message)) {
570
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
571 571
 				}
572
-				elseif (preg_match(':^#H3:',$message)) {
573
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
572
+				elseif (preg_match(':^#H3:', $message)) {
573
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
574 574
 				}
575 575
 			}
576 576
 			if ($label == '10') {
577
-				if (preg_match(':^DTO01:',$message)) {
578
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
577
+				if (preg_match(':^DTO01:', $message)) {
578
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
579 579
 				}
580
-				elseif (preg_match(':^AIS01:',$message)) {
581
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
580
+				elseif (preg_match(':^AIS01:', $message)) {
581
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
582 582
 				}
583
-				elseif (preg_match(':^FTX01:',$message)) {
584
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
583
+				elseif (preg_match(':^FTX01:', $message)) {
584
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
585 585
 				}
586
-				elseif (preg_match(':^FPL01:',$message)) {
587
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
586
+				elseif (preg_match(':^FPL01:', $message)) {
587
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
588 588
 				}
589
-				elseif (preg_match(':^WAB01:',$message)) {
590
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
589
+				elseif (preg_match(':^WAB01:', $message)) {
590
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
591 591
 				}
592
-				elseif (preg_match(':^MET01:',$message)) {
593
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
592
+				elseif (preg_match(':^MET01:', $message)) {
593
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
594 594
 				}
595
-				elseif (preg_match(':^WAB02:',$message)) {
596
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
595
+				elseif (preg_match(':^WAB02:', $message)) {
596
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
597 597
 				}
598 598
 			}
599 599
 			if ($label == '15') {
600
-				if (preg_match(':^FST01:',$message)) {
601
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
600
+				if (preg_match(':^FST01:', $message)) {
601
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
602 602
 				}
603 603
 			}
604 604
 			if (!$found && $label == 'SA') {
605
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
605
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
606 606
 				if ($n == 4) {
607 607
 					$vsta = array('Version' => $version);
608 608
 					if ($state == 'E') {
609
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
609
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
610 610
 					}
611 611
 					elseif ($state == 'L') {
612
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
612
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
613 613
 					}
614 614
 					else {
615
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
615
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
616 616
 					}
617 617
 					if ($type == 'V') {
618
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
618
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
619 619
 					}
620 620
 					elseif ($type == 'S') {
621
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
621
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
622 622
 					}
623 623
 					elseif ($type == 'H') {
624
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
624
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
625 625
 					}
626 626
 					elseif ($type == 'G') {
627
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
627
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
628 628
 					}
629 629
 					elseif ($type == 'C') {
630
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
630
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
631 631
 					}
632 632
 					elseif ($type == '2') {
633
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
633
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
634 634
 					}
635 635
 					elseif ($type == 'X') {
636
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
636
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
637 637
 					}
638 638
 					elseif ($type == 'I') {
639
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
639
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
640 640
 					}
641 641
 					else {
642
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
642
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
643 643
 					}
644
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
645
-					$decode = array_merge($vsta,$decode);
644
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
645
+					$decode = array_merge($vsta, $decode);
646 646
 				}
647 647
 			}
648 648
 
649 649
 			$title = $this->getTitlefromLabel($label);
650
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
650
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
651 651
 
652 652
 			/*
653 653
 			// Business jets always use GS0001
@@ -703,23 +703,23 @@  discard block
 block discarded – undo
703 703
 			}
704 704
 		
705 705
 			// Business jets always use GS0001
706
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
706
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
707 707
 			if ($globalDebug && isset($info) && $info != '') echo $info;
708 708
 
709 709
 			if (count($decode) > 0) $decode_json = json_encode($decode);
710 710
 			else $decode_json = '';
711 711
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
712
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
712
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
713 713
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
714
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
714
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
715 715
 			}
716 716
 
717
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
718
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
719
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
717
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
718
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
719
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
720 720
 
721 721
 			if ($globalDebug && count($decode) > 0) {
722
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
722
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
723 723
 			}
724 724
 		}
725 725
 	}
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 	* @param String $msg_no Number of the ACARS message
735 735
 	* @param String $message ACARS message
736 736
 	*/
737
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
737
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
738 738
 		global $globalDebug;
739 739
 		date_default_timezone_set('UTC');
740 740
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -743,22 +743,22 @@  discard block
 block discarded – undo
743 743
 
744 744
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
745 745
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
746
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
746
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
747 747
 			try {
748 748
 				$stht = $this->db->prepare($query_test);
749 749
 				$stht->execute($query_test_values);
750
-			} catch(PDOException $e) {
750
+			} catch (PDOException $e) {
751 751
 				return "error : ".$e->getMessage();
752 752
 			}
753 753
 			if ($stht->fetchColumn() == 0) {
754 754
 				if ($globalDebug) echo "Add Live ACARS data...";
755 755
 				$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)";
756
-				$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"));
756
+				$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"));
757 757
 				try {
758 758
 
759 759
 					$sth = $this->db->prepare($query);
760 760
 					$sth->execute($query_values);
761
-				} catch(PDOException $e) {
761
+				} catch (PDOException $e) {
762 762
 					return "error : ".$e->getMessage();
763 763
 				}
764 764
 			} else {
@@ -780,10 +780,10 @@  discard block
 block discarded – undo
780 780
 	* @param String $msg_no Number of the ACARS message
781 781
 	* @param String $message ACARS message
782 782
 	*/
783
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
783
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
784 784
 		global $globalDebug;
785 785
 		date_default_timezone_set('UTC');
786
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
786
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
787 787
 			/*
788 788
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
789 789
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -799,12 +799,12 @@  discard block
 block discarded – undo
799 799
 			*/
800 800
 			if ($globalDebug) echo "Add Live ACARS data...";
801 801
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
802
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
802
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
803 803
 			try {
804 804
 
805 805
 				$sth = $this->db->prepare($query);
806 806
 				$sth->execute($query_values);
807
-			} catch(PDOException $e) {
807
+			} catch (PDOException $e) {
808 808
 				return "error : ".$e->getMessage();
809 809
 			}
810 810
 //    	    }
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 
828 828
 			$sth = $this->db->prepare($query);
829 829
 			$sth->execute($query_values);
830
-		} catch(PDOException $e) {
830
+		} catch (PDOException $e) {
831 831
 			echo "error : ".$e->getMessage();
832 832
 			die;
833 833
 		}
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 
849 849
 			$sth = $this->db->prepare($query);
850 850
 			$sth->execute($query_values);
851
-		} catch(PDOException $e) {
851
+		} catch (PDOException $e) {
852 852
 			echo "error : ".$e->getMessage();
853 853
 			die;
854 854
 		}
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 
871 871
 			$sth = $this->db->prepare($query);
872 872
 			$sth->execute($query_values);
873
-		} catch(PDOException $e) {
873
+		} catch (PDOException $e) {
874 874
 			echo "error : ".$e->getMessage();
875 875
 			die;
876 876
 		}
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 	*
885 885
 	* @return Array Return ACARS data in array
886 886
 	*/
887
-	public function getLatestAcarsData($limit = '',$label = '') {
887
+	public function getLatestAcarsData($limit = '', $label = '') {
888 888
 		global $globalURL, $globalDBdriver;
889 889
 		$Image = new Image($this->db);
890 890
 		$Spotter = new Spotter($this->db);
@@ -896,8 +896,8 @@  discard block
 block discarded – undo
896 896
 		{
897 897
 			$limit_array = explode(",", $limit);
898 898
 
899
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
900
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
899
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
900
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
901 901
 
902 902
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
903 903
 			{
@@ -919,48 +919,48 @@  discard block
 block discarded – undo
919 919
 
920 920
 			$sth = $this->db->prepare($query);
921 921
 			$sth->execute($query_values);
922
-		} catch(PDOException $e) {
922
+		} catch (PDOException $e) {
923 923
 			return "error : ".$e->getMessage();
924 924
 		}
925 925
 		$i = 0;
926 926
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
927 927
 			$data = array();
928 928
 			if ($row['registration'] != '') {
929
-				$row['registration'] = str_replace('.','',$row['registration']);
929
+				$row['registration'] = str_replace('.', '', $row['registration']);
930 930
 				$image_array = $Image->getSpotterImage($row['registration']);
931
-				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']));
932
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
933
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
931
+				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']));
932
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
933
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
934 934
 			if ($row['registration'] == '') $row['registration'] = 'NA';
935 935
 			if ($row['ident'] == '') $row['ident'] = 'NA';
936
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
936
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
937 937
 			if (isset($identicao[0])) {
938
-				if (substr($row['ident'],0,2) == 'AF') {
939
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
940
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
941
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
938
+				if (substr($row['ident'], 0, 2) == 'AF') {
939
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
940
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
941
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
942 942
 
943
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
943
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
944 944
 			} else $icao = $row['ident'];
945
-			$icao = $Translation->checkTranslation($icao,false);
945
+			$icao = $Translation->checkTranslation($icao, false);
946 946
 
947
-			$decode = json_decode($row['decode'],true);
947
+			$decode = json_decode($row['decode'], true);
948 948
 			$found = false;
949
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
949
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
950 950
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
951 951
 				if (isset($airport_info[0]['icao'])) {
952 952
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
953 953
 					$found = true;
954 954
 				}
955 955
 			}
956
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
956
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
957 957
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
958 958
 				if (isset($airport_info[0]['icao'])) {
959 959
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
960 960
 					$found = true;
961 961
 				}
962 962
 			}
963
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
963
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
964 964
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
965 965
 				if (isset($airport_info[0]['icao'])) {
966 966
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 				}
969 969
 			}
970 970
 			if ($found) $row['decode'] = json_encode($decode);
971
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
971
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
972 972
 			$result[] = $data;
973 973
 			$i++;
974 974
 		}
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 	*
985 985
 	* @return Array Return ACARS data in array
986 986
 	*/
987
-	public function getArchiveAcarsData($limit = '',$label = '') {
987
+	public function getArchiveAcarsData($limit = '', $label = '') {
988 988
 		global $globalURL, $globalDBdriver;
989 989
 		$Image = new Image($this->db);
990 990
 		$Spotter = new Spotter($this->db);
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
 		{
997 997
 			$limit_array = explode(",", $limit);
998 998
 
999
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1000
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
999
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1000
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1001 1001
 
1002 1002
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1003 1003
 			{
@@ -1027,45 +1027,45 @@  discard block
 block discarded – undo
1027 1027
 
1028 1028
 			$sth = $this->db->prepare($query);
1029 1029
 			$sth->execute($query_values);
1030
-		} catch(PDOException $e) {
1030
+		} catch (PDOException $e) {
1031 1031
 			return "error : ".$e->getMessage();
1032 1032
 		}
1033
-		$i=0;
1033
+		$i = 0;
1034 1034
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1035 1035
 			$data = array();
1036 1036
 			if ($row['registration'] != '') {
1037
-				$row['registration'] = str_replace('.','',$row['registration']);
1037
+				$row['registration'] = str_replace('.', '', $row['registration']);
1038 1038
 				$image_array = $Image->getSpotterImage($row['registration']);
1039
-				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']));
1040
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1041
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1039
+				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']));
1040
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1041
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1042 1042
 			$icao = '';
1043 1043
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1044 1044
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1045
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1045
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1046 1046
 			if (isset($identicao[0])) {
1047
-				if (substr($row['ident'],0,2) == 'AF') {
1048
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1049
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1050
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1051
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1047
+				if (substr($row['ident'], 0, 2) == 'AF') {
1048
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1049
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1050
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1051
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1052 1052
 			} else $icao = $row['ident'];
1053 1053
 			$icao = $Translation->checkTranslation($icao);
1054 1054
 
1055 1055
 
1056
-			$decode = json_decode($row['decode'],true);
1056
+			$decode = json_decode($row['decode'], true);
1057 1057
 			$found = false;
1058
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1058
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1059 1059
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1060 1060
 				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>';
1061 1061
 				$found = true;
1062 1062
 			}
1063
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1063
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1064 1064
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1065 1065
 				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>';
1066 1066
 				$found = true;
1067 1067
 			}
1068
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1068
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1069 1069
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1070 1070
 				if (isset($airport_info[0]['icao'])) {
1071 1071
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
 			}
1075 1075
 			if ($found) $row['decode'] = json_encode($decode);
1076 1076
 
1077
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1077
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1078 1078
 			$result[] = $data;
1079 1079
 			$i++;
1080 1080
 		}
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 	* @param String $icao
1093 1093
 	* @param String $ICAOTypeCode
1094 1094
 	*/
1095
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1095
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1096 1096
 		global $globalDebug, $globalDBdriver;
1097 1097
 		$ident = trim($ident);
1098 1098
 		$Translation = new Translation($this->db);
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 			return '';
1107 1107
 		}
1108 1108
 
1109
-		$registration = str_replace('.','',$registration);
1109
+		$registration = str_replace('.', '', $registration);
1110 1110
 		$ident = $Translation->ident2icao($ident);
1111 1111
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1112 1112
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 
1117 1117
 			$sthsi = $this->db->prepare($querysi);
1118 1118
 			$sthsi->execute($querysi_values);
1119
-		} catch(PDOException $e) {
1119
+		} catch (PDOException $e) {
1120 1120
 			if ($globalDebug) echo $e->getMessage();
1121 1121
 			return "error : ".$e->getMessage();
1122 1122
 		}
@@ -1126,8 +1126,8 @@  discard block
 block discarded – undo
1126 1126
 			$Translation = new Translation($this->db);
1127 1127
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1128 1128
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1129
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1130
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1129
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1130
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1131 1131
 		} else {
1132 1132
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1133 1133
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1135,14 +1135,14 @@  discard block
 block discarded – undo
1135 1135
 				try {
1136 1136
 					$sth = $this->db->prepare($query);
1137 1137
 					$sth->execute($query_values);
1138
-				} catch(PDOException $e) {
1138
+				} catch (PDOException $e) {
1139 1139
 					if ($globalDebug) echo $e->getMessage();
1140 1140
 					return "error : ".$e->getMessage();
1141 1141
 				}
1142 1142
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1143 1143
 				if (isset($result['modes'])) $hex = $result['modes'];
1144 1144
 				else $hex = '';
1145
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1145
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1146 1146
 				$this->SI->add($SI_data);
1147 1147
 			}
1148 1148
 		}
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 
1155 1155
 			$sth = $this->db->prepare($query);
1156 1156
 			$sth->execute($query_values);
1157
-		} catch(PDOException $e) {
1157
+		} catch (PDOException $e) {
1158 1158
 			if ($globalDebug) echo $e->getMessage();
1159 1159
 			return "error : ".$e->getMessage();
1160 1160
 		}
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1165 1165
 			else $ModeS = '';
1166 1166
 			if ($ModeS == '') {
1167
-				$id = explode('-',$result['flightaware_id']);
1167
+				$id = explode('-', $result['flightaware_id']);
1168 1168
 				$ModeS = $id[0];
1169 1169
 			}
1170 1170
 			if ($ModeS != '') {
@@ -1175,21 +1175,21 @@  discard block
 block discarded – undo
1175 1175
 
1176 1176
 					$sthc = $this->db->prepare($queryc);
1177 1177
 					$sthc->execute($queryc_values);
1178
-				} catch(PDOException $e) {
1178
+				} catch (PDOException $e) {
1179 1179
 					if ($globalDebug) echo $e->getMessage();
1180 1180
 					return "error : ".$e->getMessage();
1181 1181
 				}
1182 1182
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1183 1183
 
1184
-				if (count($row) ==  0) {
1184
+				if (count($row) == 0) {
1185 1185
 					if ($globalDebug) echo " Add to ModeS table - ";
1186 1186
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1187
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1187
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1188 1188
 					try {
1189 1189
 
1190 1190
 						$sthi = $this->db->prepare($queryi);
1191 1191
 						$sthi->execute($queryi_values);
1192
-					} catch(PDOException $e) {
1192
+					} catch (PDOException $e) {
1193 1193
 						if ($globalDebug) echo $e->getMessage();
1194 1194
 						return "error : ".$e->getMessage();
1195 1195
 					}
@@ -1197,16 +1197,16 @@  discard block
 block discarded – undo
1197 1197
 					if ($globalDebug) echo " Update ModeS table - ";
1198 1198
 					if ($ICAOTypeCode != '') {
1199 1199
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1200
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1200
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1201 1201
 					} else {
1202 1202
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1203
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1203
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1204 1204
 					}
1205 1205
 					try {
1206 1206
 
1207 1207
 						$sthi = $this->db->prepare($queryi);
1208 1208
 						$sthi->execute($queryi_values);
1209
-					} catch(PDOException $e) {
1209
+					} catch (PDOException $e) {
1210 1210
 						if ($globalDebug) echo $e->getMessage();
1211 1211
 						return "error : ".$e->getMessage();
1212 1212
 					}
@@ -1244,13 +1244,13 @@  discard block
 block discarded – undo
1244 1244
 					elseif ($globalDBdriver == 'pgsql') {
1245 1245
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1246 1246
 					}
1247
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1247
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1248 1248
 				}
1249 1249
 				try {
1250 1250
 
1251 1251
 					$sthi = $this->db->prepare($queryi);
1252 1252
 					$sthi->execute($queryi_values);
1253
-				} catch(PDOException $e) {
1253
+				} catch (PDOException $e) {
1254 1254
 					if ($globalDebug) echo $e->getMessage();
1255 1255
 					return "error : ".$e->getMessage();
1256 1256
 				}
Please login to merge, or discard this patch.
Braces   +403 added lines, -259 removed lines patch added patch discarded remove patch
@@ -23,14 +23,19 @@  discard block
 block discarded – undo
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
26
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
27
+				$icao = $ident;
28
+			} else {
29
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
30
+			}
28 31
 		} else {
29 32
 			$Spotter = new Spotter($this->db);
30 33
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
31 34
 			if (isset($identicao[0])) {
32 35
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
33
-			} else $icao = $ident;
36
+			} else {
37
+				$icao = $ident;
38
+			}
34 39
 		}
35 40
 		return $icao;
36 41
 	}
@@ -103,12 +108,18 @@  discard block
 block discarded – undo
103 108
 		$message = '';
104 109
 		$result = array();
105 110
 		$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);
106
-		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);
111
+		if ($n == 0) {
112
+			$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);
113
+		}
107 114
 		if ($n != 0) {
108 115
 			$registration = str_replace('.','',$registration);
109 116
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
110
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
111
-		} else $message = $data;
117
+			if ($globalDebug) {
118
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
119
+			}
120
+		} else {
121
+			$message = $data;
122
+		}
112 123
 		$icao = '';
113 124
 		$airicao = '';
114 125
 		$decode = array();
@@ -122,12 +133,21 @@  discard block
 block discarded – undo
122 133
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
123 134
 					$latitude = $la / 10000.0;
124 135
 					$longitude = $ln / 10000.0;
125
-					if ($lac == 'S') $latitude = '-'.$latitude;
126
-					if ($lnc == 'W') $longitude = '-'.$longitude;
136
+					if ($lac == 'S') {
137
+						$latitude = '-'.$latitude;
138
+					}
139
+					if ($lnc == 'W') {
140
+						$longitude = '-'.$longitude;
141
+					}
127 142
 					// Temp not always available
128
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
129
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
130
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
143
+					if ($globalDebug) {
144
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
145
+					}
146
+					if ($temp == '') {
147
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
148
+					} else {
149
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
150
+					}
131 151
 
132 152
 					//$icao = $Translation->checkTranslation($ident);
133 153
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -137,25 +157,35 @@  discard block
 block discarded – undo
137 157
 			if (!$found && ($label == '10')) {
138 158
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
139 159
 				if ($n == 4 && strlen($darr) == 4) {
140
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
141
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
142
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
160
+					if ($dhour != '') {
161
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
162
+					}
163
+					if ($ahour != '') {
164
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
165
+					}
166
+					if ($globalDebug) {
167
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
168
+					}
143 169
 					//$icao = ACARS->ident2icao($ident);
144 170
 					//$icao = $Translation->checkTranslation($ident);
145 171
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
146 172
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
147 173
 					$found = true;
148
-				}
149
-				elseif ($n == 2 || $n  == 4) {
150
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
151
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
174
+				} elseif ($n == 2 || $n  == 4) {
175
+					if ($dhour != '') {
176
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
177
+					}
178
+					if ($globalDebug) {
179
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
180
+					}
152 181
 					//$icao = ACARS->ident2icao($ident);
153 182
 					//$icao = $Translation->checkTranslation($ident);
154 183
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
155 184
 					$found = true;
156
-				}
157
-				elseif ($n == 1) {
158
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
185
+				} elseif ($n == 1) {
186
+					if ($globalDebug) {
187
+						echo 'airport arrival : '.$darr."\n";
188
+					}
159 189
 					//$icao = ACARS->ident2icao($ident);
160 190
 					//$icao = $Translation->checkTranslation($ident);
161 191
 					$decode = array('Arrival airport' => $darr);
@@ -172,7 +202,9 @@  discard block
 block discarded – undo
172 202
 
173 203
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
174 204
 				if ($n == 4) {
175
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
205
+					if ($globalDebug) {
206
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
207
+					}
176 208
 					//$icao = ACARS->ident2icao($ident);
177 209
 					//$icao = $Translation->checkTranslation($ident);
178 210
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -197,14 +229,23 @@  discard block
 block discarded – undo
197 229
 				//$n = sscanf($message, "%*[0-9A-Z]/%*3d/%4s/%*c\nSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d\n%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
198 230
 				$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);
199 231
 				if ($n > 8) {
200
-					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";
201
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
202
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
232
+					if ($globalDebug) {
233
+						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";
234
+					}
235
+					if ($dhour != '') {
236
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
237
+					}
238
+					if ($ahour != '') {
239
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
240
+					}
203 241
 					$icao = trim($aident);
204 242
 
205 243
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
206
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
207
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
244
+					if ($ahour == '') {
245
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
246
+					} else {
247
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
248
+					}
208 249
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
209 250
 					$decode['icao'] = $icao;
210 251
 					$found = true;
@@ -221,9 +262,15 @@  discard block
 block discarded – undo
221 262
 					$lns = $lns.'.'.$lns;
222 263
 					$latitude = $las / 1000.0;
223 264
 					$longitude = $lns / 1000.0;
224
-					if ($lac == 'S') $latitude = '-'.$latitude;
225
-					if ($lnc == 'W') $longitude = '-'.$longitude;
226
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
265
+					if ($lac == 'S') {
266
+						$latitude = '-'.$latitude;
267
+					}
268
+					if ($lnc == 'W') {
269
+						$longitude = '-'.$longitude;
270
+					}
271
+					if ($globalDebug) {
272
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
273
+					}
227 274
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
228 275
 					$found = true;
229 276
 				}
@@ -239,7 +286,9 @@  discard block
 block discarded – undo
239 286
 				*/
240 287
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
241 288
 				if ($n == 4) {
242
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
289
+					if ($globalDebug) {
290
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
291
+					}
243 292
 					//$icao = $Translation->checkTranslation($ident);
244 293
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
245 294
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -250,7 +299,9 @@  discard block
 block discarded – undo
250 299
 				// example message : "Reg. : TS-ION - Ident : TU0634 - Label : 1L - Message : 000442152001337,DTTJ,LFPO,1609"
251 300
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
252 301
 				if ($n == 4) {
253
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
302
+					if ($globalDebug) {
303
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
304
+					}
254 305
 					//$icao = $Translation->checkTranslation($ident);
255 306
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
256 307
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -261,7 +312,9 @@  discard block
 block discarded – undo
261 312
 				// example message : "Reg. : OO-TAH - Ident : 3V042J - Label : 5U - Message : 002AF   EBLG EBBR                     N4621.5E  524.2195"
262 313
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
263 314
 				if ($n == 2) {
264
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
315
+					if ($globalDebug) {
316
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
317
+					}
265 318
 					//$icao = $Translation->checkTranslation($ident);
266 319
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
267 320
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -273,7 +326,9 @@  discard block
 block discarded – undo
273 326
 				// example message : 'Reg. : F-GHQJ - Ident : AF6241 - Label : H1 - Message : #DFBA01/CCF-GHQJ,FEB27,205556,LFMN,LFPO,0241/C106,17404,5000,42,0010,0,0100,42,X/CEN270,36012,257,778,6106,299,B5B7G8/EC731134,42387,01439,41194,12/EE731212,44932,11870,43555,12/N10875,0875,0910,6330,1205,-----'
274 327
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
275 328
 				if ($n == 6) {
276
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
329
+					if ($globalDebug) {
330
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
331
+					}
277 332
 					//$icao = $Translation->checkTranslation($ident);
278 333
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
279 334
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -284,7 +339,9 @@  discard block
 block discarded – undo
284 339
 				// example message : 'Reg. : F-GUGP - Ident : AF1842 - Label : H1 - Message : #DFBA01/A31801,1,1/CCF-GUGP,MAR11,093856,LFPG,LSGG,1842/C106,55832,5000,37,0010,0,0100,37,X/CEN282,31018,277,750,5515,255,C11036/EC577870,02282,07070,01987,73,14/EE577871,02282,06947,01987,73/N10790,0790,0903,5'
285 340
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
286 341
 				if ($n == 7) {
287
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
342
+					if ($globalDebug) {
343
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
344
+					}
288 345
 					//$icao = $Translation->checkTranslation($ident);
289 346
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
290 347
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -304,8 +361,12 @@  discard block
 block discarded – undo
304 361
 					$decode['icao'] = $icao;
305 362
 					$latitude = $las / 100.0;
306 363
 					$longitude = $lns / 100.0;
307
-					if ($lac == 'S') $latitude = '-'.$latitude;
308
-					if ($lnc == 'W') $longitude = '-'.$longitude;
364
+					if ($lac == 'S') {
365
+						$latitude = '-'.$latitude;
366
+					}
367
+					if ($lnc == 'W') {
368
+						$longitude = '-'.$longitude;
369
+					}
309 370
 
310 371
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
311 372
 					$found = true;
@@ -319,8 +380,12 @@  discard block
 block discarded – undo
319 380
 				if ($n == 4) {
320 381
 					$latitude = $las;
321 382
 					$longitude = $lns;
322
-					if ($lac == 'S') $latitude = '-'.$latitude;
323
-					if ($lnc == 'W') $longitude = '-'.$longitude;
383
+					if ($lac == 'S') {
384
+						$latitude = '-'.$latitude;
385
+					}
386
+					if ($lnc == 'W') {
387
+						$longitude = '-'.$longitude;
388
+					}
324 389
 
325 390
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
326 391
 					$found = true;
@@ -334,7 +399,9 @@  discard block
 block discarded – undo
334 399
 				*/
335 400
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
336 401
 				if ($n == 5) {
337
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
402
+					if ($globalDebug) {
403
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
404
+					}
338 405
 					//$icao = $Translation->checkTranslation($ident);
339 406
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
340 407
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -352,7 +419,9 @@  discard block
 block discarded – undo
352 419
 //    	    $n = sscanf($message, "%*[0-9A-Z],,\n%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,\n%*4[A-Z],\n%[0-9A-Z],", $dair, $darr, $aident);
353 420
 				$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);
354 421
 				if ($n == 8) {
355
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
422
+					if ($globalDebug) {
423
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
424
+					}
356 425
 					$icao = trim($aident);
357 426
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
358 427
 					$decode['icao'] = $icao;
@@ -367,7 +436,9 @@  discard block
 block discarded – undo
367 436
 				*/
368 437
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
369 438
 				if ($n == 5) {
370
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
439
+					if ($globalDebug) {
440
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
441
+					}
371 442
 					//$icao = $Translation->checkTranslation($ident);
372 443
 
373 444
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -381,7 +452,9 @@  discard block
 block discarded – undo
381 452
 				*/
382 453
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
383 454
 				if ($n == 3) {
384
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
455
+					if ($globalDebug) {
456
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
457
+					}
385 458
 					//$icao = $Translation->checkTranslation($ident);
386 459
 
387 460
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -395,7 +468,9 @@  discard block
 block discarded – undo
395 468
 				*/
396 469
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
397 470
 				if ($n == 3) {
398
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
471
+					if ($globalDebug) {
472
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
473
+					}
399 474
 					//$icao = $Translation->checkTranslation($ident);
400 475
 
401 476
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -406,7 +481,9 @@  discard block
 block discarded – undo
406 481
 			if (!$found) {
407 482
 				$n = sscanf($message,'MET01%4c',$airport);
408 483
 				if ($n == 1) {
409
-					if ($globalDebug) echo 'airport name : '.$airport;
484
+					if ($globalDebug) {
485
+						echo 'airport name : '.$airport;
486
+					}
410 487
 					$decode = array('Airport/Waypoint name' => $airport);
411 488
 					$found = true;
412 489
 				}
@@ -415,184 +492,126 @@  discard block
 block discarded – undo
415 492
 			if ($label == 'H1') {
416 493
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
417 494
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
418
-				}
419
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
495
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
420 496
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
421
-				}
422
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
497
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
423 498
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
424
-				}
425
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
499
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
426 500
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
427
-				}
428
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
501
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
429 502
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
430
-				}
431
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
503
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
432 504
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
433
-				}
434
-				elseif (preg_match(':^#M1AAEP:',$message)) {
505
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
435 506
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
436
-				}
437
-				elseif (preg_match(':^#M2APWD:',$message)) {
507
+				} elseif (preg_match(':^#M2APWD:',$message)) {
438 508
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
439
-				}
440
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
509
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
441 510
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
442
-				}
443
-				elseif (preg_match(':^#CF:',$message)) {
511
+				} elseif (preg_match(':^#CF:',$message)) {
444 512
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
445
-				}
446
-				elseif (preg_match(':^#DF:',$message)) {
513
+				} elseif (preg_match(':^#DF:',$message)) {
447 514
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
448
-				}
449
-				elseif (preg_match(':^#EC:',$message)) {
515
+				} elseif (preg_match(':^#EC:',$message)) {
450 516
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
451
-				}
452
-				elseif (preg_match(':^#EI:',$message)) {
517
+				} elseif (preg_match(':^#EI:',$message)) {
453 518
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
454
-				}
455
-				elseif (preg_match(':^#H1:',$message)) {
519
+				} elseif (preg_match(':^#H1:',$message)) {
456 520
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
457
-				}
458
-				elseif (preg_match(':^#H2:',$message)) {
521
+				} elseif (preg_match(':^#H2:',$message)) {
459 522
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
460
-				}
461
-				elseif (preg_match(':^#HD:',$message)) {
523
+				} elseif (preg_match(':^#HD:',$message)) {
462 524
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
463
-				}
464
-				elseif (preg_match(':^#M1:',$message)) {
525
+				} elseif (preg_match(':^#M1:',$message)) {
465 526
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
466
-				}
467
-				elseif (preg_match(':^#M2:',$message)) {
527
+				} elseif (preg_match(':^#M2:',$message)) {
468 528
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
469
-				}
470
-				elseif (preg_match(':^#M3:',$message)) {
529
+				} elseif (preg_match(':^#M3:',$message)) {
471 530
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
472
-				}
473
-				elseif (preg_match(':^#MD:',$message)) {
531
+				} elseif (preg_match(':^#MD:',$message)) {
474 532
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
475
-				}
476
-				elseif (preg_match(':^#PS:',$message)) {
533
+				} elseif (preg_match(':^#PS:',$message)) {
477 534
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
478
-				}
479
-				elseif (preg_match(':^#S1:',$message)) {
535
+				} elseif (preg_match(':^#S1:',$message)) {
480 536
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
481
-				}
482
-				elseif (preg_match(':^#S2:',$message)) {
537
+				} elseif (preg_match(':^#S2:',$message)) {
483 538
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
484
-				}
485
-				elseif (preg_match(':^#SD:',$message)) {
539
+				} elseif (preg_match(':^#SD:',$message)) {
486 540
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
487
-				}
488
-				elseif (preg_match(':^#T[0-8]:',$message)) {
541
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
489 542
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
490
-				}
491
-				elseif (preg_match(':^#WO:',$message)) {
543
+				} elseif (preg_match(':^#WO:',$message)) {
492 544
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
493
-				}
494
-				elseif (preg_match(':^#A1:',$message)) {
545
+				} elseif (preg_match(':^#A1:',$message)) {
495 546
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
496
-				}
497
-				elseif (preg_match(':^#A3:',$message)) {
547
+				} elseif (preg_match(':^#A3:',$message)) {
498 548
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
499
-				}
500
-				elseif (preg_match(':^#A4:',$message)) {
549
+				} elseif (preg_match(':^#A4:',$message)) {
501 550
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
502
-				}
503
-				elseif (preg_match(':^#A6:',$message)) {
551
+				} elseif (preg_match(':^#A6:',$message)) {
504 552
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
505
-				}
506
-				elseif (preg_match(':^#A8:',$message)) {
553
+				} elseif (preg_match(':^#A8:',$message)) {
507 554
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
508
-				}
509
-				elseif (preg_match(':^#A9:',$message)) {
555
+				} elseif (preg_match(':^#A9:',$message)) {
510 556
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
511
-				}
512
-				elseif (preg_match(':^#A0:',$message)) {
557
+				} elseif (preg_match(':^#A0:',$message)) {
513 558
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
514
-				}
515
-				elseif (preg_match(':^#AA:',$message)) {
559
+				} elseif (preg_match(':^#AA:',$message)) {
516 560
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
517
-				}
518
-				elseif (preg_match(':^#AB:',$message)) {
561
+				} elseif (preg_match(':^#AB:',$message)) {
519 562
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
520
-				}
521
-				elseif (preg_match(':^#AC:',$message)) {
563
+				} elseif (preg_match(':^#AC:',$message)) {
522 564
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
523
-				}
524
-				elseif (preg_match(':^#AD:',$message)) {
565
+				} elseif (preg_match(':^#AD:',$message)) {
525 566
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
526
-				}
527
-				elseif (preg_match(':^#AF:',$message)) {
567
+				} elseif (preg_match(':^#AF:',$message)) {
528 568
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
529
-				}
530
-				elseif (preg_match(':^#B1:',$message)) {
569
+				} elseif (preg_match(':^#B1:',$message)) {
531 570
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
532
-				}
533
-				elseif (preg_match(':^#B2:',$message)) {
571
+				} elseif (preg_match(':^#B2:',$message)) {
534 572
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
535
-				}
536
-				elseif (preg_match(':^#B3:',$message)) {
573
+				} elseif (preg_match(':^#B3:',$message)) {
537 574
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
538
-				}
539
-				elseif (preg_match(':^#B4:',$message)) {
575
+				} elseif (preg_match(':^#B4:',$message)) {
540 576
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
541
-				}
542
-				elseif (preg_match(':^#B6:',$message)) {
577
+				} elseif (preg_match(':^#B6:',$message)) {
543 578
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
544
-				}
545
-				elseif (preg_match(':^#B8:',$message)) {
579
+				} elseif (preg_match(':^#B8:',$message)) {
546 580
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
547
-				}
548
-				elseif (preg_match(':^#B9:',$message)) {
581
+				} elseif (preg_match(':^#B9:',$message)) {
549 582
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
550
-				}
551
-				elseif (preg_match(':^#B0:',$message)) {
583
+				} elseif (preg_match(':^#B0:',$message)) {
552 584
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
553
-				}
554
-				elseif (preg_match(':^#BA:',$message)) {
585
+				} elseif (preg_match(':^#BA:',$message)) {
555 586
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
556
-				}
557
-				elseif (preg_match(':^#BB:',$message)) {
587
+				} elseif (preg_match(':^#BB:',$message)) {
558 588
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
559
-				}
560
-				elseif (preg_match(':^#BC:',$message)) {
589
+				} elseif (preg_match(':^#BC:',$message)) {
561 590
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
562
-				}
563
-				elseif (preg_match(':^#BD:',$message)) {
591
+				} elseif (preg_match(':^#BD:',$message)) {
564 592
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
565
-				}
566
-				elseif (preg_match(':^#BE:',$message)) {
593
+				} elseif (preg_match(':^#BE:',$message)) {
567 594
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
568
-				}
569
-				elseif (preg_match(':^#BF:',$message)) {
595
+				} elseif (preg_match(':^#BF:',$message)) {
570 596
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
571
-				}
572
-				elseif (preg_match(':^#H3:',$message)) {
597
+				} elseif (preg_match(':^#H3:',$message)) {
573 598
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
574 599
 				}
575 600
 			}
576 601
 			if ($label == '10') {
577 602
 				if (preg_match(':^DTO01:',$message)) {
578 603
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
579
-				}
580
-				elseif (preg_match(':^AIS01:',$message)) {
604
+				} elseif (preg_match(':^AIS01:',$message)) {
581 605
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
582
-				}
583
-				elseif (preg_match(':^FTX01:',$message)) {
606
+				} elseif (preg_match(':^FTX01:',$message)) {
584 607
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
585
-				}
586
-				elseif (preg_match(':^FPL01:',$message)) {
608
+				} elseif (preg_match(':^FPL01:',$message)) {
587 609
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
588
-				}
589
-				elseif (preg_match(':^WAB01:',$message)) {
610
+				} elseif (preg_match(':^WAB01:',$message)) {
590 611
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
591
-				}
592
-				elseif (preg_match(':^MET01:',$message)) {
612
+				} elseif (preg_match(':^MET01:',$message)) {
593 613
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
594
-				}
595
-				elseif (preg_match(':^WAB02:',$message)) {
614
+				} elseif (preg_match(':^WAB02:',$message)) {
596 615
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
597 616
 				}
598 617
 			}
@@ -607,38 +626,28 @@  discard block
 block discarded – undo
607 626
 					$vsta = array('Version' => $version);
608 627
 					if ($state == 'E') {
609 628
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
610
-					}
611
-					elseif ($state == 'L') {
629
+					} elseif ($state == 'L') {
612 630
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
613
-					}
614
-					else {
631
+					} else {
615 632
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
616 633
 					}
617 634
 					if ($type == 'V') {
618 635
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
619
-					}
620
-					elseif ($type == 'S') {
636
+					} elseif ($type == 'S') {
621 637
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
622
-					}
623
-					elseif ($type == 'H') {
638
+					} elseif ($type == 'H') {
624 639
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
625
-					}
626
-					elseif ($type == 'G') {
640
+					} elseif ($type == 'G') {
627 641
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
628
-					}
629
-					elseif ($type == 'C') {
642
+					} elseif ($type == 'C') {
630 643
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
631
-					}
632
-					elseif ($type == '2') {
644
+					} elseif ($type == '2') {
633 645
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
634
-					}
635
-					elseif ($type == 'X') {
646
+					} elseif ($type == 'X') {
636 647
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
637
-					}
638
-					elseif ($type == 'I') {
648
+					} elseif ($type == 'I') {
639 649
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
640
-					}
641
-					else {
650
+					} else {
642 651
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
643 652
 					}
644 653
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -647,7 +656,9 @@  discard block
 block discarded – undo
647 656
 			}
648 657
 
649 658
 			$title = $this->getTitlefromLabel($label);
650
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
659
+			if ($title != '') {
660
+				$decode = array_merge(array('Message title' => $title),$decode);
661
+			}
651 662
 
652 663
 			/*
653 664
 			// Business jets always use GS0001
@@ -688,14 +699,26 @@  discard block
 block discarded – undo
688 699
 			$decode = $message['decode'];
689 700
 			$registration = $message['registration'];
690 701
 		
691
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
692
-			else $latitude = '';
693
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
694
-			else $longitude = '';
695
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
696
-			else $airicao = '';
697
-			if (isset($decode['icao'])) $icao = $decode['icao'];
698
-			else $icao = $Translation->checkTranslation($ident);
702
+			if (isset($decode['latitude'])) {
703
+				$latitude = $decode['latitude'];
704
+			} else {
705
+				$latitude = '';
706
+			}
707
+			if (isset($decode['longitude'])) {
708
+				$longitude = $decode['longitude'];
709
+			} else {
710
+				$longitude = '';
711
+			}
712
+			if (isset($decode['airicao'])) {
713
+				$airicao = $decode['airicao'];
714
+			} else {
715
+				$airicao = '';
716
+			}
717
+			if (isset($decode['icao'])) {
718
+				$icao = $decode['icao'];
719
+			} else {
720
+				$icao = $Translation->checkTranslation($ident);
721
+			}
699 722
 		
700 723
 			$image_array = $Image->getSpotterImage($registration);
701 724
 			if (!isset($image_array[0]['registration'])) {
@@ -703,11 +726,18 @@  discard block
 block discarded – undo
703 726
 			}
704 727
 		
705 728
 			// Business jets always use GS0001
706
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
707
-			if ($globalDebug && isset($info) && $info != '') echo $info;
729
+			if ($ident != 'GS0001') {
730
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
731
+			}
732
+			if ($globalDebug && isset($info) && $info != '') {
733
+				echo $info;
734
+			}
708 735
 
709
-			if (count($decode) > 0) $decode_json = json_encode($decode);
710
-			else $decode_json = '';
736
+			if (count($decode) > 0) {
737
+				$decode_json = json_encode($decode);
738
+			} else {
739
+				$decode_json = '';
740
+			}
711 741
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
712 742
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
713 743
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
@@ -715,8 +745,12 @@  discard block
 block discarded – undo
715 745
 			}
716 746
 
717 747
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
718
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
719
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
748
+			if (!isset($globalACARSArchive)) {
749
+				$globalACARSArchive = array('10','80','81','82','3F');
750
+			}
751
+			if ($result && in_array($label,$globalACARSArchive)) {
752
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
753
+			}
720 754
 
721 755
 			if ($globalDebug && count($decode) > 0) {
722 756
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
@@ -741,7 +775,9 @@  discard block
 block discarded – undo
741 775
 			$Connection = new Connection($this->db);
742 776
 			$this->db = $Connection->db;
743 777
 
744
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
778
+			if ($globalDebug) {
779
+				echo "Test if not already in Live ACARS table...";
780
+			}
745 781
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
746 782
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
747 783
 			try {
@@ -751,7 +787,9 @@  discard block
 block discarded – undo
751 787
 				return "error : ".$e->getMessage();
752 788
 			}
753 789
 			if ($stht->fetchColumn() == 0) {
754
-				if ($globalDebug) echo "Add Live ACARS data...";
790
+				if ($globalDebug) {
791
+					echo "Add Live ACARS data...";
792
+				}
755 793
 				$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)";
756 794
 				$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"));
757 795
 				try {
@@ -762,10 +800,14 @@  discard block
 block discarded – undo
762 800
 					return "error : ".$e->getMessage();
763 801
 				}
764 802
 			} else {
765
-				if ($globalDebug) echo "Data already in DB...\n";
803
+				if ($globalDebug) {
804
+					echo "Data already in DB...\n";
805
+				}
766 806
 				return false;
767 807
 			}
768
-			if ($globalDebug) echo "Done\n";
808
+			if ($globalDebug) {
809
+				echo "Done\n";
810
+			}
769 811
 			return true;
770 812
 		}
771 813
 	}
@@ -797,7 +839,9 @@  discard block
 block discarded – undo
797 839
 			    	    }
798 840
 				    if ($stht->fetchColumn() == 0) {
799 841
 			*/
800
-			if ($globalDebug) echo "Add Live ACARS data...";
842
+			if ($globalDebug) {
843
+				echo "Add Live ACARS data...";
844
+			}
801 845
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
802 846
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
803 847
 			try {
@@ -808,7 +852,9 @@  discard block
 block discarded – undo
808 852
 				return "error : ".$e->getMessage();
809 853
 			}
810 854
 //    	    }
811
-			if ($globalDebug) echo "Done\n";
855
+			if ($globalDebug) {
856
+				echo "Done\n";
857
+			}
812 858
 		}
813 859
 	}
814 860
 
@@ -832,8 +878,11 @@  discard block
 block discarded – undo
832 878
 			die;
833 879
 		}
834 880
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
835
-		if (count($row) > 0) return $row[0]['title'];
836
-		else return '';
881
+		if (count($row) > 0) {
882
+			return $row[0]['title'];
883
+		} else {
884
+			return '';
885
+		}
837 886
 	}
838 887
 
839 888
 	/**
@@ -853,8 +902,11 @@  discard block
 block discarded – undo
853 902
 			die;
854 903
 		}
855 904
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
856
-		if (count($row) > 0) return $row;
857
-		else return array();
905
+		if (count($row) > 0) {
906
+			return $row;
907
+		} else {
908
+			return array();
909
+		}
858 910
 	}
859 911
 
860 912
 	/**
@@ -875,8 +927,11 @@  discard block
 block discarded – undo
875 927
 			die;
876 928
 		}
877 929
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
878
-		if (count($row) > 0) return $row[0];
879
-		else return array();
930
+		if (count($row) > 0) {
931
+			return $row[0];
932
+		} else {
933
+			return array();
934
+		}
880 935
 	}
881 936
 
882 937
 	/**
@@ -928,20 +983,36 @@  discard block
 block discarded – undo
928 983
 			if ($row['registration'] != '') {
929 984
 				$row['registration'] = str_replace('.','',$row['registration']);
930 985
 				$image_array = $Image->getSpotterImage($row['registration']);
931
-				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']));
932
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
933
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
934
-			if ($row['registration'] == '') $row['registration'] = 'NA';
935
-			if ($row['ident'] == '') $row['ident'] = 'NA';
986
+				if (count($image_array) > 0) {
987
+					$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']));
988
+				} else {
989
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
990
+				}
991
+			} else {
992
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
+			}
994
+			if ($row['registration'] == '') {
995
+				$row['registration'] = 'NA';
996
+			}
997
+			if ($row['ident'] == '') {
998
+				$row['ident'] = 'NA';
999
+			}
936 1000
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
937 1001
 			if (isset($identicao[0])) {
938 1002
 				if (substr($row['ident'],0,2) == 'AF') {
939
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
940
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
941
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1003
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1004
+						$icao = $row['ident'];
1005
+					} else {
1006
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1007
+					}
1008
+				} else {
1009
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1010
+				}
942 1011
 
943 1012
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
944
-			} else $icao = $row['ident'];
1013
+			} else {
1014
+				$icao = $row['ident'];
1015
+			}
945 1016
 			$icao = $Translation->checkTranslation($icao,false);
946 1017
 
947 1018
 			$decode = json_decode($row['decode'],true);
@@ -967,7 +1038,9 @@  discard block
 block discarded – undo
967 1038
 					$found = true;
968 1039
 				}
969 1040
 			}
970
-			if ($found) $row['decode'] = json_encode($decode);
1041
+			if ($found) {
1042
+				$row['decode'] = json_encode($decode);
1043
+			}
971 1044
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
972 1045
 			$result[] = $data;
973 1046
 			$i++;
@@ -975,8 +1048,9 @@  discard block
 block discarded – undo
975 1048
 		if (isset($result)) {
976 1049
 			$result[0]['query_number_rows'] = $i;
977 1050
 			return $result;
1051
+		} else {
1052
+			return array();
978 1053
 		}
979
-		else return array();
980 1054
 	}
981 1055
 
982 1056
 	/**
@@ -1036,20 +1110,36 @@  discard block
 block discarded – undo
1036 1110
 			if ($row['registration'] != '') {
1037 1111
 				$row['registration'] = str_replace('.','',$row['registration']);
1038 1112
 				$image_array = $Image->getSpotterImage($row['registration']);
1039
-				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']));
1040
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1041
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1113
+				if (count($image_array) > 0) {
1114
+					$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']));
1115
+				} else {
1116
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1117
+				}
1118
+			} else {
1119
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1120
+			}
1042 1121
 			$icao = '';
1043
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1044
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1122
+			if ($row['registration'] == '') {
1123
+				$row['registration'] = 'NA';
1124
+			}
1125
+			if ($row['ident'] == '') {
1126
+				$row['ident'] = 'NA';
1127
+			}
1045 1128
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1046 1129
 			if (isset($identicao[0])) {
1047 1130
 				if (substr($row['ident'],0,2) == 'AF') {
1048
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1049
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1050
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1131
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1132
+						$icao = $row['ident'];
1133
+					} else {
1134
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1135
+					}
1136
+				} else {
1137
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1138
+				}
1051 1139
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1052
-			} else $icao = $row['ident'];
1140
+			} else {
1141
+				$icao = $row['ident'];
1142
+			}
1053 1143
 			$icao = $Translation->checkTranslation($icao);
1054 1144
 
1055 1145
 
@@ -1057,12 +1147,16 @@  discard block
 block discarded – undo
1057 1147
 			$found = false;
1058 1148
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1059 1149
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1060
-				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>';
1150
+				if (isset($airport_info[0]['icao'])) {
1151
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1152
+				}
1061 1153
 				$found = true;
1062 1154
 			}
1063 1155
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1064 1156
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1065
-				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>';
1157
+				if (isset($airport_info[0]['icao'])) {
1158
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1159
+				}
1066 1160
 				$found = true;
1067 1161
 			}
1068 1162
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1072,7 +1166,9 @@  discard block
 block discarded – undo
1072 1166
 					$found = true;
1073 1167
 				}
1074 1168
 			}
1075
-			if ($found) $row['decode'] = json_encode($decode);
1169
+			if ($found) {
1170
+				$row['decode'] = json_encode($decode);
1171
+			}
1076 1172
 
1077 1173
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1078 1174
 			$result[] = $data;
@@ -1081,7 +1177,9 @@  discard block
 block discarded – undo
1081 1177
 		if (isset($result)) {
1082 1178
 			$result[0]['query_number_rows'] = $i;
1083 1179
 			return $result;
1084
-		} else return array();
1180
+		} else {
1181
+			return array();
1182
+		}
1085 1183
 	}
1086 1184
 
1087 1185
 	/**
@@ -1097,19 +1195,29 @@  discard block
 block discarded – undo
1097 1195
 		$ident = trim($ident);
1098 1196
 		$Translation = new Translation($this->db);
1099 1197
 		$Spotter = new Spotter($this->db);
1100
-		if ($globalDebug) echo "Test if we add ModeS data...";
1198
+		if ($globalDebug) {
1199
+			echo "Test if we add ModeS data...";
1200
+		}
1101 1201
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1102
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1103
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1202
+		if ($icao == '') {
1203
+			$icao = $Translation->checkTranslation($ident);
1204
+		}
1205
+		if ($globalDebug) {
1206
+			echo '- Ident : '.$icao.' - ';
1207
+		}
1104 1208
 		if ($ident == '' || $registration == '') {
1105
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1209
+			if ($globalDebug) {
1210
+				echo "Ident or registration null, exit\n";
1211
+			}
1106 1212
 			return '';
1107 1213
 		}
1108 1214
 
1109 1215
 		$registration = str_replace('.','',$registration);
1110 1216
 		$ident = $Translation->ident2icao($ident);
1111 1217
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1112
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1218
+		if ($globalDebug) {
1219
+			echo "Check if needed to add translation ".$ident.'... ';
1220
+		}
1113 1221
 		$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";
1114 1222
 		$querysi_values = array(':registration' => $registration);
1115 1223
 		try {
@@ -1117,7 +1225,9 @@  discard block
 block discarded – undo
1117 1225
 			$sthsi = $this->db->prepare($querysi);
1118 1226
 			$sthsi->execute($querysi_values);
1119 1227
 		} catch(PDOException $e) {
1120
-			if ($globalDebug) echo $e->getMessage();
1228
+			if ($globalDebug) {
1229
+				echo $e->getMessage();
1230
+			}
1121 1231
 			return "error : ".$e->getMessage();
1122 1232
 		}
1123 1233
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1125,9 +1235,14 @@  discard block
 block discarded – undo
1125 1235
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1126 1236
 			$Translation = new Translation($this->db);
1127 1237
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1128
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1129
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1130
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1238
+			if ($globalDebug) {
1239
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1240
+			}
1241
+			if ($ident != $trans_ident) {
1242
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1243
+			} elseif ($trans_ident == $ident) {
1244
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1245
+			}
1131 1246
 		} else {
1132 1247
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1133 1248
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1136,17 +1251,24 @@  discard block
 block discarded – undo
1136 1251
 					$sth = $this->db->prepare($query);
1137 1252
 					$sth->execute($query_values);
1138 1253
 				} catch(PDOException $e) {
1139
-					if ($globalDebug) echo $e->getMessage();
1254
+					if ($globalDebug) {
1255
+						echo $e->getMessage();
1256
+					}
1140 1257
 					return "error : ".$e->getMessage();
1141 1258
 				}
1142 1259
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1143
-				if (isset($result['modes'])) $hex = $result['modes'];
1144
-				else $hex = '';
1260
+				if (isset($result['modes'])) {
1261
+					$hex = $result['modes'];
1262
+				} else {
1263
+					$hex = '';
1264
+				}
1145 1265
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1146 1266
 				$this->SI->add($SI_data);
1147 1267
 			}
1148 1268
 		}
1149
-		if ($globalDebug) echo 'Done'."\n";
1269
+		if ($globalDebug) {
1270
+			echo 'Done'."\n";
1271
+		}
1150 1272
 
1151 1273
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1152 1274
 		$query_values = array(':ident' => $icao);
@@ -1155,14 +1277,19 @@  discard block
 block discarded – undo
1155 1277
 			$sth = $this->db->prepare($query);
1156 1278
 			$sth->execute($query_values);
1157 1279
 		} catch(PDOException $e) {
1158
-			if ($globalDebug) echo $e->getMessage();
1280
+			if ($globalDebug) {
1281
+				echo $e->getMessage();
1282
+			}
1159 1283
 			return "error : ".$e->getMessage();
1160 1284
 		}
1161 1285
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1162 1286
 		//print_r($result);
1163 1287
 		if (isset($result['flightaware_id'])) {
1164
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1165
-			else $ModeS = '';
1288
+			if (isset($result['ModeS'])) {
1289
+				$ModeS = $result['ModeS'];
1290
+			} else {
1291
+				$ModeS = '';
1292
+			}
1166 1293
 			if ($ModeS == '') {
1167 1294
 				$id = explode('-',$result['flightaware_id']);
1168 1295
 				$ModeS = $id[0];
@@ -1176,13 +1303,17 @@  discard block
 block discarded – undo
1176 1303
 					$sthc = $this->db->prepare($queryc);
1177 1304
 					$sthc->execute($queryc_values);
1178 1305
 				} catch(PDOException $e) {
1179
-					if ($globalDebug) echo $e->getMessage();
1306
+					if ($globalDebug) {
1307
+						echo $e->getMessage();
1308
+					}
1180 1309
 					return "error : ".$e->getMessage();
1181 1310
 				}
1182 1311
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1183 1312
 
1184 1313
 				if (count($row) ==  0) {
1185
-					if ($globalDebug) echo " Add to ModeS table - ";
1314
+					if ($globalDebug) {
1315
+						echo " Add to ModeS table - ";
1316
+					}
1186 1317
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1187 1318
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1188 1319
 					try {
@@ -1190,11 +1321,15 @@  discard block
 block discarded – undo
1190 1321
 						$sthi = $this->db->prepare($queryi);
1191 1322
 						$sthi->execute($queryi_values);
1192 1323
 					} catch(PDOException $e) {
1193
-						if ($globalDebug) echo $e->getMessage();
1324
+						if ($globalDebug) {
1325
+							echo $e->getMessage();
1326
+						}
1194 1327
 						return "error : ".$e->getMessage();
1195 1328
 					}
1196 1329
 				} else {
1197
-					if ($globalDebug) echo " Update ModeS table - ";
1330
+					if ($globalDebug) {
1331
+						echo " Update ModeS table - ";
1332
+					}
1198 1333
 					if ($ICAOTypeCode != '') {
1199 1334
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1200 1335
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1207,7 +1342,9 @@  discard block
 block discarded – undo
1207 1342
 						$sthi = $this->db->prepare($queryi);
1208 1343
 						$sthi->execute($queryi_values);
1209 1344
 					} catch(PDOException $e) {
1210
-						if ($globalDebug) echo $e->getMessage();
1345
+						if ($globalDebug) {
1346
+							echo $e->getMessage();
1347
+						}
1211 1348
 						return "error : ".$e->getMessage();
1212 1349
 					}
1213 1350
 				}
@@ -1229,7 +1366,9 @@  discard block
 block discarded – undo
1229 1366
 					    return "error : ".$e->getMessage();
1230 1367
 				}
1231 1368
 				*/
1232
-				if ($globalDebug) echo " Update Spotter_output table - ";
1369
+				if ($globalDebug) {
1370
+					echo " Update Spotter_output table - ";
1371
+				}
1233 1372
 				if ($ICAOTypeCode != '') {
1234 1373
 					if ($globalDBdriver == 'mysql') {
1235 1374
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1240,8 +1379,7 @@  discard block
 block discarded – undo
1240 1379
 				} else {
1241 1380
 					if ($globalDBdriver == 'mysql') {
1242 1381
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1243
-					}
1244
-					elseif ($globalDBdriver == 'pgsql') {
1382
+					} elseif ($globalDBdriver == 'pgsql') {
1245 1383
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1246 1384
 					}
1247 1385
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1251,15 +1389,21 @@  discard block
 block discarded – undo
1251 1389
 					$sthi = $this->db->prepare($queryi);
1252 1390
 					$sthi->execute($queryi_values);
1253 1391
 				} catch(PDOException $e) {
1254
-					if ($globalDebug) echo $e->getMessage();
1392
+					if ($globalDebug) {
1393
+						echo $e->getMessage();
1394
+					}
1255 1395
 					return "error : ".$e->getMessage();
1256 1396
 				}
1257 1397
 
1258 1398
 			}
1259 1399
 		} else {
1260
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1400
+			if ($globalDebug) {
1401
+				echo " Can't find ModeS in spotter_output - ";
1402
+			}
1403
+		}
1404
+		if ($globalDebug) {
1405
+			echo "Done\n";
1261 1406
 		}
1262
-		if ($globalDebug) echo "Done\n";
1263 1407
 	}
1264 1408
 }
1265 1409
 ?>
Please login to merge, or discard this patch.