Completed
Push — master ( 2c5525...528bd8 )
by Yannick
32:59
created
install/class.update_schema.php 1 patch
Braces   +522 added lines, -192 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2206,10 +2350,14 @@  discard block
 block discarded – undo
2206 2350
 		if (!$Connection->tableExists('stats_marine_type')) {
2207 2351
 			if ($globalDBdriver == 'mysql') {
2208 2352
 				$error .= create_db::import_file('../db/stats_marine_type.sql');
2209
-				if ($error != '') return $error;
2353
+				if ($error != '') {
2354
+					return $error;
2355
+				}
2210 2356
 			} else {
2211 2357
 				$error .= create_db::import_file('../db/pgsql/stats_marine_type.sql');
2212
-				if ($error != '') return $error;
2358
+				if ($error != '') {
2359
+					return $error;
2360
+				}
2213 2361
 			}
2214 2362
 		}
2215 2363
 		$query = "UPDATE config SET value = '48' WHERE name = 'schema_version'";
@@ -2229,10 +2377,14 @@  discard block
 block discarded – undo
2229 2377
 		if (!$Connection->tableExists('stats_tracker_type')) {
2230 2378
 			if ($globalDBdriver == 'mysql') {
2231 2379
 				$error .= create_db::import_file('../db/stats_tracker_type.sql');
2232
-				if ($error != '') return $error;
2380
+				if ($error != '') {
2381
+					return $error;
2382
+				}
2233 2383
 			} else {
2234 2384
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql');
2235
-				if ($error != '') return $error;
2385
+				if ($error != '') {
2386
+					return $error;
2387
+				}
2236 2388
 			}
2237 2389
 		}
2238 2390
 		$query = "UPDATE config SET value = '49' WHERE name = 'schema_version'";
@@ -2251,10 +2403,14 @@  discard block
 block discarded – undo
2251 2403
 		$error = '';
2252 2404
 		if ($globalDBdriver == 'mysql') {
2253 2405
 			$error .= create_db::import_file('../db/airport.sql');
2254
-			if ($error != '') return $error;
2406
+			if ($error != '') {
2407
+				return $error;
2408
+			}
2255 2409
 		} else {
2256 2410
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2257
-			if ($error != '') return $error;
2411
+			if ($error != '') {
2412
+				return $error;
2413
+			}
2258 2414
 		}
2259 2415
 		$query = "UPDATE config SET value = '50' WHERE name = 'schema_version'";
2260 2416
 		try {
@@ -2272,14 +2428,22 @@  discard block
 block discarded – undo
2272 2428
 		$error = '';
2273 2429
 		if ($globalDBdriver == 'mysql') {
2274 2430
 			$error .= create_db::import_file('../db/aircraft.sql');
2275
-			if ($error != '') return $error;
2431
+			if ($error != '') {
2432
+				return $error;
2433
+			}
2276 2434
 			$error .= create_db::import_file('../db/aircraft_block.sql');
2277
-			if ($error != '') return $error;
2435
+			if ($error != '') {
2436
+				return $error;
2437
+			}
2278 2438
 		} else {
2279 2439
 			$error .= create_db::import_file('../db/pgsql/aircraft.sql');
2280
-			if ($error != '') return $error;
2440
+			if ($error != '') {
2441
+				return $error;
2442
+			}
2281 2443
 			$error .= create_db::import_file('../db/pgsql/aircraft_block.sql');
2282
-			if ($error != '') return $error;
2444
+			if ($error != '') {
2445
+				return $error;
2446
+			}
2283 2447
 		}
2284 2448
 		$query = "UPDATE config SET value = '51' WHERE name = 'schema_version'";
2285 2449
 		try {
@@ -2536,8 +2700,11 @@  discard block
 block discarded – undo
2536 2700
 			if ($Connection->tableExists('aircraft')) {
2537 2701
 				if (!$Connection->tableExists('config')) {
2538 2702
 					$version = '1';
2539
-					if ($update) return self::update_from_1();
2540
-					else return $version;
2703
+					if ($update) {
2704
+						return self::update_from_1();
2705
+					} else {
2706
+						return $version;
2707
+					}
2541 2708
 				} else {
2542 2709
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2543 2710
 					try {
@@ -2550,219 +2717,382 @@  discard block
 block discarded – undo
2550 2717
 					if ($update) {
2551 2718
 						if ($result['value'] == '2') {
2552 2719
 							$error = self::update_from_2();
2553
-							if ($error != '') return $error;
2554
-							else return self::check_version(true);
2720
+							if ($error != '') {
2721
+								return $error;
2722
+							} else {
2723
+								return self::check_version(true);
2724
+							}
2555 2725
 						} elseif ($result['value'] == '3') {
2556 2726
 							$error = self::update_from_3();
2557
-							if ($error != '') return $error;
2558
-							else return self::check_version(true);
2727
+							if ($error != '') {
2728
+								return $error;
2729
+							} else {
2730
+								return self::check_version(true);
2731
+							}
2559 2732
 						} elseif ($result['value'] == '4') {
2560 2733
 							$error = self::update_from_4();
2561
-							if ($error != '') return $error;
2562
-							else return self::check_version(true);
2734
+							if ($error != '') {
2735
+								return $error;
2736
+							} else {
2737
+								return self::check_version(true);
2738
+							}
2563 2739
 						} elseif ($result['value'] == '5') {
2564 2740
 							$error = self::update_from_5();
2565
-							if ($error != '') return $error;
2566
-							else return self::check_version(true);
2741
+							if ($error != '') {
2742
+								return $error;
2743
+							} else {
2744
+								return self::check_version(true);
2745
+							}
2567 2746
 						} elseif ($result['value'] == '6') {
2568 2747
 							$error = self::update_from_6();
2569
-							if ($error != '') return $error;
2570
-							else return self::check_version(true);
2748
+							if ($error != '') {
2749
+								return $error;
2750
+							} else {
2751
+								return self::check_version(true);
2752
+							}
2571 2753
 						} elseif ($result['value'] == '7') {
2572 2754
 							$error = self::update_from_7();
2573
-							if ($error != '') return $error;
2574
-							else return self::check_version(true);
2755
+							if ($error != '') {
2756
+								return $error;
2757
+							} else {
2758
+								return self::check_version(true);
2759
+							}
2575 2760
 						} elseif ($result['value'] == '8') {
2576 2761
 							$error = self::update_from_8();
2577
-							if ($error != '') return $error;
2578
-							else return self::check_version(true);
2762
+							if ($error != '') {
2763
+								return $error;
2764
+							} else {
2765
+								return self::check_version(true);
2766
+							}
2579 2767
 						} elseif ($result['value'] == '9') {
2580 2768
 							$error = self::update_from_9();
2581
-							if ($error != '') return $error;
2582
-							else return self::check_version(true);
2769
+							if ($error != '') {
2770
+								return $error;
2771
+							} else {
2772
+								return self::check_version(true);
2773
+							}
2583 2774
 						} elseif ($result['value'] == '10') {
2584 2775
 							$error = self::update_from_10();
2585
-							if ($error != '') return $error;
2586
-							else return self::check_version(true);
2776
+							if ($error != '') {
2777
+								return $error;
2778
+							} else {
2779
+								return self::check_version(true);
2780
+							}
2587 2781
 						} elseif ($result['value'] == '11') {
2588 2782
 							$error = self::update_from_11();
2589
-							if ($error != '') return $error;
2590
-							else return self::check_version(true);
2783
+							if ($error != '') {
2784
+								return $error;
2785
+							} else {
2786
+								return self::check_version(true);
2787
+							}
2591 2788
 						} elseif ($result['value'] == '12') {
2592 2789
 							$error = self::update_from_12();
2593
-							if ($error != '') return $error;
2594
-							else return self::check_version(true);
2790
+							if ($error != '') {
2791
+								return $error;
2792
+							} else {
2793
+								return self::check_version(true);
2794
+							}
2595 2795
 						} elseif ($result['value'] == '13') {
2596 2796
 							$error = self::update_from_13();
2597
-							if ($error != '') return $error;
2598
-							else return self::check_version(true);
2797
+							if ($error != '') {
2798
+								return $error;
2799
+							} else {
2800
+								return self::check_version(true);
2801
+							}
2599 2802
 						} elseif ($result['value'] == '14') {
2600 2803
 							$error = self::update_from_14();
2601
-							if ($error != '') return $error;
2602
-							else return self::check_version(true);
2804
+							if ($error != '') {
2805
+								return $error;
2806
+							} else {
2807
+								return self::check_version(true);
2808
+							}
2603 2809
 						} elseif ($result['value'] == '15') {
2604 2810
 							$error = self::update_from_15();
2605
-							if ($error != '') return $error;
2606
-							else return self::check_version(true);
2811
+							if ($error != '') {
2812
+								return $error;
2813
+							} else {
2814
+								return self::check_version(true);
2815
+							}
2607 2816
 						} elseif ($result['value'] == '16') {
2608 2817
 							$error = self::update_from_16();
2609
-							if ($error != '') return $error;
2610
-							else return self::check_version(true);
2818
+							if ($error != '') {
2819
+								return $error;
2820
+							} else {
2821
+								return self::check_version(true);
2822
+							}
2611 2823
 						} elseif ($result['value'] == '17') {
2612 2824
 							$error = self::update_from_17();
2613
-							if ($error != '') return $error;
2614
-							else return self::check_version(true);
2825
+							if ($error != '') {
2826
+								return $error;
2827
+							} else {
2828
+								return self::check_version(true);
2829
+							}
2615 2830
 						} elseif ($result['value'] == '18') {
2616 2831
 							$error = self::update_from_18();
2617
-							if ($error != '') return $error;
2618
-							else return self::check_version(true);
2832
+							if ($error != '') {
2833
+								return $error;
2834
+							} else {
2835
+								return self::check_version(true);
2836
+							}
2619 2837
 						} elseif ($result['value'] == '19') {
2620 2838
 							$error = self::update_from_19();
2621
-							if ($error != '') return $error;
2622
-							else return self::check_version(true);
2839
+							if ($error != '') {
2840
+								return $error;
2841
+							} else {
2842
+								return self::check_version(true);
2843
+							}
2623 2844
 						} elseif ($result['value'] == '20') {
2624 2845
 							$error = self::update_from_20();
2625
-							if ($error != '') return $error;
2626
-							else return self::check_version(true);
2846
+							if ($error != '') {
2847
+								return $error;
2848
+							} else {
2849
+								return self::check_version(true);
2850
+							}
2627 2851
 						} elseif ($result['value'] == '21') {
2628 2852
 							$error = self::update_from_21();
2629
-							if ($error != '') return $error;
2630
-							else return self::check_version(true);
2853
+							if ($error != '') {
2854
+								return $error;
2855
+							} else {
2856
+								return self::check_version(true);
2857
+							}
2631 2858
 						} elseif ($result['value'] == '22') {
2632 2859
 							$error = self::update_from_22();
2633
-							if ($error != '') return $error;
2634
-							else return self::check_version(true);
2860
+							if ($error != '') {
2861
+								return $error;
2862
+							} else {
2863
+								return self::check_version(true);
2864
+							}
2635 2865
 						} elseif ($result['value'] == '23') {
2636 2866
 							$error = self::update_from_23();
2637
-							if ($error != '') return $error;
2638
-							else return self::check_version(true);
2867
+							if ($error != '') {
2868
+								return $error;
2869
+							} else {
2870
+								return self::check_version(true);
2871
+							}
2639 2872
 						} elseif ($result['value'] == '24') {
2640 2873
 							$error = self::update_from_24();
2641
-							if ($error != '') return $error;
2642
-							else return self::check_version(true);
2874
+							if ($error != '') {
2875
+								return $error;
2876
+							} else {
2877
+								return self::check_version(true);
2878
+							}
2643 2879
 						} elseif ($result['value'] == '25') {
2644 2880
 							$error = self::update_from_25();
2645
-							if ($error != '') return $error;
2646
-							else return self::check_version(true);
2881
+							if ($error != '') {
2882
+								return $error;
2883
+							} else {
2884
+								return self::check_version(true);
2885
+							}
2647 2886
 						} elseif ($result['value'] == '26') {
2648 2887
 							$error = self::update_from_26();
2649
-							if ($error != '') return $error;
2650
-							else return self::check_version(true);
2888
+							if ($error != '') {
2889
+								return $error;
2890
+							} else {
2891
+								return self::check_version(true);
2892
+							}
2651 2893
 						} elseif ($result['value'] == '27') {
2652 2894
 							$error = self::update_from_27();
2653
-							if ($error != '') return $error;
2654
-							else return self::check_version(true);
2895
+							if ($error != '') {
2896
+								return $error;
2897
+							} else {
2898
+								return self::check_version(true);
2899
+							}
2655 2900
 						} elseif ($result['value'] == '28') {
2656 2901
 							$error = self::update_from_28();
2657
-							if ($error != '') return $error;
2658
-							else return self::check_version(true);
2902
+							if ($error != '') {
2903
+								return $error;
2904
+							} else {
2905
+								return self::check_version(true);
2906
+							}
2659 2907
 						} elseif ($result['value'] == '29') {
2660 2908
 							$error = self::update_from_29();
2661
-							if ($error != '') return $error;
2662
-							else return self::check_version(true);
2909
+							if ($error != '') {
2910
+								return $error;
2911
+							} else {
2912
+								return self::check_version(true);
2913
+							}
2663 2914
 						} elseif ($result['value'] == '30') {
2664 2915
 							$error = self::update_from_30();
2665
-							if ($error != '') return $error;
2666
-							else return self::check_version(true);
2916
+							if ($error != '') {
2917
+								return $error;
2918
+							} else {
2919
+								return self::check_version(true);
2920
+							}
2667 2921
 						} elseif ($result['value'] == '31') {
2668 2922
 							$error = self::update_from_31();
2669
-							if ($error != '') return $error;
2670
-							else return self::check_version(true);
2923
+							if ($error != '') {
2924
+								return $error;
2925
+							} else {
2926
+								return self::check_version(true);
2927
+							}
2671 2928
 						} elseif ($result['value'] == '32') {
2672 2929
 							$error = self::update_from_32();
2673
-							if ($error != '') return $error;
2674
-							else return self::check_version(true);
2930
+							if ($error != '') {
2931
+								return $error;
2932
+							} else {
2933
+								return self::check_version(true);
2934
+							}
2675 2935
 						} elseif ($result['value'] == '33') {
2676 2936
 							$error = self::update_from_33();
2677
-							if ($error != '') return $error;
2678
-							else return self::check_version(true);
2937
+							if ($error != '') {
2938
+								return $error;
2939
+							} else {
2940
+								return self::check_version(true);
2941
+							}
2679 2942
 						} elseif ($result['value'] == '34') {
2680 2943
 							$error = self::update_from_34();
2681
-							if ($error != '') return $error;
2682
-							else return self::check_version(true);
2944
+							if ($error != '') {
2945
+								return $error;
2946
+							} else {
2947
+								return self::check_version(true);
2948
+							}
2683 2949
 						} elseif ($result['value'] == '35') {
2684 2950
 							$error = self::update_from_35();
2685
-							if ($error != '') return $error;
2686
-							else return self::check_version(true);
2951
+							if ($error != '') {
2952
+								return $error;
2953
+							} else {
2954
+								return self::check_version(true);
2955
+							}
2687 2956
 						} elseif ($result['value'] == '36') {
2688 2957
 							$error = self::update_from_36();
2689
-							if ($error != '') return $error;
2690
-							else return self::check_version(true);
2958
+							if ($error != '') {
2959
+								return $error;
2960
+							} else {
2961
+								return self::check_version(true);
2962
+							}
2691 2963
 						} elseif ($result['value'] == '37') {
2692 2964
 							$error = self::update_from_37();
2693
-							if ($error != '') return $error;
2694
-							else return self::check_version(true);
2965
+							if ($error != '') {
2966
+								return $error;
2967
+							} else {
2968
+								return self::check_version(true);
2969
+							}
2695 2970
 						} elseif ($result['value'] == '38') {
2696 2971
 							$error = self::update_from_38();
2697
-							if ($error != '') return $error;
2698
-							else return self::check_version(true);
2972
+							if ($error != '') {
2973
+								return $error;
2974
+							} else {
2975
+								return self::check_version(true);
2976
+							}
2699 2977
 						} elseif ($result['value'] == '39') {
2700 2978
 							$error = self::update_from_39();
2701
-							if ($error != '') return $error;
2702
-							else return self::check_version(true);
2979
+							if ($error != '') {
2980
+								return $error;
2981
+							} else {
2982
+								return self::check_version(true);
2983
+							}
2703 2984
 						} elseif ($result['value'] == '40') {
2704 2985
 							$error = self::update_from_40();
2705
-							if ($error != '') return $error;
2706
-							else return self::check_version(true);
2986
+							if ($error != '') {
2987
+								return $error;
2988
+							} else {
2989
+								return self::check_version(true);
2990
+							}
2707 2991
 						} elseif ($result['value'] == '41') {
2708 2992
 							$error = self::update_from_41();
2709
-							if ($error != '') return $error;
2710
-							else return self::check_version(true);
2993
+							if ($error != '') {
2994
+								return $error;
2995
+							} else {
2996
+								return self::check_version(true);
2997
+							}
2711 2998
 						} elseif ($result['value'] == '42') {
2712 2999
 							$error = self::update_from_42();
2713
-							if ($error != '') return $error;
2714
-							else return self::check_version(true);
3000
+							if ($error != '') {
3001
+								return $error;
3002
+							} else {
3003
+								return self::check_version(true);
3004
+							}
2715 3005
 						} elseif ($result['value'] == '43') {
2716 3006
 							$error = self::update_from_43();
2717
-							if ($error != '') return $error;
2718
-							else return self::check_version(true);
3007
+							if ($error != '') {
3008
+								return $error;
3009
+							} else {
3010
+								return self::check_version(true);
3011
+							}
2719 3012
 						} elseif ($result['value'] == '44') {
2720 3013
 							$error = self::update_from_44();
2721
-							if ($error != '') return $error;
2722
-							else return self::check_version(true);
3014
+							if ($error != '') {
3015
+								return $error;
3016
+							} else {
3017
+								return self::check_version(true);
3018
+							}
2723 3019
 						} elseif ($result['value'] == '45') {
2724 3020
 							$error = self::update_from_45();
2725
-							if ($error != '') return $error;
2726
-							else return self::check_version(true);
3021
+							if ($error != '') {
3022
+								return $error;
3023
+							} else {
3024
+								return self::check_version(true);
3025
+							}
2727 3026
 						} elseif ($result['value'] == '46') {
2728 3027
 							$error = self::update_from_46();
2729
-							if ($error != '') return $error;
2730
-							else return self::check_version(true);
3028
+							if ($error != '') {
3029
+								return $error;
3030
+							} else {
3031
+								return self::check_version(true);
3032
+							}
2731 3033
 						} elseif ($result['value'] == '47') {
2732 3034
 							$error = self::update_from_47();
2733
-							if ($error != '') return $error;
2734
-							else return self::check_version(true);
3035
+							if ($error != '') {
3036
+								return $error;
3037
+							} else {
3038
+								return self::check_version(true);
3039
+							}
2735 3040
 						} elseif ($result['value'] == '48') {
2736 3041
 							$error = self::update_from_48();
2737
-							if ($error != '') return $error;
2738
-							else return self::check_version(true);
3042
+							if ($error != '') {
3043
+								return $error;
3044
+							} else {
3045
+								return self::check_version(true);
3046
+							}
2739 3047
 						} elseif ($result['value'] == '49') {
2740 3048
 							$error = self::update_from_49();
2741
-							if ($error != '') return $error;
2742
-							else return self::check_version(true);
3049
+							if ($error != '') {
3050
+								return $error;
3051
+							} else {
3052
+								return self::check_version(true);
3053
+							}
2743 3054
 						} elseif ($result['value'] == '50') {
2744 3055
 							$error = self::update_from_50();
2745
-							if ($error != '') return $error;
2746
-							else return self::check_version(true);
3056
+							if ($error != '') {
3057
+								return $error;
3058
+							} else {
3059
+								return self::check_version(true);
3060
+							}
2747 3061
 						} elseif ($result['value'] == '51') {
2748 3062
 							$error = self::update_from_51();
2749
-							if ($error != '') return $error;
2750
-							else return self::check_version(true);
3063
+							if ($error != '') {
3064
+								return $error;
3065
+							} else {
3066
+								return self::check_version(true);
3067
+							}
2751 3068
 						} elseif ($result['value'] == '52') {
2752 3069
 							$error = self::update_from_52();
2753
-							if ($error != '') return $error;
2754
-							else return self::check_version(true);
3070
+							if ($error != '') {
3071
+								return $error;
3072
+							} else {
3073
+								return self::check_version(true);
3074
+							}
2755 3075
 						} elseif ($result['value'] == '53') {
2756 3076
 							$error = self::update_from_53();
2757
-							if ($error != '') return $error;
2758
-							else return self::check_version(true);
2759
-						} else return '';
3077
+							if ($error != '') {
3078
+								return $error;
3079
+							} else {
3080
+								return self::check_version(true);
3081
+							}
3082
+						} else {
3083
+							return '';
3084
+						}
2760 3085
 					} else {
2761
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2762
-						else return 0;
3086
+						if (isset($result['value']) && $result['value'] != '') {
3087
+							return $result['value'];
3088
+						} else {
3089
+							return 0;
3090
+						}
2763 3091
 					}
2764 3092
 				}
2765
-			} else return $version;
3093
+			} else {
3094
+				return $version;
3095
+			}
2766 3096
 		}
2767 3097
 	}
2768 3098
 }
Please login to merge, or discard this patch.
captain-detailed.php 1 patch
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,8 +38,12 @@  discard block
 block discarded – undo
38 38
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
39 39
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
40 40
 	$filter = array();
41
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
42
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
41
+	if ($year != '') {
42
+		$filter = array_merge($filter,array('year' => $year));
43
+	}
44
+	if ($month != '') {
45
+		$filter = array_merge($filter,array('month' => $month));
46
+	}
43 47
 	if ($sort != '') 
44 48
 	{
45 49
 		$spotter_array = $Marine->getMarineDataByCaptain($captain,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -57,8 +61,12 @@  discard block
 block discarded – undo
57 61
 	{
58 62
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['captain_name']);
59 63
 		$ident = $spotter_array[0]['ident'];
60
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
61
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
64
+		if (isset($spotter_array[0]['latitude'])) {
65
+			$latitude = $spotter_array[0]['latitude'];
66
+		}
67
+		if (isset($spotter_array[0]['longitude'])) {
68
+			$longitude = $spotter_array[0]['longitude'];
69
+		}
62 70
 		require_once('header.php');
63 71
 		/*
64 72
 		if (isset($globalArchive) && $globalArchive) {
@@ -111,7 +119,9 @@  discard block
 block discarded – undo
111 119
 		*/
112 120
 		print '<div class="info column">';
113 121
 		print '<h1>'.$spotter_array[0]['captain_name'].'</h1>';
114
-		if (isset($spotter_array[0]['captain_id']) && $spotter_array[0]['captain_id'] != '') print '<div><span class="label">'._("Captain ID").'</span>'.$spotter_array[0]['captain_id'].'</div>';
122
+		if (isset($spotter_array[0]['captain_id']) && $spotter_array[0]['captain_id'] != '') {
123
+			print '<div><span class="label">'._("Captain ID").'</span>'.$spotter_array[0]['captain_id'].'</div>';
124
+		}
115 125
 		/*
116 126
 		if ($year == '' && $month == '') {
117 127
 			$Stats = new Stats();
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
 		//$airlines = count($Marine->countAllAirlinesByCaptain($captain,$filter));
131 141
 		//print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
132 142
 		$duration = $Marine->getRaceDurationByCaptain($captain,$filter);
133
-		if ($duration != '0') print '<div><span class="label">'._("Total races spotted duration").'</span>'.$duration.'</div>';
143
+		if ($duration != '0') {
144
+			print '<div><span class="label">'._("Total races spotted duration").'</span>'.$duration.'</div>';
145
+		}
134 146
 		print '</div>';
135 147
 	
136 148
 		//include('captain-sub-menu.php');
Please login to merge, or discard this patch.
header.php 1 patch
Braces   +95 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,12 +6,19 @@  discard block
 block discarded – undo
6 6
 //gets the page file and stores it in a variable
7 7
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
8 8
 $current_page = $file_path['filename'];
9
-if ($globalTimezone == '') $globalTimezone = 'UTC';
9
+if ($globalTimezone == '') {
10
+	$globalTimezone = 'UTC';
11
+}
10 12
 date_default_timezone_set($globalTimezone);
11
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
12
-else $MapType = $globalMapProvider;
13
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
14
+	$MapType = $_COOKIE['MapType'];
15
+} else {
16
+	$MapType = $globalMapProvider;
17
+}
13 18
 
14
-if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
19
+if (isset($globalMapOffline) && $globalMapOffline) {
20
+	$MapType = 'offline';
21
+}
15 22
 
16 23
 if (isset($_GET['3d'])) {
17 24
 	setcookie('MapFormat','3d');
@@ -209,7 +216,10 @@  discard block
 block discarded – undo
209 216
 <?php
210 217
 		} else {
211 218
 ?>
212
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) print '&tsk='.$tsk; ?>"></script>
219
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) {
220
+	print '&tsk='.$tsk;
221
+}
222
+?>"></script>
213 223
 <?php
214 224
 		}
215 225
 		if (!isset($globalAircraft) || $globalAircraft) {
@@ -249,7 +259,13 @@  discard block
 block discarded – undo
249 259
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
250 260
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
251 261
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
252
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
262
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
263
+	print '&latitude='.$latitude;
264
+}
265
+?><?php if(isset($longitude)) {
266
+	print '&longitude='.$longitude;
267
+}
268
+?>&<?php print time(); ?>"></script>
253 269
 <?php
254 270
 		if (!isset($type) || $type == 'aircraft') {
255 271
 ?>
@@ -322,7 +338,13 @@  discard block
 block discarded – undo
322 338
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
323 339
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
324 340
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
325
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
341
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
342
+	print '&latitude='.$latitude;
343
+}
344
+?><?php if(isset($longitude)) {
345
+	print '&longitude='.$longitude;
346
+}
347
+?>&<?php print time(); ?>"></script>
326 348
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
327 349
 <?php
328 350
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -403,7 +425,12 @@  discard block
 block discarded – undo
403 425
         <span class="icon-bar"></span>
404 426
       </button>
405 427
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle search"><i class="fa fa-search"></i></a>
406
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
428
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
429
+	print '/';
430
+} else {
431
+	print $globalURL;
432
+}
433
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
407 434
     </div>
408 435
     <div class="collapse navbar-collapse">
409 436
 
@@ -458,7 +485,10 @@  discard block
 block discarded – undo
458 485
 	}
459 486
 ?>
460 487
 
461
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
488
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
489
+	echo 'right-';
490
+}
491
+?>caret"></b></a>
462 492
           <ul class="dropdown-menu">
463 493
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircraft Types"); ?></a></li>
464 494
 <?php
@@ -529,8 +559,14 @@  discard block
 block discarded – undo
529 559
         </li>
530 560
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
531 561
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
532
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
533
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
562
+        <li class="dropdown<?php if ($sub) {
563
+	echo '-submenu';
564
+}
565
+?>">
566
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
567
+	echo 'right-';
568
+}
569
+?>caret"></b></a>
534 570
           <ul class="dropdown-menu">
535 571
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
536 572
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -574,7 +610,10 @@  discard block
 block discarded – undo
574 610
 <?php
575 611
 	}
576 612
 ?>
577
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
613
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
614
+	echo 'right-';
615
+}
616
+?>caret"></b></a>
578 617
 		<ul class="dropdown-menu">
579 618
 <?php
580 619
 	if (isset($globalVM) && $globalVM) {
@@ -624,7 +663,10 @@  discard block
 block discarded – undo
624 663
 <?php
625 664
 	}
626 665
 ?>
627
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
666
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
667
+	echo 'right-';
668
+}
669
+?>caret"></b></a>
628 670
 		<ul class="dropdown-menu">
629 671
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
630 672
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -667,7 +709,10 @@  discard block
 block discarded – undo
667 709
 ?>
668 710
 
669 711
 <!--
670
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
712
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
713
+	echo 'right-';
714
+}
715
+?>caret"></b></a>
671 716
 		<ul class="dropdown-menu">
672 717
 		    <li><a href="<?php print $globalURL; ?>/satellite/currently"><?php echo _("Current Activity"); ?></a></li>
673 718
 		    <li><a href="<?php print $globalURL; ?>/satellite/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -725,9 +770,14 @@  discard block
 block discarded – undo
725 770
   		    <?php
726 771
   		        foreach ($alllang as $key => $lang) {
727 772
   		            print '<option value="'.$key.'"';
728
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
729
-  		            if ($lang[0] == 'Deutsch') print '>'.$lang[0].' (&beta;eta)</option>';
730
-  		            else print '>'.$lang[0].'</option>';
773
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
774
+  		            	print ' selected ';
775
+  		            }
776
+  		            if ($lang[0] == 'Deutsch') {
777
+  		            	print '>'.$lang[0].' (&beta;eta)</option>';
778
+  		            } else {
779
+  		            	print '>'.$lang[0].'</option>';
780
+  		            }
731 781
   		        }
732 782
   		    ?>
733 783
   		</select>
@@ -875,9 +925,24 @@  discard block
 block discarded – undo
875 925
 	$customid = $globalMapProvider;
876 926
 ?>
877 927
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
878
-        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
879
-        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
880
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
928
+        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
929
+	print $globalMapCustomLayer[$customid]['maxZoom'];
930
+} else {
931
+	print '18';
932
+}
933
+?>,
934
+        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
935
+	print $globalMapCustomLayer[$customid]['minZoom'];
936
+} else {
937
+	print '0';
938
+}
939
+?>,
940
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
941
+	print 'false';
942
+} else {
943
+	print 'true';
944
+}
945
+?>,
881 946
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
882 947
     }).addTo(map);
883 948
 <?php
@@ -892,7 +957,12 @@  discard block
 block discarded – undo
892 957
         maxZoom: 5,
893 958
         tms : true,
894 959
         zindex : 3,
895
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
960
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
961
+	print 'false';
962
+} else {
963
+	print 'true';
964
+}
965
+?>,
896 966
         attribution: 'Natural Earth'
897 967
     }).addTo(map);
898 968
 <?php
@@ -915,4 +985,7 @@  discard block
 block discarded – undo
915 985
 
916 986
 ?>
917 987
 
918
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
988
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
989
+	print 'index ';
990
+}
991
+?>clear">
Please login to merge, or discard this patch.
captain.php 1 patch
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 			}
34 34
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
35 35
 		}
36
-		if ($firstLetter != "'") $previous = $firstLetter;
36
+		if ($firstLetter != "'") {
37
+			$previous = $firstLetter;
38
+		}
37 39
 	}
38 40
 	print '</div>';
39 41
 	$previous = null;
@@ -48,10 +50,15 @@  discard block
 block discarded – undo
48 50
 				}
49 51
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
50 52
 			}
51
-			if ($firstLetter != "'") $previous = $firstLetter;
53
+			if ($firstLetter != "'") {
54
+				$previous = $firstLetter;
55
+			}
52 56
 			print '<div class="alphabet-item">';
53
-			if (isset($value['captain_id']) && $value['captain_id'] != '') print '<a href="'.$globalURL.'/marine/captain/'.$value['captain_id'].'">'.$value['captain_name'].' ('.$value['captain_id'].')';
54
-			else print '<a href="'.$globalURL.'/captain/'.$value['captain_name'].'">'.$value['captain_name'];
57
+			if (isset($value['captain_id']) && $value['captain_id'] != '') {
58
+				print '<a href="'.$globalURL.'/marine/captain/'.$value['captain_id'].'">'.$value['captain_name'].' ('.$value['captain_id'].')';
59
+			} else {
60
+				print '<a href="'.$globalURL.'/captain/'.$value['captain_name'].'">'.$value['captain_name'];
61
+			}
55 62
 			print '</a>';
56 63
 			print '</div>';
57 64
 		}
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +1210 added lines, -406 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,32 +211,44 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftjson';
178 233
         	$globalSources[$id]['format'] = 'aircraftjson';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraft.json source (".$host.")...\n";
237
+        	}
181 238
     	    } else if (preg_match('/aircraft$/i',$host)) {
182 239
         	//$formats[$id] = 'planefinderclient';
183 240
         	$globalSources[$id]['format'] = 'planefinderclient';
184 241
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to planefinderclient source (".$host.")...\n";
244
+        	}
186 245
     	    } else if (preg_match('/opensky/i',$host)) {
187 246
         	//$formats[$id] = 'aircraftlistjson';
188 247
         	$globalSources[$id]['format'] = 'opensky';
189 248
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to opensky source (".$host.")...\n";
251
+        	}
191 252
     	    /*
192 253
     	    // Disabled for now, site change source format
193 254
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -204,7 +265,9 @@  discard block
 block discarded – undo
204 265
         	//$formats[$id] = 'planeupdatefaa';
205 266
         	$globalSources[$id]['format'] = 'planeupdatefaa';
206 267
         	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
270
+        	}
208 271
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209 272
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210 273
         	    exit(0);
@@ -213,37 +276,53 @@  discard block
 block discarded – undo
213 276
         	//$formats[$id] = 'phpvmacars';
214 277
         	$globalSources[$id]['format'] = 'phpvmacars';
215 278
         	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
279
+        	if ($globalDebug) {
280
+        		echo "Connect to phpvmacars source (".$host.")...\n";
281
+        	}
217 282
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218 283
         	//$formats[$id] = 'phpvmacars';
219 284
         	$globalSources[$id]['format'] = 'vaos';
220 285
         	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
286
+        	if ($globalDebug) {
287
+        		echo "Connect to vaos source (".$host.")...\n";
288
+        	}
222 289
             } else if (preg_match('/VAM-json.php$/i',$host)) {
223 290
         	//$formats[$id] = 'phpvmacars';
224 291
         	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
292
+        	if ($globalDebug) {
293
+        		echo "Connect to Vam source (".$host.")...\n";
294
+        	}
226 295
             } else if (preg_match('/whazzup/i',$host)) {
227 296
         	//$formats[$id] = 'whazzup';
228 297
         	$globalSources[$id]['format'] = 'whazzup';
229 298
         	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
299
+        	if ($globalDebug) {
300
+        		echo "Connect to whazzup source (".$host.")...\n";
301
+        	}
231 302
             } else if (preg_match('/blitzortung/i',$host)) {
232 303
         	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
304
+        	if ($globalDebug) {
305
+        		echo "Connect to blitzortung source (".$host.")...\n";
306
+        	}
234 307
             } else if (preg_match('/airwhere/i',$host)) {
235 308
         	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
309
+        	if ($globalDebug) {
310
+        		echo "Connect to airwhere source (".$host.")...\n";
311
+        	}
237 312
             } else if (preg_match('/recentpireps/i',$host)) {
238 313
         	//$formats[$id] = 'pirepsjson';
239 314
         	$globalSources[$id]['format'] = 'pirepsjson';
240 315
         	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to pirepsjson source (".$host.")...\n";
318
+        	}
242 319
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243 320
         	//$formats[$id] = 'fr24json';
244 321
         	$globalSources[$id]['format'] = 'fr24json';
245 322
         	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
323
+        	if ($globalDebug) {
324
+        		echo "Connect to fr24 source (".$host.")...\n";
325
+        	}
247 326
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248 327
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249 328
         	    exit(0);
@@ -252,7 +331,9 @@  discard block
 block discarded – undo
252 331
         	//$formats[$id] = 'fr24json';
253 332
         	$globalSources[$id]['format'] = 'myshiptracking';
254 333
         	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
334
+        	if ($globalDebug) {
335
+        		echo "Connect to myshiptracking source (".$host.")...\n";
336
+        	}
256 337
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257 338
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 339
         	    exit(0);
@@ -261,17 +342,26 @@  discard block
 block discarded – undo
261 342
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262 343
         	//$formats[$id] = 'tsv';
263 344
         	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
345
+        	if ($globalDebug) {
346
+        		echo "Connect to tsv source (".$host.")...\n";
347
+        	}
265 348
             }
266 349
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267 350
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268 351
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269 352
     		    if ($idf !== false) {
270 353
     			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
354
+        		if ($globalDebug) {
355
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
356
+        		}
357
+    		    } elseif ($globalDebug) {
358
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
359
+    		    }
360
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
361
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
362
+    		} elseif ($globalDebug) {
363
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
364
+    		}
275 365
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276 366
 	    $hostport = explode(':',$host);
277 367
 	    if (isset($hostport[1])) {
@@ -311,19 +401,27 @@  discard block
 block discarded – undo
311 401
         		//$formats[$id] = 'beast';
312 402
         		$globalSources[$id]['format'] = 'beast';
313 403
 		    //} else $formats[$id] = 'sbs';
314
-		    } else $globalSources[$id]['format'] = 'sbs';
404
+		    } else {
405
+		    	$globalSources[$id]['format'] = 'sbs';
406
+		    }
315 407
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
316 408
 		}
317
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
409
+		if ($globalDebug) {
410
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
411
+		}
318 412
             } else {
319
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
413
+		if ($globalDebug) {
414
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
415
+		}
320 416
 		sleep(10);
321 417
 		connect_all($hosts);
322 418
     	    }
323 419
         }
324 420
     }
325 421
 }
326
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
422
+if (!isset($globalMinFetch)) {
423
+	$globalMinFetch = 15;
424
+}
327 425
 
328 426
 // Initialize all
329 427
 $status = array();
@@ -332,13 +430,19 @@  discard block
 block discarded – undo
332 430
 $formats = array();
333 431
 $last_exec = array();
334 432
 $time = time();
335
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
336
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
337
-else $timeout = 20;
433
+if (isset($globalSourcesTimeout)) {
434
+	$timeout = $globalSourcesTimeOut;
435
+} else if (isset($globalSBS1TimeOut)) {
436
+	$timeout = $globalSBS1TimeOut;
437
+} else {
438
+	$timeout = 20;
439
+}
338 440
 $errno = '';
339 441
 $errstr='';
340 442
 
341
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
443
+if (!isset($globalDaemon)) {
444
+	$globalDaemon = TRUE;
445
+}
342 446
 /* Initiate connections to all the hosts simultaneously */
343 447
 //connect_all($hosts);
344 448
 //connect_all($globalSources);
@@ -367,7 +471,9 @@  discard block
 block discarded – undo
367 471
     if (isset($source['format']) && $source['format'] == 'aprs') {
368 472
 	$aprs_connect = 0;
369 473
 	$use_aprs = true;
370
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
474
+	if (isset($source['port']) && $source['port'] == '10152') {
475
+		$aprs_full = true;
476
+	}
371 477
 	break;
372 478
     }
373 479
 }
@@ -378,25 +484,46 @@  discard block
 block discarded – undo
378 484
 	$aprs_connect = 0;
379 485
 	$aprs_keep = 120;
380 486
 	$aprs_last_tx = time();
381
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
382
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
383
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
384
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
385
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
386
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
387
-	if ($aprs_full) $aprs_filter = '';
388
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
389
-	else $aprs_pass = '-1';
487
+	if (isset($globalAPRSversion)) {
488
+		$aprs_version = $globalAPRSversion;
489
+	} else {
490
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
491
+	}
492
+	if (isset($globalAPRSssid)) {
493
+		$aprs_ssid = $globalAPRSssid;
494
+	} else {
495
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
496
+	}
497
+	if (isset($globalAPRSfilter)) {
498
+		$aprs_filter = $globalAPRSfilter;
499
+	} else {
500
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
501
+	}
502
+	if ($aprs_full) {
503
+		$aprs_filter = '';
504
+	}
505
+	if (isset($globalAPRSpass)) {
506
+		$aprs_pass = $globalAPRSpass;
507
+	} else {
508
+		$aprs_pass = '-1';
509
+	}
390 510
 
391
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
392
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
393
-}
511
+	if ($aprs_filter != '') {
512
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
513
+	} else {
514
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
515
+	}
516
+	}
394 517
 
395 518
 // connected - lets do some work
396 519
 //if ($globalDebug) echo "Connected!\n";
397 520
 sleep(1);
398
-if ($globalDebug) echo "SCAN MODE \n\n";
399
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
521
+if ($globalDebug) {
522
+	echo "SCAN MODE \n\n";
523
+}
524
+if (!isset($globalCronEnd)) {
525
+	$globalCronEnd = 60;
526
+}
400 527
 $endtime = time()+$globalCronEnd;
401 528
 $i = 1;
402 529
 $tt = array();
@@ -410,22 +537,32 @@  discard block
 block discarded – undo
410 537
 
411 538
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
412 539
 while ($i > 0) {
413
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
540
+    if (function_exists('pcntl_fork')) {
541
+    	pcntl_signal_dispatch();
542
+    }
414 543
 
415
-    if (!$globalDaemon) $i = $endtime-time();
544
+    if (!$globalDaemon) {
545
+    	$i = $endtime-time();
546
+    }
416 547
     // Delete old ATC
417 548
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
418
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
549
+	if ($globalDebug) {
550
+		echo 'Delete old ATC...'."\n";
551
+	}
419 552
         $ATC->deleteOldATC();
420 553
     }
421 554
     
422 555
     if (count($last_exec) == count($globalSources)) {
423 556
 	$max = $globalMinFetch;
424 557
 	foreach ($last_exec as $last) {
425
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
558
+	    if ((time() - $last['last']) < $max) {
559
+	    	$max = time() - $last['last'];
560
+	    }
426 561
 	}
427 562
 	if ($max < $globalMinFetch) {
428
-	    if ($globalDebug) echo 'Sleeping...'."\n";
563
+	    if ($globalDebug) {
564
+	    	echo 'Sleeping...'."\n";
565
+	    }
429 566
 	    sleep($globalMinFetch-$max+2);
430 567
 	}
431 568
     }
@@ -435,7 +572,9 @@  discard block
 block discarded – undo
435 572
     foreach ($globalSources as $id => $value) {
436 573
 	date_default_timezone_set('UTC');
437 574
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
438
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
575
+	if (!isset($last_exec[$id]['last'])) {
576
+		$last_exec[$id]['last'] = 0;
577
+	}
439 578
 	if ($value['format'] === 'deltadbtxt' && 
440 579
 	    (
441 580
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -444,7 +583,9 @@  discard block
 block discarded – undo
444 583
 	) {
445 584
 	    //$buffer = $Common->getData($hosts[$id]);
446 585
 	    $buffer = $Common->getData($value['host']);
447
-	    if ($buffer != '') $reset = 0;
586
+	    if ($buffer != '') {
587
+	    	$reset = 0;
588
+	    }
448 589
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449 590
 	    $buffer = explode('\n',$buffer);
450 591
 	    foreach ($buffer as $line) {
@@ -453,20 +594,41 @@  discard block
 block discarded – undo
453 594
 	            $data = array();
454 595
 	            $data['hex'] = $line[1]; // hex
455 596
 	            $data['ident'] = $line[2]; // ident
456
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
597
+	            if (isset($line[3])) {
598
+	            	$data['altitude'] = $line[3];
599
+	            }
600
+	            // altitude
601
+	            if (isset($line[4])) {
602
+	            	$data['speed'] = $line[4];
603
+	            }
604
+	            // speed
605
+	            if (isset($line[5])) {
606
+	            	$data['heading'] = $line[5];
607
+	            }
608
+	            // heading
609
+	            if (isset($line[6])) {
610
+	            	$data['latitude'] = $line[6];
611
+	            }
612
+	            // lat
613
+	            if (isset($line[7])) {
614
+	            	$data['longitude'] = $line[7];
615
+	            }
616
+	            // long
461 617
 	            $data['verticalrate'] = ''; // vertical rate
462 618
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463 619
 	            $data['emergency'] = ''; // emergency
464 620
 		    $data['datetime'] = date('Y-m-d H:i:s');
465 621
 		    $data['format_source'] = 'deltadbtxt';
466 622
     		    $data['id_source'] = $id_source;
467
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
623
+		    if (isset($value['name']) && $value['name'] != '') {
624
+		    	$data['source_name'] = $value['name'];
625
+		    }
626
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
627
+		    	$data['noarchive'] = true;
628
+		    }
629
+		    if (isset($value['sourcestats'])) {
630
+		    	$data['sourcestats'] = $value['sourcestats'];
631
+		    }
470 632
     		    $SI->add($data);
471 633
 		    unset($data);
472 634
     		}
@@ -481,7 +643,9 @@  discard block
 block discarded – undo
481 643
 	    date_default_timezone_set('CET');
482 644
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483 645
 	    date_default_timezone_set('UTC');
484
-	    if ($buffer != '') $reset = 0;
646
+	    if ($buffer != '') {
647
+	    	$reset = 0;
648
+	    }
485 649
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486 650
 	    $buffer = explode('\n',$buffer);
487 651
 	    foreach ($buffer as $line) {
@@ -490,18 +654,42 @@  discard block
 block discarded – undo
490 654
 		    $add = false;
491 655
 		    $ais_data = $AIS->parse_line(trim($line));
492 656
 		    $data = array();
493
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
657
+		    if (isset($ais_data['ident'])) {
658
+		    	$data['ident'] = $ais_data['ident'];
659
+		    }
660
+		    if (isset($ais_data['mmsi'])) {
661
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
662
+		    }
663
+		    if (isset($ais_data['speed'])) {
664
+		    	$data['speed'] = $ais_data['speed'];
665
+		    }
666
+		    if (isset($ais_data['heading'])) {
667
+		    	$data['heading'] = $ais_data['heading'];
668
+		    }
669
+		    if (isset($ais_data['latitude'])) {
670
+		    	$data['latitude'] = $ais_data['latitude'];
671
+		    }
672
+		    if (isset($ais_data['longitude'])) {
673
+		    	$data['longitude'] = $ais_data['longitude'];
674
+		    }
675
+		    if (isset($ais_data['status'])) {
676
+		    	$data['status'] = $ais_data['status'];
677
+		    }
678
+		    if (isset($ais_data['statusid'])) {
679
+		    	$data['status_id'] = $ais_data['statusid'];
680
+		    }
681
+		    if (isset($ais_data['type'])) {
682
+		    	$data['type'] = $ais_data['type'];
683
+		    }
684
+		    if (isset($ais_data['typeid'])) {
685
+		    	$data['type_id'] = $ais_data['typeid'];
686
+		    }
687
+		    if (isset($ais_data['imo'])) {
688
+		    	$data['imo'] = $ais_data['imo'];
689
+		    }
690
+		    if (isset($ais_data['callsign'])) {
691
+		    	$data['callsign'] = $ais_data['callsign'];
692
+		    }
505 693
 		    if (isset($ais_data['timestamp'])) {
506 694
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
507 695
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -515,8 +703,12 @@  discard block
 block discarded – undo
515 703
 		    $data['format_source'] = 'aisnmeatxt';
516 704
     		    $data['id_source'] = $id_source;
517 705
 		    //print_r($data);
518
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
706
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
707
+		    	$data['noarchive'] = true;
708
+		    }
709
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
710
+		    	$MI->add($data);
711
+		    }
520 712
 		    unset($data);
521 713
 		}
522 714
     	    }
@@ -539,20 +731,48 @@  discard block
 block discarded – undo
539 731
 			    if ($line != '') {
540 732
 				$ais_data = $AIS->parse_line(trim($line));
541 733
 				$data = array();
542
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
543
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
544
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
545
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
546
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
547
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
548
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
549
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
550
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
551
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
552
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
553
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
554
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
555
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
734
+				if (isset($ais_data['ident'])) {
735
+					$data['ident'] = $ais_data['ident'];
736
+				}
737
+				if (isset($ais_data['mmsi'])) {
738
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
739
+				}
740
+				if (isset($ais_data['speed'])) {
741
+					$data['speed'] = $ais_data['speed'];
742
+				}
743
+				if (isset($ais_data['heading'])) {
744
+					$data['heading'] = $ais_data['heading'];
745
+				}
746
+				if (isset($ais_data['latitude'])) {
747
+					$data['latitude'] = $ais_data['latitude'];
748
+				}
749
+				if (isset($ais_data['longitude'])) {
750
+					$data['longitude'] = $ais_data['longitude'];
751
+				}
752
+				if (isset($ais_data['status'])) {
753
+					$data['status'] = $ais_data['status'];
754
+				}
755
+				if (isset($ais_data['statusid'])) {
756
+					$data['status_id'] = $ais_data['statusid'];
757
+				}
758
+				if (isset($ais_data['type'])) {
759
+					$data['type'] = $ais_data['type'];
760
+				}
761
+				if (isset($ais_data['typeid'])) {
762
+					$data['type_id'] = $ais_data['typeid'];
763
+				}
764
+				if (isset($ais_data['imo'])) {
765
+					$data['imo'] = $ais_data['imo'];
766
+				}
767
+				if (isset($ais_data['callsign'])) {
768
+					$data['callsign'] = $ais_data['callsign'];
769
+				}
770
+				if (isset($ais_data['destination'])) {
771
+					$data['arrival_code'] = $ais_data['destination'];
772
+				}
773
+				if (isset($ais_data['eta_ts'])) {
774
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
775
+				}
556 776
 				if (isset($ais_data['timestamp'])) {
557 777
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558 778
 				} else {
@@ -560,18 +780,27 @@  discard block
 block discarded – undo
560 780
 				}
561 781
 				$data['format_source'] = 'aisnmeahttp';
562 782
 				$data['id_source'] = $id_source;
563
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
564
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
783
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
784
+					$data['noarchive'] = true;
785
+				}
786
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
787
+					$MI->add($data);
788
+				}
565 789
 				unset($data);
566 790
 			    }
567 791
 			}
568 792
 		    }
569 793
 		} else {
570 794
 		    $format = $value['format'];
571
-		    if (isset($tt[$format])) $tt[$format]++;
572
-		    else $tt[$format] = 0;
795
+		    if (isset($tt[$format])) {
796
+		    	$tt[$format]++;
797
+		    } else {
798
+		    	$tt[$format] = 0;
799
+		    }
573 800
 		    if ($tt[$format] > 30) {
574
-			if ($globalDebug) echo 'Reconnect...'."\n";
801
+			if ($globalDebug) {
802
+				echo 'Reconnect...'."\n";
803
+			}
575 804
 			sleep(2);
576 805
 			//$sourceeen[] = $value;
577 806
 			//connect_all($sourceeen);
@@ -607,12 +836,18 @@  discard block
 block discarded – undo
607 836
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608 837
 			    //$data['type_id'] = $line['TYPE'];
609 838
 			    $data['imo'] = $line['IMO'];
610
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
839
+			    if ($line['DEST'] != '') {
840
+			    	$data['arrival_code'] = $line['DEST'];
841
+			    }
842
+			    if ($line['ARV'] != '') {
843
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
844
+			    }
612 845
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613 846
 			    $data['format_source'] = 'myshiptracking';
614 847
 			    $data['id_source'] = $id_source;
615
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
848
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
849
+			    	$data['noarchive'] = true;
850
+			    }
616 851
 			    $MI->add($data);
617 852
 			    unset($data);
618 853
 			}
@@ -637,7 +872,9 @@  discard block
 block discarded – undo
637 872
 			    $data['callsign'] = $line['callsign'];
638 873
 			    $data['mmsi'] = substr($line['mmsi'],-9);
639 874
 			    $data['speed'] = $line['sog'];
640
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
875
+			    if ($line['heading'] != '511') {
876
+			    	$data['heading'] = $line['heading'];
877
+			    }
641 878
 			    $data['latitude'] = $line['latitude'];
642 879
 			    $data['longitude'] = $line['longitude'];
643 880
 			    $data['type_id'] = $line['shiptype'];
@@ -645,7 +882,9 @@  discard block
 block discarded – undo
645 882
 			    $data['datetime'] = $line['time'];
646 883
 			    $data['format_source'] = 'boatbeaconapp';
647 884
 			    $data['id_source'] = $id_source;
648
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
885
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
886
+			    	$data['noarchive'] = true;
887
+			    }
649 888
 			    $MI->add($data);
650 889
 			    unset($data);
651 890
 			}
@@ -667,22 +906,44 @@  discard block
 block discarded – undo
667 906
 		    foreach ($all_data['features'] as $line) {
668 907
 			print_r($line);
669 908
 			$data = array();
670
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
671
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
672
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
673
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
674
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
675
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
909
+			if (isset($line['properties']['name'])) {
910
+				$data['ident'] = $line['properties']['name'];
911
+			}
912
+			if (isset($line['properties']['callsign'])) {
913
+				$data['callsign'] = $line['properties']['callsign'];
914
+			}
915
+			if (isset($line['properties']['mmsi'])) {
916
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
917
+			}
918
+			if (isset($line['properties']['imo'])) {
919
+				$data['imo'] = $line['properties']['imo'];
920
+			}
921
+			if (isset($line['properties']['speed'])) {
922
+				$data['speed'] = $line['properties']['speed'];
923
+			}
924
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
925
+				$data['heading'] = $line['properties']['heading'];
926
+			}
676 927
 			$data['latitude'] = $line['geometry']['coordinates'][1];
677 928
 			$data['longitude'] = $line['geometry']['coordinates'][0];
678
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
679
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
680
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
929
+			if (isset($line['properties']['vesselType'])) {
930
+				$data['type'] = $line['properties']['vesselType'];
931
+			}
932
+			if (isset($line['properties']['destination'])) {
933
+				$data['arrival_code'] = $line['properties']['destination'];
934
+			}
935
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
936
+				$data['arrival_date'] = $line['properties']['eta'];
937
+			}
681 938
 			$data['format_source'] = 'boatnerd';
682 939
 			$data['id_source'] = $id_source;
683 940
 			$data['datetime'] = date('Y-m-d H:i:s');
684
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
685
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
941
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
942
+				$data['noarchive'] = true;
943
+			}
944
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
945
+				$MI->add($data);
946
+			}
686 947
 			unset($data);
687 948
 		    }
688 949
 		}
@@ -695,11 +956,17 @@  discard block
 block discarded – undo
695 956
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
696 957
 	    )
697 958
 	) {
698
-	    if ($globalDebug) echo 'download...';
959
+	    if ($globalDebug) {
960
+	    	echo 'download...';
961
+	    }
699 962
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
-	    if ($globalDebug) echo 'done !'."\n";
963
+	    if ($globalDebug) {
964
+	    	echo 'done !'."\n";
965
+	    }
701 966
 	    // FIXME: Need more work
702
-	    if ($buffer != '') $reset = 0;
967
+	    if ($buffer != '') {
968
+	    	$reset = 0;
969
+	    }
703 970
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704 971
 	    $buffer = explode('\n',$buffer);
705 972
 	    foreach ($buffer as $line) {
@@ -725,7 +992,9 @@  discard block
 block discarded – undo
725 992
 		    //$data['etaTime'] = substr($line,135,5);
726 993
 		    $data['format_source'] = 'shipplotter';
727 994
     		    $data['id_source'] = $id_source;
728
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
995
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
996
+		    	$data['noarchive'] = true;
997
+		    }
729 998
 		    //print_r($data);
730 999
 		    //echo 'Add...'."\n";
731 1000
 		    $MI->add($data);
@@ -739,11 +1008,17 @@  discard block
 block discarded – undo
739 1008
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
740 1009
 	    )
741 1010
 	) {
742
-	    if ($globalDebug) echo '! Download... ';
1011
+	    if ($globalDebug) {
1012
+	    	echo '! Download... ';
1013
+	    }
743 1014
 	    for ($i =0; $i <= 1; $i++) {
744
-		    if ($globalDebug) echo 'Racetype: '.$i.' ';
1015
+		    if ($globalDebug) {
1016
+		    	echo 'Racetype: '.$i.' ';
1017
+		    }
745 1018
 	    $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
746
-	    if ($globalDebug) echo 'done'."\n";
1019
+	    if ($globalDebug) {
1020
+	    	echo 'done'."\n";
1021
+	    }
747 1022
 	    if ($buffer != '') {
748 1023
 		$all_data = json_decode($buffer,true);
749 1024
 		if (isset($all_data['missions'])) {
@@ -752,7 +1027,9 @@  discard block
 block discarded – undo
752 1027
 				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$mission['mistitle']);
753 1028
 				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
754 1029
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
755
-				} else $bufferm = '';
1030
+				} else {
1031
+					$bufferm = '';
1032
+				}
756 1033
 				if ($bufferm != '') {
757 1034
 					$mission_data = json_decode($bufferm,true);
758 1035
 					if (isset($mission_data['leaderboard'][0]['results'])) {
@@ -791,7 +1068,9 @@  discard block
 block discarded – undo
791 1068
 								//$data['callsign'] = trim(substr($line,100,7);
792 1069
 								$data['format_source'] = 'sailaway';
793 1070
 								$data['id_source'] = $id_source;
794
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1071
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1072
+									$data['noarchive'] = true;
1073
+								}
795 1074
 								//print_r($data);
796 1075
 								//echo 'Add...'."\n";
797 1076
 								$MI->add($data);
@@ -832,16 +1111,28 @@  discard block
 block discarded – undo
832 1111
     		    $line = explode(':', $line);
833 1112
     		    if (count($line) > 30 && $line[0] != 'callsign') {
834 1113
 			$data = array();
835
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
836
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1114
+			if (isset($line[37]) && $line[37] != '') {
1115
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1116
+			} else {
1117
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1118
+			}
837 1119
 			$data['pilot_id'] = $line[1];
838 1120
 			$data['pilot_name'] = $line[2];
839 1121
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
840 1122
 			$data['ident'] = $line[0]; // ident
841
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1123
+			if ($line[7] != '' && $line[7] != 0) {
1124
+				$data['altitude'] = $line[7];
1125
+			}
1126
+			// altitude
842 1127
 			$data['speed'] = $line[8]; // speed
843
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
844
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1128
+			if (isset($line[45])) {
1129
+				$data['heading'] = $line[45];
1130
+			}
1131
+			// heading
1132
+			elseif (isset($line[38])) {
1133
+				$data['heading'] = $line[38];
1134
+			}
1135
+			// heading
845 1136
 			$data['latitude'] = $line[5]; // lat
846 1137
 	        	$data['longitude'] = $line[6]; // long
847 1138
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -857,7 +1148,9 @@  discard block
 block discarded – undo
857 1148
 			$data['frequency'] = $line[4];
858 1149
 			$data['type'] = $line[18];
859 1150
 			$data['range'] = $line[19];
860
-			if (isset($line[35])) $data['info'] = $line[35];
1151
+			if (isset($line[35])) {
1152
+				$data['info'] = $line[35];
1153
+			}
861 1154
     			$data['id_source'] = $id_source;
862 1155
 	    		//$data['arrival_airport_time'] = ;
863 1156
 	    		if ($line[9] != '') {
@@ -871,27 +1164,47 @@  discard block
 block discarded – undo
871 1164
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
872 1165
 	    		*/
873 1166
 	    		$data['format_source'] = $value['format'];
874
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
875
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
876
-    			if ($line[3] === 'PILOT') $SI->add($data);
877
-			elseif ($line[3] === 'ATC') {
1167
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1168
+				$data['noarchive'] = true;
1169
+			}
1170
+			if (isset($value['name']) && $value['name'] != '') {
1171
+				$data['source_name'] = $value['name'];
1172
+			}
1173
+    			if ($line[3] === 'PILOT') {
1174
+    				$SI->add($data);
1175
+    			} elseif ($line[3] === 'ATC') {
878 1176
 				//print_r($data);
879 1177
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
880 1178
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
881 1179
 				$typec = substr($data['ident'],-3);
882
-				if ($typec === 'APP') $data['type'] = 'Approach';
883
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
884
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
885
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
886
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
887
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
888
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
889
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
890
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
891
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1180
+				if ($typec === 'APP') {
1181
+					$data['type'] = 'Approach';
1182
+				} elseif ($typec === 'TWR') {
1183
+					$data['type'] = 'Tower';
1184
+				} elseif ($typec === 'OBS') {
1185
+					$data['type'] = 'Observer';
1186
+				} elseif ($typec === 'GND') {
1187
+					$data['type'] = 'Ground';
1188
+				} elseif ($typec === 'DEL') {
1189
+					$data['type'] = 'Delivery';
1190
+				} elseif ($typec === 'DEP') {
1191
+					$data['type'] = 'Departure';
1192
+				} elseif ($typec === 'FSS') {
1193
+					$data['type'] = 'Flight Service Station';
1194
+				} elseif ($typec === 'CTR') {
1195
+					$data['type'] = 'Control Radar or Centre';
1196
+				} elseif ($data['type'] === '') {
1197
+					$data['type'] = 'Observer';
1198
+				}
1199
+				if (!isset($data['source_name'])) {
1200
+					$data['source_name'] = '';
1201
+				}
892 1202
 				if (isset($ATC)) {
893
-					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']);
894
-					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']);
1203
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1204
+						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']);
1205
+					} else {
1206
+						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']);
1207
+					}
895 1208
 				}
896 1209
 			}
897 1210
     			unset($data);
@@ -918,14 +1231,20 @@  discard block
 block discarded – undo
918 1231
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
919 1232
 			$data['latitude'] = (float)$line['pktLatitude'];
920 1233
 			$data['longitude'] = (float)$line['pktLongitude'];
921
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
922
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1234
+			if ((float)$line['pktTrack'] != 0) {
1235
+				$data['heading'] = (float)$line['pktTrack'];
1236
+			}
1237
+			if ((int)$line['pktSpeed'] != 0) {
1238
+				$data['speed'] = (int)$line['pktSpeed'];
1239
+			}
923 1240
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
924 1241
 			$data['altitude_relative'] = 'AMSL';
925 1242
 			$data['pilot_id'] = (int)$line['pktPilotID'];
926 1243
 			$data['aircraft_icao'] = 'PARAGLIDER';
927 1244
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
928
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1245
+			if (isset($pilot_data[4])) {
1246
+				$data['pilot_name'] = $pilot_data[4];
1247
+			}
929 1248
 			$data['format_source'] = $value['format'];
930 1249
 			$SI->add($data);
931 1250
 			unset($data);
@@ -973,25 +1292,59 @@  discard block
 block discarded – undo
973 1292
 		    foreach ($all_data['acList'] as $line) {
974 1293
 			$data = array();
975 1294
 			$data['hex'] = $line['Icao']; // hex
976
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
977
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
978
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
979
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
980
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
981
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1295
+			if (isset($line['Call'])) {
1296
+				$data['ident'] = $line['Call'];
1297
+			}
1298
+			// ident
1299
+			if (isset($line['Alt'])) {
1300
+				$data['altitude'] = $line['Alt'];
1301
+			}
1302
+			// altitude
1303
+			if (isset($line['Spd'])) {
1304
+				$data['speed'] = $line['Spd'];
1305
+			}
1306
+			// speed
1307
+			if (isset($line['Trak'])) {
1308
+				$data['heading'] = $line['Trak'];
1309
+			}
1310
+			// heading
1311
+			if (isset($line['Lat'])) {
1312
+				$data['latitude'] = $line['Lat'];
1313
+			}
1314
+			// lat
1315
+			if (isset($line['Long'])) {
1316
+				$data['longitude'] = $line['Long'];
1317
+			}
1318
+			// long
982 1319
 			//$data['verticalrate'] = $line['']; // verticale rate
983
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1320
+			if (isset($line['Sqk'])) {
1321
+				$data['squawk'] = $line['Sqk'];
1322
+			}
1323
+			// squawk
984 1324
 			$data['emergency'] = ''; // emergency
985
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
986
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
987
-			else $data['datetime'] = date('Y-m-d H:i:s');
1325
+			if (isset($line['Reg'])) {
1326
+				$data['registration'] = $line['Reg'];
1327
+			}
1328
+			if (isset($line['PosTime'])) {
1329
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1330
+			} else {
1331
+				$data['datetime'] = date('Y-m-d H:i:s');
1332
+			}
988 1333
 			//$data['datetime'] = date('Y-m-d H:i:s');
989
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1334
+			if (isset($line['Type'])) {
1335
+				$data['aircraft_icao'] = $line['Type'];
1336
+			}
990 1337
 			$data['format_source'] = 'aircraftlistjson';
991 1338
 			$data['id_source'] = $id_source;
992
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
993
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
994
-			if (isset($data['latitude'])) $SI->add($data);
1339
+			if (isset($value['name']) && $value['name'] != '') {
1340
+				$data['source_name'] = $value['name'];
1341
+			}
1342
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1343
+				$data['noarchive'] = true;
1344
+			}
1345
+			if (isset($data['latitude'])) {
1346
+				$SI->add($data);
1347
+			}
995 1348
 			unset($data);
996 1349
 		    }
997 1350
 		} elseif (is_array($all_data)) {
@@ -1008,17 +1361,26 @@  discard block
 block discarded – undo
1008 1361
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1009 1362
 			$data['squawk'] = $line['squawk']; // squawk
1010 1363
 			$data['emergency'] = ''; // emergency
1011
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1012
-			else $data['datetime'] = date('Y-m-d H:i:s');
1364
+			if (isset($line['PosTime'])) {
1365
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1366
+			} else {
1367
+				$data['datetime'] = date('Y-m-d H:i:s');
1368
+			}
1013 1369
 			$data['format_source'] = 'aircraftlistjson';
1014 1370
 			$data['id_source'] = $id_source;
1015
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1016
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1371
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1372
+				$data['noarchive'] = true;
1373
+			}
1374
+			if (isset($value['name']) && $value['name'] != '') {
1375
+				$data['source_name'] = $value['name'];
1376
+			}
1017 1377
 			$SI->add($data);
1018 1378
 			unset($data);
1019 1379
 		    }
1020 1380
 		}
1021
-	    } elseif ($globalDebug) echo 'No data'."\n";
1381
+	    } elseif ($globalDebug) {
1382
+	    	echo 'No data'."\n";
1383
+	    }
1022 1384
     	    //$last_exec['aircraftlistjson'] = time();
1023 1385
     	    $last_exec[$id]['last'] = time();
1024 1386
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1054,8 +1416,12 @@  discard block
 block discarded – undo
1054 1416
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1055 1417
 	    	    $data['format_source'] = 'planeupdatefaa';
1056 1418
     		    $data['id_source'] = $id_source;
1057
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1419
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1420
+		    	$data['noarchive'] = true;
1421
+		    }
1422
+		    if (isset($value['name']) && $value['name'] != '') {
1423
+		    	$data['source_name'] = $value['name'];
1424
+		    }
1059 1425
 		    $SI->add($data);
1060 1426
 		    unset($data);
1061 1427
 		}
@@ -1089,7 +1455,9 @@  discard block
 block discarded – undo
1089 1455
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1090 1456
 		    $data['format_source'] = 'opensky';
1091 1457
 		    $data['id_source'] = $id_source;
1092
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1458
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1459
+		    	$data['noarchive'] = true;
1460
+		    }
1093 1461
 		    $SI->add($data);
1094 1462
 		    unset($data);
1095 1463
 		}
@@ -1109,15 +1477,42 @@  discard block
 block discarded – undo
1109 1477
 		foreach ($all_data['aircraft'] as $key => $line) {
1110 1478
 		    $data = array();
1111 1479
 		    // add support for ground vehicule with ~ in front of hex
1112
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1113
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1114
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1115
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1116
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1117
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1118
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1119
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1120
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1480
+		    if (isset($line['hex'])) {
1481
+		    	$data['hex'] = $line['hex'];
1482
+		    }
1483
+		    // hex
1484
+		    if (isset($line['flight'])) {
1485
+		    	$data['ident'] = trim($line['flight']);
1486
+		    }
1487
+		    // ident
1488
+		    if (isset($line['altitude'])) {
1489
+		    	$data['altitude'] = $line['altitude'];
1490
+		    }
1491
+		    // altitude
1492
+		    if (isset($line['speed'])) {
1493
+		    	$data['speed'] = $line['speed'];
1494
+		    }
1495
+		    // speed
1496
+		    if (isset($line['track'])) {
1497
+		    	$data['heading'] = $line['track'];
1498
+		    }
1499
+		    // heading
1500
+		    if (isset($line['lat'])) {
1501
+		    	$data['latitude'] = $line['lat'];
1502
+		    }
1503
+		    // lat
1504
+		    if (isset($line['lon'])) {
1505
+		    	$data['longitude'] = $line['lon'];
1506
+		    }
1507
+		    // long
1508
+		    if (isset($line['vert_rate'])) {
1509
+		    	$data['verticalrate'] = $line['vert_rate'];
1510
+		    }
1511
+		    // verticale rate
1512
+		    if (isset($line['squawk'])) {
1513
+		    	$data['squawk'] = $line['squawk'];
1514
+		    }
1515
+		    // squawk
1121 1516
 		    //$data['emergency'] = ''; // emergency
1122 1517
 		    //$data['registration'] = $line[2];
1123 1518
 		    //$data['aircraft_icao'] = $line[0];
@@ -1125,10 +1520,17 @@  discard block
 block discarded – undo
1125 1520
 		    $data['format_source'] = 'aircraftjson';
1126 1521
 		    $data['id_source'] = $id_source;
1127 1522
 		    if (isset($value['name']) && $value['name'] != '') {
1128
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1129
-			    else $data['source_name'] = $value['name'];
1130
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1131
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1523
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1524
+			    	$data['source_name'] = $value['name'].'_MLAT';
1525
+			    } else {
1526
+			    	$data['source_name'] = $value['name'];
1527
+			    }
1528
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1529
+		    	$data['source_name'] = 'MLAT';
1530
+		    }
1531
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1532
+		    	$data['noarchive'] = true;
1533
+		    }
1132 1534
 		    $SI->add($data);
1133 1535
 		    unset($data);
1134 1536
 		}
@@ -1148,22 +1550,54 @@  discard block
 block discarded – undo
1148 1550
 		foreach ($all_data['aircraft'] as $key => $line) {
1149 1551
 		    $data = array();
1150 1552
 		    $data['hex'] = $key; // hex
1151
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1152
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1153
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1154
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1155
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1156
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1157
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1158
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1553
+		    if (isset($line['callsign'])) {
1554
+		    	$data['ident'] = trim($line['callsign']);
1555
+		    }
1556
+		    // ident
1557
+		    if (isset($line['altitude'])) {
1558
+		    	$data['altitude'] = $line['altitude'];
1559
+		    }
1560
+		    // altitude
1561
+		    if (isset($line['speed'])) {
1562
+		    	$data['speed'] = $line['speed'];
1563
+		    }
1564
+		    // speed
1565
+		    if (isset($line['heading'])) {
1566
+		    	$data['heading'] = $line['heading'];
1567
+		    }
1568
+		    // heading
1569
+		    if (isset($line['lat'])) {
1570
+		    	$data['latitude'] = $line['lat'];
1571
+		    }
1572
+		    // lat
1573
+		    if (isset($line['lon'])) {
1574
+		    	$data['longitude'] = $line['lon'];
1575
+		    }
1576
+		    // long
1577
+		    if (isset($line['vert_rate'])) {
1578
+		    	$data['verticalrate'] = $line['vert_rate'];
1579
+		    }
1580
+		    // verticale rate
1581
+		    if (isset($line['squawk'])) {
1582
+		    	$data['squawk'] = $line['squawk'];
1583
+		    }
1584
+		    // squawk
1159 1585
 		    //$data['emergency'] = ''; // emergency
1160
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1161
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1586
+		    if (isset($line['reg'])) {
1587
+		    	$data['registration'] = $line['reg'];
1588
+		    }
1589
+		    if (isset($line['type'])) {
1590
+		    	$data['aircraft_icao'] = $line['type'];
1591
+		    }
1162 1592
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1163 1593
 		    $data['format_source'] = 'planefinderclient';
1164 1594
 		    $data['id_source'] = $id_source;
1165
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1166
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1595
+		    if (isset($value['name']) && $value['name'] != '') {
1596
+		    	$data['source_name'] = $value['name'];
1597
+		    }
1598
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1599
+		    	$data['noarchive'] = true;
1600
+		    }
1167 1601
 		    $SI->add($data);
1168 1602
 		    unset($data);
1169 1603
 		}
@@ -1179,7 +1613,9 @@  discard block
 block discarded – undo
1179 1613
 	    //$buffer = $Common->getData($hosts[$id]);
1180 1614
 	    $buffer = $Common->getData($value['host']);
1181 1615
 	    $all_data = json_decode($buffer,true);
1182
-	    if (!empty($all_data)) $reset = 0;
1616
+	    if (!empty($all_data)) {
1617
+	    	$reset = 0;
1618
+	    }
1183 1619
 	    foreach ($all_data as $key => $line) {
1184 1620
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1185 1621
 		    $data = array();
@@ -1200,8 +1636,12 @@  discard block
 block discarded – undo
1200 1636
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1201 1637
 	    	    $data['format_source'] = 'fr24json';
1202 1638
     		    $data['id_source'] = $id_source;
1203
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1204
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1639
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1640
+		    	$data['noarchive'] = true;
1641
+		    }
1642
+		    if (isset($value['name']) && $value['name'] != '') {
1643
+		    	$data['source_name'] = $value['name'];
1644
+		    }
1205 1645
 		    $SI->add($data);
1206 1646
 		    unset($data);
1207 1647
 		}
@@ -1230,24 +1670,42 @@  discard block
 block discarded – undo
1230 1670
 		    if (isset($line['inf'])) {
1231 1671
 			$data = array();
1232 1672
 			$data['hex'] = $line['inf']['ia'];
1233
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1673
+			if (isset($line['inf']['cs'])) {
1674
+				$data['ident'] = $line['inf']['cs'];
1675
+			}
1676
+			//$line[13]
1234 1677
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1235
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1236
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1678
+	    		if (isset($line['inf']['gs'])) {
1679
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1680
+	    		}
1681
+	    		// speed
1682
+	    		if (isset($line['inf']['tr'])) {
1683
+	    			$data['heading'] = $line['inf']['tr'];
1684
+	    		}
1685
+	    		// heading
1237 1686
 	    		$data['latitude'] = $line['pt'][0]; // lat
1238 1687
 	    		$data['longitude'] = $line['pt'][1]; // long
1239 1688
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1240
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1689
+	    		if (isset($line['inf']['sq'])) {
1690
+	    			$data['squawk'] = $line['inf']['sq'];
1691
+	    		}
1692
+	    		// squawk
1241 1693
 	    		//$data['aircraft_icao'] = $line[8];
1242
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1694
+	    		if (isset($line['inf']['rc'])) {
1695
+	    			$data['registration'] = $line['inf']['rc'];
1696
+	    		}
1243 1697
 			//$data['departure_airport_iata'] = $line[11];
1244 1698
 			//$data['arrival_airport_iata'] = $line[12];
1245 1699
 	    		//$data['emergency'] = ''; // emergency
1246 1700
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1247 1701
 	    		$data['format_source'] = 'radarvirtueljson';
1248 1702
     			$data['id_source'] = $id_source;
1249
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1250
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1703
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1704
+				$data['noarchive'] = true;
1705
+			}
1706
+			if (isset($value['name']) && $value['name'] != '') {
1707
+				$data['source_name'] = $value['name'];
1708
+			}
1251 1709
 			$SI->add($data);
1252 1710
 			unset($data);
1253 1711
 		    }
@@ -1273,30 +1731,65 @@  discard block
 block discarded – undo
1273 1731
 		    $data['id'] = $line['id'];
1274 1732
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1275 1733
 		    $data['ident'] = $line['callsign']; // ident
1276
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1277
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1278
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1279
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1280
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1281
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1734
+		    if (isset($line['pilotid'])) {
1735
+		    	$data['pilot_id'] = $line['pilotid'];
1736
+		    }
1737
+		    // pilot id
1738
+		    if (isset($line['name'])) {
1739
+		    	$data['pilot_name'] = $line['name'];
1740
+		    }
1741
+		    // pilot name
1742
+		    if (isset($line['alt'])) {
1743
+		    	$data['altitude'] = $line['alt'];
1744
+		    }
1745
+		    // altitude
1746
+		    if (isset($line['gs'])) {
1747
+		    	$data['speed'] = $line['gs'];
1748
+		    }
1749
+		    // speed
1750
+		    if (isset($line['heading'])) {
1751
+		    	$data['heading'] = $line['heading'];
1752
+		    }
1753
+		    // heading
1754
+		    if (isset($line['route'])) {
1755
+		    	$data['waypoints'] = $line['route'];
1756
+		    }
1757
+		    // route
1282 1758
 		    $data['latitude'] = $line['lat']; // lat
1283 1759
 		    $data['longitude'] = $line['lon']; // long
1284 1760
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1285 1761
 		    //$data['squawk'] = $line['squawk']; // squawk
1286 1762
 		    //$data['emergency'] = ''; // emergency
1287
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1288
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1289
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1763
+		    if (isset($line['depicao'])) {
1764
+		    	$data['departure_airport_icao'] = $line['depicao'];
1765
+		    }
1766
+		    if (isset($line['deptime'])) {
1767
+		    	$data['departure_airport_time'] = $line['deptime'];
1768
+		    }
1769
+		    if (isset($line['arricao'])) {
1770
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1771
+		    }
1290 1772
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1291
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1292
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1293
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1294
-		    else $data['info'] = '';
1773
+		    if (isset($line['aircraft'])) {
1774
+		    	$data['aircraft_icao'] = $line['aircraft'];
1775
+		    }
1776
+		    if (isset($line['transponder'])) {
1777
+		    	$data['squawk'] = $line['transponder'];
1778
+		    }
1779
+		    if (isset($line['atis'])) {
1780
+		    	$data['info'] = $line['atis'];
1781
+		    } else {
1782
+		    	$data['info'] = '';
1783
+		    }
1295 1784
 		    $data['format_source'] = 'pireps';
1296 1785
     		    $data['id_source'] = $id_source;
1297 1786
 		    $data['datetime'] = date('Y-m-d H:i:s');
1298
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1299
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1787
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1788
+		    	$data['noarchive'] = true;
1789
+		    }
1790
+		    if (isset($value['name']) && $value['name'] != '') {
1791
+		    	$data['source_name'] = $value['name'];
1792
+		    }
1300 1793
 		    if ($line['icon'] === 'plane') {
1301 1794
 			$SI->add($data);
1302 1795
 		    //    print_r($data);
@@ -1305,16 +1798,28 @@  discard block
 block discarded – undo
1305 1798
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1306 1799
 			$typec = substr($data['ident'],-3);
1307 1800
 			$data['type'] = '';
1308
-			if ($typec === 'APP') $data['type'] = 'Approach';
1309
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1310
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1311
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1312
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1313
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1314
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1315
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1316
-			else $data['type'] = 'Observer';
1317
-			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']);
1801
+			if ($typec === 'APP') {
1802
+				$data['type'] = 'Approach';
1803
+			} elseif ($typec === 'TWR') {
1804
+				$data['type'] = 'Tower';
1805
+			} elseif ($typec === 'OBS') {
1806
+				$data['type'] = 'Observer';
1807
+			} elseif ($typec === 'GND') {
1808
+				$data['type'] = 'Ground';
1809
+			} elseif ($typec === 'DEL') {
1810
+				$data['type'] = 'Delivery';
1811
+			} elseif ($typec === 'DEP') {
1812
+				$data['type'] = 'Departure';
1813
+			} elseif ($typec === 'FSS') {
1814
+				$data['type'] = 'Flight Service Station';
1815
+			} elseif ($typec === 'CTR') {
1816
+				$data['type'] = 'Control Radar or Centre';
1817
+			} else {
1818
+				$data['type'] = 'Observer';
1819
+			}
1820
+			if (isset($ATC)) {
1821
+				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']);
1822
+			}
1318 1823
 		    }
1319 1824
 		    unset($data);
1320 1825
 		}
@@ -1329,7 +1834,9 @@  discard block
 block discarded – undo
1329 1834
 	    )
1330 1835
 	) {
1331 1836
 	    //$buffer = $Common->getData($hosts[$id]);
1332
-	    if ($globalDebug) echo 'Get Data...'."\n";
1837
+	    if ($globalDebug) {
1838
+	    	echo 'Get Data...'."\n";
1839
+	    }
1333 1840
 	    $buffer = $Common->getData($value['host']);
1334 1841
 	    $all_data = json_decode($buffer,true);
1335 1842
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1337,10 +1844,16 @@  discard block
 block discarded – undo
1337 1844
 		foreach ($all_data as $line) {
1338 1845
 	    	    $data = array();
1339 1846
 	    	    //$data['id'] = $line['id']; // id not usable
1340
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1847
+	    	    if (isset($line['pilotid'])) {
1848
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1849
+	    	    }
1341 1850
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1342
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1343
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1851
+	    	    if (isset($line['pilotname'])) {
1852
+	    	    	$data['pilot_name'] = $line['pilotname'];
1853
+	    	    }
1854
+	    	    if (isset($line['pilotid'])) {
1855
+	    	    	$data['pilot_id'] = $line['pilotid'];
1856
+	    	    }
1344 1857
 	    	    $data['ident'] = $line['flightnum']; // ident
1345 1858
 	    	    $data['altitude'] = $line['alt']; // altitude
1346 1859
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1356,7 +1869,9 @@  discard block
 block discarded – undo
1356 1869
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1357 1870
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1358 1871
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1359
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1872
+	    	    } else {
1873
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1874
+	    	    }
1360 1875
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1361 1876
 	    	    $data['departure_airport_time'] = $line['deptime'];
1362 1877
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1364,29 +1879,47 @@  discard block
 block discarded – undo
1364 1879
     		    if (isset($line['registration'])) {
1365 1880
     			$data['registration'] = $line['registration'];
1366 1881
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1367
-    		    } else $data['registration'] = $line['aircraft'];
1368
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1369
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1882
+    		    } else {
1883
+    		    	$data['registration'] = $line['aircraft'];
1884
+    		    }
1885
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1886
+		    	$data['noarchive'] = true;
1887
+		    }
1888
+		    if (isset($line['route'])) {
1889
+		    	$data['waypoints'] = $line['route'];
1890
+		    }
1891
+		    // route
1370 1892
 		    if (isset($line['aircraftname'])) {
1371 1893
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1372 1894
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1373 1895
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1374
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1375
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1376
-	    		else {
1896
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1897
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1898
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1899
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1900
+	    		} else {
1377 1901
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1378
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1379
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1902
+	    		    if (isset($aircraft_data[1])) {
1903
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1904
+	    		    } else {
1905
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1906
+	    		    }
1380 1907
 	    		}
1381 1908
 	    	    }
1382
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1909
+    		    if (isset($line['route'])) {
1910
+    		    	$data['waypoints'] = $line['route'];
1911
+    		    }
1383 1912
     		    $data['id_source'] = $id_source;
1384 1913
 	    	    $data['format_source'] = 'phpvmacars';
1385
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1914
+		    if (isset($value['name']) && $value['name'] != '') {
1915
+		    	$data['source_name'] = $value['name'];
1916
+		    }
1386 1917
 		    $SI->add($data);
1387 1918
 		    unset($data);
1388 1919
 		}
1389
-		if ($globalDebug) echo 'No more data...'."\n";
1920
+		if ($globalDebug) {
1921
+			echo 'No more data...'."\n";
1922
+		}
1390 1923
 		unset($buffer);
1391 1924
 		unset($all_data);
1392 1925
 	    }
@@ -1399,7 +1932,9 @@  discard block
 block discarded – undo
1399 1932
 	    )
1400 1933
 	) {
1401 1934
 	    //$buffer = $Common->getData($hosts[$id]);
1402
-	    if ($globalDebug) echo 'Get Data...'."\n";
1935
+	    if ($globalDebug) {
1936
+	    	echo 'Get Data...'."\n";
1937
+	    }
1403 1938
 	    $buffer = $Common->getData($value['host']);
1404 1939
 	    $all_data = json_decode($buffer,true);
1405 1940
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1410,10 +1945,16 @@  discard block
 block discarded – undo
1410 1945
 	    	    //$data['id'] = $line['id']; // id not usable
1411 1946
 	    	    $data['id'] = $line['id'];
1412 1947
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1413
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1414
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1948
+	    	    if (isset($line['user']['username'])) {
1949
+	    	    	$data['pilot_name'] = $line['user']['username'];
1950
+	    	    }
1951
+	    	    if (isset($line['user_id'])) {
1952
+	    	    	$data['pilot_id'] = $line['user_id'];
1953
+	    	    }
1415 1954
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1416
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1955
+	    	    if (is_numeric($data['ident'])) {
1956
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1957
+	    	    }
1417 1958
 	    	    $data['altitude'] = $line['altitude']; // altitude
1418 1959
 	    	    $data['speed'] = $line['groundspeed']; // speed
1419 1960
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1426,7 +1967,9 @@  discard block
 block discarded – undo
1426 1967
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1427 1968
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1428 1969
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1429
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1970
+	    	    } else {
1971
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1972
+	    	    }
1430 1973
 	    	    
1431 1974
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1432 1975
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1434,17 +1977,26 @@  discard block
 block discarded – undo
1434 1977
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1435 1978
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1436 1979
 
1437
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1438
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1980
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1981
+		    	$data['noarchive'] = true;
1982
+		    }
1983
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
1984
+		    	$data['waypoints'] = $line['bid']['route'];
1985
+		    }
1986
+		    // route
1439 1987
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1440 1988
 
1441 1989
     		    $data['id_source'] = $id_source;
1442 1990
 	    	    $data['format_source'] = 'vaos';
1443
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1991
+		    if (isset($value['name']) && $value['name'] != '') {
1992
+		    	$data['source_name'] = $value['name'];
1993
+		    }
1444 1994
 		    $SI->add($data);
1445 1995
 		    unset($data);
1446 1996
 		}
1447
-		if ($globalDebug) echo 'No more data...'."\n";
1997
+		if ($globalDebug) {
1998
+			echo 'No more data...'."\n";
1999
+		}
1448 2000
 		unset($buffer);
1449 2001
 		unset($all_data);
1450 2002
 	    }
@@ -1457,7 +2009,9 @@  discard block
 block discarded – undo
1457 2009
 	    )
1458 2010
 	) {
1459 2011
 	    //$buffer = $Common->getData($hosts[$id]);
1460
-	    if ($globalDebug) echo 'Get Data...'."\n";
2012
+	    if ($globalDebug) {
2013
+	    	echo 'Get Data...'."\n";
2014
+	    }
1461 2015
 	    $buffer = $Common->getData($value['host']);
1462 2016
 	    $all_data = json_decode($buffer,true);
1463 2017
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1486,16 +2040,25 @@  discard block
 block discarded – undo
1486 2040
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1487 2041
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1488 2042
     		    //$data['registration'] = $line['aircraft'];
1489
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2043
+		    if (isset($line['route'])) {
2044
+		    	$data['waypoints'] = $line['route'];
2045
+		    }
2046
+		    // route
1490 2047
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1491 2048
     		    $data['id_source'] = $id_source;
1492 2049
 	    	    $data['format_source'] = 'vam';
1493
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1494
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2050
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2051
+		    	$data['noarchive'] = true;
2052
+		    }
2053
+		    if (isset($value['name']) && $value['name'] != '') {
2054
+		    	$data['source_name'] = $value['name'];
2055
+		    }
1495 2056
 		    $SI->add($data);
1496 2057
 		    unset($data);
1497 2058
 		}
1498
-		if ($globalDebug) echo 'No more data...'."\n";
2059
+		if ($globalDebug) {
2060
+			echo 'No more data...'."\n";
2061
+		}
1499 2062
 		unset($buffer);
1500 2063
 		unset($all_data);
1501 2064
 	    }
@@ -1508,7 +2071,9 @@  discard block
 block discarded – undo
1508 2071
 	    )
1509 2072
 	) {
1510 2073
 	    //$buffer = $Common->getData($hosts[$id]);
1511
-	    if ($globalDebug) echo 'Get Data...'."\n";
2074
+	    if ($globalDebug) {
2075
+	    	echo 'Get Data...'."\n";
2076
+	    }
1512 2077
 	    $buffer = $Common->getData($value['host']);
1513 2078
 	    $all_data = json_decode($buffer,true);
1514 2079
 	    if ($buffer != '') {
@@ -1526,12 +2091,16 @@  discard block
 block discarded – undo
1526 2091
 			$data['id_source'] = $id_source;
1527 2092
 			$data['format_source'] = 'blitzortung';
1528 2093
 			$SI->add($data);
1529
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2094
+			if ($globalDebug) {
2095
+				echo '☈ Lightning added'."\n";
2096
+			}
1530 2097
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1531 2098
 			unset($data);
1532 2099
 		    }
1533 2100
 		}
1534
-		if ($globalDebug) echo 'No more data...'."\n";
2101
+		if ($globalDebug) {
2102
+			echo 'No more data...'."\n";
2103
+		}
1535 2104
 		unset($buffer);
1536 2105
 	    }
1537 2106
 	    $last_exec[$id]['last'] = time();
@@ -1543,7 +2112,9 @@  discard block
 block discarded – undo
1543 2112
 	    $write = NULL;
1544 2113
 	    $e = NULL;
1545 2114
 	    $n = socket_select($read, $write, $e, $timeout);
1546
-	    if ($e != NULL) var_dump($e);
2115
+	    if ($e != NULL) {
2116
+	    	var_dump($e);
2117
+	    }
1547 2118
 	    if ($n > 0) {
1548 2119
 		$reset = 0;
1549 2120
 		foreach ($read as $nb => $r) {
@@ -1565,13 +2136,17 @@  discard block
 block discarded – undo
1565 2136
 		    if ($buffer !== FALSE) {
1566 2137
 			if ($format === 'vrstcp') {
1567 2138
 			    $buffer = explode('},{',$buffer);
1568
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2139
+			} else {
2140
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2141
+			}
1569 2142
 		    }
1570 2143
 		    // SBS format is CSV format
1571 2144
 		    if ($buffer !== FALSE && $buffer !== '') {
1572 2145
 			$tt[$format] = 0;
1573 2146
 			if ($format === 'acarssbs3') {
1574
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2147
+			    if ($globalDebug) {
2148
+			    	echo 'ACARS : '.$buffer."\n";
2149
+			    }
1575 2150
 			    $ACARS->add(trim($buffer));
1576 2151
 			    $ACARS->deleteLiveAcarsData();
1577 2152
 			} elseif ($format === 'raw') {
@@ -1580,30 +2155,70 @@  discard block
 block discarded – undo
1580 2155
 			    if (is_array($data)) {
1581 2156
 				$data['datetime'] = date('Y-m-d H:i:s');
1582 2157
 				$data['format_source'] = 'raw';
1583
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1584
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1585
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2158
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2159
+					$data['source_name'] = $globalSources[$nb]['name'];
2160
+				}
2161
+				if (isset($globalSources[$nb]['sourcestats'])) {
2162
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2163
+				}
2164
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2165
+					$data['noarchive'] = true;
2166
+				}
2167
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2168
+					$SI->add($data);
2169
+				}
1587 2170
 			    }
1588 2171
 			} elseif ($format === 'ais') {
1589 2172
 			    $ais_data = $AIS->parse_line(trim($buffer));
1590 2173
 			    $data = array();
1591
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1592
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1593
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1594
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1595
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1596
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1597
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1598
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1599
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1600
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1601
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1602
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1603
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1604
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1605
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1606
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2174
+			    if (isset($ais_data['ident'])) {
2175
+			    	$data['ident'] = $ais_data['ident'];
2176
+			    }
2177
+			    if (isset($ais_data['mmsi'])) {
2178
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2179
+			    }
2180
+			    if (isset($ais_data['speed'])) {
2181
+			    	$data['speed'] = $ais_data['speed'];
2182
+			    }
2183
+			    if (isset($ais_data['heading'])) {
2184
+			    	$data['heading'] = $ais_data['heading'];
2185
+			    }
2186
+			    if (isset($ais_data['latitude'])) {
2187
+			    	$data['latitude'] = $ais_data['latitude'];
2188
+			    }
2189
+			    if (isset($ais_data['longitude'])) {
2190
+			    	$data['longitude'] = $ais_data['longitude'];
2191
+			    }
2192
+			    if (isset($ais_data['status'])) {
2193
+			    	$data['status'] = $ais_data['status'];
2194
+			    }
2195
+			    if (isset($ais_data['statusid'])) {
2196
+			    	$data['status_id'] = $ais_data['statusid'];
2197
+			    }
2198
+			    if (isset($ais_data['type'])) {
2199
+			    	$data['type'] = $ais_data['type'];
2200
+			    }
2201
+			    if (isset($ais_data['imo'])) {
2202
+			    	$data['imo'] = $ais_data['imo'];
2203
+			    }
2204
+			    if (isset($ais_data['callsign'])) {
2205
+			    	$data['callsign'] = $ais_data['callsign'];
2206
+			    }
2207
+			    if (isset($ais_data['destination'])) {
2208
+			    	$data['arrival_code'] = $ais_data['destination'];
2209
+			    }
2210
+			    if (isset($ais_data['eta_ts'])) {
2211
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2212
+			    }
2213
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2214
+			    	$data['noarchive'] = true;
2215
+			    }
2216
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2217
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2218
+			    }
2219
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2220
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2221
+			    }
1607 2222
 
1608 2223
 			    if (isset($ais_data['timestamp'])) {
1609 2224
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1612,7 +2227,9 @@  discard block
 block discarded – undo
1612 2227
 			    }
1613 2228
 			    $data['format_source'] = 'aisnmea';
1614 2229
     			    $data['id_source'] = $id_source;
1615
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2230
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2231
+			    	$MI->add($data);
2232
+			    }
1616 2233
 			    unset($data);
1617 2234
                         } elseif ($format === 'flightgearsp') {
1618 2235
                     	    //echo $buffer."\n";
@@ -1630,12 +2247,18 @@  discard block
 block discarded – undo
1630 2247
 				$data['speed'] = round($line[5]*1.94384);
1631 2248
 				$data['datetime'] = date('Y-m-d H:i:s');
1632 2249
 				$data['format_source'] = 'flightgearsp';
1633
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1634
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2250
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2251
+					$data['noarchive'] = true;
2252
+				}
2253
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2254
+					$SI->add($data);
2255
+				}
1635 2256
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1636 2257
 			    }
1637 2258
                         } elseif ($format === 'acars') {
1638
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2259
+                    	    if ($globalDebug) {
2260
+                    	    	echo 'ACARS : '.$buffer."\n";
2261
+                    	    }
1639 2262
 			    $ACARS->add(trim($buffer));
1640 2263
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1641 2264
 			    $ACARS->deleteLiveAcarsData();
@@ -1656,8 +2279,12 @@  discard block
 block discarded – undo
1656 2279
 				    $aircraft_type = $line[10];
1657 2280
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1658 2281
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1659
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1660
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2282
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2283
+				    	$data['noarchive'] = true;
2284
+				    }
2285
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2286
+				    	$SI->add($data);
2287
+				    }
1661 2288
 				}
1662 2289
 			    }
1663 2290
 			} elseif ($format === 'beast') {
@@ -1667,28 +2294,62 @@  discard block
 block discarded – undo
1667 2294
 			    foreach($buffer as $all_data) {
1668 2295
 				$line = json_decode('{'.$all_data.'}',true);
1669 2296
 				$data = array();
1670
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1671
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1672
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1673
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1674
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1675
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1676
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2297
+				if (isset($line['Icao'])) {
2298
+					$data['hex'] = $line['Icao'];
2299
+				}
2300
+				// hex
2301
+				if (isset($line['Call'])) {
2302
+					$data['ident'] = $line['Call'];
2303
+				}
2304
+				// ident
2305
+				if (isset($line['Alt'])) {
2306
+					$data['altitude'] = $line['Alt'];
2307
+				}
2308
+				// altitude
2309
+				if (isset($line['Spd'])) {
2310
+					$data['speed'] = $line['Spd'];
2311
+				}
2312
+				// speed
2313
+				if (isset($line['Trak'])) {
2314
+					$data['heading'] = $line['Trak'];
2315
+				}
2316
+				// heading
2317
+				if (isset($line['Lat'])) {
2318
+					$data['latitude'] = $line['Lat'];
2319
+				}
2320
+				// lat
2321
+				if (isset($line['Long'])) {
2322
+					$data['longitude'] = $line['Long'];
2323
+				}
2324
+				// long
1677 2325
 				//$data['verticalrate'] = $line['']; // verticale rate
1678
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2326
+				if (isset($line['Sqk'])) {
2327
+					$data['squawk'] = $line['Sqk'];
2328
+				}
2329
+				// squawk
1679 2330
 				$data['emergency'] = ''; // emergency
1680
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2331
+				if (isset($line['Reg'])) {
2332
+					$data['registration'] = $line['Reg'];
2333
+				}
1681 2334
 				/*
1682 2335
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1683 2336
 				else $data['datetime'] = date('Y-m-d H:i:s');
1684 2337
 				*/
1685 2338
 				$data['datetime'] = date('Y-m-d H:i:s');
1686
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2339
+				if (isset($line['Type'])) {
2340
+					$data['aircraft_icao'] = $line['Type'];
2341
+				}
1687 2342
 		    		$data['format_source'] = 'vrstcp';
1688 2343
 				$data['id_source'] = $id_source;
1689
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1690
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1691
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2344
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2345
+					$data['noarchive'] = true;
2346
+				}
2347
+				if (isset($value['name']) && $value['name'] != '') {
2348
+					$data['source_name'] = $value['name'];
2349
+				}
2350
+				if (isset($data['latitude']) && isset($data['hex'])) {
2351
+					$SI->add($data);
2352
+				}
1692 2353
 				unset($data);
1693 2354
 			    }
1694 2355
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1701,22 +2362,46 @@  discard block
 block discarded – undo
1701 2362
     				$data['hex'] = $lined['hexid'];
1702 2363
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1703 2364
     				$data['datetime'] = date('Y-m-d H:i:s');;
1704
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1705
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1706
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1707
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1708
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1709
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1710
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2365
+    				if (isset($lined['ident'])) {
2366
+    					$data['ident'] = $lined['ident'];
2367
+    				}
2368
+    				if (isset($lined['lat'])) {
2369
+    					$data['latitude'] = $lined['lat'];
2370
+    				}
2371
+    				if (isset($lined['lon'])) {
2372
+    					$data['longitude'] = $lined['lon'];
2373
+    				}
2374
+    				if (isset($lined['speed'])) {
2375
+    					$data['speed'] = $lined['speed'];
2376
+    				}
2377
+    				if (isset($lined['squawk'])) {
2378
+    					$data['squawk'] = $lined['squawk'];
2379
+    				}
2380
+    				if (isset($lined['alt'])) {
2381
+    					$data['altitude'] = $lined['alt'];
2382
+    				}
2383
+    				if (isset($lined['heading'])) {
2384
+    					$data['heading'] = $lined['heading'];
2385
+    				}
1711 2386
     				$data['id_source'] = $id_source;
1712 2387
     				$data['format_source'] = 'tsv';
1713
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1714
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1715
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1716
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2388
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2389
+    					$data['source_name'] = $globalSources[$nb]['name'];
2390
+    				}
2391
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2392
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2393
+    				}
2394
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2395
+					$data['noarchive'] = true;
2396
+				}
2397
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2398
+    					$SI->add($data);
2399
+    				}
1717 2400
     				unset($lined);
1718 2401
     				unset($data);
1719
-    			    } else $error = true;
2402
+    			    } else {
2403
+    			    	$error = true;
2404
+    			    }
1720 2405
 			} elseif ($format === 'aprs' && $use_aprs) {
1721 2406
 			    if ($aprs_connect === 0) {
1722 2407
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1742,47 +2427,96 @@  discard block
 block discarded – undo
1742 2427
 				    $aprs_last_tx = time();
1743 2428
 				    $data = array();
1744 2429
 				    //print_r($line);
1745
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1746
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1747
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1748
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1749
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1750
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1751
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1752
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1753
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1754
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2430
+				    if (isset($line['address'])) {
2431
+				    	$data['hex'] = $line['address'];
2432
+				    }
2433
+				    if (isset($line['mmsi'])) {
2434
+				    	$data['mmsi'] = $line['mmsi'];
2435
+				    }
2436
+				    if (isset($line['imo'])) {
2437
+				    	$data['imo'] = $line['imo'];
2438
+				    }
2439
+				    if (isset($line['squawk'])) {
2440
+				    	$data['squawk'] = $line['squawk'];
2441
+				    }
2442
+				    if (isset($line['arrival_code'])) {
2443
+				    	$data['arrival_code'] = $line['arrival_code'];
2444
+				    }
2445
+				    if (isset($line['arrival_date'])) {
2446
+				    	$data['arrival_date'] = $line['arrival_date'];
2447
+				    }
2448
+				    if (isset($line['typeid'])) {
2449
+				    	$data['type_id'] = $line['typeid'];
2450
+				    }
2451
+				    if (isset($line['statusid'])) {
2452
+				    	$data['status_id'] = $line['statusid'];
2453
+				    }
2454
+				    if (isset($line['timestamp'])) {
2455
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2456
+				    } else {
2457
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2458
+				    }
1755 2459
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1756
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2460
+				    if (isset($line['ident'])) {
2461
+				    	$data['ident'] = $line['ident'];
2462
+				    }
1757 2463
 				    $data['latitude'] = $line['latitude'];
1758 2464
 				    $data['longitude'] = $line['longitude'];
1759 2465
 				    //$data['verticalrate'] = $line[16];
1760
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2466
+				    if (isset($line['speed'])) {
2467
+				    	$data['speed'] = $line['speed'];
2468
+				    }
1761 2469
 				    //else $data['speed'] = 0;
1762
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1763
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1764
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2470
+				    if (isset($line['altitude'])) {
2471
+				    	$data['altitude'] = $line['altitude'];
2472
+				    }
2473
+				    if (isset($line['comment'])) {
2474
+				    	$data['comment'] = $line['comment'];
2475
+				    }
2476
+				    if (isset($line['symbol'])) {
2477
+				    	$data['type'] = $line['symbol'];
2478
+				    }
1765 2479
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1766 2480
 				    
1767
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2481
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2482
+				    	$data['heading'] = $line['heading'];
2483
+				    }
1768 2484
 				    //else echo 'No heading...'."\n";
1769 2485
 				    //else $data['heading'] = 0;
1770
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2486
+				    if (isset($line['stealth'])) {
2487
+				    	$data['aircraft_type'] = $line['stealth'];
2488
+				    }
1771 2489
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1772
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1773
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1774
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1775
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2490
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2491
+				    	$data['noarchive'] = true;
2492
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2493
+				    	$data['noarchive'] = false;
2494
+				    }
2495
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2496
+				    	$data['noarchive'] = true;
2497
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2498
+				    	$data['noarchive'] = false;
2499
+				    }
1776 2500
     				    $data['id_source'] = $id_source;
1777
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1778
-				    else $data['format_source'] = 'aprs';
2501
+    				    if (isset($line['format_source'])) {
2502
+    				    	$data['format_source'] = $line['format_source'];
2503
+    				    } else {
2504
+				    	$data['format_source'] = 'aprs';
2505
+				    }
1779 2506
 				    $data['source_name'] = $line['source'];
1780
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1781
-				    else $data['source_type'] = 'flarm';
1782
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2507
+				    if (isset($line['source_type'])) {
2508
+				    	$data['source_type'] = $line['source_type'];
2509
+				    } else {
2510
+				    	$data['source_type'] = 'flarm';
2511
+				    }
2512
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2513
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2514
+    				    }
1783 2515
 				    $currentdate = date('Y-m-d H:i:s');
1784 2516
 				    $aprsdate = strtotime($data['datetime']);
1785
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2517
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2518
+				    	$data['altitude_relative'] = 'AMSL';
2519
+				    }
1786 2520
 				    // Accept data if time <= system time + 20s
1787 2521
 				    //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'])))) {
1788 2522
 				    if (
@@ -1794,7 +2528,9 @@  discard block
 block discarded – undo
1794 2528
 					$send = $SI->add($data);
1795 2529
 				    } elseif ($data['source_type'] === 'ais') {
1796 2530
 					$data['type'] = '';
1797
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2531
+					if (isset($globalMarine) && $globalMarine) {
2532
+						$send = $MI->add($data);
2533
+					}
1798 2534
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1799 2535
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1800 2536
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1802,8 +2538,12 @@  discard block
 block discarded – undo
1802 2538
 					    $line['symbol'] === 'Glider' || 
1803 2539
 					    $line['symbol'] === 'No. Plane' || 
1804 2540
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1805
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1806
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2541
+					    if ($line['symbol'] === 'Ballon') {
2542
+					    	$data['aircraft_icao'] = 'BALL';
2543
+					    }
2544
+					    if ($line['symbol'] === 'Glider') {
2545
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2546
+					    }
1807 2547
 					    $send = $SI->add($data);
1808 2548
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1809 2549
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1834,9 +2574,13 @@  discard block
 block discarded – undo
1834 2574
 				    //} 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') {
1835 2575
 				//    } 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') {
1836 2576
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1837
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2577
+					if (isset($globalTracker) && $globalTracker) {
2578
+						$send = $TI->add($data);
2579
+					}
1838 2580
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1839
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2581
+					if (!isset($data['altitude'])) {
2582
+						$data['altitude'] = 0;
2583
+					}
1840 2584
 					$Source->deleteOldLocationByType('gs');
1841 2585
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1842 2586
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1845,7 +2589,9 @@  discard block
 block discarded – undo
1845 2589
 					}
1846 2590
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1847 2591
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1848
-					if ($globalDebug) echo '# Weather Station added'."\n";
2592
+					if ($globalDebug) {
2593
+						echo '# Weather Station added'."\n";
2594
+					}
1849 2595
 					$Source->deleteOldLocationByType('wx');
1850 2596
 					$weather_data = json_encode($line);
1851 2597
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1855,7 +2601,9 @@  discard block
 block discarded – undo
1855 2601
 					}
1856 2602
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1857 2603
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1858
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2604
+					if ($globalDebug) {
2605
+						echo '☈ Lightning added'."\n";
2606
+					}
1859 2607
 					$Source->deleteOldLocationByType('lightning');
1860 2608
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1861 2609
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1867,8 +2615,7 @@  discard block
 block discarded – undo
1867 2615
 				    	print_r($line);
1868 2616
 				    }
1869 2617
 				    unset($data);
1870
-				}
1871
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2618
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1872 2619
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1873 2620
 				}
1874 2621
 				/*
@@ -1877,7 +2624,9 @@  discard block
 block discarded – undo
1877 2624
 				}
1878 2625
 				*/
1879 2626
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1880
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2627
+				elseif ($line === true && $globalDebug) {
2628
+					echo '!! Failed : '.$buffer."!!\n";
2629
+				}
1881 2630
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1882 2631
 					$Source->deleteOldLocationByType('lightning');
1883 2632
 					$Source->deleteOldLocationByType('wx');
@@ -1913,27 +2662,47 @@  discard block
 block discarded – undo
1913 2662
     				$data['ground'] = $line[21];
1914 2663
     				$data['emergency'] = $line[19];
1915 2664
     				$data['format_source'] = 'sbs';
1916
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1917
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1918
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1919
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2665
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2666
+					$data['source_name'] = $globalSources[$nb]['name'];
2667
+				} elseif ($line[0] == 'MLAT') {
2668
+					$data['source_name'] = 'MLAT';
2669
+				}
2670
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2671
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2672
+    				}
2673
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2674
+					$data['noarchive'] = true;
2675
+				}
1920 2676
     				$data['id_source'] = $id_source;
1921
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1922
-    				else $error = true;
2677
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2678
+    					$send = $SI->add($data);
2679
+    				} else {
2680
+    					$error = true;
2681
+    				}
1923 2682
     				unset($data);
1924
-    			    } else $error = true;
2683
+    			    } else {
2684
+    			    	$error = true;
2685
+    			    }
1925 2686
 			    if ($error) {
1926 2687
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1927
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2688
+					if ($globalDebug) {
2689
+						echo "Not a message. Ignoring... \n";
2690
+					}
1928 2691
 				} else {
1929
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2692
+					if ($globalDebug) {
2693
+						echo "Wrong line format. Ignoring... \n";
2694
+					}
1930 2695
 					if ($globalDebug) {
1931 2696
 						echo $buffer;
1932 2697
 						//print_r($line);
1933 2698
 					}
1934 2699
 					//socket_close($r);
1935
-					if ($globalDebug) echo "Reconnect after an error...\n";
1936
-					if ($format === 'aprs') $aprs_connect = 0;
2700
+					if ($globalDebug) {
2701
+						echo "Reconnect after an error...\n";
2702
+					}
2703
+					if ($format === 'aprs') {
2704
+						$aprs_connect = 0;
2705
+					}
1937 2706
 					$sourceer[$nb] = $globalSources[$nb];
1938 2707
 					connect_all($sourceer);
1939 2708
 					$sourceer = array();
@@ -1941,10 +2710,14 @@  discard block
 block discarded – undo
1941 2710
 			    }
1942 2711
 			}
1943 2712
 			// Sleep for xxx microseconds
1944
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2713
+			if (isset($globalSBSSleep)) {
2714
+				usleep($globalSBSSleep);
2715
+			}
1945 2716
 		    } else {
1946 2717
 			if ($format === 'flightgearmp') {
1947
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2718
+			    	if ($globalDebug) {
2719
+			    		echo "Reconnect FlightGear MP...";
2720
+			    	}
1948 2721
 				//@socket_close($r);
1949 2722
 				sleep($globalMinFetch);
1950 2723
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1953,10 +2726,15 @@  discard block
 block discarded – undo
1953 2726
 				break;
1954 2727
 				
1955 2728
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1956
-			    if (isset($tt[$format])) $tt[$format]++;
1957
-			    else $tt[$format] = 0;
2729
+			    if (isset($tt[$format])) {
2730
+			    	$tt[$format]++;
2731
+			    } else {
2732
+			    	$tt[$format] = 0;
2733
+			    }
1958 2734
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1959
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2735
+				if ($globalDebug) {
2736
+					echo "ERROR : Reconnect ".$format."...";
2737
+				}
1960 2738
 				//@socket_close($r);
1961 2739
 				sleep(2);
1962 2740
 				$aprs_connect = 0;
@@ -1974,11 +2752,17 @@  discard block
 block discarded – undo
1974 2752
 	    } else {
1975 2753
 		$error = socket_strerror(socket_last_error());
1976 2754
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1977
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1978
-			if (isset($globalDebug)) echo "Restarting...\n";
2755
+			if ($globalDebug) {
2756
+				echo "ERROR : socket_select give this error ".$error . "\n";
2757
+			}
2758
+			if (isset($globalDebug)) {
2759
+				echo "Restarting...\n";
2760
+			}
1979 2761
 			// Restart the script if possible
1980 2762
 			if (is_array($sockets)) {
1981
-			    if ($globalDebug) echo "Shutdown all sockets...";
2763
+			    if ($globalDebug) {
2764
+			    	echo "Shutdown all sockets...";
2765
+			    }
1982 2766
 			    
1983 2767
 			    foreach ($sockets as $sock) {
1984 2768
 				@socket_shutdown($sock,2);
@@ -1986,25 +2770,45 @@  discard block
 block discarded – undo
1986 2770
 			    }
1987 2771
 			    
1988 2772
 			}
1989
-			if ($globalDebug) echo "Waiting...";
2773
+			if ($globalDebug) {
2774
+				echo "Waiting...";
2775
+			}
1990 2776
 			sleep(2);
1991 2777
 			$time = time();
1992 2778
 			//connect_all($hosts);
1993 2779
 			$aprs_connect = 0;
1994
-			if ($reset%5 === 0) sleep(20);
1995
-			if ($reset%10 === 0) sleep(100);
1996
-			if ($reset%20 === 0) sleep(200);
1997
-			if ($reset > 100) exit('Too many attempts...');
1998
-			if ($globalDebug) echo "Restart all connections...";
2780
+			if ($reset%5 === 0) {
2781
+				sleep(20);
2782
+			}
2783
+			if ($reset%10 === 0) {
2784
+				sleep(100);
2785
+			}
2786
+			if ($reset%20 === 0) {
2787
+				sleep(200);
2788
+			}
2789
+			if ($reset > 100) {
2790
+				exit('Too many attempts...');
2791
+			}
2792
+			if ($globalDebug) {
2793
+				echo "Restart all connections...";
2794
+			}
1999 2795
 			connect_all($globalSources);
2000 2796
 		}
2001 2797
 	    }
2002 2798
 	}
2003 2799
 	if ($globalDaemon === false) {
2004
-	    if ($globalDebug) echo 'Check all...'."\n";
2005
-	    if (isset($SI)) $SI->checkAll();
2006
-	    if (isset($TI)) $TI->checkAll();
2007
-	    if (isset($MI)) $MI->checkAll();
2800
+	    if ($globalDebug) {
2801
+	    	echo 'Check all...'."\n";
2802
+	    }
2803
+	    if (isset($SI)) {
2804
+	    	$SI->checkAll();
2805
+	    }
2806
+	    if (isset($TI)) {
2807
+	    	$TI->checkAll();
2808
+	    }
2809
+	    if (isset($MI)) {
2810
+	    	$MI->checkAll();
2811
+	    }
2008 2812
 	}
2009 2813
     }
2010 2814
 }
Please login to merge, or discard this patch.