Completed
Push — master ( f7c9fa...92ea23 )
by Yannick
27:20
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 aircrafts 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 aircrafts 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 aircrafts 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 aircrafts 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.
statistics.php 1 patch
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -73,7 +82,9 @@  discard block
 block discarded – undo
73 82
 if (isset($last_update[0]['value'])) {
74 83
 	date_default_timezone_set('UTC');
75 84
 	$lastupdate = strtotime($last_update[0]['value']);
76
-	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
85
+	if (isset($globalTimezone) && $globalTimezone != '') {
86
+		date_default_timezone_set($globalTimezone);
87
+	}
77 88
 	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
78 89
 }
79 90
 
@@ -158,8 +169,11 @@  discard block
 block discarded – undo
158 169
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 170
 		$aircraft_data = '';
160 171
 		foreach($aircraft_array as $aircraft_item) {
161
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
173
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
174
+			} else {
175
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
176
+			}
163 177
 		}
164 178
 		$aircraft_data = substr($aircraft_data, 0, -1);
165 179
 		print 'var series = ['.$aircraft_data.'];';
@@ -176,11 +190,17 @@  discard block
 block discarded – undo
176 190
 <?php
177 191
 	if ($year != '' && $month != '') {
178 192
 ?>
179
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
193
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
194
+	echo '/'.$airline_icao;
195
+}
196
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 197
 <?php
181 198
 	} else {
182 199
 ?>
183
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
200
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
201
+	echo '/'.$airline_icao;
202
+}
203
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
184 204
 <?php
185 205
 	}
186 206
 ?>
@@ -209,11 +229,15 @@  discard block
 block discarded – undo
209 229
 			print '</script>';
210 230
 			if ($year != '' && $month != '') {
211 231
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
232
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
233
+					echo '/'.$airline_icao;
234
+				}
213 235
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 236
 			} else {
215 237
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
216
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
238
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
239
+					echo '/'.$airline_icao;
240
+				}
217 241
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
218 242
 			}
219 243
 			print '</div>';
@@ -233,8 +257,9 @@  discard block
 block discarded – undo
233 257
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 258
 <?php
235 259
 	$marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
236
-	if (count($marine_array) == 0) print _("No data available");
237
-	else {
260
+	if (count($marine_array) == 0) {
261
+		print _("No data available");
262
+	} else {
238 263
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 264
 		$marine_data = '';
240 265
 		foreach($marine_array as $marine_item) {
@@ -278,8 +303,9 @@  discard block
 block discarded – undo
278 303
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
279 304
 <?php
280 305
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
281
-	if (count($tracker_array) == 0) print _("No data available");
282
-	else {
306
+	if (count($tracker_array) == 0) {
307
+		print _("No data available");
308
+	} else {
283 309
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
284 310
 		$tracker_data = '';
285 311
 		foreach($tracker_array as $tracker_item) {
@@ -323,8 +349,9 @@  discard block
 block discarded – undo
323 349
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
324 350
 <?php
325 351
 		$owner_array = $Satellite->countAllOwners(true);
326
-		if (count($owner_array) == 0) print _("No data available");
327
-		else {
352
+		if (count($owner_array) == 0) {
353
+			print _("No data available");
354
+		} else {
328 355
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
329 356
 			$owner_data = '';
330 357
 			foreach($owner_array as $owner_item) {
@@ -343,7 +370,10 @@  discard block
 block discarded – undo
343 370
 ?>
344 371
                <!--
345 372
                 <div class="more">
346
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
373
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
374
+	echo '/'.$airline_icao;
375
+}
376
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
347 377
                 </div>
348 378
                 -->
349 379
             </div>
@@ -352,8 +382,9 @@  discard block
 block discarded – undo
352 382
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
353 383
 <?php
354 384
 		$countries_array = $Satellite->countAllCountriesOwners(true);
355
-		if (count($countries_array) == 0) print _("No data available");
356
-		else {
385
+		if (count($countries_array) == 0) {
386
+			print _("No data available");
387
+		} else {
357 388
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
358 389
 			$owner_data = '';
359 390
 			foreach($countries_array as $owner_item) {
@@ -372,7 +403,10 @@  discard block
 block discarded – undo
372 403
 ?>
373 404
 	    <!--
374 405
                 <div class="more">
375
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
406
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
407
+	echo '/'.$airline_icao;
408
+}
409
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
376 410
                 </div>
377 411
                 -->
378 412
             </div>
@@ -384,8 +418,9 @@  discard block
 block discarded – undo
384 418
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
385 419
 <?php
386 420
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
387
-		if (count($launch_site_array) == 0) print _("No data available");
388
-		else {
421
+		if (count($launch_site_array) == 0) {
422
+			print _("No data available");
423
+		} else {
389 424
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
390 425
 			$launch_site_data = '';
391 426
 			foreach($launch_site_array as $launch_site_item) {
@@ -404,7 +439,10 @@  discard block
 block discarded – undo
404 439
 ?>
405 440
                <!--
406 441
                 <div class="more">
407
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
442
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
443
+	echo '/'.$airline_icao;
444
+}
445
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
408 446
                 </div>
409 447
                 -->
410 448
             </div>
@@ -427,8 +465,9 @@  discard block
 block discarded – undo
427 465
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
428 466
 <?php
429 467
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
430
-		if (count($pilot_array) == 0) print _("No data available");
431
-		else {
468
+		if (count($pilot_array) == 0) {
469
+			print _("No data available");
470
+		} else {
432 471
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
433 472
 			$pilot_data = '';
434 473
 			foreach($pilot_array as $pilot_item) {
@@ -446,7 +485,9 @@  discard block
 block discarded – undo
446 485
 		}
447 486
 		print '<div class="more">';
448 487
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
449
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
488
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
489
+			echo '/'.$airline_icao;
490
+		}
450 491
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
451 492
 		print '</div>';
452 493
 ?>
@@ -462,8 +503,9 @@  discard block
 block discarded – undo
462 503
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
463 504
 <?php
464 505
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
465
-		if (count($owner_array) == 0) print _("No data available");
466
-		else {
506
+		if (count($owner_array) == 0) {
507
+			print _("No data available");
508
+		} else {
467 509
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
468 510
 			$owner_data = '';
469 511
 			foreach($owner_array as $owner_item) {
@@ -481,7 +523,10 @@  discard block
 block discarded – undo
481 523
 		}
482 524
 ?>
483 525
                 <div class="more">
484
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
526
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
527
+	echo '/'.$airline_icao;
528
+}
529
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
485 530
                 </div>
486 531
             </div>
487 532
         
@@ -494,8 +539,9 @@  discard block
 block discarded – undo
494 539
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
495 540
 <?php
496 541
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
497
-		if (count($flightover_array) == 0) print _("No data available");
498
-		else {
542
+		if (count($flightover_array) == 0) {
543
+			print _("No data available");
544
+		} else {
499 545
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
500 546
 			print 'var series = [';
501 547
 			$flightover_data = '';
@@ -537,7 +583,10 @@  discard block
 block discarded – undo
537 583
 		}
538 584
 ?>
539 585
                 <div class="more">
540
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
586
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
587
+	echo '/'.$airline_icao;
588
+}
589
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
541 590
                 </div>
542 591
             </div>
543 592
 <?php
@@ -555,8 +604,9 @@  discard block
 block discarded – undo
555 604
 	<div class="col-md-6">
556 605
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
557 606
 <?php
558
-	if (count($flightover_array) == 0) print _("No data available");
559
-	else {
607
+	if (count($flightover_array) == 0) {
608
+		print _("No data available");
609
+	} else {
560 610
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
561 611
 		print 'var series = [';
562 612
 		$flightover_data = '';
@@ -612,8 +662,9 @@  discard block
 block discarded – undo
612 662
 	<div class="col-md-6">
613 663
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
614 664
 <?php
615
-	if (count($flightover_array) == 0) print _("No data available");
616
-	else {
665
+	if (count($flightover_array) == 0) {
666
+		print _("No data available");
667
+	} else {
617 668
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
618 669
 		print 'var series = [';
619 670
 		$flightover_data = '';
@@ -719,7 +770,9 @@  discard block
 block discarded – undo
719 770
 		});";
720 771
 		print '</script>';
721 772
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
722
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
773
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
774
+			echo '/'.$airline_icao;
775
+		}
723 776
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
724 777
 	}
725 778
 ?>
@@ -781,7 +834,9 @@  discard block
 block discarded – undo
781 834
 		});";
782 835
 		print '</script>';
783 836
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
784
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
837
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
838
+			echo '/'.$airline_icao;
839
+		}
785 840
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
786 841
 	}
787 842
 ?>
@@ -800,8 +855,9 @@  discard block
 block discarded – undo
800 855
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
801 856
 <?php
802 857
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
803
-		if (count($year_array) == 0) print _("No data available");
804
-		else {
858
+		if (count($year_array) == 0) {
859
+			print _("No data available");
860
+		} else {
805 861
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
806 862
 			$year_data = '';
807 863
 			$year_cnt = '';
@@ -820,7 +876,10 @@  discard block
 block discarded – undo
820 876
 		}
821 877
 ?>
822 878
                 <div class="more">
823
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
879
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
880
+	echo '/'.$airline_icao;
881
+}
882
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
824 883
                 </div>
825 884
             </div>
826 885
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -828,8 +887,9 @@  discard block
 block discarded – undo
828 887
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
829 888
 <?php
830 889
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
831
-		if (count($month_array) == 0) print _("No data available");
832
-		else {
890
+		if (count($month_array) == 0) {
891
+			print _("No data available");
892
+		} else {
833 893
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
834 894
 			$month_data = '';
835 895
 			$month_cnt = '';
@@ -848,7 +908,10 @@  discard block
 block discarded – undo
848 908
 		}
849 909
 ?>
850 910
                 <div class="more">
851
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
911
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
912
+	echo '/'.$airline_icao;
913
+}
914
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
852 915
                 </div>
853 916
             </div>
854 917
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -857,8 +920,9 @@  discard block
 block discarded – undo
857 920
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
858 921
 <?php
859 922
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
860
-		if (empty($date_array)) print _("No data available");
861
-		else {
923
+		if (empty($date_array)) {
924
+			print _("No data available");
925
+		} else {
862 926
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
863 927
 			$date_data = '';
864 928
 			$date_cnt = '';
@@ -877,7 +941,10 @@  discard block
 block discarded – undo
877 941
 		}
878 942
 ?>
879 943
                 <div class="more">
880
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
944
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
945
+	echo '/'.$airline_icao;
946
+}
947
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
881 948
                 </div>
882 949
             </div>
883 950
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -885,8 +952,9 @@  discard block
 block discarded – undo
885 952
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
886 953
 <?php
887 954
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
888
-		if (empty($hour_array)) print _("No data available");
889
-		else {
955
+		if (empty($hour_array)) {
956
+			print _("No data available");
957
+		} else {
890 958
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
891 959
 			$hour_data = '';
892 960
 			$hour_cnt = '';
@@ -905,7 +973,10 @@  discard block
 block discarded – undo
905 973
 		}
906 974
 ?>
907 975
                 <div class="more">
908
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
976
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
977
+	echo '/'.$airline_icao;
978
+}
979
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
909 980
                 </div>
910 981
             </div>
911 982
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -925,8 +996,9 @@  discard block
 block discarded – undo
925 996
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
926 997
 <?php
927 998
 		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
928
-		if (count($year_array) == 0) print _("No data available");
929
-		else {
999
+		if (count($year_array) == 0) {
1000
+			print _("No data available");
1001
+		} else {
930 1002
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
931 1003
 			$year_data = '';
932 1004
 			$year_cnt = '';
@@ -954,8 +1026,9 @@  discard block
 block discarded – undo
954 1026
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
955 1027
 <?php
956 1028
 		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
957
-		if (count($month_array) == 0) print _("No data available");
958
-		else {
1029
+		if (count($month_array) == 0) {
1030
+			print _("No data available");
1031
+		} else {
959 1032
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
960 1033
 			$month_data = '';
961 1034
 			$month_cnt = '';
@@ -983,8 +1056,9 @@  discard block
 block discarded – undo
983 1056
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
984 1057
 <?php
985 1058
 		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
986
-		if (empty($date_array)) print _("No data available");
987
-		else {
1059
+		if (empty($date_array)) {
1060
+			print _("No data available");
1061
+		} else {
988 1062
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
989 1063
 			$date_data = '';
990 1064
 			$date_cnt = '';
@@ -1011,8 +1085,9 @@  discard block
 block discarded – undo
1011 1085
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1012 1086
 <?php
1013 1087
 		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1014
-		if (empty($hour_array)) print _("No data available");
1015
-		else {
1088
+		if (empty($hour_array)) {
1089
+			print _("No data available");
1090
+		} else {
1016 1091
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1017 1092
 			$hour_data = '';
1018 1093
 			$hour_cnt = '';
@@ -1051,8 +1126,9 @@  discard block
 block discarded – undo
1051 1126
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1052 1127
 <?php
1053 1128
 		$year_array = $Tracker->countAllMonthsLastYear(true);
1054
-		if (count($year_array) == 0) print _("No data available");
1055
-		else {
1129
+		if (count($year_array) == 0) {
1130
+			print _("No data available");
1131
+		} else {
1056 1132
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1057 1133
 			$year_data = '';
1058 1134
 			$year_cnt = '';
@@ -1080,8 +1156,9 @@  discard block
 block discarded – undo
1080 1156
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1081 1157
 <?php
1082 1158
 		$month_array = $Tracker->countAllDatesLastMonth();
1083
-		if (count($month_array) == 0) print _("No data available");
1084
-		else {
1159
+		if (count($month_array) == 0) {
1160
+			print _("No data available");
1161
+		} else {
1085 1162
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1086 1163
 			$month_data = '';
1087 1164
 			$month_cnt = '';
@@ -1109,8 +1186,9 @@  discard block
 block discarded – undo
1109 1186
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1110 1187
 <?php
1111 1188
 		$date_array = $Tracker->countAllDatesLast7Days();
1112
-		if (empty($date_array)) print _("No data available");
1113
-		else {
1189
+		if (empty($date_array)) {
1190
+			print _("No data available");
1191
+		} else {
1114 1192
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1115 1193
 			$date_data = '';
1116 1194
 			$date_cnt = '';
@@ -1137,8 +1215,9 @@  discard block
 block discarded – undo
1137 1215
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1138 1216
 <?php
1139 1217
 		$hour_array = $Tracker->countAllHours('hour',true);
1140
-		if (empty($hour_array)) print _("No data available");
1141
-		else {
1218
+		if (empty($hour_array)) {
1219
+			print _("No data available");
1220
+		} else {
1142 1221
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1143 1222
 			$hour_data = '';
1144 1223
 			$hour_cnt = '';
@@ -1177,8 +1256,9 @@  discard block
 block discarded – undo
1177 1256
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1178 1257
 <?php
1179 1258
 		$year_array = $Satellite->countAllMonthsLastYear();
1180
-		if (count($year_array) == 0) print _("No data available");
1181
-		else {
1259
+		if (count($year_array) == 0) {
1260
+			print _("No data available");
1261
+		} else {
1182 1262
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1183 1263
 			$year_data = '';
1184 1264
 			$year_cnt = '';
@@ -1208,8 +1288,9 @@  discard block
 block discarded – undo
1208 1288
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1209 1289
 <?php
1210 1290
 		$year_array = $Satellite->countAllYears();
1211
-		if (count($year_array) == 0) print _("No data available");
1212
-		else {
1291
+		if (count($year_array) == 0) {
1292
+			print _("No data available");
1293
+		} else {
1213 1294
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1214 1295
 			$year_data = '';
1215 1296
 			$year_cnt = '';
@@ -1251,8 +1332,9 @@  discard block
 block discarded – undo
1251 1332
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1252 1333
 <?php
1253 1334
 		$year_array = $Stats->countFatalitiesByYear();
1254
-		if (count($year_array) == 0) print _("No data available");
1255
-		else {
1335
+		if (count($year_array) == 0) {
1336
+			print _("No data available");
1337
+		} else {
1256 1338
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1257 1339
 			$year_data = '';
1258 1340
 			$year_cnt = '';
@@ -1281,8 +1363,9 @@  discard block
 block discarded – undo
1281 1363
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1282 1364
 <?php
1283 1365
 		$year_array = $Stats->countFatalitiesLast12Months();
1284
-		if (count($year_array) == 0) print _("No data available");
1285
-		else {
1366
+		if (count($year_array) == 0) {
1367
+			print _("No data available");
1368
+		} else {
1286 1369
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1287 1370
 			$year_data = '';
1288 1371
 			$year_cnt = '';
@@ -1353,8 +1436,11 @@  discard block
 block discarded – undo
1353 1436
 					$distance = $distance;
1354 1437
 					$unit = 'km';
1355 1438
 				}
1356
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1357
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1439
+				if (!isset($polar_data)) {
1440
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1441
+				} else {
1442
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1443
+				}
1358 1444
 			}
1359 1445
 ?>
1360 1446
             <div class="col-md-6">
@@ -1418,9 +1504,12 @@  discard block
 block discarded – undo
1418 1504
 		foreach ($msg as $eachmsg) {
1419 1505
 			//$eachmsg = $msg[0];
1420 1506
 			$data = $eachmsg['source_data'];
1421
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1422
-			else $max = 500;
1423
-?>
1507
+			if ($data > 500) {
1508
+				$max = (round(($data+100)/100))*100;
1509
+			} else {
1510
+				$max = 500;
1511
+			}
1512
+			?>
1424 1513
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1425 1514
         	<script>
1426 1515
 		      var g = new JustGage({
Please login to merge, or discard this patch.
scripts/update_db.php 1 patch
Braces   +30 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -29,14 +31,18 @@  discard block
 block discarded – undo
29 31
 			$update_db->update_notam();
30 32
 		}
31 33
 		$update_db->insert_last_notam_update();
32
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
34
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
35
+		echo "NOTAM are only updated once a day.\n";
36
+	}
33 37
 	if ($update_db->check_last_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
34 38
 		$update_db->update_all();
35 39
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
36 40
 	//	$Spotter = new Spotter();
37 41
 	//	$Spotter->updateFieldsFromOtherTables();
38 42
 		$update_db->insert_last_update();
39
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
43
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
44
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
45
+	}
40 46
 	if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
41 47
 		echo "Check if new airspace version exist...";
42 48
 		echo $update_db->update_airspace_fam();
@@ -45,8 +51,11 @@  discard block
 block discarded – undo
45 51
 	if (isset($globalGeoid) && $globalGeoid && $update_db->check_last_geoid_update()) {
46 52
 		echo "Check if new geoid version exist...";
47 53
 		$error = $update_db->update_geoid_fam();
48
-		if ($error == '') $update_db->insert_last_geoid_update();
49
-		else echo $error;
54
+		if ($error == '') {
55
+			$update_db->insert_last_geoid_update();
56
+		} else {
57
+			echo $error;
58
+		}
50 59
 	}
51 60
 	if (isset($globalMarine) && $globalMarine && $update_db->check_last_marine_identity_update()) {
52 61
 		echo "Check if new marine identity version exist...";
@@ -64,13 +73,17 @@  discard block
 block discarded – undo
64 73
 			//echo "Done";
65 74
 		}
66 75
 		$update_db->insert_last_owner_update();
67
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
76
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
77
+		echo "Owner are only updated every 15 days.\n";
78
+	}
68 79
 
69 80
 	if ($update_db->check_last_airlines_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
70 81
 		echo "Updating airlines...\n";
71 82
 		echo $update_db->update_airlines_fam();
72 83
 		$update_db->insert_last_airlines_update();
73
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Airlines are only updated every 15 days.\n";
84
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
85
+		echo "Airlines are only updated every 15 days.\n";
86
+	}
74 87
 
75 88
 	if (isset($globalAccidents) && $globalAccidents && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
76 89
 		require_once(dirname(__FILE__).'/../require/class.Accident.php');
@@ -79,7 +92,9 @@  discard block
 block discarded – undo
79 92
 		if ($Accident->check_last_accidents_update()) {
80 93
 			$Accident->download_update();
81 94
 			$Accident->insert_last_accidents_update();
82
-		} else echo "Accidents are updated once a day.\n";
95
+		} else {
96
+			echo "Accidents are updated once a day.\n";
97
+		}
83 98
 	}
84 99
   
85 100
 }
@@ -92,15 +107,19 @@  discard block
 block discarded – undo
92 107
 	if ($METAR->check_last_update()) {
93 108
 		$METAR->addMETARCycle();
94 109
 		$METAR->insert_last_update();
95
-	} else echo "METAR are only updated every 30 minutes.\n";
96
-}
110
+	} else {
111
+		echo "METAR are only updated every 30 minutes.\n";
112
+	}
113
+	}
97 114
 
98 115
 if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
99 116
 	echo "Updating schedules...";
100 117
 	//$update_db->update_oneworld();
101 118
 	$update_db->update_skyteam();
102 119
 	$update_db->insert_last_schedules_update();
103
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
120
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
121
+	echo "Schedules are only updated every 15 days.\n";
122
+}
104 123
 
105 124
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
106 125
 	echo "Updating statistics and archive old data...\n";
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +191 added lines, -68 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (Marine)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (Marine)');
13
+		}
12 14
 	}
13 15
 
14 16
 	/**
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -69,8 +73,11 @@  discard block
 block discarded – undo
69 73
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
70 74
 			}
71 75
 		}
72
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
73
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
76
+		if ($filter_query_where == '' && $where) {
77
+			$filter_query_where = ' WHERE';
78
+		} elseif ($filter_query_where != '' && $and) {
79
+			$filter_query_where .= ' AND';
80
+		}
74 81
 		if ($filter_query_where != '') {
75 82
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
76 83
 		}
@@ -124,32 +131,54 @@  discard block
 block discarded – undo
124 131
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
125 132
 			} elseif (isset($row['spotter_archive_output_id'])) {
126 133
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
127
-			*/} 
128
-			elseif (isset($row['marineid'])) {
134
+			*/} elseif (isset($row['marineid'])) {
129 135
 				$temp_array['marine_id'] = $row['marineid'];
130 136
 			} else {
131 137
 				$temp_array['marine_id'] = '';
132 138
 			}
133
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
134
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
135
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
136
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
137
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
138
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
139
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
140
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
139
+			if (isset($row['fammarine_id'])) {
140
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
141
+			}
142
+			if (isset($row['mmsi'])) {
143
+				$temp_array['mmsi'] = $row['mmsi'];
144
+			}
145
+			if (isset($row['type'])) {
146
+				$temp_array['type'] = $row['type'];
147
+			}
148
+			if (isset($row['type_id'])) {
149
+				$temp_array['type_id'] = $row['type_id'];
150
+			}
151
+			if (isset($row['ident'])) {
152
+				$temp_array['ident'] = $row['ident'];
153
+			}
154
+			if (isset($row['latitude'])) {
155
+				$temp_array['latitude'] = $row['latitude'];
156
+			}
157
+			if (isset($row['longitude'])) {
158
+				$temp_array['longitude'] = $row['longitude'];
159
+			}
160
+			if (isset($row['format_source'])) {
161
+				$temp_array['format_source'] = $row['format_source'];
162
+			}
141 163
 			if (isset($row['heading'])) {
142 164
 				$temp_array['heading'] = $row['heading'];
143 165
 				$heading_direction = $this->parseDirection($row['heading']);
144
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
166
+				if (isset($heading_direction[0]['direction_fullname'])) {
167
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
168
+				}
169
+			}
170
+			if (isset($row['ground_speed'])) {
171
+				$temp_array['ground_speed'] = $row['ground_speed'];
145 172
 			}
146
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
147 173
 
148 174
 			if($temp_array['mmsi'] != "")
149 175
 			{
150 176
 				$Image = new Image($this->db);
151
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
152
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
177
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
178
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
179
+				} else {
180
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
181
+				}
153 182
 				unset($Image);
154 183
 				if (count($image_array) > 0) {
155 184
 					$temp_array['image'] = $image_array[0]['image'];
@@ -201,13 +230,21 @@  discard block
 block discarded – undo
201 230
 			}
202 231
 			
203 232
 			$fromsource = NULL;
204
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
205
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
206
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
233
+			if (isset($row['source_name']) && $row['source_name'] != '') {
234
+				$temp_array['source_name'] = $row['source_name'];
235
+			}
236
+			if (isset($row['over_country']) && $row['over_country'] != '') {
237
+				$temp_array['over_country'] = $row['over_country'];
238
+			}
239
+			if (isset($row['distance']) && $row['distance'] != '') {
240
+				$temp_array['distance'] = $row['distance'];
241
+			}
207 242
 			$temp_array['query_number_rows'] = $num_rows;
208 243
 			$spotter_array[] = $temp_array;
209 244
 		}
210
-		if ($num_rows == 0) return array();
245
+		if ($num_rows == 0) {
246
+			return array();
247
+		}
211 248
 		$spotter_array[0]['query_number_rows'] = $num_rows;
212 249
 		return $spotter_array;
213 250
 	}	
@@ -233,8 +270,12 @@  discard block
 block discarded – undo
233 270
 			{
234 271
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
235 272
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
236
-			} else $limit_query = "";
237
-		} else $limit_query = "";
273
+			} else {
274
+				$limit_query = "";
275
+			}
276
+		} else {
277
+			$limit_query = "";
278
+		}
238 279
 		if ($sort != "")
239 280
 		{
240 281
 			$search_orderby_array = $this->getOrderBy();
@@ -258,7 +299,9 @@  discard block
 block discarded – undo
258 299
 		global $global_query;
259 300
 		
260 301
 		date_default_timezone_set('UTC');
261
-		if ($id == '') return array();
302
+		if ($id == '') {
303
+			return array();
304
+		}
262 305
 		$additional_query = "marine_output.fammarine_id = :id";
263 306
 		$query_values = array(':id' => $id);
264 307
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -401,8 +444,11 @@  discard block
 block discarded – undo
401 444
 		$query .= " ORDER BY marine_output.source_name ASC";
402 445
 
403 446
 		$sth = $this->db->prepare($query);
404
-		if (!empty($query_values)) $sth->execute($query_values);
405
-		else $sth->execute();
447
+		if (!empty($query_values)) {
448
+			$sth->execute($query_values);
449
+		} else {
450
+			$sth->execute();
451
+		}
406 452
 
407 453
 		$source_array = array();
408 454
 		$temp_array = array();
@@ -457,8 +503,11 @@  discard block
 block discarded – undo
457 503
 		$sth = $this->db->prepare($query);
458 504
 		$sth->execute(array(':mmsi' => $mmsi));
459 505
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
460
-		if (isset($result[0])) return $result[0];
461
-		else return array();
506
+		if (isset($result[0])) {
507
+			return $result[0];
508
+		} else {
509
+			return array();
510
+		}
462 511
 	}
463 512
 
464 513
 	/*
@@ -474,7 +523,9 @@  discard block
 block discarded – undo
474 523
 			date_default_timezone_set($globalTimezone);
475 524
 			$datetime = new DateTime();
476 525
 			$offset = $datetime->format('P');
477
-		} else $offset = '+00:00';
526
+		} else {
527
+			$offset = '+00:00';
528
+		}
478 529
 
479 530
 		if ($globalDBdriver == 'mysql') {
480 531
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -704,9 +755,15 @@  discard block
 block discarded – undo
704 755
             		$latitude = 0;
705 756
             		$longitude = 0;
706 757
             	}
707
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
708
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
709
-                if ($arrival_date == '') $arrival_date = NULL;
758
+                if ($heading == '' || $Common->isInteger($heading) === false) {
759
+                	$heading = 0;
760
+                }
761
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
762
+                	$groundspeed = 0;
763
+                }
764
+                if ($arrival_date == '') {
765
+                	$arrival_date = NULL;
766
+                }
710 767
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
711 768
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
712 769
 
@@ -814,7 +871,9 @@  discard block
 block discarded – undo
814 871
 		global $globalDBdriver, $globalArchive;
815 872
 		//$filter_query = $this->getFilter($filters,true,true);
816 873
 		$Connection= new Connection($this->db);
817
-		if (!$Connection->tableExists('countries')) return array();
874
+		if (!$Connection->tableExists('countries')) {
875
+			return array();
876
+		}
818 877
 		require_once('class.SpotterLive.php');
819 878
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
820 879
 			$MarineLive = new MarineLive($this->db);
@@ -858,7 +917,9 @@  discard block
 block discarded – undo
858 917
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
859 918
 		}
860 919
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
861
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
920
+		if ($limit) {
921
+			$query .= " LIMIT 10 OFFSET 0";
922
+		}
862 923
 
863 924
 		$sth = $this->db->prepare($query);
864 925
 		$sth->execute();
@@ -892,12 +953,18 @@  discard block
 block discarded – undo
892 953
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
893 954
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
894 955
 		 if ($olderthanmonths > 0) {
895
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
896
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
956
+			if ($globalDBdriver == 'mysql') {
957
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
958
+			} else {
959
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
960
+			}
897 961
 		}
898 962
 		if ($sincedate != '') {
899
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
900
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
963
+			if ($globalDBdriver == 'mysql') {
964
+				$query .= " AND marine_output.date > '".$sincedate."'";
965
+			} else {
966
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
967
+			}
901 968
 		}
902 969
 		$query_values = array();
903 970
 		if ($year != '') {
@@ -928,7 +995,9 @@  discard block
 block discarded – undo
928 995
 			}
929 996
 		}
930 997
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
931
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
998
+		if ($limit) {
999
+			$query .= " LIMIT 10 OFFSET 0";
1000
+		}
932 1001
       		
933 1002
 		$sth = $this->db->prepare($query);
934 1003
 		$sth->execute($query_values);
@@ -963,7 +1032,9 @@  discard block
 block discarded – undo
963 1032
 			date_default_timezone_set($globalTimezone);
964 1033
 			$datetime = new DateTime();
965 1034
 			$offset = $datetime->format('P');
966
-		} else $offset = '+00:00';
1035
+		} else {
1036
+			$offset = '+00:00';
1037
+		}
967 1038
 
968 1039
 		if ($globalDBdriver == 'mysql') {
969 1040
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1013,7 +1084,9 @@  discard block
 block discarded – undo
1013 1084
 			date_default_timezone_set($globalTimezone);
1014 1085
 			$datetime = new DateTime();
1015 1086
 			$offset = $datetime->format('P');
1016
-		} else $offset = '+00:00';
1087
+		} else {
1088
+			$offset = '+00:00';
1089
+		}
1017 1090
 		$filter_query = $this->getFilter($filters,true,true);
1018 1091
 		if ($globalDBdriver == 'mysql') {
1019 1092
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1059,7 +1132,9 @@  discard block
 block discarded – undo
1059 1132
 			date_default_timezone_set($globalTimezone);
1060 1133
 			$datetime = new DateTime();
1061 1134
 			$offset = $datetime->format('P');
1062
-		} else $offset = '+00:00';
1135
+		} else {
1136
+			$offset = '+00:00';
1137
+		}
1063 1138
 		$filter_query = $this->getFilter($filters,true,true);
1064 1139
 		if ($globalDBdriver == 'mysql') {
1065 1140
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1107,7 +1182,9 @@  discard block
 block discarded – undo
1107 1182
 			date_default_timezone_set($globalTimezone);
1108 1183
 			$datetime = new DateTime();
1109 1184
 			$offset = $datetime->format('P');
1110
-		} else $offset = '+00:00';
1185
+		} else {
1186
+			$offset = '+00:00';
1187
+		}
1111 1188
 
1112 1189
 		if ($globalDBdriver == 'mysql') {
1113 1190
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1156,7 +1233,9 @@  discard block
 block discarded – undo
1156 1233
 			date_default_timezone_set($globalTimezone);
1157 1234
 			$datetime = new DateTime();
1158 1235
 			$offset = $datetime->format('P');
1159
-		} else $offset = '+00:00';
1236
+		} else {
1237
+			$offset = '+00:00';
1238
+		}
1160 1239
 		$filter_query = $this->getFilter($filters,true,true);
1161 1240
 		if ($globalDBdriver == 'mysql') {
1162 1241
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1205,7 +1284,9 @@  discard block
 block discarded – undo
1205 1284
 			date_default_timezone_set($globalTimezone);
1206 1285
 			$datetime = new DateTime();
1207 1286
 			$offset = $datetime->format('P');
1208
-		} else $offset = '+00:00';
1287
+		} else {
1288
+			$offset = '+00:00';
1289
+		}
1209 1290
 
1210 1291
 		$orderby_sql = '';
1211 1292
 		if ($orderby == "hour")
@@ -1274,7 +1355,9 @@  discard block
 block discarded – undo
1274 1355
 			date_default_timezone_set($globalTimezone);
1275 1356
 			$datetime = new DateTime($date);
1276 1357
 			$offset = $datetime->format('P');
1277
-		} else $offset = '+00:00';
1358
+		} else {
1359
+			$offset = '+00:00';
1360
+		}
1278 1361
 
1279 1362
 		if ($globalDBdriver == 'mysql') {
1280 1363
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1322,7 +1405,9 @@  discard block
 block discarded – undo
1322 1405
 			date_default_timezone_set($globalTimezone);
1323 1406
 			$datetime = new DateTime();
1324 1407
 			$offset = $datetime->format('P');
1325
-		} else $offset = '+00:00';
1408
+		} else {
1409
+			$offset = '+00:00';
1410
+		}
1326 1411
 
1327 1412
 		if ($globalDBdriver == 'mysql') {
1328 1413
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1387,8 +1472,11 @@  discard block
 block discarded – undo
1387 1472
 				$query_values = array_merge($query_values,array(':month' => $month));
1388 1473
 			}
1389 1474
 		}
1390
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1391
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1475
+		if (empty($query_values)) {
1476
+			$queryi .= $this->getFilter($filters);
1477
+		} else {
1478
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1479
+		}
1392 1480
 		
1393 1481
 		$sth = $this->db->prepare($queryi);
1394 1482
 		$sth->execute($query_values);
@@ -1425,8 +1513,11 @@  discard block
 block discarded – undo
1425 1513
 				$query_values = array_merge($query_values,array(':month' => $month));
1426 1514
 			}
1427 1515
 		}
1428
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1429
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1516
+		if (empty($query_values)) {
1517
+			$queryi .= $this->getFilter($filters);
1518
+		} else {
1519
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1520
+		}
1430 1521
 		
1431 1522
 		$sth = $this->db->prepare($queryi);
1432 1523
 		$sth->execute($query_values);
@@ -1448,7 +1539,9 @@  discard block
 block discarded – undo
1448 1539
 			date_default_timezone_set($globalTimezone);
1449 1540
 			$datetime = new DateTime();
1450 1541
 			$offset = $datetime->format('P');
1451
-		} else $offset = '+00:00';
1542
+		} else {
1543
+			$offset = '+00:00';
1544
+		}
1452 1545
 
1453 1546
 		if ($globalDBdriver == 'mysql') {
1454 1547
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1552,7 +1645,9 @@  discard block
 block discarded – undo
1552 1645
 	*/
1553 1646
 	public function parseDirection($direction = 0)
1554 1647
 	{
1555
-		if ($direction == '') $direction = 0;
1648
+		if ($direction == '') {
1649
+			$direction = 0;
1650
+		}
1556 1651
 		$direction_array = array();
1557 1652
 		$temp_array = array();
1558 1653
 
@@ -1641,7 +1736,9 @@  discard block
 block discarded – undo
1641 1736
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1642 1737
 	
1643 1738
 		$Connection = new Connection($this->db);
1644
-		if (!$Connection->tableExists('countries')) return '';
1739
+		if (!$Connection->tableExists('countries')) {
1740
+			return '';
1741
+		}
1645 1742
 	
1646 1743
 		try {
1647 1744
 			/*
@@ -1661,9 +1758,13 @@  discard block
 block discarded – undo
1661 1758
 			$sth->closeCursor();
1662 1759
 			if (count($row) > 0) {
1663 1760
 				return $row;
1664
-			} else return '';
1761
+			} else {
1762
+				return '';
1763
+			}
1665 1764
 		} catch (PDOException $e) {
1666
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1765
+			if (isset($globalDebug) && $globalDebug) {
1766
+				echo 'Error : '.$e->getMessage()."\n";
1767
+			}
1667 1768
 			return '';
1668 1769
 		}
1669 1770
 	
@@ -1681,7 +1782,9 @@  discard block
 block discarded – undo
1681 1782
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1682 1783
 	
1683 1784
 		$Connection = new Connection($this->db);
1684
-		if (!$Connection->tableExists('countries')) return '';
1785
+		if (!$Connection->tableExists('countries')) {
1786
+			return '';
1787
+		}
1685 1788
 	
1686 1789
 		try {
1687 1790
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1693,9 +1796,13 @@  discard block
 block discarded – undo
1693 1796
 			$sth->closeCursor();
1694 1797
 			if (count($row) > 0) {
1695 1798
 				return $row;
1696
-			} else return '';
1799
+			} else {
1800
+				return '';
1801
+			}
1697 1802
 		} catch (PDOException $e) {
1698
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1803
+			if (isset($globalDebug) && $globalDebug) {
1804
+				echo 'Error : '.$e->getMessage()."\n";
1805
+			}
1699 1806
 			return '';
1700 1807
 		}
1701 1808
 	
@@ -1713,7 +1820,9 @@  discard block
 block discarded – undo
1713 1820
 	{
1714 1821
 		global $globalBitlyAccessToken;
1715 1822
 		
1716
-		if ($globalBitlyAccessToken == '') return $url;
1823
+		if ($globalBitlyAccessToken == '') {
1824
+			return $url;
1825
+		}
1717 1826
         
1718 1827
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1719 1828
 		
@@ -1789,7 +1898,9 @@  discard block
 block discarded – undo
1789 1898
 			}
1790 1899
 		}
1791 1900
 		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC";
1792
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1901
+		if ($limit) {
1902
+			$query .= " LIMIT 10 OFFSET 0";
1903
+		}
1793 1904
 		$sth = $this->db->prepare($query);
1794 1905
 		$sth->execute($query_values);
1795 1906
 		$marine_array = array();
@@ -1826,9 +1937,15 @@  discard block
 block discarded – undo
1826 1937
 				foreach ($q_array as $q_item){
1827 1938
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1828 1939
 					$additional_query .= " AND (";
1829
-					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1830
-					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
1831
-					if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR ";
1940
+					if (is_int($q_item)) {
1941
+						$additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1942
+					}
1943
+					if (is_int($q_item)) {
1944
+						$additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
1945
+					}
1946
+					if (is_int($q_item)) {
1947
+						$additional_query .= "(marine_output.imo = '".$q_item."') OR ";
1948
+					}
1832 1949
 					$additional_query .= "(marine_output.ident like '%".$q_item."%') OR ";
1833 1950
 					$additional_query .= ")";
1834 1951
 				}
@@ -1876,7 +1993,9 @@  discard block
 block discarded – undo
1876 1993
 				date_default_timezone_set($globalTimezone);
1877 1994
 				$datetime = new DateTime();
1878 1995
 				$offset = $datetime->format('P');
1879
-			} else $offset = '+00:00';
1996
+			} else {
1997
+				$offset = '+00:00';
1998
+			}
1880 1999
 			if ($date_array[1] != "")
1881 2000
 			{
1882 2001
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -1903,8 +2022,12 @@  discard block
 block discarded – undo
1903 2022
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1904 2023
 			{
1905 2024
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1906
-			} else $limit_query = "";
1907
-		} else $limit_query = "";
2025
+			} else {
2026
+				$limit_query = "";
2027
+			}
2028
+		} else {
2029
+			$limit_query = "";
2030
+		}
1908 2031
 		if ($sort != "")
1909 2032
 		{
1910 2033
 			$search_orderby_array = $this->getOrderBy();
Please login to merge, or discard this patch.
require/class.Tracker.php 1 patch
Braces   +172 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 	public function __construct($dbc = null) {
11 11
 		$Connection = new Connection($dbc);
12 12
 		$this->db = $Connection->db();
13
-		if ($this->db === null) die('Error: No DB connection. (Tracker)');
13
+		if ($this->db === null) {
14
+			die('Error: No DB connection. (Tracker)');
15
+		}
14 16
 	}
15 17
 
16 18
 	/**
@@ -32,7 +34,9 @@  discard block
 block discarded – undo
32 34
 		if (isset($filter[0]['source'])) {
33 35
 			$filters = array_merge($filters,$filter);
34 36
 		}
35
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
37
+		if (is_array($globalFilter)) {
38
+			$filter = array_merge($filter,$globalFilter);
39
+		}
36 40
 		$filter_query_join = '';
37 41
 		$filter_query_where = '';
38 42
 		foreach($filters as $flt) {
@@ -71,8 +75,11 @@  discard block
 block discarded – undo
71 75
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
72 76
 			}
73 77
 		}
74
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
75
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
78
+		if ($filter_query_where == '' && $where) {
79
+			$filter_query_where = ' WHERE';
80
+		} elseif ($filter_query_where != '' && $and) {
81
+			$filter_query_where .= ' AND';
82
+		}
76 83
 		if ($filter_query_where != '') {
77 84
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78 85
 		}
@@ -126,26 +133,43 @@  discard block
 block discarded – undo
126 133
 				$temp_array['tracker_id'] = $row['tracker_archive_id'];
127 134
 			} elseif (isset($row['tracker_archive_output_id'])) {
128 135
 				$temp_array['tracker_id'] = $row['tracker_archive_output_id'];
129
-			*/} 
130
-			elseif (isset($row['trackerid'])) {
136
+			*/} elseif (isset($row['trackerid'])) {
131 137
 				$temp_array['trackerid'] = $row['trackerid'];
132 138
 			} else {
133 139
 				$temp_array['trackerid'] = '';
134 140
 			}
135
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
136
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
137
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
141
+			if (isset($row['famtrackid'])) {
142
+				$temp_array['famtrackid'] = $row['famtrackid'];
143
+			}
144
+			if (isset($row['type'])) {
145
+				$temp_array['type'] = $row['type'];
146
+			}
147
+			if (isset($row['comment'])) {
148
+				$temp_array['comment'] = $row['comment'];
149
+			}
138 150
 			$temp_array['ident'] = $row['ident'];
139
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
140
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
141
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
142
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
151
+			if (isset($row['latitude'])) {
152
+				$temp_array['latitude'] = $row['latitude'];
153
+			}
154
+			if (isset($row['longitude'])) {
155
+				$temp_array['longitude'] = $row['longitude'];
156
+			}
157
+			if (isset($row['format_source'])) {
158
+				$temp_array['format_source'] = $row['format_source'];
159
+			}
160
+			if (isset($row['altitude'])) {
161
+				$temp_array['altitude'] = $row['altitude'];
162
+			}
143 163
 			if (isset($row['heading'])) {
144 164
 				$temp_array['heading'] = $row['heading'];
145 165
 				$heading_direction = $this->parseDirection($row['heading']);
146
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
166
+				if (isset($heading_direction[0]['direction_fullname'])) {
167
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
168
+				}
169
+			}
170
+			if (isset($row['ground_speed'])) {
171
+				$temp_array['ground_speed'] = $row['ground_speed'];
147 172
 			}
148
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
149 173
 			
150 174
 			if (isset($row['date'])) {
151 175
 				$dateArray = $this->parseDateString($row['date']);
@@ -188,13 +212,21 @@  discard block
 block discarded – undo
188 212
 			}
189 213
 			
190 214
 			$fromsource = NULL;
191
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
192
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
193
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
215
+			if (isset($row['source_name']) && $row['source_name'] != '') {
216
+				$temp_array['source_name'] = $row['source_name'];
217
+			}
218
+			if (isset($row['over_country']) && $row['over_country'] != '') {
219
+				$temp_array['over_country'] = $row['over_country'];
220
+			}
221
+			if (isset($row['distance']) && $row['distance'] != '') {
222
+				$temp_array['distance'] = $row['distance'];
223
+			}
194 224
 			$temp_array['query_number_rows'] = $num_rows;
195 225
 			$tracker_array[] = $temp_array;
196 226
 		}
197
-		if ($num_rows == 0) return array();
227
+		if ($num_rows == 0) {
228
+			return array();
229
+		}
198 230
 		$tracker_array[0]['query_number_rows'] = $num_rows;
199 231
 		return $tracker_array;
200 232
 	}	
@@ -225,8 +257,12 @@  discard block
 block discarded – undo
225 257
 			{
226 258
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
227 259
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
228
-			} else $limit_query = "";
229
-		} else $limit_query = "";
260
+			} else {
261
+				$limit_query = "";
262
+			}
263
+		} else {
264
+			$limit_query = "";
265
+		}
230 266
 		
231 267
 		if ($sort != "")
232 268
 		{
@@ -254,7 +290,9 @@  discard block
 block discarded – undo
254 290
 		global $global_query;
255 291
 		
256 292
 		date_default_timezone_set('UTC');
257
-		if ($id == '') return array();
293
+		if ($id == '') {
294
+			return array();
295
+		}
258 296
 		$additional_query = "tracker_output.famtrackid = :id";
259 297
 		$query_values = array(':id' => $id);
260 298
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -397,8 +435,11 @@  discard block
 block discarded – undo
397 435
 		$query .= " ORDER BY tracker_output.source_name ASC";
398 436
 
399 437
 		$sth = $this->db->prepare($query);
400
-		if (!empty($query_values)) $sth->execute($query_values);
401
-		else $sth->execute();
438
+		if (!empty($query_values)) {
439
+			$sth->execute($query_values);
440
+		} else {
441
+			$sth->execute();
442
+		}
402 443
 
403 444
 		$source_array = array();
404 445
 		$temp_array = array();
@@ -453,7 +494,9 @@  discard block
 block discarded – undo
453 494
 			date_default_timezone_set($globalTimezone);
454 495
 			$datetime = new DateTime();
455 496
 			$offset = $datetime->format('P');
456
-		} else $offset = '+00:00';
497
+		} else {
498
+			$offset = '+00:00';
499
+		}
457 500
 
458 501
 		if ($globalDBdriver == 'mysql') {
459 502
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -609,7 +652,9 @@  discard block
 block discarded – undo
609 652
 			{
610 653
 				return false;
611 654
 			}
612
-		} else $altitude = 0;
655
+		} else {
656
+			$altitude = 0;
657
+		}
613 658
 		
614 659
 		if ($heading != "")
615 660
 		{
@@ -648,8 +693,12 @@  discard block
 block discarded – undo
648 693
             		$latitude = 0;
649 694
             		$longitude = 0;
650 695
             	}
651
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
652
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
696
+                if ($heading == '' || $Common->isInteger($heading) === false) {
697
+                	$heading = 0;
698
+                }
699
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
700
+                	$groundspeed = 0;
701
+                }
653 702
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
654 703
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
655 704
 
@@ -753,7 +802,9 @@  discard block
 block discarded – undo
753 802
 		global $globalDBdriver, $globalArchive;
754 803
 		//$filter_query = $this->getFilter($filters,true,true);
755 804
 		$Connection= new Connection($this->db);
756
-		if (!$Connection->tableExists('countries')) return array();
805
+		if (!$Connection->tableExists('countries')) {
806
+			return array();
807
+		}
757 808
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
758 809
 			require_once('class.TrackerLive.php');
759 810
 			$TrackerLive = new TrackerLive($this->db);
@@ -796,7 +847,9 @@  discard block
 block discarded – undo
796 847
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country ";
797 848
 		}
798 849
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
799
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
850
+		if ($limit) {
851
+			$query .= " LIMIT 10 OFFSET 0";
852
+		}
800 853
       
801 854
 		
802 855
 		$sth = $this->db->prepare($query);
@@ -829,12 +882,18 @@  discard block
 block discarded – undo
829 882
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
830 883
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
831 884
 		 if ($olderthanmonths > 0) {
832
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
833
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
885
+			if ($globalDBdriver == 'mysql') {
886
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
887
+			} else {
888
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
889
+			}
834 890
 		}
835 891
 		if ($sincedate != '') {
836
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
837
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
892
+			if ($globalDBdriver == 'mysql') {
893
+				$query .= " AND tracker_output.date > '".$sincedate."'";
894
+			} else {
895
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
896
+			}
838 897
 		}
839 898
 		$query_values = array();
840 899
 		if ($year != '') {
@@ -865,7 +924,9 @@  discard block
 block discarded – undo
865 924
 			}
866 925
 		}
867 926
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
868
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
927
+		if ($limit) {
928
+			$query .= " LIMIT 10 OFFSET 0";
929
+		}
869 930
       		
870 931
 		$sth = $this->db->prepare($query);
871 932
 		$sth->execute($query_values);
@@ -900,7 +961,9 @@  discard block
 block discarded – undo
900 961
 			date_default_timezone_set($globalTimezone);
901 962
 			$datetime = new DateTime();
902 963
 			$offset = $datetime->format('P');
903
-		} else $offset = '+00:00';
964
+		} else {
965
+			$offset = '+00:00';
966
+		}
904 967
 
905 968
 		if ($globalDBdriver == 'mysql') {
906 969
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -950,7 +1013,9 @@  discard block
 block discarded – undo
950 1013
 			date_default_timezone_set($globalTimezone);
951 1014
 			$datetime = new DateTime();
952 1015
 			$offset = $datetime->format('P');
953
-		} else $offset = '+00:00';
1016
+		} else {
1017
+			$offset = '+00:00';
1018
+		}
954 1019
 		$filter_query = $this->getFilter($filters,true,true);
955 1020
 		if ($globalDBdriver == 'mysql') {
956 1021
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -996,7 +1061,9 @@  discard block
 block discarded – undo
996 1061
 			date_default_timezone_set($globalTimezone);
997 1062
 			$datetime = new DateTime();
998 1063
 			$offset = $datetime->format('P');
999
-		} else $offset = '+00:00';
1064
+		} else {
1065
+			$offset = '+00:00';
1066
+		}
1000 1067
 		$filter_query = $this->getFilter($filters,true,true);
1001 1068
 		if ($globalDBdriver == 'mysql') {
1002 1069
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1044,7 +1111,9 @@  discard block
 block discarded – undo
1044 1111
 			date_default_timezone_set($globalTimezone);
1045 1112
 			$datetime = new DateTime();
1046 1113
 			$offset = $datetime->format('P');
1047
-		} else $offset = '+00:00';
1114
+		} else {
1115
+			$offset = '+00:00';
1116
+		}
1048 1117
 
1049 1118
 		if ($globalDBdriver == 'mysql') {
1050 1119
 			$query  = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1093,7 +1162,9 @@  discard block
 block discarded – undo
1093 1162
 			date_default_timezone_set($globalTimezone);
1094 1163
 			$datetime = new DateTime();
1095 1164
 			$offset = $datetime->format('P');
1096
-		} else $offset = '+00:00';
1165
+		} else {
1166
+			$offset = '+00:00';
1167
+		}
1097 1168
 		$filter_query = $this->getFilter($filters,true,true);
1098 1169
 		if ($globalDBdriver == 'mysql') {
1099 1170
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1142,7 +1213,9 @@  discard block
 block discarded – undo
1142 1213
 			date_default_timezone_set($globalTimezone);
1143 1214
 			$datetime = new DateTime();
1144 1215
 			$offset = $datetime->format('P');
1145
-		} else $offset = '+00:00';
1216
+		} else {
1217
+			$offset = '+00:00';
1218
+		}
1146 1219
 
1147 1220
 		$orderby_sql = '';
1148 1221
 		if ($orderby == "hour")
@@ -1211,7 +1284,9 @@  discard block
 block discarded – undo
1211 1284
 			date_default_timezone_set($globalTimezone);
1212 1285
 			$datetime = new DateTime($date);
1213 1286
 			$offset = $datetime->format('P');
1214
-		} else $offset = '+00:00';
1287
+		} else {
1288
+			$offset = '+00:00';
1289
+		}
1215 1290
 
1216 1291
 		if ($globalDBdriver == 'mysql') {
1217 1292
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1259,7 +1334,9 @@  discard block
 block discarded – undo
1259 1334
 			date_default_timezone_set($globalTimezone);
1260 1335
 			$datetime = new DateTime();
1261 1336
 			$offset = $datetime->format('P');
1262
-		} else $offset = '+00:00';
1337
+		} else {
1338
+			$offset = '+00:00';
1339
+		}
1263 1340
 
1264 1341
 		if ($globalDBdriver == 'mysql') {
1265 1342
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1324,8 +1401,11 @@  discard block
 block discarded – undo
1324 1401
 				$query_values = array_merge($query_values,array(':month' => $month));
1325 1402
 			}
1326 1403
 		}
1327
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1328
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1404
+		if (empty($query_values)) {
1405
+			$queryi .= $this->getFilter($filters);
1406
+		} else {
1407
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1408
+		}
1329 1409
 		
1330 1410
 		$sth = $this->db->prepare($queryi);
1331 1411
 		$sth->execute($query_values);
@@ -1362,8 +1442,11 @@  discard block
 block discarded – undo
1362 1442
 				$query_values = array_merge($query_values,array(':month' => $month));
1363 1443
 			}
1364 1444
 		}
1365
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1366
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1445
+		if (empty($query_values)) {
1446
+			$queryi .= $this->getFilter($filters);
1447
+		} else {
1448
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1449
+		}
1367 1450
 		
1368 1451
 		$sth = $this->db->prepare($queryi);
1369 1452
 		$sth->execute($query_values);
@@ -1385,7 +1468,9 @@  discard block
 block discarded – undo
1385 1468
 			date_default_timezone_set($globalTimezone);
1386 1469
 			$datetime = new DateTime();
1387 1470
 			$offset = $datetime->format('P');
1388
-		} else $offset = '+00:00';
1471
+		} else {
1472
+			$offset = '+00:00';
1473
+		}
1389 1474
 
1390 1475
 		if ($globalDBdriver == 'mysql') {
1391 1476
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1489,7 +1574,9 @@  discard block
 block discarded – undo
1489 1574
 	*/
1490 1575
 	public function parseDirection($direction = 0)
1491 1576
 	{
1492
-		if ($direction == '') $direction = 0;
1577
+		if ($direction == '') {
1578
+			$direction = 0;
1579
+		}
1493 1580
 		$direction_array = array();
1494 1581
 		$temp_array = array();
1495 1582
 
@@ -1578,7 +1665,9 @@  discard block
 block discarded – undo
1578 1665
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1579 1666
 	
1580 1667
 		$Connection = new Connection($this->db);
1581
-		if (!$Connection->tableExists('countries')) return '';
1668
+		if (!$Connection->tableExists('countries')) {
1669
+			return '';
1670
+		}
1582 1671
 	
1583 1672
 		try {
1584 1673
 			/*
@@ -1598,9 +1687,13 @@  discard block
 block discarded – undo
1598 1687
 			$sth->closeCursor();
1599 1688
 			if (count($row) > 0) {
1600 1689
 				return $row;
1601
-			} else return '';
1690
+			} else {
1691
+				return '';
1692
+			}
1602 1693
 		} catch (PDOException $e) {
1603
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1694
+			if (isset($globalDebug) && $globalDebug) {
1695
+				echo 'Error : '.$e->getMessage()."\n";
1696
+			}
1604 1697
 			return '';
1605 1698
 		}
1606 1699
 	
@@ -1618,7 +1711,9 @@  discard block
 block discarded – undo
1618 1711
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1619 1712
 	
1620 1713
 		$Connection = new Connection($this->db);
1621
-		if (!$Connection->tableExists('countries')) return '';
1714
+		if (!$Connection->tableExists('countries')) {
1715
+			return '';
1716
+		}
1622 1717
 	
1623 1718
 		try {
1624 1719
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1630,9 +1725,13 @@  discard block
 block discarded – undo
1630 1725
 			$sth->closeCursor();
1631 1726
 			if (count($row) > 0) {
1632 1727
 				return $row;
1633
-			} else return '';
1728
+			} else {
1729
+				return '';
1730
+			}
1634 1731
 		} catch (PDOException $e) {
1635
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1732
+			if (isset($globalDebug) && $globalDebug) {
1733
+				echo 'Error : '.$e->getMessage()."\n";
1734
+			}
1636 1735
 			return '';
1637 1736
 		}
1638 1737
 	
@@ -1693,7 +1792,9 @@  discard block
 block discarded – undo
1693 1792
 			}
1694 1793
 		}
1695 1794
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
1696
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1795
+		if ($limit) {
1796
+			$query .= " LIMIT 10 OFFSET 0";
1797
+		}
1697 1798
 		$sth = $this->db->prepare($query);
1698 1799
 		$sth->execute($query_values);
1699 1800
 		$tracker_array = array();
@@ -1730,7 +1831,9 @@  discard block
 block discarded – undo
1730 1831
 				foreach ($q_array as $q_item){
1731 1832
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1732 1833
 					$additional_query .= " AND (";
1733
-					if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1834
+					if (is_int($q_item)) {
1835
+						$additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1836
+					}
1734 1837
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%') OR ";
1735 1838
 					$additional_query .= ")";
1736 1839
 				}
@@ -1756,7 +1859,9 @@  discard block
 block discarded – undo
1756 1859
 				date_default_timezone_set($globalTimezone);
1757 1860
 				$datetime = new DateTime();
1758 1861
 				$offset = $datetime->format('P');
1759
-			} else $offset = '+00:00';
1862
+			} else {
1863
+				$offset = '+00:00';
1864
+			}
1760 1865
 			if ($date_array[1] != "")
1761 1866
 			{
1762 1867
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -1783,8 +1888,12 @@  discard block
 block discarded – undo
1783 1888
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1784 1889
 			{
1785 1890
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1786
-			} else $limit_query = "";
1787
-		} else $limit_query = "";
1891
+			} else {
1892
+				$limit_query = "";
1893
+			}
1894
+		} else {
1895
+			$limit_query = "";
1896
+		}
1788 1897
 		if ($sort != "")
1789 1898
 		{
1790 1899
 			$search_orderby_array = $this->getOrderBy();
@@ -1827,7 +1936,9 @@  discard block
 block discarded – undo
1827 1936
 	{
1828 1937
 		global $globalBitlyAccessToken;
1829 1938
 		
1830
-		if ($globalBitlyAccessToken == '') return $url;
1939
+		if ($globalBitlyAccessToken == '') {
1940
+			return $url;
1941
+		}
1831 1942
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1832 1943
 		$ch = curl_init();
1833 1944
 		curl_setopt($ch, CURLOPT_HEADER, 0);
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +1047 added lines, -357 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,22 +211,30 @@  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('/opensky/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftlistjson';
178 233
         	$globalSources[$id]['format'] = 'opensky';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to opensky source (".$host.")...\n";
237
+        	}
181 238
     	    /*
182 239
     	    // Disabled for now, site change source format
183 240
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -194,7 +251,9 @@  discard block
 block discarded – undo
194 251
         	//$formats[$id] = 'planeupdatefaa';
195 252
         	$globalSources[$id]['format'] = 'planeupdatefaa';
196 253
         	//$last_exec['planeupdatefaa'] = 0;
197
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
254
+        	if ($globalDebug) {
255
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
256
+        	}
198 257
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200 259
         	    exit(0);
@@ -203,32 +262,46 @@  discard block
 block discarded – undo
203 262
         	//$formats[$id] = 'phpvmacars';
204 263
         	$globalSources[$id]['format'] = 'phpvmacars';
205 264
         	//$last_exec['phpvmacars'] = 0;
206
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
265
+        	if ($globalDebug) {
266
+        		echo "Connect to phpvmacars source (".$host.")...\n";
267
+        	}
207 268
             } else if (preg_match('/VAM-json.php$/i',$host)) {
208 269
         	//$formats[$id] = 'phpvmacars';
209 270
         	$globalSources[$id]['format'] = 'vam';
210
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
271
+        	if ($globalDebug) {
272
+        		echo "Connect to Vam source (".$host.")...\n";
273
+        	}
211 274
             } else if (preg_match('/whazzup/i',$host)) {
212 275
         	//$formats[$id] = 'whazzup';
213 276
         	$globalSources[$id]['format'] = 'whazzup';
214 277
         	//$last_exec['whazzup'] = 0;
215
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
278
+        	if ($globalDebug) {
279
+        		echo "Connect to whazzup source (".$host.")...\n";
280
+        	}
216 281
             } else if (preg_match('/blitzortung/i',$host)) {
217 282
         	$globalSources[$id]['format'] = 'blitzortung';
218
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
283
+        	if ($globalDebug) {
284
+        		echo "Connect to blitzortung source (".$host.")...\n";
285
+        	}
219 286
             } else if (preg_match('/airwhere/i',$host)) {
220 287
         	$globalSources[$id]['format'] = 'airwhere';
221
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
288
+        	if ($globalDebug) {
289
+        		echo "Connect to airwhere source (".$host.")...\n";
290
+        	}
222 291
             } else if (preg_match('/recentpireps/i',$host)) {
223 292
         	//$formats[$id] = 'pirepsjson';
224 293
         	$globalSources[$id]['format'] = 'pirepsjson';
225 294
         	//$last_exec['pirepsjson'] = 0;
226
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
295
+        	if ($globalDebug) {
296
+        		echo "Connect to pirepsjson source (".$host.")...\n";
297
+        	}
227 298
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
228 299
         	//$formats[$id] = 'fr24json';
229 300
         	$globalSources[$id]['format'] = 'fr24json';
230 301
         	//$last_exec['fr24json'] = 0;
231
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
302
+        	if ($globalDebug) {
303
+        		echo "Connect to fr24 source (".$host.")...\n";
304
+        	}
232 305
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
233 306
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
234 307
         	    exit(0);
@@ -237,7 +310,9 @@  discard block
 block discarded – undo
237 310
         	//$formats[$id] = 'fr24json';
238 311
         	$globalSources[$id]['format'] = 'myshiptracking';
239 312
         	//$last_exec['fr24json'] = 0;
240
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
313
+        	if ($globalDebug) {
314
+        		echo "Connect to myshiptracking source (".$host.")...\n";
315
+        	}
241 316
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
242 317
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
243 318
         	    exit(0);
@@ -246,16 +321,24 @@  discard block
 block discarded – undo
246 321
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
247 322
         	//$formats[$id] = 'tsv';
248 323
         	$globalSources[$id]['format'] = 'tsv';
249
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
324
+        	if ($globalDebug) {
325
+        		echo "Connect to tsv source (".$host.")...\n";
326
+        	}
250 327
             }
251 328
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
252 329
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
253 330
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
254 331
     		    if ($idf !== false) {
255 332
     			$httpfeeds[$id] = $idf;
256
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
257
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
258
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
333
+        		if ($globalDebug) {
334
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
335
+        		}
336
+    		    } elseif ($globalDebug) {
337
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
338
+    		    }
339
+    		} elseif ($globalDebug) {
340
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
341
+    		}
259 342
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
260 343
 	    $hostport = explode(':',$host);
261 344
 	    if (isset($hostport[1])) {
@@ -295,17 +378,25 @@  discard block
 block discarded – undo
295 378
         		//$formats[$id] = 'beast';
296 379
         		$globalSources[$id]['format'] = 'beast';
297 380
 		    //} else $formats[$id] = 'sbs';
298
-		    } else $globalSources[$id]['format'] = 'sbs';
381
+		    } else {
382
+		    	$globalSources[$id]['format'] = 'sbs';
383
+		    }
299 384
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
300 385
 		}
301
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
386
+		if ($globalDebug) {
387
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
388
+		}
302 389
             } else {
303
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
390
+		if ($globalDebug) {
391
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
392
+		}
304 393
     	    }
305 394
         }
306 395
     }
307 396
 }
308
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
397
+if (!isset($globalMinFetch)) {
398
+	$globalMinFetch = 15;
399
+}
309 400
 
310 401
 // Initialize all
311 402
 $status = array();
@@ -314,13 +405,19 @@  discard block
 block discarded – undo
314 405
 $formats = array();
315 406
 $last_exec = array();
316 407
 $time = time();
317
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
318
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
319
-else $timeout = 20;
408
+if (isset($globalSourcesTimeout)) {
409
+	$timeout = $globalSourcesTimeOut;
410
+} else if (isset($globalSBS1TimeOut)) {
411
+	$timeout = $globalSBS1TimeOut;
412
+} else {
413
+	$timeout = 20;
414
+}
320 415
 $errno = '';
321 416
 $errstr='';
322 417
 
323
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
418
+if (!isset($globalDaemon)) {
419
+	$globalDaemon = TRUE;
420
+}
324 421
 /* Initiate connections to all the hosts simultaneously */
325 422
 //connect_all($hosts);
326 423
 //connect_all($globalSources);
@@ -349,7 +446,9 @@  discard block
 block discarded – undo
349 446
     if (isset($source['format']) && $source['format'] == 'aprs') {
350 447
 	$aprs_connect = 0;
351 448
 	$use_aprs = true;
352
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
449
+	if (isset($source['port']) && $source['port'] == '10152') {
450
+		$aprs_full = true;
451
+	}
353 452
 	break;
354 453
     }
355 454
 }
@@ -360,25 +459,46 @@  discard block
 block discarded – undo
360 459
 	$aprs_connect = 0;
361 460
 	$aprs_keep = 120;
362 461
 	$aprs_last_tx = time();
363
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
364
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
365
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
366
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
367
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
368
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
369
-	if ($aprs_full) $aprs_filter = '';
370
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
371
-	else $aprs_pass = '-1';
462
+	if (isset($globalAPRSversion)) {
463
+		$aprs_version = $globalAPRSversion;
464
+	} else {
465
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
466
+	}
467
+	if (isset($globalAPRSssid)) {
468
+		$aprs_ssid = $globalAPRSssid;
469
+	} else {
470
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
471
+	}
472
+	if (isset($globalAPRSfilter)) {
473
+		$aprs_filter = $globalAPRSfilter;
474
+	} else {
475
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
476
+	}
477
+	if ($aprs_full) {
478
+		$aprs_filter = '';
479
+	}
480
+	if (isset($globalAPRSpass)) {
481
+		$aprs_pass = $globalAPRSpass;
482
+	} else {
483
+		$aprs_pass = '-1';
484
+	}
372 485
 
373
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
374
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
375
-}
486
+	if ($aprs_filter != '') {
487
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
488
+	} else {
489
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
490
+	}
491
+	}
376 492
 
377 493
 // connected - lets do some work
378 494
 //if ($globalDebug) echo "Connected!\n";
379 495
 sleep(1);
380
-if ($globalDebug) echo "SCAN MODE \n\n";
381
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
496
+if ($globalDebug) {
497
+	echo "SCAN MODE \n\n";
498
+}
499
+if (!isset($globalCronEnd)) {
500
+	$globalCronEnd = 60;
501
+}
382 502
 $endtime = time()+$globalCronEnd;
383 503
 $i = 1;
384 504
 $tt = array();
@@ -392,20 +512,28 @@  discard block
 block discarded – undo
392 512
 
393 513
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
394 514
 while ($i > 0) {
395
-    if (!$globalDaemon) $i = $endtime-time();
515
+    if (!$globalDaemon) {
516
+    	$i = $endtime-time();
517
+    }
396 518
     // Delete old ATC
397 519
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
398
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
520
+	if ($globalDebug) {
521
+		echo 'Delete old ATC...'."\n";
522
+	}
399 523
         $ATC->deleteOldATC();
400 524
     }
401 525
     
402 526
     if (count($last_exec) == count($globalSources)) {
403 527
 	$max = $globalMinFetch;
404 528
 	foreach ($last_exec as $last) {
405
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
529
+	    if ((time() - $last['last']) < $max) {
530
+	    	$max = time() - $last['last'];
531
+	    }
406 532
 	}
407 533
 	if ($max != $globalMinFetch) {
408
-	    if ($globalDebug) echo 'Sleeping...'."\n";
534
+	    if ($globalDebug) {
535
+	    	echo 'Sleeping...'."\n";
536
+	    }
409 537
 	    sleep($globalMinFetch-$max+2);
410 538
 	}
411 539
     }
@@ -415,7 +543,9 @@  discard block
 block discarded – undo
415 543
     foreach ($globalSources as $id => $value) {
416 544
 	date_default_timezone_set('UTC');
417 545
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
418
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
546
+	if (!isset($last_exec[$id]['last'])) {
547
+		$last_exec[$id]['last'] = 0;
548
+	}
419 549
 	if ($value['format'] == 'deltadbtxt' && 
420 550
 	    (
421 551
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -424,7 +554,9 @@  discard block
 block discarded – undo
424 554
 	) {
425 555
 	    //$buffer = $Common->getData($hosts[$id]);
426 556
 	    $buffer = $Common->getData($value['host']);
427
-	    if ($buffer != '') $reset = 0;
557
+	    if ($buffer != '') {
558
+	    	$reset = 0;
559
+	    }
428 560
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
429 561
 	    $buffer = explode('\n',$buffer);
430 562
 	    foreach ($buffer as $line) {
@@ -433,20 +565,41 @@  discard block
 block discarded – undo
433 565
 	            $data = array();
434 566
 	            $data['hex'] = $line[1]; // hex
435 567
 	            $data['ident'] = $line[2]; // ident
436
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
437
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
438
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
439
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
440
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
568
+	            if (isset($line[3])) {
569
+	            	$data['altitude'] = $line[3];
570
+	            }
571
+	            // altitude
572
+	            if (isset($line[4])) {
573
+	            	$data['speed'] = $line[4];
574
+	            }
575
+	            // speed
576
+	            if (isset($line[5])) {
577
+	            	$data['heading'] = $line[5];
578
+	            }
579
+	            // heading
580
+	            if (isset($line[6])) {
581
+	            	$data['latitude'] = $line[6];
582
+	            }
583
+	            // lat
584
+	            if (isset($line[7])) {
585
+	            	$data['longitude'] = $line[7];
586
+	            }
587
+	            // long
441 588
 	            $data['verticalrate'] = ''; // vertical rate
442 589
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
443 590
 	            $data['emergency'] = ''; // emergency
444 591
 		    $data['datetime'] = date('Y-m-d H:i:s');
445 592
 		    $data['format_source'] = 'deltadbtxt';
446 593
     		    $data['id_source'] = $id_source;
447
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
448
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
449
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
594
+		    if (isset($value['name']) && $value['name'] != '') {
595
+		    	$data['source_name'] = $value['name'];
596
+		    }
597
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
598
+		    	$data['noarchive'] = true;
599
+		    }
600
+		    if (isset($value['sourcestats'])) {
601
+		    	$data['sourcestats'] = $value['sourcestats'];
602
+		    }
450 603
     		    $SI->add($data);
451 604
 		    unset($data);
452 605
     		}
@@ -461,7 +614,9 @@  discard block
 block discarded – undo
461 614
 	    date_default_timezone_set('CET');
462 615
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
463 616
 	    date_default_timezone_set('UTC');
464
-	    if ($buffer != '') $reset = 0;
617
+	    if ($buffer != '') {
618
+	    	$reset = 0;
619
+	    }
465 620
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
466 621
 	    $buffer = explode('\n',$buffer);
467 622
 	    foreach ($buffer as $line) {
@@ -470,16 +625,36 @@  discard block
 block discarded – undo
470 625
 		    $add = false;
471 626
 		    $ais_data = $AIS->parse_line(trim($line));
472 627
 		    $data = array();
473
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
474
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
475
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
476
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
477
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
478
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
479
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
480
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
481
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
482
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
628
+		    if (isset($ais_data['ident'])) {
629
+		    	$data['ident'] = $ais_data['ident'];
630
+		    }
631
+		    if (isset($ais_data['mmsi'])) {
632
+		    	$data['mmsi'] = $ais_data['mmsi'];
633
+		    }
634
+		    if (isset($ais_data['speed'])) {
635
+		    	$data['speed'] = $ais_data['speed'];
636
+		    }
637
+		    if (isset($ais_data['heading'])) {
638
+		    	$data['heading'] = $ais_data['heading'];
639
+		    }
640
+		    if (isset($ais_data['latitude'])) {
641
+		    	$data['latitude'] = $ais_data['latitude'];
642
+		    }
643
+		    if (isset($ais_data['longitude'])) {
644
+		    	$data['longitude'] = $ais_data['longitude'];
645
+		    }
646
+		    if (isset($ais_data['status'])) {
647
+		    	$data['status'] = $ais_data['status'];
648
+		    }
649
+		    if (isset($ais_data['type'])) {
650
+		    	$data['type'] = $ais_data['type'];
651
+		    }
652
+		    if (isset($ais_data['imo'])) {
653
+		    	$data['imo'] = $ais_data['imo'];
654
+		    }
655
+		    if (isset($ais_data['callsign'])) {
656
+		    	$data['callsign'] = $ais_data['callsign'];
657
+		    }
483 658
 		    if (isset($ais_data['timestamp'])) {
484 659
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
485 660
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -493,8 +668,12 @@  discard block
 block discarded – undo
493 668
 		    $data['format_source'] = 'aisnmeatxt';
494 669
     		    $data['id_source'] = $id_source;
495 670
 		    //print_r($data);
496
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
497
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
671
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
672
+		    	$data['noarchive'] = true;
673
+		    }
674
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
675
+		    	$MI->add($data);
676
+		    }
498 677
 		    unset($data);
499 678
 		}
500 679
     	    }
@@ -517,20 +696,48 @@  discard block
 block discarded – undo
517 696
 			    if ($line != '') {
518 697
 				$ais_data = $AIS->parse_line(trim($line));
519 698
 				$data = array();
520
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
521
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
522
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
523
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
524
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
525
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
526
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
527
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
528
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
529
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
530
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
531
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
532
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
533
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
699
+				if (isset($ais_data['ident'])) {
700
+					$data['ident'] = $ais_data['ident'];
701
+				}
702
+				if (isset($ais_data['mmsi'])) {
703
+					$data['mmsi'] = $ais_data['mmsi'];
704
+				}
705
+				if (isset($ais_data['speed'])) {
706
+					$data['speed'] = $ais_data['speed'];
707
+				}
708
+				if (isset($ais_data['heading'])) {
709
+					$data['heading'] = $ais_data['heading'];
710
+				}
711
+				if (isset($ais_data['latitude'])) {
712
+					$data['latitude'] = $ais_data['latitude'];
713
+				}
714
+				if (isset($ais_data['longitude'])) {
715
+					$data['longitude'] = $ais_data['longitude'];
716
+				}
717
+				if (isset($ais_data['status'])) {
718
+					$data['status'] = $ais_data['status'];
719
+				}
720
+				if (isset($ais_data['statusid'])) {
721
+					$data['status_id'] = $ais_data['statusid'];
722
+				}
723
+				if (isset($ais_data['type'])) {
724
+					$data['type'] = $ais_data['type'];
725
+				}
726
+				if (isset($ais_data['typeid'])) {
727
+					$data['type_id'] = $ais_data['typeid'];
728
+				}
729
+				if (isset($ais_data['imo'])) {
730
+					$data['imo'] = $ais_data['imo'];
731
+				}
732
+				if (isset($ais_data['callsign'])) {
733
+					$data['callsign'] = $ais_data['callsign'];
734
+				}
735
+				if (isset($ais_data['destination'])) {
736
+					$data['arrival_code'] = $ais_data['destination'];
737
+				}
738
+				if (isset($ais_data['eta_ts'])) {
739
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
740
+				}
534 741
 				if (isset($ais_data['timestamp'])) {
535 742
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
536 743
 				} else {
@@ -538,18 +745,27 @@  discard block
 block discarded – undo
538 745
 				}
539 746
 				$data['format_source'] = 'aisnmeahttp';
540 747
 				$data['id_source'] = $id_source;
541
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
542
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
748
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
749
+					$data['noarchive'] = true;
750
+				}
751
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
752
+					$MI->add($data);
753
+				}
543 754
 				unset($data);
544 755
 			    }
545 756
 			}
546 757
 		    }
547 758
 		} else {
548 759
 		    $format = $value['format'];
549
-		    if (isset($tt[$format])) $tt[$format]++;
550
-		    else $tt[$format] = 0;
760
+		    if (isset($tt[$format])) {
761
+		    	$tt[$format]++;
762
+		    } else {
763
+		    	$tt[$format] = 0;
764
+		    }
551 765
 		    if ($tt[$format] > 30) {
552
-			if ($globalDebug) echo 'Reconnect...'."\n";
766
+			if ($globalDebug) {
767
+				echo 'Reconnect...'."\n";
768
+			}
553 769
 			sleep(2);
554 770
 			//$sourceeen[] = $value;
555 771
 			//connect_all($sourceeen);
@@ -588,7 +804,9 @@  discard block
 block discarded – undo
588 804
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
589 805
 			    $data['format_source'] = 'myshiptracking';
590 806
 			    $data['id_source'] = $id_source;
591
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
807
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
808
+			    	$data['noarchive'] = true;
809
+			    }
592 810
 			    $MI->add($data);
593 811
 			    unset($data);
594 812
 			}
@@ -613,7 +831,9 @@  discard block
 block discarded – undo
613 831
 			    $data['callsign'] = $line['callsign'];
614 832
 			    $data['mmsi'] = $line['mmsi'];
615 833
 			    $data['speed'] = $line['sog'];
616
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
834
+			    if ($line['heading'] != '511') {
835
+			    	$data['heading'] = $line['heading'];
836
+			    }
617 837
 			    $data['latitude'] = $line['latitude'];
618 838
 			    $data['longitude'] = $line['longitude'];
619 839
 			    $data['type_id'] = $line['shiptype'];
@@ -621,7 +841,9 @@  discard block
 block discarded – undo
621 841
 			    $data['datetime'] = $line['time'];
622 842
 			    $data['format_source'] = 'boatbeaconapp';
623 843
 			    $data['id_source'] = $id_source;
624
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
844
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
845
+			    	$data['noarchive'] = true;
846
+			    }
625 847
 			    $MI->add($data);
626 848
 			    unset($data);
627 849
 			}
@@ -642,22 +864,44 @@  discard block
 block discarded – undo
642 864
 		if (isset($all_data['features'][0]['id'])) {
643 865
 		    foreach ($all_data['features'] as $line) {
644 866
 			$data = array();
645
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
646
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
647
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
648
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
649
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
650
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
867
+			if (isset($line['properties']['name'])) {
868
+				$data['ident'] = $line['properties']['name'];
869
+			}
870
+			if (isset($line['properties']['callsign'])) {
871
+				$data['callsign'] = $line['properties']['callsign'];
872
+			}
873
+			if (isset($line['properties']['mmsi'])) {
874
+				$data['mmsi'] = $line['properties']['mmsi'];
875
+			}
876
+			if (isset($line['properties']['imo'])) {
877
+				$data['mmsi'] = $line['properties']['imo'];
878
+			}
879
+			if (isset($line['properties']['speed'])) {
880
+				$data['speed'] = $line['properties']['speed'];
881
+			}
882
+			if (isset($line['properties']['heading'])) {
883
+				$data['heading'] = $line['properties']['heading'];
884
+			}
651 885
 			$data['latitude'] = $line['geometry']['coordinates'][1];
652 886
 			$data['longitude'] = $line['geometry']['coordinates'][0];
653
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
654
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
655
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
887
+			if (isset($line['properties']['vesselType'])) {
888
+				$data['type'] = $line['properties']['vesselType'];
889
+			}
890
+			if (isset($line['properties']['destination'])) {
891
+				$data['arrival_code'] = $line['properties']['destination'];
892
+			}
893
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
894
+				$data['arrival_date'] = $line['properties']['eta'];
895
+			}
656 896
 			$data['format_source'] = 'boatnerd';
657 897
 			$data['id_source'] = $id_source;
658 898
 			$data['datetime'] = date('Y-m-d H:i:s');
659
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
660
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
899
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
900
+				$data['noarchive'] = true;
901
+			}
902
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
903
+				$MI->add($data);
904
+			}
661 905
 			unset($data);
662 906
 		    }
663 907
 		}
@@ -673,7 +917,9 @@  discard block
 block discarded – undo
673 917
 	    echo 'download...';
674 918
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
675 919
 	    echo 'done !'."\n";
676
-	    if ($buffer != '') $reset = 0;
920
+	    if ($buffer != '') {
921
+	    	$reset = 0;
922
+	    }
677 923
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
678 924
 	    $buffer = explode('\n',$buffer);
679 925
 	    foreach ($buffer as $line) {
@@ -698,7 +944,9 @@  discard block
 block discarded – undo
698 944
 		    //$data['etaTime'] = substr($line,135,5);
699 945
 		    $data['format_source'] = 'shipplotter';
700 946
     		    $data['id_source'] = $id_source;
701
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
947
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
948
+		    	$data['noarchive'] = true;
949
+		    }
702 950
 		    //print_r($data);
703 951
 		    echo 'Add...'."\n";
704 952
 		    $MI->add($data);
@@ -732,16 +980,28 @@  discard block
 block discarded – undo
732 980
     		    $line = explode(':', $line);
733 981
     		    if (count($line) > 30 && $line[0] != 'callsign') {
734 982
 			$data = array();
735
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
736
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
983
+			if (isset($line[37]) && $line[37] != '') {
984
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
985
+			} else {
986
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
987
+			}
737 988
 			$data['pilot_id'] = $line[1];
738 989
 			$data['pilot_name'] = $line[2];
739 990
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
740 991
 			$data['ident'] = $line[0]; // ident
741
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
992
+			if ($line[7] != '' && $line[7] != 0) {
993
+				$data['altitude'] = $line[7];
994
+			}
995
+			// altitude
742 996
 			$data['speed'] = $line[8]; // speed
743
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
744
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
997
+			if (isset($line[45])) {
998
+				$data['heading'] = $line[45];
999
+			}
1000
+			// heading
1001
+			elseif (isset($line[38])) {
1002
+				$data['heading'] = $line[38];
1003
+			}
1004
+			// heading
745 1005
 			$data['latitude'] = $line[5]; // lat
746 1006
 	        	$data['longitude'] = $line[6]; // long
747 1007
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -757,7 +1017,9 @@  discard block
 block discarded – undo
757 1017
 			$data['frequency'] = $line[4];
758 1018
 			$data['type'] = $line[18];
759 1019
 			$data['range'] = $line[19];
760
-			if (isset($line[35])) $data['info'] = $line[35];
1020
+			if (isset($line[35])) {
1021
+				$data['info'] = $line[35];
1022
+			}
761 1023
     			$data['id_source'] = $id_source;
762 1024
 	    		//$data['arrival_airport_time'] = ;
763 1025
 	    		if ($line[9] != '') {
@@ -771,27 +1033,47 @@  discard block
 block discarded – undo
771 1033
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
772 1034
 	    		*/
773 1035
 	    		$data['format_source'] = $value['format'];
774
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
775
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
776
-    			if ($line[3] == 'PILOT') $SI->add($data);
777
-			elseif ($line[3] == 'ATC') {
1036
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1037
+				$data['noarchive'] = true;
1038
+			}
1039
+			if (isset($value['name']) && $value['name'] != '') {
1040
+				$data['source_name'] = $value['name'];
1041
+			}
1042
+    			if ($line[3] == 'PILOT') {
1043
+    				$SI->add($data);
1044
+    			} elseif ($line[3] == 'ATC') {
778 1045
 				//print_r($data);
779 1046
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
780 1047
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
781 1048
 				$typec = substr($data['ident'],-3);
782
-				if ($typec == 'APP') $data['type'] = 'Approach';
783
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
784
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
785
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
786
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
787
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
788
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
789
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
790
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
791
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1049
+				if ($typec == 'APP') {
1050
+					$data['type'] = 'Approach';
1051
+				} elseif ($typec == 'TWR') {
1052
+					$data['type'] = 'Tower';
1053
+				} elseif ($typec == 'OBS') {
1054
+					$data['type'] = 'Observer';
1055
+				} elseif ($typec == 'GND') {
1056
+					$data['type'] = 'Ground';
1057
+				} elseif ($typec == 'DEL') {
1058
+					$data['type'] = 'Delivery';
1059
+				} elseif ($typec == 'DEP') {
1060
+					$data['type'] = 'Departure';
1061
+				} elseif ($typec == 'FSS') {
1062
+					$data['type'] = 'Flight Service Station';
1063
+				} elseif ($typec == 'CTR') {
1064
+					$data['type'] = 'Control Radar or Centre';
1065
+				} elseif ($data['type'] == '') {
1066
+					$data['type'] = 'Observer';
1067
+				}
1068
+				if (!isset($data['source_name'])) {
1069
+					$data['source_name'] = '';
1070
+				}
792 1071
 				if (isset($ATC)) {
793
-					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']);
794
-					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']);
1072
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1073
+						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']);
1074
+					} else {
1075
+						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']);
1076
+					}
795 1077
 				}
796 1078
 			}
797 1079
     			unset($data);
@@ -818,14 +1100,20 @@  discard block
 block discarded – undo
818 1100
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
819 1101
 			$data['latitude'] = (float)$line['pktLatitude'];
820 1102
 			$data['longitude'] = (float)$line['pktLongitude'];
821
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
822
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1103
+			if ((float)$line['pktTrack'] != 0) {
1104
+				$data['heading'] = (float)$line['pktTrack'];
1105
+			}
1106
+			if ((int)$line['pktSpeed'] != 0) {
1107
+				$data['speed'] = (int)$line['pktSpeed'];
1108
+			}
823 1109
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
824 1110
 			$data['altitude_relative'] = 'AMSL';
825 1111
 			$data['pilot_id'] = (int)$line['pktPilotID'];
826 1112
 			$data['aircraft_icao'] = 'PARAGLIDER';
827 1113
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
828
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1114
+			if (isset($pilot_data[4])) {
1115
+				$data['pilot_name'] = $pilot_data[4];
1116
+			}
829 1117
 			$data['format_source'] = $value['format'];
830 1118
 			$SI->add($data);
831 1119
 			unset($data);
@@ -873,25 +1161,59 @@  discard block
 block discarded – undo
873 1161
 		    foreach ($all_data['acList'] as $line) {
874 1162
 			$data = array();
875 1163
 			$data['hex'] = $line['Icao']; // hex
876
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
877
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
878
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
879
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
880
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
881
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1164
+			if (isset($line['Call'])) {
1165
+				$data['ident'] = $line['Call'];
1166
+			}
1167
+			// ident
1168
+			if (isset($line['Alt'])) {
1169
+				$data['altitude'] = $line['Alt'];
1170
+			}
1171
+			// altitude
1172
+			if (isset($line['Spd'])) {
1173
+				$data['speed'] = $line['Spd'];
1174
+			}
1175
+			// speed
1176
+			if (isset($line['Trak'])) {
1177
+				$data['heading'] = $line['Trak'];
1178
+			}
1179
+			// heading
1180
+			if (isset($line['Lat'])) {
1181
+				$data['latitude'] = $line['Lat'];
1182
+			}
1183
+			// lat
1184
+			if (isset($line['Long'])) {
1185
+				$data['longitude'] = $line['Long'];
1186
+			}
1187
+			// long
882 1188
 			//$data['verticalrate'] = $line['']; // verticale rate
883
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1189
+			if (isset($line['Sqk'])) {
1190
+				$data['squawk'] = $line['Sqk'];
1191
+			}
1192
+			// squawk
884 1193
 			$data['emergency'] = ''; // emergency
885
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
886
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
887
-			else $data['datetime'] = date('Y-m-d H:i:s');
1194
+			if (isset($line['Reg'])) {
1195
+				$data['registration'] = $line['Reg'];
1196
+			}
1197
+			if (isset($line['PosTime'])) {
1198
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1199
+			} else {
1200
+				$data['datetime'] = date('Y-m-d H:i:s');
1201
+			}
888 1202
 			//$data['datetime'] = date('Y-m-d H:i:s');
889
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1203
+			if (isset($line['Type'])) {
1204
+				$data['aircraft_icao'] = $line['Type'];
1205
+			}
890 1206
 			$data['format_source'] = 'aircraftlistjson';
891 1207
 			$data['id_source'] = $id_source;
892
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
893
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
894
-			if (isset($data['latitude'])) $SI->add($data);
1208
+			if (isset($value['name']) && $value['name'] != '') {
1209
+				$data['source_name'] = $value['name'];
1210
+			}
1211
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1212
+				$data['noarchive'] = true;
1213
+			}
1214
+			if (isset($data['latitude'])) {
1215
+				$SI->add($data);
1216
+			}
895 1217
 			unset($data);
896 1218
 		    }
897 1219
 		} elseif (is_array($all_data)) {
@@ -908,17 +1230,26 @@  discard block
 block discarded – undo
908 1230
 			$data['verticalrate'] = $line['vrt']; // verticale rate
909 1231
 			$data['squawk'] = $line['squawk']; // squawk
910 1232
 			$data['emergency'] = ''; // emergency
911
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
912
-			else $data['datetime'] = date('Y-m-d H:i:s');
1233
+			if (isset($line['PosTime'])) {
1234
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1235
+			} else {
1236
+				$data['datetime'] = date('Y-m-d H:i:s');
1237
+			}
913 1238
 			$data['format_source'] = 'aircraftlistjson';
914 1239
 			$data['id_source'] = $id_source;
915
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
916
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1240
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1241
+				$data['noarchive'] = true;
1242
+			}
1243
+			if (isset($value['name']) && $value['name'] != '') {
1244
+				$data['source_name'] = $value['name'];
1245
+			}
917 1246
 			$SI->add($data);
918 1247
 			unset($data);
919 1248
 		    }
920 1249
 		}
921
-	    } elseif ($globalDebug) echo 'No data'."\n";
1250
+	    } elseif ($globalDebug) {
1251
+	    	echo 'No data'."\n";
1252
+	    }
922 1253
     	    //$last_exec['aircraftlistjson'] = time();
923 1254
     	    $last_exec[$id]['last'] = time();
924 1255
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -954,8 +1285,12 @@  discard block
 block discarded – undo
954 1285
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
955 1286
 	    	    $data['format_source'] = 'planeupdatefaa';
956 1287
     		    $data['id_source'] = $id_source;
957
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
958
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1288
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1289
+		    	$data['noarchive'] = true;
1290
+		    }
1291
+		    if (isset($value['name']) && $value['name'] != '') {
1292
+		    	$data['source_name'] = $value['name'];
1293
+		    }
959 1294
 		    $SI->add($data);
960 1295
 		    unset($data);
961 1296
 		}
@@ -989,7 +1324,9 @@  discard block
 block discarded – undo
989 1324
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
990 1325
 		    $data['format_source'] = 'opensky';
991 1326
 		    $data['id_source'] = $id_source;
992
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1327
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1328
+		    	$data['noarchive'] = true;
1329
+		    }
993 1330
 		    $SI->add($data);
994 1331
 		    unset($data);
995 1332
 		}
@@ -1006,7 +1343,9 @@  discard block
 block discarded – undo
1006 1343
 	    //$buffer = $Common->getData($hosts[$id]);
1007 1344
 	    $buffer = $Common->getData($value['host']);
1008 1345
 	    $all_data = json_decode($buffer,true);
1009
-	    if (!empty($all_data)) $reset = 0;
1346
+	    if (!empty($all_data)) {
1347
+	    	$reset = 0;
1348
+	    }
1010 1349
 	    foreach ($all_data as $key => $line) {
1011 1350
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1012 1351
 		    $data = array();
@@ -1027,8 +1366,12 @@  discard block
 block discarded – undo
1027 1366
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1028 1367
 	    	    $data['format_source'] = 'fr24json';
1029 1368
     		    $data['id_source'] = $id_source;
1030
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1031
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1369
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1370
+		    	$data['noarchive'] = true;
1371
+		    }
1372
+		    if (isset($value['name']) && $value['name'] != '') {
1373
+		    	$data['source_name'] = $value['name'];
1374
+		    }
1032 1375
 		    $SI->add($data);
1033 1376
 		    unset($data);
1034 1377
 		}
@@ -1057,24 +1400,42 @@  discard block
 block discarded – undo
1057 1400
 		    if (isset($line['inf'])) {
1058 1401
 			$data = array();
1059 1402
 			$data['hex'] = $line['inf']['ia'];
1060
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1403
+			if (isset($line['inf']['cs'])) {
1404
+				$data['ident'] = $line['inf']['cs'];
1405
+			}
1406
+			//$line[13]
1061 1407
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1062
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1063
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1408
+	    		if (isset($line['inf']['gs'])) {
1409
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1410
+	    		}
1411
+	    		// speed
1412
+	    		if (isset($line['inf']['tr'])) {
1413
+	    			$data['heading'] = $line['inf']['tr'];
1414
+	    		}
1415
+	    		// heading
1064 1416
 	    		$data['latitude'] = $line['pt'][0]; // lat
1065 1417
 	    		$data['longitude'] = $line['pt'][1]; // long
1066 1418
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1067
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1419
+	    		if (isset($line['inf']['sq'])) {
1420
+	    			$data['squawk'] = $line['inf']['sq'];
1421
+	    		}
1422
+	    		// squawk
1068 1423
 	    		//$data['aircraft_icao'] = $line[8];
1069
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1424
+	    		if (isset($line['inf']['rc'])) {
1425
+	    			$data['registration'] = $line['inf']['rc'];
1426
+	    		}
1070 1427
 			//$data['departure_airport_iata'] = $line[11];
1071 1428
 			//$data['arrival_airport_iata'] = $line[12];
1072 1429
 	    		//$data['emergency'] = ''; // emergency
1073 1430
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1074 1431
 	    		$data['format_source'] = 'radarvirtueljson';
1075 1432
     			$data['id_source'] = $id_source;
1076
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1077
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1433
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1434
+				$data['noarchive'] = true;
1435
+			}
1436
+			if (isset($value['name']) && $value['name'] != '') {
1437
+				$data['source_name'] = $value['name'];
1438
+			}
1078 1439
 			$SI->add($data);
1079 1440
 			unset($data);
1080 1441
 		    }
@@ -1100,30 +1461,65 @@  discard block
 block discarded – undo
1100 1461
 		    $data['id'] = $line['id'];
1101 1462
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1102 1463
 		    $data['ident'] = $line['callsign']; // ident
1103
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1104
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1105
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1106
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1107
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1108
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1464
+		    if (isset($line['pilotid'])) {
1465
+		    	$data['pilot_id'] = $line['pilotid'];
1466
+		    }
1467
+		    // pilot id
1468
+		    if (isset($line['name'])) {
1469
+		    	$data['pilot_name'] = $line['name'];
1470
+		    }
1471
+		    // pilot name
1472
+		    if (isset($line['alt'])) {
1473
+		    	$data['altitude'] = $line['alt'];
1474
+		    }
1475
+		    // altitude
1476
+		    if (isset($line['gs'])) {
1477
+		    	$data['speed'] = $line['gs'];
1478
+		    }
1479
+		    // speed
1480
+		    if (isset($line['heading'])) {
1481
+		    	$data['heading'] = $line['heading'];
1482
+		    }
1483
+		    // heading
1484
+		    if (isset($line['route'])) {
1485
+		    	$data['waypoints'] = $line['route'];
1486
+		    }
1487
+		    // route
1109 1488
 		    $data['latitude'] = $line['lat']; // lat
1110 1489
 		    $data['longitude'] = $line['lon']; // long
1111 1490
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1112 1491
 		    //$data['squawk'] = $line['squawk']; // squawk
1113 1492
 		    //$data['emergency'] = ''; // emergency
1114
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1115
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1116
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1493
+		    if (isset($line['depicao'])) {
1494
+		    	$data['departure_airport_icao'] = $line['depicao'];
1495
+		    }
1496
+		    if (isset($line['deptime'])) {
1497
+		    	$data['departure_airport_time'] = $line['deptime'];
1498
+		    }
1499
+		    if (isset($line['arricao'])) {
1500
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1501
+		    }
1117 1502
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1118
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1119
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1120
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1121
-		    else $data['info'] = '';
1503
+		    if (isset($line['aircraft'])) {
1504
+		    	$data['aircraft_icao'] = $line['aircraft'];
1505
+		    }
1506
+		    if (isset($line['transponder'])) {
1507
+		    	$data['squawk'] = $line['transponder'];
1508
+		    }
1509
+		    if (isset($line['atis'])) {
1510
+		    	$data['info'] = $line['atis'];
1511
+		    } else {
1512
+		    	$data['info'] = '';
1513
+		    }
1122 1514
 		    $data['format_source'] = 'pireps';
1123 1515
     		    $data['id_source'] = $id_source;
1124 1516
 		    $data['datetime'] = date('Y-m-d H:i:s');
1125
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1126
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1517
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1518
+		    	$data['noarchive'] = true;
1519
+		    }
1520
+		    if (isset($value['name']) && $value['name'] != '') {
1521
+		    	$data['source_name'] = $value['name'];
1522
+		    }
1127 1523
 		    if ($line['icon'] == 'plane') {
1128 1524
 			$SI->add($data);
1129 1525
 		    //    print_r($data);
@@ -1132,16 +1528,28 @@  discard block
 block discarded – undo
1132 1528
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1133 1529
 			$typec = substr($data['ident'],-3);
1134 1530
 			$data['type'] = '';
1135
-			if ($typec == 'APP') $data['type'] = 'Approach';
1136
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1137
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1138
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1139
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1140
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1141
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1142
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1143
-			else $data['type'] = 'Observer';
1144
-			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']);
1531
+			if ($typec == 'APP') {
1532
+				$data['type'] = 'Approach';
1533
+			} elseif ($typec == 'TWR') {
1534
+				$data['type'] = 'Tower';
1535
+			} elseif ($typec == 'OBS') {
1536
+				$data['type'] = 'Observer';
1537
+			} elseif ($typec == 'GND') {
1538
+				$data['type'] = 'Ground';
1539
+			} elseif ($typec == 'DEL') {
1540
+				$data['type'] = 'Delivery';
1541
+			} elseif ($typec == 'DEP') {
1542
+				$data['type'] = 'Departure';
1543
+			} elseif ($typec == 'FSS') {
1544
+				$data['type'] = 'Flight Service Station';
1545
+			} elseif ($typec == 'CTR') {
1546
+				$data['type'] = 'Control Radar or Centre';
1547
+			} else {
1548
+				$data['type'] = 'Observer';
1549
+			}
1550
+			if (isset($ATC)) {
1551
+				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']);
1552
+			}
1145 1553
 		    }
1146 1554
 		    unset($data);
1147 1555
 		}
@@ -1156,7 +1564,9 @@  discard block
 block discarded – undo
1156 1564
 	    )
1157 1565
 	) {
1158 1566
 	    //$buffer = $Common->getData($hosts[$id]);
1159
-	    if ($globalDebug) echo 'Get Data...'."\n";
1567
+	    if ($globalDebug) {
1568
+	    	echo 'Get Data...'."\n";
1569
+	    }
1160 1570
 	    $buffer = $Common->getData($value['host']);
1161 1571
 	    $all_data = json_decode($buffer,true);
1162 1572
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1164,10 +1574,16 @@  discard block
 block discarded – undo
1164 1574
 		foreach ($all_data as $line) {
1165 1575
 	    	    $data = array();
1166 1576
 	    	    //$data['id'] = $line['id']; // id not usable
1167
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1577
+	    	    if (isset($line['pilotid'])) {
1578
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1579
+	    	    }
1168 1580
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1169
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1170
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1581
+	    	    if (isset($line['pilotname'])) {
1582
+	    	    	$data['pilot_name'] = $line['pilotname'];
1583
+	    	    }
1584
+	    	    if (isset($line['pilotid'])) {
1585
+	    	    	$data['pilot_id'] = $line['pilotid'];
1586
+	    	    }
1171 1587
 	    	    $data['ident'] = $line['flightnum']; // ident
1172 1588
 	    	    $data['altitude'] = $line['alt']; // altitude
1173 1589
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1183,34 +1599,52 @@  discard block
 block discarded – undo
1183 1599
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1184 1600
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1185 1601
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1186
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1602
+	    	    } else {
1603
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1604
+	    	    }
1187 1605
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1188 1606
 	    	    $data['departure_airport_time'] = $line['deptime'];
1189 1607
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1190 1608
     		    $data['arrival_airport_time'] = $line['arrtime'];
1191 1609
     		    $data['registration'] = $line['aircraft'];
1192
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1193
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1610
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1611
+		    	$data['noarchive'] = true;
1612
+		    }
1613
+		    if (isset($line['route'])) {
1614
+		    	$data['waypoints'] = $line['route'];
1615
+		    }
1616
+		    // route
1194 1617
 		    if (isset($line['aircraftname'])) {
1195 1618
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1196 1619
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1197 1620
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1198
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1199
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1200
-	    		else {
1621
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1622
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1623
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1624
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1625
+	    		} else {
1201 1626
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1202
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1203
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1627
+	    		    if (isset($aircraft_data[1])) {
1628
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1629
+	    		    } else {
1630
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1631
+	    		    }
1204 1632
 	    		}
1205 1633
 	    	    }
1206
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1634
+    		    if (isset($line['route'])) {
1635
+    		    	$data['waypoints'] = $line['route'];
1636
+    		    }
1207 1637
     		    $data['id_source'] = $id_source;
1208 1638
 	    	    $data['format_source'] = 'phpvmacars';
1209
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1639
+		    if (isset($value['name']) && $value['name'] != '') {
1640
+		    	$data['source_name'] = $value['name'];
1641
+		    }
1210 1642
 		    $SI->add($data);
1211 1643
 		    unset($data);
1212 1644
 		}
1213
-		if ($globalDebug) echo 'No more data...'."\n";
1645
+		if ($globalDebug) {
1646
+			echo 'No more data...'."\n";
1647
+		}
1214 1648
 		unset($buffer);
1215 1649
 		unset($all_data);
1216 1650
 	    }
@@ -1223,7 +1657,9 @@  discard block
 block discarded – undo
1223 1657
 	    )
1224 1658
 	) {
1225 1659
 	    //$buffer = $Common->getData($hosts[$id]);
1226
-	    if ($globalDebug) echo 'Get Data...'."\n";
1660
+	    if ($globalDebug) {
1661
+	    	echo 'Get Data...'."\n";
1662
+	    }
1227 1663
 	    $buffer = $Common->getData($value['host']);
1228 1664
 	    $all_data = json_decode($buffer,true);
1229 1665
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1252,16 +1688,25 @@  discard block
 block discarded – undo
1252 1688
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1253 1689
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1254 1690
     		    //$data['registration'] = $line['aircraft'];
1255
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1691
+		    if (isset($line['route'])) {
1692
+		    	$data['waypoints'] = $line['route'];
1693
+		    }
1694
+		    // route
1256 1695
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1257 1696
     		    $data['id_source'] = $id_source;
1258 1697
 	    	    $data['format_source'] = 'vam';
1259
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1260
-		    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
+		    }
1261 1704
 		    $SI->add($data);
1262 1705
 		    unset($data);
1263 1706
 		}
1264
-		if ($globalDebug) echo 'No more data...'."\n";
1707
+		if ($globalDebug) {
1708
+			echo 'No more data...'."\n";
1709
+		}
1265 1710
 		unset($buffer);
1266 1711
 		unset($all_data);
1267 1712
 	    }
@@ -1274,7 +1719,9 @@  discard block
 block discarded – undo
1274 1719
 	    )
1275 1720
 	) {
1276 1721
 	    //$buffer = $Common->getData($hosts[$id]);
1277
-	    if ($globalDebug) echo 'Get Data...'."\n";
1722
+	    if ($globalDebug) {
1723
+	    	echo 'Get Data...'."\n";
1724
+	    }
1278 1725
 	    $buffer = $Common->getData($value['host']);
1279 1726
 	    $all_data = json_decode($buffer,true);
1280 1727
 	    if ($buffer != '') {
@@ -1292,18 +1739,24 @@  discard block
 block discarded – undo
1292 1739
 			$data['id_source'] = $id_source;
1293 1740
 			$data['format_source'] = 'blitzortung';
1294 1741
 			$SI->add($data);
1295
-			if ($globalDebug) echo '☈ Lightning added'."\n";
1742
+			if ($globalDebug) {
1743
+				echo '☈ Lightning added'."\n";
1744
+			}
1296 1745
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1297 1746
 			unset($data);
1298 1747
 		    }
1299 1748
 		}
1300
-		if ($globalDebug) echo 'No more data...'."\n";
1749
+		if ($globalDebug) {
1750
+			echo 'No more data...'."\n";
1751
+		}
1301 1752
 		unset($buffer);
1302 1753
 	    }
1303 1754
 	    $last_exec[$id]['last'] = time();
1304 1755
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1305 1756
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1306
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1757
+	    if (function_exists('pcntl_fork')) {
1758
+	    	pcntl_signal_dispatch();
1759
+	    }
1307 1760
     	    //$last_exec[$id]['last'] = time();
1308 1761
 
1309 1762
 	    //$read = array( $sockets[$id] );
@@ -1311,7 +1764,9 @@  discard block
 block discarded – undo
1311 1764
 	    $write = NULL;
1312 1765
 	    $e = NULL;
1313 1766
 	    $n = socket_select($read, $write, $e, $timeout);
1314
-	    if ($e != NULL) var_dump($e);
1767
+	    if ($e != NULL) {
1768
+	    	var_dump($e);
1769
+	    }
1315 1770
 	    if ($n > 0) {
1316 1771
 		$reset = 0;
1317 1772
 		foreach ($read as $nb => $r) {
@@ -1333,13 +1788,17 @@  discard block
 block discarded – undo
1333 1788
 		    if ($buffer !== FALSE) {
1334 1789
 			if ($format == 'vrstcp') {
1335 1790
 			    $buffer = explode('},{',$buffer);
1336
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1791
+			} else {
1792
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1793
+			}
1337 1794
 		    }
1338 1795
 		    // SBS format is CSV format
1339 1796
 		    if ($buffer !== FALSE && $buffer !== '') {
1340 1797
 			$tt[$format] = 0;
1341 1798
 			if ($format == 'acarssbs3') {
1342
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1799
+			    if ($globalDebug) {
1800
+			    	echo 'ACARS : '.$buffer."\n";
1801
+			    }
1343 1802
 			    $ACARS->add(trim($buffer));
1344 1803
 			    $ACARS->deleteLiveAcarsData();
1345 1804
 			} elseif ($format == 'raw') {
@@ -1348,30 +1807,70 @@  discard block
 block discarded – undo
1348 1807
 			    if (is_array($data)) {
1349 1808
 				$data['datetime'] = date('Y-m-d H:i:s');
1350 1809
 				$data['format_source'] = 'raw';
1351
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1352
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1353
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1354
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1810
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1811
+					$data['source_name'] = $globalSources[$nb]['name'];
1812
+				}
1813
+				if (isset($globalSources[$nb]['sourcestats'])) {
1814
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1815
+				}
1816
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1817
+					$data['noarchive'] = true;
1818
+				}
1819
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1820
+					$SI->add($data);
1821
+				}
1355 1822
 			    }
1356 1823
 			} elseif ($format == 'ais') {
1357 1824
 			    $ais_data = $AIS->parse_line(trim($buffer));
1358 1825
 			    $data = array();
1359
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1360
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1361
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1362
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1363
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1364
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1365
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1366
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1367
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1368
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1369
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1370
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1371
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1372
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1373
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1374
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1826
+			    if (isset($ais_data['ident'])) {
1827
+			    	$data['ident'] = $ais_data['ident'];
1828
+			    }
1829
+			    if (isset($ais_data['mmsi'])) {
1830
+			    	$data['mmsi'] = $ais_data['mmsi'];
1831
+			    }
1832
+			    if (isset($ais_data['speed'])) {
1833
+			    	$data['speed'] = $ais_data['speed'];
1834
+			    }
1835
+			    if (isset($ais_data['heading'])) {
1836
+			    	$data['heading'] = $ais_data['heading'];
1837
+			    }
1838
+			    if (isset($ais_data['latitude'])) {
1839
+			    	$data['latitude'] = $ais_data['latitude'];
1840
+			    }
1841
+			    if (isset($ais_data['longitude'])) {
1842
+			    	$data['longitude'] = $ais_data['longitude'];
1843
+			    }
1844
+			    if (isset($ais_data['status'])) {
1845
+			    	$data['status'] = $ais_data['status'];
1846
+			    }
1847
+			    if (isset($ais_data['statusid'])) {
1848
+			    	$data['status_id'] = $ais_data['statusid'];
1849
+			    }
1850
+			    if (isset($ais_data['type'])) {
1851
+			    	$data['type'] = $ais_data['type'];
1852
+			    }
1853
+			    if (isset($ais_data['imo'])) {
1854
+			    	$data['imo'] = $ais_data['imo'];
1855
+			    }
1856
+			    if (isset($ais_data['callsign'])) {
1857
+			    	$data['callsign'] = $ais_data['callsign'];
1858
+			    }
1859
+			    if (isset($ais_data['destination'])) {
1860
+			    	$data['arrival_code'] = $ais_data['destination'];
1861
+			    }
1862
+			    if (isset($ais_data['eta_ts'])) {
1863
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1864
+			    }
1865
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1866
+			    	$data['noarchive'] = true;
1867
+			    }
1868
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1869
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1870
+			    }
1871
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1872
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1873
+			    }
1375 1874
 
1376 1875
 			    if (isset($ais_data['timestamp'])) {
1377 1876
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1380,7 +1879,9 @@  discard block
 block discarded – undo
1380 1879
 			    }
1381 1880
 			    $data['format_source'] = 'aisnmea';
1382 1881
     			    $data['id_source'] = $id_source;
1383
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1882
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1883
+			    	$MI->add($data);
1884
+			    }
1384 1885
 			    unset($data);
1385 1886
                         } elseif ($format == 'flightgearsp') {
1386 1887
                     	    //echo $buffer."\n";
@@ -1398,12 +1899,18 @@  discard block
 block discarded – undo
1398 1899
 				$data['speed'] = round($line[5]*1.94384);
1399 1900
 				$data['datetime'] = date('Y-m-d H:i:s');
1400 1901
 				$data['format_source'] = 'flightgearsp';
1401
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1402
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1902
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1903
+					$data['noarchive'] = true;
1904
+				}
1905
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1906
+					$SI->add($data);
1907
+				}
1403 1908
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1404 1909
 			    }
1405 1910
                         } elseif ($format == 'acars') {
1406
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1911
+                    	    if ($globalDebug) {
1912
+                    	    	echo 'ACARS : '.$buffer."\n";
1913
+                    	    }
1407 1914
 			    $ACARS->add(trim($buffer));
1408 1915
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1409 1916
 			    $ACARS->deleteLiveAcarsData();
@@ -1424,8 +1931,12 @@  discard block
 block discarded – undo
1424 1931
 				    $aircraft_type = $line[10];
1425 1932
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1426 1933
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1427
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1428
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1934
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1935
+				    	$data['noarchive'] = true;
1936
+				    }
1937
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1938
+				    	$SI->add($data);
1939
+				    }
1429 1940
 				}
1430 1941
 			    }
1431 1942
 			} elseif ($format == 'beast') {
@@ -1435,28 +1946,62 @@  discard block
 block discarded – undo
1435 1946
 			    foreach($buffer as $all_data) {
1436 1947
 				$line = json_decode('{'.$all_data.'}',true);
1437 1948
 				$data = array();
1438
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1439
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1440
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1441
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1442
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1443
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1444
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1949
+				if (isset($line['Icao'])) {
1950
+					$data['hex'] = $line['Icao'];
1951
+				}
1952
+				// hex
1953
+				if (isset($line['Call'])) {
1954
+					$data['ident'] = $line['Call'];
1955
+				}
1956
+				// ident
1957
+				if (isset($line['Alt'])) {
1958
+					$data['altitude'] = $line['Alt'];
1959
+				}
1960
+				// altitude
1961
+				if (isset($line['Spd'])) {
1962
+					$data['speed'] = $line['Spd'];
1963
+				}
1964
+				// speed
1965
+				if (isset($line['Trak'])) {
1966
+					$data['heading'] = $line['Trak'];
1967
+				}
1968
+				// heading
1969
+				if (isset($line['Lat'])) {
1970
+					$data['latitude'] = $line['Lat'];
1971
+				}
1972
+				// lat
1973
+				if (isset($line['Long'])) {
1974
+					$data['longitude'] = $line['Long'];
1975
+				}
1976
+				// long
1445 1977
 				//$data['verticalrate'] = $line['']; // verticale rate
1446
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1978
+				if (isset($line['Sqk'])) {
1979
+					$data['squawk'] = $line['Sqk'];
1980
+				}
1981
+				// squawk
1447 1982
 				$data['emergency'] = ''; // emergency
1448
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1983
+				if (isset($line['Reg'])) {
1984
+					$data['registration'] = $line['Reg'];
1985
+				}
1449 1986
 				/*
1450 1987
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1451 1988
 				else $data['datetime'] = date('Y-m-d H:i:s');
1452 1989
 				*/
1453 1990
 				$data['datetime'] = date('Y-m-d H:i:s');
1454
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1991
+				if (isset($line['Type'])) {
1992
+					$data['aircraft_icao'] = $line['Type'];
1993
+				}
1455 1994
 		    		$data['format_source'] = 'vrstcp';
1456 1995
 				$data['id_source'] = $id_source;
1457
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1458
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1459
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1996
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1997
+					$data['noarchive'] = true;
1998
+				}
1999
+				if (isset($value['name']) && $value['name'] != '') {
2000
+					$data['source_name'] = $value['name'];
2001
+				}
2002
+				if (isset($data['latitude']) && isset($data['hex'])) {
2003
+					$SI->add($data);
2004
+				}
1460 2005
 				unset($data);
1461 2006
 			    }
1462 2007
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1469,22 +2014,46 @@  discard block
 block discarded – undo
1469 2014
     				$data['hex'] = $lined['hexid'];
1470 2015
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1471 2016
     				$data['datetime'] = date('Y-m-d H:i:s');;
1472
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1473
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1474
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1475
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1476
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1477
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1478
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2017
+    				if (isset($lined['ident'])) {
2018
+    					$data['ident'] = $lined['ident'];
2019
+    				}
2020
+    				if (isset($lined['lat'])) {
2021
+    					$data['latitude'] = $lined['lat'];
2022
+    				}
2023
+    				if (isset($lined['lon'])) {
2024
+    					$data['longitude'] = $lined['lon'];
2025
+    				}
2026
+    				if (isset($lined['speed'])) {
2027
+    					$data['speed'] = $lined['speed'];
2028
+    				}
2029
+    				if (isset($lined['squawk'])) {
2030
+    					$data['squawk'] = $lined['squawk'];
2031
+    				}
2032
+    				if (isset($lined['alt'])) {
2033
+    					$data['altitude'] = $lined['alt'];
2034
+    				}
2035
+    				if (isset($lined['heading'])) {
2036
+    					$data['heading'] = $lined['heading'];
2037
+    				}
1479 2038
     				$data['id_source'] = $id_source;
1480 2039
     				$data['format_source'] = 'tsv';
1481
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1482
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1483
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1484
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2040
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2041
+    					$data['source_name'] = $globalSources[$nb]['name'];
2042
+    				}
2043
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2044
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2045
+    				}
2046
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2047
+					$data['noarchive'] = true;
2048
+				}
2049
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2050
+    					$SI->add($data);
2051
+    				}
1485 2052
     				unset($lined);
1486 2053
     				unset($data);
1487
-    			    } else $error = true;
2054
+    			    } else {
2055
+    			    	$error = true;
2056
+    			    }
1488 2057
 			} elseif ($format == 'aprs' && $use_aprs) {
1489 2058
 			    if ($aprs_connect == 0) {
1490 2059
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1510,63 +2079,121 @@  discard block
 block discarded – undo
1510 2079
 				    $aprs_last_tx = time();
1511 2080
 				    $data = array();
1512 2081
 				    //print_r($line);
1513
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1514
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1515
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1516
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1517
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1518
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1519
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1520
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1521
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1522
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2082
+				    if (isset($line['address'])) {
2083
+				    	$data['hex'] = $line['address'];
2084
+				    }
2085
+				    if (isset($line['mmsi'])) {
2086
+				    	$data['mmsi'] = $line['mmsi'];
2087
+				    }
2088
+				    if (isset($line['imo'])) {
2089
+				    	$data['imo'] = $line['imo'];
2090
+				    }
2091
+				    if (isset($line['squawk'])) {
2092
+				    	$data['squawk'] = $line['squawk'];
2093
+				    }
2094
+				    if (isset($line['arrival_code'])) {
2095
+				    	$data['arrical_code'] = $line['arrival_code'];
2096
+				    }
2097
+				    if (isset($line['arrival_date'])) {
2098
+				    	$data['arrical_date'] = $line['arrival_date'];
2099
+				    }
2100
+				    if (isset($line['type_id'])) {
2101
+				    	$data['type_id'] = $line['typeid'];
2102
+				    }
2103
+				    if (isset($line['status_id'])) {
2104
+				    	$data['status_id'] = $line['statusid'];
2105
+				    }
2106
+				    if (isset($line['timestamp'])) {
2107
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2108
+				    } else {
2109
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2110
+				    }
1523 2111
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1524
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2112
+				    if (isset($line['ident'])) {
2113
+				    	$data['ident'] = $line['ident'];
2114
+				    }
1525 2115
 				    $data['latitude'] = $line['latitude'];
1526 2116
 				    $data['longitude'] = $line['longitude'];
1527 2117
 				    //$data['verticalrate'] = $line[16];
1528
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2118
+				    if (isset($line['speed'])) {
2119
+				    	$data['speed'] = $line['speed'];
2120
+				    }
1529 2121
 				    //else $data['speed'] = 0;
1530
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1531
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1532
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2122
+				    if (isset($line['altitude'])) {
2123
+				    	$data['altitude'] = $line['altitude'];
2124
+				    }
2125
+				    if (isset($line['comment'])) {
2126
+				    	$data['comment'] = $line['comment'];
2127
+				    }
2128
+				    if (isset($line['symbol'])) {
2129
+				    	$data['type'] = $line['symbol'];
2130
+				    }
1533 2131
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1534 2132
 				    
1535
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2133
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2134
+				    	$data['heading'] = $line['heading'];
2135
+				    }
1536 2136
 				    //else echo 'No heading...'."\n";
1537 2137
 				    //else $data['heading'] = 0;
1538
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2138
+				    if (isset($line['stealth'])) {
2139
+				    	$data['aircraft_type'] = $line['stealth'];
2140
+				    }
1539 2141
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1540
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1541
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1542
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1543
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2142
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2143
+				    	$data['noarchive'] = true;
2144
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2145
+				    	$data['noarchive'] = false;
2146
+				    }
2147
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2148
+				    	$data['noarchive'] = true;
2149
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2150
+				    	$data['noarchive'] = false;
2151
+				    }
1544 2152
     				    $data['id_source'] = $id_source;
1545
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1546
-				    else $data['format_source'] = 'aprs';
2153
+    				    if (isset($line['format_source'])) {
2154
+    				    	$data['format_source'] = $line['format_source'];
2155
+    				    } else {
2156
+				    	$data['format_source'] = 'aprs';
2157
+				    }
1547 2158
 				    $data['source_name'] = $line['source'];
1548
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1549
-				    else $data['source_type'] = 'flarm';
1550
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2159
+				    if (isset($line['source_type'])) {
2160
+				    	$data['source_type'] = $line['source_type'];
2161
+				    } else {
2162
+				    	$data['source_type'] = 'flarm';
2163
+				    }
2164
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2165
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2166
+    				    }
1551 2167
 				    $currentdate = date('Y-m-d H:i:s');
1552 2168
 				    $aprsdate = strtotime($data['datetime']);
1553
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2169
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2170
+				    	$data['altitude_relative'] = 'AMSL';
2171
+				    }
1554 2172
 				    // Accept data if time <= system time + 20s
1555 2173
 				    //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'])))) {
1556 2174
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1557 2175
 					$send = $SI->add($data);
1558 2176
 				    } elseif ($data['source_type'] == 'ais') {
1559 2177
 					$data['type'] = '';
1560
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2178
+					if (isset($globalMarine) && $globalMarine) {
2179
+						$send = $MI->add($data);
2180
+					}
1561 2181
 				    } elseif (isset($line['stealth'])) {
1562
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1563
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2182
+					if ($line['stealth'] != 0) {
2183
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2184
+					} else {
2185
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2186
+					}
1564 2187
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1565 2188
 					    //$line['symbol'] == 'Balloon' ||
1566 2189
 					    $line['symbol'] == 'Glider' || 
1567 2190
 					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1568
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1569
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2191
+					    if ($line['symbol'] == 'Ballon') {
2192
+					    	$data['aircraft_icao'] = 'BALL';
2193
+					    }
2194
+					    if ($line['symbol'] == 'Glider') {
2195
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2196
+					    }
1570 2197
 					    $send = $SI->add($data);
1571 2198
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1572 2199
 					    $line['symbol'] == 'Yacht (Sail)' || 
@@ -1597,9 +2224,13 @@  discard block
 block discarded – undo
1597 2224
 				    //} 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') {
1598 2225
 				//    } 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') {
1599 2226
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1600
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2227
+					if (isset($globalTracker) && $globalTracker) {
2228
+						$send = $TI->add($data);
2229
+					}
1601 2230
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1602
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2231
+					if (!isset($data['altitude'])) {
2232
+						$data['altitude'] = 0;
2233
+					}
1603 2234
 					$Source->deleteOldLocationByType('gs');
1604 2235
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1605 2236
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1608,7 +2239,9 @@  discard block
 block discarded – undo
1608 2239
 					}
1609 2240
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1610 2241
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1611
-					if ($globalDebug) echo '# Weather Station added'."\n";
2242
+					if ($globalDebug) {
2243
+						echo '# Weather Station added'."\n";
2244
+					}
1612 2245
 					$Source->deleteOldLocationByType('wx');
1613 2246
 					$weather_data = json_encode($line);
1614 2247
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1618,7 +2251,9 @@  discard block
 block discarded – undo
1618 2251
 					}
1619 2252
 				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1620 2253
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1621
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2254
+					if ($globalDebug) {
2255
+						echo '☈ Lightning added'."\n";
2256
+					}
1622 2257
 					$Source->deleteOldLocationByType('lightning');
1623 2258
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1624 2259
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1630,8 +2265,7 @@  discard block
 block discarded – undo
1630 2265
 				    	print_r($line);
1631 2266
 				    }
1632 2267
 				    unset($data);
1633
-				}
1634
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2268
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1635 2269
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1636 2270
 				}
1637 2271
 				/*
@@ -1640,7 +2274,9 @@  discard block
 block discarded – undo
1640 2274
 				}
1641 2275
 				*/
1642 2276
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1643
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2277
+				elseif ($line == true && $globalDebug) {
2278
+					echo '!! Failed : '.$buffer."!!\n";
2279
+				}
1644 2280
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1645 2281
 					$Source->deleteOldLocationByType('lightning');
1646 2282
 					$Source->deleteOldLocationByType('wx');
@@ -1676,26 +2312,45 @@  discard block
 block discarded – undo
1676 2312
     				$data['ground'] = $line[21];
1677 2313
     				$data['emergency'] = $line[19];
1678 2314
     				$data['format_source'] = 'sbs';
1679
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1680
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1681
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2315
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2316
+					$data['source_name'] = $globalSources[$nb]['name'];
2317
+				}
2318
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2319
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2320
+    				}
2321
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2322
+					$data['noarchive'] = true;
2323
+				}
1682 2324
     				$data['id_source'] = $id_source;
1683
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1684
-    				else $error = true;
2325
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2326
+    					$send = $SI->add($data);
2327
+    				} else {
2328
+    					$error = true;
2329
+    				}
1685 2330
     				unset($data);
1686
-    			    } else $error = true;
2331
+    			    } else {
2332
+    			    	$error = true;
2333
+    			    }
1687 2334
 			    if ($error) {
1688 2335
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1689
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2336
+					if ($globalDebug) {
2337
+						echo "Not a message. Ignoring... \n";
2338
+					}
1690 2339
 				} else {
1691
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2340
+					if ($globalDebug) {
2341
+						echo "Wrong line format. Ignoring... \n";
2342
+					}
1692 2343
 					if ($globalDebug) {
1693 2344
 						echo $buffer;
1694 2345
 						//print_r($line);
1695 2346
 					}
1696 2347
 					//socket_close($r);
1697
-					if ($globalDebug) echo "Reconnect after an error...\n";
1698
-					if ($format == 'aprs') $aprs_connect = 0;
2348
+					if ($globalDebug) {
2349
+						echo "Reconnect after an error...\n";
2350
+					}
2351
+					if ($format == 'aprs') {
2352
+						$aprs_connect = 0;
2353
+					}
1699 2354
 					$sourceer[$nb] = $globalSources[$nb];
1700 2355
 					connect_all($sourceer);
1701 2356
 					$sourceer = array();
@@ -1703,10 +2358,14 @@  discard block
 block discarded – undo
1703 2358
 			    }
1704 2359
 			}
1705 2360
 			// Sleep for xxx microseconds
1706
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2361
+			if (isset($globalSBSSleep)) {
2362
+				usleep($globalSBSSleep);
2363
+			}
1707 2364
 		    } else {
1708 2365
 			if ($format == 'flightgearmp') {
1709
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2366
+			    	if ($globalDebug) {
2367
+			    		echo "Reconnect FlightGear MP...";
2368
+			    	}
1710 2369
 				//@socket_close($r);
1711 2370
 				sleep($globalMinFetch);
1712 2371
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1715,10 +2374,15 @@  discard block
 block discarded – undo
1715 2374
 				break;
1716 2375
 				
1717 2376
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1718
-			    if (isset($tt[$format])) $tt[$format]++;
1719
-			    else $tt[$format] = 0;
2377
+			    if (isset($tt[$format])) {
2378
+			    	$tt[$format]++;
2379
+			    } else {
2380
+			    	$tt[$format] = 0;
2381
+			    }
1720 2382
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1721
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2383
+				if ($globalDebug) {
2384
+					echo "ERROR : Reconnect ".$format."...";
2385
+				}
1722 2386
 				//@socket_close($r);
1723 2387
 				sleep(2);
1724 2388
 				$aprs_connect = 0;
@@ -1736,11 +2400,17 @@  discard block
 block discarded – undo
1736 2400
 	    } else {
1737 2401
 		$error = socket_strerror(socket_last_error());
1738 2402
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1739
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1740
-			if (isset($globalDebug)) echo "Restarting...\n";
2403
+			if ($globalDebug) {
2404
+				echo "ERROR : socket_select give this error ".$error . "\n";
2405
+			}
2406
+			if (isset($globalDebug)) {
2407
+				echo "Restarting...\n";
2408
+			}
1741 2409
 			// Restart the script if possible
1742 2410
 			if (is_array($sockets)) {
1743
-			    if ($globalDebug) echo "Shutdown all sockets...";
2411
+			    if ($globalDebug) {
2412
+			    	echo "Shutdown all sockets...";
2413
+			    }
1744 2414
 			    
1745 2415
 			    foreach ($sockets as $sock) {
1746 2416
 				@socket_shutdown($sock,2);
@@ -1748,25 +2418,45 @@  discard block
 block discarded – undo
1748 2418
 			    }
1749 2419
 			    
1750 2420
 			}
1751
-			if ($globalDebug) echo "Waiting...";
2421
+			if ($globalDebug) {
2422
+				echo "Waiting...";
2423
+			}
1752 2424
 			sleep(2);
1753 2425
 			$time = time();
1754 2426
 			//connect_all($hosts);
1755 2427
 			$aprs_connect = 0;
1756
-			if ($reset%5 == 0) sleep(20);
1757
-			if ($reset%10 == 0) sleep(100);
1758
-			if ($reset%20 == 0) sleep(200);
1759
-			if ($reset > 100) exit('Too many attempts...');
1760
-			if ($globalDebug) echo "Restart all connections...";
2428
+			if ($reset%5 == 0) {
2429
+				sleep(20);
2430
+			}
2431
+			if ($reset%10 == 0) {
2432
+				sleep(100);
2433
+			}
2434
+			if ($reset%20 == 0) {
2435
+				sleep(200);
2436
+			}
2437
+			if ($reset > 100) {
2438
+				exit('Too many attempts...');
2439
+			}
2440
+			if ($globalDebug) {
2441
+				echo "Restart all connections...";
2442
+			}
1761 2443
 			connect_all($globalSources);
1762 2444
 		}
1763 2445
 	    }
1764 2446
 	}
1765 2447
 	if ($globalDaemon === false) {
1766
-	    if ($globalDebug) echo 'Check all...'."\n";
1767
-	    if (isset($SI)) $SI->checkAll();
1768
-	    if (isset($TI)) $TI->checkAll();
1769
-	    if (isset($MI)) $MI->checkAll();
2448
+	    if ($globalDebug) {
2449
+	    	echo 'Check all...'."\n";
2450
+	    }
2451
+	    if (isset($SI)) {
2452
+	    	$SI->checkAll();
2453
+	    }
2454
+	    if (isset($TI)) {
2455
+	    	$TI->checkAll();
2456
+	    }
2457
+	    if (isset($MI)) {
2458
+	    	$MI->checkAll();
2459
+	    }
1770 2460
 	}
1771 2461
     }
1772 2462
 }
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +297 added lines, -116 removed lines patch added patch discarded remove patch
@@ -48,27 +48,52 @@  discard block
 block discarded – undo
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
51
-if (!isset($globalJsonCompress)) $compress = true;
52
-else $compress = $globalJsonCompress;
51
+if (!isset($globalJsonCompress)) {
52
+	$compress = true;
53
+} else {
54
+	$compress = $globalJsonCompress;
55
+}
53 56
 
54 57
 $from_archive = false;
55 58
 $min = true;
56 59
 $allhistory = false;
57 60
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
61
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
62
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
63
+}
64
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
65
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
66
+}
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
68
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
+}
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
71
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
+}
73
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
75
+}
76
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
77
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
78
+}
79
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
80
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
81
+}
82
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
83
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
+}
85
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
86
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
87
+}
88
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
89
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
90
+}
68 91
 
69 92
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 93
 	$min = true;
71
-} else $min = false;
94
+} else {
95
+	$min = false;
96
+}
72 97
 
73 98
 if (isset($_GET['ident'])) {
74 99
 	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
@@ -162,24 +187,38 @@  discard block
 block discarded – undo
162 187
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
163 188
 		}
164 189
 	}
165
-	if ($flightcnt == '') $flightcnt = 0;
166
-} else $flightcnt = 0;
190
+	if ($flightcnt == '') {
191
+		$flightcnt = 0;
192
+	}
193
+	} else {
194
+	$flightcnt = 0;
195
+}
167 196
 
168 197
 $sqltime = round(microtime(true)-$begintime,2);
169 198
 
170 199
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
171
-if ($currenttime != '') $currenttime = round($currenttime/1000);
200
+if ($currenttime != '') {
201
+	$currenttime = round($currenttime/1000);
202
+}
172 203
 
173
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
174
-else $usenextlatlon = true;
175
-if ($usenextlatlon === false) $currenttime = '';
204
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
205
+	$usenextlatlon = false;
206
+} else {
207
+	$usenextlatlon = true;
208
+}
209
+if ($usenextlatlon === false) {
210
+	$currenttime = '';
211
+}
176 212
 $j = 0;
177 213
 $prev_flightaware_id = '';
178 214
 $aircrafts_shadow = array();
179 215
 $output = '{';
180 216
 	$output .= '"type": "FeatureCollection",';
181
-		if ($min) $output .= '"minimal": "true",';
182
-		else $output .= '"minimal": "false",';
217
+		if ($min) {
218
+			$output .= '"minimal": "true",';
219
+		} else {
220
+			$output .= '"minimal": "false",';
221
+		}
183 222
 		//$output .= '"fc": "'.$flightcnt.'",';
184 223
 		$output .= '"sqt": "'.$sqltime.'",';
185 224
 
@@ -223,18 +262,29 @@  discard block
 block discarded – undo
223 262
 						}
224 263
 						$output .= '"properties": {';
225 264
 						if (isset($spotter_item['flightaware_id'])) {
226
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
227
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
265
+							if ($compress) {
266
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
267
+							} else {
268
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
269
+							}
228 270
 						} elseif (isset($spotter_item['famtrackid'])) {
229
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
230
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
271
+							if ($compress) {
272
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
273
+							} else {
274
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
275
+							}
231 276
 						} elseif (isset($spotter_item['fammarine_id'])) {
232
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
233
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
277
+							if ($compress) {
278
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
279
+							} else {
280
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
281
+							}
234 282
 						}
235 283
 							$output .= '"fc": "'.$flightcnt.'",';
236 284
 							$output .= '"sqt": "'.$sqltime.'",';
237
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
285
+							if (isset($begindate)) {
286
+								$output .= '"archive_date": "'.$begindate.'",';
287
+							}
238 288
 
239 289
 /*
240 290
 							if ($min) $output .= '"minimal": "true",';
@@ -242,14 +292,22 @@  discard block
 block discarded – undo
242 292
 */
243 293
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
244 294
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
245
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
246
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
295
+							if ($compress) {
296
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
297
+							} else {
298
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
299
+							}
247 300
 							//"
248 301
 						} else {
249
-							if ($compress) $output .= '"c": "NA",';
250
-							else $output .= '"callsign": "NA",';
302
+							if ($compress) {
303
+								$output .= '"c": "NA",';
304
+							} else {
305
+								$output .= '"callsign": "NA",';
306
+							}
307
+						}
308
+						if (isset($spotter_item['registration'])) {
309
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
251 310
 						}
252
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
253 311
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
254 312
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
255 313
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -262,16 +320,23 @@  discard block
 block discarded – undo
262 320
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
263 321
 						}
264 322
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
265
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
266
-							else {
323
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
324
+								$spotter_item['aircraft_shadow'] = '';
325
+							} else {
267 326
 								$aircraft_icao = $spotter_item['aircraft_icao'];
268
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
269
-								else {
327
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
328
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
329
+								} else {
270 330
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
271
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
272
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
273
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
274
-									else $spotter_item['aircraft_shadow'] = '';
331
+									if (count($aircraft_info) > 0) {
332
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
333
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
334
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
335
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
336
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
337
+									} else {
338
+										$spotter_item['aircraft_shadow'] = '';
339
+									}
275 340
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
276 341
 								}
277 342
 							}
@@ -279,73 +344,139 @@  discard block
 block discarded – undo
279 344
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
280 345
 							if ($tracker) {
281 346
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
282
-									if ($compress) $output .= '"as": "ambulance.png",';
283
-									else $output .= '"aircraft_shadow": "ambulance.png",';
347
+									if ($compress) {
348
+										$output .= '"as": "ambulance.png",';
349
+									} else {
350
+										$output .= '"aircraft_shadow": "ambulance.png",';
351
+									}
284 352
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
285
-									if ($compress) $output .= '"as": "police.png",';
286
-									else $output .= '"aircraft_shadow": "police.png",';
353
+									if ($compress) {
354
+										$output .= '"as": "police.png",';
355
+									} else {
356
+										$output .= '"aircraft_shadow": "police.png",';
357
+									}
287 358
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
288
-									if ($compress) $output .= '"as": "ship.png",';
289
-									else $output .= '"aircraft_shadow": "ship.png",';
359
+									if ($compress) {
360
+										$output .= '"as": "ship.png",';
361
+									} else {
362
+										$output .= '"aircraft_shadow": "ship.png",';
363
+									}
290 364
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
291
-									if ($compress) $output .= '"as": "ship.png",';
292
-									else $output .= '"aircraft_shadow": "ship.png",';
365
+									if ($compress) {
366
+										$output .= '"as": "ship.png",';
367
+									} else {
368
+										$output .= '"aircraft_shadow": "ship.png",';
369
+									}
293 370
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
294
-									if ($compress) $output .= '"as": "ship.png",';
295
-									else $output .= '"aircraft_shadow": "ship.png",';
371
+									if ($compress) {
372
+										$output .= '"as": "ship.png",';
373
+									} else {
374
+										$output .= '"aircraft_shadow": "ship.png",';
375
+									}
296 376
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
297
-									if ($compress) $output .= '"as": "truck.png",';
298
-									else $output .= '"aircraft_shadow": "truck.png",';
377
+									if ($compress) {
378
+										$output .= '"as": "truck.png",';
379
+									} else {
380
+										$output .= '"aircraft_shadow": "truck.png",';
381
+									}
299 382
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
300
-									if ($compress) $output .= '"as": "truck.png",';
301
-									else $output .= '"aircraft_shadow": "truck.png",';
383
+									if ($compress) {
384
+										$output .= '"as": "truck.png",';
385
+									} else {
386
+										$output .= '"aircraft_shadow": "truck.png",';
387
+									}
302 388
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
303
-									if ($compress) $output .= '"as": "aircraft.png",';
304
-									else $output .= '"aircraft_shadow": "aircraft.png",';
389
+									if ($compress) {
390
+										$output .= '"as": "aircraft.png",';
391
+									} else {
392
+										$output .= '"aircraft_shadow": "aircraft.png",';
393
+									}
305 394
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
306
-									if ($compress) $output .= '"as": "aircraft.png",';
307
-									else $output .= '"aircraft_shadow": "aircraft.png",';
395
+									if ($compress) {
396
+										$output .= '"as": "aircraft.png",';
397
+									} else {
398
+										$output .= '"aircraft_shadow": "aircraft.png",';
399
+									}
308 400
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
309
-									if ($compress) $output .= '"as": "helico.png",';
310
-									else $output .= '"aircraft_shadow": "helico.png",';
401
+									if ($compress) {
402
+										$output .= '"as": "helico.png",';
403
+									} else {
404
+										$output .= '"aircraft_shadow": "helico.png",';
405
+									}
311 406
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
312
-									if ($compress) $output .= '"as": "rail.png",';
313
-									else $output .= '"aircraft_shadow": "rail.png",';
407
+									if ($compress) {
408
+										$output .= '"as": "rail.png",';
409
+									} else {
410
+										$output .= '"aircraft_shadow": "rail.png",';
411
+									}
314 412
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
315
-									if ($compress) $output .= '"as": "firetruck.png",';
316
-									else $output .= '"aircraft_shadow": "firetruck.png",';
413
+									if ($compress) {
414
+										$output .= '"as": "firetruck.png",';
415
+									} else {
416
+										$output .= '"aircraft_shadow": "firetruck.png",';
417
+									}
317 418
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
318
-									if ($compress) $output .= '"as": "bus.png",';
319
-									else $output .= '"aircraft_shadow": "bus.png",';
419
+									if ($compress) {
420
+										$output .= '"as": "bus.png",';
421
+									} else {
422
+										$output .= '"aircraft_shadow": "bus.png",';
423
+									}
320 424
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
321
-									if ($compress) $output .= '"as": "phone.png",';
322
-									else $output .= '"aircraft_shadow": "phone.png",';
425
+									if ($compress) {
426
+										$output .= '"as": "phone.png",';
427
+									} else {
428
+										$output .= '"aircraft_shadow": "phone.png",';
429
+									}
323 430
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
324
-									if ($compress) $output .= '"as": "jogger.png",';
325
-									else $output .= '"aircraft_shadow": "jogger.png",';
431
+									if ($compress) {
432
+										$output .= '"as": "jogger.png",';
433
+									} else {
434
+										$output .= '"aircraft_shadow": "jogger.png",';
435
+									}
326 436
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
327
-									if ($compress) $output .= '"as": "bike.png",';
328
-									else $output .= '"aircraft_shadow": "bike.png",';
437
+									if ($compress) {
438
+										$output .= '"as": "bike.png",';
439
+									} else {
440
+										$output .= '"aircraft_shadow": "bike.png",';
441
+									}
329 442
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
330
-									if ($compress) $output .= '"as": "motorcycle.png",';
331
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
443
+									if ($compress) {
444
+										$output .= '"as": "motorcycle.png",';
445
+									} else {
446
+										$output .= '"aircraft_shadow": "motorcycle.png",';
447
+									}
332 448
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
333
-									if ($compress) $output .= '"as": "balloon.png",';
334
-									else $output .= '"aircraft_shadow": "balloon.png",';
449
+									if ($compress) {
450
+										$output .= '"as": "balloon.png",';
451
+									} else {
452
+										$output .= '"aircraft_shadow": "balloon.png",';
453
+									}
335 454
 								} else {
336
-									if ($compress) $output .= '"as": "car.png",';
337
-									else $output .= '"aircraft_shadow": "car.png",';
455
+									if ($compress) {
456
+										$output .= '"as": "car.png",';
457
+									} else {
458
+										$output .= '"aircraft_shadow": "car.png",';
459
+									}
338 460
 								}
339 461
 							} elseif ($marine) {
340
-								if ($compress) $output .= '"as": "ship.png",';
341
-								else $output .= '"aircraft_shadow": "ship.png",';
462
+								if ($compress) {
463
+									$output .= '"as": "ship.png",';
464
+								} else {
465
+									$output .= '"aircraft_shadow": "ship.png",';
466
+								}
342 467
 							} else {
343
-								if ($compress) $output .= '"as": "default.png",';
344
-								else $output .= '"aircraft_shadow": "default.png",';
468
+								if ($compress) {
469
+									$output .= '"as": "default.png",';
470
+								} else {
471
+									$output .= '"aircraft_shadow": "default.png",';
472
+								}
345 473
 							}
346 474
 						} else {
347
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
348
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
475
+							if ($compress) {
476
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
477
+							} else {
478
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
479
+							}
349 480
 						}
350 481
 						if (isset($spotter_item['airline_name'])) {
351 482
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -353,8 +484,11 @@  discard block
 block discarded – undo
353 484
 							$output .= '"airline_name": "NA",';
354 485
 						}
355 486
 						if (isset($spotter_item['departure_airport'])) {
356
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
357
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
487
+							if ($compress) {
488
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
489
+							} else {
490
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
491
+							}
358 492
 						}
359 493
 						if (isset($spotter_item['departure_airport_city'])) {
360 494
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -366,8 +500,11 @@  discard block
 block discarded – undo
366 500
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
367 501
 						}
368 502
 						if (isset($spotter_item['arrival_airport'])) {
369
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
370
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
503
+							if ($compress) {
504
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
505
+							} else {
506
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
507
+							}
371 508
 						}
372 509
 						if (isset($spotter_item['arrival_airport_city'])) {
373 510
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -386,11 +523,17 @@  discard block
 block discarded – undo
386 523
 						}
387 524
 						
388 525
 						if (isset($spotter_item['altitude'])) {
389
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
390
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
526
+							if ($compress) {
527
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
528
+							} else {
529
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
530
+							}
531
+						}
532
+						if ($compress) {
533
+							$output .= '"h": "'.$spotter_item['heading'].'",';
534
+						} else {
535
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
391 536
 						}
392
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
393
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
394 537
 						
395 538
 						if ($currenttime != '') {
396 539
 							if (strtotime($spotter_item['date']) < $currenttime) {
@@ -412,7 +555,9 @@  discard block
 block discarded – undo
412 555
 							}
413 556
 						}
414 557
 
415
-						if (!$min) $output .= '"image": "'.$image.'",';
558
+						if (!$min) {
559
+							$output .= '"image": "'.$image.'",';
560
+						}
416 561
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
417 562
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
418 563
 						}
@@ -420,8 +565,11 @@  discard block
 block discarded – undo
420 565
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
421 566
 						}
422 567
 						if (isset($spotter_item['squawk'])) {
423
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
424
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
568
+							if ($compress) {
569
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
570
+							} else {
571
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
572
+							}
425 573
 						}
426 574
 						if (isset($spotter_item['squawk_usage'])) {
427 575
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -440,14 +588,23 @@  discard block
 block discarded – undo
440 588
 						}
441 589
 						// type when not aircraft ?
442 590
 						if (isset($spotter_item['type'])) {
443
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
444
-							else $output .= '"type": "'.$spotter_item['type'].'"';
591
+							if ($compress) {
592
+								$output .= '"t": "'.$spotter_item['type'].'"';
593
+							} else {
594
+								$output .= '"type": "'.$spotter_item['type'].'"';
595
+							}
445 596
 						} elseif ($marine) {
446
-							if ($compress) $output .= '"t": "ship"';
447
-							else $output .= '"type": "ship"';
597
+							if ($compress) {
598
+								$output .= '"t": "ship"';
599
+							} else {
600
+								$output .= '"type": "ship"';
601
+							}
448 602
 						} else {
449
-							if ($compress) $output .= '"t": "aircraft"';
450
-							else $output .= '"type": "aircraft"';
603
+							if ($compress) {
604
+								$output .= '"t": "aircraft"';
605
+							} else {
606
+								$output .= '"type": "aircraft"';
607
+							}
451 608
 						}
452 609
 						$output .= '},';
453 610
 						$output .= '"geometry": {';
@@ -455,7 +612,9 @@  discard block
 block discarded – undo
455 612
 								$output .= '"coordinates": [';
456 613
 								if ($currenttime != '') {
457 614
 									if (strtotime($spotter_item['date']) < $currenttime) {
458
-										if (!isset($archivespeed)) $archivespeed = 1;
615
+										if (!isset($archivespeed)) {
616
+											$archivespeed = 1;
617
+										}
459 618
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed,$currenttime-strtotime($spotter_item['date']));
460 619
 										$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
461 620
 									} else {
@@ -526,7 +685,9 @@  discard block
 block discarded – undo
526 685
 			}
527 686
 */
528 687
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
529
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
688
+				if ($history == '' && isset($_COOKIE['history'])) {
689
+					$history = $_COOKIE['history'];
690
+				}
530 691
 				
531 692
 				if (
532 693
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -570,8 +731,11 @@  discard block
 block discarded – undo
570 731
 									$output_history .= ']}},';
571 732
 									$output .= $output_history;
572 733
 								}
573
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
574
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
734
+								if ($compress) {
735
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
736
+								} else {
737
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
738
+								}
575 739
 							}
576 740
 							$output_history .= '[';
577 741
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -590,9 +754,14 @@  discard block
 block discarded – undo
590 754
 							$prev_alt = $alt;
591 755
 						} else {
592 756
 							if ($d == false) {
593
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
594
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
595
-							} else $d = true;
757
+								if ($compress) {
758
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
759
+								} else {
760
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
761
+								}
762
+							} else {
763
+								$d = true;
764
+							}
596 765
 							$output_history .= '[';
597 766
 							$output_history .=  $spotter_history['longitude'].', ';
598 767
 							$output_history .=  $spotter_history['latitude'];
@@ -613,7 +782,9 @@  discard block
 block discarded – undo
613 782
 							$output_historyd = '[';
614 783
 							$output_historyd .=  $spotter_item['longitude'].', ';
615 784
 							$output_historyd .=  $spotter_item['latitude'];
616
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
785
+							if (isset($spotter_history['altitude'])) {
786
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
787
+							}
617 788
 							$output_historyd .= '],';
618 789
 							//$output_history = $output_historyd.$output_history;
619 790
 							$output_history = $output_history.$output_historyd;
@@ -635,8 +806,11 @@  discard block
 block discarded – undo
635 806
 				        && $spotter_item['arrival_airport'] != 'NA' 
636 807
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
637 808
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
638
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
639
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
809
+				    if ($compress) {
810
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
811
+				    } else {
812
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
813
+				    }
640 814
 				    if (isset($spotter_item['departure_airport_latitude'])) {
641 815
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
642 816
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -669,8 +843,11 @@  discard block
 block discarded – undo
669 843
 				    	    || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) 
670 844
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
671 845
 				    $havedata = false;
672
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
673
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
846
+				    if ($compress) {
847
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
848
+				    } else {
849
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
850
+				    }
674 851
 				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
675 852
 
676 853
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -685,7 +862,9 @@  discard block
 block discarded – undo
685 862
 				    }
686 863
 				    //$output_dest  = substr($output_dest, 0, -1);
687 864
 				    $output_dest .= ']}},';
688
-				    if ($havedata) $output .= $output_dest;
865
+				    if ($havedata) {
866
+				    	$output .= $output_dest;
867
+				    }
689 868
 				    unset($output_dest);
690 869
 				}
691 870
 			}
@@ -693,7 +872,9 @@  discard block
 block discarded – undo
693 872
 			$output .= ']';
694 873
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
695 874
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
696
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
875
+			if (isset($begindate)) {
876
+				$output .= '"archive_date": "'.$begindate.'",';
877
+			}
697 878
 			$output .= '"fc": "'.$j.'"';
698 879
 		} else {
699 880
 			$output .= '"features": ';
Please login to merge, or discard this patch.
manufacturer-statistics-airline-country.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
 	print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
23 23
 	$Stats = new Stats();
24 24
 	$all_manufacturers = $Stats->getAllManufacturers();
25
-	if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
25
+	if (empty($all_manufacturers)) {
26
+		$all_manufacturers = $Spotter->getAllManufacturers();
27
+	}
26 28
 	foreach($all_manufacturers as $all_manufacturer)
27 29
 	{
28 30
 		if($manufacturer == ucwords($all_manufacturer['aircraft_manufacturer']))
Please login to merge, or discard this patch.
manufacturer-statistics-aircraft.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
 	print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
23 23
 	$Stats = new Stats();
24 24
 	$all_manufacturers = $Stats->getAllManufacturers();
25
-	if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
25
+	if (empty($all_manufacturers)) {
26
+		$all_manufacturers = $Spotter->getAllManufacturers();
27
+	}
26 28
 	foreach($all_manufacturers as $all_manufacturer)
27 29
 	{
28 30
 		if($manufacturer == ucwords($all_manufacturer['aircraft_manufacturer']))
Please login to merge, or discard this patch.