Completed
Push — master ( 138e82...9af14b )
by Yannick
21:48
created
require/class.APRS.php 1 patch
Braces   +307 added lines, -110 removed lines patch added patch discarded remove patch
@@ -183,17 +183,23 @@  discard block
 block discarded – undo
183 183
 	
184 184
 	/* Check that end was found and body has at least one byte. */
185 185
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
186
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
186
+	    if ($globalDebug) {
187
+	    	echo '!!! APRS invalid : '.$input."\n";
188
+	    }
187 189
 	    return false;
188 190
 	}
189 191
 	
190
-	if ($debug) echo 'input : '.$input."\n";
192
+	if ($debug) {
193
+		echo 'input : '.$input."\n";
194
+	}
191 195
 	/* Save header and body. */
192 196
 	$body = substr($input,$splitpos+1,$input_len);
193 197
 	$body_len = strlen($body);
194 198
 	$header = substr($input,0,$splitpos);
195 199
 	//$header_len = strlen($header);
196
-	if ($debug) echo 'header : '.$header."\n";
200
+	if ($debug) {
201
+		echo 'header : '.$header."\n";
202
+	}
197 203
 	
198 204
 	/* Parse source, target and path. */
199 205
 	//FLRDF0A52>APRS,qAS,LSTB
@@ -207,11 +213,15 @@  discard block
 block discarded – undo
207 213
 		$result['format_source'] = 'famaprs';
208 214
 		$result['source_type'] = 'ais';
209 215
 	    } else {
210
-		if ($debug) echo 'ident : '.$ident."\n";
216
+		if ($debug) {
217
+			echo 'ident : '.$ident."\n";
218
+		}
211 219
 		$result['ident'] = $ident;
212 220
 	    }
213 221
 	} else {
214
-	    if ($debug) 'No ident'."\n";
222
+	    if ($debug) {
223
+	    	'No ident'."\n";
224
+	    }
215 225
 	    return false;
216 226
 	}
217 227
 	$elements = explode(',',$all_elements);
@@ -222,7 +232,9 @@  discard block
 block discarded – undo
222 232
 	        //echo "ok";
223 233
 	        //if ($element == 'TCPIP*') return false;
224 234
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
225
-		if ($debug) echo 'element : '.$element."\n";
235
+		if ($debug) {
236
+			echo 'element : '.$element."\n";
237
+		}
226 238
 		return false;
227 239
 	    }
228 240
 	    /*
@@ -235,13 +247,17 @@  discard block
 block discarded – undo
235 247
 	}
236 248
 	
237 249
 	$type = substr($body,0,1);
238
-	if ($debug) echo 'type : '.$type."\n";
250
+	if ($debug) {
251
+		echo 'type : '.$type."\n";
252
+	}
239 253
 	if ($type == ';') {
240 254
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
241 255
 			$result['address'] = trim(substr($body,1,9));
242 256
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
243 257
 			$result['mmsi'] = trim(substr($body,1,9));
244
-		} else $result['ident'] = trim(substr($body,1,9));
258
+		} else {
259
+			$result['ident'] = trim(substr($body,1,9));
260
+		}
245 261
 	} elseif ($type == ',') {
246 262
 		// Invalid data or test data
247 263
 		return false;
@@ -310,7 +326,9 @@  discard block
 block discarded – undo
310 326
 		//$symbol_table = $matches[4];
311 327
 		$lat = intval($lat_deg);
312 328
 		$lon = intval($lon_deg);
313
-		if ($lat > 89 || $lon > 179) return false;
329
+		if ($lat > 89 || $lon > 179) {
330
+			return false;
331
+		}
314 332
 	    
315 333
 	    /*
316 334
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -320,8 +338,12 @@  discard block
 block discarded – undo
320 338
 	    */
321 339
 		$latitude = $lat + floatval($lat_min)/60;
322 340
 		$longitude = $lon + floatval($lon_min)/60;
323
-		if ($sind == 'S') $latitude = 0-$latitude;
324
-		if ($wind == 'W') $longitude = 0-$longitude;
341
+		if ($sind == 'S') {
342
+			$latitude = 0-$latitude;
343
+		}
344
+		if ($wind == 'W') {
345
+			$longitude = 0-$longitude;
346
+		}
325 347
 		$result['latitude'] = $latitude;
326 348
 		$result['longitude'] = $longitude;
327 349
 		$body_parse = substr($body_parse,18);
@@ -349,8 +371,11 @@  discard block
 block discarded – undo
349 371
 			//echo 'find'."\n";
350 372
 			$body_split = str_split($body_parse);
351 373
 			$symbol_code = $body_split[0];
352
-			if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code;
353
-			else $symbol_code = '\\'.$symbol_code;
374
+			if (!isset($symbolll) || $symbolll == '/') {
375
+				$symbol_code = '/'.$symbol_code;
376
+			} else {
377
+				$symbol_code = '\\'.$symbol_code;
378
+			}
354 379
 		//'
355 380
 		//}
356 381
 		//echo $body_parse;
@@ -359,7 +384,9 @@  discard block
 block discarded – undo
359 384
 			$body_parse = substr($body_parse,1);
360 385
 			$body_parse_len = strlen($body_parse);
361 386
 			$result['symbol_code'] = $symbol_code;
362
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
387
+			if (isset($this->symbols[$symbol_code])) {
388
+				$result['symbol'] = $this->symbols[$symbol_code];
389
+			}
363 390
 			if ($symbol_code != '_') {
364 391
 			}
365 392
 		    //$body_parse = substr($body_parse,1);
@@ -370,7 +397,9 @@  discard block
 block discarded – undo
370 397
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
371 398
 		    	    $course = substr($body_parse,0,3);
372 399
 		    	    $tmp_s = intval($course);
373
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
400
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
401
+		    	    	$result['heading'] = intval($course);
402
+		    	    }
374 403
 		    	    $speed = substr($body_parse,4,3);
375 404
 		    	    if ($speed != '...') {
376 405
 		    		//$result['speed'] = round($speed*1.852);
@@ -411,10 +440,16 @@  discard block
 block discarded – undo
411 440
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
412 441
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
413 442
 			    
414
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
415
-				else $result['latitude'] += $lat_off;
416
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
417
-				else $result['longitude'] += $lon_off;
443
+				if ($result['latitude'] < 0) {
444
+					$result['latitude'] -= $lat_off;
445
+				} else {
446
+					$result['latitude'] += $lat_off;
447
+				}
448
+				if ($result['longitude'] < 0) {
449
+					$result['longitude'] -= $lon_off;
450
+				} else {
451
+					$result['longitude'] += $lon_off;
452
+				}
418 453
 			    }
419 454
 			    
420 455
 		            $body_parse = substr($body_parse,6);
@@ -456,27 +491,48 @@  discard block
 block discarded – undo
456 491
 			$address = substr($id,2);
457 492
 			//print_r($matches);
458 493
 			$addressType = (intval(substr($id,0,2),16))&3;
459
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
460
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
461
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
462
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
494
+			if ($addressType == 0) {
495
+				$result['addresstype'] = "RANDOM";
496
+			} elseif ($addressType == 1) {
497
+				$result['addresstype'] = "ICAO";
498
+			} elseif ($addressType == 2) {
499
+				$result['addresstype'] = "FLARM";
500
+			} elseif ($addressType == 3) {
501
+				$result['addresstype'] = "OGN";
502
+			}
463 503
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
464 504
 			$result['aircrafttype_code'] = $aircraftType;
465
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
466
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
467
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
468
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
469
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
470
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
471
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
472
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
473
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
474
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
475
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
476
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
477
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
478
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
479
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
505
+			if ($aircraftType == 0) {
506
+				$result['aircrafttype'] = "UNKNOWN";
507
+			} elseif ($aircraftType == 1) {
508
+				$result['aircrafttype'] = "GLIDER";
509
+			} elseif ($aircraftType == 2) {
510
+				$result['aircrafttype'] = "TOW_PLANE";
511
+			} elseif ($aircraftType == 3) {
512
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
513
+			} elseif ($aircraftType == 4) {
514
+				$result['aircrafttype'] = "PARACHUTE";
515
+			} elseif ($aircraftType == 5) {
516
+				$result['aircrafttype'] = "DROP_PLANE";
517
+			} elseif ($aircraftType == 6) {
518
+				$result['aircrafttype'] = "HANG_GLIDER";
519
+			} elseif ($aircraftType == 7) {
520
+				$result['aircrafttype'] = "PARA_GLIDER";
521
+			} elseif ($aircraftType == 8) {
522
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
523
+			} elseif ($aircraftType == 9) {
524
+				$result['aircrafttype'] = "JET_AIRCRAFT";
525
+			} elseif ($aircraftType == 10) {
526
+				$result['aircrafttype'] = "UFO";
527
+			} elseif ($aircraftType == 11) {
528
+				$result['aircrafttype'] = "BALLOON";
529
+			} elseif ($aircraftType == 12) {
530
+				$result['aircrafttype'] = "AIRSHIP";
531
+			} elseif ($aircraftType == 13) {
532
+				$result['aircrafttype'] = "UAV";
533
+			} elseif ($aircraftType == 15) {
534
+				$result['aircrafttype'] = "STATIC_OBJECT";
535
+			}
480 536
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
481 537
 			$result['stealth'] = $stealth;
482 538
 			$result['address'] = $address;
@@ -516,79 +572,183 @@  discard block
 block discarded – undo
516 572
 		    //g012t088r000p000P000h38b10110
517 573
 		    //g011t086r000p000P000h29b10198
518 574
 		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
519
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
520
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
521
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
522
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
523
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
524
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
525
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
575
+			if ($matches[1] != '...') {
576
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
577
+			}
578
+			if ($matches[2] != '...') {
579
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
580
+			}
581
+			if ($matches[3] != '...') {
582
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
583
+			}
584
+			if ($matches[4] != '...') {
585
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
586
+			}
587
+			if ($matches[5] != '...') {
588
+				$result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
589
+			}
590
+			if ($matches[6] != '...') {
591
+				$result['humidity'] = intval($matches[6]);
592
+			}
593
+			if ($matches[7] != '...') {
594
+				$result['pressure'] = round((intval($matches[7])/10),1);
595
+			}
526 596
 		        $body_parse = substr($body_parse,strlen($matches[0]));
527 597
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
528
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
529
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
530
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
531
-			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
532
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
533
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
534
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
598
+			if ($matches[1] != '...') {
599
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
600
+			}
601
+			if ($matches[2] != '...') {
602
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
603
+			}
604
+			if ($matches[3] != '...') {
605
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
606
+			}
607
+			if ($matches[5] != '...') {
608
+				$result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
609
+			}
610
+			if ($matches[4] != '...') {
611
+				$result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
612
+			}
613
+			if ($matches[6] != '...') {
614
+				$result['humidity'] = intval($matches[6]);
615
+			}
616
+			if ($matches[7] != '...') {
617
+				$result['pressure'] = round((intval($matches[7])/10),1);
618
+			}
535 619
 		        $body_parse = substr($body_parse,strlen($matches[0]));
536 620
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
537
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
538
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
539
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
540
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
541
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
542
-			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
543
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
621
+			if ($matches[1] != '...') {
622
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
623
+			}
624
+			if ($matches[2] != '...') {
625
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
626
+			}
627
+			if ($matches[3] != '...') {
628
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
629
+			}
630
+			if ($matches[4] != '...') {
631
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
632
+			}
633
+			if ($matches[5] != '...') {
634
+				$result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
635
+			}
636
+			if ($matches[7] != '...') {
637
+				$result['humidity'] = intval($matches[7]);
638
+			}
639
+			if ($matches[6] != '...') {
640
+				$result['pressure'] = round((intval($matches[6])/10),1);
641
+			}
544 642
 		        $body_parse = substr($body_parse,strlen($matches[0]));
545 643
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
546
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
547
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
548
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
549
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
550
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
551
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
644
+			if ($matches[1] != '...') {
645
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
646
+			}
647
+			if ($matches[2] != '...') {
648
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
649
+			}
650
+			if ($matches[3] != '...') {
651
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
652
+			}
653
+			if ($matches[4] != '...') {
654
+				$result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
655
+			}
656
+			if ($matches[6] != '...') {
657
+				$result['humidity'] = intval($matches[6]);
658
+			}
659
+			if ($matches[5] != '...') {
660
+				$result['pressure'] = round((intval($matches[5])/10),1);
661
+			}
552 662
 		        $body_parse = substr($body_parse,strlen($matches[0]));
553 663
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
554
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
555
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
556
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
557
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
558
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
559
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
664
+			if ($matches[1] != '...') {
665
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
666
+			}
667
+			if ($matches[2] != '...') {
668
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
669
+			}
670
+			if ($matches[3] != '...') {
671
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
672
+			}
673
+			if ($matches[4] != '...') {
674
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
675
+			}
676
+			if ($matches[6] != '...') {
677
+				$result['humidity'] = intval($matches[6]);
678
+			}
679
+			if ($matches[5] != '...') {
680
+				$result['pressure'] = round((intval($matches[5])/10),1);
681
+			}
560 682
 		        $body_parse = substr($body_parse,strlen($matches[0]));
561 683
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
562
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
563
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
564
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
565
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
566
-			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
567
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
684
+			if ($matches[1] != '...') {
685
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
686
+			}
687
+			if ($matches[2] != '...') {
688
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
689
+			}
690
+			if ($matches[3] != '...') {
691
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
692
+			}
693
+			if ($matches[4] != '...') {
694
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
695
+			}
696
+			if ($matches[5] != '...') {
697
+				$result['humidity'] = intval($matches[5]);
698
+			}
699
+			if ($matches[6] != '...') {
700
+				$result['pressure'] = round((intval($matches[6])/10),1);
701
+			}
568 702
 		        $body_parse = substr($body_parse,strlen($matches[0]));
569 703
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
570
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
571
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
572
-			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
573
-			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
704
+			if ($matches[1] != '...') {
705
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
706
+			}
707
+			if ($matches[2] != '...') {
708
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
709
+			}
710
+			if ($matches[2] != '...') {
711
+				$result['humidity'] = intval($matches[3]);
712
+			}
713
+			if ($matches[4] != '...') {
714
+				$result['pressure'] = round((intval($matches[4])/10),1);
715
+			}
574 716
 		        $body_parse = substr($body_parse,strlen($matches[0]));
575 717
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
576
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
577
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
578
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
579
-			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
580
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
718
+			if ($matches[1] != '...') {
719
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
720
+			}
721
+			if ($matches[2] != '...') {
722
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
723
+			}
724
+			if ($matches[3] != '...') {
725
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
726
+			}
727
+			if ($matches[4] != '...') {
728
+				$result['humidity'] = intval($matches[4]);
729
+			}
730
+			if ($matches[5] != '...') {
731
+				$result['pressure'] = round((intval($matches[5])/10),1);
732
+			}
581 733
 		        $body_parse = substr($body_parse,strlen($matches[0]));
582 734
 		    }
583 735
 		    $result['comment'] = trim($body_parse);
584 736
 		}
585
-		} else $result['comment'] = trim($body_parse);
737
+		} else {
738
+			$result['comment'] = trim($body_parse);
739
+		}
586 740
 
587 741
 	    }
588 742
 	//}
589
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
590
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
591
-	if ($debug) print_r($result);
743
+	if (isset($result['latitude'])) {
744
+		$result['latitude'] = round($result['latitude'],4);
745
+	}
746
+	if (isset($result['longitude'])) {
747
+		$result['longitude'] = round($result['longitude'],4);
748
+	}
749
+	if ($debug) {
750
+		print_r($result);
751
+	}
592 752
 	return $result;
593 753
     }
594 754
     
@@ -597,12 +757,21 @@  discard block
 block discarded – undo
597 757
 	$aprs_connect = 0;
598 758
 	$aprs_keep = 120;
599 759
 	$aprs_last_tx = time();
600
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
601
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
602
-	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
603
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
604
-	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
605
-	else $aprs_pass = '-1';
760
+	if (isset($globalAPRSversion)) {
761
+		$aprs_version = $globalAPRSversion;
762
+	} else {
763
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
764
+	}
765
+	if (isset($globalServerAPRSssid)) {
766
+		$aprs_ssid = $globalServerAPRSssid;
767
+	} else {
768
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
769
+	}
770
+	if (isset($globalServerAPRSpass)) {
771
+		$aprs_pass = $globalServerAPRSpass;
772
+	} else {
773
+		$aprs_pass = '-1';
774
+	}
606 775
 	
607 776
 	$aprs_filter  = '';
608 777
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
@@ -635,10 +804,14 @@  discard block
 block discarded – undo
635 804
     
636 805
     public function send($data) {
637 806
 	global $globalDebug;
638
-	if ($this->connected === false) $this->connect();
807
+	if ($this->connected === false) {
808
+		$this->connect();
809
+	}
639 810
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
640 811
 	if ($send === FALSE) {
641
-		if ($globalDebug) echo 'Reconnect...';
812
+		if ($globalDebug) {
813
+			echo 'Reconnect...';
814
+		}
642 815
 		socket_close($this->socket);
643 816
 		$this->connect();
644 817
 	}
@@ -658,22 +831,32 @@  discard block
 block discarded – undo
658 831
 			//$w = '00';
659 832
 			$custom = '';
660 833
 			if ($ident != '') {
661
-				if ($custom != '') $custom .= '/';
834
+				if ($custom != '') {
835
+					$custom .= '/';
836
+				}
662 837
 				$custom .= 'CS='.$ident;
663 838
 			}
664 839
 			if ($squawk != '') {
665
-				if ($custom != '') $custom .= '/';
840
+				if ($custom != '') {
841
+					$custom .= '/';
842
+				}
666 843
 				$custom .= 'SQ='.$squawk;
667 844
 			}
668 845
 			if ($verticalrate != '') {
669
-				if ($custom != '') $custom .= '/';
846
+				if ($custom != '') {
847
+					$custom .= '/';
848
+				}
670 849
 				$custom .= 'VR='.$verticalrate;
671 850
 			}
672 851
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
673
-				if ($custom != '') $custom .= '/';
852
+				if ($custom != '') {
853
+					$custom .= '/';
854
+				}
674 855
 				$custom .= 'AI='.$aircraft_icao;
675 856
 			}
676
-			if ($custom != '') $custom = ' '.$custom;
857
+			if ($custom != '') {
858
+				$custom = ' '.$custom;
859
+			}
677 860
 			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
678 861
 		}
679 862
 	}
@@ -691,30 +874,44 @@  discard block
 block discarded – undo
691 874
 			//$w = '00';
692 875
 			$custom = '';
693 876
 			if ($ident != '') {
694
-				if ($custom != '') $custom .= '/';
877
+				if ($custom != '') {
878
+					$custom .= '/';
879
+				}
695 880
 				$custom .= 'CS='.str_replace(' ','_',$ident);
696 881
 			}
697 882
 			if ($typeid != '') {
698
-				if ($custom != '') $custom .= '/';
883
+				if ($custom != '') {
884
+					$custom .= '/';
885
+				}
699 886
 				$custom .= 'TI='.$typeid;
700 887
 			}
701 888
 			if ($statusid != '') {
702
-				if ($custom != '') $custom .= '/';
889
+				if ($custom != '') {
890
+					$custom .= '/';
891
+				}
703 892
 				$custom .= 'SI='.$statusid;
704 893
 			}
705 894
 			if ($imo != '') {
706
-				if ($custom != '') $custom .= '/';
895
+				if ($custom != '') {
896
+					$custom .= '/';
897
+				}
707 898
 				$custom .= 'IMO='.$imo;
708 899
 			}
709 900
 			if ($arrival_date != '') {
710
-				if ($custom != '') $custom .= '/';
901
+				if ($custom != '') {
902
+					$custom .= '/';
903
+				}
711 904
 				$custom .= 'AD='.strtotime($arrival_date);
712 905
 			}
713 906
 			if ($arrival_code != '') {
714
-				if ($custom != '') $custom .= '/';
907
+				if ($custom != '') {
908
+					$custom .= '/';
909
+				}
715 910
 				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
716 911
 			}
717
-			if ($custom != '') $custom = ' '.$custom;
912
+			if ($custom != '') {
913
+				$custom = ' '.$custom;
914
+			}
718 915
 			$altitude = 0;
719 916
 			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
720 917
 		}
Please login to merge, or discard this patch.
live-czml.php 1 patch
Braces   +108 added lines, -39 removed lines patch added patch discarded remove patch
@@ -8,8 +8,12 @@  discard block
 block discarded – undo
8 8
 }
9 9
 $tracker = false;
10 10
 $marine = false;
11
-if (isset($_GET['tracker'])) $tracker = true;
12
-if (isset($_GET['marine'])) $marine = true;
11
+if (isset($_GET['tracker'])) {
12
+	$tracker = true;
13
+}
14
+if (isset($_GET['marine'])) {
15
+	$marine = true;
16
+}
13 17
 if ($tracker) {
14 18
 	require_once('require/class.Tracker.php');
15 19
 	require_once('require/class.TrackerLive.php');
@@ -66,23 +70,46 @@  discard block
 block discarded – undo
66 70
 }
67 71
 header('Content-Type: text/javascript');
68 72
 
69
-if (!isset($globalJsonCompress)) $compress = true;
70
-else $compress = $globalJsonCompress;
73
+if (!isset($globalJsonCompress)) {
74
+	$compress = true;
75
+} else {
76
+	$compress = $globalJsonCompress;
77
+}
71 78
 
72 79
 $from_archive = false;
73 80
 $min = false;
74 81
 $allhistory = false;
75 82
 $filter['source'] = array();
76
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
77
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
78
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
79
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
80
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
81
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
82
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
83
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
85
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
83
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
84
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
85
+}
86
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
87
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
88
+}
89
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
90
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
91
+}
92
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
93
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
94
+}
95
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
96
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
97
+}
98
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
99
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
100
+}
101
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
102
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
103
+}
104
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
105
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
106
+}
107
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
108
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
109
+}
110
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
111
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
112
+}
86 113
 /*
87 114
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
88 115
 	$min = true;
@@ -167,8 +194,12 @@  discard block
 block discarded – undo
167 194
 	} else {
168 195
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
169 196
 	}
170
-	if ($flightcnt == '') $flightcnt = 0;
171
-} else $flightcnt = 0;
197
+	if ($flightcnt == '') {
198
+		$flightcnt = 0;
199
+	}
200
+	} else {
201
+	$flightcnt = 0;
202
+}
172 203
 
173 204
 $sqltime = round(microtime(true)-$begintime,2);
174 205
 $minitime = time();
@@ -191,7 +222,9 @@  discard block
 block discarded – undo
191 222
 $j = 0;
192 223
 $prev_flightaware_id = '';
193 224
 $speed = 1;
194
-if (isset($archivespeed)) $speed = $archivespeed;
225
+if (isset($archivespeed)) {
226
+	$speed = $archivespeed;
227
+}
195 228
 $output = '[';
196 229
 if ($tracker) {
197 230
 	$output .= '{"id" : "document", "name" : "tracker","version" : "1.0"';
@@ -226,9 +259,13 @@  discard block
 block discarded – undo
226 259
 			$image = "images/placeholder_thumb.png";
227 260
 		}
228 261
 
229
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
230
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
231
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
262
+                if (isset($spotter_item['flightaware_id'])) {
263
+                	$id = $spotter_item['flightaware_id'];
264
+                } elseif (isset($spotter_item['famtrackid'])) {
265
+                	$id = $spotter_item['famtrackid'];
266
+                } elseif (isset($spotter_item['fammarine_id'])) {
267
+                	$id = $spotter_item['fammarine_id'];
268
+                }
232 269
                 if ($prev_flightaware_id != $id) {
233 270
 			if ($prev_flightaware_id != '') {
234 271
 				$output .= ']';
@@ -270,7 +307,9 @@  discard block
 block discarded – undo
270 307
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
271 308
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
272 309
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
273
-						} else $aircraft_shadow = '';
310
+						} else {
311
+							$aircraft_shadow = '';
312
+						}
274 313
 	    					$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
275 314
 						if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] && isset($_COOKIE['IconColor'])) {
276 315
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
@@ -278,7 +317,9 @@  discard block
 block discarded – undo
278 317
 						}
279 318
 						$output .= '},';
280 319
 					}
281
-				} else $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},';
320
+				} else {
321
+					$output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},';
322
+				}
282 323
 			} elseif ($one3dmodel) {
283 324
 				if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') {
284 325
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : 1.0,"minimumPixelSize": 20';
@@ -309,7 +350,9 @@  discard block
 block discarded – undo
309 350
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
310 351
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
311 352
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
312
-						} else $aircraft_shadow = '';
353
+						} else {
354
+							$aircraft_shadow = '';
355
+						}
313 356
 						if ($aircraft_shadow != '') {
314 357
 							if (isset($modelsdb[$aircraft_shadow])) {
315 358
 								$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20';
@@ -446,7 +489,9 @@  discard block
 block discarded – undo
446 489
 								}
447 490
 								$output .= '},';
448 491
 								//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
449
-								if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
492
+								if ($spotter_item['aircraft_icao'] != '') {
493
+									$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
494
+								}
450 495
 								$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
451 496
 							}
452 497
 						} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
@@ -468,7 +513,9 @@  discard block
 block discarded – undo
468 513
 							}
469 514
 							$output .= '},';
470 515
 							//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
471
-							if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
516
+							if ($spotter_item['aircraft_icao'] != '') {
517
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
518
+							}
472 519
 							$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
473 520
 						}
474 521
 					} else {
@@ -481,7 +528,9 @@  discard block
 block discarded – undo
481 528
 						}
482 529
 						$output .= '},';
483 530
 						//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
484
-						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
531
+						if ($spotter_item['aircraft_icao'] != '') {
532
+							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
533
+						}
485 534
 						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
486 535
 					}
487 536
 				} elseif ($tracker && isset($spotter_item['type'])) {
@@ -585,8 +634,11 @@  discard block
 block discarded – undo
585 634
 					$output .= '},';
586 635
 				}
587 636
 			}
588
-			if ($onground) $output = str_replace('%onground%','true',$output);
589
-			else $output = str_replace('%onground%','false',$output);
637
+			if ($onground) {
638
+				$output = str_replace('%onground%','true',$output);
639
+			} else {
640
+				$output = str_replace('%onground%','false',$output);
641
+			}
590 642
 
591 643
 	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
592 644
 			//$output .= '"heightReference": "'.$heightrelative.'",';
@@ -599,8 +651,12 @@  discard block
 block discarded – undo
599 651
 	//		$output .= '"interpolationDegree" : 5,';
600 652
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
601 653
 			$output .= '"cartographicDegrees": [';
602
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
603
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
654
+			if ($minitime > strtotime($spotter_item['date'])) {
655
+				$minitime = strtotime($spotter_item['date']);
656
+			}
657
+			if ($maxitime < strtotime($spotter_item['date'])) {
658
+				$maxitime = strtotime($spotter_item['date']);
659
+			}
604 660
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
605 661
 			$output .= $spotter_item['longitude'].', ';
606 662
 			$output .= $spotter_item['latitude'];
@@ -623,20 +679,27 @@  discard block
 block discarded – undo
623 679
 					$output .= ', '.round($spotter_item['altitude']*30.48);
624 680
 					$prevalt = round($spotter_item['altitude']*30.48);
625 681
 				}
626
-			} else $output .= ', 0';
682
+			} else {
683
+				$output .= ', 0';
684
+			}
627 685
 			//$orientation = '"orientation" : { ';
628 686
 			//$orientation .= '"unitQuaternion": [';
629 687
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
630 688
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
631 689
 		} else {
632 690
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
633
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
691
+			if ($maxitime < strtotime($spotter_item['date'])) {
692
+				$maxitime = strtotime($spotter_item['date']);
693
+			}
634 694
 			if ($spotter_item['ground_speed'] == 0) {
635 695
 				$output .= $prevlong.', ';
636 696
 				$output .= $prevlat;
637 697
 				//if (!$marine && (!isset($onground) || !$onground)) $output .= ', '.$prevalt;
638
-				if (!$marine) $output .= ', '.$prevalt;
639
-				else $output .= ', 0';
698
+				if (!$marine) {
699
+					$output .= ', '.$prevalt;
700
+				} else {
701
+					$output .= ', 0';
702
+				}
640 703
 			} else {
641 704
 				$output .= $spotter_item['longitude'].', ';
642 705
 				$output .= $spotter_item['latitude'];
@@ -649,14 +712,17 @@  discard block
 block discarded – undo
649 712
 							$output .= ', 0';
650 713
 						}
651 714
 					} else {
652
-						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') $output .= ', '.round($spotter_item['real_altitude']*0.3048);
653
-						elseif ($tracker) {
715
+						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
716
+							$output .= ', '.round($spotter_item['real_altitude']*0.3048);
717
+						} elseif ($tracker) {
654 718
 							$output .= ', '.round($spotter_item['altitude']*0.3048);
655 719
 						} else {
656 720
 							$output .= ', '.round($spotter_item['altitude']*30.48);
657 721
 						}
658 722
 					}
659
-				} else $output .= ', 0';
723
+				} else {
724
+					$output .= ', 0';
725
+				}
660 726
 			}
661 727
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
662 728
 			//$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
@@ -675,9 +741,12 @@  discard block
 block discarded – undo
675 741
 		} else {
676 742
 			$output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
677 743
 		}
744
+	} else {
745
+		$output = str_replace('%minitime%',date("c",$minitime),$output);
678 746
 	}
679
-	else $output = str_replace('%minitime%',date("c",$minitime),$output);
680
-} else $output = str_replace('%minitime%',date("c",$minitime),$output);
747
+	} else {
748
+	$output = str_replace('%minitime%',date("c",$minitime),$output);
749
+}
681 750
 $output = str_replace('%maxitime%',date("c",$maxitime),$output);
682 751
 print $output;
683 752
 ?>
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Braces   +74 added lines, -25 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
 			}
120 125
 		}
121 126
 
122
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
127
+		if (!isset($globalLiveInterval)) {
128
+			$globalLiveInterval = '200';
129
+		}
123 130
 		if ($globalDBdriver == 'mysql') {
124 131
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
125 132
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -144,7 +151,9 @@  discard block
 block discarded – undo
144 151
 
145 152
 		$filter_query = $this->getFilter($filter,true,true);
146 153
 
147
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
148 157
 		if ($globalDBdriver == 'mysql') {
149 158
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
150 159
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -182,7 +191,9 @@  discard block
 block discarded – undo
182 191
 
183 192
 		$filter_query = $this->getFilter($filter,true,true);
184 193
 
185
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
+		if (!isset($globalLiveInterval)) {
195
+			$globalLiveInterval = '200';
196
+		}
186 197
 		if ($globalDBdriver == 'mysql') {
187 198
 			if (isset($globalArchive) && $globalArchive) {
188 199
 				$query  = "SELECT * FROM (
@@ -240,7 +251,9 @@  discard block
 block discarded – undo
240 251
 		global $globalDBdriver, $globalLiveInterval;
241 252
 		$filter_query = $this->getFilter($filter,true,true);
242 253
 
243
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
254
+		if (!isset($globalLiveInterval)) {
255
+			$globalLiveInterval = '200';
256
+		}
244 257
 		if ($globalDBdriver == 'mysql') {
245 258
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
246 259
 		} else {
@@ -268,7 +281,9 @@  discard block
 block discarded – undo
268 281
 	{
269 282
 		global $globalDBdriver, $globalLiveInterval;
270 283
 		$Spotter = new Spotter($this->db);
271
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
284
+		if (!isset($globalLiveInterval)) {
285
+			$globalLiveInterval = '200';
286
+		}
272 287
 		$filter_query = $this->getFilter($filter);
273 288
 
274 289
 		if (is_array($coord)) {
@@ -276,7 +291,9 @@  discard block
 block discarded – undo
276 291
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277 292
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278 293
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
279
-		} else return array();
294
+		} else {
295
+			return array();
296
+		}
280 297
 		if ($globalDBdriver == 'mysql') {
281 298
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
282 299
 		} else {
@@ -296,7 +313,9 @@  discard block
 block discarded – undo
296 313
 	{
297 314
 		global $globalDBdriver, $globalLiveInterval;
298 315
 		$Spotter = new Spotter($this->db);
299
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
316
+		if (!isset($globalLiveInterval)) {
317
+			$globalLiveInterval = '200';
318
+		}
300 319
 		$filter_query = $this->getFilter($filter);
301 320
 
302 321
 		if (is_array($coord)) {
@@ -304,7 +323,9 @@  discard block
 block discarded – undo
304 323
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
305 324
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
306 325
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
307
-		} else return array();
326
+		} else {
327
+			return array();
328
+		}
308 329
 		if ($globalDBdriver == 'mysql') {
309 330
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
310 331
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -497,11 +518,15 @@  discard block
 block discarded – undo
497 518
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
498 519
 		if ($globalDBdriver == 'mysql') {
499 520
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
500
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
521
+			if ($liveinterval) {
522
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
523
+			}
501 524
 			$query .= ' ORDER BY date';
502 525
 		} else {
503 526
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
504
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
527
+			if ($liveinterval) {
528
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
529
+			}
505 530
 			$query .= ' ORDER BY date';
506 531
 		}
507 532
 
@@ -596,7 +621,9 @@  discard block
 block discarded – undo
596 621
 				$i++;
597 622
 				$j++;
598 623
 				if ($j == 30) {
599
-					if ($globalDebug) echo ".";
624
+					if ($globalDebug) {
625
+						echo ".";
626
+					}
600 627
 				    	try {
601 628
 						
602 629
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -843,7 +870,9 @@  discard block
 block discarded – undo
843 870
 			{
844 871
 				return false;
845 872
 			}
846
-		} else return '';
873
+		} else {
874
+			return '';
875
+		}
847 876
 
848 877
 		if ($longitude != '')
849 878
 		{
@@ -851,7 +880,9 @@  discard block
 block discarded – undo
851 880
 			{
852 881
 				return false;
853 882
 			}
854
-		} else return '';
883
+		} else {
884
+			return '';
885
+		}
855 886
 
856 887
 		if ($altitude != '')
857 888
 		{
@@ -859,7 +890,9 @@  discard block
 block discarded – undo
859 890
 			{
860 891
 				return false;
861 892
 			}
862
-		} else $altitude = 0;
893
+		} else {
894
+			$altitude = 0;
895
+		}
863 896
 
864 897
 		if ($heading != '')
865 898
 		{
@@ -867,7 +900,9 @@  discard block
 block discarded – undo
867 900
 			{
868 901
 				return false;
869 902
 			}
870
-		} else $heading = 0;
903
+		} else {
904
+			$heading = 0;
905
+		}
871 906
 
872 907
 		if ($groundspeed != '')
873 908
 		{
@@ -875,9 +910,13 @@  discard block
 block discarded – undo
875 910
 			{
876 911
 				return false;
877 912
 			}
878
-		} else $groundspeed = 0;
913
+		} else {
914
+			$groundspeed = 0;
915
+		}
879 916
 		date_default_timezone_set('UTC');
880
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
917
+		if ($date == '') {
918
+			$date = date("Y-m-d H:i:s", time());
919
+		}
881 920
 
882 921
         
883 922
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -893,12 +932,18 @@  discard block
 block discarded – undo
893 932
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
894 933
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
895 934
 
896
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
897
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
935
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
936
+            		$groundspeed = 0;
937
+            	}
938
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
939
+            		$heading = 0;
940
+            	}
898 941
             	
899 942
 		$query = '';
900 943
 		if ($globalArchive) {
901
-			if ($globalDebug) echo '-- Delete previous data -- ';
944
+			if ($globalDebug) {
945
+				echo '-- Delete previous data -- ';
946
+			}
902 947
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
903 948
 		}
904 949
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -917,10 +962,14 @@  discard block
 block discarded – undo
917 962
                 echo 'noarchive : '.$noarchive."\n";
918 963
                 */
919 964
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
920
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
965
+		    if ($globalDebug) {
966
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
967
+		    }
921 968
 		    $TrackerArchive = new TrackerArchive($this->db);
922 969
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
923
-		    if ($globalDebug) echo $result.')';
970
+		    if ($globalDebug) {
971
+		    	echo $result.')';
972
+		    }
924 973
 		}
925 974
 
926 975
 		return "success";
Please login to merge, or discard this patch.
js/map-tracker.2d.js.php 1 patch
Braces   +42 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 setcookie("MapFormat",'2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8
-if (!isset($globalJsonCompress)) $compress = true;
9
-else $compress = $globalJsonCompress;
8
+if (!isset($globalJsonCompress)) {
9
+	$compress = true;
10
+} else {
11
+	$compress = $globalJsonCompress;
12
+}
10 13
 ?>
11 14
 
12 15
 
@@ -155,9 +158,13 @@  discard block
 block discarded – undo
155 158
 		    if (callsign != ""){ markerTrackerLabel += callsign; }
156 159
 		    if (type != ""){ markerTrackerLabel += ' - '+type; }
157 160
 <?php
158
-	if (isset($_COOKIE['TrackerIconColor'])) $IconColor = $_COOKIE['TrackerIconColor'];
159
-	elseif (isset($globalTrackerIconColor)) $IconColor = $globalTrackerIconColor;
160
-	else $IconColor = '1a3151';
161
+	if (isset($_COOKIE['TrackerIconColor'])) {
162
+		$IconColor = $_COOKIE['TrackerIconColor'];
163
+	} elseif (isset($globalTrackerIconColor)) {
164
+		$IconColor = $globalTrackerIconColor;
165
+	} else {
166
+		$IconColor = '1a3151';
167
+	}
161 168
 	if (!isset($ident) && !isset($famtrackid)) {
162 169
 ?>
163 170
 		    info_tracker_update(feature.properties.fc);
@@ -191,7 +198,12 @@  discard block
 block discarded – undo
191 198
 <?php
192 199
 		} else {
193 200
 ?>
194
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
201
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
202
+	print $archiveupdatetime*1000;
203
+} else {
204
+	print $globalMapRefresh*1000+20000;
205
+}
206
+?>+feature.properties.sqt*1000);
195 207
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
196 208
 <?php
197 209
 		}
@@ -247,7 +259,12 @@  discard block
 block discarded – undo
247 259
 <?php
248 260
 		} else {
249 261
 ?>
250
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
262
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
263
+	print $archiveupdatetime*1000;
264
+} else {
265
+	print $globalMapRefresh*1000+20000;
266
+}
267
+?>+feature.properties.sqt*1000);
251 268
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
252 269
 <?php
253 270
 		}
@@ -302,7 +319,12 @@  discard block
 block discarded – undo
302 319
 <?php
303 320
 		} else {
304 321
 ?>
305
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
322
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
323
+	print $archiveupdatetime*1000;
324
+} else {
325
+	print $globalMapRefresh*1000+20000;
326
+}
327
+?>+feature.properties.sqt*1000);
306 328
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
307 329
 <?php
308 330
 		}
@@ -592,14 +614,24 @@  discard block
 block discarded – undo
592 614
 	if (isset($archive) && $archive) {
593 615
 ?>
594 616
 //then load it again every 30 seconds
595
-//  var reload = setInterval(function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
617
+//  var reload = setInterval(function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) {
618
+	print ($globalMapRefresh*1000)/2;
619
+} else {
620
+	print '15000';
621
+}
622
+?>);
596 623
 reloadTrackerPage = setInterval(function(){if (noTimeout) getLiveTrackerData(0)},<?php print $archiveupdatetime*1000; ?>);
597 624
 <?php
598 625
 	} else {
599 626
 ?>
600 627
 //then load it again every 30 seconds
601 628
 reloadTrackerPage = setInterval(
602
-    function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
629
+    function(){if (noTimeout) getLiveTrackerData(0)},<?php if (isset($globalMapRefresh)) {
630
+	print $globalMapRefresh*1000;
631
+} else {
632
+	print '30000';
633
+}
634
+?>);
603 635
 <?php
604 636
 	}
605 637
 ?>
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +1025 added lines, -350 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -55,35 +59,62 @@  discard block
 block discarded – undo
55 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 60
 if (isset($options['s'])) {
57 61
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
60
-} elseif (isset($options['source'])) {
62
+    if (isset($options['format'])) {
63
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
64
+    } else {
65
+    	$globalSources[] = array('host' => $options['s']);
66
+    }
67
+    } elseif (isset($options['source'])) {
61 68
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
64
-}
69
+    if (isset($options['format'])) {
70
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
71
+    } else {
72
+    	$globalSources[] = array('host' => $options['source']);
73
+    }
74
+    }
65 75
 if (isset($options['aprsserverhost'])) {
66 76
 	$globalServerAPRS = TRUE;
67 77
 	$globalServerAPRShost = $options['aprsserverhost'];
68 78
 }
69
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
70
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
71
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
72
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
73
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
74
-if (isset($options['server'])) $globalServer = TRUE;
75
-if (isset($options['idsource'])) $id_source = $options['idsource'];
76
-else $id_source = 1;
79
+if (isset($options['aprsserverport'])) {
80
+	$globalServerAPRSport = $options['aprsserverport'];
81
+}
82
+if (isset($options['aprsserverssid'])) {
83
+	$globalServerAPRSssid = $options['aprsserverssid'];
84
+}
85
+if (isset($options['aprsserverpass'])) {
86
+	$globalServerAPRSpass = $options['aprsserverpass'];
87
+}
88
+if (isset($options['noaprsserver'])) {
89
+	$globalServerAPRS = FALSE;
90
+}
91
+if (isset($options['nodaemon'])) {
92
+	$globalDaemon = FALSE;
93
+}
94
+if (isset($options['server'])) {
95
+	$globalServer = TRUE;
96
+}
97
+if (isset($options['idsource'])) {
98
+	$id_source = $options['idsource'];
99
+} else {
100
+	$id_source = 1;
101
+}
77 102
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
103
+    if ($globalDebug) {
104
+    	echo "Using Server Mode\n";
105
+    }
79 106
     $SI=new SpotterServer();
80 107
 /*
81 108
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 109
     $SI = new adsb2aprs();
83 110
     $SI->connect();
84 111
 */
85
-} else $SI=new SpotterImport($Connection->db);
86
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
112
+} else {
113
+	$SI=new SpotterImport($Connection->db);
114
+}
115
+if (isset($globalTracker) && $globalTracker) {
116
+	$TI = new TrackerImport($Connection->db);
117
+}
87 118
 if (isset($globalMarine) && $globalMarine) {
88 119
     $AIS = new AIS();
89 120
     $MI = new MarineImport($Connection->db);
@@ -106,7 +137,9 @@  discard block
 block discarded – undo
106 137
 }
107 138
 
108 139
 // let's try and connect
109
-if ($globalDebug) echo "Connecting...\n";
140
+if ($globalDebug) {
141
+	echo "Connecting...\n";
142
+}
110 143
 $use_aprs = false;
111 144
 $aprs_full = false;
112 145
 $reset = 0;
@@ -115,7 +148,9 @@  discard block
 block discarded – undo
115 148
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 149
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117 150
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
151
+    if ($globalDebug) {
152
+    	echo 'Connect to all...'."\n";
153
+    }
119 154
     foreach ($hosts as $id => $value) {
120 155
 	$host = $value['host'];
121 156
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,22 +160,30 @@  discard block
 block discarded – undo
125 160
         	//$formats[$id] = 'deltadbtxt';
126 161
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 162
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
163
+        	if ($globalDebug) {
164
+        		echo "Connect to deltadb source (".$host.")...\n";
165
+        	}
129 166
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 167
         	//$formats[$id] = 'vatsimtxt';
131 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 169
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
170
+        	if ($globalDebug) {
171
+        		echo "Connect to vatsim source (".$host.")...\n";
172
+        	}
134 173
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 174
         	//$formats[$id] = 'aircraftlistjson';
136 175
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 176
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	if ($globalDebug) {
178
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
179
+        	}
139 180
     	    } else if (preg_match('/opensky/i',$host)) {
140 181
         	//$formats[$id] = 'aircraftlistjson';
141 182
         	$globalSources[$id]['format'] = 'opensky';
142 183
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to opensky source (".$host.")...\n";
186
+        	}
144 187
     	    /*
145 188
     	    // Disabled for now, site change source format
146 189
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -157,7 +200,9 @@  discard block
 block discarded – undo
157 200
         	//$formats[$id] = 'planeupdatefaa';
158 201
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 202
         	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+        	if ($globalDebug) {
204
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
205
+        	}
161 206
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162 207
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 208
         	    exit(0);
@@ -166,32 +211,46 @@  discard block
 block discarded – undo
166 211
         	//$formats[$id] = 'phpvmacars';
167 212
         	$globalSources[$id]['format'] = 'phpvmacars';
168 213
         	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to phpvmacars source (".$host.")...\n";
216
+        	}
170 217
             } else if (preg_match('/VAM-json.php$/i',$host)) {
171 218
         	//$formats[$id] = 'phpvmacars';
172 219
         	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
220
+        	if ($globalDebug) {
221
+        		echo "Connect to Vam source (".$host.")...\n";
222
+        	}
174 223
             } else if (preg_match('/whazzup/i',$host)) {
175 224
         	//$formats[$id] = 'whazzup';
176 225
         	$globalSources[$id]['format'] = 'whazzup';
177 226
         	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
227
+        	if ($globalDebug) {
228
+        		echo "Connect to whazzup source (".$host.")...\n";
229
+        	}
179 230
             } else if (preg_match('/blitzortung/i',$host)) {
180 231
         	$globalSources[$id]['format'] = 'blitzortung';
181
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to blitzortung source (".$host.")...\n";
234
+        	}
182 235
             } else if (preg_match('/airwhere/i',$host)) {
183 236
         	$globalSources[$id]['format'] = 'airwhere';
184
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
+        	if ($globalDebug) {
238
+        		echo "Connect to airwhere source (".$host.")...\n";
239
+        	}
185 240
             } else if (preg_match('/recentpireps/i',$host)) {
186 241
         	//$formats[$id] = 'pirepsjson';
187 242
         	$globalSources[$id]['format'] = 'pirepsjson';
188 243
         	//$last_exec['pirepsjson'] = 0;
189
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
244
+        	if ($globalDebug) {
245
+        		echo "Connect to pirepsjson source (".$host.")...\n";
246
+        	}
190 247
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
191 248
         	//$formats[$id] = 'fr24json';
192 249
         	$globalSources[$id]['format'] = 'fr24json';
193 250
         	//$last_exec['fr24json'] = 0;
194
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
251
+        	if ($globalDebug) {
252
+        		echo "Connect to fr24 source (".$host.")...\n";
253
+        	}
195 254
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
196 255
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
197 256
         	    exit(0);
@@ -200,7 +259,9 @@  discard block
 block discarded – undo
200 259
         	//$formats[$id] = 'fr24json';
201 260
         	$globalSources[$id]['format'] = 'myshiptracking';
202 261
         	//$last_exec['fr24json'] = 0;
203
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
262
+        	if ($globalDebug) {
263
+        		echo "Connect to myshiptracking source (".$host.")...\n";
264
+        	}
204 265
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
205 266
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
206 267
         	    exit(0);
@@ -209,17 +270,24 @@  discard block
 block discarded – undo
209 270
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
210 271
         	//$formats[$id] = 'tsv';
211 272
         	$globalSources[$id]['format'] = 'tsv';
212
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
273
+        	if ($globalDebug) {
274
+        		echo "Connect to tsv source (".$host.")...\n";
275
+        	}
213 276
             }
214 277
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
215 278
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
216 279
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
217 280
     		    if ($idf !== false) {
218 281
     			$httpfeeds[$id] = $idf;
219
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
+        		if ($globalDebug) {
283
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
284
+        		}
285
+    		    } elseif ($globalDebug) {
286
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
220 287
     		    }
221
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
222
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
288
+    		} elseif ($globalDebug) {
289
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
290
+    		}
223 291
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
224 292
 	    $hostport = explode(':',$host);
225 293
 	    if (isset($hostport[1])) {
@@ -259,17 +327,25 @@  discard block
 block discarded – undo
259 327
         		//$formats[$id] = 'beast';
260 328
         		$globalSources[$id]['format'] = 'beast';
261 329
 		    //} else $formats[$id] = 'sbs';
262
-		    } else $globalSources[$id]['format'] = 'sbs';
330
+		    } else {
331
+		    	$globalSources[$id]['format'] = 'sbs';
332
+		    }
263 333
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
264 334
 		}
265
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
335
+		if ($globalDebug) {
336
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
337
+		}
266 338
             } else {
267
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
339
+		if ($globalDebug) {
340
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
341
+		}
268 342
     	    }
269 343
         }
270 344
     }
271 345
 }
272
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
346
+if (!isset($globalMinFetch)) {
347
+	$globalMinFetch = 15;
348
+}
273 349
 
274 350
 // Initialize all
275 351
 $status = array();
@@ -278,13 +354,19 @@  discard block
 block discarded – undo
278 354
 $formats = array();
279 355
 $last_exec = array();
280 356
 $time = time();
281
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
282
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
283
-else $timeout = 20;
357
+if (isset($globalSourcesTimeout)) {
358
+	$timeout = $globalSourcesTimeOut;
359
+} else if (isset($globalSBS1TimeOut)) {
360
+	$timeout = $globalSBS1TimeOut;
361
+} else {
362
+	$timeout = 20;
363
+}
284 364
 $errno = '';
285 365
 $errstr='';
286 366
 
287
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
367
+if (!isset($globalDaemon)) {
368
+	$globalDaemon = TRUE;
369
+}
288 370
 /* Initiate connections to all the hosts simultaneously */
289 371
 //connect_all($hosts);
290 372
 //connect_all($globalSources);
@@ -313,7 +395,9 @@  discard block
 block discarded – undo
313 395
     if (isset($source['format']) && $source['format'] == 'aprs') {
314 396
 	$aprs_connect = 0;
315 397
 	$use_aprs = true;
316
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
398
+	if (isset($source['port']) && $source['port'] == '10152') {
399
+		$aprs_full = true;
400
+	}
317 401
 	break;
318 402
     }
319 403
 }
@@ -324,25 +408,48 @@  discard block
 block discarded – undo
324 408
 	$aprs_connect = 0;
325 409
 	$aprs_keep = 120;
326 410
 	$aprs_last_tx = time();
327
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
328
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
329
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
330
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
331
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
332
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
333
-	if ($aprs_full) $aprs_filter = '';
334
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
335
-	else $aprs_pass = '-1';
411
+	if (isset($globalAPRSversion)) {
412
+		$aprs_version = $globalAPRSversion;
413
+	} else {
414
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
415
+	}
416
+	if (isset($globalAPRSssid)) {
417
+		$aprs_ssid = $globalAPRSssid;
418
+	} else {
419
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
420
+	}
421
+	if (isset($globalAPRSfilter)) {
422
+		$aprs_filter = $globalAPRSfilter;
423
+	} else {
424
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
425
+	}
426
+	if ($aprs_full) {
427
+		$aprs_filter = '';
428
+	}
429
+	if (isset($globalAPRSpass)) {
430
+		$aprs_pass = $globalAPRSpass;
431
+	} else {
432
+		$aprs_pass = '-1';
433
+	}
336 434
 
337
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
338
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
339
-}
435
+	if ($aprs_filter != '') {
436
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
437
+	} else {
438
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
439
+	}
440
+	}
340 441
 
341 442
 // connected - lets do some work
342
-if ($globalDebug) echo "Connected!\n";
443
+if ($globalDebug) {
444
+	echo "Connected!\n";
445
+}
343 446
 sleep(1);
344
-if ($globalDebug) echo "SCAN MODE \n\n";
345
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
447
+if ($globalDebug) {
448
+	echo "SCAN MODE \n\n";
449
+}
450
+if (!isset($globalCronEnd)) {
451
+	$globalCronEnd = 60;
452
+}
346 453
 $endtime = time()+$globalCronEnd;
347 454
 $i = 1;
348 455
 $tt = array();
@@ -356,20 +463,28 @@  discard block
 block discarded – undo
356 463
 
357 464
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
358 465
 while ($i > 0) {
359
-    if (!$globalDaemon) $i = $endtime-time();
466
+    if (!$globalDaemon) {
467
+    	$i = $endtime-time();
468
+    }
360 469
     // Delete old ATC
361 470
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
362
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
471
+	if ($globalDebug) {
472
+		echo 'Delete old ATC...'."\n";
473
+	}
363 474
         $ATC->deleteOldATC();
364 475
     }
365 476
     
366 477
     if (count($last_exec) == count($globalSources)) {
367 478
 	$max = $globalMinFetch;
368 479
 	foreach ($last_exec as $last) {
369
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
480
+	    if ((time() - $last['last']) < $max) {
481
+	    	$max = time() - $last['last'];
482
+	    }
370 483
 	}
371 484
 	if ($max != $globalMinFetch) {
372
-	    if ($globalDebug) echo 'Sleeping...'."\n";
485
+	    if ($globalDebug) {
486
+	    	echo 'Sleeping...'."\n";
487
+	    }
373 488
 	    sleep($globalMinFetch-$max+2);
374 489
 	}
375 490
     }
@@ -378,11 +493,15 @@  discard block
 block discarded – undo
378 493
     //foreach ($formats as $id => $value) {
379 494
     foreach ($globalSources as $id => $value) {
380 495
 	date_default_timezone_set('UTC');
381
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
496
+	if (!isset($last_exec[$id]['last'])) {
497
+		$last_exec[$id]['last'] = 0;
498
+	}
382 499
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
383 500
 	    //$buffer = $Common->getData($hosts[$id]);
384 501
 	    $buffer = $Common->getData($value['host']);
385
-	    if ($buffer != '') $reset = 0;
502
+	    if ($buffer != '') {
503
+	    	$reset = 0;
504
+	    }
386 505
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
387 506
 	    $buffer = explode('\n',$buffer);
388 507
 	    foreach ($buffer as $line) {
@@ -391,20 +510,41 @@  discard block
 block discarded – undo
391 510
 	            $data = array();
392 511
 	            $data['hex'] = $line[1]; // hex
393 512
 	            $data['ident'] = $line[2]; // ident
394
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
395
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
396
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
397
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
398
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
513
+	            if (isset($line[3])) {
514
+	            	$data['altitude'] = $line[3];
515
+	            }
516
+	            // altitude
517
+	            if (isset($line[4])) {
518
+	            	$data['speed'] = $line[4];
519
+	            }
520
+	            // speed
521
+	            if (isset($line[5])) {
522
+	            	$data['heading'] = $line[5];
523
+	            }
524
+	            // heading
525
+	            if (isset($line[6])) {
526
+	            	$data['latitude'] = $line[6];
527
+	            }
528
+	            // lat
529
+	            if (isset($line[7])) {
530
+	            	$data['longitude'] = $line[7];
531
+	            }
532
+	            // long
399 533
 	            $data['verticalrate'] = ''; // vertical rate
400 534
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
401 535
 	            $data['emergency'] = ''; // emergency
402 536
 		    $data['datetime'] = date('Y-m-d H:i:s');
403 537
 		    $data['format_source'] = 'deltadbtxt';
404 538
     		    $data['id_source'] = $id_source;
405
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
406
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
407
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
539
+		    if (isset($value['name']) && $value['name'] != '') {
540
+		    	$data['source_name'] = $value['name'];
541
+		    }
542
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
543
+		    	$data['noarchive'] = true;
544
+		    }
545
+		    if (isset($value['sourcestats'])) {
546
+		    	$data['sourcestats'] = $value['sourcestats'];
547
+		    }
408 548
     		    $SI->add($data);
409 549
 		    unset($data);
410 550
     		}
@@ -414,7 +554,9 @@  discard block
 block discarded – undo
414 554
 	    date_default_timezone_set('CET');
415 555
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
416 556
 	    date_default_timezone_set('UTC');
417
-	    if ($buffer != '') $reset = 0;
557
+	    if ($buffer != '') {
558
+	    	$reset = 0;
559
+	    }
418 560
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
419 561
 	    $buffer = explode('\n',$buffer);
420 562
 	    foreach ($buffer as $line) {
@@ -423,16 +565,36 @@  discard block
 block discarded – undo
423 565
 		    $add = false;
424 566
 		    $ais_data = $AIS->parse_line(trim($line));
425 567
 		    $data = array();
426
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
427
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
428
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
429
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
430
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
431
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
432
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
433
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
434
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
435
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
568
+		    if (isset($ais_data['ident'])) {
569
+		    	$data['ident'] = $ais_data['ident'];
570
+		    }
571
+		    if (isset($ais_data['mmsi'])) {
572
+		    	$data['mmsi'] = $ais_data['mmsi'];
573
+		    }
574
+		    if (isset($ais_data['speed'])) {
575
+		    	$data['speed'] = $ais_data['speed'];
576
+		    }
577
+		    if (isset($ais_data['heading'])) {
578
+		    	$data['heading'] = $ais_data['heading'];
579
+		    }
580
+		    if (isset($ais_data['latitude'])) {
581
+		    	$data['latitude'] = $ais_data['latitude'];
582
+		    }
583
+		    if (isset($ais_data['longitude'])) {
584
+		    	$data['longitude'] = $ais_data['longitude'];
585
+		    }
586
+		    if (isset($ais_data['status'])) {
587
+		    	$data['status'] = $ais_data['status'];
588
+		    }
589
+		    if (isset($ais_data['type'])) {
590
+		    	$data['type'] = $ais_data['type'];
591
+		    }
592
+		    if (isset($ais_data['imo'])) {
593
+		    	$data['imo'] = $ais_data['imo'];
594
+		    }
595
+		    if (isset($ais_data['callsign'])) {
596
+		    	$data['callsign'] = $ais_data['callsign'];
597
+		    }
436 598
 		    if (isset($ais_data['timestamp'])) {
437 599
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
438 600
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -446,8 +608,12 @@  discard block
 block discarded – undo
446 608
 		    $data['format_source'] = 'aisnmeatxt';
447 609
     		    $data['id_source'] = $id_source;
448 610
 		    //print_r($data);
449
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
450
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
611
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
612
+		    	$data['noarchive'] = true;
613
+		    }
614
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
615
+		    	$MI->add($data);
616
+		    }
451 617
 		    unset($data);
452 618
 		}
453 619
     	    }
@@ -467,20 +633,48 @@  discard block
 block discarded – undo
467 633
 			    if ($line != '') {
468 634
 				$ais_data = $AIS->parse_line(trim($line));
469 635
 				$data = array();
470
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
471
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
472
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
473
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
474
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
475
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
476
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
477
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
478
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
479
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
480
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
481
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
482
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
483
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
636
+				if (isset($ais_data['ident'])) {
637
+					$data['ident'] = $ais_data['ident'];
638
+				}
639
+				if (isset($ais_data['mmsi'])) {
640
+					$data['mmsi'] = $ais_data['mmsi'];
641
+				}
642
+				if (isset($ais_data['speed'])) {
643
+					$data['speed'] = $ais_data['speed'];
644
+				}
645
+				if (isset($ais_data['heading'])) {
646
+					$data['heading'] = $ais_data['heading'];
647
+				}
648
+				if (isset($ais_data['latitude'])) {
649
+					$data['latitude'] = $ais_data['latitude'];
650
+				}
651
+				if (isset($ais_data['longitude'])) {
652
+					$data['longitude'] = $ais_data['longitude'];
653
+				}
654
+				if (isset($ais_data['status'])) {
655
+					$data['status'] = $ais_data['status'];
656
+				}
657
+				if (isset($ais_data['statusid'])) {
658
+					$data['status_id'] = $ais_data['statusid'];
659
+				}
660
+				if (isset($ais_data['type'])) {
661
+					$data['type'] = $ais_data['type'];
662
+				}
663
+				if (isset($ais_data['typeid'])) {
664
+					$data['type_id'] = $ais_data['typeid'];
665
+				}
666
+				if (isset($ais_data['imo'])) {
667
+					$data['imo'] = $ais_data['imo'];
668
+				}
669
+				if (isset($ais_data['callsign'])) {
670
+					$data['callsign'] = $ais_data['callsign'];
671
+				}
672
+				if (isset($ais_data['destination'])) {
673
+					$data['arrival_code'] = $ais_data['destination'];
674
+				}
675
+				if (isset($ais_data['eta_ts'])) {
676
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
677
+				}
484 678
 				if (isset($ais_data['timestamp'])) {
485 679
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
486 680
 				} else {
@@ -488,18 +682,27 @@  discard block
 block discarded – undo
488 682
 				}
489 683
 				$data['format_source'] = 'aisnmeahttp';
490 684
 				$data['id_source'] = $id_source;
491
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
492
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
685
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
686
+					$data['noarchive'] = true;
687
+				}
688
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
689
+					$MI->add($data);
690
+				}
493 691
 				unset($data);
494 692
 			    }
495 693
 			}
496 694
 		    }
497 695
 		} else {
498 696
 		    $format = $value['format'];
499
-		    if (isset($tt[$format])) $tt[$format]++;
500
-		    else $tt[$format] = 0;
697
+		    if (isset($tt[$format])) {
698
+		    	$tt[$format]++;
699
+		    } else {
700
+		    	$tt[$format] = 0;
701
+		    }
501 702
 		    if ($tt[$format] > 30) {
502
-			if ($globalDebug) echo 'Reconnect...'."\n";
703
+			if ($globalDebug) {
704
+				echo 'Reconnect...'."\n";
705
+			}
503 706
 			sleep(2);
504 707
 			$sourceeen[] = $value;
505 708
 			connect_all($sourceeen);
@@ -529,7 +732,9 @@  discard block
 block discarded – undo
529 732
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
530 733
 			    $data['format_source'] = 'myshiptracking';
531 734
 			    $data['id_source'] = $id_source;
532
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
735
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
736
+			    	$data['noarchive'] = true;
737
+			    }
533 738
 			    $MI->add($data);
534 739
 			    unset($data);
535 740
 			}
@@ -549,7 +754,9 @@  discard block
 block discarded – undo
549 754
 			    $data['callsign'] = $line['callsign'];
550 755
 			    $data['mmsi'] = $line['mmsi'];
551 756
 			    $data['speed'] = $line['sog'];
552
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
757
+			    if ($line['heading'] != '511') {
758
+			    	$data['heading'] = $line['heading'];
759
+			    }
553 760
 			    $data['latitude'] = $line['latitude'];
554 761
 			    $data['longitude'] = $line['longitude'];
555 762
 			    $data['type_id'] = $line['shiptype'];
@@ -557,7 +764,9 @@  discard block
 block discarded – undo
557 764
 			    $data['datetime'] = $line['time'];
558 765
 			    $data['format_source'] = 'boatbeaconapp';
559 766
 			    $data['id_source'] = $id_source;
560
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
767
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
768
+			    	$data['noarchive'] = true;
769
+			    }
561 770
 			    $MI->add($data);
562 771
 			    unset($data);
563 772
 			}
@@ -573,22 +782,44 @@  discard block
 block discarded – undo
573 782
 		if (isset($all_data['features'][0]['id'])) {
574 783
 		    foreach ($all_data['features'] as $line) {
575 784
 			$data = array();
576
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
577
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
578
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
579
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
580
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
581
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
785
+			if (isset($line['properties']['name'])) {
786
+				$data['ident'] = $line['properties']['name'];
787
+			}
788
+			if (isset($line['properties']['callsign'])) {
789
+				$data['callsign'] = $line['properties']['callsign'];
790
+			}
791
+			if (isset($line['properties']['mmsi'])) {
792
+				$data['mmsi'] = $line['properties']['mmsi'];
793
+			}
794
+			if (isset($line['properties']['imo'])) {
795
+				$data['mmsi'] = $line['properties']['imo'];
796
+			}
797
+			if (isset($line['properties']['speed'])) {
798
+				$data['speed'] = $line['properties']['speed'];
799
+			}
800
+			if (isset($line['properties']['heading'])) {
801
+				$data['heading'] = $line['properties']['heading'];
802
+			}
582 803
 			$data['latitude'] = $line['geometry']['coordinates'][1];
583 804
 			$data['longitude'] = $line['geometry']['coordinates'][0];
584
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
585
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
586
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
805
+			if (isset($line['properties']['vesselType'])) {
806
+				$data['type'] = $line['properties']['vesselType'];
807
+			}
808
+			if (isset($line['properties']['destination'])) {
809
+				$data['arrival_code'] = $line['properties']['destination'];
810
+			}
811
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
812
+				$data['arrival_date'] = $line['properties']['eta'];
813
+			}
587 814
 			$data['format_source'] = 'boatnerd';
588 815
 			$data['id_source'] = $id_source;
589 816
 			$data['datetime'] = date('Y-m-d H:i:s');
590
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
591
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
817
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
818
+				$data['noarchive'] = true;
819
+			}
820
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
821
+				$MI->add($data);
822
+			}
592 823
 			unset($data);
593 824
 		    }
594 825
 		}
@@ -599,7 +830,9 @@  discard block
 block discarded – undo
599 830
 	    echo 'download...';
600 831
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
601 832
 	    echo 'done !'."\n";
602
-	    if ($buffer != '') $reset = 0;
833
+	    if ($buffer != '') {
834
+	    	$reset = 0;
835
+	    }
603 836
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
604 837
 	    $buffer = explode('\n',$buffer);
605 838
 	    foreach ($buffer as $line) {
@@ -624,7 +857,9 @@  discard block
 block discarded – undo
624 857
 		    //$data['etaTime'] = substr($line,135,5);
625 858
 		    $data['format_source'] = 'shipplotter';
626 859
     		    $data['id_source'] = $id_source;
627
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
860
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
861
+		    	$data['noarchive'] = true;
862
+		    }
628 863
 		    //print_r($data);
629 864
 		    echo 'Add...'."\n";
630 865
 		    $MI->add($data);
@@ -644,16 +879,28 @@  discard block
 block discarded – undo
644 879
     		    $line = explode(':', $line);
645 880
     		    if (count($line) > 30 && $line[0] != 'callsign') {
646 881
 			$data = array();
647
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
648
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
882
+			if (isset($line[37]) && $line[37] != '') {
883
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
884
+			} else {
885
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
886
+			}
649 887
 			$data['pilot_id'] = $line[1];
650 888
 			$data['pilot_name'] = $line[2];
651 889
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
652 890
 			$data['ident'] = $line[0]; // ident
653
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
891
+			if ($line[7] != '' && $line[7] != 0) {
892
+				$data['altitude'] = $line[7];
893
+			}
894
+			// altitude
654 895
 			$data['speed'] = $line[8]; // speed
655
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
656
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
896
+			if (isset($line[45])) {
897
+				$data['heading'] = $line[45];
898
+			}
899
+			// heading
900
+			elseif (isset($line[38])) {
901
+				$data['heading'] = $line[38];
902
+			}
903
+			// heading
657 904
 			$data['latitude'] = $line[5]; // lat
658 905
 	        	$data['longitude'] = $line[6]; // long
659 906
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -669,7 +916,9 @@  discard block
 block discarded – undo
669 916
 			$data['frequency'] = $line[4];
670 917
 			$data['type'] = $line[18];
671 918
 			$data['range'] = $line[19];
672
-			if (isset($line[35])) $data['info'] = $line[35];
919
+			if (isset($line[35])) {
920
+				$data['info'] = $line[35];
921
+			}
673 922
     			$data['id_source'] = $id_source;
674 923
 	    		//$data['arrival_airport_time'] = ;
675 924
 	    		if ($line[9] != '') {
@@ -683,27 +932,47 @@  discard block
 block discarded – undo
683 932
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
684 933
 	    		*/
685 934
 	    		$data['format_source'] = $value['format'];
686
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
687
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
688
-    			if ($line[3] == 'PILOT') $SI->add($data);
689
-			elseif ($line[3] == 'ATC') {
935
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
936
+				$data['noarchive'] = true;
937
+			}
938
+			if (isset($value['name']) && $value['name'] != '') {
939
+				$data['source_name'] = $value['name'];
940
+			}
941
+    			if ($line[3] == 'PILOT') {
942
+    				$SI->add($data);
943
+    			} elseif ($line[3] == 'ATC') {
690 944
 				//print_r($data);
691 945
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
692 946
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
693 947
 				$typec = substr($data['ident'],-3);
694
-				if ($typec == 'APP') $data['type'] = 'Approach';
695
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
696
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
697
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
698
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
699
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
700
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
701
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
702
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
703
-				if (!isset($data['source_name'])) $data['source_name'] = '';
948
+				if ($typec == 'APP') {
949
+					$data['type'] = 'Approach';
950
+				} elseif ($typec == 'TWR') {
951
+					$data['type'] = 'Tower';
952
+				} elseif ($typec == 'OBS') {
953
+					$data['type'] = 'Observer';
954
+				} elseif ($typec == 'GND') {
955
+					$data['type'] = 'Ground';
956
+				} elseif ($typec == 'DEL') {
957
+					$data['type'] = 'Delivery';
958
+				} elseif ($typec == 'DEP') {
959
+					$data['type'] = 'Departure';
960
+				} elseif ($typec == 'FSS') {
961
+					$data['type'] = 'Flight Service Station';
962
+				} elseif ($typec == 'CTR') {
963
+					$data['type'] = 'Control Radar or Centre';
964
+				} elseif ($data['type'] == '') {
965
+					$data['type'] = 'Observer';
966
+				}
967
+				if (!isset($data['source_name'])) {
968
+					$data['source_name'] = '';
969
+				}
704 970
 				if (isset($ATC)) {
705
-					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']);
706
-					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']);
971
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
972
+						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']);
973
+					} else {
974
+						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']);
975
+					}
707 976
 				}
708 977
 			}
709 978
     			unset($data);
@@ -725,14 +994,20 @@  discard block
 block discarded – undo
725 994
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
726 995
 			$data['latitude'] = (float)$line['pktLatitude'];
727 996
 			$data['longitude'] = (float)$line['pktLongitude'];
728
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
729
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
997
+			if ((float)$line['pktTrack'] != 0) {
998
+				$data['heading'] = (float)$line['pktTrack'];
999
+			}
1000
+			if ((int)$line['pktSpeed'] != 0) {
1001
+				$data['speed'] = (int)$line['pktSpeed'];
1002
+			}
730 1003
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
731 1004
 			$data['altitude_relative'] = 'AMSL';
732 1005
 			$data['pilot_id'] = (int)$line['pktPilotID'];
733 1006
 			$data['aircraft_icao'] = 'PARAGLIDER';
734 1007
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
735
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1008
+			if (isset($pilot_data[4])) {
1009
+				$data['pilot_name'] = $pilot_data[4];
1010
+			}
736 1011
 			$data['format_source'] = $value['format'];
737 1012
 			$SI->add($data);
738 1013
 			unset($data);
@@ -769,27 +1044,61 @@  discard block
 block discarded – undo
769 1044
 		foreach ($all_data['acList'] as $line) {
770 1045
 		    $data = array();
771 1046
 		    $data['hex'] = $line['Icao']; // hex
772
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
773
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
774
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
775
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
776
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
777
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1047
+		    if (isset($line['Call'])) {
1048
+		    	$data['ident'] = $line['Call'];
1049
+		    }
1050
+		    // ident
1051
+		    if (isset($line['Alt'])) {
1052
+		    	$data['altitude'] = $line['Alt'];
1053
+		    }
1054
+		    // altitude
1055
+		    if (isset($line['Spd'])) {
1056
+		    	$data['speed'] = $line['Spd'];
1057
+		    }
1058
+		    // speed
1059
+		    if (isset($line['Trak'])) {
1060
+		    	$data['heading'] = $line['Trak'];
1061
+		    }
1062
+		    // heading
1063
+		    if (isset($line['Lat'])) {
1064
+		    	$data['latitude'] = $line['Lat'];
1065
+		    }
1066
+		    // lat
1067
+		    if (isset($line['Long'])) {
1068
+		    	$data['longitude'] = $line['Long'];
1069
+		    }
1070
+		    // long
778 1071
 		    //$data['verticalrate'] = $line['']; // verticale rate
779
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1072
+		    if (isset($line['Sqk'])) {
1073
+		    	$data['squawk'] = $line['Sqk'];
1074
+		    }
1075
+		    // squawk
780 1076
 		    $data['emergency'] = ''; // emergency
781
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1077
+		    if (isset($line['Reg'])) {
1078
+		    	$data['registration'] = $line['Reg'];
1079
+		    }
782 1080
 		    
783
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
784
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1081
+		    if (isset($line['PosTime'])) {
1082
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1083
+		    } else {
1084
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1085
+		    }
785 1086
 		    
786 1087
 		    //$data['datetime'] = date('Y-m-d H:i:s');
787
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1088
+		    if (isset($line['Type'])) {
1089
+		    	$data['aircraft_icao'] = $line['Type'];
1090
+		    }
788 1091
 	    	    $data['format_source'] = 'aircraftlistjson';
789 1092
 		    $data['id_source'] = $id_source;
790
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
791
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
792
-		    if (isset($data['latitude'])) $SI->add($data);
1093
+		    if (isset($value['name']) && $value['name'] != '') {
1094
+		    	$data['source_name'] = $value['name'];
1095
+		    }
1096
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1097
+		    	$data['noarchive'] = true;
1098
+		    }
1099
+		    if (isset($data['latitude'])) {
1100
+		    	$SI->add($data);
1101
+		    }
793 1102
 		    unset($data);
794 1103
 		}
795 1104
 	    } elseif (is_array($all_data)) {
@@ -806,12 +1115,19 @@  discard block
 block discarded – undo
806 1115
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
807 1116
 		    $data['squawk'] = $line['squawk']; // squawk
808 1117
 		    $data['emergency'] = ''; // emergency
809
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
810
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1118
+		    if (isset($line['PosTime'])) {
1119
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1120
+		    } else {
1121
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1122
+		    }
811 1123
 	    	    $data['format_source'] = 'aircraftlistjson';
812 1124
     		    $data['id_source'] = $id_source;
813
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
814
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1125
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1126
+		    	$data['noarchive'] = true;
1127
+		    }
1128
+		    if (isset($value['name']) && $value['name'] != '') {
1129
+		    	$data['source_name'] = $value['name'];
1130
+		    }
815 1131
 		    $SI->add($data);
816 1132
 		    unset($data);
817 1133
 		}
@@ -847,8 +1163,12 @@  discard block
 block discarded – undo
847 1163
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
848 1164
 	    	    $data['format_source'] = 'planeupdatefaa';
849 1165
     		    $data['id_source'] = $id_source;
850
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
851
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1166
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1167
+		    	$data['noarchive'] = true;
1168
+		    }
1169
+		    if (isset($value['name']) && $value['name'] != '') {
1170
+		    	$data['source_name'] = $value['name'];
1171
+		    }
852 1172
 		    $SI->add($data);
853 1173
 		    unset($data);
854 1174
 		}
@@ -877,7 +1197,9 @@  discard block
 block discarded – undo
877 1197
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
878 1198
 	    	    $data['format_source'] = 'opensky';
879 1199
     		    $data['id_source'] = $id_source;
880
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1200
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1201
+		    	$data['noarchive'] = true;
1202
+		    }
881 1203
 		    $SI->add($data);
882 1204
 		    unset($data);
883 1205
 		}
@@ -889,7 +1211,9 @@  discard block
 block discarded – undo
889 1211
 	    //$buffer = $Common->getData($hosts[$id]);
890 1212
 	    $buffer = $Common->getData($value['host']);
891 1213
 	    $all_data = json_decode($buffer,true);
892
-	    if (!empty($all_data)) $reset = 0;
1214
+	    if (!empty($all_data)) {
1215
+	    	$reset = 0;
1216
+	    }
893 1217
 	    foreach ($all_data as $key => $line) {
894 1218
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
895 1219
 		    $data = array();
@@ -910,8 +1234,12 @@  discard block
 block discarded – undo
910 1234
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
911 1235
 	    	    $data['format_source'] = 'fr24json';
912 1236
     		    $data['id_source'] = $id_source;
913
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
914
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1237
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1238
+		    	$data['noarchive'] = true;
1239
+		    }
1240
+		    if (isset($value['name']) && $value['name'] != '') {
1241
+		    	$data['source_name'] = $value['name'];
1242
+		    }
915 1243
 		    $SI->add($data);
916 1244
 		    unset($data);
917 1245
 		}
@@ -935,24 +1263,42 @@  discard block
 block discarded – undo
935 1263
 		    if (isset($line['inf'])) {
936 1264
 			$data = array();
937 1265
 			$data['hex'] = $line['inf']['ia'];
938
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1266
+			if (isset($line['inf']['cs'])) {
1267
+				$data['ident'] = $line['inf']['cs'];
1268
+			}
1269
+			//$line[13]
939 1270
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
940
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
941
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1271
+	    		if (isset($line['inf']['gs'])) {
1272
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1273
+	    		}
1274
+	    		// speed
1275
+	    		if (isset($line['inf']['tr'])) {
1276
+	    			$data['heading'] = $line['inf']['tr'];
1277
+	    		}
1278
+	    		// heading
942 1279
 	    		$data['latitude'] = $line['pt'][0]; // lat
943 1280
 	    		$data['longitude'] = $line['pt'][1]; // long
944 1281
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
945
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1282
+	    		if (isset($line['inf']['sq'])) {
1283
+	    			$data['squawk'] = $line['inf']['sq'];
1284
+	    		}
1285
+	    		// squawk
946 1286
 	    		//$data['aircraft_icao'] = $line[8];
947
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1287
+	    		if (isset($line['inf']['rc'])) {
1288
+	    			$data['registration'] = $line['inf']['rc'];
1289
+	    		}
948 1290
 			//$data['departure_airport_iata'] = $line[11];
949 1291
 			//$data['arrival_airport_iata'] = $line[12];
950 1292
 	    		//$data['emergency'] = ''; // emergency
951 1293
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
952 1294
 	    		$data['format_source'] = 'radarvirtueljson';
953 1295
     			$data['id_source'] = $id_source;
954
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
955
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1296
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1297
+				$data['noarchive'] = true;
1298
+			}
1299
+			if (isset($value['name']) && $value['name'] != '') {
1300
+				$data['source_name'] = $value['name'];
1301
+			}
956 1302
 			$SI->add($data);
957 1303
 			unset($data);
958 1304
 		    }
@@ -973,30 +1319,65 @@  discard block
 block discarded – undo
973 1319
 		    $data['id'] = $line['id'];
974 1320
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
975 1321
 		    $data['ident'] = $line['callsign']; // ident
976
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
977
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
978
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
979
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
980
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
981
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1322
+		    if (isset($line['pilotid'])) {
1323
+		    	$data['pilot_id'] = $line['pilotid'];
1324
+		    }
1325
+		    // pilot id
1326
+		    if (isset($line['name'])) {
1327
+		    	$data['pilot_name'] = $line['name'];
1328
+		    }
1329
+		    // pilot name
1330
+		    if (isset($line['alt'])) {
1331
+		    	$data['altitude'] = $line['alt'];
1332
+		    }
1333
+		    // altitude
1334
+		    if (isset($line['gs'])) {
1335
+		    	$data['speed'] = $line['gs'];
1336
+		    }
1337
+		    // speed
1338
+		    if (isset($line['heading'])) {
1339
+		    	$data['heading'] = $line['heading'];
1340
+		    }
1341
+		    // heading
1342
+		    if (isset($line['route'])) {
1343
+		    	$data['waypoints'] = $line['route'];
1344
+		    }
1345
+		    // route
982 1346
 		    $data['latitude'] = $line['lat']; // lat
983 1347
 		    $data['longitude'] = $line['lon']; // long
984 1348
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
985 1349
 		    //$data['squawk'] = $line['squawk']; // squawk
986 1350
 		    //$data['emergency'] = ''; // emergency
987
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
988
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
989
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1351
+		    if (isset($line['depicao'])) {
1352
+		    	$data['departure_airport_icao'] = $line['depicao'];
1353
+		    }
1354
+		    if (isset($line['deptime'])) {
1355
+		    	$data['departure_airport_time'] = $line['deptime'];
1356
+		    }
1357
+		    if (isset($line['arricao'])) {
1358
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1359
+		    }
990 1360
 		    //$data['arrival_airport_time'] = $line['arrtime'];
991
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
992
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
993
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
994
-		    else $data['info'] = '';
1361
+		    if (isset($line['aircraft'])) {
1362
+		    	$data['aircraft_icao'] = $line['aircraft'];
1363
+		    }
1364
+		    if (isset($line['transponder'])) {
1365
+		    	$data['squawk'] = $line['transponder'];
1366
+		    }
1367
+		    if (isset($line['atis'])) {
1368
+		    	$data['info'] = $line['atis'];
1369
+		    } else {
1370
+		    	$data['info'] = '';
1371
+		    }
995 1372
 		    $data['format_source'] = 'pireps';
996 1373
     		    $data['id_source'] = $id_source;
997 1374
 		    $data['datetime'] = date('Y-m-d H:i:s');
998
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
999
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1375
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1376
+		    	$data['noarchive'] = true;
1377
+		    }
1378
+		    if (isset($value['name']) && $value['name'] != '') {
1379
+		    	$data['source_name'] = $value['name'];
1380
+		    }
1000 1381
 		    if ($line['icon'] == 'plane') {
1001 1382
 			$SI->add($data);
1002 1383
 		    //    print_r($data);
@@ -1005,16 +1386,28 @@  discard block
 block discarded – undo
1005 1386
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1006 1387
 			$typec = substr($data['ident'],-3);
1007 1388
 			$data['type'] = '';
1008
-			if ($typec == 'APP') $data['type'] = 'Approach';
1009
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1010
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1011
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1012
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1013
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1014
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1015
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1016
-			else $data['type'] = 'Observer';
1017
-			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']);
1389
+			if ($typec == 'APP') {
1390
+				$data['type'] = 'Approach';
1391
+			} elseif ($typec == 'TWR') {
1392
+				$data['type'] = 'Tower';
1393
+			} elseif ($typec == 'OBS') {
1394
+				$data['type'] = 'Observer';
1395
+			} elseif ($typec == 'GND') {
1396
+				$data['type'] = 'Ground';
1397
+			} elseif ($typec == 'DEL') {
1398
+				$data['type'] = 'Delivery';
1399
+			} elseif ($typec == 'DEP') {
1400
+				$data['type'] = 'Departure';
1401
+			} elseif ($typec == 'FSS') {
1402
+				$data['type'] = 'Flight Service Station';
1403
+			} elseif ($typec == 'CTR') {
1404
+				$data['type'] = 'Control Radar or Centre';
1405
+			} else {
1406
+				$data['type'] = 'Observer';
1407
+			}
1408
+			if (isset($ATC)) {
1409
+				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']);
1410
+			}
1018 1411
 		    }
1019 1412
 		    unset($data);
1020 1413
 		}
@@ -1024,7 +1417,9 @@  discard block
 block discarded – undo
1024 1417
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1025 1418
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1026 1419
 	    //$buffer = $Common->getData($hosts[$id]);
1027
-	    if ($globalDebug) echo 'Get Data...'."\n";
1420
+	    if ($globalDebug) {
1421
+	    	echo 'Get Data...'."\n";
1422
+	    }
1028 1423
 	    $buffer = $Common->getData($value['host']);
1029 1424
 	    $all_data = json_decode($buffer,true);
1030 1425
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1032,10 +1427,16 @@  discard block
 block discarded – undo
1032 1427
 		foreach ($all_data as $line) {
1033 1428
 	    	    $data = array();
1034 1429
 	    	    //$data['id'] = $line['id']; // id not usable
1035
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1430
+	    	    if (isset($line['pilotid'])) {
1431
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1432
+	    	    }
1036 1433
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1037
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1038
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1434
+	    	    if (isset($line['pilotname'])) {
1435
+	    	    	$data['pilot_name'] = $line['pilotname'];
1436
+	    	    }
1437
+	    	    if (isset($line['pilotid'])) {
1438
+	    	    	$data['pilot_id'] = $line['pilotid'];
1439
+	    	    }
1039 1440
 	    	    $data['ident'] = $line['flightnum']; // ident
1040 1441
 	    	    $data['altitude'] = $line['alt']; // altitude
1041 1442
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1051,34 +1452,52 @@  discard block
 block discarded – undo
1051 1452
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1052 1453
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1053 1454
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1054
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1455
+	    	    } else {
1456
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1457
+	    	    }
1055 1458
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1056 1459
 	    	    $data['departure_airport_time'] = $line['deptime'];
1057 1460
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1058 1461
     		    $data['arrival_airport_time'] = $line['arrtime'];
1059 1462
     		    $data['registration'] = $line['aircraft'];
1060
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1061
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1463
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1464
+		    	$data['noarchive'] = true;
1465
+		    }
1466
+		    if (isset($line['route'])) {
1467
+		    	$data['waypoints'] = $line['route'];
1468
+		    }
1469
+		    // route
1062 1470
 		    if (isset($line['aircraftname'])) {
1063 1471
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1064 1472
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1065 1473
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1066
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1067
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1068
-	    		else {
1474
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1475
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1476
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1477
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1478
+	    		} else {
1069 1479
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1070
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1071
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1480
+	    		    if (isset($aircraft_data[1])) {
1481
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1482
+	    		    } else {
1483
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1484
+	    		    }
1072 1485
 	    		}
1073 1486
 	    	    }
1074
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1487
+    		    if (isset($line['route'])) {
1488
+    		    	$data['waypoints'] = $line['route'];
1489
+    		    }
1075 1490
     		    $data['id_source'] = $id_source;
1076 1491
 	    	    $data['format_source'] = 'phpvmacars';
1077
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1492
+		    if (isset($value['name']) && $value['name'] != '') {
1493
+		    	$data['source_name'] = $value['name'];
1494
+		    }
1078 1495
 		    $SI->add($data);
1079 1496
 		    unset($data);
1080 1497
 		}
1081
-		if ($globalDebug) echo 'No more data...'."\n";
1498
+		if ($globalDebug) {
1499
+			echo 'No more data...'."\n";
1500
+		}
1082 1501
 		unset($buffer);
1083 1502
 		unset($all_data);
1084 1503
 	    }
@@ -1086,7 +1505,9 @@  discard block
 block discarded – undo
1086 1505
     	    $last_exec[$id]['last'] = time();
1087 1506
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1088 1507
 	    //$buffer = $Common->getData($hosts[$id]);
1089
-	    if ($globalDebug) echo 'Get Data...'."\n";
1508
+	    if ($globalDebug) {
1509
+	    	echo 'Get Data...'."\n";
1510
+	    }
1090 1511
 	    $buffer = $Common->getData($value['host']);
1091 1512
 	    $all_data = json_decode($buffer,true);
1092 1513
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1115,16 +1536,25 @@  discard block
 block discarded – undo
1115 1536
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1116 1537
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1117 1538
     		    //$data['registration'] = $line['aircraft'];
1118
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1539
+		    if (isset($line['route'])) {
1540
+		    	$data['waypoints'] = $line['route'];
1541
+		    }
1542
+		    // route
1119 1543
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1120 1544
     		    $data['id_source'] = $id_source;
1121 1545
 	    	    $data['format_source'] = 'vam';
1122
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1123
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1546
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1547
+		    	$data['noarchive'] = true;
1548
+		    }
1549
+		    if (isset($value['name']) && $value['name'] != '') {
1550
+		    	$data['source_name'] = $value['name'];
1551
+		    }
1124 1552
 		    $SI->add($data);
1125 1553
 		    unset($data);
1126 1554
 		}
1127
-		if ($globalDebug) echo 'No more data...'."\n";
1555
+		if ($globalDebug) {
1556
+			echo 'No more data...'."\n";
1557
+		}
1128 1558
 		unset($buffer);
1129 1559
 		unset($all_data);
1130 1560
 	    }
@@ -1132,7 +1562,9 @@  discard block
 block discarded – undo
1132 1562
     	    $last_exec[$id]['last'] = time();
1133 1563
     	} elseif ($value['format'] == 'blitzortung' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1134 1564
 	    //$buffer = $Common->getData($hosts[$id]);
1135
-	    if ($globalDebug) echo 'Get Data...'."\n";
1565
+	    if ($globalDebug) {
1566
+	    	echo 'Get Data...'."\n";
1567
+	    }
1136 1568
 	    $buffer = $Common->getData($value['host']);
1137 1569
 	    $all_data = json_decode($buffer,true);
1138 1570
 	    if ($buffer != '') {
@@ -1150,18 +1582,24 @@  discard block
 block discarded – undo
1150 1582
 			$data['id_source'] = $id_source;
1151 1583
 			$data['format_source'] = 'blitzortung';
1152 1584
 			$SI->add($data);
1153
-			if ($globalDebug) echo '☈ Lightning added'."\n";
1585
+			if ($globalDebug) {
1586
+				echo '☈ Lightning added'."\n";
1587
+			}
1154 1588
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1155 1589
 			unset($data);
1156 1590
 		    }
1157 1591
 		}
1158
-		if ($globalDebug) echo 'No more data...'."\n";
1592
+		if ($globalDebug) {
1593
+			echo 'No more data...'."\n";
1594
+		}
1159 1595
 		unset($buffer);
1160 1596
 	    }
1161 1597
 	    $last_exec[$id]['last'] = time();
1162 1598
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1163 1599
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1164
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1600
+	    if (function_exists('pcntl_fork')) {
1601
+	    	pcntl_signal_dispatch();
1602
+	    }
1165 1603
     	    //$last_exec[$id]['last'] = time();
1166 1604
 
1167 1605
 	    //$read = array( $sockets[$id] );
@@ -1169,7 +1607,9 @@  discard block
 block discarded – undo
1169 1607
 	    $write = NULL;
1170 1608
 	    $e = NULL;
1171 1609
 	    $n = socket_select($read, $write, $e, $timeout);
1172
-	    if ($e != NULL) var_dump($e);
1610
+	    if ($e != NULL) {
1611
+	    	var_dump($e);
1612
+	    }
1173 1613
 	    if ($n > 0) {
1174 1614
 		$reset = 0;
1175 1615
 		foreach ($read as $nb => $r) {
@@ -1190,12 +1630,16 @@  discard block
 block discarded – undo
1190 1630
 		    //$SI::del();
1191 1631
 		    if ($format == 'vrstcp') {
1192 1632
 			$buffer = explode('},{',$buffer);
1193
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1633
+		    } else {
1634
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1635
+		    }
1194 1636
 		    // SBS format is CSV format
1195 1637
 		    if ($buffer !== FALSE && $buffer != '') {
1196 1638
 			$tt[$format] = 0;
1197 1639
 			if ($format == 'acarssbs3') {
1198
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1640
+			    if ($globalDebug) {
1641
+			    	echo 'ACARS : '.$buffer."\n";
1642
+			    }
1199 1643
 			    $ACARS->add(trim($buffer));
1200 1644
 			    $ACARS->deleteLiveAcarsData();
1201 1645
 			} elseif ($format == 'raw') {
@@ -1204,30 +1648,70 @@  discard block
 block discarded – undo
1204 1648
 			    if (is_array($data)) {
1205 1649
 				$data['datetime'] = date('Y-m-d H:i:s');
1206 1650
 				$data['format_source'] = 'raw';
1207
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1208
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1209
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1210
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1651
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1652
+					$data['source_name'] = $globalSources[$nb]['name'];
1653
+				}
1654
+				if (isset($globalSources[$nb]['sourcestats'])) {
1655
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1656
+				}
1657
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1658
+					$data['noarchive'] = true;
1659
+				}
1660
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1661
+					$SI->add($data);
1662
+				}
1211 1663
 			    }
1212 1664
 			} elseif ($format == 'ais') {
1213 1665
 			    $ais_data = $AIS->parse_line(trim($buffer));
1214 1666
 			    $data = array();
1215
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1216
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1217
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1218
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1219
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1220
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1221
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1222
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1223
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1224
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1225
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1226
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1227
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1228
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1229
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1230
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1667
+			    if (isset($ais_data['ident'])) {
1668
+			    	$data['ident'] = $ais_data['ident'];
1669
+			    }
1670
+			    if (isset($ais_data['mmsi'])) {
1671
+			    	$data['mmsi'] = $ais_data['mmsi'];
1672
+			    }
1673
+			    if (isset($ais_data['speed'])) {
1674
+			    	$data['speed'] = $ais_data['speed'];
1675
+			    }
1676
+			    if (isset($ais_data['heading'])) {
1677
+			    	$data['heading'] = $ais_data['heading'];
1678
+			    }
1679
+			    if (isset($ais_data['latitude'])) {
1680
+			    	$data['latitude'] = $ais_data['latitude'];
1681
+			    }
1682
+			    if (isset($ais_data['longitude'])) {
1683
+			    	$data['longitude'] = $ais_data['longitude'];
1684
+			    }
1685
+			    if (isset($ais_data['status'])) {
1686
+			    	$data['status'] = $ais_data['status'];
1687
+			    }
1688
+			    if (isset($ais_data['statusid'])) {
1689
+			    	$data['status_id'] = $ais_data['statusid'];
1690
+			    }
1691
+			    if (isset($ais_data['type'])) {
1692
+			    	$data['type'] = $ais_data['type'];
1693
+			    }
1694
+			    if (isset($ais_data['imo'])) {
1695
+			    	$data['imo'] = $ais_data['imo'];
1696
+			    }
1697
+			    if (isset($ais_data['callsign'])) {
1698
+			    	$data['callsign'] = $ais_data['callsign'];
1699
+			    }
1700
+			    if (isset($ais_data['destination'])) {
1701
+			    	$data['arrival_code'] = $ais_data['destination'];
1702
+			    }
1703
+			    if (isset($ais_data['eta_ts'])) {
1704
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1705
+			    }
1706
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1707
+			    	$data['noarchive'] = true;
1708
+			    }
1709
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1710
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1711
+			    }
1712
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1713
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1714
+			    }
1231 1715
 
1232 1716
 			    if (isset($ais_data['timestamp'])) {
1233 1717
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1236,7 +1720,9 @@  discard block
 block discarded – undo
1236 1720
 			    }
1237 1721
 			    $data['format_source'] = 'aisnmea';
1238 1722
     			    $data['id_source'] = $id_source;
1239
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1723
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1724
+			    	$MI->add($data);
1725
+			    }
1240 1726
 			    unset($data);
1241 1727
                         } elseif ($format == 'flightgearsp') {
1242 1728
                     	    //echo $buffer."\n";
@@ -1254,12 +1740,18 @@  discard block
 block discarded – undo
1254 1740
 				$data['speed'] = round($line[5]*1.94384);
1255 1741
 				$data['datetime'] = date('Y-m-d H:i:s');
1256 1742
 				$data['format_source'] = 'flightgearsp';
1257
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1258
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1743
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1744
+					$data['noarchive'] = true;
1745
+				}
1746
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1747
+					$SI->add($data);
1748
+				}
1259 1749
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1260 1750
 			    }
1261 1751
                         } elseif ($format == 'acars') {
1262
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1752
+                    	    if ($globalDebug) {
1753
+                    	    	echo 'ACARS : '.$buffer."\n";
1754
+                    	    }
1263 1755
 			    $ACARS->add(trim($buffer));
1264 1756
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1265 1757
 			    $ACARS->deleteLiveAcarsData();
@@ -1280,8 +1772,12 @@  discard block
 block discarded – undo
1280 1772
 				    $aircraft_type = $line[10];
1281 1773
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1282 1774
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1283
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1284
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1775
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1776
+				    	$data['noarchive'] = true;
1777
+				    }
1778
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1779
+				    	$SI->add($data);
1780
+				    }
1285 1781
 				}
1286 1782
 			    }
1287 1783
 			} elseif ($format == 'beast') {
@@ -1291,28 +1787,62 @@  discard block
 block discarded – undo
1291 1787
 			    foreach($buffer as $all_data) {
1292 1788
 				$line = json_decode('{'.$all_data.'}',true);
1293 1789
 				$data = array();
1294
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1295
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1296
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1297
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1298
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1299
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1300
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1790
+				if (isset($line['Icao'])) {
1791
+					$data['hex'] = $line['Icao'];
1792
+				}
1793
+				// hex
1794
+				if (isset($line['Call'])) {
1795
+					$data['ident'] = $line['Call'];
1796
+				}
1797
+				// ident
1798
+				if (isset($line['Alt'])) {
1799
+					$data['altitude'] = $line['Alt'];
1800
+				}
1801
+				// altitude
1802
+				if (isset($line['Spd'])) {
1803
+					$data['speed'] = $line['Spd'];
1804
+				}
1805
+				// speed
1806
+				if (isset($line['Trak'])) {
1807
+					$data['heading'] = $line['Trak'];
1808
+				}
1809
+				// heading
1810
+				if (isset($line['Lat'])) {
1811
+					$data['latitude'] = $line['Lat'];
1812
+				}
1813
+				// lat
1814
+				if (isset($line['Long'])) {
1815
+					$data['longitude'] = $line['Long'];
1816
+				}
1817
+				// long
1301 1818
 				//$data['verticalrate'] = $line['']; // verticale rate
1302
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1819
+				if (isset($line['Sqk'])) {
1820
+					$data['squawk'] = $line['Sqk'];
1821
+				}
1822
+				// squawk
1303 1823
 				$data['emergency'] = ''; // emergency
1304
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1824
+				if (isset($line['Reg'])) {
1825
+					$data['registration'] = $line['Reg'];
1826
+				}
1305 1827
 				/*
1306 1828
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1307 1829
 				else $data['datetime'] = date('Y-m-d H:i:s');
1308 1830
 				*/
1309 1831
 				$data['datetime'] = date('Y-m-d H:i:s');
1310
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1832
+				if (isset($line['Type'])) {
1833
+					$data['aircraft_icao'] = $line['Type'];
1834
+				}
1311 1835
 		    		$data['format_source'] = 'vrstcp';
1312 1836
 				$data['id_source'] = $id_source;
1313
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1314
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1315
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1837
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1838
+					$data['noarchive'] = true;
1839
+				}
1840
+				if (isset($value['name']) && $value['name'] != '') {
1841
+					$data['source_name'] = $value['name'];
1842
+				}
1843
+				if (isset($data['latitude']) && isset($data['hex'])) {
1844
+					$SI->add($data);
1845
+				}
1316 1846
 				unset($data);
1317 1847
 			    }
1318 1848
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1325,22 +1855,46 @@  discard block
 block discarded – undo
1325 1855
     				$data['hex'] = $lined['hexid'];
1326 1856
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1327 1857
     				$data['datetime'] = date('Y-m-d H:i:s');;
1328
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1329
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1330
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1331
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1332
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1333
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1334
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1858
+    				if (isset($lined['ident'])) {
1859
+    					$data['ident'] = $lined['ident'];
1860
+    				}
1861
+    				if (isset($lined['lat'])) {
1862
+    					$data['latitude'] = $lined['lat'];
1863
+    				}
1864
+    				if (isset($lined['lon'])) {
1865
+    					$data['longitude'] = $lined['lon'];
1866
+    				}
1867
+    				if (isset($lined['speed'])) {
1868
+    					$data['speed'] = $lined['speed'];
1869
+    				}
1870
+    				if (isset($lined['squawk'])) {
1871
+    					$data['squawk'] = $lined['squawk'];
1872
+    				}
1873
+    				if (isset($lined['alt'])) {
1874
+    					$data['altitude'] = $lined['alt'];
1875
+    				}
1876
+    				if (isset($lined['heading'])) {
1877
+    					$data['heading'] = $lined['heading'];
1878
+    				}
1335 1879
     				$data['id_source'] = $id_source;
1336 1880
     				$data['format_source'] = 'tsv';
1337
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1338
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1339
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1340
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1881
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1882
+    					$data['source_name'] = $globalSources[$nb]['name'];
1883
+    				}
1884
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1885
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1886
+    				}
1887
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1888
+					$data['noarchive'] = true;
1889
+				}
1890
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1891
+    					$SI->add($data);
1892
+    				}
1341 1893
     				unset($lined);
1342 1894
     				unset($data);
1343
-    			    } else $error = true;
1895
+    			    } else {
1896
+    			    	$error = true;
1897
+    			    }
1344 1898
 			} elseif ($format == 'aprs' && $use_aprs) {
1345 1899
 			    if ($aprs_connect == 0) {
1346 1900
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1365,59 +1919,117 @@  discard block
 block discarded – undo
1365 1919
 				    $aprs_last_tx = time();
1366 1920
 				    $data = array();
1367 1921
 				    //print_r($line);
1368
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1369
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1370
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1371
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1372
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1373
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1374
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1375
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1376
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1377
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1922
+				    if (isset($line['address'])) {
1923
+				    	$data['hex'] = $line['address'];
1924
+				    }
1925
+				    if (isset($line['mmsi'])) {
1926
+				    	$data['mmsi'] = $line['mmsi'];
1927
+				    }
1928
+				    if (isset($line['imo'])) {
1929
+				    	$data['imo'] = $line['imo'];
1930
+				    }
1931
+				    if (isset($line['squawk'])) {
1932
+				    	$data['squawk'] = $line['squawk'];
1933
+				    }
1934
+				    if (isset($line['arrival_code'])) {
1935
+				    	$data['arrical_code'] = $line['arrival_code'];
1936
+				    }
1937
+				    if (isset($line['arrival_date'])) {
1938
+				    	$data['arrical_date'] = $line['arrival_date'];
1939
+				    }
1940
+				    if (isset($line['type_id'])) {
1941
+				    	$data['type_id'] = $line['typeid'];
1942
+				    }
1943
+				    if (isset($line['status_id'])) {
1944
+				    	$data['status_id'] = $line['statusid'];
1945
+				    }
1946
+				    if (isset($line['timestamp'])) {
1947
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1948
+				    } else {
1949
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1950
+				    }
1378 1951
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1379
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1952
+				    if (isset($line['ident'])) {
1953
+				    	$data['ident'] = $line['ident'];
1954
+				    }
1380 1955
 				    $data['latitude'] = $line['latitude'];
1381 1956
 				    $data['longitude'] = $line['longitude'];
1382 1957
 				    //$data['verticalrate'] = $line[16];
1383
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1958
+				    if (isset($line['speed'])) {
1959
+				    	$data['speed'] = $line['speed'];
1960
+				    }
1384 1961
 				    //else $data['speed'] = 0;
1385
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1386
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1387
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1388
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1962
+				    if (isset($line['altitude'])) {
1963
+				    	$data['altitude'] = $line['altitude'];
1964
+				    }
1965
+				    if (isset($line['comment'])) {
1966
+				    	$data['comment'] = $line['comment'];
1967
+				    }
1968
+				    if (isset($line['symbol'])) {
1969
+				    	$data['type'] = $line['symbol'];
1970
+				    }
1971
+				    if (isset($line['heading'])) {
1972
+				    	$data['heading'] = $line['heading'];
1973
+				    }
1389 1974
 				    //else $data['heading'] = 0;
1390
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1975
+				    if (isset($line['stealth'])) {
1976
+				    	$data['aircraft_type'] = $line['stealth'];
1977
+				    }
1391 1978
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1392
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1393
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1394
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1395
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1979
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
1980
+				    	$data['noarchive'] = true;
1981
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
1982
+				    	$data['noarchive'] = false;
1983
+				    }
1984
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1985
+				    	$data['noarchive'] = true;
1986
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
1987
+				    	$data['noarchive'] = false;
1988
+				    }
1396 1989
     				    $data['id_source'] = $id_source;
1397
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1398
-				    else $data['format_source'] = 'aprs';
1990
+    				    if (isset($line['format_source'])) {
1991
+    				    	$data['format_source'] = $line['format_source'];
1992
+    				    } else {
1993
+				    	$data['format_source'] = 'aprs';
1994
+				    }
1399 1995
 				    $data['source_name'] = $line['source'];
1400
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1401
-				    else $data['source_type'] = 'flarm';
1402
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1996
+				    if (isset($line['source_type'])) {
1997
+				    	$data['source_type'] = $line['source_type'];
1998
+				    } else {
1999
+				    	$data['source_type'] = 'flarm';
2000
+				    }
2001
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2002
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2003
+    				    }
1403 2004
 				    $currentdate = date('Y-m-d H:i:s');
1404 2005
 				    $aprsdate = strtotime($data['datetime']);
1405
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2006
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2007
+				    	$data['altitude_relative'] = 'AMSL';
2008
+				    }
1406 2009
 				    // Accept data if time <= system time + 20s
1407 2010
 				    //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'])))) {
1408 2011
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1409 2012
 					$send = $SI->add($data);
1410 2013
 				    } elseif ($data['source_type'] == 'ais') {
1411
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2014
+					if (isset($globalMarine) && $globalMarine) {
2015
+						$send = $MI->add($data);
2016
+					}
1412 2017
 				    } elseif (isset($line['stealth'])) {
1413
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1414
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2018
+					if ($line['stealth'] != 0) {
2019
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2020
+					} else {
2021
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2022
+					}
1415 2023
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1416 2024
 					    //$line['symbol'] == 'Balloon' ||
1417 2025
 					    $line['symbol'] == 'Glider' || 
1418 2026
 					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1419
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1420
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2027
+					    if ($line['symbol'] == 'Ballon') {
2028
+					    	$data['aircraft_icao'] = 'BALL';
2029
+					    }
2030
+					    if ($line['symbol'] == 'Glider') {
2031
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2032
+					    }
1421 2033
 					    $send = $SI->add($data);
1422 2034
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1423 2035
 					    $line['symbol'] == 'Yacht (Sail)' || 
@@ -1448,9 +2060,13 @@  discard block
 block discarded – undo
1448 2060
 				    //} 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') {
1449 2061
 				//    } 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') {
1450 2062
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1451
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2063
+					if (isset($globalTracker) && $globalTracker) {
2064
+						$send = $TI->add($data);
2065
+					}
1452 2066
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1453
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2067
+					if (!isset($data['altitude'])) {
2068
+						$data['altitude'] = 0;
2069
+					}
1454 2070
 					$Source->deleteOldLocationByType('gs');
1455 2071
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1456 2072
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1459,7 +2075,9 @@  discard block
 block discarded – undo
1459 2075
 					}
1460 2076
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1461 2077
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1462
-					if ($globalDebug) echo '# Weather Station added'."\n";
2078
+					if ($globalDebug) {
2079
+						echo '# Weather Station added'."\n";
2080
+					}
1463 2081
 					$Source->deleteOldLocationByType('wx');
1464 2082
 					$weather_data = json_encode($line);
1465 2083
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1469,7 +2087,9 @@  discard block
 block discarded – undo
1469 2087
 					}
1470 2088
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1471 2089
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1472
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2090
+					if ($globalDebug) {
2091
+						echo '☈ Lightning added'."\n";
2092
+					}
1473 2093
 					$Source->deleteOldLocationByType('lightning');
1474 2094
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1475 2095
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1481,8 +2101,7 @@  discard block
 block discarded – undo
1481 2101
 				    	print_r($line);
1482 2102
 				    }
1483 2103
 				    unset($data);
1484
-				}
1485
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2104
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1486 2105
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1487 2106
 				}
1488 2107
 				/*
@@ -1491,7 +2110,9 @@  discard block
 block discarded – undo
1491 2110
 				}
1492 2111
 				*/
1493 2112
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1494
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2113
+				elseif ($line == true && $globalDebug) {
2114
+					echo '!! Failed : '.$buffer."!!\n";
2115
+				}
1495 2116
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1496 2117
 					$Source->deleteOldLocationByType('lightning');
1497 2118
 					$Source->deleteOldLocationByType('wx');
@@ -1527,26 +2148,45 @@  discard block
 block discarded – undo
1527 2148
     				$data['ground'] = $line[21];
1528 2149
     				$data['emergency'] = $line[19];
1529 2150
     				$data['format_source'] = 'sbs';
1530
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1531
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1532
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2151
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2152
+					$data['source_name'] = $globalSources[$nb]['name'];
2153
+				}
2154
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2155
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2156
+    				}
2157
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2158
+					$data['noarchive'] = true;
2159
+				}
1533 2160
     				$data['id_source'] = $id_source;
1534
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1535
-    				else $error = true;
2161
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2162
+    					$send = $SI->add($data);
2163
+    				} else {
2164
+    					$error = true;
2165
+    				}
1536 2166
     				unset($data);
1537
-    			    } else $error = true;
2167
+    			    } else {
2168
+    			    	$error = true;
2169
+    			    }
1538 2170
 			    if ($error) {
1539 2171
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1540
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2172
+					if ($globalDebug) {
2173
+						echo "Not a message. Ignoring... \n";
2174
+					}
1541 2175
 				} else {
1542
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2176
+					if ($globalDebug) {
2177
+						echo "Wrong line format. Ignoring... \n";
2178
+					}
1543 2179
 					if ($globalDebug) {
1544 2180
 						echo $buffer;
1545 2181
 						//print_r($line);
1546 2182
 					}
1547 2183
 					//socket_close($r);
1548
-					if ($globalDebug) echo "Reconnect after an error...\n";
1549
-					if ($format == 'aprs') $aprs_connect = 0;
2184
+					if ($globalDebug) {
2185
+						echo "Reconnect after an error...\n";
2186
+					}
2187
+					if ($format == 'aprs') {
2188
+						$aprs_connect = 0;
2189
+					}
1550 2190
 					$sourceer[$nb] = $globalSources[$nb];
1551 2191
 					connect_all($sourceer);
1552 2192
 					$sourceer = array();
@@ -1554,10 +2194,14 @@  discard block
 block discarded – undo
1554 2194
 			    }
1555 2195
 			}
1556 2196
 			// Sleep for xxx microseconds
1557
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2197
+			if (isset($globalSBSSleep)) {
2198
+				usleep($globalSBSSleep);
2199
+			}
1558 2200
 		    } else {
1559 2201
 			if ($format == 'flightgearmp') {
1560
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2202
+			    	if ($globalDebug) {
2203
+			    		echo "Reconnect FlightGear MP...";
2204
+			    	}
1561 2205
 				//@socket_close($r);
1562 2206
 				sleep($globalMinFetch);
1563 2207
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1566,10 +2210,15 @@  discard block
 block discarded – undo
1566 2210
 				break;
1567 2211
 				
1568 2212
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1569
-			    if (isset($tt[$format])) $tt[$format]++;
1570
-			    else $tt[$format] = 0;
2213
+			    if (isset($tt[$format])) {
2214
+			    	$tt[$format]++;
2215
+			    } else {
2216
+			    	$tt[$format] = 0;
2217
+			    }
1571 2218
 			    if ($tt[$format] > 30) {
1572
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2219
+				if ($globalDebug) {
2220
+					echo "ERROR : Reconnect ".$format."...";
2221
+				}
1573 2222
 				//@socket_close($r);
1574 2223
 				sleep(2);
1575 2224
 				$aprs_connect = 0;
@@ -1586,11 +2235,17 @@  discard block
 block discarded – undo
1586 2235
 	    } else {
1587 2236
 		$error = socket_strerror(socket_last_error());
1588 2237
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1589
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1590
-			if (isset($globalDebug)) echo "Restarting...\n";
2238
+			if ($globalDebug) {
2239
+				echo "ERROR : socket_select give this error ".$error . "\n";
2240
+			}
2241
+			if (isset($globalDebug)) {
2242
+				echo "Restarting...\n";
2243
+			}
1591 2244
 			// Restart the script if possible
1592 2245
 			if (is_array($sockets)) {
1593
-			    if ($globalDebug) echo "Shutdown all sockets...";
2246
+			    if ($globalDebug) {
2247
+			    	echo "Shutdown all sockets...";
2248
+			    }
1594 2249
 			    
1595 2250
 			    foreach ($sockets as $sock) {
1596 2251
 				@socket_shutdown($sock,2);
@@ -1598,25 +2253,45 @@  discard block
 block discarded – undo
1598 2253
 			    }
1599 2254
 			    
1600 2255
 			}
1601
-			if ($globalDebug) echo "Waiting...";
2256
+			if ($globalDebug) {
2257
+				echo "Waiting...";
2258
+			}
1602 2259
 			sleep(2);
1603 2260
 			$time = time();
1604 2261
 			//connect_all($hosts);
1605 2262
 			$aprs_connect = 0;
1606
-			if ($reset%5 == 0) sleep(20);
1607
-			if ($reset%10 == 0) sleep(100);
1608
-			if ($reset%20 == 0) sleep(200);
1609
-			if ($reset > 100) exit('Too many attempts...');
1610
-			if ($globalDebug) echo "Restart all connections...";
2263
+			if ($reset%5 == 0) {
2264
+				sleep(20);
2265
+			}
2266
+			if ($reset%10 == 0) {
2267
+				sleep(100);
2268
+			}
2269
+			if ($reset%20 == 0) {
2270
+				sleep(200);
2271
+			}
2272
+			if ($reset > 100) {
2273
+				exit('Too many attempts...');
2274
+			}
2275
+			if ($globalDebug) {
2276
+				echo "Restart all connections...";
2277
+			}
1611 2278
 			connect_all($globalSources);
1612 2279
 		}
1613 2280
 	    }
1614 2281
 	}
1615 2282
 	if ($globalDaemon === false) {
1616
-	    if ($globalDebug) echo 'Check all...'."\n";
1617
-	    if (isset($SI)) $SI->checkAll();
1618
-	    if (isset($TI)) $TI->checkAll();
1619
-	    if (isset($MI)) $MI->checkAll();
2283
+	    if ($globalDebug) {
2284
+	    	echo 'Check all...'."\n";
2285
+	    }
2286
+	    if (isset($SI)) {
2287
+	    	$SI->checkAll();
2288
+	    }
2289
+	    if (isset($TI)) {
2290
+	    	$TI->checkAll();
2291
+	    }
2292
+	    if (isset($MI)) {
2293
+	    	$MI->checkAll();
2294
+	    }
1620 2295
 	}
1621 2296
     }
1622 2297
 }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +501 added lines, -134 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<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>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<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>
236 284
 			</div>
@@ -238,7 +286,10 @@  discard block
 block discarded – undo
238 286
 			<div id="openweathermap_data">
239 287
 				<p>
240 288
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
241
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
289
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
290
+	print $globalOpenWeatherMapKey;
291
+}
292
+?>" />
242 293
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
243 294
 				</p>
244 295
 			</div>
@@ -248,42 +299,86 @@  discard block
 block discarded – undo
248 299
 			<legend>Coverage area</legend>
249 300
 			<p>
250 301
 				<label for="latitudemax">The maximum latitude (north)</label>
251
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
302
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
303
+	print $globalLatitudeMax;
304
+}
305
+?>" />
252 306
 			</p>
253 307
 			<p>
254 308
 				<label for="latitudemin">The minimum latitude (south)</label>
255
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
309
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
310
+	print $globalLatitudeMin;
311
+}
312
+?>" />
256 313
 			</p>
257 314
 			<p>
258 315
 				<label for="longitudemax">The maximum longitude (west)</label>
259
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
316
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
317
+	print $globalLongitudeMax;
318
+}
319
+?>" />
260 320
 			</p>
261 321
 			<p>
262 322
 				<label for="longitudemin">The minimum longitude (east)</label>
263
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
323
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
324
+	print $globalLongitudeMin;
325
+}
326
+?>" />
264 327
 			</p>
265 328
 			<p>
266 329
 				<label for="latitudecenter">The latitude center</label>
267
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
330
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
331
+	print $globalCenterLatitude;
332
+}
333
+?>" />
268 334
 			</p>
269 335
 			<p>
270 336
 				<label for="longitudecenter">The longitude center</label>
271
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
337
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
338
+	print $globalCenterLongitude;
339
+}
340
+?>" />
272 341
 			</p>
273 342
 			<p>
274 343
 				<label for="livezoom">Default Zoom on live map</label>
275
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
344
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
345
+	print $globalLiveZoom;
346
+} else {
347
+	print '9';
348
+}
349
+?>" />
276 350
 			</p>
277 351
 			<p>
278 352
 				<label for="squawk_country">Country for squawk usage</label>
279 353
 				<select name="squawk_country" id="squawk_country">
280
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
281
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
282
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
283
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
284
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
285
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
286
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
354
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
355
+	print ' selected ';
356
+}
357
+?>>UK</option>
358
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
359
+	print ' selected ';
360
+}
361
+?>>NZ</option>
362
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
363
+	print ' selected ';
364
+}
365
+?>>US</option>
366
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
367
+	print ' selected ';
368
+}
369
+?>>AU</option>
370
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
371
+	print ' selected ';
372
+}
373
+?>>NL</option>
374
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
375
+	print ' selected ';
376
+}
377
+?>>FR</option>
378
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
379
+	print ' selected ';
380
+}
381
+?>>TR</option>
287 382
 				</select>
288 383
 			</p>
289 384
 		</fieldset>
@@ -292,15 +387,24 @@  discard block
 block discarded – undo
292 387
 			<p><i>Only put in DB flights that are inside a circle</i></p>
293 388
 			<p>
294 389
 				<label for="latitude">Center latitude</label>
295
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
390
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
391
+	echo $globalDistanceIgnore['latitude'];
392
+}
393
+?>" />
296 394
 			</p>
297 395
 			<p>
298 396
 				<label for="longitude">Center longitude</label>
299
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
397
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
398
+	echo $globalDistanceIgnore['longitude'];
399
+}
400
+?>" />
300 401
 			</p>
301 402
 			<p>
302 403
 				<label for="Distance">Distance (in km)</label>
303
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
404
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
405
+	echo $globalDistanceIgnore['distance'];
406
+}
407
+?>" />
304 408
 			</p>
305 409
 		</fieldset>
306 410
 		<fieldset id="sourceloc">
@@ -409,11 +513,17 @@  discard block
 block discarded – undo
409 513
 			<div id="flightaware_data">
410 514
 				<p>
411 515
 					<label for="flightawareusername">FlightAware username</label>
412
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
516
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
517
+	print $globalFlightAwareUsername;
518
+}
519
+?>" />
413 520
 				</p>
414 521
 				<p>
415 522
 					<label for="flightawarepassword">FlightAware password/API key</label>
416
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
523
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
524
+	print $globalFlightAwarePassword;
525
+}
526
+?>" />
417 527
 				</p>
418 528
 			</div>
419 529
 -->
@@ -455,7 +565,10 @@  discard block
 block discarded – undo
455 565
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
456 566
 								?>
457 567
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
458
-								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
568
+								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
569
+	print $source['port'];
570
+}
571
+?>" /></td>
459 572
 								<?php
460 573
 								    } else {
461 574
 									$hostport = explode(':',$source['host']);
@@ -474,33 +587,102 @@  discard block
 block discarded – undo
474 587
 								?>
475 588
 								<td>
476 589
 									<select name="format[]" id="format">
477
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
478
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
479
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
480
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
481
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
482
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
483
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
484
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
485
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
486
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
487
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
488
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
489
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
490
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
491
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
492
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
493
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
494
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
495
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
496
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
590
+										<option value="auto" <?php if (!isset($source['format'])) {
591
+	print 'selected';
592
+}
593
+?>>Auto</option>
594
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
595
+	print 'selected';
596
+}
597
+?>>SBS</option>
598
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
599
+	print 'selected';
600
+}
601
+?>>TSV</option>
602
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
603
+	print 'selected';
604
+}
605
+?>>Raw</option>
606
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
607
+	print 'selected';
608
+}
609
+?>>APRS</option>
610
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
611
+	print 'selected';
612
+}
613
+?>>Radarcape deltadb.txt</option>
614
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
615
+	print 'selected';
616
+}
617
+?>>Vatsim</option>
618
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
619
+	print 'selected';
620
+}
621
+?>>Virtual Radar Server AircraftList.json</option>
622
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
623
+	print 'selected';
624
+}
625
+?>>Virtual Radar Server TCP</option>
626
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
627
+	print 'selected';
628
+}
629
+?>>phpVMS</option>
630
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
631
+	print 'selected';
632
+}
633
+?>>Virtual Airlines Manager</option>
634
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
635
+	print 'selected';
636
+}
637
+?>>IVAO</option>
638
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
639
+	print 'selected';
640
+}
641
+?>>FlightGear Multiplayer</option>
642
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
643
+	print 'selected';
644
+}
645
+?>>FlightGear Singleplayer</option>
646
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
647
+	print 'selected';
648
+}
649
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
650
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
651
+	print 'selected';
652
+}
653
+?>>ACARS SBS-3 over TCP</option>
654
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
655
+	print 'selected';
656
+}
657
+?>>NMEA AIS over TCP</option>
658
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
659
+	print 'selected';
660
+}
661
+?>>AirWhere website</option>
662
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
663
+	print 'selected';
664
+}
665
+?>>HidnSeek Callback</option>
666
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
667
+	print 'selected';
668
+}
669
+?>>Blitzortung</option>
497 670
 									</select>
498 671
 								</td>
499 672
 								<td>
500
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
673
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
674
+	print $source['name'];
675
+}
676
+?>" />
501 677
 								</td>
502
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
503
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
678
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
679
+	print 'checked';
680
+}
681
+?> /></td>
682
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
683
+	print 'checked';
684
+}
685
+?> /></td>
504 686
 								<td>
505 687
 									<select name="timezones[]" id="timezones">
506 688
 								<?php
@@ -510,7 +692,9 @@  discard block
 block discarded – undo
510 692
 											print '<option selected>'.$timezones.'</option>';
511 693
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
512 694
 											print '<option selected>'.$timezones.'</option>';
513
-										} else print '<option>'.$timezones.'</option>';
695
+										} else {
696
+											print '<option>'.$timezones.'</option>';
697
+										}
514 698
 									}
515 699
 								?>
516 700
 									</select>
@@ -560,7 +744,9 @@  discard block
 block discarded – undo
560 744
 									foreach($timezonelist as $timezones){
561 745
 										if ($timezones == 'UTC') {
562 746
 											print '<option selected>'.$timezones.'</option>';
563
-										} else print '<option>'.$timezones.'</option>';
747
+										} else {
748
+											print '<option>'.$timezones.'</option>';
749
+										}
564 750
 									}
565 751
 								?>
566 752
 									</select>
@@ -583,11 +769,17 @@  discard block
 block discarded – undo
583 769
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
584 770
 					<p>
585 771
 						<label for="acarshost">ACARS UDP host</label>
586
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
772
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
773
+	print $globalACARSHost;
774
+}
775
+?>" />
587 776
 					</p>
588 777
 					<p>
589 778
 						<label for="acarsport">ACARS UDP port</label>
590
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
779
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
780
+	print $globalACARSPort;
781
+}
782
+?>" />
591 783
 					</p>
592 784
 				</fieldset>
593 785
 			</div>
@@ -667,13 +859,19 @@  discard block
 block discarded – undo
667 859
 			<div id="schedules_options">
668 860
 				<p>
669 861
 					<label for="britishairways">British Airways API Key</label>
670
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
862
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
863
+	print $globalBritishAirwaysKey;
864
+}
865
+?>" />
671 866
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
672 867
 				</p>
673 868
 				<!--
674 869
 				<p>
675 870
 					<label for="transavia">Transavia Test API Consumer Key</label>
676
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
871
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
872
+	print $globalTransaviaKey;
873
+}
874
+?>" />
677 875
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
678 876
 				</p>
679 877
 				-->
@@ -682,10 +880,16 @@  discard block
 block discarded – undo
682 880
 						<b>Lufthansa API Key</b>
683 881
 						<p>
684 882
 							<label for="lufthansakey">Key</label>
685
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
883
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
884
+	print $globalLufthansaKey['key'];
885
+}
886
+?>" />
686 887
 						</p><p>
687 888
 							<label for="lufthansasecret">Secret</label>
688
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
889
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
890
+	print $globalLufthansaKey['secret'];
891
+}
892
+?>" />
689 893
 						</p>
690 894
 					</div>
691 895
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -705,7 +909,10 @@  discard block
 block discarded – undo
705 909
 			</p>
706 910
 			<p>
707 911
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
708
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
912
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
913
+	print $globalNOTAMSource;
914
+}
915
+?>" />
709 916
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
710 917
 			</p>
711 918
 			<br />
@@ -721,14 +928,20 @@  discard block
 block discarded – undo
721 928
 			<div id="metarsrc">
722 929
 				<p>
723 930
 					<label for="metarsource">URL of your METAR source</label>
724
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
931
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
932
+	print $globalMETARurl;
933
+}
934
+?>" />
725 935
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
726 936
 				</p>
727 937
 			</div>
728 938
 			<br />
729 939
 			<p>
730 940
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
731
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
941
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
942
+	print $globalBitlyAccessToken;
943
+}
944
+?>" />
732 945
 			</p>
733 946
 			<br />
734 947
 			<p>
@@ -744,11 +957,26 @@  discard block
 block discarded – undo
744 957
 			<p>
745 958
 				<label for="geoid_source">Geoid Source</label>
746 959
 				<select name="geoid_source" id="geoid_source">
747
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
748
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
749
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
750
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
751
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
960
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
961
+	print ' selected="selected"';
962
+}
963
+?>>EGM96 15' (2.1MB)</option>
964
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
965
+	print ' selected="selected"';
966
+}
967
+?>>EGM96 5' (19MB)</option>
968
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
969
+	print ' selected="selected"';
970
+}
971
+?>>EGM2008 5' (19MB)</option>
972
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
973
+	print ' selected="selected"';
974
+}
975
+?>>EGM2008 2.5' (75MB)</option>
976
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
977
+	print ' selected="selected"';
978
+}
979
+?>>EGM2008 1' (470MB)</option>
752 980
 				</select>
753 981
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
754 982
 			</p>
@@ -766,7 +994,12 @@  discard block
 block discarded – undo
766 994
 			</p>
767 995
 			<p>
768 996
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
769
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
997
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
998
+	print $globalArchiveMonths;
999
+} else {
1000
+	echo '0';
1001
+}
1002
+?>" />
770 1003
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
771 1004
 			</p>
772 1005
 			<p>
@@ -776,12 +1009,22 @@  discard block
 block discarded – undo
776 1009
 			</p>
777 1010
 			<p>
778 1011
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
779
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
1012
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1013
+	print $globalArchiveKeepMonths;
1014
+} else {
1015
+	echo '0';
1016
+}
1017
+?>" />
780 1018
 				<p class="help-block">0 to disable</p>
781 1019
 			</p>
782 1020
 			<p>
783 1021
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
784
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
1022
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1023
+	print $globalArchiveKeepTrackMonths;
1024
+} else {
1025
+	echo '0';
1026
+}
1027
+?>" />
785 1028
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
786 1029
 			</p>
787 1030
 			<br />
@@ -791,7 +1034,12 @@  discard block
 block discarded – undo
791 1034
 				<p class="help-block">Uncheck if the script is running as cron job</p>
792 1035
 				<div id="cronends"> 
793 1036
 					<label for="cronend">Run script for xx seconds</label>
794
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1037
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1038
+	print $globalCronEnd;
1039
+} else {
1040
+	print '0';
1041
+}
1042
+?>" />
795 1043
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
796 1044
 				</div>
797 1045
 			</p>
@@ -844,15 +1092,30 @@  discard block
 block discarded – undo
844 1092
 			<br />
845 1093
 			<p>
846 1094
 				<label for="refresh">Show flights detected since xxx seconds</label>
847
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1095
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1096
+	echo $globalLiveInterval;
1097
+} else {
1098
+	echo '200';
1099
+}
1100
+?>" />
848 1101
 			</p>
849 1102
 			<p>
850 1103
 				<label for="maprefresh">Live map refresh (in seconds)</label>
851
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1104
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1105
+	echo $globalMapRefresh;
1106
+} else {
1107
+	echo '30';
1108
+}
1109
+?>" />
852 1110
 			</p>
853 1111
 			<p>
854 1112
 				<label for="mapidle">Map idle timeout (in minutes)</label>
855
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1113
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1114
+	echo $globalMapIdleTimeout;
1115
+} else {
1116
+	echo '30';
1117
+}
1118
+?>" />
856 1119
 				<p class="help-block">0 to disable</p>
857 1120
 			</p>
858 1121
 			<p>
@@ -867,12 +1130,20 @@  discard block
 block discarded – undo
867 1130
 			<br />
868 1131
 			<p>
869 1132
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
870
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1133
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1134
+	echo $globalClosestMinDist;
1135
+} else {
1136
+	echo '50';
1137
+}
1138
+?>" />
871 1139
 			</p>
872 1140
 			<br />
873 1141
 			<p>
874 1142
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
875
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1143
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1144
+	echo $globalAircraftSize;
1145
+}
1146
+?>" />
876 1147
 			</p>
877 1148
 			<br />
878 1149
 			<p>
@@ -885,7 +1156,12 @@  discard block
 block discarded – undo
885 1156
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
886 1157
 			?>
887 1158
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
888
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1159
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1160
+	echo $globalAircraftIconColor;
1161
+} else {
1162
+	echo '1a3151';
1163
+}
1164
+?>" />
889 1165
 			<?php
890 1166
 				if (!is_writable('../cache')) {
891 1167
 			?>
@@ -903,14 +1179,27 @@  discard block
 block discarded – undo
903 1179
 			<p>
904 1180
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
905 1181
 				<div class="range">
906
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
907
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1182
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1183
+	echo $globalAirportZoom;
1184
+} else {
1185
+	echo '7';
1186
+}
1187
+?>" />
1188
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1189
+	echo $globalAirportZoom;
1190
+} else {
1191
+	echo '7';
1192
+}
1193
+?></output>
908 1194
 				</div>
909 1195
 			</p>
910 1196
 			<br />
911 1197
 			<p>
912 1198
 				<label for="customcss">Custom CSS web path</label>
913
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1199
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1200
+	echo $globalCustomCSS;
1201
+}
1202
+?>" />
914 1203
 			</p>
915 1204
 		</fieldset>
916 1205
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -937,8 +1226,12 @@  discard block
 block discarded – undo
937 1226
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
938 1227
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
939 1228
 
940
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
941
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1229
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1230
+		$error .= 'Mysql driver for PDO must be loaded';
1231
+	}
1232
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1233
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1234
+	}
942 1235
 	
943 1236
 	$_SESSION['database_root'] = $dbroot;
944 1237
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1006,15 +1299,23 @@  discard block
 block discarded – undo
1006 1299
 	$source_city = $_POST['source_city'];
1007 1300
 	$source_country = $_POST['source_country'];
1008 1301
 	$source_ref = $_POST['source_ref'];
1009
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1010
-	else $source_id = array();
1302
+	if (isset($source_id)) {
1303
+		$source_id = $_POST['source_id'];
1304
+	} else {
1305
+		$source_id = array();
1306
+	}
1011 1307
 	
1012 1308
 	$sources = array();
1013 1309
 	foreach ($source_name as $keys => $name) {
1014
-	    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]);
1015
-	    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]);
1310
+	    if (isset($source_id[$keys])) {
1311
+	    	$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]);
1312
+	    } else {
1313
+	    	$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]);
1314
+	    }
1315
+	}
1316
+	if (count($sources) > 0) {
1317
+		$_SESSION['sources'] = $sources;
1016 1318
 	}
1017
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1018 1319
 
1019 1320
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1020 1321
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1035,14 +1336,23 @@  discard block
 block discarded – undo
1035 1336
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1036 1337
 
1037 1338
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1038
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1039
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1339
+	if ($globalaircraft == 'aircraft') {
1340
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1341
+	} else {
1342
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1343
+	}
1040 1344
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1041
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1042
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1345
+	if ($globaltracker == 'tracker') {
1346
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1347
+	} else {
1348
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1349
+	}
1043 1350
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1044
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1045
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1351
+	if ($globalmarine == 'marine') {
1352
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1353
+	} else {
1354
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1355
+	}
1046 1356
 
1047 1357
 /*	
1048 1358
 	$globalSBS1Hosts = array();
@@ -1064,23 +1374,37 @@  discard block
 block discarded – undo
1064 1374
 	$name = $_POST['name'];
1065 1375
 	$format = $_POST['format'];
1066 1376
 	$timezones = $_POST['timezones'];
1067
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1068
-	else $sourcestats = array();
1069
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1070
-	else $noarchive = array();
1377
+	if (isset($_POST['sourcestats'])) {
1378
+		$sourcestats = $_POST['sourcestats'];
1379
+	} else {
1380
+		$sourcestats = array();
1381
+	}
1382
+	if (isset($_POST['noarchive'])) {
1383
+		$noarchive = $_POST['noarchive'];
1384
+	} else {
1385
+		$noarchive = array();
1386
+	}
1071 1387
 	$gSources = array();
1072 1388
 	$forcepilots = false;
1073 1389
 	foreach ($host as $key => $h) {
1074
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1075
-		else $cov = 'FALSE';
1076
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1077
-		else $arch = 'FALSE';
1390
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1391
+			$cov = 'TRUE';
1392
+		} else {
1393
+			$cov = 'FALSE';
1394
+		}
1395
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1396
+			$arch = 'TRUE';
1397
+		} else {
1398
+			$arch = 'FALSE';
1399
+		}
1078 1400
 		if (strpos($format[$key],'_callback')) {
1079 1401
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1080 1402
 		} elseif ($h != '' || $name[$key] != '') {
1081 1403
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1082 1404
 		}
1083
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1405
+		if ($format[$key] == 'airwhere') {
1406
+			$forcepilots = true;
1407
+		}
1084 1408
 	}
1085 1409
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1086 1410
 
@@ -1108,7 +1432,9 @@  discard block
 block discarded – undo
1108 1432
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1109 1433
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1110 1434
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1111
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1435
+	} else {
1436
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1437
+	}
1112 1438
 
1113 1439
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1114 1440
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1147,7 +1473,9 @@  discard block
 block discarded – undo
1147 1473
 
1148 1474
 	// Create in settings.php keys not yet configurable if not already here
1149 1475
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1150
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1476
+	if (!isset($globalDebug)) {
1477
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1478
+	}
1151 1479
 
1152 1480
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1153 1481
 	if ($resetyearstats == 'resetyearstats') {
@@ -1184,37 +1512,56 @@  discard block
 block discarded – undo
1184 1512
 	}
1185 1513
 */
1186 1514
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1187
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1188
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1189
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1190
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1515
+	if ($globalsbs == 'sbs') {
1516
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1517
+	} else {
1518
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1519
+	}
1520
+	if ($globalaprs == 'aprs') {
1521
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1522
+	} else {
1523
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1524
+	}
1191 1525
 	$va = false;
1192 1526
 	if ($globalivao == 'ivao') {
1193 1527
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1194 1528
 		$va = true;
1195
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1529
+	} else {
1530
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1531
+	}
1196 1532
 	if ($globalvatsim == 'vatsim') {
1197 1533
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1198 1534
 		$va = true;
1199
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1535
+	} else {
1536
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1537
+	}
1200 1538
 	if ($globalphpvms == 'phpvms') {
1201 1539
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1202 1540
 		$va = true;
1203
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1541
+	} else {
1542
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1543
+	}
1204 1544
 	if ($globalvam == 'vam') {
1205 1545
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1206 1546
 		$va = true;
1207
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1547
+	} else {
1548
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1549
+	}
1208 1550
 	if ($va) {
1209 1551
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1210
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1552
+	} else {
1553
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1554
+	}
1211 1555
 	if ($globalva == 'va' || $va) {
1212 1556
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1213 1557
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1214 1558
 	} else {
1215 1559
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1216
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1217
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1560
+		if ($forcepilots) {
1561
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1562
+		} else {
1563
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1564
+		}
1218 1565
 	}
1219 1566
 	
1220 1567
 	
@@ -1390,7 +1737,9 @@  discard block
 block discarded – undo
1390 1737
 		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1391 1738
 	}
1392 1739
 
1393
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1740
+	if (!isset($globalTransaction)) {
1741
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1742
+	}
1394 1743
 
1395 1744
 	// Set some defaults values...
1396 1745
 	if (!isset($globalAircraftImageSources)) {
@@ -1405,15 +1754,23 @@  discard block
 block discarded – undo
1405 1754
 
1406 1755
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1407 1756
 
1408
-	if ($error == '') settings::modify_settings($settings);
1409
-	if ($error == '') settings::comment_settings($settings_comment);
1757
+	if ($error == '') {
1758
+		settings::modify_settings($settings);
1759
+	}
1760
+	if ($error == '') {
1761
+		settings::comment_settings($settings_comment);
1762
+	}
1410 1763
 	if ($error != '') {
1411 1764
 		print '<div class="info column">'.$error.'</div>';
1412 1765
 		require('../footer.php');
1413 1766
 		exit;
1414 1767
 	} else {
1415
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1416
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1768
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1769
+			$_SESSION['waypoints'] = 1;
1770
+		}
1771
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1772
+			$_SESSION['owner'] = 1;
1773
+		}
1417 1774
 		if (isset($_POST['createdb'])) {
1418 1775
 			$_SESSION['install'] = 'database_create';
1419 1776
 		} else {
@@ -1449,10 +1806,18 @@  discard block
 block discarded – undo
1449 1806
 	$popw = false;
1450 1807
 	foreach ($_SESSION['done'] as $done) {
1451 1808
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1452
-	    if ($done == 'Create database') $pop = true;
1453
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1454
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1455
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1809
+	    if ($done == 'Create database') {
1810
+	    	$pop = true;
1811
+	    }
1812
+	    if ($_SESSION['install'] == 'database_create') {
1813
+	    	$pop = true;
1814
+	    }
1815
+	    if ($_SESSION['install'] == 'database_import') {
1816
+	    	$popi = true;
1817
+	    }
1818
+	    if ($_SESSION['install'] == 'waypoints') {
1819
+	    	$popw = true;
1820
+	    }
1456 1821
 	}
1457 1822
 	if ($pop) {
1458 1823
 	    sleep(5);
@@ -1463,7 +1828,9 @@  discard block
 block discarded – undo
1463 1828
 	} else if ($popw) {
1464 1829
 	    sleep(5);
1465 1830
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1466
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1831
+	} else {
1832
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1833
+	}
1467 1834
 	print '</div></ul>';
1468 1835
 	print '<div id="error"></div>';
1469 1836
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
location-data.php 1 patch
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,9 +17,13 @@  discard block
 block discarded – undo
17 17
 date_default_timezone_set('UTC');
18 18
 
19 19
 print '<div class="top">';
20
-if ($spotter_item['name'] != '') print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
21
-elseif ($spotter_item['location_id'] != 0) print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
22
-else print '<div class="right"><div class="callsign-details"><div class="callsign"></div>';
20
+if ($spotter_item['name'] != '') {
21
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
22
+} elseif ($spotter_item['location_id'] != 0) {
23
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
24
+} else {
25
+	print '<div class="right"><div class="callsign-details"><div class="callsign"></div>';
26
+}
23 27
 print '</div>';
24 28
 
25 29
 print '</div></div>';
@@ -34,8 +38,12 @@  discard block
 block discarded – undo
34 38
 print $spotter_item['last_seen'].' UTC';
35 39
 print '</div>';
36 40
 
37
-if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
38
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41
+if ($spotter_item['city'] != '') {
42
+	print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
43
+}
44
+if ($spotter_item['country'] !='') {
45
+	print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
46
+}
39 47
 print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
40 48
 /*
41 49
 if ($spotter_item['atc_range'] > 0) {
@@ -47,13 +55,27 @@  discard block
 block discarded – undo
47 55
 if ($spotter_item['type'] == 'wx') {
48 56
 	$weather = json_decode($spotter_item['description'],true);
49 57
 	//print_r($weather);
50
-	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
51
-	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
52
-	if (isset($weather['wind_gust'])) print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
53
-	if (isset($weather['humidity'])) print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
54
-	if (isset($weather['rain'])) print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
55
-	if (isset($weather['precipitation'])) print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
56
-	if (isset($weather['precipitation24h'])) print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
58
+	if (isset($weather['temp'])) {
59
+		print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
60
+	}
61
+	if (isset($weather['pressure'])) {
62
+		print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
63
+	}
64
+	if (isset($weather['wind_gust'])) {
65
+		print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
66
+	}
67
+	if (isset($weather['humidity'])) {
68
+		print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
69
+	}
70
+	if (isset($weather['rain'])) {
71
+		print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
72
+	}
73
+	if (isset($weather['precipitation'])) {
74
+		print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
75
+	}
76
+	if (isset($weather['precipitation24h'])) {
77
+		print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
78
+	}
57 79
 	$spotter_item['description'] = $weather['comment'];
58 80
 }
59 81
 print '</div>';
Please login to merge, or discard this patch.
js/map.2d.js.php 1 patch
Braces   +101 added lines, -26 removed lines patch added patch discarded remove patch
@@ -4,10 +4,15 @@  discard block
 block discarded – undo
4 4
 
5 5
 setcookie("MapFormat",'2d');
6 6
 
7
-if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = '';
7
+if (!isset($globalOpenWeatherMapKey)) {
8
+	$globalOpenWeatherMapKey = '';
9
+}
8 10
 // Compressed GeoJson is used if true
9
-if (!isset($globalJsonCompress)) $compress = true;
10
-else $compress = $globalJsonCompress;
11
+if (!isset($globalJsonCompress)) {
12
+	$compress = true;
13
+} else {
14
+	$compress = $globalJsonCompress;
15
+}
11 16
 if (isset($_GET['archive'])) {
12 17
 	$archive = true;
13 18
 	//$archiveupdatetime = 50;
@@ -18,8 +23,11 @@  discard block
 block discarded – undo
18 23
 	//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
19 24
 	//$lastupd = 20;
20 25
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
21
-	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
22
-	else $enddate = time();
26
+	if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
27
+		$enddate = $_GET['enddate'];
28
+	} else {
29
+		$enddate = time();
30
+	}
23 31
 	setcookie("archive_begin",$begindate);
24 32
 	setcookie("archive_end",$enddate);
25 33
 	setcookie("archive_update",$lastupd);
@@ -106,7 +114,17 @@  discard block
 block discarded – undo
106 114
 	}
107 115
 
108 116
 	//create the map
109
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
117
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
118
+	print $latitude;
119
+} else {
120
+	print $globalCenterLatitude;
121
+}
122
+?>,<?php if (isset($longitude)) {
123
+	print $longitude;
124
+} else {
125
+	print $globalCenterLongitude;
126
+}
127
+?>], zoom);
110 128
 <?php
111 129
 	} else {
112 130
 ?>
@@ -119,9 +137,19 @@  discard block
 block discarded – undo
119 137
 	     || navigator.userAgent.match(/BlackBerry/i)
120 138
 	     || navigator.userAgent.match(/Windows Phone/i))
121 139
 	{
122
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
140
+		var zoom = <?php if (isset($globalLiveZoom)) {
141
+	print $globalLiveZoom-1;
142
+} else {
143
+	print '8';
144
+}
145
+?>;
123 146
 	} else {
124
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
147
+		var zoom = <?php if (isset($globalLiveZoom)) {
148
+	print $globalLiveZoom;
149
+} else {
150
+	print '9';
151
+}
152
+?>;
125 153
 	}
126 154
 
127 155
 	//create the map
@@ -146,16 +174,27 @@  discard block
 block discarded – undo
146 174
 	bounds = L.latLngBounds(southWest,northEast);
147 175
 	//a few title layers
148 176
 <?php
149
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
150
-	else $MapType = $globalMapProvider;
177
+	if (isset($_COOKIE['MapType'])) {
178
+		$MapType = $_COOKIE['MapType'];
179
+	} else {
180
+		$MapType = $globalMapProvider;
181
+	}
151 182
 
152 183
 	if ($MapType == 'Mapbox') {
153
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
154
-		else $MapBoxId = $_COOKIE['MapTypeId'];
155
-?>
184
+		if ($_COOKIE['MapTypeId'] == 'default') {
185
+			$MapBoxId = $globalMapboxId;
186
+		} else {
187
+			$MapBoxId = $_COOKIE['MapTypeId'];
188
+		}
189
+		?>
156 190
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
157 191
 	    maxZoom: 18,
158
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
192
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
193
+	print 'false';
194
+} else {
195
+	print 'true';
196
+}
197
+?>,
159 198
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
160 199
 	      '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
161 200
 	      'Imagery © <a href="http://mapbox.com">Mapbox</a>',
@@ -167,7 +206,12 @@  discard block
 block discarded – undo
167 206
 ?>
168 207
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
169 208
 	    maxZoom: 18,
170
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
209
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
210
+	print 'false';
211
+} else {
212
+	print 'true';
213
+}
214
+?>,
171 215
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
172 216
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
173 217
 	}).addTo(map);
@@ -213,20 +257,26 @@  discard block
 block discarded – undo
213 257
 	map.addLayer(yandexLayer);
214 258
 <?php
215 259
 	} elseif ($MapType == 'Bing-Aerial') {
216
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
217
-?>
260
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
261
+			setcookie('MapType','OpenStreetMap');
262
+		}
263
+		?>
218 264
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
219 265
 	map.addLayer(bingLayer);
220 266
 <?php
221 267
 	} elseif ($MapType == 'Bing-Hybrid') {
222
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
223
-?>
268
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
269
+			setcookie('MapType','OpenStreetMap');
270
+		}
271
+		?>
224 272
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
225 273
 	map.addLayer(bingLayer);
226 274
 <?php
227 275
 	} elseif ($MapType == 'Bing-Road') {
228
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
229
-?>
276
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
277
+			setcookie('MapType','OpenStreetMap');
278
+		}
279
+		?>
230 280
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
231 281
 	map.addLayer(bingLayer);
232 282
 <?php
@@ -249,9 +299,24 @@  discard block
 block discarded – undo
249 299
 		$customid = $MapType;
250 300
 ?>
251 301
 	L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
252
-	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
253
-	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
254
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
302
+	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
303
+	print $globalMapCustomLayer[$customid]['maxZoom'];
304
+} else {
305
+	print '18';
306
+}
307
+?>,
308
+	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
309
+	print $globalMapCustomLayer[$customid]['minZoom'];
310
+} else {
311
+	print '0';
312
+}
313
+?>,
314
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
315
+	print 'false';
316
+} else {
317
+	print 'true';
318
+}
319
+?>,
255 320
 	    attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
256 321
 	}).addTo(map);
257 322
 
@@ -285,7 +350,12 @@  discard block
 block discarded – undo
285 350
 		}
286 351
 	} elseif ($globalBounding == 'circle') {
287 352
 ?>
288
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
353
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
354
+	print $globalBoundingCircleSize;
355
+} else {
356
+	print '70000';
357
+}
358
+?>,{
289 359
 	    color: '#92C7D1',
290 360
 	    fillColor: '#92C7D1',
291 361
 	    fillOpacity: 0.3,
@@ -382,7 +452,12 @@  discard block
 block discarded – undo
382 452
 		//}
383 453
 	});
384 454
 update_locationsLayer();
385
-setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
455
+setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) {
456
+	print $globalMapRefresh*1000*2;
457
+} else {
458
+	print '60000';
459
+}
460
+?>);
386 461
 
387 462
 <?php
388 463
     // Add support for custom json via $globalMapJson
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Braces   +190 added lines, -65 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
94
+	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') {
95
+		$globalCoordMinChangeTracker = '0.015';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -97,19 +107,29 @@  discard block
 block discarded – undo
97 107
 		// Increment message number
98 108
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99 109
 		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
110
+		    if (isset($line['source_name'])) {
111
+		    	$source = $line['source_name'];
112
+		    } else {
113
+		    	$source = '';
114
+		    }
115
+		    if ($source == '' || $line['format_source'] == 'aprs') {
116
+		    	$source = $line['format_source'];
117
+		    }
103 118
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104 119
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105 120
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
121
+		    } else {
122
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
123
+		    }
107 124
 		}
108 125
 		
109 126
 		
110 127
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
128
+	        if (!isset($line['id'])) {
129
+	        	$id = trim($line['ident']);
130
+	        } else {
131
+	        	$id = trim($line['id']);
132
+	        }
113 133
 		
114 134
 		if (!isset($this->all_tracked[$id])) {
115 135
 		    $this->all_tracked[$id] = array();
@@ -117,31 +137,46 @@  discard block
 block discarded – undo
117 137
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118 138
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119 139
 		    if (!isset($line['id'])) {
120
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
140
+			if (!isset($globalDaemon)) {
141
+				$globalDaemon = TRUE;
142
+			}
121 143
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
144
+		     } else {
145
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
146
+		     }
147
+		    if ($globalAllTracked !== FALSE) {
148
+		    	$dataFound = true;
149
+		    }
124 150
 		}
125 151
 		
126 152
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127 153
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 154
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129 155
 		    } else {
130
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
156
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
157
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
158
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
159
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
160
+				}
132 161
 				return '';
133 162
 		    }
134 163
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
164
+			if ($globalDebug) {
165
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
166
+			}
136 167
 			return '';
137 168
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
169
+			if ($globalDebug) {
170
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
171
+			}
139 172
 			return '';
140 173
 		} elseif (!isset($line['datetime'])) {
141 174
 			date_default_timezone_set('UTC');
142 175
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143 176
 		} else {
144
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
177
+			if ($globalDebug) {
178
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
179
+			}
145 180
 			return '';
146 181
 		}
147 182
 		
@@ -153,11 +188,17 @@  discard block
 block discarded – undo
153 188
             		$Tracker = new Tracker($this->db);
154 189
             		$fromsource = NULL;
155 190
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
191
+			if ($globalDebug && $result != 'success') {
192
+				echo '!!! ERROR : '.$result."\n";
193
+			}
157 194
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195
+			if ($globalDebugTimeElapsed) {
196
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
197
+			}
198
+		    }
199
+		    if (!isset($this->all_tracked[$id]['id'])) {
200
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159 201
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 202
 		}
162 203
 
163 204
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -168,14 +209,21 @@  discard block
 block discarded – undo
168 209
 		    if ($distance > 100 && $distance < 10000) {
169 210
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 211
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
212
+			if ($speed < 1000) {
213
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
214
+			}
215
+  			if ($globalDebug) {
216
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
217
+  			}
173 218
 		    }
174 219
 		}
175 220
 
176 221
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
222
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
223
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
224
+	    	    } else {
225
+	    	    	unset($timediff);
226
+	    	    }
179 227
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 228
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181 229
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) {
@@ -183,20 +231,30 @@  discard block
 block discarded – undo
183 231
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 232
 				$this->all_tracked[$id]['putinarchive'] = true;
185 233
 				
186
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
234
+				if ($globalDebug) {
235
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
236
+				}
187 237
 				$timeelapsed = microtime(true);
188 238
 				$Tracker = new Tracker($this->db);
189 239
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
240
+				if (!empty($all_country)) {
241
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
242
+				}
191 243
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+				if ($globalDebugTimeElapsed) {
245
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
246
+				}
193 247
 				$this->tmd = 0;
194
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
248
+				if ($globalDebug) {
249
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
250
+				}
195 251
 			    }
196 252
 			}
197 253
 
198 254
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
255
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
256
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
+				}
200 258
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 259
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 260
 				    $dataFound = true;
@@ -205,8 +263,12 @@  discard block
 block discarded – undo
205 263
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 264
 			}
207 265
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
266
+			    if ($line['longitude'] > 180) {
267
+			    	$line['longitude'] = $line['longitude'] - 360;
268
+			    }
269
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
270
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
+				}
210 272
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 273
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 274
 				    $dataFound = true;
@@ -226,7 +288,9 @@  discard block
 block discarded – undo
226 288
 		    }
227 289
 		}
228 290
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
291
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
292
+		    	$dataFound = true;
293
+		    }
230 294
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 295
 		}
232 296
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -246,7 +310,9 @@  discard block
 block discarded – undo
246 310
 
247 311
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 312
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
313
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
314
+				$this->all_tracked[$id]['putinarchive'] = true;
315
+			}
250 316
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 317
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 318
 			//$dataFound = true;
@@ -258,15 +324,21 @@  discard block
 block discarded – undo
258 324
 		}
259 325
 		
260 326
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
262 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264 332
 		    //$dataFound = true;
265 333
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266 334
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267 335
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
270 342
   		}
271 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 344
 
@@ -275,20 +347,31 @@  discard block
 block discarded – undo
275 347
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276 348
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 349
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
350
+				if ($globalDebug) {
351
+					echo "Check if aircraft is already in DB...";
352
+				}
279 353
 				$timeelapsed = microtime(true);
280 354
 				$TrackerLive = new TrackerLive($this->db);
281 355
 				if (isset($line['id'])) {
282 356
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
357
+				    if ($globalDebugTimeElapsed) {
358
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+				    }
284 360
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 361
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
-				} else $recent_ident = '';
362
+				    if ($globalDebugTimeElapsed) {
363
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364
+				    }
365
+				} else {
366
+					$recent_ident = '';
367
+				}
288 368
 				$TrackerLive->db=null;
289 369
 
290
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
292 375
 			    } else {
293 376
 				$recent_ident = '';
294 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -296,27 +379,41 @@  discard block
 block discarded – undo
296 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297 380
 			    if($recent_ident == "")
298 381
 			    {
299
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
384
+				}
300 385
 				//adds the spotter data for the archive
301 386
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
389
+				    }
303 390
 				    $timeelapsed = microtime(true);
304 391
 				    $Tracker = new Tracker($this->db);
305 392
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306 393
 				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
309 400
 				    
310 401
 				    
311 402
 				    // Add source stat in DB
312 403
 				    $Stats = new Stats($this->db);
313 404
 				    if (!empty($this->stats)) {
314
-					if ($globalDebug) echo 'Add source stats : ';
405
+					if ($globalDebug) {
406
+						echo 'Add source stats : ';
407
+					}
315 408
 				        foreach($this->stats as $date => $data) {
316 409
 					    foreach($data as $source => $sourced) {
317 410
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
411
+				    	        if (isset($sourced['polar'])) {
412
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
413
+				    	        }
414
+				    	        if (isset($sourced['hist'])) {
415
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
416
+				    	        }
320 417
 				    		if (isset($sourced['msg'])) {
321 418
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 419
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -329,7 +426,9 @@  discard block
 block discarded – undo
329 426
 			    			unset($this->stats[$date]);
330 427
 			    		    }
331 428
 				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
429
+				    	if ($globalDebug) {
430
+				    		echo 'Done'."\n";
431
+				    	}
333 432
 
334 433
 				    }
335 434
 				    $Stats->db = null;
@@ -339,12 +438,16 @@  discard block
 block discarded – undo
339 438
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 439
 				//print_r($this->all_tracked[$id]);
341 440
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
441
+				    if ($globalDebug) {
442
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
443
+				    }
343 444
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 445
 				    $TrackerLive = new TrackerLive($this->db);
345 446
 				    $TrackerLive->deleteLiveTrackerData();
346 447
 				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
448
+				    if ($globalDebug) {
449
+				    	echo " Done\n";
450
+				    }
348 451
 				    $this->last_delete = time();
349 452
 				}
350 453
 			    } else {
@@ -367,19 +470,25 @@  discard block
 block discarded – undo
367 470
 
368 471
 		    if (!$ignoreImport) {
369 472
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
473
+				if ($globalDebug) {
474
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
475
+				}
371 476
 				$timeelapsed = microtime(true);
372 477
 				$TrackerLive = new TrackerLive($this->db);
373 478
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
374 479
 				$TrackerLive->db = null;
375 480
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
377 484
 
378 485
 				// Put statistics in $this->stats variable
379 486
 				
380 487
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
381 488
 					$source = $this->all_tracked[$id]['source_name'];
382
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
489
+					if ($source == '') {
490
+						$source = $this->all_tracked[$id]['format_source'];
491
+					}
383 492
 					if (!isset($this->source_location[$source])) {
384 493
 						$Location = new Source();
385 494
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -400,7 +509,9 @@  discard block
 block discarded – undo
400 509
 					$stats_heading = round($stats_heading/22.5);
401 510
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
402 511
 					$current_date = date('Y-m-d');
403
-					if ($stats_heading == 16) $stats_heading = 0;
512
+					if ($stats_heading == 16) {
513
+						$stats_heading = 0;
514
+					}
404 515
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 516
 						for ($i=0;$i<=15;$i++) {
406 517
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -418,7 +529,9 @@  discard block
 block discarded – undo
418 529
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 530
 						    end($this->stats[$current_date][$source]['hist']);
420 531
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
421
-						} else $mini = 0;
532
+						} else {
533
+							$mini = 0;
534
+						}
422 535
 						for ($i=$mini;$i<=$distance;$i+=10) {
423 536
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 537
 						}
@@ -429,19 +542,29 @@  discard block
 block discarded – undo
429 542
 				}
430 543
 
431 544
 				$this->all_tracked[$id]['lastupdate'] = time();
432
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433
-				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
545
+				if ($this->all_tracked[$id]['putinarchive']) {
546
+					$send = true;
547
+				}
548
+				if ($globalDebug) {
549
+					echo $result."\n";
550
+				}
551
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
552
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
553
+			}
435 554
 			//$this->del();
436 555
 			
437 556
 			
438 557
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
558
+			    if ($globalDebug) {
559
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
560
+			    }
440 561
 			    $TrackerLive = new TrackerLive($this->db);
441 562
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 563
 			    $TrackerLive->db = null;
443 564
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
565
+			    if ($globalDebug) {
566
+			    	echo " Done\n";
567
+			    }
445 568
 			    $this->last_delete_hourly = time();
446 569
 			}
447 570
 			
@@ -449,7 +572,9 @@  discard block
 block discarded – undo
449 572
 		    //$ignoreImport = false;
450 573
 		}
451 574
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
575
+		if ($send) {
576
+			return $this->all_tracked[$id];
577
+		}
453 578
 	    }
454 579
 	}
455 580
     }
Please login to merge, or discard this patch.