Completed
Push — master ( 2dcb43...e8e430 )
by Yannick
30:24
created
search.php 1 patch
Braces   +142 added lines, -39 removed lines patch added patch discarded remove patch
@@ -46,8 +46,10 @@  discard block
 block discarded – undo
46 46
 			$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
47 47
 			$sql_date = $end_date;
48 48
 		}
49
-	} else $sql_date = '';
50
-}
49
+	} else {
50
+		$sql_date = '';
51
+	}
52
+	}
51 53
 
52 54
 if (isset($_GET['highest_altitude'])) {
53 55
 	//for altitude manipulation
@@ -61,8 +63,12 @@  discard block
 block discarded – undo
61 63
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
62 64
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
63 65
 		$sql_altitude = $start_altitude;
64
-	} else $sql_altitude = '';
65
-} else $sql_altitude = '';
66
+	} else {
67
+		$sql_altitude = '';
68
+	}
69
+	} else {
70
+	$sql_altitude = '';
71
+}
66 72
 
67 73
 //calculuation for the pagination
68 74
 if(!isset($_GET['limit']))
@@ -80,7 +86,7 @@  discard block
 block discarded – undo
80 86
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
81 87
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
82 88
 	}
83
-}  else {
89
+} else {
84 90
 	$limit_explode = explode(",", $_GET['limit']);
85 91
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
86 92
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -138,10 +144,15 @@  discard block
 block discarded – undo
138 144
 	$dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT);
139 145
 	$number_results = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
140 146
 	if ($dist != '') {
141
-		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934;
142
-		elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852;
147
+		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') {
148
+			$dist = $dist*1.60934;
149
+		} elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') {
150
+			$dist = $dist*1.852;
151
+		}
152
+	}
153
+	if (!isset($sql_date)) {
154
+		$sql_date = '';
143 155
 	}
144
-	if (!isset($sql_date)) $sql_date = '';
145 156
 	if ($archive == 1) {
146 157
 		if ($type == 'aircraft') {
147 158
 			$SpotterArchive = new SpotterArchive();
@@ -219,7 +230,10 @@  discard block
 block discarded – undo
219 230
 		if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
220 231
 		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
221 232
 		if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; }
222
-		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; }
233
+		if (isset($_GET['highlights'])) {
234
+			if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> ';
235
+		}
236
+		}
223 237
 		if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; }
224 238
 		if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; }
225 239
 		if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; }
@@ -355,7 +369,10 @@  discard block
 block discarded – undo
355 369
 			<div class="form-group">
356 370
 				<label class="control-label col-sm-2"><?php echo _("Keywords"); ?></label>
357 371
 				<div class="col-sm-10">
358
-					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) print $q; ?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
372
+					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) {
373
+	print $q;
374
+}
375
+?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
359 376
 				</div>
360 377
 			</div>
361 378
 		</fieldset>
@@ -374,7 +391,10 @@  discard block
 block discarded – undo
374 391
 					    </select>
375 392
 					</div>
376 393
 				</div>
377
-				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
394
+				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) {
395
+	print $manufacturer;
396
+}
397
+?>')</script>
378 398
 				<div class="form-group">
379 399
 					<label class="control-label col-sm-2"><?php echo _("Type"); ?></label>
380 400
 						<div class="col-sm-10">
@@ -383,11 +403,17 @@  discard block
 block discarded – undo
383 403
 							</select>
384 404
 						</div>
385 405
 				</div>
386
-				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
406
+				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) {
407
+	print $aircraft_icao;
408
+}
409
+?>');</script>
387 410
 				<div class="form-group">
388 411
 					<label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> 
389 412
 					<div class="col-sm-10">
390
-						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) print $registration; ?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
413
+						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) {
414
+	print $registration;
415
+}
416
+?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
391 417
 					</div>
392 418
 				</div>
393 419
 <?php
@@ -396,22 +422,31 @@  discard block
 block discarded – undo
396 422
 				<div class="form-group">
397 423
 					<label class="control-label col-sm-2"><?php echo _("Pilot id"); ?></label> 
398 424
 					<div class="col-sm-10">
399
-						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) print $pilot_id; ?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
425
+						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) {
426
+	print $pilot_id;
427
+}
428
+?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
400 429
 					</div>
401 430
 				</div>
402 431
 				<div class="form-group">
403 432
 					<label class="control-label col-sm-2"><?php echo _("Pilot name"); ?></label> 
404 433
 					<div class="col-sm-10">
405
-						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) print $pilot_name; ?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
434
+						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) {
435
+	print $pilot_name;
436
+}
437
+?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
406 438
 					</div>
407 439
 				</div>
408 440
 <?php
409
-	}else {
441
+	} else {
410 442
 ?>
411 443
 				<div class="form-group">
412 444
 					<label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> 
413 445
 					<div class="col-sm-10">
414
-						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) print $owner; ?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
446
+						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) {
447
+	print $owner;
448
+}
449
+?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
415 450
 					</div>
416 451
 				</div>
417 452
 <?php
@@ -419,8 +454,14 @@  discard block
 block discarded – undo
419 454
 ?>
420 455
 				<div class="form-group">
421 456
 					<div class="col-sm-offset-2 col-sm-10">
422
-					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
423
-					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label>
457
+					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
458
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
459
+}
460
+} ?>> <label for="highlights"><?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
461
+					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
462
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
463
+}
464
+} ?>> <?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label>
424 465
 					</div>
425 466
 				</div>
426 467
 			</fieldset>
@@ -434,7 +475,10 @@  discard block
 block discarded – undo
434 475
 						</select>
435 476
 					</div>
436 477
 				</div>
437
-				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script>
478
+				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) {
479
+	print $airline;
480
+}
481
+?>');</script>
438 482
 				<div class="form-group">
439 483
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
440 484
 					<div class="col-sm-10">
@@ -443,19 +487,34 @@  discard block
 block discarded – undo
443 487
 						</select>
444 488
 					</div>
445 489
 				</div>
446
-				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script>
490
+				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) {
491
+	print $airline_country;
492
+}
493
+?>');</script>
447 494
 				<div class="form-group">
448 495
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
449 496
 					<div class="col-sm-10">
450
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
497
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
498
+	print $callsign;
499
+}
500
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
451 501
 					</div>
452 502
 				</div>
453 503
 				<div class="form-group">
454 504
 					<div class="col-sm-offset-2 col-sm-10">
455 505
 						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
456
-						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
457
-						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
458
-						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
506
+						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) {
507
+	if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"';
508
+}
509
+} ?>> <?php echo _("Only Passenger airlines"); ?></label>
510
+						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) {
511
+	if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"';
512
+}
513
+} ?>> <?php echo _("Only Cargo airlines"); ?></label>
514
+						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) {
515
+	if ( $_GET['airline_type'] == "military"){ print 'checked="checked"';
516
+}
517
+} ?>> <?php echo _("Only Military airlines"); ?></label>
459 518
 					</div>
460 519
 				</div>
461 520
 			</fieldset>
@@ -469,7 +528,10 @@  discard block
 block discarded – undo
469 528
 						</select>
470 529
 					</div>
471 530
 				</div>
472
-				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
531
+				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) {
532
+	print $airport_icao;
533
+}
534
+?>');</script>
473 535
 				<div class="form-group">
474 536
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
475 537
 					<div class="col-sm-10">
@@ -478,7 +540,10 @@  discard block
 block discarded – undo
478 540
 						</select>
479 541
 					</div>
480 542
 				</div>
481
-				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script>
543
+				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) {
544
+	print $airport_country;
545
+}
546
+?>');</script>
482 547
 			</fieldset>
483 548
 			<fieldset>
484 549
 				<legend><?php echo _("Route"); ?></legend>
@@ -490,7 +555,10 @@  discard block
 block discarded – undo
490 555
 						</select>
491 556
 					</div>
492 557
 				</div>
493
-				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
558
+				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) {
559
+	print $departure_airport_route;
560
+}
561
+?>');</script>
494 562
 				<div class="form-group">
495 563
 					<label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> 
496 564
 					<div class="col-sm-10">
@@ -499,7 +567,10 @@  discard block
 block discarded – undo
499 567
 						</select>
500 568
 					</div>
501 569
 				</div>
502
-				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
570
+				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) {
571
+	print $arrival_airport_route;
572
+}
573
+?>');</script>
503 574
 			</fieldset>
504 575
 			<fieldset>
505 576
 				<legend>Altitude</legend>
@@ -549,19 +620,33 @@  discard block
 block discarded – undo
549 620
 				<div class="form-group">
550 621
 					<label class="control-label col-sm-2"><?php echo _("Latitude"); ?></label>
551 622
 					<div class="col-sm-10">
552
-						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) print $origlat; ?>" />
623
+						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) {
624
+	print $origlat;
625
+}
626
+?>" />
553 627
 					</div>
554 628
 				</div>
555 629
 				<div class="form-group">
556 630
 					<label class="control-label col-sm-2"><?php echo _("Longitude"); ?></label>
557 631
 					<div class="col-sm-10">
558
-						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) print $origlon; ?>" />
632
+						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) {
633
+	print $origlon;
634
+}
635
+?>" />
559 636
 					</div>
560 637
 				</div>
561 638
 				<div class="form-group">
562
-					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) print $globalDistanceUnit; else print 'km'; print ')'; ?></label>
639
+					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) {
640
+	print $globalDistanceUnit;
641
+} else {
642
+	print 'km';
643
+}
644
+print ')'; ?></label>
563 645
 					<div class="col-sm-10">
564
-						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) print $distance; ?>" />
646
+						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) {
647
+	print $distance;
648
+}
649
+?>" />
565 650
 					</div>
566 651
 				</div>
567 652
 			</fieldset>
@@ -572,7 +657,10 @@  discard block
 block discarded – undo
572 657
 				<div class="form-group">
573 658
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
574 659
 					<div class="col-sm-10">
575
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
660
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
661
+	print $callsign;
662
+}
663
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
576 664
 					</div>
577 665
 				</div>
578 666
 			</fieldset>
@@ -583,7 +671,10 @@  discard block
 block discarded – undo
583 671
 				<div class="form-group">
584 672
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
585 673
 					<div class="col-sm-10">
586
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
674
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
675
+	print $callsign;
676
+}
677
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
587 678
 					</div>
588 679
 				</div>
589 680
 			</fieldset>
@@ -591,7 +682,10 @@  discard block
 block discarded – undo
591 682
 				<div class="form-group">
592 683
 					<label class="control-label col-sm-2"><?php echo _("MMSI"); ?></label> 
593 684
 					<div class="col-sm-10">
594
-						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) print $mmsi; ?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
685
+						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) {
686
+	print $mmsi;
687
+}
688
+?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
595 689
 					</div>
596 690
 				</div>
597 691
 			</fieldset>
@@ -599,7 +693,10 @@  discard block
 block discarded – undo
599 693
 				<div class="form-group">
600 694
 					<label class="control-label col-sm-2"><?php echo _("IMO"); ?></label> 
601 695
 					<div class="col-sm-10">
602
-						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) print $imo; ?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
696
+						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) {
697
+	print $imo;
698
+}
699
+?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
603 700
 					</div>
604 701
 				</div>
605 702
 			</fieldset>
@@ -612,7 +709,10 @@  discard block
 block discarded – undo
612 709
 					<label class="control-label col-sm-2"><?php echo _("Start Date"); ?></label>
613 710
 					<div class="col-sm-10">
614 711
 						<div class='input-group date' id='datetimepicker1'>
615
-							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') print $start_date; ?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
712
+							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') {
713
+	print $start_date;
714
+}
715
+?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
616 716
 							<span class="input-group-addon">
617 717
 								<span class="glyphicon glyphicon-calendar"></span>
618 718
 							</span>
@@ -623,7 +723,10 @@  discard block
 block discarded – undo
623 723
 					<label class="control-label col-sm-2"><?php echo _("End Date"); ?></label>
624 724
 					<div class="col-sm-10">
625 725
 						<div class='input-group date' id='datetimepicker2'>
626
-						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') print $end_date; ?>" placeholder="<?php echo _("End Date/Time"); ?>" />
726
+						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') {
727
+	print $end_date;
728
+}
729
+?>" placeholder="<?php echo _("End Date/Time"); ?>" />
627 730
 						<span class="input-group-addon">
628 731
 							<span class="glyphicon glyphicon-calendar"></span>
629 732
 						</span>
Please login to merge, or discard this patch.
pilot-detailed.php 1 patch
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,8 +37,12 @@  discard block
 block discarded – undo
37 37
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
38 38
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
39 39
 	$filter = array();
40
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
41
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
40
+	if ($year != '') {
41
+		$filter = array_merge($filter,array('year' => $year));
42
+	}
43
+	if ($month != '') {
44
+		$filter = array_merge($filter,array('month' => $month));
45
+	}
42 46
 	if ($sort != '') 
43 47
 	{
44 48
 		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -56,8 +60,12 @@  discard block
 block discarded – undo
56 60
 	{
57 61
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
58 62
 		$ident = $spotter_array[0]['ident'];
59
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
60
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
63
+		if (isset($spotter_array[0]['latitude'])) {
64
+			$latitude = $spotter_array[0]['latitude'];
65
+		}
66
+		if (isset($spotter_array[0]['longitude'])) {
67
+			$longitude = $spotter_array[0]['longitude'];
68
+		}
61 69
 		require_once('header.php');
62 70
 		/*
63 71
 		if (isset($globalArchive) && $globalArchive) {
@@ -110,12 +118,18 @@  discard block
 block discarded – undo
110 118
 		*/
111 119
 		print '<div class="info column">';
112 120
 		print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
113
-		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
121
+		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') {
122
+			print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
123
+		}
114 124
 		if ($year == '' && $month == '') {
115 125
 			$Stats = new Stats();
116 126
 			$flights = $Stats->getStatsPilot($pilot);
117
-		} else $flights = 0;
118
-		if ($flights == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter);
127
+		} else {
128
+			$flights = 0;
129
+		}
130
+		if ($flights == 0) {
131
+			$flights = $Spotter->countFlightsByPilot($pilot,$filter);
132
+		}
119 133
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
120 134
 		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter));
121 135
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
@@ -126,7 +140,9 @@  discard block
 block discarded – undo
126 140
 		$airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter));
127 141
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
128 142
 		$duration = $Spotter->getFlightDurationByPilot($pilot,$filter);
129
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
143
+		if ($duration != '0') {
144
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
145
+		}
130 146
 		print '</div>';
131 147
 	
132 148
 		include('pilot-sub-menu.php');
Please login to merge, or discard this patch.
header.php 1 patch
Braces   +90 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,12 +6,19 @@  discard block
 block discarded – undo
6 6
 //gets the page file and stores it in a variable
7 7
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
8 8
 $current_page = $file_path['filename'];
9
-if ($globalTimezone == '') $globalTimezone = 'UTC';
9
+if ($globalTimezone == '') {
10
+	$globalTimezone = 'UTC';
11
+}
10 12
 date_default_timezone_set($globalTimezone);
11
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
12
-else $MapType = $globalMapProvider;
13
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
14
+	$MapType = $_COOKIE['MapType'];
15
+} else {
16
+	$MapType = $globalMapProvider;
17
+}
13 18
 
14
-if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
19
+if (isset($globalMapOffline) && $globalMapOffline) {
20
+	$MapType = 'offline';
21
+}
15 22
 
16 23
 if (isset($_GET['3d'])) {
17 24
 	setcookie('MapFormat','3d');
@@ -219,7 +226,10 @@  discard block
 block discarded – undo
219 226
 <?php
220 227
 //		}
221 228
 ?>
222
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) print '&tsk='.$tsk; ?>"></script>
229
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) {
230
+	print '&tsk='.$tsk;
231
+}
232
+?>"></script>
223 233
 <?php
224 234
 		if (!isset($globalAircraft) || $globalAircraft) {
225 235
 ?>
@@ -264,7 +274,13 @@  discard block
 block discarded – undo
264 274
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
265 275
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
266 276
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
267
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
277
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
278
+	print '&latitude='.$latitude;
279
+}
280
+?><?php if(isset($longitude)) {
281
+	print '&longitude='.$longitude;
282
+}
283
+?>&<?php print time(); ?>"></script>
268 284
 <?php
269 285
 		if (!isset($type) || $type == 'aircraft') {
270 286
 ?>
@@ -337,7 +353,13 @@  discard block
 block discarded – undo
337 353
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
338 354
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
339 355
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
340
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
356
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
357
+	print '&latitude='.$latitude;
358
+}
359
+?><?php if(isset($longitude)) {
360
+	print '&longitude='.$longitude;
361
+}
362
+?>&<?php print time(); ?>"></script>
341 363
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
342 364
 <?php
343 365
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -418,7 +440,12 @@  discard block
 block discarded – undo
418 440
         <span class="icon-bar"></span>
419 441
       </button>
420 442
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle search"><i class="fa fa-search"></i></a>
421
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
443
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
444
+	print '/';
445
+} else {
446
+	print $globalURL;
447
+}
448
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
422 449
     </div>
423 450
     <div class="collapse navbar-collapse">
424 451
 
@@ -473,7 +500,10 @@  discard block
 block discarded – undo
473 500
 	}
474 501
 ?>
475 502
 
476
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
503
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
504
+	echo 'right-';
505
+}
506
+?>caret"></b></a>
477 507
           <ul class="dropdown-menu">
478 508
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircraft Types"); ?></a></li>
479 509
 <?php
@@ -544,8 +574,14 @@  discard block
 block discarded – undo
544 574
         </li>
545 575
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
546 576
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
547
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
548
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
577
+        <li class="dropdown<?php if ($sub) {
578
+	echo '-submenu';
579
+}
580
+?>">
581
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
582
+	echo 'right-';
583
+}
584
+?>caret"></b></a>
549 585
           <ul class="dropdown-menu">
550 586
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
551 587
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -589,7 +625,10 @@  discard block
 block discarded – undo
589 625
 <?php
590 626
 	}
591 627
 ?>
592
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
628
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
629
+	echo 'right-';
630
+}
631
+?>caret"></b></a>
593 632
 		<ul class="dropdown-menu">
594 633
 		    <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li>
595 634
 		    <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -630,7 +669,10 @@  discard block
 block discarded – undo
630 669
 <?php
631 670
 	}
632 671
 ?>
633
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
672
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
673
+	echo 'right-';
674
+}
675
+?>caret"></b></a>
634 676
 		<ul class="dropdown-menu">
635 677
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
636 678
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -673,7 +715,10 @@  discard block
 block discarded – undo
673 715
 ?>
674 716
 
675 717
 <!--
676
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
718
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
719
+	echo 'right-';
720
+}
721
+?>caret"></b></a>
677 722
 		<ul class="dropdown-menu">
678 723
 		    <li><a href="<?php print $globalURL; ?>/satellite/currently"><?php echo _("Current Activity"); ?></a></li>
679 724
 		    <li><a href="<?php print $globalURL; ?>/satellite/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -730,7 +775,9 @@  discard block
 block discarded – undo
730 775
   		        $alllang = $Language->getLanguages();
731 776
   		        foreach ($alllang as $key => $lang) {
732 777
   		            print '<option value="'.$key.'"';
733
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
778
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
779
+  		            	print ' selected ';
780
+  		            }
734 781
   		            print '>'.$lang[0].'</option>';
735 782
   		        }
736 783
   		    ?>
@@ -878,9 +925,24 @@  discard block
 block discarded – undo
878 925
 	$customid = $globalMapProvider;
879 926
 ?>
880 927
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
881
-        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
882
-        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
883
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
928
+        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
929
+	print $globalMapCustomLayer[$customid]['maxZoom'];
930
+} else {
931
+	print '18';
932
+}
933
+?>,
934
+        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
935
+	print $globalMapCustomLayer[$customid]['minZoom'];
936
+} else {
937
+	print '0';
938
+}
939
+?>,
940
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
941
+	print 'false';
942
+} else {
943
+	print 'true';
944
+}
945
+?>,
884 946
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
885 947
     }).addTo(map);
886 948
 <?php
@@ -895,7 +957,12 @@  discard block
 block discarded – undo
895 957
         maxZoom: 5,
896 958
         tms : true,
897 959
         zindex : 3,
898
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
960
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
961
+	print 'false';
962
+} else {
963
+	print 'true';
964
+}
965
+?>,
899 966
         attribution: 'Natural Earth'
900 967
     }).addTo(map);
901 968
 <?php
@@ -918,4 +985,7 @@  discard block
 block discarded – undo
918 985
 
919 986
 ?>
920 987
 
921
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
988
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
989
+	print 'index ';
990
+}
991
+?>clear">
Please login to merge, or discard this patch.
aircraft.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 	print '<h1>'._("Aircraft Types").'</h1>';
17 17
 
18 18
 	$aircraft_types = $Stats->getAllAircraftTypes();
19
-	if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') $aircraft_types = $Spotter->getAllAircraftTypes();
19
+	if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') {
20
+		$aircraft_types = $Spotter->getAllAircraftTypes();
21
+	}
20 22
 	$previous = null;
21 23
 	print '<div class="alphabet-legend">';
22 24
 	foreach($aircraft_types as $value) {
@@ -24,10 +26,14 @@  discard block
 block discarded – undo
24 26
 		$firstLetter = substr($value['aircraft_manufacturer'], 0, 1);
25 27
 		if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')')
26 28
 		{
27
-			if ($previous !== null) print ' | ';
29
+			if ($previous !== null) {
30
+				print ' | ';
31
+			}
28 32
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
29 33
 		}
30
-		if ($firstLetter != '(' && $firstLetter != ')') $previous = $firstLetter;
34
+		if ($firstLetter != '(' && $firstLetter != ')') {
35
+			$previous = $firstLetter;
36
+		}
31 37
 	}
32 38
 	print '</div>';
33 39
 	$previous = null;
@@ -38,10 +44,14 @@  discard block
 block discarded – undo
38 44
 		{
39 45
 			if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')')
40 46
 			{
41
-				if ($previous !== null) print '</div>';
47
+				if ($previous !== null) {
48
+					print '</div>';
49
+				}
42 50
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
43 51
 			}
44
-			if ($firstLetter != '(' && $firstLetter != ')') $previous = $firstLetter;
52
+			if ($firstLetter != '(' && $firstLetter != ')') {
53
+				$previous = $firstLetter;
54
+			}
45 55
 			print '<div class="alphabet-item">';
46 56
 			print '<a href="'.$globalURL.'/aircraft/'.$value['aircraft_icao'].'">';
47 57
 			if ($value['aircraft_name'] == '') {
Please login to merge, or discard this patch.
owner-detailed.php 1 patch
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,8 +45,12 @@  discard block
 block discarded – undo
45 45
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46 46
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
47 47
 	$filter = array();
48
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
49
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
48
+	if ($year != '') {
49
+		$filter = array_merge($filter,array('year' => $year));
50
+	}
51
+	if ($month != '') {
52
+		$filter = array_merge($filter,array('month' => $month));
53
+	}
50 54
 	if ($sort != '') 
51 55
 	{
52 56
 		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -64,8 +68,12 @@  discard block
 block discarded – undo
64 68
 	{
65 69
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
66 70
 		//$ident = $spotter_array[0]['ident'];
67
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
68
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
71
+		if (isset($spotter_array[0]['latitude'])) {
72
+			$latitude = $spotter_array[0]['latitude'];
73
+		}
74
+		if (isset($spotter_array[0]['longitude'])) {
75
+			$longitude = $spotter_array[0]['longitude'];
76
+		}
69 77
 		require_once('header.php');
70 78
 		/*
71 79
 		if (isset($globalArchive) && $globalArchive) {
@@ -120,9 +128,14 @@  discard block
 block discarded – undo
120 128
 		print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
121 129
 		//print '<div><span class="label">'._("Owner").'</span>'.$spotter_array[0]['aircraft_owner'].'</div>';
122 130
 		$Stats = new Stats();
123
-		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
124
-		else $flights = 0;
125
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
131
+		if ($year == '' && $month == '') {
132
+			$flights = $Stats->getStatsOwner($owner);
133
+		} else {
134
+			$flights = 0;
135
+		}
136
+		if ($flights == 0) {
137
+			$flights = $Spotter->countFlightsByOwner($owner,$filter);
138
+		}
126 139
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
127 140
 		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
128 141
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
@@ -133,7 +146,9 @@  discard block
 block discarded – undo
133 146
 		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
134 147
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
135 148
 		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
136
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
149
+		if ($duration != '0') {
150
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
151
+		}
137 152
 		print '</div>';
138 153
 	
139 154
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +1190 added lines, -399 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();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,32 +211,44 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftjson';
178 233
         	$globalSources[$id]['format'] = 'aircraftjson';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraft.json source (".$host.")...\n";
237
+        	}
181 238
     	    } else if (preg_match('/aircraft$/i',$host)) {
182 239
         	//$formats[$id] = 'planefinderclient';
183 240
         	$globalSources[$id]['format'] = 'planefinderclient';
184 241
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to planefinderclient source (".$host.")...\n";
244
+        	}
186 245
     	    } else if (preg_match('/opensky/i',$host)) {
187 246
         	//$formats[$id] = 'aircraftlistjson';
188 247
         	$globalSources[$id]['format'] = 'opensky';
189 248
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to opensky source (".$host.")...\n";
251
+        	}
191 252
     	    /*
192 253
     	    // Disabled for now, site change source format
193 254
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -204,7 +265,9 @@  discard block
 block discarded – undo
204 265
         	//$formats[$id] = 'planeupdatefaa';
205 266
         	$globalSources[$id]['format'] = 'planeupdatefaa';
206 267
         	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
270
+        	}
208 271
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209 272
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210 273
         	    exit(0);
@@ -213,37 +276,53 @@  discard block
 block discarded – undo
213 276
         	//$formats[$id] = 'phpvmacars';
214 277
         	$globalSources[$id]['format'] = 'phpvmacars';
215 278
         	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
279
+        	if ($globalDebug) {
280
+        		echo "Connect to phpvmacars source (".$host.")...\n";
281
+        	}
217 282
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218 283
         	//$formats[$id] = 'phpvmacars';
219 284
         	$globalSources[$id]['format'] = 'vaos';
220 285
         	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
286
+        	if ($globalDebug) {
287
+        		echo "Connect to vaos source (".$host.")...\n";
288
+        	}
222 289
             } else if (preg_match('/VAM-json.php$/i',$host)) {
223 290
         	//$formats[$id] = 'phpvmacars';
224 291
         	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
292
+        	if ($globalDebug) {
293
+        		echo "Connect to Vam source (".$host.")...\n";
294
+        	}
226 295
             } else if (preg_match('/whazzup/i',$host)) {
227 296
         	//$formats[$id] = 'whazzup';
228 297
         	$globalSources[$id]['format'] = 'whazzup';
229 298
         	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
299
+        	if ($globalDebug) {
300
+        		echo "Connect to whazzup source (".$host.")...\n";
301
+        	}
231 302
             } else if (preg_match('/blitzortung/i',$host)) {
232 303
         	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
304
+        	if ($globalDebug) {
305
+        		echo "Connect to blitzortung source (".$host.")...\n";
306
+        	}
234 307
             } else if (preg_match('/airwhere/i',$host)) {
235 308
         	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
309
+        	if ($globalDebug) {
310
+        		echo "Connect to airwhere source (".$host.")...\n";
311
+        	}
237 312
             } else if (preg_match('/recentpireps/i',$host)) {
238 313
         	//$formats[$id] = 'pirepsjson';
239 314
         	$globalSources[$id]['format'] = 'pirepsjson';
240 315
         	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to pirepsjson source (".$host.")...\n";
318
+        	}
242 319
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243 320
         	//$formats[$id] = 'fr24json';
244 321
         	$globalSources[$id]['format'] = 'fr24json';
245 322
         	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
323
+        	if ($globalDebug) {
324
+        		echo "Connect to fr24 source (".$host.")...\n";
325
+        	}
247 326
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248 327
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249 328
         	    exit(0);
@@ -252,7 +331,9 @@  discard block
 block discarded – undo
252 331
         	//$formats[$id] = 'fr24json';
253 332
         	$globalSources[$id]['format'] = 'myshiptracking';
254 333
         	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
334
+        	if ($globalDebug) {
335
+        		echo "Connect to myshiptracking source (".$host.")...\n";
336
+        	}
256 337
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257 338
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 339
         	    exit(0);
@@ -261,16 +342,24 @@  discard block
 block discarded – undo
261 342
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262 343
         	//$formats[$id] = 'tsv';
263 344
         	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
345
+        	if ($globalDebug) {
346
+        		echo "Connect to tsv source (".$host.")...\n";
347
+        	}
265 348
             }
266 349
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
267 350
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268 351
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269 352
     		    if ($idf !== false) {
270 353
     			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
354
+        		if ($globalDebug) {
355
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
356
+        		}
357
+    		    } elseif ($globalDebug) {
358
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
359
+    		    }
360
+    		} elseif ($globalDebug) {
361
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
362
+    		}
274 363
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
275 364
 	    $hostport = explode(':',$host);
276 365
 	    if (isset($hostport[1])) {
@@ -310,19 +399,27 @@  discard block
 block discarded – undo
310 399
         		//$formats[$id] = 'beast';
311 400
         		$globalSources[$id]['format'] = 'beast';
312 401
 		    //} else $formats[$id] = 'sbs';
313
-		    } else $globalSources[$id]['format'] = 'sbs';
402
+		    } else {
403
+		    	$globalSources[$id]['format'] = 'sbs';
404
+		    }
314 405
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
315 406
 		}
316
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
407
+		if ($globalDebug) {
408
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
409
+		}
317 410
             } else {
318
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
411
+		if ($globalDebug) {
412
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
413
+		}
319 414
 		sleep(10);
320 415
 		connect_all($hosts);
321 416
     	    }
322 417
         }
323 418
     }
324 419
 }
325
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
420
+if (!isset($globalMinFetch)) {
421
+	$globalMinFetch = 15;
422
+}
326 423
 
327 424
 // Initialize all
328 425
 $status = array();
@@ -331,13 +428,19 @@  discard block
 block discarded – undo
331 428
 $formats = array();
332 429
 $last_exec = array();
333 430
 $time = time();
334
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
335
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
336
-else $timeout = 20;
431
+if (isset($globalSourcesTimeout)) {
432
+	$timeout = $globalSourcesTimeOut;
433
+} else if (isset($globalSBS1TimeOut)) {
434
+	$timeout = $globalSBS1TimeOut;
435
+} else {
436
+	$timeout = 20;
437
+}
337 438
 $errno = '';
338 439
 $errstr='';
339 440
 
340
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
441
+if (!isset($globalDaemon)) {
442
+	$globalDaemon = TRUE;
443
+}
341 444
 /* Initiate connections to all the hosts simultaneously */
342 445
 //connect_all($hosts);
343 446
 //connect_all($globalSources);
@@ -366,7 +469,9 @@  discard block
 block discarded – undo
366 469
     if (isset($source['format']) && $source['format'] == 'aprs') {
367 470
 	$aprs_connect = 0;
368 471
 	$use_aprs = true;
369
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
472
+	if (isset($source['port']) && $source['port'] == '10152') {
473
+		$aprs_full = true;
474
+	}
370 475
 	break;
371 476
     }
372 477
 }
@@ -377,25 +482,46 @@  discard block
 block discarded – undo
377 482
 	$aprs_connect = 0;
378 483
 	$aprs_keep = 120;
379 484
 	$aprs_last_tx = time();
380
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
381
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
382
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
383
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
384
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
385
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
386
-	if ($aprs_full) $aprs_filter = '';
387
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
388
-	else $aprs_pass = '-1';
485
+	if (isset($globalAPRSversion)) {
486
+		$aprs_version = $globalAPRSversion;
487
+	} else {
488
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
489
+	}
490
+	if (isset($globalAPRSssid)) {
491
+		$aprs_ssid = $globalAPRSssid;
492
+	} else {
493
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
494
+	}
495
+	if (isset($globalAPRSfilter)) {
496
+		$aprs_filter = $globalAPRSfilter;
497
+	} else {
498
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
499
+	}
500
+	if ($aprs_full) {
501
+		$aprs_filter = '';
502
+	}
503
+	if (isset($globalAPRSpass)) {
504
+		$aprs_pass = $globalAPRSpass;
505
+	} else {
506
+		$aprs_pass = '-1';
507
+	}
389 508
 
390
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
391
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
392
-}
509
+	if ($aprs_filter != '') {
510
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
511
+	} else {
512
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
513
+	}
514
+	}
393 515
 
394 516
 // connected - lets do some work
395 517
 //if ($globalDebug) echo "Connected!\n";
396 518
 sleep(1);
397
-if ($globalDebug) echo "SCAN MODE \n\n";
398
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
519
+if ($globalDebug) {
520
+	echo "SCAN MODE \n\n";
521
+}
522
+if (!isset($globalCronEnd)) {
523
+	$globalCronEnd = 60;
524
+}
399 525
 $endtime = time()+$globalCronEnd;
400 526
 $i = 1;
401 527
 $tt = array();
@@ -409,22 +535,32 @@  discard block
 block discarded – undo
409 535
 
410 536
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
411 537
 while ($i > 0) {
412
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
538
+    if (function_exists('pcntl_fork')) {
539
+    	pcntl_signal_dispatch();
540
+    }
413 541
 
414
-    if (!$globalDaemon) $i = $endtime-time();
542
+    if (!$globalDaemon) {
543
+    	$i = $endtime-time();
544
+    }
415 545
     // Delete old ATC
416 546
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
417
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
547
+	if ($globalDebug) {
548
+		echo 'Delete old ATC...'."\n";
549
+	}
418 550
         $ATC->deleteOldATC();
419 551
     }
420 552
     
421 553
     if (count($last_exec) == count($globalSources)) {
422 554
 	$max = $globalMinFetch;
423 555
 	foreach ($last_exec as $last) {
424
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
556
+	    if ((time() - $last['last']) < $max) {
557
+	    	$max = time() - $last['last'];
558
+	    }
425 559
 	}
426 560
 	if ($max < $globalMinFetch) {
427
-	    if ($globalDebug) echo 'Sleeping...'."\n";
561
+	    if ($globalDebug) {
562
+	    	echo 'Sleeping...'."\n";
563
+	    }
428 564
 	    sleep($globalMinFetch-$max+2);
429 565
 	}
430 566
     }
@@ -434,7 +570,9 @@  discard block
 block discarded – undo
434 570
     foreach ($globalSources as $id => $value) {
435 571
 	date_default_timezone_set('UTC');
436 572
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
437
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
573
+	if (!isset($last_exec[$id]['last'])) {
574
+		$last_exec[$id]['last'] = 0;
575
+	}
438 576
 	if ($value['format'] === 'deltadbtxt' && 
439 577
 	    (
440 578
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -443,7 +581,9 @@  discard block
 block discarded – undo
443 581
 	) {
444 582
 	    //$buffer = $Common->getData($hosts[$id]);
445 583
 	    $buffer = $Common->getData($value['host']);
446
-	    if ($buffer != '') $reset = 0;
584
+	    if ($buffer != '') {
585
+	    	$reset = 0;
586
+	    }
447 587
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
448 588
 	    $buffer = explode('\n',$buffer);
449 589
 	    foreach ($buffer as $line) {
@@ -452,20 +592,41 @@  discard block
 block discarded – undo
452 592
 	            $data = array();
453 593
 	            $data['hex'] = $line[1]; // hex
454 594
 	            $data['ident'] = $line[2]; // ident
455
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
456
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
457
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
458
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
459
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
595
+	            if (isset($line[3])) {
596
+	            	$data['altitude'] = $line[3];
597
+	            }
598
+	            // altitude
599
+	            if (isset($line[4])) {
600
+	            	$data['speed'] = $line[4];
601
+	            }
602
+	            // speed
603
+	            if (isset($line[5])) {
604
+	            	$data['heading'] = $line[5];
605
+	            }
606
+	            // heading
607
+	            if (isset($line[6])) {
608
+	            	$data['latitude'] = $line[6];
609
+	            }
610
+	            // lat
611
+	            if (isset($line[7])) {
612
+	            	$data['longitude'] = $line[7];
613
+	            }
614
+	            // long
460 615
 	            $data['verticalrate'] = ''; // vertical rate
461 616
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
462 617
 	            $data['emergency'] = ''; // emergency
463 618
 		    $data['datetime'] = date('Y-m-d H:i:s');
464 619
 		    $data['format_source'] = 'deltadbtxt';
465 620
     		    $data['id_source'] = $id_source;
466
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
467
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
468
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
621
+		    if (isset($value['name']) && $value['name'] != '') {
622
+		    	$data['source_name'] = $value['name'];
623
+		    }
624
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
625
+		    	$data['noarchive'] = true;
626
+		    }
627
+		    if (isset($value['sourcestats'])) {
628
+		    	$data['sourcestats'] = $value['sourcestats'];
629
+		    }
469 630
     		    $SI->add($data);
470 631
 		    unset($data);
471 632
     		}
@@ -480,7 +641,9 @@  discard block
 block discarded – undo
480 641
 	    date_default_timezone_set('CET');
481 642
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482 643
 	    date_default_timezone_set('UTC');
483
-	    if ($buffer != '') $reset = 0;
644
+	    if ($buffer != '') {
645
+	    	$reset = 0;
646
+	    }
484 647
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
485 648
 	    $buffer = explode('\n',$buffer);
486 649
 	    foreach ($buffer as $line) {
@@ -489,18 +652,42 @@  discard block
 block discarded – undo
489 652
 		    $add = false;
490 653
 		    $ais_data = $AIS->parse_line(trim($line));
491 654
 		    $data = array();
492
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
493
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
495
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
496
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
497
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
498
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
499
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
500
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
501
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
502
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
503
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
655
+		    if (isset($ais_data['ident'])) {
656
+		    	$data['ident'] = $ais_data['ident'];
657
+		    }
658
+		    if (isset($ais_data['mmsi'])) {
659
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
660
+		    }
661
+		    if (isset($ais_data['speed'])) {
662
+		    	$data['speed'] = $ais_data['speed'];
663
+		    }
664
+		    if (isset($ais_data['heading'])) {
665
+		    	$data['heading'] = $ais_data['heading'];
666
+		    }
667
+		    if (isset($ais_data['latitude'])) {
668
+		    	$data['latitude'] = $ais_data['latitude'];
669
+		    }
670
+		    if (isset($ais_data['longitude'])) {
671
+		    	$data['longitude'] = $ais_data['longitude'];
672
+		    }
673
+		    if (isset($ais_data['status'])) {
674
+		    	$data['status'] = $ais_data['status'];
675
+		    }
676
+		    if (isset($ais_data['statusid'])) {
677
+		    	$data['status_id'] = $ais_data['statusid'];
678
+		    }
679
+		    if (isset($ais_data['type'])) {
680
+		    	$data['type'] = $ais_data['type'];
681
+		    }
682
+		    if (isset($ais_data['typeid'])) {
683
+		    	$data['type_id'] = $ais_data['typeid'];
684
+		    }
685
+		    if (isset($ais_data['imo'])) {
686
+		    	$data['imo'] = $ais_data['imo'];
687
+		    }
688
+		    if (isset($ais_data['callsign'])) {
689
+		    	$data['callsign'] = $ais_data['callsign'];
690
+		    }
504 691
 		    if (isset($ais_data['timestamp'])) {
505 692
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
506 693
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -514,8 +701,12 @@  discard block
 block discarded – undo
514 701
 		    $data['format_source'] = 'aisnmeatxt';
515 702
     		    $data['id_source'] = $id_source;
516 703
 		    //print_r($data);
517
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
518
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
704
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
705
+		    	$data['noarchive'] = true;
706
+		    }
707
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
708
+		    	$MI->add($data);
709
+		    }
519 710
 		    unset($data);
520 711
 		}
521 712
     	    }
@@ -538,20 +729,48 @@  discard block
 block discarded – undo
538 729
 			    if ($line != '') {
539 730
 				$ais_data = $AIS->parse_line(trim($line));
540 731
 				$data = array();
541
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
542
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
543
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
544
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
545
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
546
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
547
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
548
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
549
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
550
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
551
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
552
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
553
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
554
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
732
+				if (isset($ais_data['ident'])) {
733
+					$data['ident'] = $ais_data['ident'];
734
+				}
735
+				if (isset($ais_data['mmsi'])) {
736
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
737
+				}
738
+				if (isset($ais_data['speed'])) {
739
+					$data['speed'] = $ais_data['speed'];
740
+				}
741
+				if (isset($ais_data['heading'])) {
742
+					$data['heading'] = $ais_data['heading'];
743
+				}
744
+				if (isset($ais_data['latitude'])) {
745
+					$data['latitude'] = $ais_data['latitude'];
746
+				}
747
+				if (isset($ais_data['longitude'])) {
748
+					$data['longitude'] = $ais_data['longitude'];
749
+				}
750
+				if (isset($ais_data['status'])) {
751
+					$data['status'] = $ais_data['status'];
752
+				}
753
+				if (isset($ais_data['statusid'])) {
754
+					$data['status_id'] = $ais_data['statusid'];
755
+				}
756
+				if (isset($ais_data['type'])) {
757
+					$data['type'] = $ais_data['type'];
758
+				}
759
+				if (isset($ais_data['typeid'])) {
760
+					$data['type_id'] = $ais_data['typeid'];
761
+				}
762
+				if (isset($ais_data['imo'])) {
763
+					$data['imo'] = $ais_data['imo'];
764
+				}
765
+				if (isset($ais_data['callsign'])) {
766
+					$data['callsign'] = $ais_data['callsign'];
767
+				}
768
+				if (isset($ais_data['destination'])) {
769
+					$data['arrival_code'] = $ais_data['destination'];
770
+				}
771
+				if (isset($ais_data['eta_ts'])) {
772
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
773
+				}
555 774
 				if (isset($ais_data['timestamp'])) {
556 775
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557 776
 				} else {
@@ -559,18 +778,27 @@  discard block
 block discarded – undo
559 778
 				}
560 779
 				$data['format_source'] = 'aisnmeahttp';
561 780
 				$data['id_source'] = $id_source;
562
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
563
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
781
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
782
+					$data['noarchive'] = true;
783
+				}
784
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
785
+					$MI->add($data);
786
+				}
564 787
 				unset($data);
565 788
 			    }
566 789
 			}
567 790
 		    }
568 791
 		} else {
569 792
 		    $format = $value['format'];
570
-		    if (isset($tt[$format])) $tt[$format]++;
571
-		    else $tt[$format] = 0;
793
+		    if (isset($tt[$format])) {
794
+		    	$tt[$format]++;
795
+		    } else {
796
+		    	$tt[$format] = 0;
797
+		    }
572 798
 		    if ($tt[$format] > 30) {
573
-			if ($globalDebug) echo 'Reconnect...'."\n";
799
+			if ($globalDebug) {
800
+				echo 'Reconnect...'."\n";
801
+			}
574 802
 			sleep(2);
575 803
 			//$sourceeen[] = $value;
576 804
 			//connect_all($sourceeen);
@@ -606,12 +834,18 @@  discard block
 block discarded – undo
606 834
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
607 835
 			    //$data['type_id'] = $line['TYPE'];
608 836
 			    $data['imo'] = $line['IMO'];
609
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
610
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
837
+			    if ($line['DEST'] != '') {
838
+			    	$data['arrival_code'] = $line['DEST'];
839
+			    }
840
+			    if ($line['ARV'] != '') {
841
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
842
+			    }
611 843
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
612 844
 			    $data['format_source'] = 'myshiptracking';
613 845
 			    $data['id_source'] = $id_source;
614
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
846
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
847
+			    	$data['noarchive'] = true;
848
+			    }
615 849
 			    $MI->add($data);
616 850
 			    unset($data);
617 851
 			}
@@ -636,7 +870,9 @@  discard block
 block discarded – undo
636 870
 			    $data['callsign'] = $line['callsign'];
637 871
 			    $data['mmsi'] = substr($line['mmsi'],-9);
638 872
 			    $data['speed'] = $line['sog'];
639
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
873
+			    if ($line['heading'] != '511') {
874
+			    	$data['heading'] = $line['heading'];
875
+			    }
640 876
 			    $data['latitude'] = $line['latitude'];
641 877
 			    $data['longitude'] = $line['longitude'];
642 878
 			    $data['type_id'] = $line['shiptype'];
@@ -644,7 +880,9 @@  discard block
 block discarded – undo
644 880
 			    $data['datetime'] = $line['time'];
645 881
 			    $data['format_source'] = 'boatbeaconapp';
646 882
 			    $data['id_source'] = $id_source;
647
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
883
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
884
+			    	$data['noarchive'] = true;
885
+			    }
648 886
 			    $MI->add($data);
649 887
 			    unset($data);
650 888
 			}
@@ -666,22 +904,44 @@  discard block
 block discarded – undo
666 904
 		    foreach ($all_data['features'] as $line) {
667 905
 			print_r($line);
668 906
 			$data = array();
669
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
670
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
671
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
672
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
673
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
674
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
907
+			if (isset($line['properties']['name'])) {
908
+				$data['ident'] = $line['properties']['name'];
909
+			}
910
+			if (isset($line['properties']['callsign'])) {
911
+				$data['callsign'] = $line['properties']['callsign'];
912
+			}
913
+			if (isset($line['properties']['mmsi'])) {
914
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
915
+			}
916
+			if (isset($line['properties']['imo'])) {
917
+				$data['imo'] = $line['properties']['imo'];
918
+			}
919
+			if (isset($line['properties']['speed'])) {
920
+				$data['speed'] = $line['properties']['speed'];
921
+			}
922
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
923
+				$data['heading'] = $line['properties']['heading'];
924
+			}
675 925
 			$data['latitude'] = $line['geometry']['coordinates'][1];
676 926
 			$data['longitude'] = $line['geometry']['coordinates'][0];
677
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
678
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
679
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
927
+			if (isset($line['properties']['vesselType'])) {
928
+				$data['type'] = $line['properties']['vesselType'];
929
+			}
930
+			if (isset($line['properties']['destination'])) {
931
+				$data['arrival_code'] = $line['properties']['destination'];
932
+			}
933
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
934
+				$data['arrival_date'] = $line['properties']['eta'];
935
+			}
680 936
 			$data['format_source'] = 'boatnerd';
681 937
 			$data['id_source'] = $id_source;
682 938
 			$data['datetime'] = date('Y-m-d H:i:s');
683
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
684
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
939
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
940
+				$data['noarchive'] = true;
941
+			}
942
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
943
+				$MI->add($data);
944
+			}
685 945
 			unset($data);
686 946
 		    }
687 947
 		}
@@ -698,7 +958,9 @@  discard block
 block discarded – undo
698 958
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699 959
 	    echo 'done !'."\n";
700 960
 	    // FIXME: Need more work
701
-	    if ($buffer != '') $reset = 0;
961
+	    if ($buffer != '') {
962
+	    	$reset = 0;
963
+	    }
702 964
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
703 965
 	    $buffer = explode('\n',$buffer);
704 966
 	    foreach ($buffer as $line) {
@@ -724,7 +986,9 @@  discard block
 block discarded – undo
724 986
 		    //$data['etaTime'] = substr($line,135,5);
725 987
 		    $data['format_source'] = 'shipplotter';
726 988
     		    $data['id_source'] = $id_source;
727
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
989
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
990
+		    	$data['noarchive'] = true;
991
+		    }
728 992
 		    //print_r($data);
729 993
 		    echo 'Add...'."\n";
730 994
 		    $MI->add($data);
@@ -758,16 +1022,28 @@  discard block
 block discarded – undo
758 1022
     		    $line = explode(':', $line);
759 1023
     		    if (count($line) > 30 && $line[0] != 'callsign') {
760 1024
 			$data = array();
761
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
762
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1025
+			if (isset($line[37]) && $line[37] != '') {
1026
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1027
+			} else {
1028
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1029
+			}
763 1030
 			$data['pilot_id'] = $line[1];
764 1031
 			$data['pilot_name'] = $line[2];
765 1032
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
766 1033
 			$data['ident'] = $line[0]; // ident
767
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1034
+			if ($line[7] != '' && $line[7] != 0) {
1035
+				$data['altitude'] = $line[7];
1036
+			}
1037
+			// altitude
768 1038
 			$data['speed'] = $line[8]; // speed
769
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
770
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1039
+			if (isset($line[45])) {
1040
+				$data['heading'] = $line[45];
1041
+			}
1042
+			// heading
1043
+			elseif (isset($line[38])) {
1044
+				$data['heading'] = $line[38];
1045
+			}
1046
+			// heading
771 1047
 			$data['latitude'] = $line[5]; // lat
772 1048
 	        	$data['longitude'] = $line[6]; // long
773 1049
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -783,7 +1059,9 @@  discard block
 block discarded – undo
783 1059
 			$data['frequency'] = $line[4];
784 1060
 			$data['type'] = $line[18];
785 1061
 			$data['range'] = $line[19];
786
-			if (isset($line[35])) $data['info'] = $line[35];
1062
+			if (isset($line[35])) {
1063
+				$data['info'] = $line[35];
1064
+			}
787 1065
     			$data['id_source'] = $id_source;
788 1066
 	    		//$data['arrival_airport_time'] = ;
789 1067
 	    		if ($line[9] != '') {
@@ -797,27 +1075,47 @@  discard block
 block discarded – undo
797 1075
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
798 1076
 	    		*/
799 1077
 	    		$data['format_source'] = $value['format'];
800
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
801
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
802
-    			if ($line[3] === 'PILOT') $SI->add($data);
803
-			elseif ($line[3] === 'ATC') {
1078
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1079
+				$data['noarchive'] = true;
1080
+			}
1081
+			if (isset($value['name']) && $value['name'] != '') {
1082
+				$data['source_name'] = $value['name'];
1083
+			}
1084
+    			if ($line[3] === 'PILOT') {
1085
+    				$SI->add($data);
1086
+    			} elseif ($line[3] === 'ATC') {
804 1087
 				//print_r($data);
805 1088
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
806 1089
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
807 1090
 				$typec = substr($data['ident'],-3);
808
-				if ($typec === 'APP') $data['type'] = 'Approach';
809
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
810
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
811
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
812
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
813
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
814
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
815
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
816
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
817
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1091
+				if ($typec === 'APP') {
1092
+					$data['type'] = 'Approach';
1093
+				} elseif ($typec === 'TWR') {
1094
+					$data['type'] = 'Tower';
1095
+				} elseif ($typec === 'OBS') {
1096
+					$data['type'] = 'Observer';
1097
+				} elseif ($typec === 'GND') {
1098
+					$data['type'] = 'Ground';
1099
+				} elseif ($typec === 'DEL') {
1100
+					$data['type'] = 'Delivery';
1101
+				} elseif ($typec === 'DEP') {
1102
+					$data['type'] = 'Departure';
1103
+				} elseif ($typec === 'FSS') {
1104
+					$data['type'] = 'Flight Service Station';
1105
+				} elseif ($typec === 'CTR') {
1106
+					$data['type'] = 'Control Radar or Centre';
1107
+				} elseif ($data['type'] === '') {
1108
+					$data['type'] = 'Observer';
1109
+				}
1110
+				if (!isset($data['source_name'])) {
1111
+					$data['source_name'] = '';
1112
+				}
818 1113
 				if (isset($ATC)) {
819
-					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']);
820
-					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']);
1114
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1115
+						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']);
1116
+					} else {
1117
+						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']);
1118
+					}
821 1119
 				}
822 1120
 			}
823 1121
     			unset($data);
@@ -844,14 +1142,20 @@  discard block
 block discarded – undo
844 1142
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
845 1143
 			$data['latitude'] = (float)$line['pktLatitude'];
846 1144
 			$data['longitude'] = (float)$line['pktLongitude'];
847
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
848
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1145
+			if ((float)$line['pktTrack'] != 0) {
1146
+				$data['heading'] = (float)$line['pktTrack'];
1147
+			}
1148
+			if ((int)$line['pktSpeed'] != 0) {
1149
+				$data['speed'] = (int)$line['pktSpeed'];
1150
+			}
849 1151
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
850 1152
 			$data['altitude_relative'] = 'AMSL';
851 1153
 			$data['pilot_id'] = (int)$line['pktPilotID'];
852 1154
 			$data['aircraft_icao'] = 'PARAGLIDER';
853 1155
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
854
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1156
+			if (isset($pilot_data[4])) {
1157
+				$data['pilot_name'] = $pilot_data[4];
1158
+			}
855 1159
 			$data['format_source'] = $value['format'];
856 1160
 			$SI->add($data);
857 1161
 			unset($data);
@@ -899,25 +1203,59 @@  discard block
 block discarded – undo
899 1203
 		    foreach ($all_data['acList'] as $line) {
900 1204
 			$data = array();
901 1205
 			$data['hex'] = $line['Icao']; // hex
902
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
903
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
904
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
905
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
906
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
907
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1206
+			if (isset($line['Call'])) {
1207
+				$data['ident'] = $line['Call'];
1208
+			}
1209
+			// ident
1210
+			if (isset($line['Alt'])) {
1211
+				$data['altitude'] = $line['Alt'];
1212
+			}
1213
+			// altitude
1214
+			if (isset($line['Spd'])) {
1215
+				$data['speed'] = $line['Spd'];
1216
+			}
1217
+			// speed
1218
+			if (isset($line['Trak'])) {
1219
+				$data['heading'] = $line['Trak'];
1220
+			}
1221
+			// heading
1222
+			if (isset($line['Lat'])) {
1223
+				$data['latitude'] = $line['Lat'];
1224
+			}
1225
+			// lat
1226
+			if (isset($line['Long'])) {
1227
+				$data['longitude'] = $line['Long'];
1228
+			}
1229
+			// long
908 1230
 			//$data['verticalrate'] = $line['']; // verticale rate
909
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1231
+			if (isset($line['Sqk'])) {
1232
+				$data['squawk'] = $line['Sqk'];
1233
+			}
1234
+			// squawk
910 1235
 			$data['emergency'] = ''; // emergency
911
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
912
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
913
-			else $data['datetime'] = date('Y-m-d H:i:s');
1236
+			if (isset($line['Reg'])) {
1237
+				$data['registration'] = $line['Reg'];
1238
+			}
1239
+			if (isset($line['PosTime'])) {
1240
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1241
+			} else {
1242
+				$data['datetime'] = date('Y-m-d H:i:s');
1243
+			}
914 1244
 			//$data['datetime'] = date('Y-m-d H:i:s');
915
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1245
+			if (isset($line['Type'])) {
1246
+				$data['aircraft_icao'] = $line['Type'];
1247
+			}
916 1248
 			$data['format_source'] = 'aircraftlistjson';
917 1249
 			$data['id_source'] = $id_source;
918
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
919
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
920
-			if (isset($data['latitude'])) $SI->add($data);
1250
+			if (isset($value['name']) && $value['name'] != '') {
1251
+				$data['source_name'] = $value['name'];
1252
+			}
1253
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1254
+				$data['noarchive'] = true;
1255
+			}
1256
+			if (isset($data['latitude'])) {
1257
+				$SI->add($data);
1258
+			}
921 1259
 			unset($data);
922 1260
 		    }
923 1261
 		} elseif (is_array($all_data)) {
@@ -934,17 +1272,26 @@  discard block
 block discarded – undo
934 1272
 			$data['verticalrate'] = $line['vrt']; // verticale rate
935 1273
 			$data['squawk'] = $line['squawk']; // squawk
936 1274
 			$data['emergency'] = ''; // emergency
937
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
938
-			else $data['datetime'] = date('Y-m-d H:i:s');
1275
+			if (isset($line['PosTime'])) {
1276
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1277
+			} else {
1278
+				$data['datetime'] = date('Y-m-d H:i:s');
1279
+			}
939 1280
 			$data['format_source'] = 'aircraftlistjson';
940 1281
 			$data['id_source'] = $id_source;
941
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
942
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1282
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1283
+				$data['noarchive'] = true;
1284
+			}
1285
+			if (isset($value['name']) && $value['name'] != '') {
1286
+				$data['source_name'] = $value['name'];
1287
+			}
943 1288
 			$SI->add($data);
944 1289
 			unset($data);
945 1290
 		    }
946 1291
 		}
947
-	    } elseif ($globalDebug) echo 'No data'."\n";
1292
+	    } elseif ($globalDebug) {
1293
+	    	echo 'No data'."\n";
1294
+	    }
948 1295
     	    //$last_exec['aircraftlistjson'] = time();
949 1296
     	    $last_exec[$id]['last'] = time();
950 1297
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -980,8 +1327,12 @@  discard block
 block discarded – undo
980 1327
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
981 1328
 	    	    $data['format_source'] = 'planeupdatefaa';
982 1329
     		    $data['id_source'] = $id_source;
983
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
984
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1330
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1331
+		    	$data['noarchive'] = true;
1332
+		    }
1333
+		    if (isset($value['name']) && $value['name'] != '') {
1334
+		    	$data['source_name'] = $value['name'];
1335
+		    }
985 1336
 		    $SI->add($data);
986 1337
 		    unset($data);
987 1338
 		}
@@ -1015,7 +1366,9 @@  discard block
 block discarded – undo
1015 1366
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1016 1367
 		    $data['format_source'] = 'opensky';
1017 1368
 		    $data['id_source'] = $id_source;
1018
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1369
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1370
+		    	$data['noarchive'] = true;
1371
+		    }
1019 1372
 		    $SI->add($data);
1020 1373
 		    unset($data);
1021 1374
 		}
@@ -1035,15 +1388,42 @@  discard block
 block discarded – undo
1035 1388
 		foreach ($all_data['aircraft'] as $key => $line) {
1036 1389
 		    $data = array();
1037 1390
 		    // add support for ground vehicule with ~ in front of hex
1038
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1039
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1040
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1041
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1042
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1043
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1044
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1045
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1046
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1391
+		    if (isset($line['hex'])) {
1392
+		    	$data['hex'] = $line['hex'];
1393
+		    }
1394
+		    // hex
1395
+		    if (isset($line['flight'])) {
1396
+		    	$data['ident'] = trim($line['flight']);
1397
+		    }
1398
+		    // ident
1399
+		    if (isset($line['altitude'])) {
1400
+		    	$data['altitude'] = $line['altitude'];
1401
+		    }
1402
+		    // altitude
1403
+		    if (isset($line['speed'])) {
1404
+		    	$data['speed'] = $line['speed'];
1405
+		    }
1406
+		    // speed
1407
+		    if (isset($line['track'])) {
1408
+		    	$data['heading'] = $line['track'];
1409
+		    }
1410
+		    // heading
1411
+		    if (isset($line['lat'])) {
1412
+		    	$data['latitude'] = $line['lat'];
1413
+		    }
1414
+		    // lat
1415
+		    if (isset($line['lon'])) {
1416
+		    	$data['longitude'] = $line['lon'];
1417
+		    }
1418
+		    // long
1419
+		    if (isset($line['vert_rate'])) {
1420
+		    	$data['verticalrate'] = $line['vert_rate'];
1421
+		    }
1422
+		    // verticale rate
1423
+		    if (isset($line['squawk'])) {
1424
+		    	$data['squawk'] = $line['squawk'];
1425
+		    }
1426
+		    // squawk
1047 1427
 		    //$data['emergency'] = ''; // emergency
1048 1428
 		    //$data['registration'] = $line[2];
1049 1429
 		    //$data['aircraft_icao'] = $line[0];
@@ -1051,10 +1431,17 @@  discard block
 block discarded – undo
1051 1431
 		    $data['format_source'] = 'aircraftjson';
1052 1432
 		    $data['id_source'] = $id_source;
1053 1433
 		    if (isset($value['name']) && $value['name'] != '') {
1054
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1055
-			    else $data['source_name'] = $value['name'];
1056
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1057
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1434
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1435
+			    	$data['source_name'] = $value['name'].'_MLAT';
1436
+			    } else {
1437
+			    	$data['source_name'] = $value['name'];
1438
+			    }
1439
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1440
+		    	$data['source_name'] = 'MLAT';
1441
+		    }
1442
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1443
+		    	$data['noarchive'] = true;
1444
+		    }
1058 1445
 		    $SI->add($data);
1059 1446
 		    unset($data);
1060 1447
 		}
@@ -1074,22 +1461,54 @@  discard block
 block discarded – undo
1074 1461
 		foreach ($all_data['aircraft'] as $key => $line) {
1075 1462
 		    $data = array();
1076 1463
 		    $data['hex'] = $key; // hex
1077
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1078
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1079
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1080
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1081
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1082
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1083
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1084
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1464
+		    if (isset($line['callsign'])) {
1465
+		    	$data['ident'] = trim($line['callsign']);
1466
+		    }
1467
+		    // ident
1468
+		    if (isset($line['altitude'])) {
1469
+		    	$data['altitude'] = $line['altitude'];
1470
+		    }
1471
+		    // altitude
1472
+		    if (isset($line['speed'])) {
1473
+		    	$data['speed'] = $line['speed'];
1474
+		    }
1475
+		    // speed
1476
+		    if (isset($line['heading'])) {
1477
+		    	$data['heading'] = $line['heading'];
1478
+		    }
1479
+		    // heading
1480
+		    if (isset($line['lat'])) {
1481
+		    	$data['latitude'] = $line['lat'];
1482
+		    }
1483
+		    // lat
1484
+		    if (isset($line['lon'])) {
1485
+		    	$data['longitude'] = $line['lon'];
1486
+		    }
1487
+		    // long
1488
+		    if (isset($line['vert_rate'])) {
1489
+		    	$data['verticalrate'] = $line['vert_rate'];
1490
+		    }
1491
+		    // verticale rate
1492
+		    if (isset($line['squawk'])) {
1493
+		    	$data['squawk'] = $line['squawk'];
1494
+		    }
1495
+		    // squawk
1085 1496
 		    //$data['emergency'] = ''; // emergency
1086
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1087
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1497
+		    if (isset($line['reg'])) {
1498
+		    	$data['registration'] = $line['reg'];
1499
+		    }
1500
+		    if (isset($line['type'])) {
1501
+		    	$data['aircraft_icao'] = $line['type'];
1502
+		    }
1088 1503
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1089 1504
 		    $data['format_source'] = 'planefinderclient';
1090 1505
 		    $data['id_source'] = $id_source;
1091
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1506
+		    if (isset($value['name']) && $value['name'] != '') {
1507
+		    	$data['source_name'] = $value['name'];
1508
+		    }
1509
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1510
+		    	$data['noarchive'] = true;
1511
+		    }
1093 1512
 		    $SI->add($data);
1094 1513
 		    unset($data);
1095 1514
 		}
@@ -1105,7 +1524,9 @@  discard block
 block discarded – undo
1105 1524
 	    //$buffer = $Common->getData($hosts[$id]);
1106 1525
 	    $buffer = $Common->getData($value['host']);
1107 1526
 	    $all_data = json_decode($buffer,true);
1108
-	    if (!empty($all_data)) $reset = 0;
1527
+	    if (!empty($all_data)) {
1528
+	    	$reset = 0;
1529
+	    }
1109 1530
 	    foreach ($all_data as $key => $line) {
1110 1531
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1111 1532
 		    $data = array();
@@ -1126,8 +1547,12 @@  discard block
 block discarded – undo
1126 1547
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1127 1548
 	    	    $data['format_source'] = 'fr24json';
1128 1549
     		    $data['id_source'] = $id_source;
1129
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1550
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1551
+		    	$data['noarchive'] = true;
1552
+		    }
1553
+		    if (isset($value['name']) && $value['name'] != '') {
1554
+		    	$data['source_name'] = $value['name'];
1555
+		    }
1131 1556
 		    $SI->add($data);
1132 1557
 		    unset($data);
1133 1558
 		}
@@ -1156,24 +1581,42 @@  discard block
 block discarded – undo
1156 1581
 		    if (isset($line['inf'])) {
1157 1582
 			$data = array();
1158 1583
 			$data['hex'] = $line['inf']['ia'];
1159
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1584
+			if (isset($line['inf']['cs'])) {
1585
+				$data['ident'] = $line['inf']['cs'];
1586
+			}
1587
+			//$line[13]
1160 1588
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1161
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1162
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1589
+	    		if (isset($line['inf']['gs'])) {
1590
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1591
+	    		}
1592
+	    		// speed
1593
+	    		if (isset($line['inf']['tr'])) {
1594
+	    			$data['heading'] = $line['inf']['tr'];
1595
+	    		}
1596
+	    		// heading
1163 1597
 	    		$data['latitude'] = $line['pt'][0]; // lat
1164 1598
 	    		$data['longitude'] = $line['pt'][1]; // long
1165 1599
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1166
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1600
+	    		if (isset($line['inf']['sq'])) {
1601
+	    			$data['squawk'] = $line['inf']['sq'];
1602
+	    		}
1603
+	    		// squawk
1167 1604
 	    		//$data['aircraft_icao'] = $line[8];
1168
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1605
+	    		if (isset($line['inf']['rc'])) {
1606
+	    			$data['registration'] = $line['inf']['rc'];
1607
+	    		}
1169 1608
 			//$data['departure_airport_iata'] = $line[11];
1170 1609
 			//$data['arrival_airport_iata'] = $line[12];
1171 1610
 	    		//$data['emergency'] = ''; // emergency
1172 1611
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1173 1612
 	    		$data['format_source'] = 'radarvirtueljson';
1174 1613
     			$data['id_source'] = $id_source;
1175
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1614
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1615
+				$data['noarchive'] = true;
1616
+			}
1617
+			if (isset($value['name']) && $value['name'] != '') {
1618
+				$data['source_name'] = $value['name'];
1619
+			}
1177 1620
 			$SI->add($data);
1178 1621
 			unset($data);
1179 1622
 		    }
@@ -1199,30 +1642,65 @@  discard block
 block discarded – undo
1199 1642
 		    $data['id'] = $line['id'];
1200 1643
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1201 1644
 		    $data['ident'] = $line['callsign']; // ident
1202
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1203
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1204
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1205
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1206
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1207
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1645
+		    if (isset($line['pilotid'])) {
1646
+		    	$data['pilot_id'] = $line['pilotid'];
1647
+		    }
1648
+		    // pilot id
1649
+		    if (isset($line['name'])) {
1650
+		    	$data['pilot_name'] = $line['name'];
1651
+		    }
1652
+		    // pilot name
1653
+		    if (isset($line['alt'])) {
1654
+		    	$data['altitude'] = $line['alt'];
1655
+		    }
1656
+		    // altitude
1657
+		    if (isset($line['gs'])) {
1658
+		    	$data['speed'] = $line['gs'];
1659
+		    }
1660
+		    // speed
1661
+		    if (isset($line['heading'])) {
1662
+		    	$data['heading'] = $line['heading'];
1663
+		    }
1664
+		    // heading
1665
+		    if (isset($line['route'])) {
1666
+		    	$data['waypoints'] = $line['route'];
1667
+		    }
1668
+		    // route
1208 1669
 		    $data['latitude'] = $line['lat']; // lat
1209 1670
 		    $data['longitude'] = $line['lon']; // long
1210 1671
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1211 1672
 		    //$data['squawk'] = $line['squawk']; // squawk
1212 1673
 		    //$data['emergency'] = ''; // emergency
1213
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1214
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1215
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1674
+		    if (isset($line['depicao'])) {
1675
+		    	$data['departure_airport_icao'] = $line['depicao'];
1676
+		    }
1677
+		    if (isset($line['deptime'])) {
1678
+		    	$data['departure_airport_time'] = $line['deptime'];
1679
+		    }
1680
+		    if (isset($line['arricao'])) {
1681
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1682
+		    }
1216 1683
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1217
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1218
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1219
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1220
-		    else $data['info'] = '';
1684
+		    if (isset($line['aircraft'])) {
1685
+		    	$data['aircraft_icao'] = $line['aircraft'];
1686
+		    }
1687
+		    if (isset($line['transponder'])) {
1688
+		    	$data['squawk'] = $line['transponder'];
1689
+		    }
1690
+		    if (isset($line['atis'])) {
1691
+		    	$data['info'] = $line['atis'];
1692
+		    } else {
1693
+		    	$data['info'] = '';
1694
+		    }
1221 1695
 		    $data['format_source'] = 'pireps';
1222 1696
     		    $data['id_source'] = $id_source;
1223 1697
 		    $data['datetime'] = date('Y-m-d H:i:s');
1224
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1225
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1698
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1699
+		    	$data['noarchive'] = true;
1700
+		    }
1701
+		    if (isset($value['name']) && $value['name'] != '') {
1702
+		    	$data['source_name'] = $value['name'];
1703
+		    }
1226 1704
 		    if ($line['icon'] === 'plane') {
1227 1705
 			$SI->add($data);
1228 1706
 		    //    print_r($data);
@@ -1231,16 +1709,28 @@  discard block
 block discarded – undo
1231 1709
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1232 1710
 			$typec = substr($data['ident'],-3);
1233 1711
 			$data['type'] = '';
1234
-			if ($typec === 'APP') $data['type'] = 'Approach';
1235
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1236
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1237
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1238
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1239
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1240
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1241
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1242
-			else $data['type'] = 'Observer';
1243
-			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']);
1712
+			if ($typec === 'APP') {
1713
+				$data['type'] = 'Approach';
1714
+			} elseif ($typec === 'TWR') {
1715
+				$data['type'] = 'Tower';
1716
+			} elseif ($typec === 'OBS') {
1717
+				$data['type'] = 'Observer';
1718
+			} elseif ($typec === 'GND') {
1719
+				$data['type'] = 'Ground';
1720
+			} elseif ($typec === 'DEL') {
1721
+				$data['type'] = 'Delivery';
1722
+			} elseif ($typec === 'DEP') {
1723
+				$data['type'] = 'Departure';
1724
+			} elseif ($typec === 'FSS') {
1725
+				$data['type'] = 'Flight Service Station';
1726
+			} elseif ($typec === 'CTR') {
1727
+				$data['type'] = 'Control Radar or Centre';
1728
+			} else {
1729
+				$data['type'] = 'Observer';
1730
+			}
1731
+			if (isset($ATC)) {
1732
+				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']);
1733
+			}
1244 1734
 		    }
1245 1735
 		    unset($data);
1246 1736
 		}
@@ -1255,7 +1745,9 @@  discard block
 block discarded – undo
1255 1745
 	    )
1256 1746
 	) {
1257 1747
 	    //$buffer = $Common->getData($hosts[$id]);
1258
-	    if ($globalDebug) echo 'Get Data...'."\n";
1748
+	    if ($globalDebug) {
1749
+	    	echo 'Get Data...'."\n";
1750
+	    }
1259 1751
 	    $buffer = $Common->getData($value['host']);
1260 1752
 	    $all_data = json_decode($buffer,true);
1261 1753
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1263,10 +1755,16 @@  discard block
 block discarded – undo
1263 1755
 		foreach ($all_data as $line) {
1264 1756
 	    	    $data = array();
1265 1757
 	    	    //$data['id'] = $line['id']; // id not usable
1266
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1758
+	    	    if (isset($line['pilotid'])) {
1759
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1760
+	    	    }
1267 1761
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1268
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1269
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1762
+	    	    if (isset($line['pilotname'])) {
1763
+	    	    	$data['pilot_name'] = $line['pilotname'];
1764
+	    	    }
1765
+	    	    if (isset($line['pilotid'])) {
1766
+	    	    	$data['pilot_id'] = $line['pilotid'];
1767
+	    	    }
1270 1768
 	    	    $data['ident'] = $line['flightnum']; // ident
1271 1769
 	    	    $data['altitude'] = $line['alt']; // altitude
1272 1770
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1282,7 +1780,9 @@  discard block
 block discarded – undo
1282 1780
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1283 1781
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1284 1782
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1285
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1783
+	    	    } else {
1784
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1785
+	    	    }
1286 1786
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1287 1787
 	    	    $data['departure_airport_time'] = $line['deptime'];
1288 1788
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1290,29 +1790,47 @@  discard block
 block discarded – undo
1290 1790
     		    if (isset($line['registration'])) {
1291 1791
     			$data['registration'] = $line['registration'];
1292 1792
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1293
-    		    } else $data['registration'] = $line['aircraft'];
1294
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1295
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1793
+    		    } else {
1794
+    		    	$data['registration'] = $line['aircraft'];
1795
+    		    }
1796
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1797
+		    	$data['noarchive'] = true;
1798
+		    }
1799
+		    if (isset($line['route'])) {
1800
+		    	$data['waypoints'] = $line['route'];
1801
+		    }
1802
+		    // route
1296 1803
 		    if (isset($line['aircraftname'])) {
1297 1804
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1298 1805
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1299 1806
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1300
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1301
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1302
-	    		else {
1807
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1808
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1809
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1810
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1811
+	    		} else {
1303 1812
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1304
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1305
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1813
+	    		    if (isset($aircraft_data[1])) {
1814
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1815
+	    		    } else {
1816
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1817
+	    		    }
1306 1818
 	    		}
1307 1819
 	    	    }
1308
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1820
+    		    if (isset($line['route'])) {
1821
+    		    	$data['waypoints'] = $line['route'];
1822
+    		    }
1309 1823
     		    $data['id_source'] = $id_source;
1310 1824
 	    	    $data['format_source'] = 'phpvmacars';
1311
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1825
+		    if (isset($value['name']) && $value['name'] != '') {
1826
+		    	$data['source_name'] = $value['name'];
1827
+		    }
1312 1828
 		    $SI->add($data);
1313 1829
 		    unset($data);
1314 1830
 		}
1315
-		if ($globalDebug) echo 'No more data...'."\n";
1831
+		if ($globalDebug) {
1832
+			echo 'No more data...'."\n";
1833
+		}
1316 1834
 		unset($buffer);
1317 1835
 		unset($all_data);
1318 1836
 	    }
@@ -1325,7 +1843,9 @@  discard block
 block discarded – undo
1325 1843
 	    )
1326 1844
 	) {
1327 1845
 	    //$buffer = $Common->getData($hosts[$id]);
1328
-	    if ($globalDebug) echo 'Get Data...'."\n";
1846
+	    if ($globalDebug) {
1847
+	    	echo 'Get Data...'."\n";
1848
+	    }
1329 1849
 	    $buffer = $Common->getData($value['host']);
1330 1850
 	    $all_data = json_decode($buffer,true);
1331 1851
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1336,10 +1856,16 @@  discard block
 block discarded – undo
1336 1856
 	    	    //$data['id'] = $line['id']; // id not usable
1337 1857
 	    	    $data['id'] = $line['id'];
1338 1858
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1339
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1340
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1859
+	    	    if (isset($line['user']['username'])) {
1860
+	    	    	$data['pilot_name'] = $line['user']['username'];
1861
+	    	    }
1862
+	    	    if (isset($line['user_id'])) {
1863
+	    	    	$data['pilot_id'] = $line['user_id'];
1864
+	    	    }
1341 1865
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1342
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1866
+	    	    if (is_numeric($data['ident'])) {
1867
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1868
+	    	    }
1343 1869
 	    	    $data['altitude'] = $line['altitude']; // altitude
1344 1870
 	    	    $data['speed'] = $line['groundspeed']; // speed
1345 1871
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1352,7 +1878,9 @@  discard block
 block discarded – undo
1352 1878
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1353 1879
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1354 1880
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1355
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1881
+	    	    } else {
1882
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1883
+	    	    }
1356 1884
 	    	    
1357 1885
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1358 1886
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1360,17 +1888,26 @@  discard block
 block discarded – undo
1360 1888
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1361 1889
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1362 1890
 
1363
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1891
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1892
+		    	$data['noarchive'] = true;
1893
+		    }
1894
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
1895
+		    	$data['waypoints'] = $line['bid']['route'];
1896
+		    }
1897
+		    // route
1365 1898
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1366 1899
 
1367 1900
     		    $data['id_source'] = $id_source;
1368 1901
 	    	    $data['format_source'] = 'vaos';
1369
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1902
+		    if (isset($value['name']) && $value['name'] != '') {
1903
+		    	$data['source_name'] = $value['name'];
1904
+		    }
1370 1905
 		    $SI->add($data);
1371 1906
 		    unset($data);
1372 1907
 		}
1373
-		if ($globalDebug) echo 'No more data...'."\n";
1908
+		if ($globalDebug) {
1909
+			echo 'No more data...'."\n";
1910
+		}
1374 1911
 		unset($buffer);
1375 1912
 		unset($all_data);
1376 1913
 	    }
@@ -1383,7 +1920,9 @@  discard block
 block discarded – undo
1383 1920
 	    )
1384 1921
 	) {
1385 1922
 	    //$buffer = $Common->getData($hosts[$id]);
1386
-	    if ($globalDebug) echo 'Get Data...'."\n";
1923
+	    if ($globalDebug) {
1924
+	    	echo 'Get Data...'."\n";
1925
+	    }
1387 1926
 	    $buffer = $Common->getData($value['host']);
1388 1927
 	    $all_data = json_decode($buffer,true);
1389 1928
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1412,16 +1951,25 @@  discard block
 block discarded – undo
1412 1951
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1413 1952
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1414 1953
     		    //$data['registration'] = $line['aircraft'];
1415
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1954
+		    if (isset($line['route'])) {
1955
+		    	$data['waypoints'] = $line['route'];
1956
+		    }
1957
+		    // route
1416 1958
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1417 1959
     		    $data['id_source'] = $id_source;
1418 1960
 	    	    $data['format_source'] = 'vam';
1419
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1420
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1961
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1962
+		    	$data['noarchive'] = true;
1963
+		    }
1964
+		    if (isset($value['name']) && $value['name'] != '') {
1965
+		    	$data['source_name'] = $value['name'];
1966
+		    }
1421 1967
 		    $SI->add($data);
1422 1968
 		    unset($data);
1423 1969
 		}
1424
-		if ($globalDebug) echo 'No more data...'."\n";
1970
+		if ($globalDebug) {
1971
+			echo 'No more data...'."\n";
1972
+		}
1425 1973
 		unset($buffer);
1426 1974
 		unset($all_data);
1427 1975
 	    }
@@ -1434,7 +1982,9 @@  discard block
 block discarded – undo
1434 1982
 	    )
1435 1983
 	) {
1436 1984
 	    //$buffer = $Common->getData($hosts[$id]);
1437
-	    if ($globalDebug) echo 'Get Data...'."\n";
1985
+	    if ($globalDebug) {
1986
+	    	echo 'Get Data...'."\n";
1987
+	    }
1438 1988
 	    $buffer = $Common->getData($value['host']);
1439 1989
 	    $all_data = json_decode($buffer,true);
1440 1990
 	    if ($buffer != '') {
@@ -1452,12 +2002,16 @@  discard block
 block discarded – undo
1452 2002
 			$data['id_source'] = $id_source;
1453 2003
 			$data['format_source'] = 'blitzortung';
1454 2004
 			$SI->add($data);
1455
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2005
+			if ($globalDebug) {
2006
+				echo '☈ Lightning added'."\n";
2007
+			}
1456 2008
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1457 2009
 			unset($data);
1458 2010
 		    }
1459 2011
 		}
1460
-		if ($globalDebug) echo 'No more data...'."\n";
2012
+		if ($globalDebug) {
2013
+			echo 'No more data...'."\n";
2014
+		}
1461 2015
 		unset($buffer);
1462 2016
 	    }
1463 2017
 	    $last_exec[$id]['last'] = time();
@@ -1469,7 +2023,9 @@  discard block
 block discarded – undo
1469 2023
 	    $write = NULL;
1470 2024
 	    $e = NULL;
1471 2025
 	    $n = socket_select($read, $write, $e, $timeout);
1472
-	    if ($e != NULL) var_dump($e);
2026
+	    if ($e != NULL) {
2027
+	    	var_dump($e);
2028
+	    }
1473 2029
 	    if ($n > 0) {
1474 2030
 		$reset = 0;
1475 2031
 		foreach ($read as $nb => $r) {
@@ -1491,13 +2047,17 @@  discard block
 block discarded – undo
1491 2047
 		    if ($buffer !== FALSE) {
1492 2048
 			if ($format === 'vrstcp') {
1493 2049
 			    $buffer = explode('},{',$buffer);
1494
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2050
+			} else {
2051
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2052
+			}
1495 2053
 		    }
1496 2054
 		    // SBS format is CSV format
1497 2055
 		    if ($buffer !== FALSE && $buffer !== '') {
1498 2056
 			$tt[$format] = 0;
1499 2057
 			if ($format === 'acarssbs3') {
1500
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2058
+			    if ($globalDebug) {
2059
+			    	echo 'ACARS : '.$buffer."\n";
2060
+			    }
1501 2061
 			    $ACARS->add(trim($buffer));
1502 2062
 			    $ACARS->deleteLiveAcarsData();
1503 2063
 			} elseif ($format === 'raw') {
@@ -1506,30 +2066,70 @@  discard block
 block discarded – undo
1506 2066
 			    if (is_array($data)) {
1507 2067
 				$data['datetime'] = date('Y-m-d H:i:s');
1508 2068
 				$data['format_source'] = 'raw';
1509
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1510
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1511
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1512
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2069
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2070
+					$data['source_name'] = $globalSources[$nb]['name'];
2071
+				}
2072
+				if (isset($globalSources[$nb]['sourcestats'])) {
2073
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2074
+				}
2075
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2076
+					$data['noarchive'] = true;
2077
+				}
2078
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2079
+					$SI->add($data);
2080
+				}
1513 2081
 			    }
1514 2082
 			} elseif ($format === 'ais') {
1515 2083
 			    $ais_data = $AIS->parse_line(trim($buffer));
1516 2084
 			    $data = array();
1517
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1518
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1519
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1520
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1521
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1522
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1523
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1524
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1525
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1526
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1527
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1528
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1529
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1530
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1531
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1532
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2085
+			    if (isset($ais_data['ident'])) {
2086
+			    	$data['ident'] = $ais_data['ident'];
2087
+			    }
2088
+			    if (isset($ais_data['mmsi'])) {
2089
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2090
+			    }
2091
+			    if (isset($ais_data['speed'])) {
2092
+			    	$data['speed'] = $ais_data['speed'];
2093
+			    }
2094
+			    if (isset($ais_data['heading'])) {
2095
+			    	$data['heading'] = $ais_data['heading'];
2096
+			    }
2097
+			    if (isset($ais_data['latitude'])) {
2098
+			    	$data['latitude'] = $ais_data['latitude'];
2099
+			    }
2100
+			    if (isset($ais_data['longitude'])) {
2101
+			    	$data['longitude'] = $ais_data['longitude'];
2102
+			    }
2103
+			    if (isset($ais_data['status'])) {
2104
+			    	$data['status'] = $ais_data['status'];
2105
+			    }
2106
+			    if (isset($ais_data['statusid'])) {
2107
+			    	$data['status_id'] = $ais_data['statusid'];
2108
+			    }
2109
+			    if (isset($ais_data['type'])) {
2110
+			    	$data['type'] = $ais_data['type'];
2111
+			    }
2112
+			    if (isset($ais_data['imo'])) {
2113
+			    	$data['imo'] = $ais_data['imo'];
2114
+			    }
2115
+			    if (isset($ais_data['callsign'])) {
2116
+			    	$data['callsign'] = $ais_data['callsign'];
2117
+			    }
2118
+			    if (isset($ais_data['destination'])) {
2119
+			    	$data['arrival_code'] = $ais_data['destination'];
2120
+			    }
2121
+			    if (isset($ais_data['eta_ts'])) {
2122
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2123
+			    }
2124
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2125
+			    	$data['noarchive'] = true;
2126
+			    }
2127
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2128
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2129
+			    }
2130
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2131
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2132
+			    }
1533 2133
 
1534 2134
 			    if (isset($ais_data['timestamp'])) {
1535 2135
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1538,7 +2138,9 @@  discard block
 block discarded – undo
1538 2138
 			    }
1539 2139
 			    $data['format_source'] = 'aisnmea';
1540 2140
     			    $data['id_source'] = $id_source;
1541
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2141
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2142
+			    	$MI->add($data);
2143
+			    }
1542 2144
 			    unset($data);
1543 2145
                         } elseif ($format === 'flightgearsp') {
1544 2146
                     	    //echo $buffer."\n";
@@ -1556,12 +2158,18 @@  discard block
 block discarded – undo
1556 2158
 				$data['speed'] = round($line[5]*1.94384);
1557 2159
 				$data['datetime'] = date('Y-m-d H:i:s');
1558 2160
 				$data['format_source'] = 'flightgearsp';
1559
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1560
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2161
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2162
+					$data['noarchive'] = true;
2163
+				}
2164
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2165
+					$SI->add($data);
2166
+				}
1561 2167
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1562 2168
 			    }
1563 2169
                         } elseif ($format === 'acars') {
1564
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2170
+                    	    if ($globalDebug) {
2171
+                    	    	echo 'ACARS : '.$buffer."\n";
2172
+                    	    }
1565 2173
 			    $ACARS->add(trim($buffer));
1566 2174
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1567 2175
 			    $ACARS->deleteLiveAcarsData();
@@ -1582,8 +2190,12 @@  discard block
 block discarded – undo
1582 2190
 				    $aircraft_type = $line[10];
1583 2191
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1584 2192
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1585
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2193
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2194
+				    	$data['noarchive'] = true;
2195
+				    }
2196
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2197
+				    	$SI->add($data);
2198
+				    }
1587 2199
 				}
1588 2200
 			    }
1589 2201
 			} elseif ($format === 'beast') {
@@ -1593,28 +2205,62 @@  discard block
 block discarded – undo
1593 2205
 			    foreach($buffer as $all_data) {
1594 2206
 				$line = json_decode('{'.$all_data.'}',true);
1595 2207
 				$data = array();
1596
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1597
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1598
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1599
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1600
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1601
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1602
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2208
+				if (isset($line['Icao'])) {
2209
+					$data['hex'] = $line['Icao'];
2210
+				}
2211
+				// hex
2212
+				if (isset($line['Call'])) {
2213
+					$data['ident'] = $line['Call'];
2214
+				}
2215
+				// ident
2216
+				if (isset($line['Alt'])) {
2217
+					$data['altitude'] = $line['Alt'];
2218
+				}
2219
+				// altitude
2220
+				if (isset($line['Spd'])) {
2221
+					$data['speed'] = $line['Spd'];
2222
+				}
2223
+				// speed
2224
+				if (isset($line['Trak'])) {
2225
+					$data['heading'] = $line['Trak'];
2226
+				}
2227
+				// heading
2228
+				if (isset($line['Lat'])) {
2229
+					$data['latitude'] = $line['Lat'];
2230
+				}
2231
+				// lat
2232
+				if (isset($line['Long'])) {
2233
+					$data['longitude'] = $line['Long'];
2234
+				}
2235
+				// long
1603 2236
 				//$data['verticalrate'] = $line['']; // verticale rate
1604
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2237
+				if (isset($line['Sqk'])) {
2238
+					$data['squawk'] = $line['Sqk'];
2239
+				}
2240
+				// squawk
1605 2241
 				$data['emergency'] = ''; // emergency
1606
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2242
+				if (isset($line['Reg'])) {
2243
+					$data['registration'] = $line['Reg'];
2244
+				}
1607 2245
 				/*
1608 2246
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1609 2247
 				else $data['datetime'] = date('Y-m-d H:i:s');
1610 2248
 				*/
1611 2249
 				$data['datetime'] = date('Y-m-d H:i:s');
1612
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2250
+				if (isset($line['Type'])) {
2251
+					$data['aircraft_icao'] = $line['Type'];
2252
+				}
1613 2253
 		    		$data['format_source'] = 'vrstcp';
1614 2254
 				$data['id_source'] = $id_source;
1615
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1616
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1617
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2255
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2256
+					$data['noarchive'] = true;
2257
+				}
2258
+				if (isset($value['name']) && $value['name'] != '') {
2259
+					$data['source_name'] = $value['name'];
2260
+				}
2261
+				if (isset($data['latitude']) && isset($data['hex'])) {
2262
+					$SI->add($data);
2263
+				}
1618 2264
 				unset($data);
1619 2265
 			    }
1620 2266
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1627,22 +2273,46 @@  discard block
 block discarded – undo
1627 2273
     				$data['hex'] = $lined['hexid'];
1628 2274
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1629 2275
     				$data['datetime'] = date('Y-m-d H:i:s');;
1630
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1631
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1632
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1633
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1634
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1635
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1636
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2276
+    				if (isset($lined['ident'])) {
2277
+    					$data['ident'] = $lined['ident'];
2278
+    				}
2279
+    				if (isset($lined['lat'])) {
2280
+    					$data['latitude'] = $lined['lat'];
2281
+    				}
2282
+    				if (isset($lined['lon'])) {
2283
+    					$data['longitude'] = $lined['lon'];
2284
+    				}
2285
+    				if (isset($lined['speed'])) {
2286
+    					$data['speed'] = $lined['speed'];
2287
+    				}
2288
+    				if (isset($lined['squawk'])) {
2289
+    					$data['squawk'] = $lined['squawk'];
2290
+    				}
2291
+    				if (isset($lined['alt'])) {
2292
+    					$data['altitude'] = $lined['alt'];
2293
+    				}
2294
+    				if (isset($lined['heading'])) {
2295
+    					$data['heading'] = $lined['heading'];
2296
+    				}
1637 2297
     				$data['id_source'] = $id_source;
1638 2298
     				$data['format_source'] = 'tsv';
1639
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1640
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1641
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1642
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2299
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2300
+    					$data['source_name'] = $globalSources[$nb]['name'];
2301
+    				}
2302
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2303
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2304
+    				}
2305
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2306
+					$data['noarchive'] = true;
2307
+				}
2308
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2309
+    					$SI->add($data);
2310
+    				}
1643 2311
     				unset($lined);
1644 2312
     				unset($data);
1645
-    			    } else $error = true;
2313
+    			    } else {
2314
+    			    	$error = true;
2315
+    			    }
1646 2316
 			} elseif ($format === 'aprs' && $use_aprs) {
1647 2317
 			    if ($aprs_connect === 0) {
1648 2318
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1668,63 +2338,121 @@  discard block
 block discarded – undo
1668 2338
 				    $aprs_last_tx = time();
1669 2339
 				    $data = array();
1670 2340
 				    //print_r($line);
1671
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1672
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1673
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1674
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1675
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1676
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1677
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1678
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1679
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1680
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2341
+				    if (isset($line['address'])) {
2342
+				    	$data['hex'] = $line['address'];
2343
+				    }
2344
+				    if (isset($line['mmsi'])) {
2345
+				    	$data['mmsi'] = $line['mmsi'];
2346
+				    }
2347
+				    if (isset($line['imo'])) {
2348
+				    	$data['imo'] = $line['imo'];
2349
+				    }
2350
+				    if (isset($line['squawk'])) {
2351
+				    	$data['squawk'] = $line['squawk'];
2352
+				    }
2353
+				    if (isset($line['arrival_code'])) {
2354
+				    	$data['arrival_code'] = $line['arrival_code'];
2355
+				    }
2356
+				    if (isset($line['arrival_date'])) {
2357
+				    	$data['arrival_date'] = $line['arrival_date'];
2358
+				    }
2359
+				    if (isset($line['typeid'])) {
2360
+				    	$data['type_id'] = $line['typeid'];
2361
+				    }
2362
+				    if (isset($line['statusid'])) {
2363
+				    	$data['status_id'] = $line['statusid'];
2364
+				    }
2365
+				    if (isset($line['timestamp'])) {
2366
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2367
+				    } else {
2368
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2369
+				    }
1681 2370
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1682
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2371
+				    if (isset($line['ident'])) {
2372
+				    	$data['ident'] = $line['ident'];
2373
+				    }
1683 2374
 				    $data['latitude'] = $line['latitude'];
1684 2375
 				    $data['longitude'] = $line['longitude'];
1685 2376
 				    //$data['verticalrate'] = $line[16];
1686
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2377
+				    if (isset($line['speed'])) {
2378
+				    	$data['speed'] = $line['speed'];
2379
+				    }
1687 2380
 				    //else $data['speed'] = 0;
1688
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1689
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1690
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2381
+				    if (isset($line['altitude'])) {
2382
+				    	$data['altitude'] = $line['altitude'];
2383
+				    }
2384
+				    if (isset($line['comment'])) {
2385
+				    	$data['comment'] = $line['comment'];
2386
+				    }
2387
+				    if (isset($line['symbol'])) {
2388
+				    	$data['type'] = $line['symbol'];
2389
+				    }
1691 2390
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1692 2391
 				    
1693
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2392
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2393
+				    	$data['heading'] = $line['heading'];
2394
+				    }
1694 2395
 				    //else echo 'No heading...'."\n";
1695 2396
 				    //else $data['heading'] = 0;
1696
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2397
+				    if (isset($line['stealth'])) {
2398
+				    	$data['aircraft_type'] = $line['stealth'];
2399
+				    }
1697 2400
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1698
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1699
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1700
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1701
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2401
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2402
+				    	$data['noarchive'] = true;
2403
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2404
+				    	$data['noarchive'] = false;
2405
+				    }
2406
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2407
+				    	$data['noarchive'] = true;
2408
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2409
+				    	$data['noarchive'] = false;
2410
+				    }
1702 2411
     				    $data['id_source'] = $id_source;
1703
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1704
-				    else $data['format_source'] = 'aprs';
2412
+    				    if (isset($line['format_source'])) {
2413
+    				    	$data['format_source'] = $line['format_source'];
2414
+    				    } else {
2415
+				    	$data['format_source'] = 'aprs';
2416
+				    }
1705 2417
 				    $data['source_name'] = $line['source'];
1706
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1707
-				    else $data['source_type'] = 'flarm';
1708
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2418
+				    if (isset($line['source_type'])) {
2419
+				    	$data['source_type'] = $line['source_type'];
2420
+				    } else {
2421
+				    	$data['source_type'] = 'flarm';
2422
+				    }
2423
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2424
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2425
+    				    }
1709 2426
 				    $currentdate = date('Y-m-d H:i:s');
1710 2427
 				    $aprsdate = strtotime($data['datetime']);
1711
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2428
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2429
+				    	$data['altitude_relative'] = 'AMSL';
2430
+				    }
1712 2431
 				    // Accept data if time <= system time + 20s
1713 2432
 				    //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'])))) {
1714 2433
 				    if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1715 2434
 					$send = $SI->add($data);
1716 2435
 				    } elseif ($data['source_type'] === 'ais') {
1717 2436
 					$data['type'] = '';
1718
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2437
+					if (isset($globalMarine) && $globalMarine) {
2438
+						$send = $MI->add($data);
2439
+					}
1719 2440
 				    } elseif (isset($line['stealth'])) {
1720
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1721
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2441
+					if ($line['stealth'] != 0) {
2442
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2443
+					} else {
2444
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2445
+					}
1722 2446
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1723 2447
 					    //$line['symbol'] === 'Balloon' ||
1724 2448
 					    $line['symbol'] === 'Glider' || 
1725 2449
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1726
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1727
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2450
+					    if ($line['symbol'] === 'Ballon') {
2451
+					    	$data['aircraft_icao'] = 'BALL';
2452
+					    }
2453
+					    if ($line['symbol'] === 'Glider') {
2454
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2455
+					    }
1728 2456
 					    $send = $SI->add($data);
1729 2457
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1730 2458
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1755,9 +2483,13 @@  discard block
 block discarded – undo
1755 2483
 				    //} 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') {
1756 2484
 				//    } 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') {
1757 2485
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1758
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2486
+					if (isset($globalTracker) && $globalTracker) {
2487
+						$send = $TI->add($data);
2488
+					}
1759 2489
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1760
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2490
+					if (!isset($data['altitude'])) {
2491
+						$data['altitude'] = 0;
2492
+					}
1761 2493
 					$Source->deleteOldLocationByType('gs');
1762 2494
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1763 2495
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1766,7 +2498,9 @@  discard block
 block discarded – undo
1766 2498
 					}
1767 2499
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1768 2500
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1769
-					if ($globalDebug) echo '# Weather Station added'."\n";
2501
+					if ($globalDebug) {
2502
+						echo '# Weather Station added'."\n";
2503
+					}
1770 2504
 					$Source->deleteOldLocationByType('wx');
1771 2505
 					$weather_data = json_encode($line);
1772 2506
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1776,7 +2510,9 @@  discard block
 block discarded – undo
1776 2510
 					}
1777 2511
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1778 2512
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1779
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2513
+					if ($globalDebug) {
2514
+						echo '☈ Lightning added'."\n";
2515
+					}
1780 2516
 					$Source->deleteOldLocationByType('lightning');
1781 2517
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1782 2518
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1788,8 +2524,7 @@  discard block
 block discarded – undo
1788 2524
 				    	print_r($line);
1789 2525
 				    }
1790 2526
 				    unset($data);
1791
-				}
1792
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2527
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1793 2528
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1794 2529
 				}
1795 2530
 				/*
@@ -1798,7 +2533,9 @@  discard block
 block discarded – undo
1798 2533
 				}
1799 2534
 				*/
1800 2535
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1801
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2536
+				elseif ($line === true && $globalDebug) {
2537
+					echo '!! Failed : '.$buffer."!!\n";
2538
+				}
1802 2539
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1803 2540
 					$Source->deleteOldLocationByType('lightning');
1804 2541
 					$Source->deleteOldLocationByType('wx');
@@ -1834,26 +2571,45 @@  discard block
 block discarded – undo
1834 2571
     				$data['ground'] = $line[21];
1835 2572
     				$data['emergency'] = $line[19];
1836 2573
     				$data['format_source'] = 'sbs';
1837
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1838
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1839
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2574
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2575
+					$data['source_name'] = $globalSources[$nb]['name'];
2576
+				}
2577
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2578
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2579
+    				}
2580
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2581
+					$data['noarchive'] = true;
2582
+				}
1840 2583
     				$data['id_source'] = $id_source;
1841
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1842
-    				else $error = true;
2584
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2585
+    					$send = $SI->add($data);
2586
+    				} else {
2587
+    					$error = true;
2588
+    				}
1843 2589
     				unset($data);
1844
-    			    } else $error = true;
2590
+    			    } else {
2591
+    			    	$error = true;
2592
+    			    }
1845 2593
 			    if ($error) {
1846 2594
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1847
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2595
+					if ($globalDebug) {
2596
+						echo "Not a message. Ignoring... \n";
2597
+					}
1848 2598
 				} else {
1849
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2599
+					if ($globalDebug) {
2600
+						echo "Wrong line format. Ignoring... \n";
2601
+					}
1850 2602
 					if ($globalDebug) {
1851 2603
 						echo $buffer;
1852 2604
 						//print_r($line);
1853 2605
 					}
1854 2606
 					//socket_close($r);
1855
-					if ($globalDebug) echo "Reconnect after an error...\n";
1856
-					if ($format === 'aprs') $aprs_connect = 0;
2607
+					if ($globalDebug) {
2608
+						echo "Reconnect after an error...\n";
2609
+					}
2610
+					if ($format === 'aprs') {
2611
+						$aprs_connect = 0;
2612
+					}
1857 2613
 					$sourceer[$nb] = $globalSources[$nb];
1858 2614
 					connect_all($sourceer);
1859 2615
 					$sourceer = array();
@@ -1861,10 +2617,14 @@  discard block
 block discarded – undo
1861 2617
 			    }
1862 2618
 			}
1863 2619
 			// Sleep for xxx microseconds
1864
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2620
+			if (isset($globalSBSSleep)) {
2621
+				usleep($globalSBSSleep);
2622
+			}
1865 2623
 		    } else {
1866 2624
 			if ($format === 'flightgearmp') {
1867
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2625
+			    	if ($globalDebug) {
2626
+			    		echo "Reconnect FlightGear MP...";
2627
+			    	}
1868 2628
 				//@socket_close($r);
1869 2629
 				sleep($globalMinFetch);
1870 2630
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1873,10 +2633,15 @@  discard block
 block discarded – undo
1873 2633
 				break;
1874 2634
 				
1875 2635
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1876
-			    if (isset($tt[$format])) $tt[$format]++;
1877
-			    else $tt[$format] = 0;
2636
+			    if (isset($tt[$format])) {
2637
+			    	$tt[$format]++;
2638
+			    } else {
2639
+			    	$tt[$format] = 0;
2640
+			    }
1878 2641
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1879
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2642
+				if ($globalDebug) {
2643
+					echo "ERROR : Reconnect ".$format."...";
2644
+				}
1880 2645
 				//@socket_close($r);
1881 2646
 				sleep(2);
1882 2647
 				$aprs_connect = 0;
@@ -1894,11 +2659,17 @@  discard block
 block discarded – undo
1894 2659
 	    } else {
1895 2660
 		$error = socket_strerror(socket_last_error());
1896 2661
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1897
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1898
-			if (isset($globalDebug)) echo "Restarting...\n";
2662
+			if ($globalDebug) {
2663
+				echo "ERROR : socket_select give this error ".$error . "\n";
2664
+			}
2665
+			if (isset($globalDebug)) {
2666
+				echo "Restarting...\n";
2667
+			}
1899 2668
 			// Restart the script if possible
1900 2669
 			if (is_array($sockets)) {
1901
-			    if ($globalDebug) echo "Shutdown all sockets...";
2670
+			    if ($globalDebug) {
2671
+			    	echo "Shutdown all sockets...";
2672
+			    }
1902 2673
 			    
1903 2674
 			    foreach ($sockets as $sock) {
1904 2675
 				@socket_shutdown($sock,2);
@@ -1906,25 +2677,45 @@  discard block
 block discarded – undo
1906 2677
 			    }
1907 2678
 			    
1908 2679
 			}
1909
-			if ($globalDebug) echo "Waiting...";
2680
+			if ($globalDebug) {
2681
+				echo "Waiting...";
2682
+			}
1910 2683
 			sleep(2);
1911 2684
 			$time = time();
1912 2685
 			//connect_all($hosts);
1913 2686
 			$aprs_connect = 0;
1914
-			if ($reset%5 === 0) sleep(20);
1915
-			if ($reset%10 === 0) sleep(100);
1916
-			if ($reset%20 === 0) sleep(200);
1917
-			if ($reset > 100) exit('Too many attempts...');
1918
-			if ($globalDebug) echo "Restart all connections...";
2687
+			if ($reset%5 === 0) {
2688
+				sleep(20);
2689
+			}
2690
+			if ($reset%10 === 0) {
2691
+				sleep(100);
2692
+			}
2693
+			if ($reset%20 === 0) {
2694
+				sleep(200);
2695
+			}
2696
+			if ($reset > 100) {
2697
+				exit('Too many attempts...');
2698
+			}
2699
+			if ($globalDebug) {
2700
+				echo "Restart all connections...";
2701
+			}
1919 2702
 			connect_all($globalSources);
1920 2703
 		}
1921 2704
 	    }
1922 2705
 	}
1923 2706
 	if ($globalDaemon === false) {
1924
-	    if ($globalDebug) echo 'Check all...'."\n";
1925
-	    if (isset($SI)) $SI->checkAll();
1926
-	    if (isset($TI)) $TI->checkAll();
1927
-	    if (isset($MI)) $MI->checkAll();
2707
+	    if ($globalDebug) {
2708
+	    	echo 'Check all...'."\n";
2709
+	    }
2710
+	    if (isset($SI)) {
2711
+	    	$SI->checkAll();
2712
+	    }
2713
+	    if (isset($TI)) {
2714
+	    	$TI->checkAll();
2715
+	    }
2716
+	    if (isset($MI)) {
2717
+	    	$MI->checkAll();
2718
+	    }
1928 2719
 	}
1929 2720
     }
1930 2721
 }
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +404 added lines, -144 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54 54
 		} catch(Exception $e) {
55
-			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
55
+			if ($globalDebug) {
56
+				echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
57
+			}
56 58
 			$GeoidClass = FALSE;
57 59
 		}
58 60
 	}
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 	$dbc = $this->db;
72 74
 	$this->all_flights[$id]['schedule_check'] = true;
73 75
 	if ($globalSchedulesFetch) {
74
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
76
+	if ($globalDebug) {
77
+		echo 'Getting schedule info...'."\n";
78
+	}
75 79
 	$Spotter = new Spotter($dbc);
76 80
 	$Schedule = new Schedule($dbc);
77 81
 	$Translation = new Translation($dbc);
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 	    if ($Schedule->checkSchedule($operator) == 0) {
83 87
 		$schedule = $Schedule->fetchSchedule($operator);
84 88
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
89
+		    if ($globalDebug) {
90
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
91
+		    }
86 92
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87 93
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88 94
 		    // Should also check if route schedule = route from DB
@@ -91,7 +97,9 @@  discard block
 block discarded – undo
91 97
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92 98
 			    if (trim($airport_icao) != '') {
93 99
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
100
+				if ($globalDebug) {
101
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
+				}
95 103
 			    }
96 104
 			}
97 105
 		    }
@@ -100,20 +108,30 @@  discard block
 block discarded – undo
100 108
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101 109
 			    if (trim($airport_icao) != '') {
102 110
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
+				if ($globalDebug) {
112
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
113
+				}
104 114
 			    }
105 115
 			}
106 116
 		    }
107 117
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 118
 		}
109
-	    } else $scheduleexist = true;
110
-	} else $scheduleexist = true;
119
+	    } else {
120
+	    	$scheduleexist = true;
121
+	    }
122
+	} else {
123
+		$scheduleexist = true;
124
+	}
111 125
 	// close connection, at least one way will work ?
112 126
        if ($scheduleexist) {
113
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
127
+		if ($globalDebug) {
128
+			echo "-> get arrival/departure airport info for ".$ident."\n";
129
+		}
114 130
     		$sch = $Schedule->getSchedule($operator);
115 131
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
132
+		if ($this->all_flights[$id]['addedSpotter'] == 1) {
133
+			$Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
134
+		}
117 135
        }
118 136
 	$Spotter->db = null;
119 137
 	$Schedule->db = null;
@@ -133,14 +151,18 @@  discard block
 block discarded – undo
133 151
 
134 152
     public function checkAll() {
135 153
 	global $globalDebug, $globalNoImport;
136
-	if ($globalDebug) echo "Update last seen flights data...\n";
154
+	if ($globalDebug) {
155
+		echo "Update last seen flights data...\n";
156
+	}
137 157
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
138 158
 	    foreach ($this->all_flights as $key => $flight) {
139 159
 		if (isset($this->all_flights[$key]['id'])) {
140 160
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141 161
     		    $Spotter = new Spotter($this->db);
142 162
         	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
163
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
164
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
165
+        	    }
144 166
         	}
145 167
 	    }
146 168
 	}
@@ -148,24 +170,32 @@  discard block
 block discarded – undo
148 170
 
149 171
     public function arrival($key) {
150 172
 	global $globalClosestMinDist, $globalDebug;
151
-	if ($globalDebug) echo 'Update arrival...'."\n";
173
+	if ($globalDebug) {
174
+		echo 'Update arrival...'."\n";
175
+	}
152 176
 	$Spotter = new Spotter($this->db);
153 177
         $airport_icao = '';
154 178
         $airport_time = '';
155
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
179
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
180
+        	$globalClosestMinDist = 50;
181
+        }
156 182
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157 183
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158 184
     	    if (isset($closestAirports[0])) {
159 185
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160 186
         	    $airport_icao = $closestAirports[0]['icao'];
161 187
         	    $airport_time = $this->all_flights[$key]['datetime'];
162
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
188
+        	    if ($globalDebug) {
189
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
190
+        	    }
163 191
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164 192
         	    foreach ($closestAirports as $airport) {
165 193
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166 194
         		    $airport_icao = $airport['icao'];
167 195
         		    $airport_time = $this->all_flights[$key]['datetime'];
168
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
196
+        		    if ($globalDebug) {
197
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
198
+        		    }
169 199
         		    break;
170 200
         		}
171 201
         	    }
@@ -173,14 +203,20 @@  discard block
 block discarded – undo
173 203
         		$airport_icao = $closestAirports[0]['icao'];
174 204
         		$airport_time = $this->all_flights[$key]['datetime'];
175 205
         	} else {
176
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
206
+        		if ($globalDebug) {
207
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
208
+        		}
177 209
         	}
178 210
     	    } else {
179
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
211
+    		    if ($globalDebug) {
212
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
213
+    		    }
180 214
     	    }
181 215
 
182 216
         } else {
183
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
217
+        	if ($globalDebug) {
218
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
219
+        	}
184 220
         }
185 221
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186 222
     }
@@ -190,7 +226,9 @@  discard block
 block discarded – undo
190 226
     public function del() {
191 227
 	global $globalDebug, $globalNoImport, $globalNoDB;
192 228
 	// Delete old infos
193
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
229
+	if ($globalDebug) {
230
+		echo 'Delete old values and update latest data...'."\n";
231
+	}
194 232
 	foreach ($this->all_flights as $key => $flight) {
195 233
 	    if (isset($flight['lastupdate'])) {
196 234
 		if ($flight['lastupdate'] < (time()-1800)) {
@@ -204,13 +242,17 @@  discard block
 block discarded – undo
204 242
 	global $globalDebug, $globalNoImport, $globalNoDB;
205 243
 	// Delete old infos
206 244
 	if (isset($this->all_flights[$key]['id'])) {
207
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
245
+		if ($globalDebug) {
246
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
247
+		}
208 248
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
209 249
 			$real_arrival = $this->arrival($key);
210 250
 			$Spotter = new Spotter($this->db);
211 251
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
212 252
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
213
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
253
+				if ($globalDebug && $result != 'success') {
254
+					echo '!!! ERROR : '.$result."\n";
255
+				}
214 256
 			}
215 257
 		}
216 258
 	}
@@ -220,9 +262,13 @@  discard block
 block discarded – undo
220 262
     public function add($line) {
221 263
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
222 264
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
223
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
224
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
225
-/*
265
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
266
+		$globalCoordMinChange = '0.01';
267
+	}
268
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
269
+		$globalAircraftMaxUpdate = 3000;
270
+	}
271
+	/*
226 272
 	$Spotter = new Spotter();
227 273
 	$dbc = $Spotter->db;
228 274
 	$SpotterLive = new SpotterLive($dbc);
@@ -244,19 +290,28 @@  discard block
 block discarded – undo
244 290
 	// SBS format is CSV format
245 291
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
246 292
 	    //print_r($line);
247
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
293
+	    if (isset($line['hex'])) {
294
+	    	$line['hex'] = strtoupper($line['hex']);
295
+	    }
248 296
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
249 297
 
250 298
 		// Increment message number
251 299
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
252 300
 		    $current_date = date('Y-m-d');
253
-		    if (isset($line['source_name'])) $source = $line['source_name'];
254
-		    else $source = '';
255
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
301
+		    if (isset($line['source_name'])) {
302
+		    	$source = $line['source_name'];
303
+		    } else {
304
+		    	$source = '';
305
+		    }
306
+		    if ($source == '' || $line['format_source'] == 'aprs') {
307
+		    	$source = $line['format_source'];
308
+		    }
256 309
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
257 310
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
258 311
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
259
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
312
+		    } else {
313
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
314
+		    }
260 315
 		}
261 316
 		
262 317
 		/*
@@ -272,23 +327,38 @@  discard block
 block discarded – undo
272 327
 		//$this->db = $dbc;
273 328
 
274 329
 		//$hex = trim($line['hex']);
275
-	        if (!isset($line['id'])) $id = trim($line['hex']);
276
-	        else $id = trim($line['id']);
330
+	        if (!isset($line['id'])) {
331
+	        	$id = trim($line['hex']);
332
+	        } else {
333
+	        	$id = trim($line['id']);
334
+	        }
277 335
 		
278 336
 		if (!isset($this->all_flights[$id])) {
279
-		    if ($globalDebug) echo 'New flight...'."\n";
337
+		    if ($globalDebug) {
338
+		    	echo 'New flight...'."\n";
339
+		    }
280 340
 		    $this->all_flights[$id] = array();
281 341
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
282 342
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
283
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
343
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
344
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
345
+		    }
284 346
 		    if (!isset($line['id'])) {
285
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
286
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
347
+			if (!isset($globalDaemon)) {
348
+				$globalDaemon = TRUE;
349
+			}
350
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
287 351
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
288
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
352
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
353
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
354
+			}
289 355
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
290
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
291
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
356
+		     } else {
357
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
358
+		     }
359
+		    if ($globalAllFlights !== FALSE) {
360
+		    	$dataFound = true;
361
+		    }
292 362
 		}
293 363
 		if (isset($line['source_type']) && $line['source_type'] != '') {
294 364
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -310,12 +380,20 @@  discard block
 block discarded – undo
310 380
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
311 381
 			    }
312 382
 			    $Spotter->db = null;
313
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
314
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
383
+			    if ($globalDebugTimeElapsed) {
384
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
385
+			    }
386
+			    if ($aircraft_icao != '') {
387
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
388
+			    }
315 389
 			}
316 390
 		    }
317
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
318
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
391
+		    if ($globalAllFlights !== FALSE) {
392
+		    	$dataFound = true;
393
+		    }
394
+		    if ($globalDebug) {
395
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
396
+		    }
319 397
 		}
320 398
 	        if (isset($line['id']) && !isset($line['hex'])) {
321 399
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -324,7 +402,9 @@  discard block
 block discarded – undo
324 402
 			$icao = $line['aircraft_icao'];
325 403
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
326 404
 				$Spotter = new Spotter($this->db);
327
-				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
405
+				if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
406
+					$icao = $Spotter->aircraft_correct_icaotype[$icao];
407
+				}
328 408
 				$Spotter->db = null;
329 409
 			}
330 410
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
@@ -334,15 +414,24 @@  discard block
 block discarded – undo
334 414
 				$Spotter = new Spotter($this->db);
335 415
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
336 416
 				$Spotter->db = null;
337
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
417
+				if ($aircraft_icao != '') {
418
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
419
+				}
338 420
 			}
339 421
 		}
340 422
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
341
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
342
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
343
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
344
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
345
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
423
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
424
+				$aircraft_icao = 'GLID';
425
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
426
+				$aircraft_icao = 'UHEL';
427
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
428
+				$aircraft_icao = 'TOWPLANE';
429
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
430
+				$aircraft_icao = 'POWAIRC';
431
+			}
432
+			if (isset($aircraft_icao)) {
433
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
434
+			}
346 435
 		}
347 436
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
348 437
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -352,8 +441,11 @@  discard block
 block discarded – undo
352 441
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
353 442
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
354 443
 		    } else {
355
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
356
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
444
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
445
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
446
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
447
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
448
+				}
357 449
 				/*
358 450
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
359 451
 				print_r($this->all_flights[$id]);
@@ -362,16 +454,22 @@  discard block
 block discarded – undo
362 454
 				return '';
363 455
 		    }
364 456
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
365
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
457
+			if ($globalDebug) {
458
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
459
+			}
366 460
 			return '';
367 461
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
368
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
462
+			if ($globalDebug) {
463
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
464
+			}
369 465
 			return '';
370 466
 		} elseif (!isset($line['datetime'])) {
371 467
 			date_default_timezone_set('UTC');
372 468
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
373 469
 		} else {
374
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
470
+			if ($globalDebug) {
471
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
472
+			}
375 473
 			return '';
376 474
 		}
377 475
 
@@ -392,30 +490,48 @@  discard block
 block discarded – undo
392 490
 
393 491
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
394 492
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
395
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
493
+				if ($globalDebug) {
494
+					echo '---!!!! New ident, reset aircraft data...'."\n";
495
+				}
396 496
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
397 497
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
398
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
399
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
400
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
498
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
499
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
500
+				} elseif (isset($line['id'])) {
501
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
502
+				} elseif (isset($this->all_flights[$id]['ident'])) {
503
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
504
+				}
401 505
 			} else {
402 506
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
403 507
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
404 508
 				$timeelapsed = microtime(true);
405 509
             			$Spotter = new Spotter($this->db);
406 510
             			$fromsource = NULL;
407
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
408
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
409
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
410
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
411
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
511
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
512
+            				$fromsource = $globalAirlinesSource;
513
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
514
+            				$fromsource = 'vatsim';
515
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
516
+					$fromsource = 'ivao';
517
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
518
+					$fromsource = 'vatsim';
519
+				} elseif (isset($globalIVAO) && $globalIVAO) {
520
+					$fromsource = 'ivao';
521
+				}
412 522
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
413
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
523
+				if ($globalDebug && $result != 'success') {
524
+					echo '!!! ERROR : '.$result."\n";
525
+				}
414 526
 				$Spotter->db = null;
415
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
527
+				if ($globalDebugTimeElapsed) {
528
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
529
+				}
416 530
 			    }
417 531
 			}
418
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
532
+		    } else {
533
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
534
+		    }
419 535
 		    
420 536
 /*
421 537
 		    if (!isset($line['id'])) {
@@ -425,7 +541,9 @@  discard block
 block discarded – undo
425 541
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
426 542
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
427 543
   */
428
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
544
+		    if (!isset($this->all_flights[$id]['id'])) {
545
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
546
+		    }
429 547
 
430 548
 		    //$putinarchive = true;
431 549
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -443,7 +561,9 @@  discard block
 block discarded – undo
443 561
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
444 562
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
445 563
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
446
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
564
+				if ($globalDebugTimeElapsed) {
565
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
566
+				}
447 567
                         }
448 568
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
449 569
 			$timeelapsed = microtime(true);
@@ -457,7 +577,9 @@  discard block
 block discarded – undo
457 577
 				$Translation->db = null;
458 578
 			    }
459 579
 			    $Spotter->db = null;
460
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
580
+			    if ($globalDebugTimeElapsed) {
581
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
582
+			    }
461 583
                     	}
462 584
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
463 585
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -466,9 +588,13 @@  discard block
 block discarded – undo
466 588
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
467 589
 		    	    }
468 590
 			}
469
-			if (!isset($globalFork)) $globalFork = TRUE;
591
+			if (!isset($globalFork)) {
592
+				$globalFork = TRUE;
593
+			}
470 594
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
471
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
595
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
596
+					$this->get_Schedule($id,trim($line['ident']));
597
+				}
472 598
 			}
473 599
 		    }
474 600
 		}
@@ -486,9 +612,13 @@  discard block
 block discarded – undo
486 612
 			$speed = $speed*3.6;
487 613
 			if ($speed < 1000) {
488 614
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
489
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
615
+	  			if ($globalDebug) {
616
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
617
+	  			}
490 618
 	  		} else {
491
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
619
+	  			if ($globalDebug) {
620
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
621
+	  			}
492 622
 	  		}
493 623
 		    }
494 624
 		}
@@ -497,13 +627,21 @@  discard block
 block discarded – undo
497 627
 
498 628
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
499 629
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
500
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
630
+	    	    	if ($globalDebug) {
631
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
632
+	    	    	}
501 633
 	    	    	return false;
502 634
 	    	    }
503
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
504
-	    	    else unset($timediff);
505
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
506
-	    	    else unset($timediff_archive);
635
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
636
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
637
+	    	    } else {
638
+	    	    	unset($timediff);
639
+	    	    }
640
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
641
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
642
+	    	    } else {
643
+	    	    	unset($timediff_archive);
644
+	    	    }
507 645
 	    	    if ($this->tmd > 5
508 646
 	    	        || (isset($line['format_source']) 
509 647
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -540,16 +678,25 @@  discard block
 block discarded – undo
540 678
 				$this->all_flights[$id]['putinarchive'] = true;
541 679
 				$this->tmd = 0;
542 680
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
543
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
681
+				    if ($globalDebug) {
682
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
683
+				    }
544 684
 				    $timeelapsed = microtime(true);
545 685
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
546 686
 					$Spotter = new Spotter($this->db);
547 687
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
548
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
549
-					else $this->all_flights[$id]['over_country'] = '';
688
+					if (!empty($all_country)) {
689
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
690
+					} else {
691
+						$this->all_flights[$id]['over_country'] = '';
692
+					}
550 693
 					$Spotter->db = null;
551
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
552
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
694
+					if ($globalDebugTimeElapsed) {
695
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
696
+					}
697
+					if ($globalDebug) {
698
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
699
+					}
553 700
 				    }
554 701
 				}
555 702
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -595,7 +742,9 @@  discard block
 block discarded – undo
595 742
 			    */
596 743
 			}
597 744
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
598
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
745
+			    if ($line['longitude'] > 180) {
746
+			    	$line['longitude'] = $line['longitude'] - 360;
747
+			    }
599 748
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
600 749
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
601 750
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -632,7 +781,9 @@  discard block
 block discarded – undo
632 781
 		    }
633 782
 		}
634 783
 		if (isset($line['last_update']) && $line['last_update'] != '') {
635
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
784
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
785
+		    	$dataFound = true;
786
+		    }
636 787
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
637 788
 		}
638 789
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -654,35 +805,53 @@  discard block
 block discarded – undo
654 805
 			// Here we force archive of flight because after ground it's a new one (or should be)
655 806
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
656 807
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
657
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
658
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
659
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
808
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
809
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
810
+			} elseif (isset($line['id'])) {
811
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
812
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
813
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
814
+			}
815
+		    }
816
+		    if ($line['ground'] != 1) {
817
+		    	$line['ground'] = 0;
660 818
 		    }
661
-		    if ($line['ground'] != 1) $line['ground'] = 0;
662 819
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
663 820
 		    //$dataFound = true;
664 821
 		}
665 822
 		if (isset($line['squawk']) && $line['squawk'] != '') {
666 823
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
667
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
824
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
825
+			    	$this->all_flights[$id]['putinarchive'] = true;
826
+			    }
668 827
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
669 828
 			    $highlight = '';
670
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
671
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
672
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
829
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
830
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
831
+			    }
832
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
833
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
834
+			    }
835
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
836
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
837
+			    }
673 838
 			    if ($highlight != '') {
674 839
 				$timeelapsed = microtime(true);
675 840
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
676 841
 				    $Spotter = new Spotter($this->db);
677 842
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
678 843
 				    $Spotter->db = null;
679
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
844
+				    if ($globalDebugTimeElapsed) {
845
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
846
+				    }
680 847
 				}
681 848
 				//$putinarchive = true;
682 849
 				//$highlight = '';
683 850
 			    }
684 851
 			    
685
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
852
+		    } else {
853
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
854
+		    }
686 855
 		    //$dataFound = true;
687 856
 		}
688 857
 
@@ -695,19 +864,27 @@  discard block
 block discarded – undo
695 864
 				}
696 865
 			}
697 866
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
698
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
867
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
868
+				$this->all_flights[$id]['putinarchive'] = true;
869
+			}
699 870
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
700 871
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
701 872
 			//$dataFound = true;
702 873
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
703 874
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
704 875
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
705
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
876
+				if ($globalDebug) {
877
+					echo '--- Reset because of altitude'."\n";
878
+				}
706 879
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
707 880
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
708
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
709
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
710
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
881
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
882
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
883
+				} elseif (isset($line['id'])) {
884
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
885
+				} elseif (isset($this->all_flights[$id]['ident'])) {
886
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
887
+				}
711 888
 			}
712 889
 		    }
713 890
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -718,22 +895,32 @@  discard block
 block discarded – undo
718 895
 		}
719 896
 		
720 897
 		if (isset($line['heading']) && $line['heading'] != '') {
721
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
898
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
899
+		    	$this->all_flights[$id]['putinarchive'] = true;
900
+		    }
722 901
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
723 902
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
724 903
 		    //$dataFound = true;
725 904
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
726 905
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
727 906
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
728
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
729
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
907
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
908
+		    	$this->all_flights[$id]['putinarchive'] = true;
909
+		    }
910
+  		    if ($globalDebug) {
911
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
912
+  		    }
730 913
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
731 914
   		    // If not enough messages and ACARS set heading to 0
732 915
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
733 916
   		}
734
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
735
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
736
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
917
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
918
+			$dataFound = false;
919
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
920
+			$dataFound = false;
921
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) {
922
+			$dataFound = false;
923
+		}
737 924
 
738 925
 //		print_r($this->all_flights[$id]);
739 926
 		//gets the callsign from the last hour
@@ -750,23 +937,38 @@  discard block
 block discarded – undo
750 937
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
751 938
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
752 939
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
753
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
940
+				    if ($globalDebug) {
941
+				    	echo "Check if aircraft is already in DB...";
942
+				    }
754 943
 				    $timeelapsed = microtime(true);
755 944
 				    $SpotterLive = new SpotterLive($this->db);
756 945
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
757 946
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
758
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
947
+					if ($globalDebugTimeElapsed) {
948
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
949
+					}
759 950
 				    } elseif (isset($line['id'])) {
760 951
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
761
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
952
+					if ($globalDebugTimeElapsed) {
953
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
954
+					}
762 955
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
763 956
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
764
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
765
-				    } else $recent_ident = '';
957
+					if ($globalDebugTimeElapsed) {
958
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
959
+					}
960
+				    } else {
961
+				    	$recent_ident = '';
962
+				    }
766 963
 				    $SpotterLive->db=null;
767
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
768
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
769
-				} else $recent_ident = '';
964
+				    if ($globalDebug && $recent_ident == '') {
965
+				    	echo " Not in DB.\n";
966
+				    } elseif ($globalDebug && $recent_ident != '') {
967
+				    	echo " Already in DB.\n";
968
+				    }
969
+				} else {
970
+					$recent_ident = '';
971
+				}
770 972
 			    } else {
771 973
 				$recent_ident = '';
772 974
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -774,7 +976,9 @@  discard block
 block discarded – undo
774 976
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
775 977
 			    if($recent_ident == "")
776 978
 			    {
777
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
979
+				if ($globalDebug) {
980
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
981
+				}
778 982
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
779 983
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
780 984
 				//adds the spotter data for the archive
@@ -818,31 +1022,49 @@  discard block
 block discarded – undo
818 1022
 				
819 1023
 				if (!$ignoreImport) {
820 1024
 				    $highlight = '';
821
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
822
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
823
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
824
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1025
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1026
+				    	$highlight = 'Squawk 7500 : Hijack';
1027
+				    }
1028
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1029
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1030
+				    }
1031
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1032
+				    	$highlight = 'Squawk 7700 : Emergency';
1033
+				    }
1034
+				    if (!isset($this->all_flights[$id]['id'])) {
1035
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1036
+				    }
825 1037
 				    $timeelapsed = microtime(true);
826 1038
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
827 1039
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
828 1040
 					    $Spotter = new Spotter($this->db);
829 1041
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
830 1042
 					    $Spotter->db = null;
831
-					    if ($globalDebug && isset($result)) echo $result."\n";
1043
+					    if ($globalDebug && isset($result)) {
1044
+					    	echo $result."\n";
1045
+					    }
832 1046
 					}
833 1047
 				    }
834
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1048
+				    if ($globalDebugTimeElapsed) {
1049
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1050
+				    }
835 1051
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
836 1052
 
837 1053
 				    // Add source stat in DB
838 1054
 				    $Stats = new Stats($this->db);
839 1055
 				    if (!empty($this->stats)) {
840
-					if ($globalDebug) echo 'Add source stats : ';
1056
+					if ($globalDebug) {
1057
+						echo 'Add source stats : ';
1058
+					}
841 1059
 				        foreach($this->stats as $date => $data) {
842 1060
 					    foreach($data as $source => $sourced) {
843 1061
 					        //print_r($sourced);
844
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
845
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1062
+				    	        if (isset($sourced['polar'])) {
1063
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1064
+				    	        }
1065
+				    	        if (isset($sourced['hist'])) {
1066
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1067
+				    	        }
846 1068
 				    		if (isset($sourced['msg'])) {
847 1069
 				    		    if (time() - $sourced['msg']['date'] > 10) {
848 1070
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -855,13 +1077,17 @@  discard block
 block discarded – undo
855 1077
 			    			unset($this->stats[$date]);
856 1078
 			    		    }
857 1079
 				    	}
858
-				    	if ($globalDebug) echo 'Done'."\n";
1080
+				    	if ($globalDebug) {
1081
+				    		echo 'Done'."\n";
1082
+				    	}
859 1083
 
860 1084
 				    }
861 1085
 				    $Stats->db = null;
862 1086
 				    }
863 1087
 				    $this->del();
864
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1088
+				} elseif ($globalDebug) {
1089
+					echo 'Ignore data'."\n";
1090
+				}
865 1091
 				//$ignoreImport = false;
866 1092
 				$this->all_flights[$id]['addedSpotter'] = 1;
867 1093
 				//print_r($this->all_flights[$id]);
@@ -878,7 +1104,9 @@  discard block
 block discarded – undo
878 1104
 			*/
879 1105
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
880 1106
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
881
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1107
+				    if ($globalDebug) {
1108
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1109
+				    }
882 1110
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
883 1111
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
884 1112
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -887,7 +1115,9 @@  discard block
 block discarded – undo
887 1115
 					    $SpotterLive->db=null;
888 1116
 					}
889 1117
 				    }
890
-				    if ($globalDebug) echo " Done\n";
1118
+				    if ($globalDebug) {
1119
+				    	echo " Done\n";
1120
+				    }
891 1121
 				    $this->last_delete = time();
892 1122
 				}
893 1123
 			    } else {
@@ -914,11 +1144,17 @@  discard block
 block discarded – undo
914 1144
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
915 1145
 		    if ($globalDebug) {
916 1146
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
917
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
918
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1147
+				if (isset($this->all_flights[$id]['source_name'])) {
1148
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1149
+				} else {
1150
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1151
+				}
919 1152
 			} else {
920
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
921
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1153
+				if (isset($this->all_flights[$id]['source_name'])) {
1154
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1155
+				} else {
1156
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1157
+				}
922 1158
 			}
923 1159
 		    }
924 1160
 		    $ignoreImport = false;
@@ -964,22 +1200,30 @@  discard block
 block discarded – undo
964 1200
 
965 1201
 		    if (!$ignoreImport) {
966 1202
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
967
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1203
+				if (!isset($this->all_flights[$id]['id'])) {
1204
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1205
+				}
968 1206
 				$timeelapsed = microtime(true);
969 1207
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
970 1208
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
971
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1209
+					if ($globalDebug) {
1210
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1211
+					}
972 1212
 					$SpotterLive = new SpotterLive($this->db);
973 1213
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
974 1214
 					$SpotterLive->db = null;
975
-					if ($globalDebug) echo $result."\n";
1215
+					if ($globalDebug) {
1216
+						echo $result."\n";
1217
+					}
976 1218
 				    }
977 1219
 				}
978 1220
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
979 1221
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
980 1222
 				}
981 1223
 				$this->all_flights[$id]['putinarchive'] = false;
982
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1224
+				if ($globalDebugTimeElapsed) {
1225
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1226
+				}
983 1227
 
984 1228
 				// Put statistics in $this->stats variable
985 1229
 				//if ($line['format_source'] != 'aprs') {
@@ -987,7 +1231,9 @@  discard block
 block discarded – undo
987 1231
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
988 1232
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
989 1233
 					$source = $this->all_flights[$id]['source_name'];
990
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1234
+					if ($source == '') {
1235
+						$source = $this->all_flights[$id]['format_source'];
1236
+					}
991 1237
 					if (!isset($this->source_location[$source])) {
992 1238
 						$Location = new Source($this->db);
993 1239
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1008,7 +1254,9 @@  discard block
 block discarded – undo
1008 1254
 					$stats_heading = round($stats_heading/22.5);
1009 1255
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1010 1256
 					$current_date = date('Y-m-d');
1011
-					if ($stats_heading == 16) $stats_heading = 0;
1257
+					if ($stats_heading == 16) {
1258
+						$stats_heading = 0;
1259
+					}
1012 1260
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1013 1261
 						for ($i=0;$i<=15;$i++) {
1014 1262
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1026,7 +1274,9 @@  discard block
 block discarded – undo
1026 1274
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1027 1275
 						    end($this->stats[$current_date][$source]['hist']);
1028 1276
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1029
-						} else $mini = 0;
1277
+						} else {
1278
+							$mini = 0;
1279
+						}
1030 1280
 						for ($i=$mini;$i<=$distance;$i+=10) {
1031 1281
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1032 1282
 						}
@@ -1038,19 +1288,27 @@  discard block
 block discarded – undo
1038 1288
 				}
1039 1289
 
1040 1290
 				$this->all_flights[$id]['lastupdate'] = time();
1041
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1291
+				if ($this->all_flights[$id]['putinarchive']) {
1292
+					$send = true;
1293
+				}
1042 1294
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1043
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1295
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1296
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1297
+			}
1044 1298
 			//$this->del();
1045 1299
 			
1046 1300
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1047 1301
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1048
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1302
+				if ($globalDebug) {
1303
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1304
+				}
1049 1305
 				$SpotterLive = new SpotterLive($this->db);
1050 1306
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1051 1307
 				$SpotterLive->db = null;
1052 1308
 				//SpotterLive->deleteLiveSpotterData();
1053
-				if ($globalDebug) echo " Done\n";
1309
+				if ($globalDebug) {
1310
+					echo " Done\n";
1311
+				}
1054 1312
 				$this->last_delete_hourly = time();
1055 1313
 			    } else {
1056 1314
 				$this->del();
@@ -1062,7 +1320,9 @@  discard block
 block discarded – undo
1062 1320
 		    //$ignoreImport = false;
1063 1321
 		}
1064 1322
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1065
-		if ($send) return $this->all_flights[$id];
1323
+		if ($send) {
1324
+			return $this->all_flights[$id];
1325
+		}
1066 1326
 	    }
1067 1327
 	}
1068 1328
     }
Please login to merge, or discard this patch.
require/class.Scheduler.php 1 patch
Braces   +180 added lines, -62 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection.');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection.');
29
+		}
28 30
 	}
29 31
 
30 32
 	/**
@@ -139,7 +141,9 @@  discard block
 block discarded – undo
139 141
 		$sth->closeCursor();
140 142
 		if (count($row) > 0) {
141 143
 			return $row;
142
-		} else return array();
144
+		} else {
145
+			return array();
146
+		}
143 147
 	}
144 148
 
145 149
 	/*
@@ -180,7 +184,9 @@  discard block
 block discarded – undo
180 184
 		$Common = new Common();
181 185
 		$check_date = new Datetime($date);
182 186
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
183
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
187
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
188
+			return array();
189
+		}
184 190
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
185 191
 		$json = $Common->getData($url);
186 192
 		var_dump($json);
@@ -207,7 +213,9 @@  discard block
 block discarded – undo
207 213
 			*/
208 214
 		
209 215
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
210
-		} else return array();
216
+		} else {
217
+			return array();
218
+		}
211 219
 	}
212 220
 
213 221
 	/**
@@ -222,7 +230,9 @@  discard block
 block discarded – undo
222 230
 		date_default_timezone_set($globalTimezone);
223 231
 		$check_date = new Datetime($date);
224 232
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
225
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
233
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
234
+			return array();
235
+		}
226 236
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
227 237
 		$json = $Common->getData($url);
228 238
 		$parsed_json = json_decode($json);
@@ -235,7 +245,9 @@  discard block
 block discarded – undo
235 245
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
236 246
 
237 247
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
238
-		} else return array();
248
+		} else {
249
+			return array();
250
+		}
239 251
 	}
240 252
 
241 253
 	/**
@@ -246,7 +258,9 @@  discard block
 block discarded – undo
246 258
 	private function getRyanair($callsign) {
247 259
 		$Common = new Common();
248 260
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
249
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
261
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
262
+			return array();
263
+		}
250 264
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
251 265
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
252 266
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -260,8 +274,12 @@  discard block
 block discarded – undo
260 274
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
261 275
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
262 276
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
263
-			} else return array();
264
-		} else return array();
277
+			} else {
278
+				return array();
279
+			}
280
+		} else {
281
+			return array();
282
+		}
265 283
 	}
266 284
 
267 285
 	/**
@@ -272,7 +290,9 @@  discard block
 block discarded – undo
272 290
 	private function getSwiss($callsign) {
273 291
 		$Common = new Common();
274 292
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
275
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
293
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
294
+			return array();
295
+		}
276 296
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
277 297
 		$json = $Common->getData($url);
278 298
 		$parsed_json = json_decode($json);
@@ -292,8 +312,12 @@  discard block
 block discarded – undo
292 312
 			}
293 313
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
294 314
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
295
-			} else return array();
296
-		} else return array();
315
+			} else {
316
+				return array();
317
+			}
318
+		} else {
319
+			return array();
320
+		}
297 321
 	}
298 322
 	
299 323
 	/**
@@ -307,12 +331,18 @@  discard block
 block discarded – undo
307 331
 		$Common = new Common();
308 332
 		$check_date = new Datetime($date);
309 333
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
310
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
311
-		if ($globalBritishAirwaysKey == '') return array();
334
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
335
+			return array();
336
+		}
337
+		if ($globalBritishAirwaysKey == '') {
338
+			return array();
339
+		}
312 340
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
313 341
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
314 342
 		$json = $Common->getData($url,'get','',$headers);
315
-		if ($json == '') return array();
343
+		if ($json == '') {
344
+			return array();
345
+		}
316 346
 		$parsed_json = json_decode($json);
317 347
 		$flights = $parsed_json->{'FlightsResponse'};
318 348
 		if (count($flights) > 0) {
@@ -321,7 +351,9 @@  discard block
 block discarded – undo
321 351
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
322 352
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
323 353
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
324
-		} else return array();
354
+		} else {
355
+			return array();
356
+		}
325 357
 	}
326 358
 
327 359
 	/**
@@ -335,19 +367,27 @@  discard block
 block discarded – undo
335 367
 		$Common = new Common();
336 368
 		$check_date = new Datetime($date);
337 369
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
338
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
339
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
370
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
371
+			return array();
372
+		}
373
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
374
+			return array();
375
+		}
340 376
 		$url = "https://api.lufthansa.com/v1/oauth/token";
341 377
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
342 378
 		$data = $Common->getData($url,'post',$post);
343 379
 		$parsed_data = json_decode($data);
344
-		if (!isset($parsed_data->{'access_token'})) return array();
380
+		if (!isset($parsed_data->{'access_token'})) {
381
+			return array();
382
+		}
345 383
 		$token = $parsed_data->{'access_token'};
346 384
 		
347 385
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
348 386
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
349 387
 		$json = $Common->getData($url,'get','',$headers);
350
-		if ($json == '') return array();
388
+		if ($json == '') {
389
+			return array();
390
+		}
351 391
 		$parsed_json = json_decode($json);
352 392
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
353 393
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -355,7 +395,9 @@  discard block
 block discarded – undo
355 395
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
356 396
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357 397
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
358
-		} else return array();
398
+		} else {
399
+			return array();
400
+		}
359 401
 	}
360 402
 
361 403
 	/**
@@ -369,14 +411,20 @@  discard block
 block discarded – undo
369 411
 		$Common = new Common();
370 412
 		$check_date = new Datetime($date);
371 413
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
372
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
373
-		if ($globalTransaviaKey == '') return array();
414
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
415
+			return array();
416
+		}
417
+		if ($globalTransaviaKey == '') {
418
+			return array();
419
+		}
374 420
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
375 421
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
376 422
 		$headers = array('apikey: '.$globalTransaviaKey);
377 423
 		$json = $Common->getData($url,'get','',$headers);
378 424
 		//echo 'result : '.$json;
379
-		if ($json == '') return array();
425
+		if ($json == '') {
426
+			return array();
427
+		}
380 428
 		$parsed_json = json_decode($json);
381 429
 		
382 430
 		if (isset($parsed_json->{'data'}[0])) {
@@ -385,7 +433,9 @@  discard block
 block discarded – undo
385 433
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
386 434
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
387 435
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
388
-		} else return array();
436
+		} else {
437
+			return array();
438
+		}
389 439
 	}
390 440
 
391 441
 	/**
@@ -396,7 +446,9 @@  discard block
 block discarded – undo
396 446
 	public function getTunisair($callsign) {
397 447
 		$Common = new Common();
398 448
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
399
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
449
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
450
+			return array();
451
+		}
400 452
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
401 453
 		$data = $Common->getData($url);
402 454
 		$table = $Common->table2array($data);
@@ -417,7 +469,9 @@  discard block
 block discarded – undo
417 469
 		$Common = new Common();
418 470
 		$check_date = new Datetime($date);
419 471
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
420
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
472
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
473
+			return array();
474
+		}
421 475
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
422 476
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
423 477
 		$data = $Common->getData($url);
@@ -427,8 +481,11 @@  discard block
 block discarded – undo
427 481
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
428 482
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
429 483
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
430
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
431
-			else return array();
484
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
485
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
486
+			} else {
487
+				return array();
488
+			}
432 489
 		}
433 490
 		return array();
434 491
 	}
@@ -443,7 +500,9 @@  discard block
 block discarded – undo
443 500
 		$Common = new Common();
444 501
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
445 502
 		$check_date = new Datetime($date);
446
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
503
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
504
+			return array();
505
+		}
447 506
 		$url = "https://www.iberia.com/web/flightDetail.do";
448 507
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
449 508
 		$data = $Common->getData($url,'post',$post);
@@ -460,7 +519,9 @@  discard block
 block discarded – undo
460 519
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
461 520
 				if ($arrivalTime == 'Hora estimada de llegada') {
462 521
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
463
-				} else $arrivalTime = substr($arrivalTime,0,5);
522
+				} else {
523
+					$arrivalTime = substr($arrivalTime,0,5);
524
+				}
464 525
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
465 526
 			}
466 527
 		}
@@ -478,7 +539,9 @@  discard block
 block discarded – undo
478 539
 		$Common = new Common();
479 540
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
480 541
 		$check_date = new Datetime($date);
481
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
542
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
543
+			return array();
544
+		}
482 545
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
483 546
 		$data = $Common->getData($url);
484 547
 		if ($data != '') {
@@ -494,7 +557,9 @@  discard block
 block discarded – undo
494 557
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
495 558
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
496 559
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
497
-				} else return array();
560
+				} else {
561
+					return array();
562
+				}
498 563
 			}
499 564
 			
500 565
 
@@ -514,7 +579,9 @@  discard block
 block discarded – undo
514 579
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
515 580
 		$check_date = new Datetime($date);
516 581
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
517
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
582
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
583
+			return array();
584
+		}
518 585
 		$data = $Common->getData($url);
519 586
 		if ($data != '') {
520 587
 			$table = $Common->text2array($data);
@@ -538,7 +605,9 @@  discard block
 block discarded – undo
538 605
 		$check_date = new Datetime($date);
539 606
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
540 607
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
541
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
608
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
609
+			return array();
610
+		}
542 611
 		$data = $Common->getData($url);
543 612
 		if ($data != '') {
544 613
 		    //echo $data;
@@ -628,7 +697,9 @@  discard block
 block discarded – undo
628 697
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
629 698
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
630 699
 		//$check_date = new Datetime($date);
631
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
700
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
701
+			return array();
702
+		}
632 703
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
633 704
 		$data = $Common->getData($url,'post',$post);
634 705
 		if ($data != '') {
@@ -660,11 +731,15 @@  discard block
 block discarded – undo
660 731
 				$airline_icao = substr($callsign, 0, 3);
661 732
 			} 
662 733
 		}
663
-		if ($airline_icao == '') return array();
734
+		if ($airline_icao == '') {
735
+			return array();
736
+		}
664 737
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
665 738
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
666 739
 		//$check_date = new Datetime($date);
667
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
740
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
741
+			return array();
742
+		}
668 743
 		$data = $Common->getData($url);
669 744
 		if ($data != '') {
670 745
 			$table = $Common->table2array($data);
@@ -757,10 +832,16 @@  discard block
 block discarded – undo
757 832
 		if ($data != '') {
758 833
 			$table = $Common->table2array($data);
759 834
 			if (isset($table[11][1])) {
760
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
761
-				else $departureTime = '';
762
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
763
-				else $arrivalTime = '';
835
+				if (is_numeric(substr($table[11][1],0,1))) {
836
+					$departureTime = substr($table[11][1],0,5);
837
+				} else {
838
+					$departureTime = '';
839
+				}
840
+				if (is_numeric(substr($table[17][1],0,1))) {
841
+					$arrivalTime = substr($table[17][1],0,5);
842
+				} else {
843
+					$arrivalTime = '';
844
+				}
764 845
 				$DepartureAirportIata = substr($table[13][1],0,3);
765 846
 				$ArrivalAirportIata = substr($table[15][1],0,3);
766 847
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
@@ -777,16 +858,22 @@  discard block
 block discarded – undo
777 858
 	*/
778 859
 	private function getAirCanada($callsign,$date = 'NOW') {
779 860
 		$Common = new Common();
780
-		if (class_exists("DomDocument") === FALSE) return array();
861
+		if (class_exists("DomDocument") === FALSE) {
862
+			return array();
863
+		}
781 864
 		date_default_timezone_set('UTC');
782 865
 		$check_date = new Datetime($date);
783 866
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
784 867
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
785
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
868
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
869
+			return array();
870
+		}
786 871
 		$data = $Common->getData($url);
787 872
 		$dom = new DomDocument();
788 873
 		$dom->loadXML($data);
789
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
874
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
875
+			return array();
876
+		}
790 877
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
791 878
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
792 879
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -795,7 +882,9 @@  discard block
 block discarded – undo
795 882
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
796 883
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
797 884
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
798
-		} else return array();
885
+		} else {
886
+			return array();
887
+		}
799 888
 	}
800 889
 
801 890
 	/**
@@ -809,7 +898,9 @@  discard block
 block discarded – undo
809 898
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
810 899
 		$check_date = new Datetime($date);
811 900
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
812
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
901
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
902
+			return array();
903
+		}
813 904
 		$data = $Common->getData($url);
814 905
 		if ($data != '') {
815 906
 			$table = $Common->table2array($data);
@@ -838,7 +929,9 @@  discard block
 block discarded – undo
838 929
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
839 930
 		$check_date = new Datetime($date);
840 931
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
841
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
932
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
933
+			return array();
934
+		}
842 935
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
843 936
 		$data = $Common->getData($url,'post',$post);
844 937
 		//echo $data;
@@ -848,11 +941,19 @@  discard block
 block discarded – undo
848 941
 		if ($data != '') {
849 942
 			$table = $Common->table2array($data);
850 943
 			$flight = $table;
851
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
852
-			else $departureTime = '';
853
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
854
-			else $departureAirport = '';
855
-		} else return array();
944
+			if (isset($flight[5][4])) {
945
+				$departureTime = $flight[5][4];
946
+			} else {
947
+				$departureTime = '';
948
+			}
949
+			if (isset($flight[5][2])) {
950
+				$departureAirport = $flight[5][2];
951
+			} else {
952
+				$departureAirport = '';
953
+			}
954
+		} else {
955
+			return array();
956
+		}
856 957
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
857 958
 		$data = $Common->getData($url,'post',$post);
858 959
 		if ($data != '') {
@@ -865,10 +966,14 @@  discard block
 block discarded – undo
865 966
 			    $arrivalTime = '';
866 967
 			    $arrivalAirport = '';
867 968
 			}
868
-		} else return array();
969
+		} else {
970
+			return array();
971
+		}
869 972
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
870 973
 		$json = $Common->getData($url);
871
-		if ($json == '') return array();
974
+		if ($json == '') {
975
+			return array();
976
+		}
872 977
 		$parsed_json = json_decode($json);
873 978
 		$airports = $parsed_json->{'suggestList'};
874 979
 		if (count($airports) > 0) {
@@ -883,7 +988,9 @@  discard block
 block discarded – undo
883 988
 		}
884 989
 		if (isset($DepartureAirportIata)) {
885 990
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
886
-		} else return array();
991
+		} else {
992
+			return array();
993
+		}
887 994
 	}
888 995
 
889 996
 	/*
@@ -895,7 +1002,9 @@  discard block
 block discarded – undo
895 1002
 	public function fetchSchedule($ident,$date = 'NOW') {
896 1003
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
897 1004
 		//$Common = new Common();
898
-		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
1005
+		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) {
1006
+			return array();
1007
+		}
899 1008
 		$airline_icao = '';
900 1009
 		if (!is_numeric(substr($ident, 0, 3)))
901 1010
 		{
@@ -1130,18 +1239,27 @@  discard block
 block discarded – undo
1130 1239
 					if (strlen($airline_icao) == 3) {
1131 1240
 						$Spotter = new Spotter($this->db);
1132 1241
 						$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
1133
-						if (isset($airline_info[0]['iata'])) $airline_icao = $airline_info[0]['iata'];
1242
+						if (isset($airline_info[0]['iata'])) {
1243
+							$airline_icao = $airline_info[0]['iata'];
1244
+						}
1134 1245
 					}
1135 1246
 					// Randomly use a generic function to get hours
1136 1247
 					if (strlen($airline_icao) == 2) {
1137
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1248
+						if (!isset($globalSchedulesSources)) {
1249
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1250
+						}
1138 1251
 						if (count($globalSchedulesSources) > 0) {
1139 1252
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1140 1253
 							$source = $globalSchedulesSources[$rand];
1141
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1142
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1254
+							if ($source == 'flightmapper') {
1255
+								return $this->getFlightMapper($ident);
1256
+							} elseif ($source == 'costtotravel') {
1257
+								return $this->getCostToTravel($ident);
1258
+							}
1143 1259
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1144
-							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') return $this->getFlightAware($ident);
1260
+							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') {
1261
+								return $this->getFlightAware($ident);
1262
+							}
1145 1263
 						}
1146 1264
 					}
1147 1265
 			}
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +321 added lines, -130 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 $tracker = false;
13 13
 $marine = false;
14 14
 $usecoord = false;
15
-if (isset($_GET['test'])) exit();
15
+if (isset($_GET['test'])) {
16
+	exit();
17
+}
16 18
 if (isset($_GET['tracker'])) {
17 19
     $tracker = true;
18 20
 }
@@ -57,28 +59,55 @@  discard block
 block discarded – undo
57 59
 }
58 60
 header('Content-Type: text/javascript');
59 61
 
60
-if (!isset($globalJsonCompress)) $compress = true;
61
-else $compress = $globalJsonCompress;
62
+if (!isset($globalJsonCompress)) {
63
+	$compress = true;
64
+} else {
65
+	$compress = $globalJsonCompress;
66
+}
62 67
 
63 68
 $from_archive = false;
64 69
 $min = true;
65 70
 $allhistory = false;
66 71
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
74
+}
75
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
76
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
77
+}
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
80
+}
81
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
83
+}
84
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
85
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
86
+}
87
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
88
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
89
+}
90
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
91
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
92
+}
93
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
94
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
97
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
100
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
101
+}
102
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
103
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
104
+}
78 105
 
79 106
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
80 107
 	$min = true;
81
-} else $min = false;
108
+} else {
109
+	$min = false;
110
+}
82 111
 
83 112
 $spotter_array = array();
84 113
 
@@ -189,24 +218,38 @@  discard block
 block discarded – undo
189 218
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
190 219
 		}
191 220
 	}
192
-	if ($flightcnt == '') $flightcnt = 0;
193
-} else $flightcnt = 0;
221
+	if ($flightcnt == '') {
222
+		$flightcnt = 0;
223
+	}
224
+	} else {
225
+	$flightcnt = 0;
226
+}
194 227
 
195 228
 $sqltime = round(microtime(true)-$begintime,2);
196 229
 
197 230
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
198
-if ($currenttime != '') $currenttime = round($currenttime/1000);
231
+if ($currenttime != '') {
232
+	$currenttime = round($currenttime/1000);
233
+}
199 234
 
200
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
201
-else $usenextlatlon = true;
202
-if ($usenextlatlon === false) $currenttime = '';
235
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
236
+	$usenextlatlon = false;
237
+} else {
238
+	$usenextlatlon = true;
239
+}
240
+if ($usenextlatlon === false) {
241
+	$currenttime = '';
242
+}
203 243
 $j = 0;
204 244
 $prev_flightaware_id = '';
205 245
 $aircrafts_shadow = array();
206 246
 $output = '{';
207 247
 	$output .= '"type": "FeatureCollection",';
208
-		if ($min) $output .= '"minimal": "true",';
209
-		else $output .= '"minimal": "false",';
248
+		if ($min) {
249
+			$output .= '"minimal": "true",';
250
+		} else {
251
+			$output .= '"minimal": "false",';
252
+		}
210 253
 		//$output .= '"fc": "'.$flightcnt.'",';
211 254
 		$output .= '"sqt": "'.$sqltime.'",';
212 255
 
@@ -251,18 +294,29 @@  discard block
 block discarded – undo
251 294
 						}
252 295
 						$output .= '"properties": {';
253 296
 						if (isset($spotter_item['flightaware_id'])) {
254
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
255
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
297
+							if ($compress) {
298
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
299
+							} else {
300
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
301
+							}
256 302
 						} elseif (isset($spotter_item['famtrackid'])) {
257
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
258
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
303
+							if ($compress) {
304
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
305
+							} else {
306
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
307
+							}
259 308
 						} elseif (isset($spotter_item['fammarine_id'])) {
260
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
261
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
309
+							if ($compress) {
310
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
311
+							} else {
312
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
313
+							}
262 314
 						}
263 315
 							$output .= '"fc": "'.$flightcnt.'",';
264 316
 							$output .= '"sqt": "'.$sqltime.'",';
265
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
317
+							if (isset($begindate)) {
318
+								$output .= '"archive_date": "'.$begindate.'",';
319
+							}
266 320
 
267 321
 /*
268 322
 							if ($min) $output .= '"minimal": "true",';
@@ -270,14 +324,22 @@  discard block
 block discarded – undo
270 324
 */
271 325
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
272 326
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
273
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
274
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
327
+							if ($compress) {
328
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
329
+							} else {
330
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
331
+							}
275 332
 							//"
276 333
 						} else {
277
-							if ($compress) $output .= '"c": "NA",';
278
-							else $output .= '"callsign": "NA",';
334
+							if ($compress) {
335
+								$output .= '"c": "NA",';
336
+							} else {
337
+								$output .= '"callsign": "NA",';
338
+							}
339
+						}
340
+						if (isset($spotter_item['registration'])) {
341
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
279 342
 						}
280
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
281 343
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
282 344
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
283 345
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -290,16 +352,23 @@  discard block
 block discarded – undo
290 352
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
291 353
 						}
292 354
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
293
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
294
-							else {
355
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
356
+								$spotter_item['aircraft_shadow'] = '';
357
+							} else {
295 358
 								$aircraft_icao = $spotter_item['aircraft_icao'];
296
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
297
-								else {
359
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
360
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
361
+								} else {
298 362
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
299
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
300
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
301
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
302
-									else $spotter_item['aircraft_shadow'] = '';
363
+									if (count($aircraft_info) > 0) {
364
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
365
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
366
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
367
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
368
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
369
+									} else {
370
+										$spotter_item['aircraft_shadow'] = '';
371
+									}
303 372
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
304 373
 								}
305 374
 							}
@@ -307,73 +376,139 @@  discard block
 block discarded – undo
307 376
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
308 377
 							if ($tracker) {
309 378
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
310
-									if ($compress) $output .= '"as": "ambulance.png",';
311
-									else $output .= '"aircraft_shadow": "ambulance.png",';
379
+									if ($compress) {
380
+										$output .= '"as": "ambulance.png",';
381
+									} else {
382
+										$output .= '"aircraft_shadow": "ambulance.png",';
383
+									}
312 384
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
313
-									if ($compress) $output .= '"as": "police.png",';
314
-									else $output .= '"aircraft_shadow": "police.png",';
385
+									if ($compress) {
386
+										$output .= '"as": "police.png",';
387
+									} else {
388
+										$output .= '"aircraft_shadow": "police.png",';
389
+									}
315 390
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
316
-									if ($compress) $output .= '"as": "ship.png",';
317
-									else $output .= '"aircraft_shadow": "ship.png",';
391
+									if ($compress) {
392
+										$output .= '"as": "ship.png",';
393
+									} else {
394
+										$output .= '"aircraft_shadow": "ship.png",';
395
+									}
318 396
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
319
-									if ($compress) $output .= '"as": "ship.png",';
320
-									else $output .= '"aircraft_shadow": "ship.png",';
397
+									if ($compress) {
398
+										$output .= '"as": "ship.png",';
399
+									} else {
400
+										$output .= '"aircraft_shadow": "ship.png",';
401
+									}
321 402
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
322
-									if ($compress) $output .= '"as": "ship.png",';
323
-									else $output .= '"aircraft_shadow": "ship.png",';
403
+									if ($compress) {
404
+										$output .= '"as": "ship.png",';
405
+									} else {
406
+										$output .= '"aircraft_shadow": "ship.png",';
407
+									}
324 408
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
325
-									if ($compress) $output .= '"as": "truck.png",';
326
-									else $output .= '"aircraft_shadow": "truck.png",';
409
+									if ($compress) {
410
+										$output .= '"as": "truck.png",';
411
+									} else {
412
+										$output .= '"aircraft_shadow": "truck.png",';
413
+									}
327 414
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
328
-									if ($compress) $output .= '"as": "truck.png",';
329
-									else $output .= '"aircraft_shadow": "truck.png",';
415
+									if ($compress) {
416
+										$output .= '"as": "truck.png",';
417
+									} else {
418
+										$output .= '"aircraft_shadow": "truck.png",';
419
+									}
330 420
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
331
-									if ($compress) $output .= '"as": "aircraft.png",';
332
-									else $output .= '"aircraft_shadow": "aircraft.png",';
421
+									if ($compress) {
422
+										$output .= '"as": "aircraft.png",';
423
+									} else {
424
+										$output .= '"aircraft_shadow": "aircraft.png",';
425
+									}
333 426
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
334
-									if ($compress) $output .= '"as": "aircraft.png",';
335
-									else $output .= '"aircraft_shadow": "aircraft.png",';
427
+									if ($compress) {
428
+										$output .= '"as": "aircraft.png",';
429
+									} else {
430
+										$output .= '"aircraft_shadow": "aircraft.png",';
431
+									}
336 432
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
337
-									if ($compress) $output .= '"as": "helico.png",';
338
-									else $output .= '"aircraft_shadow": "helico.png",';
433
+									if ($compress) {
434
+										$output .= '"as": "helico.png",';
435
+									} else {
436
+										$output .= '"aircraft_shadow": "helico.png",';
437
+									}
339 438
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
340
-									if ($compress) $output .= '"as": "rail.png",';
341
-									else $output .= '"aircraft_shadow": "rail.png",';
439
+									if ($compress) {
440
+										$output .= '"as": "rail.png",';
441
+									} else {
442
+										$output .= '"aircraft_shadow": "rail.png",';
443
+									}
342 444
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
343
-									if ($compress) $output .= '"as": "firetruck.png",';
344
-									else $output .= '"aircraft_shadow": "firetruck.png",';
445
+									if ($compress) {
446
+										$output .= '"as": "firetruck.png",';
447
+									} else {
448
+										$output .= '"aircraft_shadow": "firetruck.png",';
449
+									}
345 450
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
346
-									if ($compress) $output .= '"as": "bus.png",';
347
-									else $output .= '"aircraft_shadow": "bus.png",';
451
+									if ($compress) {
452
+										$output .= '"as": "bus.png",';
453
+									} else {
454
+										$output .= '"aircraft_shadow": "bus.png",';
455
+									}
348 456
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
349
-									if ($compress) $output .= '"as": "phone.png",';
350
-									else $output .= '"aircraft_shadow": "phone.png",';
457
+									if ($compress) {
458
+										$output .= '"as": "phone.png",';
459
+									} else {
460
+										$output .= '"aircraft_shadow": "phone.png",';
461
+									}
351 462
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
352
-									if ($compress) $output .= '"as": "jogger.png",';
353
-									else $output .= '"aircraft_shadow": "jogger.png",';
463
+									if ($compress) {
464
+										$output .= '"as": "jogger.png",';
465
+									} else {
466
+										$output .= '"aircraft_shadow": "jogger.png",';
467
+									}
354 468
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
355
-									if ($compress) $output .= '"as": "bike.png",';
356
-									else $output .= '"aircraft_shadow": "bike.png",';
469
+									if ($compress) {
470
+										$output .= '"as": "bike.png",';
471
+									} else {
472
+										$output .= '"aircraft_shadow": "bike.png",';
473
+									}
357 474
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
358
-									if ($compress) $output .= '"as": "motorcycle.png",';
359
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
475
+									if ($compress) {
476
+										$output .= '"as": "motorcycle.png",';
477
+									} else {
478
+										$output .= '"aircraft_shadow": "motorcycle.png",';
479
+									}
360 480
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
361
-									if ($compress) $output .= '"as": "balloon.png",';
362
-									else $output .= '"aircraft_shadow": "balloon.png",';
481
+									if ($compress) {
482
+										$output .= '"as": "balloon.png",';
483
+									} else {
484
+										$output .= '"aircraft_shadow": "balloon.png",';
485
+									}
363 486
 								} else {
364
-									if ($compress) $output .= '"as": "car.png",';
365
-									else $output .= '"aircraft_shadow": "car.png",';
487
+									if ($compress) {
488
+										$output .= '"as": "car.png",';
489
+									} else {
490
+										$output .= '"aircraft_shadow": "car.png",';
491
+									}
366 492
 								}
367 493
 							} elseif ($marine) {
368
-								if ($compress) $output .= '"as": "ship.png",';
369
-								else $output .= '"aircraft_shadow": "ship.png",';
494
+								if ($compress) {
495
+									$output .= '"as": "ship.png",';
496
+								} else {
497
+									$output .= '"aircraft_shadow": "ship.png",';
498
+								}
370 499
 							} else {
371
-								if ($compress) $output .= '"as": "default.png",';
372
-								else $output .= '"aircraft_shadow": "default.png",';
500
+								if ($compress) {
501
+									$output .= '"as": "default.png",';
502
+								} else {
503
+									$output .= '"aircraft_shadow": "default.png",';
504
+								}
373 505
 							}
374 506
 						} else {
375
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
376
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
507
+							if ($compress) {
508
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
509
+							} else {
510
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
511
+							}
377 512
 						}
378 513
 						if (isset($spotter_item['airline_name'])) {
379 514
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -381,8 +516,11 @@  discard block
 block discarded – undo
381 516
 							$output .= '"airline_name": "NA",';
382 517
 						}
383 518
 						if (isset($spotter_item['departure_airport'])) {
384
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
385
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
519
+							if ($compress) {
520
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
521
+							} else {
522
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
523
+							}
386 524
 						}
387 525
 						if (isset($spotter_item['departure_airport_city'])) {
388 526
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -394,8 +532,11 @@  discard block
 block discarded – undo
394 532
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
395 533
 						}
396 534
 						if (isset($spotter_item['arrival_airport'])) {
397
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
398
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
535
+							if ($compress) {
536
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
537
+							} else {
538
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
539
+							}
399 540
 						}
400 541
 						if (isset($spotter_item['arrival_airport_city'])) {
401 542
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -414,8 +555,11 @@  discard block
 block discarded – undo
414 555
 						}
415 556
 						
416 557
 						if (isset($spotter_item['altitude'])) {
417
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
418
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
558
+							if ($compress) {
559
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
560
+							} else {
561
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
562
+							}
419 563
 						}
420 564
 						
421 565
 						$heading = $spotter_item['heading'];
@@ -439,19 +583,24 @@  discard block
 block discarded – undo
439 583
 							}
440 584
 						}
441 585
 						
442
-						if ($compress)$output .= '"h": "'.$heading.'",';
443
-						else $output .= '"heading": "'.$heading.'",';
586
+						if ($compress) {
587
+							$output .= '"h": "'.$heading.'",';
588
+						} else {
589
+							$output .= '"heading": "'.$heading.'",';
590
+						}
444 591
 						if ($currenttime != '') {
445 592
 							if (strtotime($spotter_item['date']) < $currenttime) {
446 593
 								if (isset($archivespeed)) {
447 594
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
448 595
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
449
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
450
-									else {
596
+									if (!isset($idistance) || $fdistance < $idistance) {
597
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
598
+									} else {
451 599
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
452 600
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
453
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
454
-										else {
601
+										if (!isset($idistance) || $fdistance < $idistance) {
602
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
603
+										} else {
455 604
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
456 605
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
457 606
 										}
@@ -459,12 +608,14 @@  discard block
 block discarded – undo
459 608
 								} elseif ($usenextlatlon) {
460 609
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
461 610
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
462
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
463
-									else {
611
+									if (!isset($idistance) || $fdistance < $idistance) {
612
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
613
+									} else {
464 614
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
465 615
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
466
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
467
-										else {
616
+										if (!isset($idistance) || $fdistance < $idistance) {
617
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
618
+										} else {
468 619
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
469 620
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
470 621
 										}
@@ -503,7 +654,9 @@  discard block
 block discarded – undo
503 654
 							}
504 655
 						}
505 656
 
506
-						if (!$min) $output .= '"image": "'.$image.'",';
657
+						if (!$min) {
658
+							$output .= '"image": "'.$image.'",';
659
+						}
507 660
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
508 661
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
509 662
 						}
@@ -511,8 +664,11 @@  discard block
 block discarded – undo
511 664
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
512 665
 						}
513 666
 						if (isset($spotter_item['squawk'])) {
514
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
515
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
667
+							if ($compress) {
668
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
669
+							} else {
670
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
671
+							}
516 672
 						}
517 673
 						if (isset($spotter_item['squawk_usage'])) {
518 674
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -531,14 +687,23 @@  discard block
 block discarded – undo
531 687
 						}
532 688
 						// type when not aircraft ?
533 689
 						if (isset($spotter_item['type'])) {
534
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
535
-							else $output .= '"type": "'.$spotter_item['type'].'"';
690
+							if ($compress) {
691
+								$output .= '"t": "'.$spotter_item['type'].'"';
692
+							} else {
693
+								$output .= '"type": "'.$spotter_item['type'].'"';
694
+							}
536 695
 						} elseif ($marine) {
537
-							if ($compress) $output .= '"t": "ship"';
538
-							else $output .= '"type": "ship"';
696
+							if ($compress) {
697
+								$output .= '"t": "ship"';
698
+							} else {
699
+								$output .= '"type": "ship"';
700
+							}
539 701
 						} else {
540
-							if ($compress) $output .= '"t": "aircraft"';
541
-							else $output .= '"type": "aircraft"';
702
+							if ($compress) {
703
+								$output .= '"t": "aircraft"';
704
+							} else {
705
+								$output .= '"type": "aircraft"';
706
+							}
542 707
 						}
543 708
 						$output .= '},';
544 709
 						$output .= '"geometry": {';
@@ -546,15 +711,19 @@  discard block
 block discarded – undo
546 711
 								$output .= '"coordinates": [';
547 712
 								if ($currenttime != '') {
548 713
 									if (strtotime($spotter_item['date']) < $currenttime) {
549
-										if (!isset($archivespeed)) $archivespeed = 1;
714
+										if (!isset($archivespeed)) {
715
+											$archivespeed = 1;
716
+										}
550 717
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
551 718
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
552
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
553
-										else {
719
+										if (!isset($idistance) || $fdistance < $idistance) {
720
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
721
+										} else {
554 722
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
555 723
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
556
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
557
-											else {
724
+											if (!isset($idistance) || $fdistance < $idistance) {
725
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
726
+											} else {
558 727
 												$output .= $spotter_item['longitude'].', ';
559 728
 												$output .= $spotter_item['latitude'];
560 729
 											}
@@ -632,7 +801,9 @@  discard block
 block discarded – undo
632 801
 			}
633 802
 */
634 803
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
635
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
804
+				if ($history == '' && isset($_COOKIE['history'])) {
805
+					$history = $_COOKIE['history'];
806
+				}
636 807
 				
637 808
 				if (
638 809
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -702,8 +873,11 @@  discard block
 block discarded – undo
702 873
 									$output_history .= ']}},';
703 874
 									$output .= $output_history;
704 875
 								}
705
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
706
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
876
+								if ($compress) {
877
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
878
+								} else {
879
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
880
+								}
707 881
 							}
708 882
 							$output_history .= '[';
709 883
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -724,10 +898,15 @@  discard block
 block discarded – undo
724 898
 							if ($d == false) {
725 899
 								if ($compress) {
726 900
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
727
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
728
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
901
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
902
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
903
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
904
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
905
+									}
729 906
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
730
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
907
+								} else {
908
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
909
+								}
731 910
 								$d = true;
732 911
 							}
733 912
 							$output_history .= '[';
@@ -750,7 +929,9 @@  discard block
 block discarded – undo
750 929
 							$output_historyd = '[';
751 930
 							$output_historyd .=  $spotter_item['longitude'].', ';
752 931
 							$output_historyd .=  $spotter_item['latitude'];
753
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
932
+							if (isset($spotter_history['altitude'])) {
933
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
934
+							}
754 935
 							$output_historyd .= '],';
755 936
 							//$output_history = $output_historyd.$output_history;
756 937
 							$output_history = $output_history.$output_historyd;
@@ -777,8 +958,11 @@  discard block
 block discarded – undo
777 958
 				        && $spotter_item['arrival_airport'] != 'NA' 
778 959
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
779 960
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
780
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
781
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
961
+				    if ($compress) {
962
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
963
+				    } else {
964
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
965
+				    }
782 966
 				    if (isset($spotter_item['departure_airport_latitude'])) {
783 967
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
784 968
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -811,8 +995,11 @@  discard block
 block discarded – undo
811 995
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
812 996
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
813 997
 				    $havedata = false;
814
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
998
+				    if ($compress) {
999
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1000
+				    } else {
1001
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1002
+				    }
816 1003
 				    
817 1004
 				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
818 1005
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -837,7 +1024,9 @@  discard block
 block discarded – undo
837 1024
 					$output_dest  = substr($output_dest, 0, -1);
838 1025
 				    }
839 1026
 				    $output_dest .= ']}},';
840
-				    if ($havedata) $output .= $output_dest;
1027
+				    if ($havedata) {
1028
+				    	$output .= $output_dest;
1029
+				    }
841 1030
 				    unset($output_dest);
842 1031
 				}
843 1032
 			}
@@ -845,7 +1034,9 @@  discard block
 block discarded – undo
845 1034
 			$output .= ']';
846 1035
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
847 1036
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
848
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1037
+			if (isset($begindate)) {
1038
+				$output .= '"archive_date": "'.$begindate.'",';
1039
+			}
849 1040
 			$output .= '"fc": "'.$j.'"';
850 1041
 		} else {
851 1042
 			$output .= '"features": ';
Please login to merge, or discard this patch.