Completed
Pull Request — master (#448)
by
unknown
10:23
created
require/class.ACARS.php 1 patch
Braces   +421 added lines, -265 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 	public function __construct($dbc = null,$fromACARSscript = false) {
26 26
 		$Connection = new Connection($dbc);
27 27
 		$this->db = $Connection->db();
28
-		if ($this->db === null) die('Error: No DB connection. (ACARS)');
28
+		if ($this->db === null) {
29
+			die('Error: No DB connection. (ACARS)');
30
+		}
29 31
 		if ($fromACARSscript) {
30 32
 			$this->fromACARSscript = true;
31 33
 			$this->SI = new SpotterImport($this->db);
@@ -40,14 +42,19 @@  discard block
 block discarded – undo
40 42
 	*/
41 43
 	public function ident2icao($ident) {
42 44
 		if (substr($ident,0,2) == 'AF') {
43
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
44
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
45
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
46
+				$icao = $ident;
47
+			} else {
48
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
49
+			}
45 50
 		} else {
46 51
 			$Spotter = new Spotter($this->db);
47 52
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
48 53
 			if (isset($identicao[0])) {
49 54
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
50
-			} else $icao = $ident;
55
+			} else {
56
+				$icao = $ident;
57
+			}
51 58
 		}
52 59
 		return $icao;
53 60
 	}
@@ -121,16 +128,30 @@  discard block
 block discarded – undo
121 128
 		$message = '';
122 129
 		$result = array();
123 130
 		$n = sscanf($data,'%*[0-9a-z.] %*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);
124
-		if ($n == 0 || $message == '') $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);
125
-		if ($n == 0 || $message == '') $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
126
-		if ($n == 0 || $message == '') $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
127
-		if ($n == 0 || $message == '') $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
128
-		if ($n == 0 || $message == '') $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
131
+		if ($n == 0 || $message == '') {
132
+			$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);
133
+		}
134
+		if ($n == 0 || $message == '') {
135
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
136
+		}
137
+		if ($n == 0 || $message == '') {
138
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
139
+		}
140
+		if ($n == 0 || $message == '') {
141
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
142
+		}
143
+		if ($n == 0 || $message == '') {
144
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
145
+		}
129 146
 		if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) {
130 147
 			$registration = str_replace('.','',$registration);
131 148
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
132
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
133
-		} else $message = $data;
149
+			if ($globalDebug) {
150
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
151
+			}
152
+		} else {
153
+			$message = $data;
154
+		}
134 155
 		$decode = array();
135 156
 		$found = false;
136 157
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -150,12 +171,21 @@  discard block
 block discarded – undo
150 171
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
151 172
 					$latitude = $la / 10000.0;
152 173
 					$longitude = $ln / 10000.0;
153
-					if ($lac == 'S') $latitude = '-'.$latitude;
154
-					if ($lnc == 'W') $longitude = '-'.$longitude;
174
+					if ($lac == 'S') {
175
+						$latitude = '-'.$latitude;
176
+					}
177
+					if ($lnc == 'W') {
178
+						$longitude = '-'.$longitude;
179
+					}
155 180
 					// Temp not always available
156
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
157
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
158
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
181
+					if ($globalDebug) {
182
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
183
+					}
184
+					if ($temp == '') {
185
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
186
+					} else {
187
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
188
+					}
159 189
 
160 190
 					//$icao = $Translation->checkTranslation($ident);
161 191
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -169,25 +199,35 @@  discard block
 block discarded – undo
169 199
 				$ahour = '';
170 200
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
171 201
 				if ($n == 4 && strlen($darr) == 4) {
172
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
173
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
174
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
202
+					if ($dhour != '') {
203
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
204
+					}
205
+					if ($ahour != '') {
206
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
207
+					}
208
+					if ($globalDebug) {
209
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
210
+					}
175 211
 					//$icao = ACARS->ident2icao($ident);
176 212
 					//$icao = $Translation->checkTranslation($ident);
177 213
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
178 214
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
179 215
 					$found = true;
180
-				}
181
-				elseif ($n == 2 || $n  == 4) {
182
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
183
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
216
+				} elseif ($n == 2 || $n  == 4) {
217
+					if ($dhour != '') {
218
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
219
+					}
220
+					if ($globalDebug) {
221
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
222
+					}
184 223
 					//$icao = ACARS->ident2icao($ident);
185 224
 					//$icao = $Translation->checkTranslation($ident);
186 225
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
187 226
 					$found = true;
188
-				}
189
-				elseif ($n == 1) {
190
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
227
+				} elseif ($n == 1) {
228
+					if ($globalDebug) {
229
+						echo 'airport arrival : '.$darr."\n";
230
+					}
191 231
 					//$icao = ACARS->ident2icao($ident);
192 232
 					//$icao = $Translation->checkTranslation($ident);
193 233
 					$decode = array('Arrival airport' => $darr);
@@ -205,7 +245,9 @@  discard block
 block discarded – undo
205 245
 				$darr = '';
206 246
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
207 247
 				if ($n == 4) {
208
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
248
+					if ($globalDebug) {
249
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
250
+					}
209 251
 					//$icao = ACARS->ident2icao($ident);
210 252
 					//$icao = $Translation->checkTranslation($ident);
211 253
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -239,14 +281,23 @@  discard block
 block discarded – undo
239 281
 				$apiste = '';
240 282
 				$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);
241 283
 				if ($n > 8) {
242
-					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";
243
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
244
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
284
+					if ($globalDebug) {
285
+						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";
286
+					}
287
+					if ($dhour != '') {
288
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
289
+					}
290
+					if ($ahour != '') {
291
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
292
+					}
245 293
 					$icao = trim($aident);
246 294
 
247 295
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
248
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
249
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
296
+					if ($ahour == '') {
297
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
298
+					} else {
299
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
300
+					}
250 301
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
251 302
 					$decode['icao'] = $icao;
252 303
 					$found = true;
@@ -268,9 +319,15 @@  discard block
 block discarded – undo
268 319
 					$lns = $lns.'.'.$lns;
269 320
 					$latitude = $las / 1000.0;
270 321
 					$longitude = $lns / 1000.0;
271
-					if ($lac == 'S') $latitude = '-'.$latitude;
272
-					if ($lnc == 'W') $longitude = '-'.$longitude;
273
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
322
+					if ($lac == 'S') {
323
+						$latitude = '-'.$latitude;
324
+					}
325
+					if ($lnc == 'W') {
326
+						$longitude = '-'.$longitude;
327
+					}
328
+					if ($globalDebug) {
329
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
330
+					}
274 331
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
275 332
 					$found = true;
276 333
 				}
@@ -288,7 +345,9 @@  discard block
 block discarded – undo
288 345
 				$darr = '';
289 346
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
290 347
 				if ($n == 4) {
291
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
348
+					if ($globalDebug) {
349
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
350
+					}
292 351
 					//$icao = $Translation->checkTranslation($ident);
293 352
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
294 353
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -301,7 +360,9 @@  discard block
 block discarded – undo
301 360
 				$darr = '';
302 361
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
303 362
 				if ($n == 4) {
304
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
363
+					if ($globalDebug) {
364
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
365
+					}
305 366
 					//$icao = $Translation->checkTranslation($ident);
306 367
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
307 368
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -314,7 +375,9 @@  discard block
 block discarded – undo
314 375
 				$darr = '';
315 376
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
316 377
 				if ($n == 2) {
317
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
378
+					if ($globalDebug) {
379
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
380
+					}
318 381
 					//$icao = $Translation->checkTranslation($ident);
319 382
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
320 383
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -328,7 +391,9 @@  discard block
 block discarded – undo
328 391
 				$darr = '';
329 392
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
330 393
 				if ($n == 6) {
331
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
394
+					if ($globalDebug) {
395
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
396
+					}
332 397
 					//$icao = $Translation->checkTranslation($ident);
333 398
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
334 399
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -341,7 +406,9 @@  discard block
 block discarded – undo
341 406
 				$darr = '';
342 407
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
343 408
 				if ($n == 7) {
344
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
409
+					if ($globalDebug) {
410
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
411
+					}
345 412
 					//$icao = $Translation->checkTranslation($ident);
346 413
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
347 414
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -369,8 +436,12 @@  discard block
 block discarded – undo
369 436
 					$decode['icao'] = $icao;
370 437
 					$latitude = $las / 100.0;
371 438
 					$longitude = $lns / 100.0;
372
-					if ($lac == 'S') $latitude = '-'.$latitude;
373
-					if ($lnc == 'W') $longitude = '-'.$longitude;
439
+					if ($lac == 'S') {
440
+						$latitude = '-'.$latitude;
441
+					}
442
+					if ($lnc == 'W') {
443
+						$longitude = '-'.$longitude;
444
+					}
374 445
 
375 446
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
376 447
 					$found = true;
@@ -388,8 +459,12 @@  discard block
 block discarded – undo
388 459
 				if ($n == 4) {
389 460
 					$latitude = $las;
390 461
 					$longitude = $lns;
391
-					if ($lac == 'S') $latitude = '-'.$latitude;
392
-					if ($lnc == 'W') $longitude = '-'.$longitude;
462
+					if ($lac == 'S') {
463
+						$latitude = '-'.$latitude;
464
+					}
465
+					if ($lnc == 'W') {
466
+						$longitude = '-'.$longitude;
467
+					}
393 468
 
394 469
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
395 470
 					$found = true;
@@ -405,7 +480,9 @@  discard block
 block discarded – undo
405 480
 				$darr = '';
406 481
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
407 482
 				if ($n == 5) {
408
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
483
+					if ($globalDebug) {
484
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
485
+					}
409 486
 					//$icao = $Translation->checkTranslation($ident);
410 487
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
411 488
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -426,7 +503,9 @@  discard block
 block discarded – undo
426 503
 				$aident = '';
427 504
 				$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);
428 505
 				if ($n == 8) {
429
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
506
+					if ($globalDebug) {
507
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
508
+					}
430 509
 					$icao = trim($aident);
431 510
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
432 511
 					$decode['icao'] = $icao;
@@ -443,7 +522,9 @@  discard block
 block discarded – undo
443 522
 				$darr = '';
444 523
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
445 524
 				if ($n == 5) {
446
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
525
+					if ($globalDebug) {
526
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
527
+					}
447 528
 					//$icao = $Translation->checkTranslation($ident);
448 529
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
449 530
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -458,7 +539,9 @@  discard block
 block discarded – undo
458 539
 				$darr = '';
459 540
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
460 541
 				if ($n == 3) {
461
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
542
+					if ($globalDebug) {
543
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
544
+					}
462 545
 					//$icao = $Translation->checkTranslation($ident);
463 546
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
464 547
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -473,7 +556,9 @@  discard block
 block discarded – undo
473 556
 				$darr = '';
474 557
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
475 558
 				if ($n == 3) {
476
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
559
+					if ($globalDebug) {
560
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
561
+					}
477 562
 					//$icao = $Translation->checkTranslation($ident);
478 563
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
479 564
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -483,7 +568,9 @@  discard block
 block discarded – undo
483 568
 			if (!$found) {
484 569
 				$n = sscanf($message,'MET01%4c',$airport);
485 570
 				if ($n == 1) {
486
-					if ($globalDebug) echo 'airport name : '.$airport;
571
+					if ($globalDebug) {
572
+						echo 'airport name : '.$airport;
573
+					}
487 574
 					$decode = array('Airport/Waypoint name' => $airport);
488 575
 					$found = true;
489 576
 				}
@@ -491,184 +578,126 @@  discard block
 block discarded – undo
491 578
 			if ($label == 'H1') {
492 579
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
493 580
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
494
-				}
495
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
581
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
496 582
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
497
-				}
498
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
583
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
499 584
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
500
-				}
501
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
585
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
502 586
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
503
-				}
504
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
587
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
505 588
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
506
-				}
507
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
589
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
508 590
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
509
-				}
510
-				elseif (preg_match(':^#M1AAEP:',$message)) {
591
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
511 592
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
512
-				}
513
-				elseif (preg_match(':^#M2APWD:',$message)) {
593
+				} elseif (preg_match(':^#M2APWD:',$message)) {
514 594
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
515
-				}
516
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
595
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
517 596
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
518
-				}
519
-				elseif (preg_match(':^#CF:',$message)) {
597
+				} elseif (preg_match(':^#CF:',$message)) {
520 598
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
521
-				}
522
-				elseif (preg_match(':^#DF:',$message)) {
599
+				} elseif (preg_match(':^#DF:',$message)) {
523 600
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
524
-				}
525
-				elseif (preg_match(':^#EC:',$message)) {
601
+				} elseif (preg_match(':^#EC:',$message)) {
526 602
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
527
-				}
528
-				elseif (preg_match(':^#EI:',$message)) {
603
+				} elseif (preg_match(':^#EI:',$message)) {
529 604
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
530
-				}
531
-				elseif (preg_match(':^#H1:',$message)) {
605
+				} elseif (preg_match(':^#H1:',$message)) {
532 606
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
533
-				}
534
-				elseif (preg_match(':^#H2:',$message)) {
607
+				} elseif (preg_match(':^#H2:',$message)) {
535 608
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
536
-				}
537
-				elseif (preg_match(':^#HD:',$message)) {
609
+				} elseif (preg_match(':^#HD:',$message)) {
538 610
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
539
-				}
540
-				elseif (preg_match(':^#M1:',$message)) {
611
+				} elseif (preg_match(':^#M1:',$message)) {
541 612
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
542
-				}
543
-				elseif (preg_match(':^#M2:',$message)) {
613
+				} elseif (preg_match(':^#M2:',$message)) {
544 614
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
545
-				}
546
-				elseif (preg_match(':^#M3:',$message)) {
615
+				} elseif (preg_match(':^#M3:',$message)) {
547 616
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
548
-				}
549
-				elseif (preg_match(':^#MD:',$message)) {
617
+				} elseif (preg_match(':^#MD:',$message)) {
550 618
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
551
-				}
552
-				elseif (preg_match(':^#PS:',$message)) {
619
+				} elseif (preg_match(':^#PS:',$message)) {
553 620
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
554
-				}
555
-				elseif (preg_match(':^#S1:',$message)) {
621
+				} elseif (preg_match(':^#S1:',$message)) {
556 622
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
557
-				}
558
-				elseif (preg_match(':^#S2:',$message)) {
623
+				} elseif (preg_match(':^#S2:',$message)) {
559 624
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
560
-				}
561
-				elseif (preg_match(':^#SD:',$message)) {
625
+				} elseif (preg_match(':^#SD:',$message)) {
562 626
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
563
-				}
564
-				elseif (preg_match(':^#T[0-8]:',$message)) {
627
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
565 628
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
566
-				}
567
-				elseif (preg_match(':^#WO:',$message)) {
629
+				} elseif (preg_match(':^#WO:',$message)) {
568 630
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
569
-				}
570
-				elseif (preg_match(':^#A1:',$message)) {
631
+				} elseif (preg_match(':^#A1:',$message)) {
571 632
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
572
-				}
573
-				elseif (preg_match(':^#A3:',$message)) {
633
+				} elseif (preg_match(':^#A3:',$message)) {
574 634
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
575
-				}
576
-				elseif (preg_match(':^#A4:',$message)) {
635
+				} elseif (preg_match(':^#A4:',$message)) {
577 636
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
578
-				}
579
-				elseif (preg_match(':^#A6:',$message)) {
637
+				} elseif (preg_match(':^#A6:',$message)) {
580 638
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
581
-				}
582
-				elseif (preg_match(':^#A8:',$message)) {
639
+				} elseif (preg_match(':^#A8:',$message)) {
583 640
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
584
-				}
585
-				elseif (preg_match(':^#A9:',$message)) {
641
+				} elseif (preg_match(':^#A9:',$message)) {
586 642
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
587
-				}
588
-				elseif (preg_match(':^#A0:',$message)) {
643
+				} elseif (preg_match(':^#A0:',$message)) {
589 644
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
590
-				}
591
-				elseif (preg_match(':^#AA:',$message)) {
645
+				} elseif (preg_match(':^#AA:',$message)) {
592 646
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
593
-				}
594
-				elseif (preg_match(':^#AB:',$message)) {
647
+				} elseif (preg_match(':^#AB:',$message)) {
595 648
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
596
-				}
597
-				elseif (preg_match(':^#AC:',$message)) {
649
+				} elseif (preg_match(':^#AC:',$message)) {
598 650
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
599
-				}
600
-				elseif (preg_match(':^#AD:',$message)) {
651
+				} elseif (preg_match(':^#AD:',$message)) {
601 652
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
602
-				}
603
-				elseif (preg_match(':^#AF:',$message)) {
653
+				} elseif (preg_match(':^#AF:',$message)) {
604 654
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
605
-				}
606
-				elseif (preg_match(':^#B1:',$message)) {
655
+				} elseif (preg_match(':^#B1:',$message)) {
607 656
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
608
-				}
609
-				elseif (preg_match(':^#B2:',$message)) {
657
+				} elseif (preg_match(':^#B2:',$message)) {
610 658
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
611
-				}
612
-				elseif (preg_match(':^#B3:',$message)) {
659
+				} elseif (preg_match(':^#B3:',$message)) {
613 660
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
614
-				}
615
-				elseif (preg_match(':^#B4:',$message)) {
661
+				} elseif (preg_match(':^#B4:',$message)) {
616 662
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
617
-				}
618
-				elseif (preg_match(':^#B6:',$message)) {
663
+				} elseif (preg_match(':^#B6:',$message)) {
619 664
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
620
-				}
621
-				elseif (preg_match(':^#B8:',$message)) {
665
+				} elseif (preg_match(':^#B8:',$message)) {
622 666
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
623
-				}
624
-				elseif (preg_match(':^#B9:',$message)) {
667
+				} elseif (preg_match(':^#B9:',$message)) {
625 668
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
626
-				}
627
-				elseif (preg_match(':^#B0:',$message)) {
669
+				} elseif (preg_match(':^#B0:',$message)) {
628 670
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
629
-				}
630
-				elseif (preg_match(':^#BA:',$message)) {
671
+				} elseif (preg_match(':^#BA:',$message)) {
631 672
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
632
-				}
633
-				elseif (preg_match(':^#BB:',$message)) {
673
+				} elseif (preg_match(':^#BB:',$message)) {
634 674
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
635
-				}
636
-				elseif (preg_match(':^#BC:',$message)) {
675
+				} elseif (preg_match(':^#BC:',$message)) {
637 676
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
638
-				}
639
-				elseif (preg_match(':^#BD:',$message)) {
677
+				} elseif (preg_match(':^#BD:',$message)) {
640 678
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
641
-				}
642
-				elseif (preg_match(':^#BE:',$message)) {
679
+				} elseif (preg_match(':^#BE:',$message)) {
643 680
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
644
-				}
645
-				elseif (preg_match(':^#BF:',$message)) {
681
+				} elseif (preg_match(':^#BF:',$message)) {
646 682
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
647
-				}
648
-				elseif (preg_match(':^#H3:',$message)) {
683
+				} elseif (preg_match(':^#H3:',$message)) {
649 684
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
650 685
 				}
651 686
 			}
652 687
 			if ($label == '10') {
653 688
 				if (preg_match(':^DTO01:',$message)) {
654 689
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
655
-				}
656
-				elseif (preg_match(':^AIS01:',$message)) {
690
+				} elseif (preg_match(':^AIS01:',$message)) {
657 691
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
658
-				}
659
-				elseif (preg_match(':^FTX01:',$message)) {
692
+				} elseif (preg_match(':^FTX01:',$message)) {
660 693
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
661
-				}
662
-				elseif (preg_match(':^FPL01:',$message)) {
694
+				} elseif (preg_match(':^FPL01:',$message)) {
663 695
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
664
-				}
665
-				elseif (preg_match(':^WAB01:',$message)) {
696
+				} elseif (preg_match(':^WAB01:',$message)) {
666 697
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
667
-				}
668
-				elseif (preg_match(':^MET01:',$message)) {
698
+				} elseif (preg_match(':^MET01:',$message)) {
669 699
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
670
-				}
671
-				elseif (preg_match(':^WAB02:',$message)) {
700
+				} elseif (preg_match(':^WAB02:',$message)) {
672 701
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
673 702
 				}
674 703
 			}
@@ -683,38 +712,28 @@  discard block
 block discarded – undo
683 712
 					$vsta = array('Version' => $version);
684 713
 					if ($state == 'E') {
685 714
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
686
-					}
687
-					elseif ($state == 'L') {
715
+					} elseif ($state == 'L') {
688 716
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
689
-					}
690
-					else {
717
+					} else {
691 718
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
692 719
 					}
693 720
 					if ($type == 'V') {
694 721
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
695
-					}
696
-					elseif ($type == 'S') {
722
+					} elseif ($type == 'S') {
697 723
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
698
-					}
699
-					elseif ($type == 'H') {
724
+					} elseif ($type == 'H') {
700 725
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
701
-					}
702
-					elseif ($type == 'G') {
726
+					} elseif ($type == 'G') {
703 727
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
704
-					}
705
-					elseif ($type == 'C') {
728
+					} elseif ($type == 'C') {
706 729
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
707
-					}
708
-					elseif ($type == '2') {
730
+					} elseif ($type == '2') {
709 731
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
710
-					}
711
-					elseif ($type == 'X') {
732
+					} elseif ($type == 'X') {
712 733
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
713
-					}
714
-					elseif ($type == 'I') {
734
+					} elseif ($type == 'I') {
715 735
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
716
-					}
717
-					else {
736
+					} else {
718 737
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
719 738
 					}
720 739
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -723,7 +742,9 @@  discard block
 block discarded – undo
723 742
 			}
724 743
 
725 744
 			$title = $this->getTitlefromLabel($label);
726
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
745
+			if ($title != '') {
746
+				$decode = array_merge(array('Message title' => $title),$decode);
747
+			}
727 748
 			/*
728 749
 			// Business jets always use GS0001
729 750
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -759,31 +780,54 @@  discard block
 block discarded – undo
759 780
 			$msg = $message['message'];
760 781
 			$decode = $message['decode'];
761 782
 			$registration = (string)$message['registration'];
762
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
763
-			else $latitude = '';
764
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
765
-			else $longitude = '';
766
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
767
-			else $airicao = '';
768
-			if (isset($decode['icao'])) $icao = $decode['icao'];
769
-			else $icao = $Translation->checkTranslation($ident);
783
+			if (isset($decode['latitude'])) {
784
+				$latitude = $decode['latitude'];
785
+			} else {
786
+				$latitude = '';
787
+			}
788
+			if (isset($decode['longitude'])) {
789
+				$longitude = $decode['longitude'];
790
+			} else {
791
+				$longitude = '';
792
+			}
793
+			if (isset($decode['airicao'])) {
794
+				$airicao = $decode['airicao'];
795
+			} else {
796
+				$airicao = '';
797
+			}
798
+			if (isset($decode['icao'])) {
799
+				$icao = $decode['icao'];
800
+			} else {
801
+				$icao = $Translation->checkTranslation($ident);
802
+			}
770 803
 			$image_array = $Image->getSpotterImage($registration);
771 804
 			if (!isset($image_array[0]['registration'])) {
772 805
 				$Image->addSpotterImage($registration);
773 806
 			}
774 807
 			// Business jets always use GS0001
775
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
776
-			if ($globalDebug && isset($info) && $info != '') echo $info;
777
-			if (count($decode) > 0) $decode_json = json_encode($decode);
778
-			else $decode_json = '';
808
+			if ($ident != 'GS0001') {
809
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
810
+			}
811
+			if ($globalDebug && isset($info) && $info != '') {
812
+				echo $info;
813
+			}
814
+			if (count($decode) > 0) {
815
+				$decode_json = json_encode($decode);
816
+			} else {
817
+				$decode_json = '';
818
+			}
779 819
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
780 820
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
781 821
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
782 822
 				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
783 823
 			}
784 824
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
785
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
786
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
825
+			if (!isset($globalACARSArchive)) {
826
+				$globalACARSArchive = array('10','80','81','82','3F');
827
+			}
828
+			if ($result && in_array($label,$globalACARSArchive)) {
829
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
830
+			}
787 831
 			if ($globalDebug && count($decode) > 0) {
788 832
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
789 833
 			}
@@ -808,7 +852,9 @@  discard block
 block discarded – undo
808 852
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
809 853
 			$Connection = new Connection($this->db);
810 854
 			$this->db = $Connection->db;
811
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
855
+			if ($globalDebug) {
856
+				echo "Test if not already in Live ACARS table...";
857
+			}
812 858
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
813 859
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
814 860
 			try {
@@ -819,7 +865,9 @@  discard block
 block discarded – undo
819 865
 				return false;
820 866
 			}
821 867
 			if ($stht->fetchColumn() == 0) {
822
-				if ($globalDebug) echo "Add Live ACARS data...";
868
+				if ($globalDebug) {
869
+					echo "Add Live ACARS data...";
870
+				}
823 871
 				$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)";
824 872
 				$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"));
825 873
 				try {
@@ -830,10 +878,14 @@  discard block
 block discarded – undo
830 878
 					return false;
831 879
 				}
832 880
 			} else {
833
-				if ($globalDebug) echo "Data already in DB...\n";
881
+				if ($globalDebug) {
882
+					echo "Data already in DB...\n";
883
+				}
834 884
 				return false;
835 885
 			}
836
-			if ($globalDebug) echo "Done\n";
886
+			if ($globalDebug) {
887
+				echo "Done\n";
888
+			}
837 889
 			return true;
838 890
 		}
839 891
 		return false;
@@ -867,7 +919,9 @@  discard block
 block discarded – undo
867 919
 			    	    }
868 920
 				    if ($stht->fetchColumn() == 0) {
869 921
 			*/
870
-			if ($globalDebug) echo "Add Live ACARS data...";
922
+			if ($globalDebug) {
923
+				echo "Add Live ACARS data...";
924
+			}
871 925
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
872 926
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
873 927
 			try {
@@ -876,7 +930,9 @@  discard block
 block discarded – undo
876 930
 			} catch(PDOException $e) {
877 931
 				return "error : ".$e->getMessage();
878 932
 			}
879
-			if ($globalDebug) echo "Done\n";
933
+			if ($globalDebug) {
934
+				echo "Done\n";
935
+			}
880 936
 		}
881 937
 		return '';
882 938
 	}
@@ -900,8 +956,11 @@  discard block
 block discarded – undo
900 956
 			return '';
901 957
 		}
902 958
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
903
-		if (count($row) > 0) return $row[0]['title'];
904
-		else return '';
959
+		if (count($row) > 0) {
960
+			return $row[0]['title'];
961
+		} else {
962
+			return '';
963
+		}
905 964
 	}
906 965
 
907 966
 	/**
@@ -920,8 +979,11 @@  discard block
 block discarded – undo
920 979
 			return array();
921 980
 		}
922 981
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
923
-		if (count($row) > 0) return $row;
924
-		else return array();
982
+		if (count($row) > 0) {
983
+			return $row;
984
+		} else {
985
+			return array();
986
+		}
925 987
 	}
926 988
 
927 989
 	/**
@@ -941,8 +1003,11 @@  discard block
 block discarded – undo
941 1003
 			return array();
942 1004
 		}
943 1005
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
944
-		if (count($row) > 0) return $row[0];
945
-		else return array();
1006
+		if (count($row) > 0) {
1007
+			return $row[0];
1008
+		} else {
1009
+			return array();
1010
+		}
946 1011
 	}
947 1012
 
948 1013
     /**
@@ -990,19 +1055,35 @@  discard block
 block discarded – undo
990 1055
 			if ($row['registration'] != '') {
991 1056
 				$row['registration'] = str_replace('.','',$row['registration']);
992 1057
 				$image_array = $Image->getSpotterImage($row['registration']);
993
-				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']));
994
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
995
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
996
-			if ($row['registration'] == '') $row['registration'] = 'NA';
997
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1058
+				if (count($image_array) > 0) {
1059
+					$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']));
1060
+				} else {
1061
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1062
+				}
1063
+			} else {
1064
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1065
+			}
1066
+			if ($row['registration'] == '') {
1067
+				$row['registration'] = 'NA';
1068
+			}
1069
+			if ($row['ident'] == '') {
1070
+				$row['ident'] = 'NA';
1071
+			}
998 1072
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
999 1073
 			if (isset($identicao[0])) {
1000 1074
 				if (substr($row['ident'],0,2) == 'AF') {
1001
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1002
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1003
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1075
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1076
+						$icao = $row['ident'];
1077
+					} else {
1078
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1079
+					}
1080
+				} else {
1081
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1082
+				}
1004 1083
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1005
-			} else $icao = $row['ident'];
1084
+			} else {
1085
+				$icao = $row['ident'];
1086
+			}
1006 1087
 			$icao = $Translation->checkTranslation($icao,false);
1007 1088
 			$decode = json_decode($row['decode'],true);
1008 1089
 			$found = false;
@@ -1027,7 +1108,9 @@  discard block
 block discarded – undo
1027 1108
 					$found = true;
1028 1109
 				}
1029 1110
 			}
1030
-			if ($found) $row['decode'] = json_encode($decode);
1111
+			if ($found) {
1112
+				$row['decode'] = json_encode($decode);
1113
+			}
1031 1114
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1032 1115
 			$result[] = $data;
1033 1116
 			$i++;
@@ -1035,8 +1118,9 @@  discard block
 block discarded – undo
1035 1118
 		if (isset($result)) {
1036 1119
 			$result[0]['query_number_rows'] = $i;
1037 1120
 			return $result;
1121
+		} else {
1122
+			return array();
1038 1123
 		}
1039
-		else return array();
1040 1124
 	}
1041 1125
 
1042 1126
     /**
@@ -1089,31 +1173,51 @@  discard block
 block discarded – undo
1089 1173
 			if ($row['registration'] != '') {
1090 1174
 				$row['registration'] = str_replace('.','',$row['registration']);
1091 1175
 				$image_array = $Image->getSpotterImage($row['registration']);
1092
-				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']));
1093
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1094
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1176
+				if (count($image_array) > 0) {
1177
+					$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']));
1178
+				} else {
1179
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1180
+				}
1181
+			} else {
1182
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1183
+			}
1095 1184
 			$icao = '';
1096
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1097
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1185
+			if ($row['registration'] == '') {
1186
+				$row['registration'] = 'NA';
1187
+			}
1188
+			if ($row['ident'] == '') {
1189
+				$row['ident'] = 'NA';
1190
+			}
1098 1191
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1099 1192
 			if (isset($identicao[0])) {
1100 1193
 				if (substr($row['ident'],0,2) == 'AF') {
1101
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1102
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1103
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1194
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1195
+						$icao = $row['ident'];
1196
+					} else {
1197
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1198
+					}
1199
+				} else {
1200
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1201
+				}
1104 1202
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1105
-			} else $icao = $row['ident'];
1203
+			} else {
1204
+				$icao = $row['ident'];
1205
+			}
1106 1206
 			$icao = $Translation->checkTranslation($icao);
1107 1207
 			$decode = json_decode($row['decode'],true);
1108 1208
 			$found = false;
1109 1209
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1110 1210
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1111
-				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>';
1211
+				if (isset($airport_info[0]['icao'])) {
1212
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1213
+				}
1112 1214
 				$found = true;
1113 1215
 			}
1114 1216
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1115 1217
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1116
-				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>';
1218
+				if (isset($airport_info[0]['icao'])) {
1219
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1220
+				}
1117 1221
 				$found = true;
1118 1222
 			}
1119 1223
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1123,7 +1227,9 @@  discard block
 block discarded – undo
1123 1227
 					$found = true;
1124 1228
 				}
1125 1229
 			}
1126
-			if ($found) $row['decode'] = json_encode($decode);
1230
+			if ($found) {
1231
+				$row['decode'] = json_encode($decode);
1232
+			}
1127 1233
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1128 1234
 			$result[] = $data;
1129 1235
 			$i++;
@@ -1131,7 +1237,9 @@  discard block
 block discarded – undo
1131 1237
 		if (!empty($result)) {
1132 1238
 			$result[0]['query_number_rows'] = $i;
1133 1239
 			return $result;
1134
-		} else return array();
1240
+		} else {
1241
+			return array();
1242
+		}
1135 1243
 	}
1136 1244
 
1137 1245
     /**
@@ -1150,25 +1258,37 @@  discard block
 block discarded – undo
1150 1258
 		$ident = trim($ident);
1151 1259
 		$Translation = new Translation($this->db);
1152 1260
 		$Spotter = new Spotter($this->db);
1153
-		if ($globalDebug) echo "Test if we add ModeS data...";
1261
+		if ($globalDebug) {
1262
+			echo "Test if we add ModeS data...";
1263
+		}
1154 1264
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1155
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1156
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1265
+		if ($icao == '') {
1266
+			$icao = $Translation->checkTranslation($ident);
1267
+		}
1268
+		if ($globalDebug) {
1269
+			echo '- Ident : '.$icao.' - ';
1270
+		}
1157 1271
 		if ($ident == '' || $registration == '') {
1158
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1272
+			if ($globalDebug) {
1273
+				echo "Ident or registration null, exit\n";
1274
+			}
1159 1275
 			return '';
1160 1276
 		}
1161 1277
 		$registration = str_replace('.','',$registration);
1162 1278
 		$ident = $Translation->ident2icao($ident);
1163 1279
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1164
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1280
+		if ($globalDebug) {
1281
+			echo "Check if needed to add translation ".$ident.'... ';
1282
+		}
1165 1283
 		$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";
1166 1284
 		$querysi_values = array(':registration' => $registration);
1167 1285
 		try {
1168 1286
 			$sthsi = $this->db->prepare($querysi);
1169 1287
 			$sthsi->execute($querysi_values);
1170 1288
 		} catch(PDOException $e) {
1171
-			if ($globalDebug) echo $e->getMessage();
1289
+			if ($globalDebug) {
1290
+				echo $e->getMessage();
1291
+			}
1172 1292
 			return "error : ".$e->getMessage();
1173 1293
 		}
1174 1294
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1176,9 +1296,14 @@  discard block
 block discarded – undo
1176 1296
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1177 1297
 			$Translation = new Translation($this->db);
1178 1298
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1179
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1180
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1181
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1299
+			if ($globalDebug) {
1300
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1301
+			}
1302
+			if ($ident != $trans_ident) {
1303
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1304
+			} elseif ($trans_ident == $ident) {
1305
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1306
+			}
1182 1307
 		} else {
1183 1308
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1184 1309
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1187,32 +1312,46 @@  discard block
 block discarded – undo
1187 1312
 					$sth = $this->db->prepare($query);
1188 1313
 					$sth->execute($query_values);
1189 1314
 				} catch(PDOException $e) {
1190
-					if ($globalDebug) echo $e->getMessage();
1315
+					if ($globalDebug) {
1316
+						echo $e->getMessage();
1317
+					}
1191 1318
 					return "error : ".$e->getMessage();
1192 1319
 				}
1193 1320
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1194 1321
 				$sth->closeCursor();
1195
-				if (isset($result['modes'])) $hex = $result['modes'];
1196
-				else $hex = '';
1322
+				if (isset($result['modes'])) {
1323
+					$hex = $result['modes'];
1324
+				} else {
1325
+					$hex = '';
1326
+				}
1197 1327
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1198
-				if ($this->fromACARSscript) $this->SI->add($SI_data);
1328
+				if ($this->fromACARSscript) {
1329
+					$this->SI->add($SI_data);
1330
+				}
1199 1331
 			}
1200 1332
 		}
1201
-		if ($globalDebug) echo 'Done'."\n";
1333
+		if ($globalDebug) {
1334
+			echo 'Done'."\n";
1335
+		}
1202 1336
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1203 1337
 		$query_values = array(':ident' => $icao);
1204 1338
 		try {
1205 1339
 			$sth = $this->db->prepare($query);
1206 1340
 			$sth->execute($query_values);
1207 1341
 		} catch(PDOException $e) {
1208
-			if ($globalDebug) echo $e->getMessage();
1342
+			if ($globalDebug) {
1343
+				echo $e->getMessage();
1344
+			}
1209 1345
 			return "error : ".$e->getMessage();
1210 1346
 		}
1211 1347
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1212 1348
 		$sth->closeCursor();
1213 1349
 		if (isset($result['flightaware_id'])) {
1214
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1215
-			else $ModeS = '';
1350
+			if (isset($result['ModeS'])) {
1351
+				$ModeS = $result['ModeS'];
1352
+			} else {
1353
+				$ModeS = '';
1354
+			}
1216 1355
 			if ($ModeS == '') {
1217 1356
 				$id = explode('-',$result['flightaware_id']);
1218 1357
 				$ModeS = $id[0];
@@ -1225,24 +1364,32 @@  discard block
 block discarded – undo
1225 1364
 					$sthc = $this->db->prepare($queryc);
1226 1365
 					$sthc->execute($queryc_values);
1227 1366
 				} catch(PDOException $e) {
1228
-					if ($globalDebug) echo $e->getMessage();
1367
+					if ($globalDebug) {
1368
+						echo $e->getMessage();
1369
+					}
1229 1370
 					return "error : ".$e->getMessage();
1230 1371
 				}
1231 1372
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1232 1373
 				$sthc->closeCursor();
1233 1374
 				if (count($row) ==  0) {
1234
-					if ($globalDebug) echo " Add to ModeS table - ";
1375
+					if ($globalDebug) {
1376
+						echo " Add to ModeS table - ";
1377
+					}
1235 1378
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1236 1379
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1237 1380
 					try {
1238 1381
 						$sthi = $this->db->prepare($queryi);
1239 1382
 						$sthi->execute($queryi_values);
1240 1383
 					} catch(PDOException $e) {
1241
-						if ($globalDebug) echo $e->getMessage();
1384
+						if ($globalDebug) {
1385
+							echo $e->getMessage();
1386
+						}
1242 1387
 						return "error : ".$e->getMessage();
1243 1388
 					}
1244 1389
 				} else {
1245
-					if ($globalDebug) echo " Update ModeS table - ";
1390
+					if ($globalDebug) {
1391
+						echo " Update ModeS table - ";
1392
+					}
1246 1393
 					if ($ICAOTypeCode != '') {
1247 1394
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1248 1395
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1254,7 +1401,9 @@  discard block
 block discarded – undo
1254 1401
 						$sthi = $this->db->prepare($queryi);
1255 1402
 						$sthi->execute($queryi_values);
1256 1403
 					} catch(PDOException $e) {
1257
-						if ($globalDebug) echo $e->getMessage();
1404
+						if ($globalDebug) {
1405
+							echo $e->getMessage();
1406
+						}
1258 1407
 						return "error : ".$e->getMessage();
1259 1408
 					}
1260 1409
 				}
@@ -1275,7 +1424,9 @@  discard block
 block discarded – undo
1275 1424
 					    return "error : ".$e->getMessage();
1276 1425
 				}
1277 1426
 				*/
1278
-				if ($globalDebug) echo " Update Spotter_output table - ";
1427
+				if ($globalDebug) {
1428
+					echo " Update Spotter_output table - ";
1429
+				}
1279 1430
 				if ($ICAOTypeCode != '') {
1280 1431
 					if ($globalDBdriver == 'mysql') {
1281 1432
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1286,8 +1437,7 @@  discard block
 block discarded – undo
1286 1437
 				} else {
1287 1438
 					if ($globalDBdriver == 'mysql') {
1288 1439
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1289
-					}
1290
-					elseif ($globalDBdriver == 'pgsql') {
1440
+					} elseif ($globalDBdriver == 'pgsql') {
1291 1441
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1292 1442
 					}
1293 1443
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1296,14 +1446,20 @@  discard block
 block discarded – undo
1296 1446
 					$sthi = $this->db->prepare($queryi);
1297 1447
 					$sthi->execute($queryi_values);
1298 1448
 				} catch(PDOException $e) {
1299
-					if ($globalDebug) echo $e->getMessage();
1449
+					if ($globalDebug) {
1450
+						echo $e->getMessage();
1451
+					}
1300 1452
 					return "error : ".$e->getMessage();
1301 1453
 				}
1302 1454
 			}
1303 1455
 		} else {
1304
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1456
+			if ($globalDebug) {
1457
+				echo " Can't find ModeS in spotter_output - ";
1458
+			}
1459
+		}
1460
+		if ($globalDebug) {
1461
+			echo "Done\n";
1305 1462
 		}
1306
-		if ($globalDebug) echo "Done\n";
1307 1463
 		return '';
1308 1464
 	}
1309 1465
 }
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +1252 added lines, -433 removed lines patch added patch discarded remove patch
@@ -36,7 +36,9 @@  discard block
 block discarded – undo
36 36
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
37 37
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
38 38
 		curl_setopt($ch, CURLOPT_TIMEOUT, 200);
39
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
39
+		if ($referer != '') {
40
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
41
+		}
40 42
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
41 43
 		curl_setopt($ch, CURLOPT_FILE, $fp);
42 44
 		curl_exec($ch);
@@ -47,12 +49,16 @@  discard block
 block discarded – undo
47 49
 	public static function gunzip($in_file,$out_file_name = '') {
48 50
 		//echo $in_file.' -> '.$out_file_name."\n";
49 51
 		$buffer_size = 4096; // read 4kb at a time
50
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
52
+		if ($out_file_name == '') {
53
+			$out_file_name = str_replace('.gz', '', $in_file);
54
+		}
51 55
 		if ($in_file != '' && file_exists($in_file)) {
52 56
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
53
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
54
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
55
-			else {
57
+			if (function_exists('gzopen')) {
58
+				$file = gzopen($in_file,'rb');
59
+			} elseif (function_exists('gzopen64')) {
60
+				$file = gzopen64($in_file,'rb');
61
+			} else {
56 62
 				echo 'gzopen not available';
57 63
 				die;
58 64
 			}
@@ -73,8 +79,12 @@  discard block
 block discarded – undo
73 79
 			if ($res === TRUE) {
74 80
 				$zip->extractTo($path);
75 81
 				$zip->close();
76
-			} else return false;
77
-		} else return false;
82
+			} else {
83
+				return false;
84
+			}
85
+		} else {
86
+			return false;
87
+		}
78 88
 	}
79 89
 	
80 90
 	public static function connect_sqlite($database) {
@@ -89,7 +99,9 @@  discard block
 block discarded – undo
89 99
 	public static function retrieve_route_sqlite_to_dest($database_file) {
90 100
 		global $globalDebug, $globalTransaction;
91 101
 		//$query = 'TRUNCATE TABLE routes';
92
-		if ($globalDebug) echo " - Delete previous routes from DB -";
102
+		if ($globalDebug) {
103
+			echo " - Delete previous routes from DB -";
104
+		}
93 105
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
94 106
 		$Connection = new Connection();
95 107
 		try {
@@ -100,7 +112,9 @@  discard block
 block discarded – undo
100 112
                         return "error : ".$e->getMessage();
101 113
                 }
102 114
 
103
-    		if ($globalDebug) echo " - Add routes to DB -";
115
+    		if ($globalDebug) {
116
+    			echo " - Add routes to DB -";
117
+    		}
104 118
     		update_db::connect_sqlite($database_file);
105 119
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
106 120
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -115,15 +129,21 @@  discard block
 block discarded – undo
115 129
 		$Connection = new Connection();
116 130
 		$sth_dest = $Connection->db->prepare($query_dest);
117 131
 		try {
118
-			if ($globalTransaction) $Connection->db->beginTransaction();
132
+			if ($globalTransaction) {
133
+				$Connection->db->beginTransaction();
134
+			}
119 135
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
120 136
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
121 137
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
122 138
 				$sth_dest->execute($query_dest_values);
123 139
             		}
124
-			if ($globalTransaction) $Connection->db->commit();
140
+			if ($globalTransaction) {
141
+				$Connection->db->commit();
142
+			}
125 143
 		} catch(PDOException $e) {
126
-			if ($globalTransaction) $Connection->db->rollBack(); 
144
+			if ($globalTransaction) {
145
+				$Connection->db->rollBack();
146
+			}
127 147
 			return "error : ".$e->getMessage();
128 148
 		}
129 149
                 return '';
@@ -131,7 +151,9 @@  discard block
 block discarded – undo
131 151
 	public static function retrieve_route_oneworld($database_file) {
132 152
 		global $globalDebug, $globalTransaction;
133 153
 		//$query = 'TRUNCATE TABLE routes';
134
-		if ($globalDebug) echo " - Delete previous routes from DB -";
154
+		if ($globalDebug) {
155
+			echo " - Delete previous routes from DB -";
156
+		}
135 157
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
136 158
 		$Connection = new Connection();
137 159
 		try {
@@ -142,14 +164,18 @@  discard block
 block discarded – undo
142 164
                         return "error : ".$e->getMessage();
143 165
                 }
144 166
 
145
-    		if ($globalDebug) echo " - Add routes to DB -";
167
+    		if ($globalDebug) {
168
+    			echo " - Add routes to DB -";
169
+    		}
146 170
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
147 171
 		$Spotter = new Spotter();
148 172
 		if ($fh = fopen($database_file,"r")) {
149 173
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
150 174
 			$Connection = new Connection();
151 175
 			$sth_dest = $Connection->db->prepare($query_dest);
152
-			if ($globalTransaction) $Connection->db->beginTransaction();
176
+			if ($globalTransaction) {
177
+				$Connection->db->beginTransaction();
178
+			}
153 179
 			while (!feof($fh)) {
154 180
 				$line = fgetcsv($fh,9999,',');
155 181
 				if ($line[0] != '') {
@@ -158,13 +184,17 @@  discard block
 block discarded – undo
158 184
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
159 185
 							$sth_dest->execute($query_dest_values);
160 186
 						} catch(PDOException $e) {
161
-							if ($globalTransaction) $Connection->db->rollBack(); 
187
+							if ($globalTransaction) {
188
+								$Connection->db->rollBack();
189
+							}
162 190
 							return "error : ".$e->getMessage();
163 191
 						}
164 192
 					}
165 193
 				}
166 194
 			}
167
-			if ($globalTransaction) $Connection->db->commit();
195
+			if ($globalTransaction) {
196
+				$Connection->db->commit();
197
+			}
168 198
 		}
169 199
                 return '';
170 200
 	}
@@ -172,7 +202,9 @@  discard block
 block discarded – undo
172 202
 	public static function retrieve_route_skyteam($database_file) {
173 203
 		global $globalDebug, $globalTransaction;
174 204
 		//$query = 'TRUNCATE TABLE routes';
175
-		if ($globalDebug) echo " - Delete previous routes from DB -";
205
+		if ($globalDebug) {
206
+			echo " - Delete previous routes from DB -";
207
+		}
176 208
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
177 209
 		$Connection = new Connection();
178 210
 		try {
@@ -183,7 +215,9 @@  discard block
 block discarded – undo
183 215
                         return "error : ".$e->getMessage();
184 216
                 }
185 217
 
186
-    		if ($globalDebug) echo " - Add routes to DB -";
218
+    		if ($globalDebug) {
219
+    			echo " - Add routes to DB -";
220
+    		}
187 221
 
188 222
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
189 223
 		$Spotter = new Spotter();
@@ -192,7 +226,9 @@  discard block
 block discarded – undo
192 226
 			$Connection = new Connection();
193 227
 			$sth_dest = $Connection->db->prepare($query_dest);
194 228
 			try {
195
-				if ($globalTransaction) $Connection->db->beginTransaction();
229
+				if ($globalTransaction) {
230
+					$Connection->db->beginTransaction();
231
+				}
196 232
 				while (!feof($fh)) {
197 233
 					$line = fgetcsv($fh,9999,',');
198 234
 					if ($line[0] != '') {
@@ -203,9 +239,13 @@  discard block
 block discarded – undo
203 239
 						}
204 240
 					}
205 241
 				}
206
-				if ($globalTransaction) $Connection->db->commit();
242
+				if ($globalTransaction) {
243
+					$Connection->db->commit();
244
+				}
207 245
 			} catch(PDOException $e) {
208
-				if ($globalTransaction) $Connection->db->rollBack(); 
246
+				if ($globalTransaction) {
247
+					$Connection->db->rollBack();
248
+				}
209 249
 				return "error : ".$e->getMessage();
210 250
 			}
211 251
 		}
@@ -248,11 +288,16 @@  discard block
 block discarded – undo
248 288
 		$sth_dest = $Connection->db->prepare($query_dest);
249 289
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
250 290
 		try {
251
-			if ($globalTransaction) $Connection->db->beginTransaction();
291
+			if ($globalTransaction) {
292
+				$Connection->db->beginTransaction();
293
+			}
252 294
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
253 295
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
254
-				if ($values['UserString4'] == 'M') $type = 'military';
255
-				else $type = null;
296
+				if ($values['UserString4'] == 'M') {
297
+					$type = 'military';
298
+				} else {
299
+					$type = null;
300
+				}
256 301
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
257 302
 				$sth_dest->execute($query_dest_values);
258 303
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -260,7 +305,9 @@  discard block
 block discarded – undo
260 305
 				    $sth_dest_owner->execute($query_dest_owner_values);
261 306
 				}
262 307
             		}
263
-			if ($globalTransaction) $Connection->db->commit();
308
+			if ($globalTransaction) {
309
+				$Connection->db->commit();
310
+			}
264 311
 		} catch(PDOException $e) {
265 312
 			return "error : ".$e->getMessage();
266 313
 		}
@@ -297,7 +344,9 @@  discard block
 block discarded – undo
297 344
 			$Connection = new Connection();
298 345
 			$sth_dest = $Connection->db->prepare($query_dest);
299 346
 			try {
300
-				if ($globalTransaction) $Connection->db->beginTransaction();
347
+				if ($globalTransaction) {
348
+					$Connection->db->beginTransaction();
349
+				}
301 350
             			while (!feof($fh)) {
302 351
             				$values = array();
303 352
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -308,7 +357,9 @@  discard block
 block discarded – undo
308 357
             				// Check if we can find ICAO, else set it to GLID
309 358
             				$aircraft_name_split = explode(' ',$aircraft_name);
310 359
             				$search_more = '';
311
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
360
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
361
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
362
+            				}
312 363
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
313 364
             				$sth_search = $Connection->db->prepare($query_search);
314 365
 					try {
@@ -321,7 +372,9 @@  discard block
 block discarded – undo
321 372
 					} catch(PDOException $e) {
322 373
 						return "error : ".$e->getMessage();
323 374
 					}
324
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
375
+					if (!isset($values['ICAOTypeCode'])) {
376
+						$values['ICAOTypeCode'] = 'GLID';
377
+					}
325 378
 					// Add data to db
326 379
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
327 380
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -330,7 +383,9 @@  discard block
 block discarded – undo
330 383
 						$sth_dest->execute($query_dest_values);
331 384
 					}
332 385
 				}
333
-				if ($globalTransaction) $Connection->db->commit();
386
+				if ($globalTransaction) {
387
+					$Connection->db->commit();
388
+				}
334 389
 			} catch(PDOException $e) {
335 390
 				return "error : ".$e->getMessage();
336 391
 			}
@@ -366,7 +421,9 @@  discard block
 block discarded – undo
366 421
 			$Connection = new Connection();
367 422
 			$sth_dest = $Connection->db->prepare($query_dest);
368 423
 			try {
369
-				if ($globalTransaction) $Connection->db->beginTransaction();
424
+				if ($globalTransaction) {
425
+					$Connection->db->beginTransaction();
426
+				}
370 427
 				$tmp = fgetcsv($fh,9999,',',"'");
371 428
             			while (!feof($fh)) {
372 429
             				$line = fgetcsv($fh,9999,',',"'");
@@ -380,13 +437,17 @@  discard block
 block discarded – undo
380 437
             				// Check if we can find ICAO, else set it to GLID
381 438
             				$aircraft_name_split = explode(' ',$aircraft_name);
382 439
             				$search_more = '';
383
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
440
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
441
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
442
+            				}
384 443
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
385 444
             				$sth_search = $Connection->db->prepare($query_search);
386 445
 					try {
387 446
                                     		$sth_search->execute();
388 447
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
389
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
448
+	            				if (isset($result['icao']) && $result['icao'] != '') {
449
+	            					$values['ICAOTypeCode'] = $result['icao'];
450
+	            				}
390 451
 					} catch(PDOException $e) {
391 452
 						return "error : ".$e->getMessage();
392 453
 					}
@@ -399,7 +460,9 @@  discard block
 block discarded – undo
399 460
 						$sth_dest->execute($query_dest_values);
400 461
 					}
401 462
 				}
402
-				if ($globalTransaction) $Connection->db->commit();
463
+				if ($globalTransaction) {
464
+					$Connection->db->commit();
465
+				}
403 466
 			} catch(PDOException $e) {
404 467
 				return "error : ".$e->getMessage();
405 468
 			}
@@ -438,7 +501,9 @@  discard block
 block discarded – undo
438 501
 			$sth_dest = $Connection->db->prepare($query_dest);
439 502
 			$sth_modes = $Connection->db->prepare($query_modes);
440 503
 			try {
441
-				if ($globalTransaction) $Connection->db->beginTransaction();
504
+				if ($globalTransaction) {
505
+					$Connection->db->beginTransaction();
506
+				}
442 507
 				$tmp = fgetcsv($fh,9999,',','"');
443 508
             			while (!feof($fh)) {
444 509
             				$line = fgetcsv($fh,9999,',','"');
@@ -448,16 +513,22 @@  discard block
 block discarded – undo
448 513
             				    $values['registration'] = $line[0];
449 514
             				    $values['base'] = $line[4];
450 515
             				    $values['owner'] = $line[5];
451
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
452
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
516
+            				    if ($line[6] == '') {
517
+            				    	$values['date_first_reg'] = null;
518
+            				    } else {
519
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
520
+					    }
453 521
 					    $values['cancel'] = $line[7];
454 522
 					} elseif ($country == 'EI') {
455 523
 					    // TODO : add modeS & reg to aircraft_modes
456 524
             				    $values['registration'] = $line[0];
457 525
             				    $values['base'] = $line[3];
458 526
             				    $values['owner'] = $line[2];
459
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
460
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
527
+            				    if ($line[1] == '') {
528
+            				    	$values['date_first_reg'] = null;
529
+            				    } else {
530
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
531
+					    }
461 532
 					    $values['cancel'] = '';
462 533
 					    $values['modes'] = $line[7];
463 534
 					    $values['icao'] = $line[8];
@@ -476,16 +547,22 @@  discard block
 block discarded – undo
476 547
             				    $values['registration'] = $line[3];
477 548
             				    $values['base'] = null;
478 549
             				    $values['owner'] = $line[5];
479
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
480
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
550
+            				    if ($line[18] == '') {
551
+            				    	$values['date_first_reg'] = null;
552
+            				    } else {
553
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
554
+					    }
481 555
 					    $values['cancel'] = '';
482 556
 					} elseif ($country == 'VH') {
483 557
 					    // TODO : add modeS & reg to aircraft_modes
484 558
             				    $values['registration'] = $line[0];
485 559
             				    $values['base'] = null;
486 560
             				    $values['owner'] = $line[12];
487
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
488
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
561
+            				    if ($line[28] == '') {
562
+            				    	$values['date_first_reg'] = null;
563
+            				    } else {
564
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
565
+					    }
489 566
 
490 567
 					    $values['cancel'] = $line[39];
491 568
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -504,29 +581,41 @@  discard block
 block discarded – undo
504 581
             				    $values['registration'] = $line[0];
505 582
             				    $values['base'] = null;
506 583
             				    $values['owner'] = $line[8];
507
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
584
+            				    if ($line[7] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
588
+					    }
509 589
 					    $values['cancel'] = '';
510 590
 					} elseif ($country == 'PP') {
511 591
             				    $values['registration'] = $line[0];
512 592
             				    $values['base'] = null;
513 593
             				    $values['owner'] = $line[4];
514
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
515
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
594
+            				    if ($line[6] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
598
+					    }
516 599
 					    $values['cancel'] = $line[7];
517 600
 					} elseif ($country == 'E7') {
518 601
             				    $values['registration'] = $line[0];
519 602
             				    $values['base'] = null;
520 603
             				    $values['owner'] = $line[4];
521
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
522
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
604
+            				    if ($line[5] == '') {
605
+            				    	$values['date_first_reg'] = null;
606
+            				    } else {
607
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
608
+					    }
523 609
 					    $values['cancel'] = '';
524 610
 					} elseif ($country == '8Q') {
525 611
             				    $values['registration'] = $line[0];
526 612
             				    $values['base'] = null;
527 613
             				    $values['owner'] = $line[3];
528
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
529
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
614
+            				    if ($line[7] == '') {
615
+            				    	$values['date_first_reg'] = null;
616
+            				    } else {
617
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
618
+					    }
530 619
 					    $values['cancel'] = '';
531 620
 					} elseif ($country == 'ZK') {
532 621
             				    $values['registration'] = $line[0];
@@ -571,7 +660,9 @@  discard block
 block discarded – undo
571 660
 						$sth_modes->execute($query_modes_values);
572 661
 					}
573 662
 				}
574
-				if ($globalTransaction) $Connection->db->commit();
663
+				if ($globalTransaction) {
664
+					$Connection->db->commit();
665
+				}
575 666
 			} catch(PDOException $e) {
576 667
 				return "error : ".$e->getMessage();
577 668
 			}
@@ -707,25 +798,45 @@  discard block
 block discarded – undo
707 798
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
708 799
 		$Connection = new Connection();
709 800
 		$sth_dest = $Connection->db->prepare($query_dest);
710
-		if ($globalTransaction) $Connection->db->beginTransaction();
801
+		if ($globalTransaction) {
802
+			$Connection->db->beginTransaction();
803
+		}
711 804
   
712 805
 		$i = 0;
713 806
 		while($row = sparql_fetch_array($result))
714 807
 		{
715 808
 			if ($i >= 1) {
716 809
 			//print_r($row);
717
-			if (!isset($row['iata'])) $row['iata'] = '';
718
-			if (!isset($row['icao'])) $row['icao'] = '';
719
-			if (!isset($row['type'])) $row['type'] = '';
720
-			if (!isset($row['altitude'])) $row['altitude'] = '';
810
+			if (!isset($row['iata'])) {
811
+				$row['iata'] = '';
812
+			}
813
+			if (!isset($row['icao'])) {
814
+				$row['icao'] = '';
815
+			}
816
+			if (!isset($row['type'])) {
817
+				$row['type'] = '';
818
+			}
819
+			if (!isset($row['altitude'])) {
820
+				$row['altitude'] = '';
821
+			}
721 822
 			if (isset($row['city_bis'])) {
722 823
 				$row['city'] = $row['city_bis'];
723 824
 			}
724
-			if (!isset($row['city'])) $row['city'] = '';
725
-			if (!isset($row['country'])) $row['country'] = '';
726
-			if (!isset($row['homepage'])) $row['homepage'] = '';
727
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
728
-			if (!isset($row['name'])) continue;
825
+			if (!isset($row['city'])) {
826
+				$row['city'] = '';
827
+			}
828
+			if (!isset($row['country'])) {
829
+				$row['country'] = '';
830
+			}
831
+			if (!isset($row['homepage'])) {
832
+				$row['homepage'] = '';
833
+			}
834
+			if (!isset($row['wikipedia_page'])) {
835
+				$row['wikipedia_page'] = '';
836
+			}
837
+			if (!isset($row['name'])) {
838
+				continue;
839
+			}
729 840
 			if (!isset($row['image'])) {
730 841
 				$row['image'] = '';
731 842
 				$row['image_thumb'] = '';
@@ -781,7 +892,9 @@  discard block
 block discarded – undo
781 892
 
782 893
 			$i++;
783 894
 		}
784
-		if ($globalTransaction) $Connection->db->commit();
895
+		if ($globalTransaction) {
896
+			$Connection->db->commit();
897
+		}
785 898
 		/*
786 899
 		echo "Delete duplicate rows...\n";
787 900
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -824,7 +937,9 @@  discard block
 block discarded – undo
824 937
 		$delimiter = ',';
825 938
 		$out_file = $tmp_dir.'airports.csv';
826 939
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
827
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
940
+		if (!file_exists($out_file) || !is_readable($out_file)) {
941
+			return FALSE;
942
+		}
828 943
 		echo "Add data from ourairports.com...\n";
829 944
 
830 945
 		$header = NULL;
@@ -834,8 +949,9 @@  discard block
 block discarded – undo
834 949
 			//$Connection->db->beginTransaction();
835 950
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
836 951
 			{
837
-				if(!$header) $header = $row;
838
-				else {
952
+				if(!$header) {
953
+					$header = $row;
954
+				} else {
839 955
 					$data = array();
840 956
 					$data = array_combine($header, $row);
841 957
 					try {
@@ -876,7 +992,9 @@  discard block
 block discarded – undo
876 992
 		echo "Download data from another free database...\n";
877 993
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
878 994
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
879
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
995
+		if (!file_exists($out_file) || !is_readable($out_file)) {
996
+			return FALSE;
997
+		}
880 998
 		update_db::unzip($out_file);
881 999
 		$header = NULL;
882 1000
 		echo "Add data from another free database...\n";
@@ -887,8 +1005,9 @@  discard block
 block discarded – undo
887 1005
 			//$Connection->db->beginTransaction();
888 1006
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
889 1007
 			{
890
-				if(!$header) $header = $row;
891
-				else {
1008
+				if(!$header) {
1009
+					$header = $row;
1010
+				} else {
892 1011
 					$data = $row;
893 1012
 
894 1013
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1082,7 +1201,9 @@  discard block
 block discarded – undo
1082 1201
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1083 1202
 		{
1084 1203
 			$i = 0;
1085
-			if ($globalTransaction) $Connection->db->beginTransaction();
1204
+			if ($globalTransaction) {
1205
+				$Connection->db->beginTransaction();
1206
+			}
1086 1207
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1087 1208
 			{
1088 1209
 				if ($i > 0) {
@@ -1095,7 +1216,9 @@  discard block
 block discarded – undo
1095 1216
 					}
1096 1217
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1097 1218
 					if (!empty($result_search)) {
1098
-						if ($globalDebug) echo '.';
1219
+						if ($globalDebug) {
1220
+							echo '.';
1221
+						}
1099 1222
 							//if ($globalDBdriver == 'mysql') {
1100 1223
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1101 1224
 							//} else {
@@ -1117,8 +1240,12 @@  discard block
 block discarded – undo
1117 1240
 						}
1118 1241
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1119 1242
 						if (!empty($result_search_mfr)) {
1120
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1121
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1243
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1244
+								$data[16] = $data[23];
1245
+							}
1246
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1247
+								$data[16] = $data[15];
1248
+							}
1122 1249
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1123 1250
 							try {
1124 1251
 								$sthf = $Connection->db->prepare($queryf);
@@ -1129,7 +1256,9 @@  discard block
 block discarded – undo
1129 1256
 						}
1130 1257
 					}
1131 1258
 					if (strtotime($data[29]) > time()) {
1132
-						if ($globalDebug) echo 'i';
1259
+						if ($globalDebug) {
1260
+							echo 'i';
1261
+						}
1133 1262
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1134 1263
 						try {
1135 1264
 							$sth = $Connection->db->prepare($query);
@@ -1140,13 +1269,19 @@  discard block
 block discarded – undo
1140 1269
 					}
1141 1270
 				}
1142 1271
 				if ($i % 90 == 0) {
1143
-					if ($globalTransaction) $Connection->db->commit();
1144
-					if ($globalTransaction) $Connection->db->beginTransaction();
1272
+					if ($globalTransaction) {
1273
+						$Connection->db->commit();
1274
+					}
1275
+					if ($globalTransaction) {
1276
+						$Connection->db->beginTransaction();
1277
+					}
1145 1278
 				}
1146 1279
 				$i++;
1147 1280
 			}
1148 1281
 			fclose($handle);
1149
-			if ($globalTransaction) $Connection->db->commit();
1282
+			if ($globalTransaction) {
1283
+				$Connection->db->commit();
1284
+			}
1150 1285
 		}
1151 1286
 		return '';
1152 1287
 	}
@@ -1166,11 +1301,15 @@  discard block
 block discarded – undo
1166 1301
 		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE)
1167 1302
 		{
1168 1303
 			$i = 0;
1169
-			if ($globalTransaction) $Connection->db->beginTransaction();
1304
+			if ($globalTransaction) {
1305
+				$Connection->db->beginTransaction();
1306
+			}
1170 1307
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1171 1308
 			{
1172 1309
 				if ($i > 0) {
1173
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1310
+					if ($data[1] == 'NULL') {
1311
+						$data[1] = $data[0];
1312
+					}
1174 1313
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1175 1314
 					try {
1176 1315
 						$sth = $Connection->db->prepare($query);
@@ -1182,7 +1321,9 @@  discard block
 block discarded – undo
1182 1321
 				$i++;
1183 1322
 			}
1184 1323
 			fclose($handle);
1185
-			if ($globalTransaction) $Connection->db->commit();
1324
+			if ($globalTransaction) {
1325
+				$Connection->db->commit();
1326
+			}
1186 1327
 		}
1187 1328
 		return '';
1188 1329
 	}
@@ -1214,11 +1355,15 @@  discard block
 block discarded – undo
1214 1355
 		if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE)
1215 1356
 		{
1216 1357
 			$i = 0;
1217
-			if ($globalTransaction) $Connection->db->beginTransaction();
1358
+			if ($globalTransaction) {
1359
+				$Connection->db->beginTransaction();
1360
+			}
1218 1361
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1219 1362
 			{
1220 1363
 				if ($i > 0) {
1221
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1364
+					if ($data[1] == 'NULL') {
1365
+						$data[1] = $data[0];
1366
+					}
1222 1367
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1223 1368
 					try {
1224 1369
 						$sth = $Connection->db->prepare($query);
@@ -1230,7 +1375,9 @@  discard block
 block discarded – undo
1230 1375
 				$i++;
1231 1376
 			}
1232 1377
 			fclose($handle);
1233
-			if ($globalTransaction) $Connection->db->commit();
1378
+			if ($globalTransaction) {
1379
+				$Connection->db->commit();
1380
+			}
1234 1381
 		}
1235 1382
 		/*
1236 1383
 		$query = "UNLOCK TABLES";
@@ -1260,7 +1407,9 @@  discard block
 block discarded – undo
1260 1407
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1261 1408
 		{
1262 1409
 			$i = 0;
1263
-			if ($globalTransaction) $Connection->db->beginTransaction();
1410
+			if ($globalTransaction) {
1411
+				$Connection->db->beginTransaction();
1412
+			}
1264 1413
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1265 1414
 			{
1266 1415
 				if ($i > 0) {
@@ -1276,7 +1425,9 @@  discard block
 block discarded – undo
1276 1425
 				$i++;
1277 1426
 			}
1278 1427
 			fclose($handle);
1279
-			if ($globalTransaction) $Connection->db->commit();
1428
+			if ($globalTransaction) {
1429
+				$Connection->db->commit();
1430
+			}
1280 1431
 		}
1281 1432
 		return '';
1282 1433
         }
@@ -1296,7 +1447,9 @@  discard block
 block discarded – undo
1296 1447
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1297 1448
 		{
1298 1449
 			$i = 0;
1299
-			if ($globalTransaction) $Connection->db->beginTransaction();
1450
+			if ($globalTransaction) {
1451
+				$Connection->db->beginTransaction();
1452
+			}
1300 1453
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1301 1454
 			{
1302 1455
 				if ($i > 0) {
@@ -1306,19 +1459,25 @@  discard block
 block discarded – undo
1306 1459
 						$sth = $Connection->db->prepare($query);
1307 1460
 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1308 1461
 					} catch(PDOException $e) {
1309
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1462
+						if ($globalDebug) {
1463
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1464
+						}
1310 1465
 						die();
1311 1466
 					}
1312 1467
 				}
1313 1468
 				if ($globalTransaction && $i % 2000 == 0) {
1314 1469
 					$Connection->db->commit();
1315
-					if ($globalDebug) echo '.';
1470
+					if ($globalDebug) {
1471
+						echo '.';
1472
+					}
1316 1473
 					$Connection->db->beginTransaction();
1317 1474
 				}
1318 1475
 				$i++;
1319 1476
 			}
1320 1477
 			fclose($handle);
1321
-			if ($globalTransaction) $Connection->db->commit();
1478
+			if ($globalTransaction) {
1479
+				$Connection->db->commit();
1480
+			}
1322 1481
 		}
1323 1482
 		return '';
1324 1483
 	}
@@ -1337,7 +1496,9 @@  discard block
 block discarded – undo
1337 1496
 		if (($handle = fopen($tmp_dir.'block.tsv', 'r')) !== FALSE)
1338 1497
 		{
1339 1498
 			$i = 0;
1340
-			if ($globalTransaction) $Connection->db->beginTransaction();
1499
+			if ($globalTransaction) {
1500
+				$Connection->db->beginTransaction();
1501
+			}
1341 1502
 			while (($data = fgets($handle, 1000)) !== FALSE)
1342 1503
 			{
1343 1504
 				$query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)';
@@ -1345,18 +1506,24 @@  discard block
 block discarded – undo
1345 1506
 					$sth = $Connection->db->prepare($query);
1346 1507
 					$sth->execute(array(':callSign' => trim($data),':source' => 'website_fam'));
1347 1508
 				} catch(PDOException $e) {
1348
-					if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data;
1509
+					if ($globalDebug) {
1510
+						echo "error: ".$e->getMessage()." - data: ".$data;
1511
+					}
1349 1512
 					die();
1350 1513
 				}
1351 1514
 				if ($globalTransaction && $i % 2000 == 0) {
1352 1515
 					$Connection->db->commit();
1353
-					if ($globalDebug) echo '.';
1516
+					if ($globalDebug) {
1517
+						echo '.';
1518
+					}
1354 1519
 					$Connection->db->beginTransaction();
1355 1520
 				}
1356 1521
 				$i++;
1357 1522
 			}
1358 1523
 			fclose($handle);
1359
-			if ($globalTransaction) $Connection->db->commit();
1524
+			if ($globalTransaction) {
1525
+				$Connection->db->commit();
1526
+			}
1360 1527
 		}
1361 1528
 		return '';
1362 1529
         }
@@ -1381,7 +1548,9 @@  discard block
 block discarded – undo
1381 1548
 			$i = 0;
1382 1549
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1383 1550
 			//$Connection->db->beginTransaction();
1384
-			if ($globalTransaction) $Connection->db->beginTransaction();
1551
+			if ($globalTransaction) {
1552
+				$Connection->db->beginTransaction();
1553
+			}
1385 1554
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1386 1555
 			{
1387 1556
 				if ($i > 0) {
@@ -1397,7 +1566,9 @@  discard block
 block discarded – undo
1397 1566
 				$i++;
1398 1567
 			}
1399 1568
 			fclose($handle);
1400
-			if ($globalTransaction) $Connection->db->commit();
1569
+			if ($globalTransaction) {
1570
+				$Connection->db->commit();
1571
+			}
1401 1572
 		}
1402 1573
 		return '';
1403 1574
         }
@@ -1417,7 +1588,9 @@  discard block
 block discarded – undo
1417 1588
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1418 1589
 		{
1419 1590
 			$i = 0;
1420
-			if ($globalTransaction) $Connection->db->beginTransaction();
1591
+			if ($globalTransaction) {
1592
+				$Connection->db->beginTransaction();
1593
+			}
1421 1594
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1422 1595
 			{
1423 1596
 				if ($i > 0) {
@@ -1434,7 +1607,9 @@  discard block
 block discarded – undo
1434 1607
 				$i++;
1435 1608
 			}
1436 1609
 			fclose($handle);
1437
-			if ($globalTransaction) $Connection->db->commit();
1610
+			if ($globalTransaction) {
1611
+				$Connection->db->commit();
1612
+			}
1438 1613
 		}
1439 1614
 		return '';
1440 1615
 	}
@@ -1453,7 +1628,9 @@  discard block
 block discarded – undo
1453 1628
 		$Connection = new Connection();
1454 1629
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1455 1630
 		{
1456
-			if ($globalTransaction) $Connection->db->beginTransaction();
1631
+			if ($globalTransaction) {
1632
+				$Connection->db->beginTransaction();
1633
+			}
1457 1634
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1458 1635
 			{
1459 1636
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1468,7 +1645,9 @@  discard block
 block discarded – undo
1468 1645
 				}
1469 1646
 			}
1470 1647
 			fclose($handle);
1471
-			if ($globalTransaction) $Connection->db->commit();
1648
+			if ($globalTransaction) {
1649
+				$Connection->db->commit();
1650
+			}
1472 1651
 		}
1473 1652
 		return '';
1474 1653
         }
@@ -1546,9 +1725,14 @@  discard block
 block discarded – undo
1546 1725
 				if ($i > 0 && $data[0] != '') {
1547 1726
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1548 1727
 					$period = str_replace(',','',$data[14]);
1549
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1550
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1551
-					else $launch_date = NULL;
1728
+					if (!empty($period) && strpos($period,'days')) {
1729
+						$period = str_replace(' days','',$period)*24*60;
1730
+					}
1731
+					if ($data[18] != '') {
1732
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1733
+					} else {
1734
+						$launch_date = NULL;
1735
+					}
1552 1736
 					$data = array_map(function($value) {
1553 1737
 						return trim($value) === '' ? null : $value;
1554 1738
 					}, $data);
@@ -1740,10 +1924,14 @@  discard block
 block discarded – undo
1740 1924
 				$owner_code = trim(substr($data,49,5));
1741 1925
 				
1742 1926
 				if (!isset($satcat_sources[$owner_code]) && $owner_code != 'TBD') {
1743
-					if ($globalDebug) echo $data.'owner_code: '.$owner_code."\n";
1927
+					if ($globalDebug) {
1928
+						echo $data.'owner_code: '.$owner_code."\n";
1929
+					}
1744 1930
 				}
1745 1931
 				if (!isset($satcat_launch_site[trim(substr($data,68,5))])) {
1746
-					if ($globalDebug) echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1932
+					if ($globalDebug) {
1933
+						echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1934
+					}
1747 1935
 				}
1748 1936
 				
1749 1937
 				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) {
@@ -1910,7 +2098,9 @@  discard block
 block discarded – undo
1910 2098
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1911 2099
 		{
1912 2100
 			$i = 0;
1913
-			if ($globalTransaction) $Connection->db->beginTransaction();
2101
+			if ($globalTransaction) {
2102
+				$Connection->db->beginTransaction();
2103
+			}
1914 2104
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1915 2105
 			{
1916 2106
 				$i++;
@@ -1938,7 +2128,9 @@  discard block
 block discarded – undo
1938 2128
 				}
1939 2129
 			}
1940 2130
 			fclose($handle);
1941
-			if ($globalTransaction) $Connection->db->commit();
2131
+			if ($globalTransaction) {
2132
+				$Connection->db->commit();
2133
+			}
1942 2134
 		}
1943 2135
 		return '';
1944 2136
 	}
@@ -1954,7 +2146,9 @@  discard block
 block discarded – undo
1954 2146
 		$Source->deleteLocationByType('fires');
1955 2147
 		$i = 0;
1956 2148
 		if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) {
1957
-			if ($globalTransaction) $Connection->db->beginTransaction();
2149
+			if ($globalTransaction) {
2150
+				$Connection->db->beginTransaction();
2151
+			}
1958 2152
 			while (($row = fgetcsv($handle,1000)) !== false) {
1959 2153
 				if ($i > 0 && $row[0] != '' && $row[8] != 'low') {
1960 2154
 					$description = array('bright_t14' => $row[2],'scan' => $row[3],'track' => $row[4],'sat' => $row[7],'confidence' => $row[8],'version' => $row[9],'bright_t15' => $row[10],'frp' => $row[11],'daynight' => $row[12]);
@@ -1969,7 +2163,9 @@  discard block
 block discarded – undo
1969 2163
 				}
1970 2164
 				$i++;
1971 2165
 			}
1972
-			if ($globalTransaction) $Connection->db->commit();
2166
+			if ($globalTransaction) {
2167
+				$Connection->db->commit();
2168
+			}
1973 2169
 		}
1974 2170
 	}
1975 2171
 
@@ -1990,7 +2186,9 @@  discard block
 block discarded – undo
1990 2186
 		$Connection = new Connection();
1991 2187
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1992 2188
 		{
1993
-			if ($globalTransaction) $Connection->db->beginTransaction();
2189
+			if ($globalTransaction) {
2190
+				$Connection->db->beginTransaction();
2191
+			}
1994 2192
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1995 2193
 			{
1996 2194
 				if(count($row) > 1) {
@@ -2004,7 +2202,9 @@  discard block
 block discarded – undo
2004 2202
 				}
2005 2203
 			}
2006 2204
 			fclose($handle);
2007
-			if ($globalTransaction) $Connection->db->commit();
2205
+			if ($globalTransaction) {
2206
+				$Connection->db->commit();
2207
+			}
2008 2208
 		}
2009 2209
 		return '';
2010 2210
         }
@@ -2024,8 +2224,9 @@  discard block
 block discarded – undo
2024 2224
 	        }
2025 2225
 
2026 2226
 
2027
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2028
-		else {
2227
+		if ($globalDBdriver == 'mysql') {
2228
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2229
+		} else {
2029 2230
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
2030 2231
 			$query = "CREATE EXTENSION postgis";
2031 2232
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -2044,7 +2245,9 @@  discard block
 block discarded – undo
2044 2245
 		global $tmp_dir, $globalDebug;
2045 2246
 		include_once('class.create_db.php');
2046 2247
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
2047
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2248
+		if ($globalDebug) {
2249
+			echo "NOTAM from FlightAirMap website : Download...";
2250
+		}
2048 2251
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
2049 2252
 		$error = '';
2050 2253
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
@@ -2054,20 +2257,34 @@  discard block
 block discarded – undo
2054 2257
 				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
2055 2258
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
2056 2259
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
2057
-						if ($globalDebug) echo "Gunzip...";
2260
+						if ($globalDebug) {
2261
+							echo "Gunzip...";
2262
+						}
2058 2263
 						update_db::gunzip($tmp_dir.'notam.txt.gz');
2059
-						if ($globalDebug) echo "Add to DB...";
2264
+						if ($globalDebug) {
2265
+							echo "Add to DB...";
2266
+						}
2060 2267
 						//$error = create_db::import_file($tmp_dir.'notam.sql');
2061 2268
 						$NOTAM = new NOTAM();
2062 2269
 						$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
2063 2270
 						update_db::insert_notam_version($notam_md5);
2064
-					} else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2065
-				} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2066
-			} elseif ($globalDebug) echo "No new version.";
2067
-		} else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2271
+					} else {
2272
+						$error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2273
+					}
2274
+				} else {
2275
+					$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2276
+				}
2277
+			} elseif ($globalDebug) {
2278
+				echo "No new version.";
2279
+			}
2280
+		} else {
2281
+			$error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2282
+		}
2068 2283
 		if ($error != '') {
2069 2284
 			return $error;
2070
-		} elseif ($globalDebug) echo "Done\n";
2285
+		} elseif ($globalDebug) {
2286
+			echo "Done\n";
2287
+		}
2071 2288
 		return '';
2072 2289
 	}
2073 2290
 
@@ -2122,68 +2339,114 @@  discard block
 block discarded – undo
2122 2339
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
2123 2340
 		if (extension_loaded('zip')) {
2124 2341
 			if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
2125
-				if ($globalDebug) echo "Unzip...";
2342
+				if ($globalDebug) {
2343
+					echo "Unzip...";
2344
+				}
2126 2345
 				update_db::unzip($tmp_dir.'ivae_feb2013.zip');
2127
-				if ($globalDebug) echo "Add to DB...";
2346
+				if ($globalDebug) {
2347
+					echo "Add to DB...";
2348
+				}
2128 2349
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2129
-				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2350
+				if ($globalDebug) {
2351
+					echo "Copy airlines logos to airlines images directory...";
2352
+				}
2130 2353
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2131
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2132
-				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2133
-			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2134
-		} else $error = "ZIP module not loaded but required for IVAO.";
2354
+					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2355
+						$error = "Failed to copy airlines logo.";
2356
+					}
2357
+				} else {
2358
+					$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2359
+				}
2360
+			} else {
2361
+				$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2362
+			}
2363
+		} else {
2364
+			$error = "ZIP module not loaded but required for IVAO.";
2365
+		}
2135 2366
 		if ($error != '') {
2136 2367
 			return $error;
2137
-		} elseif ($globalDebug) echo "Done\n";
2368
+		} elseif ($globalDebug) {
2369
+			echo "Done\n";
2370
+		}
2138 2371
 		return '';
2139 2372
 	}
2140 2373
 
2141 2374
 	public static function update_routes() {
2142 2375
 		global $tmp_dir, $globalDebug;
2143 2376
 		$error = '';
2144
-		if ($globalDebug) echo "Routes : Download...";
2377
+		if ($globalDebug) {
2378
+			echo "Routes : Download...";
2379
+		}
2145 2380
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2146 2381
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2147
-			if ($globalDebug) echo "Gunzip...";
2382
+			if ($globalDebug) {
2383
+				echo "Gunzip...";
2384
+			}
2148 2385
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
2149
-			if ($globalDebug) echo "Add to DB...";
2386
+			if ($globalDebug) {
2387
+				echo "Add to DB...";
2388
+			}
2150 2389
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
2151
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2390
+		} else {
2391
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2392
+		}
2152 2393
 		if ($error != '') {
2153 2394
 			return $error;
2154
-		} elseif ($globalDebug) echo "Done\n";
2395
+		} elseif ($globalDebug) {
2396
+			echo "Done\n";
2397
+		}
2155 2398
 		return '';
2156 2399
 	}
2157 2400
 	public static function update_oneworld() {
2158 2401
 		global $tmp_dir, $globalDebug;
2159 2402
 		$error = '';
2160
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2403
+		if ($globalDebug) {
2404
+			echo "Schedules Oneworld : Download...";
2405
+		}
2161 2406
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2162 2407
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2163
-			if ($globalDebug) echo "Gunzip...";
2408
+			if ($globalDebug) {
2409
+				echo "Gunzip...";
2410
+			}
2164 2411
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
2165
-			if ($globalDebug) echo "Add to DB...";
2412
+			if ($globalDebug) {
2413
+				echo "Add to DB...";
2414
+			}
2166 2415
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
2167
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2416
+		} else {
2417
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2418
+		}
2168 2419
 		if ($error != '') {
2169 2420
 			return $error;
2170
-		} elseif ($globalDebug) echo "Done\n";
2421
+		} elseif ($globalDebug) {
2422
+			echo "Done\n";
2423
+		}
2171 2424
 		return '';
2172 2425
 	}
2173 2426
 	public static function update_skyteam() {
2174 2427
 		global $tmp_dir, $globalDebug;
2175 2428
 		$error = '';
2176
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2429
+		if ($globalDebug) {
2430
+			echo "Schedules Skyteam : Download...";
2431
+		}
2177 2432
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2178 2433
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2179
-			if ($globalDebug) echo "Gunzip...";
2434
+			if ($globalDebug) {
2435
+				echo "Gunzip...";
2436
+			}
2180 2437
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
2181
-			if ($globalDebug) echo "Add to DB...";
2438
+			if ($globalDebug) {
2439
+				echo "Add to DB...";
2440
+			}
2182 2441
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
2183
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2442
+		} else {
2443
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2444
+		}
2184 2445
 		if ($error != '') {
2185 2446
 			return $error;
2186
-		} elseif ($globalDebug) echo "Done\n";
2447
+		} elseif ($globalDebug) {
2448
+			echo "Done\n";
2449
+		}
2187 2450
 		return '';
2188 2451
 	}
2189 2452
 	public static function update_ModeS() {
@@ -2200,340 +2463,590 @@  discard block
 block discarded – undo
2200 2463
 			exit;
2201 2464
 		} elseif ($globalDebug) echo "Done\n";
2202 2465
 */
2203
-		if ($globalDebug) echo "Modes : Download...";
2204
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2466
+		if ($globalDebug) {
2467
+			echo "Modes : Download...";
2468
+		}
2469
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2205 2470
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2206 2471
 
2207 2472
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2208 2473
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2209
-			if ($globalDebug) echo "Unzip...";
2210
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2474
+			if ($globalDebug) {
2475
+				echo "Unzip...";
2476
+			}
2477
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2211 2478
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2212
-			if ($globalDebug) echo "Add to DB...";
2479
+			if ($globalDebug) {
2480
+				echo "Add to DB...";
2481
+			}
2213 2482
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2214 2483
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2215
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2484
+		} else {
2485
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2486
+		}
2216 2487
 		if ($error != '') {
2217 2488
 			return $error;
2218
-		} elseif ($globalDebug) echo "Done\n";
2489
+		} elseif ($globalDebug) {
2490
+			echo "Done\n";
2491
+		}
2219 2492
 		return '';
2220 2493
 	}
2221 2494
 
2222 2495
 	public static function update_ModeS_faa() {
2223 2496
 		global $tmp_dir, $globalDebug;
2224
-		if ($globalDebug) echo "Modes FAA: Download...";
2497
+		if ($globalDebug) {
2498
+			echo "Modes FAA: Download...";
2499
+		}
2225 2500
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2226 2501
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2227
-			if ($globalDebug) echo "Unzip...";
2502
+			if ($globalDebug) {
2503
+				echo "Unzip...";
2504
+			}
2228 2505
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2229
-			if ($globalDebug) echo "Add to DB...";
2506
+			if ($globalDebug) {
2507
+				echo "Add to DB...";
2508
+			}
2230 2509
 			$error = update_db::modes_faa();
2231
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2510
+		} else {
2511
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2512
+		}
2232 2513
 		if ($error != '') {
2233 2514
 			return $error;
2234
-		} elseif ($globalDebug) echo "Done\n";
2515
+		} elseif ($globalDebug) {
2516
+			echo "Done\n";
2517
+		}
2235 2518
 		return '';
2236 2519
 	}
2237 2520
 
2238 2521
 	public static function update_ModeS_flarm() {
2239 2522
 		global $tmp_dir, $globalDebug;
2240
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2523
+		if ($globalDebug) {
2524
+			echo "Modes Flarmnet: Download...";
2525
+		}
2241 2526
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2242 2527
 		if (file_exists($tmp_dir.'data.fln')) {
2243
-			if ($globalDebug) echo "Add to DB...";
2528
+			if ($globalDebug) {
2529
+				echo "Add to DB...";
2530
+			}
2244 2531
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2245
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2532
+		} else {
2533
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2534
+		}
2246 2535
 		if ($error != '') {
2247 2536
 			return $error;
2248
-		} elseif ($globalDebug) echo "Done\n";
2537
+		} elseif ($globalDebug) {
2538
+			echo "Done\n";
2539
+		}
2249 2540
 		return '';
2250 2541
 	}
2251 2542
 
2252 2543
 	public static function update_ModeS_ogn() {
2253 2544
 		global $tmp_dir, $globalDebug;
2254
-		if ($globalDebug) echo "Modes OGN: Download...";
2545
+		if ($globalDebug) {
2546
+			echo "Modes OGN: Download...";
2547
+		}
2255 2548
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2256 2549
 		if (file_exists($tmp_dir.'ogn.csv')) {
2257
-			if ($globalDebug) echo "Add to DB...";
2550
+			if ($globalDebug) {
2551
+				echo "Add to DB...";
2552
+			}
2258 2553
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2259
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2554
+		} else {
2555
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2556
+		}
2260 2557
 		if ($error != '') {
2261 2558
 			return $error;
2262
-		} elseif ($globalDebug) echo "Done\n";
2559
+		} elseif ($globalDebug) {
2560
+			echo "Done\n";
2561
+		}
2263 2562
 		return '';
2264 2563
 	}
2265 2564
 
2266 2565
 	public static function update_owner() {
2267 2566
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2268 2567
 		
2269
-		if ($globalDebug) echo "Owner France: Download...";
2568
+		if ($globalDebug) {
2569
+			echo "Owner France: Download...";
2570
+		}
2270 2571
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2271 2572
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2272
-			if ($globalDebug) echo "Add to DB...";
2573
+			if ($globalDebug) {
2574
+				echo "Add to DB...";
2575
+			}
2273 2576
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2274
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2577
+		} else {
2578
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2579
+		}
2275 2580
 		if ($error != '') {
2276 2581
 			return $error;
2277
-		} elseif ($globalDebug) echo "Done\n";
2582
+		} elseif ($globalDebug) {
2583
+			echo "Done\n";
2584
+		}
2278 2585
 		
2279
-		if ($globalDebug) echo "Owner Ireland: Download...";
2586
+		if ($globalDebug) {
2587
+			echo "Owner Ireland: Download...";
2588
+		}
2280 2589
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2281 2590
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2282
-			if ($globalDebug) echo "Add to DB...";
2591
+			if ($globalDebug) {
2592
+				echo "Add to DB...";
2593
+			}
2283 2594
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2284
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2595
+		} else {
2596
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2597
+		}
2285 2598
 		if ($error != '') {
2286 2599
 			return $error;
2287
-		} elseif ($globalDebug) echo "Done\n";
2288
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2600
+		} elseif ($globalDebug) {
2601
+			echo "Done\n";
2602
+		}
2603
+		if ($globalDebug) {
2604
+			echo "Owner Switzerland: Download...";
2605
+		}
2289 2606
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2290 2607
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2291
-			if ($globalDebug) echo "Add to DB...";
2608
+			if ($globalDebug) {
2609
+				echo "Add to DB...";
2610
+			}
2292 2611
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2293
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2612
+		} else {
2613
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2614
+		}
2294 2615
 		if ($error != '') {
2295 2616
 			return $error;
2296
-		} elseif ($globalDebug) echo "Done\n";
2297
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2617
+		} elseif ($globalDebug) {
2618
+			echo "Done\n";
2619
+		}
2620
+		if ($globalDebug) {
2621
+			echo "Owner Czech Republic: Download...";
2622
+		}
2298 2623
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2299 2624
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2300
-			if ($globalDebug) echo "Add to DB...";
2625
+			if ($globalDebug) {
2626
+				echo "Add to DB...";
2627
+			}
2301 2628
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2302
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2629
+		} else {
2630
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2631
+		}
2303 2632
 		if ($error != '') {
2304 2633
 			return $error;
2305
-		} elseif ($globalDebug) echo "Done\n";
2306
-		if ($globalDebug) echo "Owner Australia: Download...";
2634
+		} elseif ($globalDebug) {
2635
+			echo "Done\n";
2636
+		}
2637
+		if ($globalDebug) {
2638
+			echo "Owner Australia: Download...";
2639
+		}
2307 2640
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2308 2641
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2309
-			if ($globalDebug) echo "Add to DB...";
2642
+			if ($globalDebug) {
2643
+				echo "Add to DB...";
2644
+			}
2310 2645
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2311
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2646
+		} else {
2647
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2648
+		}
2312 2649
 		if ($error != '') {
2313 2650
 			return $error;
2314
-		} elseif ($globalDebug) echo "Done\n";
2315
-		if ($globalDebug) echo "Owner Austria: Download...";
2651
+		} elseif ($globalDebug) {
2652
+			echo "Done\n";
2653
+		}
2654
+		if ($globalDebug) {
2655
+			echo "Owner Austria: Download...";
2656
+		}
2316 2657
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2317 2658
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2318
-			if ($globalDebug) echo "Add to DB...";
2659
+			if ($globalDebug) {
2660
+				echo "Add to DB...";
2661
+			}
2319 2662
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2320
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2663
+		} else {
2664
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2665
+		}
2321 2666
 		if ($error != '') {
2322 2667
 			return $error;
2323
-		} elseif ($globalDebug) echo "Done\n";
2324
-		if ($globalDebug) echo "Owner Chile: Download...";
2668
+		} elseif ($globalDebug) {
2669
+			echo "Done\n";
2670
+		}
2671
+		if ($globalDebug) {
2672
+			echo "Owner Chile: Download...";
2673
+		}
2325 2674
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2326 2675
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2327
-			if ($globalDebug) echo "Add to DB...";
2676
+			if ($globalDebug) {
2677
+				echo "Add to DB...";
2678
+			}
2328 2679
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2329
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2680
+		} else {
2681
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2682
+		}
2330 2683
 		if ($error != '') {
2331 2684
 			return $error;
2332
-		} elseif ($globalDebug) echo "Done\n";
2333
-		if ($globalDebug) echo "Owner Colombia: Download...";
2685
+		} elseif ($globalDebug) {
2686
+			echo "Done\n";
2687
+		}
2688
+		if ($globalDebug) {
2689
+			echo "Owner Colombia: Download...";
2690
+		}
2334 2691
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2335 2692
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2336
-			if ($globalDebug) echo "Add to DB...";
2693
+			if ($globalDebug) {
2694
+				echo "Add to DB...";
2695
+			}
2337 2696
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2338
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2697
+		} else {
2698
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2699
+		}
2339 2700
 		if ($error != '') {
2340 2701
 			return $error;
2341
-		} elseif ($globalDebug) echo "Done\n";
2342
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2702
+		} elseif ($globalDebug) {
2703
+			echo "Done\n";
2704
+		}
2705
+		if ($globalDebug) {
2706
+			echo "Owner Bosnia Herzegobina: Download...";
2707
+		}
2343 2708
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2344 2709
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2345
-			if ($globalDebug) echo "Add to DB...";
2710
+			if ($globalDebug) {
2711
+				echo "Add to DB...";
2712
+			}
2346 2713
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2347
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2714
+		} else {
2715
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2716
+		}
2348 2717
 		if ($error != '') {
2349 2718
 			return $error;
2350
-		} elseif ($globalDebug) echo "Done\n";
2351
-		if ($globalDebug) echo "Owner Brazil: Download...";
2719
+		} elseif ($globalDebug) {
2720
+			echo "Done\n";
2721
+		}
2722
+		if ($globalDebug) {
2723
+			echo "Owner Brazil: Download...";
2724
+		}
2352 2725
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2353 2726
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2354
-			if ($globalDebug) echo "Add to DB...";
2727
+			if ($globalDebug) {
2728
+				echo "Add to DB...";
2729
+			}
2355 2730
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2356
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2731
+		} else {
2732
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2733
+		}
2357 2734
 		if ($error != '') {
2358 2735
 			return $error;
2359
-		} elseif ($globalDebug) echo "Done\n";
2360
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2736
+		} elseif ($globalDebug) {
2737
+			echo "Done\n";
2738
+		}
2739
+		if ($globalDebug) {
2740
+			echo "Owner Cayman Islands: Download...";
2741
+		}
2361 2742
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2362 2743
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2363
-			if ($globalDebug) echo "Add to DB...";
2744
+			if ($globalDebug) {
2745
+				echo "Add to DB...";
2746
+			}
2364 2747
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2365
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2748
+		} else {
2749
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2750
+		}
2366 2751
 		if ($error != '') {
2367 2752
 			return $error;
2368
-		} elseif ($globalDebug) echo "Done\n";
2369
-		if ($globalDebug) echo "Owner Croatia: Download...";
2753
+		} elseif ($globalDebug) {
2754
+			echo "Done\n";
2755
+		}
2756
+		if ($globalDebug) {
2757
+			echo "Owner Croatia: Download...";
2758
+		}
2370 2759
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2371 2760
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2372
-			if ($globalDebug) echo "Add to DB...";
2761
+			if ($globalDebug) {
2762
+				echo "Add to DB...";
2763
+			}
2373 2764
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2374
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2765
+		} else {
2766
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2767
+		}
2375 2768
 		if ($error != '') {
2376 2769
 			return $error;
2377
-		} elseif ($globalDebug) echo "Done\n";
2378
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2770
+		} elseif ($globalDebug) {
2771
+			echo "Done\n";
2772
+		}
2773
+		if ($globalDebug) {
2774
+			echo "Owner Luxembourg: Download...";
2775
+		}
2379 2776
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2380 2777
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2381
-			if ($globalDebug) echo "Add to DB...";
2778
+			if ($globalDebug) {
2779
+				echo "Add to DB...";
2780
+			}
2382 2781
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2383
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2782
+		} else {
2783
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2784
+		}
2384 2785
 		if ($error != '') {
2385 2786
 			return $error;
2386
-		} elseif ($globalDebug) echo "Done\n";
2387
-		if ($globalDebug) echo "Owner Maldives: Download...";
2787
+		} elseif ($globalDebug) {
2788
+			echo "Done\n";
2789
+		}
2790
+		if ($globalDebug) {
2791
+			echo "Owner Maldives: Download...";
2792
+		}
2388 2793
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2389 2794
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2390
-			if ($globalDebug) echo "Add to DB...";
2795
+			if ($globalDebug) {
2796
+				echo "Add to DB...";
2797
+			}
2391 2798
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2392
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2799
+		} else {
2800
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2801
+		}
2393 2802
 		if ($error != '') {
2394 2803
 			return $error;
2395
-		} elseif ($globalDebug) echo "Done\n";
2396
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2804
+		} elseif ($globalDebug) {
2805
+			echo "Done\n";
2806
+		}
2807
+		if ($globalDebug) {
2808
+			echo "Owner New Zealand: Download...";
2809
+		}
2397 2810
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2398 2811
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2399
-			if ($globalDebug) echo "Add to DB...";
2812
+			if ($globalDebug) {
2813
+				echo "Add to DB...";
2814
+			}
2400 2815
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2401
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2816
+		} else {
2817
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2818
+		}
2402 2819
 		if ($error != '') {
2403 2820
 			return $error;
2404
-		} elseif ($globalDebug) echo "Done\n";
2405
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2821
+		} elseif ($globalDebug) {
2822
+			echo "Done\n";
2823
+		}
2824
+		if ($globalDebug) {
2825
+			echo "Owner Papua New Guinea: Download...";
2826
+		}
2406 2827
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2407 2828
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2408
-			if ($globalDebug) echo "Add to DB...";
2829
+			if ($globalDebug) {
2830
+				echo "Add to DB...";
2831
+			}
2409 2832
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2410
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2833
+		} else {
2834
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2835
+		}
2411 2836
 		if ($error != '') {
2412 2837
 			return $error;
2413
-		} elseif ($globalDebug) echo "Done\n";
2414
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2838
+		} elseif ($globalDebug) {
2839
+			echo "Done\n";
2840
+		}
2841
+		if ($globalDebug) {
2842
+			echo "Owner Slovakia: Download...";
2843
+		}
2415 2844
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2416 2845
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2417
-			if ($globalDebug) echo "Add to DB...";
2846
+			if ($globalDebug) {
2847
+				echo "Add to DB...";
2848
+			}
2418 2849
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2419
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2850
+		} else {
2851
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2852
+		}
2420 2853
 		if ($error != '') {
2421 2854
 			return $error;
2422
-		} elseif ($globalDebug) echo "Done\n";
2423
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2855
+		} elseif ($globalDebug) {
2856
+			echo "Done\n";
2857
+		}
2858
+		if ($globalDebug) {
2859
+			echo "Owner Ecuador: Download...";
2860
+		}
2424 2861
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2425 2862
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2426
-			if ($globalDebug) echo "Add to DB...";
2863
+			if ($globalDebug) {
2864
+				echo "Add to DB...";
2865
+			}
2427 2866
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2428
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2867
+		} else {
2868
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2869
+		}
2429 2870
 		if ($error != '') {
2430 2871
 			return $error;
2431
-		} elseif ($globalDebug) echo "Done\n";
2432
-		if ($globalDebug) echo "Owner Iceland: Download...";
2872
+		} elseif ($globalDebug) {
2873
+			echo "Done\n";
2874
+		}
2875
+		if ($globalDebug) {
2876
+			echo "Owner Iceland: Download...";
2877
+		}
2433 2878
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2434 2879
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2435
-			if ($globalDebug) echo "Add to DB...";
2880
+			if ($globalDebug) {
2881
+				echo "Add to DB...";
2882
+			}
2436 2883
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2437
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2884
+		} else {
2885
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2886
+		}
2438 2887
 		if ($error != '') {
2439 2888
 			return $error;
2440
-		} elseif ($globalDebug) echo "Done\n";
2441
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2889
+		} elseif ($globalDebug) {
2890
+			echo "Done\n";
2891
+		}
2892
+		if ($globalDebug) {
2893
+			echo "Owner Isle of Man: Download...";
2894
+		}
2442 2895
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2443 2896
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2444
-			if ($globalDebug) echo "Add to DB...";
2897
+			if ($globalDebug) {
2898
+				echo "Add to DB...";
2899
+			}
2445 2900
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2446
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2901
+		} else {
2902
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2903
+		}
2447 2904
 		if ($error != '') {
2448 2905
 			return $error;
2449
-		} elseif ($globalDebug) echo "Done\n";
2906
+		} elseif ($globalDebug) {
2907
+			echo "Done\n";
2908
+		}
2450 2909
 		if ($globalMasterSource) {
2451
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2910
+			if ($globalDebug) {
2911
+				echo "ModeS Netherlands: Download...";
2912
+			}
2452 2913
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2453 2914
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2454
-				if ($globalDebug) echo "Add to DB...";
2915
+				if ($globalDebug) {
2916
+					echo "Add to DB...";
2917
+				}
2455 2918
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2456
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2919
+			} else {
2920
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2921
+			}
2457 2922
 			if ($error != '') {
2458 2923
 				return $error;
2459
-			} elseif ($globalDebug) echo "Done\n";
2460
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2924
+			} elseif ($globalDebug) {
2925
+				echo "Done\n";
2926
+			}
2927
+			if ($globalDebug) {
2928
+				echo "ModeS Denmark: Download...";
2929
+			}
2461 2930
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2462 2931
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2463
-				if ($globalDebug) echo "Add to DB...";
2932
+				if ($globalDebug) {
2933
+					echo "Add to DB...";
2934
+				}
2464 2935
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2465
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2936
+			} else {
2937
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2938
+			}
2466 2939
 			if ($error != '') {
2467 2940
 				return $error;
2468
-			} elseif ($globalDebug) echo "Done\n";
2469
-		} elseif ($globalDebug) echo "Done\n";
2941
+			} elseif ($globalDebug) {
2942
+				echo "Done\n";
2943
+			}
2944
+		} elseif ($globalDebug) {
2945
+			echo "Done\n";
2946
+		}
2470 2947
 		return '';
2471 2948
 	}
2472 2949
 
2473 2950
 	public static function update_translation() {
2474 2951
 		global $tmp_dir, $globalDebug;
2475 2952
 		$error = '';
2476
-		if ($globalDebug) echo "Translation : Download...";
2953
+		if ($globalDebug) {
2954
+			echo "Translation : Download...";
2955
+		}
2477 2956
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2478 2957
 		if (file_exists($tmp_dir.'translation.zip')) {
2479
-			if ($globalDebug) echo "Unzip...";
2958
+			if ($globalDebug) {
2959
+				echo "Unzip...";
2960
+			}
2480 2961
 			update_db::unzip($tmp_dir.'translation.zip');
2481
-			if ($globalDebug) echo "Add to DB...";
2962
+			if ($globalDebug) {
2963
+				echo "Add to DB...";
2964
+			}
2482 2965
 			$error = update_db::translation();
2483
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2966
+		} else {
2967
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2968
+		}
2484 2969
 		if ($error != '') {
2485 2970
 			return $error;
2486
-		} elseif ($globalDebug) echo "Done\n";
2971
+		} elseif ($globalDebug) {
2972
+			echo "Done\n";
2973
+		}
2487 2974
 		return '';
2488 2975
 	}
2489 2976
 
2490 2977
 	public static function update_translation_fam() {
2491 2978
 		global $tmp_dir, $globalDebug;
2492 2979
 		$error = '';
2493
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2980
+		if ($globalDebug) {
2981
+			echo "Translation from FlightAirMap website : Download...";
2982
+		}
2494 2983
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2495 2984
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2496 2985
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2497 2986
 			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2498 2987
 			$translation_md5 = $translation_md5_file[0];
2499 2988
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2500
-				if ($globalDebug) echo "Gunzip...";
2989
+				if ($globalDebug) {
2990
+					echo "Gunzip...";
2991
+				}
2501 2992
 				update_db::gunzip($tmp_dir.'translation.tsv.gz');
2502
-				if ($globalDebug) echo "Add to DB...";
2993
+				if ($globalDebug) {
2994
+					echo "Add to DB...";
2995
+				}
2503 2996
 				$error = update_db::translation_fam();
2504
-			} else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2505
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2997
+			} else {
2998
+				$error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2999
+			}
3000
+		} else {
3001
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
3002
+		}
2506 3003
 		if ($error != '') {
2507 3004
 			return $error;
2508
-		} elseif ($globalDebug) echo "Done\n";
3005
+		} elseif ($globalDebug) {
3006
+			echo "Done\n";
3007
+		}
2509 3008
 		return '';
2510 3009
 	}
2511 3010
 	public static function update_ModeS_fam() {
2512 3011
 		global $tmp_dir, $globalDebug;
2513 3012
 		$error = '';
2514
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
3013
+		if ($globalDebug) {
3014
+			echo "ModeS from FlightAirMap website : Download...";
3015
+		}
2515 3016
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2516 3017
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2517 3018
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2518 3019
 			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2519 3020
 			$modes_md5 = $modes_md5_file[0];
2520 3021
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2521
-				if ($globalDebug) echo "Gunzip...";
3022
+				if ($globalDebug) {
3023
+					echo "Gunzip...";
3024
+				}
2522 3025
 				update_db::gunzip($tmp_dir.'modes.tsv.gz');
2523
-				if ($globalDebug) echo "Add to DB...";
3026
+				if ($globalDebug) {
3027
+					echo "Add to DB...";
3028
+				}
2524 3029
 				$error = update_db::modes_fam();
2525
-			} else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2526
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
3030
+			} else {
3031
+				$error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
3032
+			}
3033
+		} else {
3034
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
3035
+		}
2527 3036
 		if ($error != '') {
2528 3037
 			return $error;
2529
-		} elseif ($globalDebug) echo "Done\n";
3038
+		} elseif ($globalDebug) {
3039
+			echo "Done\n";
3040
+		}
2530 3041
 		return '';
2531 3042
 	}
2532 3043
 
2533 3044
 	public static function update_airlines_fam() {
2534 3045
 		global $tmp_dir, $globalDebug;
2535 3046
 		$error = '';
2536
-		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
3047
+		if ($globalDebug) {
3048
+			echo "Airlines from FlightAirMap website : Download...";
3049
+		}
2537 3050
 		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2538 3051
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2539 3052
 			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
@@ -2542,26 +3055,42 @@  discard block
 block discarded – undo
2542 3055
 				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2543 3056
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2544 3057
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2545
-						if ($globalDebug) echo "Gunzip...";
3058
+						if ($globalDebug) {
3059
+							echo "Gunzip...";
3060
+						}
2546 3061
 						update_db::gunzip($tmp_dir.'airlines.tsv.gz');
2547
-						if ($globalDebug) echo "Add to DB...";
3062
+						if ($globalDebug) {
3063
+							echo "Add to DB...";
3064
+						}
2548 3065
 						$error = update_db::airlines_fam();
2549 3066
 						update_db::insert_airlines_version($airlines_md5);
2550
-					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2551
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2552
-			} elseif ($globalDebug) echo "No update.";
2553
-		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
3067
+					} else {
3068
+						$error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
3069
+					}
3070
+			    } else {
3071
+			    	$error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
3072
+			    }
3073
+			} elseif ($globalDebug) {
3074
+				echo "No update.";
3075
+			}
3076
+		} else {
3077
+			$error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
3078
+		}
2554 3079
 		if ($error != '') {
2555 3080
 			return $error;
2556 3081
 		} else {
2557
-			if ($globalDebug) echo "Done\n";
3082
+			if ($globalDebug) {
3083
+				echo "Done\n";
3084
+			}
2558 3085
 		}
2559 3086
 		return '';
2560 3087
 	}
2561 3088
 
2562 3089
 	public static function update_owner_fam() {
2563 3090
 		global $tmp_dir, $globalDebug, $globalOwner;
2564
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
3091
+		if ($globalDebug) {
3092
+			echo "owner from FlightAirMap website : Download...";
3093
+		}
2565 3094
 		$error = '';
2566 3095
 		if ($globalOwner === TRUE) {
2567 3096
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
@@ -2574,55 +3103,89 @@  discard block
 block discarded – undo
2574 3103
 			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2575 3104
 			$owners_md5 = $owners_md5_file[0];
2576 3105
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2577
-				if ($globalDebug) echo "Gunzip...";
3106
+				if ($globalDebug) {
3107
+					echo "Gunzip...";
3108
+				}
2578 3109
 				update_db::gunzip($tmp_dir.'owners.tsv.gz');
2579
-				if ($globalDebug) echo "Add to DB...";
3110
+				if ($globalDebug) {
3111
+					echo "Add to DB...";
3112
+				}
2580 3113
 				$error = update_db::owner_fam();
2581
-			} else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2582
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3114
+			} else {
3115
+				$error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
3116
+			}
3117
+		} else {
3118
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3119
+		}
2583 3120
 		if ($error != '') {
2584 3121
 			return $error;
2585
-		} elseif ($globalDebug) echo "Done\n";
3122
+		} elseif ($globalDebug) {
3123
+			echo "Done\n";
3124
+		}
2586 3125
 		return '';
2587 3126
 	}
2588 3127
 	public static function update_routes_fam() {
2589 3128
 		global $tmp_dir, $globalDebug;
2590
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
3129
+		if ($globalDebug) {
3130
+			echo "Routes from FlightAirMap website : Download...";
3131
+		}
2591 3132
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2592 3133
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2593 3134
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2594 3135
 			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2595 3136
 			$routes_md5 = $routes_md5_file[0];
2596 3137
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2597
-				if ($globalDebug) echo "Gunzip...";
3138
+				if ($globalDebug) {
3139
+					echo "Gunzip...";
3140
+				}
2598 3141
 				update_db::gunzip($tmp_dir.'routes.tsv.gz');
2599
-				if ($globalDebug) echo "Add to DB...";
3142
+				if ($globalDebug) {
3143
+					echo "Add to DB...";
3144
+				}
2600 3145
 				$error = update_db::routes_fam();
2601
-			} else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2602
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3146
+			} else {
3147
+				$error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
3148
+			}
3149
+		} else {
3150
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3151
+		}
2603 3152
 		if ($error != '') {
2604 3153
 			return $error;
2605
-		} elseif ($globalDebug) echo "Done\n";
3154
+		} elseif ($globalDebug) {
3155
+			echo "Done\n";
3156
+		}
2606 3157
 		return '';
2607 3158
 	}
2608 3159
 	public static function update_block_fam() {
2609 3160
 		global $tmp_dir, $globalDebug;
2610
-		if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download...";
3161
+		if ($globalDebug) {
3162
+			echo "Blocked aircraft from FlightAirMap website : Download...";
3163
+		}
2611 3164
 		update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz');
2612 3165
 		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5');
2613 3166
 		if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) {
2614 3167
 			$block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2615 3168
 			$block_md5 = $block_md5_file[0];
2616 3169
 			if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) {
2617
-				if ($globalDebug) echo "Gunzip...";
3170
+				if ($globalDebug) {
3171
+					echo "Gunzip...";
3172
+				}
2618 3173
 				update_db::gunzip($tmp_dir.'block.tsv.gz');
2619
-				if ($globalDebug) echo "Add to DB...";
3174
+				if ($globalDebug) {
3175
+					echo "Add to DB...";
3176
+				}
2620 3177
 				$error = update_db::block_fam();
2621
-			} else $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed.";
2622
-		} else $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed.";
3178
+			} else {
3179
+				$error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed.";
3180
+			}
3181
+		} else {
3182
+			$error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed.";
3183
+		}
2623 3184
 		if ($error != '') {
2624 3185
 			return $error;
2625
-		} elseif ($globalDebug) echo "Done\n";
3186
+		} elseif ($globalDebug) {
3187
+			echo "Done\n";
3188
+		}
2626 3189
 		return '';
2627 3190
 	}
2628 3191
 	public static function update_marine_identity_fam() {
@@ -2632,21 +3195,33 @@  discard block
 block discarded – undo
2632 3195
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2633 3196
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2634 3197
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2635
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
3198
+				if ($globalDebug) {
3199
+					echo "Marine identity from FlightAirMap website : Download...";
3200
+				}
2636 3201
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2637 3202
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2638 3203
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2639
-						if ($globalDebug) echo "Gunzip...";
3204
+						if ($globalDebug) {
3205
+							echo "Gunzip...";
3206
+						}
2640 3207
 						update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2641
-						if ($globalDebug) echo "Add to DB...";
3208
+						if ($globalDebug) {
3209
+							echo "Add to DB...";
3210
+						}
2642 3211
 						$error = update_db::marine_identity_fam();
2643
-					} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2644
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3212
+					} else {
3213
+						$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
3214
+					}
3215
+				} else {
3216
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3217
+				}
2645 3218
 				if ($error != '') {
2646 3219
 					return $error;
2647 3220
 				} else {
2648 3221
 					update_db::insert_marine_identity_version($marine_identity_md5);
2649
-					if ($globalDebug) echo "Done\n";
3222
+					if ($globalDebug) {
3223
+						echo "Done\n";
3224
+					}
2650 3225
 				}
2651 3226
 			}
2652 3227
 		}
@@ -2660,21 +3235,33 @@  discard block
 block discarded – undo
2660 3235
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2661 3236
 			$satellite_md5 = $satellite_md5_file[0];
2662 3237
 			if (!update_db::check_satellite_version($satellite_md5)) {
2663
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
3238
+				if ($globalDebug) {
3239
+					echo "Satellite from FlightAirMap website : Download...";
3240
+				}
2664 3241
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2665 3242
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2666 3243
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2667
-						if ($globalDebug) echo "Gunzip...";
3244
+						if ($globalDebug) {
3245
+							echo "Gunzip...";
3246
+						}
2668 3247
 						update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2669
-						if ($globalDebug) echo "Add to DB...";
3248
+						if ($globalDebug) {
3249
+							echo "Add to DB...";
3250
+						}
2670 3251
 						$error = update_db::satellite_fam();
2671
-					} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2672
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3252
+					} else {
3253
+						$error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
3254
+					}
3255
+				} else {
3256
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3257
+				}
2673 3258
 				if ($error != '') {
2674 3259
 					return $error;
2675 3260
 				} else {
2676 3261
 					update_db::insert_satellite_version($satellite_md5);
2677
-					if ($globalDebug) echo "Done\n";
3262
+					if ($globalDebug) {
3263
+						echo "Done\n";
3264
+					}
2678 3265
 				}
2679 3266
 			}
2680 3267
 		}
@@ -2687,19 +3274,29 @@  discard block
 block discarded – undo
2687 3274
 			$diagrams_md5_file = explode(' ',file_get_contents($tmp_dir.'diagramspdf.md5'));
2688 3275
 			$diagrams_md5 = $diagrams_md5_file[0];
2689 3276
 			if (!update_db::check_diagrams_version($diagrams_md5)) {
2690
-				if ($globalDebug) echo "Airports diagrams from FlightAirMap website : Download...";
3277
+				if ($globalDebug) {
3278
+					echo "Airports diagrams from FlightAirMap website : Download...";
3279
+				}
2691 3280
 				update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf',$tmp_dir.'diagramspdf');
2692 3281
 				if (file_exists($tmp_dir.'diagramspdf')) {
2693 3282
 					if (md5_file($tmp_dir.'diagramspdf') == $diagrams_md5) {
2694
-						if ($globalDebug) echo "Add to DB...";
3283
+						if ($globalDebug) {
3284
+							echo "Add to DB...";
3285
+						}
2695 3286
 						$error = update_db::diagrams_fam();
2696
-					} else $error = "File ".$tmp_dir.'diagramspdf'." md5 failed. Download failed.";
2697
-				} else $error = "File ".$tmp_dir.'diagramspdf'." doesn't exist. Download failed.";
3287
+					} else {
3288
+						$error = "File ".$tmp_dir.'diagramspdf'." md5 failed. Download failed.";
3289
+					}
3290
+				} else {
3291
+					$error = "File ".$tmp_dir.'diagramspdf'." doesn't exist. Download failed.";
3292
+				}
2698 3293
 				if ($error != '') {
2699 3294
 					return $error;
2700 3295
 				} else {
2701 3296
 					update_db::insert_diagrams_version($diagrams_md5);
2702
-					if ($globalDebug) echo "Done\n";
3297
+					if ($globalDebug) {
3298
+						echo "Done\n";
3299
+					}
2703 3300
 				}
2704 3301
 			}
2705 3302
 		}
@@ -2707,17 +3304,25 @@  discard block
 block discarded – undo
2707 3304
 	}
2708 3305
 	public static function update_banned_fam() {
2709 3306
 		global $tmp_dir, $globalDebug;
2710
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
3307
+		if ($globalDebug) {
3308
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
3309
+		}
2711 3310
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2712 3311
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2713 3312
 			//if ($globalDebug) echo "Gunzip...";
2714 3313
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2715
-			if ($globalDebug) echo "Add to DB...";
3314
+			if ($globalDebug) {
3315
+				echo "Add to DB...";
3316
+			}
2716 3317
 			$error = update_db::banned_fam();
2717
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3318
+		} else {
3319
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3320
+		}
2718 3321
 		if ($error != '') {
2719 3322
 			return $error;
2720
-		} elseif ($globalDebug) echo "Done\n";
3323
+		} elseif ($globalDebug) {
3324
+			echo "Done\n";
3325
+		}
2721 3326
 		return '';
2722 3327
 	}
2723 3328
 
@@ -2725,7 +3330,9 @@  discard block
 block discarded – undo
2725 3330
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2726 3331
 		include_once('class.create_db.php');
2727 3332
 		$error = '';
2728
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
3333
+		if ($globalDebug) {
3334
+			echo "Airspace from FlightAirMap website : Download...";
3335
+		}
2729 3336
 		if ($globalDBdriver == 'mysql') {
2730 3337
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2731 3338
 		} else {
@@ -2742,9 +3349,13 @@  discard block
 block discarded – undo
2742 3349
 				}
2743 3350
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2744 3351
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
2745
-						if ($globalDebug) echo "Gunzip...";
3352
+						if ($globalDebug) {
3353
+							echo "Gunzip...";
3354
+						}
2746 3355
 						update_db::gunzip($tmp_dir.'airspace.sql.gz');
2747
-						if ($globalDebug) echo "Add to DB...";
3356
+						if ($globalDebug) {
3357
+							echo "Add to DB...";
3358
+						}
2748 3359
 						$Connection = new Connection();
2749 3360
 						if ($Connection->tableExists('airspace')) {
2750 3361
 							$query = 'DROP TABLE airspace';
@@ -2757,20 +3368,30 @@  discard block
 block discarded – undo
2757 3368
 						}
2758 3369
 						$error = create_db::import_file($tmp_dir.'airspace.sql');
2759 3370
 						update_db::insert_airspace_version($airspace_md5);
2760
-					} else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
2761
-				} else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3371
+					} else {
3372
+						$error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
3373
+					}
3374
+				} else {
3375
+					$error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3376
+				}
2762 3377
 			}
2763
-		} else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3378
+		} else {
3379
+			$error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3380
+		}
2764 3381
 		if ($error != '') {
2765 3382
 			return $error;
2766
-		} elseif ($globalDebug) echo "Done\n";
3383
+		} elseif ($globalDebug) {
3384
+			echo "Done\n";
3385
+		}
2767 3386
 		return '';
2768 3387
 	}
2769 3388
 
2770 3389
 	public static function update_geoid_fam() {
2771 3390
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2772 3391
 		$error = '';
2773
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3392
+		if ($globalDebug) {
3393
+			echo "Geoid from FlightAirMap website : Download...";
3394
+		}
2774 3395
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2775 3396
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2776 3397
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2779,80 +3400,126 @@  discard block
 block discarded – undo
2779 3400
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2780 3401
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2781 3402
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2782
-						if ($globalDebug) echo "Gunzip...";
3403
+						if ($globalDebug) {
3404
+							echo "Gunzip...";
3405
+						}
2783 3406
 						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2784 3407
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2785 3408
 							update_db::insert_geoid_version($geoid_md5);
2786
-						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
2787
-					} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
2788
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2789
-			} elseif ($globalDebug) echo 'No new version'."\n";
2790
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3409
+						} else {
3410
+							$error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
3411
+						}
3412
+					} else {
3413
+						$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
3414
+					}
3415
+				} else {
3416
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3417
+				}
3418
+			} elseif ($globalDebug) {
3419
+				echo 'No new version'."\n";
3420
+			}
3421
+		} else {
3422
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3423
+		}
2791 3424
 		if ($error != '') {
2792 3425
 			return $error;
2793
-		} elseif ($globalDebug) echo "Done\n";
3426
+		} elseif ($globalDebug) {
3427
+			echo "Done\n";
3428
+		}
2794 3429
 		return '';
2795 3430
 	}
2796 3431
 
2797 3432
 	public static function update_tle() {
2798 3433
 		global $tmp_dir, $globalDebug;
2799
-		if ($globalDebug) echo "Download TLE : Download...";
3434
+		if ($globalDebug) {
3435
+			echo "Download TLE : Download...";
3436
+		}
2800 3437
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2801 3438
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2802 3439
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2803 3440
 		foreach ($alltle as $filename) {
2804
-			if ($globalDebug) echo "downloading ".$filename.'...';
3441
+			if ($globalDebug) {
3442
+				echo "downloading ".$filename.'...';
3443
+			}
2805 3444
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2806 3445
 			if (file_exists($tmp_dir.$filename)) {
2807
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3446
+				if ($globalDebug) {
3447
+					echo "Add to DB ".$filename."...";
3448
+				}
2808 3449
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2809
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3450
+			} else {
3451
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3452
+			}
2810 3453
 			if ($error != '') {
2811 3454
 				echo $error."\n";
2812
-			} elseif ($globalDebug) echo "Done\n";
3455
+			} elseif ($globalDebug) {
3456
+				echo "Done\n";
3457
+			}
2813 3458
 		}
2814 3459
 		return '';
2815 3460
 	}
2816 3461
 
2817 3462
 	public static function update_ucsdb() {
2818 3463
 		global $tmp_dir, $globalDebug;
2819
-		if ($globalDebug) echo "Download UCS DB : Download...";
3464
+		if ($globalDebug) {
3465
+			echo "Download UCS DB : Download...";
3466
+		}
2820 3467
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/5-9-19-update/UCS_Satellite_Database_officialname_4-1-2019.txt',$tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt');
2821 3468
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt')) {
2822
-			if ($globalDebug) echo "Add to DB...";
3469
+			if ($globalDebug) {
3470
+				echo "Add to DB...";
3471
+			}
2823 3472
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt');
2824
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt'." doesn't exist. Download failed.";
3473
+		} else {
3474
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt'." doesn't exist. Download failed.";
3475
+		}
2825 3476
 		if ($error != '') {
2826 3477
 			echo $error."\n";
2827
-		} elseif ($globalDebug) echo "Done\n";
3478
+		} elseif ($globalDebug) {
3479
+			echo "Done\n";
3480
+		}
2828 3481
 		return '';
2829 3482
 	}
2830 3483
 
2831 3484
 	public static function update_celestrak() {
2832 3485
 		global $tmp_dir, $globalDebug;
2833
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3486
+		if ($globalDebug) {
3487
+			echo "Download Celestrak DB : Download...";
3488
+		}
2834 3489
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2835 3490
 		if (file_exists($tmp_dir.'satcat.txt')) {
2836
-			if ($globalDebug) echo "Add to DB...";
3491
+			if ($globalDebug) {
3492
+				echo "Add to DB...";
3493
+			}
2837 3494
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2838
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3495
+		} else {
3496
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3497
+		}
2839 3498
 		if ($error != '') {
2840 3499
 			echo $error."\n";
2841
-		} elseif ($globalDebug) echo "Done\n";
3500
+		} elseif ($globalDebug) {
3501
+			echo "Done\n";
3502
+		}
2842 3503
 		return '';
2843 3504
 	}
2844 3505
 
2845 3506
 	public static function update_models() {
2846 3507
 		global $tmp_dir, $globalDebug;
2847 3508
 		$error = '';
2848
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3509
+		if ($globalDebug) {
3510
+			echo "Models from FlightAirMap website : Download...";
3511
+		}
2849 3512
 		if (!is_writable(dirname(__FILE__).'/../models')) {
2850
-			if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !';
3513
+			if ($globalDebug) {
3514
+				echo dirname(__FILE__).'/../models'.' is not writable !';
3515
+			}
2851 3516
 			return '';
2852 3517
 		}
2853 3518
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2854 3519
 		if (file_exists($tmp_dir.'models.md5sum')) {
2855
-			if ($globalDebug) echo "Check files...\n";
3520
+			if ($globalDebug) {
3521
+				echo "Check files...\n";
3522
+			}
2856 3523
 			$newmodelsdb = array();
2857 3524
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2858 3525
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2871,18 +3538,28 @@  discard block
 block discarded – undo
2871 3538
 			}
2872 3539
 			$diff = array_diff($newmodelsdb,$modelsdb);
2873 3540
 			foreach ($diff as $key => $value) {
2874
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3541
+				if ($globalDebug) {
3542
+					echo 'Downloading model '.$key.' ...'."\n";
3543
+				}
2875 3544
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2876 3545
 			}
2877 3546
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2878
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3547
+		} else {
3548
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3549
+		}
2879 3550
 		if ($error != '') {
2880 3551
 			return $error;
2881
-		} elseif ($globalDebug) echo "Done\n";
2882
-		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
3552
+		} elseif ($globalDebug) {
3553
+			echo "Done\n";
3554
+		}
3555
+		if ($globalDebug) {
3556
+			echo "glTF 2.0 Models from FlightAirMap website : Download...";
3557
+		}
2883 3558
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2884 3559
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2885
-			if ($globalDebug) echo "Check files...\n";
3560
+			if ($globalDebug) {
3561
+				echo "Check files...\n";
3562
+			}
2886 3563
 			$newmodelsdb = array();
2887 3564
 			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2888 3565
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2901,29 +3578,43 @@  discard block
 block discarded – undo
2901 3578
 			}
2902 3579
 			$diff = array_diff($newmodelsdb,$modelsdb);
2903 3580
 			foreach ($diff as $key => $value) {
2904
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3581
+				if ($globalDebug) {
3582
+					echo 'Downloading model '.$key.' ...'."\n";
3583
+				}
2905 3584
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2906 3585
 				
2907 3586
 			}
2908 3587
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2909
-		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3588
+		} else {
3589
+			$error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3590
+		}
2910 3591
 		if ($error != '') {
2911 3592
 			return $error;
2912
-		} elseif ($globalDebug) echo "Done\n";
3593
+		} elseif ($globalDebug) {
3594
+			echo "Done\n";
3595
+		}
2913 3596
 		return '';
2914 3597
 	}
2915 3598
 	public static function update_weather_models() {
2916 3599
 		global $tmp_dir, $globalDebug;
2917 3600
 		$error = '';
2918
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3601
+		if ($globalDebug) {
3602
+			echo "Models from FlightAirMap website : Download...";
3603
+		}
2919 3604
 		if (!is_writable(dirname(__FILE__).'/../models/gltf2/weather')) {
2920
-			if ($globalDebug) echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !';
3605
+			if ($globalDebug) {
3606
+				echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !';
3607
+			}
2921 3608
 			return '';
2922 3609
 		}
2923
-		if ($globalDebug) echo "Weather Models from FlightAirMap website : Download...";
3610
+		if ($globalDebug) {
3611
+			echo "Weather Models from FlightAirMap website : Download...";
3612
+		}
2924 3613
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum');
2925 3614
 		if (file_exists($tmp_dir.'modelsweather.md5sum')) {
2926
-			if ($globalDebug) echo "Check files...\n";
3615
+			if ($globalDebug) {
3616
+				echo "Check files...\n";
3617
+			}
2927 3618
 			$newmodelsdb = array();
2928 3619
 			if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) {
2929 3620
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2942,25 +3633,35 @@  discard block
 block discarded – undo
2942 3633
 			}
2943 3634
 			$diff = array_diff($newmodelsdb,$modelsdb);
2944 3635
 			foreach ($diff as $key => $value) {
2945
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3636
+				if ($globalDebug) {
3637
+					echo 'Downloading model '.$key.' ...'."\n";
3638
+				}
2946 3639
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2947 3640
 				
2948 3641
 			}
2949 3642
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2950
-		} else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
3643
+		} else {
3644
+			$error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
3645
+		}
2951 3646
 		if ($error != '') {
2952 3647
 			return $error;
2953
-		} elseif ($globalDebug) echo "Done\n";
3648
+		} elseif ($globalDebug) {
3649
+			echo "Done\n";
3650
+		}
2954 3651
 		return '';
2955 3652
 	}
2956 3653
 
2957 3654
 	public static function update_liveries() {
2958 3655
 		global $tmp_dir, $globalDebug;
2959 3656
 		$error = '';
2960
-		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
3657
+		if ($globalDebug) {
3658
+			echo "Liveries from FlightAirMap website : Download...";
3659
+		}
2961 3660
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2962 3661
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2963
-			if ($globalDebug) echo "Check files...\n";
3662
+			if ($globalDebug) {
3663
+				echo "Check files...\n";
3664
+			}
2964 3665
 			$newmodelsdb = array();
2965 3666
 			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2966 3667
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2979,15 +3680,21 @@  discard block
 block discarded – undo
2979 3680
 			}
2980 3681
 			$diff = array_diff($newmodelsdb,$modelsdb);
2981 3682
 			foreach ($diff as $key => $value) {
2982
-				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
3683
+				if ($globalDebug) {
3684
+					echo 'Downloading liveries '.$key.' ...'."\n";
3685
+				}
2983 3686
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2984 3687
 				
2985 3688
 			}
2986 3689
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2987
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3690
+		} else {
3691
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3692
+		}
2988 3693
 		if ($error != '') {
2989 3694
 			return $error;
2990
-		} elseif ($globalDebug) echo "Done\n";
3695
+		} elseif ($globalDebug) {
3696
+			echo "Done\n";
3697
+		}
2991 3698
 		return '';
2992 3699
 	}
2993 3700
 
@@ -2995,13 +3702,19 @@  discard block
 block discarded – undo
2995 3702
 		global $tmp_dir, $globalDebug;
2996 3703
 		$error = '';
2997 3704
 		if (!is_writable(dirname(__FILE__).'/../models')) {
2998
-			if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !';
3705
+			if ($globalDebug) {
3706
+				echo dirname(__FILE__).'/../models'.' is not writable !';
3707
+			}
2999 3708
 			return '';
3000 3709
 		}
3001
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3710
+		if ($globalDebug) {
3711
+			echo "Space models from FlightAirMap website : Download...";
3712
+		}
3002 3713
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
3003 3714
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
3004
-			if ($globalDebug) echo "Check files...\n";
3715
+			if ($globalDebug) {
3716
+				echo "Check files...\n";
3717
+			}
3005 3718
 			$newmodelsdb = array();
3006 3719
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
3007 3720
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -3020,15 +3733,21 @@  discard block
 block discarded – undo
3020 3733
 			}
3021 3734
 			$diff = array_diff($newmodelsdb,$modelsdb);
3022 3735
 			foreach ($diff as $key => $value) {
3023
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3736
+				if ($globalDebug) {
3737
+					echo 'Downloading space model '.$key.' ...'."\n";
3738
+				}
3024 3739
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
3025 3740
 				
3026 3741
 			}
3027 3742
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
3028
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3743
+		} else {
3744
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3745
+		}
3029 3746
 		if ($error != '') {
3030 3747
 			return $error;
3031
-		} elseif ($globalDebug) echo "Done\n";
3748
+		} elseif ($globalDebug) {
3749
+			echo "Done\n";
3750
+		}
3032 3751
 		return '';
3033 3752
 	}
3034 3753
 
@@ -3036,13 +3755,19 @@  discard block
 block discarded – undo
3036 3755
 		global $tmp_dir, $globalDebug;
3037 3756
 		$error = '';
3038 3757
 		if (!is_writable(dirname(__FILE__).'/../models/vehicules')) {
3039
-			if ($globalDebug) echo dirname(__FILE__).'/../models/vehicules'.' is not writable !';
3758
+			if ($globalDebug) {
3759
+				echo dirname(__FILE__).'/../models/vehicules'.' is not writable !';
3760
+			}
3040 3761
 			return '';
3041 3762
 		}
3042
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3763
+		if ($globalDebug) {
3764
+			echo "Vehicules models from FlightAirMap website : Download...";
3765
+		}
3043 3766
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
3044 3767
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
3045
-			if ($globalDebug) echo "Check files...\n";
3768
+			if ($globalDebug) {
3769
+				echo "Check files...\n";
3770
+			}
3046 3771
 			$newmodelsdb = array();
3047 3772
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
3048 3773
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -3061,15 +3786,21 @@  discard block
 block discarded – undo
3061 3786
 			}
3062 3787
 			$diff = array_diff($newmodelsdb,$modelsdb);
3063 3788
 			foreach ($diff as $key => $value) {
3064
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3789
+				if ($globalDebug) {
3790
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3791
+				}
3065 3792
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
3066 3793
 				
3067 3794
 			}
3068 3795
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
3069
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3796
+		} else {
3797
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3798
+		}
3070 3799
 		if ($error != '') {
3071 3800
 			return $error;
3072
-		} elseif ($globalDebug) echo "Done\n";
3801
+		} elseif ($globalDebug) {
3802
+			echo "Done\n";
3803
+		}
3073 3804
 		return '';
3074 3805
 	}
3075 3806
 
@@ -3142,7 +3873,9 @@  discard block
 block discarded – undo
3142 3873
                 }
3143 3874
 
3144 3875
 		$error = '';
3145
-		if ($globalDebug) echo "Notam : Download...";
3876
+		if ($globalDebug) {
3877
+			echo "Notam : Download...";
3878
+		}
3146 3879
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
3147 3880
 		if (file_exists($tmp_dir.'notam.rss')) {
3148 3881
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -3157,14 +3890,30 @@  discard block
 block discarded – undo
3157 3890
 				$data['fir'] = $q[0];
3158 3891
 				$data['code'] = $q[1];
3159 3892
 				$ifrvfr = $q[2];
3160
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
3161
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
3162
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
3163
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
3164
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
3165
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
3166
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
3167
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3893
+				if ($ifrvfr == 'IV') {
3894
+					$data['rules'] = 'IFR/VFR';
3895
+				}
3896
+				if ($ifrvfr == 'I') {
3897
+					$data['rules'] = 'IFR';
3898
+				}
3899
+				if ($ifrvfr == 'V') {
3900
+					$data['rules'] = 'VFR';
3901
+				}
3902
+				if ($q[4] == 'A') {
3903
+					$data['scope'] = 'Airport warning';
3904
+				}
3905
+				if ($q[4] == 'E') {
3906
+					$data['scope'] = 'Enroute warning';
3907
+				}
3908
+				if ($q[4] == 'W') {
3909
+					$data['scope'] = 'Navigation warning';
3910
+				}
3911
+				if ($q[4] == 'AE') {
3912
+					$data['scope'] = 'Airport/Enroute warning';
3913
+				}
3914
+				if ($q[4] == 'AW') {
3915
+					$data['scope'] = 'Airport/Navigation warning';
3916
+				}
3168 3917
 				//$data['scope'] = $q[4];
3169 3918
 				$data['lower_limit'] = $q[5];
3170 3919
 				$data['upper_limit'] = $q[6];
@@ -3172,8 +3921,12 @@  discard block
 block discarded – undo
3172 3921
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
3173 3922
 				$latitude = $Common->convertDec($las,'latitude');
3174 3923
 				$longitude = $Common->convertDec($lns,'longitude');
3175
-				if ($lac == 'S') $latitude = '-'.$latitude;
3176
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3924
+				if ($lac == 'S') {
3925
+					$latitude = '-'.$latitude;
3926
+				}
3927
+				if ($lnc == 'W') {
3928
+					$longitude = '-'.$longitude;
3929
+				}
3177 3930
 				$data['center_latitude'] = $latitude;
3178 3931
 				$data['center_longitude'] = $longitude;
3179 3932
 				$data['radius'] = intval($radius);
@@ -3203,10 +3956,14 @@  discard block
 block discarded – undo
3203 3956
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
3204 3957
 				unset($data);
3205 3958
 			} 
3206
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3959
+		} else {
3960
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3961
+		}
3207 3962
 		if ($error != '') {
3208 3963
 			return $error;
3209
-		} elseif ($globalDebug) echo "Done\n";
3964
+		} elseif ($globalDebug) {
3965
+			echo "Done\n";
3966
+		}
3210 3967
 		return '';
3211 3968
 	}
3212 3969
 	
@@ -3231,7 +3988,9 @@  discard block
 block discarded – undo
3231 3988
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3232 3989
 		$airspace_json = json_decode($airspace_lst,true);
3233 3990
 		foreach ($airspace_json['records'] as $airspace) {
3234
-			if ($globalDebug) echo $airspace['name']."...\n";
3991
+			if ($globalDebug) {
3992
+				echo $airspace['name']."...\n";
3993
+			}
3235 3994
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3236 3995
 			if (file_exists($tmp_dir.$airspace['name'])) {
3237 3996
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -3275,8 +4034,11 @@  discard block
 block discarded – undo
3275 4034
                         return "error : ".$e->getMessage();
3276 4035
                 }
3277 4036
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3278
-                if ($row['nb'] > 0) return false;
3279
-                else return true;
4037
+                if ($row['nb'] > 0) {
4038
+                	return false;
4039
+                } else {
4040
+                	return true;
4041
+                }
3280 4042
 	}
3281 4043
 
3282 4044
 	public static function insert_last_update() {
@@ -3301,8 +4063,11 @@  discard block
 block discarded – undo
3301 4063
                         return "error : ".$e->getMessage();
3302 4064
                 }
3303 4065
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3304
-                if ($row['nb'] > 0) return true;
3305
-                else return false;
4066
+                if ($row['nb'] > 0) {
4067
+                	return true;
4068
+                } else {
4069
+                	return false;
4070
+                }
3306 4071
 	}
3307 4072
 
3308 4073
 	public static function check_geoid_version($version) {
@@ -3315,8 +4080,11 @@  discard block
 block discarded – undo
3315 4080
                         return "error : ".$e->getMessage();
3316 4081
                 }
3317 4082
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3318
-                if ($row['nb'] > 0) return true;
3319
-                else return false;
4083
+                if ($row['nb'] > 0) {
4084
+                	return true;
4085
+                } else {
4086
+                	return false;
4087
+                }
3320 4088
 	}
3321 4089
 
3322 4090
 	public static function check_marine_identity_version($version) {
@@ -3329,8 +4097,11 @@  discard block
 block discarded – undo
3329 4097
 			return "error : ".$e->getMessage();
3330 4098
 		}
3331 4099
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3332
-		if ($row['nb'] > 0) return true;
3333
-		else return false;
4100
+		if ($row['nb'] > 0) {
4101
+			return true;
4102
+		} else {
4103
+			return false;
4104
+		}
3334 4105
 	}
3335 4106
 
3336 4107
 	public static function check_satellite_version($version) {
@@ -3343,8 +4114,11 @@  discard block
 block discarded – undo
3343 4114
 			return "error : ".$e->getMessage();
3344 4115
 		}
3345 4116
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3346
-		if ($row['nb'] > 0) return true;
3347
-		else return false;
4117
+		if ($row['nb'] > 0) {
4118
+			return true;
4119
+		} else {
4120
+			return false;
4121
+		}
3348 4122
 	}
3349 4123
 	public static function check_diagrams_version($version) {
3350 4124
 		$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'diagrams_version' AND value = :version";
@@ -3356,8 +4130,11 @@  discard block
 block discarded – undo
3356 4130
 			return "error : ".$e->getMessage();
3357 4131
 		}
3358 4132
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3359
-		if ($row['nb'] > 0) return true;
3360
-		else return false;
4133
+		if ($row['nb'] > 0) {
4134
+			return true;
4135
+		} else {
4136
+			return false;
4137
+		}
3361 4138
 	}
3362 4139
 
3363 4140
 	public static function check_airlines_version($version) {
@@ -3370,8 +4147,11 @@  discard block
 block discarded – undo
3370 4147
 			return "error : ".$e->getMessage();
3371 4148
 		}
3372 4149
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3373
-		if ($row['nb'] > 0) return true;
3374
-		else return false;
4150
+		if ($row['nb'] > 0) {
4151
+			return true;
4152
+		} else {
4153
+			return false;
4154
+		}
3375 4155
 	}
3376 4156
 
3377 4157
 	public static function check_notam_version($version) {
@@ -3384,8 +4164,11 @@  discard block
 block discarded – undo
3384 4164
 			return "error : ".$e->getMessage();
3385 4165
 		}
3386 4166
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3387
-		if ($row['nb'] > 0) return true;
3388
-		else return false;
4167
+		if ($row['nb'] > 0) {
4168
+			return true;
4169
+		} else {
4170
+			return false;
4171
+		}
3389 4172
 	}
3390 4173
 
3391 4174
 	public static function insert_airlines_version($version) {
@@ -3486,8 +4269,11 @@  discard block
 block discarded – undo
3486 4269
                         return "error : ".$e->getMessage();
3487 4270
                 }
3488 4271
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3489
-                if ($row['nb'] > 0) return false;
3490
-                else return true;
4272
+                if ($row['nb'] > 0) {
4273
+                	return false;
4274
+                } else {
4275
+                	return true;
4276
+                }
3491 4277
 	}
3492 4278
 
3493 4279
 	public static function insert_last_notam_update() {
@@ -3517,8 +4303,11 @@  discard block
 block discarded – undo
3517 4303
                         return "error : ".$e->getMessage();
3518 4304
                 }
3519 4305
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3520
-                if ($row['nb'] > 0) return false;
3521
-                else return true;
4306
+                if ($row['nb'] > 0) {
4307
+                	return false;
4308
+                } else {
4309
+                	return true;
4310
+                }
3522 4311
 	}
3523 4312
 
3524 4313
 	public static function insert_last_airspace_update() {
@@ -3548,8 +4337,11 @@  discard block
 block discarded – undo
3548 4337
                         return "error : ".$e->getMessage();
3549 4338
                 }
3550 4339
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3551
-                if ($row['nb'] > 0) return false;
3552
-                else return true;
4340
+                if ($row['nb'] > 0) {
4341
+                	return false;
4342
+                } else {
4343
+                	return true;
4344
+                }
3553 4345
 	}
3554 4346
 
3555 4347
 	public static function insert_last_geoid_update() {
@@ -3579,8 +4371,11 @@  discard block
 block discarded – undo
3579 4371
 			return "error : ".$e->getMessage();
3580 4372
 		}
3581 4373
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3582
-		if ($row['nb'] > 0) return false;
3583
-		else return true;
4374
+		if ($row['nb'] > 0) {
4375
+			return false;
4376
+		} else {
4377
+			return true;
4378
+		}
3584 4379
 	}
3585 4380
 
3586 4381
 	public static function insert_last_owner_update() {
@@ -3610,8 +4405,11 @@  discard block
 block discarded – undo
3610 4405
 			return "error : ".$e->getMessage();
3611 4406
 		}
3612 4407
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3613
-		if ($row['nb'] > 0) return false;
3614
-		else return true;
4408
+		if ($row['nb'] > 0) {
4409
+			return false;
4410
+		} else {
4411
+			return true;
4412
+		}
3615 4413
 	}
3616 4414
 
3617 4415
 	public static function insert_last_fires_update() {
@@ -3641,8 +4439,11 @@  discard block
 block discarded – undo
3641 4439
 			return "error : ".$e->getMessage();
3642 4440
 		}
3643 4441
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3644
-		if ($row['nb'] > 0) return false;
3645
-		else return true;
4442
+		if ($row['nb'] > 0) {
4443
+			return false;
4444
+		} else {
4445
+			return true;
4446
+		}
3646 4447
 	}
3647 4448
 
3648 4449
 	public static function insert_last_airlines_update() {
@@ -3672,8 +4473,11 @@  discard block
 block discarded – undo
3672 4473
                         return "error : ".$e->getMessage();
3673 4474
                 }
3674 4475
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3675
-                if ($row['nb'] > 0) return false;
3676
-                else return true;
4476
+                if ($row['nb'] > 0) {
4477
+                	return false;
4478
+                } else {
4479
+                	return true;
4480
+                }
3677 4481
 	}
3678 4482
 
3679 4483
 	public static function insert_last_schedules_update() {
@@ -3703,8 +4507,11 @@  discard block
 block discarded – undo
3703 4507
 			return "error : ".$e->getMessage();
3704 4508
 		}
3705 4509
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3706
-		if ($row['nb'] > 0) return false;
3707
-		else return true;
4510
+		if ($row['nb'] > 0) {
4511
+			return false;
4512
+		} else {
4513
+			return true;
4514
+		}
3708 4515
 	}
3709 4516
 
3710 4517
 	public static function insert_last_tle_update() {
@@ -3734,8 +4541,11 @@  discard block
 block discarded – undo
3734 4541
 			return "error : ".$e->getMessage();
3735 4542
 		}
3736 4543
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3737
-		if ($row['nb'] > 0) return false;
3738
-		else return true;
4544
+		if ($row['nb'] > 0) {
4545
+			return false;
4546
+		} else {
4547
+			return true;
4548
+		}
3739 4549
 	}
3740 4550
 
3741 4551
 	public static function insert_last_ucsdb_update() {
@@ -3765,8 +4575,11 @@  discard block
 block discarded – undo
3765 4575
 			return "error : ".$e->getMessage();
3766 4576
 		}
3767 4577
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3768
-		if ($row['nb'] > 0) return false;
3769
-		else return true;
4578
+		if ($row['nb'] > 0) {
4579
+			return false;
4580
+		} else {
4581
+			return true;
4582
+		}
3770 4583
 	}
3771 4584
 
3772 4585
 	public static function insert_last_celestrak_update() {
@@ -3796,8 +4609,11 @@  discard block
 block discarded – undo
3796 4609
 			return "error : ".$e->getMessage();
3797 4610
 		}
3798 4611
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3799
-		if ($row['nb'] > 0) return false;
3800
-		else return true;
4612
+		if ($row['nb'] > 0) {
4613
+			return false;
4614
+		} else {
4615
+			return true;
4616
+		}
3801 4617
 	}
3802 4618
 
3803 4619
 	public static function check_last_satellite_update() {
@@ -3815,8 +4631,11 @@  discard block
 block discarded – undo
3815 4631
 			return "error : ".$e->getMessage();
3816 4632
 		}
3817 4633
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3818
-		if ($row['nb'] > 0) return false;
3819
-		else return true;
4634
+		if ($row['nb'] > 0) {
4635
+			return false;
4636
+		} else {
4637
+			return true;
4638
+		}
3820 4639
 	}
3821 4640
 
3822 4641
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
require/class.SBS.php 1 patch
Braces   +246 added lines, -86 removed lines patch added patch discarded remove patch
@@ -26,8 +26,11 @@  discard block
 block discarded – undo
26 26
 			}
27 27
 		}
28 28
 		//elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
29
-		elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-1);
30
-		else $hex = substr($buffer,1,-1);
29
+		elseif ($typehex == '@' || $typehex == '%') {
30
+			$hex = substr($buffer,13,-1);
31
+		} else {
32
+			$hex = substr($buffer,1,-1);
33
+		}
31 34
 		$bin = gmp_strval( gmp_init($hex,16), 2);
32 35
 		//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
33 36
 		//if (strlen($hex) == 28) {
@@ -95,8 +98,9 @@  discard block
 block discarded – undo
95 98
 					//  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
96 99
 					$cprlat = intval(substr($bin,54,17),2)/131072.0;
97 100
 					$cprlon = intval(substr($bin,71,17),2)/131072.0;
98
-					if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
99
-					elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
101
+					if ($oe == 0) {
102
+						$this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
103
+					} elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
100 104
 						$cprlat_odd = $cprlat;
101 105
 						$cprlon_odd = $cprlon;
102 106
 						$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -104,8 +108,12 @@  discard block
 block discarded – undo
104 108
 						$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
105 109
 						$lat_even = (360.0/60)*($j%60+$cprlat_even);
106 110
 						$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
107
-						if ($lat_even >= 270) $lat_even = $lat_even - 360;
108
-						if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
111
+						if ($lat_even >= 270) {
112
+							$lat_even = $lat_even - 360;
113
+						}
114
+						if ($lat_odd >= 270) {
115
+							$lat_odd = $lat_odd - 360;
116
+						}
109 117
 						// check latitude zone
110 118
 						if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
111 119
 							if ($this::$latlon[$icao]['created'] > time()) {
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
 								$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
114 122
 								$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
115 123
 								$lat = $lat_even;
116
-								if ($lon > 180) $lon = $lon -360;
124
+								if ($lon > 180) {
125
+									$lon = $lon -360;
126
+								}
117 127
 								if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
118 128
 									//if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
119 129
 									$data['latitude'] = $lat;
@@ -124,14 +134,18 @@  discard block
 block discarded – undo
124 134
 								$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
125 135
 								$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
126 136
 								$lat = $lat_odd;
127
-								if ($lon > 180) $lon = $lon -360;
137
+								if ($lon > 180) {
138
+									$lon = $lon -360;
139
+								}
128 140
 								if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
129 141
 									//if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
130 142
 									$data['latitude'] = $lat;
131 143
 									$data['longitude'] = $lon;
132 144
 								}
133 145
 							}
134
-						} else echo "Not cprNL";
146
+						} else {
147
+							echo "Not cprNL";
148
+						}
135 149
 						unset($this::$latlon[$icao]);
136 150
 					}
137 151
 				} elseif ($tc == 19) {
@@ -140,11 +154,17 @@  discard block
 block discarded – undo
140 154
 					$v_ew = intval(substr($bin,46,10),2);
141 155
 					$v_ns_dir = intval(substr($bin,56,1));
142 156
 					$v_ns = intval(substr($bin,57,10),2);
143
-					if ($v_ew_dir) $v_ew = -1*$v_ew;
144
-					if ($v_ns_dir) $v_ns = -1*$v_ns;
157
+					if ($v_ew_dir) {
158
+						$v_ew = -1*$v_ew;
159
+					}
160
+					if ($v_ns_dir) {
161
+						$v_ns = -1*$v_ns;
162
+					}
145 163
 					$speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
146 164
 					$heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
147
-					if ($heading <0) $heading = $heading+360;
165
+					if ($heading <0) {
166
+						$heading = $heading+360;
167
+					}
148 168
 					$data['speed'] = $speed;
149 169
 					$data['heading'] = $heading;
150 170
 				}
@@ -159,72 +179,194 @@  discard block
 block discarded – undo
159 179
 	 * Lookup table to convert the latitude to index.
160 180
 	*/
161 181
 	private function cprNL($lat) {
162
-		if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
163
-		if ($lat < 10.47047130) return 59;
164
-		if ($lat < 14.82817437) return 58;
165
-		if ($lat < 18.18626357) return 57;
166
-		if ($lat < 21.02939493) return 56;
167
-		if ($lat < 23.54504487) return 55;
168
-		if ($lat < 25.82924707) return 54;
169
-		if ($lat < 27.93898710) return 53;
170
-		if ($lat < 29.91135686) return 52;
171
-		if ($lat < 31.77209708) return 51;
172
-		if ($lat < 33.53993436) return 50;
173
-		if ($lat < 35.22899598) return 49;
174
-		if ($lat < 36.85025108) return 48;
175
-		if ($lat < 38.41241892) return 47;
176
-		if ($lat < 39.92256684) return 46;
177
-		if ($lat < 41.38651832) return 45;
178
-		if ($lat < 42.80914012) return 44;
179
-		if ($lat < 44.19454951) return 43;
180
-		if ($lat < 45.54626723) return 42;
181
-		if ($lat < 46.86733252) return 41;
182
-		if ($lat < 48.16039128) return 40;
183
-		if ($lat < 49.42776439) return 39;
184
-		if ($lat < 50.67150166) return 38;
185
-		if ($lat < 51.89342469) return 37;
186
-		if ($lat < 53.09516153) return 36;
187
-		if ($lat < 54.27817472) return 35;
188
-		if ($lat < 55.44378444) return 34;
189
-		if ($lat < 56.59318756) return 33;
190
-		if ($lat < 57.72747354) return 32;
191
-		if ($lat < 58.84763776) return 31;
192
-		if ($lat < 59.95459277) return 30;
193
-		if ($lat < 61.04917774) return 29;
194
-		if ($lat < 62.13216659) return 28;
195
-		if ($lat < 63.20427479) return 27;
196
-		if ($lat < 64.26616523) return 26;
197
-		if ($lat < 65.31845310) return 25;
198
-		if ($lat < 66.36171008) return 24;
199
-		if ($lat < 67.39646774) return 23;
200
-		if ($lat < 68.42322022) return 22;
201
-		if ($lat < 69.44242631) return 21;
202
-		if ($lat < 70.45451075) return 20;
203
-		if ($lat < 71.45986473) return 19;
204
-		if ($lat < 72.45884545) return 18;
205
-		if ($lat < 73.45177442) return 17;
206
-		if ($lat < 74.43893416) return 16;
207
-		if ($lat < 75.42056257) return 15;
208
-		if ($lat < 76.39684391) return 14;
209
-		if ($lat < 77.36789461) return 13;
210
-		if ($lat < 78.33374083) return 12;
211
-		if ($lat < 79.29428225) return 11;
212
-		if ($lat < 80.24923213) return 10;
213
-		if ($lat < 81.19801349) return 9;
214
-		if ($lat < 82.13956981) return 8;
215
-		if ($lat < 83.07199445) return 7;
216
-		if ($lat < 83.99173563) return 6;
217
-		if ($lat < 84.89166191) return 5;
218
-		if ($lat < 85.75541621) return 4;
219
-		if ($lat < 86.53536998) return 3;
220
-		if ($lat < 87.00000000) return 2;
182
+		if ($lat < 0) {
183
+			$lat = -$lat;
184
+		}
185
+		// Table is simmetric about the equator.
186
+		if ($lat < 10.47047130) {
187
+			return 59;
188
+		}
189
+		if ($lat < 14.82817437) {
190
+			return 58;
191
+		}
192
+		if ($lat < 18.18626357) {
193
+			return 57;
194
+		}
195
+		if ($lat < 21.02939493) {
196
+			return 56;
197
+		}
198
+		if ($lat < 23.54504487) {
199
+			return 55;
200
+		}
201
+		if ($lat < 25.82924707) {
202
+			return 54;
203
+		}
204
+		if ($lat < 27.93898710) {
205
+			return 53;
206
+		}
207
+		if ($lat < 29.91135686) {
208
+			return 52;
209
+		}
210
+		if ($lat < 31.77209708) {
211
+			return 51;
212
+		}
213
+		if ($lat < 33.53993436) {
214
+			return 50;
215
+		}
216
+		if ($lat < 35.22899598) {
217
+			return 49;
218
+		}
219
+		if ($lat < 36.85025108) {
220
+			return 48;
221
+		}
222
+		if ($lat < 38.41241892) {
223
+			return 47;
224
+		}
225
+		if ($lat < 39.92256684) {
226
+			return 46;
227
+		}
228
+		if ($lat < 41.38651832) {
229
+			return 45;
230
+		}
231
+		if ($lat < 42.80914012) {
232
+			return 44;
233
+		}
234
+		if ($lat < 44.19454951) {
235
+			return 43;
236
+		}
237
+		if ($lat < 45.54626723) {
238
+			return 42;
239
+		}
240
+		if ($lat < 46.86733252) {
241
+			return 41;
242
+		}
243
+		if ($lat < 48.16039128) {
244
+			return 40;
245
+		}
246
+		if ($lat < 49.42776439) {
247
+			return 39;
248
+		}
249
+		if ($lat < 50.67150166) {
250
+			return 38;
251
+		}
252
+		if ($lat < 51.89342469) {
253
+			return 37;
254
+		}
255
+		if ($lat < 53.09516153) {
256
+			return 36;
257
+		}
258
+		if ($lat < 54.27817472) {
259
+			return 35;
260
+		}
261
+		if ($lat < 55.44378444) {
262
+			return 34;
263
+		}
264
+		if ($lat < 56.59318756) {
265
+			return 33;
266
+		}
267
+		if ($lat < 57.72747354) {
268
+			return 32;
269
+		}
270
+		if ($lat < 58.84763776) {
271
+			return 31;
272
+		}
273
+		if ($lat < 59.95459277) {
274
+			return 30;
275
+		}
276
+		if ($lat < 61.04917774) {
277
+			return 29;
278
+		}
279
+		if ($lat < 62.13216659) {
280
+			return 28;
281
+		}
282
+		if ($lat < 63.20427479) {
283
+			return 27;
284
+		}
285
+		if ($lat < 64.26616523) {
286
+			return 26;
287
+		}
288
+		if ($lat < 65.31845310) {
289
+			return 25;
290
+		}
291
+		if ($lat < 66.36171008) {
292
+			return 24;
293
+		}
294
+		if ($lat < 67.39646774) {
295
+			return 23;
296
+		}
297
+		if ($lat < 68.42322022) {
298
+			return 22;
299
+		}
300
+		if ($lat < 69.44242631) {
301
+			return 21;
302
+		}
303
+		if ($lat < 70.45451075) {
304
+			return 20;
305
+		}
306
+		if ($lat < 71.45986473) {
307
+			return 19;
308
+		}
309
+		if ($lat < 72.45884545) {
310
+			return 18;
311
+		}
312
+		if ($lat < 73.45177442) {
313
+			return 17;
314
+		}
315
+		if ($lat < 74.43893416) {
316
+			return 16;
317
+		}
318
+		if ($lat < 75.42056257) {
319
+			return 15;
320
+		}
321
+		if ($lat < 76.39684391) {
322
+			return 14;
323
+		}
324
+		if ($lat < 77.36789461) {
325
+			return 13;
326
+		}
327
+		if ($lat < 78.33374083) {
328
+			return 12;
329
+		}
330
+		if ($lat < 79.29428225) {
331
+			return 11;
332
+		}
333
+		if ($lat < 80.24923213) {
334
+			return 10;
335
+		}
336
+		if ($lat < 81.19801349) {
337
+			return 9;
338
+		}
339
+		if ($lat < 82.13956981) {
340
+			return 8;
341
+		}
342
+		if ($lat < 83.07199445) {
343
+			return 7;
344
+		}
345
+		if ($lat < 83.99173563) {
346
+			return 6;
347
+		}
348
+		if ($lat < 84.89166191) {
349
+			return 5;
350
+		}
351
+		if ($lat < 85.75541621) {
352
+			return 4;
353
+		}
354
+		if ($lat < 86.53536998) {
355
+			return 3;
356
+		}
357
+		if ($lat < 87.00000000) {
358
+			return 2;
359
+		}
221 360
 		return 1;
222 361
 	}
223 362
 
224 363
 	private function cprN($lat,$isodd) {
225 364
 		$nl = $this->cprNL($lat) - $isodd;
226
-		if ($nl > 1) return $nl;
227
-		else return 1;
365
+		if ($nl > 1) {
366
+			return $nl;
367
+		} else {
368
+			return 1;
369
+		}
228 370
 	}
229 371
 
230 372
 	private function parityCheck($msg, $bin) {
@@ -247,10 +389,13 @@  discard block
 block discarded – undo
247 389
 		$crc = 0;
248 390
 		$checksum = intval(substr($msg,22,6),16);
249 391
 		for ($j = 0; $j < strlen($bin); $j++) {
250
-			if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
392
+			if ($bin[$j]) {
393
+				$crc = $crc^intval($modes_checksum_table[$j],0);
394
+			}
251 395
 		}
252
-		if ($crc == $checksum) return true;
253
-		else {
396
+		if ($crc == $checksum) {
397
+			return true;
398
+		} else {
254 399
 			//echo "**** CRC ERROR ****\n";
255 400
 			return false;
256 401
 		}
@@ -300,22 +445,37 @@  discard block
 block discarded – undo
300 445
 			$msg['date_log'] = date('Y/m/d',$data['timestamp']);
301 446
 			$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
302 447
 			$msg['callsign'] = '';
303
-			if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
304
-			else $msg['altitude'] = '';
448
+			if (isset($data['altitude'])) {
449
+				$msg['altitude'] = $data['altitude'];
450
+			} else {
451
+				$msg['altitude'] = '';
452
+			}
305 453
 			$msg['speed'] = $data['speed'];
306
-			if (isset($data['heading'])) $msg['track'] = $data['heading'];
307
-			else $msg['track'] = '';
454
+			if (isset($data['heading'])) {
455
+				$msg['track'] = $data['heading'];
456
+			} else {
457
+				$msg['track'] = '';
458
+			}
308 459
 			$msg['latitude'] = $data['latitude'];
309 460
 			$msg['longitude'] = $data['longitude'];
310
-			if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate'];
311
-			else $msg['verticalrate'] = '';
312
-			if (isset($data['squawk'])) $msg['squawk'] = $data['squawk'];
313
-			else $msg['squawk'] = 0;
461
+			if (isset($data['verticalrate'])) {
462
+				$msg['verticalrate'] = $data['verticalrate'];
463
+			} else {
464
+				$msg['verticalrate'] = '';
465
+			}
466
+			if (isset($data['squawk'])) {
467
+				$msg['squawk'] = $data['squawk'];
468
+			} else {
469
+				$msg['squawk'] = 0;
470
+			}
314 471
 			$msg['alert'] = 0;
315 472
 			$msg['emergency'] = 0;
316 473
 			$msg['SPI'] = 0;
317
-			if (isset($data['ground'])) $msg['ground'] = 1;
318
-			else $msg['ground'] = 0;
474
+			if (isset($data['ground'])) {
475
+				$msg['ground'] = 1;
476
+			} else {
477
+				$msg['ground'] = 0;
478
+			}
319 479
 			$result[] = implode(',',$msg);
320 480
 		}
321 481
 		return $result;
Please login to merge, or discard this patch.
require/class.Weather.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,12 +63,16 @@  discard block
 block discarded – undo
63 63
 	
64 64
 	public function openweathermap($latitude,$longitude) {
65 65
 		global $globalOpenWeatherMapKey;
66
-		if ($globalOpenWeatherMapKey == '') return array();
66
+		if ($globalOpenWeatherMapKey == '') {
67
+			return array();
68
+		}
67 69
 		$Common = new Common();
68 70
 		$url = 'http://api.openweathermap.org/data/2.5/weather?lat='.$latitude.'&lon='.$longitude.'&units=metric&appid='.$globalOpenWeatherMapKey;
69 71
 		//echo $url."\n";
70 72
 		$weatherdata = json_decode($Common->getData($url),true);
71
-		if (!isset($weatherdata['main']['temp']) || !isset($weatherdata['weather'][0]['id'])) return array('clouds' => array(),'rain' => array());
73
+		if (!isset($weatherdata['main']['temp']) || !isset($weatherdata['weather'][0]['id'])) {
74
+			return array('clouds' => array(),'rain' => array());
75
+		}
72 76
 		$dew = $weatherdata['main']['temp'] - ((100-$weatherdata['main']['humidity'])/5);
73 77
 		$cumulus_base = 122.0 * ($weatherdata['main']['temp'] - $dew);
74 78
 		$stratus_base = 100.0 * (100.0 * $weatherdata['main']['humidity'])*0.3048;
@@ -104,7 +108,9 @@  discard block
 block discarded – undo
104 108
 	
105 109
 	public function nomad_wind($hour = '') {
106 110
 		global $globalWindsPath;
107
-		if ($hour == '') $hour = date('G');
111
+		if ($hour == '') {
112
+			$hour = date('G');
113
+		}
108 114
 		if (isset($globalWindsPath) && $globalWindsPath != '') {
109 115
 			$grib2json = $globalWindsPath['grib2json'];
110 116
 			$windpathsrc = $globalWindsPath['source'];
@@ -142,13 +148,17 @@  discard block
 block discarded – undo
142 148
 			system($grib2json.' --data --output '.$windpathdest.' --names --compact '.$windpathsrc);
143 149
 		} else {
144 150
 			// if not try previous run
145
-			if ($hour == date('G')) $this->nomad_wind(date('G')-6);
151
+			if ($hour == date('G')) {
152
+				$this->nomad_wind(date('G')-6);
153
+			}
146 154
 		}
147 155
 	}
148 156
 
149 157
 	public function oscar_wave() {
150 158
 		global $globalWavesPath, $globalPODACCuser,$globalPODACCpass;
151
-		if ($globalPODACCuser == '' && $globalPODACCpass == '') return;
159
+		if ($globalPODACCuser == '' && $globalPODACCpass == '') {
160
+			return;
161
+		}
152 162
 		if (isset($globalWavesPath) && $globalWavesPath != '') {
153 163
 			$grib2json = $globalWavesPath['grib2json'];
154 164
 			$wavepathsrc = $globalWavesPath['source'];
Please login to merge, or discard this patch.
require/class.Common.php 1 patch
Braces   +123 added lines, -53 removed lines patch added patch discarded remove patch
@@ -36,7 +36,9 @@  discard block
 block discarded – undo
36 36
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
37 37
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
38 38
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
39
-		if ($getheaders) curl_setopt($ch, CURLOPT_HEADER, 1); 
39
+		if ($getheaders) {
40
+			curl_setopt($ch, CURLOPT_HEADER, 1);
41
+		}
40 42
 		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
41 43
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
42 44
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
@@ -45,8 +47,11 @@  discard block
 block discarded – undo
45 47
 		} else {
46 48
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
47 49
 		}
48
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
49
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
50
+		if ($timeout == '') {
51
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
52
+		} else {
53
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
54
+		}
50 55
 		//curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
51 56
 		if ($type == 'post') {
52 57
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -59,7 +64,9 @@  discard block
 block discarded – undo
59 64
 			} else {
60 65
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
61 66
 			}
62
-		} elseif ($type != 'get' && $type != '') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
67
+		} elseif ($type != 'get' && $type != '') {
68
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
69
+		}
63 70
 		if ($headers != '') {
64 71
 			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
65 72
 		}
@@ -104,8 +111,9 @@  discard block
 block discarded – undo
104 111
 	private function curlResponseHeaderCallback($ch, $headerLine) {
105 112
 		global $curl_cookies;
106 113
 		$curl_cookies = array();
107
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
108
-			$curl_cookies[] = $cookie;
114
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
115
+					$curl_cookies[] = $cookie;
116
+		}
109 117
 		return strlen($headerLine); // Needed by curl
110 118
 	}
111 119
 
@@ -118,7 +126,9 @@  discard block
 block discarded – undo
118 126
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
119 127
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
120 128
 		curl_setopt($ch, CURLOPT_COOKIEFILE, '');
121
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
129
+		if ($referer != '') {
130
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
131
+		}
122 132
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
123 133
 			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
124 134
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@@ -133,7 +143,9 @@  discard block
 block discarded – undo
133 143
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
134 144
 		curl_setopt($ch, CURLOPT_FILE, $fp);
135 145
 		curl_exec($ch);
136
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
146
+		if (curl_errno($ch) && $globalDebug) {
147
+			echo 'Download error: '.curl_error($ch);
148
+		}
137 149
 		curl_close($ch);
138 150
 		fclose($fp);
139 151
 	}
@@ -141,12 +153,16 @@  discard block
 block discarded – undo
141 153
 	public static function gunzip($in_file,$out_file_name = '') {
142 154
 		//echo $in_file.' -> '.$out_file_name."\n";
143 155
 		$buffer_size = 4096; // read 4kb at a time
144
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
156
+		if ($out_file_name == '') {
157
+			$out_file_name = str_replace('.gz', '', $in_file);
158
+		}
145 159
 		if ($in_file != '' && file_exists($in_file)) {
146 160
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
147
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
148
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
149
-			else {
161
+			if (function_exists('gzopen')) {
162
+				$file = gzopen($in_file,'rb');
163
+			} elseif (function_exists('gzopen64')) {
164
+				$file = gzopen64($in_file,'rb');
165
+			} else {
150 166
 				echo 'gzopen not available';
151 167
 				die;
152 168
 			}
@@ -162,11 +178,14 @@  discard block
 block discarded – undo
162 178
 	public static function bunzip2($in_file,$out_file_name = '') {
163 179
 		//echo $in_file.' -> '.$out_file_name."\n";
164 180
 		$buffer_size = 4096; // read 4kb at a time
165
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
181
+		if ($out_file_name == '') {
182
+			$out_file_name = str_replace('.bz2', '', $in_file);
183
+		}
166 184
 		if ($in_file != '' && file_exists($in_file)) {
167 185
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
168
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
169
-			else {
186
+			if (function_exists('bzopen')) {
187
+				$file = bzopen($in_file,'rb');
188
+			} else {
170 189
 				echo 'bzopen not available';
171 190
 				die;
172 191
 			}
@@ -185,10 +204,16 @@  discard block
 block discarded – undo
185 204
 	* @return array array of the tables in HTML page
186 205
 	*/
187 206
 	public function table2array($data) {
188
-		if (!is_string($data)) return array();
189
-		if ($data == '') return array();
207
+		if (!is_string($data)) {
208
+			return array();
209
+		}
210
+		if ($data == '') {
211
+			return array();
212
+		}
190 213
 		$html = str_get_html($data);
191
-		if ($html === false) return array();
214
+		if ($html === false) {
215
+			return array();
216
+		}
192 217
 		$tabledata=array();
193 218
 		foreach($html->find('tr') as $element)
194 219
 		{
@@ -223,7 +248,9 @@  discard block
 block discarded – undo
223 248
 	*/
224 249
 	public function text2array($data) {
225 250
 		$html = str_get_html($data);
226
-		if ($html === false) return array();
251
+		if ($html === false) {
252
+			return array();
253
+		}
227 254
 		$tabledata=array();
228 255
 		foreach($html->find('p') as $element)
229 256
 		{
@@ -244,7 +271,9 @@  discard block
 block discarded – undo
244 271
 	* @return Float Distance in $unit
245 272
 	*/
246 273
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
247
-		if ($lat == $latc && $lon == $lonc) return 0;
274
+		if ($lat == $latc && $lon == $lonc) {
275
+			return 0;
276
+		}
248 277
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
249 278
 		if ($unit == "km") {
250 279
 			return round($dist * 1.609344);
@@ -290,7 +319,9 @@  discard block
 block discarded – undo
290 319
 		$dX = $latc - $lat;
291 320
 		$dY = $lonc - $lon;
292 321
 		$azimuth = rad2deg(atan2($dY,$dX));
293
-		if ($azimuth < 0) return $azimuth+360;
322
+		if ($azimuth < 0) {
323
+			return $azimuth+360;
324
+		}
294 325
 		return $azimuth;
295 326
 	}
296 327
 	
@@ -304,10 +335,16 @@  discard block
 block discarded – undo
304 335
 	public function withinThreshold ($timeDifference, $distance) {
305 336
 		$x = abs($timeDifference);
306 337
 		$d = abs($distance);
307
-		if ($x == 0 || $d == 0) return true;
338
+		if ($x == 0 || $d == 0) {
339
+			return true;
340
+		}
308 341
 		// may be due to Internet jitter; distance is realistic
309
-		if ($x < 0.7 && $d < 2000) return true;
310
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
342
+		if ($x < 0.7 && $d < 2000) {
343
+			return true;
344
+		} else {
345
+			return $d/$x < 1500*0.27778;
346
+		}
347
+		// 1500 km/h max
311 348
 	}
312 349
 
313 350
 
@@ -359,11 +396,17 @@  discard block
 block discarded – undo
359 396
 	
360 397
 	public function convertDM($coord,$latlong) {
361 398
 		if ($latlong == 'latitude') {
362
-			if ($coord < 0) $NSEW = 'S';
363
-			else $NSEW = 'N';
399
+			if ($coord < 0) {
400
+				$NSEW = 'S';
401
+			} else {
402
+				$NSEW = 'N';
403
+			}
364 404
 		} else {
365
-			if ($coord < 0) $NSEW = 'W';
366
-			else $NSEW = 'E';
405
+			if ($coord < 0) {
406
+				$NSEW = 'W';
407
+			} else {
408
+				$NSEW = 'E';
409
+			}
367 410
 		}
368 411
 		$coord = abs($coord);
369 412
 		$deg = floor($coord);
@@ -373,11 +416,17 @@  discard block
 block discarded – undo
373 416
 	}
374 417
 	public function convertDMS($coord,$latlong) {
375 418
 		if ($latlong == 'latitude') {
376
-			if ($coord < 0) $NSEW = 'S';
377
-			else $NSEW = 'N';
419
+			if ($coord < 0) {
420
+				$NSEW = 'S';
421
+			} else {
422
+				$NSEW = 'N';
423
+			}
378 424
 		} else {
379
-			if ($coord < 0) $NSEW = 'W';
380
-			else $NSEW = 'E';
425
+			if ($coord < 0) {
426
+				$NSEW = 'W';
427
+			} else {
428
+				$NSEW = 'E';
429
+			}
381 430
 		}
382 431
 		$coord = abs($coord);
383 432
 		$deg = floor($coord);
@@ -421,7 +470,9 @@  discard block
 block discarded – undo
421 470
 	public function hex2str($hex) {
422 471
 		$str = '';
423 472
 		$hexln = strlen($hex);
424
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
473
+		for($i=0;$i<$hexln;$i+=2) {
474
+			$str .= chr(hexdec(substr($hex,$i,2)));
475
+		}
425 476
 		return $str;
426 477
 	}
427 478
 	
@@ -458,8 +509,11 @@  discard block
 block discarded – undo
458 509
 		$b = $lat2 - $lat1;
459 510
 		$c = -($a*$lat1+$b*$lon1);
460 511
 		$d = $a*$lat3+$b*$lon3+$c;
461
-		if ($d > -$approx && $d < $approx) return true;
462
-		else return false;
512
+		if ($d > -$approx && $d < $approx) {
513
+			return true;
514
+		} else {
515
+			return false;
516
+		}
463 517
 	}
464 518
 	
465 519
 	public function array_merge_noappend() {
@@ -518,7 +572,9 @@  discard block
 block discarded – undo
518 572
 			return $result;
519 573
 		}
520 574
 		$handle = @opendir('./locale');
521
-		if ($handle === false) return $result;
575
+		if ($handle === false) {
576
+			return $result;
577
+		}
522 578
 		while (false !== ($file = readdir($handle))) {
523 579
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
524 580
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -589,8 +645,9 @@  discard block
 block discarded – undo
589 645
 		$error = false; 
590 646
 		if ($fp_out = gzopen($dest, $mode)) { 
591 647
 			if ($fp_in = fopen($source,'rb')) { 
592
-				while (!feof($fp_in)) 
593
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
648
+				while (!feof($fp_in)) {
649
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
650
+				}
594 651
 				fclose($fp_in); 
595 652
 			} else {
596 653
 				$error = true; 
@@ -599,14 +656,17 @@  discard block
 block discarded – undo
599 656
 		} else {
600 657
 			$error = true; 
601 658
 		}
602
-		if ($error)
603
-			return false; 
604
-		else
605
-			return $dest; 
659
+		if ($error) {
660
+					return false;
661
+		} else {
662
+					return $dest;
663
+		}
606 664
 	} 
607 665
 	
608 666
 	public function remove_accents($string) {
609
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
667
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
668
+			return $string;
669
+		}
610 670
 		$chars = array(
611 671
 		    // Decompositions for Latin-1 Supplement
612 672
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -730,7 +790,9 @@  discard block
 block discarded – undo
730 790
 		$ip = gethostbyname($host);
731 791
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
732 792
 		$r = @socket_connect($s, $ip, $port);
733
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
793
+		if (!socket_set_nonblock($s)) {
794
+			echo "Unable to set nonblock on socket\n";
795
+		}
734 796
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
735 797
 			return $s;
736 798
 		}
@@ -775,18 +837,22 @@  discard block
 block discarded – undo
775 837
 		//NOTE: use a trailing slash for folders!!!
776 838
 		//see http://bugs.php.net/bug.php?id=27609
777 839
 		//see http://bugs.php.net/bug.php?id=30931
778
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
840
+		if ($path{strlen($path)-1}=='/') {
841
+			// recursively return a temporary file path
779 842
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
780
-		else if (is_dir($path))
781
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
843
+		} else if (is_dir($path)) {
844
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
845
+		}
782 846
 		// check tmp file for read/write capabilities
783 847
 		$rm = file_exists($path);
784 848
 		$f = @fopen($path, 'a');
785
-		if ($f===false)
786
-			return false;
849
+		if ($f===false) {
850
+					return false;
851
+		}
787 852
 		fclose($f);
788
-		if (!$rm)
789
-			unlink($path);
853
+		if (!$rm) {
854
+					unlink($path);
855
+		}
790 856
 		return true;
791 857
 	}
792 858
 	
@@ -802,7 +868,9 @@  discard block
 block discarded – undo
802 868
 	 * @return Array Coordinate of the route
803 869
 	*/
804 870
 	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
805
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
871
+		if ($nbpts <= 2) {
872
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
873
+		}
806 874
 		$sx = deg2rad($begin_lon);
807 875
 		$sy = deg2rad($begin_lat);
808 876
 		$ex = deg2rad($end_lon);
@@ -811,7 +879,9 @@  discard block
 block discarded – undo
811 879
 		$h = $sy - $ey;
812 880
 		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
813 881
 		$g = 2.0*asin(sqrt($z));
814
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
882
+		if ($g == M_PI || is_nan($g)) {
883
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
884
+		}
815 885
 		$first_pass = array();
816 886
 		$delta = 1.0/($nbpts-1);
817 887
 		for ($i =0; $i < $nbpts; ++$i) {
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +667 added lines, -177 removed lines patch added patch discarded remove patch
@@ -4,12 +4,22 @@  discard block
 block discarded – undo
4 4
 if (isset($_SESSION['error'])) {
5 5
 	header('Content-Encoding: none;');
6 6
 	echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.';
7
-	if (isset($_SESSION['error'])) unset($_SESSION['error']);
8
-	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
9
-	if (isset($_SESSION['next'])) unset($_SESSION['next']);
10
-	if (isset($_SESSION['install'])) unset($_SESSION['install']);
11
-	if (isset($_SESSION['identitied'])) unset($_SESSION['identified']);
12
-}
7
+	if (isset($_SESSION['error'])) {
8
+		unset($_SESSION['error']);
9
+	}
10
+	if (isset($_SESSION['errorlst'])) {
11
+		unset($_SESSION['errorlst']);
12
+	}
13
+	if (isset($_SESSION['next'])) {
14
+		unset($_SESSION['next']);
15
+	}
16
+	if (isset($_SESSION['install'])) {
17
+		unset($_SESSION['install']);
18
+	}
19
+	if (isset($_SESSION['identitied'])) {
20
+		unset($_SESSION['identified']);
21
+	}
22
+	}
13 23
 /*
14 24
 if (isset($_SESSION['errorlst'])) {
15 25
 	header('Content-Encoding: none;');
@@ -131,7 +141,9 @@  discard block
 block discarded – undo
131 141
 		if (count($alllng) != count($availablelng)) {
132 142
 			$notavailable = array();
133 143
 			foreach($alllng as $lng) {
134
-				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
144
+				if (!isset($availablelng[$lng])) {
145
+					$notavailable[] = $lng;
146
+				}
135 147
 			}
136 148
 			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
137 149
 		}
@@ -170,7 +182,10 @@  discard block
 block discarded – undo
170 182
 			<legend>Install script configuration</legend>
171 183
 			<p>
172 184
 				<label for="installpass">Install password</label>
173
-				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" />
185
+				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) {
186
+	print $globalInstallPassword;
187
+}
188
+?>" />
174 189
 			</p>
175 190
 			<p class="help-block">Password needed to access this install script. If empty, to access this script,  you will need to change the $globalInstalled setting in require/settings.php to FALSE</p>
176 191
 		</fieldset>
@@ -200,31 +215,49 @@  discard block
 block discarded – undo
200 215
 			</div>
201 216
 			<p>
202 217
 				<label for="dbhost">Database hostname</label>
203
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
218
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
219
+	print $globalDBhost;
220
+}
221
+?>" />
204 222
 			</p>
205 223
 			<p>
206 224
 				<label for="dbport">Database port</label>
207
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
225
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
226
+	print $globalDBport;
227
+}
228
+?>" />
208 229
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
209 230
 			</p>
210 231
 			<p>
211 232
 				<label for="dbname">Database name</label>
212
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
233
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
234
+	print $globalDBname;
235
+}
236
+?>" />
213 237
 			</p>
214 238
 			<p>
215 239
 				<label for="dbuser">Database user</label>
216
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
240
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
241
+	print $globalDBuser;
242
+}
243
+?>" />
217 244
 			</p>
218 245
 			<p>
219 246
 				<label for="dbuserpass">Database user password</label>
220
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
247
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
248
+	print $globalDBpass;
249
+}
250
+?>" />
221 251
 			</p>
222 252
 		</fieldset>
223 253
 		<fieldset id="site">
224 254
 			<legend>Site configuration</legend>
225 255
 			<p>
226 256
 				<label for="sitename">Site name</label>
227
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
257
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
258
+	print $globalName;
259
+}
260
+?>" />
228 261
 			</p>
229 262
 			<p>
230 263
 				<label for="siteurl">Site directory</label>
@@ -237,18 +270,27 @@  discard block
 block discarded – undo
237 270
 					}
238 271
 				    }
239 272
 				?>
240
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
273
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
274
+	print $globalURL;
275
+}
276
+?>" />
241 277
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
242 278
 				<p class="help-block">Can be empty</p>
243 279
 			</p>
244 280
 			<p>
245 281
 				<label for="timezone">Timezone</label>
246
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
282
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
283
+	print $globalTimezone;
284
+}
285
+?>" />
247 286
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
248 287
 			</p>
249 288
 			<p>
250 289
 				<label for="language">Language</label>
251
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
290
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
291
+	print $globalLanguage;
292
+}
293
+?>" />
252 294
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
253 295
 			</p>
254 296
 		</fieldset>
@@ -268,11 +310,17 @@  discard block
 block discarded – undo
268 310
 			<div id="mapbox_data">
269 311
 				<p>
270 312
 					<label for="mapboxid">Mapbox id</label>
271
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
313
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
314
+	print $globalMapboxId;
315
+}
316
+?>" />
272 317
 				</p>
273 318
 				<p>
274 319
 					<label for="mapboxtoken">Mapbox token</label>
275
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
320
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
321
+	print $globalMapboxToken;
322
+}
323
+?>" />
276 324
 				</p>
277 325
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
278 326
 			</div>
@@ -280,7 +328,10 @@  discard block
 block discarded – undo
280 328
 			<div id="google_data">
281 329
 				<p>
282 330
 					<label for="googlekey">Google API key</label>
283
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
331
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
332
+	print $globalGoogleAPIKey;
333
+}
334
+?>" />
284 335
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
285 336
 				</p>
286 337
 			</div>
@@ -288,7 +339,10 @@  discard block
 block discarded – undo
288 339
 			<div id="bing_data">
289 340
 				<p>
290 341
 					<label for="bingkey">Bing Map key</label>
291
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
342
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
343
+	print $globalBingMapKey;
344
+}
345
+?>" />
292 346
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
293 347
 				</p>
294 348
 			</div>
@@ -296,7 +350,10 @@  discard block
 block discarded – undo
296 350
 			<div id="mapquest_data">
297 351
 				<p>
298 352
 					<label for="mapquestkey">MapQuest key</label>
299
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
353
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
354
+	print $globalMapQuestKey;
355
+}
356
+?>" />
300 357
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
301 358
 				</p>
302 359
 			</div>
@@ -304,11 +361,17 @@  discard block
 block discarded – undo
304 361
 			<div id="here_data">
305 362
 				<p>
306 363
 					<label for="hereappid">Here App_Id</label>
307
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
364
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
365
+	print $globalHereappId;
366
+}
367
+?>" />
308 368
 				</p>
309 369
 				<p>
310 370
 					<label for="hereappcode">Here App_Code</label>
311
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
371
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
372
+	print $globalHereappCode;
373
+}
374
+?>" />
312 375
 				</p>
313 376
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
314 377
 			</div>
@@ -316,7 +379,10 @@  discard block
 block discarded – undo
316 379
 			<div id="openweathermap_data">
317 380
 				<p>
318 381
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
319
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
382
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
383
+	print $globalOpenWeatherMapKey;
384
+}
385
+?>" />
320 386
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
321 387
 				</p>
322 388
 			</div>
@@ -345,42 +411,86 @@  discard block
 block discarded – undo
345 411
 			<legend>Coverage area</legend>
346 412
 			<p>
347 413
 				<label for="latitudemax">The maximum latitude (north)</label>
348
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
414
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
415
+	print $globalLatitudeMax;
416
+}
417
+?>" />
349 418
 			</p>
350 419
 			<p>
351 420
 				<label for="latitudemin">The minimum latitude (south)</label>
352
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
421
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
422
+	print $globalLatitudeMin;
423
+}
424
+?>" />
353 425
 			</p>
354 426
 			<p>
355 427
 				<label for="longitudemax">The maximum longitude (west)</label>
356
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
428
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
429
+	print $globalLongitudeMax;
430
+}
431
+?>" />
357 432
 			</p>
358 433
 			<p>
359 434
 				<label for="longitudemin">The minimum longitude (east)</label>
360
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
435
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
436
+	print $globalLongitudeMin;
437
+}
438
+?>" />
361 439
 			</p>
362 440
 			<p>
363 441
 				<label for="latitudecenter">The latitude center</label>
364
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
442
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
443
+	print $globalCenterLatitude;
444
+}
445
+?>" />
365 446
 			</p>
366 447
 			<p>
367 448
 				<label for="longitudecenter">The longitude center</label>
368
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
449
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
450
+	print $globalCenterLongitude;
451
+}
452
+?>" />
369 453
 			</p>
370 454
 			<p>
371 455
 				<label for="livezoom">Default Zoom on live map</label>
372
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
456
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
457
+	print $globalLiveZoom;
458
+} else {
459
+	print '9';
460
+}
461
+?>" />
373 462
 			</p>
374 463
 			<p>
375 464
 				<label for="squawk_country">Country for squawk usage</label>
376 465
 				<select name="squawk_country" id="squawk_country">
377
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
378
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
379
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
380
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
381
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
382
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
383
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
466
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
467
+	print ' selected ';
468
+}
469
+?>>UK</option>
470
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
471
+	print ' selected ';
472
+}
473
+?>>NZ</option>
474
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
475
+	print ' selected ';
476
+}
477
+?>>US</option>
478
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
479
+	print ' selected ';
480
+}
481
+?>>AU</option>
482
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
483
+	print ' selected ';
484
+}
485
+?>>NL</option>
486
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
487
+	print ' selected ';
488
+}
489
+?>>FR</option>
490
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
491
+	print ' selected ';
492
+}
493
+?>>TR</option>
384 494
 				</select>
385 495
 			</p>
386 496
 		</fieldset>
@@ -389,15 +499,24 @@  discard block
 block discarded – undo
389 499
 			<p><i>Only put in DB flights that are inside a circle</i></p>
390 500
 			<p>
391 501
 				<label for="latitude">Center latitude</label>
392
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
502
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
503
+	echo $globalDistanceIgnore['latitude'];
504
+}
505
+?>" />
393 506
 			</p>
394 507
 			<p>
395 508
 				<label for="longitude">Center longitude</label>
396
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
509
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
510
+	echo $globalDistanceIgnore['longitude'];
511
+}
512
+?>" />
397 513
 			</p>
398 514
 			<p>
399 515
 				<label for="Distance">Distance (in km)</label>
400
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
516
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
517
+	echo $globalDistanceIgnore['distance'];
518
+}
519
+?>" />
401 520
 			</p>
402 521
 		</fieldset>
403 522
 		<fieldset id="sourceloc">
@@ -523,28 +642,43 @@  discard block
 block discarded – undo
523 642
 			<div id="flightaware_data">
524 643
 				<p>
525 644
 					<label for="flightawareusername">FlightAware username</label>
526
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
645
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
646
+	print $globalFlightAwareUsername;
647
+}
648
+?>" />
527 649
 				</p>
528 650
 				<p>
529 651
 					<label for="flightawarepassword">FlightAware password/API key</label>
530
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
652
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
653
+	print $globalFlightAwarePassword;
654
+}
655
+?>" />
531 656
 				</p>
532 657
 			</div>
533 658
 -->
534 659
 			<div id="sailaway_data">
535 660
 				<p>
536 661
 					<label for="sailawayemail">Sailaway email</label>
537
-					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" />
662
+					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) {
663
+	print $globalSailaway['email'];
664
+}
665
+?>" />
538 666
 					<p class="help-block">Only needed for Sailaway full format</p>
539 667
 				</p>
540 668
 				<p>
541 669
 					<label for="sailawaypassword">Sailaway password</label>
542
-					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" />
670
+					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) {
671
+	print $globalSailaway['password'];
672
+}
673
+?>" />
543 674
 					<p class="help-block">Only needed for Sailaway full format</p>
544 675
 				</p>
545 676
 				<p>
546 677
 					<label for="sailawaykey">Sailaway API key</label>
547
-					<input type="text" name="sailawaykey" id="sailawaykey" value="<?php if (isset($globalSailaway['key'])) print $globalSailaway['key']; ?>" />
678
+					<input type="text" name="sailawaykey" id="sailawaykey" value="<?php if (isset($globalSailaway['key'])) {
679
+	print $globalSailaway['key'];
680
+}
681
+?>" />
548 682
 				</p>
549 683
 			</div>
550 684
 
@@ -586,7 +720,10 @@  discard block
 block discarded – undo
586 720
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
587 721
 								?>
588 722
 								<td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td>
589
-								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
723
+								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) {
724
+	print $source['port'];
725
+}
726
+?>" /></td>
590 727
 								<?php
591 728
 								    } else {
592 729
 									$hostport = explode(':',$source['host']);
@@ -605,41 +742,134 @@  discard block
 block discarded – undo
605 742
 								?>
606 743
 								<td>
607 744
 									<select name="format[]">
608
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
609
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
610
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
611
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
612
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
613
-										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option>
614
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
615
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
616
-                                        <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') print 'selected'; ?>>Radarcape json</option>
617
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
618
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
619
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
620
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
621
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
622
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
623
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
624
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
625
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
626
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
627
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
628
-										<option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec</option>
629
-										<option value="acarsjsonudp" <?php if (isset($source['format']) && $source['format'] == 'acarsjsonudp') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec over UDP</option>
630
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
631
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
632
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
633
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
634
-										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option>
635
-										<option value="sailawayfull" <?php if (isset($source['format']) && $source['format'] == 'sailawayfull') print 'selected'; ?>>Sailaway with missions, races,...</option>
745
+										<option value="auto" <?php if (!isset($source['format'])) {
746
+	print 'selected';
747
+}
748
+?>>Auto</option>
749
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
750
+	print 'selected';
751
+}
752
+?>>SBS</option>
753
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
754
+	print 'selected';
755
+}
756
+?>>TSV</option>
757
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
758
+	print 'selected';
759
+}
760
+?>>Raw</option>
761
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
762
+	print 'selected';
763
+}
764
+?>>Dump1090 aircraft.json</option>
765
+										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') {
766
+	print 'selected';
767
+}
768
+?>>Planefinder client</option>
769
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
770
+	print 'selected';
771
+}
772
+?>>APRS</option>
773
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
774
+	print 'selected';
775
+}
776
+?>>Radarcape deltadb.txt</option>
777
+                                        <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') {
778
+	print 'selected';
779
+}
780
+?>>Radarcape json</option>
781
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
782
+	print 'selected';
783
+}
784
+?>>Vatsim</option>
785
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
786
+	print 'selected';
787
+}
788
+?>>Virtual Radar Server AircraftList.json</option>
789
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
790
+	print 'selected';
791
+}
792
+?>>Virtual Radar Server TCP</option>
793
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
794
+	print 'selected';
795
+}
796
+?>>phpVMS</option>
797
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
798
+	print 'selected';
799
+}
800
+?>>Virtual Airline Operations System (VAOS)</option>
801
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
802
+	print 'selected';
803
+}
804
+?>>Virtual Airlines Manager</option>
805
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
806
+	print 'selected';
807
+}
808
+?>>IVAO</option>
809
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
810
+	print 'selected';
811
+}
812
+?>>FlightGear Multiplayer</option>
813
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
814
+	print 'selected';
815
+}
816
+?>>FlightGear Singleplayer</option>
817
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
818
+	print 'selected';
819
+}
820
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
821
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
822
+	print 'selected';
823
+}
824
+?>>ACARS SBS-3 over TCP</option>
825
+										<option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') {
826
+	print 'selected';
827
+}
828
+?>>ACARS from acarsdec json and vdlm2dec</option>
829
+										<option value="acarsjsonudp" <?php if (isset($source['format']) && $source['format'] == 'acarsjsonudp') {
830
+	print 'selected';
831
+}
832
+?>>ACARS from acarsdec json and vdlm2dec over UDP</option>
833
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
834
+	print 'selected';
835
+}
836
+?>>NMEA AIS over TCP</option>
837
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
838
+	print 'selected';
839
+}
840
+?>>AirWhere website</option>
841
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
842
+	print 'selected';
843
+}
844
+?>>HidnSeek Callback</option>
845
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
846
+	print 'selected';
847
+}
848
+?>>Blitzortung</option>
849
+										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') {
850
+	print 'selected';
851
+}
852
+?>>Sailaway</option>
853
+										<option value="sailawayfull" <?php if (isset($source['format']) && $source['format'] == 'sailawayfull') {
854
+	print 'selected';
855
+}
856
+?>>Sailaway with missions, races,...</option>
636 857
 									</select>
637 858
 								</td>
638 859
 								<td>
639
-									<input type="text" name="name[]" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
860
+									<input type="text" name="name[]" value="<?php if (isset($source['name'])) {
861
+	print $source['name'];
862
+}
863
+?>" />
640 864
 								</td>
641
-								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
642
-								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
865
+								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
866
+	print 'checked';
867
+}
868
+?> /></td>
869
+								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
870
+	print 'checked';
871
+}
872
+?> /></td>
643 873
 								<td>
644 874
 									<select name="timezones[]">
645 875
 								<?php
@@ -649,7 +879,9 @@  discard block
 block discarded – undo
649 879
 											print '<option selected>'.$timezones.'</option>';
650 880
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
651 881
 											print '<option selected>'.$timezones.'</option>';
652
-										} else print '<option>'.$timezones.'</option>';
882
+										} else {
883
+											print '<option>'.$timezones.'</option>';
884
+										}
653 885
 									}
654 886
 								?>
655 887
 									</select>
@@ -707,7 +939,9 @@  discard block
 block discarded – undo
707 939
 									foreach($timezonelist as $timezones){
708 940
 										if ($timezones == 'UTC') {
709 941
 											print '<option selected>'.$timezones.'</option>';
710
-										} else print '<option>'.$timezones.'</option>';
942
+										} else {
943
+											print '<option>'.$timezones.'</option>';
944
+										}
711 945
 									}
712 946
 								?>
713 947
 									</select>
@@ -732,11 +966,17 @@  discard block
 block discarded – undo
732 966
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
733 967
 					<p>
734 968
 						<label for="acarshost">ACARS UDP host</label>
735
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
969
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
970
+	print $globalACARSHost;
971
+}
972
+?>" />
736 973
 					</p>
737 974
 					<p>
738 975
 						<label for="acarsport">ACARS UDP port</label>
739
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
976
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
977
+	print $globalACARSPort;
978
+}
979
+?>" />
740 980
 					</p>
741 981
 					<p class="help-block"><i>daemon-acars.php</i> can only be run as daemon. It's an alternate script for ACARS data, <i>daemon-spotter.php</i> may be better.</p>
742 982
 				</fieldset>
@@ -763,17 +1003,38 @@  discard block
 block discarded – undo
763 1003
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
764 1004
 				    <td>
765 1005
 					<select name="newslang[]">
766
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
767
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
1006
+					    <option value="en"<?php if ($lng == 'en') {
1007
+	print ' selected';
1008
+}
1009
+?>>English</option>
1010
+					    <option value="fr"<?php if ($lng == 'fr') {
1011
+	print ' selected';
1012
+}
1013
+?>>French</option>
768 1014
 					</select>
769 1015
 				    </td>
770 1016
 				    <td>
771 1017
 					<select name="newstype[]">
772
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
773
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
774
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
775
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
776
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
1018
+					    <option value="global"<?php if ($type == 'global') {
1019
+	print ' selected';
1020
+}
1021
+?>>Global</option>
1022
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
1023
+	print ' selected';
1024
+}
1025
+?>>Aircraft</option>
1026
+					    <option value="marine"<?php if ($type == 'marine') {
1027
+	print ' selected';
1028
+}
1029
+?>>Marine</option>
1030
+					    <option value="tracker"<?php if ($type == 'tracker') {
1031
+	print ' selected';
1032
+}
1033
+?>>Tracker</option>
1034
+					    <option value="satellite"<?php if ($type == 'Satellite') {
1035
+	print ' selected';
1036
+}
1037
+?>>Satellite</option>
777 1038
 					</select>
778 1039
 				    </td>
779 1040
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -857,7 +1118,10 @@  discard block
 block discarded – undo
857 1118
 			</p>
858 1119
 			<p>
859 1120
 				<label for="corsproxy">CORS proxy</label>
860
-				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
1121
+				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) {
1122
+	print $globalCORSproxy;
1123
+} else {
1124
+	print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
861 1125
 				<p class="help-block">CORS proxy used for some WMS servers</p>
862 1126
 			</p>
863 1127
 <!--
@@ -920,13 +1184,18 @@  discard block
 block discarded – undo
920 1184
 			<div id="schedules_options">
921 1185
 				<p>
922 1186
 					<label for="britishairways">British Airways API Key</label>
923
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1187
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey;
1188
+}
1189
+?>" />
924 1190
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
925 1191
 				</p>
926 1192
 				<!--
927 1193
 				<p>
928 1194
 					<label for="transavia">Transavia Test API Consumer Key</label>
929
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1195
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1196
+	print $globalTransaviaKey;
1197
+}
1198
+?>" />
930 1199
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
931 1200
 				</p>
932 1201
 				-->
@@ -935,10 +1204,16 @@  discard block
 block discarded – undo
935 1204
 						<b>Lufthansa API Key</b>
936 1205
 						<p>
937 1206
 							<label for="lufthansakey">Key</label>
938
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1207
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1208
+	print $globalLufthansaKey['key'];
1209
+}
1210
+?>" />
939 1211
 						</p><p>
940 1212
 							<label for="lufthansasecret">Secret</label>
941
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1213
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1214
+	print $globalLufthansaKey['secret'];
1215
+}
1216
+?>" />
942 1217
 						</p>
943 1218
 					</div>
944 1219
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -948,11 +1223,17 @@  discard block
 block discarded – undo
948 1223
 						<b>FlightAware API Key</b>
949 1224
 						<p>
950 1225
 							<label for="flightawareusername">Username</label>
951
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1226
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1227
+	print $globalFlightAwareUsername;
1228
+}
1229
+?>" />
952 1230
 						</p>
953 1231
 						<p>
954 1232
 							<label for="flightawarepassword">API key</label>
955
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1233
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1234
+	print $globalFlightAwarePassword;
1235
+}
1236
+?>" />
956 1237
 						</p>
957 1238
 					</div>
958 1239
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -969,10 +1250,22 @@  discard block
 block discarded – undo
969 1250
 				<p>
970 1251
 					<label for="mapmatchingsource">Map Matching source</label>
971 1252
 					<select name="mapmatchingsource" id="mapmatchingsource">
972
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
973
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
974
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
975
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1253
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1254
+	print 'selected="selected" ';
1255
+}
1256
+?>>FlightAirMap Map Matching</option>
1257
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1258
+	print 'selected="selected" ';
1259
+}
1260
+?>>GraphHopper</option>
1261
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1262
+	print 'selected="selected" ';
1263
+}
1264
+?>>OSMR</option>
1265
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1266
+	print 'selected="selected" ';
1267
+}
1268
+?>>Mapbox</option>
976 1269
 					</select>
977 1270
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
978 1271
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -980,7 +1273,10 @@  discard block
 block discarded – undo
980 1273
 				<br />
981 1274
 				<p>
982 1275
 					<label for="graphhopper">GraphHopper API Key</label>
983
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1276
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1277
+	print $globalGraphHopperKey;
1278
+}
1279
+?>" />
984 1280
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
985 1281
 				</p>
986 1282
 			</div>
@@ -998,7 +1294,10 @@  discard block
 block discarded – undo
998 1294
 			</p>
999 1295
 			<p>
1000 1296
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
1001
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1297
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1298
+	print $globalNOTAMSource;
1299
+}
1300
+?>" />
1002 1301
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
1003 1302
 			</p>
1004 1303
 			<br />
@@ -1014,7 +1313,10 @@  discard block
 block discarded – undo
1014 1313
 			<div id="metarsrc">
1015 1314
 				<p>
1016 1315
 					<label for="metarsource">URL of your METAR source</label>
1017
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1316
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1317
+	print $globalMETARurl;
1318
+}
1319
+?>" />
1018 1320
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
1019 1321
 				</p>
1020 1322
 			</div>
@@ -1023,11 +1325,17 @@  discard block
 block discarded – undo
1023 1325
 			<div id="podaac">
1024 1326
 				<p>
1025 1327
 					<label for="podaccuser">PO.DAAC username (used for waves)</label>
1026
-					<input type="text" name="podaccuser" id="podaccuser" value="<?php if (isset($globalPODAACuser)) print $globalPODAACuser; ?>" />
1328
+					<input type="text" name="podaccuser" id="podaccuser" value="<?php if (isset($globalPODAACuser)) {
1329
+	print $globalPODAACuser;
1330
+}
1331
+?>" />
1027 1332
 				</p>
1028 1333
 				<p>
1029 1334
 					<label for="podaccpass">PO.DAAC password</label>
1030
-					<input type="text" name="podaccpass" id="podaccpass" value="<?php if (isset($globalPODAACpass)) print $globalPODAACpass; ?>" />
1335
+					<input type="text" name="podaccpass" id="podaccpass" value="<?php if (isset($globalPODAACpass)) {
1336
+	print $globalPODAACpass;
1337
+}
1338
+?>" />
1031 1339
 				</p>
1032 1340
 				<p class="help-block">Register an account on <a href="https://podaac-tools.jpl.nasa.gov/drive/">https://podaac-tools.jpl.nasa.gov/drive/</a>, an encoded password is available on this page after registration (not the same as the one used for registration).</p>
1033 1341
 			</div>
@@ -1035,7 +1343,10 @@  discard block
 block discarded – undo
1035 1343
 			-->
1036 1344
 			<p>
1037 1345
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
1038
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1346
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1347
+	print $globalBitlyAccessToken;
1348
+}
1349
+?>" />
1039 1350
 			</p>
1040 1351
 			<br />
1041 1352
 			<p>
@@ -1051,11 +1362,26 @@  discard block
 block discarded – undo
1051 1362
 			<p>
1052 1363
 				<label for="geoid_source">Geoid Source</label>
1053 1364
 				<select name="geoid_source" id="geoid_source">
1054
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
1055
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
1056
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
1057
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
1058
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1365
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1366
+	print ' selected="selected"';
1367
+}
1368
+?>>EGM96 15' (2.1MB)</option>
1369
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1370
+	print ' selected="selected"';
1371
+}
1372
+?>>EGM96 5' (19MB)</option>
1373
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1374
+	print ' selected="selected"';
1375
+}
1376
+?>>EGM2008 5' (19MB)</option>
1377
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1378
+	print ' selected="selected"';
1379
+}
1380
+?>>EGM2008 2.5' (75MB)</option>
1381
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1382
+	print ' selected="selected"';
1383
+}
1384
+?>>EGM2008 1' (470MB)</option>
1059 1385
 				</select>
1060 1386
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
1061 1387
 			</p>
@@ -1077,7 +1403,12 @@  discard block
 block discarded – undo
1077 1403
 			</p>
1078 1404
 			<p>
1079 1405
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
1080
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1406
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1407
+	print $globalArchiveMonths;
1408
+} else {
1409
+	echo '1';
1410
+}
1411
+?>" />
1081 1412
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
1082 1413
 			</p>
1083 1414
 			<p>
@@ -1087,12 +1418,22 @@  discard block
 block discarded – undo
1087 1418
 			</p>
1088 1419
 			<p>
1089 1420
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
1090
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1421
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1422
+	print $globalArchiveKeepMonths;
1423
+} else {
1424
+	echo '1';
1425
+}
1426
+?>" />
1091 1427
 				<p class="help-block">0 to disable</p>
1092 1428
 			</p>
1093 1429
 			<p>
1094 1430
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
1095
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1431
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1432
+	print $globalArchiveKeepTrackMonths;
1433
+} else {
1434
+	echo '1';
1435
+}
1436
+?>" />
1096 1437
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
1097 1438
 			</p>
1098 1439
 			<br />
@@ -1102,7 +1443,12 @@  discard block
 block discarded – undo
1102 1443
 				<p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p>
1103 1444
 				<div id="cronends"> 
1104 1445
 					<label for="cronend">Run script for xx seconds</label>
1105
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1446
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1447
+	print $globalCronEnd;
1448
+} else {
1449
+	print '0';
1450
+}
1451
+?>" />
1106 1452
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
1107 1453
 				</div>
1108 1454
 			</p>
@@ -1161,20 +1507,40 @@  discard block
 block discarded – undo
1161 1507
 			<br />
1162 1508
 			<p>
1163 1509
 				<label for="refresh">Show flights detected since xxx seconds</label>
1164
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1510
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1511
+	echo $globalLiveInterval;
1512
+} else {
1513
+	echo '200';
1514
+}
1515
+?>" />
1165 1516
 			</p>
1166 1517
 			<p>
1167 1518
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1168
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1519
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1520
+	echo $globalMapRefresh;
1521
+} else {
1522
+	echo '30';
1523
+}
1524
+?>" />
1169 1525
 			</p>
1170 1526
 			<p>
1171 1527
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1172
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1528
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1529
+	echo $globalMapIdleTimeout;
1530
+} else {
1531
+	echo '30';
1532
+}
1533
+?>" />
1173 1534
 				<p class="help-block">0 to disable</p>
1174 1535
 			</p>
1175 1536
 			<p>
1176 1537
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1177
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1538
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1539
+	echo $globalMinFetch;
1540
+} else {
1541
+	echo '20';
1542
+}
1543
+?>" />
1178 1544
 			</p>
1179 1545
 			<p>
1180 1546
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1193,12 +1559,20 @@  discard block
 block discarded – undo
1193 1559
 			<br />
1194 1560
 			<p>
1195 1561
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1196
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1562
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1563
+	echo $globalClosestMinDist;
1564
+} else {
1565
+	echo '50';
1566
+}
1567
+?>" />
1197 1568
 			</p>
1198 1569
 			<br />
1199 1570
 			<p>
1200 1571
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1201
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1572
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1573
+	echo $globalAircraftSize;
1574
+}
1575
+?>" />
1202 1576
 			</p>
1203 1577
 			<br />
1204 1578
 			<p>
@@ -1217,22 +1591,42 @@  discard block
 block discarded – undo
1217 1591
 			<br />
1218 1592
 			<p>
1219 1593
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1220
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1594
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1595
+	echo $globalAircraftIconColor;
1596
+} else {
1597
+	echo '1a3151';
1598
+}
1599
+?>" />
1221 1600
 			</p>
1222 1601
 			<br />
1223 1602
 			<p>
1224 1603
 				<label for="marineiconcolor">Color of marine icon on map</label>
1225
-				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" />
1604
+				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) {
1605
+	echo $globalMarineIconColor;
1606
+} else {
1607
+	echo '43d1d8';
1608
+}
1609
+?>" />
1226 1610
 			</p>
1227 1611
 			<br />
1228 1612
 			<p>
1229 1613
 				<label for="trackericoncolor">Color of tracker icon on map</label>
1230
-				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" />
1614
+				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) {
1615
+	echo $globalTrackerIconColor;
1616
+} else {
1617
+	echo '1a3151';
1618
+}
1619
+?>" />
1231 1620
 			</p>
1232 1621
 			<br />
1233 1622
 			<p>
1234 1623
 				<label for="satelliteiconcolor">Color of satellite icon on map</label>
1235
-				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" />
1624
+				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) {
1625
+	echo $globalSatelliteIconColor;
1626
+} else {
1627
+	echo '1a3151';
1628
+}
1629
+?>" />
1236 1630
 			</p>
1237 1631
 			<?php
1238 1632
 				if (!is_writable('../cache')) {
@@ -1256,14 +1650,27 @@  discard block
 block discarded – undo
1256 1650
 			<p>
1257 1651
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1258 1652
 				<div class="range">
1259
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1260
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1653
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1654
+	echo $globalAirportZoom;
1655
+} else {
1656
+	echo '7';
1657
+}
1658
+?>" />
1659
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1660
+	echo $globalAirportZoom;
1661
+} else {
1662
+	echo '7';
1663
+}
1664
+?></output>
1261 1665
 				</div>
1262 1666
 			</p>
1263 1667
 			<br />
1264 1668
 			<p>
1265 1669
 				<label for="customcss">Custom CSS web path</label>
1266
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1670
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1671
+	echo $globalCustomCSS;
1672
+}
1673
+?>" />
1267 1674
 			</p>
1268 1675
 		</fieldset>
1269 1676
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1293,8 +1700,12 @@  discard block
 block discarded – undo
1293 1700
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1294 1701
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1295 1702
 
1296
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1297
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1703
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1704
+		$error .= 'Mysql driver for PDO must be loaded';
1705
+	}
1706
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1707
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1708
+	}
1298 1709
 	
1299 1710
 	$_SESSION['database_root'] = $dbroot;
1300 1711
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1373,15 +1784,23 @@  discard block
 block discarded – undo
1373 1784
 	$source_city = $_POST['source_city'];
1374 1785
 	$source_country = $_POST['source_country'];
1375 1786
 	$source_ref = $_POST['source_ref'];
1376
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1377
-	else $source_id = array();
1787
+	if (isset($source_id)) {
1788
+		$source_id = $_POST['source_id'];
1789
+	} else {
1790
+		$source_id = array();
1791
+	}
1378 1792
 	
1379 1793
 	$sources = array();
1380 1794
 	foreach ($source_name as $keys => $name) {
1381
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1382
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1795
+	    if (isset($source_id[$keys])) {
1796
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1797
+	    } else {
1798
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1799
+	    }
1800
+	}
1801
+	if (count($sources) > 0) {
1802
+		$_SESSION['sources'] = $sources;
1383 1803
 	}
1384
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1385 1804
 
1386 1805
 	$newsurl = $_POST['newsurl'];
1387 1806
 	$newslng = $_POST['newslang'];
@@ -1394,7 +1813,9 @@  discard block
 block discarded – undo
1394 1813
 		$lng = $newslng[$newskey];
1395 1814
 		if (isset($newsfeeds[$type][$lng])) {
1396 1815
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1397
-		} else $newsfeeds[$type][$lng] = array($url);
1816
+		} else {
1817
+			$newsfeeds[$type][$lng] = array($url);
1818
+		}
1398 1819
 	    }
1399 1820
 	}
1400 1821
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1419,17 +1840,29 @@  discard block
 block discarded – undo
1419 1840
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1420 1841
 
1421 1842
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1422
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1423
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1843
+	if ($globalaircraft == 'aircraft') {
1844
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1845
+	} else {
1846
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1847
+	}
1424 1848
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1425
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1426
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1849
+	if ($globaltracker == 'tracker') {
1850
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1851
+	} else {
1852
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1853
+	}
1427 1854
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1428
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1429
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1855
+	if ($globalmarine == 'marine') {
1856
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1857
+	} else {
1858
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1859
+	}
1430 1860
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1431
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1432
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1861
+	if ($globalsatellite == 'satellite') {
1862
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1863
+	} else {
1864
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1865
+	}
1433 1866
 
1434 1867
 /*	
1435 1868
 	$globalSBS1Hosts = array();
@@ -1451,23 +1884,37 @@  discard block
 block discarded – undo
1451 1884
 	$name = $_POST['name'];
1452 1885
 	$format = $_POST['format'];
1453 1886
 	$timezones = $_POST['timezones'];
1454
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1455
-	else $sourcestats = array();
1456
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1457
-	else $noarchive = array();
1887
+	if (isset($_POST['sourcestats'])) {
1888
+		$sourcestats = $_POST['sourcestats'];
1889
+	} else {
1890
+		$sourcestats = array();
1891
+	}
1892
+	if (isset($_POST['noarchive'])) {
1893
+		$noarchive = $_POST['noarchive'];
1894
+	} else {
1895
+		$noarchive = array();
1896
+	}
1458 1897
 	$gSources = array();
1459 1898
 	$forcepilots = false;
1460 1899
 	foreach ($host as $key => $h) {
1461
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1462
-		else $cov = 'FALSE';
1463
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1464
-		else $arch = 'FALSE';
1900
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1901
+			$cov = 'TRUE';
1902
+		} else {
1903
+			$cov = 'FALSE';
1904
+		}
1905
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1906
+			$arch = 'TRUE';
1907
+		} else {
1908
+			$arch = 'FALSE';
1909
+		}
1465 1910
 		if (strpos($format[$key],'_callback')) {
1466 1911
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1467 1912
 		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1468 1913
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1469 1914
 		}
1470
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1915
+		if ($format[$key] == 'airwhere') {
1916
+			$forcepilots = true;
1917
+		}
1471 1918
 	}
1472 1919
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1473 1920
 
@@ -1503,7 +1950,9 @@  discard block
 block discarded – undo
1503 1950
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1504 1951
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1505 1952
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1506
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1953
+	} else {
1954
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1955
+	}
1507 1956
 
1508 1957
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1509 1958
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1544,7 +1993,9 @@  discard block
 block discarded – undo
1544 1993
 
1545 1994
 	// Create in settings.php keys not yet configurable if not already here
1546 1995
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1547
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1996
+	if (!isset($globalDebug)) {
1997
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1998
+	}
1548 1999
 
1549 2000
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1550 2001
 	if ($resetyearstats == 'resetyearstats') {
@@ -1587,37 +2038,56 @@  discard block
 block discarded – undo
1587 2038
 	}
1588 2039
 */
1589 2040
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1590
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1591
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1592
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1593
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
2041
+	if ($globalsbs == 'sbs') {
2042
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
2043
+	} else {
2044
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
2045
+	}
2046
+	if ($globalaprs == 'aprs') {
2047
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
2048
+	} else {
2049
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
2050
+	}
1594 2051
 	$va = false;
1595 2052
 	if ($globalivao == 'ivao') {
1596 2053
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1597 2054
 		$va = true;
1598
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2055
+	} else {
2056
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2057
+	}
1599 2058
 	if ($globalvatsim == 'vatsim') {
1600 2059
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1601 2060
 		$va = true;
1602
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2061
+	} else {
2062
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2063
+	}
1603 2064
 	if ($globalphpvms == 'phpvms') {
1604 2065
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1605 2066
 		$va = true;
1606
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2067
+	} else {
2068
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2069
+	}
1607 2070
 	if ($globalvam == 'vam') {
1608 2071
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1609 2072
 		$va = true;
1610
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2073
+	} else {
2074
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2075
+	}
1611 2076
 	if ($va) {
1612 2077
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1613
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2078
+	} else {
2079
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2080
+	}
1614 2081
 	if ($globalva == 'va' || $va) {
1615 2082
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1616 2083
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1617 2084
 	} else {
1618 2085
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1619
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1620
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2086
+		if ($forcepilots) {
2087
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
2088
+		} else {
2089
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2090
+		}
1621 2091
 	}
1622 2092
 	if ($globalvm == 'vm') {
1623 2093
 		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
@@ -1877,7 +2347,9 @@  discard block
 block discarded – undo
1877 2347
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1878 2348
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1879 2349
 
1880
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2350
+	if (!isset($globalTransaction)) {
2351
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2352
+	}
1881 2353
 
1882 2354
 	// Set some defaults values...
1883 2355
 	if (!isset($globalAircraftImageSources)) {
@@ -1892,15 +2364,23 @@  discard block
 block discarded – undo
1892 2364
 
1893 2365
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1894 2366
 
1895
-	if ($error == '') settings::modify_settings($settings);
1896
-	if ($error == '') settings::comment_settings($settings_comment);
2367
+	if ($error == '') {
2368
+		settings::modify_settings($settings);
2369
+	}
2370
+	if ($error == '') {
2371
+		settings::comment_settings($settings_comment);
2372
+	}
1897 2373
 	if ($error != '') {
1898 2374
 		print '<div class="info column">'.$error.'</div>';
1899 2375
 		require('../footer.php');
1900 2376
 		exit;
1901 2377
 	} else {
1902
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1903
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2378
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2379
+			$_SESSION['waypoints'] = 1;
2380
+		}
2381
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2382
+			$_SESSION['owner'] = 1;
2383
+		}
1904 2384
 		if (isset($_POST['createdb'])) {
1905 2385
 			$_SESSION['install'] = 'database_create';
1906 2386
 		} else {
@@ -1937,10 +2417,18 @@  discard block
 block discarded – undo
1937 2417
 	$popw = false;
1938 2418
 	foreach ($_SESSION['done'] as $done) {
1939 2419
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1940
-	    if ($done == 'Create database') $pop = true;
1941
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1942
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1943
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2420
+	    if ($done == 'Create database') {
2421
+	    	$pop = true;
2422
+	    }
2423
+	    if ($_SESSION['install'] == 'database_create') {
2424
+	    	$pop = true;
2425
+	    }
2426
+	    if ($_SESSION['install'] == 'database_import') {
2427
+	    	$popi = true;
2428
+	    }
2429
+	    if ($_SESSION['install'] == 'waypoints') {
2430
+	    	$popw = true;
2431
+	    }
1944 2432
 	}
1945 2433
 	if ($pop) {
1946 2434
 	    sleep(5);
@@ -1951,7 +2439,9 @@  discard block
 block discarded – undo
1951 2439
 	} else if ($popw) {
1952 2440
 	    sleep(5);
1953 2441
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1954
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2442
+	} else {
2443
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2444
+	}
1955 2445
 	print '</div></ul>';
1956 2446
 	print '<div id="error"></div>';
1957 2447
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +1276 added lines, -430 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
26 28
 
27 29
 if ($globalInstalled === FALSE) {
28 30
     echo "This script MUST be run after install script. Use your web browser to run install/index.php";
@@ -68,66 +70,107 @@  discard block
 block discarded – undo
68 70
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 71
 if (isset($options['s'])) {
70 72
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
73
-} elseif (isset($options['source'])) {
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['s']);
77
+    }
78
+    } elseif (isset($options['source'])) {
74 79
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
77
-}
80
+    if (isset($options['format'])) {
81
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
82
+    } else {
83
+    	$globalSources[] = array('host' => $options['source']);
84
+    }
85
+    }
78 86
 if (isset($options['aprsserverhost'])) {
79 87
 	$globalServerAPRS = TRUE;
80 88
 	$globalServerAPRShost = $options['aprsserverhost'];
81 89
 }
82
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
83
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
84
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
85
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
90
+if (isset($options['aprsserverport'])) {
91
+	$globalServerAPRSport = $options['aprsserverport'];
92
+}
93
+if (isset($options['aprsserverssid'])) {
94
+	$globalServerAPRSssid = $options['aprsserverssid'];
95
+}
96
+if (isset($options['aprsserverpass'])) {
97
+	$globalServerAPRSpass = $options['aprsserverpass'];
98
+}
99
+if (isset($options['noaprsserver'])) {
100
+	$globalServerAPRS = FALSE;
101
+}
86 102
 if (isset($options['enable-aircraft'])) {
87
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
103
+	if ($globalDebug) {
104
+		echo 'Enable Aircraft mode'."\n";
105
+	}
88 106
 	$globalAircraft = TRUE; 
89 107
 }
90 108
 if (isset($options['disable-aircraft'])) {
91
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
109
+	if ($globalDebug) {
110
+		echo 'Disable Aircraft mode'."\n";
111
+	}
92 112
 	$globalAircraft = FALSE;
93 113
 }
94 114
 if (isset($options['enable-tracker'])) {
95
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
115
+	if ($globalDebug) {
116
+		echo 'Enable Tracker mode'."\n";
117
+	}
96 118
 	$globalTracker = TRUE; 
97 119
 }
98 120
 if (isset($options['disable-tracker'])) {
99
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
121
+	if ($globalDebug) {
122
+		echo 'Disable Tracker mode'."\n";
123
+	}
100 124
 	$globalTracker = FALSE;
101 125
 }
102 126
 if (isset($options['enable-marine'])) {
103
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
127
+	if ($globalDebug) {
128
+		echo 'Enable Marine mode'."\n";
129
+	}
104 130
 	$globalMarine = TRUE;
105 131
 }
106 132
 if (isset($options['disable-marine'])) {
107
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
133
+	if ($globalDebug) {
134
+		echo 'Disable Marine mode'."\n";
135
+	}
108 136
 	$globalMarine = FALSE;
109 137
 }
110
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
111
-if (isset($options['server'])) $globalServer = TRUE;
112
-if (isset($options['idsource'])) $id_source = $options['idsource'];
113
-else $id_source = 1;
138
+if (isset($options['nodaemon'])) {
139
+	$globalDaemon = FALSE;
140
+}
141
+if (isset($options['server'])) {
142
+	$globalServer = TRUE;
143
+}
144
+if (isset($options['idsource'])) {
145
+	$id_source = $options['idsource'];
146
+} else {
147
+	$id_source = 1;
148
+}
114 149
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
150
+    if ($globalDebug) {
151
+    	echo "Using Server Mode\n";
152
+    }
116 153
     $SI=new SpotterServer();
117 154
 /*
118 155
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 156
     $SI = new adsb2aprs();
120 157
     $SI->connect();
121 158
 */
122
-} else $SI=new SpotterImport($Connection->db);
159
+} else {
160
+	$SI=new SpotterImport($Connection->db);
161
+}
123 162
 
124
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
163
+if (isset($globalTracker) && $globalTracker) {
164
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
165
+}
125 166
 if (isset($globalMarine) && $globalMarine) {
126 167
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
127 168
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 169
 }
129 170
 
130
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
171
+if (isset($globalTracker) && $globalTracker) {
172
+	$TI = new TrackerImport($Connection->db);
173
+}
131 174
 if (isset($globalMarine) && $globalMarine) {
132 175
     $AIS = new AIS();
133 176
     $MI = new MarineImport($Connection->db);
@@ -152,7 +195,9 @@  discard block
 block discarded – undo
152 195
 }
153 196
 
154 197
 // let's try and connect
155
-if ($globalDebug) echo "Connecting...\n";
198
+if ($globalDebug) {
199
+	echo "Connecting...\n";
200
+}
156 201
 $use_aprs = false;
157 202
 $aprs_full = false;
158 203
 $reset = 0;
@@ -161,7 +206,9 @@  discard block
 block discarded – undo
161 206
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162 207
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163 208
     $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
209
+    if ($globalDebug) {
210
+    	echo 'Connect to all...'."\n";
211
+    }
165 212
     foreach ($hosts as $id => $value) {
166 213
 	$host = $value['host'];
167 214
 	$udp = false;
@@ -172,32 +219,44 @@  discard block
 block discarded – undo
172 219
         	//$formats[$id] = 'deltadbtxt';
173 220
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 221
         	//$last_exec['deltadbtxt'] = 0;
175
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to deltadb source (".$host.")...\n";
224
+        	}
176 225
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
177 226
         	//$formats[$id] = 'vatsimtxt';
178 227
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 228
         	//$last_exec['vatsimtxt'] = 0;
180
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
229
+        	if ($globalDebug) {
230
+        		echo "Connect to vatsim source (".$host.")...\n";
231
+        	}
181 232
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
182 233
         	//$formats[$id] = 'aircraftlistjson';
183 234
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 235
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
236
+        	if ($globalDebug) {
237
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
238
+        	}
186 239
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
187 240
         	//$formats[$id] = 'aircraftjson';
188 241
         	$globalSources[$id]['format'] = 'aircraftjson';
189 242
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
243
+        	if ($globalDebug) {
244
+        		echo "Connect to aircraft.json source (".$host.")...\n";
245
+        	}
191 246
     	    } else if (preg_match('/aircraft$/i',$host)) {
192 247
         	//$formats[$id] = 'planefinderclient';
193 248
         	$globalSources[$id]['format'] = 'planefinderclient';
194 249
         	//$last_exec['aircraftlistjson'] = 0;
195
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
250
+        	if ($globalDebug) {
251
+        		echo "Connect to planefinderclient source (".$host.")...\n";
252
+        	}
196 253
     	    } else if (preg_match('/opensky/i',$host)) {
197 254
         	//$formats[$id] = 'aircraftlistjson';
198 255
         	$globalSources[$id]['format'] = 'opensky';
199 256
         	//$last_exec['aircraftlistjson'] = 0;
200
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
257
+        	if ($globalDebug) {
258
+        		echo "Connect to opensky source (".$host.")...\n";
259
+        	}
201 260
     	    /*
202 261
     	    // Disabled for now, site change source format
203 262
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -214,7 +273,9 @@  discard block
 block discarded – undo
214 273
         	//$formats[$id] = 'planeupdatefaa';
215 274
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 275
         	//$last_exec['planeupdatefaa'] = 0;
217
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
276
+        	if ($globalDebug) {
277
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
278
+        	}
218 279
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219 280
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 281
         	    exit(0);
@@ -223,37 +284,53 @@  discard block
 block discarded – undo
223 284
         	//$formats[$id] = 'phpvmacars';
224 285
         	$globalSources[$id]['format'] = 'phpvmacars';
225 286
         	//$last_exec['phpvmacars'] = 0;
226
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
287
+        	if ($globalDebug) {
288
+        		echo "Connect to phpvmacars source (".$host.")...\n";
289
+        	}
227 290
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228 291
         	//$formats[$id] = 'phpvmacars';
229 292
         	$globalSources[$id]['format'] = 'vaos';
230 293
         	//$last_exec['phpvmacars'] = 0;
231
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
294
+        	if ($globalDebug) {
295
+        		echo "Connect to vaos source (".$host.")...\n";
296
+        	}
232 297
             } else if (preg_match('/VAM-json.php$/i',$host)) {
233 298
         	//$formats[$id] = 'phpvmacars';
234 299
         	$globalSources[$id]['format'] = 'vam';
235
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
300
+        	if ($globalDebug) {
301
+        		echo "Connect to Vam source (".$host.")...\n";
302
+        	}
236 303
             } else if (preg_match('/whazzup/i',$host)) {
237 304
         	//$formats[$id] = 'whazzup';
238 305
         	$globalSources[$id]['format'] = 'whazzup';
239 306
         	//$last_exec['whazzup'] = 0;
240
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
307
+        	if ($globalDebug) {
308
+        		echo "Connect to whazzup source (".$host.")...\n";
309
+        	}
241 310
             } else if (preg_match('/blitzortung/i',$host)) {
242 311
         	$globalSources[$id]['format'] = 'blitzortung';
243
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
312
+        	if ($globalDebug) {
313
+        		echo "Connect to blitzortung source (".$host.")...\n";
314
+        	}
244 315
             } else if (preg_match('/airwhere/i',$host)) {
245 316
         	$globalSources[$id]['format'] = 'airwhere';
246
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
317
+        	if ($globalDebug) {
318
+        		echo "Connect to airwhere source (".$host.")...\n";
319
+        	}
247 320
             } else if (preg_match('/recentpireps/i',$host)) {
248 321
         	//$formats[$id] = 'pirepsjson';
249 322
         	$globalSources[$id]['format'] = 'pirepsjson';
250 323
         	//$last_exec['pirepsjson'] = 0;
251
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
324
+        	if ($globalDebug) {
325
+        		echo "Connect to pirepsjson source (".$host.")...\n";
326
+        	}
252 327
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253 328
         	//$formats[$id] = 'fr24json';
254 329
         	$globalSources[$id]['format'] = 'fr24json';
255 330
         	//$last_exec['fr24json'] = 0;
256
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
331
+        	if ($globalDebug) {
332
+        		echo "Connect to fr24 source (".$host.")...\n";
333
+        	}
257 334
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258 335
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 336
         	    exit(0);
@@ -262,7 +339,9 @@  discard block
 block discarded – undo
262 339
         	//$formats[$id] = 'fr24json';
263 340
         	$globalSources[$id]['format'] = 'myshiptracking';
264 341
         	//$last_exec['fr24json'] = 0;
265
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
342
+        	if ($globalDebug) {
343
+        		echo "Connect to myshiptracking source (".$host.")...\n";
344
+        	}
266 345
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267 346
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268 347
         	    exit(0);
@@ -271,18 +350,28 @@  discard block
 block discarded – undo
271 350
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 351
         	//$formats[$id] = 'tsv';
273 352
         	$globalSources[$id]['format'] = 'tsv';
274
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
353
+        	if ($globalDebug) {
354
+        		echo "Connect to tsv source (".$host.")...\n";
355
+        	}
275 356
             }
276 357
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 358
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278 359
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
279 360
     		    if ($idf !== false) {
280 361
     			$httpfeeds[$id] = $idf;
281
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
-    		elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
362
+        		if ($globalDebug) {
363
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
364
+        		}
365
+    		    } elseif ($globalDebug) {
366
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
367
+    		    }
368
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
369
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
370
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') {
371
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
372
+    		} elseif ($globalDebug) {
373
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
374
+    		}
286 375
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287 376
 	    $hostport = explode(':',$host);
288 377
 	    if (isset($hostport[1])) {
@@ -323,20 +412,29 @@  discard block
 block discarded – undo
323 412
         		//$formats[$id] = 'beast';
324 413
         		$globalSources[$id]['format'] = 'beast';
325 414
 		    //} else $formats[$id] = 'sbs';
326
-		    } else $globalSources[$id]['format'] = 'sbs';
415
+		    } else {
416
+		    	$globalSources[$id]['format'] = 'sbs';
417
+		    }
327 418
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
328 419
 		}
329
-		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
-		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
420
+		if ($globalDebug && $udp) {
421
+			echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
422
+		} elseif ($globalDebug) {
423
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
424
+		}
331 425
             } else {
332
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
426
+		if ($globalDebug) {
427
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
428
+		}
333 429
 		sleep(10);
334 430
 		connect_all($hosts);
335 431
     	    }
336 432
         }
337 433
     }
338 434
 }
339
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
435
+if (!isset($globalMinFetch)) {
436
+	$globalMinFetch = 15;
437
+}
340 438
 
341 439
 // Initialize all
342 440
 $status = array();
@@ -345,13 +443,19 @@  discard block
 block discarded – undo
345 443
 $formats = array();
346 444
 $last_exec = array();
347 445
 $time = time();
348
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
349
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
350
-else $timeout = 20;
446
+if (isset($globalSourcesTimeout)) {
447
+	$timeout = $globalSourcesTimeOut;
448
+} else if (isset($globalSBS1TimeOut)) {
449
+	$timeout = $globalSBS1TimeOut;
450
+} else {
451
+	$timeout = 20;
452
+}
351 453
 $errno = '';
352 454
 $errstr='';
353 455
 
354
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
456
+if (!isset($globalDaemon)) {
457
+	$globalDaemon = TRUE;
458
+}
355 459
 /* Initiate connections to all the hosts simultaneously */
356 460
 //connect_all($hosts);
357 461
 //connect_all($globalSources);
@@ -380,7 +484,9 @@  discard block
 block discarded – undo
380 484
     if (isset($source['format']) && $source['format'] == 'aprs') {
381 485
 	$aprs_connect = 0;
382 486
 	$use_aprs = true;
383
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
487
+	if (isset($source['port']) && $source['port'] == '10152') {
488
+		$aprs_full = true;
489
+	}
384 490
 	break;
385 491
     }
386 492
 }
@@ -391,25 +497,46 @@  discard block
 block discarded – undo
391 497
 	$aprs_connect = 0;
392 498
 	$aprs_keep = 120;
393 499
 	$aprs_last_tx = time();
394
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
395
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
396
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
397
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
398
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
399
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
400
-	if ($aprs_full) $aprs_filter = '';
401
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
402
-	else $aprs_pass = '-1';
500
+	if (isset($globalAPRSversion)) {
501
+		$aprs_version = $globalAPRSversion;
502
+	} else {
503
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
504
+	}
505
+	if (isset($globalAPRSssid)) {
506
+		$aprs_ssid = $globalAPRSssid;
507
+	} else {
508
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
509
+	}
510
+	if (isset($globalAPRSfilter)) {
511
+		$aprs_filter = $globalAPRSfilter;
512
+	} else {
513
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
514
+	}
515
+	if ($aprs_full) {
516
+		$aprs_filter = '';
517
+	}
518
+	if (isset($globalAPRSpass)) {
519
+		$aprs_pass = $globalAPRSpass;
520
+	} else {
521
+		$aprs_pass = '-1';
522
+	}
403 523
 
404
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
405
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
406
-}
524
+	if ($aprs_filter != '') {
525
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
526
+	} else {
527
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
528
+	}
529
+	}
407 530
 
408 531
 // connected - lets do some work
409 532
 //if ($globalDebug) echo "Connected!\n";
410 533
 sleep(1);
411
-if ($globalDebug) echo "SCAN MODE \n\n";
412
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
534
+if ($globalDebug) {
535
+	echo "SCAN MODE \n\n";
536
+}
537
+if (!isset($globalCronEnd)) {
538
+	$globalCronEnd = 60;
539
+}
413 540
 $endtime = time()+$globalCronEnd;
414 541
 $i = 1;
415 542
 $tt = array();
@@ -423,22 +550,32 @@  discard block
 block discarded – undo
423 550
 
424 551
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
425 552
 while ($i > 0) {
426
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
553
+    if (function_exists('pcntl_fork')) {
554
+    	pcntl_signal_dispatch();
555
+    }
427 556
 
428
-    if (!$globalDaemon) $i = $endtime-time();
557
+    if (!$globalDaemon) {
558
+    	$i = $endtime-time();
559
+    }
429 560
     // Delete old ATC
430 561
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
431
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
562
+	if ($globalDebug) {
563
+		echo 'Delete old ATC...'."\n";
564
+	}
432 565
         $ATC->deleteOldATC();
433 566
     }
434 567
     
435 568
     if (count($last_exec) == count($globalSources)) {
436 569
 	$max = $globalMinFetch;
437 570
 	foreach ($last_exec as $last) {
438
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
571
+	    if ((time() - $last['last']) < $max) {
572
+	    	$max = time() - $last['last'];
573
+	    }
439 574
 	}
440 575
 	if ($max < $globalMinFetch) {
441
-	    if ($globalDebug) echo 'Sleeping...'."\n";
576
+	    if ($globalDebug) {
577
+	    	echo 'Sleeping...'."\n";
578
+	    }
442 579
 	    sleep($globalMinFetch-$max+2);
443 580
 	}
444 581
     }
@@ -448,7 +585,9 @@  discard block
 block discarded – undo
448 585
     foreach ($globalSources as $id => $value) {
449 586
 	date_default_timezone_set('UTC');
450 587
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
451
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
588
+	if (!isset($last_exec[$id]['last'])) {
589
+		$last_exec[$id]['last'] = 0;
590
+	}
452 591
 	if ($value['format'] === 'deltadbtxt' && 
453 592
 	    (
454 593
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -457,7 +596,9 @@  discard block
 block discarded – undo
457 596
 	) {
458 597
         //$buffer = $Common->getData($hosts[$id]);
459 598
         $buffer = $Common->getData($value['host']);
460
-        if ($buffer != '') $reset = 0;
599
+        if ($buffer != '') {
600
+        	$reset = 0;
601
+        }
461 602
         $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
462 603
         $buffer = explode('\n', $buffer);
463 604
         foreach ($buffer as $line) {
@@ -466,20 +607,41 @@  discard block
 block discarded – undo
466 607
                 $data = array();
467 608
                 $data['hex'] = $line[1]; // hex
468 609
                 $data['ident'] = $line[2]; // ident
469
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
470
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
471
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
472
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
473
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
610
+                if (isset($line[3])) {
611
+                	$data['altitude'] = $line[3];
612
+                }
613
+                // altitude
614
+                if (isset($line[4])) {
615
+                	$data['speed'] = $line[4];
616
+                }
617
+                // speed
618
+                if (isset($line[5])) {
619
+                	$data['heading'] = $line[5];
620
+                }
621
+                // heading
622
+                if (isset($line[6])) {
623
+                	$data['latitude'] = $line[6];
624
+                }
625
+                // lat
626
+                if (isset($line[7])) {
627
+                	$data['longitude'] = $line[7];
628
+                }
629
+                // long
474 630
                 $data['verticalrate'] = ''; // vertical rate
475 631
                 //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
476 632
                 $data['emergency'] = ''; // emergency
477 633
                 $data['datetime'] = date('Y-m-d H:i:s');
478 634
                 $data['format_source'] = 'deltadbtxt';
479 635
                 $data['id_source'] = $id_source;
480
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
481
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
636
+                if (isset($value['name']) && $value['name'] != '') {
637
+                	$data['source_name'] = $value['name'];
638
+                }
639
+                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
640
+                	$data['noarchive'] = true;
641
+                }
642
+                if (isset($value['sourcestats'])) {
643
+                	$data['sourcestats'] = $value['sourcestats'];
644
+                }
483 645
                 $SI->add($data);
484 646
                 unset($data);
485 647
             }
@@ -514,11 +676,20 @@  discard block
 block discarded – undo
514 676
                     $data['format_source'] = 'radarcapejson';
515 677
                     $data['id_source'] = $id_source;
516 678
                     if (isset($value['name']) && $value['name'] != '') {
517
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
518
-                        else $data['source_name'] = $value['name'];
519
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
520
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
521
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
679
+                        if (isset($line['src']) && !$line['src'] == 'M') {
680
+                        	$data['source_name'] = $value['name'].'_MLAT';
681
+                        } else {
682
+                        	$data['source_name'] = $value['name'];
683
+                        }
684
+                    } elseif (isset($line['src']) && $line['src'] == 'M') {
685
+                    	$data['source_name'] = 'MLAT';
686
+                    }
687
+                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
688
+                    	$data['noarchive'] = true;
689
+                    }
690
+                    if (isset($value['sourcestats'])) {
691
+                    	$data['sourcestats'] = $value['sourcestats'];
692
+                    }
522 693
 
523 694
                     $SI->add($data);
524 695
                     unset($data);
@@ -534,7 +705,9 @@  discard block
 block discarded – undo
534 705
 	    date_default_timezone_set('CET');
535 706
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
536 707
 	    date_default_timezone_set('UTC');
537
-	    if ($buffer != '') $reset = 0;
708
+	    if ($buffer != '') {
709
+	    	$reset = 0;
710
+	    }
538 711
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539 712
 	    $buffer = explode('\n',$buffer);
540 713
 	    foreach ($buffer as $line) {
@@ -543,18 +716,42 @@  discard block
 block discarded – undo
543 716
 		    $add = false;
544 717
 		    $ais_data = $AIS->parse_line(trim($line));
545 718
 		    $data = array();
546
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
548
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
551
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
552
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
553
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
554
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
555
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
556
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
719
+		    if (isset($ais_data['ident'])) {
720
+		    	$data['ident'] = $ais_data['ident'];
721
+		    }
722
+		    if (isset($ais_data['mmsi'])) {
723
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
724
+		    }
725
+		    if (isset($ais_data['speed'])) {
726
+		    	$data['speed'] = $ais_data['speed'];
727
+		    }
728
+		    if (isset($ais_data['heading'])) {
729
+		    	$data['heading'] = $ais_data['heading'];
730
+		    }
731
+		    if (isset($ais_data['latitude'])) {
732
+		    	$data['latitude'] = $ais_data['latitude'];
733
+		    }
734
+		    if (isset($ais_data['longitude'])) {
735
+		    	$data['longitude'] = $ais_data['longitude'];
736
+		    }
737
+		    if (isset($ais_data['status'])) {
738
+		    	$data['status'] = $ais_data['status'];
739
+		    }
740
+		    if (isset($ais_data['statusid'])) {
741
+		    	$data['status_id'] = $ais_data['statusid'];
742
+		    }
743
+		    if (isset($ais_data['type'])) {
744
+		    	$data['type'] = $ais_data['type'];
745
+		    }
746
+		    if (isset($ais_data['typeid'])) {
747
+		    	$data['type_id'] = $ais_data['typeid'];
748
+		    }
749
+		    if (isset($ais_data['imo'])) {
750
+		    	$data['imo'] = $ais_data['imo'];
751
+		    }
752
+		    if (isset($ais_data['callsign'])) {
753
+		    	$data['callsign'] = $ais_data['callsign'];
754
+		    }
558 755
 		    if (isset($ais_data['timestamp'])) {
559 756
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
560 757
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -568,8 +765,12 @@  discard block
 block discarded – undo
568 765
 		    $data['format_source'] = 'aisnmeatxt';
569 766
     		    $data['id_source'] = $id_source;
570 767
 		    //print_r($data);
571
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
572
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
768
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
769
+		    	$data['noarchive'] = true;
770
+		    }
771
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
772
+		    	$MI->add($data);
773
+		    }
573 774
 		    unset($data);
574 775
 		}
575 776
     	    }
@@ -592,20 +793,48 @@  discard block
 block discarded – undo
592 793
 			    if ($line != '') {
593 794
 				$ais_data = $AIS->parse_line(trim($line));
594 795
 				$data = array();
595
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
596
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
597
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
598
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
599
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
600
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
601
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
602
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
603
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
604
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
605
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
606
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
607
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
608
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
796
+				if (isset($ais_data['ident'])) {
797
+					$data['ident'] = $ais_data['ident'];
798
+				}
799
+				if (isset($ais_data['mmsi'])) {
800
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
801
+				}
802
+				if (isset($ais_data['speed'])) {
803
+					$data['speed'] = $ais_data['speed'];
804
+				}
805
+				if (isset($ais_data['heading'])) {
806
+					$data['heading'] = $ais_data['heading'];
807
+				}
808
+				if (isset($ais_data['latitude'])) {
809
+					$data['latitude'] = $ais_data['latitude'];
810
+				}
811
+				if (isset($ais_data['longitude'])) {
812
+					$data['longitude'] = $ais_data['longitude'];
813
+				}
814
+				if (isset($ais_data['status'])) {
815
+					$data['status'] = $ais_data['status'];
816
+				}
817
+				if (isset($ais_data['statusid'])) {
818
+					$data['status_id'] = $ais_data['statusid'];
819
+				}
820
+				if (isset($ais_data['type'])) {
821
+					$data['type'] = $ais_data['type'];
822
+				}
823
+				if (isset($ais_data['typeid'])) {
824
+					$data['type_id'] = $ais_data['typeid'];
825
+				}
826
+				if (isset($ais_data['imo'])) {
827
+					$data['imo'] = $ais_data['imo'];
828
+				}
829
+				if (isset($ais_data['callsign'])) {
830
+					$data['callsign'] = $ais_data['callsign'];
831
+				}
832
+				if (isset($ais_data['destination'])) {
833
+					$data['arrival_code'] = $ais_data['destination'];
834
+				}
835
+				if (isset($ais_data['eta_ts'])) {
836
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
837
+				}
609 838
 				if (isset($ais_data['timestamp'])) {
610 839
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
611 840
 				} else {
@@ -613,18 +842,27 @@  discard block
 block discarded – undo
613 842
 				}
614 843
 				$data['format_source'] = 'aisnmeahttp';
615 844
 				$data['id_source'] = $id_source;
616
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
617
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
845
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
846
+					$data['noarchive'] = true;
847
+				}
848
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
849
+					$MI->add($data);
850
+				}
618 851
 				unset($data);
619 852
 			    }
620 853
 			}
621 854
 		    }
622 855
 		} else {
623 856
 		    $format = $value['format'];
624
-		    if (isset($tt[$format])) $tt[$format]++;
625
-		    else $tt[$format] = 0;
857
+		    if (isset($tt[$format])) {
858
+		    	$tt[$format]++;
859
+		    } else {
860
+		    	$tt[$format] = 0;
861
+		    }
626 862
 		    if ($tt[$format] > 30) {
627
-			if ($globalDebug) echo 'Reconnect...'."\n";
863
+			if ($globalDebug) {
864
+				echo 'Reconnect...'."\n";
865
+			}
628 866
 			sleep(2);
629 867
 			//$sourceeen[] = $value;
630 868
 			//connect_all($sourceeen);
@@ -660,12 +898,18 @@  discard block
 block discarded – undo
660 898
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
661 899
 			    //$data['type_id'] = $line['TYPE'];
662 900
 			    $data['imo'] = $line['IMO'];
663
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
901
+			    if ($line['DEST'] != '') {
902
+			    	$data['arrival_code'] = $line['DEST'];
903
+			    }
904
+			    if ($line['ARV'] != '') {
905
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
906
+			    }
665 907
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
666 908
 			    $data['format_source'] = 'myshiptracking';
667 909
 			    $data['id_source'] = $id_source;
668
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
910
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
911
+			    	$data['noarchive'] = true;
912
+			    }
669 913
 			    $MI->add($data);
670 914
 			    unset($data);
671 915
 			}
@@ -690,7 +934,9 @@  discard block
 block discarded – undo
690 934
 			    $data['callsign'] = $line['callsign'];
691 935
 			    $data['mmsi'] = substr($line['mmsi'],-9);
692 936
 			    $data['speed'] = $line['sog'];
693
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
937
+			    if ($line['heading'] != '511') {
938
+			    	$data['heading'] = $line['heading'];
939
+			    }
694 940
 			    $data['latitude'] = $line['latitude'];
695 941
 			    $data['longitude'] = $line['longitude'];
696 942
 			    $data['type_id'] = $line['shiptype'];
@@ -698,7 +944,9 @@  discard block
 block discarded – undo
698 944
 			    $data['datetime'] = $line['time'];
699 945
 			    $data['format_source'] = 'boatbeaconapp';
700 946
 			    $data['id_source'] = $id_source;
701
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
947
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
948
+			    	$data['noarchive'] = true;
949
+			    }
702 950
 			    $MI->add($data);
703 951
 			    unset($data);
704 952
 			}
@@ -720,22 +968,44 @@  discard block
 block discarded – undo
720 968
 		    foreach ($all_data['features'] as $line) {
721 969
 			print_r($line);
722 970
 			$data = array();
723
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
724
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
725
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
726
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
727
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
728
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
971
+			if (isset($line['properties']['name'])) {
972
+				$data['ident'] = $line['properties']['name'];
973
+			}
974
+			if (isset($line['properties']['callsign'])) {
975
+				$data['callsign'] = $line['properties']['callsign'];
976
+			}
977
+			if (isset($line['properties']['mmsi'])) {
978
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
979
+			}
980
+			if (isset($line['properties']['imo'])) {
981
+				$data['imo'] = $line['properties']['imo'];
982
+			}
983
+			if (isset($line['properties']['speed'])) {
984
+				$data['speed'] = $line['properties']['speed'];
985
+			}
986
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
987
+				$data['heading'] = $line['properties']['heading'];
988
+			}
729 989
 			$data['latitude'] = $line['geometry']['coordinates'][1];
730 990
 			$data['longitude'] = $line['geometry']['coordinates'][0];
731
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
732
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
733
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
991
+			if (isset($line['properties']['vesselType'])) {
992
+				$data['type'] = $line['properties']['vesselType'];
993
+			}
994
+			if (isset($line['properties']['destination'])) {
995
+				$data['arrival_code'] = $line['properties']['destination'];
996
+			}
997
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
998
+				$data['arrival_date'] = $line['properties']['eta'];
999
+			}
734 1000
 			$data['format_source'] = 'boatnerd';
735 1001
 			$data['id_source'] = $id_source;
736 1002
 			$data['datetime'] = date('Y-m-d H:i:s');
737
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
738
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
1003
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1004
+				$data['noarchive'] = true;
1005
+			}
1006
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
1007
+				$MI->add($data);
1008
+			}
739 1009
 			unset($data);
740 1010
 		    }
741 1011
 		}
@@ -748,11 +1018,17 @@  discard block
 block discarded – undo
748 1018
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
749 1019
 	    )
750 1020
 	) {
751
-	    if ($globalDebug) echo 'download...';
1021
+	    if ($globalDebug) {
1022
+	    	echo 'download...';
1023
+	    }
752 1024
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
753
-	    if ($globalDebug) echo 'done !'."\n";
1025
+	    if ($globalDebug) {
1026
+	    	echo 'done !'."\n";
1027
+	    }
754 1028
 	    // FIXME: Need more work
755
-	    if ($buffer != '') $reset = 0;
1029
+	    if ($buffer != '') {
1030
+	    	$reset = 0;
1031
+	    }
756 1032
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757 1033
 	    $buffer = explode('\n',$buffer);
758 1034
 	    foreach ($buffer as $line) {
@@ -778,7 +1054,9 @@  discard block
 block discarded – undo
778 1054
 		    //$data['etaTime'] = substr($line,135,5);
779 1055
 		    $data['format_source'] = 'shipplotter';
780 1056
     		    $data['id_source'] = $id_source;
781
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1057
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1058
+		    	$data['noarchive'] = true;
1059
+		    }
782 1060
 		    //print_r($data);
783 1061
 		    //echo 'Add...'."\n";
784 1062
 		    $MI->add($data);
@@ -796,13 +1074,21 @@  discard block
 block discarded – undo
796 1074
 		exit(0);
797 1075
 	    }
798 1076
 	    $sailawayoption = array('key' => $globalSailaway['key']);
799
-	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
800
-	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
1077
+	    if (isset($globalSailaway['usrnr'])) {
1078
+	    	$sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
1079
+	    }
1080
+	    if (isset($globalSailaway['ubtnr'])) {
1081
+	    	$sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
1082
+	    }
801 1083
 
802 1084
 	    for ($i = 0; $i <= 1; $i++) {
803
-		if ($globalDebug) echo '! Download... ';
1085
+		if ($globalDebug) {
1086
+			echo '! Download... ';
1087
+		}
804 1088
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30);
805
-		if ($globalDebug) echo 'done'."\n";
1089
+		if ($globalDebug) {
1090
+			echo 'done'."\n";
1091
+		}
806 1092
 		if ($buffer != '') {
807 1093
 		    $all_data = json_decode($buffer,true);
808 1094
 		    if (isset($all_data['missions'])) {
@@ -817,8 +1103,11 @@  discard block
 block discarded – undo
817 1103
 					//$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['usrname'])));
818 1104
 					$datar['creator'] = '';
819 1105
 					$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])));
820
-					if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart']));
821
-					else $datar['startdate'] = '1970-01-01 00:00:00';
1106
+					if (isset($mission['misstart'])) {
1107
+						$datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart']));
1108
+					} else {
1109
+						$datar['startdate'] = '1970-01-01 00:00:00';
1110
+					}
822 1111
 					/*
823 1112
 					$markers = array();
824 1113
 					foreach ($race_data['mission']['course'] as $course) {
@@ -834,7 +1123,9 @@  discard block
 block discarded – undo
834 1123
 			}
835 1124
 		    }
836 1125
 		}
837
-		if ($globalDebug) echo '=== Wait... ===';
1126
+		if ($globalDebug) {
1127
+			echo '=== Wait... ===';
1128
+		}
838 1129
 		sleep(10*60);
839 1130
 	    }
840 1131
 	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
@@ -846,7 +1137,9 @@  discard block
 block discarded – undo
846 1137
 			$data = array();
847 1138
 			$data['id'] = $sail['ubtnr'];
848 1139
 			$data['datetime'] = date('Y-m-d H:i:s');
849
-			if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s');
1140
+			if ($sail['online'] == '1') {
1141
+				$data['last_update'] = date('Y-m-d H:i:s');
1142
+			}
850 1143
 			$data['latitude'] = $sail['ubtlat'];
851 1144
 			$data['longitude'] = $sail['ubtlon'];
852 1145
 			$data['type_id'] = 36;
@@ -855,16 +1148,24 @@  discard block
 block discarded – undo
855 1148
 			$data['captain_name'] = $sail['usrname'];
856 1149
 			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52&#39; Cruising Cat','50&#39; Performance Cruiser','Nordic Folkboat','32&#39; Offshore Racer');
857 1150
 			$boattype = $sail['ubtbtpnr'];
858
-			if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1];
1151
+			if (isset($allboats[$boattype-1])) {
1152
+				$data['type'] = $allboats[$boattype-1];
1153
+			}
859 1154
 			$data['speed'] = round($sail['ubtspeed']*3.6,2);
860 1155
 			$data['format_source'] = 'sailaway';
861 1156
 			$data['id_source'] = $id_source;
862
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1157
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1158
+				$data['noarchive'] = true;
1159
+			}
863 1160
 			$MI->add($data);
864 1161
 			unset($data);
865 1162
 		    }
866
-		} elseif ($globalDebug) echo 'Error in JSON parsing';
867
-	    } elseif ($globalDebug) echo 'Empty result !'."\n";
1163
+		} elseif ($globalDebug) {
1164
+			echo 'Error in JSON parsing';
1165
+		}
1166
+	    } elseif ($globalDebug) {
1167
+	    	echo 'Empty result !'."\n";
1168
+	    }
868 1169
 
869 1170
     	    $last_exec[$id]['last'] = time();
870 1171
 	} elseif ($value['format'] === 'sailaway' && 
@@ -887,11 +1188,19 @@  discard block
 block discarded – undo
887 1188
 		echo 'Sailaway API key MUST be defined';
888 1189
 		exit(0);
889 1190
 	    }
890
-	    if ($globalDebug) echo '! Download... ';
1191
+	    if ($globalDebug) {
1192
+	    	echo '! Download... ';
1193
+	    }
891 1194
 	    $sailawayoption = array('key' => $globalSailaway['key']);
892
-	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
893
-	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
894
-	    if (isset($globalSailaway['misnr'])) $sailawayoption = array_merge($sailawayoption,array('misnr' => $globalSailaway['misnr']));
1195
+	    if (isset($globalSailaway['usrnr'])) {
1196
+	    	$sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
1197
+	    }
1198
+	    if (isset($globalSailaway['ubtnr'])) {
1199
+	    	$sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
1200
+	    }
1201
+	    if (isset($globalSailaway['misnr'])) {
1202
+	    	$sailawayoption = array_merge($sailawayoption,array('misnr' => $globalSailaway['misnr']));
1203
+	    }
895 1204
 	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
896 1205
 	    if ($buffer != '') {
897 1206
 		$data = json_decode($buffer,true);
@@ -901,7 +1210,9 @@  discard block
 block discarded – undo
901 1210
 			$data = array();
902 1211
 			$data['id'] = $sail['ubtnr'];
903 1212
 			$data['datetime'] = date('Y-m-d H:i:s');
904
-			if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s');
1213
+			if ($sail['online'] == '1') {
1214
+				$data['last_update'] = date('Y-m-d H:i:s');
1215
+			}
905 1216
 			$data['latitude'] = $sail['ubtlat'];
906 1217
 			$data['longitude'] = $sail['ubtlon'];
907 1218
 			$data['type_id'] = 36;
@@ -910,16 +1221,24 @@  discard block
 block discarded – undo
910 1221
 			$data['captain_name'] = $sail['usrname'];
911 1222
 			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52&#39; Cruising Cat','50&#39; Performance Cruiser','Nordic Folkboat','32&#39; Offshore Racer');
912 1223
 			$boattype = $sail['ubtbtpnr'];
913
-			if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1];
1224
+			if (isset($allboats[$boattype-1])) {
1225
+				$data['type'] = $allboats[$boattype-1];
1226
+			}
914 1227
 			$data['speed'] = round($sail['ubtspeed']*3.6,2);
915 1228
 			$data['format_source'] = 'sailaway';
916 1229
 			$data['id_source'] = $id_source;
917
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1230
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1231
+				$data['noarchive'] = true;
1232
+			}
918 1233
 			$MI->add($data);
919 1234
 			unset($data);
920 1235
 		    }
921
-		} elseif ($globalDebug) echo 'Error in JSON parsing';
922
-	    } elseif ($globalDebug) echo 'Empty result !'."\n";
1236
+		} elseif ($globalDebug) {
1237
+			echo 'Error in JSON parsing';
1238
+		}
1239
+	    } elseif ($globalDebug) {
1240
+	    	echo 'Empty result !'."\n";
1241
+	    }
923 1242
     	    $last_exec[$id]['last'] = time();
924 1243
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
925 1244
 	} elseif (
@@ -947,16 +1266,28 @@  discard block
 block discarded – undo
947 1266
     		    $line = explode(':', $line);
948 1267
     		    if (count($line) > 30 && $line[0] != 'callsign') {
949 1268
 			$data = array();
950
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
951
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1269
+			if (isset($line[37]) && $line[37] != '') {
1270
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1271
+			} else {
1272
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1273
+			}
952 1274
 			$data['pilot_id'] = $line[1];
953 1275
 			$data['pilot_name'] = $line[2];
954 1276
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
955 1277
 			$data['ident'] = $line[0]; // ident
956
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1278
+			if ($line[7] != '' && $line[7] != 0) {
1279
+				$data['altitude'] = $line[7];
1280
+			}
1281
+			// altitude
957 1282
 			$data['speed'] = $line[8]; // speed
958
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
959
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1283
+			if (isset($line[45])) {
1284
+				$data['heading'] = $line[45];
1285
+			}
1286
+			// heading
1287
+			elseif (isset($line[38])) {
1288
+				$data['heading'] = $line[38];
1289
+			}
1290
+			// heading
960 1291
 			$data['latitude'] = $line[5]; // lat
961 1292
 	        	$data['longitude'] = $line[6]; // long
962 1293
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -972,7 +1303,9 @@  discard block
 block discarded – undo
972 1303
 			$data['frequency'] = $line[4];
973 1304
 			$data['type'] = $line[18];
974 1305
 			$data['range'] = $line[19];
975
-			if (isset($line[35])) $data['info'] = $line[35];
1306
+			if (isset($line[35])) {
1307
+				$data['info'] = $line[35];
1308
+			}
976 1309
     			$data['id_source'] = $id_source;
977 1310
 	    		//$data['arrival_airport_time'] = ;
978 1311
 	    		if ($line[9] != '') {
@@ -990,27 +1323,47 @@  discard block
 block discarded – undo
990 1323
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
991 1324
 	    		*/
992 1325
 	    		$data['format_source'] = $value['format'];
993
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
994
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
995
-    			if ($line[3] === 'PILOT') $SI->add($data);
996
-			elseif ($line[3] === 'ATC') {
1326
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1327
+				$data['noarchive'] = true;
1328
+			}
1329
+			if (isset($value['name']) && $value['name'] != '') {
1330
+				$data['source_name'] = $value['name'];
1331
+			}
1332
+    			if ($line[3] === 'PILOT') {
1333
+    				$SI->add($data);
1334
+    			} elseif ($line[3] === 'ATC') {
997 1335
 				//print_r($data);
998 1336
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
999 1337
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000 1338
 				$typec = substr($data['ident'],-3);
1001
-				if ($typec === 'APP') $data['type'] = 'Approach';
1002
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
1003
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
1004
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
1005
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1006
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
1007
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1008
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1009
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
1010
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1339
+				if ($typec === 'APP') {
1340
+					$data['type'] = 'Approach';
1341
+				} elseif ($typec === 'TWR') {
1342
+					$data['type'] = 'Tower';
1343
+				} elseif ($typec === 'OBS') {
1344
+					$data['type'] = 'Observer';
1345
+				} elseif ($typec === 'GND') {
1346
+					$data['type'] = 'Ground';
1347
+				} elseif ($typec === 'DEL') {
1348
+					$data['type'] = 'Delivery';
1349
+				} elseif ($typec === 'DEP') {
1350
+					$data['type'] = 'Departure';
1351
+				} elseif ($typec === 'FSS') {
1352
+					$data['type'] = 'Flight Service Station';
1353
+				} elseif ($typec === 'CTR') {
1354
+					$data['type'] = 'Control Radar or Centre';
1355
+				} elseif ($data['type'] === '') {
1356
+					$data['type'] = 'Observer';
1357
+				}
1358
+				if (!isset($data['source_name'])) {
1359
+					$data['source_name'] = '';
1360
+				}
1011 1361
 				if (isset($ATC)) {
1012
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1013
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1362
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1363
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1364
+					} else {
1365
+						echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1366
+					}
1014 1367
 				}
1015 1368
 			}
1016 1369
     			unset($data);
@@ -1037,14 +1390,20 @@  discard block
 block discarded – undo
1037 1390
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1038 1391
 			$data['latitude'] = (float)$line['pktLatitude'];
1039 1392
 			$data['longitude'] = (float)$line['pktLongitude'];
1040
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1041
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1393
+			if ((float)$line['pktTrack'] != 0) {
1394
+				$data['heading'] = (float)$line['pktTrack'];
1395
+			}
1396
+			if ((int)$line['pktSpeed'] != 0) {
1397
+				$data['speed'] = (int)$line['pktSpeed'];
1398
+			}
1042 1399
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1043 1400
 			$data['altitude_relative'] = 'AMSL';
1044 1401
 			$data['pilot_id'] = (int)$line['pktPilotID'];
1045 1402
 			$data['aircraft_icao'] = 'PARAGLIDER';
1046 1403
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1047
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1404
+			if (isset($pilot_data[4])) {
1405
+				$data['pilot_name'] = $pilot_data[4];
1406
+			}
1048 1407
 			$data['format_source'] = $value['format'];
1049 1408
 			$SI->add($data);
1050 1409
 			unset($data);
@@ -1092,25 +1451,59 @@  discard block
 block discarded – undo
1092 1451
 		    foreach ($all_data['acList'] as $line) {
1093 1452
 			$data = array();
1094 1453
 			$data['hex'] = $line['Icao']; // hex
1095
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1096
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1097
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1098
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1099
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1100
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1454
+			if (isset($line['Call'])) {
1455
+				$data['ident'] = $line['Call'];
1456
+			}
1457
+			// ident
1458
+			if (isset($line['Alt'])) {
1459
+				$data['altitude'] = $line['Alt'];
1460
+			}
1461
+			// altitude
1462
+			if (isset($line['Spd'])) {
1463
+				$data['speed'] = $line['Spd'];
1464
+			}
1465
+			// speed
1466
+			if (isset($line['Trak'])) {
1467
+				$data['heading'] = $line['Trak'];
1468
+			}
1469
+			// heading
1470
+			if (isset($line['Lat'])) {
1471
+				$data['latitude'] = $line['Lat'];
1472
+			}
1473
+			// lat
1474
+			if (isset($line['Long'])) {
1475
+				$data['longitude'] = $line['Long'];
1476
+			}
1477
+			// long
1101 1478
 			//$data['verticalrate'] = $line['']; // verticale rate
1102
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1479
+			if (isset($line['Sqk'])) {
1480
+				$data['squawk'] = $line['Sqk'];
1481
+			}
1482
+			// squawk
1103 1483
 			$data['emergency'] = ''; // emergency
1104
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1105
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1106
-			else $data['datetime'] = date('Y-m-d H:i:s');
1484
+			if (isset($line['Reg'])) {
1485
+				$data['registration'] = $line['Reg'];
1486
+			}
1487
+			if (isset($line['PosTime'])) {
1488
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1489
+			} else {
1490
+				$data['datetime'] = date('Y-m-d H:i:s');
1491
+			}
1107 1492
 			//$data['datetime'] = date('Y-m-d H:i:s');
1108
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1493
+			if (isset($line['Type'])) {
1494
+				$data['aircraft_icao'] = $line['Type'];
1495
+			}
1109 1496
 			$data['format_source'] = 'aircraftlistjson';
1110 1497
 			$data['id_source'] = $id_source;
1111
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1112
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1113
-			if (isset($data['latitude'])) $SI->add($data);
1498
+			if (isset($value['name']) && $value['name'] != '') {
1499
+				$data['source_name'] = $value['name'];
1500
+			}
1501
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1502
+				$data['noarchive'] = true;
1503
+			}
1504
+			if (isset($data['latitude'])) {
1505
+				$SI->add($data);
1506
+			}
1114 1507
 			unset($data);
1115 1508
 		    }
1116 1509
 		} elseif (is_array($all_data)) {
@@ -1127,17 +1520,26 @@  discard block
 block discarded – undo
1127 1520
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1128 1521
 			$data['squawk'] = $line['squawk']; // squawk
1129 1522
 			$data['emergency'] = ''; // emergency
1130
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1131
-			else $data['datetime'] = date('Y-m-d H:i:s');
1523
+			if (isset($line['PosTime'])) {
1524
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1525
+			} else {
1526
+				$data['datetime'] = date('Y-m-d H:i:s');
1527
+			}
1132 1528
 			$data['format_source'] = 'aircraftlistjson';
1133 1529
 			$data['id_source'] = $id_source;
1134
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1135
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1530
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1531
+				$data['noarchive'] = true;
1532
+			}
1533
+			if (isset($value['name']) && $value['name'] != '') {
1534
+				$data['source_name'] = $value['name'];
1535
+			}
1136 1536
 			$SI->add($data);
1137 1537
 			unset($data);
1138 1538
 		    }
1139 1539
 		}
1140
-	    } elseif ($globalDebug) echo 'No data'."\n";
1540
+	    } elseif ($globalDebug) {
1541
+	    	echo 'No data'."\n";
1542
+	    }
1141 1543
     	    //$last_exec['aircraftlistjson'] = time();
1142 1544
     	    $last_exec[$id]['last'] = time();
1143 1545
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1173,8 +1575,12 @@  discard block
 block discarded – undo
1173 1575
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1174 1576
 	    	    $data['format_source'] = 'planeupdatefaa';
1175 1577
     		    $data['id_source'] = $id_source;
1176
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1177
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1578
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1579
+		    	$data['noarchive'] = true;
1580
+		    }
1581
+		    if (isset($value['name']) && $value['name'] != '') {
1582
+		    	$data['source_name'] = $value['name'];
1583
+		    }
1178 1584
 		    $SI->add($data);
1179 1585
 		    unset($data);
1180 1586
 		}
@@ -1208,7 +1614,9 @@  discard block
 block discarded – undo
1208 1614
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1209 1615
 		    $data['format_source'] = 'opensky';
1210 1616
 		    $data['id_source'] = $id_source;
1211
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1617
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1618
+		    	$data['noarchive'] = true;
1619
+		    }
1212 1620
 		    $SI->add($data);
1213 1621
 		    unset($data);
1214 1622
 		}
@@ -1228,15 +1636,42 @@  discard block
 block discarded – undo
1228 1636
 		foreach ($all_data['aircraft'] as $key => $line) {
1229 1637
 		    $data = array();
1230 1638
 		    // add support for ground vehicule with ~ in front of hex
1231
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1232
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1233
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1234
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1235
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1236
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1237
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1238
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1239
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1639
+		    if (isset($line['hex'])) {
1640
+		    	$data['hex'] = $line['hex'];
1641
+		    }
1642
+		    // hex
1643
+		    if (isset($line['flight'])) {
1644
+		    	$data['ident'] = trim($line['flight']);
1645
+		    }
1646
+		    // ident
1647
+		    if (isset($line['altitude'])) {
1648
+		    	$data['altitude'] = $line['altitude'];
1649
+		    }
1650
+		    // altitude
1651
+		    if (isset($line['speed'])) {
1652
+		    	$data['speed'] = $line['speed'];
1653
+		    }
1654
+		    // speed
1655
+		    if (isset($line['track'])) {
1656
+		    	$data['heading'] = $line['track'];
1657
+		    }
1658
+		    // heading
1659
+		    if (isset($line['lat'])) {
1660
+		    	$data['latitude'] = $line['lat'];
1661
+		    }
1662
+		    // lat
1663
+		    if (isset($line['lon'])) {
1664
+		    	$data['longitude'] = $line['lon'];
1665
+		    }
1666
+		    // long
1667
+		    if (isset($line['vert_rate'])) {
1668
+		    	$data['verticalrate'] = $line['vert_rate'];
1669
+		    }
1670
+		    // verticale rate
1671
+		    if (isset($line['squawk'])) {
1672
+		    	$data['squawk'] = $line['squawk'];
1673
+		    }
1674
+		    // squawk
1240 1675
 		    //$data['emergency'] = ''; // emergency
1241 1676
 		    //$data['registration'] = $line[2];
1242 1677
 		    //$data['aircraft_icao'] = $line[0];
@@ -1244,10 +1679,17 @@  discard block
 block discarded – undo
1244 1679
 		    $data['format_source'] = 'aircraftjson';
1245 1680
 		    $data['id_source'] = $id_source;
1246 1681
 		    if (isset($value['name']) && $value['name'] != '') {
1247
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1248
-			    else $data['source_name'] = $value['name'];
1249
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1250
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1682
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1683
+			    	$data['source_name'] = $value['name'].'_MLAT';
1684
+			    } else {
1685
+			    	$data['source_name'] = $value['name'];
1686
+			    }
1687
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1688
+		    	$data['source_name'] = 'MLAT';
1689
+		    }
1690
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1691
+		    	$data['noarchive'] = true;
1692
+		    }
1251 1693
 		    $SI->add($data);
1252 1694
 		    unset($data);
1253 1695
 		}
@@ -1267,22 +1709,54 @@  discard block
 block discarded – undo
1267 1709
 		foreach ($all_data['aircraft'] as $key => $line) {
1268 1710
 		    $data = array();
1269 1711
 		    $data['hex'] = $key; // hex
1270
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1271
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1272
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1273
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1274
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1275
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1276
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1277
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1712
+		    if (isset($line['callsign'])) {
1713
+		    	$data['ident'] = trim($line['callsign']);
1714
+		    }
1715
+		    // ident
1716
+		    if (isset($line['altitude'])) {
1717
+		    	$data['altitude'] = $line['altitude'];
1718
+		    }
1719
+		    // altitude
1720
+		    if (isset($line['speed'])) {
1721
+		    	$data['speed'] = $line['speed'];
1722
+		    }
1723
+		    // speed
1724
+		    if (isset($line['heading'])) {
1725
+		    	$data['heading'] = $line['heading'];
1726
+		    }
1727
+		    // heading
1728
+		    if (isset($line['lat'])) {
1729
+		    	$data['latitude'] = $line['lat'];
1730
+		    }
1731
+		    // lat
1732
+		    if (isset($line['lon'])) {
1733
+		    	$data['longitude'] = $line['lon'];
1734
+		    }
1735
+		    // long
1736
+		    if (isset($line['vert_rate'])) {
1737
+		    	$data['verticalrate'] = $line['vert_rate'];
1738
+		    }
1739
+		    // verticale rate
1740
+		    if (isset($line['squawk'])) {
1741
+		    	$data['squawk'] = $line['squawk'];
1742
+		    }
1743
+		    // squawk
1278 1744
 		    //$data['emergency'] = ''; // emergency
1279
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1280
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1745
+		    if (isset($line['reg'])) {
1746
+		    	$data['registration'] = $line['reg'];
1747
+		    }
1748
+		    if (isset($line['type'])) {
1749
+		    	$data['aircraft_icao'] = $line['type'];
1750
+		    }
1281 1751
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1282 1752
 		    $data['format_source'] = 'planefinderclient';
1283 1753
 		    $data['id_source'] = $id_source;
1284
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1285
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1754
+		    if (isset($value['name']) && $value['name'] != '') {
1755
+		    	$data['source_name'] = $value['name'];
1756
+		    }
1757
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1758
+		    	$data['noarchive'] = true;
1759
+		    }
1286 1760
 		    $SI->add($data);
1287 1761
 		    unset($data);
1288 1762
 		}
@@ -1298,7 +1772,9 @@  discard block
 block discarded – undo
1298 1772
 	    //$buffer = $Common->getData($hosts[$id]);
1299 1773
 	    $buffer = $Common->getData($value['host']);
1300 1774
 	    $all_data = json_decode($buffer,true);
1301
-	    if (!empty($all_data)) $reset = 0;
1775
+	    if (!empty($all_data)) {
1776
+	    	$reset = 0;
1777
+	    }
1302 1778
 	    foreach ($all_data as $key => $line) {
1303 1779
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1304 1780
 		    $data = array();
@@ -1319,8 +1795,12 @@  discard block
 block discarded – undo
1319 1795
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1320 1796
 	    	    $data['format_source'] = 'fr24json';
1321 1797
     		    $data['id_source'] = $id_source;
1322
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1323
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1798
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1799
+		    	$data['noarchive'] = true;
1800
+		    }
1801
+		    if (isset($value['name']) && $value['name'] != '') {
1802
+		    	$data['source_name'] = $value['name'];
1803
+		    }
1324 1804
 		    $SI->add($data);
1325 1805
 		    unset($data);
1326 1806
 		}
@@ -1349,24 +1829,42 @@  discard block
 block discarded – undo
1349 1829
 		    if (isset($line['inf'])) {
1350 1830
 			$data = array();
1351 1831
 			$data['hex'] = $line['inf']['ia'];
1352
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1832
+			if (isset($line['inf']['cs'])) {
1833
+				$data['ident'] = $line['inf']['cs'];
1834
+			}
1835
+			//$line[13]
1353 1836
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1354
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1355
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1837
+	    		if (isset($line['inf']['gs'])) {
1838
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1839
+	    		}
1840
+	    		// speed
1841
+	    		if (isset($line['inf']['tr'])) {
1842
+	    			$data['heading'] = $line['inf']['tr'];
1843
+	    		}
1844
+	    		// heading
1356 1845
 	    		$data['latitude'] = $line['pt'][0]; // lat
1357 1846
 	    		$data['longitude'] = $line['pt'][1]; // long
1358 1847
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1359
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1848
+	    		if (isset($line['inf']['sq'])) {
1849
+	    			$data['squawk'] = $line['inf']['sq'];
1850
+	    		}
1851
+	    		// squawk
1360 1852
 	    		//$data['aircraft_icao'] = $line[8];
1361
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1853
+	    		if (isset($line['inf']['rc'])) {
1854
+	    			$data['registration'] = $line['inf']['rc'];
1855
+	    		}
1362 1856
 			//$data['departure_airport_iata'] = $line[11];
1363 1857
 			//$data['arrival_airport_iata'] = $line[12];
1364 1858
 	    		//$data['emergency'] = ''; // emergency
1365 1859
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1366 1860
 	    		$data['format_source'] = 'radarvirtueljson';
1367 1861
     			$data['id_source'] = $id_source;
1368
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1369
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1862
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1863
+				$data['noarchive'] = true;
1864
+			}
1865
+			if (isset($value['name']) && $value['name'] != '') {
1866
+				$data['source_name'] = $value['name'];
1867
+			}
1370 1868
 			$SI->add($data);
1371 1869
 			unset($data);
1372 1870
 		    }
@@ -1392,30 +1890,65 @@  discard block
 block discarded – undo
1392 1890
 		    $data['id'] = $line['id'];
1393 1891
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1394 1892
 		    $data['ident'] = $line['callsign']; // ident
1395
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1396
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1397
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1398
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1399
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1400
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1893
+		    if (isset($line['pilotid'])) {
1894
+		    	$data['pilot_id'] = $line['pilotid'];
1895
+		    }
1896
+		    // pilot id
1897
+		    if (isset($line['name'])) {
1898
+		    	$data['pilot_name'] = $line['name'];
1899
+		    }
1900
+		    // pilot name
1901
+		    if (isset($line['alt'])) {
1902
+		    	$data['altitude'] = $line['alt'];
1903
+		    }
1904
+		    // altitude
1905
+		    if (isset($line['gs'])) {
1906
+		    	$data['speed'] = $line['gs'];
1907
+		    }
1908
+		    // speed
1909
+		    if (isset($line['heading'])) {
1910
+		    	$data['heading'] = $line['heading'];
1911
+		    }
1912
+		    // heading
1913
+		    if (isset($line['route'])) {
1914
+		    	$data['waypoints'] = $line['route'];
1915
+		    }
1916
+		    // route
1401 1917
 		    $data['latitude'] = $line['lat']; // lat
1402 1918
 		    $data['longitude'] = $line['lon']; // long
1403 1919
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1404 1920
 		    //$data['squawk'] = $line['squawk']; // squawk
1405 1921
 		    //$data['emergency'] = ''; // emergency
1406
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1407
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1408
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1922
+		    if (isset($line['depicao'])) {
1923
+		    	$data['departure_airport_icao'] = $line['depicao'];
1924
+		    }
1925
+		    if (isset($line['deptime'])) {
1926
+		    	$data['departure_airport_time'] = $line['deptime'];
1927
+		    }
1928
+		    if (isset($line['arricao'])) {
1929
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1930
+		    }
1409 1931
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1410
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1411
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1412
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1413
-		    else $data['info'] = '';
1932
+		    if (isset($line['aircraft'])) {
1933
+		    	$data['aircraft_icao'] = $line['aircraft'];
1934
+		    }
1935
+		    if (isset($line['transponder'])) {
1936
+		    	$data['squawk'] = $line['transponder'];
1937
+		    }
1938
+		    if (isset($line['atis'])) {
1939
+		    	$data['info'] = $line['atis'];
1940
+		    } else {
1941
+		    	$data['info'] = '';
1942
+		    }
1414 1943
 		    $data['format_source'] = 'pireps';
1415 1944
     		    $data['id_source'] = $id_source;
1416 1945
 		    $data['datetime'] = date('Y-m-d H:i:s');
1417
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1418
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1946
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1947
+		    	$data['noarchive'] = true;
1948
+		    }
1949
+		    if (isset($value['name']) && $value['name'] != '') {
1950
+		    	$data['source_name'] = $value['name'];
1951
+		    }
1419 1952
 		    if ($line['icon'] === 'plane') {
1420 1953
 			$SI->add($data);
1421 1954
 		    //    print_r($data);
@@ -1424,16 +1957,28 @@  discard block
 block discarded – undo
1424 1957
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1425 1958
 			$typec = substr($data['ident'],-3);
1426 1959
 			$data['type'] = '';
1427
-			if ($typec === 'APP') $data['type'] = 'Approach';
1428
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1429
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1430
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1431
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1432
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1433
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1434
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1435
-			else $data['type'] = 'Observer';
1436
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1960
+			if ($typec === 'APP') {
1961
+				$data['type'] = 'Approach';
1962
+			} elseif ($typec === 'TWR') {
1963
+				$data['type'] = 'Tower';
1964
+			} elseif ($typec === 'OBS') {
1965
+				$data['type'] = 'Observer';
1966
+			} elseif ($typec === 'GND') {
1967
+				$data['type'] = 'Ground';
1968
+			} elseif ($typec === 'DEL') {
1969
+				$data['type'] = 'Delivery';
1970
+			} elseif ($typec === 'DEP') {
1971
+				$data['type'] = 'Departure';
1972
+			} elseif ($typec === 'FSS') {
1973
+				$data['type'] = 'Flight Service Station';
1974
+			} elseif ($typec === 'CTR') {
1975
+				$data['type'] = 'Control Radar or Centre';
1976
+			} else {
1977
+				$data['type'] = 'Observer';
1978
+			}
1979
+			if (isset($ATC)) {
1980
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1981
+			}
1437 1982
 		    }
1438 1983
 		    unset($data);
1439 1984
 		}
@@ -1448,7 +1993,9 @@  discard block
 block discarded – undo
1448 1993
 	    )
1449 1994
 	) {
1450 1995
 	    //$buffer = $Common->getData($hosts[$id]);
1451
-	    if ($globalDebug) echo 'Get Data...'."\n";
1996
+	    if ($globalDebug) {
1997
+	    	echo 'Get Data...'."\n";
1998
+	    }
1452 1999
 	    $buffer = $Common->getData($value['host']);
1453 2000
 	    $all_data = json_decode($buffer,true);
1454 2001
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1456,11 +2003,18 @@  discard block
 block discarded – undo
1456 2003
 		foreach ($all_data as $line) {
1457 2004
 	    	    $data = array();
1458 2005
 	    	    //$data['id'] = $line['id']; // id not usable
1459
-	    	    if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']);
1460
-	    	    elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
2006
+	    	    if (isset($line['pilotid']) && isset($line['registration'])) {
2007
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']);
2008
+	    	    } elseif (isset($line['pilotid'])) {
2009
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
2010
+	    	    }
1461 2011
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1462
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1463
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
2012
+	    	    if (isset($line['pilotname'])) {
2013
+	    	    	$data['pilot_name'] = $line['pilotname'];
2014
+	    	    }
2015
+	    	    if (isset($line['pilotid'])) {
2016
+	    	    	$data['pilot_id'] = $line['pilotid'];
2017
+	    	    }
1464 2018
 	    	    $data['ident'] = $line['flightnum']; // ident
1465 2019
 	    	    $data['altitude'] = $line['alt']; // altitude
1466 2020
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1476,7 +2030,9 @@  discard block
 block discarded – undo
1476 2030
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1477 2031
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1478 2032
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1479
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2033
+	    	    } else {
2034
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2035
+	    	    }
1480 2036
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1481 2037
 	    	    $data['departure_airport_time'] = $line['deptime'];
1482 2038
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1484,29 +2040,47 @@  discard block
 block discarded – undo
1484 2040
     		    if (isset($line['registration'])) {
1485 2041
     			$data['registration'] = trim($line['registration']);
1486 2042
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1487
-    		    } else $data['registration'] = $line['aircraft'];
1488
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1489
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2043
+    		    } else {
2044
+    		    	$data['registration'] = $line['aircraft'];
2045
+    		    }
2046
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2047
+		    	$data['noarchive'] = true;
2048
+		    }
2049
+		    if (isset($line['route'])) {
2050
+		    	$data['waypoints'] = $line['route'];
2051
+		    }
2052
+		    // route
1490 2053
 		    if (isset($line['aircraftname'])) {
1491 2054
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1492 2055
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1493 2056
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1494
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1495
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1496
-	    		else {
2057
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
2058
+	    			$data['aircraft_icao'] = $aircraft_data[0];
2059
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
2060
+	    			$data['aircraft_icao'] = $aircraft_data[1];
2061
+	    		} else {
1497 2062
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1498
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1499
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2063
+	    		    if (isset($aircraft_data[1])) {
2064
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
2065
+	    		    } else {
2066
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2067
+	    		    }
1500 2068
 	    		}
1501 2069
 	    	    }
1502
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
2070
+    		    if (isset($line['route'])) {
2071
+    		    	$data['waypoints'] = $line['route'];
2072
+    		    }
1503 2073
     		    $data['id_source'] = $id_source;
1504 2074
 	    	    $data['format_source'] = 'phpvmacars';
1505
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2075
+		    if (isset($value['name']) && $value['name'] != '') {
2076
+		    	$data['source_name'] = $value['name'];
2077
+		    }
1506 2078
 		    $SI->add($data);
1507 2079
 		    unset($data);
1508 2080
 		}
1509
-		if ($globalDebug) echo 'No more data...'."\n";
2081
+		if ($globalDebug) {
2082
+			echo 'No more data...'."\n";
2083
+		}
1510 2084
 		unset($buffer);
1511 2085
 		unset($all_data);
1512 2086
 	    }
@@ -1519,7 +2093,9 @@  discard block
 block discarded – undo
1519 2093
 	    )
1520 2094
 	) {
1521 2095
 	    //$buffer = $Common->getData($hosts[$id]);
1522
-	    if ($globalDebug) echo 'Get Data...'."\n";
2096
+	    if ($globalDebug) {
2097
+	    	echo 'Get Data...'."\n";
2098
+	    }
1523 2099
 	    $buffer = $Common->getData($value['host']);
1524 2100
 	    $all_data = json_decode($buffer,true);
1525 2101
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1530,10 +2106,16 @@  discard block
 block discarded – undo
1530 2106
 	    	    //$data['id'] = $line['id']; // id not usable
1531 2107
 	    	    $data['id'] = $line['id'];
1532 2108
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1533
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1534
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
2109
+	    	    if (isset($line['user']['username'])) {
2110
+	    	    	$data['pilot_name'] = $line['user']['username'];
2111
+	    	    }
2112
+	    	    if (isset($line['user_id'])) {
2113
+	    	    	$data['pilot_id'] = $line['user_id'];
2114
+	    	    }
1535 2115
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1536
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2116
+	    	    if (is_numeric($data['ident'])) {
2117
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2118
+	    	    }
1537 2119
 	    	    $data['altitude'] = $line['altitude']; // altitude
1538 2120
 	    	    $data['speed'] = $line['groundspeed']; // speed
1539 2121
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1546,7 +2128,9 @@  discard block
 block discarded – undo
1546 2128
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1547 2129
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1548 2130
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1549
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2131
+	    	    } else {
2132
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2133
+	    	    }
1550 2134
 	    	    
1551 2135
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1552 2136
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1554,17 +2138,26 @@  discard block
 block discarded – undo
1554 2138
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1555 2139
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1556 2140
 
1557
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1558
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2141
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2142
+		    	$data['noarchive'] = true;
2143
+		    }
2144
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2145
+		    	$data['waypoints'] = $line['bid']['route'];
2146
+		    }
2147
+		    // route
1559 2148
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1560 2149
 
1561 2150
     		    $data['id_source'] = $id_source;
1562 2151
 	    	    $data['format_source'] = 'vaos';
1563
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2152
+		    if (isset($value['name']) && $value['name'] != '') {
2153
+		    	$data['source_name'] = $value['name'];
2154
+		    }
1564 2155
 		    $SI->add($data);
1565 2156
 		    unset($data);
1566 2157
 		}
1567
-		if ($globalDebug) echo 'No more data...'."\n";
2158
+		if ($globalDebug) {
2159
+			echo 'No more data...'."\n";
2160
+		}
1568 2161
 		unset($buffer);
1569 2162
 		unset($all_data);
1570 2163
 	    }
@@ -1577,7 +2170,9 @@  discard block
 block discarded – undo
1577 2170
 	    )
1578 2171
 	) {
1579 2172
 	    //$buffer = $Common->getData($hosts[$id]);
1580
-	    if ($globalDebug) echo 'Get Data...'."\n";
2173
+	    if ($globalDebug) {
2174
+	    	echo 'Get Data...'."\n";
2175
+	    }
1581 2176
 	    $buffer = $Common->getData($value['host']);
1582 2177
 	    $all_data = json_decode($buffer,true);
1583 2178
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1606,16 +2201,25 @@  discard block
 block discarded – undo
1606 2201
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1607 2202
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1608 2203
     		    //$data['registration'] = $line['aircraft'];
1609
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2204
+		    if (isset($line['route'])) {
2205
+		    	$data['waypoints'] = $line['route'];
2206
+		    }
2207
+		    // route
1610 2208
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1611 2209
     		    $data['id_source'] = $id_source;
1612 2210
 	    	    $data['format_source'] = 'vam';
1613
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1614
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2211
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2212
+		    	$data['noarchive'] = true;
2213
+		    }
2214
+		    if (isset($value['name']) && $value['name'] != '') {
2215
+		    	$data['source_name'] = $value['name'];
2216
+		    }
1615 2217
 		    $SI->add($data);
1616 2218
 		    unset($data);
1617 2219
 		}
1618
-		if ($globalDebug) echo 'No more data...'."\n";
2220
+		if ($globalDebug) {
2221
+			echo 'No more data...'."\n";
2222
+		}
1619 2223
 		unset($buffer);
1620 2224
 		unset($all_data);
1621 2225
 	    }
@@ -1628,7 +2232,9 @@  discard block
 block discarded – undo
1628 2232
 	    )
1629 2233
 	) {
1630 2234
 	    //$buffer = $Common->getData($hosts[$id]);
1631
-	    if ($globalDebug) echo 'Get Data...'."\n";
2235
+	    if ($globalDebug) {
2236
+	    	echo 'Get Data...'."\n";
2237
+	    }
1632 2238
 	    $buffer = $Common->getData($value['host']);
1633 2239
 	    $all_data = json_decode($buffer,true);
1634 2240
 	    if ($buffer != '') {
@@ -1646,12 +2252,16 @@  discard block
 block discarded – undo
1646 2252
 			$data['id_source'] = $id_source;
1647 2253
 			$data['format_source'] = 'blitzortung';
1648 2254
 			$SI->add($data);
1649
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2255
+			if ($globalDebug) {
2256
+				echo '☈ Lightning added'."\n";
2257
+			}
1650 2258
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1651 2259
 			unset($data);
1652 2260
 		    }
1653 2261
 		}
1654
-		if ($globalDebug) echo 'No more data...'."\n";
2262
+		if ($globalDebug) {
2263
+			echo 'No more data...'."\n";
2264
+		}
1655 2265
 		unset($buffer);
1656 2266
 	    }
1657 2267
 	    $last_exec[$id]['last'] = time();
@@ -1680,10 +2290,15 @@  discard block
 block discarded – undo
1680 2290
                 }
1681 2291
             } else {
1682 2292
                 $format = $value['format'];
1683
-                if (isset($tt[$format])) $tt[$format]++;
1684
-                else $tt[$format] = 0;
2293
+                if (isset($tt[$format])) {
2294
+                	$tt[$format]++;
2295
+                } else {
2296
+                	$tt[$format] = 0;
2297
+                }
1685 2298
                 if ($tt[$format] > 30) {
1686
-                    if ($globalDebug) echo 'Reconnect...'."\n";
2299
+                    if ($globalDebug) {
2300
+                    	echo 'Reconnect...'."\n";
2301
+                    }
1687 2302
                     sleep(2);
1688 2303
                     //$sourceeen[] = $value;
1689 2304
                     //connect_all($sourceeen);
@@ -1700,7 +2315,9 @@  discard block
 block discarded – undo
1700 2315
 	    $write = NULL;
1701 2316
 	    $e = NULL;
1702 2317
 	    $n = socket_select($read, $write, $e, $timeout);
1703
-	    if ($e != NULL) var_dump($e);
2318
+	    if ($e != NULL) {
2319
+	    	var_dump($e);
2320
+	    }
1704 2321
 	    if ($n > 0) {
1705 2322
 		$reset = 0;
1706 2323
 		foreach ($read as $nb => $r) {
@@ -1722,13 +2339,17 @@  discard block
 block discarded – undo
1722 2339
 		    if ($buffer !== FALSE) {
1723 2340
 			if ($format === 'vrstcp') {
1724 2341
 			    $buffer = explode('},{',$buffer);
1725
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2342
+			} else {
2343
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2344
+			}
1726 2345
 		    }
1727 2346
 		    // SBS format is CSV format
1728 2347
 		    if ($buffer !== FALSE && $buffer !== '') {
1729 2348
 			$tt[$format] = 0;
1730 2349
 			if ($format === 'acarssbs3') {
1731
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2350
+			    if ($globalDebug) {
2351
+			    	echo 'ACARS : '.$buffer."\n";
2352
+			    }
1732 2353
 			    $ACARS->add(trim($buffer));
1733 2354
 			    $ACARS->deleteLiveAcarsData();
1734 2355
 			} elseif ($format === 'raw') {
@@ -1738,9 +2359,15 @@  discard block
 block discarded – undo
1738 2359
 				//if (!empty($data)) print_r($data);
1739 2360
 				$data['datetime'] = date('Y-m-d H:i:s');
1740 2361
 				$data['format_source'] = 'raw';
1741
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1742
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1743
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2362
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2363
+					$data['source_name'] = $globalSources[$nb]['name'];
2364
+				}
2365
+				if (isset($globalSources[$nb]['sourcestats'])) {
2366
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2367
+				}
2368
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2369
+					$data['noarchive'] = true;
2370
+				}
1744 2371
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1745 2372
 				$SI->add($data);
1746 2373
 				unset($data);
@@ -1748,22 +2375,54 @@  discard block
 block discarded – undo
1748 2375
 			} elseif ($format === 'ais') {
1749 2376
 			    $ais_data = $AIS->parse_line(trim($buffer));
1750 2377
 			    $data = array();
1751
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1752
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1753
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1754
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1755
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1756
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1757
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1758
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1759
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1760
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1761
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1762
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1763
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1764
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1765
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1766
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2378
+			    if (isset($ais_data['ident'])) {
2379
+			    	$data['ident'] = $ais_data['ident'];
2380
+			    }
2381
+			    if (isset($ais_data['mmsi'])) {
2382
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2383
+			    }
2384
+			    if (isset($ais_data['speed'])) {
2385
+			    	$data['speed'] = $ais_data['speed'];
2386
+			    }
2387
+			    if (isset($ais_data['heading'])) {
2388
+			    	$data['heading'] = $ais_data['heading'];
2389
+			    }
2390
+			    if (isset($ais_data['latitude'])) {
2391
+			    	$data['latitude'] = $ais_data['latitude'];
2392
+			    }
2393
+			    if (isset($ais_data['longitude'])) {
2394
+			    	$data['longitude'] = $ais_data['longitude'];
2395
+			    }
2396
+			    if (isset($ais_data['status'])) {
2397
+			    	$data['status'] = $ais_data['status'];
2398
+			    }
2399
+			    if (isset($ais_data['statusid'])) {
2400
+			    	$data['status_id'] = $ais_data['statusid'];
2401
+			    }
2402
+			    if (isset($ais_data['type'])) {
2403
+			    	$data['type'] = $ais_data['type'];
2404
+			    }
2405
+			    if (isset($ais_data['imo'])) {
2406
+			    	$data['imo'] = $ais_data['imo'];
2407
+			    }
2408
+			    if (isset($ais_data['callsign'])) {
2409
+			    	$data['callsign'] = $ais_data['callsign'];
2410
+			    }
2411
+			    if (isset($ais_data['destination'])) {
2412
+			    	$data['arrival_code'] = $ais_data['destination'];
2413
+			    }
2414
+			    if (isset($ais_data['eta_ts'])) {
2415
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2416
+			    }
2417
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2418
+			    	$data['noarchive'] = true;
2419
+			    }
2420
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2421
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2422
+			    }
2423
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2424
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2425
+			    }
1767 2426
 
1768 2427
 			    if (isset($ais_data['timestamp'])) {
1769 2428
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1772,7 +2431,9 @@  discard block
 block discarded – undo
1772 2431
 			    }
1773 2432
 			    $data['format_source'] = 'aisnmea';
1774 2433
     			    $data['id_source'] = $id_source;
1775
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2434
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2435
+			    	$MI->add($data);
2436
+			    }
1776 2437
 			    unset($data);
1777 2438
                         } elseif ($format === 'flightgearsp') {
1778 2439
                     	    //echo $buffer."\n";
@@ -1790,17 +2451,25 @@  discard block
 block discarded – undo
1790 2451
 				$data['speed'] = round($line[5]*1.94384);
1791 2452
 				$data['datetime'] = date('Y-m-d H:i:s');
1792 2453
 				$data['format_source'] = 'flightgearsp';
1793
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1794
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2454
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2455
+					$data['noarchive'] = true;
2456
+				}
2457
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2458
+					$SI->add($data);
2459
+				}
1795 2460
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1796 2461
 			    }
1797 2462
                         } elseif ($format === 'acars') {
1798
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2463
+                    	    if ($globalDebug) {
2464
+                    	    	echo 'ACARS : '.$buffer."\n";
2465
+                    	    }
1799 2466
 			    $ACARS->add(trim($buffer));
1800 2467
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1801 2468
 			    $ACARS->deleteLiveAcarsData();
1802 2469
 			} elseif ($format === 'acarsjsonudp') {
1803
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2470
+			    if ($globalDebug) {
2471
+			    	echo 'ACARS : '.$buffer."\n";
2472
+			    }
1804 2473
                             $line = json_decode(trim($buffer), true);
1805 2474
                             if (!empty($line)) {
1806 2475
 				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
@@ -1825,8 +2494,12 @@  discard block
 block discarded – undo
1825 2494
 				    $aircraft_type = $line[10];
1826 2495
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1827 2496
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1828
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1829
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2497
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2498
+				    	$data['noarchive'] = true;
2499
+				    }
2500
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2501
+				    	$SI->add($data);
2502
+				    }
1830 2503
 				}
1831 2504
 			    }
1832 2505
 			} elseif ($format === 'beast') {
@@ -1836,28 +2509,62 @@  discard block
 block discarded – undo
1836 2509
 			    foreach($buffer as $all_data) {
1837 2510
 				$line = json_decode('{'.$all_data.'}',true);
1838 2511
 				$data = array();
1839
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1840
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1841
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1842
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1843
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1844
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1845
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2512
+				if (isset($line['Icao'])) {
2513
+					$data['hex'] = $line['Icao'];
2514
+				}
2515
+				// hex
2516
+				if (isset($line['Call'])) {
2517
+					$data['ident'] = $line['Call'];
2518
+				}
2519
+				// ident
2520
+				if (isset($line['Alt'])) {
2521
+					$data['altitude'] = $line['Alt'];
2522
+				}
2523
+				// altitude
2524
+				if (isset($line['Spd'])) {
2525
+					$data['speed'] = $line['Spd'];
2526
+				}
2527
+				// speed
2528
+				if (isset($line['Trak'])) {
2529
+					$data['heading'] = $line['Trak'];
2530
+				}
2531
+				// heading
2532
+				if (isset($line['Lat'])) {
2533
+					$data['latitude'] = $line['Lat'];
2534
+				}
2535
+				// lat
2536
+				if (isset($line['Long'])) {
2537
+					$data['longitude'] = $line['Long'];
2538
+				}
2539
+				// long
1846 2540
 				//$data['verticalrate'] = $line['']; // verticale rate
1847
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2541
+				if (isset($line['Sqk'])) {
2542
+					$data['squawk'] = $line['Sqk'];
2543
+				}
2544
+				// squawk
1848 2545
 				$data['emergency'] = ''; // emergency
1849
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2546
+				if (isset($line['Reg'])) {
2547
+					$data['registration'] = $line['Reg'];
2548
+				}
1850 2549
 				/*
1851 2550
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1852 2551
 				else $data['datetime'] = date('Y-m-d H:i:s');
1853 2552
 				*/
1854 2553
 				$data['datetime'] = date('Y-m-d H:i:s');
1855
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2554
+				if (isset($line['Type'])) {
2555
+					$data['aircraft_icao'] = $line['Type'];
2556
+				}
1856 2557
 		    		$data['format_source'] = 'vrstcp';
1857 2558
 				$data['id_source'] = $id_source;
1858
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1859
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1860
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2559
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2560
+					$data['noarchive'] = true;
2561
+				}
2562
+				if (isset($value['name']) && $value['name'] != '') {
2563
+					$data['source_name'] = $value['name'];
2564
+				}
2565
+				if (isset($data['latitude']) && isset($data['hex'])) {
2566
+					$SI->add($data);
2567
+				}
1861 2568
 				unset($data);
1862 2569
 			    }
1863 2570
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1870,22 +2577,46 @@  discard block
 block discarded – undo
1870 2577
     				$data['hex'] = $lined['hexid'];
1871 2578
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1872 2579
     				$data['datetime'] = date('Y-m-d H:i:s');;
1873
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1874
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1875
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1876
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1877
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1878
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1879
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2580
+    				if (isset($lined['ident'])) {
2581
+    					$data['ident'] = $lined['ident'];
2582
+    				}
2583
+    				if (isset($lined['lat'])) {
2584
+    					$data['latitude'] = $lined['lat'];
2585
+    				}
2586
+    				if (isset($lined['lon'])) {
2587
+    					$data['longitude'] = $lined['lon'];
2588
+    				}
2589
+    				if (isset($lined['speed'])) {
2590
+    					$data['speed'] = $lined['speed'];
2591
+    				}
2592
+    				if (isset($lined['squawk'])) {
2593
+    					$data['squawk'] = $lined['squawk'];
2594
+    				}
2595
+    				if (isset($lined['alt'])) {
2596
+    					$data['altitude'] = $lined['alt'];
2597
+    				}
2598
+    				if (isset($lined['heading'])) {
2599
+    					$data['heading'] = $lined['heading'];
2600
+    				}
1880 2601
     				$data['id_source'] = $id_source;
1881 2602
     				$data['format_source'] = 'tsv';
1882
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1883
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1884
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1885
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2603
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2604
+    					$data['source_name'] = $globalSources[$nb]['name'];
2605
+    				}
2606
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2607
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2608
+    				}
2609
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2610
+					$data['noarchive'] = true;
2611
+				}
2612
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2613
+    					$SI->add($data);
2614
+    				}
1886 2615
     				unset($lined);
1887 2616
     				unset($data);
1888
-    			    } else $error = true;
2617
+    			    } else {
2618
+    			    	$error = true;
2619
+    			    }
1889 2620
 			} elseif ($format === 'aprs' && $use_aprs) {
1890 2621
 			    if ($aprs_connect === 0) {
1891 2622
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1911,47 +2642,96 @@  discard block
 block discarded – undo
1911 2642
 				    $aprs_last_tx = time();
1912 2643
 				    $data = array();
1913 2644
 				    //print_r($line);
1914
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1915
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1916
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1917
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1918
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1919
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1920
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1921
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1922
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1923
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2645
+				    if (isset($line['address'])) {
2646
+				    	$data['hex'] = $line['address'];
2647
+				    }
2648
+				    if (isset($line['mmsi'])) {
2649
+				    	$data['mmsi'] = $line['mmsi'];
2650
+				    }
2651
+				    if (isset($line['imo'])) {
2652
+				    	$data['imo'] = $line['imo'];
2653
+				    }
2654
+				    if (isset($line['squawk'])) {
2655
+				    	$data['squawk'] = $line['squawk'];
2656
+				    }
2657
+				    if (isset($line['arrival_code'])) {
2658
+				    	$data['arrival_code'] = $line['arrival_code'];
2659
+				    }
2660
+				    if (isset($line['arrival_date'])) {
2661
+				    	$data['arrival_date'] = $line['arrival_date'];
2662
+				    }
2663
+				    if (isset($line['typeid'])) {
2664
+				    	$data['type_id'] = $line['typeid'];
2665
+				    }
2666
+				    if (isset($line['statusid'])) {
2667
+				    	$data['status_id'] = $line['statusid'];
2668
+				    }
2669
+				    if (isset($line['timestamp'])) {
2670
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2671
+				    } else {
2672
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2673
+				    }
1924 2674
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1925
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2675
+				    if (isset($line['ident'])) {
2676
+				    	$data['ident'] = $line['ident'];
2677
+				    }
1926 2678
 				    $data['latitude'] = $line['latitude'];
1927 2679
 				    $data['longitude'] = $line['longitude'];
1928 2680
 				    //$data['verticalrate'] = $line[16];
1929
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2681
+				    if (isset($line['speed'])) {
2682
+				    	$data['speed'] = $line['speed'];
2683
+				    }
1930 2684
 				    //else $data['speed'] = 0;
1931
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1932
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1933
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2685
+				    if (isset($line['altitude'])) {
2686
+				    	$data['altitude'] = $line['altitude'];
2687
+				    }
2688
+				    if (isset($line['comment'])) {
2689
+				    	$data['comment'] = $line['comment'];
2690
+				    }
2691
+				    if (isset($line['symbol'])) {
2692
+				    	$data['type'] = $line['symbol'];
2693
+				    }
1934 2694
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1935 2695
 				    
1936
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2696
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2697
+				    	$data['heading'] = $line['heading'];
2698
+				    }
1937 2699
 				    //else echo 'No heading...'."\n";
1938 2700
 				    //else $data['heading'] = 0;
1939
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2701
+				    if (isset($line['stealth'])) {
2702
+				    	$data['aircraft_type'] = $line['stealth'];
2703
+				    }
1940 2704
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1941
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1942
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1943
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1944
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2705
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2706
+				    	$data['noarchive'] = true;
2707
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2708
+				    	$data['noarchive'] = false;
2709
+				    }
2710
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2711
+				    	$data['noarchive'] = true;
2712
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2713
+				    	$data['noarchive'] = false;
2714
+				    }
1945 2715
     				    $data['id_source'] = $id_source;
1946
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1947
-				    else $data['format_source'] = 'aprs';
2716
+    				    if (isset($line['format_source'])) {
2717
+    				    	$data['format_source'] = $line['format_source'];
2718
+    				    } else {
2719
+				    	$data['format_source'] = 'aprs';
2720
+				    }
1948 2721
 				    $data['source_name'] = $line['source'];
1949
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1950
-				    else $data['source_type'] = 'flarm';
1951
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2722
+				    if (isset($line['source_type'])) {
2723
+				    	$data['source_type'] = $line['source_type'];
2724
+				    } else {
2725
+				    	$data['source_type'] = 'flarm';
2726
+				    }
2727
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2728
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2729
+    				    }
1952 2730
 				    $currentdate = date('Y-m-d H:i:s');
1953 2731
 				    $aprsdate = strtotime($data['datetime']);
1954
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2732
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2733
+				    	$data['altitude_relative'] = 'AMSL';
2734
+				    }
1955 2735
 				    // Accept data if time <= system time + 20s
1956 2736
 				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1957 2737
 				    if (
@@ -1963,7 +2743,9 @@  discard block
 block discarded – undo
1963 2743
 					$send = $SI->add($data);
1964 2744
 				    } elseif ($data['source_type'] === 'ais') {
1965 2745
 					$data['type'] = '';
1966
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2746
+					if (isset($globalMarine) && $globalMarine) {
2747
+						$send = $MI->add($data);
2748
+					}
1967 2749
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1968 2750
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1969 2751
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1971,8 +2753,12 @@  discard block
 block discarded – undo
1971 2753
 					    $line['symbol'] === 'Glider' || 
1972 2754
 					    $line['symbol'] === 'No. Plane' || 
1973 2755
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1974
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1975
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2756
+					    if ($line['symbol'] === 'Ballon') {
2757
+					    	$data['aircraft_icao'] = 'BALL';
2758
+					    }
2759
+					    if ($line['symbol'] === 'Glider') {
2760
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2761
+					    }
1976 2762
 					    $send = $SI->add($data);
1977 2763
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1978 2764
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -2003,9 +2789,13 @@  discard block
 block discarded – undo
2003 2789
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
2004 2790
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
2005 2791
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
2006
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2792
+					if (isset($globalTracker) && $globalTracker) {
2793
+						$send = $TI->add($data);
2794
+					}
2007 2795
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2008
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2796
+					if (!isset($data['altitude'])) {
2797
+						$data['altitude'] = 0;
2798
+					}
2009 2799
 					$Source->deleteOldLocationByType('gs');
2010 2800
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
2011 2801
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -2014,7 +2804,9 @@  discard block
 block discarded – undo
2014 2804
 					}
2015 2805
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2016 2806
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2017
-					if ($globalDebug) echo '# Weather Station added'."\n";
2807
+					if ($globalDebug) {
2808
+						echo '# Weather Station added'."\n";
2809
+					}
2018 2810
 					$Source->deleteOldLocationByType('wx');
2019 2811
 					$weather_data = json_encode($line);
2020 2812
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -2024,7 +2816,9 @@  discard block
 block discarded – undo
2024 2816
 					}
2025 2817
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2026 2818
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2027
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2819
+					if ($globalDebug) {
2820
+						echo '☈ Lightning added'."\n";
2821
+					}
2028 2822
 					$Source->deleteOldLocationByType('lightning');
2029 2823
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2030 2824
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -2036,8 +2830,7 @@  discard block
 block discarded – undo
2036 2830
 				    	print_r($line);
2037 2831
 				    }
2038 2832
 				    unset($data);
2039
-				}
2040
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2833
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2041 2834
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2042 2835
 				}
2043 2836
 				/*
@@ -2046,7 +2839,9 @@  discard block
 block discarded – undo
2046 2839
 				}
2047 2840
 				*/
2048 2841
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2049
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2842
+				elseif ($line === true && $globalDebug) {
2843
+					echo '!! Failed : '.$buffer."!!\n";
2844
+				}
2050 2845
 				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2051 2846
 					$Source->deleteOldLocationByType('lightning');
2052 2847
 					$Source->deleteOldLocationByType('wx');
@@ -2083,27 +2878,47 @@  discard block
 block discarded – undo
2083 2878
     				$data['ground'] = $line[21];
2084 2879
     				$data['emergency'] = $line[19];
2085 2880
     				$data['format_source'] = 'sbs';
2086
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2087
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2088
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2089
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2881
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2882
+					$data['source_name'] = $globalSources[$nb]['name'];
2883
+				} elseif ($line[0] == 'MLAT') {
2884
+					$data['source_name'] = 'MLAT';
2885
+				}
2886
+				if (isset($globalSources[$nb]['sourcestats'])) {
2887
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2888
+				}
2889
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2890
+					$data['noarchive'] = true;
2891
+				}
2090 2892
     				$data['id_source'] = $id_source;
2091
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2092
-    				else $error = true;
2893
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2894
+    					$send = $SI->add($data);
2895
+    				} else {
2896
+    					$error = true;
2897
+    				}
2093 2898
     				unset($data);
2094
-    			    } else $error = true;
2899
+    			    } else {
2900
+    			    	$error = true;
2901
+    			    }
2095 2902
 			    if ($error) {
2096 2903
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2097
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2904
+					if ($globalDebug) {
2905
+						echo "Not a message. Ignoring... \n";
2906
+					}
2098 2907
 				} else {
2099
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2908
+					if ($globalDebug) {
2909
+						echo "Wrong line format. Ignoring... \n";
2910
+					}
2100 2911
 					if ($globalDebug) {
2101 2912
 						echo $buffer;
2102 2913
 						//print_r($line);
2103 2914
 					}
2104 2915
 					//socket_close($r);
2105
-					if ($globalDebug) echo "Reconnect after an error...\n";
2106
-					if ($format === 'aprs') $aprs_connect = 0;
2916
+					if ($globalDebug) {
2917
+						echo "Reconnect after an error...\n";
2918
+					}
2919
+					if ($format === 'aprs') {
2920
+						$aprs_connect = 0;
2921
+					}
2107 2922
 					$sourceer[$nb] = $globalSources[$nb];
2108 2923
 					connect_all($sourceer);
2109 2924
 					$sourceer = array();
@@ -2111,10 +2926,14 @@  discard block
 block discarded – undo
2111 2926
 			    }
2112 2927
 			}
2113 2928
 			// Sleep for xxx microseconds
2114
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2929
+			if (isset($globalSBSSleep)) {
2930
+				usleep($globalSBSSleep);
2931
+			}
2115 2932
 		    } else {
2116 2933
 			if ($format === 'flightgearmp') {
2117
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2934
+			    	if ($globalDebug) {
2935
+			    		echo "Reconnect FlightGear MP...";
2936
+			    	}
2118 2937
 				//@socket_close($r);
2119 2938
 				sleep($globalMinFetch);
2120 2939
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2123,10 +2942,15 @@  discard block
 block discarded – undo
2123 2942
 				break;
2124 2943
 				
2125 2944
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2126
-			    if (isset($tt[$format])) $tt[$format]++;
2127
-			    else $tt[$format] = 0;
2945
+			    if (isset($tt[$format])) {
2946
+			    	$tt[$format]++;
2947
+			    } else {
2948
+			    	$tt[$format] = 0;
2949
+			    }
2128 2950
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2129
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2951
+				if ($globalDebug) {
2952
+					echo "ERROR : Reconnect ".$format."...";
2953
+				}
2130 2954
 				//@socket_close($r);
2131 2955
 				sleep(2);
2132 2956
 				$aprs_connect = 0;
@@ -2144,11 +2968,17 @@  discard block
 block discarded – undo
2144 2968
 	    } else {
2145 2969
 		$error = socket_strerror(socket_last_error());
2146 2970
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2147
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2148
-			if (isset($globalDebug)) echo "Restarting...\n";
2971
+			if ($globalDebug) {
2972
+				echo "ERROR : socket_select give this error ".$error . "\n";
2973
+			}
2974
+			if (isset($globalDebug)) {
2975
+				echo "Restarting...\n";
2976
+			}
2149 2977
 			// Restart the script if possible
2150 2978
 			if (is_array($sockets)) {
2151
-			    if ($globalDebug) echo "Shutdown all sockets...";
2979
+			    if ($globalDebug) {
2980
+			    	echo "Shutdown all sockets...";
2981
+			    }
2152 2982
 			    
2153 2983
 			    foreach ($sockets as $sock) {
2154 2984
 				@socket_shutdown($sock,2);
@@ -2156,23 +2986,39 @@  discard block
 block discarded – undo
2156 2986
 			    }
2157 2987
 			    
2158 2988
 			}
2159
-			if ($globalDebug) echo "Waiting...";
2989
+			if ($globalDebug) {
2990
+				echo "Waiting...";
2991
+			}
2160 2992
 			sleep(2);
2161 2993
 			$time = time();
2162 2994
 			//connect_all($hosts);
2163 2995
 			$aprs_connect = 0;
2164
-			if ($reset%5 === 0) sleep(20);
2165
-			if ($reset > 100) exit('Too many attempts...');
2166
-			if ($globalDebug) echo "Restart all connections...";
2996
+			if ($reset%5 === 0) {
2997
+				sleep(20);
2998
+			}
2999
+			if ($reset > 100) {
3000
+				exit('Too many attempts...');
3001
+			}
3002
+			if ($globalDebug) {
3003
+				echo "Restart all connections...";
3004
+			}
2167 3005
 			connect_all($globalSources);
2168 3006
 		}
2169 3007
 	    }
2170 3008
 	}
2171 3009
 	if ($globalDaemon === false) {
2172
-	    if ($globalDebug) echo 'Check all...'."\n";
2173
-	    if (isset($SI)) $SI->checkAll();
2174
-	    if (isset($TI)) $TI->checkAll();
2175
-	    if (isset($MI)) $MI->checkAll();
3010
+	    if ($globalDebug) {
3011
+	    	echo 'Check all...'."\n";
3012
+	    }
3013
+	    if (isset($SI)) {
3014
+	    	$SI->checkAll();
3015
+	    }
3016
+	    if (isset($TI)) {
3017
+	    	$TI->checkAll();
3018
+	    }
3019
+	    if (isset($MI)) {
3020
+	    	$MI->checkAll();
3021
+	    }
2176 3022
 	}
2177 3023
     }
2178 3024
 }
Please login to merge, or discard this patch.
search.php 1 patch
Braces   +158 added lines, -43 removed lines patch added patch discarded remove patch
@@ -46,8 +46,10 @@  discard block
 block discarded – undo
46 46
 			$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
47 47
 			$sql_date = $end_date;
48 48
 		}
49
-	} else $sql_date = '';
50
-}
49
+	} else {
50
+		$sql_date = '';
51
+	}
52
+	}
51 53
 
52 54
 if (isset($_GET['highest_altitude'])) {
53 55
 	//for altitude manipulation
@@ -61,8 +63,12 @@  discard block
 block discarded – undo
61 63
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
62 64
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
63 65
 		$sql_altitude = $start_altitude;
64
-	} else $sql_altitude = '';
65
-} else $sql_altitude = '';
66
+	} else {
67
+		$sql_altitude = '';
68
+	}
69
+	} else {
70
+	$sql_altitude = '';
71
+}
66 72
 
67 73
 //calculuation for the pagination
68 74
 if(!isset($_GET['limit']))
@@ -80,7 +86,7 @@  discard block
 block discarded – undo
80 86
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
81 87
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
82 88
 	}
83
-}  else {
89
+} else {
84 90
 	$limit_explode = explode(",", $_GET['limit']);
85 91
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
86 92
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -146,10 +152,15 @@  discard block
 block discarded – undo
146 152
 	$dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT);
147 153
 	$number_results = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
148 154
 	if ($dist != '') {
149
-		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934;
150
-		elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852;
155
+		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') {
156
+			$dist = $dist*1.60934;
157
+		} elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') {
158
+			$dist = $dist*1.852;
159
+		}
160
+	}
161
+	if (!isset($sql_date)) {
162
+		$sql_date = '';
151 163
 	}
152
-	if (!isset($sql_date)) $sql_date = '';
153 164
 	if ($archive == 1) {
154 165
 		if ($type == 'aircraft') {
155 166
 			$SpotterArchive = new SpotterArchive();
@@ -227,7 +238,10 @@  discard block
 block discarded – undo
227 238
 		if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
228 239
 		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
229 240
 		if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; }
230
-		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; }
241
+		if (isset($_GET['highlights'])) {
242
+			if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> ';
243
+		}
244
+		}
231 245
 		if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; }
232 246
 		if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; }
233 247
 		if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; }
@@ -371,7 +385,10 @@  discard block
 block discarded – undo
371 385
 			<div class="form-group">
372 386
 				<label class="control-label col-sm-2"><?php echo _("Keywords"); ?></label>
373 387
 				<div class="col-sm-10">
374
-					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) print $q; ?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
388
+					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) {
389
+	print $q;
390
+}
391
+?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
375 392
 				</div>
376 393
 			</div>
377 394
 		</fieldset>
@@ -390,7 +407,10 @@  discard block
 block discarded – undo
390 407
 					    </select>
391 408
 					</div>
392 409
 				</div>
393
-				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
410
+				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) {
411
+	print $manufacturer;
412
+}
413
+?>')</script>
394 414
 				<div class="form-group">
395 415
 					<label class="control-label col-sm-2"><?php echo _("Type"); ?></label>
396 416
 						<div class="col-sm-10">
@@ -399,11 +419,17 @@  discard block
 block discarded – undo
399 419
 							</select>
400 420
 						</div>
401 421
 				</div>
402
-				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
422
+				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) {
423
+	print $aircraft_icao;
424
+}
425
+?>');</script>
403 426
 				<div class="form-group">
404 427
 					<label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> 
405 428
 					<div class="col-sm-10">
406
-						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) print $registration; ?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
429
+						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) {
430
+	print $registration;
431
+}
432
+?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
407 433
 					</div>
408 434
 				</div>
409 435
 <?php
@@ -412,22 +438,31 @@  discard block
 block discarded – undo
412 438
 				<div class="form-group">
413 439
 					<label class="control-label col-sm-2"><?php echo _("Pilot id"); ?></label> 
414 440
 					<div class="col-sm-10">
415
-						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) print $pilot_id; ?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
441
+						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) {
442
+	print $pilot_id;
443
+}
444
+?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
416 445
 					</div>
417 446
 				</div>
418 447
 				<div class="form-group">
419 448
 					<label class="control-label col-sm-2"><?php echo _("Pilot name"); ?></label> 
420 449
 					<div class="col-sm-10">
421
-						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) print $pilot_name; ?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
450
+						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) {
451
+	print $pilot_name;
452
+}
453
+?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
422 454
 					</div>
423 455
 				</div>
424 456
 <?php
425
-	}else {
457
+	} else {
426 458
 ?>
427 459
 				<div class="form-group">
428 460
 					<label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> 
429 461
 					<div class="col-sm-10">
430
-						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) print $owner; ?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
462
+						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) {
463
+	print $owner;
464
+}
465
+?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
431 466
 					</div>
432 467
 				</div>
433 468
 <?php
@@ -435,8 +470,14 @@  discard block
 block discarded – undo
435 470
 ?>
436 471
 				<div class="form-group">
437 472
 					<div class="col-sm-offset-2 col-sm-10">
438
-					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
439
-					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label>
473
+					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
474
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
475
+}
476
+} ?>> <label for="highlights"><?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
477
+					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
478
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
479
+}
480
+} ?>> <?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label>
440 481
 					</div>
441 482
 				</div>
442 483
 			</fieldset>
@@ -450,7 +491,10 @@  discard block
 block discarded – undo
450 491
 						</select>
451 492
 					</div>
452 493
 				</div>
453
-				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script>
494
+				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) {
495
+	print $airline;
496
+}
497
+?>');</script>
454 498
 				<div class="form-group">
455 499
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
456 500
 					<div class="col-sm-10">
@@ -459,19 +503,34 @@  discard block
 block discarded – undo
459 503
 						</select>
460 504
 					</div>
461 505
 				</div>
462
-				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script>
506
+				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) {
507
+	print $airline_country;
508
+}
509
+?>');</script>
463 510
 				<div class="form-group">
464 511
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
465 512
 					<div class="col-sm-10">
466
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
513
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
514
+	print $callsign;
515
+}
516
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
467 517
 					</div>
468 518
 				</div>
469 519
 				<div class="form-group">
470 520
 					<div class="col-sm-offset-2 col-sm-10">
471 521
 						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
472
-						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
473
-						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
474
-						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
522
+						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) {
523
+	if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"';
524
+}
525
+} ?>> <?php echo _("Only Passenger airlines"); ?></label>
526
+						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) {
527
+	if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"';
528
+}
529
+} ?>> <?php echo _("Only Cargo airlines"); ?></label>
530
+						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) {
531
+	if ( $_GET['airline_type'] == "military"){ print 'checked="checked"';
532
+}
533
+} ?>> <?php echo _("Only Military airlines"); ?></label>
475 534
 					</div>
476 535
 				</div>
477 536
 			</fieldset>
@@ -485,7 +544,10 @@  discard block
 block discarded – undo
485 544
 						</select>
486 545
 					</div>
487 546
 				</div>
488
-				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
547
+				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) {
548
+	print $airport_icao;
549
+}
550
+?>');</script>
489 551
 				<div class="form-group">
490 552
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
491 553
 					<div class="col-sm-10">
@@ -494,7 +556,10 @@  discard block
 block discarded – undo
494 556
 						</select>
495 557
 					</div>
496 558
 				</div>
497
-				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script>
559
+				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) {
560
+	print $airport_country;
561
+}
562
+?>');</script>
498 563
 			</fieldset>
499 564
 			<fieldset>
500 565
 				<legend><?php echo _("Route"); ?></legend>
@@ -506,7 +571,10 @@  discard block
 block discarded – undo
506 571
 						</select>
507 572
 					</div>
508 573
 				</div>
509
-				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
574
+				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) {
575
+	print $departure_airport_route;
576
+}
577
+?>');</script>
510 578
 				<div class="form-group">
511 579
 					<label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> 
512 580
 					<div class="col-sm-10">
@@ -515,7 +583,10 @@  discard block
 block discarded – undo
515 583
 						</select>
516 584
 					</div>
517 585
 				</div>
518
-				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
586
+				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) {
587
+	print $arrival_airport_route;
588
+}
589
+?>');</script>
519 590
 			</fieldset>
520 591
 			<fieldset>
521 592
 				<legend><?php echo _("Altitude"); ?></legend>
@@ -565,19 +636,33 @@  discard block
 block discarded – undo
565 636
 				<div class="form-group">
566 637
 					<label class="control-label col-sm-2"><?php echo _("Latitude"); ?></label>
567 638
 					<div class="col-sm-10">
568
-						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) print $origlat; ?>" />
639
+						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) {
640
+	print $origlat;
641
+}
642
+?>" />
569 643
 					</div>
570 644
 				</div>
571 645
 				<div class="form-group">
572 646
 					<label class="control-label col-sm-2"><?php echo _("Longitude"); ?></label>
573 647
 					<div class="col-sm-10">
574
-						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) print $origlon; ?>" />
648
+						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) {
649
+	print $origlon;
650
+}
651
+?>" />
575 652
 					</div>
576 653
 				</div>
577 654
 				<div class="form-group">
578
-					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) print $globalDistanceUnit; else print 'km'; print ')'; ?></label>
655
+					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) {
656
+	print $globalDistanceUnit;
657
+} else {
658
+	print 'km';
659
+}
660
+print ')'; ?></label>
579 661
 					<div class="col-sm-10">
580
-						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) print $distance; ?>" />
662
+						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) {
663
+	print $distance;
664
+}
665
+?>" />
581 666
 					</div>
582 667
 				</div>
583 668
 			</fieldset>
@@ -588,7 +673,10 @@  discard block
 block discarded – undo
588 673
 				<div class="form-group">
589 674
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
590 675
 					<div class="col-sm-10">
591
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
676
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
677
+	print $callsign;
678
+}
679
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
592 680
 					</div>
593 681
 				</div>
594 682
 			</fieldset>
@@ -599,7 +687,10 @@  discard block
 block discarded – undo
599 687
 				<div class="form-group">
600 688
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
601 689
 					<div class="col-sm-10">
602
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
690
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
691
+	print $callsign;
692
+}
693
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
603 694
 					</div>
604 695
 				</div>
605 696
 			</fieldset>
@@ -610,7 +701,10 @@  discard block
 block discarded – undo
610 701
 				<div class="form-group">
611 702
 					<label class="control-label col-sm-2"><?php echo _("Captain id"); ?></label> 
612 703
 					<div class="col-sm-10">
613
-						<input type="text" name="captain_id" class="form-control" value="<?php if (isset($_GET['captain_id'])) print $captain_id; ?>" size="8" placeholder="<?php echo _("Captain id"); ?>" />
704
+						<input type="text" name="captain_id" class="form-control" value="<?php if (isset($_GET['captain_id'])) {
705
+	print $captain_id;
706
+}
707
+?>" size="8" placeholder="<?php echo _("Captain id"); ?>" />
614 708
 					</div>
615 709
 				</div>
616 710
 			</fieldset>
@@ -618,7 +712,10 @@  discard block
 block discarded – undo
618 712
 				<div class="form-group">
619 713
 					<label class="control-label col-sm-2"><?php echo _("Captain name"); ?></label> 
620 714
 					<div class="col-sm-10">
621
-						<input type="text" name="captain_name" class="form-control" value="<?php if (isset($_GET['captain_name'])) print $captain_name; ?>" size="8" placeholder="<?php echo _("Captain name"); ?>" />
715
+						<input type="text" name="captain_name" class="form-control" value="<?php if (isset($_GET['captain_name'])) {
716
+	print $captain_name;
717
+}
718
+?>" size="8" placeholder="<?php echo _("Captain name"); ?>" />
622 719
 					</div>
623 720
 				</div>
624 721
 			</fieldset>
@@ -626,7 +723,10 @@  discard block
 block discarded – undo
626 723
 				<div class="form-group">
627 724
 					<label class="control-label col-sm-2"><?php echo _("Race id"); ?></label> 
628 725
 					<div class="col-sm-10">
629
-						<input type="text" name="race_id" class="form-control" value="<?php if (isset($_GET['race_id'])) print $race_id; ?>" size="8" placeholder="<?php echo _("Race id"); ?>" />
726
+						<input type="text" name="race_id" class="form-control" value="<?php if (isset($_GET['race_id'])) {
727
+	print $race_id;
728
+}
729
+?>" size="8" placeholder="<?php echo _("Race id"); ?>" />
630 730
 					</div>
631 731
 				</div>
632 732
 			</fieldset>
@@ -634,7 +734,10 @@  discard block
 block discarded – undo
634 734
 				<div class="form-group">
635 735
 					<label class="control-label col-sm-2"><?php echo _("Race name"); ?></label> 
636 736
 					<div class="col-sm-10">
637
-						<input type="text" name="race_name" class="form-control" value="<?php if (isset($_GET['race_name'])) print $race_name; ?>" size="8" placeholder="<?php echo _("Race name"); ?>" />
737
+						<input type="text" name="race_name" class="form-control" value="<?php if (isset($_GET['race_name'])) {
738
+	print $race_name;
739
+}
740
+?>" size="8" placeholder="<?php echo _("Race name"); ?>" />
638 741
 					</div>
639 742
 				</div>
640 743
 			</fieldset>
@@ -645,7 +748,10 @@  discard block
 block discarded – undo
645 748
 				<div class="form-group">
646 749
 					<label class="control-label col-sm-2"><?php echo _("MMSI"); ?></label> 
647 750
 					<div class="col-sm-10">
648
-						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) print $mmsi; ?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
751
+						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) {
752
+	print $mmsi;
753
+}
754
+?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
649 755
 					</div>
650 756
 				</div>
651 757
 			</fieldset>
@@ -653,7 +759,10 @@  discard block
 block discarded – undo
653 759
 				<div class="form-group">
654 760
 					<label class="control-label col-sm-2"><?php echo _("IMO"); ?></label> 
655 761
 					<div class="col-sm-10">
656
-						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) print $imo; ?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
762
+						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) {
763
+	print $imo;
764
+}
765
+?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
657 766
 					</div>
658 767
 				</div>
659 768
 			</fieldset>
@@ -667,7 +776,10 @@  discard block
 block discarded – undo
667 776
 					<label class="control-label col-sm-2"><?php echo _("Start Date"); ?></label>
668 777
 					<div class="col-sm-10">
669 778
 						<div class='input-group date' id='datetimepicker1'>
670
-							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') print $start_date; ?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
779
+							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') {
780
+	print $start_date;
781
+}
782
+?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
671 783
 							<span class="input-group-addon">
672 784
 								<span class="glyphicon glyphicon-calendar"></span>
673 785
 							</span>
@@ -678,7 +790,10 @@  discard block
 block discarded – undo
678 790
 					<label class="control-label col-sm-2"><?php echo _("End Date"); ?></label>
679 791
 					<div class="col-sm-10">
680 792
 						<div class='input-group date' id='datetimepicker2'>
681
-						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') print $end_date; ?>" placeholder="<?php echo _("End Date/Time"); ?>" />
793
+						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') {
794
+	print $end_date;
795
+}
796
+?>" placeholder="<?php echo _("End Date/Time"); ?>" />
682 797
 						<span class="input-group-addon">
683 798
 							<span class="glyphicon glyphicon-calendar"></span>
684 799
 						</span>
Please login to merge, or discard this patch.